From 07842084fe3e11041f83563c851236395f481470 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Tue, 25 May 1999 16:15:34 +0000 Subject: [PATCH] pgindent run over code. --- contrib/array/array_iterator.c | 24 +- contrib/array/array_iterator.h | 8 +- contrib/datetime/datetime_functions.c | 6 +- contrib/earthdistance/earthdistance.c | 49 +- contrib/findoidjoins/findoidjoins.c | 23 +- contrib/fulltextindex/fti.c | 258 +- contrib/isbn_issn/isbn.c | 66 +- contrib/isbn_issn/issn.c | 66 +- contrib/lo/lo.c | 245 +- contrib/mSQL-interface/mpgsql.c | 492 ++-- contrib/miscutil/misc_utils.c | 8 +- contrib/miscutil/misc_utils.h | 8 +- contrib/noupdate/noup.c | 6 +- contrib/os2client/c.h | 9 +- contrib/os2client/config.h | 16 +- contrib/pginterface/pginterface.c | 25 +- contrib/pginterface/pginterface.h | 6 +- contrib/spi/moddatetime.c | 50 +- contrib/spi/preprocessor/step1.c | 31 +- contrib/spi/refint.c | 128 +- contrib/string/string_io.c | 7 +- contrib/string/string_io.h | 7 +- contrib/userlock/user_locks.c | 10 +- contrib/userlock/user_locks.h | 6 +- contrib/vacuumlo/vacuumlo.c | 326 +-- src/backend/access/common/heaptuple.c | 74 +- src/backend/access/common/printtup.c | 74 +- src/backend/access/common/scankey.c | 8 +- src/backend/access/common/tupdesc.c | 4 +- src/backend/access/gist/gist.c | 8 +- src/backend/access/gist/gistscan.c | 2 +- src/backend/access/hash/hash.c | 8 +- src/backend/access/hash/hashfunc.c | 6 +- src/backend/access/hash/hashpage.c | 6 +- src/backend/access/heap/heapam.c | 112 +- src/backend/access/heap/hio.c | 23 +- src/backend/access/index/genam.c | 4 +- src/backend/access/index/istrat.c | 14 +- src/backend/access/nbtree/nbtcompare.c | 4 +- src/backend/access/nbtree/nbtinsert.c | 41 +- src/backend/access/nbtree/nbtpage.c | 15 +- src/backend/access/nbtree/nbtree.c | 20 +- src/backend/access/nbtree/nbtscan.c | 18 +- src/backend/access/nbtree/nbtsearch.c | 33 +- src/backend/access/nbtree/nbtsort.c | 10 +- src/backend/access/rtree/rtree.c | 10 +- src/backend/access/rtree/rtscan.c | 4 +- src/backend/access/transam/transam.c | 14 +- src/backend/access/transam/varsup.c | 4 +- src/backend/access/transam/xact.c | 24 +- src/backend/access/transam/xid.c | 2 +- src/backend/bootstrap/bootstrap.c | 8 +- src/backend/catalog/catalog.c | 10 +- src/backend/catalog/heap.c | 115 +- src/backend/catalog/index.c | 54 +- src/backend/catalog/indexing.c | 36 +- src/backend/catalog/pg_operator.c | 84 +- src/backend/catalog/pg_proc.c | 14 +- src/backend/catalog/pg_type.c | 21 +- src/backend/commands/_deadcode/recipe.c | 40 +- src/backend/commands/_deadcode/version.c | 6 +- src/backend/commands/async.c | 196 +- src/backend/commands/cluster.c | 44 +- src/backend/commands/command.c | 26 +- src/backend/commands/copy.c | 200 +- src/backend/commands/creatinh.c | 38 +- src/backend/commands/dbcommands.c | 34 +- src/backend/commands/define.c | 6 +- src/backend/commands/explain.c | 48 +- src/backend/commands/indexcmds.c | 14 +- src/backend/commands/remove.c | 6 +- src/backend/commands/rename.c | 8 +- src/backend/commands/sequence.c | 20 +- src/backend/commands/trigger.c | 82 +- src/backend/commands/user.c | 88 +- src/backend/commands/vacuum.c | 398 +-- src/backend/commands/variable.c | 56 +- src/backend/commands/view.c | 8 +- src/backend/executor/_deadcode/nodeTee.c | 19 +- src/backend/executor/execAmi.c | 4 +- src/backend/executor/execMain.c | 686 +++-- src/backend/executor/execQual.c | 296 +-- src/backend/executor/execTuples.c | 4 +- src/backend/executor/execUtils.c | 45 +- src/backend/executor/functions.c | 8 +- src/backend/executor/nodeAgg.c | 89 +- src/backend/executor/nodeAppend.c | 4 +- src/backend/executor/nodeGroup.c | 6 +- src/backend/executor/nodeHash.c | 166 +- src/backend/executor/nodeHashjoin.c | 80 +- src/backend/executor/nodeIndexscan.c | 81 +- src/backend/executor/nodeMaterial.c | 12 +- src/backend/executor/nodeMergejoin.c | 10 +- src/backend/executor/nodeResult.c | 9 +- src/backend/executor/nodeSeqscan.c | 22 +- src/backend/executor/nodeSubplan.c | 19 +- src/backend/executor/spi.c | 62 +- src/backend/lib/fstack.c | 10 +- src/backend/lib/stringinfo.c | 26 +- src/backend/libpq/auth.c | 71 +- src/backend/libpq/be-dumpdata.c | 8 +- src/backend/libpq/be-fsstubs.c | 20 +- src/backend/libpq/crypt.c | 59 +- src/backend/libpq/hba.c | 153 +- src/backend/libpq/password.c | 16 +- src/backend/libpq/portal.c | 6 +- src/backend/libpq/portalbuf.c | 4 +- src/backend/libpq/pqcomm.c | 107 +- src/backend/libpq/pqformat.c | 46 +- src/backend/libpq/util.c | 4 +- src/backend/nodes/copyfuncs.c | 45 +- src/backend/nodes/equalfuncs.c | 48 +- src/backend/nodes/freefuncs.c | 41 +- src/backend/nodes/list.c | 9 +- src/backend/nodes/outfuncs.c | 501 ++-- src/backend/nodes/print.c | 10 +- src/backend/nodes/readfuncs.c | 61 +- src/backend/optimizer/geqo/geqo_eval.c | 46 +- src/backend/optimizer/geqo/geqo_main.c | 8 +- src/backend/optimizer/geqo/geqo_misc.c | 4 +- src/backend/optimizer/geqo/geqo_pool.c | 4 +- src/backend/optimizer/geqo/minspantree.c | 4 +- .../optimizer/path/_deadcode/predmig.c | 32 +- src/backend/optimizer/path/_deadcode/xfunc.c | 80 +- src/backend/optimizer/path/allpaths.c | 24 +- src/backend/optimizer/path/clausesel.c | 6 +- src/backend/optimizer/path/costsize.c | 53 +- src/backend/optimizer/path/hashutils.c | 8 +- src/backend/optimizer/path/indxpath.c | 166 +- src/backend/optimizer/path/joinpath.c | 214 +- src/backend/optimizer/path/joinrels.c | 79 +- src/backend/optimizer/path/mergeutils.c | 19 +- src/backend/optimizer/path/orindxpath.c | 46 +- src/backend/optimizer/path/pathkeys.c | 83 +- src/backend/optimizer/path/prune.c | 13 +- src/backend/optimizer/plan/createplan.c | 157 +- src/backend/optimizer/plan/initsplan.c | 23 +- src/backend/optimizer/plan/planmain.c | 13 +- src/backend/optimizer/plan/planner.c | 345 +-- src/backend/optimizer/plan/setrefs.c | 205 +- src/backend/optimizer/plan/subselect.c | 10 +- src/backend/optimizer/prep/prepkeyset.c | 180 +- src/backend/optimizer/prep/prepqual.c | 29 +- src/backend/optimizer/prep/preptlist.c | 33 +- src/backend/optimizer/prep/prepunion.c | 6 +- src/backend/optimizer/util/clauses.c | 34 +- src/backend/optimizer/util/indexnode.c | 4 +- src/backend/optimizer/util/joininfo.c | 8 +- src/backend/optimizer/util/keys.c | 36 +- src/backend/optimizer/util/ordering.c | 24 +- src/backend/optimizer/util/pathnode.c | 157 +- src/backend/optimizer/util/plancat.c | 6 +- src/backend/optimizer/util/relnode.c | 6 +- src/backend/optimizer/util/restrictinfo.c | 8 +- src/backend/optimizer/util/tlist.c | 44 +- src/backend/optimizer/util/var.c | 18 +- src/backend/parser/analyze.c | 287 ++- src/backend/parser/parse_agg.c | 26 +- src/backend/parser/parse_clause.c | 138 +- src/backend/parser/parse_coerce.c | 24 +- src/backend/parser/parse_expr.c | 87 +- src/backend/parser/parse_func.c | 113 +- src/backend/parser/parse_oper.c | 22 +- src/backend/parser/parse_relation.c | 6 +- src/backend/parser/parse_target.c | 50 +- src/backend/parser/parse_type.c | 3 +- src/backend/parser/parser.c | 4 +- src/backend/parser/scansup.c | 8 +- src/backend/port/dynloader/freebsd.c | 2 +- src/backend/port/hpux/fixade.h | 6 +- src/backend/port/snprintf.c | 26 +- src/backend/postmaster/postmaster.c | 61 +- src/backend/regex/regcomp.c | 10 +- src/backend/regex/retest.c | 58 +- src/backend/rewrite/rewriteDefine.c | 42 +- src/backend/rewrite/rewriteHandler.c | 2257 +++++++++-------- src/backend/rewrite/rewriteManip.c | 447 ++-- src/backend/rewrite/rewriteRemove.c | 4 +- src/backend/storage/buffer/buf_init.c | 9 +- src/backend/storage/buffer/bufmgr.c | 74 +- src/backend/storage/buffer/freelist.c | 4 +- src/backend/storage/buffer/s_lock.c | 8 +- src/backend/storage/file/fd.c | 93 +- src/backend/storage/ipc/ipc.c | 5 +- src/backend/storage/ipc/ipci.c | 12 +- src/backend/storage/ipc/shmem.c | 46 +- src/backend/storage/ipc/sinval.c | 6 +- src/backend/storage/ipc/sinvaladt.c | 6 +- src/backend/storage/large_object/inv_api.c | 72 +- src/backend/storage/lmgr/lmgr.c | 18 +- src/backend/storage/lmgr/lock.c | 184 +- src/backend/storage/lmgr/multi.c | 3 +- src/backend/storage/lmgr/proc.c | 53 +- src/backend/storage/page/bufpage.c | 16 +- src/backend/storage/page/itemptr.c | 4 +- src/backend/storage/smgr/md.c | 16 +- src/backend/storage/smgr/mm.c | 10 +- src/backend/storage/smgr/smgr.c | 4 +- src/backend/tcop/dest.c | 42 +- src/backend/tcop/postgres.c | 102 +- src/backend/tcop/pquery.c | 6 +- src/backend/tcop/utility.c | 5 +- src/backend/tioga/Varray.c | 2 +- src/backend/tioga/tgRecipe.h | 5 +- src/backend/utils/adt/acl.c | 8 +- src/backend/utils/adt/arrayfuncs.c | 134 +- src/backend/utils/adt/cash.c | 6 +- src/backend/utils/adt/char.c | 8 +- src/backend/utils/adt/chunk.c | 12 +- src/backend/utils/adt/date.c | 3 +- src/backend/utils/adt/datetime.c | 18 +- src/backend/utils/adt/dt.c | 78 +- src/backend/utils/adt/float.c | 33 +- src/backend/utils/adt/inet_net_ntop.c | 23 +- src/backend/utils/adt/inet_net_pton.c | 61 +- src/backend/utils/adt/int8.c | 99 +- src/backend/utils/adt/like.c | 28 +- src/backend/utils/adt/mac.c | 228 +- src/backend/utils/adt/nabstime.c | 21 +- src/backend/utils/adt/name.c | 3 +- src/backend/utils/adt/network.c | 20 +- src/backend/utils/adt/not_in.c | 8 +- src/backend/utils/adt/numeric.c | 1020 ++++---- src/backend/utils/adt/numutils.c | 10 +- src/backend/utils/adt/regproc.c | 19 +- src/backend/utils/adt/ruleutils.c | 165 +- src/backend/utils/adt/selfuncs.c | 4 +- src/backend/utils/adt/varchar.c | 35 +- src/backend/utils/adt/varlena.c | 25 +- src/backend/utils/cache/catcache.c | 5 +- src/backend/utils/cache/inval.c | 12 +- src/backend/utils/cache/rel.c | 6 +- src/backend/utils/cache/relcache.c | 39 +- src/backend/utils/cache/syscache.c | 22 +- src/backend/utils/cache/temprel.c | 34 +- src/backend/utils/error/elog.c | 24 +- src/backend/utils/error/exc.c | 4 +- src/backend/utils/error/excid.c | 14 +- src/backend/utils/error/format.c | 3 +- src/backend/utils/fmgr/dfmgr.c | 11 +- src/backend/utils/fmgr/fmgr.c | 38 +- src/backend/utils/hash/dynahash.c | 50 +- src/backend/utils/init/enbl.c | 4 +- src/backend/utils/init/findbe.c | 4 +- src/backend/utils/init/globals.c | 3 +- src/backend/utils/init/miscinit.c | 20 +- src/backend/utils/init/postinit.c | 6 +- src/backend/utils/mb/alt.c | 106 +- src/backend/utils/mb/big5.c | 614 ++--- src/backend/utils/mb/common.c | 5 +- src/backend/utils/mb/conv.c | 512 ++-- src/backend/utils/mb/iso.c | 106 +- src/backend/utils/mb/mbutils.c | 12 +- src/backend/utils/mb/variable.c | 10 +- src/backend/utils/mb/wchar.c | 56 +- src/backend/utils/mb/win.c | 106 +- src/backend/utils/misc/database.c | 4 +- src/backend/utils/misc/trace.c | 18 +- src/backend/utils/mmgr/aset.c | 98 +- src/backend/utils/mmgr/mcxt.c | 42 +- src/backend/utils/mmgr/oset.c | 24 +- src/backend/utils/mmgr/palloc.c | 5 +- src/backend/utils/mmgr/portalmem.c | 62 +- src/backend/utils/sort/psort.c | 43 +- src/backend/utils/time/tqual.c | 95 +- src/bin/pg_dump/common.c | 12 +- src/bin/pg_dump/pg_dump.c | 467 ++-- src/bin/pg_dump/pg_dump.h | 4 +- src/bin/pgtclsh/pgtclAppInit.c | 6 +- src/bin/pgtclsh/pgtkAppInit.c | 6 +- src/bin/psql/psql.c | 171 +- src/include/access/attnum.h | 10 +- src/include/access/hash.h | 4 +- src/include/access/heapam.h | 8 +- src/include/access/hio.h | 6 +- src/include/access/htup.h | 30 +- src/include/access/istrat.h | 10 +- src/include/access/nbtree.h | 4 +- src/include/access/printtup.h | 12 +- src/include/access/relscan.h | 54 +- src/include/access/sdir.h | 10 +- src/include/access/strat.h | 5 +- src/include/access/transam.h | 4 +- src/include/access/tupmacs.h | 6 +- src/include/c.h | 121 +- src/include/catalog/heap.h | 4 +- src/include/catalog/index.h | 4 +- src/include/catalog/pg_attribute.h | 8 +- src/include/catalog/pg_class.h | 4 +- src/include/catalog/pg_index.h | 6 +- src/include/catalog/pg_opclass.h | 8 +- src/include/catalog/pg_operator.h | 68 +- src/include/catalog/pg_proc.h | 98 +- src/include/catalog/pg_type.h | 25 +- src/include/commands/command.h | 10 +- src/include/commands/vacuum.h | 36 +- src/include/executor/executor.h | 16 +- src/include/executor/hashjoin.h | 64 +- src/include/executor/nodeGroup.h | 3 +- src/include/executor/nodeHash.h | 8 +- src/include/executor/nodeHashjoin.h | 4 +- src/include/executor/nodeNestloop.h | 4 +- src/include/executor/spi.h | 6 +- src/include/executor/spi_priv.h | 4 +- src/include/executor/tuptable.h | 16 +- src/include/lib/fstack.h | 16 +- src/include/lib/stringinfo.h | 8 +- src/include/libpq/libpq.h | 20 +- src/include/libpq/pqformat.h | 14 +- src/include/mb/pg_wchar.h | 4 +- src/include/miscadmin.h | 6 +- src/include/nodes/execnodes.h | 89 +- src/include/nodes/makefuncs.h | 46 +- src/include/nodes/memnodes.h | 6 +- src/include/nodes/parsenodes.h | 28 +- src/include/nodes/plannodes.h | 5 +- src/include/nodes/primnodes.h | 4 +- src/include/nodes/relation.h | 35 +- src/include/optimizer/clauses.h | 4 +- src/include/optimizer/cost.h | 6 +- src/include/optimizer/geqo.h | 12 +- src/include/optimizer/geqo_misc.h | 4 +- src/include/optimizer/internal.h | 4 +- src/include/optimizer/joininfo.h | 4 +- src/include/optimizer/keys.h | 4 +- src/include/optimizer/ordering.h | 6 +- src/include/optimizer/pathnode.h | 20 +- src/include/optimizer/paths.h | 36 +- src/include/optimizer/planmain.h | 16 +- src/include/optimizer/restrictinfo.h | 4 +- src/include/optimizer/tlist.h | 4 +- src/include/optimizer/xfunc.h | 12 +- src/include/parser/analyze.h | 3 +- src/include/parser/parse_agg.h | 4 +- src/include/parser/parse_coerce.h | 8 +- src/include/parser/parse_func.h | 10 +- src/include/port/bsd.h | 2 + src/include/port/svr4.h | 1 + src/include/port/win.h | 4 +- src/include/rewrite/rewriteHandler.h | 4 +- src/include/rewrite/rewriteManip.h | 4 +- src/include/storage/block.h | 14 +- src/include/storage/buf.h | 8 +- src/include/storage/buf_internals.h | 12 +- src/include/storage/bufmgr.h | 14 +- src/include/storage/bufpage.h | 30 +- src/include/storage/fd.h | 12 +- src/include/storage/itemid.h | 6 +- src/include/storage/itemptr.h | 18 +- src/include/storage/lock.h | 8 +- src/include/storage/off.h | 8 +- src/include/storage/page.h | 4 +- src/include/storage/pagenum.h | 4 +- src/include/storage/pos.h | 10 +- src/include/storage/proc.h | 10 +- src/include/storage/shmem.h | 4 +- src/include/storage/sinvaladt.h | 5 +- src/include/tcop/dest.h | 21 +- src/include/tcop/tcopprot.h | 10 +- src/include/utils/array.h | 6 +- src/include/utils/bit.h | 8 +- src/include/utils/builtins.h | 70 +- src/include/utils/dt.h | 6 +- src/include/utils/geo_decls.h | 4 +- src/include/utils/hsearch.h | 13 +- src/include/utils/inet.h | 9 +- src/include/utils/int8.h | 6 +- src/include/utils/mcxt.h | 4 +- src/include/utils/memutils.h | 44 +- src/include/utils/nabstime.h | 6 +- src/include/utils/numeric.h | 30 +- src/include/utils/palloc.h | 20 +- src/include/utils/portal.h | 4 +- src/include/utils/psort.h | 6 +- src/include/utils/rel.h | 30 +- src/include/utils/temprel.h | 11 +- src/include/utils/tqual.h | 38 +- src/include/utils/trace.h | 6 +- src/interfaces/ecpg/include/ecpglib.h | 4 +- src/interfaces/ecpg/lib/ecpglib.c | 226 +- src/interfaces/ecpg/lib/typename.c | 2 +- src/interfaces/ecpg/preproc/ecpg.c | 9 +- src/interfaces/ecpg/preproc/extern.h | 10 +- src/interfaces/ecpg/preproc/type.c | 31 +- src/interfaces/ecpg/preproc/type.h | 16 +- src/interfaces/ecpg/test/header_test.h | 12 +- src/interfaces/libpgtcl/pgtclCmds.c | 112 +- src/interfaces/libpgtcl/pgtclCmds.h | 4 +- src/interfaces/libpgtcl/pgtclId.c | 93 +- src/interfaces/libpgtcl/pgtclId.h | 5 +- src/interfaces/libpq/fe-auth.c | 24 +- src/interfaces/libpq/fe-connect.c | 6 +- src/interfaces/libpq/fe-exec.c | 148 +- src/interfaces/libpq/fe-misc.c | 14 +- src/interfaces/libpq/fe-print.c | 15 +- src/interfaces/libpq/libpq-fe.h | 106 +- src/interfaces/libpq/libpq-int.h | 221 +- src/interfaces/libpq/libpqdll.c | 15 +- src/interfaces/python/pgmodule.c | 833 +++--- src/pl/plpgsql/src/pl_comp.c | 6 +- src/pl/plpgsql/src/pl_exec.c | 149 +- src/pl/plpgsql/src/pl_funcs.c | 6 +- src/pl/tcl/pltcl.c | 5 +- src/test/examples/testlo.c | 8 +- src/test/examples/testlo2.c | 8 +- src/test/regress/regress.c | 12 +- src/tools/pgindent/README | 2 +- src/tutorial/funcs.c | 12 +- src/utils/dllinit.c | 77 +- src/utils/getopt.c | 2 +- src/win32/endian.h | 2 - src/win32/tcp.h | 6 +- src/win32/un.h | 13 +- 413 files changed, 11723 insertions(+), 10769 deletions(-) diff --git a/contrib/array/array_iterator.c b/contrib/array/array_iterator.c index 5c4a3371a4..1561c1b192 100644 --- a/contrib/array/array_iterator.c +++ b/contrib/array/array_iterator.c @@ -43,8 +43,8 @@ array_iterator(Oid elemtype, Oid proc, int and, ArrayType *array, Datum value) int ndim, *dim; char *p; - FmgrInfo finf; /*Tobias Gabele Jan 18 1999*/ - + FmgrInfo finf; /* Tobias Gabele Jan 18 1999 */ + /* Sanity checks */ if ((array == (ArrayType *) NULL) @@ -75,9 +75,9 @@ array_iterator(Oid elemtype, Oid proc, int and, ArrayType *array, Datum value) /* Lookup the function entry point */ proc_fn = (func_ptr) NULL; - fmgr_info(proc,&finf); /*Tobias Gabele Jan 18 1999*/ - proc_fn=finf.fn_addr; /*Tobias Gabele Jan 18 1999*/ - pronargs=finf.fn_nargs; /*Tobias Gabele Jan 18 1999*/ + fmgr_info(proc, &finf); /* Tobias Gabele Jan 18 1999 */ + proc_fn = finf.fn_addr; /* Tobias Gabele Jan 18 1999 */ + pronargs = finf.fn_nargs; /* Tobias Gabele Jan 18 1999 */ if ((proc_fn == NULL) || (pronargs != 2)) { elog(ERROR, "array_iterator: fmgr_info lookup failed for oid %d", proc); @@ -110,38 +110,26 @@ array_iterator(Oid elemtype, Oid proc, int and, ArrayType *array, Datum value) { result = (int) (*proc_fn) (p, value); if (typlen > 0) - { p += typlen; - } else - { p += INTALIGN(*(int32 *) p); - } } if (result) { if (!and) - { return (1); - } } else { if (and) - { return (0); - } } } if (and && result) - { return (1); - } else - { return (0); - } } /* @@ -344,7 +332,7 @@ int32 array_oideq(ArrayType *array, Oid value) { return array_iterator((Oid) 26, /* oid */ - (Oid) 184, /* oideq */ + (Oid) 184, /* oideq */ 0, /* logical or */ array, (Datum) value); } diff --git a/contrib/array/array_iterator.h b/contrib/array/array_iterator.h index 5eab8d985b..6e84088487 100644 --- a/contrib/array/array_iterator.h +++ b/contrib/array/array_iterator.h @@ -1,8 +1,7 @@ #ifndef ARRAY_ITERATOR_H #define ARRAY_ITERATOR_H -static int32 -array_iterator(Oid elemtype, Oid proc, int and, +static int32 array_iterator(Oid elemtype, Oid proc, int and, ArrayType *array, Datum value); int32 array_texteq(ArrayType *array, char *value); int32 array_all_texteq(ArrayType *array, char *value); @@ -24,6 +23,7 @@ int32 array_int4lt(ArrayType *array, int4 value); int32 array_all_int4lt(ArrayType *array, int4 value); int32 array_int4le(ArrayType *array, int4 value); int32 array_all_int4le(ArrayType *array, int4 value); -int32 array_oideq(ArrayType *array, Oid value); -int32 array_all_oidne(ArrayType *array, Oid value); +int32 array_oideq(ArrayType *array, Oid value); +int32 array_all_oidne(ArrayType *array, Oid value); + #endif diff --git a/contrib/datetime/datetime_functions.c b/contrib/datetime/datetime_functions.c index 11c0be64f6..9dd0828457 100644 --- a/contrib/datetime/datetime_functions.c +++ b/contrib/datetime/datetime_functions.c @@ -225,8 +225,8 @@ currentdate() /* * Local variables: - * tab-width: 4 - * c-indent-level: 4 - * c-basic-offset: 4 + * tab-width: 4 + * c-indent-level: 4 + * c-basic-offset: 4 * End: */ diff --git a/contrib/earthdistance/earthdistance.c b/contrib/earthdistance/earthdistance.c index 0c106f670b..8dbef7295c 100644 --- a/contrib/earthdistance/earthdistance.c +++ b/contrib/earthdistance/earthdistance.c @@ -4,23 +4,24 @@ #include #include /* for Pt */ -#include /* for palloc */ +#include /* for palloc */ /* Earth's radius is in statute miles. */ -const EARTH_RADIUS = 3958.747716; -const TWO_PI = 2.0 * M_PI; +const EARTH_RADIUS = 3958.747716; +const TWO_PI = 2.0 * M_PI; /****************************************************** * * degtorad - convert degrees to radians * - * arg: double, angle in degrees + * arg: double, angle in degrees * - * returns: double, same angle in radians + * returns: double, same angle in radians ******************************************************/ static double -degtorad (double degrees) { +degtorad(double degrees) +{ return (degrees / 360.0) * TWO_PI; } @@ -30,36 +31,40 @@ degtorad (double degrees) { * geo_distance - distance between points * * args: - * a pair of points - for each point, - * x-coordinate is longitude in degrees west of Greenwich - * y-coordinate is latitude in degrees above equator + * a pair of points - for each point, + * x-coordinate is longitude in degrees west of Greenwich + * y-coordinate is latitude in degrees above equator * - * returns: double - * distance between the points in miles on earth's surface + * returns: double + * distance between the points in miles on earth's surface ******************************************************/ double * -geo_distance (Point *pt1, Point *pt2) { +geo_distance(Point *pt1, Point *pt2) +{ - double long1, lat1, long2, lat2; - double longdiff; - double * resultp = palloc (sizeof(double)); + double long1, + lat1, + long2, + lat2; + double longdiff; + double *resultp = palloc(sizeof(double)); /* convert degrees to radians */ - long1 = degtorad (pt1->x); - lat1 = degtorad (pt1->y); + long1 = degtorad(pt1->x); + lat1 = degtorad(pt1->y); - long2 = degtorad (pt2->x); - lat2 = degtorad (pt2->y); + long2 = degtorad(pt2->x); + lat2 = degtorad(pt2->y); /* compute difference in longitudes - want < 180 degrees */ - longdiff = fabs (long1 - long2); + longdiff = fabs(long1 - long2); if (longdiff > M_PI) longdiff = TWO_PI - longdiff; - * resultp = EARTH_RADIUS * acos - (sin (lat1) * sin (lat2) + cos (lat1) * cos (lat2) * cos (longdiff)); + *resultp = EARTH_RADIUS * acos + (sin(lat1) * sin(lat2) + cos(lat1) * cos(lat2) * cos(longdiff)); return resultp; } diff --git a/contrib/findoidjoins/findoidjoins.c b/contrib/findoidjoins/findoidjoins.c index 77e8c7475d..f1b82a14ef 100644 --- a/contrib/findoidjoins/findoidjoins.c +++ b/contrib/findoidjoins/findoidjoins.c @@ -9,7 +9,8 @@ #include #include "pginterface.h" -PGresult *attres, *relres; +PGresult *attres, + *relres; int main(int argc, char **argv) @@ -55,7 +56,7 @@ main(int argc, char **argv) "); doquery("FETCH ALL IN c_relations"); relres = get_result(); - + set_result(attres); while (fetch(typname, relname, attname) != END_OF_TUPLES) { @@ -65,17 +66,17 @@ main(int argc, char **argv) { unset_result(relres); if (strcmp(typname, "oid") == 0) - sprintf(query,"\ + sprintf(query, "\ DECLARE c_matches BINARY CURSOR FOR \ - SELECT count(*) - FROM %s t1, %s t2 \ - WHERE t1.%s = t2.oid", relname, relname2, attname); + SELECT count(*) \ + FROM % s t1, %s t2 \ + WHERE t1.% s = t2.oid ", relname, relname2, attname); else - sprintf(query,"\ + sprintf(query, "\ DECLARE c_matches BINARY CURSOR FOR \ - SELECT count(*) - FROM %s t1, %s t2 \ - WHERE RegprocToOid(t1.%s) = t2.oid", relname, relname2, attname); + SELECT count(*) \ + FROM % s t1, %s t2 \ + WHERE RegprocToOid(t1.% s) = t2.oid ", relname, relname2, attname); doquery(query); doquery("FETCH ALL IN c_matches"); @@ -96,7 +97,7 @@ main(int argc, char **argv) doquery("CLOSE c_attributes"); PQclear(attres); unset_result(attres); - + doquery("COMMIT WORK"); disconnectdb(); diff --git a/contrib/fulltextindex/fti.c b/contrib/fulltextindex/fti.c index e5539b4457..0291a48a27 100644 --- a/contrib/fulltextindex/fti.c +++ b/contrib/fulltextindex/fti.c @@ -1,18 +1,18 @@ #include "postgres.h" #include "executor/spi.h" #include "commands/trigger.h" -#include /* tolower */ -#include /* debugging */ +#include /* tolower */ +#include /* debugging */ /* * Trigger function takes 2 arguments: - 1. relation in which to store the substrings - 2. field to extract substrings from + 1. relation in which to store the substrings + 2. field to extract substrings from The relation in which to insert *must* have the following layout: - string varchar(#) - id oid + string varchar(#) + id oid Example: @@ -24,9 +24,9 @@ create index title_fti_idx on title_fti (string); create trigger title_fti_trigger after update or insert or delete on product for each row execute procedure fti(title_fti, title); - ^^^^^^^^^ + ^^^^^^^^^ where to store index in - ^^^^^ + ^^^^^ which column to index ofcourse don't forget to create an index on title_idx, column string, else @@ -39,8 +39,8 @@ select p.* from product p, title_fti f1, title_fti f2 where */ /* - march 4 1998 Changed breakup() to return less substrings. Only breakup - in word parts which are in turn shortened from the start + march 4 1998 Changed breakup() to return less substrings. Only breakup + in word parts which are in turn shortened from the start of the word (ie. word, ord, rd) Did allocation of substring buffer outside of breakup() oct. 5 1997, fixed a bug in string breakup (where there are more nonalpha @@ -62,14 +62,14 @@ select p.* from product p, title_fti f1, title_fti f2 where */ HeapTuple fti(void); -char *breakup(char*, char*); -bool is_stopword(char*); +char *breakup(char *, char *); +bool is_stopword(char *); -bool new_tuple = false; +bool new_tuple = false; /* THIS LIST MUST BE IN SORTED ORDER, A BINARY SEARCH IS USED!!!! */ -char *StopWords[] = { /* list of words to skip in indexing */ +char *StopWords[] = { /* list of words to skip in indexing */ #ifdef SAMPLE_STOP_WORDS "no" "the", @@ -88,7 +88,7 @@ typedef struct static EPlan *InsertPlans = NULL; static EPlan *DeletePlans = NULL; static int nInsertPlans = 0; -static int nDeletePlans = 0; +static int nDeletePlans = 0; static EPlan *find_plan(char *ident, EPlan ** eplan, int *nplans); @@ -96,28 +96,28 @@ static EPlan *find_plan(char *ident, EPlan ** eplan, int *nplans); HeapTuple fti() { - Trigger *trigger; /* to get trigger name */ - int nargs; /* # of arguments */ - char **args; /* arguments */ - char *relname; /* triggered relation name */ - Relation rel; /* triggered relation */ - char *indexname; /* name of table for substrings */ + Trigger *trigger; /* to get trigger name */ + int nargs; /* # of arguments */ + char **args; /* arguments */ + char *relname; /* triggered relation name */ + Relation rel; /* triggered relation */ + char *indexname; /* name of table for substrings */ HeapTuple rettuple = NULL; - TupleDesc tupdesc; /* tuple description */ - bool isinsert=false; - bool isdelete=false; + TupleDesc tupdesc; /* tuple description */ + bool isinsert = false; + bool isdelete = false; int ret; char query[8192]; Oid oid; - /* - FILE *debug; - */ /* - debug = fopen("/dev/xconsole", "w"); - fprintf(debug, "FTI: entered function\n"); - fflush(debug); - */ + * FILE *debug; + */ + + /* + * debug = fopen("/dev/xconsole", "w"); fprintf(debug, "FTI: entered + * function\n"); fflush(debug); + */ if (!CurrentTriggerData) elog(ERROR, "Full Text Indexing: triggers are not initialized"); @@ -127,47 +127,53 @@ fti() elog(ERROR, "Full Text Indexing: must be fired AFTER event"); if (TRIGGER_FIRED_BY_INSERT(CurrentTriggerData->tg_event)) - isinsert=true; + isinsert = true; if (TRIGGER_FIRED_BY_UPDATE(CurrentTriggerData->tg_event)) - { isdelete=true;isinsert=true;} + { + isdelete = true; + isinsert = true; + } if (TRIGGER_FIRED_BY_DELETE(CurrentTriggerData->tg_event)) - isdelete=true; + isdelete = true; trigger = CurrentTriggerData->tg_trigger; rel = CurrentTriggerData->tg_relation; relname = SPI_getrelname(rel); - rettuple=CurrentTriggerData->tg_trigtuple; - if (isdelete&&isinsert) /* is an UPDATE */ - rettuple=CurrentTriggerData->tg_newtuple; + rettuple = CurrentTriggerData->tg_trigtuple; + if (isdelete && isinsert) /* is an UPDATE */ + rettuple = CurrentTriggerData->tg_newtuple; - CurrentTriggerData = NULL; /* invalidate 'normal' calls to this function */ + CurrentTriggerData = NULL; /* invalidate 'normal' calls to this + * function */ + + if ((ret = SPI_connect()) < 0) + elog(ERROR, "Full Text Indexing: SPI_connect failed, returned %d\n", ret); - if ((ret = SPI_connect()) <0) - elog(ERROR,"Full Text Indexing: SPI_connect failed, returned %d\n",ret); - nargs = trigger->tgnargs; if (nargs != 2) elog(ERROR, "Full Text Indexing: trigger can only have 2 arguments"); - + args = trigger->tgargs; indexname = args[0]; - tupdesc = rel->rd_att; /* what the tuple looks like (?) */ + tupdesc = rel->rd_att; /* what the tuple looks like (?) */ /* get oid of current tuple, needed by all, so place here */ oid = rettuple->t_data->t_oid; if (!OidIsValid(oid)) - elog(ERROR,"Full Text Indexing: oid of current tuple is NULL"); + elog(ERROR, "Full Text Indexing: oid of current tuple is NULL"); - if (isdelete) { - void *pplan; - Oid *argtypes; - Datum values[1]; - EPlan *plan; + if (isdelete) + { + void *pplan; + Oid *argtypes; + Datum values[1]; + EPlan *plan; sprintf(query, "D%s$%s", args[0], args[1]); plan = find_plan(query, &DeletePlans, &nDeletePlans); - if (plan->nplans <= 0) { - argtypes = (Oid *)palloc(sizeof(Oid)); + if (plan->nplans <= 0) + { + argtypes = (Oid *) palloc(sizeof(Oid)); argtypes[0] = OIDOID; @@ -181,7 +187,7 @@ fti() elog(ERROR, "Full Text Indexing: SPI_saveplan returned NULL " "in delete"); - plan->splan = (void **)malloc(sizeof(void*)); + plan->splan = (void **) malloc(sizeof(void *)); *(plan->splan) = pplan; plan->nplans = 1; } @@ -192,26 +198,29 @@ fti() if (ret != SPI_OK_DELETE) elog(ERROR, "Full Text Indexing: error executing plan in delete"); } - - if (isinsert) { - char *substring, *column; - void *pplan; - Oid *argtypes; - Datum values[2]; - int colnum; + + if (isinsert) + { + char *substring, + *column; + void *pplan; + Oid *argtypes; + Datum values[2]; + int colnum; struct varlena *data; - EPlan *plan; + EPlan *plan; sprintf(query, "I%s$%s", args[0], args[1]); plan = find_plan(query, &InsertPlans, &nInsertPlans); /* no plan yet, so allocate mem for argtypes */ - if (plan->nplans <= 0) { - argtypes = (Oid *)palloc(2*sizeof(Oid)); + if (plan->nplans <= 0) + { + argtypes = (Oid *) palloc(2 * sizeof(Oid)); - argtypes[0] = VARCHAROID; /*create table t_name - (string varchar, */ - argtypes[1] = OIDOID; /* id oid); */ + argtypes[0] = VARCHAROID; /* create table t_name (string + * varchar, */ + argtypes[1] = OIDOID; /* id oid); */ /* prepare plan to gain speed */ sprintf(query, "INSERT INTO %s (string, id) VALUES ($1, $2)", @@ -226,45 +235,49 @@ fti() elog(ERROR, "Full Text Indexing: SPI_saveplan returned NULL" " in insert"); - plan->splan = (void **)malloc(sizeof(void*)); + plan->splan = (void **) malloc(sizeof(void *)); *(plan->splan) = pplan; plan->nplans = 1; } - - + + /* prepare plan for query */ - colnum=SPI_fnumber(tupdesc, args[1]); + colnum = SPI_fnumber(tupdesc, args[1]); if (colnum == SPI_ERROR_NOATTRIBUTE) elog(ERROR, "Full Text Indexing: column '%s' of '%s' not found", args[1], args[0]); - + /* Get the char* representation of the column with name args[1] */ column = SPI_getvalue(rettuple, tupdesc, colnum); - - if (column) { /* make sure we don't try to index NULL's */ - char *buff; - char *string = column; - - while(*string != '\0') { /* placed 'really' inline. */ - *string = tolower(*string); /* some compilers will choke */ - string++; /* on 'inline' keyword */ + + if (column) + { /* make sure we don't try to index NULL's */ + char *buff; + char *string = column; + + while (*string != '\0') + { /* placed 'really' inline. */ + *string = tolower(*string); /* some compilers will + * choke */ + string++; /* on 'inline' keyword */ } - data = (struct varlena*)palloc(sizeof(int32)+strlen(column)+1); + data = (struct varlena *) palloc(sizeof(int32) + strlen(column) +1); buff = palloc(strlen(column) + 1); - /* saves lots of calls in while-loop and in breakup()*/ + /* saves lots of calls in while-loop and in breakup() */ - new_tuple=true; - while ((substring = breakup(column, buff))) { - int l; + new_tuple = true; + while ((substring = breakup(column, buff))) + { + int l; l = strlen(substring); - data->vl_len = l+sizeof(int32); + data->vl_len = l + sizeof(int32); memcpy(VARDATA(data), substring, l); values[0] = PointerGetDatum(data); values[1] = oid; - + ret = SPI_execp(*(plan->splan), values, NULL, 0); if (ret != SPI_OK_INSERT) elog(ERROR, "Full Text Indexing: error executing plan " @@ -279,76 +292,83 @@ fti() return (rettuple); } -char *breakup(char *string, char *substring) +char * +breakup(char *string, char *substring) { static char *last_start; static char *cur_pos; if (new_tuple) { - cur_pos=last_start=&string[strlen(string)-1]; - new_tuple=false; /* don't initialize this next time */ + cur_pos = last_start = &string[strlen(string) - 1]; + new_tuple = false; /* don't initialize this next time */ } - while (cur_pos > string) /* don't read before start of 'string' */ + while (cur_pos > string) /* don't read before start of 'string' */ { - /* skip pieces at the end of a string that are not - alfa-numeric (ie. 'string$%^&', last_start first points to - '&', and after this to 'g' */ - if (!isalnum((int)*last_start)) { - while (!isalnum((int)*last_start) && + + /* + * skip pieces at the end of a string that are not alfa-numeric + * (ie. 'string$%^&', last_start first points to '&', and after + * this to 'g' + */ + if (!isalnum((int) *last_start)) + { + while (!isalnum((int) *last_start) && last_start > string) last_start--; - cur_pos=last_start; + cur_pos = last_start; } - cur_pos--; /* substrings are at minimum 2 characters long */ + cur_pos--; /* substrings are at minimum 2 characters + * long */ - if (isalnum((int)*cur_pos)) + if (isalnum((int) *cur_pos)) { /* Houston, we have a substring! :) */ memcpy(substring, cur_pos, last_start - cur_pos + 1); - substring[last_start-cur_pos+1]='\0'; - if (!is_stopword(substring)) return substring; + substring[last_start - cur_pos + 1] = '\0'; + if (!is_stopword(substring)) + return substring; } else { - last_start=cur_pos-1; + last_start = cur_pos - 1; cur_pos = last_start; } } - return NULL; /* we've processed all of 'string' */ + return NULL; /* we've processed all of 'string' */ } /* copied from src/backend/parser/keywords.c and adjusted for our situation*/ bool is_stopword(char *text) { - char **StopLow; /* for list of stop-words */ - char **StopHigh; - char **StopMiddle; - unsigned int difference; + char **StopLow; /* for list of stop-words */ + char **StopHigh; + char **StopMiddle; + unsigned int difference; - StopLow = &StopWords[0]; /* initialize stuff for binary search */ + StopLow = &StopWords[0]; /* initialize stuff for binary search */ StopHigh = endof(StopWords); if (lengthof(StopWords) == 0) return false; - - while (StopLow <= StopHigh) - { - StopMiddle = StopLow + (StopHigh - StopLow) / 2; - difference = strcmp(*StopMiddle, text); - if (difference == 0) - return (true); - else if (difference < 0) - StopLow = StopMiddle + 1; - else - StopHigh = StopMiddle - 1; - } - return (false); + while (StopLow <= StopHigh) + { + StopMiddle = StopLow + (StopHigh - StopLow) / 2; + difference = strcmp(*StopMiddle, text); + if (difference == 0) + return (true); + else if (difference < 0) + StopLow = StopMiddle + 1; + else + StopHigh = StopMiddle - 1; + } + + return (false); } /* for caching of query plans, stolen from contrib/spi/\*.c */ diff --git a/contrib/isbn_issn/isbn.c b/contrib/isbn_issn/isbn.c index ed608f3e13..5f4ac88905 100644 --- a/contrib/isbn_issn/isbn.c +++ b/contrib/isbn_issn/isbn.c @@ -1,7 +1,7 @@ /* * PostgreSQL type definitions for ISBNs. * - * $Id: isbn.c,v 1.1 1998/08/17 03:35:04 scrappy Exp $ + * $Id: isbn.c,v 1.2 1999/05/25 16:05:40 momjian Exp $ */ #include @@ -16,8 +16,8 @@ typedef struct isbn { - char num[13]; - char pad[3]; + char num[13]; + char pad[3]; } isbn; /* @@ -50,13 +50,15 @@ isbn_in(char *str) char *cp; int count; - if (strlen(str) != 13) { + if (strlen(str) != 13) + { elog(ERROR, "isbn_in: invalid ISBN \"%s\"", str); return (NULL); } - if (isbn_sum(str) != 0) { + if (isbn_sum(str) != 0) + { elog(ERROR, "isbn_in: purported ISBN \"%s\" failed checksum", - str); + str); return (NULL); } @@ -84,28 +86,40 @@ isbn_in(char *str) int4 isbn_sum(char *str) { - int4 sum = 0, dashes = 0, val; - int i; + int4 sum = 0, + dashes = 0, + val; + int i; - for (i = 0; str[i] && i < 13; i++) { - switch(str[i]) { - case '-': - if (++dashes > 3) + for (i = 0; str[i] && i < 13; i++) + { + switch (str[i]) + { + case '-': + if (++dashes > 3) + return 12; + continue; + + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + val = str[i] - '0'; + break; + + case 'X': + case 'x': + val = 10; + break; + + default: return 12; - continue; - - case '0': case '1': case '2': case '3': - case '4': case '5': case '6': case '7': - case '8': case '9': - val = str[i] - '0'; - break; - - case 'X': case 'x': - val = 10; - break; - - default: - return 12; } sum += val * (i + 1 - dashes); diff --git a/contrib/isbn_issn/issn.c b/contrib/isbn_issn/issn.c index 8f5aa22f7c..ccb264ac8f 100644 --- a/contrib/isbn_issn/issn.c +++ b/contrib/isbn_issn/issn.c @@ -1,7 +1,7 @@ /* * PostgreSQL type definitions for ISSNs. * - * $Id: issn.c,v 1.1 1998/08/17 03:35:05 scrappy Exp $ + * $Id: issn.c,v 1.2 1999/05/25 16:05:42 momjian Exp $ */ #include @@ -16,8 +16,8 @@ typedef struct issn { - char num[9]; - char pad[7]; + char num[9]; + char pad[7]; } issn; /* @@ -50,13 +50,15 @@ issn_in(char *str) char *cp; int count; - if (strlen(str) != 9) { + if (strlen(str) != 9) + { elog(ERROR, "issn_in: invalid ISSN \"%s\"", str); return (NULL); } - if (issn_sum(str) != 0) { + if (issn_sum(str) != 0) + { elog(ERROR, "issn_in: purported ISSN \"%s\" failed checksum", - str); + str); return (NULL); } @@ -75,28 +77,40 @@ issn_in(char *str) int4 issn_sum(char *str) { - int4 sum = 0, dashes = 0, val; - int i; + int4 sum = 0, + dashes = 0, + val; + int i; - for (i = 0; str[i] && i < 9; i++) { - switch(str[i]) { - case '-': - if (++dashes > 1) + for (i = 0; str[i] && i < 9; i++) + { + switch (str[i]) + { + case '-': + if (++dashes > 1) + return 12; + continue; + + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + val = str[i] - '0'; + break; + + case 'X': + case 'x': + val = 10; + break; + + default: return 12; - continue; - - case '0': case '1': case '2': case '3': - case '4': case '5': case '6': case '7': - case '8': case '9': - val = str[i] - '0'; - break; - - case 'X': case 'x': - val = 10; - break; - - default: - return 12; } sum += val * (8 - (i - dashes)); diff --git a/contrib/lo/lo.c b/contrib/lo/lo.c index 96af1df3d9..3b0c1e2614 100644 --- a/contrib/lo/lo.c +++ b/contrib/lo/lo.c @@ -1,7 +1,7 @@ /* * PostgreSQL type definitions for managed LargeObjects. * - * $Id: lo.c,v 1.1 1998/06/16 07:07:11 momjian Exp $ + * $Id: lo.c,v 1.2 1999/05/25 16:05:45 momjian Exp $ * */ @@ -33,11 +33,11 @@ typedef Oid Blob; * Various forward declarations: */ -Blob *lo_in(char *str); /* Create from String */ -char *lo_out(Blob * addr); /* Output oid as String */ -Oid lo_oid(Blob * addr); /* Return oid as an oid */ -Blob *lo(Oid oid); /* Return Blob based on oid */ -HeapTuple lo_manage(void); /* Trigger handler */ +Blob *lo_in(char *str); /* Create from String */ +char *lo_out(Blob * addr);/* Output oid as String */ +Oid lo_oid(Blob * addr);/* Return oid as an oid */ +Blob *lo(Oid oid); /* Return Blob based on oid */ +HeapTuple lo_manage(void); /* Trigger handler */ /* * This creates a large object, and set's its OID to the value in the @@ -49,45 +49,46 @@ HeapTuple lo_manage(void); /* Trigger handler */ Blob * lo_in(char *str) { - Blob *result; - Oid oid; - int count; - - if (strlen(str) > 0) + Blob *result; + Oid oid; + int count; + + if (strlen(str) > 0) { - - count = sscanf(str, "%d", &oid); - - if (count < 1) + + count = sscanf(str, "%d", &oid); + + if (count < 1) { - elog(ERROR, "lo_in: error in parsing \"%s\"", str); - return (NULL); + elog(ERROR, "lo_in: error in parsing \"%s\"", str); + return (NULL); } - - if(oid < 0) + + if (oid < 0) { - elog(ERROR, "lo_in: illegal oid \"%s\"", str); - return (NULL); + elog(ERROR, "lo_in: illegal oid \"%s\"", str); + return (NULL); } } - else + else { - /* - * There is no Oid passed, so create a new one - */ - oid = lo_creat(INV_READ|INV_WRITE); - if(oid == InvalidOid) + + /* + * There is no Oid passed, so create a new one + */ + oid = lo_creat(INV_READ | INV_WRITE); + if (oid == InvalidOid) { - elog(ERROR,"lo_in: InvalidOid returned from lo_creat"); - return (NULL); + elog(ERROR, "lo_in: InvalidOid returned from lo_creat"); + return (NULL); } } - - result = (Blob *) palloc(sizeof(Blob)); - - *result = oid; - - return (result); + + result = (Blob *) palloc(sizeof(Blob)); + + *result = oid; + + return (result); } /* @@ -96,42 +97,43 @@ lo_in(char *str) char * lo_out(Blob * addr) { - char *result; - - if (addr == NULL) - return (NULL); - - result = (char *) palloc(32); - sprintf(result,"%d",*addr); - return (result); + char *result; + + if (addr == NULL) + return (NULL); + + result = (char *) palloc(32); + sprintf(result, "%d", *addr); + return (result); } /* * This function converts Blob to oid. * * eg: select lo_export(raster::oid,'/path/file') from table; - * + * */ Oid lo_oid(Blob * addr) { - if(addr == NULL) - return InvalidOid; - return (Oid)(*addr); + if (addr == NULL) + return InvalidOid; + return (Oid) (*addr); } /* * This function is used so we can convert oid's to lo's * - * ie: insert into table values(lo_import('/path/file')::lo); + * ie: insert into table values(lo_import('/path/file')::lo); * */ Blob * lo(Oid oid) { - Blob *result = (Blob *) palloc(sizeof(Blob)); - *result = oid; - return (result); + Blob *result = (Blob *) palloc(sizeof(Blob)); + + *result = oid; + return (result); } /* @@ -140,74 +142,77 @@ lo(Oid oid) HeapTuple lo_manage(void) { - int attnum; /* attribute number to monitor */ - char **args; /* Args containing attr name */ - TupleDesc tupdesc; /* Tuple Descriptor */ - HeapTuple rettuple; /* Tuple to be returned */ - bool isdelete; /* are we deleting? */ - HeapTuple newtuple=NULL; /* The new value for tuple */ - HeapTuple trigtuple; /* The original value of tuple */ - - if (!CurrentTriggerData) - elog(ERROR, "lo: triggers are not initialized"); - - /* - * Fetch some values from CurrentTriggerData - */ - newtuple = CurrentTriggerData->tg_newtuple; - trigtuple = CurrentTriggerData->tg_trigtuple; - tupdesc = CurrentTriggerData->tg_relation->rd_att; - args = CurrentTriggerData->tg_trigger->tgargs; - - /* tuple to return to Executor */ - if (TRIGGER_FIRED_BY_UPDATE(CurrentTriggerData->tg_event)) - rettuple = newtuple; - else - rettuple = trigtuple; - - /* Are we deleting the row? */ - isdelete = TRIGGER_FIRED_BY_DELETE(CurrentTriggerData->tg_event); - - /* Were done with it */ - CurrentTriggerData = NULL; - - /* Get the column were interested in */ - attnum = SPI_fnumber(tupdesc,args[0]); - - /* - * Handle updates - * - * Here, if the value of the monitored attribute changes, then the - * large object associated with the original value is unlinked. - */ - if(newtuple!=NULL) { - char *orig = SPI_getvalue(trigtuple,tupdesc,attnum); - char *newv = SPI_getvalue(newtuple,tupdesc,attnum); - - if((orig != newv && (orig==NULL || newv==NULL)) || (orig!=NULL && newv!=NULL && strcmp(orig,newv))) - lo_unlink(atoi(orig)); - - if(newv) - pfree(newv); - if(orig) - pfree(orig); - } - - /* - * Handle deleting of rows - * - * Here, we unlink the large object associated with the managed attribute - * - */ - if(isdelete) { - char *orig = SPI_getvalue(trigtuple,tupdesc,attnum); - - if(orig != NULL) { - lo_unlink(atoi(orig)); - - pfree(orig); + int attnum; /* attribute number to monitor */ + char **args; /* Args containing attr name */ + TupleDesc tupdesc; /* Tuple Descriptor */ + HeapTuple rettuple; /* Tuple to be returned */ + bool isdelete; /* are we deleting? */ + HeapTuple newtuple = NULL;/* The new value for tuple */ + HeapTuple trigtuple; /* The original value of tuple */ + + if (!CurrentTriggerData) + elog(ERROR, "lo: triggers are not initialized"); + + /* + * Fetch some values from CurrentTriggerData + */ + newtuple = CurrentTriggerData->tg_newtuple; + trigtuple = CurrentTriggerData->tg_trigtuple; + tupdesc = CurrentTriggerData->tg_relation->rd_att; + args = CurrentTriggerData->tg_trigger->tgargs; + + /* tuple to return to Executor */ + if (TRIGGER_FIRED_BY_UPDATE(CurrentTriggerData->tg_event)) + rettuple = newtuple; + else + rettuple = trigtuple; + + /* Are we deleting the row? */ + isdelete = TRIGGER_FIRED_BY_DELETE(CurrentTriggerData->tg_event); + + /* Were done with it */ + CurrentTriggerData = NULL; + + /* Get the column were interested in */ + attnum = SPI_fnumber(tupdesc, args[0]); + + /* + * Handle updates + * + * Here, if the value of the monitored attribute changes, then the large + * object associated with the original value is unlinked. + */ + if (newtuple != NULL) + { + char *orig = SPI_getvalue(trigtuple, tupdesc, attnum); + char *newv = SPI_getvalue(newtuple, tupdesc, attnum); + + if ((orig != newv && (orig == NULL || newv == NULL)) || (orig != NULL && newv != NULL && strcmp(orig, newv))) + lo_unlink(atoi(orig)); + + if (newv) + pfree(newv); + if (orig) + pfree(orig); } - } - - return (rettuple); + + /* + * Handle deleting of rows + * + * Here, we unlink the large object associated with the managed attribute + * + */ + if (isdelete) + { + char *orig = SPI_getvalue(trigtuple, tupdesc, attnum); + + if (orig != NULL) + { + lo_unlink(atoi(orig)); + + pfree(orig); + } + } + + return (rettuple); } diff --git a/contrib/mSQL-interface/mpgsql.c b/contrib/mSQL-interface/mpgsql.c index 2f39d7cad9..5b35fe1638 100644 --- a/contrib/mSQL-interface/mpgsql.c +++ b/contrib/mSQL-interface/mpgsql.c @@ -6,270 +6,360 @@ #define HNDMAX 10 -PGconn *PGh[HNDMAX] = { - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL +PGconn *PGh[HNDMAX] = { + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL }; #define E_NOHANDLERS 0 -char *msqlErrors[] = { - "Out of database handlers." +char *msqlErrors[] = { + "Out of database handlers." }; -char msqlErrMsg[BUFSIZ], *tfrom = "dunno"; -PGresult *queryres = NULL; +char msqlErrMsg[BUFSIZ], + *tfrom = "dunno"; +PGresult *queryres = NULL; -int msqlConnect (char *host) { - int count; - - for (count = 0; count < HNDMAX; count++) - if (PGh[count] == NULL) break; - - if (count == HNDMAX) { - strncpy(msqlErrMsg, msqlErrors[E_NOHANDLERS], BUFSIZ); - return -1; - } +int +msqlConnect(char *host) +{ + int count; - PGh[count] = malloc(sizeof (PGconn)); - PGh[count]->pghost = host ? strdup(host) : NULL; - return count; + for (count = 0; count < HNDMAX; count++) + if (PGh[count] == NULL) + break; + + if (count == HNDMAX) + { + strncpy(msqlErrMsg, msqlErrors[E_NOHANDLERS], BUFSIZ); + return -1; + } + + PGh[count] = malloc(sizeof(PGconn)); + PGh[count]->pghost = host ? strdup(host) : NULL; + return count; } -int msqlSelectDB(int handle, char *dbname) { - char *options = calloc(1, BUFSIZ); - char *e = getenv("PG_OPTIONS"); - - if (e == NULL) - e = ""; - - if (PGh[handle]->pghost) { - strcat(options, "host="); - strncat(options, PGh[handle]->pghost, BUFSIZ); - strncat(options, " ", BUFSIZ); - free(PGh[handle]->pghost); - PGh[handle]->pghost = NULL; - } - strncat(options, "dbname=", BUFSIZ); - strncat(options, dbname, BUFSIZ); - strncat(options, " ", BUFSIZ); - strncat(options, e, BUFSIZ); - free(PGh[handle]); - PGh[handle] = PQconnectdb(options); - free(options); - strncpy(msqlErrMsg, PQerrorMessage(PGh[handle]), BUFSIZ); - return (PQstatus(PGh[handle]) == CONNECTION_BAD ? -1 : 0); +int +msqlSelectDB(int handle, char *dbname) +{ + char *options = calloc(1, BUFSIZ); + char *e = getenv("PG_OPTIONS"); + + if (e == NULL) + e = ""; + + if (PGh[handle]->pghost) + { + strcat(options, "host="); + strncat(options, PGh[handle]->pghost, BUFSIZ); + strncat(options, " ", BUFSIZ); + free(PGh[handle]->pghost); + PGh[handle]->pghost = NULL; + } + strncat(options, "dbname=", BUFSIZ); + strncat(options, dbname, BUFSIZ); + strncat(options, " ", BUFSIZ); + strncat(options, e, BUFSIZ); + free(PGh[handle]); + PGh[handle] = PQconnectdb(options); + free(options); + strncpy(msqlErrMsg, PQerrorMessage(PGh[handle]), BUFSIZ); + return (PQstatus(PGh[handle]) == CONNECTION_BAD ? -1 : 0); } -int msqlQuery(int handle, char *query) { - char *tq = strdup(query); - char *p = tq; - PGresult *res; - PGconn *conn = PGh[handle]; - ExecStatusType rcode; - - res = PQexec(conn, p); +int +msqlQuery(int handle, char *query) +{ + char *tq = strdup(query); + char *p = tq; + PGresult *res; + PGconn *conn = PGh[handle]; + ExecStatusType rcode; - rcode = PQresultStatus(res); - - if (rcode == PGRES_TUPLES_OK) { - queryres = res; - return PQntuples(res); - } else if (rcode == PGRES_FATAL_ERROR || rcode == PGRES_NONFATAL_ERROR) { - PQclear(res); - queryres = NULL; - return -1; - } else { - PQclear(res); - queryres = NULL; - return 0; - } + res = PQexec(conn, p); + + rcode = PQresultStatus(res); + + if (rcode == PGRES_TUPLES_OK) + { + queryres = res; + return PQntuples(res); + } + else if (rcode == PGRES_FATAL_ERROR || rcode == PGRES_NONFATAL_ERROR) + { + PQclear(res); + queryres = NULL; + return -1; + } + else + { + PQclear(res); + queryres = NULL; + return 0; + } } -int msqlCreateDB (int a, char*b) { - char tbuf[BUFSIZ]; - sprintf(tbuf, "create database %s", b); - return msqlQuery(a, tbuf) >= 0 ? 0 : -1; +int +msqlCreateDB(int a, char *b) +{ + char tbuf[BUFSIZ]; + + sprintf(tbuf, "create database %s", b); + return msqlQuery(a, tbuf) >= 0 ? 0 : -1; } -int msqlDropDB (int a, char* b) { - char tbuf[BUFSIZ]; - sprintf(tbuf, "drop database %s", b); - return msqlQuery(a, tbuf) >= 0 ? 0 : -1; +int +msqlDropDB(int a, char *b) +{ + char tbuf[BUFSIZ]; + + sprintf(tbuf, "drop database %s", b); + return msqlQuery(a, tbuf) >= 0 ? 0 : -1; } -int msqlShutdown(int a) { +int +msqlShutdown(int a) +{ } -int msqlGetProtoInfo(void) { +int +msqlGetProtoInfo(void) +{ } -int msqlReloadAcls(int a) { +int +msqlReloadAcls(int a) +{ } -char *msqlGetServerInfo(void) { +char * +msqlGetServerInfo(void) +{ } -char *msqlGetHostInfo(void) { +char * +msqlGetHostInfo(void) +{ } -char *msqlUnixTimeToDate(time_t date) { +char * +msqlUnixTimeToDate(time_t date) +{ } -char *msqlUnixTimeToTime(time_t time) { +char * +msqlUnixTimeToTime(time_t time) +{ } -void msqlClose(int a) { - PQfinish(PGh[a]); - PGh[a] = NULL; - if (queryres) { - free(queryres); - queryres = NULL; - } +void +msqlClose(int a) +{ + PQfinish(PGh[a]); + PGh[a] = NULL; + if (queryres) + { + free(queryres); + queryres = NULL; + } } -void msqlDataSeek(m_result *result, int count) { - int c; - result->cursor = result->queryData; - for (c = 1; c < count; c++) - if (result->cursor->next) - result->cursor = result->cursor->next; +void +msqlDataSeek(m_result * result, int count) +{ + int c; + + result->cursor = result->queryData; + for (c = 1; c < count; c++) + if (result->cursor->next) + result->cursor = result->cursor->next; } -void msqlFieldSeek(m_result *result, int count) { - int c; - result->fieldCursor = result->fieldData; - for (c = 1; c < count; c++) - if (result->fieldCursor->next) - result->fieldCursor = result->fieldCursor->next; +void +msqlFieldSeek(m_result * result, int count) +{ + int c; + + result->fieldCursor = result->fieldData; + for (c = 1; c < count; c++) + if (result->fieldCursor->next) + result->fieldCursor = result->fieldCursor->next; } -void msqlFreeResult(m_result *result) { - if (result) { - /* Clears fields */ - free(result->fieldData); - result->cursor = result->queryData; - while (result->cursor) { - int c; - m_row m = result->cursor->data; - - for (c = 0; m[c]; c++) - free(m[c]); +void +msqlFreeResult(m_result * result) +{ + if (result) + { + /* Clears fields */ + free(result->fieldData); + result->cursor = result->queryData; + while (result->cursor) + { + int c; + m_row m = result->cursor->data; - result->cursor = result->cursor->next; - } - free(result->queryData); - free(result); - } + for (c = 0; m[c]; c++) + free(m[c]); + + result->cursor = result->cursor->next; + } + free(result->queryData); + free(result); + } } -m_row msqlFetchRow(m_result *row) { - m_data *r = row->cursor; - if (r) { - row->cursor = row->cursor->next; - return (m_row)r->data; - } - return (m_row)NULL; +m_row +msqlFetchRow(m_result * row) +{ + m_data *r = row->cursor; + + if (r) + { + row->cursor = row->cursor->next; + return (m_row) r->data; + } + return (m_row) NULL; } -m_seq *msqlGetSequenceInfo(int a, char *b) { +m_seq * +msqlGetSequenceInfo(int a, char *b) +{ } -m_field *msqlFetchField (m_result *mr) { - m_field *m = (m_field*)mr->fieldCursor; - if (m) { - mr->fieldCursor = mr->fieldCursor->next; - return m; - } - return NULL; +m_field * +msqlFetchField(m_result * mr) +{ + m_field *m = (m_field *) mr->fieldCursor; + + if (m) + { + mr->fieldCursor = mr->fieldCursor->next; + return m; + } + return NULL; } -m_result *msqlListDBs(int a) { - m_result *m; - if (msqlQuery(a, "select datname from pg_database") > 0) { - m = msqlStoreResult(); - return m; - } else return NULL; +m_result * +msqlListDBs(int a) +{ + m_result *m; + + if (msqlQuery(a, "select datname from pg_database") > 0) + { + m = msqlStoreResult(); + return m; + } + else + return NULL; } -m_result *msqlListTables(int a) { - m_result *m; - char tbuf[BUFSIZ]; - - sprintf(tbuf, "select relname from pg_class where relkind='r' and relowner=%d", getuid()); - if (msqlQuery(a, tbuf) > 0) { - m = msqlStoreResult(); - return m; - } else return NULL; +m_result * +msqlListTables(int a) +{ + m_result *m; + char tbuf[BUFSIZ]; + + sprintf(tbuf, "select relname from pg_class where relkind='r' and relowner=%d", getuid()); + if (msqlQuery(a, tbuf) > 0) + { + m = msqlStoreResult(); + return m; + } + else + return NULL; } -m_result *msqlListFields(int a, char *b) { - +m_result * +msqlListFields(int a, char *b) +{ + } -m_result *msqlListIndex(int a, char *b, char *c) { - m_result *m; - char tbuf[BUFSIZ]; - - sprintf(tbuf, "select relname from pg_class where relkind='i' and relowner=%d", getuid()); - if (msqlQuery(a, tbuf) > 0) { - m = msqlStoreResult(); - return m; - } else return NULL; +m_result * +msqlListIndex(int a, char *b, char *c) +{ + m_result *m; + char tbuf[BUFSIZ]; + + sprintf(tbuf, "select relname from pg_class where relkind='i' and relowner=%d", getuid()); + if (msqlQuery(a, tbuf) > 0) + { + m = msqlStoreResult(); + return m; + } + else + return NULL; } -m_result *msqlStoreResult(void) { - if (queryres) { - m_result *mr = malloc(sizeof(m_result)); - m_fdata *mf; - m_data *md; - int count; - mr->queryData = mr->cursor = NULL; - mr->numRows = PQntuples(queryres); - mr->numFields = PQnfields(queryres); - - mf = calloc(PQnfields(queryres), sizeof(m_fdata)); - for (count = 0; count < PQnfields(queryres); count++) { - (m_fdata*)(mf+count)->field.name = strdup(PQfname(queryres, count)); - (m_fdata*)(mf+count)->field.table = tfrom; - (m_fdata*)(mf+count)->field.type = CHAR_TYPE; - (m_fdata*)(mf+count)->field.length = PQfsize(queryres, count); - (m_fdata*)(mf+count)->next = (m_fdata*)(mf+count+1); - } - (m_fdata*)(mf+count-1)->next = NULL; - - md = calloc(PQntuples(queryres), sizeof(m_data)); - for (count = 0; count < PQntuples(queryres); count++) { - m_row rows = calloc(PQnfields(queryres)*sizeof(m_row)+1, 1); - int c; - - for (c = 0; c < PQnfields(queryres); c++) { - rows[c] = strdup(PQgetvalue(queryres, count, c)); - } - (m_data*)(md+count)->data = rows; - - (m_data*)(md+count)->width = PQnfields(queryres); - (m_data*)(md+count)->next = (m_data*)(md+count+1); - } - (m_data*)(md+count-1)->next = NULL; - - mr->queryData = mr->cursor = md; - mr->fieldCursor = mr->fieldData = mf; +m_result * +msqlStoreResult(void) +{ + if (queryres) + { + m_result *mr = malloc(sizeof(m_result)); + m_fdata *mf; + m_data *md; + int count; - return mr; - } else return NULL; + mr->queryData = mr->cursor = NULL; + mr->numRows = PQntuples(queryres); + mr->numFields = PQnfields(queryres); + + mf = calloc(PQnfields(queryres), sizeof(m_fdata)); + for (count = 0; count < PQnfields(queryres); count++) + { + (m_fdata *) (mf + count)->field.name = strdup(PQfname(queryres, count)); + (m_fdata *) (mf + count)->field.table = tfrom; + (m_fdata *) (mf + count)->field.type = CHAR_TYPE; + (m_fdata *) (mf + count)->field.length = PQfsize(queryres, count); + (m_fdata *) (mf + count)->next = (m_fdata *) (mf + count + 1); + } + (m_fdata *) (mf + count - 1)->next = NULL; + + md = calloc(PQntuples(queryres), sizeof(m_data)); + for (count = 0; count < PQntuples(queryres); count++) + { + m_row rows = calloc(PQnfields(queryres) * sizeof(m_row) + 1, 1); + int c; + + for (c = 0; c < PQnfields(queryres); c++) + rows[c] = strdup(PQgetvalue(queryres, count, c)); + (m_data *) (md + count)->data = rows; + + (m_data *) (md + count)->width = PQnfields(queryres); + (m_data *) (md + count)->next = (m_data *) (md + count + 1); + } + (m_data *) (md + count - 1)->next = NULL; + + mr->queryData = mr->cursor = md; + mr->fieldCursor = mr->fieldData = mf; + + return mr; + } + else + return NULL; } -time_t msqlDateToUnixTime(char *a) { +time_t +msqlDateToUnixTime(char *a) +{ } -time_t msqlTimeToUnixTime(char *b) { +time_t +msqlTimeToUnixTime(char *b) +{ } -char *msql_tmpnam(void) { - return tmpnam("/tmp/msql.XXXXXX"); +char * +msql_tmpnam(void) +{ + return tmpnam("/tmp/msql.XXXXXX"); } -int msqlLoadConfigFile(char *a) { +int +msqlLoadConfigFile(char *a) +{ } - diff --git a/contrib/miscutil/misc_utils.c b/contrib/miscutil/misc_utils.c index ee2f3ec2b2..24d069f71c 100644 --- a/contrib/miscutil/misc_utils.c +++ b/contrib/miscutil/misc_utils.c @@ -23,6 +23,7 @@ extern int assertTest(int val); #ifdef ASSERT_CHECKING_TEST extern int assertEnable(int val); + #endif int @@ -68,14 +69,15 @@ assert_test(int val) { return assertTest(val); } + #endif /* end of file */ /* * Local variables: - * tab-width: 4 - * c-indent-level: 4 - * c-basic-offset: 4 + * tab-width: 4 + * c-indent-level: 4 + * c-basic-offset: 4 * End: */ diff --git a/contrib/miscutil/misc_utils.h b/contrib/miscutil/misc_utils.h index cc7f923443..e82fd4a29d 100644 --- a/contrib/miscutil/misc_utils.h +++ b/contrib/miscutil/misc_utils.h @@ -7,16 +7,18 @@ int unlisten(char *relname); int max(int x, int y); int min(int x, int y); int assert_enable(int val); + #ifdef ASSERT_CHECKING_TEST int assert_test(int val); + #endif #endif /* * Local variables: - * tab-width: 4 - * c-indent-level: 4 - * c-basic-offset: 4 + * tab-width: 4 + * c-indent-level: 4 + * c-basic-offset: 4 * End: */ diff --git a/contrib/noupdate/noup.c b/contrib/noupdate/noup.c index efbe031239..ecbbd3d5ed 100644 --- a/contrib/noupdate/noup.c +++ b/contrib/noupdate/noup.c @@ -12,7 +12,7 @@ HeapTuple noup(void); * noup () -- revoke permission on column * * Though it's called without args You have to specify referenced - * table/column while creating trigger: + * table/column while creating trigger: * EXECUTE PROCEDURE noup ('col'). */ @@ -98,8 +98,8 @@ noup() */ if (!isnull) { - - elog(WARN, "%s: update not allowed", args[i] ); + + elog(WARN, "%s: update not allowed", args[i]); SPI_finish(); return NULL; } diff --git a/contrib/os2client/c.h b/contrib/os2client/c.h index 5fbc5ae22e..8c7ed3fe2a 100644 --- a/contrib/os2client/c.h +++ b/contrib/os2client/c.h @@ -1,5 +1,5 @@ -#undef PORTNAME -#define PORTNAME OS2 +#undef PORTNAME +#define PORTNAME OS2 /*------------------------------------------------------------------------- * * c.h-- @@ -9,7 +9,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: c.h,v 1.1 1998/10/31 04:10:53 scrappy Exp $ + * $Id: c.h,v 1.2 1999/05/25 16:06:01 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -65,7 +65,8 @@ #ifndef __cplusplus #ifndef bool typedef char bool; -#endif /* ndef bool */ + +#endif /* ndef bool */ #endif /* not C++ */ typedef bool *BoolPtr; diff --git a/contrib/os2client/config.h b/contrib/os2client/config.h index d09a59630a..872b34a656 100644 --- a/contrib/os2client/config.h +++ b/contrib/os2client/config.h @@ -1,17 +1,17 @@ #ifndef TCPIPV4 -# define TCPIPV4 -#endif +#define TCPIPV4 +#endif /* */ #ifndef MAXSOCKETS #define MAXSOCKETS 2048 -#endif +#endif /* */ -/* - * 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) - */ +/* + * 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) + */ #define DEF_PGPORT "5432" diff --git a/contrib/pginterface/pginterface.c b/contrib/pginterface/pginterface.c index 42e4a3c47c..1da61aae49 100644 --- a/contrib/pginterface/pginterface.c +++ b/contrib/pginterface/pginterface.c @@ -206,28 +206,30 @@ on_error_continue() ** get_result ** */ -PGresult *get_result() +PGresult * +get_result() { - char *cmdstatus = PQcmdStatus(res); - + char *cmdstatus = PQcmdStatus(res); + was_get_unset_result = TRUE; /* we have to store the fetch location somewhere */ cmdstatus[0] = NUL; - memcpy(&cmdstatus[1],&tuple, sizeof(tuple)); + memcpy(&cmdstatus[1], &tuple, sizeof(tuple)); return res; } - + /* ** ** set_result ** */ -void set_result(PGresult *newres) +void +set_result(PGresult *newres) { - char *cmdstatus = PQcmdStatus(res); + char *cmdstatus = PQcmdStatus(res); if (newres == NULL) halt("set_result called with null result pointer\n"); @@ -256,9 +258,10 @@ void set_result(PGresult *newres) ** unset_result ** */ -void unset_result(PGresult *oldres) +void +unset_result(PGresult *oldres) { - char *cmdstatus = PQcmdStatus(oldres); + char *cmdstatus = PQcmdStatus(oldres); if (oldres == NULL) halt("unset_result called with null result pointer\n"); @@ -277,8 +280,8 @@ void unset_result(PGresult *oldres) ** reset_fetch ** */ -void reset_fetch() +void +reset_fetch() { tuple = 0; } - diff --git a/contrib/pginterface/pginterface.h b/contrib/pginterface/pginterface.h index 5f856ac016..11253acebc 100644 --- a/contrib/pginterface/pginterface.h +++ b/contrib/pginterface/pginterface.h @@ -11,8 +11,8 @@ int fetchwithnulls(void *param,...); void on_error_continue(); void on_error_stop(); PGresult *get_result(); -void set_result(PGresult *newres); -void unset_result(PGresult *oldres); -void reset_fetch(); +void set_result(PGresult *newres); +void unset_result(PGresult *oldres); +void reset_fetch(); #define END_OF_TUPLES (-1) diff --git a/contrib/spi/moddatetime.c b/contrib/spi/moddatetime.c index a6ef3b2795..39c3ddf0f2 100644 --- a/contrib/spi/moddatetime.c +++ b/contrib/spi/moddatetime.c @@ -7,7 +7,7 @@ a modification datetime stamp in a record when that record is UPDATEd. Credits This is 95%+ based on autoinc.c, which I used as a starting point as I do -not really know what I am doing. I also had help from +not really know what I am doing. I also had help from Jan Wieck who told me about the datetime_in("now") function. OH, me, I'm Terry Mackintosh */ @@ -17,17 +17,18 @@ OH, me, I'm Terry Mackintosh HeapTuple moddatetime(void); -HeapTuple moddatetime() +HeapTuple +moddatetime() { - Trigger *trigger; /* to get trigger name */ + Trigger *trigger; /* to get trigger name */ int nargs; /* # of arguments */ int attnum; /* positional number of field to change */ - Datum newdt; /* The current datetime. */ - char **args; /* arguments */ - char *relname; /* triggered relation name */ - Relation rel; /* triggered relation */ + Datum newdt; /* The current datetime. */ + char **args; /* arguments */ + char *relname; /* triggered relation name */ + Relation rel; /* triggered relation */ HeapTuple rettuple = NULL; - TupleDesc tupdesc; /* tuple description */ + TupleDesc tupdesc; /* tuple description */ if (!CurrentTriggerData) elog(ERROR, "moddatetime: triggers are not initialized."); @@ -65,28 +66,31 @@ HeapTuple moddatetime() /* Get the current datetime. */ newdt = datetime_in("now"); - /* This gets the position in the turple of the field we want. - args[0] being the name of the field to update, as passed in - from the trigger. - */ + /* + * This gets the position in the turple of the field we want. args[0] + * being the name of the field to update, as passed in from the + * trigger. + */ attnum = SPI_fnumber(tupdesc, args[0]); - /* This is were we check to see if the feild we are suppost to update even - exits. The above function must return -1 if name not found? - */ + /* + * This is were we check to see if the feild we are suppost to update + * even exits. The above function must return -1 if name not found? + */ if (attnum < 0) elog(ERROR, "moddatetime (%s): there is no attribute %s", relname, - args[0]); - - /* OK, this is where we make sure the datetime field that we are - modifying is really a datetime field. - Hay, error checking, what a novel idea !-) - */ - if (SPI_gettypeid(tupdesc, attnum) != DATETIMEOID ) + args[0]); + + /* + * OK, this is where we make sure the datetime field that we are + * modifying is really a datetime field. Hay, error checking, what a + * novel idea !-) + */ + if (SPI_gettypeid(tupdesc, attnum) != DATETIMEOID) elog(ERROR, "moddatetime (%s): attribute %s must be of DATETIME type", relname, args[0]); -/* 1 is the number of items in the arrays attnum and newdt. +/* 1 is the number of items in the arrays attnum and newdt. attnum is the positional number of the field to be updated. newdt is the new datetime stamp. NOTE that attnum and newdt are not arrays, but then a 1 ellement array diff --git a/contrib/spi/preprocessor/step1.c b/contrib/spi/preprocessor/step1.c index 9d59c47edd..1f2c5380d5 100644 --- a/contrib/spi/preprocessor/step1.c +++ b/contrib/spi/preprocessor/step1.c @@ -1,24 +1,27 @@ #include -char *strtoupper(char *string) +char * +strtoupper(char *string) { - int i ; - for (i=0;itg_event)) - { + { newtuple = CurrentTriggerData->tg_newtuple; - is_update=1; - } + is_update = 1; + } trigger = CurrentTriggerData->tg_trigger; nargs = trigger->tgnargs; args = trigger->tgargs; @@ -288,7 +290,7 @@ check_foreign_key() if (nargs < 5) /* nrefs, action, key, Relation, key - at * least */ elog(ERROR, "check_foreign_key: too short %d (< 5) list of arguments", nargs); - + nrefs = pg_atoi(args[0], sizeof(int), 0); if (nrefs < 1) elog(ERROR, "check_foreign_key: %d (< 1) number of references specified", nrefs); @@ -386,7 +388,7 @@ check_foreign_key() if (plan->nplans <= 0) /* Get typeId of column */ argtypes[i] = SPI_gettypeid(tupdesc, fnumber); } - args_temp = args; + args_temp = args; nargs -= nkeys; args += nkeys; @@ -397,13 +399,14 @@ check_foreign_key() { void *pplan; char sql[8192]; - char **args2 = args ; + char **args2 = args; plan->splan = (void **) malloc(nrefs * sizeof(void *)); for (r = 0; r < nrefs; r++) { relname = args2[0]; + /* * For 'R'estrict action we construct SELECT query - SELECT 1 * FROM _referencing_relation_ WHERE Fkey1 = $1 [AND Fkey2 = @@ -417,50 +420,59 @@ check_foreign_key() * For 'C'ascade action we construct DELETE query - DELETE * FROM _referencing_relation_ WHERE Fkey1 = $1 [AND Fkey2 = * $2 [...]] - to delete all referencing tuples. - */ - /*Max : Cascade with UPDATE query i create update query that - updates new key values in referenced tables - */ - - - else if (action == 'c'){ - if (is_update == 1) - { - int fn; - char *nv; - int k ; - sprintf(sql, "update %s set ", relname); - for (k = 1; k <= nkeys; k++) + */ + + /* + * Max : Cascade with UPDATE query i create update query that + * updates new key values in referenced tables + */ + + + else if (action == 'c') + { + if (is_update == 1) { - int is_char_type =0; - char *type; - - fn = SPI_fnumber(tupdesc, args_temp[k-1]); - nv = SPI_getvalue(newtuple, tupdesc, fn); - type=SPI_gettype(tupdesc,fn); - - if ( (strcmp(type,"text") && strcmp (type,"varchar") && - strcmp(type,"char") && strcmp (type,"bpchar") && - strcmp(type,"date") && strcmp (type,"datetime")) == 0 ) - is_char_type=1; -#ifdef DEBUG_QUERY - elog(NOTICE,"Check_foreign_key Debug value %s type %s %d", - nv,type,is_char_type); + int fn; + char *nv; + int k; + + sprintf(sql, "update %s set ", relname); + for (k = 1; k <= nkeys; k++) + { + int is_char_type = 0; + char *type; + + fn = SPI_fnumber(tupdesc, args_temp[k - 1]); + nv = SPI_getvalue(newtuple, tupdesc, fn); + type = SPI_gettype(tupdesc, fn); + + if ((strcmp(type, "text") && strcmp(type, "varchar") && + strcmp(type, "char") && strcmp(type, "bpchar") && + strcmp(type, "date") && strcmp(type, "datetime")) == 0) + is_char_type = 1; +#ifdef DEBUG_QUERY + elog(NOTICE, "Check_foreign_key Debug value %s type %s %d", + nv, type, is_char_type); #endif - /* is_char_type =1 i set ' ' for define a new value - */ - sprintf(sql + strlen(sql), " %s = %s%s%s %s ", - args2[k], (is_char_type>0) ? "'" :"" , - nv, (is_char_type >0) ? "'" :"",(k < nkeys) ? ", " : ""); - is_char_type=0; + + /* + * is_char_type =1 i set ' ' for define a new + * value + */ + sprintf(sql + strlen(sql), " %s = %s%s%s %s ", + args2[k], (is_char_type > 0) ? "'" : "", + nv, (is_char_type > 0) ? "'" : "", (k < nkeys) ? ", " : ""); + is_char_type = 0; + } + strcat(sql, " where "); + } - strcat(sql, " where "); - - } - else /* DELETE */ - sprintf(sql, "delete from %s where ", relname); - - } + else +/* DELETE */ + sprintf(sql, "delete from %s where ", relname); + + } + /* * For 'S'etnull action we construct UPDATE query - UPDATE * _referencing_relation_ SET Fkey1 null [, Fkey2 null [...]] @@ -500,15 +512,15 @@ check_foreign_key() elog(ERROR, "check_foreign_key: SPI_saveplan returned %d", SPI_result); plan->splan[r] = pplan; - + args2 += nkeys + 1; /* to the next relation */ } plan->nplans = nrefs; -#ifdef DEBUG_QUERY - elog(NOTICE,"Check_foreign_key Debug Query is : %s ", sql); +#ifdef DEBUG_QUERY + elog(NOTICE, "Check_foreign_key Debug Query is : %s ", sql); #endif } - + /* * If UPDATE and key is not changed ... */ diff --git a/contrib/string/string_io.c b/contrib/string/string_io.c index 03b7169a54..a83203887c 100644 --- a/contrib/string/string_io.c +++ b/contrib/string/string_io.c @@ -352,14 +352,15 @@ c_charin(char *str) { return (string_input(str, 1, 0, NULL)); } + #endif /* end of file */ /* * Local variables: - * tab-width: 4 - * c-indent-level: 4 - * c-basic-offset: 4 + * tab-width: 4 + * c-indent-level: 4 + * c-basic-offset: 4 * End: */ diff --git a/contrib/string/string_io.h b/contrib/string/string_io.h index 1ac0f2fb16..b4a900bbb9 100644 --- a/contrib/string/string_io.h +++ b/contrib/string/string_io.h @@ -14,14 +14,15 @@ char *c_varcharout(char *s); #if 0 struct varlena *c_textin(char *str); char *c_char16in(char *str); + #endif #endif /* * Local variables: - * tab-width: 4 - * c-indent-level: 4 - * c-basic-offset: 4 + * tab-width: 4 + * c-indent-level: 4 + * c-basic-offset: 4 * End: */ diff --git a/contrib/userlock/user_locks.c b/contrib/userlock/user_locks.c index 745f28d5bc..c3a6e8676b 100644 --- a/contrib/userlock/user_locks.c +++ b/contrib/userlock/user_locks.c @@ -29,7 +29,7 @@ user_lock(unsigned int id1, unsigned int id2, LOCKMODE lockmode) LOCKTAG tag; memset(&tag, 0, sizeof(LOCKTAG)); - tag.dbId = MyDatabaseId; + tag.dbId = MyDatabaseId; tag.relId = 0; tag.tupleId.ip_blkid.bi_hi = id2 >> 16; tag.tupleId.ip_blkid.bi_lo = id2 & 0xffff; @@ -44,7 +44,7 @@ user_unlock(unsigned int id1, unsigned int id2, LOCKMODE lockmode) LOCKTAG tag; memset(&tag, 0, sizeof(LOCKTAG)); - tag.dbId = MyDatabaseId; + tag.dbId = MyDatabaseId; tag.relId = 0; tag.tupleId.ip_blkid.bi_hi = id2 >> 16; tag.tupleId.ip_blkid.bi_lo = id2 & 0xffff; @@ -99,8 +99,8 @@ user_unlock_all() /* * Local variables: - * tab-width: 4 - * c-indent-level: 4 - * c-basic-offset: 4 + * tab-width: 4 + * c-indent-level: 4 + * c-basic-offset: 4 * End: */ diff --git a/contrib/userlock/user_locks.h b/contrib/userlock/user_locks.h index 0a8f55cbdd..ae77839f37 100644 --- a/contrib/userlock/user_locks.h +++ b/contrib/userlock/user_locks.h @@ -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: */ diff --git a/contrib/vacuumlo/vacuumlo.c b/contrib/vacuumlo/vacuumlo.c index 8b893f26e2..b954c4d9b5 100644 --- a/contrib/vacuumlo/vacuumlo.c +++ b/contrib/vacuumlo/vacuumlo.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/contrib/vacuumlo/vacuumlo.c,v 1.1 1999/04/10 16:48:05 peter Exp $ + * $Header: /cvsroot/pgsql/contrib/vacuumlo/vacuumlo.c,v 1.2 1999/05/25 16:06:31 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -25,177 +25,187 @@ #define BUFSIZE 1024 -int vacuumlo(char *,int); +int vacuumlo(char *, int); /* * This vacuums a database. It returns 1 on success, -1 on failure. */ -int vacuumlo(char *database,int verbose) +int +vacuumlo(char *database, int verbose) { - PGconn *conn; - PGresult *res, *res2; - char buf[BUFSIZE]; - int matched=0; /* Number matched per scan */ - int i; - - conn = PQsetdb(NULL, NULL, NULL, NULL, database); - - /* check to see that the backend connection was successfully made */ - if (PQstatus(conn) == CONNECTION_BAD) - { - fprintf(stderr, "Connection to database '%s' failed.\n", database); - fprintf(stderr, "%s", PQerrorMessage(conn)); - return -1; - } - - if(verbose) - fprintf(stdout,"Connected to %s\n",database); - - /* - * First we create and populate the lo temp table - */ - buf[0]='\0'; - strcat(buf,"SELECT oid AS lo "); - strcat(buf,"INTO TEMP TABLE vacuum_l "); - strcat(buf,"FROM pg_class "); - strcat(buf,"WHERE relkind='l'"); - if(!(res = PQexec(conn,buf))) { - fprintf(stderr,"Failed to create temp table.\n"); - PQfinish(conn); - return -1; - } - PQclear(res); - - /* - * Now find any candidate tables who have columns of type oid (the column - * oid is ignored, as it has attnum < 1) - */ - buf[0]='\0'; - strcat(buf,"SELECT c.relname, a.attname "); - strcat(buf,"FROM pg_class c, pg_attribute a, pg_type t "); - strcat(buf,"WHERE a.attnum > 0 "); - strcat(buf," AND a.attrelid = c.oid "); - strcat(buf," AND a.atttypid = t.oid "); - strcat(buf," AND t.typname = 'oid' "); - strcat(buf," AND c.relname NOT LIKE 'pg_%'"); - if(!(res = PQexec(conn,buf))) { - fprintf(stderr,"Failed to create temp table.\n"); - PQfinish(conn); - return -1; - } - for(i=0;i 0 "); + strcat(buf, " AND a.attrelid = c.oid "); + strcat(buf, " AND a.atttypid = t.oid "); + strcat(buf, " AND t.typname = 'oid' "); + strcat(buf, " AND c.relname NOT LIKE 'pg_%'"); + if (!(res = PQexec(conn, buf))) + { + fprintf(stderr, "Failed to create temp table.\n"); + PQfinish(conn); + return -1; + } + for (i = 0; i < PQntuples(res); i++) + { + char *table, + *field; + + table = PQgetvalue(res, i, 0); + field = PQgetvalue(res, i, 1); + + if (verbose) + { + fprintf(stdout, "Checking %s in %s: ", field, table); + fflush(stdout); + } + + res2 = PQexec(conn, "begin"); + PQclear(res2); + + buf[0] = '\0'; + strcat(buf, "DELETE FROM vacuum_l "); + strcat(buf, "WHERE lo IN ("); + strcat(buf, "SELECT "); + strcat(buf, field); + strcat(buf, " FROM "); + strcat(buf, table); + strcat(buf, ");"); + if (!(res2 = PQexec(conn, buf))) + { + fprintf(stderr, "Failed to check %s in table %s\n", field, table); + PQclear(res); + PQfinish(conn); + return -1; + } + if (PQresultStatus(res2) != PGRES_COMMAND_OK) + { + fprintf(stderr, + "Failed to check %s in table %s\n%s\n", + field, table, + PQerrorMessage(conn) + ); + PQclear(res2); + PQclear(res); + PQfinish(conn); + return -1; + } + PQclear(res2); + + res2 = PQexec(conn, "end"); + PQclear(res2); + + } + PQclear(res); + + /* Start the transaction */ + res = PQexec(conn, "begin"); + PQclear(res); + + /* + * Finally, those entries remaining in vacuum_l are orphans. + */ + buf[0] = '\0'; + strcat(buf, "SELECT lo "); + strcat(buf, "FROM vacuum_l"); + if (!(res = PQexec(conn, buf))) + { + fprintf(stderr, "Failed to read temp table.\n"); + PQfinish(conn); + return -1; + } + matched = PQntuples(res); + for (i = 0; i < matched; i++) + { + Oid lo = (Oid) atoi(PQgetvalue(res, i, 0)); + + if (verbose) + { + fprintf(stdout, "\rRemoving lo %6d \n", lo); + fflush(stdout); + } + + if (lo_unlink(conn, lo) < 0) + fprintf(stderr, "Failed to remove lo %d\n", lo); + } + PQclear(res); + + /* + * That's all folks! + */ + res = PQexec(conn, "end"); + PQclear(res); + PQfinish(conn); + + if (verbose) + fprintf(stdout, "\rRemoved %d large objects from %s.\n", matched, database); + + return 0; } int main(int argc, char **argv) { - int verbose = 0; - int arg; - int rc=0; - - if (argc < 2) + int verbose = 0; + int arg; + int rc = 0; + + if (argc < 2) { - fprintf(stderr, "Usage: %s [-v] database_name [db2 ... dbn]\n", - argv[0]); - exit(1); + fprintf(stderr, "Usage: %s [-v] database_name [db2 ... dbn]\n", + argv[0]); + exit(1); } - - for(arg=1;argattlen, att[i]->attalign); + data = (char *) att_align((long) data, att[i]->attlen, att[i]->attalign); switch (att[i]->attlen) { case -1: @@ -151,7 +151,7 @@ DataFill(char *data, att[i]->attlen); break; } - data = (char *)att_addlength((long)data, att[i]->attlen, value[i]); + data = (char *) att_addlength((long) data, att[i]->attlen, value[i]); } } @@ -210,7 +210,7 @@ heap_attisnull(HeapTuple tup, int attnum) int heap_sysattrlen(AttrNumber attno) { - HeapTupleHeader f = NULL; + HeapTupleHeader f = NULL; switch (attno) { @@ -301,6 +301,7 @@ heap_getsysattr(HeapTuple tup, Buffer b, int attnum) } return (Datum) NULL; } + #endif /* ---------------- @@ -328,11 +329,11 @@ nocachegetattr(HeapTuple tuple, TupleDesc tupleDesc, bool *isnull) { - char *tp; /* ptr to att in tuple */ - HeapTupleHeader tup = tuple->t_data; - bits8 *bp = tup->t_bits; /* ptr to att in tuple */ - Form_pg_attribute *att = tupleDesc->attrs; - int slow = 0; /* do we have to walk nulls? */ + char *tp; /* ptr to att in tuple */ + HeapTupleHeader tup = tuple->t_data; + bits8 *bp = tup->t_bits; /* ptr to att in tuple */ + Form_pg_attribute *att = tupleDesc->attrs; + int slow = 0; /* do we have to walk nulls? */ #if IN_MACRO @@ -376,6 +377,7 @@ nocachegetattr(HeapTuple tuple, } else { + /* * there's a null somewhere in the tuple */ @@ -404,12 +406,13 @@ nocachegetattr(HeapTuple tuple, int finalbit = attnum & 0x07; /* check for nulls "before" final bit of last byte */ - if ((~ bp[byte]) & ((1 << finalbit) - 1)) + if ((~bp[byte]) & ((1 << finalbit) - 1)) slow = 1; else { /* check for nulls in any "earlier" bytes */ - int i; + int i; + for (i = 0; i < byte; i++) { if (bp[i] != 0xFF) @@ -439,6 +442,7 @@ nocachegetattr(HeapTuple tuple, else if (!HeapTupleAllFixed(tuple)) { int j; + /* * In for(), we make this <= and not < because we want to test * if we can go past it in initializing offsets. @@ -456,9 +460,9 @@ nocachegetattr(HeapTuple tuple, /* * If slow is zero, and we got here, we know that we have a tuple with - * no nulls or varlenas before the target attribute. - * If possible, we also want to initialize the remainder of the - * attribute cached offset values. + * no nulls or varlenas before the target attribute. If possible, we + * also want to initialize the remainder of the attribute cached + * offset values. */ if (!slow) { @@ -570,7 +574,7 @@ heap_copytuple(HeapTuple tuple) newTuple->t_len = tuple->t_len; newTuple->t_self = tuple->t_self; newTuple->t_data = (HeapTupleHeader) ((char *) newTuple + HEAPTUPLESIZE); - memmove((char *) newTuple->t_data, + memmove((char *) newTuple->t_data, (char *) tuple->t_data, (int) tuple->t_len); return newTuple; } @@ -589,11 +593,11 @@ heap_copytuple_with_tuple(HeapTuple src, HeapTuple dest) dest->t_data = NULL; return; } - + dest->t_len = src->t_len; dest->t_self = src->t_self; dest->t_data = (HeapTupleHeader) palloc(src->t_len); - memmove((char *) dest->t_data, + memmove((char *) dest->t_data, (char *) src->t_data, (int) src->t_len); return; } @@ -657,14 +661,14 @@ heap_formtuple(TupleDesc tupleDescriptor, Datum *value, char *nulls) { - HeapTuple tuple; /* return tuple */ - HeapTupleHeader td; /* tuple data */ - int bitmaplen; - long len; - int hoff; - bool hasnull = false; - int i; - int numberOfAttributes = tupleDescriptor->natts; + HeapTuple tuple; /* return tuple */ + HeapTupleHeader td; /* tuple data */ + int bitmaplen; + long len; + int hoff; + bool hasnull = false; + int i; + int numberOfAttributes = tupleDescriptor->natts; len = offsetof(HeapTupleHeaderData, t_bits); @@ -760,9 +764,9 @@ heap_modifytuple(HeapTuple tuple, if (repl[attoff] == ' ') { value[attoff] = heap_getattr(tuple, - AttrOffsetGetAttrNumber(attoff), - RelationGetDescr(relation), - &isNull); + AttrOffsetGetAttrNumber(attoff), + RelationGetDescr(relation), + &isNull); nulls[attoff] = (isNull) ? 'n' : ' '; } @@ -790,12 +794,12 @@ heap_modifytuple(HeapTuple tuple, infomask = newTuple->t_data->t_infomask; memmove((char *) &newTuple->t_data->t_oid, /* XXX */ (char *) &tuple->t_data->t_oid, - ((char *) &tuple->t_data->t_hoff - - (char *) &tuple->t_data->t_oid)); /* XXX */ + ((char *) &tuple->t_data->t_hoff - + (char *) &tuple->t_data->t_oid)); /* XXX */ newTuple->t_data->t_infomask = infomask; newTuple->t_data->t_natts = numberOfAttributes; newTuple->t_self = tuple->t_self; - + return newTuple; } @@ -809,10 +813,10 @@ heap_addheader(uint32 natts, /* max domain index */ int structlen, /* its length */ char *structure) /* pointer to the struct */ { - HeapTuple tuple; - HeapTupleHeader td; /* tuple data */ - long len; - int hoff; + HeapTuple tuple; + HeapTupleHeader td; /* tuple data */ + long len; + int hoff; AssertArg(natts > 0); diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 7615c79a74..0a2eee932f 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.45 1999/05/10 00:44:50 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.46 1999/05/25 16:06:39 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -25,9 +25,9 @@ #include "libpq/pqformat.h" #include "utils/syscache.h" -static void printtup_setup(DestReceiver* self, TupleDesc typeinfo); -static void printtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver* self); -static void printtup_cleanup(DestReceiver* self); +static void printtup_setup(DestReceiver * self, TupleDesc typeinfo); +static void printtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver * self); +static void printtup_cleanup(DestReceiver * self); /* ---------------------------------------------------------------- * printtup / debugtup support @@ -43,7 +43,7 @@ static void printtup_cleanup(DestReceiver* self); * ---------------- */ int -getTypeOutAndElem(Oid type, Oid* typOutput, Oid* typElem) +getTypeOutAndElem(Oid type, Oid *typOutput, Oid *typElem) { HeapTuple typeTuple; @@ -54,6 +54,7 @@ getTypeOutAndElem(Oid type, Oid* typOutput, Oid* typElem) if (HeapTupleIsValid(typeTuple)) { Form_pg_type pt = (Form_pg_type) GETSTRUCT(typeTuple); + *typOutput = (Oid) pt->typoutput; *typElem = (Oid) pt->typelem; return OidIsValid(*typOutput); @@ -70,27 +71,29 @@ getTypeOutAndElem(Oid type, Oid* typOutput, Oid* typElem) * Private state for a printtup destination object * ---------------- */ -typedef struct { /* Per-attribute information */ +typedef struct +{ /* Per-attribute information */ Oid typoutput; /* Oid for the attribute's type output fn */ Oid typelem; /* typelem value to pass to the output fn */ FmgrInfo finfo; /* Precomputed call info for typoutput */ -} PrinttupAttrInfo; +} PrinttupAttrInfo; -typedef struct { - DestReceiver pub; /* publicly-known function pointers */ - TupleDesc attrinfo; /* The attr info we are set up for */ - int nattrs; - PrinttupAttrInfo *myinfo; /* Cached info about each attr */ -} DR_printtup; +typedef struct +{ + DestReceiver pub; /* publicly-known function pointers */ + TupleDesc attrinfo; /* The attr info we are set up for */ + int nattrs; + PrinttupAttrInfo *myinfo; /* Cached info about each attr */ +} DR_printtup; /* ---------------- * Initialize: create a DestReceiver for printtup * ---------------- */ -DestReceiver* +DestReceiver * printtup_create_DR() { - DR_printtup* self = (DR_printtup*) palloc(sizeof(DR_printtup)); + DR_printtup *self = (DR_printtup *) palloc(sizeof(DR_printtup)); self->pub.receiveTuple = printtup; self->pub.setup = printtup_setup; @@ -100,42 +103,43 @@ printtup_create_DR() self->nattrs = 0; self->myinfo = NULL; - return (DestReceiver*) self; + return (DestReceiver *) self; } static void -printtup_setup(DestReceiver* self, TupleDesc typeinfo) +printtup_setup(DestReceiver * self, TupleDesc typeinfo) { /* ---------------- * We could set up the derived attr info at this time, but we postpone it * until the first call of printtup, for 3 reasons: * 1. We don't waste time (compared to the old way) if there are no - * tuples at all to output. + * tuples at all to output. * 2. Checking in printtup allows us to handle the case that the tuples - * change type midway through (although this probably can't happen in - * the current executor). + * change type midway through (although this probably can't happen in + * the current executor). * 3. Right now, ExecutorRun passes a NULL for typeinfo anyway :-( * ---------------- */ } static void -printtup_prepare_info(DR_printtup* myState, TupleDesc typeinfo, int numAttrs) +printtup_prepare_info(DR_printtup * myState, TupleDesc typeinfo, int numAttrs) { - int i; + int i; if (myState->myinfo) - pfree(myState->myinfo); /* get rid of any old data */ + pfree(myState->myinfo); /* get rid of any old data */ myState->myinfo = NULL; myState->attrinfo = typeinfo; myState->nattrs = numAttrs; if (numAttrs <= 0) return; - myState->myinfo = (PrinttupAttrInfo*) + myState->myinfo = (PrinttupAttrInfo *) palloc(numAttrs * sizeof(PrinttupAttrInfo)); for (i = 0; i < numAttrs; i++) { - PrinttupAttrInfo* thisState = myState->myinfo + i; + PrinttupAttrInfo *thisState = myState->myinfo + i; + if (getTypeOutAndElem((Oid) typeinfo->attrs[i]->atttypid, &thisState->typoutput, &thisState->typelem)) fmgr_info(thisState->typoutput, &thisState->finfo); @@ -147,9 +151,9 @@ printtup_prepare_info(DR_printtup* myState, TupleDesc typeinfo, int numAttrs) * ---------------- */ static void -printtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver* self) +printtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver * self) { - DR_printtup *myState = (DR_printtup*) self; + DR_printtup *myState = (DR_printtup *) self; StringInfoData buf; int i, j, @@ -178,7 +182,7 @@ printtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver* self) k = 1 << 7; for (i = 0; i < tuple->t_data->t_natts; ++i) { - if (! heap_attisnull(tuple, i + 1)) + if (!heap_attisnull(tuple, i + 1)) j |= k; /* set bit if not null */ k >>= 1; if (k == 0) /* end of byte? */ @@ -197,7 +201,8 @@ printtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver* self) */ for (i = 0; i < tuple->t_data->t_natts; ++i) { - PrinttupAttrInfo* thisState = myState->myinfo + i; + PrinttupAttrInfo *thisState = myState->myinfo + i; + attr = heap_getattr(tuple, i + 1, typeinfo, &isnull); if (isnull) continue; @@ -223,9 +228,10 @@ printtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver* self) * ---------------- */ static void -printtup_cleanup(DestReceiver* self) +printtup_cleanup(DestReceiver * self) { - DR_printtup* myState = (DR_printtup*) self; + DR_printtup *myState = (DR_printtup *) self; + if (myState->myinfo) pfree(myState->myinfo); pfree(myState); @@ -274,7 +280,7 @@ showatts(char *name, TupleDesc tupleDesc) * ---------------- */ void -debugtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver* self) +debugtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver * self) { int i; Datum attr; @@ -310,7 +316,7 @@ debugtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver* self) * ---------------- */ void -printtup_internal(HeapTuple tuple, TupleDesc typeinfo, DestReceiver* self) +printtup_internal(HeapTuple tuple, TupleDesc typeinfo, DestReceiver * self) { StringInfoData buf; int i, @@ -334,7 +340,7 @@ printtup_internal(HeapTuple tuple, TupleDesc typeinfo, DestReceiver* self) k = 1 << 7; for (i = 0; i < tuple->t_data->t_natts; ++i) { - if (! heap_attisnull(tuple, i + 1)) + if (!heap_attisnull(tuple, i + 1)) j |= k; /* set bit if not null */ k >>= 1; if (k == 0) /* end of byte? */ diff --git a/src/backend/access/common/scankey.c b/src/backend/access/common/scankey.c index bd3e047e6a..7dd9b6a920 100644 --- a/src/backend/access/common/scankey.c +++ b/src/backend/access/common/scankey.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/common/scankey.c,v 1.13 1999/02/13 23:14:13 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/common/scankey.c,v 1.14 1999/05/25 16:06:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -18,7 +18,7 @@ #include /* - * ScanKeyEntryIsLegal + * ScanKeyEntryIsLegal * True iff the scan key entry is legal. */ #define ScanKeyEntryIsLegal(entry) \ @@ -28,7 +28,7 @@ ) /* - * ScanKeyEntrySetIllegal + * ScanKeyEntrySetIllegal * Marks a scan key entry as illegal. */ void @@ -43,7 +43,7 @@ ScanKeyEntrySetIllegal(ScanKey entry) } /* - * ScanKeyEntryInitialize + * ScanKeyEntryInitialize * Initializes an scan key entry. * * Note: diff --git a/src/backend/access/common/tupdesc.c b/src/backend/access/common/tupdesc.c index 656b997404..71e8db45a4 100644 --- a/src/backend/access/common/tupdesc.c +++ b/src/backend/access/common/tupdesc.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.48 1999/02/13 23:14:14 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.49 1999/05/25 16:06:42 momjian Exp $ * * NOTES * some of the executor utility code such as "ExecTypeFromTL" should be @@ -487,7 +487,7 @@ BuildDescForRelation(List *schema, char *relname) { /* array of XXX is _XXX */ snprintf(typename, NAMEDATALEN, - "_%.*s", NAMEDATALEN - 2, entry->typename->name); + "_%.*s", NAMEDATALEN - 2, entry->typename->name); attdim = length(arry); } else diff --git a/src/backend/access/gist/gist.c b/src/backend/access/gist/gist.c index 1342bc6aec..06321990a8 100644 --- a/src/backend/access/gist/gist.c +++ b/src/backend/access/gist/gist.c @@ -344,7 +344,7 @@ gistinsert(Relation r, Datum *datum, char *nulls, ItemPointer ht_ctid, Relation /* * Notes in ExecUtils:ExecOpenIndices() * - RelationSetLockForWrite(r); + * RelationSetLockForWrite(r); */ res = gistdoinsert(r, itup, &giststate); @@ -1106,10 +1106,10 @@ gistdelete(Relation r, ItemPointer tid) Page page; /* - * Notes in ExecUtils:ExecOpenIndices() - * Also note that only vacuum deletes index tuples now... + * Notes in ExecUtils:ExecOpenIndices() Also note that only vacuum + * deletes index tuples now... * - RelationSetLockForWrite(r); + * RelationSetLockForWrite(r); */ blkno = ItemPointerGetBlockNumber(tid); diff --git a/src/backend/access/gist/gistscan.c b/src/backend/access/gist/gistscan.c index 92353d71b2..d26387d828 100644 --- a/src/backend/access/gist/gistscan.c +++ b/src/backend/access/gist/gistscan.c @@ -68,7 +68,7 @@ gistbeginscan(Relation r, /* * Let index_beginscan does its work... * - RelationSetLockForRead(r); + * RelationSetLockForRead(r); */ s = RelationGetIndexScan(r, fromEnd, nkeys, key); diff --git a/src/backend/access/hash/hash.c b/src/backend/access/hash/hash.c index 122c9ad379..65d04658c5 100644 --- a/src/backend/access/hash/hash.c +++ b/src/backend/access/hash/hash.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.25 1999/02/13 23:14:17 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.26 1999/05/25 16:06:54 momjian Exp $ * * NOTES * This file contains only the public interface routines. @@ -485,9 +485,9 @@ hashrestrpos(IndexScanDesc scan) /* bump lock on currentMarkData and copy to currentItemData */ if (ItemPointerIsValid(&(scan->currentMarkData))) { - so->hashso_curbuf =_hash_getbuf(scan->relation, - BufferGetBlockNumber(so->hashso_mrkbuf), - HASH_READ); + so->hashso_curbuf = _hash_getbuf(scan->relation, + BufferGetBlockNumber(so->hashso_mrkbuf), + HASH_READ); scan->currentItemData = scan->currentMarkData; } diff --git a/src/backend/access/hash/hashfunc.c b/src/backend/access/hash/hashfunc.c index c8be6dc60e..f5605a3f10 100644 --- a/src/backend/access/hash/hashfunc.c +++ b/src/backend/access/hash/hashfunc.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/hash/hashfunc.c,v 1.16 1999/03/14 16:27:59 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/hash/hashfunc.c,v 1.17 1999/05/25 16:06:56 momjian Exp $ * * NOTES * These functions are stored in pg_amproc. For each operator class @@ -34,9 +34,9 @@ hashint4(uint32 key) } uint32 -hashint8(int64 *key) +hashint8(int64 * key) { - return ~((uint32)*key); + return ~((uint32) *key); } /* Hash function from Chris Torek. */ diff --git a/src/backend/access/hash/hashpage.c b/src/backend/access/hash/hashpage.c index 7c81e7ab5c..bcda5f85e7 100644 --- a/src/backend/access/hash/hashpage.c +++ b/src/backend/access/hash/hashpage.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/hash/hashpage.c,v 1.19 1999/02/13 23:14:20 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/hash/hashpage.c,v 1.20 1999/05/25 16:06:58 momjian Exp $ * * NOTES * Postgres hash pages look like ordinary relation pages. The opaque @@ -321,7 +321,7 @@ _hash_setpagelock(Relation rel, { switch (access) { - case HASH_WRITE: + case HASH_WRITE: LockPage(rel, blkno, ExclusiveLock); break; case HASH_READ: @@ -345,7 +345,7 @@ _hash_unsetpagelock(Relation rel, { switch (access) { - case HASH_WRITE: + case HASH_WRITE: UnlockPage(rel, blkno, ExclusiveLock); break; case HASH_READ: diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c index 63fd52d124..1ea78ec863 100644 --- a/src/backend/access/heap/heapam.c +++ b/src/backend/access/heap/heapam.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.42 1999/03/28 20:31:56 vadim Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.43 1999/05/25 16:07:04 momjian Exp $ * * * INTERFACE ROUTINES @@ -117,7 +117,7 @@ initscan(HeapScanDesc scan, * relation is empty * ---------------- */ - scan->rs_ntup.t_data = scan->rs_ctup.t_data = + scan->rs_ntup.t_data = scan->rs_ctup.t_data = scan->rs_ptup.t_data = NULL; scan->rs_nbuf = scan->rs_cbuf = scan->rs_pbuf = InvalidBuffer; } @@ -216,15 +216,15 @@ heapgettup(Relation relation, int nkeys, ScanKey key) { - ItemId lpp; - Page dp; - int page; - int pages; - int lines; - OffsetNumber lineoff; - int linesleft; - ItemPointer tid = (tuple->t_data == NULL) ? - (ItemPointer) NULL : &(tuple->t_self); + ItemId lpp; + Page dp; + int page; + int pages; + int lines; + OffsetNumber lineoff; + int linesleft; + ItemPointer tid = (tuple->t_data == NULL) ? + (ItemPointer) NULL : &(tuple->t_self); /* ---------------- * increment access statistics @@ -290,8 +290,8 @@ heapgettup(Relation relation, return; } *buffer = RelationGetBufferWithBuffer(relation, - ItemPointerGetBlockNumber(tid), - *buffer); + ItemPointerGetBlockNumber(tid), + *buffer); if (!BufferIsValid(*buffer)) elog(ERROR, "heapgettup: failed ReadBuffer"); @@ -439,7 +439,8 @@ heapgettup(Relation relation, } else { - ++lpp; /* move forward in this page's ItemId array */ + ++lpp; /* move forward in this page's ItemId + * array */ ++lineoff; } } @@ -816,6 +817,7 @@ heap_getnext(HeapScanDesc scandesc, int backw) } else { /* NONTUP */ + /* * Don't release scan->rs_cbuf at this point, because * heapgettup doesn't increase PrivateRefCount if it is @@ -897,6 +899,7 @@ heap_getnext(HeapScanDesc scandesc, int backw) } else { /* NONTUP */ + /* * Don't release scan->rs_cbuf at this point, because * heapgettup doesn't increase PrivateRefCount if it is @@ -966,11 +969,11 @@ heap_fetch(Relation relation, HeapTuple tuple, Buffer *userbuf) { - ItemId lp; - Buffer buffer; - PageHeader dp; - ItemPointer tid = &(tuple->t_self); - OffsetNumber offnum; + ItemId lp; + Buffer buffer; + PageHeader dp; + ItemPointer tid = &(tuple->t_self); + OffsetNumber offnum; AssertMacro(PointerIsValid(userbuf)); /* see comments above */ @@ -1093,9 +1096,7 @@ heap_insert(Relation relation, HeapTuple tup) RelationPutHeapTupleAtEnd(relation, tup); if (IsSystemRelationName(RelationGetRelationName(relation)->data)) - { RelationInvalidateHeapTuple(relation, tup); - } return tup->t_data->t_oid; } @@ -1106,11 +1107,11 @@ heap_insert(Relation relation, HeapTuple tup) int heap_delete(Relation relation, ItemPointer tid, ItemPointer ctid) { - ItemId lp; - HeapTupleData tp; - PageHeader dp; - Buffer buffer; - int result; + ItemId lp; + HeapTupleData tp; + PageHeader dp; + Buffer buffer; + int result; /* increment access statistics */ IncrHeapAccessStat(local_delete); @@ -1130,10 +1131,10 @@ heap_delete(Relation relation, ItemPointer tid, ItemPointer ctid) tp.t_data = (HeapTupleHeader) PageGetItem((Page) dp, lp); tp.t_len = ItemIdGetLength(lp); tp.t_self = *tid; - + l1: result = HeapTupleSatisfiesUpdate(&tp); - + if (result == HeapTupleInvisible) { LockBuffer(buffer, BUFFER_LOCK_UNLOCK); @@ -1142,7 +1143,7 @@ l1: } else if (result == HeapTupleBeingUpdated) { - TransactionId xwait = tp.t_data->t_xmax; + TransactionId xwait = tp.t_data->t_xmax; /* sleep untill concurrent transaction ends */ LockBuffer(buffer, BUFFER_LOCK_UNLOCK); @@ -1177,8 +1178,8 @@ l1: /* store transaction information of xact deleting the tuple */ TransactionIdStore(GetCurrentTransactionId(), &(tp.t_data->t_xmax)); tp.t_data->t_cmax = GetCurrentCommandId(); - tp.t_data->t_infomask &= ~(HEAP_XMAX_COMMITTED | - HEAP_XMAX_INVALID | HEAP_MARKED_FOR_UPDATE); + tp.t_data->t_infomask &= ~(HEAP_XMAX_COMMITTED | + HEAP_XMAX_INVALID | HEAP_MARKED_FOR_UPDATE); LockBuffer(buffer, BUFFER_LOCK_UNLOCK); @@ -1194,14 +1195,14 @@ l1: * heap_replace - replace a tuple */ int -heap_replace(Relation relation, ItemPointer otid, HeapTuple newtup, - ItemPointer ctid) +heap_replace(Relation relation, ItemPointer otid, HeapTuple newtup, + ItemPointer ctid) { - ItemId lp; - HeapTupleData oldtup; - PageHeader dp; - Buffer buffer; - int result; + ItemId lp; + HeapTupleData oldtup; + PageHeader dp; + Buffer buffer; + int result; /* increment access statistics */ IncrHeapAccessStat(local_replace); @@ -1223,7 +1224,7 @@ heap_replace(Relation relation, ItemPointer otid, HeapTuple newtup, l2: result = HeapTupleSatisfiesUpdate(&oldtup); - + if (result == HeapTupleInvisible) { LockBuffer(buffer, BUFFER_LOCK_UNLOCK); @@ -1232,7 +1233,7 @@ l2: } else if (result == HeapTupleBeingUpdated) { - TransactionId xwait = oldtup.t_data->t_xmax; + TransactionId xwait = oldtup.t_data->t_xmax; /* sleep untill concurrent transaction ends */ LockBuffer(buffer, BUFFER_LOCK_UNLOCK); @@ -1275,19 +1276,20 @@ l2: /* logically delete old item */ TransactionIdStore(GetCurrentTransactionId(), &(oldtup.t_data->t_xmax)); oldtup.t_data->t_cmax = GetCurrentCommandId(); - oldtup.t_data->t_infomask &= ~(HEAP_XMAX_COMMITTED | - HEAP_XMAX_INVALID | HEAP_MARKED_FOR_UPDATE); + oldtup.t_data->t_infomask &= ~(HEAP_XMAX_COMMITTED | + HEAP_XMAX_INVALID | HEAP_MARKED_FOR_UPDATE); /* insert new item */ if ((unsigned) DOUBLEALIGN(newtup->t_len) <= PageGetFreeSpace((Page) dp)) RelationPutHeapTuple(relation, buffer, newtup); else { + /* - * New item won't fit on same page as old item, have to look - * for a new place to put it. Note that we have to unlock - * current buffer context - not good but RelationPutHeapTupleAtEnd - * uses extend lock. + * New item won't fit on same page as old item, have to look for a + * new place to put it. Note that we have to unlock current buffer + * context - not good but RelationPutHeapTupleAtEnd uses extend + * lock. */ LockBuffer(buffer, BUFFER_LOCK_UNLOCK); RelationPutHeapTupleAtEnd(relation, newtup); @@ -1295,8 +1297,8 @@ l2: } /* - * New item in place, now record address of new tuple in - * t_ctid of old one. + * New item in place, now record address of new tuple in t_ctid of old + * one. */ oldtup.t_data->t_ctid = newtup->t_self; @@ -1316,10 +1318,10 @@ l2: int heap_mark4update(Relation relation, HeapTuple tuple, Buffer *buffer) { - ItemPointer tid = &(tuple->t_self); - ItemId lp; - PageHeader dp; - int result; + ItemPointer tid = &(tuple->t_self); + ItemId lp; + PageHeader dp; + int result; /* increment access statistics */ IncrHeapAccessStat(local_mark4update); @@ -1336,10 +1338,10 @@ heap_mark4update(Relation relation, HeapTuple tuple, Buffer *buffer) lp = PageGetItemId(dp, ItemPointerGetOffsetNumber(tid)); tuple->t_data = (HeapTupleHeader) PageGetItem((Page) dp, lp); tuple->t_len = ItemIdGetLength(lp); - + l3: result = HeapTupleSatisfiesUpdate(tuple); - + if (result == HeapTupleInvisible) { LockBuffer(*buffer, BUFFER_LOCK_UNLOCK); @@ -1348,7 +1350,7 @@ l3: } else if (result == HeapTupleBeingUpdated) { - TransactionId xwait = tuple->t_data->t_xmax; + TransactionId xwait = tuple->t_data->t_xmax; /* sleep untill concurrent transaction ends */ LockBuffer(*buffer, BUFFER_LOCK_UNLOCK); diff --git a/src/backend/access/heap/hio.c b/src/backend/access/heap/hio.c index f991b206d4..682c072c19 100644 --- a/src/backend/access/heap/hio.c +++ b/src/backend/access/heap/hio.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Id: hio.c,v 1.19 1999/05/07 01:22:53 vadim Exp $ + * $Id: hio.c,v 1.20 1999/05/25 16:07:07 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -39,11 +39,11 @@ RelationPutHeapTuple(Relation relation, Buffer buffer, HeapTuple tuple) { - Page pageHeader; - OffsetNumber offnum; - unsigned int len; - ItemId itemId; - Item item; + Page pageHeader; + OffsetNumber offnum; + unsigned int len; + ItemId itemId; + Item item; /* ---------------- * increment access statistics @@ -62,13 +62,13 @@ RelationPutHeapTuple(Relation relation, itemId = PageGetItemId((Page) pageHeader, offnum); item = PageGetItem((Page) pageHeader, itemId); - ItemPointerSet(&((HeapTupleHeader) item)->t_ctid, - BufferGetBlockNumber(buffer), offnum); + ItemPointerSet(&((HeapTupleHeader) item)->t_ctid, + BufferGetBlockNumber(buffer), offnum); /* * Let the caller do this! * - WriteBuffer(buffer); + * WriteBuffer(buffer); */ /* return an accurate tuple */ @@ -111,8 +111,8 @@ RelationPutHeapTupleAtEnd(Relation relation, HeapTuple tuple) Item item; /* - * Lock relation for extention. We can use LockPage here as long as - * in all other places we use page-level locking for indices only. + * Lock relation for extention. We can use LockPage here as long as in + * all other places we use page-level locking for indices only. * Alternatevely, we could define pseudo-table as we do for * transactions with XactLockTable. */ @@ -132,6 +132,7 @@ RelationPutHeapTupleAtEnd(Relation relation, HeapTuple tuple) { buffer = ReadBuffer(relation, lastblock); pageHeader = (Page) BufferGetPage(buffer); + /* * There was IF instead of ASSERT here ?! */ diff --git a/src/backend/access/index/genam.c b/src/backend/access/index/genam.c index 5752f2cf44..70b9ae2a4b 100644 --- a/src/backend/access/index/genam.c +++ b/src/backend/access/index/genam.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/index/genam.c,v 1.16 1999/02/13 23:14:29 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/index/genam.c,v 1.17 1999/05/25 16:07:12 momjian Exp $ * * NOTES * many of the old access method routines have been turned into @@ -270,5 +270,5 @@ IndexScanRestorePosition(IndexScanDesc scan) scan->flags = 0x0; /* XXX should have a symbolic name */ } -#endif +#endif diff --git a/src/backend/access/index/istrat.c b/src/backend/access/index/istrat.c index e0b4e61a15..61cbe56065 100644 --- a/src/backend/access/index/istrat.c +++ b/src/backend/access/index/istrat.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/index/Attic/istrat.c,v 1.31 1999/02/13 23:14:30 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/index/Attic/istrat.c,v 1.32 1999/05/25 16:07:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -57,7 +57,7 @@ static bool StrategyTermIsValid(StrategyTerm term, */ /* - * StrategyMapGetScanKeyEntry + * StrategyMapGetScanKeyEntry * Returns a scan key entry of a index strategy mapping member. * * Note: @@ -75,7 +75,7 @@ StrategyMapGetScanKeyEntry(StrategyMap map, } /* - * IndexStrategyGetStrategyMap + * IndexStrategyGetStrategyMap * Returns an index strategy mapping of an index strategy. * * Note: @@ -97,7 +97,7 @@ IndexStrategyGetStrategyMap(IndexStrategy indexStrategy, } /* - * AttributeNumberGetIndexStrategySize + * AttributeNumberGetIndexStrategySize * Computes the size of an index strategy. */ Size @@ -294,8 +294,8 @@ RelationGetStrategy(Relation relation, Assert(RegProcedureIsValid(procedure)); strategyMap = IndexStrategyGetStrategyMap(RelationGetIndexStrategy(relation), - evaluation->maxStrategy, - attributeNumber); + evaluation->maxStrategy, + attributeNumber); /* get a strategy number for the procedure ignoring flags for now */ for (index = 0; index < evaluation->maxStrategy; index += 1) @@ -526,7 +526,7 @@ OperatorRelationFillScanKeyEntry(Relation operatorRelation, /* - * IndexSupportInitialize + * IndexSupportInitialize * Initializes an index strategy and associated support procedures. */ void diff --git a/src/backend/access/nbtree/nbtcompare.c b/src/backend/access/nbtree/nbtcompare.c index 127f2b0357..796087f812 100644 --- a/src/backend/access/nbtree/nbtcompare.c +++ b/src/backend/access/nbtree/nbtcompare.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtcompare.c,v 1.22 1999/03/14 05:08:56 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtcompare.c,v 1.23 1999/05/25 16:07:21 momjian Exp $ * * NOTES * These functions are stored in pg_amproc. For each operator class @@ -40,7 +40,7 @@ btint4cmp(int32 a, int32 b) } int32 -btint8cmp(int64 *a, int64 *b) +btint8cmp(int64 * a, int64 * b) { if (*a > *b) return 1; diff --git a/src/backend/access/nbtree/nbtinsert.c b/src/backend/access/nbtree/nbtinsert.c index 265a658363..3cc67661cd 100644 --- a/src/backend/access/nbtree/nbtinsert.c +++ b/src/backend/access/nbtree/nbtinsert.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.39 1999/05/01 16:09:45 vadim Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.40 1999/05/25 16:07:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -99,13 +99,13 @@ l1: /* key on the page before trying to compare it */ if (!PageIsEmpty(page) && offset <= maxoff) { - TupleDesc itupdesc; - BTItem cbti; - HeapTupleData htup; - BTPageOpaque opaque; - Buffer nbuf; - BlockNumber blkno; - bool chtup = true; + TupleDesc itupdesc; + BTItem cbti; + HeapTupleData htup; + BTPageOpaque opaque; + Buffer nbuf; + BlockNumber blkno; + bool chtup = true; itupdesc = RelationGetDescr(rel); nbuf = InvalidBuffer; @@ -122,15 +122,16 @@ l1: */ while (_bt_isequal(itupdesc, page, offset, natts, itup_scankey)) { /* they're equal */ + /* - * Have to check is inserted heap tuple deleted one - * (i.e. just moved to another place by vacuum)! + * Have to check is inserted heap tuple deleted one (i.e. + * just moved to another place by vacuum)! */ if (chtup) { htup.t_self = btitem->bti_itup.t_tid; heap_fetch(heapRel, SnapshotDirty, &htup, &buffer); - if (htup.t_data == NULL) /* YES! */ + if (htup.t_data == NULL) /* YES! */ break; /* Live tuple was inserted */ ReleaseBuffer(buffer); @@ -139,11 +140,11 @@ l1: cbti = (BTItem) PageGetItem(page, PageGetItemId(page, offset)); htup.t_self = cbti->bti_itup.t_tid; heap_fetch(heapRel, SnapshotDirty, &htup, &buffer); - if (htup.t_data != NULL) /* it is a duplicate */ + if (htup.t_data != NULL) /* it is a duplicate */ { - TransactionId xwait = - (TransactionIdIsValid(SnapshotDirty->xmin)) ? - SnapshotDirty->xmin : SnapshotDirty->xmax; + TransactionId xwait = + (TransactionIdIsValid(SnapshotDirty->xmin)) ? + SnapshotDirty->xmin : SnapshotDirty->xmax; /* * If this tuple is being updated by other transaction @@ -156,7 +157,7 @@ l1: _bt_relbuf(rel, nbuf, BT_READ); _bt_relbuf(rel, buf, BT_WRITE); XactLockTableWait(xwait); - goto l1; /* continue from the begin */ + goto l1;/* continue from the begin */ } elog(ERROR, "Cannot insert a duplicate key into a unique index"); } @@ -571,10 +572,10 @@ _bt_insertonpg(Relation rel, * reasoning). */ -l_spl:; +l_spl: ; if (stack == (BTStack) NULL) { - if (!is_root) /* if this page was not root page */ + if (!is_root) /* if this page was not root page */ { elog(DEBUG, "btree: concurrent ROOT page split"); stack = (BTStack) palloc(sizeof(BTStackData)); @@ -1144,8 +1145,8 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf) lpage = BufferGetPage(lbuf); rpage = BufferGetPage(rbuf); - ((BTPageOpaque) PageGetSpecialPointer(lpage))->btpo_parent = - ((BTPageOpaque) PageGetSpecialPointer(rpage))->btpo_parent = + ((BTPageOpaque) PageGetSpecialPointer(lpage))->btpo_parent = + ((BTPageOpaque) PageGetSpecialPointer(rpage))->btpo_parent = rootbknum; /* diff --git a/src/backend/access/nbtree/nbtpage.c b/src/backend/access/nbtree/nbtpage.c index daff4e6bdd..5a93616054 100644 --- a/src/backend/access/nbtree/nbtpage.c +++ b/src/backend/access/nbtree/nbtpage.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtpage.c,v 1.20 1999/04/22 08:19:59 vadim Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtpage.c,v 1.21 1999/05/25 16:07:26 momjian Exp $ * * NOTES * Postgres btree pages look like ordinary relation pages. The opaque @@ -421,7 +421,7 @@ _bt_pageinit(Page page, Size size) MemSet(page, 0, size); PageInit(page, size, sizeof(BTPageOpaqueData)); - ((BTPageOpaque) PageGetSpecialPointer(page))->btpo_parent = + ((BTPageOpaque) PageGetSpecialPointer(page))->btpo_parent = InvalidBlockNumber; } @@ -494,17 +494,16 @@ _bt_getstackbuf(Relation rel, BTStack stack, int access) opaque = (BTPageOpaque) PageGetSpecialPointer(page); maxoff = PageGetMaxOffsetNumber(page); - if (stack->bts_offset == InvalidOffsetNumber || + if (stack->bts_offset == InvalidOffsetNumber || maxoff >= stack->bts_offset) { + /* - * _bt_insertonpg set bts_offset to InvalidOffsetNumber - * in the case of concurrent ROOT page split + * _bt_insertonpg set bts_offset to InvalidOffsetNumber in the + * case of concurrent ROOT page split */ if (stack->bts_offset == InvalidOffsetNumber) - { i = P_RIGHTMOST(opaque) ? P_HIKEY : P_FIRSTKEY; - } else { itemid = PageGetItemId(page, stack->bts_offset); @@ -524,7 +523,7 @@ _bt_getstackbuf(Relation rel, BTStack stack, int access) } /* if the item has just moved right on this page, we're done */ - for ( ; + for (; i <= maxoff; i = OffsetNumberNext(i)) { diff --git a/src/backend/access/nbtree/nbtree.c b/src/backend/access/nbtree/nbtree.c index 2ded78b1a6..b45d189a85 100644 --- a/src/backend/access/nbtree/nbtree.c +++ b/src/backend/access/nbtree/nbtree.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.37 1999/03/28 20:31:58 vadim Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.38 1999/05/25 16:07:27 momjian Exp $ * * NOTES * This file contains only the public interface routines. @@ -367,7 +367,7 @@ btinsert(Relation rel, Datum *datum, char *nulls, ItemPointer ht_ctid, Relation btitem = _bt_formitem(itup); res = _bt_doinsert(rel, btitem, - IndexIsUnique(RelationGetRelid(rel)), heapRel); + IndexIsUnique(RelationGetRelid(rel)), heapRel); pfree(btitem); pfree(itup); @@ -391,9 +391,10 @@ btgettuple(IndexScanDesc scan, ScanDirection dir) if (ItemPointerIsValid(&(scan->currentItemData))) { + /* - * Restore scan position using heap TID returned - * by previous call to btgettuple(). + * Restore scan position using heap TID returned by previous call + * to btgettuple(). */ _bt_restscan(scan); res = _bt_next(scan, dir); @@ -623,16 +624,15 @@ _bt_restscan(IndexScanDesc scan) BlockNumber blkno; /* - * We use this as flag when first index tuple on page - * is deleted but we do not move left (this would - * slowdown vacuum) - so we set current->ip_posid - * before first index tuple on the current page + * We use this as flag when first index tuple on page is deleted but + * we do not move left (this would slowdown vacuum) - so we set + * current->ip_posid before first index tuple on the current page * (_bt_step will move it right)... */ if (!ItemPointerIsValid(&target)) { - ItemPointerSetOffsetNumber(&(scan->currentItemData), - OffsetNumberPrev(P_RIGHTMOST(opaque) ? P_HIKEY : P_FIRSTKEY)); + ItemPointerSetOffsetNumber(&(scan->currentItemData), + OffsetNumberPrev(P_RIGHTMOST(opaque) ? P_HIKEY : P_FIRSTKEY)); return; } diff --git a/src/backend/access/nbtree/nbtscan.c b/src/backend/access/nbtree/nbtscan.c index a2a6707d19..79e0c879d0 100644 --- a/src/backend/access/nbtree/nbtscan.c +++ b/src/backend/access/nbtree/nbtscan.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/nbtree/Attic/nbtscan.c,v 1.20 1999/03/28 20:31:58 vadim Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/nbtree/Attic/nbtscan.c,v 1.21 1999/05/25 16:07:29 momjian Exp $ * * * NOTES @@ -112,12 +112,12 @@ _bt_adjscans(Relation rel, ItemPointer tid) static void _bt_scandel(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno) { - ItemPointer current; - Buffer buf; - BTScanOpaque so; - OffsetNumber start; - Page page; - BTPageOpaque opaque; + ItemPointer current; + Buffer buf; + BTScanOpaque so; + OffsetNumber start; + Page page; + BTPageOpaque opaque; so = (BTScanOpaque) scan->opaque; buf = so->btso_curbuf; @@ -140,7 +140,7 @@ _bt_scandel(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno) { Page pg = BufferGetPage(buf); BTItem btitem = (BTItem) PageGetItem(pg, - PageGetItemId(pg, ItemPointerGetOffsetNumber(current))); + PageGetItemId(pg, ItemPointerGetOffsetNumber(current))); so->curHeapIptr = btitem->bti_itup.t_tid; } @@ -181,7 +181,7 @@ _bt_scandel(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno) { Page pg = BufferGetPage(buf); BTItem btitem = (BTItem) PageGetItem(pg, - PageGetItemId(pg, ItemPointerGetOffsetNumber(current))); + PageGetItemId(pg, ItemPointerGetOffsetNumber(current))); so->mrkHeapIptr = btitem->bti_itup.t_tid; } diff --git a/src/backend/access/nbtree/nbtsearch.c b/src/backend/access/nbtree/nbtsearch.c index 1ea080abd7..cc3fc7475b 100644 --- a/src/backend/access/nbtree/nbtsearch.c +++ b/src/backend/access/nbtree/nbtsearch.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.43 1999/04/13 17:18:28 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.44 1999/05/25 16:07:31 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -706,7 +706,7 @@ _bt_next(IndexScanDesc scan, ScanDirection dir) so = (BTScanOpaque) scan->opaque; current = &(scan->currentItemData); - Assert (BufferIsValid(so->btso_curbuf)); + Assert(BufferIsValid(so->btso_curbuf)); /* we still have the buffer pinned and locked */ buf = so->btso_curbuf; @@ -733,8 +733,8 @@ _bt_next(IndexScanDesc scan, ScanDirection dir) return res; } - } while (keysok >= so->numberOfFirstKeys || - (keysok == -1 && ScanDirectionIsBackward(dir))); + } while (keysok >= so->numberOfFirstKeys || + (keysok == -1 && ScanDirectionIsBackward(dir))); ItemPointerSetInvalid(current); so->btso_curbuf = InvalidBuffer; @@ -776,8 +776,8 @@ _bt_first(IndexScanDesc scan, ScanDirection dir) BTScanOpaque so; ScanKeyData skdata; Size keysok; - int i; - int nKeyIndex = -1; + int i; + int nKeyIndex = -1; rel = scan->relation; so = (BTScanOpaque) scan->opaque; @@ -795,27 +795,27 @@ _bt_first(IndexScanDesc scan, ScanDirection dir) if (ScanDirectionIsBackward(dir)) { - for (i=0; inumberOfKeys; i++) + for (i = 0; i < so->numberOfKeys; i++) { if (so->keyData[i].sk_attno != 1) break; - strat = _bt_getstrat(rel, so->keyData[i].sk_attno, - so->keyData[i].sk_procedure); + strat = _bt_getstrat(rel, so->keyData[i].sk_attno, + so->keyData[i].sk_procedure); if (strat == BTLessStrategyNumber || - strat == BTLessEqualStrategyNumber|| - strat == BTEqualStrategyNumber) + strat == BTLessEqualStrategyNumber || + strat == BTEqualStrategyNumber) { nKeyIndex = i; break; } } } - else + else { strat = _bt_getstrat(rel, 1, so->keyData[0].sk_procedure); if (strat == BTLessStrategyNumber || - strat == BTLessEqualStrategyNumber) + strat == BTLessEqualStrategyNumber) ; else nKeyIndex = 0; @@ -850,7 +850,7 @@ _bt_first(IndexScanDesc scan, ScanDirection dir) } proc = index_getprocid(rel, 1, BTORDER_PROC); ScanKeyEntryInitialize(&skdata, so->keyData[nKeyIndex].sk_flags, - 1, proc, so->keyData[nKeyIndex].sk_argument); + 1, proc, so->keyData[nKeyIndex].sk_argument); stack = _bt_search(rel, 1, &skdata, &buf); _bt_freestack(stack); @@ -1104,9 +1104,10 @@ _bt_step(IndexScanDesc scan, Buffer *bufP, ScanDirection dir) rel = scan->relation; current = &(scan->currentItemData); + /* - * Don't use ItemPointerGetOffsetNumber or you risk to get - * assertion due to ability of ip_posid to be equal 0. + * Don't use ItemPointerGetOffsetNumber or you risk to get assertion + * due to ability of ip_posid to be equal 0. */ offnum = current->ip_posid; page = BufferGetPage(*bufP); diff --git a/src/backend/access/nbtree/nbtsort.c b/src/backend/access/nbtree/nbtsort.c index c8c494d3f9..d5c2c30bef 100644 --- a/src/backend/access/nbtree/nbtsort.c +++ b/src/backend/access/nbtree/nbtsort.c @@ -5,7 +5,7 @@ * * * IDENTIFICATION - * $Id: nbtsort.c,v 1.38 1999/05/09 00:53:19 tgl Exp $ + * $Id: nbtsort.c,v 1.39 1999/05/25 16:07:34 momjian Exp $ * * NOTES * @@ -552,16 +552,16 @@ _bt_spoolinit(Relation index, int ntapes, bool isunique) btspool->bts_tape = 0; btspool->isunique = isunique; - btspool->bts_itape =(BTTapeBlock **) palloc(sizeof(BTTapeBlock *) * ntapes); - btspool->bts_otape =(BTTapeBlock **) palloc(sizeof(BTTapeBlock *) * ntapes); + btspool->bts_itape = (BTTapeBlock **) palloc(sizeof(BTTapeBlock *) * ntapes); + btspool->bts_otape = (BTTapeBlock **) palloc(sizeof(BTTapeBlock *) * ntapes); if (btspool->bts_itape == (BTTapeBlock **) NULL || btspool->bts_otape == (BTTapeBlock **) NULL) elog(ERROR, "_bt_spoolinit: out of memory"); for (i = 0; i < ntapes; ++i) { - btspool->bts_itape[i] = _bt_tapecreate(); - btspool->bts_otape[i] = _bt_tapecreate(); + btspool->bts_itape[i] = _bt_tapecreate(); + btspool->bts_otape[i] = _bt_tapecreate(); } _bt_isortcmpinit(index, btspool); diff --git a/src/backend/access/rtree/rtree.c b/src/backend/access/rtree/rtree.c index 57e8942450..f62a4bf648 100644 --- a/src/backend/access/rtree/rtree.c +++ b/src/backend/access/rtree/rtree.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.31 1999/02/13 23:14:42 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.32 1999/05/25 16:07:38 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -307,7 +307,7 @@ rtinsert(Relation r, Datum *datum, char *nulls, ItemPointer ht_ctid, Relation he /* * Notes in ExecUtils:ExecOpenIndices() * - RelationSetLockForWrite(r); + * RelationSetLockForWrite(r); */ res = rtdoinsert(r, itup, &rtState); @@ -947,10 +947,10 @@ rtdelete(Relation r, ItemPointer tid) Page page; /* - * Notes in ExecUtils:ExecOpenIndices() - * Also note that only vacuum deletes index tuples now... + * Notes in ExecUtils:ExecOpenIndices() Also note that only vacuum + * deletes index tuples now... * - RelationSetLockForWrite(r); + * RelationSetLockForWrite(r); */ blkno = ItemPointerGetBlockNumber(tid); diff --git a/src/backend/access/rtree/rtscan.c b/src/backend/access/rtree/rtscan.c index 596972960b..b74a341304 100644 --- a/src/backend/access/rtree/rtscan.c +++ b/src/backend/access/rtree/rtscan.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtscan.c,v 1.22 1999/02/13 23:14:43 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtscan.c,v 1.23 1999/05/25 16:07:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -69,7 +69,7 @@ rtbeginscan(Relation r, /* * Let index_beginscan does its work... * - RelationSetLockForRead(r); + * RelationSetLockForRead(r); */ s = RelationGetIndexScan(r, fromEnd, nkeys, key); diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c index 35f07e6185..fe1d57d769 100644 --- a/src/backend/access/transam/transam.c +++ b/src/backend/access/transam/transam.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.25 1999/03/30 01:37:21 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.26 1999/05/25 16:07:45 momjian Exp $ * * NOTES * This file contains the high level access-method interface to the @@ -221,7 +221,7 @@ TransactionLogUpdate(TransactionId transactionId, /* trans id to update */ /* * update (invalidate) our single item TransactionLogTest cache. * - if (status != XID_COMMIT) + * if (status != XID_COMMIT) * * What's the hell ?! Why != XID_COMMIT ?! */ @@ -374,7 +374,7 @@ TransRecover(Relation logRelation) */ /* - * InitializeTransactionLog + * InitializeTransactionLog * Initializes transaction logging. */ void @@ -484,7 +484,7 @@ InitializeTransactionLog(void) */ /* - * TransactionIdDidCommit + * TransactionIdDidCommit * True iff transaction associated with the identifier did commit. * * Note: @@ -500,7 +500,7 @@ TransactionIdDidCommit(TransactionId transactionId) } /* - * TransactionIdDidAborted + * TransactionIdDidAborted * True iff transaction associated with the identifier did abort. * * Note: @@ -541,7 +541,7 @@ TransactionIdIsInProgress(TransactionId transactionId) */ /* - * TransactionIdCommit + * TransactionIdCommit * Commits the transaction associated with the identifier. * * Note: @@ -557,7 +557,7 @@ TransactionIdCommit(TransactionId transactionId) } /* - * TransactionIdAbort + * TransactionIdAbort * Aborts the transaction associated with the identifier. * * Note: diff --git a/src/backend/access/transam/varsup.c b/src/backend/access/transam/varsup.c index f910ea5f0f..4bcc55bb92 100644 --- a/src/backend/access/transam/varsup.c +++ b/src/backend/access/transam/varsup.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.19 1999/02/13 23:14:48 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.20 1999/05/25 16:07:48 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -260,7 +260,7 @@ VariableRelationPutNextOid(Oid *oidP) * In the version 2 transaction system, transaction id's are * restricted in several ways. * - * -- Old comments removed + * -- Old comments removed * * Second, since we may someday preform compression of the data * in the log and time relations, we cause the numbering of the diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index f125baed6d..000abbc7ec 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.35 1999/05/13 00:34:57 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.36 1999/05/25 16:07:50 momjian Exp $ * * NOTES * Transaction aborts can now occur two ways: @@ -194,8 +194,8 @@ TransactionStateData CurrentTransactionStateData = { TransactionState CurrentTransactionState = &CurrentTransactionStateData; -int DefaultXactIsoLevel = XACT_READ_COMMITTED; -int XactIsoLevel; +int DefaultXactIsoLevel = XACT_READ_COMMITTED; +int XactIsoLevel; /* ---------------- * info returned when the system is disabled @@ -299,6 +299,7 @@ IsTransactionState(void) */ return false; } + #endif /* -------------------------------- @@ -516,7 +517,7 @@ CommandCounterIncrement() AtStart_Cache(); TransactionIdFlushCache(); - + } void @@ -695,9 +696,9 @@ AtCommit_Memory() /* ---------------- * Release memory in the blank portal. - * Since EndPortalAllocMode implicitly works on the current context, - * first make real sure that the blank portal is the selected context. - * (This is probably not necessary, but seems like a good idea...) + * Since EndPortalAllocMode implicitly works on the current context, + * first make real sure that the blank portal is the selected context. + * (This is probably not necessary, but seems like a good idea...) * ---------------- */ portal = GetPortalByName(NULL); @@ -789,9 +790,9 @@ AtAbort_Memory() /* ---------------- * Release memory in the blank portal. - * Since EndPortalAllocMode implicitly works on the current context, - * first make real sure that the blank portal is the selected context. - * (This is ESSENTIAL in case we aborted from someplace where it wasn't.) + * Since EndPortalAllocMode implicitly works on the current context, + * first make real sure that the blank portal is the selected context. + * (This is ESSENTIAL in case we aborted from someplace where it wasn't.) * ---------------- */ portal = GetPortalByName(NULL); @@ -1074,7 +1075,7 @@ StartTransactionCommand() break; /* ---------------- - * As with BEGIN, we should never experience this + * As with BEGIN, we should never experience this * if we do it means the END state was not changed in the * previous CommitTransactionCommand(). If we get it, we * print a warning, commit the transaction, start a new @@ -1509,6 +1510,7 @@ AbortOutOfAnyTransaction() */ if (s->state != TRANS_DEFAULT) AbortTransaction(); + /* * Now reset the high-level state */ diff --git a/src/backend/access/transam/xid.c b/src/backend/access/transam/xid.c index e7b68d48e7..2b15fec1bf 100644 --- a/src/backend/access/transam/xid.c +++ b/src/backend/access/transam/xid.c @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: xid.c,v 1.21 1999/02/13 23:14:49 momjian Exp $ + * $Id: xid.c,v 1.22 1999/05/25 16:07:52 momjian Exp $ * * OLD COMMENTS * XXX WARNING diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c index 80f1142949..6c7e7c16fa 100644 --- a/src/backend/bootstrap/bootstrap.c +++ b/src/backend/bootstrap/bootstrap.c @@ -7,7 +7,7 @@ * Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.59 1999/05/10 00:44:52 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.60 1999/05/25 16:07:56 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -182,7 +182,7 @@ static char *relname; /* current relation name */ Form_pg_attribute attrtypes[MAXATTR]; /* points to attribute info */ static char *values[MAXATTR]; /* cooresponding attribute values */ int numattr; /* number of attributes for cur. rel */ -extern bool disableFsync; /* do not fsync the database */ +extern bool disableFsync; /* do not fsync the database */ int DebugMode; static GlobalMemory nogc = (GlobalMemory) NULL; /* special no-gc mem @@ -587,7 +587,9 @@ DefineAttr(char *name, char *type, int attnum) printf("<%s %s> ", attrtypes[attnum]->attname.data, type); attrtypes[attnum]->attnum = 1 + attnum; /* fillatt */ attlen = attrtypes[attnum]->attlen = Procid[typeoid].len; - /* Cheat like mad to fill in these items from the length only. + + /* + * Cheat like mad to fill in these items from the length only. * This only has to work for types used in the system catalogs... */ switch (attlen) diff --git a/src/backend/catalog/catalog.c b/src/backend/catalog/catalog.c index 8e0953809c..5e72071435 100644 --- a/src/backend/catalog/catalog.c +++ b/src/backend/catalog/catalog.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/catalog.c,v 1.20 1999/02/13 23:14:55 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/catalog.c,v 1.21 1999/05/25 16:08:01 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -29,8 +29,8 @@ char * relpath(char *relname) { - char *path; - int bufsize = 0; + char *path; + int bufsize = 0; if (IsSharedSystemRelationName(relname)) { @@ -43,7 +43,7 @@ relpath(char *relname) } /* - * IsSystemRelationName + * IsSystemRelationName * True iff name is the name of a system catalog relation. * * We now make a new requirement where system catalog relns must begin @@ -64,7 +64,7 @@ IsSystemRelationName(char *relname) } /* - * IsSharedSystemRelationName + * IsSharedSystemRelationName * True iff name is the name of a shared system catalog relation. */ bool diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c index c82a258a3b..89e45fb2bf 100644 --- a/src/backend/catalog/heap.c +++ b/src/backend/catalog/heap.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.84 1999/05/22 04:12:24 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.85 1999/05/25 16:08:03 momjian Exp $ * * * INTERFACE ROUTINES @@ -70,8 +70,8 @@ #endif static void AddNewRelationTuple(Relation pg_class_desc, - Relation new_rel_desc, Oid new_rel_oid, unsigned natts, - char relkind, char *temp_relname); + Relation new_rel_desc, Oid new_rel_oid, unsigned natts, + char relkind, char *temp_relname); static void AddToNoNameRelList(Relation r); static void DeleteAttributeTuples(Relation rel); static void DeleteRelationTuple(Relation rel); @@ -185,7 +185,7 @@ heap_create(char *relname, bool nailme = false; int natts = tupDesc->natts; static unsigned int uniqueId = 0; - + extern GlobalMemory CacheCxt; MemoryContext oldcxt; @@ -240,23 +240,21 @@ heap_create(char *relname, nailme = true; } else - { relid = newoid(); - } if (isnoname) { Assert(!relname); relname = palloc(NAMEDATALEN); snprintf(relname, NAMEDATALEN, "pg_noname.%d.%u", - (int) MyProcPid, uniqueId++); + (int) MyProcPid, uniqueId++); } if (istemp) { /* replace relname of caller */ snprintf(relname, NAMEDATALEN, "pg_temp.%d.%u", - (int) MyProcPid, uniqueId++); + (int) MyProcPid, uniqueId++); } /* ---------------- @@ -272,7 +270,7 @@ heap_create(char *relname, /* * create a new tuple descriptor from the one passed in - */ + */ rel->rd_att = CreateTupleDescCopyConstr(tupDesc); /* ---------------- @@ -321,7 +319,7 @@ heap_create(char *relname, * ---------------- */ - rel->rd_nonameunlinked = TRUE; /* change once table is created */ + rel->rd_nonameunlinked = TRUE; /* change once table is created */ rel->rd_fd = (File) smgrcreate(DEFAULT_SMGR, rel); rel->rd_nonameunlinked = FALSE; @@ -479,8 +477,8 @@ RelnameFindRelid(char *relname) if (!IsBootstrapProcessingMode()) { tuple = SearchSysCacheTuple(RELNAME, - PointerGetDatum(relname), - 0, 0, 0); + PointerGetDatum(relname), + 0, 0, 0); if (HeapTupleIsValid(tuple)) relid = tuple->t_data->t_oid; else @@ -488,10 +486,10 @@ RelnameFindRelid(char *relname) } else { - Relation pg_class_desc; + Relation pg_class_desc; ScanKeyData key; HeapScanDesc pg_class_scan; - + pg_class_desc = heap_openr(RelationRelationName); /* ---------------- @@ -504,7 +502,7 @@ RelnameFindRelid(char *relname) (AttrNumber) Anum_pg_class_relname, (RegProcedure) F_NAMEEQ, (Datum) relname); - + /* ---------------- * begin the scan * ---------------- @@ -514,14 +512,14 @@ RelnameFindRelid(char *relname) SnapshotNow, 1, &key); - + /* ---------------- * get a tuple. if the tuple is NULL then it means we * didn't find an existing relation. * ---------------- */ tuple = heap_getnext(pg_class_scan, 0); - + if (HeapTupleIsValid(tuple)) relid = tuple->t_data->t_oid; else @@ -594,7 +592,7 @@ AddNewAttributeTuples(Oid new_rel_oid, (char *) *dpp); heap_insert(rel, tup); - + if (hasindex) CatalogIndexInsert(idescs, Num_pg_attr_indices, rel, tup); @@ -643,11 +641,11 @@ AddNewAttributeTuples(Oid new_rel_oid, */ static void AddNewRelationTuple(Relation pg_class_desc, - Relation new_rel_desc, - Oid new_rel_oid, - unsigned natts, - char relkind, - char *temp_relname) + Relation new_rel_desc, + Oid new_rel_oid, + unsigned natts, + char relkind, + char *temp_relname) { Form_pg_class new_rel_reltup; HeapTuple tup; @@ -678,12 +676,12 @@ AddNewRelationTuple(Relation pg_class_desc, * the table has been proven to be small by VACUUM or CREATE INDEX. * (NOTE: if user does CREATE TABLE, then CREATE INDEX, then loads * the table, he still loses until he vacuums, because CREATE INDEX - * will set reltuples to zero. Can't win 'em all. Maintaining the + * will set reltuples to zero. Can't win 'em all. Maintaining the * stats on-the-fly would solve the problem, but the overhead of that * would likely cost more than it'd save.) * ---------------- */ - new_rel_reltup->relpages = 10; /* bogus estimates */ + new_rel_reltup->relpages = 10; /* bogus estimates */ new_rel_reltup->reltuples = 1000; new_rel_reltup->relowner = GetUserId(); @@ -716,9 +714,10 @@ AddNewRelationTuple(Relation pg_class_desc, if (temp_relname) create_temp_relation(temp_relname, tup); - + if (!isBootstrap) { + /* * First, open the catalog indices and insert index tuples for the * new relation. @@ -730,7 +729,7 @@ AddNewRelationTuple(Relation pg_class_desc, /* now restore processing mode */ SetProcessingMode(NormalProcessing); } - + pfree(tup); } @@ -788,8 +787,8 @@ heap_create_with_catalog(char *relname, Relation new_rel_desc; Oid new_rel_oid; int natts = tupdesc->natts; - char *temp_relname = NULL; - + char *temp_relname = NULL; + /* ---------------- * sanity checks * ---------------- @@ -804,33 +803,34 @@ heap_create_with_catalog(char *relname, /* temp tables can mask non-temp tables */ if ((!istemp && RelnameFindRelid(relname)) || - (istemp && get_temp_rel_by_name(relname) != NULL)) + (istemp && get_temp_rel_by_name(relname) != NULL)) elog(ERROR, "Relation '%s' already exists", relname); /* invalidate cache so non-temp table is masked by temp */ if (istemp) { - Oid relid = RelnameFindRelid(relname); + Oid relid = RelnameFindRelid(relname); if (relid != InvalidOid) { + /* - * This is heavy-handed, but appears necessary bjm 1999/02/01 - * SystemCacheRelationFlushed(relid) is not enough either. + * This is heavy-handed, but appears necessary bjm 1999/02/01 + * SystemCacheRelationFlushed(relid) is not enough either. */ RelationForgetRelation(relid); ResetSystemCache(); - } + } } - + /* save user relation name because heap_create changes it */ if (istemp) { - temp_relname = pstrdup(relname); /* save original value */ + temp_relname = pstrdup(relname); /* save original value */ relname = palloc(NAMEDATALEN); - strcpy(relname, temp_relname); /* heap_create will change this */ + strcpy(relname, temp_relname); /* heap_create will change this */ } - + /* ---------------- * ok, relation does not already exist so now we * create an uncataloged relation and pull its relation oid @@ -838,7 +838,7 @@ heap_create_with_catalog(char *relname, * * Note: The call to heap_create() does all the "real" work * of creating the disk file for the relation. - * This changes relname for noname and temp tables. + * This changes relname for noname and temp tables. * ---------------- */ new_rel_desc = heap_create(relname, tupdesc, false, istemp); @@ -866,11 +866,11 @@ heap_create_with_catalog(char *relname, pg_class_desc = heap_openr(RelationRelationName); AddNewRelationTuple(pg_class_desc, - new_rel_desc, - new_rel_oid, - natts, - relkind, - temp_relname); + new_rel_desc, + new_rel_oid, + natts, + relkind, + temp_relname); StoreConstraints(new_rel_desc); @@ -1320,7 +1320,7 @@ heap_destroy_with_catalog(char *relname) if (istemp) remove_temp_relation(rid); - + /* ---------------- * delete type tuple. here we want to see the effects * of the deletions we just did, so we use setheapoverride(). @@ -1334,7 +1334,7 @@ heap_destroy_with_catalog(char *relname) * delete relation tuple * ---------------- */ - /* must delete fake tuple in cache */ + /* must delete fake tuple in cache */ DeleteRelationTuple(rel); /* @@ -1516,10 +1516,12 @@ StoreAttrDefault(Relation rel, AttrDefault *attrdef) extern GlobalMemory CacheCxt; start: - /* Surround table name with double quotes to allow mixed-case and + + /* + * Surround table name with double quotes to allow mixed-case and * whitespaces in names. - BGA 1998-11-14 */ - snprintf(str, MAX_PARSE_BUFFER, + snprintf(str, MAX_PARSE_BUFFER, "select %s%s from \"%.*s\"", attrdef->adsrc, cast, NAMEDATALEN, rel->rd_rel->relname.data); setheapoverride(true); @@ -1539,16 +1541,16 @@ start: if (type != atp->atttypid) { if (IS_BINARY_COMPATIBLE(type, atp->atttypid)) - ; /* use without change */ + ; /* use without change */ else if (can_coerce_type(1, &(type), &(atp->atttypid))) - expr = coerce_type(NULL, (Node *)expr, type, atp->atttypid, - atp->atttypmod); + expr = coerce_type(NULL, (Node *) expr, type, atp->atttypid, + atp->atttypmod); else if (IsA(expr, Const)) { if (*cast != 0) elog(ERROR, "DEFAULT clause const type '%s' mismatched with column type '%s'", typeidTypeName(type), typeidTypeName(atp->atttypid)); - snprintf(cast, 2*NAMEDATALEN, ":: %s", typeidTypeName(atp->atttypid)); + snprintf(cast, 2 * NAMEDATALEN, ":: %s", typeidTypeName(atp->atttypid)); goto start; } else @@ -1598,12 +1600,13 @@ StoreRelCheck(Relation rel, ConstrCheck *check) char nulls[4] = {' ', ' ', ' ', ' '}; extern GlobalMemory CacheCxt; - /* Check for table's existance. Surround table name with double-quotes + /* + * Check for table's existance. Surround table name with double-quotes * to allow mixed-case and whitespace names. - thomas 1998-11-12 */ - snprintf(str, MAX_PARSE_BUFFER, - "select 1 from \"%.*s\" where %s", - NAMEDATALEN, rel->rd_rel->relname.data, check->ccsrc); + snprintf(str, MAX_PARSE_BUFFER, + "select 1 from \"%.*s\" where %s", + NAMEDATALEN, rel->rd_rel->relname.data, check->ccsrc); setheapoverride(true); planTree_list = pg_parse_and_plan(str, NULL, 0, &queryTree_list, None, FALSE); diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c index 7fc6cb0464..93f34ce074 100644 --- a/src/backend/catalog/index.c +++ b/src/backend/catalog/index.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.74 1999/05/17 00:27:45 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.75 1999/05/25 16:08:06 momjian Exp $ * * * INTERFACE ROUTINES @@ -60,8 +60,8 @@ #define NTUPLES_PER_PAGE(natts) (BLCKSZ/((natts)*AVG_TUPLE_SIZE)) /* non-export function prototypes */ -static Oid GetHeapRelationOid(char *heapRelationName, char *indexRelationName, - bool istemp); +static Oid GetHeapRelationOid(char *heapRelationName, char *indexRelationName, + bool istemp); static TupleDesc BuildFuncTupleDesc(FuncIndexInfo *funcInfo); static TupleDesc ConstructTupleDescriptor(Oid heapoid, Relation heapRelation, List *attributeList, @@ -77,7 +77,7 @@ static void static void UpdateIndexRelation(Oid indexoid, Oid heapoid, FuncIndexInfo *funcInfo, int natts, AttrNumber *attNums, Oid *classOids, Node *predicate, - List *attributeList, bool islossy, bool unique, bool primary); + List *attributeList, bool islossy, bool unique, bool primary); static void DefaultBuild(Relation heapRelation, Relation indexRelation, int numberOfAttributes, AttrNumber *attributeNumber, IndexStrategy indexStrategy, uint16 parameterCount, @@ -126,11 +126,11 @@ GetHeapRelationOid(char *heapRelationName, char *indexRelationName, bool istemp) Oid indoid; Oid heapoid; - + indoid = RelnameFindRelid(indexRelationName); if ((!istemp && OidIsValid(indoid)) || - (istemp && get_temp_rel_by_name(indexRelationName) != NULL)) + (istemp && get_temp_rel_by_name(indexRelationName) != NULL)) elog(ERROR, "Cannot create index: '%s' already exists", indexRelationName); @@ -139,7 +139,7 @@ GetHeapRelationOid(char *heapRelationName, char *indexRelationName, bool istemp) if (!OidIsValid(heapoid)) elog(ERROR, "Cannot create index on '%s': relation does not exist", heapRelationName); - + return heapoid; } @@ -356,7 +356,7 @@ ConstructTupleDescriptor(Oid heapoid, } /* ---------------------------------------------------------------- - * AccessMethodObjectIdGetForm + * AccessMethodObjectIdGetForm * Returns the formated access method tuple given its object identifier. * * XXX ADD INDEXING @@ -482,7 +482,7 @@ UpdateRelationRelation(Relation indexRelation, char *temp_relname) if (temp_relname) create_temp_relation(temp_relname, tuple); - + /* * During normal processing, we need to make sure that the system * catalog indices are correct. Bootstrap (initdb) time doesn't @@ -571,7 +571,7 @@ AppendAttributeTuples(Relation indexRelation, int numatts) value[Anum_pg_attribute_attcacheoff - 1] = Int32GetDatum(-1); init_tuple = heap_addheader(Natts_pg_attribute, - ATTRIBUTE_TUPLE_SIZE, + ATTRIBUTE_TUPLE_SIZE, (char *) (indexRelation->rd_att->attrs[0])); hasind = false; @@ -611,7 +611,7 @@ AppendAttributeTuples(Relation indexRelation, int numatts) */ memmove(GETSTRUCT(cur_tuple), (char *) indexTupDesc->attrs[i], - ATTRIBUTE_TUPLE_SIZE); + ATTRIBUTE_TUPLE_SIZE); value[Anum_pg_attribute_attnum - 1] = Int16GetDatum(i + 1); @@ -657,7 +657,7 @@ UpdateIndexRelation(Oid indexoid, List *attributeList, bool islossy, bool unique, - bool primary) + bool primary) { Form_pg_index indexForm; IndexElem *IndexKey; @@ -686,7 +686,7 @@ UpdateIndexRelation(Oid indexoid, predLen = VARSIZE(predText); itupLen = predLen + sizeof(FormData_pg_index); indexForm = (Form_pg_index) palloc(itupLen); - memset (indexForm, 0, sizeof(FormData_pg_index)); + memset(indexForm, 0, sizeof(FormData_pg_index)); memmove((char *) &indexForm->indpred, (char *) predText, predLen); @@ -939,7 +939,7 @@ index_create(char *heapRelationName, Node *predicate, bool islossy, bool unique, - bool primary) + bool primary) { Relation heapRelation; Relation indexRelation; @@ -948,15 +948,15 @@ index_create(char *heapRelationName, Oid indexoid; PredInfo *predInfo; bool istemp = (get_temp_rel_by_name(heapRelationName) != NULL); - char *temp_relname = NULL; - + char *temp_relname = NULL; + /* ---------------- * check parameters * ---------------- */ if (numatts < 1) elog(ERROR, "must index at least one attribute"); - + /* ---------------- * get heap relation oid and open the heap relation * XXX ADD INDEXING @@ -987,25 +987,27 @@ index_create(char *heapRelationName, /* invalidate cache so possible non-temp index is masked by temp */ if (istemp) { - Oid relid = RelnameFindRelid(indexRelationName); + Oid relid = RelnameFindRelid(indexRelationName); if (relid != InvalidOid) { + /* - * This is heavy-handed, but appears necessary bjm 1999/02/01 - * SystemCacheRelationFlushed(relid) is not enough either. + * This is heavy-handed, but appears necessary bjm 1999/02/01 + * SystemCacheRelationFlushed(relid) is not enough either. */ RelationForgetRelation(relid); ResetSystemCache(); } } - + /* save user relation name because heap_create changes it */ if (istemp) { - temp_relname = pstrdup(indexRelationName); /* save original value */ + temp_relname = pstrdup(indexRelationName); /* save original value */ indexRelationName = palloc(NAMEDATALEN); - strcpy(indexRelationName, temp_relname); /* heap_create will change this */ + strcpy(indexRelationName, temp_relname); /* heap_create will + * change this */ } /* ---------------- @@ -1122,8 +1124,8 @@ index_destroy(Oid indexId) Relation relationRelation; Relation attributeRelation; HeapTuple tuple; - int16 attnum; - + int16 attnum; + Assert(OidIsValid(indexId)); /* Open now to obtain lock by referencing table? bjm */ @@ -1166,7 +1168,7 @@ index_destroy(Oid indexId) /* does something only if it is a temp index */ remove_temp_relation(indexId); - + /* ---------------- * fix INDEX relation * ---------------- diff --git a/src/backend/catalog/indexing.c b/src/backend/catalog/indexing.c index 89230f16c0..a7a1dda444 100644 --- a/src/backend/catalog/indexing.c +++ b/src/backend/catalog/indexing.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.37 1999/05/10 00:44:55 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.38 1999/05/25 16:08:07 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -46,15 +46,15 @@ */ char *Name_pg_attr_indices[Num_pg_attr_indices] = {AttributeNameIndex, - AttributeNumIndex, - AttributeRelidIndex}; + AttributeNumIndex, +AttributeRelidIndex}; char *Name_pg_proc_indices[Num_pg_proc_indices] = {ProcedureNameIndex, - ProcedureOidIndex, - ProcedureSrcIndex}; + ProcedureOidIndex, +ProcedureSrcIndex}; char *Name_pg_type_indices[Num_pg_type_indices] = {TypeNameIndex, - TypeOidIndex}; +TypeOidIndex}; char *Name_pg_class_indices[Num_pg_class_indices] = {ClassNameIndex, - ClassOidIndex}; +ClassOidIndex}; char *Name_pg_attrdef_indices[Num_pg_attrdef_indices] = {AttrDefaultIndex}; char *Name_pg_relcheck_indices[Num_pg_relcheck_indices] = {RelCheckIndex}; @@ -63,9 +63,9 @@ char *Name_pg_trigger_indices[Num_pg_trigger_indices] = {TriggerRelidIndex}; static HeapTuple CatalogIndexFetchTuple(Relation heapRelation, - Relation idesc, - ScanKey skey, - int16 num_keys); + Relation idesc, + ScanKey skey, + int16 num_keys); /* @@ -126,13 +126,13 @@ CatalogIndexInsert(Relation *idescs, index_tup = SearchSysCacheTupleCopy(INDEXRELID, ObjectIdGetDatum(idescs[i]->rd_id), - 0, 0, 0); + 0, 0, 0); Assert(index_tup); index_form = (Form_pg_index) GETSTRUCT(index_tup); if (index_form->indproc != InvalidOid) { - int fatts; + int fatts; /* * Compute the number of attributes we are indexing upon. @@ -152,7 +152,7 @@ CatalogIndexInsert(Relation *idescs, natts = RelationGetDescr(idescs[i])->natts; finfoP = (FuncIndexInfo *) NULL; } - + FormIndexDatum(natts, (AttrNumber *) index_form->indkey, heapTuple, @@ -229,11 +229,11 @@ CatalogIndexFetchTuple(Relation heapRelation, ScanKey skey, int16 num_keys) { - IndexScanDesc sd; + IndexScanDesc sd; RetrieveIndexResult indexRes; - HeapTupleData tuple; - HeapTuple result = NULL; - Buffer buffer; + HeapTupleData tuple; + HeapTuple result = NULL; + Buffer buffer; sd = index_beginscan(idesc, false, num_keys, skey); tuple.t_data = NULL; @@ -462,7 +462,7 @@ ClassNameIndexScan(Relation heapRelation, char *relName) */ if ((tuple = get_temp_rel_by_name(relName)) != NULL) return heap_copytuple(tuple); - + ScanKeyEntryInitialize(&skey[0], (bits16) 0x0, (AttrNumber) 1, diff --git a/src/backend/catalog/pg_operator.c b/src/backend/catalog/pg_operator.c index b3b11f845a..58c87302d0 100644 --- a/src/backend/catalog/pg_operator.c +++ b/src/backend/catalog/pg_operator.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.36 1999/05/10 00:44:56 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.37 1999/05/25 16:08:09 momjian Exp $ * * NOTES * these routines moved here from commands/define.c and somewhat cleaned up. @@ -36,15 +36,15 @@ #endif static Oid OperatorGetWithOpenRelation(Relation pg_operator_desc, - const char *operatorName, - Oid leftObjectId, - Oid rightObjectId, - bool *defined); + const char *operatorName, + Oid leftObjectId, + Oid rightObjectId, + bool *defined); static Oid OperatorGet(char *operatorName, - char *leftTypeName, - char *rightTypeName, - bool *defined); + char *leftTypeName, + char *rightTypeName, + bool *defined); static Oid OperatorShellMakeWithOpenRelation(Relation pg_operator_desc, char *operatorName, @@ -135,6 +135,7 @@ OperatorGetWithOpenRelation(Relation pg_operator_desc, if (HeapTupleIsValid(tup)) { regproc oprcode = ((Form_pg_operator) GETSTRUCT(tup))->oprcode; + operatorObjectId = tup->t_data->t_oid; *defined = RegProcedureIsValid(oprcode); } @@ -259,7 +260,7 @@ OperatorShellMakeWithOpenRelation(Relation pg_operator_desc, /* ---------------- * initialize *values with the operator name and input data types. - * Note that oprcode is set to InvalidOid, indicating it's a shell. + * Note that oprcode is set to InvalidOid, indicating it's a shell. * ---------------- */ i = 0; @@ -356,9 +357,9 @@ OperatorShellMake(char *operatorName, * ---------------- */ operatorObjectId = OperatorShellMakeWithOpenRelation(pg_operator_desc, - operatorName, - leftObjectId, - rightObjectId); + operatorName, + leftObjectId, + rightObjectId); /* ---------------- * close the operator relation and return the oid. * ---------------- @@ -506,8 +507,9 @@ OperatorDef(char *operatorName, elog(ERROR, "OperatorDef: operator \"%s\" already defined", operatorName); - /* At this point, if operatorObjectId is not InvalidOid then - * we are filling in a previously-created shell. + /* + * At this point, if operatorObjectId is not InvalidOid then we are + * filling in a previously-created shell. */ /* ---------------- @@ -580,7 +582,7 @@ OperatorDef(char *operatorName, values[Anum_pg_operator_oprcode - 1] = ObjectIdGetDatum(tup->t_data->t_oid); values[Anum_pg_operator_oprresult - 1] = ObjectIdGetDatum(((Form_pg_proc) - GETSTRUCT(tup))->prorettype); + GETSTRUCT(tup))->prorettype); /* ---------------- * find restriction @@ -648,7 +650,8 @@ OperatorDef(char *operatorName, values[i++] = ObjectIdGetDatum(leftTypeId); values[i++] = ObjectIdGetDatum(rightTypeId); - ++i; /* Skip "oprresult", it was filled in above */ + ++i; /* Skip "oprresult", it was filled in + * above */ /* * Set up the other operators. If they do not currently exist, create @@ -663,16 +666,16 @@ OperatorDef(char *operatorName, { if (name[j]) { - char *otherLeftTypeName = NULL; - char *otherRightTypeName = NULL; - Oid otherLeftTypeId = InvalidOid; - Oid otherRightTypeId = InvalidOid; - Oid other_oid = InvalidOid; - bool otherDefined = false; + char *otherLeftTypeName = NULL; + char *otherRightTypeName = NULL; + Oid otherLeftTypeId = InvalidOid; + Oid otherRightTypeId = InvalidOid; + Oid other_oid = InvalidOid; + bool otherDefined = false; switch (j) { - case 0: /* commutator has reversed arg types */ + case 0: /* commutator has reversed arg types */ otherLeftTypeName = rightTypeName; otherRightTypeName = leftTypeName; otherLeftTypeId = rightTypeId; @@ -683,7 +686,7 @@ OperatorDef(char *operatorName, &otherDefined); commutatorId = other_oid; break; - case 1: /* negator has same arg types */ + case 1: /* negator has same arg types */ otherLeftTypeName = leftTypeName; otherRightTypeName = rightTypeName; otherLeftTypeId = leftTypeId; @@ -694,7 +697,7 @@ OperatorDef(char *operatorName, &otherDefined); negatorId = other_oid; break; - case 2: /* left sort op takes left-side data type */ + case 2: /* left sort op takes left-side data type */ otherLeftTypeName = leftTypeName; otherRightTypeName = leftTypeName; otherLeftTypeId = leftTypeId; @@ -704,7 +707,8 @@ OperatorDef(char *operatorName, otherRightTypeName, &otherDefined); break; - case 3: /* right sort op takes right-side data type */ + case 3: /* right sort op takes right-side data + * type */ otherLeftTypeName = rightTypeName; otherRightTypeName = rightTypeName; otherLeftTypeId = rightTypeId; @@ -737,8 +741,10 @@ OperatorDef(char *operatorName, } else { - /* self-linkage to this operator; will fix below. - * Note that only self-linkage for commutation makes sense. + + /* + * self-linkage to this operator; will fix below. Note + * that only self-linkage for commutation makes sense. */ if (j != 0) elog(ERROR, @@ -804,15 +810,14 @@ OperatorDef(char *operatorName, /* * If a commutator and/or negator link is provided, update the other - * operator(s) to point at this one, if they don't already have a link. - * This supports an alternate style of operator definition wherein the - * user first defines one operator without giving negator or - * commutator, then defines the other operator of the pair with the - * proper commutator or negator attribute. That style doesn't require - * creation of a shell, and it's the only style that worked right before - * Postgres version 6.5. - * This code also takes care of the situation where the new operator - * is its own commutator. + * operator(s) to point at this one, if they don't already have a + * link. This supports an alternate style of operator definition + * wherein the user first defines one operator without giving negator + * or commutator, then defines the other operator of the pair with the + * proper commutator or negator attribute. That style doesn't require + * creation of a shell, and it's the only style that worked right + * before Postgres version 6.5. This code also takes care of the + * situation where the new operator is its own commutator. */ if (selfCommutator) commutatorId = operatorObjectId; @@ -869,7 +874,8 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId) tup = heap_getnext(pg_operator_scan, 0); - /* if the commutator and negator are the same operator, do one update. + /* + * if the commutator and negator are the same operator, do one update. * XXX this is probably useless code --- I doubt it ever makes sense * for commutator and negator to be the same thing... */ @@ -1008,7 +1014,7 @@ OperatorCreate(char *operatorName, if (!leftTypeName && !rightTypeName) elog(ERROR, "OperatorCreate: at least one of leftarg or rightarg must be defined"); - if (! (leftTypeName && rightTypeName)) + if (!(leftTypeName && rightTypeName)) { /* If it's not a binary op, these things mustn't be set: */ if (commutatorName) diff --git a/src/backend/catalog/pg_proc.c b/src/backend/catalog/pg_proc.c index 7c22ce007c..3d31741cfe 100644 --- a/src/backend/catalog/pg_proc.c +++ b/src/backend/catalog/pg_proc.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.28 1999/05/13 07:28:27 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.29 1999/05/25 16:08:11 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -226,11 +226,11 @@ ProcedureCreate(char *procedureName, * function name (the 'prosrc' value) is a known builtin function. * * NOTE: in Postgres versions before 6.5, the SQL name of the created - * function could not be different from the internal name, and 'prosrc' - * wasn't used. So there is code out there that does CREATE FUNCTION - * xyz AS '' LANGUAGE 'internal'. To preserve some modicum of - * backwards compatibility, accept an empty 'prosrc' value as meaning - * the supplied SQL function name. + * function could not be different from the internal name, and + * 'prosrc' wasn't used. So there is code out there that does CREATE + * FUNCTION xyz AS '' LANGUAGE 'internal'. To preserve some modicum + * of backwards compatibility, accept an empty 'prosrc' value as + * meaning the supplied SQL function name. */ if (strcmp(languageName, "internal") == 0) @@ -239,7 +239,7 @@ ProcedureCreate(char *procedureName, prosrc = procedureName; if (fmgr_lookupByName(prosrc) == (func_ptr) NULL) elog(ERROR, - "ProcedureCreate: there is no builtin function named \"%s\"", + "ProcedureCreate: there is no builtin function named \"%s\"", prosrc); } diff --git a/src/backend/catalog/pg_type.c b/src/backend/catalog/pg_type.c index 4d108a825f..54856d4b76 100644 --- a/src/backend/catalog/pg_type.c +++ b/src/backend/catalog/pg_type.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.36 1999/04/20 03:51:14 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.37 1999/05/25 16:08:12 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -400,8 +400,8 @@ TypeCreate(char *typeName, procname = procs[j]; /* - * First look for a 1-argument func with all argtypes 0. - * This is valid for all four kinds of procedure. + * First look for a 1-argument func with all argtypes 0. This is + * valid for all four kinds of procedure. */ MemSet(argList, 0, 8 * sizeof(Oid)); @@ -413,20 +413,23 @@ TypeCreate(char *typeName, if (!HeapTupleIsValid(tup)) { + /* - * For array types, the input procedures may take 3 args - * (data value, element OID, atttypmod); the pg_proc - * argtype signature is 0,0,INT4OID. The output procedures - * may take 2 args (data value, element OID). + * For array types, the input procedures may take 3 args (data + * value, element OID, atttypmod); the pg_proc argtype + * signature is 0,0,INT4OID. The output procedures may take 2 + * args (data value, element OID). */ if (OidIsValid(elementObjectId)) { - int nargs; + int nargs; + if (j % 2) { /* output proc */ nargs = 2; - } else + } + else { /* input proc */ nargs = 3; diff --git a/src/backend/commands/_deadcode/recipe.c b/src/backend/commands/_deadcode/recipe.c index b3ec01b915..997c02d85d 100644 --- a/src/backend/commands/_deadcode/recipe.c +++ b/src/backend/commands/_deadcode/recipe.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/_deadcode/Attic/recipe.c,v 1.2 1999/03/16 04:25:46 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/_deadcode/Attic/recipe.c,v 1.3 1999/05/25 16:08:30 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -121,18 +121,18 @@ static QueryTreeList *tg_parseTeeNode(TgRecipe * r, void beginRecipe(RecipeStmt *stmt) { - TgRecipe *r; - int i, - numTees; + TgRecipe *r; + int i, + numTees; QueryTreeList *qList; - char portalName[1024]; + char portalName[1024]; - Plan *plan; - TupleDesc attinfo; - QueryDesc *queryDesc; - Query *parsetree; + Plan *plan; + TupleDesc attinfo; + QueryDesc *queryDesc; + Query *parsetree; - TeeInfo *teeInfo; + TeeInfo *teeInfo; /* * retrieveRecipe() reads the recipe from the database and returns a @@ -808,21 +808,21 @@ tg_parseTeeNode(TgRecipe * r, static QueryTreeList * tg_parseSubQuery(TgRecipe * r, TgNode * n, TeeInfo * teeInfo) { - TgElement *elem; - char *funcName; - Oid typev[8], /* eight arguments maximum */ - relid; - int i, - parameterCount; + TgElement *elem; + char *funcName; + Oid typev[8], /* eight arguments maximum */ + relid; + int i, + parameterCount; QueryTreeList *qList; /* the parse tree of the nodeElement */ QueryTreeList *inputQlist; /* the list of parse trees for the inputs * to this node */ QueryTreeList *q; - TgNode *child; - Relation rel; - unsigned int len; - TupleDesc tupdesc; + TgNode *child; + Relation rel; + unsigned int len; + TupleDesc tupdesc; qList = NULL; diff --git a/src/backend/commands/_deadcode/version.c b/src/backend/commands/_deadcode/version.c index 9cb98cc5b3..6eddfdccfa 100644 --- a/src/backend/commands/_deadcode/version.c +++ b/src/backend/commands/_deadcode/version.c @@ -5,17 +5,17 @@ * * Copyright (c) 1994, Regents of the University of California * - * The version stuff has not been tested under postgres95 and probably + * The version stuff has not been tested under postgres95 and probably * doesn't work! - jolly 8/19/95 * * - * $Id: version.c,v 1.18 1999/02/13 23:15:12 momjian Exp $ + * $Id: version.c,v 1.19 1999/05/25 16:08:32 momjian Exp $ * * NOTES * At the point the version is defined, 2 physical relations are created * _added and _deleted. * - * In addition, 4 rules are defined which govern the semantics of + * In addition, 4 rules are defined which govern the semantics of * versions w.r.t retrieves, appends, replaces and deletes. * *------------------------------------------------------------------------- diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c index fb1c116bc4..0e3cb83aa9 100644 --- a/src/backend/commands/async.c +++ b/src/backend/commands/async.c @@ -6,7 +6,7 @@ * Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.46 1999/04/25 19:27:43 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.47 1999/05/25 16:08:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -31,17 +31,17 @@ * relname to a list of outstanding NOTIFY requests. Actual processing * happens if and only if we reach transaction commit. At that time (in * routine AtCommit_Notify) we scan pg_listener for matching relnames. - * If the listenerPID in a matching tuple is ours, we just send a notify + * If the listenerPID in a matching tuple is ours, we just send a notify * message to our own front end. If it is not ours, and "notification" * is not already nonzero, we set notification to our own PID and send a * SIGUSR2 signal to the receiving process (indicated by listenerPID). * BTW: if the signal operation fails, we presume that the listener backend - * crashed without removing this tuple, and remove the tuple for it. + * crashed without removing this tuple, and remove the tuple for it. * * 4. Upon receipt of a SIGUSR2 signal, the signal handler can call inbound- * notify processing immediately if this backend is idle (ie, it is * waiting for a frontend command and is not within a transaction block). - * Otherwise the handler may only set a flag, which will cause the + * Otherwise the handler may only set a flag, which will cause the * processing to occur just before we next go idle. * * 5. Inbound-notify processing consists of scanning pg_listener for tuples @@ -53,7 +53,7 @@ * * Note that the system's use of pg_listener is confined to very short * intervals at the end of a transaction that contains NOTIFY statements, - * or during the transaction caused by an inbound SIGUSR2. So the fact that + * or during the transaction caused by an inbound SIGUSR2. So the fact that * pg_listener is a global resource shouldn't cause too much performance * problem. But application authors ought to be discouraged from doing * LISTEN or UNLISTEN near the start of a long transaction --- that would @@ -109,8 +109,8 @@ extern CommandDest whereToSendOutput; /* * State for outbound notifies consists of a list of all relnames NOTIFYed - * in the current transaction. We do not actually perform a NOTIFY until - * and unless the transaction commits. pendingNotifies is NULL if no + * in the current transaction. We do not actually perform a NOTIFY until + * and unless the transaction commits. pendingNotifies is NULL if no * NOTIFYs have been done in the current transaction. */ static Dllist *pendingNotifies = NULL; @@ -125,8 +125,8 @@ static Dllist *pendingNotifies = NULL; * does not grok "volatile", you'd be best advised to compile this file * with all optimization turned off. */ -static volatile int notifyInterruptEnabled = 0; -static volatile int notifyInterruptOccurred = 0; +static volatile int notifyInterruptEnabled = 0; +static volatile int notifyInterruptOccurred = 0; /* True if we've registered an on_shmem_exit cleanup (or at least tried to). */ static int unlistenExitRegistered = 0; @@ -142,7 +142,7 @@ static void ClearPendingNotifies(void); /* *-------------------------------------------------------------- - * Async_Notify + * Async_Notify * * This is executed by the SQL notify command. * @@ -164,28 +164,29 @@ Async_Notify(char *relname) /* * We allocate list memory from the global malloc pool to ensure that - * it will live until we want to use it. This is probably not necessary - * any longer, since we will use it before the end of the transaction. - * DLList only knows how to use malloc() anyway, but we could probably - * palloc() the strings... + * it will live until we want to use it. This is probably not + * necessary any longer, since we will use it before the end of the + * transaction. DLList only knows how to use malloc() anyway, but we + * could probably palloc() the strings... */ if (!pendingNotifies) pendingNotifies = DLNewList(); notifyName = strdup(relname); DLAddHead(pendingNotifies, DLNewElem(notifyName)); + /* * NOTE: we could check to see if pendingNotifies already has an entry - * for relname, and thus avoid making duplicate entries. However, most - * apps probably don't notify the same name multiple times per transaction, - * so we'd likely just be wasting cycles to make such a check. - * AsyncExistsPendingNotify() doesn't really care whether the list - * contains duplicates... + * for relname, and thus avoid making duplicate entries. However, + * most apps probably don't notify the same name multiple times per + * transaction, so we'd likely just be wasting cycles to make such a + * check. AsyncExistsPendingNotify() doesn't really care whether the + * list contains duplicates... */ } /* *-------------------------------------------------------------- - * Async_Listen + * Async_Listen * * This is executed by the SQL listen command. * @@ -274,7 +275,7 @@ Async_Listen(char *relname, int pid) /* * now that we are listening, make sure we will unlisten before dying. */ - if (! unlistenExitRegistered) + if (!unlistenExitRegistered) { if (on_shmem_exit(Async_UnlistenOnExit, (caddr_t) NULL) < 0) elog(NOTICE, "Async_Listen: out of shmem_exit slots"); @@ -284,7 +285,7 @@ Async_Listen(char *relname, int pid) /* *-------------------------------------------------------------- - * Async_Unlisten + * Async_Unlisten * * This is executed by the SQL unlisten command. * @@ -326,14 +327,16 @@ Async_Unlisten(char *relname, int pid) UnlockRelation(lRel, AccessExclusiveLock); heap_close(lRel); } - /* We do not complain about unlistening something not being listened; + + /* + * We do not complain about unlistening something not being listened; * should we? */ } /* *-------------------------------------------------------------- - * Async_UnlistenAll + * Async_UnlistenAll * * Unlisten all relations for this backend. * @@ -379,7 +382,7 @@ Async_UnlistenAll() /* *-------------------------------------------------------------- - * Async_UnlistenOnExit + * Async_UnlistenOnExit * * Clean up the pg_listener table at backend exit. * @@ -398,11 +401,12 @@ Async_UnlistenAll() static void Async_UnlistenOnExit() { + /* - * We need to start/commit a transaction for the unlisten, - * but if there is already an active transaction we had better - * abort that one first. Otherwise we'd end up committing changes - * that probably ought to be discarded. + * We need to start/commit a transaction for the unlisten, but if + * there is already an active transaction we had better abort that one + * first. Otherwise we'd end up committing changes that probably + * ought to be discarded. */ AbortOutOfAnyTransaction(); /* Now we can do the unlisten */ @@ -413,7 +417,7 @@ Async_UnlistenOnExit() /* *-------------------------------------------------------------- - * AtCommit_Notify + * AtCommit_Notify * * This is called at transaction commit. * @@ -450,12 +454,14 @@ AtCommit_Notify() int32 listenerPID; if (!pendingNotifies) - return; /* no NOTIFY statements in this transaction */ + return; /* no NOTIFY statements in this + * transaction */ - /* NOTIFY is disabled if not normal processing mode. - * This test used to be in xact.c, but it seems cleaner to do it here. + /* + * NOTIFY is disabled if not normal processing mode. This test used to + * be in xact.c, but it seems cleaner to do it here. */ - if (! IsNormalProcessingMode()) + if (!IsNormalProcessingMode()) { ClearPendingNotifies(); return; @@ -487,10 +493,13 @@ AtCommit_Notify() if (listenerPID == MyProcPid) { - /* Self-notify: no need to bother with table update. + + /* + * Self-notify: no need to bother with table update. * Indeed, we *must not* clear the notification field in - * this path, or we could lose an outside notify, which'd be - * bad for applications that ignore self-notify messages. + * this path, or we could lose an outside notify, which'd + * be bad for applications that ignore self-notify + * messages. */ TPRINTF(TRACE_NOTIFY, "AtCommit_Notify: notifying self"); NotifyMyFrontEnd(relname, listenerPID); @@ -499,23 +508,27 @@ AtCommit_Notify() { TPRINTF(TRACE_NOTIFY, "AtCommit_Notify: notifying pid %d", listenerPID); + /* - * If someone has already notified this listener, - * we don't bother modifying the table, but we do still send - * a SIGUSR2 signal, just in case that backend missed the - * earlier signal for some reason. It's OK to send the signal - * first, because the other guy can't read pg_listener until - * we unlock it. + * If someone has already notified this listener, we don't + * bother modifying the table, but we do still send a + * SIGUSR2 signal, just in case that backend missed the + * earlier signal for some reason. It's OK to send the + * signal first, because the other guy can't read + * pg_listener until we unlock it. */ #ifdef HAVE_KILL if (kill(listenerPID, SIGUSR2) < 0) { - /* Get rid of pg_listener entry if it refers to a PID + + /* + * Get rid of pg_listener entry if it refers to a PID * that no longer exists. Presumably, that backend * crashed without deleting its pg_listener entries. - * This code used to only delete the entry if errno==ESRCH, - * but as far as I can see we should just do it for any - * failure (certainly at least for EPERM too...) + * This code used to only delete the entry if + * errno==ESRCH, but as far as I can see we should + * just do it for any failure (certainly at least for + * EPERM too...) */ heap_delete(lRel, &lTuple->t_self, NULL); } @@ -536,6 +549,7 @@ AtCommit_Notify() } heap_endscan(sRel); + /* * We do not do RelationUnsetLockForWrite(lRel) here, because the * transaction is about to be committed anyway. @@ -549,7 +563,7 @@ AtCommit_Notify() /* *-------------------------------------------------------------- - * AtAbort_Notify + * AtAbort_Notify * * This is called at transaction abort. * @@ -569,7 +583,7 @@ AtAbort_Notify() /* *-------------------------------------------------------------- - * Async_NotifyHandler + * Async_NotifyHandler * * This is the signal handler for SIGUSR2. * @@ -588,25 +602,30 @@ AtAbort_Notify() void Async_NotifyHandler(SIGNAL_ARGS) { + /* - * Note: this is a SIGNAL HANDLER. You must be very wary what you do here. - * Some helpful soul had this routine sprinkled with TPRINTFs, which would - * likely lead to corruption of stdio buffers if they were ever turned on. + * Note: this is a SIGNAL HANDLER. You must be very wary what you do + * here. Some helpful soul had this routine sprinkled with TPRINTFs, + * which would likely lead to corruption of stdio buffers if they were + * ever turned on. */ if (notifyInterruptEnabled) { - /* I'm not sure whether some flavors of Unix might allow another - * SIGUSR2 occurrence to recursively interrupt this routine. - * To cope with the possibility, we do the same sort of dance that - * EnableNotifyInterrupt must do --- see that routine for comments. + + /* + * I'm not sure whether some flavors of Unix might allow another + * SIGUSR2 occurrence to recursively interrupt this routine. To + * cope with the possibility, we do the same sort of dance that + * EnableNotifyInterrupt must do --- see that routine for + * comments. */ notifyInterruptEnabled = 0; /* disable any recursive signal */ notifyInterruptOccurred = 1; /* do at least one iteration */ for (;;) { notifyInterruptEnabled = 1; - if (! notifyInterruptOccurred) + if (!notifyInterruptOccurred) break; notifyInterruptEnabled = 0; if (notifyInterruptOccurred) @@ -621,14 +640,18 @@ Async_NotifyHandler(SIGNAL_ARGS) } else { - /* In this path it is NOT SAFE to do much of anything, except this: */ + + /* + * In this path it is NOT SAFE to do much of anything, except + * this: + */ notifyInterruptOccurred = 1; } } /* * -------------------------------------------------------------- - * EnableNotifyInterrupt + * EnableNotifyInterrupt * * This is called by the PostgresMain main loop just before waiting * for a frontend command. If we are truly idle (ie, *not* inside @@ -652,26 +675,27 @@ EnableNotifyInterrupt(void) * notifyInterruptOccurred and then set notifyInterruptEnabled, we * could fail to respond promptly to a signal that happens in between * those two steps. (A very small time window, perhaps, but Murphy's - * Law says you can hit it...) Instead, we first set the enable flag, - * then test the occurred flag. If we see an unserviced interrupt - * has occurred, we re-clear the enable flag before going off to do - * the service work. (That prevents re-entrant invocation of - * ProcessIncomingNotify() if another interrupt occurs.) - * If an interrupt comes in between the setting and clearing of - * notifyInterruptEnabled, then it will have done the service - * work and left notifyInterruptOccurred zero, so we have to check - * again after clearing enable. The whole thing has to be in a loop - * in case another interrupt occurs while we're servicing the first. - * Once we get out of the loop, enable is set and we know there is no + * Law says you can hit it...) Instead, we first set the enable flag, + * then test the occurred flag. If we see an unserviced interrupt has + * occurred, we re-clear the enable flag before going off to do the + * service work. (That prevents re-entrant invocation of + * ProcessIncomingNotify() if another interrupt occurs.) If an + * interrupt comes in between the setting and clearing of + * notifyInterruptEnabled, then it will have done the service work and + * left notifyInterruptOccurred zero, so we have to check again after + * clearing enable. The whole thing has to be in a loop in case + * another interrupt occurs while we're servicing the first. Once we + * get out of the loop, enable is set and we know there is no * unserviced interrupt. * * NB: an overenthusiastic optimizing compiler could easily break this - * code. Hopefully, they all understand what "volatile" means these days. + * code. Hopefully, they all understand what "volatile" means these + * days. */ for (;;) { notifyInterruptEnabled = 1; - if (! notifyInterruptOccurred) + if (!notifyInterruptOccurred) break; notifyInterruptEnabled = 0; if (notifyInterruptOccurred) @@ -686,7 +710,7 @@ EnableNotifyInterrupt(void) /* * -------------------------------------------------------------- - * DisableNotifyInterrupt + * DisableNotifyInterrupt * * This is called by the PostgresMain main loop just after receiving * a frontend command. Signal handler execution of inbound notifies @@ -702,7 +726,7 @@ DisableNotifyInterrupt(void) /* * -------------------------------------------------------------- - * ProcessIncomingNotify + * ProcessIncomingNotify * * Deal with arriving NOTIFYs from other backends. * This is called either directly from the SIGUSR2 signal handler, @@ -777,6 +801,7 @@ ProcessIncomingNotify(void) } } heap_endscan(sRel); + /* * We do not do RelationUnsetLockForWrite(lRel) here, because the * transaction is about to be committed anyway. @@ -785,7 +810,10 @@ ProcessIncomingNotify(void) CommitTransactionCommand(); - /* Must flush the notify messages to ensure frontend gets them promptly. */ + /* + * Must flush the notify messages to ensure frontend gets them + * promptly. + */ pq_flush(); PS_SET_STATUS("idle"); @@ -800,20 +828,22 @@ NotifyMyFrontEnd(char *relname, int32 listenerPID) if (whereToSendOutput == Remote) { StringInfoData buf; + pq_beginmessage(&buf); pq_sendbyte(&buf, 'A'); pq_sendint(&buf, listenerPID, sizeof(int32)); pq_sendstring(&buf, relname); pq_endmessage(&buf); - /* NOTE: we do not do pq_flush() here. For a self-notify, it will + + /* + * NOTE: we do not do pq_flush() here. For a self-notify, it will * happen at the end of the transaction, and for incoming notifies - * ProcessIncomingNotify will do it after finding all the notifies. + * ProcessIncomingNotify will do it after finding all the + * notifies. */ } else - { elog(NOTICE, "NOTIFY for %s", relname); - } } /* Does pendingNotifies include the given relname? @@ -847,10 +877,12 @@ ClearPendingNotifies() if (pendingNotifies) { - /* Since the referenced strings are malloc'd, we have to scan the + + /* + * Since the referenced strings are malloc'd, we have to scan the * list and delete them individually. If we used palloc for the - * strings then we could just do DLFreeList to get rid of both - * the list nodes and the list base... + * strings then we could just do DLFreeList to get rid of both the + * list nodes and the list base... */ while ((p = DLRemHead(pendingNotifies)) != NULL) { diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c index ae6cafa7b7..29fb0d9a49 100644 --- a/src/backend/commands/cluster.c +++ b/src/backend/commands/cluster.c @@ -14,7 +14,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.38 1999/02/13 23:15:02 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.39 1999/05/25 16:08:16 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -236,17 +236,17 @@ copy_heap(Oid OIDOldHeap) static void copy_index(Oid OIDOldIndex, Oid OIDNewHeap) { - Relation OldIndex, - NewHeap; - HeapTuple Old_pg_index_Tuple, - Old_pg_index_relation_Tuple, - pg_proc_Tuple; + Relation OldIndex, + NewHeap; + HeapTuple Old_pg_index_Tuple, + Old_pg_index_relation_Tuple, + pg_proc_Tuple; Form_pg_index Old_pg_index_Form; Form_pg_class Old_pg_index_relation_Form; - Form_pg_proc pg_proc_Form; - char *NewIndexName; - AttrNumber *attnumP; - int natts; + Form_pg_proc pg_proc_Form; + char *NewIndexName; + AttrNumber *attnumP; + int natts; FuncIndexInfo *finfo; NewHeap = heap_open(OIDNewHeap); @@ -259,14 +259,14 @@ copy_index(Oid OIDOldIndex, Oid OIDNewHeap) */ Old_pg_index_Tuple = SearchSysCacheTuple(INDEXRELID, ObjectIdGetDatum(RelationGetRelid(OldIndex)), - 0, 0, 0); + 0, 0, 0); Assert(Old_pg_index_Tuple); Old_pg_index_Form = (Form_pg_index) GETSTRUCT(Old_pg_index_Tuple); Old_pg_index_relation_Tuple = SearchSysCacheTuple(RELOID, ObjectIdGetDatum(RelationGetRelid(OldIndex)), - 0, 0, 0); + 0, 0, 0); Assert(Old_pg_index_relation_Tuple); Old_pg_index_relation_Form = (Form_pg_class) GETSTRUCT(Old_pg_index_relation_Tuple); @@ -296,7 +296,7 @@ copy_index(Oid OIDOldIndex, Oid OIDNewHeap) pg_proc_Tuple = SearchSysCacheTuple(PROOID, ObjectIdGetDatum(Old_pg_index_Form->indproc), - 0, 0, 0); + 0, 0, 0); Assert(pg_proc_Tuple); pg_proc_Form = (Form_pg_proc) GETSTRUCT(pg_proc_Tuple); @@ -319,7 +319,7 @@ copy_index(Oid OIDOldIndex, Oid OIDNewHeap) (uint16) 0, (Datum) NULL, NULL, Old_pg_index_Form->indislossy, Old_pg_index_Form->indisunique, - Old_pg_index_Form->indisprimary); + Old_pg_index_Form->indisprimary); heap_close(OldIndex); heap_close(NewHeap); @@ -329,14 +329,14 @@ copy_index(Oid OIDOldIndex, Oid OIDNewHeap) static void rebuildheap(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex) { - Relation LocalNewHeap, - LocalOldHeap, - LocalOldIndex; - IndexScanDesc ScanDesc; - RetrieveIndexResult ScanResult; - HeapTupleData LocalHeapTuple; - Buffer LocalBuffer; - Oid OIDNewHeapInsert; + Relation LocalNewHeap, + LocalOldHeap, + LocalOldIndex; + IndexScanDesc ScanDesc; + RetrieveIndexResult ScanResult; + HeapTupleData LocalHeapTuple; + Buffer LocalBuffer; + Oid OIDNewHeapInsert; /* * Open the relations I need. Scan through the OldHeap on the OldIndex diff --git a/src/backend/commands/command.c b/src/backend/commands/command.c index 7d8f72d51f..f4c0f2115a 100644 --- a/src/backend/commands/command.c +++ b/src/backend/commands/command.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.44 1999/05/10 00:44:56 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.45 1999/05/25 16:08:17 momjian Exp $ * * NOTES * The PortalExecutorHeapMemory crap needs to be eliminated @@ -117,18 +117,18 @@ PerformPortalFetch(char *name, } /* ---------------- - * Create a const node from the given count value + * Create a const node from the given count value * ---------------- */ memset(&limcount, 0, sizeof(limcount)); - limcount.type = T_Const; - limcount.consttype = INT4OID; - limcount.constlen = sizeof(int4); - limcount.constvalue = (Datum)count; - limcount.constisnull = FALSE; + limcount.type = T_Const; + limcount.consttype = INT4OID; + limcount.constlen = sizeof(int4); + limcount.constvalue = (Datum) count; + limcount.constisnull = FALSE; limcount.constbyval = TRUE; limcount.constisset = FALSE; - limcount.constiscast = FALSE; + limcount.constiscast = FALSE; /* ---------------- @@ -193,8 +193,8 @@ PerformPortalFetch(char *name, */ PortalExecutorHeapMemory = (MemoryContext) PortalGetHeapMemory(portal); - ExecutorRun(queryDesc, PortalGetState(portal), feature, - (Node *)NULL, (Node *)&limcount); + ExecutorRun(queryDesc, PortalGetState(portal), feature, + (Node *) NULL, (Node *) &limcount); if (dest == None) /* MOVE */ pfree(queryDesc); @@ -211,7 +211,7 @@ PerformPortalFetch(char *name, * ---------------- */ MemoryContextSwitchTo( - (MemoryContext) PortalGetHeapMemory(GetPortalByName(NULL))); + (MemoryContext) PortalGetHeapMemory(GetPortalByName(NULL))); } /* -------------------------------- @@ -503,7 +503,7 @@ PerformAddAttribute(char *relationName, heap_replace(rel, &reltup->t_self, reltup, NULL); { - HeapTuple temptup; + HeapTuple temptup; if ((temptup = get_temp_rel_by_name(relationName)) != NULL) ((Form_pg_class) GETSTRUCT(temptup))->relnatts = maxatts; @@ -519,7 +519,7 @@ PerformAddAttribute(char *relationName, } void -LockTableCommand(LockStmt *lockstmt) +LockTableCommand(LockStmt * lockstmt) { Relation rel; int aclresult; diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c index 9347c6d67d..d2b98ec4bc 100644 --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@ -6,7 +6,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.76 1999/05/10 00:44:58 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.77 1999/05/25 16:08:19 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -70,111 +70,138 @@ static int CountTuples(Relation relation); static int lineno; -/* +/* * Internal communications functions */ inline void CopySendData(void *databuf, int datasize, FILE *fp); inline void CopySendString(char *str, FILE *fp); inline void CopySendChar(char c, FILE *fp); inline void CopyGetData(void *databuf, int datasize, FILE *fp); -inline int CopyGetChar(FILE *fp); -inline int CopyGetEof(FILE *fp); -inline int CopyPeekChar(FILE *fp); +inline int CopyGetChar(FILE *fp); +inline int CopyGetEof(FILE *fp); +inline int CopyPeekChar(FILE *fp); inline void CopyDonePeek(FILE *fp, int c, int pickup); /* * CopySendData sends output data either to the file - * specified by fp or, if fp is NULL, using the standard - * backend->frontend functions + * specified by fp or, if fp is NULL, using the standard + * backend->frontend functions * * CopySendString does the same for null-terminated strings * CopySendChar does the same for single characters * * NB: no data conversion is applied by these functions */ -inline void CopySendData(void *databuf, int datasize, FILE *fp) { - if (!fp) - pq_putbytes((char*) databuf, datasize); - else - fwrite(databuf, datasize, 1, fp); -} - -inline void CopySendString(char *str, FILE *fp) { - CopySendData(str,strlen(str),fp); +inline void +CopySendData(void *databuf, int datasize, FILE *fp) +{ + if (!fp) + pq_putbytes((char *) databuf, datasize); + else + fwrite(databuf, datasize, 1, fp); } -inline void CopySendChar(char c, FILE *fp) { - CopySendData(&c,1,fp); +inline void +CopySendString(char *str, FILE *fp) +{ + CopySendData(str, strlen(str), fp); +} + +inline void +CopySendChar(char c, FILE *fp) +{ + CopySendData(&c, 1, fp); } /* * CopyGetData reads output data either from the file - * specified by fp or, if fp is NULL, using the standard - * backend->frontend functions + * specified by fp or, if fp is NULL, using the standard + * backend->frontend functions * * CopyGetChar does the same for single characters * CopyGetEof checks if it's EOF on the input * * NB: no data conversion is applied by these functions */ -inline void CopyGetData(void *databuf, int datasize, FILE *fp) { - if (!fp) - pq_getbytes((char*) databuf, datasize); - else - fread(databuf, datasize, 1, fp); +inline void +CopyGetData(void *databuf, int datasize, FILE *fp) +{ + if (!fp) + pq_getbytes((char *) databuf, datasize); + else + fread(databuf, datasize, 1, fp); } -inline int CopyGetChar(FILE *fp) { - if (!fp) - { - unsigned char ch; - if (pq_getbytes((char*) &ch, 1)) - return EOF; - return ch; - } - else - return getc(fp); +inline int +CopyGetChar(FILE *fp) +{ + if (!fp) + { + unsigned char ch; + + if (pq_getbytes((char *) &ch, 1)) + return EOF; + return ch; + } + else + return getc(fp); } -inline int CopyGetEof(FILE *fp) { - if (!fp) - return 0; /* Never return EOF when talking to frontend ? */ - else - return feof(fp); +inline int +CopyGetEof(FILE *fp) +{ + if (!fp) + return 0; /* Never return EOF when talking to + * frontend ? */ + else + return feof(fp); } /* * CopyPeekChar reads a byte in "peekable" mode. * after each call to CopyPeekChar, a call to CopyDonePeek _must_ * follow. - * CopyDonePeek will either take the peeked char off the steam + * CopyDonePeek will either take the peeked char off the steam * (if pickup is != 0) or leave it on the stream (if pickup == 0) */ -inline int CopyPeekChar(FILE *fp) { - if (!fp) - return pq_peekbyte(); - else - return getc(fp); +inline int +CopyPeekChar(FILE *fp) +{ + if (!fp) + return pq_peekbyte(); + else + return getc(fp); } -inline void CopyDonePeek(FILE *fp, int c, int pickup) { - if (!fp) { - if (pickup) { - /* We want to pick it up - just receive again into dummy buffer */ - char c; - pq_getbytes(&c, 1); - } - /* If we didn't want to pick it up, just leave it where it sits */ - } - else { - if (!pickup) { - /* We don't want to pick it up - so put it back in there */ - ungetc(c,fp); - } - /* If we wanted to pick it up, it's already there */ - } +inline void +CopyDonePeek(FILE *fp, int c, int pickup) +{ + if (!fp) + { + if (pickup) + { + + /* + * We want to pick it up - just receive again into dummy + * buffer + */ + char c; + + pq_getbytes(&c, 1); + } + /* If we didn't want to pick it up, just leave it where it sits */ + } + else + { + if (!pickup) + { + /* We don't want to pick it up - so put it back in there */ + ungetc(c, fp); + } + /* If we wanted to pick it up, it's already there */ + } } - + /* @@ -317,7 +344,7 @@ DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe, else if (!from) { if (!binary) - CopySendData("\\.\n",3,fp); + CopySendData("\\.\n", 3, fp); if (IsUnderPostmaster) pq_endcopyout(false); } @@ -395,8 +422,8 @@ CopyTo(Relation rel, bool binary, bool oids, FILE *fp, char *delim) if (oids && !binary) { - CopySendString(oidout(tuple->t_data->t_oid),fp); - CopySendChar(delim[0],fp); + CopySendString(oidout(tuple->t_data->t_oid), fp); + CopySendChar(delim[0], fp); } for (i = 0; i < attr_count; i++) @@ -466,8 +493,8 @@ CopyTo(Relation rel, bool binary, bool oids, FILE *fp, char *delim) } } } - CopySendData((char *) tuple->t_data + tuple->t_data->t_hoff, - length, fp); + CopySendData((char *) tuple->t_data + tuple->t_data->t_hoff, + length, fp); } } @@ -521,7 +548,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim) Node **indexPred = NULL; TupleDesc rtupdesc; ExprContext *econtext = NULL; - EState *estate = makeNode(EState); /* for ExecConstraints() */ + EState *estate = makeNode(EState); /* for ExecConstraints() */ #ifndef OMIT_PARTIAL_INDEX TupleTable tupleTable; @@ -566,11 +593,11 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim) itupdescArr[i] = RelationGetDescr(index_rels[i]); pgIndexTup = SearchSysCacheTuple(INDEXRELID, ObjectIdGetDatum(RelationGetRelid(index_rels[i])), - 0, 0, 0); + 0, 0, 0); Assert(pgIndexTup); pgIndexP[i] = (Form_pg_index) GETSTRUCT(pgIndexTup); for (attnumP = &(pgIndexP[i]->indkey[0]), natts = 0; - natts < INDEX_MAX_KEYS && *attnumP != InvalidAttrNumber; + natts < INDEX_MAX_KEYS && *attnumP != InvalidAttrNumber; attnumP++, natts++); if (pgIndexP[i]->indproc != InvalidOid) { @@ -777,7 +804,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim) } else if (nulls[i] != 'n') { - ptr = (char *)att_align(ptr, attr[i]->attlen, attr[i]->attalign); + ptr = (char *) att_align(ptr, attr[i]->attlen, attr[i]->attalign); values[i] = (Datum) ptr; ptr = att_addlength(ptr, attr[i]->attlen, ptr); } @@ -888,7 +915,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim) pfree(index_nulls); pfree(idatum); pfree(byval); - + if (!binary) { pfree(in_functions); @@ -903,7 +930,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim) { if (index_rels[i] == NULL) continue; - if ((index_rels[i])->rd_rel->relam != BTREE_AM_OID && + if ((index_rels[i])->rd_rel->relam != BTREE_AM_OID && (index_rels[i])->rd_rel->relam != HASH_AM_OID) UnlockRelation(index_rels[i], AccessExclusiveLock); index_close(index_rels[i]); @@ -1022,12 +1049,12 @@ GetIndexRelations(Oid main_relation_oid, { index_relation_oid = (Oid) DatumGetInt32(heap_getattr(tuple, 2, - tupDesc, &isnull)); + tupDesc, &isnull)); if (index_relation_oid == main_relation_oid) { scan->index_rel_oid = (Oid) DatumGetInt32(heap_getattr(tuple, - Anum_pg_index_indexrelid, - tupDesc, &isnull)); + Anum_pg_index_indexrelid, + tupDesc, &isnull)); (*n_indices)++; scan->next = (RelationList *) palloc(sizeof(RelationList)); scan = scan->next; @@ -1047,7 +1074,7 @@ GetIndexRelations(Oid main_relation_oid, { (*index_rels)[i] = index_open(scan->index_rel_oid); /* comments in execUtils.c */ - if ((*index_rels)[i] != NULL && + if ((*index_rels)[i] != NULL && ((*index_rels)[i])->rd_rel->relam != BTREE_AM_OID && ((*index_rels)[i])->rd_rel->relam != HASH_AM_OID) LockRelation((*index_rels)[i], AccessExclusiveLock); @@ -1176,26 +1203,29 @@ CopyReadAttribute(FILE *fp, bool *isnull, char *delim) if (ISOCTAL(c)) { val = (val << 3) + VALUE(c); - CopyDonePeek(fp, c, 1); /* Pick up the character! */ + CopyDonePeek(fp, c, 1); /* Pick up the + * character! */ c = CopyPeekChar(fp); - if (ISOCTAL(c)) { - CopyDonePeek(fp,c,1); /* pick up! */ + if (ISOCTAL(c)) + { + CopyDonePeek(fp, c, 1); /* pick up! */ val = (val << 3) + VALUE(c); } else { - if (CopyGetEof(fp)) { - CopyDonePeek(fp,c,1); /* pick up */ + if (CopyGetEof(fp)) + { + CopyDonePeek(fp, c, 1); /* pick up */ return NULL; } - CopyDonePeek(fp,c,0); /* Return to stream! */ + CopyDonePeek(fp, c, 0); /* Return to stream! */ } } else { if (CopyGetEof(fp)) return NULL; - CopyDonePeek(fp,c,0); /* Return to stream! */ + CopyDonePeek(fp, c, 0); /* Return to stream! */ } c = val & 0377; } diff --git a/src/backend/commands/creatinh.c b/src/backend/commands/creatinh.c index 0d4c3fc8b8..e9c5fdcd89 100644 --- a/src/backend/commands/creatinh.c +++ b/src/backend/commands/creatinh.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.40 1999/02/13 23:15:05 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.41 1999/05/25 16:08:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -39,7 +39,7 @@ static List *MergeAttributes(List *schema, List *supers, List **supconstr); static void StoreCatalogInheritance(Oid relationId, List *supers); /* ---------------------------------------------------------------- - * DefineRelation + * DefineRelation * Creates a new relation. * ---------------------------------------------------------------- */ @@ -90,10 +90,10 @@ DefineRelation(CreateStmt *stmt, char relkind) if (constraints != NIL) { - List *entry; - int nconstr = length(constraints), - ncheck = 0, - i; + List *entry; + int nconstr = length(constraints), + ncheck = 0, + i; ConstrCheck *check = (ConstrCheck *) palloc(nconstr * sizeof(ConstrCheck)); foreach(entry, constraints) @@ -107,9 +107,9 @@ DefineRelation(CreateStmt *stmt, char relkind) for (i = 0; i < ncheck; i++) { if (strcmp(check[i].ccname, cdef->name) == 0) - elog(ERROR, - "DefineRelation: name (%s) of CHECK constraint duplicated", - cdef->name); + elog(ERROR, + "DefineRelation: name (%s) of CHECK constraint duplicated", + cdef->name); } check[ncheck].ccname = cdef->name; } @@ -145,7 +145,7 @@ DefineRelation(CreateStmt *stmt, char relkind) } /* - * RemoveRelation + * RemoveRelation * Deletes a new relation. * * Exceptions: @@ -164,7 +164,7 @@ RemoveRelation(char *name) /* - * MergeAttributes + * MergeAttributes * Returns new schema given initial schema and supers. * * @@ -276,8 +276,8 @@ MergeAttributes(List *schema, List *supers, List **supconstr) */ attributeName = (attribute->attname).data; tuple = SearchSysCacheTuple(TYPOID, - ObjectIdGetDatum(attribute->atttypid), - 0, 0, 0); + ObjectIdGetDatum(attribute->atttypid), + 0, 0, 0); Assert(HeapTupleIsValid(tuple)); attributeType = (((Form_pg_type) GETSTRUCT(tuple))->typname).data; @@ -365,7 +365,7 @@ MergeAttributes(List *schema, List *supers, List **supconstr) } /* - * StoreCatalogInheritance + * StoreCatalogInheritance * Updates the system catalogs with proper inheritance information. */ static void @@ -411,9 +411,9 @@ StoreCatalogInheritance(Oid relationId, List *supers) */ idList = lappendi(idList, tuple->t_data->t_oid); - datum[0] = ObjectIdGetDatum(relationId); /* inhrel */ - datum[1] = ObjectIdGetDatum(tuple->t_data->t_oid); /* inhparent */ - datum[2] = Int16GetDatum(seqNumber); /* inhseqno */ + datum[0] = ObjectIdGetDatum(relationId); /* inhrel */ + datum[1] = ObjectIdGetDatum(tuple->t_data->t_oid); /* inhparent */ + datum[2] = Int16GetDatum(seqNumber); /* inhseqno */ nullarr[0] = ' '; nullarr[1] = ' '; @@ -467,8 +467,8 @@ StoreCatalogInheritance(Oid relationId, List *supers) break; lnext(current) = lconsi(((Form_pg_inherits) - GETSTRUCT(tuple))->inhparent, - NIL); + GETSTRUCT(tuple))->inhparent, + NIL); current = lnext(current); } diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c index 943d7acb43..06f0a8115a 100644 --- a/src/backend/commands/dbcommands.c +++ b/src/backend/commands/dbcommands.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.34 1999/05/10 00:44:59 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.35 1999/05/25 16:08:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -47,8 +47,8 @@ createdb(char *dbname, char *dbpath, int encoding, CommandDest dest) Oid db_id; int4 user_id; char buf[512]; - char *lp, - loc[512]; + char *lp, + loc[512]; /* * If this call returns, the database does not exist and we're allowed @@ -80,13 +80,13 @@ createdb(char *dbname, char *dbpath, int encoding, CommandDest dest) elog(ERROR, "Unable to create database directory '%s'", lp); snprintf(buf, 512, "%s %s%cbase%ctemplate1%c* %s", - COPY_CMD, DataDir, SEP_CHAR, SEP_CHAR, SEP_CHAR, lp); + COPY_CMD, DataDir, SEP_CHAR, SEP_CHAR, SEP_CHAR, lp); system(buf); - snprintf(buf, 512, - "insert into pg_database (datname, datdba, encoding, datpath)" - " values ('%s', '%d', '%d', '%s');", dbname, user_id, encoding, - loc); + snprintf(buf, 512, + "insert into pg_database (datname, datdba, encoding, datpath)" + " values ('%s', '%d', '%d', '%s');", dbname, user_id, encoding, + loc); pg_exec_query_dest(buf, dest, false); } @@ -96,9 +96,9 @@ destroydb(char *dbname, CommandDest dest) { int4 user_id; Oid db_id; - char *path, - dbpath[MAXPGPATH + 1], - buf[512]; + char *path, + dbpath[MAXPGPATH + 1], + buf[512]; /* * If this call returns, the database exists and we're allowed to @@ -122,9 +122,9 @@ destroydb(char *dbname, CommandDest dest) * remove the pg_database tuple FIRST, this may fail due to * permissions problems */ - snprintf(buf, 512, - "delete from pg_database where pg_database.oid = \'%u\'::oid", db_id); - pg_exec_query_dest(buf ,dest, false); + snprintf(buf, 512, + "delete from pg_database where pg_database.oid = \'%u\'::oid", db_id); + pg_exec_query_dest(buf, dest, false); /* drop pages for this database that are in the shared buffer cache */ DropBuffers(db_id); @@ -294,13 +294,13 @@ static void stop_vacuum(char *dbpath, char *dbname) { char filename[256]; - FILE *fp; + FILE *fp; int pid; if (strchr(dbpath, SEP_CHAR) != 0) { - snprintf(filename, 256, "%s%cbase%c%s%c%s.vacuum", - DataDir, SEP_CHAR, SEP_CHAR, dbname, SEP_CHAR, dbname); + snprintf(filename, 256, "%s%cbase%c%s%c%s.vacuum", + DataDir, SEP_CHAR, SEP_CHAR, dbname, SEP_CHAR, dbname); } else snprintf(filename, 256, "%s%c%s.vacuum", dbpath, SEP_CHAR, dbname); diff --git a/src/backend/commands/define.c b/src/backend/commands/define.c index 04bd1e8963..34d322524c 100644 --- a/src/backend/commands/define.c +++ b/src/backend/commands/define.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.28 1999/04/09 22:35:41 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.29 1999/05/25 16:08:22 momjian Exp $ * * DESCRIPTION * The "DefineFoo" routines take the parse tree and pick out the @@ -203,7 +203,7 @@ interpret_AS_clause(const char *languageName, const char *as, /* - * CreateFunction + * CreateFunction * Execute a CREATE FUNCTION utility statement. * */ @@ -574,7 +574,7 @@ DefineAggregate(char *aggName, List *parameters) } /* - * DefineType + * DefineType * Registers a new type. * */ diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index 6a04417964..66fcd8647b 100644 --- a/src/backend/commands/explain.c +++ b/src/backend/commands/explain.c @@ -4,7 +4,7 @@ * * Copyright (c) 1994-5, Regents of the University of California * - * $Id: explain.c,v 1.36 1999/05/09 23:31:45 tgl Exp $ + * $Id: explain.c,v 1.37 1999/05/25 16:08:23 momjian Exp $ * */ #include @@ -34,7 +34,7 @@ typedef struct ExplainState } ExplainState; static char *Explain_PlanToString(Plan *plan, ExplainState *es); -static void printLongNotice(const char * header, const char * message); +static void printLongNotice(const char *header, const char *message); static void ExplainOneQuery(Query *query, bool verbose, CommandDest dest); @@ -46,8 +46,8 @@ static void ExplainOneQuery(Query *query, bool verbose, CommandDest dest); void ExplainQuery(Query *query, bool verbose, CommandDest dest) { - List *rewritten; - List *l; + List *rewritten; + List *l; /* rewriter and planner may not work in aborted state? */ if (IsAbortedTransactionBlockState()) @@ -145,10 +145,10 @@ ExplainOneQuery(Query *query, bool verbose, CommandDest dest) static void explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es) { - List *l; + List *l; Relation relation; - char *pname; - int i; + char *pname; + int i; if (plan == NULL) { @@ -208,15 +208,13 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es) case T_IndexScan: appendStringInfo(str, " using "); i = 0; - foreach (l, ((IndexScan *) plan)->indxid) + foreach(l, ((IndexScan *) plan)->indxid) { relation = RelationIdCacheGetRelation((int) lfirst(l)); if (++i > 1) - { appendStringInfo(str, ", "); - } - appendStringInfo(str, - stringStringInfo((RelationGetRelationName(relation))->data)); + appendStringInfo(str, + stringStringInfo((RelationGetRelationName(relation))->data)); } case T_SeqScan: if (((Scan *) plan)->scanrelid > 0) @@ -227,7 +225,7 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es) if (strcmp(rte->refname, rte->relname) != 0) { appendStringInfo(str, "%s ", - stringStringInfo(rte->relname)); + stringStringInfo(rte->relname)); } appendStringInfo(str, stringStringInfo(rte->refname)); } @@ -238,7 +236,7 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es) if (es->printCost) { appendStringInfo(str, " (cost=%.2f rows=%d width=%d)", - plan->cost, plan->plan_size, plan->plan_width); + plan->cost, plan->plan_size, plan->plan_width); } appendStringInfo(str, "\n"); @@ -248,18 +246,14 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es) List *saved_rtable = es->rtable; List *lst; - for (i = 0; i < indent; i++) - { + for (i = 0; i < indent; i++) appendStringInfo(str, " "); - } appendStringInfo(str, " InitPlan\n"); foreach(lst, plan->initPlan) { es->rtable = ((SubPlan *) lfirst(lst))->rtable; for (i = 0; i < indent; i++) - { appendStringInfo(str, " "); - } appendStringInfo(str, " -> "); explain_outNode(str, ((SubPlan *) lfirst(lst))->plan, indent + 2, es); } @@ -270,9 +264,7 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es) if (outerPlan(plan)) { for (i = 0; i < indent; i++) - { appendStringInfo(str, " "); - } appendStringInfo(str, " -> "); explain_outNode(str, outerPlan(plan), indent + 3, es); } @@ -281,9 +273,7 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es) if (innerPlan(plan)) { for (i = 0; i < indent; i++) - { appendStringInfo(str, " "); - } appendStringInfo(str, " -> "); explain_outNode(str, innerPlan(plan), indent + 3, es); } @@ -295,17 +285,13 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es) List *lst; for (i = 0; i < indent; i++) - { appendStringInfo(str, " "); - } appendStringInfo(str, " SubPlan\n"); foreach(lst, plan->subPlan) { es->rtable = ((SubPlan *) lfirst(lst))->rtable; for (i = 0; i < indent; i++) - { appendStringInfo(str, " "); - } appendStringInfo(str, " -> "); explain_outNode(str, ((SubPlan *) lfirst(lst))->plan, indent + 4, es); } @@ -336,9 +322,7 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es) es->rtable = nth(whichplan, appendplan->unionrtables); for (i = 0; i < indent; i++) - { appendStringInfo(str, " "); - } appendStringInfo(str, " -> "); explain_outNode(str, subnode, indent + 4, es); @@ -353,7 +337,7 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es) static char * Explain_PlanToString(Plan *plan, ExplainState *es) { - StringInfoData str; + StringInfoData str; /* see stringinfo.h for an explanation of this maneuver */ initStringInfo(&str); @@ -367,9 +351,9 @@ Explain_PlanToString(Plan *plan, ExplainState *es) * This is a crock ... there shouldn't be an upper limit to what you can elog(). */ static void -printLongNotice(const char * header, const char * message) +printLongNotice(const char *header, const char *message) { - int len = strlen(message); + int len = strlen(message); elog(NOTICE, "%.20s%.*s", header, ELOG_MAXLEN - 64, message); len -= ELOG_MAXLEN - 64; diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 5907205bd8..e7f047477c 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.3 1999/05/10 00:44:59 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.4 1999/05/25 16:08:24 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -53,7 +53,7 @@ static void NormIndexAttrs(List *attList, AttrNumber *attNumP, static char *GetDefaultOpClass(Oid atttypid); /* - * DefineIndex + * DefineIndex * Creates a new index. * * 'attributeList' is a list of IndexElem specifying either a functional @@ -164,7 +164,7 @@ DefineIndex(char *heapRelationName, if (nargs > INDEX_MAX_KEYS) { elog(ERROR, - "Too many args to function, limit of %d", INDEX_MAX_KEYS); + "Too many args to function, limit of %d", INDEX_MAX_KEYS); } FIsetnArgs(&fInfo, nargs); @@ -207,7 +207,7 @@ DefineIndex(char *heapRelationName, /* - * ExtendIndex + * ExtendIndex * Extends a partial index. * * Exceptions: @@ -304,7 +304,7 @@ ExtendIndex(char *indexRelationName, Expr *predicate, List *rangetable) predInfo->oldPred = oldPred; attributeNumberA = (AttrNumber *) palloc(numberOfAttributes * - sizeof attributeNumberA[0]); + sizeof attributeNumberA[0]); classObjectId = (Oid *) palloc(numberOfAttributes * sizeof classObjectId[0]); @@ -501,7 +501,7 @@ NormIndexAttrs(List *attList, /* list of IndexElem's */ /* we just set the type name because that is all we need */ attribute->typename = makeNode(TypeName); attribute->typename->name = nameout(&((Form_pg_type) GETSTRUCT(tuple))->typname); - + /* we all need the typmod for the char and varchar types. */ attribute->typename->typmod = attform->atttypmod; } @@ -547,7 +547,7 @@ GetDefaultOpClass(Oid atttypid) } /* - * RemoveIndex + * RemoveIndex * Deletes an index. * * Exceptions: diff --git a/src/backend/commands/remove.c b/src/backend/commands/remove.c index 5334bd347d..7ae4c2c176 100644 --- a/src/backend/commands/remove.c +++ b/src/backend/commands/remove.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.32 1999/02/13 23:15:08 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.33 1999/05/25 16:08:25 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -36,7 +36,7 @@ #endif /* - * RemoveOperator + * RemoveOperator * Deletes an operator. * * Exceptions: @@ -288,7 +288,7 @@ RemoveType(char *typeName) /* type name to be removed */ } /* - * RemoveFunction + * RemoveFunction * Deletes a function. * * Exceptions: diff --git a/src/backend/commands/rename.c b/src/backend/commands/rename.c index 457facdd8f..061534054a 100644 --- a/src/backend/commands/rename.c +++ b/src/backend/commands/rename.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.24 1999/05/17 18:24:48 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.25 1999/05/25 16:08:26 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -142,7 +142,7 @@ renameatt(char *relname, } } - + if ((relid = RelnameFindRelid(relname)) == InvalidOid) elog(ERROR, "renameatt: relation \"%s\" nonexistent", relname); @@ -201,7 +201,7 @@ renameatt(char *relname, void renamerel(char *oldrelname, char *newrelname) { - int i; + int i; Relation relrelation; /* for RELATION relation */ HeapTuple oldreltup; char oldpath[MAXPGPATH], @@ -237,7 +237,7 @@ renamerel(char *oldrelname, char *newrelname) { sprintf(toldpath, "%s.%d", oldpath, i); sprintf(tnewpath, "%s.%d", newpath, i); - if(rename(toldpath, tnewpath) < 0) + if (rename(toldpath, tnewpath) < 0) break; } diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c index d76eb07481..a6f18e01d3 100644 --- a/src/backend/commands/sequence.c +++ b/src/backend/commands/sequence.c @@ -66,7 +66,7 @@ static void init_params(CreateSeqStmt *seq, Form_pg_sequence new); static int get_param(DefElem *def); /* - * DefineSequence + * DefineSequence * Creates a new sequence relation */ void @@ -218,8 +218,8 @@ nextval(struct varlena * seqin) return elm->last; } - seq = read_info("nextval", elm, &buf); /* lock page' buffer and read - * tuple */ + seq = read_info("nextval", elm, &buf); /* lock page' buffer and + * read tuple */ next = result = seq->last_value; incby = seq->increment_by; @@ -327,8 +327,8 @@ setval(struct varlena * seqin, int4 next) /* open and AccessShareLock sequence */ elm = init_sequence("setval", seqname); - seq = read_info("setval", elm, &buf); /* lock page' buffer and read - * tuple */ + seq = read_info("setval", elm, &buf); /* lock page' buffer and + * read tuple */ if (seq->cache_value != 1) { @@ -361,11 +361,11 @@ setval(struct varlena * seqin, int4 next) static Form_pg_sequence read_info(char *caller, SeqTable elm, Buffer *buf) { - PageHeader page; - ItemId lp; - HeapTupleData tuple; + PageHeader page; + ItemId lp; + HeapTupleData tuple; sequence_magic *sm; - Form_pg_sequence seq; + Form_pg_sequence seq; if (RelationGetNumberOfBlocks(elm->rel) != 1) elog(ERROR, "%s.%s: invalid number of blocks in sequence", @@ -464,7 +464,7 @@ init_sequence(char *caller, char *name) /* - * CloseSequences + * CloseSequences * is calling by xact mgr at commit/abort. */ void diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c index 09b7fdcbc3..cc3d27599c 100644 --- a/src/backend/commands/trigger.c +++ b/src/backend/commands/trigger.c @@ -362,9 +362,9 @@ RelationBuildTriggers(Relation relation) Form_pg_trigger pg_trigger; Relation irel; ScanKeyData skey; - HeapTupleData tuple; - IndexScanDesc sd; - RetrieveIndexResult indexRes; + HeapTupleData tuple; + IndexScanDesc sd; + RetrieveIndexResult indexRes; Buffer buffer; struct varlena *val; bool isnull; @@ -659,14 +659,14 @@ ExecARInsertTriggers(Relation rel, HeapTuple trigtuple) bool ExecBRDeleteTriggers(EState *estate, ItemPointer tupleid) { - Relation rel = estate->es_result_relation_info->ri_RelationDesc; - TriggerData *SaveTriggerData; - int ntrigs = rel->trigdesc->n_before_row[TRIGGER_EVENT_DELETE]; - Trigger **trigger = rel->trigdesc->tg_before_row[TRIGGER_EVENT_DELETE]; - HeapTuple trigtuple; - HeapTuple newtuple = NULL; + Relation rel = estate->es_result_relation_info->ri_RelationDesc; + TriggerData *SaveTriggerData; + int ntrigs = rel->trigdesc->n_before_row[TRIGGER_EVENT_DELETE]; + Trigger **trigger = rel->trigdesc->tg_before_row[TRIGGER_EVENT_DELETE]; + HeapTuple trigtuple; + HeapTuple newtuple = NULL; TupleTableSlot *newSlot; - int i; + int i; trigtuple = GetTupleForTrigger(estate, tupleid, &newSlot); if (trigtuple == NULL) @@ -697,7 +697,7 @@ ExecBRDeleteTriggers(EState *estate, ItemPointer tupleid) void ExecARDeleteTriggers(EState *estate, ItemPointer tupleid) { - Relation rel = estate->es_result_relation_info->ri_RelationDesc; + Relation rel = estate->es_result_relation_info->ri_RelationDesc; TriggerData *SaveTriggerData; int ntrigs = rel->trigdesc->n_after_row[TRIGGER_EVENT_DELETE]; Trigger **trigger = rel->trigdesc->tg_after_row[TRIGGER_EVENT_DELETE]; @@ -727,23 +727,23 @@ ExecARDeleteTriggers(EState *estate, ItemPointer tupleid) HeapTuple ExecBRUpdateTriggers(EState *estate, ItemPointer tupleid, HeapTuple newtuple) { - Relation rel = estate->es_result_relation_info->ri_RelationDesc; - TriggerData *SaveTriggerData; - int ntrigs = rel->trigdesc->n_before_row[TRIGGER_EVENT_UPDATE]; - Trigger **trigger = rel->trigdesc->tg_before_row[TRIGGER_EVENT_UPDATE]; - HeapTuple trigtuple; - HeapTuple oldtuple; - HeapTuple intuple = newtuple; + Relation rel = estate->es_result_relation_info->ri_RelationDesc; + TriggerData *SaveTriggerData; + int ntrigs = rel->trigdesc->n_before_row[TRIGGER_EVENT_UPDATE]; + Trigger **trigger = rel->trigdesc->tg_before_row[TRIGGER_EVENT_UPDATE]; + HeapTuple trigtuple; + HeapTuple oldtuple; + HeapTuple intuple = newtuple; TupleTableSlot *newSlot; - int i; + int i; trigtuple = GetTupleForTrigger(estate, tupleid, &newSlot); if (trigtuple == NULL) return NULL; /* - * In READ COMMITTED isolevel it's possible that newtuple - * was changed due to concurrent update. + * In READ COMMITTED isolevel it's possible that newtuple was changed + * due to concurrent update. */ if (newSlot != NULL) intuple = newtuple = ExecRemoveJunk(estate->es_junkFilter, newSlot); @@ -772,7 +772,7 @@ ExecBRUpdateTriggers(EState *estate, ItemPointer tupleid, HeapTuple newtuple) void ExecARUpdateTriggers(EState *estate, ItemPointer tupleid, HeapTuple newtuple) { - Relation rel = estate->es_result_relation_info->ri_RelationDesc; + Relation rel = estate->es_result_relation_info->ri_RelationDesc; TriggerData *SaveTriggerData; int ntrigs = rel->trigdesc->n_after_row[TRIGGER_EVENT_UPDATE]; Trigger **trigger = rel->trigdesc->tg_after_row[TRIGGER_EVENT_UPDATE]; @@ -799,22 +799,22 @@ ExecARUpdateTriggers(EState *estate, ItemPointer tupleid, HeapTuple newtuple) return; } -extern TupleTableSlot *EvalPlanQual(EState *estate, Index rti, ItemPointer tid); +extern TupleTableSlot *EvalPlanQual(EState *estate, Index rti, ItemPointer tid); static HeapTuple GetTupleForTrigger(EState *estate, ItemPointer tid, TupleTableSlot **newSlot) { - Relation relation = estate->es_result_relation_info->ri_RelationDesc; - HeapTupleData tuple; - HeapTuple result; - Buffer buffer; + Relation relation = estate->es_result_relation_info->ri_RelationDesc; + HeapTupleData tuple; + HeapTuple result; + Buffer buffer; if (newSlot != NULL) { - int test; + int test; /* - * mark tuple for update + * mark tuple for update */ *newSlot = NULL; tuple.t_self = *tid; @@ -824,7 +824,7 @@ ltrmark:; { case HeapTupleSelfUpdated: ReleaseBuffer(buffer); - return(NULL); + return (NULL); case HeapTupleMayBeUpdated: break; @@ -835,9 +835,9 @@ ltrmark:; elog(ERROR, "Can't serialize access due to concurrent update"); else if (!(ItemPointerEquals(&(tuple.t_self), tid))) { - TupleTableSlot *epqslot = EvalPlanQual(estate, - estate->es_result_relation_info->ri_RangeTableIndex, - &(tuple.t_self)); + TupleTableSlot *epqslot = EvalPlanQual(estate, + estate->es_result_relation_info->ri_RangeTableIndex, + &(tuple.t_self)); if (!(TupIsNull(epqslot))) { @@ -846,23 +846,23 @@ ltrmark:; goto ltrmark; } } - /* - * if tuple was deleted or PlanQual failed - * for updated tuple - we have not process - * this tuple! + + /* + * if tuple was deleted or PlanQual failed for updated + * tuple - we have not process this tuple! */ - return(NULL); + return (NULL); default: ReleaseBuffer(buffer); elog(ERROR, "Unknown status %u from heap_mark4update", test); - return(NULL); + return (NULL); } } else { - PageHeader dp; - ItemId lp; + PageHeader dp; + ItemId lp; buffer = ReadBuffer(relation, ItemPointerGetBlockNumber(tid)); diff --git a/src/backend/commands/user.c b/src/backend/commands/user.c index 2b99c8efa8..57ac35fb1f 100644 --- a/src/backend/commands/user.c +++ b/src/backend/commands/user.c @@ -5,11 +5,11 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: user.c,v 1.27 1999/04/02 06:16:36 tgl Exp $ + * $Id: user.c,v 1.28 1999/05/25 16:08:27 momjian Exp $ * *------------------------------------------------------------------------- */ -#include +#include #include #include #include @@ -35,7 +35,7 @@ static void CheckPgUserAclNotNull(void); -#define SQL_LENGTH 512 +#define SQL_LENGTH 512 /*--------------------------------------------------------------------- * UpdatePgPwdFile @@ -49,9 +49,9 @@ void UpdatePgPwdFile(char *sql, CommandDest dest) { - char *filename, - *tempname; - int bufsize; + char *filename, + *tempname; + int bufsize; /* * Create a temporary filename to be renamed later. This prevents the @@ -68,9 +68,9 @@ UpdatePgPwdFile(char *sql, CommandDest dest) * SEPCHAR character as the delimiter between fields. Then rename the * file to its final name. */ - snprintf(sql, SQL_LENGTH, - "copy %s to '%s' using delimiters %s", - ShadowRelationName, tempname, CRYPT_PWD_FILE_SEPCHAR); + snprintf(sql, SQL_LENGTH, + "copy %s to '%s' using delimiters %s", + ShadowRelationName, tempname, CRYPT_PWD_FILE_SEPCHAR); pg_exec_query_dest(sql, dest, false); rename(tempname, filename); pfree((void *) tempname); @@ -94,19 +94,19 @@ UpdatePgPwdFile(char *sql, CommandDest dest) void DefineUser(CreateUserStmt *stmt, CommandDest dest) { - char *pg_shadow, - sql[SQL_LENGTH]; - Relation pg_shadow_rel; - TupleDesc pg_shadow_dsc; - HeapScanDesc scan; - HeapTuple tuple; - Datum datum; - bool exists = false, - n, - inblock, - havepassword, - havevaluntil; - int max_id = -1; + char *pg_shadow, + sql[SQL_LENGTH]; + Relation pg_shadow_rel; + TupleDesc pg_shadow_dsc; + HeapScanDesc scan; + HeapTuple tuple; + Datum datum; + bool exists = false, + n, + inblock, + havepassword, + havevaluntil; + int max_id = -1; havepassword = stmt->password && stmt->password[0]; havevaluntil = stmt->validUntil && stmt->validUntil[0]; @@ -161,21 +161,21 @@ DefineUser(CreateUserStmt *stmt, CommandDest dest) UnlockRelation(pg_shadow_rel, AccessExclusiveLock); heap_close(pg_shadow_rel); UserAbortTransactionBlock(); - elog(ERROR, - "defineUser: user \"%s\" has already been created", stmt->user); + elog(ERROR, + "defineUser: user \"%s\" has already been created", stmt->user); return; } /* * Build the insert statement to be executed. * - * XXX Ugly as this code is, it still fails to cope with ' or \ - * in any of the provided strings. + * XXX Ugly as this code is, it still fails to cope with ' or \ in any of + * the provided strings. */ - snprintf(sql, SQL_LENGTH, + snprintf(sql, SQL_LENGTH, "insert into %s (usename,usesysid,usecreatedb,usetrace," "usesuper,usecatupd,passwd,valuntil) " - "values('%s',%d,'%c','t','%c','t',%s%s%s,%s%s%s)", + "values('%s',%d,'%c','t','%c','t',%s%s%s,%s%s%s)", ShadowRelationName, stmt->user, max_id + 1, @@ -216,12 +216,12 @@ extern void AlterUser(AlterUserStmt *stmt, CommandDest dest) { - char *pg_shadow, - sql[SQL_LENGTH]; + char *pg_shadow, + sql[SQL_LENGTH]; Relation pg_shadow_rel; TupleDesc pg_shadow_dsc; HeapTuple tuple; - bool inblock; + bool inblock; if (stmt->password) CheckPgUserAclNotNull(); @@ -272,34 +272,32 @@ AlterUser(AlterUserStmt *stmt, CommandDest dest) snprintf(sql, SQL_LENGTH, "update %s set", ShadowRelationName); if (stmt->password) - { snprintf(sql, SQL_LENGTH, "%s passwd = '%s'", pstrdup(sql), stmt->password); - } if (stmt->createdb) { snprintf(sql, SQL_LENGTH, "%s %susecreatedb='%s'", - pstrdup(sql), stmt->password ? "," : "", - *stmt->createdb ? "t" : "f"); + pstrdup(sql), stmt->password ? "," : "", + *stmt->createdb ? "t" : "f"); } if (stmt->createuser) { snprintf(sql, SQL_LENGTH, "%s %susesuper='%s'", - pstrdup(sql), (stmt->password || stmt->createdb) ? "," : "", - *stmt->createuser ? "t" : "f"); + pstrdup(sql), (stmt->password || stmt->createdb) ? "," : "", + *stmt->createuser ? "t" : "f"); } if (stmt->validUntil) { snprintf(sql, SQL_LENGTH, "%s %svaluntil='%s'", - pstrdup(sql), - (stmt->password || stmt->createdb || stmt->createuser) ? "," : "", - stmt->validUntil); + pstrdup(sql), + (stmt->password || stmt->createdb || stmt->createuser) ? "," : "", + stmt->validUntil); } snprintf(sql, SQL_LENGTH, "%s where usename = '%s'", - pstrdup(sql), stmt->user); + pstrdup(sql), stmt->user); pg_exec_query_dest(sql, dest, false); @@ -393,8 +391,8 @@ RemoveUser(char *user, CommandDest dest) datum = heap_getattr(tuple, Anum_pg_database_datname, pg_dsc, &n); if (memcmp((void *) datum, "template1", 9)) { - dbase = - (char **) repalloc((void *) dbase, sizeof(char *) * (ndbase + 1)); + dbase = + (char **) repalloc((void *) dbase, sizeof(char *) * (ndbase + 1)); dbase[ndbase] = (char *) palloc(NAMEDATALEN + 1); memcpy((void *) dbase[ndbase], (void *) datum, NAMEDATALEN); dbase[ndbase++][NAMEDATALEN] = '\0'; @@ -435,8 +433,8 @@ RemoveUser(char *user, CommandDest dest) /* * Remove the user from the pg_shadow table */ - snprintf(sql, SQL_LENGTH, - "delete from %s where usename = '%s'", ShadowRelationName, user); + snprintf(sql, SQL_LENGTH, + "delete from %s where usename = '%s'", ShadowRelationName, user); pg_exec_query_dest(sql, dest, false); UpdatePgPwdFile(sql, dest); diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c index 82ba86f84e..8c929678b3 100644 --- a/src/backend/commands/vacuum.c +++ b/src/backend/commands/vacuum.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.103 1999/05/23 09:10:24 vadim Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.104 1999/05/25 16:08:27 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -66,7 +66,7 @@ static Portal vc_portal; static int MESSAGE_LEVEL; /* message level */ -static TransactionId XmaxRecent; +static TransactionId XmaxRecent; #define swapLong(a,b) {long tmp; tmp=a; a=b; b=tmp;} #define swapInt(a,b) {int tmp; tmp=a; a=b; b=tmp;} @@ -101,8 +101,8 @@ static void vc_free(VRelList vrl); static void vc_getindices(Oid relid, int *nindices, Relation **Irel); static void vc_clsindices(int nindices, Relation *Irel); static void vc_mkindesc(Relation onerel, int nindices, Relation *Irel, IndDesc **Idesc); -static void *vc_find_eq(void *bot, int nelem, int size, void *elm, - int (*compar) (const void *, const void *)); +static void *vc_find_eq(void *bot, int nelem, int size, void *elm, + int (*compar) (const void *, const void *)); static int vc_cmp_blk(const void *left, const void *right); static int vc_cmp_offno(const void *left, const void *right); static int vc_cmp_vtlinks(const void *left, const void *right); @@ -222,14 +222,15 @@ vc_shutdown() { /* on entry, we are not in a transaction */ - /* Flush the init file that relcache.c uses to save startup time. - * The next backend startup will rebuild the init file with up-to-date - * information from pg_class. This lets the optimizer see the stats that - * we've collected for certain critical system indexes. See relcache.c - * for more details. + /* + * Flush the init file that relcache.c uses to save startup time. The + * next backend startup will rebuild the init file with up-to-date + * information from pg_class. This lets the optimizer see the stats + * that we've collected for certain critical system indexes. See + * relcache.c for more details. * - * Ignore any failure to unlink the file, since it might not be there - * if no backend has been started since the last vacuum... + * Ignore any failure to unlink the file, since it might not be there if + * no backend has been started since the last vacuum... */ unlink(RELCACHE_INIT_FILENAME); @@ -578,7 +579,7 @@ vc_vacone(Oid relid, bool analyze, List *va_cols) /* update statistics in pg_class */ vc_updstats(vacrelstats->relid, vacrelstats->num_pages, - vacrelstats->num_tuples, vacrelstats->hasindex, vacrelstats); + vacrelstats->num_tuples, vacrelstats->hasindex, vacrelstats); /* next command frees attribute stats */ CommitTransactionCommand(); @@ -601,7 +602,7 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel, blkno; ItemId itemid; Buffer buf; - HeapTupleData tuple; + HeapTupleData tuple; Page page, tempPage = NULL; OffsetNumber offnum, @@ -712,7 +713,7 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel, else if (tuple.t_data->t_infomask & HEAP_MOVED_OFF) { if (TransactionIdDidCommit((TransactionId) - tuple.t_data->t_cmin)) + tuple.t_data->t_cmin)) { tuple.t_data->t_infomask |= HEAP_XMIN_INVALID; tupgone = true; @@ -759,7 +760,7 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel, else { elog(NOTICE, "Rel %s: TID %u/%u: InsertTransactionInProgress %u - can't shrink relation", - relname, blkno, offnum, tuple.t_data->t_xmin); + relname, blkno, offnum, tuple.t_data->t_xmin); do_shrinking = false; } } @@ -799,6 +800,7 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel, } else if (!TransactionIdIsInProgress(tuple.t_data->t_xmax)) { + /* * Not Aborted, Not Committed, Not in Progress - so it * from crashed process. - vadim 06/02/97 @@ -812,11 +814,12 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel, relname, blkno, offnum, tuple.t_data->t_xmax); do_shrinking = false; } + /* - * If tuple is recently deleted then - * we must not remove it from relation. + * If tuple is recently deleted then we must not remove it + * from relation. */ - if (tupgone && tuple.t_data->t_xmax >= XmaxRecent && + if (tupgone && tuple.t_data->t_xmax >= XmaxRecent && tuple.t_data->t_infomask & HEAP_XMIN_COMMITTED) { tupgone = false; @@ -826,20 +829,21 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel, tuple.t_data->t_infomask |= HEAP_XMAX_COMMITTED; pgchanged = true; } + /* * If we do shrinking and this tuple is updated one * then remember it to construct updated tuple * dependencies. */ - if (do_shrinking && !(ItemPointerEquals(&(tuple.t_self), - &(tuple.t_data->t_ctid)))) + if (do_shrinking && !(ItemPointerEquals(&(tuple.t_self), + &(tuple.t_data->t_ctid)))) { if (free_vtlinks == 0) { free_vtlinks = 1000; - vtlinks = (VTupleLink) repalloc(vtlinks, - (free_vtlinks + num_vtlinks) * - sizeof(VTupleLinkData)); + vtlinks = (VTupleLink) repalloc(vtlinks, + (free_vtlinks + num_vtlinks) * + sizeof(VTupleLinkData)); } vtlinks[num_vtlinks].new_tid = tuple.t_data->t_ctid; vtlinks[num_vtlinks].this_tid = tuple.t_self; @@ -962,8 +966,8 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel, if (usable_free_size > 0 && num_vtlinks > 0) { - qsort((char *) vtlinks, num_vtlinks, sizeof (VTupleLinkData), - vc_cmp_vtlinks); + qsort((char *) vtlinks, num_vtlinks, sizeof(VTupleLinkData), + vc_cmp_vtlinks); vacrelstats->vtlinks = vtlinks; vacrelstats->num_vtlinks = num_vtlinks; } @@ -980,10 +984,10 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel, Tup %u: Vac %u, Keep/VTL %u/%u, Crash %u, UnUsed %u, MinLen %u, MaxLen %u; \ Re-using: Free/Avail. Space %u/%u; EndEmpty/Avail. Pages %u/%u. \ Elapsed %u/%u sec.", - nblocks, changed_pages, vacuum_pages->vpl_num_pages, empty_pages, - new_pages, num_tuples, tups_vacuumed, - nkeep, vacrelstats->num_vtlinks, ncrash, - nunused, min_tlen, max_tlen, free_size, usable_free_size, + nblocks, changed_pages, vacuum_pages->vpl_num_pages, empty_pages, + new_pages, num_tuples, tups_vacuumed, + nkeep, vacrelstats->num_vtlinks, ncrash, + nunused, min_tlen, max_tlen, free_size, usable_free_size, empty_end_pages, fraged_pages->vpl_num_pages, ru1.ru_stime.tv_sec - ru0.ru_stime.tv_sec, ru1.ru_utime.tv_sec - ru0.ru_utime.tv_sec); @@ -1019,8 +1023,8 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel, max_offset; ItemId itemid, newitemid; - HeapTupleData tuple, - newtup; + HeapTupleData tuple, + newtup; TupleDesc tupdesc = NULL; Datum *idatum = NULL; char *inulls = NULL; @@ -1128,7 +1132,8 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel, else Assert(!isempty); - chain_tuple_moved = false; /* no one chain-tuple was moved off this page, yet */ + chain_tuple_moved = false; /* no one chain-tuple was moved + * off this page, yet */ vpc->vpd_blkno = blkno; maxoff = PageGetMaxOffsetNumber(page); for (offnum = FirstOffsetNumber; @@ -1146,28 +1151,30 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel, if (!(tuple.t_data->t_infomask & HEAP_XMIN_COMMITTED)) { - if ((TransactionId)tuple.t_data->t_cmin != myXID) + if ((TransactionId) tuple.t_data->t_cmin != myXID) elog(ERROR, "Invalid XID in t_cmin"); if (tuple.t_data->t_infomask & HEAP_MOVED_IN) elog(ERROR, "HEAP_MOVED_IN was not expected"); - /* - * If this (chain) tuple is moved by me already then - * I have to check is it in vpc or not - i.e. is it - * moved while cleaning this page or some previous one. + + /* + * If this (chain) tuple is moved by me already then I + * have to check is it in vpc or not - i.e. is it moved + * while cleaning this page or some previous one. */ if (tuple.t_data->t_infomask & HEAP_MOVED_OFF) { if (keep_tuples == 0) continue; - if (chain_tuple_moved) /* some chains was moved while */ - { /* cleaning this page */ + if (chain_tuple_moved) /* some chains was moved + * while */ + { /* cleaning this page */ Assert(vpc->vpd_offsets_free > 0); for (i = 0; i < vpc->vpd_offsets_free; i++) { if (vpc->vpd_offsets[i] == offnum) break; } - if (i >= vpc->vpd_offsets_free) /* not found */ + if (i >= vpc->vpd_offsets_free) /* not found */ { vpc->vpd_offsets[vpc->vpd_offsets_free++] = offnum; keep_tuples--; @@ -1184,29 +1191,29 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel, } /* - * If this tuple is in the chain of tuples created in - * updates by "recent" transactions then we have to - * move all chain of tuples to another places. + * If this tuple is in the chain of tuples created in updates + * by "recent" transactions then we have to move all chain of + * tuples to another places. */ - if ((tuple.t_data->t_infomask & HEAP_UPDATED && + if ((tuple.t_data->t_infomask & HEAP_UPDATED && tuple.t_data->t_xmin >= XmaxRecent) || - (!(tuple.t_data->t_infomask & HEAP_XMAX_INVALID) && + (!(tuple.t_data->t_infomask & HEAP_XMAX_INVALID) && !(ItemPointerEquals(&(tuple.t_self), &(tuple.t_data->t_ctid))))) { - Buffer Cbuf = buf; - Page Cpage; - ItemId Citemid; - ItemPointerData Ctid; - HeapTupleData tp = tuple; - Size tlen = tuple_len; - VTupleMove vtmove = (VTupleMove) - palloc(100 * sizeof(VTupleMoveData)); - int num_vtmove = 0; - int free_vtmove = 100; - VPageDescr to_vpd = fraged_pages->vpl_pagedesc[0]; - int to_item = 0; - bool freeCbuf = false; - int ti; + Buffer Cbuf = buf; + Page Cpage; + ItemId Citemid; + ItemPointerData Ctid; + HeapTupleData tp = tuple; + Size tlen = tuple_len; + VTupleMove vtmove = (VTupleMove) + palloc(100 * sizeof(VTupleMoveData)); + int num_vtmove = 0; + int free_vtmove = 100; + VPageDescr to_vpd = fraged_pages->vpl_pagedesc[0]; + int to_item = 0; + bool freeCbuf = false; + int ti; if (vacrelstats->vtlinks == NULL) elog(ERROR, "No one parent tuple was found"); @@ -1215,22 +1222,23 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel, WriteBuffer(cur_buffer); cur_buffer = InvalidBuffer; } + /* - * If this tuple is in the begin/middle of the chain - * then we have to move to the end of chain. + * If this tuple is in the begin/middle of the chain then + * we have to move to the end of chain. */ - while (!(tp.t_data->t_infomask & HEAP_XMAX_INVALID) && - !(ItemPointerEquals(&(tp.t_self), &(tp.t_data->t_ctid)))) + while (!(tp.t_data->t_infomask & HEAP_XMAX_INVALID) && + !(ItemPointerEquals(&(tp.t_self), &(tp.t_data->t_ctid)))) { Ctid = tp.t_data->t_ctid; if (freeCbuf) ReleaseBuffer(Cbuf); freeCbuf = true; - Cbuf = ReadBuffer(onerel, - ItemPointerGetBlockNumber(&Ctid)); + Cbuf = ReadBuffer(onerel, + ItemPointerGetBlockNumber(&Ctid)); Cpage = BufferGetPage(Cbuf); - Citemid = PageGetItemId(Cpage, - ItemPointerGetOffsetNumber(&Ctid)); + Citemid = PageGetItemId(Cpage, + ItemPointerGetOffsetNumber(&Ctid)); if (!ItemIdIsUsed(Citemid)) elog(ERROR, "Child itemid marked as unused"); tp.t_data = (HeapTupleHeader) PageGetItem(Cpage, Citemid); @@ -1238,16 +1246,16 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel, tlen = tp.t_len = ItemIdGetLength(Citemid); } /* first, can chain be moved ? */ - for ( ; ; ) + for (;;) { if (!vc_enough_space(to_vpd, tlen)) { if (to_vpd != last_fraged_page && - !vc_enough_space(to_vpd, vacrelstats->min_tlen)) + !vc_enough_space(to_vpd, vacrelstats->min_tlen)) { Assert(num_fraged_pages > to_item + 1); memmove(fraged_pages->vpl_pagedesc + to_item, - fraged_pages->vpl_pagedesc + to_item + 1, + fraged_pages->vpl_pagedesc + to_item + 1, sizeof(VPageDescr *) * (num_fraged_pages - to_item - 1)); num_fraged_pages--; Assert(last_fraged_page == fraged_pages->vpl_pagedesc[num_fraged_pages - 1]); @@ -1257,7 +1265,8 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel, if (vc_enough_space(fraged_pages->vpl_pagedesc[i], tlen)) break; } - if (i == num_fraged_pages) /* can't move item anywhere */ + if (i == num_fraged_pages) /* can't move item + * anywhere */ { for (i = 0; i < num_vtmove; i++) { @@ -1277,9 +1286,9 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel, if (free_vtmove == 0) { free_vtmove = 1000; - vtmove = (VTupleMove) repalloc(vtmove, - (free_vtmove + num_vtmove) * - sizeof(VTupleMoveData)); + vtmove = (VTupleMove) repalloc(vtmove, + (free_vtmove + num_vtmove) * + sizeof(VTupleMoveData)); } vtmove[num_vtmove].tid = tp.t_self; vtmove[num_vtmove].vpd = to_vpd; @@ -1289,56 +1298,59 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel, vtmove[num_vtmove].cleanVpd = false; free_vtmove--; num_vtmove++; + /* * All done ? */ - if (!(tp.t_data->t_infomask & HEAP_UPDATED) || - tp.t_data->t_xmin < XmaxRecent) + if (!(tp.t_data->t_infomask & HEAP_UPDATED) || + tp.t_data->t_xmin < XmaxRecent) break; + /* * Well, try to find tuple with old row version */ - for ( ; ; ) + for (;;) { - Buffer Pbuf; - Page Ppage; - ItemId Pitemid; - HeapTupleData Ptp; - VTupleLinkData vtld, - *vtlp; + Buffer Pbuf; + Page Ppage; + ItemId Pitemid; + HeapTupleData Ptp; + VTupleLinkData vtld, + *vtlp; vtld.new_tid = tp.t_self; - vtlp = (VTupleLink) - vc_find_eq((void *) (vacrelstats->vtlinks), - vacrelstats->num_vtlinks, - sizeof(VTupleLinkData), - (void *) &vtld, - vc_cmp_vtlinks); + vtlp = (VTupleLink) + vc_find_eq((void *) (vacrelstats->vtlinks), + vacrelstats->num_vtlinks, + sizeof(VTupleLinkData), + (void *) &vtld, + vc_cmp_vtlinks); if (vtlp == NULL) elog(ERROR, "Parent tuple was not found"); tp.t_self = vtlp->this_tid; - Pbuf = ReadBuffer(onerel, + Pbuf = ReadBuffer(onerel, ItemPointerGetBlockNumber(&(tp.t_self))); Ppage = BufferGetPage(Pbuf); - Pitemid = PageGetItemId(Ppage, - ItemPointerGetOffsetNumber(&(tp.t_self))); + Pitemid = PageGetItemId(Ppage, + ItemPointerGetOffsetNumber(&(tp.t_self))); if (!ItemIdIsUsed(Pitemid)) elog(ERROR, "Parent itemid marked as unused"); Ptp.t_data = (HeapTupleHeader) PageGetItem(Ppage, Pitemid); Assert(Ptp.t_data->t_xmax == tp.t_data->t_xmin); + /* - * If this tuple is updated version of row and - * it was created by the same transaction then - * no one is interested in this tuple - - * mark it as removed. + * If this tuple is updated version of row and it + * was created by the same transaction then no one + * is interested in this tuple - mark it as + * removed. */ - if (Ptp.t_data->t_infomask & HEAP_UPDATED && + if (Ptp.t_data->t_infomask & HEAP_UPDATED && Ptp.t_data->t_xmin == Ptp.t_data->t_xmax) { - TransactionIdStore(myXID, - (TransactionId*) &(Ptp.t_data->t_cmin)); - Ptp.t_data->t_infomask &= - ~(HEAP_XMIN_COMMITTED|HEAP_XMIN_INVALID|HEAP_MOVED_IN); + TransactionIdStore(myXID, + (TransactionId *) &(Ptp.t_data->t_cmin)); + Ptp.t_data->t_infomask &= + ~(HEAP_XMIN_COMMITTED | HEAP_XMIN_INVALID | HEAP_MOVED_IN); Ptp.t_data->t_infomask |= HEAP_MOVED_OFF; WriteBuffer(Pbuf); continue; @@ -1354,7 +1366,7 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel, } if (freeCbuf) ReleaseBuffer(Cbuf); - if (num_vtmove == 0) /* chain can't be moved */ + if (num_vtmove == 0) /* chain can't be moved */ { pfree(vtmove); break; @@ -1364,19 +1376,20 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel, { /* Get tuple from chain */ tuple.t_self = vtmove[ti].tid; - Cbuf = ReadBuffer(onerel, - ItemPointerGetBlockNumber(&(tuple.t_self))); + Cbuf = ReadBuffer(onerel, + ItemPointerGetBlockNumber(&(tuple.t_self))); Cpage = BufferGetPage(Cbuf); - Citemid = PageGetItemId(Cpage, + Citemid = PageGetItemId(Cpage, ItemPointerGetOffsetNumber(&(tuple.t_self))); tuple.t_data = (HeapTupleHeader) PageGetItem(Cpage, Citemid); tuple_len = tuple.t_len = ItemIdGetLength(Citemid); /* Get page to move in */ cur_buffer = ReadBuffer(onerel, vtmove[ti].vpd->vpd_blkno); + /* - * We should LockBuffer(cur_buffer) but don't, at the - * moment. If you'll do LockBuffer then UNLOCK it - * before index_insert: unique btree-s call heap_fetch + * We should LockBuffer(cur_buffer) but don't, at the + * moment. If you'll do LockBuffer then UNLOCK it + * before index_insert: unique btree-s call heap_fetch * to get t_infomask of inserted heap tuple !!! */ ToPage = BufferGetPage(cur_buffer); @@ -1385,22 +1398,23 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel, vc_vacpage(ToPage, vtmove[ti].vpd); heap_copytuple_with_tuple(&tuple, &newtup); RelationInvalidateHeapTuple(onerel, &tuple); - TransactionIdStore(myXID, (TransactionId*) &(newtup.t_data->t_cmin)); - newtup.t_data->t_infomask &= - ~(HEAP_XMIN_COMMITTED|HEAP_XMIN_INVALID|HEAP_MOVED_OFF); + TransactionIdStore(myXID, (TransactionId *) &(newtup.t_data->t_cmin)); + newtup.t_data->t_infomask &= + ~(HEAP_XMIN_COMMITTED | HEAP_XMIN_INVALID | HEAP_MOVED_OFF); newtup.t_data->t_infomask |= HEAP_MOVED_IN; newoff = PageAddItem(ToPage, (Item) newtup.t_data, tuple_len, - InvalidOffsetNumber, LP_USED); + InvalidOffsetNumber, LP_USED); if (newoff == InvalidOffsetNumber) { elog(ERROR, "\ moving chain: failed to add item with len = %u to page %u", - tuple_len, vtmove[ti].vpd->vpd_blkno); + tuple_len, vtmove[ti].vpd->vpd_blkno); } newitemid = PageGetItemId(ToPage, newoff); pfree(newtup.t_data); newtup.t_data = (HeapTupleHeader) PageGetItem(ToPage, newitemid); ItemPointerSet(&(newtup.t_self), vtmove[ti].vpd->vpd_blkno, newoff); + /* * Set t_ctid pointing to itself for last tuple in * chain and to next tuple in chain otherwise. @@ -1411,19 +1425,20 @@ moving chain: failed to add item with len = %u to page %u", newtup.t_data->t_ctid = Ctid; Ctid = newtup.t_self; - TransactionIdStore(myXID, (TransactionId*) &(tuple.t_data->t_cmin)); - tuple.t_data->t_infomask &= - ~(HEAP_XMIN_COMMITTED|HEAP_XMIN_INVALID|HEAP_MOVED_IN); + TransactionIdStore(myXID, (TransactionId *) &(tuple.t_data->t_cmin)); + tuple.t_data->t_infomask &= + ~(HEAP_XMIN_COMMITTED | HEAP_XMIN_INVALID | HEAP_MOVED_IN); tuple.t_data->t_infomask |= HEAP_MOVED_OFF; num_moved++; + /* * Remember that we moved tuple from the current page * (corresponding index tuple will be cleaned). */ if (Cbuf == buf) - vpc->vpd_offsets[vpc->vpd_offsets_free++] = - ItemPointerGetOffsetNumber(&(tuple.t_self)); + vpc->vpd_offsets[vpc->vpd_offsets_free++] = + ItemPointerGetOffsetNumber(&(tuple.t_self)); else keep_tuples++; @@ -1432,12 +1447,12 @@ moving chain: failed to add item with len = %u to page %u", for (i = 0, idcur = Idesc; i < nindices; i++, idcur++) { FormIndexDatum(idcur->natts, - (AttrNumber *) &(idcur->tform->indkey[0]), - &newtup, - tupdesc, - idatum, - inulls, - idcur->finfoP); + (AttrNumber *) &(idcur->tform->indkey[0]), + &newtup, + tupdesc, + idatum, + inulls, + idcur->finfoP); iresult = index_insert(Irel[i], idatum, inulls, @@ -1507,13 +1522,13 @@ moving chain: failed to add item with len = %u to page %u", RelationInvalidateHeapTuple(onerel, &tuple); - /* - * Mark new tuple as moved_in by vacuum and - * store vacuum XID in t_cmin !!! + /* + * Mark new tuple as moved_in by vacuum and store vacuum XID + * in t_cmin !!! */ - TransactionIdStore(myXID, (TransactionId*) &(newtup.t_data->t_cmin)); - newtup.t_data->t_infomask &= - ~(HEAP_XMIN_COMMITTED|HEAP_XMIN_INVALID|HEAP_MOVED_OFF); + TransactionIdStore(myXID, (TransactionId *) &(newtup.t_data->t_cmin)); + newtup.t_data->t_infomask &= + ~(HEAP_XMIN_COMMITTED | HEAP_XMIN_INVALID | HEAP_MOVED_OFF); newtup.t_data->t_infomask |= HEAP_MOVED_IN; /* add tuple to the page */ @@ -1532,13 +1547,13 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)", ItemPointerSet(&(newtup.t_data->t_ctid), cur_page->vpd_blkno, newoff); newtup.t_self = newtup.t_data->t_ctid; - /* - * Mark old tuple as moved_off by vacuum and - * store vacuum XID in t_cmin !!! + /* + * Mark old tuple as moved_off by vacuum and store vacuum XID + * in t_cmin !!! */ - TransactionIdStore(myXID, (TransactionId*) &(tuple.t_data->t_cmin)); - tuple.t_data->t_infomask &= - ~(HEAP_XMIN_COMMITTED|HEAP_XMIN_INVALID|HEAP_MOVED_IN); + TransactionIdStore(myXID, (TransactionId *) &(tuple.t_data->t_cmin)); + tuple.t_data->t_infomask &= + ~(HEAP_XMIN_COMMITTED | HEAP_XMIN_INVALID | HEAP_MOVED_IN); tuple.t_data->t_infomask |= HEAP_MOVED_OFF; cur_page->vpd_offsets_used++; @@ -1572,11 +1587,11 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)", if (offnum < maxoff && keep_tuples > 0) { - OffsetNumber off; + OffsetNumber off; for (off = OffsetNumberNext(offnum); - off <= maxoff; - off = OffsetNumberNext(off)) + off <= maxoff; + off = OffsetNumberNext(off)) { itemid = PageGetItemId(page, off); if (!ItemIdIsUsed(itemid)) @@ -1584,21 +1599,22 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)", tuple.t_data = (HeapTupleHeader) PageGetItem(page, itemid); if (tuple.t_data->t_infomask & HEAP_XMIN_COMMITTED) continue; - if ((TransactionId)tuple.t_data->t_cmin != myXID) + if ((TransactionId) tuple.t_data->t_cmin != myXID) elog(ERROR, "Invalid XID in t_cmin (4)"); if (tuple.t_data->t_infomask & HEAP_MOVED_IN) elog(ERROR, "HEAP_MOVED_IN was not expected (2)"); if (tuple.t_data->t_infomask & HEAP_MOVED_OFF) { - if (chain_tuple_moved) /* some chains was moved while */ - { /* cleaning this page */ + if (chain_tuple_moved) /* some chains was moved + * while */ + { /* cleaning this page */ Assert(vpc->vpd_offsets_free > 0); for (i = 0; i < vpc->vpd_offsets_free; i++) { if (vpc->vpd_offsets[i] == off) break; } - if (i >= vpc->vpd_offsets_free) /* not found */ + if (i >= vpc->vpd_offsets_free) /* not found */ { vpc->vpd_offsets[vpc->vpd_offsets_free++] = off; Assert(keep_tuples > 0); @@ -1619,8 +1635,8 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)", { if (chain_tuple_moved) /* else - they are ordered */ { - qsort((char *) (vpc->vpd_offsets), vpc->vpd_offsets_free, - sizeof(OffsetNumber), vc_cmp_offno); + qsort((char *) (vpc->vpd_offsets), vpc->vpd_offsets_free, + sizeof(OffsetNumber), vc_cmp_offno); } vc_reappage(&Nvpl, vpc); WriteBuffer(buf); @@ -1645,6 +1661,7 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)", if (num_moved > 0) { + /* * We have to commit our tuple' movings before we'll truncate * relation, but we shouldn't lose our locks. And so - quick hack: @@ -1657,8 +1674,8 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)", } /* - * Clean uncleaned reapped pages from vacuum_pages list list and set xmin - * committed for inserted tuples + * Clean uncleaned reapped pages from vacuum_pages list list and set + * xmin committed for inserted tuples */ checked_moved = 0; for (i = 0, vpp = vacuum_pages->vpl_pagedesc; i < vacuumed_pages; i++, vpp++) @@ -1671,7 +1688,8 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)", if (!PageIsEmpty(page)) vc_vacpage(page, *vpp); } - else /* this page was used */ + else +/* this page was used */ { num_tuples = 0; max_offset = PageGetMaxOffsetNumber(page); @@ -1685,7 +1703,7 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)", tuple.t_data = (HeapTupleHeader) PageGetItem(page, itemid); if (!(tuple.t_data->t_infomask & HEAP_XMIN_COMMITTED)) { - if ((TransactionId)tuple.t_data->t_cmin != myXID) + if ((TransactionId) tuple.t_data->t_cmin != myXID) elog(ERROR, "Invalid XID in t_cmin (2)"); if (tuple.t_data->t_infomask & HEAP_MOVED_IN) { @@ -1734,8 +1752,8 @@ Elapsed %u/%u sec.", } Assert(keep_tuples >= 0); for (i = 0; i < nindices; i++) - vc_vaconeind(&Nvpl, Irel[i], - vacrelstats->num_tuples, keep_tuples); + vc_vaconeind(&Nvpl, Irel[i], + vacrelstats->num_tuples, keep_tuples); } /* @@ -1757,7 +1775,7 @@ Elapsed %u/%u sec.", if (!(tuple.t_data->t_infomask & HEAP_XMIN_COMMITTED)) { - if ((TransactionId)tuple.t_data->t_cmin != myXID) + if ((TransactionId) tuple.t_data->t_cmin != myXID) elog(ERROR, "Invalid XID in t_cmin (3)"); if (tuple.t_data->t_infomask & HEAP_MOVED_OFF) { @@ -1998,7 +2016,7 @@ vc_vaconeind(VPageList vpl, Relation indrel, int num_tuples, int keep_tuples) getrusage(RUSAGE_SELF, &ru1); elog(MESSAGE_LEVEL, "Index %s: Pages %u; Tuples %u: Deleted %u. Elapsed %u/%u sec.", - indrel->rd_rel->relname.data, num_pages, + indrel->rd_rel->relname.data, num_pages, num_index_tuples - keep_tuples, tups_vacuumed, ru1.ru_stime.tv_sec - ru0.ru_stime.tv_sec, ru1.ru_utime.tv_sec - ru0.ru_utime.tv_sec); @@ -2208,25 +2226,25 @@ vc_bucketcpy(Form_pg_attribute attr, Datum value, Datum *bucket, int16 *bucket_l static void vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *vacrelstats) { - Relation rd, - ad, - sd; - HeapScanDesc scan; - HeapTupleData rtup; - HeapTuple ctup, - atup, - stup; - Form_pg_class pgcform; - ScanKeyData askey; - Form_pg_attribute attp; - Buffer buffer; + Relation rd, + ad, + sd; + HeapScanDesc scan; + HeapTupleData rtup; + HeapTuple ctup, + atup, + stup; + Form_pg_class pgcform; + ScanKeyData askey; + Form_pg_attribute attp; + Buffer buffer; /* * update number of tuples and number of pages in pg_class */ ctup = SearchSysCacheTupleCopy(RELOID, - ObjectIdGetDatum(relid), - 0, 0, 0); + ObjectIdGetDatum(relid), + 0, 0, 0); if (!HeapTupleIsValid(ctup)) elog(ERROR, "pg_class entry for relid %u vanished during vacuuming", relid); @@ -2237,7 +2255,7 @@ vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats * rtup.t_self = ctup->t_self; heap_fetch(rd, SnapshotNow, &rtup, &buffer); pfree(ctup); - + /* overwrite the existing statistics in the tuple */ vc_setpagelock(rd, ItemPointerGetBlockNumber(&(rtup.t_self))); pgcform = (Form_pg_class) GETSTRUCT(&rtup); @@ -2317,8 +2335,7 @@ vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats * attp->attdisbursion = selratio; /* - * Invalidate the cache for the tuple - * and write the buffer + * Invalidate the cache for the tuple and write the buffer */ RelationInvalidateHeapTuple(ad, atup); WriteNoReleaseBuffer(abuffer); @@ -2375,8 +2392,7 @@ vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats * } /* - * Invalidate the cached pg_class tuple and - * write the buffer + * Invalidate the cached pg_class tuple and write the buffer */ RelationInvalidateHeapTuple(rd, &rtup); @@ -2504,8 +2520,8 @@ vc_free(VRelList vrl) } static void * -vc_find_eq(void *bot, int nelem, int size, void *elm, - int (*compar) (const void *, const void *)) +vc_find_eq(void *bot, int nelem, int size, void *elm, + int (*compar) (const void *, const void *)) { int res; int last = nelem - 1; @@ -2527,16 +2543,16 @@ vc_find_eq(void *bot, int nelem, int size, void *elm, } if (last_move == true) { - res = compar(elm, (void *)((char *)bot + last * size)); + res = compar(elm, (void *) ((char *) bot + last * size)); if (res > 0) return NULL; if (res == 0) - return (void *)((char *)bot + last * size); + return (void *) ((char *) bot + last * size); last_move = false; } - res = compar(elm, (void *)((char *)bot + celm * size)); + res = compar(elm, (void *) ((char *) bot + celm * size)); if (res == 0) - return (void *)((char *)bot + celm * size); + return (void *) ((char *) bot + celm * size); if (res < 0) { if (celm == 0) @@ -2551,7 +2567,7 @@ vc_find_eq(void *bot, int nelem, int size, void *elm, return NULL; last = last - celm - 1; - bot = (void *)((char *)bot + (celm + 1) * size); + bot = (void *) ((char *) bot + (celm + 1) * size); celm = (last + 1) / 2; first_move = true; } @@ -2591,25 +2607,25 @@ static int vc_cmp_vtlinks(const void *left, const void *right) { - if (((VTupleLink)left)->new_tid.ip_blkid.bi_hi < - ((VTupleLink)right)->new_tid.ip_blkid.bi_hi) + if (((VTupleLink) left)->new_tid.ip_blkid.bi_hi < + ((VTupleLink) right)->new_tid.ip_blkid.bi_hi) return -1; - if (((VTupleLink)left)->new_tid.ip_blkid.bi_hi > - ((VTupleLink)right)->new_tid.ip_blkid.bi_hi) + if (((VTupleLink) left)->new_tid.ip_blkid.bi_hi > + ((VTupleLink) right)->new_tid.ip_blkid.bi_hi) return 1; /* bi_hi-es are equal */ - if (((VTupleLink)left)->new_tid.ip_blkid.bi_lo < - ((VTupleLink)right)->new_tid.ip_blkid.bi_lo) + if (((VTupleLink) left)->new_tid.ip_blkid.bi_lo < + ((VTupleLink) right)->new_tid.ip_blkid.bi_lo) return -1; - if (((VTupleLink)left)->new_tid.ip_blkid.bi_lo > - ((VTupleLink)right)->new_tid.ip_blkid.bi_lo) + if (((VTupleLink) left)->new_tid.ip_blkid.bi_lo > + ((VTupleLink) right)->new_tid.ip_blkid.bi_lo) return 1; /* bi_lo-es are equal */ - if (((VTupleLink)left)->new_tid.ip_posid < - ((VTupleLink)right)->new_tid.ip_posid) + if (((VTupleLink) left)->new_tid.ip_posid < + ((VTupleLink) right)->new_tid.ip_posid) return -1; - if (((VTupleLink)left)->new_tid.ip_posid > - ((VTupleLink)right)->new_tid.ip_posid) + if (((VTupleLink) left)->new_tid.ip_posid > + ((VTupleLink) right)->new_tid.ip_posid) return 1; return 0; diff --git a/src/backend/commands/variable.c b/src/backend/commands/variable.c index 66f75c5f06..f146242307 100644 --- a/src/backend/commands/variable.c +++ b/src/backend/commands/variable.c @@ -2,7 +2,7 @@ * Routines for handling of 'SET var TO', * 'SHOW var' and 'RESET var' statements. * - * $Id: variable.c,v 1.19 1999/02/18 06:00:44 momjian Exp $ + * $Id: variable.c,v 1.20 1999/05/25 16:08:28 momjian Exp $ * */ @@ -45,10 +45,12 @@ static bool parse_ksqo(const char *); static bool show_XactIsoLevel(void); static bool reset_XactIsoLevel(void); static bool parse_XactIsoLevel(const char *); + #ifdef QUERY_LIMIT static bool show_query_limit(void); static bool reset_query_limit(void); static bool parse_query_limit(const char *); + #endif extern Cost _cpu_page_wight_; @@ -545,41 +547,41 @@ reset_timezone() static bool parse_query_limit(const char *value) { - int32 limit; + int32 limit; - if (value == NULL) { - reset_query_limit(); - return(TRUE); - } - /* why is pg_atoi's arg not declared "const char *" ? */ - limit = pg_atoi((char *) value, sizeof(int32), '\0'); - if (limit <= -1) { - elog(ERROR, "Bad value for # of query limit (%s)", value); - } - ExecutorLimit(limit); - return(TRUE); + if (value == NULL) + { + reset_query_limit(); + return (TRUE); + } + /* why is pg_atoi's arg not declared "const char *" ? */ + limit = pg_atoi((char *) value, sizeof(int32), '\0'); + if (limit <= -1) + elog(ERROR, "Bad value for # of query limit (%s)", value); + ExecutorLimit(limit); + return (TRUE); } static bool show_query_limit(void) { - int limit; + int limit; - limit = ExecutorGetLimit(); - if (limit == ALL_TUPLES) { - elog(NOTICE, "No query limit is set"); - } else { - elog(NOTICE, "query limit is %d",limit); - } - return(TRUE); + limit = ExecutorGetLimit(); + if (limit == ALL_TUPLES) + elog(NOTICE, "No query limit is set"); + else + elog(NOTICE, "query limit is %d", limit); + return (TRUE); } static bool reset_query_limit(void) { - ExecutorLimit(ALL_TUPLES); - return(TRUE); + ExecutorLimit(ALL_TUPLES); + return (TRUE); } + #endif /*-----------------------------------------------------------------------*/ @@ -685,10 +687,10 @@ ResetPGVariable(const char *name) /*----------------------------------------------------------------------- -KSQO code will one day be unnecessary when the optimizer makes use of +KSQO code will one day be unnecessary when the optimizer makes use of indexes when multiple ORs are specified in the where clause. See optimizer/prep/prepkeyset.c for more on this. - daveh@insightdist.com 6/16/98 + daveh@insightdist.com 6/16/98 -----------------------------------------------------------------------*/ static bool parse_ksqo(const char *value) @@ -732,7 +734,7 @@ reset_ksqo() static bool parse_XactIsoLevel(const char *value) { - + if (value == NULL) { reset_XactIsoLevel(); @@ -770,7 +772,7 @@ show_XactIsoLevel() static bool reset_XactIsoLevel() { - + if (SerializableSnapshot != NULL) { elog(ERROR, "SET TRANSACTION ISOLATION LEVEL must be called before any query"); diff --git a/src/backend/commands/view.c b/src/backend/commands/view.c index 06de282f19..1cea214613 100644 --- a/src/backend/commands/view.c +++ b/src/backend/commands/view.c @@ -5,11 +5,11 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: view.c,v 1.32 1999/02/13 23:15:12 momjian Exp $ + * $Id: view.c,v 1.33 1999/05/25 16:08:28 momjian Exp $ * *------------------------------------------------------------------------- */ -#include +#include #include #include @@ -230,9 +230,9 @@ UpdateRangeTableOfViewParse(char *viewName, Query *viewParse) * table... CURRENT first, then NEW.... */ rt_entry1 = addRangeTableEntry(NULL, (char *) viewName, "*CURRENT*", - FALSE, FALSE); + FALSE, FALSE); rt_entry2 = addRangeTableEntry(NULL, (char *) viewName, "*NEW*", - FALSE, FALSE); + FALSE, FALSE); new_rt = lcons(rt_entry2, old_rt); new_rt = lcons(rt_entry1, new_rt); diff --git a/src/backend/executor/_deadcode/nodeTee.c b/src/backend/executor/_deadcode/nodeTee.c index b06c700c46..645a11cd11 100644 --- a/src/backend/executor/_deadcode/nodeTee.c +++ b/src/backend/executor/_deadcode/nodeTee.c @@ -6,15 +6,15 @@ * Copyright (c) 1994, Regents of the University of California * * DESCRIPTION - * This code provides support for a tee node, which allows - * multiple parent in a megaplan. + * This code provides support for a tee node, which allows + * multiple parent in a megaplan. * * INTERFACE ROUTINES * ExecTee * ExecInitTee * ExecEndTee * - * $Id: nodeTee.c,v 1.1 1999/03/23 16:50:49 momjian Exp $ + * $Id: nodeTee.c,v 1.2 1999/05/25 16:08:50 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -46,12 +46,12 @@ bool ExecInitTee(Tee *node, EState *currentEstate, Plan *parent) { - TeeState *teeState; - Plan *outerPlan; - int len; + TeeState *teeState; + Plan *outerPlan; + int len; Relation bufferRel; TupleDesc tupType; - EState *estate; + EState *estate; /* * it is possible that the Tee has already been initialized since it @@ -167,7 +167,7 @@ ExecInitTee(Tee *node, EState *currentEstate, Plan *parent) else bufferRel = heap_open( heap_create_with_catalog(teeState->tee_bufferRelname, - tupType, RELKIND_RELATION, false)); + tupType, RELKIND_RELATION, false)); } else { @@ -176,7 +176,7 @@ ExecInitTee(Tee *node, EState *currentEstate, Plan *parent) newoid()); bufferRel = heap_open( heap_create_with_catalog(teeState->tee_bufferRelname, - tupType, RELKIND_RELATION, false)); + tupType, RELKIND_RELATION, false)); } teeState->tee_bufferRel = bufferRel; @@ -339,6 +339,7 @@ ExecTee(Tee *node, Plan *parent) slot = ExecProcNode(childNode, (Plan *) node); if (!TupIsNull(slot)) { + /* * heap_insert changes something... */ diff --git a/src/backend/executor/execAmi.c b/src/backend/executor/execAmi.c index 7b8bde8e1b..d4c60687a1 100644 --- a/src/backend/executor/execAmi.c +++ b/src/backend/executor/execAmi.c @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: execAmi.c,v 1.34 1999/05/10 00:45:05 momjian Exp $ + * $Id: execAmi.c,v 1.35 1999/05/25 16:08:34 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -24,7 +24,7 @@ * ExecCreatR function to create temporary relations * */ -#include +#include #include "postgres.h" diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c index 3565613bba..cab1b06624 100644 --- a/src/backend/executor/execMain.c +++ b/src/backend/executor/execMain.c @@ -26,7 +26,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.83 1999/05/10 00:45:06 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.84 1999/05/25 16:08:36 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -61,26 +61,26 @@ void ExecCheckPerms(CmdType operation, int resultRelation, List *rangeTable, /* decls for local routines only used within this module */ static TupleDesc InitPlan(CmdType operation, - Query *parseTree, - Plan *plan, - EState *estate); + Query *parseTree, + Plan *plan, + EState *estate); static void EndPlan(Plan *plan, - EState *estate); + EState *estate); static TupleTableSlot *ExecutePlan(EState *estate, Plan *plan, - CmdType operation, - int offsetTuples, - int numberTuples, - ScanDirection direction, - DestReceiver *destfunc); + CmdType operation, + int offsetTuples, + int numberTuples, + ScanDirection direction, + DestReceiver * destfunc); static void ExecRetrieve(TupleTableSlot *slot, - DestReceiver *destfunc, - EState *estate); + DestReceiver * destfunc, + EState *estate); static void ExecAppend(TupleTableSlot *slot, ItemPointer tupleid, - EState *estate); + EState *estate); static void ExecDelete(TupleTableSlot *slot, ItemPointer tupleid, - EState *estate); + EState *estate); static void ExecReplace(TupleTableSlot *slot, ItemPointer tupleid, - EState *estate); + EState *estate); TupleTableSlot *EvalPlanQual(EState *estate, Index rti, ItemPointer tid); static TupleTableSlot *EvalPlanQualNext(EState *estate); @@ -141,14 +141,14 @@ ExecutorStart(QueryDesc *queryDesc, EState *estate) estate->es_snapshot = NULL; else { - estate->es_snapshot = (Snapshot)palloc(sizeof(SnapshotData)); + estate->es_snapshot = (Snapshot) palloc(sizeof(SnapshotData)); memcpy(estate->es_snapshot, QuerySnapshot, sizeof(SnapshotData)); if (estate->es_snapshot->xcnt > 0) { estate->es_snapshot->xip = (TransactionId *) - palloc(estate->es_snapshot->xcnt * sizeof(TransactionId)); + palloc(estate->es_snapshot->xcnt * sizeof(TransactionId)); memcpy(estate->es_snapshot->xip, QuerySnapshot->xip, - estate->es_snapshot->xcnt * sizeof(TransactionId)); + estate->es_snapshot->xcnt * sizeof(TransactionId)); } } @@ -193,25 +193,25 @@ ExecutorStart(QueryDesc *queryDesc, EState *estate) * ---------------------------------------------------------------- */ TupleTableSlot * -ExecutorRun(QueryDesc *queryDesc, EState *estate, int feature, - Node *limoffset, Node *limcount) +ExecutorRun(QueryDesc *queryDesc, EState *estate, int feature, + Node *limoffset, Node *limcount) { - CmdType operation; - Plan *plan; + CmdType operation; + Plan *plan; TupleTableSlot *result; - CommandDest dest; - DestReceiver *destfunc; - int offset = 0; - int count = 0; + CommandDest dest; + DestReceiver *destfunc; + int offset = 0; + int count = 0; /* - * sanity checks + * sanity checks */ Assert(queryDesc != NULL); /* - * extract information from the query descriptor - * and the query feature. + * extract information from the query descriptor and the query + * feature. */ operation = queryDesc->operation; plan = queryDesc->plantree; @@ -221,34 +221,34 @@ ExecutorRun(QueryDesc *queryDesc, EState *estate, int feature, estate->es_lastoid = InvalidOid; /* - * FIXME: the dest setup function ought to be handed the tuple desc - * for the tuples to be output, but I'm not quite sure how to get that - * info at this point. For now, passing NULL is OK because no existing - * dest setup function actually uses the pointer. + * FIXME: the dest setup function ought to be handed the tuple desc + * for the tuples to be output, but I'm not quite sure how to get that + * info at this point. For now, passing NULL is OK because no + * existing dest setup function actually uses the pointer. */ (*destfunc->setup) (destfunc, (TupleDesc) NULL); - /* - * if given get the offset of the LIMIT clause - */ - if (limoffset != NULL) - { - Const *coffset; - Param *poffset; - ParamListInfo paramLI; - int i; - + /* + * if given get the offset of the LIMIT clause + */ + if (limoffset != NULL) + { + Const *coffset; + Param *poffset; + ParamListInfo paramLI; + int i; + switch (nodeTag(limoffset)) { case T_Const: - coffset = (Const *)limoffset; - offset = (int)(coffset->constvalue); + coffset = (Const *) limoffset; + offset = (int) (coffset->constvalue); break; - + case T_Param: - poffset = (Param *)limoffset; + poffset = (Param *) limoffset; paramLI = estate->es_param_list_info; - + if (paramLI == NULL) elog(ERROR, "parameter for limit offset not in executor state"); for (i = 0; paramLI[i].kind != PARAM_INVALID; i++) @@ -260,60 +260,60 @@ ExecutorRun(QueryDesc *queryDesc, EState *estate, int feature, elog(ERROR, "parameter for limit offset not in executor state"); if (paramLI[i].isnull) elog(ERROR, "limit offset cannot be NULL value"); - offset = (int)(paramLI[i].value); - + offset = (int) (paramLI[i].value); + break; - + default: elog(ERROR, "unexpected node type %d as limit offset", nodeTag(limoffset)); } - + if (offset < 0) elog(ERROR, "limit offset cannot be negative"); } - + /* - * if given get the count of the LIMIT clause + * if given get the count of the LIMIT clause */ if (limcount != NULL) { - Const *ccount; - Param *pcount; - ParamListInfo paramLI; - int i; - - switch (nodeTag(limcount)) - { - case T_Const: - ccount = (Const *)limcount; - count = (int)(ccount->constvalue); - break; - - case T_Param: - pcount = (Param *)limcount; - paramLI = estate->es_param_list_info; - - if (paramLI == NULL) - elog(ERROR, "parameter for limit count not in executor state"); - for (i = 0; paramLI[i].kind != PARAM_INVALID; i++) - { - if (paramLI[i].kind == PARAM_NUM && paramLI[i].id == pcount->paramid) - break; - } - if (paramLI[i].kind == PARAM_INVALID) - elog(ERROR, "parameter for limit count not in executor state"); - if (paramLI[i].isnull) - elog(ERROR, "limit count cannot be NULL value"); - count = (int)(paramLI[i].value); - - break; - - default: - elog(ERROR, "unexpected node type %d as limit count", nodeTag(limcount)); - } - - if (count < 0) - elog(ERROR, "limit count cannot be negative"); + Const *ccount; + Param *pcount; + ParamListInfo paramLI; + int i; + + switch (nodeTag(limcount)) + { + case T_Const: + ccount = (Const *) limcount; + count = (int) (ccount->constvalue); + break; + + case T_Param: + pcount = (Param *) limcount; + paramLI = estate->es_param_list_info; + + if (paramLI == NULL) + elog(ERROR, "parameter for limit count not in executor state"); + for (i = 0; paramLI[i].kind != PARAM_INVALID; i++) + { + if (paramLI[i].kind == PARAM_NUM && paramLI[i].id == pcount->paramid) + break; + } + if (paramLI[i].kind == PARAM_INVALID) + elog(ERROR, "parameter for limit count not in executor state"); + if (paramLI[i].isnull) + elog(ERROR, "limit count cannot be NULL value"); + count = (int) (paramLI[i].value); + + break; + + default: + elog(ERROR, "unexpected node type %d as limit count", nodeTag(limcount)); + } + + if (count < 0) + elog(ERROR, "limit count cannot be negative"); } switch (feature) @@ -339,7 +339,7 @@ ExecutorRun(QueryDesc *queryDesc, EState *estate, int feature, break; /* - * retrieve next n "backward" tuples + * retrieve next n "backward" tuples */ case EXEC_BACK: result = ExecutePlan(estate, @@ -352,8 +352,8 @@ ExecutorRun(QueryDesc *queryDesc, EState *estate, int feature, break; /* - * return one tuple but don't "retrieve" it. - * (this is used by the rule manager..) -cim 9/14/89 + * return one tuple but don't "retrieve" it. (this is used by + * the rule manager..) -cim 9/14/89 */ case EXEC_RETONE: result = ExecutePlan(estate, @@ -395,20 +395,25 @@ ExecutorEnd(QueryDesc *queryDesc, EState *estate) EndPlan(queryDesc->plantree, estate); /* XXX - clean up some more from ExecutorStart() - er1p */ - if (NULL == estate->es_snapshot) { - /* nothing to free */ - } else { - if (estate->es_snapshot->xcnt > 0) { - pfree(estate->es_snapshot->xip); - } - pfree(estate->es_snapshot); + if (NULL == estate->es_snapshot) + { + /* nothing to free */ + } + else + { + if (estate->es_snapshot->xcnt > 0) + pfree(estate->es_snapshot->xip); + pfree(estate->es_snapshot); } - if (NULL == estate->es_param_exec_vals) { - /* nothing to free */ - } else { - pfree(estate->es_param_exec_vals); - estate->es_param_exec_vals = NULL; + if (NULL == estate->es_param_exec_vals) + { + /* nothing to free */ + } + else + { + pfree(estate->es_param_exec_vals); + estate->es_param_exec_vals = NULL; } /* restore saved refcounts. */ @@ -509,15 +514,15 @@ ExecCheckPerms(CmdType operation, { foreach(lp, parseTree->rowMark) { - RowMark *rm = lfirst(lp); + RowMark *rm = lfirst(lp); if (!(rm->info & ROW_ACL_FOR_UPDATE)) continue; - relid = ((RangeTblEntry *)nth(rm->rti - 1, rangeTable))->relid; + relid = ((RangeTblEntry *) nth(rm->rti - 1, rangeTable))->relid; htup = SearchSysCacheTuple(RELOID, - ObjectIdGetDatum(relid), - 0, 0, 0); + ObjectIdGetDatum(relid), + 0, 0, 0); if (!HeapTupleIsValid(htup)) elog(ERROR, "ExecCheckPerms: bogus RT relid: %u", relid); StrNCpy(rname.data, @@ -543,15 +548,15 @@ typedef struct execRowMark Relation relation; Index rti; char resname[32]; -} execRowMark; +} execRowMark; typedef struct evalPlanQual { - Plan *plan; - Index rti; - EState estate; - struct evalPlanQual *free; -} evalPlanQual; + Plan *plan; + Index rti; + EState estate; + struct evalPlanQual *free; +} evalPlanQual; /* ---------------------------------------------------------------- * InitPlan @@ -563,15 +568,15 @@ typedef struct evalPlanQual static TupleDesc InitPlan(CmdType operation, Query *parseTree, Plan *plan, EState *estate) { - List *rangeTable; - int resultRelation; - Relation intoRelationDesc; - TupleDesc tupType; - List *targetList; - int len; + List *rangeTable; + int resultRelation; + Relation intoRelationDesc; + TupleDesc tupType; + List *targetList; + int len; /* - * get information from query descriptor + * get information from query descriptor */ rangeTable = parseTree->rtable; resultRelation = parseTree->resultRelation; @@ -581,27 +586,27 @@ InitPlan(CmdType operation, Query *parseTree, Plan *plan, EState *estate) #endif /* - * initialize the node's execution state + * initialize the node's execution state */ estate->es_range_table = rangeTable; /* - * initialize the BaseId counter so node base_id's - * are assigned correctly. Someday baseid's will have to - * be stored someplace other than estate because they - * should be unique per query planned. + * initialize the BaseId counter so node base_id's are assigned + * correctly. Someday baseid's will have to be stored someplace other + * than estate because they should be unique per query planned. */ estate->es_BaseId = 1; /* - * initialize result relation stuff + * initialize result relation stuff */ - + if (resultRelation != 0 && operation != CMD_SELECT) { + /* - * if we have a result relation, open it and - * initialize the result relation info stuff. + * if we have a result relation, open it and initialize the result + * relation info stuff. */ RelationInfo *resultRelationInfo; Index resultRelationIndex; @@ -628,8 +633,8 @@ InitPlan(CmdType operation, Query *parseTree, Plan *plan, EState *estate) resultRelationInfo->ri_IndexRelationInfo = NULL; /* - * open indices on result relation and save descriptors - * in the result relation information.. + * open indices on result relation and save descriptors in the + * result relation information.. */ if (operation != CMD_DELETE) ExecOpenIndices(resultRelationOid, resultRelationInfo); @@ -638,8 +643,9 @@ InitPlan(CmdType operation, Query *parseTree, Plan *plan, EState *estate) } else { + /* - * if no result relation, then set state appropriately + * if no result relation, then set state appropriately */ estate->es_result_relation_info = NULL; } @@ -650,21 +656,21 @@ InitPlan(CmdType operation, Query *parseTree, Plan *plan, EState *estate) estate->es_rowMark = NULL; if (parseTree->rowMark != NULL) { - Relation relation; - Oid relid; - RowMark *rm; - List *l; - execRowMark *erm; + Relation relation; + Oid relid; + RowMark *rm; + List *l; + execRowMark *erm; foreach(l, parseTree->rowMark) { rm = lfirst(l); - relid = ((RangeTblEntry *)nth(rm->rti - 1, rangeTable))->relid; + relid = ((RangeTblEntry *) nth(rm->rti - 1, rangeTable))->relid; relation = heap_open(relid); LockRelation(relation, RowShareLock); if (!(rm->info & ROW_MARK_FOR_UPDATE)) continue; - erm = (execRowMark*) palloc(sizeof(execRowMark)); + erm = (execRowMark *) palloc(sizeof(execRowMark)); erm->relation = relation; erm->rti = rm->rti; sprintf(erm->resname, "ctid%u", rm->rti); @@ -673,7 +679,7 @@ InitPlan(CmdType operation, Query *parseTree, Plan *plan, EState *estate) } /* - * initialize the executor "tuple" table. + * initialize the executor "tuple" table. */ { int nSlots = ExecCountSlotsNode(plan); @@ -683,31 +689,29 @@ InitPlan(CmdType operation, Query *parseTree, Plan *plan, EState *estate) } /* - * initialize the private state information for - * all the nodes in the query tree. This opens - * files, allocates storage and leaves us ready - * to start processing tuples.. + * initialize the private state information for all the nodes in the + * query tree. This opens files, allocates storage and leaves us + * ready to start processing tuples.. */ ExecInitNode(plan, estate, NULL); /* - * get the tuple descriptor describing the type - * of tuples to return.. (this is especially important - * if we are creating a relation with "retrieve into") + * get the tuple descriptor describing the type of tuples to return.. + * (this is especially important if we are creating a relation with + * "retrieve into") */ tupType = ExecGetTupType(plan); /* tuple descriptor */ targetList = plan->targetlist; len = ExecTargetListLength(targetList); /* number of attributes */ /* - * now that we have the target list, initialize the junk filter - * if this is a REPLACE or a DELETE query. - * We also init the junk filter if this is an append query - * (there might be some rule lock info there...) - * NOTE: in the future we might want to initialize the junk - * filter for all queries. - * SELECT added by daveh@insightdist.com 5/20/98 to allow - * ORDER/GROUP BY have an identifier missing from the target. + * now that we have the target list, initialize the junk filter if + * this is a REPLACE or a DELETE query. We also init the junk filter + * if this is an append query (there might be some rule lock info + * there...) NOTE: in the future we might want to initialize the junk + * filter for all queries. SELECT added by daveh@insightdist.com + * 5/20/98 to allow ORDER/GROUP BY have an identifier missing from the + * target. */ { bool junk_filter_needed = false; @@ -743,7 +747,7 @@ InitPlan(CmdType operation, Query *parseTree, Plan *plan, EState *estate) } /* - * initialize the "into" relation + * initialize the "into" relation */ intoRelationDesc = (Relation) NULL; @@ -761,8 +765,9 @@ InitPlan(CmdType operation, Query *parseTree, Plan *plan, EState *estate) */ if (parseTree->into != NULL) { + /* - * create the "into" relation + * create the "into" relation */ intoName = parseTree->into; @@ -772,14 +777,14 @@ InitPlan(CmdType operation, Query *parseTree, Plan *plan, EState *estate) tupdesc = CreateTupleDescCopy(tupType); intoRelationId = heap_create_with_catalog(intoName, - tupdesc, RELKIND_RELATION,parseTree->isTemp); + tupdesc, RELKIND_RELATION, parseTree->isTemp); FreeTupleDesc(tupdesc); /* - * XXX rather than having to call setheapoverride(true) - * and then back to false, we should change the - * arguments to heap_open() instead.. + * XXX rather than having to call setheapoverride(true) + * and then back to false, we should change the arguments + * to heap_open() instead.. */ setheapoverride(true); @@ -813,18 +818,18 @@ EndPlan(Plan *plan, EState *estate) Relation intoRelationDesc; /* - * get information from state + * get information from state */ resultRelationInfo = estate->es_result_relation_info; intoRelationDesc = estate->es_into_relation_descriptor; /* - * shut down the query + * shut down the query */ ExecEndNode(plan, plan); /* - * destroy the executor "tuple" table. + * destroy the executor "tuple" table. */ { TupleTable tupleTable = (TupleTable) estate->es_tupleTable; @@ -834,7 +839,7 @@ EndPlan(Plan *plan, EState *estate) } /* - * close the result relations if necessary + * close the result relations if necessary */ if (resultRelationInfo != NULL) { @@ -844,13 +849,13 @@ EndPlan(Plan *plan, EState *estate) heap_close(resultRelationDesc); /* - * close indices on the result relation + * close indices on the result relation */ ExecCloseIndices(resultRelationInfo); } /* - * close the "into" relation if necessary + * close the "into" relation if necessary */ if (intoRelationDesc != NULL) heap_close(intoRelationDesc); @@ -879,7 +884,7 @@ ExecutePlan(EState *estate, int offsetTuples, int numberTuples, ScanDirection direction, - DestReceiver* destfunc) + DestReceiver * destfunc) { JunkFilter *junkfilter; TupleTableSlot *slot; @@ -889,29 +894,30 @@ ExecutePlan(EState *estate, TupleTableSlot *result; /* - * initialize local variables + * initialize local variables */ slot = NULL; current_tuple_count = 0; result = NULL; - /* - * Set the direction. + /* + * Set the direction. */ estate->es_direction = direction; /* - * Loop until we've processed the proper number - * of tuples from the plan.. + * Loop until we've processed the proper number of tuples from the + * plan.. */ for (;;) { + /* - * Execute the plan and obtain a tuple + * Execute the plan and obtain a tuple */ /* at the top level, the parent of a plan (2nd arg) is itself */ -lnext:; +lnext: ; if (estate->es_useEvalPlan) { slot = EvalPlanQualNext(estate); @@ -922,9 +928,8 @@ lnext:; slot = ExecProcNode(plan, plan); /* - * if the tuple is null, then we assume - * there is nothing more to process so - * we just return null... + * if the tuple is null, then we assume there is nothing more to + * process so we just return null... */ if (TupIsNull(slot)) { @@ -933,11 +938,9 @@ lnext:; } /* - * For now we completely execute the plan and skip - * result tuples if requested by LIMIT offset. - * Finally we should try to do it in deeper levels - * if possible (during index scan) - * - Jan + * For now we completely execute the plan and skip result tuples + * if requested by LIMIT offset. Finally we should try to do it in + * deeper levels if possible (during index scan) - Jan */ if (offsetTuples > 0) { @@ -946,13 +949,12 @@ lnext:; } /* - * if we have a junk filter, then project a new - * tuple with the junk removed. + * if we have a junk filter, then project a new tuple with the + * junk removed. * - * Store this new "clean" tuple in the place of the - * original tuple. + * Store this new "clean" tuple in the place of the original tuple. * - * Also, extract all the junk information we need. + * Also, extract all the junk information we need. */ if ((junkfilter = estate->es_junkFilter) != (JunkFilter *) NULL) { @@ -982,15 +984,15 @@ lnext:; } else if (estate->es_rowMark != NULL) { - List *l; - execRowMark *erm; - Buffer buffer; - HeapTupleData tuple; + List *l; + execRowMark *erm; + Buffer buffer; + HeapTupleData tuple; TupleTableSlot *newSlot; - int test; + int test; -lmark:; - foreach (l, estate->es_rowMark) + lmark: ; + foreach(l, estate->es_rowMark) { erm = lfirst(l); if (!ExecGetJunkAttribute(junkfilter, @@ -1016,12 +1018,12 @@ lmark:; if (XactIsoLevel == XACT_SERIALIZABLE) { elog(ERROR, "Can't serialize access due to concurrent update"); - return(NULL); + return (NULL); } - else if (!(ItemPointerEquals(&(tuple.t_self), - (ItemPointer)DatumGetPointer(datum)))) + else if (!(ItemPointerEquals(&(tuple.t_self), + (ItemPointer) DatumGetPointer(datum)))) { - newSlot = EvalPlanQual(estate, erm->rti, &(tuple.t_self)); + newSlot = EvalPlanQual(estate, erm->rti, &(tuple.t_self)); if (!(TupIsNull(newSlot))) { slot = newSlot; @@ -1029,16 +1031,17 @@ lmark:; goto lmark; } } - /* - * if tuple was deleted or PlanQual failed - * for updated tuple - we have not return - * this tuple! + + /* + * if tuple was deleted or PlanQual failed for + * updated tuple - we have not return this + * tuple! */ goto lnext; default: elog(ERROR, "Unknown status %u from heap_mark4update", test); - return(NULL); + return (NULL); } } } @@ -1057,17 +1060,17 @@ lmark:; } /* if (junkfilter... */ /* - * now that we have a tuple, do the appropriate thing - * with it.. either return it to the user, add - * it to a relation someplace, delete it from a - * relation, or modify some of it's attributes. + * now that we have a tuple, do the appropriate thing with it.. + * either return it to the user, add it to a relation someplace, + * delete it from a relation, or modify some of it's attributes. */ switch (operation) { case CMD_SELECT: ExecRetrieve(slot, /* slot containing tuple */ - destfunc, /* destination's tuple-receiver obj */ + destfunc, /* destination's tuple-receiver + * obj */ estate); /* */ result = slot; break; @@ -1092,10 +1095,10 @@ lmark:; result = NULL; break; } + /* - * check our tuple count.. if we've returned the - * proper number then return, else loop again and - * process more tuples.. + * check our tuple count.. if we've returned the proper number + * then return, else loop again and process more tuples.. */ current_tuple_count += 1; if (numberTuples == current_tuple_count) @@ -1103,8 +1106,8 @@ lmark:; } /* - * here, result is either a slot containing a tuple in the case - * of a RETRIEVE or NULL otherwise. + * here, result is either a slot containing a tuple in the case of a + * RETRIEVE or NULL otherwise. */ return result; } @@ -1121,20 +1124,20 @@ lmark:; */ static void ExecRetrieve(TupleTableSlot *slot, - DestReceiver *destfunc, + DestReceiver * destfunc, EState *estate) { HeapTuple tuple; TupleDesc attrtype; /* - * get the heap tuple out of the tuple table slot + * get the heap tuple out of the tuple table slot */ tuple = slot->val; attrtype = slot->ttc_tupleDescriptor; /* - * insert the tuple into the "into relation" + * insert the tuple into the "into relation" */ if (estate->es_into_relation_descriptor != NULL) { @@ -1143,7 +1146,7 @@ ExecRetrieve(TupleTableSlot *slot, } /* - * send the tuple to the front end (or the screen) + * send the tuple to the front end (or the screen) */ (*destfunc->receiveTuple) (tuple, attrtype, destfunc); IncrRetrieved(); @@ -1171,19 +1174,18 @@ ExecAppend(TupleTableSlot *slot, Oid newId; /* - * get the heap tuple out of the tuple table slot + * get the heap tuple out of the tuple table slot */ tuple = slot->val; /* - * get information on the result relation + * get information on the result relation */ resultRelationInfo = estate->es_result_relation_info; resultRelationDesc = resultRelationInfo->ri_RelationDesc; /* - * have to add code to preform unique checking here. - * cim -12/1/89 + * have to add code to preform unique checking here. cim -12/1/89 */ /* BEFORE ROW INSERT Triggers */ @@ -1210,23 +1212,21 @@ ExecAppend(TupleTableSlot *slot, */ if (resultRelationDesc->rd_att->constr) - { ExecConstraints("ExecAppend", resultRelationDesc, tuple, estate); - } /* - * insert the tuple + * insert the tuple */ newId = heap_insert(resultRelationDesc, /* relation desc */ tuple); /* heap tuple */ IncrAppended(); /* - * process indices + * process indices * - * Note: heap_insert adds a new tuple to a relation. As a side - * effect, the tupleid of the new tuple is placed in the new - * tuple's t_ctid field. + * Note: heap_insert adds a new tuple to a relation. As a side effect, + * the tupleid of the new tuple is placed in the new tuple's t_ctid + * field. */ numIndices = resultRelationInfo->ri_NumIndices; if (numIndices > 0) @@ -1252,13 +1252,13 @@ ExecDelete(TupleTableSlot *slot, ItemPointer tupleid, EState *estate) { - RelationInfo *resultRelationInfo; - Relation resultRelationDesc; - ItemPointerData ctid; - int result; + RelationInfo *resultRelationInfo; + Relation resultRelationDesc; + ItemPointerData ctid; + int result; /* - * get the result relation information + * get the result relation information */ resultRelationInfo = estate->es_result_relation_info; resultRelationDesc = resultRelationInfo->ri_RelationDesc; @@ -1276,7 +1276,7 @@ ExecDelete(TupleTableSlot *slot, } /* - * delete the tuple + * delete the tuple */ ldelete:; result = heap_delete(resultRelationDesc, tupleid, &ctid); @@ -1293,8 +1293,8 @@ ldelete:; elog(ERROR, "Can't serialize access due to concurrent update"); else if (!(ItemPointerEquals(tupleid, &ctid))) { - TupleTableSlot *epqslot = EvalPlanQual(estate, - resultRelationInfo->ri_RangeTableIndex, &ctid); + TupleTableSlot *epqslot = EvalPlanQual(estate, + resultRelationInfo->ri_RangeTableIndex, &ctid); if (!TupIsNull(epqslot)) { @@ -1313,14 +1313,12 @@ ldelete:; (estate->es_processed)++; /* - * Note: Normally one would think that we have to - * delete index tuples associated with the - * heap tuple now.. + * Note: Normally one would think that we have to delete index tuples + * associated with the heap tuple now.. * - * ... but in POSTGRES, we have no need to do this - * because the vacuum daemon automatically - * opens an index scan and deletes index tuples - * when it finds deleted heap tuples. -cim 9/27/89 + * ... but in POSTGRES, we have no need to do this because the vacuum + * daemon automatically opens an index scan and deletes index tuples + * when it finds deleted heap tuples. -cim 9/27/89 */ /* AFTER ROW DELETE Triggers */ @@ -1346,15 +1344,15 @@ ExecReplace(TupleTableSlot *slot, ItemPointer tupleid, EState *estate) { - HeapTuple tuple; - RelationInfo *resultRelationInfo; - Relation resultRelationDesc; - ItemPointerData ctid; - int result; - int numIndices; + HeapTuple tuple; + RelationInfo *resultRelationInfo; + Relation resultRelationDesc; + ItemPointerData ctid; + int result; + int numIndices; /* - * abort the operation if not running transactions + * abort the operation if not running transactions */ if (IsBootstrapProcessingMode()) { @@ -1363,21 +1361,20 @@ ExecReplace(TupleTableSlot *slot, } /* - * get the heap tuple out of the tuple table slot + * get the heap tuple out of the tuple table slot */ tuple = slot->val; /* - * get the result relation information + * get the result relation information */ resultRelationInfo = estate->es_result_relation_info; resultRelationDesc = resultRelationInfo->ri_RelationDesc; /* - * have to add code to preform unique checking here. - * in the event of unique tuples, this becomes a deletion - * of the original tuple affected by the replace. - * cim -12/1/89 + * have to add code to preform unique checking here. in the event of + * unique tuples, this becomes a deletion of the original tuple + * affected by the replace. cim -12/1/89 */ /* BEFORE ROW UPDATE Triggers */ @@ -1404,12 +1401,10 @@ ExecReplace(TupleTableSlot *slot, */ if (resultRelationDesc->rd_att->constr) - { ExecConstraints("ExecReplace", resultRelationDesc, tuple, estate); - } /* - * replace the heap tuple + * replace the heap tuple */ lreplace:; result = heap_replace(resultRelationDesc, tupleid, tuple, &ctid); @@ -1426,8 +1421,8 @@ lreplace:; elog(ERROR, "Can't serialize access due to concurrent update"); else if (!(ItemPointerEquals(tupleid, &ctid))) { - TupleTableSlot *epqslot = EvalPlanQual(estate, - resultRelationInfo->ri_RangeTableIndex, &ctid); + TupleTableSlot *epqslot = EvalPlanQual(estate, + resultRelationInfo->ri_RangeTableIndex, &ctid); if (!TupIsNull(epqslot)) { @@ -1448,23 +1443,21 @@ lreplace:; (estate->es_processed)++; /* - * Note: instead of having to update the old index tuples - * associated with the heap tuple, all we do is form - * and insert new index tuples.. This is because - * replaces are actually deletes and inserts and - * index tuple deletion is done automagically by - * the vaccuum deamon.. All we do is insert new - * index tuples. -cim 9/27/89 + * Note: instead of having to update the old index tuples associated + * with the heap tuple, all we do is form and insert new index + * tuples.. This is because replaces are actually deletes and inserts + * and index tuple deletion is done automagically by the vaccuum + * deamon.. All we do is insert new index tuples. -cim 9/27/89 */ /* - * process indices + * process indices * - * heap_replace updates a tuple in the base relation by invalidating - * it and then appending a new tuple to the relation. As a side - * effect, the tupleid of the new tuple is placed in the new - * tuple's t_ctid field. So we now insert index tuples using - * the new tupleid stored there. + * heap_replace updates a tuple in the base relation by invalidating it + * and then appending a new tuple to the relation. As a side effect, + * the tupleid of the new tuple is placed in the new tuple's t_ctid + * field. So we now insert index tuples using the new tupleid stored + * there. */ numIndices = resultRelationInfo->ri_NumIndices; @@ -1584,7 +1577,7 @@ ExecRelCheck(Relation rel, HeapTuple tuple, EState *estate) if (estate->es_result_relation_constraints == NULL) { estate->es_result_relation_constraints = - (List **)palloc(ncheck * sizeof(List *)); + (List **) palloc(ncheck * sizeof(List *)); for (i = 0; i < ncheck; i++) { @@ -1642,41 +1635,41 @@ ExecConstraints(char *caller, Relation rel, HeapTuple tuple, EState *estate) return; } -TupleTableSlot* +TupleTableSlot * EvalPlanQual(EState *estate, Index rti, ItemPointer tid) { - evalPlanQual *epq = (evalPlanQual*) estate->es_evalPlanQual; - evalPlanQual *oldepq; - EState *epqstate = NULL; - Relation relation; - Buffer buffer; - HeapTupleData tuple; - bool endNode = true; + evalPlanQual *epq = (evalPlanQual *) estate->es_evalPlanQual; + evalPlanQual *oldepq; + EState *epqstate = NULL; + Relation relation; + Buffer buffer; + HeapTupleData tuple; + bool endNode = true; Assert(rti != 0); if (epq != NULL && epq->rti == 0) { - Assert(!(estate->es_useEvalPlan) && - epq->estate.es_evalPlanQual == NULL); + Assert(!(estate->es_useEvalPlan) && + epq->estate.es_evalPlanQual == NULL); epq->rti = rti; endNode = false; } /* * If this is request for another RTE - Ra, - then we have to check - * wasn't PlanQual requested for Ra already and if so then Ra' row - * was updated again and we have to re-start old execution for Ra - * and forget all what we done after Ra was suspended. Cool? -:)) + * wasn't PlanQual requested for Ra already and if so then Ra' row was + * updated again and we have to re-start old execution for Ra and + * forget all what we done after Ra was suspended. Cool? -:)) */ - if (epq != NULL && epq->rti != rti && + if (epq != NULL && epq->rti != rti && epq->estate.es_evTuple[rti - 1] != NULL) { do { /* pop previous PlanQual from the stack */ epqstate = &(epq->estate); - oldepq = (evalPlanQual*) epqstate->es_evalPlanQual; + oldepq = (evalPlanQual *) epqstate->es_evalPlanQual; Assert(oldepq->rti != 0); /* stop execution */ ExecEndNode(epq->plan, epq->plan); @@ -1689,54 +1682,50 @@ EvalPlanQual(EState *estate, Index rti, ItemPointer tid) estate->es_evalPlanQual = (Pointer) epq; } - /* + /* * If we are requested for another RTE then we have to suspend * execution of current PlanQual and start execution for new one. */ if (epq == NULL || epq->rti != rti) { /* try to reuse plan used previously */ - evalPlanQual *newepq = (epq != NULL) ? epq->free : NULL; + evalPlanQual *newepq = (epq != NULL) ? epq->free : NULL; if (newepq == NULL) /* first call or freePQ stack is empty */ { - newepq = (evalPlanQual*) palloc(sizeof(evalPlanQual)); + newepq = (evalPlanQual *) palloc(sizeof(evalPlanQual)); /* Init EState */ epqstate = &(newepq->estate); memset(epqstate, 0, sizeof(EState)); - epqstate->type = T_EState; + epqstate->type = T_EState; epqstate->es_direction = ForwardScanDirection; epqstate->es_snapshot = estate->es_snapshot; epqstate->es_range_table = estate->es_range_table; epqstate->es_param_list_info = estate->es_param_list_info; if (estate->es_origPlan->nParamExec > 0) epqstate->es_param_exec_vals = (ParamExecData *) - palloc(estate->es_origPlan->nParamExec * - sizeof(ParamExecData)); - epqstate->es_tupleTable = + palloc(estate->es_origPlan->nParamExec * + sizeof(ParamExecData)); + epqstate->es_tupleTable = ExecCreateTupleTable(estate->es_tupleTable->size); epqstate->es_refcount = estate->es_refcount; /* ... rest */ newepq->plan = copyObject(estate->es_origPlan); newepq->free = NULL; - epqstate->es_evTupleNull = (bool*) + epqstate->es_evTupleNull = (bool *) palloc(length(estate->es_range_table) * sizeof(bool)); if (epq == NULL) /* first call */ { - epqstate->es_evTuple = (HeapTuple*) + epqstate->es_evTuple = (HeapTuple *) palloc(length(estate->es_range_table) * sizeof(HeapTuple)); - memset(epqstate->es_evTuple, 0, - length(estate->es_range_table) * sizeof(HeapTuple)); + memset(epqstate->es_evTuple, 0, + length(estate->es_range_table) * sizeof(HeapTuple)); } else - { epqstate->es_evTuple = epq->estate.es_evTuple; - } } else - { epqstate = &(newepq->estate); - } /* push current PQ to the stack */ epqstate->es_evalPlanQual = (Pointer) epq; epq = newepq; @@ -1748,9 +1737,8 @@ EvalPlanQual(EState *estate, Index rti, ItemPointer tid) epqstate = &(epq->estate); /* - * Ok - we're requested for the same RTE (-:)). - * I'm not sure about ability to use ExecReScan instead of - * ExecInitNode, so... + * Ok - we're requested for the same RTE (-:)). I'm not sure about + * ability to use ExecReScan instead of ExecInitNode, so... */ if (endNode) ExecEndNode(epq->plan, epq->plan); @@ -1763,22 +1751,22 @@ EvalPlanQual(EState *estate, Index rti, ItemPointer tid) } /* ** fetch tid tuple ** */ - if (estate->es_result_relation_info != NULL && + if (estate->es_result_relation_info != NULL && estate->es_result_relation_info->ri_RangeTableIndex == rti) relation = estate->es_result_relation_info->ri_RelationDesc; else { - List *l; + List *l; - foreach (l, estate->es_rowMark) + foreach(l, estate->es_rowMark) { - if (((execRowMark*) lfirst(l))->rti == rti) + if (((execRowMark *) lfirst(l))->rti == rti) break; } - relation = ((execRowMark*) lfirst(l))->relation; + relation = ((execRowMark *) lfirst(l))->relation; } tuple.t_self = *tid; - for ( ; ; ) + for (;;) { heap_fetch(relation, SnapshotDirty, &tuple, &buffer); if (tuple.t_data != NULL) @@ -1787,9 +1775,10 @@ EvalPlanQual(EState *estate, Index rti, ItemPointer tid) if (TransactionIdIsValid(SnapshotDirty->xmin)) elog(ERROR, "EvalPlanQual: t_xmin is uncommitted ?!"); + /* - * If tuple is being updated by other transaction then - * we have to wait for its commit/abort. + * If tuple is being updated by other transaction then we have + * to wait for its commit/abort. */ if (TransactionIdIsValid(xwait)) { @@ -1797,6 +1786,7 @@ EvalPlanQual(EState *estate, Index rti, ItemPointer tid) XactLockTableWait(xwait); continue; } + /* * Nice! We got tuple - now copy it. */ @@ -1806,22 +1796,24 @@ EvalPlanQual(EState *estate, Index rti, ItemPointer tid) ReleaseBuffer(buffer); break; } + /* * Ops! Invalid tuple. Have to check is it updated or deleted. - * Note that it's possible to get invalid SnapshotDirty->tid - * if tuple updated by this transaction. Have we to check this ? + * Note that it's possible to get invalid SnapshotDirty->tid if + * tuple updated by this transaction. Have we to check this ? */ - if (ItemPointerIsValid(&(SnapshotDirty->tid)) && + if (ItemPointerIsValid(&(SnapshotDirty->tid)) && !(ItemPointerEquals(&(tuple.t_self), &(SnapshotDirty->tid)))) { tuple.t_self = SnapshotDirty->tid; /* updated ... */ continue; } + /* - * Deleted or updated by this transaction. Do not - * (re-)start execution of this PQ. Continue previous PQ. + * Deleted or updated by this transaction. Do not (re-)start + * execution of this PQ. Continue previous PQ. */ - oldepq = (evalPlanQual*) epqstate->es_evalPlanQual; + oldepq = (evalPlanQual *) epqstate->es_evalPlanQual; if (oldepq != NULL) { Assert(oldepq->rti != 0); @@ -1832,36 +1824,37 @@ EvalPlanQual(EState *estate, Index rti, ItemPointer tid) estate->es_evalPlanQual = (Pointer) epq; } else - { /* this is the first (oldest) PQ - epq->rti = 0; * - mark as free and - estate->es_useEvalPlan = false; * continue Query execution - return (NULL); */ + { /* this is the first (oldest) PQ epq->rti + * = 0; * - mark as + * free and estate->es_useEvalPlan = + * false; * continue Query execution + * return (NULL); */ } } if (estate->es_origPlan->nParamExec > 0) - memset(epqstate->es_param_exec_vals, 0, - estate->es_origPlan->nParamExec * sizeof(ParamExecData)); - memset(epqstate->es_evTupleNull, false, - length(estate->es_range_table) * sizeof(bool)); + memset(epqstate->es_param_exec_vals, 0, + estate->es_origPlan->nParamExec * sizeof(ParamExecData)); + memset(epqstate->es_evTupleNull, false, + length(estate->es_range_table) * sizeof(bool)); ExecInitNode(epq->plan, epqstate, NULL); /* - * For UPDATE/DELETE we have to return tid of actual row - * we're executing PQ for. + * For UPDATE/DELETE we have to return tid of actual row we're + * executing PQ for. */ *tid = tuple.t_self; return (EvalPlanQualNext(estate)); } -static TupleTableSlot* +static TupleTableSlot * EvalPlanQualNext(EState *estate) { - evalPlanQual *epq = (evalPlanQual*) estate->es_evalPlanQual; - EState *epqstate = &(epq->estate); - evalPlanQual *oldepq; - TupleTableSlot *slot; + evalPlanQual *epq = (evalPlanQual *) estate->es_evalPlanQual; + EState *epqstate = &(epq->estate); + evalPlanQual *oldepq; + TupleTableSlot *slot; Assert(epq->rti != 0); @@ -1877,11 +1870,12 @@ lpqnext:; pfree(epqstate->es_evTuple[epq->rti - 1]); epqstate->es_evTuple[epq->rti - 1] = NULL; /* pop old PQ from the stack */ - oldepq = (evalPlanQual*) epqstate->es_evalPlanQual; - if (oldepq == (evalPlanQual*) NULL) - { /* this is the first (oldest) */ - epq->rti = 0; /* PQ - mark as free and */ - estate->es_useEvalPlan = false; /* continue Query execution */ + oldepq = (evalPlanQual *) epqstate->es_evalPlanQual; + if (oldepq == (evalPlanQual *) NULL) + { /* this is the first (oldest) */ + epq->rti = 0; /* PQ - mark as free and */ + estate->es_useEvalPlan = false; /* continue Query + * execution */ return (NULL); } Assert(oldepq->rti != 0); diff --git a/src/backend/executor/execQual.c b/src/backend/executor/execQual.c index a021209cb1..d5a793e972 100644 --- a/src/backend/executor/execQual.c +++ b/src/backend/executor/execQual.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.50 1999/03/20 02:07:31 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.51 1999/05/25 16:08:37 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -66,7 +66,7 @@ bool execConstByVal; int execConstLen; /* static functions decls */ -static Datum ExecEvalAggref(Aggref *aggref, ExprContext *econtext, bool *isNull); +static Datum ExecEvalAggref(Aggref * aggref, ExprContext *econtext, bool *isNull); static Datum ExecEvalArrayRef(ArrayRef *arrayRef, ExprContext *econtext, bool *isNull, bool *isDone); static Datum ExecEvalAnd(Expr *andExpr, ExprContext *econtext, bool *isNull); @@ -190,7 +190,7 @@ ExecEvalArrayRef(ArrayRef *arrayRef, * ---------------------------------------------------------------- */ static Datum -ExecEvalAggref(Aggref *aggref, ExprContext *econtext, bool *isNull) +ExecEvalAggref(Aggref * aggref, ExprContext *econtext, bool *isNull) { *isNull = econtext->ecxt_nulls[aggref->aggno]; return econtext->ecxt_values[aggref->aggno]; @@ -232,7 +232,7 @@ ExecEvalVar(Var *variable, ExprContext *econtext, bool *isNull) int16 len; /* - * get the slot we want + * get the slot we want */ switch (variable->varno) { @@ -251,7 +251,7 @@ ExecEvalVar(Var *variable, ExprContext *econtext, bool *isNull) } /* - * extract tuple information from the slot + * extract tuple information from the slot */ heapTuple = slot->val; tuple_type = slot->ttc_tupleDescriptor; @@ -270,7 +270,7 @@ ExecEvalVar(Var *variable, ExprContext *econtext, bool *isNull) * the entire tuple, we give back a whole slot so that callers know * what the tuple looks like. */ - if (attnum == InvalidAttrNumber) + if (attnum == InvalidAttrNumber) { TupleTableSlot *tempSlot; TupleDesc td; @@ -299,26 +299,25 @@ ExecEvalVar(Var *variable, ExprContext *econtext, bool *isNull) isNull); /* return: is attribute null? */ /* - * return null if att is null + * return null if att is null */ if (*isNull) return (Datum) NULL; /* - * get length and type information.. - * ??? what should we do about variable length attributes - * - variable length attributes have their length stored - * in the first 4 bytes of the memory pointed to by the - * returned value.. If we can determine that the type - * is a variable length type, we can do the right thing. - * -cim 9/15/89 + * get length and type information.. ??? what should we do about + * variable length attributes - variable length attributes have their + * length stored in the first 4 bytes of the memory pointed to by the + * returned value.. If we can determine that the type is a variable + * length type, we can do the right thing. -cim 9/15/89 */ if (attnum < 0) { + /* - * If this is a pseudo-att, we get the type and fake the length. - * There ought to be a routine to return the real lengths, so - * we'll mark this one ... XXX -mao + * If this is a pseudo-att, we get the type and fake the length. + * There ought to be a routine to return the real lengths, so + * we'll mark this one ... XXX -mao */ len = heap_sysattrlen(attnum); /* XXX see -mao above */ byval = heap_sysattrbyval(attnum); /* XXX see -mao above */ @@ -609,11 +608,11 @@ ExecEvalFuncArgs(FunctionCachePtr fcache, i = 0; foreach(arg, argList) { + /* - * evaluate the expression, in general functions cannot take - * sets as arguments but we make an exception in the case of - * nested dot expressions. We have to watch out for this case - * here. + * evaluate the expression, in general functions cannot take sets + * as arguments but we make an exception in the case of nested dot + * expressions. We have to watch out for this case here. */ argV[i] = (Datum) ExecEvalExpr((Node *) lfirst(arg), @@ -671,10 +670,10 @@ ExecMakeFunctionResult(Node *node, } /* - * arguments is a list of expressions to evaluate - * before passing to the function manager. - * We collect the results of evaluating the expressions - * into a datum array (argV) and pass this array to arrayFmgr() + * arguments is a list of expressions to evaluate before passing to + * the function manager. We collect the results of evaluating the + * expressions into a datum array (argV) and pass this array to + * arrayFmgr() */ if (fcache->nargs != 0) { @@ -743,8 +742,8 @@ ExecMakeFunctionResult(Node *node, } /* - * now return the value gotten by calling the function manager, - * passing the function the evaluated parameter values. + * now return the value gotten by calling the function manager, + * passing the function the evaluated parameter values. */ if (fcache->language == SQLlanguageId) { @@ -843,12 +842,12 @@ ExecEvalOper(Expr *opClause, ExprContext *econtext, bool *isNull) bool isDone; /* - * an opclause is a list (op args). (I think) + * an opclause is a list (op args). (I think) * - * we extract the oid of the function associated with - * the op and then pass the work onto ExecMakeFunctionResult - * which evaluates the arguments and returns the result of - * calling the function on the evaluated arguments. + * we extract the oid of the function associated with the op and then + * pass the work onto ExecMakeFunctionResult which evaluates the + * arguments and returns the result of calling the function on the + * evaluated arguments. */ op = (Oper *) opClause->oper; argList = opClause->args; @@ -865,8 +864,8 @@ ExecEvalOper(Expr *opClause, ExprContext *econtext, bool *isNull) } /* - * call ExecMakeFunctionResult() with a dummy isDone that we ignore. - * We don't have operator whose arguments are sets. + * call ExecMakeFunctionResult() with a dummy isDone that we ignore. + * We don't have operator whose arguments are sets. */ return ExecMakeFunctionResult((Node *) op, argList, econtext, isNull, &isDone); } @@ -887,14 +886,14 @@ ExecEvalFunc(Expr *funcClause, FunctionCachePtr fcache; /* - * an funcclause is a list (func args). (I think) + * an funcclause is a list (func args). (I think) * - * we extract the oid of the function associated with - * the func node and then pass the work onto ExecMakeFunctionResult - * which evaluates the arguments and returns the result of - * calling the function on the evaluated arguments. + * we extract the oid of the function associated with the func node and + * then pass the work onto ExecMakeFunctionResult which evaluates the + * arguments and returns the result of calling the function on the + * evaluated arguments. * - * this is nearly identical to the ExecEvalOper code. + * this is nearly identical to the ExecEvalOper code. */ func = (Func *) funcClause->oper; argList = funcClause->args; @@ -939,21 +938,21 @@ ExecEvalNot(Expr *notclause, ExprContext *econtext, bool *isNull) clause = lfirst(notclause->args); /* - * We don't iterate over sets in the quals, so pass in an isDone - * flag, but ignore it. + * We don't iterate over sets in the quals, so pass in an isDone flag, + * but ignore it. */ expr_value = ExecEvalExpr(clause, econtext, isNull, &isDone); /* - * if the expression evaluates to null, then we just - * cascade the null back to whoever called us. + * if the expression evaluates to null, then we just cascade the null + * back to whoever called us. */ if (*isNull) return expr_value; /* - * evaluation of 'not' is simple.. expr is false, then - * return 'true' and vice versa. + * evaluation of 'not' is simple.. expr is false, then return 'true' + * and vice versa. */ if (DatumGetInt32(expr_value) == 0) return (Datum) true; @@ -978,22 +977,19 @@ ExecEvalOr(Expr *orExpr, ExprContext *econtext, bool *isNull) clauses = orExpr->args; /* - * we use three valued logic functions here... - * we evaluate each of the clauses in turn, - * as soon as one is true we return that - * value. If none is true and none of the - * clauses evaluate to NULL we return - * the value of the last clause evaluated (which - * should be false) with *isNull set to false else - * if none is true and at least one clause evaluated - * to NULL we set *isNull flag to true - + * we use three valued logic functions here... we evaluate each of the + * clauses in turn, as soon as one is true we return that value. If + * none is true and none of the clauses evaluate to NULL we return + * the value of the last clause evaluated (which should be false) with + * *isNull set to false else if none is true and at least one clause + * evaluated to NULL we set *isNull flag to true - */ foreach(clause, clauses) { /* - * We don't iterate over sets in the quals, so pass in an isDone - * flag, but ignore it. + * We don't iterate over sets in the quals, so pass in an isDone + * flag, but ignore it. */ const_value = ExecEvalExpr((Node *) lfirst(clause), econtext, @@ -1001,34 +997,32 @@ ExecEvalOr(Expr *orExpr, ExprContext *econtext, bool *isNull) &isDone); /* - * if the expression evaluates to null, then we - * remember it in the local IsNull flag, if none of the - * clauses are true then we need to set *isNull - * to true again. + * if the expression evaluates to null, then we remember it in the + * local IsNull flag, if none of the clauses are true then we need + * to set *isNull to true again. */ if (*isNull) { IsNull = *isNull; /* - * Many functions don't (or can't!) check if an argument is NULL - * or NOT_NULL and may return TRUE (1) with *isNull TRUE - * (an_int4_column <> 1: int4ne returns TRUE for NULLs). - * Not having time to fix the function manager I want to fix OR: - * if we had 'x <> 1 OR x isnull' then when x is NULL - * TRUE was returned by the 'x <> 1' clause ... - * but ExecQualClause says that the qualification should *fail* - * if isnull is TRUE for any value returned by ExecEvalExpr. - * So, force this rule here: - * if isnull is TRUE then the clause failed. - * Note: nullvalue() & nonnullvalue() always sets isnull to FALSE for NULLs. - * - vadim 09/22/97 + * Many functions don't (or can't!) check if an argument is + * NULL or NOT_NULL and may return TRUE (1) with *isNull TRUE + * (an_int4_column <> 1: int4ne returns TRUE for NULLs). Not + * having time to fix the function manager I want to fix OR: + * if we had 'x <> 1 OR x isnull' then when x is NULL TRUE was + * returned by the 'x <> 1' clause ... but ExecQualClause says + * that the qualification should *fail* if isnull is TRUE for + * any value returned by ExecEvalExpr. So, force this rule + * here: if isnull is TRUE then the clause failed. Note: + * nullvalue() & nonnullvalue() always sets isnull to FALSE + * for NULLs. - vadim 09/22/97 */ const_value = 0; } /* - * if we have a true result, then we return it. + * if we have a true result, then we return it. */ if (DatumGetInt32(const_value) != 0) return const_value; @@ -1057,18 +1051,16 @@ ExecEvalAnd(Expr *andExpr, ExprContext *econtext, bool *isNull) clauses = andExpr->args; /* - * we evaluate each of the clauses in turn, - * as soon as one is false we return that - * value. If none are false or NULL then we return - * the value of the last clause evaluated, which - * should be true. + * we evaluate each of the clauses in turn, as soon as one is false we + * return that value. If none are false or NULL then we return the + * value of the last clause evaluated, which should be true. */ foreach(clause, clauses) { /* - * We don't iterate over sets in the quals, so pass in an isDone - * flag, but ignore it. + * We don't iterate over sets in the quals, so pass in an isDone + * flag, but ignore it. */ const_value = ExecEvalExpr((Node *) lfirst(clause), econtext, @@ -1076,17 +1068,16 @@ ExecEvalAnd(Expr *andExpr, ExprContext *econtext, bool *isNull) &isDone); /* - * if the expression evaluates to null, then we - * remember it in IsNull, if none of the clauses after - * this evaluates to false we will have to set *isNull - * to true again. + * if the expression evaluates to null, then we remember it in + * IsNull, if none of the clauses after this evaluates to false we + * will have to set *isNull to true again. */ if (*isNull) IsNull = *isNull; /* - * if we have a false result, then we return it, since the - * conjunction must be false. + * if we have a false result, then we return it, since the + * conjunction must be false. */ if (DatumGetInt32(const_value) == 0) return const_value; @@ -1106,7 +1097,7 @@ ExecEvalAnd(Expr *andExpr, ExprContext *econtext, bool *isNull) * ---------------------------------------------------------------- */ static Datum -ExecEvalCase(CaseExpr *caseExpr, ExprContext *econtext, bool *isNull) +ExecEvalCase(CaseExpr * caseExpr, ExprContext *econtext, bool *isNull) { List *clauses; List *clause; @@ -1117,17 +1108,16 @@ ExecEvalCase(CaseExpr *caseExpr, ExprContext *econtext, bool *isNull) clauses = caseExpr->args; /* - * we evaluate each of the WHEN clauses in turn, - * as soon as one is true we return the corresponding - * result. If none are true then we return the value - * of the default clause, or NULL. + * we evaluate each of the WHEN clauses in turn, as soon as one is + * true we return the corresponding result. If none are true then we + * return the value of the default clause, or NULL. */ foreach(clause, clauses) { /* - * We don't iterate over sets in the quals, so pass in an isDone - * flag, but ignore it. + * We don't iterate over sets in the quals, so pass in an isDone + * flag, but ignore it. */ wclause = lfirst(clause); @@ -1137,8 +1127,8 @@ ExecEvalCase(CaseExpr *caseExpr, ExprContext *econtext, bool *isNull) &isDone); /* - * if we have a true test, then we return the result, - * since the case statement is satisfied. + * if we have a true test, then we return the result, since the + * case statement is satisfied. */ if (DatumGetInt32(const_value) != 0) { @@ -1159,9 +1149,7 @@ ExecEvalCase(CaseExpr *caseExpr, ExprContext *econtext, bool *isNull) &isDone); } else - { *isNull = true; - } return const_value; } @@ -1204,8 +1192,8 @@ ExecEvalExpr(Node *expression, *isDone = true; /* - * here we dispatch the work to the appropriate type - * of function given the type of our expression. + * here we dispatch the work to the appropriate type of function given + * the type of our expression. */ if (expression == NULL) { @@ -1287,7 +1275,7 @@ ExecEvalExpr(Node *expression, } return retDatum; -} /* ExecEvalExpr() */ +} /* ExecEvalExpr() */ /* ---------------------------------------------------------------- @@ -1325,16 +1313,15 @@ ExecQualClause(Node *clause, ExprContext *econtext) ExecEvalExpr(clause, econtext, &isNull, &isDone); /* - * this is interesting behaviour here. When a clause evaluates - * to null, then we consider this as passing the qualification. - * it seems kind of like, if the qual is NULL, then there's no - * qual.. + * this is interesting behaviour here. When a clause evaluates to + * null, then we consider this as passing the qualification. it seems + * kind of like, if the qual is NULL, then there's no qual.. */ if (isNull) return true; /* - * remember, we return true when the qualification fails.. + * remember, we return true when the qualification fails.. */ if (DatumGetInt32(expr_value) == 0) return true; @@ -1356,7 +1343,7 @@ ExecQual(List *qual, ExprContext *econtext) bool result; /* - * debugging stuff + * debugging stuff */ EV_printf("ExecQual: qual is "); EV_nodeDisplay(qual); @@ -1365,18 +1352,18 @@ ExecQual(List *qual, ExprContext *econtext) IncrProcessed(); /* - * return true immediately if no qual + * return true immediately if no qual */ if (qual == NIL) return true; /* - * a "qual" is a list of clauses. To evaluate the - * qual, we evaluate each of the clauses in the list. + * a "qual" is a list of clauses. To evaluate the qual, we evaluate + * each of the clauses in the list. * - * ExecQualClause returns true when we know the qualification - * *failed* so we just pass each clause in qual to it until - * we know the qual failed or there are no more clauses. + * ExecQualClause returns true when we know the qualification *failed* so + * we just pass each clause in qual to it until we know the qual + * failed or there are no more clauses. */ result = false; @@ -1388,9 +1375,9 @@ ExecQual(List *qual, ExprContext *econtext) } /* - * if result is true, then it means a clause failed so we - * return false. if result is false then it means no clause - * failed so we return true. + * if result is true, then it means a clause failed so we return + * false. if result is false then it means no clause failed so we + * return true. */ if (result == true) return false; @@ -1447,48 +1434,46 @@ ExecTargetList(List *targetlist, bool isNull; /* - * debugging stuff + * debugging stuff */ EV_printf("ExecTargetList: tl is "); EV_nodeDisplay(targetlist); EV_printf("\n"); /* - * Return a dummy tuple if the targetlist is empty. - * the dummy tuple is necessary to differentiate - * between passing and failing the qualification. + * Return a dummy tuple if the targetlist is empty. the dummy tuple is + * necessary to differentiate between passing and failing the + * qualification. */ if (targetlist == NIL) { + /* - * I now think that the only time this makes - * any sense is when we run a delete query. Then - * we need to return something other than nil - * so we know to delete the tuple associated - * with the saved tupleid.. see what ExecutePlan - * does with the returned tuple.. -cim 9/21/89 + * I now think that the only time this makes any sense is when we + * run a delete query. Then we need to return something other + * than nil so we know to delete the tuple associated with the + * saved tupleid.. see what ExecutePlan does with the returned + * tuple.. -cim 9/21/89 * - * It could also happen in queries like: - * retrieve (foo.all) where bar.a = 3 + * It could also happen in queries like: retrieve (foo.all) where + * bar.a = 3 * - * is this a new phenomenon? it might cause bogus behavior - * if we try to free this tuple later!! I put a hook in - * ExecProject to watch out for this case -mer 24 Aug 1992 + * is this a new phenomenon? it might cause bogus behavior if we try + * to free this tuple later!! I put a hook in ExecProject to watch + * out for this case -mer 24 Aug 1992 * - * We must return dummy tuple!!! Try - * select t1.x from t1, t2 where t1.y = 1 and t2.y = 1 - * - t2 scan target list will be empty and so no one tuple - * will be returned! But Mer was right - dummy tuple - * must be palloced... - vadim 03/01/1999 + * We must return dummy tuple!!! Try select t1.x from t1, t2 where + * t1.y = 1 and t2.y = 1 - t2 scan target list will be empty and + * so no one tuple will be returned! But Mer was right - dummy + * tuple must be palloced... - vadim 03/01/1999 */ *isDone = true; return (HeapTuple) palloc(1); } /* - * allocate an array of char's to hold the "null" information - * only if we have a really large targetlist. otherwise we use - * the stack. + * allocate an array of char's to hold the "null" information only if + * we have a really large targetlist. otherwise we use the stack. */ if (nodomains > 64) { @@ -1502,20 +1487,21 @@ ExecTargetList(List *targetlist, } /* - * evaluate all the expressions in the target list + * evaluate all the expressions in the target list */ EV_printf("ExecTargetList: setting target list values\n"); *isDone = true; foreach(tl, targetlist) { + /* - * remember, a target list is a list of lists: + * remember, a target list is a list of lists: * - * (( expr) ( expr) ...) + * (( expr) ( expr) ...) * - * tl is a pointer to successive cdr's of the targetlist - * tle is a pointer to the target list entry in tl + * tl is a pointer to successive cdr's of the targetlist tle is a + * pointer to the target list entry in tl */ tle = lfirst(tl); @@ -1572,7 +1558,7 @@ ExecTargetList(List *targetlist, curNode < nNodes; curNode++, fjTlist = lnext(fjTlist)) { -#ifdef NOT_USED /* what is this?? */ +#ifdef NOT_USED /* what is this?? */ Node *outernode = lfirst(fjTlist); fjRes = (Resdom *) outernode->iterexpr; @@ -1590,19 +1576,19 @@ ExecTargetList(List *targetlist, } /* - * form the new result tuple (in the "normal" context) + * form the new result tuple (in the "normal" context) */ newTuple = (HeapTuple) heap_formtuple(targettype, values, null_head); /* - * free the nulls array if we allocated one.. + * free the nulls array if we allocated one.. */ if (nodomains > 64) { pfree(null_head); pfree(fjIsNull); } - + return newTuple; } @@ -1631,13 +1617,13 @@ ExecProject(ProjectionInfo *projInfo, bool *isDone) HeapTuple newTuple; /* - * sanity checks + * sanity checks */ if (projInfo == NULL) return (TupleTableSlot *) NULL; /* - * get the projection info we want + * get the projection info we want */ slot = projInfo->pi_slot; targetlist = projInfo->pi_targetlist; @@ -1648,7 +1634,7 @@ ExecProject(ProjectionInfo *projInfo, bool *isDone) econtext = projInfo->pi_exprContext; /* - * form a new (result) tuple + * form a new (result) tuple */ newTuple = ExecTargetList(targetlist, len, @@ -1658,11 +1644,10 @@ ExecProject(ProjectionInfo *projInfo, bool *isDone) isDone); /* - * store the tuple in the projection slot and return the slot. + * store the tuple in the projection slot and return the slot. * - * If there's no projection target list we don't want to pfree - * the bogus tuple that ExecTargetList passes back to us. - * -mer 24 Aug 1992 + * If there's no projection target list we don't want to pfree the bogus + * tuple that ExecTargetList passes back to us. -mer 24 Aug 1992 */ return (TupleTableSlot *) ExecStoreTuple(newTuple,/* tuple to store */ @@ -1670,4 +1655,3 @@ ExecProject(ProjectionInfo *projInfo, bool *isDone) InvalidBuffer, /* tuple has no buffer */ true); } - diff --git a/src/backend/executor/execTuples.c b/src/backend/executor/execTuples.c index 148b6b11c1..1ffe928b57 100644 --- a/src/backend/executor/execTuples.c +++ b/src/backend/executor/execTuples.c @@ -14,7 +14,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/execTuples.c,v 1.24 1999/03/23 16:50:48 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execTuples.c,v 1.25 1999/05/25 16:08:39 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -467,6 +467,7 @@ ExecSetSlotPolicy(TupleTableSlot *slot, /* slot to change */ return old_shouldFree; } + #endif /* -------------------------------- @@ -650,6 +651,7 @@ ExecInitMarkedTupleSlot(EState *estate, MergeJoinState *mergestate) INIT_SLOT_ALLOC; mergestate->mj_MarkedTupleSlot = (TupleTableSlot *) slot; } + #endif /* ---------------- diff --git a/src/backend/executor/execUtils.c b/src/backend/executor/execUtils.c index b6906e0a3d..2bd3d03bc6 100644 --- a/src/backend/executor/execUtils.c +++ b/src/backend/executor/execUtils.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.44 1999/03/20 01:13:22 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.45 1999/05/25 16:08:39 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -402,7 +402,7 @@ ExecFreeExprContext(CommonState *commonstate) void ExecFreeTypeInfo(CommonState *commonstate) { - TupleDesc tupDesc; + TupleDesc tupDesc; tupDesc = commonstate->cs_ResultTupleSlot->ttc_tupleDescriptor; if (tupDesc == NULL) @@ -498,12 +498,12 @@ ExecAssignScanTypeFromOuterPlan(Plan *node, CommonScanState *csstate) * Routines dealing with the structure 'attribute' which conatains * the type information about attributes in a tuple: * - * ExecMakeTypeInfo(noType) + * ExecMakeTypeInfo(noType) * returns pointer to array of 'noType' structure 'attribute'. - * ExecSetTypeInfo(index, typeInfo, attNum, attLen) + * ExecSetTypeInfo(index, typeInfo, attNum, attLen) * sets the element indexed by 'index' in typeInfo with * the values: attNum, attLen. - * ExecFreeTypeInfo(typeInfo) + * ExecFreeTypeInfo(typeInfo) * frees the structure 'typeInfo'. * ---------------------------------------------------------------- */ @@ -677,7 +677,7 @@ ExecGetIndexKeyInfo(Form_pg_index indexTuple, */ numKeys = 0; for (i = 0; i < INDEX_MAX_KEYS && - indexTuple->indkey[i] != InvalidAttrNumber; i++) + indexTuple->indkey[i] != InvalidAttrNumber; i++) numKeys++; /* ---------------- @@ -711,7 +711,7 @@ ExecGetIndexKeyInfo(Form_pg_index indexTuple, */ CXT1_printf("ExecGetIndexKeyInfo: context is %d\n", CurrentMemoryContext); - attKeys = (AttrNumber *)palloc(numKeys * sizeof(AttrNumber)); + attKeys = (AttrNumber *) palloc(numKeys * sizeof(AttrNumber)); for (i = 0; i < numKeys; i++) attKeys[i] = indexTuple->indkey[i]; @@ -917,19 +917,20 @@ ExecOpenIndices(Oid resultRelationOid, if (indexDesc != NULL) { relationDescs[i++] = indexDesc; + /* - * Hack for not btree and hash indices: they use relation level - * exclusive locking on updation (i.e. - they are not ready - * for MVCC) and so we have to exclusively lock indices here - * to prevent deadlocks if we will scan them - index_beginscan - * places AccessShareLock, indices update methods don't use - * locks at all. We release this lock in ExecCloseIndices. - * Note, that hashes use page level locking - i.e. are not - * deadlock-free, - let's them be on their way -:)) - * vadim 03-12-1998 + * Hack for not btree and hash indices: they use relation + * level exclusive locking on updation (i.e. - they are + * not ready for MVCC) and so we have to exclusively lock + * indices here to prevent deadlocks if we will scan them + * - index_beginscan places AccessShareLock, indices + * update methods don't use locks at all. We release this + * lock in ExecCloseIndices. Note, that hashes use page + * level locking - i.e. are not deadlock-free, - let's + * them be on their way -:)) vadim 03-12-1998 */ - if (indexDesc->rd_rel->relam != BTREE_AM_OID && - indexDesc->rd_rel->relam != HASH_AM_OID) + if (indexDesc->rd_rel->relam != BTREE_AM_OID && + indexDesc->rd_rel->relam != HASH_AM_OID) LockRelation(indexDesc, AccessExclusiveLock); } } @@ -1014,15 +1015,17 @@ ExecCloseIndices(RelationInfo *resultRelationInfo) { if (relationDescs[i] == NULL) continue; + /* * Notes in ExecOpenIndices. */ - if (relationDescs[i]->rd_rel->relam != BTREE_AM_OID && - relationDescs[i]->rd_rel->relam != HASH_AM_OID) + if (relationDescs[i]->rd_rel->relam != BTREE_AM_OID && + relationDescs[i]->rd_rel->relam != HASH_AM_OID) UnlockRelation(relationDescs[i], AccessExclusiveLock); index_close(relationDescs[i]); } + /* * XXX should free indexInfo array here too. */ @@ -1210,7 +1213,7 @@ ExecInsertIndexTuples(TupleTableSlot *slot, result = index_insert(relationDescs[i], /* index relation */ datum, /* array of heaptuple Datums */ nulls, /* info on nulls */ - &(heapTuple->t_self), /* tid of heap tuple */ + &(heapTuple->t_self), /* tid of heap tuple */ heapRelation); /* ---------------- diff --git a/src/backend/executor/functions.c b/src/backend/executor/functions.c index f9b729b838..c32c14a596 100644 --- a/src/backend/executor/functions.c +++ b/src/backend/executor/functions.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/functions.c,v 1.25 1999/05/13 07:28:29 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/functions.c,v 1.26 1999/05/25 16:08:39 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -107,9 +107,9 @@ init_execution_state(FunctionCachePtr fcache, preves = (execution_state *) NULL; planTree_list = pg_parse_and_plan(fcache->src, fcache->argOidVect, - nargs, &queryTree_list, None, FALSE); + nargs, &queryTree_list, None, FALSE); - foreach (qtl_item, queryTree_list) + foreach(qtl_item, queryTree_list) { Query *queryTree = lfirst(qtl_item); Plan *planTree = lfirst(planTree_list); @@ -199,7 +199,7 @@ postquel_getnext(execution_state *es) feature = (LAST_POSTQUEL_COMMAND(es)) ? EXEC_RETONE : EXEC_RUN; - return ExecutorRun(es->qd, es->estate, feature, (Node *)NULL, (Node *)NULL); + return ExecutorRun(es->qd, es->estate, feature, (Node *) NULL, (Node *) NULL); } static void diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c index a3f4f12570..f1e0433c39 100644 --- a/src/backend/executor/nodeAgg.c +++ b/src/backend/executor/nodeAgg.c @@ -45,7 +45,7 @@ typedef struct AggFuncInfo FmgrInfo finalfn; } AggFuncInfo; -static Datum aggGetAttr(TupleTableSlot *tuple, Aggref *aggref, bool *isNull); +static Datum aggGetAttr(TupleTableSlot *tuple, Aggref * aggref, bool *isNull); /* --------------------------------------- @@ -121,7 +121,8 @@ ExecAgg(Agg *node) */ /* - * We loop retrieving groups until we find one matching node->plan.qual + * We loop retrieving groups until we find one matching + * node->plan.qual */ do { @@ -133,7 +134,7 @@ ExecAgg(Agg *node) econtext = aggstate->csstate.cstate.cs_ExprContext; nagg = length(node->aggs); - + value1 = node->aggstate->csstate.cstate.cs_ExprContext->ecxt_values; nulls = node->aggstate->csstate.cstate.cs_ExprContext->ecxt_nulls; @@ -163,7 +164,7 @@ ExecAgg(Agg *node) finalfn_oid; aggref->aggno = ++aggno; - + /* --------------------- * find transfer functions of all the aggregates and initialize * their initial values @@ -172,7 +173,7 @@ ExecAgg(Agg *node) aggname = aggref->aggname; aggTuple = SearchSysCacheTuple(AGGNAME, PointerGetDatum(aggname), - ObjectIdGetDatum(aggref->basetype), + ObjectIdGetDatum(aggref->basetype), 0, 0); if (!HeapTupleIsValid(aggTuple)) elog(ERROR, "ExecAgg: cache lookup failed for aggregate \"%s\"(%s)", @@ -195,9 +196,9 @@ ExecAgg(Agg *node) fmgr_info(xfn2_oid, &aggFuncInfo[aggno].xfn2); aggFuncInfo[aggno].xfn2_oid = xfn2_oid; value2[aggno] = (Datum) AggNameGetInitVal((char *) aggname, - aggp->aggbasetype, - 2, - &isNull2); + aggp->aggbasetype, + 2, + &isNull2); /* ------------------------------------------ * If there is a second transition function, its initial * value must exist -- as it does not depend on data values, @@ -213,9 +214,9 @@ ExecAgg(Agg *node) fmgr_info(xfn1_oid, &aggFuncInfo[aggno].xfn1); aggFuncInfo[aggno].xfn1_oid = xfn1_oid; value1[aggno] = (Datum) AggNameGetInitVal((char *) aggname, - aggp->aggbasetype, - 1, - &isNull1); + aggp->aggbasetype, + 1, + &isNull1); /* ------------------------------------------ * If the initial value for the first transition function @@ -245,6 +246,7 @@ ExecAgg(Agg *node) outerslot = ExecProcNode(outerPlan, (Plan *) node); if (TupIsNull(outerslot)) { + /* * when the outerplan doesn't return a single tuple, * create a dummy heaptuple anyway because we still need @@ -299,27 +301,29 @@ ExecAgg(Agg *node) { if (noInitValue[aggno]) { + /* - * value1 has not been initialized. - * This is the first non-NULL input value. - * We use it as the initial value for value1. + * value1 has not been initialized. This is the + * first non-NULL input value. We use it as the + * initial value for value1. * - * But we can't just use it straight, we have to - * make a copy of it since the tuple from which it - * came will be freed on the next iteration of the + * But we can't just use it straight, we have to make + * a copy of it since the tuple from which it came + * will be freed on the next iteration of the * scan. This requires finding out how to copy * the Datum. We assume the datum is of the agg's - * basetype, or at least binary compatible with it. + * basetype, or at least binary compatible with + * it. */ - Type aggBaseType = typeidType(aggref->basetype); - int attlen = typeLen(aggBaseType); - bool byVal = typeByVal(aggBaseType); + Type aggBaseType = typeidType(aggref->basetype); + int attlen = typeLen(aggBaseType); + bool byVal = typeByVal(aggBaseType); if (byVal) value1[aggno] = newVal; else { - if (attlen == -1) /* variable length */ + if (attlen == -1) /* variable length */ attlen = VARSIZE((struct varlena *) newVal); value1[aggno] = (Datum) palloc(attlen); memcpy((char *) (value1[aggno]), (char *) newVal, @@ -330,13 +334,14 @@ ExecAgg(Agg *node) } else { + /* * apply the transition functions. */ args[0] = value1[aggno]; args[1] = newVal; - value1[aggno] = (Datum) fmgr_c(&aggfns->xfn1, - (FmgrValues *) args, &isNull1); + value1[aggno] = (Datum) fmgr_c(&aggfns->xfn1, + (FmgrValues *) args, &isNull1); Assert(!isNull1); } } @@ -344,8 +349,8 @@ ExecAgg(Agg *node) if (aggfns->xfn2.fn_addr != NULL) { args[0] = value2[aggno]; - value2[aggno] = (Datum) fmgr_c(&aggfns->xfn2, - (FmgrValues *) args, &isNull2); + value2[aggno] = (Datum) fmgr_c(&aggfns->xfn2, + (FmgrValues *) args, &isNull2); Assert(!isNull2); } } @@ -395,7 +400,7 @@ ExecAgg(Agg *node) else elog(NOTICE, "ExecAgg: no valid transition functions??"); value1[aggno] = (Datum) fmgr_c(&aggfns->finalfn, - (FmgrValues *) args, &(nulls[aggno])); + (FmgrValues *) args, &(nulls[aggno])); } else if (aggfns->xfn1.fn_addr != NULL) { @@ -441,10 +446,11 @@ ExecAgg(Agg *node) * As long as the retrieved group does not match the * qualifications it is ignored and the next group is fetched */ - if(node->plan.qual != NULL) - qual_result = ExecQual(fix_opids(node->plan.qual), econtext); - else qual_result = false; - + if (node->plan.qual != NULL) + qual_result = ExecQual(fix_opids(node->plan.qual), econtext); + else + qual_result = false; + if (oneTuple) pfree(oneTuple); } @@ -466,7 +472,7 @@ ExecInitAgg(Agg *node, EState *estate, Plan *parent) AggState *aggstate; Plan *outerPlan; ExprContext *econtext; - + /* * assign the node's execution state */ @@ -478,7 +484,7 @@ ExecInitAgg(Agg *node, EState *estate, Plan *parent) aggstate = makeNode(AggState); node->aggstate = aggstate; aggstate->agg_done = FALSE; - + /* * assign node's base id and create expression context */ @@ -494,7 +500,7 @@ ExecInitAgg(Agg *node, EState *estate, Plan *parent) ExecInitResultTupleSlot(estate, &aggstate->csstate.cstate); econtext = aggstate->csstate.cstate.cs_ExprContext; - econtext->ecxt_values = (Datum *) palloc(sizeof(Datum) * length(node->aggs)); + econtext->ecxt_values = (Datum *) palloc(sizeof(Datum) * length(node->aggs)); MemSet(econtext->ecxt_values, 0, sizeof(Datum) * length(node->aggs)); econtext->ecxt_nulls = (char *) palloc(sizeof(char) * length(node->aggs)); MemSet(econtext->ecxt_nulls, 0, sizeof(char) * length(node->aggs)); @@ -538,8 +544,8 @@ int ExecCountSlotsAgg(Agg *node) { return ExecCountSlotsNode(outerPlan(node)) + - ExecCountSlotsNode(innerPlan(node)) + - AGG_NSLOTS; + ExecCountSlotsNode(innerPlan(node)) + + AGG_NSLOTS; } /* ------------------------ @@ -576,7 +582,7 @@ ExecEndAgg(Agg *node) */ static Datum aggGetAttr(TupleTableSlot *slot, - Aggref *aggref, + Aggref * aggref, bool *isNull) { Datum result; @@ -622,10 +628,11 @@ aggGetAttr(TupleTableSlot *slot, return (Datum) tempSlot; } - result = heap_getattr(heapTuple, /* tuple containing attribute */ - attnum, /* attribute number of desired attribute */ - tuple_type,/* tuple descriptor of tuple */ - isNull); /* return: is attribute null? */ + result = heap_getattr(heapTuple, /* tuple containing attribute */ + attnum, /* attribute number of desired + * attribute */ + tuple_type, /* tuple descriptor of tuple */ + isNull); /* return: is attribute null? */ /* ---------------- * return null if att is null diff --git a/src/backend/executor/nodeAppend.c b/src/backend/executor/nodeAppend.c index 8a096ef0f8..c46b467caa 100644 --- a/src/backend/executor/nodeAppend.c +++ b/src/backend/executor/nodeAppend.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeAppend.c,v 1.18 1999/02/21 03:48:40 scrappy Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeAppend.c,v 1.19 1999/05/25 16:08:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -151,7 +151,7 @@ exec_append_initialize_next(Append *node) if (appendstate->as_junkFilter_list) { estate->es_junkFilter = (JunkFilter *) nth(whichplan, - appendstate->as_junkFilter_list); + appendstate->as_junkFilter_list); } if (appendstate->as_result_relation_info_list) { diff --git a/src/backend/executor/nodeGroup.c b/src/backend/executor/nodeGroup.c index c850906d8a..55659a9025 100644 --- a/src/backend/executor/nodeGroup.c +++ b/src/backend/executor/nodeGroup.c @@ -13,7 +13,7 @@ * columns. (ie. tuples from the same group are consecutive) * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeGroup.c,v 1.25 1999/02/13 23:15:21 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeGroup.c,v 1.26 1999/05/25 16:08:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -193,8 +193,8 @@ ExecGroupOneTuple(Group *node) grpstate->grp_done = TRUE; return NULL; } - grpstate->grp_firstTuple = firsttuple = - heap_copytuple(outerslot->val); + grpstate->grp_firstTuple = firsttuple = + heap_copytuple(outerslot->val); } /* diff --git a/src/backend/executor/nodeHash.c b/src/backend/executor/nodeHash.c index 4589da32bc..3a76ef8c5d 100644 --- a/src/backend/executor/nodeHash.c +++ b/src/backend/executor/nodeHash.c @@ -6,7 +6,7 @@ * Copyright (c) 1994, Regents of the University of California * * - * $Id: nodeHash.c,v 1.35 1999/05/18 21:33:06 tgl Exp $ + * $Id: nodeHash.c,v 1.36 1999/05/25 16:08:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -19,7 +19,7 @@ */ #include -#include +#include #include #include @@ -80,7 +80,8 @@ ExecHash(Hash *node) */ for (i = 0; i < nbatch; i++) { - File tfile = OpenTemporaryFile(); + File tfile = OpenTemporaryFile(); + Assert(tfile >= 0); hashtable->innerBatchFile[i] = BufFileCreate(tfile); } @@ -247,30 +248,33 @@ ExecHashTableCreate(Hash *node) int i; Portal myPortal; char myPortalName[64]; - MemoryContext oldcxt; + MemoryContext oldcxt; /* ---------------- * Get information about the size of the relation to be hashed * (it's the "outer" subtree of this node, but the inner relation of * the hashjoin). - * Caution: this is only the planner's estimates, and so - * can't be trusted too far. Apply a healthy fudge factor. + * Caution: this is only the planner's estimates, and so + * can't be trusted too far. Apply a healthy fudge factor. * ---------------- */ outerNode = outerPlan(node); ntuples = outerNode->plan_size; if (ntuples <= 0) /* force a plausible size if no info */ ntuples = 1000; - /* estimate tupsize based on footprint of tuple in hashtable... - * but what about palloc overhead? + + /* + * estimate tupsize based on footprint of tuple in hashtable... but + * what about palloc overhead? */ tupsize = MAXALIGN(outerNode->plan_width) + MAXALIGN(sizeof(HashJoinTupleData)); - inner_rel_bytes = (double) ntuples * tupsize * FUDGE_FAC; + inner_rel_bytes = (double) ntuples *tupsize * FUDGE_FAC; /* * Target hashtable size is SortMem kilobytes, but not less than - * sqrt(estimated inner rel size), so as to avoid horrible performance. + * sqrt(estimated inner rel size), so as to avoid horrible + * performance. */ hash_table_bytes = sqrt(inner_rel_bytes); if (hash_table_bytes < (SortMem * 1024L)) @@ -278,17 +282,19 @@ ExecHashTableCreate(Hash *node) /* * Count the number of hash buckets we want for the whole relation, - * for an average bucket load of NTUP_PER_BUCKET (per virtual bucket!). + * for an average bucket load of NTUP_PER_BUCKET (per virtual + * bucket!). */ totalbuckets = (int) ceil((double) ntuples * FUDGE_FAC / NTUP_PER_BUCKET); /* * Count the number of buckets we think will actually fit in the - * target memory size, at a loading of NTUP_PER_BUCKET (physical buckets). - * NOTE: FUDGE_FAC here determines the fraction of the hashtable space - * reserved to allow for nonuniform distribution of hash values. - * Perhaps this should be a different number from the other uses of - * FUDGE_FAC, but since we have no real good way to pick either one... + * target memory size, at a loading of NTUP_PER_BUCKET (physical + * buckets). NOTE: FUDGE_FAC here determines the fraction of the + * hashtable space reserved to allow for nonuniform distribution of + * hash values. Perhaps this should be a different number from the + * other uses of FUDGE_FAC, but since we have no real good way to pick + * either one... */ bucketsize = NTUP_PER_BUCKET * tupsize; nbuckets = (int) (hash_table_bytes / (bucketsize * FUDGE_FAC)); @@ -297,21 +303,25 @@ ExecHashTableCreate(Hash *node) if (totalbuckets <= nbuckets) { - /* We have enough space, so no batching. In theory we could - * even reduce nbuckets, but since that could lead to poor - * behavior if estimated ntuples is much less than reality, - * it seems better to make more buckets instead of fewer. + + /* + * We have enough space, so no batching. In theory we could even + * reduce nbuckets, but since that could lead to poor behavior if + * estimated ntuples is much less than reality, it seems better to + * make more buckets instead of fewer. */ totalbuckets = nbuckets; nbatch = 0; } else { - /* Need to batch; compute how many batches we want to use. - * Note that nbatch doesn't have to have anything to do with - * the ratio totalbuckets/nbuckets; in fact, it is the number - * of groups we will use for the part of the data that doesn't - * fall into the first nbuckets hash buckets. + + /* + * Need to batch; compute how many batches we want to use. Note + * that nbatch doesn't have to have anything to do with the ratio + * totalbuckets/nbuckets; in fact, it is the number of groups we + * will use for the part of the data that doesn't fall into the + * first nbuckets hash buckets. */ nbatch = (int) ceil((inner_rel_bytes - hash_table_bytes) / hash_table_bytes); @@ -319,16 +329,17 @@ ExecHashTableCreate(Hash *node) nbatch = 1; } - /* Now, totalbuckets is the number of (virtual) hashbuckets for the + /* + * Now, totalbuckets is the number of (virtual) hashbuckets for the * whole relation, and nbuckets is the number of physical hashbuckets - * we will use in the first pass. Data falling into the first nbuckets - * virtual hashbuckets gets handled in the first pass; everything else - * gets divided into nbatch batches to be processed in additional - * passes. + * we will use in the first pass. Data falling into the first + * nbuckets virtual hashbuckets gets handled in the first pass; + * everything else gets divided into nbatch batches to be processed in + * additional passes. */ #ifdef HJDEBUG - printf("nbatch = %d, totalbuckets = %d, nbuckets = %d\n", - nbatch, totalbuckets, nbuckets); + printf("nbatch = %d, totalbuckets = %d, nbuckets = %d\n", + nbatch, totalbuckets, nbuckets); #endif /* ---------------- @@ -353,14 +364,16 @@ ExecHashTableCreate(Hash *node) * ---------------- */ i = 0; - do { + do + { i++; sprintf(myPortalName, "", i); myPortal = GetPortalByName(myPortalName); } while (PortalIsValid(myPortal)); myPortal = CreatePortal(myPortalName); Assert(PortalIsValid(myPortal)); - hashtable->myPortal = (void*) myPortal; /* kluge for circular includes */ + hashtable->myPortal = (void *) myPortal; /* kluge for circular + * includes */ hashtable->hashCxt = (MemoryContext) PortalGetVariableMemory(myPortal); hashtable->batchCxt = (MemoryContext) PortalGetHeapMemory(myPortal); @@ -392,8 +405,9 @@ ExecHashTableCreate(Hash *node) /* The files will not be opened until later... */ } - /* Prepare portal for the first-scan space allocations; - * allocate the hashbucket array therein, and set each bucket "empty". + /* + * Prepare portal for the first-scan space allocations; allocate the + * hashbucket array therein, and set each bucket "empty". */ MemoryContextSwitchTo(hashtable->batchCxt); StartPortalAllocMode(DefaultAllocMode, 0); @@ -405,9 +419,7 @@ ExecHashTableCreate(Hash *node) elog(ERROR, "Insufficient memory for hash table."); for (i = 0; i < nbuckets; i++) - { hashtable->buckets[i] = NULL; - } MemoryContextSwitchTo(oldcxt); @@ -436,7 +448,7 @@ ExecHashTableDestroy(HashJoinTable hashtable) /* Destroy the portal to release all working memory */ /* cast here is a kluge for circular includes... */ - PortalDestroy((Portal*) & hashtable->myPortal); + PortalDestroy((Portal *) &hashtable->myPortal); /* And drop the control block */ pfree(hashtable); @@ -468,15 +480,15 @@ ExecHashTableInsert(HashJoinTable hashtable, * put the tuple in hash table * --------------- */ - HashJoinTuple hashTuple; - int hashTupleSize; + HashJoinTuple hashTuple; + int hashTupleSize; hashTupleSize = MAXALIGN(sizeof(*hashTuple)) + heapTuple->t_len; hashTuple = (HashJoinTuple) MemoryContextAlloc(hashtable->batchCxt, hashTupleSize); if (hashTuple == NULL) elog(ERROR, "Insufficient memory for hash table."); - memcpy((char *) & hashTuple->htup, + memcpy((char *) &hashTuple->htup, (char *) heapTuple, sizeof(hashTuple->htup)); hashTuple->htup.t_data = (HeapTupleHeader) @@ -493,8 +505,9 @@ ExecHashTableInsert(HashJoinTable hashtable, * put the tuple into a tmp file for other batches * ----------------- */ - int batchno = (hashtable->nbatch * (bucketno - hashtable->nbuckets)) / - (hashtable->totalbuckets - hashtable->nbuckets); + int batchno = (hashtable->nbatch * (bucketno - hashtable->nbuckets)) / + (hashtable->totalbuckets - hashtable->nbuckets); + hashtable->innerBatchSize[batchno]++; ExecHashJoinSaveTuple(heapTuple, hashtable->innerBatchFile[batchno]); @@ -563,26 +576,23 @@ ExecScanHashBucket(HashJoinState *hjstate, List *hjclauses, ExprContext *econtext) { - HashJoinTable hashtable = hjstate->hj_HashTable; - HashJoinTuple hashTuple = hjstate->hj_CurTuple; + HashJoinTable hashtable = hjstate->hj_HashTable; + HashJoinTuple hashTuple = hjstate->hj_CurTuple; - /* hj_CurTuple is NULL to start scanning a new bucket, or the address + /* + * hj_CurTuple is NULL to start scanning a new bucket, or the address * of the last tuple returned from the current bucket. */ if (hashTuple == NULL) - { hashTuple = hashtable->buckets[hjstate->hj_CurBucketNo]; - } else - { hashTuple = hashTuple->next; - } while (hashTuple != NULL) { - HeapTuple heapTuple = & hashTuple->htup; + HeapTuple heapTuple = &hashTuple->htup; TupleTableSlot *inntuple; - bool qualResult; + bool qualResult; /* insert hashtable's tuple into exec slot so ExecQual sees it */ inntuple = ExecStoreTuple(heapTuple, /* tuple to store */ @@ -618,28 +628,34 @@ ExecScanHashBucket(HashJoinState *hjstate, static int hashFunc(Datum key, int len, bool byVal) { - unsigned int h = 0; - unsigned char *k; + unsigned int h = 0; + unsigned char *k; + + if (byVal) + { - if (byVal) { /* - * If it's a by-value data type, use the 'len' least significant bytes - * of the Datum value. This should do the right thing on either - * bigendian or littleendian hardware --- see the Datum access - * macros in c.h. + * If it's a by-value data type, use the 'len' least significant + * bytes of the Datum value. This should do the right thing on + * either bigendian or littleendian hardware --- see the Datum + * access macros in c.h. */ - while (len-- > 0) { + while (len-- > 0) + { h = (h * PRIME1) ^ (key & 0xFF); key >>= 8; } - } else { + } + else + { + /* * If this is a variable length type, then 'k' points to a "struct * varlena" and len == -1. NOTE: VARSIZE returns the "real" data * length plus the sizeof the "vl_len" attribute of varlena (the * length information). 'k' points to the beginning of the varlena - * struct, so we have to use "VARDATA" to find the beginning of the - * "real" data. + * struct, so we have to use "VARDATA" to find the beginning of + * the "real" data. */ if (len == -1) { @@ -647,9 +663,7 @@ hashFunc(Datum key, int len, bool byVal) k = (unsigned char *) VARDATA(key); } else - { k = (unsigned char *) key; - } while (len-- > 0) h = (h * PRIME1) ^ (*k++); } @@ -669,7 +683,7 @@ hashFunc(Datum key, int len, bool byVal) void ExecHashTableReset(HashJoinTable hashtable, long ntuples) { - MemoryContext oldcxt; + MemoryContext oldcxt; int nbuckets = hashtable->nbuckets; int i; @@ -682,13 +696,14 @@ ExecHashTableReset(HashJoinTable hashtable, long ntuples) StartPortalAllocMode(DefaultAllocMode, 0); /* - * We still use the same number of physical buckets as in the first pass. - * (It could be different; but we already decided how many buckets would - * be appropriate for the allowed memory, so stick with that number.) - * We MUST set totalbuckets to equal nbuckets, because from now on - * no tuples will go out to temp files; there are no more virtual buckets, - * only real buckets. (This implies that tuples will go into different - * bucket numbers than they did on the first pass, but that's OK.) + * We still use the same number of physical buckets as in the first + * pass. (It could be different; but we already decided how many + * buckets would be appropriate for the allowed memory, so stick with + * that number.) We MUST set totalbuckets to equal nbuckets, because + * from now on no tuples will go out to temp files; there are no more + * virtual buckets, only real buckets. (This implies that tuples will + * go into different bucket numbers than they did on the first pass, + * but that's OK.) */ hashtable->totalbuckets = nbuckets; @@ -700,9 +715,7 @@ ExecHashTableReset(HashJoinTable hashtable, long ntuples) elog(ERROR, "Insufficient memory for hash table."); for (i = 0; i < nbuckets; i++) - { hashtable->buckets[i] = NULL; - } MemoryContextSwitchTo(oldcxt); } @@ -710,6 +723,7 @@ ExecHashTableReset(HashJoinTable hashtable, long ntuples) void ExecReScanHash(Hash *node, ExprContext *exprCtxt, Plan *parent) { + /* * if chgParam of subnode is not null then plan will be re-scanned by * first ExecProcNode. diff --git a/src/backend/executor/nodeHashjoin.c b/src/backend/executor/nodeHashjoin.c index b3808fab36..49f8429402 100644 --- a/src/backend/executor/nodeHashjoin.c +++ b/src/backend/executor/nodeHashjoin.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.20 1999/05/18 21:33:06 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.21 1999/05/25 16:08:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -23,10 +23,10 @@ #include "optimizer/clauses.h" /* for get_leftop */ static TupleTableSlot *ExecHashJoinOuterGetTuple(Plan *node, Plan *parent, - HashJoinState *hjstate); + HashJoinState *hjstate); static TupleTableSlot *ExecHashJoinGetSavedTuple(HashJoinState *hjstate, - BufFile *file, - TupleTableSlot *tupleSlot); + BufFile * file, + TupleTableSlot *tupleSlot); static int ExecHashJoinGetBatch(int bucketno, HashJoinTable hashtable); static int ExecHashJoinNewBatch(HashJoinState *hjstate); @@ -132,7 +132,8 @@ ExecHashJoin(HashJoin *node) */ for (i = 0; i < hashtable->nbatch; i++) { - File tfile = OpenTemporaryFile(); + File tfile = OpenTemporaryFile(); + Assert(tfile >= 0); hashtable->outerBatchFile[i] = BufFileCreate(tfile); } @@ -149,6 +150,7 @@ ExecHashJoin(HashJoin *node) for (;;) { + /* * if the current outer tuple is nil, get a new one */ @@ -159,6 +161,7 @@ ExecHashJoin(HashJoin *node) hjstate); if (TupIsNull(outerTupleSlot)) { + /* * when the last batch runs out, clean up and exit */ @@ -168,8 +171,8 @@ ExecHashJoin(HashJoin *node) } /* - * now we have an outer tuple, find the corresponding bucket for - * this tuple from the hash table + * now we have an outer tuple, find the corresponding bucket + * for this tuple from the hash table */ econtext->ecxt_outertuple = outerTupleSlot; hjstate->hj_CurBucketNo = ExecHashGetBucket(hashtable, econtext, @@ -184,20 +187,23 @@ ExecHashJoin(HashJoin *node) */ if (hashtable->curbatch == 0) { - int batch = ExecHashJoinGetBatch(hjstate->hj_CurBucketNo, - hashtable); + int batch = ExecHashJoinGetBatch(hjstate->hj_CurBucketNo, + hashtable); + if (batch > 0) { + /* * Need to postpone this outer tuple to a later batch. * Save it in the corresponding outer-batch file. */ - int batchno = batch - 1; + int batchno = batch - 1; + hashtable->outerBatchSize[batchno]++; ExecHashJoinSaveTuple(outerTupleSlot->val, - hashtable->outerBatchFile[batchno]); + hashtable->outerBatchFile[batchno]); ExecClearTuple(outerTupleSlot); - continue; /* loop around for a new outer tuple */ + continue; /* loop around for a new outer tuple */ } } } @@ -212,6 +218,7 @@ ExecHashJoin(HashJoin *node) econtext); if (curtuple == NULL) break; /* out of matches */ + /* * we've got a match, but still need to test qpqual */ @@ -427,32 +434,33 @@ ExecEndHashJoin(HashJoin *node) static TupleTableSlot * ExecHashJoinOuterGetTuple(Plan *node, Plan *parent, HashJoinState *hjstate) { - HashJoinTable hashtable = hjstate->hj_HashTable; - int curbatch = hashtable->curbatch; + HashJoinTable hashtable = hjstate->hj_HashTable; + int curbatch = hashtable->curbatch; TupleTableSlot *slot; if (curbatch == 0) { /* if it is the first pass */ slot = ExecProcNode(node, parent); - if (! TupIsNull(slot)) + if (!TupIsNull(slot)) return slot; + /* - * We have just reached the end of the first pass. - * Try to switch to a saved batch. + * We have just reached the end of the first pass. Try to switch + * to a saved batch. */ curbatch = ExecHashJoinNewBatch(hjstate); } /* - * Try to read from a temp file. - * Loop allows us to advance to new batch as needed. + * Try to read from a temp file. Loop allows us to advance to new + * batch as needed. */ while (curbatch <= hashtable->nbatch) { slot = ExecHashJoinGetSavedTuple(hjstate, - hashtable->outerBatchFile[curbatch-1], + hashtable->outerBatchFile[curbatch - 1], hjstate->hj_OuterTupleSlot); - if (! TupIsNull(slot)) + if (!TupIsNull(slot)) return slot; curbatch = ExecHashJoinNewBatch(hjstate); } @@ -470,12 +478,12 @@ ExecHashJoinOuterGetTuple(Plan *node, Plan *parent, HashJoinState *hjstate) static TupleTableSlot * ExecHashJoinGetSavedTuple(HashJoinState *hjstate, - BufFile *file, + BufFile * file, TupleTableSlot *tupleSlot) { - HeapTupleData htup; - size_t nread; - HeapTuple heapTuple; + HeapTupleData htup; + size_t nread; + HeapTuple heapTuple; nread = BufFileRead(file, (void *) &htup, sizeof(HeapTupleData)); if (nread == 0) @@ -484,8 +492,8 @@ ExecHashJoinGetSavedTuple(HashJoinState *hjstate, elog(ERROR, "Read from hashjoin temp file failed"); heapTuple = palloc(HEAPTUPLESIZE + htup.t_len); memcpy((char *) heapTuple, (char *) &htup, sizeof(HeapTupleData)); - heapTuple->t_data = (HeapTupleHeader) - ((char *) heapTuple + HEAPTUPLESIZE); + heapTuple->t_data = (HeapTupleHeader) + ((char *) heapTuple + HEAPTUPLESIZE); nread = BufFileRead(file, (void *) heapTuple->t_data, htup.t_len); if (nread != (size_t) htup.t_len) elog(ERROR, "Read from hashjoin temp file failed"); @@ -506,16 +514,17 @@ ExecHashJoinNewBatch(HashJoinState *hjstate) int newbatch = hashtable->curbatch + 1; long *innerBatchSize = hashtable->innerBatchSize; long *outerBatchSize = hashtable->outerBatchSize; - BufFile *innerFile; + BufFile *innerFile; TupleTableSlot *slot; ExprContext *econtext; Var *innerhashkey; if (newbatch > 1) { + /* - * We no longer need the previous outer batch file; - * close it right away to free disk space. + * We no longer need the previous outer batch file; close it right + * away to free disk space. */ BufFileClose(hashtable->outerBatchFile[newbatch - 2]); hashtable->outerBatchFile[newbatch - 2] = NULL; @@ -541,8 +550,8 @@ ExecHashJoinNewBatch(HashJoinState *hjstate) return newbatch; /* no more batches */ /* - * Rewind inner and outer batch files for this batch, - * so that we can start reading them. + * Rewind inner and outer batch files for this batch, so that we can + * start reading them. */ if (BufFileSeek(hashtable->outerBatchFile[newbatch - 1], 0L, SEEK_SET) != 0L) @@ -571,7 +580,8 @@ ExecHashJoinNewBatch(HashJoinState *hjstate) } /* - * after we build the hash table, the inner batch file is no longer needed + * after we build the hash table, the inner batch file is no longer + * needed */ BufFileClose(innerFile); hashtable->innerBatchFile[newbatch - 1] = NULL; @@ -615,9 +625,9 @@ ExecHashJoinGetBatch(int bucketno, HashJoinTable hashtable) void ExecHashJoinSaveTuple(HeapTuple heapTuple, - BufFile *file) + BufFile * file) { - size_t written; + size_t written; written = BufFileWrite(file, (void *) heapTuple, sizeof(HeapTupleData)); if (written != sizeof(HeapTupleData)) diff --git a/src/backend/executor/nodeIndexscan.c b/src/backend/executor/nodeIndexscan.c index a55d9cc6e1..461bc1b8a5 100644 --- a/src/backend/executor/nodeIndexscan.c +++ b/src/backend/executor/nodeIndexscan.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.35 1999/05/10 00:45:06 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.36 1999/05/25 16:08:43 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -91,13 +91,14 @@ IndexNext(IndexScan *node) IndexScanDesc scandesc; Relation heapRelation; RetrieveIndexResult result; - HeapTuple tuple; + HeapTuple tuple; TupleTableSlot *slot; Buffer buffer = InvalidBuffer; int numIndices; - bool bBackward; - int indexNumber; + bool bBackward; + int indexNumber; + /* ---------------- * extract necessary information from index scan node * ---------------- @@ -114,14 +115,14 @@ IndexNext(IndexScan *node) /* * Check if we are evaluating PlanQual for tuple of this relation. - * Additional checking is not good, but no other way for now. - * We could introduce new nodes for this case and handle - * IndexScan --> NewNode switching in Init/ReScan plan... + * Additional checking is not good, but no other way for now. We could + * introduce new nodes for this case and handle IndexScan --> NewNode + * switching in Init/ReScan plan... */ - if (estate->es_evTuple != NULL && + if (estate->es_evTuple != NULL && estate->es_evTuple[node->scan.scanrelid - 1] != NULL) { - int iptr; + int iptr; slot->ttc_buffer = InvalidBuffer; slot->ttc_shouldFree = false; @@ -138,7 +139,7 @@ IndexNext(IndexScan *node) scanstate->cstate.cs_ExprContext)) break; } - if (iptr == numIndices) /* would not be returned by indices */ + if (iptr == numIndices) /* would not be returned by indices */ slot->val = NULL; /* Flag for the next call that no more tuples */ estate->es_evTupleNull[node->scan.scanrelid - 1] = true; @@ -153,26 +154,26 @@ IndexNext(IndexScan *node) * appropriate heap tuple.. else return NULL. * ---------------- */ - bBackward = ScanDirectionIsBackward(direction); - if (bBackward) - { - indexNumber = numIndices - indexstate->iss_IndexPtr - 1; - if (indexNumber < 0) - { - indexNumber = 0; - indexstate->iss_IndexPtr = numIndices - 1; - } - } - else - { - if ((indexNumber = indexstate->iss_IndexPtr) < 0) - { - indexNumber = 0; - indexstate->iss_IndexPtr = 0; - } - } - while (indexNumber < numIndices) - { + bBackward = ScanDirectionIsBackward(direction); + if (bBackward) + { + indexNumber = numIndices - indexstate->iss_IndexPtr - 1; + if (indexNumber < 0) + { + indexNumber = 0; + indexstate->iss_IndexPtr = numIndices - 1; + } + } + else + { + if ((indexNumber = indexstate->iss_IndexPtr) < 0) + { + indexNumber = 0; + indexstate->iss_IndexPtr = 0; + } + } + while (indexNumber < numIndices) + { scandesc = scanDescs[indexstate->iss_IndexPtr]; while ((result = index_getnext(scandesc, direction)) != NULL) { @@ -224,14 +225,14 @@ IndexNext(IndexScan *node) if (BufferIsValid(buffer)) ReleaseBuffer(buffer); } - if (indexNumber < numIndices) - { - indexNumber++; - if (bBackward) - indexstate->iss_IndexPtr--; - else - indexstate->iss_IndexPtr++; - } + if (indexNumber < numIndices) + { + indexNumber++; + if (bBackward) + indexstate->iss_IndexPtr--; + else + indexstate->iss_IndexPtr++; + } } /* ---------------- * if we get here it means the index scan failed so we @@ -323,7 +324,7 @@ ExecIndexReScan(IndexScan *node, ExprContext *exprCtxt, Plan *parent) indexstate->iss_IndexPtr = -1; /* If this is re-scanning of PlanQual ... */ - if (estate->es_evTuple != NULL && + if (estate->es_evTuple != NULL && estate->es_evTuple[node->scan.scanrelid - 1] != NULL) { estate->es_evTupleNull[node->scan.scanrelid - 1] = false; @@ -703,7 +704,7 @@ ExecInitIndexScan(IndexScan *node, EState *estate, Plan *parent) run_keys = (n_keys <= 0) ? NULL : (int *) palloc(n_keys * sizeof(int)); - CXT1_printf("ExecInitIndexScan: context is %d\n",CurrentMemoryContext); + CXT1_printf("ExecInitIndexScan: context is %d\n", CurrentMemoryContext); /* ---------------- * for each opclause in the given qual, diff --git a/src/backend/executor/nodeMaterial.c b/src/backend/executor/nodeMaterial.c index 326475102d..b8cd808dc0 100644 --- a/src/backend/executor/nodeMaterial.c +++ b/src/backend/executor/nodeMaterial.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeMaterial.c,v 1.21 1999/02/13 23:15:24 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeMaterial.c,v 1.22 1999/05/25 16:08:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -116,7 +116,7 @@ ExecMaterial(Material *node) if (TupIsNull(slot)) break; - + /* * heap_insert changes something... */ @@ -124,12 +124,12 @@ ExecMaterial(Material *node) heapTuple = heap_copytuple(slot->val); else heapTuple = slot->val; - + heap_insert(tempRelation, heapTuple); if (slot->ttc_buffer != InvalidBuffer) pfree(heapTuple); - + ExecClearTuple(slot); } currentRelation = tempRelation; @@ -360,8 +360,8 @@ ExecMaterialReScan(Material *node, ExprContext *exprCtxt, Plan *parent) return; matstate->csstate.css_currentScanDesc = ExecReScanR(matstate->csstate.css_currentRelation, - matstate->csstate.css_currentScanDesc, - node->plan.state->es_direction, 0, NULL); + matstate->csstate.css_currentScanDesc, + node->plan.state->es_direction, 0, NULL); } diff --git a/src/backend/executor/nodeMergejoin.c b/src/backend/executor/nodeMergejoin.c index 9b0df28825..4d0c3dae92 100644 --- a/src/backend/executor/nodeMergejoin.c +++ b/src/backend/executor/nodeMergejoin.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeMergejoin.c,v 1.26 1999/05/10 00:45:07 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeMergejoin.c,v 1.27 1999/05/25 16:08:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -103,7 +103,7 @@ static bool MergeCompare(List *eqQual, List *compareQual, ExprContext *econtext) * ---------------------------------------------------------------- */ static List * -MJFormSkipQual(List *qualList, char * replaceopname) +MJFormSkipQual(List *qualList, char *replaceopname) { List *qualCopy; List *qualcdr; @@ -148,14 +148,14 @@ MJFormSkipQual(List *qualList, char * replaceopname) * ---------------- */ optup = get_operator_tuple(op->opno); - if (!HeapTupleIsValid(optup)) /* shouldn't happen */ + if (!HeapTupleIsValid(optup)) /* shouldn't happen */ elog(ERROR, "MJFormSkipQual: operator %u not found", op->opno); opform = (Form_pg_operator) GETSTRUCT(optup); oprleft = opform->oprleft; oprright = opform->oprright; /* ---------------- - * Now look up the matching "<" or ">" operator. If there isn't one, + * Now look up the matching "<" or ">" operator. If there isn't one, * whoever marked the "=" operator mergejoinable was a loser. * ---------------- */ @@ -166,7 +166,7 @@ MJFormSkipQual(List *qualList, char * replaceopname) CharGetDatum('b')); if (!HeapTupleIsValid(optup)) elog(ERROR, - "MJFormSkipQual: mergejoin operator %u has no matching %s op", + "MJFormSkipQual: mergejoin operator %u has no matching %s op", op->opno, replaceopname); opform = (Form_pg_operator) GETSTRUCT(optup); diff --git a/src/backend/executor/nodeResult.c b/src/backend/executor/nodeResult.c index 8b0d9e7ec9..7c8166c6f2 100644 --- a/src/backend/executor/nodeResult.c +++ b/src/backend/executor/nodeResult.c @@ -27,7 +27,7 @@ * SeqScan (emp.all) * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeResult.c,v 1.10 1999/03/20 01:13:22 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeResult.c,v 1.11 1999/05/25 16:08:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -263,8 +263,8 @@ ExecEndResult(Result *node) * is freed at end-transaction time. -cim 6/2/91 * ---------------- */ - ExecFreeExprContext(&resstate->cstate); /* XXX - new for us - er1p */ - ExecFreeTypeInfo(&resstate->cstate); /* XXX - new for us - er1p */ + ExecFreeExprContext(&resstate->cstate); /* XXX - new for us - er1p */ + ExecFreeTypeInfo(&resstate->cstate); /* XXX - new for us - er1p */ ExecFreeProjectionInfo(&resstate->cstate); /* ---------------- @@ -278,7 +278,8 @@ ExecEndResult(Result *node) * ---------------- */ ExecClearTuple(resstate->cstate.cs_ResultTupleSlot); - pfree(resstate); node->resstate = NULL; /* XXX - new for us - er1p */ + pfree(resstate); + node->resstate = NULL; /* XXX - new for us - er1p */ } void diff --git a/src/backend/executor/nodeSeqscan.c b/src/backend/executor/nodeSeqscan.c index 70a6761a83..04a1493413 100644 --- a/src/backend/executor/nodeSeqscan.c +++ b/src/backend/executor/nodeSeqscan.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeSeqscan.c,v 1.17 1999/02/13 23:15:26 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeSeqscan.c,v 1.18 1999/05/25 16:08:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -68,11 +68,11 @@ SeqNext(SeqScan *node) /* * Check if we are evaluating PlanQual for tuple of this relation. - * Additional checking is not good, but no other way for now. - * We could introduce new nodes for this case and handle - * SeqScan --> NewNode switching in Init/ReScan plan... + * Additional checking is not good, but no other way for now. We could + * introduce new nodes for this case and handle SeqScan --> NewNode + * switching in Init/ReScan plan... */ - if (estate->es_evTuple != NULL && + if (estate->es_evTuple != NULL && estate->es_evTuple[node->scanrelid - 1] != NULL) { slot->ttc_buffer = InvalidBuffer; @@ -83,10 +83,11 @@ SeqNext(SeqScan *node) return (slot); } slot->val = estate->es_evTuple[node->scanrelid - 1]; + /* - * Note that unlike IndexScan, SeqScan never use keys - * in heap_beginscan (and this is very bad) - so, here - * we have not check are keys ok or not. + * Note that unlike IndexScan, SeqScan never use keys in + * heap_beginscan (and this is very bad) - so, here we have not + * check are keys ok or not. */ /* Flag for the next call that no more tuples */ estate->es_evTupleNull[node->scanrelid - 1] = true; @@ -401,10 +402,11 @@ ExecSeqReScan(SeqScan *node, ExprContext *exprCtxt, Plan *parent) outerPlan = outerPlan((Plan *) node); ExecReScan(outerPlan, exprCtxt, parent); } - else /* otherwise, we are scanning a relation */ + else +/* otherwise, we are scanning a relation */ { /* If this is re-scanning of PlanQual ... */ - if (estate->es_evTuple != NULL && + if (estate->es_evTuple != NULL && estate->es_evTuple[node->scanrelid - 1] != NULL) { estate->es_evTupleNull[node->scanrelid - 1] = false; diff --git a/src/backend/executor/nodeSubplan.c b/src/backend/executor/nodeSubplan.c index 2eebbf1f1e..ef65a7afb5 100644 --- a/src/backend/executor/nodeSubplan.c +++ b/src/backend/executor/nodeSubplan.c @@ -58,15 +58,16 @@ ExecSubPlan(SubPlan *node, List *pvar, ExprContext *econtext) ExecReScan(plan, (ExprContext *) NULL, plan); /* - * For all sublink types except EXPR_SUBLINK, the result type is boolean, - * and we have a fairly clear idea of how to combine multiple subitems - * and deal with NULL values or an empty subplan result. + * For all sublink types except EXPR_SUBLINK, the result type is + * boolean, and we have a fairly clear idea of how to combine multiple + * subitems and deal with NULL values or an empty subplan result. * * For EXPR_SUBLINK, the result type is whatever the combining operator * returns. We have no way to deal with more than one column in the - * subplan result --- hopefully the parser forbids that. More seriously, - * it's unclear what to do with NULL values or an empty subplan result. - * For now, we error out, but should something else happen? + * subplan result --- hopefully the parser forbids that. More + * seriously, it's unclear what to do with NULL values or an empty + * subplan result. For now, we error out, but should something else + * happen? */ for (slot = ExecProcNode(plan, plan); @@ -105,14 +106,14 @@ ExecSubPlan(SubPlan *node, List *pvar, ExprContext *econtext) } if (subLinkType != EXPR_SUBLINK) { - if ((! (bool) result && !(sublink->useor)) || + if ((!(bool) result && !(sublink->useor)) || ((bool) result && sublink->useor)) break; } i++; } - if (subLinkType == ALL_SUBLINK && ! (bool) result) + if (subLinkType == ALL_SUBLINK && !(bool) result) break; if (subLinkType == ANY_SUBLINK && (bool) result) break; @@ -120,7 +121,7 @@ ExecSubPlan(SubPlan *node, List *pvar, ExprContext *econtext) if (!found) { - /* deal with empty subplan result. Note default result is 'false' */ + /* deal with empty subplan result. Note default result is 'false' */ if (subLinkType == ALL_SUBLINK) result = (Datum) true; else if (subLinkType == EXPR_SUBLINK) diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c index f6e5b8c585..f807412018 100644 --- a/src/backend/executor/spi.c +++ b/src/backend/executor/spi.c @@ -3,7 +3,7 @@ * spi.c * Server Programming Interface * - * $Id: spi.c,v 1.37 1999/05/13 07:28:30 tgl Exp $ + * $Id: spi.c,v 1.38 1999/05/25 16:08:48 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -19,9 +19,9 @@ static _SPI_connection *_SPI_current = NULL; static int _SPI_connected = -1; static int _SPI_curid = -1; -DLLIMPORT uint32 SPI_processed = 0; +DLLIMPORT uint32 SPI_processed = 0; DLLIMPORT SPITupleTable *SPI_tuptable; -DLLIMPORT int SPI_result; +DLLIMPORT int SPI_result; static int _SPI_execute(char *src, int tcount, _SPI_plan *plan); static int _SPI_pquery(QueryDesc *queryDesc, EState *state, int tcount); @@ -49,8 +49,8 @@ extern void ShowUsage(void); int SPI_connect() { - char pname[64]; - PortalVariableMemory pvmem; + char pname[64]; + PortalVariableMemory pvmem; /* * It's possible on startup and after commit/abort. In future we'll @@ -345,8 +345,8 @@ SPI_modifytuple(Relation rel, HeapTuple tuple, int natts, int *attnum, mtuple = heap_formtuple(rel->rd_att, v, n); infomask = mtuple->t_data->t_infomask; memmove(&(mtuple->t_data->t_oid), &(tuple->t_data->t_oid), - ((char *) &(tuple->t_data->t_hoff) - - (char *) &(tuple->t_data->t_oid))); + ((char *) &(tuple->t_data->t_hoff) - + (char *) &(tuple->t_data->t_oid))); mtuple->t_data->t_infomask = infomask; mtuple->t_data->t_natts = numberOfAttributes; } @@ -411,8 +411,8 @@ SPI_getvalue(HeapTuple tuple, TupleDesc tupdesc, int fnumber) val = heap_getattr(tuple, fnumber, tupdesc, &isnull); if (isnull) return NULL; - if (! getTypeOutAndElem((Oid) tupdesc->attrs[fnumber - 1]->atttypid, - &foutoid, &typelem)) + if (!getTypeOutAndElem((Oid) tupdesc->attrs[fnumber - 1]->atttypid, + &foutoid, &typelem)) { SPI_result = SPI_ERROR_NOOUTFUNC; return NULL; @@ -549,13 +549,13 @@ SPI_pfree(void *pointer) /* =================== private functions =================== */ /* - * spi_printtup + * spi_printtup * store tuple retrieved by Executor into SPITupleTable * of current SPI procedure * */ void -spi_printtup(HeapTuple tuple, TupleDesc tupdesc, DestReceiver* self) +spi_printtup(HeapTuple tuple, TupleDesc tupdesc, DestReceiver * self) { SPITupleTable *tuptable; MemoryContext oldcxt; @@ -633,12 +633,13 @@ _SPI_execute(char *src, int tcount, _SPI_plan *plan) _SPI_current->qtlist = queryTree_list; - foreach (queryTree_list_item, queryTree_list) + foreach(queryTree_list_item, queryTree_list) { queryTree = (Query *) lfirst(queryTree_list_item); planTree = lfirst(planTree_list); planTree_list = lnext(planTree_list); - islastquery = (planTree_list == NIL); /* assume lists are same len */ + islastquery = (planTree_list == NIL); /* assume lists are same + * len */ if (queryTree->commandType == CMD_UTILITY) { @@ -658,7 +659,7 @@ _SPI_execute(char *src, int tcount, _SPI_plan *plan) if (plan == NULL) { ProcessUtility(queryTree->utilityStmt, None); - if (! islastquery) + if (!islastquery) CommandCounterIncrement(); else return res; @@ -717,17 +718,18 @@ _SPI_execute_plan(_SPI_plan *plan, Datum *Values, char *Nulls, int tcount) _SPI_current->tuptable = NULL; _SPI_current->qtlist = NULL; - foreach (queryTree_list_item, queryTree_list) + foreach(queryTree_list_item, queryTree_list) { queryTree = (Query *) lfirst(queryTree_list_item); planTree = lfirst(planTree_list); planTree_list = lnext(planTree_list); - islastquery = (planTree_list == NIL); /* assume lists are same len */ + islastquery = (planTree_list == NIL); /* assume lists are same + * len */ if (queryTree->commandType == CMD_UTILITY) { ProcessUtility(queryTree->utilityStmt, None); - if (! islastquery) + if (!islastquery) CommandCounterIncrement(); else return SPI_OK_UTILITY; @@ -777,7 +779,7 @@ _SPI_pquery(QueryDesc *queryDesc, EState *state, int tcount) char *intoName = NULL; int res; Const tcount_const; - Node *count = NULL; + Node *count = NULL; switch (operation) { @@ -833,18 +835,18 @@ _SPI_pquery(QueryDesc *queryDesc, EState *state, int tcount) * ---------------- */ memset(&tcount_const, 0, sizeof(tcount_const)); - tcount_const.type = T_Const; - tcount_const.consttype = INT4OID; - tcount_const.constlen = sizeof(int4); - tcount_const.constvalue = (Datum)tcount; - tcount_const.constisnull = FALSE; - tcount_const.constbyval = TRUE; - tcount_const.constisset = FALSE; - tcount_const.constiscast = FALSE; - - count = (Node *)&tcount_const; + tcount_const.type = T_Const; + tcount_const.consttype = INT4OID; + tcount_const.constlen = sizeof(int4); + tcount_const.constvalue = (Datum) tcount; + tcount_const.constisnull = FALSE; + tcount_const.constbyval = TRUE; + tcount_const.constisset = FALSE; + tcount_const.constiscast = FALSE; + + count = (Node *) &tcount_const; } - + if (state == NULL) /* plan preparation */ return res; #ifdef SPI_EXECUTOR_STATS @@ -922,7 +924,7 @@ _SPI_procmem() } /* - * _SPI_begin_call + * _SPI_begin_call * */ static int diff --git a/src/backend/lib/fstack.c b/src/backend/lib/fstack.c index 7b05dbd8fd..1f2beafa92 100644 --- a/src/backend/lib/fstack.c +++ b/src/backend/lib/fstack.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/lib/Attic/fstack.c,v 1.10 1999/02/13 23:15:34 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/lib/Attic/fstack.c,v 1.11 1999/05/25 16:08:52 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -20,20 +20,20 @@ */ /* - * FixedItemIsValid + * FixedItemIsValid * True iff item is valid. */ #define FixedItemIsValid(item) PointerIsValid(item) /* - * FixedStackGetItemBase + * FixedStackGetItemBase * Returns base of enclosing structure. */ #define FixedStackGetItemBase(stack, item) \ ((Pointer)((char *)(item) - (stack)->offset)) /* - * FixedStackGetItem + * FixedStackGetItem * Returns item of given pointer to enclosing structure. */ #define FixedStackGetItem(stack, pointer) \ @@ -84,7 +84,7 @@ FixedStackPush(FixedStack stack, Pointer pointer) #ifdef USE_ASSERT_CHECKING /* - * FixedStackContains + * FixedStackContains * True iff ordered stack contains given element. * * Note: diff --git a/src/backend/lib/stringinfo.c b/src/backend/lib/stringinfo.c index 3ded779974..12d0f8625c 100644 --- a/src/backend/lib/stringinfo.c +++ b/src/backend/lib/stringinfo.c @@ -8,7 +8,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: stringinfo.c,v 1.15 1999/04/25 03:19:25 tgl Exp $ + * $Id: stringinfo.c,v 1.16 1999/05/25 16:08:53 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -67,17 +67,18 @@ initStringInfo(StringInfo str) static void enlargeStringInfo(StringInfo str, int needed) { - int newlen; - char *newdata; + int newlen; + char *newdata; needed += str->len + 1; /* total space required now */ if (needed <= str->maxlen) return; /* got enough space already */ /* - * We don't want to allocate just a little more space with each append; - * for efficiency, double the buffer size each time it overflows. - * Actually, we might need to more than double it if 'needed' is big... + * We don't want to allocate just a little more space with each + * append; for efficiency, double the buffer size each time it + * overflows. Actually, we might need to more than double it if + * 'needed' is big... */ newlen = 2 * str->maxlen; while (needed > newlen) @@ -86,7 +87,7 @@ enlargeStringInfo(StringInfo str, int needed) newdata = palloc(newlen); if (newdata == NULL) elog(ERROR, - "enlargeStringInfo: Out of memory (%d bytes requested)", newlen); + "enlargeStringInfo: Out of memory (%d bytes requested)", newlen); /* OK, transfer data into new buffer, and release old buffer */ memcpy(newdata, str->data, str->len + 1); @@ -107,11 +108,11 @@ enlargeStringInfo(StringInfo str, int needed) * generated in a single call (not on the total string length). */ void -appendStringInfo(StringInfo str, const char *fmt, ...) +appendStringInfo(StringInfo str, const char *fmt,...) { - va_list args; - char buffer[1024]; - int buflen; + va_list args; + char buffer[1024]; + int buflen; Assert(str != NULL); @@ -164,7 +165,8 @@ appendBinaryStringInfo(StringInfo str, const char *data, int datalen) memcpy(str->data + str->len, data, datalen); str->len += datalen; - /* Keep a trailing null in place, even though it's probably useless + /* + * Keep a trailing null in place, even though it's probably useless * for binary data... */ str->data[str->len] = '\0'; diff --git a/src/backend/libpq/auth.c b/src/backend/libpq/auth.c index 6941934369..c5bfc69748 100644 --- a/src/backend/libpq/auth.c +++ b/src/backend/libpq/auth.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.35 1999/04/16 04:59:03 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.36 1999/05/25 16:08:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -75,13 +75,13 @@ static int map_old_to_new(Port *port, UserAuth old, int status); static int pg_krb4_recvauth(Port *port) { - long krbopts = 0; /* one-way authentication */ - KTEXT_ST clttkt; - char instance[INST_SZ+1], - version[KRB_SENDAUTH_VLEN+1]; - AUTH_DAT auth_data; - Key_schedule key_sched; - int status; + long krbopts = 0; /* one-way authentication */ + KTEXT_ST clttkt; + char instance[INST_SZ + 1], + version[KRB_SENDAUTH_VLEN + 1]; + AUTH_DAT auth_data; + Key_schedule key_sched; + int status; strcpy(instance, "*"); /* don't care, but arg gets expanded * anyway */ @@ -99,7 +99,7 @@ pg_krb4_recvauth(Port *port) if (status != KSUCCESS) { snprintf(PQerrormsg, ERROR_MSG_LENGTH, - "pg_krb4_recvauth: kerberos error: %s\n", krb_err_txt[status]); + "pg_krb4_recvauth: kerberos error: %s\n", krb_err_txt[status]); fputs(PQerrormsg, stderr); pqdebug("%s", PQerrormsg); return STATUS_ERROR; @@ -107,7 +107,7 @@ pg_krb4_recvauth(Port *port) if (strncmp(version, PG_KRB4_VERSION, KRB_SENDAUTH_VLEN)) { snprintf(PQerrormsg, ERROR_MSG_LENGTH, - "pg_krb4_recvauth: protocol version != \"%s\"\n", PG_KRB4_VERSION); + "pg_krb4_recvauth: protocol version != \"%s\"\n", PG_KRB4_VERSION); fputs(PQerrormsg, stderr); pqdebug("%s", PQerrormsg); return STATUS_ERROR; @@ -115,8 +115,8 @@ pg_krb4_recvauth(Port *port) if (strncmp(port->user, auth_data.pname, SM_USER)) { snprintf(PQerrormsg, ERROR_MSG_LENGTH, - "pg_krb4_recvauth: name \"%s\" != \"%s\"\n", - port->user, auth_data.pname); + "pg_krb4_recvauth: name \"%s\" != \"%s\"\n", + port->user, auth_data.pname); fputs(PQerrormsg, stderr); pqdebug("%s", PQerrormsg); return STATUS_ERROR; @@ -129,7 +129,7 @@ static int pg_krb4_recvauth(Port *port) { snprintf(PQerrormsg, ERROR_MSG_LENGTH, - "pg_krb4_recvauth: Kerberos not implemented on this server.\n"); + "pg_krb4_recvauth: Kerberos not implemented on this server.\n"); fputs(PQerrormsg, stderr); pqdebug("%s", PQerrormsg); @@ -223,7 +223,7 @@ pg_krb5_recvauth(Port *port) if (code = krb5_parse_name(servbuf, &server)) { snprintf(PQerrormsg, ERROR_MSG_LENGTH, - "pg_krb5_recvauth: Kerberos error %d in krb5_parse_name\n", code); + "pg_krb5_recvauth: Kerberos error %d in krb5_parse_name\n", code); com_err("pg_krb5_recvauth", code, "in krb5_parse_name"); return STATUS_ERROR; } @@ -256,7 +256,7 @@ pg_krb5_recvauth(Port *port) (krb5_authenticator **) NULL)) { snprintf(PQerrormsg, ERROR_MSG_LENGTH, - "pg_krb5_recvauth: Kerberos error %d in krb5_recvauth\n", code); + "pg_krb5_recvauth: Kerberos error %d in krb5_recvauth\n", code); com_err("pg_krb5_recvauth", code, "in krb5_recvauth"); krb5_free_principal(server); return STATUS_ERROR; @@ -271,7 +271,7 @@ pg_krb5_recvauth(Port *port) if ((code = krb5_unparse_name(client, &kusername))) { snprintf(PQerrormsg, ERROR_MSG_LENGTH, - "pg_krb5_recvauth: Kerberos error %d in krb5_unparse_name\n", code); + "pg_krb5_recvauth: Kerberos error %d in krb5_unparse_name\n", code); com_err("pg_krb5_recvauth", code, "in krb5_unparse_name"); krb5_free_principal(client); return STATUS_ERROR; @@ -280,7 +280,7 @@ pg_krb5_recvauth(Port *port) if (!kusername) { snprintf(PQerrormsg, ERROR_MSG_LENGTH, - "pg_krb5_recvauth: could not decode username\n"); + "pg_krb5_recvauth: could not decode username\n"); fputs(PQerrormsg, stderr); pqdebug("%s", PQerrormsg); return STATUS_ERROR; @@ -289,7 +289,7 @@ pg_krb5_recvauth(Port *port) if (strncmp(username, kusername, SM_USER)) { snprintf(PQerrormsg, ERROR_MSG_LENGTH, - "pg_krb5_recvauth: name \"%s\" != \"%s\"\n", port->user, kusername); + "pg_krb5_recvauth: name \"%s\" != \"%s\"\n", port->user, kusername); fputs(PQerrormsg, stderr); pqdebug("%s", PQerrormsg); pfree(kusername); @@ -304,7 +304,7 @@ static int pg_krb5_recvauth(Port *port) { snprintf(PQerrormsg, ERROR_MSG_LENGTH, - "pg_krb5_recvauth: Kerberos not implemented on this server.\n"); + "pg_krb5_recvauth: Kerberos not implemented on this server.\n"); fputs(PQerrormsg, stderr); pqdebug("%s", PQerrormsg); @@ -359,7 +359,7 @@ pg_passwordv0_recvauth(void *arg, PacketLen len, void *pkt) if (user == NULL || password == NULL) { snprintf(PQerrormsg, ERROR_MSG_LENGTH, - "pg_password_recvauth: badly formed password packet.\n"); + "pg_password_recvauth: badly formed password packet.\n"); fputs(PQerrormsg, stderr); pqdebug("%s", PQerrormsg); @@ -405,7 +405,7 @@ pg_passwordv0_recvauth(void *arg, PacketLen len, void *pkt) void auth_failed(Port *port) { - char buffer[512]; + char buffer[512]; const char *authmethod = "Unknown auth method:"; switch (port->auth_method) @@ -449,9 +449,9 @@ be_recvauth(Port *port) /* * Get the authentication method to use for this frontend/database - * combination. Note: a failure return indicates a problem with - * the hba config file, not with the request. hba.c should have - * dropped an error message into the postmaster logfile if it failed. + * combination. Note: a failure return indicates a problem with the + * hba config file, not with the request. hba.c should have dropped + * an error message into the postmaster logfile if it failed. */ if (hba_getauthmethod(&port->raddr, port->user, port->database, @@ -470,27 +470,28 @@ be_recvauth(Port *port) { /* Handle new style authentication. */ - AuthRequest areq = AUTH_REQ_OK; - PacketDoneProc auth_handler = NULL; + AuthRequest areq = AUTH_REQ_OK; + PacketDoneProc auth_handler = NULL; switch (port->auth_method) { case uaReject: + /* - * This could have come from an explicit "reject" entry - * in pg_hba.conf, but more likely it means there was no - * matching entry. Take pity on the poor user and issue - * a helpful error message. NOTE: this is not a security - * breach, because all the info reported here is known - * at the frontend and must be assumed known to bad guys. + * This could have come from an explicit "reject" entry in + * pg_hba.conf, but more likely it means there was no + * matching entry. Take pity on the poor user and issue a + * helpful error message. NOTE: this is not a security + * breach, because all the info reported here is known at + * the frontend and must be assumed known to bad guys. * We're merely helping out the less clueful good guys. * NOTE 2: libpq-be.h defines the maximum error message * length as 99 characters. It probably wouldn't hurt - * anything to increase it, but there might be some - * client out there that will fail. So, be terse. + * anything to increase it, but there might be some client + * out there that will fail. So, be terse. */ { - char buffer[512]; + char buffer[512]; const char *hostinfo = "localhost"; if (port->raddr.sa.sa_family == AF_INET) diff --git a/src/backend/libpq/be-dumpdata.c b/src/backend/libpq/be-dumpdata.c index 8c9dcae52d..ed70ab734a 100644 --- a/src/backend/libpq/be-dumpdata.c +++ b/src/backend/libpq/be-dumpdata.c @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: be-dumpdata.c,v 1.23 1999/05/10 00:45:08 momjian Exp $ + * $Id: be-dumpdata.c,v 1.24 1999/05/25 16:08:57 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -130,8 +130,8 @@ static u_int be_portalcnt = 0; PortalEntry * be_newportal(void) { - PortalEntry *entry; - char buf[PortalNameLength]; + PortalEntry *entry; + char buf[PortalNameLength]; /* ---------------- * generate a new name @@ -208,7 +208,7 @@ be_typeinit(PortalEntry *entry, * ---------------- */ void -be_printtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver* self) +be_printtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver * self) { int i; Datum attr; diff --git a/src/backend/libpq/be-fsstubs.c b/src/backend/libpq/be-fsstubs.c index 8a063cf1ea..bef974d8a5 100644 --- a/src/backend/libpq/be-fsstubs.c +++ b/src/backend/libpq/be-fsstubs.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/libpq/be-fsstubs.c,v 1.32 1999/05/10 00:45:09 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/libpq/be-fsstubs.c,v 1.33 1999/05/25 16:08:57 momjian Exp $ * * NOTES * This should be moved to a more appropriate place. It is here @@ -131,8 +131,8 @@ lo_close(int fd) int lo_read(int fd, char *buf, int len) { - MemoryContext currentContext; - int status; + MemoryContext currentContext; + int status; if (fd < 0 || fd >= MAX_LOBJ_FDS) { @@ -144,19 +144,19 @@ lo_read(int fd, char *buf, int len) elog(ERROR, "lo_read: invalid large obj descriptor (%d)", fd); return -3; } - currentContext = MemoryContextSwitchTo((MemoryContext) fscxt); + currentContext = MemoryContextSwitchTo((MemoryContext) fscxt); status = inv_read(cookies[fd], buf, len); MemoryContextSwitchTo(currentContext); - return(status); + return (status); } int lo_write(int fd, char *buf, int len) { - MemoryContext currentContext; - int status; + MemoryContext currentContext; + int status; if (fd < 0 || fd >= MAX_LOBJ_FDS) { @@ -168,12 +168,12 @@ lo_write(int fd, char *buf, int len) elog(ERROR, "lo_write: invalid large obj descriptor (%d)", fd); return -3; } - currentContext = MemoryContextSwitchTo((MemoryContext) fscxt); + currentContext = MemoryContextSwitchTo((MemoryContext) fscxt); status = inv_write(cookies[fd], buf, len); MemoryContextSwitchTo(currentContext); - return(status); + return (status); } @@ -374,9 +374,7 @@ lo_export(Oid lobjId, text *filename) */ lobj = inv_open(lobjId, INV_READ); if (lobj == NULL) - { elog(ERROR, "lo_export: can't open inv object %u", lobjId); - } /* * open the file to be written to diff --git a/src/backend/libpq/crypt.c b/src/backend/libpq/crypt.c index ac8b373387..afd289d1f5 100644 --- a/src/backend/libpq/crypt.c +++ b/src/backend/libpq/crypt.c @@ -1,7 +1,7 @@ /*------------------------------------------------------------------------- * * crypt.c - * Look into pg_shadow and check the encrypted password with + * Look into pg_shadow and check the encrypted password with * the one passed in from the frontend. * * Modification History @@ -9,7 +9,7 @@ * Dec 17, 1997 - Todd A. Brandys * Orignal Version Completed. * - * $Id: crypt.c,v 1.16 1999/05/09 00:54:30 tgl Exp $ + * $Id: crypt.c,v 1.17 1999/05/25 16:08:58 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -38,8 +38,8 @@ char * crypt_getpwdfilename() { - static char *pfnam = NULL; - int bufsize; + static char *pfnam = NULL; + int bufsize; bufsize = strlen(DataDir) + strlen(CRYPT_PWD_FILE) + 2; pfnam = (char *) palloc(bufsize); @@ -54,9 +54,9 @@ char * crypt_getpwdreloadfilename() { - static char *rpfnam = NULL; - char *pwdfilename; - int bufsize; + static char *rpfnam = NULL; + char *pwdfilename; + int bufsize; pwdfilename = crypt_getpwdfilename(); bufsize = strlen(pwdfilename) + strlen(CRYPT_PWD_RELOAD_SUFX) + 1; @@ -147,9 +147,7 @@ crypt_loadpwdfile() { /* free the old data only if this is a * reload */ while (pwd_cache_count--) - { pfree((void *) pwd_cache[pwd_cache_count]); - } pfree((void *) pwd_cache); pwd_cache = NULL; pwd_cache_count = 0; @@ -226,9 +224,9 @@ int crypt_getloginfo(const char *user, char **passwd, char **valuntil) { - char *pwd, - *valdate; - void *fakeout; + char *pwd, + *valdate; + void *fakeout; *passwd = NULL; *valuntil = NULL; @@ -236,8 +234,8 @@ crypt_getloginfo(const char *user, char **passwd, char **valuntil) if (pwd_cache) { - char **pwd_entry; - char user_search[NAMEDATALEN + 2]; + char **pwd_entry; + char user_search[NAMEDATALEN + 2]; snprintf(user_search, NAMEDATALEN + 2, "%s\t", user); fakeout = (void *) &user_search; @@ -261,28 +259,22 @@ int crypt_verify(Port *port, const char *user, const char *pgpass) { - char *passwd, - *valuntil, - *crypt_pwd; - int retval = STATUS_ERROR; - AbsoluteTime vuntil, - current; + char *passwd, + *valuntil, + *crypt_pwd; + int retval = STATUS_ERROR; + AbsoluteTime vuntil, + current; if (crypt_getloginfo(user, &passwd, &valuntil) == STATUS_ERROR) - { return STATUS_ERROR; - } if (passwd == NULL || *passwd == '\0') { if (passwd) - { pfree((void *) passwd); - } if (valuntil) - { pfree((void *) valuntil); - } return STATUS_ERROR; } @@ -291,38 +283,29 @@ crypt_verify(Port *port, const char *user, const char *pgpass) * authentication method being used for this connection. */ - crypt_pwd = - (port->auth_method == uaCrypt ? crypt(passwd, port->salt) : passwd); + crypt_pwd = + (port->auth_method == uaCrypt ? crypt(passwd, port->salt) : passwd); if (!strcmp(pgpass, crypt_pwd)) { + /* * check here to be sure we are not past valuntil */ if (!valuntil || strcmp(valuntil, "\\N") == 0) - { vuntil = INVALID_ABSTIME; - } else - { vuntil = nabstimein(valuntil); - } current = GetCurrentAbsoluteTime(); if (vuntil != INVALID_ABSTIME && vuntil < current) - { retval = STATUS_ERROR; - } else - { retval = STATUS_OK; - } } pfree((void *) passwd); if (valuntil) - { pfree((void *) valuntil); - } return retval; } diff --git a/src/backend/libpq/hba.c b/src/backend/libpq/hba.c index 85bbcb890e..dd64971c99 100644 --- a/src/backend/libpq/hba.c +++ b/src/backend/libpq/hba.c @@ -5,7 +5,7 @@ * wherein you authenticate a user by seeing what IP address the system * says he comes from and possibly using ident). * - * $Id: hba.c,v 1.42 1999/05/10 15:17:16 momjian Exp $ + * $Id: hba.c,v 1.43 1999/05/25 16:08:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -286,7 +286,7 @@ process_hba_record(FILE *file, SockAddr *raddr, const char *user, syntax: snprintf(PQerrormsg, ERROR_MSG_LENGTH, - "process_hba_record: invalid syntax in pg_hba.conf file\n"); + "process_hba_record: invalid syntax in pg_hba.conf file\n"); fputs(PQerrormsg, stderr); pqdebug("%s", PQerrormsg); @@ -305,14 +305,15 @@ process_open_config_file(FILE *file, SockAddr *raddr, const char *user, This function does the same thing as find_hba_entry, only with the config file already open on stream descriptor "file". ----------------------------------------------------------------------------*/ - bool found_entry = false; /* found an applicable entry? */ - bool error = false; /* found an erroneous entry? */ - bool eof = false; /* end of hba file */ + bool found_entry = false; /* found an applicable entry? */ + bool error = false; /* found an erroneous entry? */ + bool eof = false; /* end of hba file */ while (!eof && !found_entry && !error) { /* Process a line from the config file */ - int c = getc(file); + int c = getc(file); + if (c == EOF) eof = true; else @@ -347,7 +348,7 @@ find_hba_entry(SockAddr *raddr, const char *user, const char *database, * Read the config file and find an entry that allows connection from * host "raddr", user "user", to database "database". If found, * return *hba_ok_p = true and *userauth_p and *auth_arg representing - * the contents of that entry. If there is no matching entry, we + * the contents of that entry. If there is no matching entry, we * set *hba_ok_p = true, *userauth_p = uaReject. * * If the config file is unreadable or contains invalid syntax, we @@ -355,15 +356,15 @@ find_hba_entry(SockAddr *raddr, const char *user, const char *database, * and return without changing *hba_ok_p. * * If we find a file by the old name of the config file (pg_hba), we issue - * an error message because it probably needs to be converted. He didn't + * an error message because it probably needs to be converted. He didn't * follow directions and just installed his old hba file in the new database * system. */ - int fd, + int fd, bufsize; - FILE *file; /* The config file we have to read */ - char *old_conf_file; + FILE *file; /* The config file we have to read */ + char *old_conf_file; /* The name of old config file that better not exist. */ @@ -387,14 +388,15 @@ find_hba_entry(SockAddr *raddr, const char *user, const char *database, "A file exists by the name used for host-based authentication " "in prior releases of Postgres (%s). The name and format of " "the configuration file have changed, so this file should be " - "converted.\n", - old_conf_file); + "converted.\n", + old_conf_file); fputs(PQerrormsg, stderr); pqdebug("%s", PQerrormsg); } else { - char *conf_file; /* The name of the config file we have to read */ + char *conf_file; /* The name of the config file we have to + * read */ /* put together the full pathname to the config file */ bufsize = (strlen(DataDir) + strlen(CONF_FILE) + 2) * sizeof(char); @@ -407,17 +409,17 @@ find_hba_entry(SockAddr *raddr, const char *user, const char *database, /* The open of the config file failed. */ snprintf(PQerrormsg, ERROR_MSG_LENGTH, - "find_hba_entry: Host-based authentication config file " - "does not exist or permissions are not setup correctly! " - "Unable to open file \"%s\".\n", - conf_file); + "find_hba_entry: Host-based authentication config file " + "does not exist or permissions are not setup correctly! " + "Unable to open file \"%s\".\n", + conf_file); fputs(PQerrormsg, stderr); pqdebug("%s", PQerrormsg); } else { - process_open_config_file(file, raddr, user, database, hba_ok_p, - userauth_p, auth_arg); + process_open_config_file(file, raddr, user, database, hba_ok_p, + userauth_p, auth_arg); FreeFile(file); } pfree(conf_file); @@ -531,16 +533,18 @@ ident(const struct in_addr remote_ip_addr, const struct in_addr local_ip_addr, ----------------------------------------------------------------------------*/ - int sock_fd, /* File descriptor for socket on which we talk to Ident */ - rc; /* Return code from a locally called function */ + int sock_fd, /* File descriptor for socket on which we + * talk to Ident */ + rc; /* Return code from a locally called + * function */ sock_fd = socket(AF_INET, SOCK_STREAM, IPPROTO_IP); if (sock_fd == -1) { - snprintf(PQerrormsg, ERROR_MSG_LENGTH, - "Failed to create socket on which to talk to Ident server. " - "socket() returned errno = %s (%d)\n", - strerror(errno), errno); + snprintf(PQerrormsg, ERROR_MSG_LENGTH, + "Failed to create socket on which to talk to Ident server. " + "socket() returned errno = %s (%d)\n", + strerror(errno), errno); fputs(PQerrormsg, stderr); pqdebug("%s", PQerrormsg); } @@ -559,66 +563,66 @@ ident(const struct in_addr remote_ip_addr, const struct in_addr local_ip_addr, /* * Bind to the address which the client originally contacted, - * otherwise the ident server won't be able to match up the - * right connection. This is necessary if the PostgreSQL - * server is running on an IP alias. + * otherwise the ident server won't be able to match up the right + * connection. This is necessary if the PostgreSQL server is + * running on an IP alias. */ memset(&la, 0, sizeof(la)); la.sin_family = AF_INET; la.sin_addr = local_ip_addr; - rc = bind(sock_fd, (struct sockaddr *) &la, sizeof(la)); + rc = bind(sock_fd, (struct sockaddr *) & la, sizeof(la)); if (rc == 0) { rc = connect(sock_fd, - (struct sockaddr *) & ident_server, sizeof(ident_server)); + (struct sockaddr *) & ident_server, sizeof(ident_server)); } if (rc != 0) { snprintf(PQerrormsg, ERROR_MSG_LENGTH, - "Unable to connect to Ident server on the host which is " - "trying to connect to Postgres " - "(IP address %s, Port %d). " - "errno = %s (%d)\n", - inet_ntoa(remote_ip_addr), IDENT_PORT, strerror(errno), errno); + "Unable to connect to Ident server on the host which is " + "trying to connect to Postgres " + "(IP address %s, Port %d). " + "errno = %s (%d)\n", + inet_ntoa(remote_ip_addr), IDENT_PORT, strerror(errno), errno); fputs(PQerrormsg, stderr); pqdebug("%s", PQerrormsg); *ident_failed = true; } else { - char ident_query[80]; + char ident_query[80]; /* The query we send to the Ident server */ snprintf(ident_query, 80, "%d,%d\n", - ntohs(remote_port), ntohs(local_port)); + ntohs(remote_port), ntohs(local_port)); rc = send(sock_fd, ident_query, strlen(ident_query), 0); if (rc < 0) { snprintf(PQerrormsg, ERROR_MSG_LENGTH, - "Unable to send query to Ident server on the host which is " + "Unable to send query to Ident server on the host which is " "trying to connect to Postgres (Host %s, Port %d)," - "even though we successfully connected to it. " - "errno = %s (%d)\n", - inet_ntoa(remote_ip_addr), IDENT_PORT, strerror(errno), errno); + "even though we successfully connected to it. " + "errno = %s (%d)\n", + inet_ntoa(remote_ip_addr), IDENT_PORT, strerror(errno), errno); fputs(PQerrormsg, stderr); pqdebug("%s", PQerrormsg); *ident_failed = true; } else { - char ident_response[80 + IDENT_USERNAME_MAX]; + char ident_response[80 + IDENT_USERNAME_MAX]; rc = recv(sock_fd, ident_response, sizeof(ident_response) - 1, 0); if (rc < 0) { snprintf(PQerrormsg, ERROR_MSG_LENGTH, - "Unable to receive response from Ident server " - "on the host which is " - "trying to connect to Postgres (Host %s, Port %d)," - "even though we successfully sent our query to it. " - "errno = %s (%d)\n", - inet_ntoa(remote_ip_addr), IDENT_PORT, - strerror(errno), errno); + "Unable to receive response from Ident server " + "on the host which is " + "trying to connect to Postgres (Host %s, Port %d)," + "even though we successfully sent our query to it. " + "errno = %s (%d)\n", + inet_ntoa(remote_ip_addr), IDENT_PORT, + strerror(errno), errno); fputs(PQerrormsg, stderr); pqdebug("%s", PQerrormsg); *ident_failed = true; @@ -676,8 +680,8 @@ parse_map_record(FILE *file, return; } } - snprintf(PQerrormsg, ERROR_MSG_LENGTH, - "Incomplete line in pg_ident: %s", file_map); + snprintf(PQerrormsg, ERROR_MSG_LENGTH, + "Incomplete line in pg_ident: %s", file_map); fputs(PQerrormsg, stderr); pqdebug("%s", PQerrormsg); } @@ -760,29 +764,26 @@ verify_against_usermap(const char *pguser, { *checks_out_p = false; snprintf(PQerrormsg, ERROR_MSG_LENGTH, - "verify_against_usermap: hba configuration file does not " - "have the usermap field filled in in the entry that pertains " - "to this connection. That field is essential for Ident-based " - "authentication.\n"); + "verify_against_usermap: hba configuration file does not " + "have the usermap field filled in in the entry that pertains " + "to this connection. That field is essential for Ident-based " + "authentication.\n"); fputs(PQerrormsg, stderr); pqdebug("%s", PQerrormsg); } else if (strcmp(usermap_name, "sameuser") == 0) { if (strcmp(ident_username, pguser) == 0) - { *checks_out_p = true; - } else - { *checks_out_p = false; - } } else { - FILE *file; /* The map file we have to read */ - char *map_file; /* The name of the map file we have to read */ - int bufsize; + FILE *file; /* The map file we have to read */ + char *map_file; /* The name of the map file we have to + * read */ + int bufsize; /* put together the full pathname to the map file */ bufsize = (strlen(DataDir) + strlen(USERMAP_FILE) + 2) * sizeof(char); @@ -801,11 +802,11 @@ verify_against_usermap(const char *pguser, *checks_out_p = false; snprintf(PQerrormsg, ERROR_MSG_LENGTH, - "verify_against_usermap: usermap file for Ident-based " - "authentication " - "does not exist or permissions are not setup correctly! " - "Unable to open file \"%s\".\n", - map_file); + "verify_against_usermap: usermap file for Ident-based " + "authentication " + "does not exist or permissions are not setup correctly! " + "Unable to open file \"%s\".\n", + map_file); fputs(PQerrormsg, stderr); pqdebug("%s", PQerrormsg); } @@ -945,21 +946,21 @@ InRange(char *buf, int host) void GetCharSetByHost(char *TableName, int host, const char *DataDir) { - FILE *file; - char buf[MAX_TOKEN], + FILE *file; + char buf[MAX_TOKEN], BaseCharset[MAX_TOKEN], OrigCharset[MAX_TOKEN], DestCharset[MAX_TOKEN], HostCharset[MAX_TOKEN], c, eof = false, - *map_file; - int key = 0, + *map_file; + int key = 0, ChIndex = 0, i, bufsize; - struct CharsetItem *ChArray[MAX_CHARSETS]; + struct CharsetItem *ChArray[MAX_CHARSETS]; *TableName = '\0'; bufsize = (strlen(DataDir) + strlen(CHARSET_FILE) + 2) * sizeof(char); @@ -971,9 +972,7 @@ GetCharSetByHost(char *TableName, int host, const char *DataDir) file = AllocateFile(map_file, "rb"); #endif if (file == NULL) - { return; - } while (!eof) { c = getc(file); @@ -1033,8 +1032,8 @@ GetCharSetByHost(char *TableName, int host, const char *DataDir) next_token(file, buf, sizeof(buf)); if (buf[0] != '\0') { - ChArray[ChIndex] = - (struct CharsetItem *) palloc(sizeof(struct CharsetItem)); + ChArray[ChIndex] = + (struct CharsetItem *) palloc(sizeof(struct CharsetItem)); strcpy(ChArray[ChIndex]->Orig, OrigCharset); strcpy(ChArray[ChIndex]->Dest, DestCharset); strcpy(ChArray[ChIndex]->Table, buf); diff --git a/src/backend/libpq/password.c b/src/backend/libpq/password.c index 968ba055e6..98c05d3074 100644 --- a/src/backend/libpq/password.c +++ b/src/backend/libpq/password.c @@ -1,7 +1,7 @@ -/* +/* * Copyright (c) 1994, Regents of the University of California * - * $Id: password.c,v 1.20 1999/01/17 06:18:26 momjian Exp $ + * $Id: password.c,v 1.21 1999/05/25 16:09:00 momjian Exp $ * */ @@ -35,8 +35,8 @@ verify_password(char *auth_arg, char *user, char *password) if (!pw_file) { snprintf(PQerrormsg, ERROR_MSG_LENGTH, - "verify_password: couldn't open password file '%s'\n", - pw_file_fullname); + "verify_password: couldn't open password file '%s'\n", + pw_file_fullname); fputs(PQerrormsg, stderr); pqdebug("%s", PQerrormsg); @@ -80,8 +80,8 @@ verify_password(char *auth_arg, char *user, char *password) } snprintf(PQerrormsg, ERROR_MSG_LENGTH, - "verify_password: password mismatch for '%s'.\n", - user); + "verify_password: password mismatch for '%s'.\n", + user); fputs(PQerrormsg, stderr); pqdebug("%s", PQerrormsg); @@ -92,8 +92,8 @@ verify_password(char *auth_arg, char *user, char *password) } snprintf(PQerrormsg, ERROR_MSG_LENGTH, - "verify_password: user '%s' not found in password file.\n", - user); + "verify_password: user '%s' not found in password file.\n", + user); fputs(PQerrormsg, stderr); pqdebug("%s", PQerrormsg); diff --git a/src/backend/libpq/portal.c b/src/backend/libpq/portal.c index 05970a5cc3..6f7dca5cb5 100644 --- a/src/backend/libpq/portal.c +++ b/src/backend/libpq/portal.c @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: portal.c,v 1.21 1999/04/25 03:19:20 tgl Exp $ + * $Id: portal.c,v 1.22 1999/05/25 16:09:01 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -50,7 +50,7 @@ * see utils/mmgr/portalmem.c for why. -cim 2/22/91 * */ -#include +#include #include #include @@ -71,7 +71,7 @@ in_range(char *msg, int value, int min, int max) if (value < min || value >= max) { snprintf(PQerrormsg, ERROR_MSG_LENGTH, - "FATAL: %s, %d is not in range [%d,%d)\n", msg, value, min, max); + "FATAL: %s, %d is not in range [%d,%d)\n", msg, value, min, max); pqdebug("%s", PQerrormsg); fputs(PQerrormsg, stderr); return 0; diff --git a/src/backend/libpq/portalbuf.c b/src/backend/libpq/portalbuf.c index 002dbf5483..038a0a4614 100644 --- a/src/backend/libpq/portalbuf.c +++ b/src/backend/libpq/portalbuf.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/libpq/Attic/portalbuf.c,v 1.13 1999/02/13 23:15:46 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/libpq/Attic/portalbuf.c,v 1.14 1999/05/25 16:09:02 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -63,7 +63,7 @@ size_t portals_array_size = 0; /* GlobalMemory portals_mmcxt = (GlobalMemory) NULL; */ /* ------------------------------- - * portals_realloc + * portals_realloc * grow the size of the portals array by size * * also ensures that elements are initially NULL diff --git a/src/backend/libpq/pqcomm.c b/src/backend/libpq/pqcomm.c index 7f830d9c56..e8489dce41 100644 --- a/src/backend/libpq/pqcomm.c +++ b/src/backend/libpq/pqcomm.c @@ -28,7 +28,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pqcomm.c,v 1.71 1999/05/21 01:25:06 tgl Exp $ + * $Id: pqcomm.c,v 1.72 1999/05/25 16:09:02 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -53,7 +53,7 @@ * * message-level I/O (and COPY OUT cruft): * pq_putmessage - send a normal message (suppressed in COPY OUT mode) - * pq_startcopyout - inform libpq that a COPY OUT transfer is beginning + * pq_startcopyout - inform libpq that a COPY OUT transfer is beginning * pq_endcopyout - end a COPY OUT transfer * *------------------------ @@ -90,7 +90,7 @@ #define SOMAXCONN 5 /* from Linux listen(2) man page */ #endif /* SOMAXCONN */ -extern FILE * debug_port; /* in util.c */ +extern FILE *debug_port; /* in util.c */ /* * Buffers for low-level I/O @@ -99,11 +99,13 @@ extern FILE * debug_port; /* in util.c */ #define PQ_BUFFER_SIZE 8192 static unsigned char PqSendBuffer[PQ_BUFFER_SIZE]; -static int PqSendPointer; /* Next index to store a byte in PqSendBuffer */ +static int PqSendPointer; /* Next index to store a byte in + * PqSendBuffer */ static unsigned char PqRecvBuffer[PQ_BUFFER_SIZE]; -static int PqRecvPointer; /* Next index to read a byte from PqRecvBuffer */ -static int PqRecvLength; /* End of data available in PqRecvBuffer */ +static int PqRecvPointer; /* Next index to read a byte from + * PqRecvBuffer */ +static int PqRecvLength; /* End of data available in PqRecvBuffer */ /* * Message status @@ -121,7 +123,7 @@ pq_init(void) PqSendPointer = PqRecvPointer = PqRecvLength = 0; DoingCopyOut = false; if (getenv("LIBPQ_DEBUG")) - debug_port = stderr; + debug_port = stderr; } /* -------------------------------- @@ -187,8 +189,10 @@ StreamServerPort(char *hostName, short portName, int *fdP) family; size_t len; int one = 1; + #ifdef HAVE_FCNTL_SETLK int lock_fd; + #endif family = ((hostName != NULL) ? AF_INET : AF_UNIX); @@ -204,19 +208,20 @@ StreamServerPort(char *hostName, short portName, int *fdP) } #ifdef ONLY_REUSE_INET_SOCKETS - if (family == AF_INET) { + if (family == AF_INET) + { #endif - if ((setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *) &one, - sizeof(one))) == -1) - { - snprintf(PQerrormsg, ERROR_MSG_LENGTH, - "FATAL: StreamServerPort: setsockopt(SO_REUSEADDR) failed: %s\n", - strerror(errno)); - fputs(PQerrormsg, stderr); - pqdebug("%s", PQerrormsg); - return STATUS_ERROR; - } + if ((setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *) &one, + sizeof(one))) == -1) + { + snprintf(PQerrormsg, ERROR_MSG_LENGTH, + "FATAL: StreamServerPort: setsockopt(SO_REUSEADDR) failed: %s\n", + strerror(errno)); + fputs(PQerrormsg, stderr); + pqdebug("%s", PQerrormsg); + return STATUS_ERROR; + } #ifdef ONLY_REUSE_INET_SOCKETS } @@ -240,9 +245,10 @@ StreamServerPort(char *hostName, short portName, int *fdP) if ((lock_fd = open(sock_path, O_WRONLY | O_NONBLOCK | O_BINARY, 0666)) >= 0) #endif { - struct flock lck; - - lck.l_whence = SEEK_SET; lck.l_start = lck.l_len = 0; + struct flock lck; + + lck.l_whence = SEEK_SET; + lck.l_start = lck.l_len = 0; lck.l_type = F_WRLCK; if (fcntl(lock_fd, F_SETLK, &lck) == 0) { @@ -253,7 +259,7 @@ StreamServerPort(char *hostName, short portName, int *fdP) TPRINTF(TRACE_VERBOSE, "flock failed for %s", sock_path); close(lock_fd); } -#endif /* HAVE_FCNTL_SETLK */ +#endif /* HAVE_FCNTL_SETLK */ } else { @@ -277,9 +283,7 @@ StreamServerPort(char *hostName, short portName, int *fdP) sock_path); } else - { strcat(PQerrormsg, "\tIf not, wait a few seconds and retry.\n"); - } fputs(PQerrormsg, stderr); pqdebug("%s", PQerrormsg); return STATUS_ERROR; @@ -300,14 +304,15 @@ StreamServerPort(char *hostName, short portName, int *fdP) if ((lock_fd = open(sock_path, O_WRONLY | O_NONBLOCK | O_BINARY, 0666)) >= 0) #endif { - struct flock lck; - - lck.l_whence = SEEK_SET; lck.l_start = lck.l_len = 0; + struct flock lck; + + lck.l_whence = SEEK_SET; + lck.l_start = lck.l_len = 0; lck.l_type = F_WRLCK; if (fcntl(lock_fd, F_SETLK, &lck) != 0) TPRINTF(TRACE_VERBOSE, "flock error for %s", sock_path); } -#endif /* HAVE_FCNTL_SETLK */ +#endif /* HAVE_FCNTL_SETLK */ } listen(fd, SOMAXCONN); @@ -339,7 +344,7 @@ StreamServerPort(char *hostName, short portName, int *fdP) int StreamConnection(int server_fd, Port *port) { - SOCKET_SIZE_TYPE addrlen; + SOCKET_SIZE_TYPE addrlen; /* accept connection (and fill in the client (remote) address) */ addrlen = sizeof(port->raddr); @@ -419,8 +424,8 @@ pq_recvbuf(void) if (PqRecvLength > PqRecvPointer) { /* still some unread data, left-justify it in the buffer */ - memmove(PqRecvBuffer, PqRecvBuffer+PqRecvPointer, - PqRecvLength-PqRecvPointer); + memmove(PqRecvBuffer, PqRecvBuffer + PqRecvPointer, + PqRecvLength - PqRecvPointer); PqRecvLength -= PqRecvPointer; PqRecvPointer = 0; } @@ -431,16 +436,19 @@ pq_recvbuf(void) /* Can fill buffer from PqRecvLength and upwards */ for (;;) { - int r = recv(MyProcPort->sock, PqRecvBuffer + PqRecvLength, - PQ_BUFFER_SIZE - PqRecvLength, 0); + int r = recv(MyProcPort->sock, PqRecvBuffer + PqRecvLength, + PQ_BUFFER_SIZE - PqRecvLength, 0); + if (r < 0) { if (errno == EINTR) continue; /* Ok if interrupted */ - /* We would like to use elog() here, but dare not because elog - * tries to write to the client, which will cause problems - * if we have a hard communications failure ... - * So just write the message to the postmaster log. + + /* + * We would like to use elog() here, but dare not because elog + * tries to write to the client, which will cause problems if + * we have a hard communications failure ... So just write the + * message to the postmaster log. */ fprintf(stderr, "pq_recvbuf: recv() failed: %s\n", strerror(errno)); @@ -499,7 +507,7 @@ pq_peekbyte(void) int pq_getbytes(char *s, size_t len) { - size_t amount; + size_t amount; while (len > 0) { @@ -539,8 +547,8 @@ pq_getstring(char *s, size_t len) int c; /* - * Keep on reading until we get the terminating '\0', - * discarding any bytes we don't have room for. + * Keep on reading until we get the terminating '\0', discarding any + * bytes we don't have room for. */ while ((c = pq_getbyte()) != EOF && c != '\0') @@ -570,7 +578,7 @@ pq_getstring(char *s, size_t len) int pq_putbytes(const char *s, size_t len) { - size_t amount; + size_t amount; while (len > 0) { @@ -602,19 +610,24 @@ pq_flush(void) while (bufptr < bufend) { - int r = send(MyProcPort->sock, bufptr, bufend - bufptr, 0); + int r = send(MyProcPort->sock, bufptr, bufend - bufptr, 0); + if (r <= 0) { if (errno == EINTR) continue; /* Ok if we were interrupted */ - /* We would like to use elog() here, but cannot because elog + + /* + * We would like to use elog() here, but cannot because elog * tries to write to the client, which would cause a recursive * flush attempt! So just write it out to the postmaster log. */ fprintf(stderr, "pq_flush: send() failed: %s\n", strerror(errno)); - /* We drop the buffered data anyway so that processing - * can continue, even though we'll probably quit soon. + + /* + * We drop the buffered data anyway so that processing can + * continue, even though we'll probably quit soon. */ PqSendPointer = 0; return EOF; @@ -661,7 +674,7 @@ pq_putmessage(char msgtype, const char *s, size_t len) } /* -------------------------------- - * pq_startcopyout - inform libpq that a COPY OUT transfer is beginning + * pq_startcopyout - inform libpq that a COPY OUT transfer is beginning * -------------------------------- */ void @@ -682,7 +695,7 @@ pq_startcopyout(void) void pq_endcopyout(bool errorAbort) { - if (! DoingCopyOut) + if (!DoingCopyOut) return; if (errorAbort) pq_putbytes("\n\n\\.\n", 5); diff --git a/src/backend/libpq/pqformat.c b/src/backend/libpq/pqformat.c index 45b4259d8b..529b3115bd 100644 --- a/src/backend/libpq/pqformat.c +++ b/src/backend/libpq/pqformat.c @@ -15,14 +15,14 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pqformat.c,v 1.3 1999/04/25 21:50:56 tgl Exp $ + * $Id: pqformat.c,v 1.4 1999/05/25 16:09:02 momjian Exp $ * *------------------------------------------------------------------------- */ /* * INTERFACE ROUTINES * Message assembly and output: - * pq_beginmessage - initialize StringInfo buffer + * pq_beginmessage - initialize StringInfo buffer * pq_sendbyte - append a raw byte to a StringInfo buffer * pq_sendint - append a binary integer to a StringInfo buffer * pq_sendbytes - append raw data to a StringInfo buffer @@ -126,6 +126,7 @@ pq_sendcountedtext(StringInfo buf, const char *str, int slen) { #ifdef MULTIBYTE const char *p; + p = (const char *) pg_server_to_client((unsigned char *) str, slen); if (p != str) /* actual conversion has been done? */ { @@ -147,9 +148,11 @@ pq_sendcountedtext(StringInfo buf, const char *str, int slen) void pq_sendstring(StringInfo buf, const char *str) { - int slen = strlen(str); + int slen = strlen(str); + #ifdef MULTIBYTE const char *p; + p = (const char *) pg_server_to_client((unsigned char *) str, slen); if (p != str) /* actual conversion has been done? */ { @@ -157,7 +160,7 @@ pq_sendstring(StringInfo buf, const char *str) slen = strlen(str); } #endif - appendBinaryStringInfo(buf, str, slen+1); + appendBinaryStringInfo(buf, str, slen + 1); } /* -------------------------------- @@ -167,9 +170,9 @@ pq_sendstring(StringInfo buf, const char *str) void pq_sendint(StringInfo buf, int i, int b) { - unsigned char n8; - uint16 n16; - uint32 n32; + unsigned char n8; + uint16 n16; + uint32 n32; switch (b) { @@ -225,9 +228,11 @@ pq_endmessage(StringInfo buf) int pq_puttextmessage(char msgtype, const char *str) { - int slen = strlen(str); + int slen = strlen(str); + #ifdef MULTIBYTE const char *p; + p = (const char *) pg_server_to_client((unsigned char *) str, slen); if (p != str) /* actual conversion has been done? */ { @@ -235,7 +240,7 @@ pq_puttextmessage(char msgtype, const char *str) slen = strlen(str); } #endif - return pq_putmessage(msgtype, str, slen+1); + return pq_putmessage(msgtype, str, slen + 1); } /* -------------------------------- @@ -247,10 +252,10 @@ pq_puttextmessage(char msgtype, const char *str) int pq_getint(int *result, int b) { - int status; - unsigned char n8; - uint16 n16; - uint32 n32; + int status; + unsigned char n8; + uint16 n16; + uint32 n32; switch (b) { @@ -269,8 +274,10 @@ pq_getint(int *result, int b) ntoh_l(n32) : ntohl(n32)); break; default: - /* if we elog(ERROR) here, we will lose sync with the frontend, - * so just complain to postmaster log instead... + + /* + * if we elog(ERROR) here, we will lose sync with the + * frontend, so just complain to postmaster log instead... */ fprintf(stderr, "pq_getint: unsupported size %d\n", b); status = EOF; @@ -293,23 +300,26 @@ int pq_getstr(char *s, int maxlen) { int c; + #ifdef MULTIBYTE char *p; + #endif c = pq_getstring(s, maxlen); #ifdef MULTIBYTE - p = (char*) pg_client_to_server((unsigned char *) s, strlen(s)); + p = (char *) pg_client_to_server((unsigned char *) s, strlen(s)); if (p != s) /* actual conversion has been done? */ { - int newlen = strlen(p); + int newlen = strlen(p); + if (newlen < maxlen) strcpy(s, p); else { strncpy(s, p, maxlen); - s[maxlen-1] = '\0'; + s[maxlen - 1] = '\0'; } } #endif diff --git a/src/backend/libpq/util.c b/src/backend/libpq/util.c index ce35c2571c..50c2846815 100644 --- a/src/backend/libpq/util.c +++ b/src/backend/libpq/util.c @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: util.c,v 1.8 1999/02/13 23:15:49 momjian Exp $ + * $Id: util.c,v 1.9 1999/05/25 16:09:03 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -17,7 +17,7 @@ * PQuntrace - turn off pqdebug() tracing */ -#include +#include #include #include diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c index 87919b4dba..723e70b1e0 100644 --- a/src/backend/nodes/copyfuncs.c +++ b/src/backend/nodes/copyfuncs.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.80 1999/05/18 21:34:27 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.81 1999/05/25 16:09:04 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -92,7 +92,7 @@ CopyPlanFields(Plan *from, Plan *newnode) newnode->chgParam = listCopy(from->chgParam); Node_Copy(from, newnode, initPlan); if (from->subPlan != NULL) - newnode->subPlan = SS_pull_subplan((Node*) newnode->qual); + newnode->subPlan = SS_pull_subplan((Node *) newnode->qual); else newnode->subPlan = NULL; newnode->nParamExec = from->nParamExec; @@ -138,10 +138,12 @@ _copyResult(Result *from) */ Node_Copy(from, newnode, resconstantqual); - /* We must add subplans in resconstantqual to the new plan's subPlan list + /* + * We must add subplans in resconstantqual to the new plan's subPlan + * list */ newnode->plan.subPlan = nconc(newnode->plan.subPlan, - SS_pull_subplan(newnode->resconstantqual)); + SS_pull_subplan(newnode->resconstantqual)); return newnode; } @@ -369,7 +371,7 @@ _copyHashJoin(HashJoin *from) * ---------------- */ static void -CopyNonameFields(Noname *from, Noname *newnode) +CopyNonameFields(Noname * from, Noname * newnode) { newnode->nonameid = from->nonameid; newnode->keycount = from->keycount; @@ -382,7 +384,7 @@ CopyNonameFields(Noname *from, Noname *newnode) * ---------------- */ static Noname * -_copyNoname(Noname *from) +_copyNoname(Noname * from) { Noname *newnode = makeNode(Noname); @@ -466,9 +468,10 @@ _copyAgg(Agg *from) CopyPlanFields((Plan *) from, (Plan *) newnode); - /* Cannot copy agg list; it must be rebuilt to point to subnodes of + /* + * Cannot copy agg list; it must be rebuilt to point to subnodes of * new node. - */ + */ set_agg_tlist_references(newnode); return newnode; @@ -859,7 +862,7 @@ _copyFunc(Func *from) * ---------------- */ static Aggref * -_copyAggref(Aggref *from) +_copyAggref(Aggref * from) { Aggref *newnode = makeNode(Aggref); @@ -904,7 +907,7 @@ _copySubLink(SubLink *from) * ---------------- */ static CaseExpr * -_copyCaseExpr(CaseExpr *from) +_copyCaseExpr(CaseExpr * from) { CaseExpr *newnode = makeNode(CaseExpr); @@ -926,7 +929,7 @@ _copyCaseExpr(CaseExpr *from) * ---------------- */ static CaseWhen * -_copyCaseWhen(CaseWhen *from) +_copyCaseWhen(CaseWhen * from) { CaseWhen *newnode = makeNode(CaseWhen); @@ -1170,7 +1173,7 @@ _copyIndexPath(IndexPath *from) * ---------------- */ static void -CopyNestPathFields(NestPath *from, NestPath *newnode) +CopyNestPathFields(NestPath * from, NestPath * newnode) { Node_Copy(from, newnode, pathinfo); Node_Copy(from, newnode, outerjoinpath); @@ -1182,7 +1185,7 @@ CopyNestPathFields(NestPath *from, NestPath *newnode) * ---------------- */ static NestPath * -_copyNestPath(NestPath *from) +_copyNestPath(NestPath * from) { NestPath *newnode = makeNode(NestPath); @@ -1316,7 +1319,7 @@ _copyMergeOrder(MergeOrder *from) * ---------------- */ static RestrictInfo * -_copyRestrictInfo(RestrictInfo *from) +_copyRestrictInfo(RestrictInfo * from) { RestrictInfo *newnode = makeNode(RestrictInfo); @@ -1371,9 +1374,9 @@ _copyJoinMethod(JoinMethod *from) * ---------------- */ static HashInfo * -_copyHashInfo(HashInfo *from) +_copyHashInfo(HashInfo * from) { - HashInfo *newnode = makeNode(HashInfo); + HashInfo *newnode = makeNode(HashInfo); /* ---------------- * copy remainder of node @@ -1390,9 +1393,9 @@ _copyHashInfo(HashInfo *from) * ---------------- */ static MergeInfo * -_copyMergeInfo(MergeInfo *from) +_copyMergeInfo(MergeInfo * from) { - MergeInfo *newnode = makeNode(MergeInfo); + MergeInfo *newnode = makeNode(MergeInfo); /* ---------------- * copy remainder of node @@ -1409,7 +1412,7 @@ _copyMergeInfo(MergeInfo *from) * ---------------- */ static JoinInfo * -_copyJoinInfo(JoinInfo *from) +_copyJoinInfo(JoinInfo * from) { JoinInfo *newnode = makeNode(JoinInfo); @@ -1493,9 +1496,9 @@ _copyRangeTblEntry(RangeTblEntry *from) } static RowMark * -_copyRowMark(RowMark *from) +_copyRowMark(RowMark * from) { - RowMark *newnode = makeNode(RowMark); + RowMark *newnode = makeNode(RowMark); newnode->rti = from->rti; newnode->info = from->info; diff --git a/src/backend/nodes/equalfuncs.c b/src/backend/nodes/equalfuncs.c index 45e752f502..7f86933496 100644 --- a/src/backend/nodes/equalfuncs.c +++ b/src/backend/nodes/equalfuncs.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.36 1999/05/12 15:01:33 wieck Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.37 1999/05/25 16:09:06 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -283,7 +283,7 @@ _equalFunc(Func *a, Func *b) * RestrictInfo is a subclass of Node. */ static bool -_equalRestrictInfo(RestrictInfo *a, RestrictInfo *b) +_equalRestrictInfo(RestrictInfo * a, RestrictInfo * b) { Assert(IsA(a, RestrictInfo)); Assert(IsA(b, RestrictInfo)); @@ -307,7 +307,7 @@ _equalRestrictInfo(RestrictInfo *a, RestrictInfo *b) * RelOptInfo is a subclass of Node. */ static bool -_equalRelOptInfo(RelOptInfo *a, RelOptInfo *b) +_equalRelOptInfo(RelOptInfo * a, RelOptInfo * b) { Assert(IsA(a, RelOptInfo)); Assert(IsA(b, RelOptInfo)); @@ -392,7 +392,7 @@ _equalIndexPath(IndexPath *a, IndexPath *b) } static bool -_equalNestPath(NestPath *a, NestPath *b) +_equalNestPath(NestPath * a, NestPath * b) { Assert(IsA_JoinPath(a)); Assert(IsA_JoinPath(b)); @@ -477,7 +477,7 @@ _equalMergeOrder(MergeOrder *a, MergeOrder *b) } static bool -_equalHashInfo(HashInfo *a, HashInfo *b) +_equalHashInfo(HashInfo * a, HashInfo * b) { Assert(IsA(a, HashInfo)); Assert(IsA(b, HashInfo)); @@ -524,7 +524,7 @@ _equalSubPlan(SubPlan *a, SubPlan *b) } static bool -_equalJoinInfo(JoinInfo *a, JoinInfo *b) +_equalJoinInfo(JoinInfo * a, JoinInfo * b) { Assert(IsA(a, JoinInfo)); Assert(IsA(b, JoinInfo)); @@ -574,10 +574,13 @@ _equalQuery(Query *a, Query *b) return false; if (a->resultRelation != b->resultRelation) return false; - if (a->into && b->into) { + if (a->into && b->into) + { if (strcmp(a->into, b->into) != 0) return false; - } else { + } + else + { if (a->into != b->into) return false; } @@ -593,10 +596,13 @@ _equalQuery(Query *a, Query *b) return false; if (a->hasSubLinks != b->hasSubLinks) return false; - if (a->uniqueFlag && b->uniqueFlag) { + if (a->uniqueFlag && b->uniqueFlag) + { if (strcmp(a->uniqueFlag, b->uniqueFlag) != 0) return false; - } else { + } + else + { if (a->uniqueFlag != b->uniqueFlag) return false; } @@ -623,10 +629,10 @@ _equalQuery(Query *a, Query *b) if (!equal(a->limitCount, b->limitCount)) return false; - /* We do not check the internal-to-the-planner fields - * base_rel_list and join_rel_list. They might not be - * set yet, and in any case they should be derivable - * from the other fields. + /* + * We do not check the internal-to-the-planner fields base_rel_list + * and join_rel_list. They might not be set yet, and in any case they + * should be derivable from the other fields. */ return true; } @@ -634,17 +640,23 @@ _equalQuery(Query *a, Query *b) static bool _equalRangeTblEntry(RangeTblEntry *a, RangeTblEntry *b) { - if (a->relname && b->relname) { + if (a->relname && b->relname) + { if (strcmp(a->relname, b->relname) != 0) return false; - } else { + } + else + { if (a->relname != b->relname) return false; } - if (a->refname && b->refname) { + if (a->refname && b->refname) + { if (strcmp(a->refname, b->refname) != 0) return false; - } else { + } + else + { if (a->refname != b->refname) return false; } diff --git a/src/backend/nodes/freefuncs.c b/src/backend/nodes/freefuncs.c index 3c95dcbe22..71bf12bcde 100644 --- a/src/backend/nodes/freefuncs.c +++ b/src/backend/nodes/freefuncs.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/Attic/freefuncs.c,v 1.16 1999/05/12 15:01:33 wieck Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/Attic/freefuncs.c,v 1.17 1999/05/25 16:09:06 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -297,12 +297,12 @@ _freeHashJoin(HashJoin *node) /* ---------------- * FreeNonameFields * - * This function frees the fields of the Noname node. It is used by + * This function frees the fields of the Noname node. It is used by * all the free functions for classes which inherit node Noname. * ---------------- */ static void -FreeNonameFields(Noname *node) +FreeNonameFields(Noname * node) { return; } @@ -313,7 +313,7 @@ FreeNonameFields(Noname *node) * ---------------- */ static void -_freeNoname(Noname *node) +_freeNoname(Noname * node) { /* ---------------- * free node superclass fields @@ -562,7 +562,7 @@ _freeConst(Const *node) * ---------------- */ if (!node->constbyval) - pfree((void *)node->constvalue); + pfree((void *) node->constvalue); pfree(node); } @@ -609,7 +609,7 @@ _freeFunc(Func *node) * ---------------- */ static void -_freeAggref(Aggref *node) +_freeAggref(Aggref * node) { /* ---------------- * free remainder of node @@ -644,7 +644,7 @@ _freeSubLink(SubLink *node) * ---------------- */ static void -_freeCaseExpr(CaseExpr *node) +_freeCaseExpr(CaseExpr * node) { /* ---------------- * free remainder of node @@ -662,7 +662,7 @@ _freeCaseExpr(CaseExpr *node) * ---------------- */ static void -_freeCaseWhen(CaseWhen *node) +_freeCaseWhen(CaseWhen * node) { /* ---------------- * free remainder of node @@ -709,7 +709,7 @@ _freeArrayRef(ArrayRef *node) * ---------------- */ static void -_freeRelOptInfo(RelOptInfo *node) +_freeRelOptInfo(RelOptInfo * node) { /* ---------------- * free remainder of node @@ -757,8 +757,8 @@ FreePathFields(Path *node) else freeObject(node->pathorder->ord.merge); - pfree(node->pathorder); /* is it an object, but we don't have - separate free for it */ + pfree(node->pathorder); /* is it an object, but we don't have + * separate free for it */ freeObject(node->pathkeys); @@ -812,7 +812,7 @@ _freeIndexPath(IndexPath *node) * ---------------- */ static void -FreeNestPathFields(NestPath *node) +FreeNestPathFields(NestPath * node) { freeObject(node->pathinfo); freeObject(node->outerjoinpath); @@ -824,7 +824,7 @@ FreeNestPathFields(NestPath *node) * ---------------- */ static void -_freeNestPath(NestPath *node) +_freeNestPath(NestPath * node) { /* ---------------- * free the node superclass fields @@ -933,7 +933,7 @@ _freeMergeOrder(MergeOrder *node) * ---------------- */ static void -_freeRestrictInfo(RestrictInfo *node) +_freeRestrictInfo(RestrictInfo * node) { /* ---------------- * free remainder of node @@ -950,7 +950,7 @@ _freeRestrictInfo(RestrictInfo *node) /* ---------------- * FreeJoinMethodFields * - * This function frees the fields of the JoinMethod node. It is used by + * This function frees the fields of the JoinMethod node. It is used by * all the free functions for classes which inherit node JoinMethod. * ---------------- */ @@ -979,7 +979,7 @@ _freeJoinMethod(JoinMethod *node) * ---------------- */ static void -_freeHashInfo(HashInfo *node) +_freeHashInfo(HashInfo * node) { /* ---------------- * free remainder of node @@ -995,7 +995,7 @@ _freeHashInfo(HashInfo *node) * ---------------- */ static void -_freeMergeInfo(MergeInfo *node) +_freeMergeInfo(MergeInfo * node) { /* ---------------- * free remainder of node @@ -1012,7 +1012,7 @@ _freeMergeInfo(MergeInfo *node) * ---------------- */ static void -_freeJoinInfo(JoinInfo *node) +_freeJoinInfo(JoinInfo * node) { /* ---------------- * free remainder of node @@ -1066,7 +1066,7 @@ _freeRangeTblEntry(RangeTblEntry *node) } static void -_freeRowMark(RowMark *node) +_freeRowMark(RowMark * node) { pfree(node); } @@ -1142,7 +1142,7 @@ _freeValue(Value *node) { switch (node->type) { - case T_String: + case T_String: pfree(node->val.str); break; default: @@ -1165,6 +1165,7 @@ freeObject(void *node) switch (nodeTag(node)) { + /* * PLAN NODES */ diff --git a/src/backend/nodes/list.c b/src/backend/nodes/list.c index e148e66669..48c15f1802 100644 --- a/src/backend/nodes/list.c +++ b/src/backend/nodes/list.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/list.c,v 1.20 1999/02/22 17:29:57 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/list.c,v 1.21 1999/05/25 16:09:08 momjian Exp $ * * NOTES * XXX a few of the following functions are duplicated to handle @@ -96,7 +96,7 @@ lconsi(int datum, List *list) * lappend * * Add obj to the end of list, or make a new list if 'list' is NIL - * + * * MORE EXPENSIVE THAN lcons */ List * @@ -161,6 +161,7 @@ nreverse(List *list) lnext(list) = lnext(rlist); return list; } + #endif /* @@ -307,6 +308,7 @@ append(List *l1, List *l2) lnext(p) = newlist2; return newlist; } + #endif #ifdef NOT_USED @@ -331,6 +333,7 @@ intAppend(List *l1, List *l2) lnext(p) = newlist2; return newlist; } + #endif /* @@ -435,7 +438,7 @@ member(void *l1, List *l2) foreach(i, l2) if (equal((Node *) l1, (Node *) lfirst(i))) - return true; + return true; return false; } diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c index f3dec72128..43fa22e045 100644 --- a/src/backend/nodes/outfuncs.c +++ b/src/backend/nodes/outfuncs.c @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: outfuncs.c,v 1.84 1999/05/19 16:46:11 momjian Exp $ + * $Id: outfuncs.c,v 1.85 1999/05/25 16:09:09 momjian Exp $ * * NOTES * Every (plan) node in POSTGRES has an associated "out" routine which @@ -54,24 +54,22 @@ static void _outNode(StringInfo str, void *obj); static void _outIntList(StringInfo str, List *list) { - List *l; + List *l; appendStringInfo(str, "("); foreach(l, list) - { appendStringInfo(str, " %d ", lfirsti(l)); - } appendStringInfo(str, ")"); } static void _outCreateStmt(StringInfo str, CreateStmt *node) { - appendStringInfo(str, " CREATE :relname %s ", - stringStringInfo(node->relname)); + appendStringInfo(str, " CREATE :relname %s ", + stringStringInfo(node->relname)); appendStringInfo(str, " :istemp %s ", - node->istemp ? "true" : "false"); + node->istemp ? "true" : "false"); appendStringInfo(str, " :columns "); _outNode(str, node->tableElts); @@ -86,11 +84,11 @@ _outCreateStmt(StringInfo str, CreateStmt *node) static void _outIndexStmt(StringInfo str, IndexStmt *node) { - appendStringInfo(str, - " INDEX :idxname %s :relname %s :accessMethod %s :indexParams ", - stringStringInfo(node->idxname), - stringStringInfo(node->relname), - stringStringInfo(node->accessMethod)); + appendStringInfo(str, + " INDEX :idxname %s :relname %s :accessMethod %s :indexParams ", + stringStringInfo(node->idxname), + stringStringInfo(node->relname), + stringStringInfo(node->accessMethod)); _outNode(str, node->indexParams); appendStringInfo(str, " :withClause "); @@ -103,8 +101,8 @@ _outIndexStmt(StringInfo str, IndexStmt *node) _outNode(str, node->rangetable); appendStringInfo(str, " :lossy %s :unique %s ", - node->lossy ? "true" : "false", - node->unique ? "true" : "false"); + node->lossy ? "true" : "false", + node->unique ? "true" : "false"); } static void @@ -125,24 +123,24 @@ static void _outColumnDef(StringInfo str, ColumnDef *node) { appendStringInfo(str, " COLUMNDEF :colname %s :typename ", - stringStringInfo(node->colname)); + stringStringInfo(node->colname)); _outNode(str, node->typename); appendStringInfo(str, " :is_not_null %s :defval %s :constraints ", - node->is_not_null ? "true" : "false", - stringStringInfo(node->defval)); + node->is_not_null ? "true" : "false", + stringStringInfo(node->defval)); _outNode(str, node->constraints); } static void _outTypeName(StringInfo str, TypeName *node) { - appendStringInfo(str, - " TYPENAME :name %s :timezone %s :setof %s typmod %d :arrayBounds ", - stringStringInfo(node->name), - node->timezone ? "true" : "false", - node->setof ? "true" : "false", - node->typmod); + appendStringInfo(str, + " TYPENAME :name %s :timezone %s :setof %s typmod %d :arrayBounds ", + stringStringInfo(node->name), + node->timezone ? "true" : "false", + node->setof ? "true" : "false", + node->typmod); appendStringInfo(str, " :arrayBounds "); _outNode(str, node->arrayBounds); @@ -152,7 +150,7 @@ static void _outIndexElem(StringInfo str, IndexElem *node) { appendStringInfo(str, " INDEXELEM :name %s :args ", - stringStringInfo(node->name)); + stringStringInfo(node->name)); _outNode(str, node->args); appendStringInfo(str, " :class %s :typename ", stringStringInfo(node->class)); @@ -171,20 +169,20 @@ _outQuery(StringInfo str, Query *node) { case T_CreateStmt: appendStringInfo(str, " :create %s ", - stringStringInfo(((CreateStmt *) (node->utilityStmt))->relname)); + stringStringInfo(((CreateStmt *) (node->utilityStmt))->relname)); _outNode(str, node->utilityStmt); break; case T_IndexStmt: appendStringInfo(str, " :index %s on %s ", - stringStringInfo(((IndexStmt *) (node->utilityStmt))->idxname), - stringStringInfo(((IndexStmt *) (node->utilityStmt))->relname)); + stringStringInfo(((IndexStmt *) (node->utilityStmt))->idxname), + stringStringInfo(((IndexStmt *) (node->utilityStmt))->relname)); _outNode(str, node->utilityStmt); break; case T_NotifyStmt: appendStringInfo(str, " :utility %s ", - stringStringInfo(((NotifyStmt *) (node->utilityStmt))->relname)); + stringStringInfo(((NotifyStmt *) (node->utilityStmt))->relname)); break; default: @@ -192,21 +190,19 @@ _outQuery(StringInfo str, Query *node) } } else - { appendStringInfo(str, " :utility <>"); - } - appendStringInfo(str, - " :resultRelation %u :into %s :isPortal %s :isBinary %s :isTemp %s :unionall %s ", - node->resultRelation, - stringStringInfo(node->into), - node->isPortal ? "true" : "false", - node->isBinary ? "true" : "false", - node->isTemp ? "true" : "false", - node->unionall ? "true" : "false"); + appendStringInfo(str, + " :resultRelation %u :into %s :isPortal %s :isBinary %s :isTemp %s :unionall %s ", + node->resultRelation, + stringStringInfo(node->into), + node->isPortal ? "true" : "false", + node->isBinary ? "true" : "false", + node->isTemp ? "true" : "false", + node->unionall ? "true" : "false"); - appendStringInfo(str, " :unique %s :sortClause ", - stringStringInfo(node->uniqueFlag)); + appendStringInfo(str, " :unique %s :sortClause ", + stringStringInfo(node->uniqueFlag)); _outNode(str, node->sortClause); appendStringInfo(str, " :rtable "); @@ -225,8 +221,8 @@ _outQuery(StringInfo str, Query *node) _outNode(str, node->havingQual); appendStringInfo(str, " :hasAggs %s :hasSubLinks %s :unionClause ", - node->hasAggs ? "true" : "false", - node->hasSubLinks ? "true" : "false"); + node->hasAggs ? "true" : "false", + node->hasSubLinks ? "true" : "false"); _outNode(str, node->unionClause); appendStringInfo(str, " :intersectClause "); @@ -255,9 +251,9 @@ _outSortClause(StringInfo str, SortClause *node) static void _outGroupClause(StringInfo str, GroupClause *node) { - appendStringInfo(str, " GROUPCLAUSE :grpOpoid %u :tleGroupref %d", - node->grpOpoid, - node->tleGroupref); + appendStringInfo(str, " GROUPCLAUSE :grpOpoid %u :tleGroupref %d", + node->grpOpoid, + node->tleGroupref); } /* @@ -266,12 +262,12 @@ _outGroupClause(StringInfo str, GroupClause *node) static void _outPlanInfo(StringInfo str, Plan *node) { - appendStringInfo(str, - ":cost %g :size %d :width %d :state %s :qptargetlist ", - node->cost, - node->plan_size, - node->plan_width, - node->state ? "not-NULL" : "<>"); + appendStringInfo(str, + ":cost %g :size %d :width %d :state %s :qptargetlist ", + node->cost, + node->plan_size, + node->plan_width, + node->state ? "not-NULL" : "<>"); _outNode(str, node->targetlist); appendStringInfo(str, " :qpqual "); @@ -331,9 +327,9 @@ _outAppend(StringInfo str, Append *node) appendStringInfo(str, " :unionrtables "); _outNode(str, node->unionrtables); - appendStringInfo(str, - " :inheritrelid %u :inheritrtable ", - node->inheritrelid); + appendStringInfo(str, + " :inheritrelid %u :inheritrtable ", + node->inheritrelid); _outNode(str, node->inheritrtable); } @@ -384,13 +380,13 @@ _outHashJoin(StringInfo str, HashJoin *node) appendStringInfo(str, " :hashclauses "); _outNode(str, node->hashclauses); - appendStringInfo(str, - " :hashjoinop %u ", - node->hashjoinop); + appendStringInfo(str, + " :hashjoinop %u ", + node->hashjoinop); - appendStringInfo(str, - " :hashdone %d ", - node->hashdone); + appendStringInfo(str, + " :hashdone %d ", + node->hashdone); } static void @@ -460,14 +456,14 @@ _outIndexScan(StringInfo str, IndexScan *node) * Noname is a subclass of Plan */ static void -_outNoname(StringInfo str, Noname *node) +_outNoname(StringInfo str, Noname * node) { appendStringInfo(str, " NONAME "); _outPlanInfo(str, (Plan *) node); - appendStringInfo(str, " :nonameid %u :keycount %d ", - node->nonameid, - node->keycount); + appendStringInfo(str, " :nonameid %u :keycount %d ", + node->nonameid, + node->keycount); } /* @@ -480,8 +476,8 @@ _outSort(StringInfo str, Sort *node) _outPlanInfo(str, (Plan *) node); appendStringInfo(str, " :nonameid %u :keycount %d ", - node->nonameid, - node->keycount); + node->nonameid, + node->keycount); } static void @@ -503,8 +499,8 @@ _outGroup(StringInfo str, Group *node) /* the actual Group fields */ appendStringInfo(str, " :numCols %d :tuplePerGroup %s ", - node->numCols, - node->tuplePerGroup ? "true" : "false"); + node->numCols, + node->tuplePerGroup ? "true" : "false"); } /* @@ -517,8 +513,8 @@ _outUnique(StringInfo str, Unique *node) _outPlanInfo(str, (Plan *) node); appendStringInfo(str, " :nonameid %u :keycount %d ", - node->nonameid, - node->keycount); + node->nonameid, + node->keycount); } @@ -548,18 +544,18 @@ static void _outResdom(StringInfo str, Resdom *node) { appendStringInfo(str, " RESDOM :resno %d :restype %u :restypmod %d", - node->resno, - node->restype, - node->restypmod); + node->resno, + node->restype, + node->restypmod); appendStringInfo(str, " :resname \"%s\" :reskey %d :reskeyop %u", - stringStringInfo(node->resname), - node->reskey, - node->reskeyop); + stringStringInfo(node->resname), + node->reskey, + node->reskeyop); appendStringInfo(str, " :resgroupref %d :resjunk %s ", - node->resgroupref, - node->resjunk ? "true" : "false"); + node->resgroupref, + node->resjunk ? "true" : "false"); } static void @@ -568,14 +564,14 @@ _outFjoin(StringInfo str, Fjoin *node) int i; appendStringInfo(str, " FJOIN :initialized %s :nNodes %d ", - node->fj_initialized ? "true" : "false", - node->fj_nNodes); + node->fj_initialized ? "true" : "false", + node->fj_nNodes); appendStringInfo(str, " :innerNode "); _outNode(str, node->fj_innerNode); - appendStringInfo(str, " :results @ 0x%x :alwaysdone", - (int) node->fj_results); + appendStringInfo(str, " :results @ 0x%x :alwaysdone", + (int) node->fj_results); for (i = 0; i < node->fj_nNodes; i++) appendStringInfo(str, (node->fj_alwaysDone[i]) ? "true" : "false"); @@ -590,7 +586,7 @@ _outExpr(StringInfo str, Expr *node) char *opstr = NULL; appendStringInfo(str, " EXPR :typeOid %u ", - node->typeOid); + node->typeOid); switch (node->opType) { @@ -626,17 +622,17 @@ _outExpr(StringInfo str, Expr *node) static void _outVar(StringInfo str, Var *node) { - appendStringInfo(str, - " VAR :varno %d :varattno %d :vartype %u :vartypmod %d ", - node->varno, - node->varattno, - node->vartype, - node->vartypmod); + appendStringInfo(str, + " VAR :varno %d :varattno %d :vartype %u :vartypmod %d ", + node->varno, + node->varattno, + node->vartype, + node->vartypmod); - appendStringInfo(str, " :varlevelsup %u :varnoold %d :varoattno %d" , - node->varlevelsup, - node->varnoold, - node->varoattno); + appendStringInfo(str, " :varlevelsup %u :varnoold %d :varoattno %d", + node->varlevelsup, + node->varnoold, + node->varoattno); } /* @@ -645,37 +641,37 @@ _outVar(StringInfo str, Var *node) static void _outConst(StringInfo str, Const *node) { - appendStringInfo(str, - " CONST :consttype %u :constlen %d :constisnull %s :constvalue ", - node->consttype, - node->constlen, - node->constisnull ? "true" : "false"); + appendStringInfo(str, + " CONST :consttype %u :constlen %d :constisnull %s :constvalue ", + node->consttype, + node->constlen, + node->constisnull ? "true" : "false"); if (node->constisnull) appendStringInfo(str, "<>"); else _outDatum(str, node->constvalue, node->consttype); - appendStringInfo(str, " :constbyval %s ", - node->constbyval ? "true" : "false"); + appendStringInfo(str, " :constbyval %s ", + node->constbyval ? "true" : "false"); } /* * Aggref */ static void -_outAggref(StringInfo str, Aggref *node) +_outAggref(StringInfo str, Aggref * node) { - appendStringInfo(str, - " AGGREG :aggname %s :basetype %u :aggtype %u :target ", - stringStringInfo(node->aggname), - node->basetype, - node->aggtype); + appendStringInfo(str, + " AGGREG :aggname %s :basetype %u :aggtype %u :target ", + stringStringInfo(node->aggname), + node->basetype, + node->aggtype); _outNode(str, node->target); appendStringInfo(str, ":aggno %d :usenulls %s", - node->aggno, - node->usenulls ? "true" : "false"); + node->aggno, + node->usenulls ? "true" : "false"); } /* @@ -684,10 +680,10 @@ _outAggref(StringInfo str, Aggref *node) static void _outSubLink(StringInfo str, SubLink *node) { - appendStringInfo(str, - " SUBLINK :subLinkType %d :useor %s :lefthand ", - node->subLinkType, - node->useor ? "true" : "false"); + appendStringInfo(str, + " SUBLINK :subLinkType %d :useor %s :lefthand ", + node->subLinkType, + node->useor ? "true" : "false"); _outNode(str, node->lefthand); appendStringInfo(str, " :oper "); @@ -705,22 +701,18 @@ _outArray(StringInfo str, Array *node) { int i; - appendStringInfo(str, - " ARRAY :arrayelemtype %u :arrayelemlength %d :arrayelembyval %c ", - node->arrayelemtype, - node->arrayelemlength, - node->arrayelembyval ? 't' : 'f'); + appendStringInfo(str, + " ARRAY :arrayelemtype %u :arrayelemlength %d :arrayelembyval %c ", + node->arrayelemtype, + node->arrayelemlength, + node->arrayelembyval ? 't' : 'f'); appendStringInfo(str, " :arrayndim %d :arraylow ", node->arrayndim); for (i = 0; i < node->arrayndim; i++) - { appendStringInfo(str, " %d ", node->arraylow.indx[i]); - } appendStringInfo(str, " :arrayhigh "); for (i = 0; i < node->arrayndim; i++) - { appendStringInfo(str, " %d ", node->arrayhigh.indx[i]); - } appendStringInfo(str, " :arraylen %d ", node->arraylen); } @@ -730,14 +722,14 @@ _outArray(StringInfo str, Array *node) static void _outArrayRef(StringInfo str, ArrayRef *node) { - appendStringInfo(str, - " ARRAYREF :refelemtype %u :refattrlength $d :refelemlength %d ", - node->refelemtype, - node->refattrlength, - node->refelemlength); + appendStringInfo(str, + " ARRAYREF :refelemtype %u :refattrlength $d :refelemlength %d ", + node->refelemtype, + node->refattrlength, + node->refelemlength); - appendStringInfo(str, " :refelembyval %c :refupperindex ", - node->refelembyval ? 't' : 'f'); + appendStringInfo(str, " :refelembyval %c :refupperindex ", + node->refelembyval ? 't' : 'f'); _outNode(str, node->refupperindexpr); appendStringInfo(str, " :reflowerindex "); @@ -756,15 +748,15 @@ _outArrayRef(StringInfo str, ArrayRef *node) static void _outFunc(StringInfo str, Func *node) { - appendStringInfo(str, - " FUNC :funcid %u :functype %u :funcisindex %s :funcsize %d ", - node->funcid, - node->functype, - node->funcisindex ? "true" : "false", - node->funcsize); + appendStringInfo(str, + " FUNC :funcid %u :functype %u :funcisindex %s :funcsize %d ", + node->funcid, + node->functype, + node->funcisindex ? "true" : "false", + node->funcsize); appendStringInfo(str, " :func_fcache @ 0x%x :func_tlist ", - (int) node->func_fcache); + (int) node->func_fcache); _outNode(str, node->func_tlist); appendStringInfo(str, " :func_planlist "); @@ -777,11 +769,11 @@ _outFunc(StringInfo str, Func *node) static void _outOper(StringInfo str, Oper *node) { - appendStringInfo(str, - " OPER :opno %u :opid %u :opresulttype %u ", - node->opno, - node->opid, - node->opresulttype); + appendStringInfo(str, + " OPER :opno %u :opid %u :opresulttype %u ", + node->opno, + node->opid, + node->opresulttype); } /* @@ -790,12 +782,12 @@ _outOper(StringInfo str, Oper *node) static void _outParam(StringInfo str, Param *node) { - appendStringInfo(str, - " PARAM :paramkind %d :paramid %d :paramname %s :paramtype %u ", - node->paramkind, - node->paramid, - stringStringInfo(node->paramname), - node->paramtype); + appendStringInfo(str, + " PARAM :paramkind %d :paramid %d :paramname %s :paramtype %u ", + node->paramkind, + node->paramid, + stringStringInfo(node->paramname), + node->paramtype); appendStringInfo(str, " :param_tlist "); _outNode(str, node->param_tlist); @@ -811,31 +803,31 @@ _outParam(StringInfo str, Param *node) static void _outEState(StringInfo str, EState *node) { - appendStringInfo(str, - " ESTATE :direction %d :range_table ", - node->es_direction); + appendStringInfo(str, + " ESTATE :direction %d :range_table ", + node->es_direction); _outNode(str, node->es_range_table); appendStringInfo(str, " :result_relation_info @ 0x%x ", - (int) (node->es_result_relation_info)); + (int) (node->es_result_relation_info)); } /* * Stuff from relation.h */ static void -_outRelOptInfo(StringInfo str, RelOptInfo *node) +_outRelOptInfo(StringInfo str, RelOptInfo * node) { appendStringInfo(str, " RELOPTINFO :relids "); _outIntList(str, node->relids); - appendStringInfo(str, - " :indexed %s :pages %u :tuples %u :size %u :width %u :targetlist ", - node->indexed ? "true" : "false", - node->pages, - node->tuples, - node->size, - node->width); + appendStringInfo(str, + " :indexed %s :pages %u :tuples %u :size %u :width %u :targetlist ", + node->indexed ? "true" : "false", + node->pages, + node->tuples, + node->size, + node->width); _outNode(str, node->targetlist); appendStringInfo(str, " :pathlist "); @@ -847,10 +839,10 @@ _outRelOptInfo(StringInfo str, RelOptInfo *node) * This can be changed later, if necessary. */ - appendStringInfo(str, - " :cheapestpath @ 0x%x :pruneable %s :restrictinfo ", - (int) node->cheapestpath, - node->pruneable ? "true" : "false"); + appendStringInfo(str, + " :cheapestpath @ 0x%x :pruneable %s :restrictinfo ", + (int) node->cheapestpath, + node->pruneable ? "true" : "false"); _outNode(str, node->restrictinfo); appendStringInfo(str, " :joininfo "); @@ -876,18 +868,18 @@ _outTargetEntry(StringInfo str, TargetEntry *node) static void _outRangeTblEntry(StringInfo str, RangeTblEntry *node) { - appendStringInfo(str, - " RTE :relname %s :refname %s :relid %u :inh %s :inFromCl %s :skipAcl %s", - stringStringInfo(node->relname), - stringStringInfo(node->refname), - node->relid, - node->inh ? "true" : "false", - node->inFromCl ? "true" : "false", - node->skipAcl ? "true" : "false"); + appendStringInfo(str, + " RTE :relname %s :refname %s :relid %u :inh %s :inFromCl %s :skipAcl %s", + stringStringInfo(node->relname), + stringStringInfo(node->refname), + node->relid, + node->inh ? "true" : "false", + node->inFromCl ? "true" : "false", + node->skipAcl ? "true" : "false"); } static void -_outRowMark(StringInfo str, RowMark *node) +_outRowMark(StringInfo str, RowMark * node) { appendStringInfo(str, " ROWMARK :rti %u :info %u", node->rti, node->info); } @@ -899,17 +891,17 @@ static void _outPathOrder(StringInfo str, PathOrder *node) { appendStringInfo(str, " PATHORDER :ordtype %d ", - node->ordtype); + node->ordtype); if (node->ordtype == SORTOP_ORDER) { - int i; - + int i; + appendStringInfo(str, " :sortop "); if (node->ord.sortop == NULL) appendStringInfo(str, "<>"); else { - for (i=0; node->ord.sortop[i] != 0; i++) + for (i = 0; node->ord.sortop[i] != 0; i++) appendStringInfo(str, " %d ", node->ord.sortop[i]); appendStringInfo(str, " %d ", 0); } @@ -917,7 +909,7 @@ _outPathOrder(StringInfo str, PathOrder *node) else { appendStringInfo(str, " :merge "); - _outNode(str,node->ord.merge); + _outNode(str, node->ord.merge); } } @@ -928,8 +920,8 @@ static void _outPath(StringInfo str, Path *node) { appendStringInfo(str, " PATH :pathtype %d :cost %f :pathkeys ", - node->pathtype, - node->path_cost); + node->pathtype, + node->path_cost); _outNode(str, node->pathkeys); appendStringInfo(str, " :pathorder "); @@ -942,10 +934,10 @@ _outPath(StringInfo str, Path *node) static void _outIndexPath(StringInfo str, IndexPath *node) { - appendStringInfo(str, - " INDEXPATH :pathtype %d :cost %f :pathkeys ", - node->path.pathtype, - node->path.path_cost); + appendStringInfo(str, + " INDEXPATH :pathtype %d :cost %f :pathkeys ", + node->path.pathtype, + node->path.path_cost); _outNode(str, node->path.pathkeys); appendStringInfo(str, " :pathorder "); @@ -962,17 +954,17 @@ _outIndexPath(StringInfo str, IndexPath *node) * NestPath is a subclass of Path */ static void -_outNestPath(StringInfo str, NestPath *node) +_outNestPath(StringInfo str, NestPath * node) { - appendStringInfo(str, - " NESTPATH :pathtype %d :cost %f :pathkeys ", - node->path.pathtype, - node->path.path_cost); + appendStringInfo(str, + " NESTPATH :pathtype %d :cost %f :pathkeys ", + node->path.pathtype, + node->path.path_cost); _outNode(str, node->path.pathkeys); appendStringInfo(str, " :pathorder "); _outNode(str, node->path.pathorder); - + appendStringInfo(str, " :pathinfo "); _outNode(str, node->pathinfo); @@ -981,11 +973,11 @@ _outNestPath(StringInfo str, NestPath *node) * For now, i'll just print the addresses. */ - appendStringInfo(str, - " :outerjoinpath @ 0x%x :innerjoinpath @ 0x%x :outjoincost %f :joinid ", - (int) node->outerjoinpath, - (int) node->innerjoinpath, - node->path.outerjoincost); + appendStringInfo(str, + " :outerjoinpath @ 0x%x :innerjoinpath @ 0x%x :outjoincost %f :joinid ", + (int) node->outerjoinpath, + (int) node->innerjoinpath, + node->path.outerjoincost); _outIntList(str, node->path.joinid); } @@ -995,15 +987,15 @@ _outNestPath(StringInfo str, NestPath *node) static void _outMergePath(StringInfo str, MergePath *node) { - appendStringInfo(str, - " MERGEPATH :pathtype %d :cost %f :pathkeys ", - node->jpath.path.pathtype, - node->jpath.path.path_cost); + appendStringInfo(str, + " MERGEPATH :pathtype %d :cost %f :pathkeys ", + node->jpath.path.pathtype, + node->jpath.path.path_cost); _outNode(str, node->jpath.path.pathkeys); appendStringInfo(str, " :pathorder "); _outNode(str, node->jpath.path.pathorder); - + appendStringInfo(str, " :pathinfo "); _outNode(str, node->jpath.pathinfo); @@ -1012,11 +1004,11 @@ _outMergePath(StringInfo str, MergePath *node) * For now, i'll just print the addresses. */ - appendStringInfo(str, - " :outerjoinpath @ 0x%x :innerjoinpath @ 0x%x :outerjoincost %f :joinid ", - (int) node->jpath.outerjoinpath, - (int) node->jpath.innerjoinpath, - (int) node->jpath.path.outerjoincost); + appendStringInfo(str, + " :outerjoinpath @ 0x%x :innerjoinpath @ 0x%x :outerjoincost %f :joinid ", + (int) node->jpath.outerjoinpath, + (int) node->jpath.innerjoinpath, + (int) node->jpath.path.outerjoincost); _outIntList(str, node->jpath.path.joinid); appendStringInfo(str, " :path_mergeclauses "); @@ -1035,10 +1027,10 @@ _outMergePath(StringInfo str, MergePath *node) static void _outHashPath(StringInfo str, HashPath *node) { - appendStringInfo(str, - " HASHPATH :pathtype %d :cost %f :pathkeys ", - node->jpath.path.pathtype, - node->jpath.path.path_cost); + appendStringInfo(str, + " HASHPATH :pathtype %d :cost %f :pathkeys ", + node->jpath.path.pathtype, + node->jpath.path.path_cost); _outNode(str, node->jpath.path.pathkeys); appendStringInfo(str, " :pathorder "); @@ -1052,11 +1044,11 @@ _outHashPath(StringInfo str, HashPath *node) * For now, i'll just print the addresses. */ - appendStringInfo(str, - " :outerjoinpath @ 0x%x :innerjoinpath @ 0x%x :outerjoincost %f :joinid ", - (int) node->jpath.outerjoinpath, - (int) node->jpath.innerjoinpath, - node->jpath.path.outerjoincost); + appendStringInfo(str, + " :outerjoinpath @ 0x%x :innerjoinpath @ 0x%x :outerjoincost %f :joinid ", + (int) node->jpath.outerjoinpath, + (int) node->jpath.innerjoinpath, + node->jpath.path.outerjoincost); _outIntList(str, node->jpath.path.joinid); appendStringInfo(str, " :path_hashclauses "); @@ -1075,10 +1067,10 @@ _outHashPath(StringInfo str, HashPath *node) static void _outOrderKey(StringInfo str, OrderKey *node) { - appendStringInfo(str, - " ORDERKEY :attribute_number %d :array_index %d ", - node->attribute_number, - node->array_index); + appendStringInfo(str, + " ORDERKEY :attribute_number %d :array_index %d ", + node->attribute_number, + node->array_index); } /* @@ -1101,31 +1093,31 @@ _outJoinKey(StringInfo str, JoinKey *node) static void _outMergeOrder(StringInfo str, MergeOrder *node) { - appendStringInfo(str, - " MERGEORDER :join_operator %u :left_operator %u :right_operator %u ", - node->join_operator, - node->left_operator, - node->right_operator); + appendStringInfo(str, + " MERGEORDER :join_operator %u :left_operator %u :right_operator %u ", + node->join_operator, + node->left_operator, + node->right_operator); - appendStringInfo(str, - " :left_type %u :right_type %u ", - node->left_type, - node->right_type); + appendStringInfo(str, + " :left_type %u :right_type %u ", + node->left_type, + node->right_type); } /* * RestrictInfo is a subclass of Node. */ static void -_outRestrictInfo(StringInfo str, RestrictInfo *node) +_outRestrictInfo(StringInfo str, RestrictInfo * node) { appendStringInfo(str, " RESTRICTINFO :clause "); _outNode(str, node->clause); - appendStringInfo(str, - " :selectivity %f :notclause %s :indexids ", - node->selectivity, - node->notclause ? "true" : "false"); + appendStringInfo(str, + " :selectivity %f :notclause %s :indexids ", + node->selectivity, + node->notclause ? "true" : "false"); _outNode(str, node->indexids); appendStringInfo(str, " :mergejoinorder "); @@ -1152,7 +1144,7 @@ _outJoinMethod(StringInfo str, JoinMethod *node) * HashInfo is a subclass of JoinMethod. */ static void -_outHashInfo(StringInfo str, HashInfo *node) +_outHashInfo(StringInfo str, HashInfo * node) { appendStringInfo(str, " HASHINFO :hashop %u :jmkeys ", node->hashop); _outNode(str, node->jmethod.jmkeys); @@ -1165,7 +1157,7 @@ _outHashInfo(StringInfo str, HashInfo *node) * JoinInfo is a subclass of Node. */ static void -_outJoinInfo(StringInfo str, JoinInfo *node) +_outJoinInfo(StringInfo str, JoinInfo * node) { appendStringInfo(str, " JINFO :unjoined_relids "); _outIntList(str, node->unjoined_relids); @@ -1174,8 +1166,8 @@ _outJoinInfo(StringInfo str, JoinInfo *node) _outNode(str, node->jinfo_restrictinfo); appendStringInfo(str, " :mergejoinable %s :hashjoinable %s ", - node->mergejoinable ? "true" : "false", - node->hashjoinable ? "true" : "false"); + node->mergejoinable ? "true" : "false", + node->hashjoinable ? "true" : "false"); } /* @@ -1184,9 +1176,9 @@ _outJoinInfo(StringInfo str, JoinInfo *node) static void _outDatum(StringInfo str, Datum value, Oid type) { - char *s; + char *s; Size length, - typeLength; + typeLength; bool byValue; int i; @@ -1213,6 +1205,7 @@ _outDatum(StringInfo str, Datum value, Oid type) appendStringInfo(str, " 0 [ ] "); else { + /* * length is unsigned - very bad to do < comparison to -1 * without casting it to int first!! -mer 8 Jan 1991 @@ -1221,9 +1214,7 @@ _outDatum(StringInfo str, Datum value, Oid type) length = VARSIZE(s); appendStringInfo(str, " %d [ ", length); for (i = 0; i < length; i++) - { appendStringInfo(str, " %d ", (int) (s[i])); - } appendStringInfo(str, "] "); } } @@ -1239,19 +1230,19 @@ _outIter(StringInfo str, Iter *node) static void _outStream(StringInfo str, Stream *node) { - appendStringInfo(str, - " STREAM :pathptr @ 0x%x :cinfo @ 0x%x :clausetype %d :upstream @ 0x%x ", - (int) node->pathptr, - (int) node->cinfo, - (int) node->clausetype, - (int) node->upstream); + appendStringInfo(str, + " STREAM :pathptr @ 0x%x :cinfo @ 0x%x :clausetype %d :upstream @ 0x%x ", + (int) node->pathptr, + (int) node->cinfo, + (int) node->clausetype, + (int) node->upstream); - appendStringInfo(str, - " :downstream @ 0x%x :groupup %d :groupcost %f :groupsel %f ", - (int) node->downstream, - node->groupup, - node->groupcost, - node->groupsel); + appendStringInfo(str, + " :downstream @ 0x%x :groupup %d :groupcost %f :groupsel %f ", + (int) node->downstream, + node->groupup, + node->groupcost, + node->groupsel); } static void @@ -1289,7 +1280,7 @@ _outValue(StringInfo str, Value *value) { switch (value->type) { - case T_String: + case T_String: appendStringInfo(str, " \"%s\" ", stringStringInfo(value->val.str)); break; case T_Integer: @@ -1340,7 +1331,7 @@ _outAConst(StringInfo str, A_Const *node) static void _outConstraint(StringInfo str, Constraint *node) { - appendStringInfo(str," %s :type", stringStringInfo(node->name)); + appendStringInfo(str, " %s :type", stringStringInfo(node->name)); switch (node->contype) { @@ -1374,7 +1365,7 @@ _outConstraint(StringInfo str, Constraint *node) } static void -_outCaseExpr(StringInfo str, CaseExpr *node) +_outCaseExpr(StringInfo str, CaseExpr * node) { appendStringInfo(str, "CASE "); _outNode(str, node->args); @@ -1386,7 +1377,7 @@ _outCaseExpr(StringInfo str, CaseExpr *node) } static void -_outCaseWhen(StringInfo str, CaseWhen *node) +_outCaseWhen(StringInfo str, CaseWhen * node) { appendStringInfo(str, " WHEN "); _outNode(str, node->expr); @@ -1653,7 +1644,7 @@ _outNode(StringInfo str, void *obj) char * nodeToString(void *obj) { - StringInfoData str; + StringInfoData str; /* see stringinfo.h for an explanation of this maneuver */ initStringInfo(&str); diff --git a/src/backend/nodes/print.c b/src/backend/nodes/print.c index 97d3c46a8e..4e8f767bbf 100644 --- a/src/backend/nodes/print.c +++ b/src/backend/nodes/print.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/print.c,v 1.27 1999/05/10 00:45:13 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/print.c,v 1.28 1999/05/25 16:09:10 momjian Exp $ * * HISTORY * AUTHOR DATE MAJOR EVENT @@ -218,17 +218,19 @@ print_expr(Node *expr, List *rtable) void print_pathkeys(List *pathkeys, List *rtable) { - List *i, *k; + List *i, + *k; printf("("); foreach(i, pathkeys) { - List *pathkey = lfirst(i); + List *pathkey = lfirst(i); printf("("); foreach(k, pathkey) { Node *var = lfirst(k); + print_expr(var, rtable); if (lnext(k)) printf(", "); @@ -241,7 +243,7 @@ print_pathkeys(List *pathkeys, List *rtable) } /* - * print_tl + * print_tl * print targetlist in a more legible way. */ void diff --git a/src/backend/nodes/readfuncs.c b/src/backend/nodes/readfuncs.c index 82ccdd2dac..b5e8d94c93 100644 --- a/src/backend/nodes/readfuncs.c +++ b/src/backend/nodes/readfuncs.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.63 1999/05/18 21:34:29 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.64 1999/05/25 16:09:11 momjian Exp $ * * NOTES * Most of the read functions for plan nodes are tested. (In fact, they @@ -169,9 +169,9 @@ _readQuery() local_node->unionClause = nodeRead(true); /***S*I***/ - token = lsptok(NULL, &length); /* skip :intersectClause */ - local_node->intersectClause = nodeRead(true); - + token = lsptok(NULL, &length); /* skip :intersectClause */ + local_node->intersectClause = nodeRead(true); + token = lsptok(NULL, &length); /* skip :limitOffset */ local_node->limitOffset = nodeRead(true); @@ -544,7 +544,7 @@ _readIndexScan() local_node->indxqual = nodeRead(true); /* now read it */ token = lsptok(NULL, &length); /* eat :indxqualorig */ - local_node->indxqualorig = nodeRead(true); /* now read it */ + local_node->indxqualorig = nodeRead(true); /* now read it */ return local_node; } @@ -1407,7 +1407,7 @@ _readRangeTblEntry() static RowMark * _readRowMark() { - RowMark *local_node = makeNode(RowMark); + RowMark *local_node = makeNode(RowMark); char *token; int length; @@ -1431,7 +1431,7 @@ _readRowMark() static PathOrder * _readPathOrder() { - PathOrder *local_node; + PathOrder *local_node; char *token; int length; @@ -1443,17 +1443,18 @@ _readPathOrder() if (local_node->ordtype == SORTOP_ORDER) { - token = lsptok(NULL, &length); /* get :sortop */ + token = lsptok(NULL, &length); /* get :sortop */ if (length == 0) local_node->ord.sortop = NULL; else { - int i = -1; - - local_node->ord.sortop = palloc(sizeof(Oid) * (INDEX_MAX_KEYS+1)); - - do { + int i = -1; + + local_node->ord.sortop = palloc(sizeof(Oid) * (INDEX_MAX_KEYS + 1)); + + do + { i++; Assert(i <= INDEX_MAX_KEYS); token = lsptok(NULL, &length); /* now read it */ @@ -1463,7 +1464,7 @@ _readPathOrder() } else { - token = lsptok(NULL, &length); /* get :merge */ + token = lsptok(NULL, &length); /* get :merge */ local_node->ord.merge = nodeRead(true); /* now read it */ } @@ -1494,10 +1495,10 @@ _readPath() local_node->path_cost = (Cost) atof(token); token = lsptok(NULL, &length); /* get :pathorder */ - local_node->pathorder = nodeRead(true); /* now read it */ + local_node->pathorder = nodeRead(true); /* now read it */ token = lsptok(NULL, &length); /* get :pathkeys */ - local_node->pathkeys = nodeRead(true); /* now read it */ + local_node->pathkeys = nodeRead(true); /* now read it */ return local_node; } @@ -1526,10 +1527,10 @@ _readIndexPath() local_node->path.path_cost = (Cost) atof(token); token = lsptok(NULL, &length); /* get :pathorder */ - local_node->path.pathorder = nodeRead(true); /* now read it */ + local_node->path.pathorder = nodeRead(true); /* now read it */ token = lsptok(NULL, &length); /* get :pathkeys */ - local_node->path.pathkeys = nodeRead(true); /* now read it */ + local_node->path.pathkeys = nodeRead(true); /* now read it */ token = lsptok(NULL, &length); /* get :indexid */ local_node->indexid = toIntList(nodeRead(true)); @@ -1568,7 +1569,7 @@ _readNestPath() local_node->path.pathorder = nodeRead(true); /* now read it */ token = lsptok(NULL, &length); /* get :pathkeys */ - local_node->path.pathkeys = nodeRead(true); /* now read it */ + local_node->path.pathkeys = nodeRead(true); /* now read it */ token = lsptok(NULL, &length); /* get :pathinfo */ local_node->pathinfo = nodeRead(true); /* now read it */ @@ -1630,13 +1631,13 @@ _readMergePath() local_node->jpath.path.path_cost = (Cost) atof(token); token = lsptok(NULL, &length); /* get :pathorder */ - local_node->jpath.path.pathorder = nodeRead(true); /* now read it */ + local_node->jpath.path.pathorder = nodeRead(true); /* now read it */ token = lsptok(NULL, &length); /* get :pathkeys */ - local_node->jpath.path.pathkeys = nodeRead(true); /* now read it */ + local_node->jpath.path.pathkeys = nodeRead(true); /* now read it */ token = lsptok(NULL, &length); /* get :pathinfo */ - local_node->jpath.pathinfo = nodeRead(true); /* now read it */ + local_node->jpath.pathinfo = nodeRead(true); /* now read it */ /* * Not sure if these are nodes; they're declared as "struct path *". @@ -1664,7 +1665,7 @@ _readMergePath() local_node->jpath.path.outerjoincost = (Cost) atof(token); token = lsptok(NULL, &length); /* get :joinid */ - local_node->jpath.path.joinid = toIntList(nodeRead(true)); /* now read it */ + local_node->jpath.path.joinid = toIntList(nodeRead(true)); /* now read it */ token = lsptok(NULL, &length); /* get :path_mergeclauses */ local_node->path_mergeclauses = nodeRead(true); /* now read it */ @@ -1704,13 +1705,13 @@ _readHashPath() local_node->jpath.path.path_cost = (Cost) atof(token); token = lsptok(NULL, &length); /* get :pathorder */ - local_node->jpath.path.pathorder = nodeRead(true); /* now read it */ + local_node->jpath.path.pathorder = nodeRead(true); /* now read it */ token = lsptok(NULL, &length); /* get :pathkeys */ - local_node->jpath.path.pathkeys = nodeRead(true); /* now read it */ + local_node->jpath.path.pathkeys = nodeRead(true); /* now read it */ token = lsptok(NULL, &length); /* get :pathinfo */ - local_node->jpath.pathinfo = nodeRead(true); /* now read it */ + local_node->jpath.pathinfo = nodeRead(true); /* now read it */ /* * Not sure if these are nodes; they're declared as "struct path *". @@ -1738,7 +1739,7 @@ _readHashPath() local_node->jpath.path.outerjoincost = (Cost) atof(token); token = lsptok(NULL, &length); /* get :joinid */ - local_node->jpath.path.joinid = toIntList(nodeRead(true)); /* now read it */ + local_node->jpath.path.joinid = toIntList(nodeRead(true)); /* now read it */ token = lsptok(NULL, &length); /* get :path_hashclauses */ local_node->path_hashclauses = nodeRead(true); /* now read it */ @@ -1924,7 +1925,7 @@ _readJoinMethod() static HashInfo * _readHashInfo() { - HashInfo *local_node; + HashInfo *local_node; char *token; int length; @@ -1960,10 +1961,10 @@ _readJoinInfo() local_node = makeNode(JoinInfo); token = lsptok(NULL, &length); /* get :unjoined_relids */ - local_node->unjoined_relids = toIntList(nodeRead(true)); /* now read it */ + local_node->unjoined_relids = toIntList(nodeRead(true)); /* now read it */ token = lsptok(NULL, &length); /* get :jinfo_restrictinfo */ - local_node->jinfo_restrictinfo = nodeRead(true); /* now read it */ + local_node->jinfo_restrictinfo = nodeRead(true); /* now read it */ token = lsptok(NULL, &length); /* get :mergejoinable */ diff --git a/src/backend/optimizer/geqo/geqo_eval.c b/src/backend/optimizer/geqo/geqo_eval.c index 31a77f46e4..69d568dbc3 100644 --- a/src/backend/optimizer/geqo/geqo_eval.c +++ b/src/backend/optimizer/geqo/geqo_eval.c @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: geqo_eval.c,v 1.37 1999/05/17 00:25:34 tgl Exp $ + * $Id: geqo_eval.c,v 1.38 1999/05/25 16:09:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -56,7 +56,7 @@ static MemoryContext geqo_eval_context; /* * geqo_eval_startup: - * Must be called during geqo_main startup (before geqo_eval may be called) + * Must be called during geqo_main startup (before geqo_eval may be called) * * The main thing we need to do here is prepare a private memory context for * allocation of temp storage used while constructing a path in geqo_eval(). @@ -70,9 +70,10 @@ void geqo_eval_startup(void) { #define GEQO_PORTAL_NAME "" - Portal geqo_portal = GetPortalByName(GEQO_PORTAL_NAME); + Portal geqo_portal = GetPortalByName(GEQO_PORTAL_NAME); - if (!PortalIsValid(geqo_portal)) { + if (!PortalIsValid(geqo_portal)) + { /* First time through (within current transaction, that is) */ geqo_portal = CreatePortal(GEQO_PORTAL_NAME); Assert(PortalIsValid(geqo_portal)); @@ -89,15 +90,18 @@ geqo_eval_startup(void) Cost geqo_eval(Query *root, Gene *tour, int num_gene) { - MemoryContext oldcxt; - RelOptInfo *joinrel; - Cost fitness; - List *savelist; + MemoryContext oldcxt; + RelOptInfo *joinrel; + Cost fitness; + List *savelist; /* preserve root->join_rel_list, which gimme_tree changes */ savelist = root->join_rel_list; - /* create a temporary allocation context for the path construction work */ + /* + * create a temporary allocation context for the path construction + * work + */ oldcxt = MemoryContextSwitchTo(geqo_eval_context); StartPortalAllocMode(DefaultAllocMode, 0); @@ -118,7 +122,7 @@ geqo_eval(Query *root, Gene *tour, int num_gene) } /* - * gimme_tree + * gimme_tree * this program presumes that only LEFT-SIDED TREES are considered! * * 'old_rel' is the preceding join @@ -126,7 +130,7 @@ geqo_eval(Query *root, Gene *tour, int num_gene) * Returns a new join relation incorporating all joins in a left-sided tree. */ RelOptInfo * -gimme_tree(Query *root, Gene *tour, int rel_count, int num_gene, RelOptInfo *old_rel) +gimme_tree(Query *root, Gene *tour, int rel_count, int num_gene, RelOptInfo * old_rel) { RelOptInfo *inner_rel; /* current relation */ int base_rel_index; @@ -139,7 +143,7 @@ gimme_tree(Query *root, Gene *tour, int rel_count, int num_gene, RelOptInfo *old /* tour[0] = 3; tour[1] = 1; tour[2] = 2 */ base_rel_index = (int) tour[rel_count]; - inner_rel = (RelOptInfo *) nth(base_rel_index-1, root->base_rel_list); + inner_rel = (RelOptInfo *) nth(base_rel_index - 1, root->base_rel_list); if (rel_count == 0) { /* processing first join with @@ -151,15 +155,17 @@ gimme_tree(Query *root, Gene *tour, int rel_count, int num_gene, RelOptInfo *old { /* tree main part */ if (!(new_rels = make_rels_by_clause_joins(root, old_rel, old_rel->joininfo, - inner_rel->relids))) + inner_rel->relids))) { new_rels = make_rels_by_clauseless_joins(old_rel, - lcons(inner_rel,NIL)); - /* we don't do bushy plans in geqo, do we? bjm 02/18/1999 - new_rels = append(new_rels, - make_rels_by_clauseless_joins(old_rel, - lcons(old_rel,NIL)); - */ + lcons(inner_rel, NIL)); + + /* + * we don't do bushy plans in geqo, do we? bjm 02/18/1999 + * new_rels = append(new_rels, + * make_rels_by_clauseless_joins(old_rel, + * lcons(old_rel,NIL)); + */ } /* process new_rel->pathlist */ @@ -202,5 +208,5 @@ gimme_tree(Query *root, Gene *tour, int rel_count, int num_gene, RelOptInfo *old } } - return old_rel; /* tree finished ... */ + return old_rel; /* tree finished ... */ } diff --git a/src/backend/optimizer/geqo/geqo_main.c b/src/backend/optimizer/geqo/geqo_main.c index 2cedda675b..88bcce1ed7 100644 --- a/src/backend/optimizer/geqo/geqo_main.c +++ b/src/backend/optimizer/geqo/geqo_main.c @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: geqo_main.c,v 1.15 1999/05/17 00:25:33 tgl Exp $ + * $Id: geqo_main.c,v 1.16 1999/05/25 16:09:16 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -77,24 +77,28 @@ geqo(Query *root) status_interval; Gene *best_tour; RelOptInfo *best_rel; + #if defined(ERX) Edge *edge_table; /* list of edges */ int edge_failures = 0; float difference; + #endif #if defined(CX) || defined(PX) || defined(OX1) || defined(OX2) City *city_table; /* list of cities */ + #endif #if defined(CX) int cycle_diffs = 0; int mutations = 0; + #endif /* set tour size */ number_of_rels = length(root->base_rel_list); /* set GA parameters */ - geqo_params(number_of_rels); /* read "$PGDATA/pg_geqo" file */ + geqo_params(number_of_rels);/* read "$PGDATA/pg_geqo" file */ pool_size = PoolSize; number_generations = Generations; status_interval = 10; diff --git a/src/backend/optimizer/geqo/geqo_misc.c b/src/backend/optimizer/geqo/geqo_misc.c index adb4255c89..dd4320a3d4 100644 --- a/src/backend/optimizer/geqo/geqo_misc.c +++ b/src/backend/optimizer/geqo/geqo_misc.c @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: geqo_misc.c,v 1.17 1999/02/13 23:16:09 momjian Exp $ + * $Id: geqo_misc.c,v 1.18 1999/05/25 16:09:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -261,7 +261,7 @@ geqo_print_path(Query *root, Path *path, int indent) } void -geqo_print_rel(Query *root, RelOptInfo *rel) +geqo_print_rel(Query *root, RelOptInfo * rel) { List *l; diff --git a/src/backend/optimizer/geqo/geqo_pool.c b/src/backend/optimizer/geqo/geqo_pool.c index f8530ef4ef..c01073e614 100644 --- a/src/backend/optimizer/geqo/geqo_pool.c +++ b/src/backend/optimizer/geqo/geqo_pool.c @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: geqo_pool.c,v 1.11 1999/02/13 23:16:12 momjian Exp $ + * $Id: geqo_pool.c,v 1.12 1999/05/25 16:09:18 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -109,7 +109,7 @@ random_init_pool(Query *root, Pool *pool, int strt, int stp) * "geqo_recombination.c" * */ - pool->data[i].worth = geqo_eval(root, chromo[i].string, pool->string_length); /* "from geqo_eval.c" */ + pool->data[i].worth = geqo_eval(root, chromo[i].string, pool->string_length); /* "from geqo_eval.c" */ } } diff --git a/src/backend/optimizer/geqo/minspantree.c b/src/backend/optimizer/geqo/minspantree.c index daf8a459e3..c49f135ce2 100644 --- a/src/backend/optimizer/geqo/minspantree.c +++ b/src/backend/optimizer/geqo/minspantree.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION -* $Header: /cvsroot/pgsql/src/backend/optimizer/geqo/Attic/minspantree.c,v 1.10 1999/02/13 23:16:13 momjian Exp $ +* $Header: /cvsroot/pgsql/src/backend/optimizer/geqo/Attic/minspantree.c,v 1.11 1999/05/25 16:09:19 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -41,7 +41,7 @@ */ void -minspantree(Query *root, List *join_rels, RelOptInfo *garel) +minspantree(Query *root, List *join_rels, RelOptInfo * garel) { int number_of_rels = length(root->base_rel_list); int number_of_joins = length(join_rels); diff --git a/src/backend/optimizer/path/_deadcode/predmig.c b/src/backend/optimizer/path/_deadcode/predmig.c index 058b89780d..a27b61fb62 100644 --- a/src/backend/optimizer/path/_deadcode/predmig.c +++ b/src/backend/optimizer/path/_deadcode/predmig.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/_deadcode/Attic/predmig.c,v 1.1 1999/02/18 19:58:53 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/_deadcode/Attic/predmig.c,v 1.2 1999/05/25 16:09:30 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -257,7 +257,7 @@ xfunc_llel_chains(Stream root, Stream bottom) */ Assert(xfunc_num_relids(pathstream) > xfunc_num_relids(tmpstream)); progress = xfunc_prdmig_pullup(origstream, tmpstream, - (JoinPath) get_pathptr(pathstream)); + (JoinPath) get_pathptr(pathstream)); } if (get_downstream(tmpstream)) pathstream = (Stream) xfunc_get_downjoin((Stream) get_downstream(tmpstream)); @@ -269,7 +269,7 @@ xfunc_llel_chains(Stream root, Stream bottom) } /* - ** xfunc_complete_stream + ** xfunc_complete_stream ** Given a stream composed of join nodes only, make a copy containing the ** join nodes along with the associated restriction nodes. */ @@ -313,7 +313,7 @@ xfunc_complete_stream(Stream stream) static bool xfunc_prdmig_pullup(Stream origstream, Stream pullme, JoinPath joinpath) { - RestrictInfo restrictinfo = get_cinfo(pullme); + RestrictInfo restrictinfo = get_cinfo(pullme); bool progress = false; Stream upjoin, orignode, @@ -347,10 +347,10 @@ xfunc_prdmig_pullup(Stream origstream, Stream pullme, JoinPath joinpath) else whichchild = INNER; restrictinfo = xfunc_pullup((Path) get_pathptr((Stream) get_downstream(upjoin)), - (JoinPath) get_pathptr(upjoin), - restrictinfo, - whichchild, - get_clausetype(orignode)); + (JoinPath) get_pathptr(upjoin), + restrictinfo, + whichchild, + get_clausetype(orignode)); set_pathptr(pullme, get_pathptr(upjoin)); /* pullme has been moved into locrestrictinfo */ set_clausetype(pullme, XFUNC_LOCPRD); @@ -390,7 +390,7 @@ xfunc_prdmig_pullup(Stream origstream, Stream pullme, JoinPath joinpath) } /* - ** xfunc_form_groups + ** xfunc_form_groups ** A group is a pair of stream nodes a,b such that a is constrained to ** precede b (for instance if a and b are both joins), but rank(a) > rank(b). ** In such a situation, Monma and Sidney prove that no clauses should end @@ -487,10 +487,10 @@ xfunc_form_groups(Query *queryInfo, Stream root, Stream bottom) } -/* ------------------- UTILITY FUNCTIONS ------------------------- */ +/* ------------------- UTILITY FUNCTIONS ------------------------- */ /* - ** xfunc_free_stream + ** xfunc_free_stream ** walk down a stream and pfree it */ static void @@ -525,7 +525,7 @@ xfunc_add_clauses(Stream current) foreach(temp, get_loc_restrictinfo((Path) get_pathptr(current))) { topnode = xfunc_streaminsert((RestrictInfo) lfirst(temp), topnode, - XFUNC_LOCPRD); + XFUNC_LOCPRD); } /* and add in the join clauses */ @@ -536,7 +536,7 @@ xfunc_add_clauses(Stream current) { if (!equal(get_clause((RestrictInfo) lfirst(temp)), primjoin)) topnode = xfunc_streaminsert((RestrictInfo) lfirst(temp), topnode, - XFUNC_JOINPRD); + XFUNC_JOINPRD); } } return topnode; @@ -623,7 +623,7 @@ xfunc_num_relids(Stream node) } /* - ** xfunc_get_downjoin + ** xfunc_get_downjoin ** Given a stream node, find the next lowest node which points to a ** join predicate or a scan node. */ @@ -642,7 +642,7 @@ xfunc_get_downjoin(Stream node) } /* - ** xfunc_get_upjoin + ** xfunc_get_upjoin ** same as above, but upwards. */ static StreamPtr @@ -660,7 +660,7 @@ xfunc_get_upjoin(Stream node) } /* - ** xfunc_stream_qsort + ** xfunc_stream_qsort ** Given a stream, sort by group rank the elements in the stream from the ** node "bottom" up. DESTRUCTIVELY MODIFIES STREAM! Returns new root. */ diff --git a/src/backend/optimizer/path/_deadcode/xfunc.c b/src/backend/optimizer/path/_deadcode/xfunc.c index f365cdcd1b..7ee1c3616c 100644 --- a/src/backend/optimizer/path/_deadcode/xfunc.c +++ b/src/backend/optimizer/path/_deadcode/xfunc.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/_deadcode/Attic/xfunc.c,v 1.2 1999/05/10 00:45:14 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/_deadcode/Attic/xfunc.c,v 1.3 1999/05/25 16:09:31 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -49,7 +49,7 @@ static int xfunc_card_unreferenced(Query *queryInfo, */ /* -** xfunc_trypullup +** xfunc_trypullup ** Preliminary pullup of predicates, to allow for maximal pruning. ** Given a relation, check each of its paths and see if you can ** pullup clauses from its inner and outer. @@ -59,7 +59,7 @@ void xfunc_trypullup(RelOptInfo rel) { LispValue y; /* list ptr */ - RestrictInfo maxcinfo; /* The RestrictInfo to pull up, as + RestrictInfo maxcinfo; /* The RestrictInfo to pull up, as * calculated by xfunc_shouldpull() */ JoinPath curpath; /* current path in list */ int progress; /* has progress been made this time @@ -81,7 +81,7 @@ xfunc_trypullup(RelOptInfo rel) { /* No, the following should NOT be '==' !! */ if (clausetype = xfunc_shouldpull((Path) get_innerjoinpath(curpath), - curpath, INNER, &maxcinfo)) + curpath, INNER, &maxcinfo)) { xfunc_pullup((Path) get_innerjoinpath(curpath), @@ -96,7 +96,7 @@ xfunc_trypullup(RelOptInfo rel) /* No, the following should NOT be '==' !! */ if (clausetype = xfunc_shouldpull((Path) get_outerjoinpath(curpath), - curpath, OUTER, &maxcinfo)) + curpath, OUTER, &maxcinfo)) { xfunc_pullup((Path) get_outerjoinpath(curpath), @@ -127,7 +127,7 @@ xfunc_trypullup(RelOptInfo rel) } /* - ** xfunc_shouldpull + ** xfunc_shouldpull ** find clause with highest rank, and decide whether to pull it up ** from child to parent. Currently we only pullup secondary join clauses ** that are in the pathrestrictinfo. Secondary hash and sort clauses are @@ -144,12 +144,12 @@ xfunc_shouldpull(Query *queryInfo, Path childpath, JoinPath parentpath, int whichchild, - RestrictInfo *maxcinfopt) /* Out: pointer to clause + RestrictInfo * maxcinfopt) /* Out: pointer to clause * to pullup */ { LispValue clauselist, tmplist; /* lists of clauses */ - RestrictInfo maxcinfo; /* clause to pullup */ + RestrictInfo maxcinfo; /* clause to pullup */ LispValue primjoinclause /* primary join clause */ = xfunc_primary_join(parentpath); Cost tmprank, @@ -225,7 +225,7 @@ xfunc_shouldpull(Query *queryInfo, || (!is_join(childpath) && (whichchild == INNER) && IsA(parentpath, NestPath) - &&!IsA(parentpath, HashPath) + && !IsA(parentpath, HashPath) &&!IsA(parentpath, MergePath))))) { @@ -250,7 +250,7 @@ xfunc_shouldpull(Query *queryInfo, /* - ** xfunc_pullup + ** xfunc_pullup ** move clause from child pathnode to parent pathnode. This operation ** makes the child pathnode produce a larger relation than it used to. ** This means that we must construct a new RelOptInfo just for the childpath, @@ -264,7 +264,7 @@ RestrictInfo xfunc_pullup(Query *queryInfo, Path childpath, JoinPath parentpath, - RestrictInfo cinfo, /* clause to pull up */ + RestrictInfo cinfo,/* clause to pull up */ int whichchild, /* whether child is INNER or OUTER of join */ int clausetype) /* whether clause to pull is join or local */ { @@ -272,22 +272,22 @@ xfunc_pullup(Query *queryInfo, RelOptInfo newrel; Cost pulled_selec; Cost cost; - RestrictInfo newinfo; + RestrictInfo newinfo; /* remove clause from childpath */ newkid = (Path) copyObject((Node) childpath); if (clausetype == XFUNC_LOCPRD) { set_locrestrictinfo(newkid, - xfunc_LispRemove((LispValue) cinfo, - (List) get_loc_restrictinfo(newkid))); + xfunc_LispRemove((LispValue) cinfo, + (List) get_loc_restrictinfo(newkid))); } else { set_pathrestrictinfo ((JoinPath) newkid, xfunc_LispRemove((LispValue) cinfo, - (List) get_pathrestrictinfo((JoinPath) newkid))); + (List) get_pathrestrictinfo((JoinPath) newkid))); } /* @@ -328,8 +328,8 @@ xfunc_pullup(Query *queryInfo, /* add clause to parentpath, and fix up its cost. */ set_locrestrictinfo(parentpath, - lispCons((LispValue) newinfo, - (LispValue) get_loc_restrictinfo(parentpath))); + lispCons((LispValue) newinfo, + (LispValue) get_loc_restrictinfo(parentpath))); /* put new childpath into the path tree */ if (whichchild == INNER) set_innerjoinpath(parentpath, (pathPtr) newkid); @@ -386,7 +386,7 @@ LispValue clause; } /* - ** xfunc_join_expense + ** xfunc_join_expense ** Find global expense of a join clause */ Cost @@ -457,7 +457,7 @@ xfunc_local_expense(LispValue clause) } /* - ** xfunc_func_expense + ** xfunc_func_expense ** given a Func or Oper and its args, find its expense. ** Note: in Stonebraker's SIGMOD '91 paper, he uses a more complicated metric ** than the one here. We can ignore the expected number of tuples for @@ -581,7 +581,7 @@ xfunc_func_expense(LispValue node, LispValue args) } /* - ** xfunc_width + ** xfunc_width ** recursively find the width of a expression */ @@ -694,7 +694,7 @@ xfunc_width(LispValue clause) */ Assert(length(get_func_tlist(func)) == 1); /* sanity */ retval = xfunc_width((LispValue) - get_expr(lfirst(get_func_tlist(func)))); + get_expr(lfirst(get_func_tlist(func)))); goto exit; } else @@ -771,8 +771,8 @@ xfunc_card_product(Query *queryInfo, Relids relids) { if (!xfunc_expense(queryInfo, get_clause((RestrictInfo) lfirst(cinfonode)))) tuples *= compute_clause_selec(queryInfo, - get_clause((RestrictInfo) lfirst(cinfonode)), - LispNil); + get_clause((RestrictInfo) lfirst(cinfonode)), + LispNil); } if (retval == 0) @@ -857,7 +857,7 @@ LispValue xfunc_primary_join(JoinPath pathnode) { LispValue joinclauselist = get_pathrestrictinfo(pathnode); - RestrictInfo mincinfo; + RestrictInfo mincinfo; LispValue tmplist; LispValue minclause = LispNil; Cost minrank, @@ -931,7 +931,7 @@ xfunc_get_path_cost(Query *queryInfo, Path pathnode) */ if (XfuncMode != XFUNC_OFF) set_locrestrictinfo(pathnode, lisp_qsort(get_loc_restrictinfo(pathnode), - xfunc_cinfo_compare)); + xfunc_cinfo_compare)); for (tmplist = get_loc_restrictinfo(pathnode), selec = 1.0; tmplist != LispNil; tmplist = lnext(tmplist)) @@ -939,7 +939,7 @@ xfunc_get_path_cost(Query *queryInfo, Path pathnode) cost += (Cost) (xfunc_local_expense(get_clause((RestrictInfo) lfirst(tmplist))) * (Cost) get_tuples(get_parent(pathnode)) * selec); selec *= compute_clause_selec(queryInfo, - get_clause((RestrictInfo) lfirst(tmplist)), + get_clause((RestrictInfo) lfirst(tmplist)), LispNil); } @@ -951,8 +951,8 @@ xfunc_get_path_cost(Query *queryInfo, Path pathnode) { if (XfuncMode != XFUNC_OFF) set_pathrestrictinfo((JoinPath) pathnode, lisp_qsort - (get_pathrestrictinfo((JoinPath) pathnode), - xfunc_cinfo_compare)); + (get_pathrestrictinfo((JoinPath) pathnode), + xfunc_cinfo_compare)); for (tmplist = get_pathrestrictinfo((JoinPath) pathnode), selec = 1.0; tmplist != LispNil; tmplist = lnext(tmplist)) @@ -960,7 +960,7 @@ xfunc_get_path_cost(Query *queryInfo, Path pathnode) cost += (Cost) (xfunc_local_expense(get_clause((RestrictInfo) lfirst(tmplist))) * (Cost) get_tuples(get_parent(pathnode)) * selec); selec *= compute_clause_selec(queryInfo, - get_clause((RestrictInfo) lfirst(tmplist)), + get_clause((RestrictInfo) lfirst(tmplist)), LispNil); } } @@ -1071,7 +1071,7 @@ xfunc_total_path_cost(JoinPath pathnode) /* - ** xfunc_expense_per_tuple + ** xfunc_expense_per_tuple ** return the expense of the join *per-tuple* of the input relation. ** The cost model here is that a join costs ** k*card(outer)*card(inner) + l*card(outer) + m*card(inner) + n @@ -1124,7 +1124,7 @@ xfunc_expense_per_tuple(JoinPath joinnode, int whichchild) } /* - ** xfunc_fixvars + ** xfunc_fixvars ** After pulling up a clause, we must walk its expression tree, fixing Var ** nodes to point to the correct varno (either INNER or OUTER, depending ** on which child the clause was pulled from), and the right varattno in the @@ -1189,8 +1189,8 @@ xfunc_fixvars(LispValue clause, /* clause being pulled up */ int xfunc_cinfo_compare(void *arg1, void *arg2) { - RestrictInfo info1 = *(RestrictInfo *) arg1; - RestrictInfo info2 = *(RestrictInfo *) arg2; + RestrictInfo info1 = *(RestrictInfo *) arg1; + RestrictInfo info2 = *(RestrictInfo *) arg2; LispValue clause1 = (LispValue) get_clause(info1), clause2 = (LispValue) get_clause(info2); @@ -1223,7 +1223,7 @@ xfunc_clause_compare(void *arg1, void *arg2) } /* - ** xfunc_disjunct_sort + ** xfunc_disjunct_sort ** given a list of clauses, for each clause sort the disjuncts by cost ** (this assumes the predicates have been converted to Conjunctive NF) ** Modifies the clause list! @@ -1287,7 +1287,7 @@ xfunc_disjunct_compare(Query *queryInfo, void *arg1, void *arg2) /* ------------------------ UTILITY FUNCTIONS ------------------------------- */ /* - ** xfunc_func_width + ** xfunc_func_width ** Given a function OID and operands, find the width of the return value. */ int @@ -1349,7 +1349,7 @@ exit: } /* - ** xfunc_tuple_width + ** xfunc_tuple_width ** Return the sum of the lengths of all the attributes of a given relation */ int @@ -1371,7 +1371,7 @@ xfunc_tuple_width(Relation rd) } /* - ** xfunc_num_join_clauses + ** xfunc_num_join_clauses ** Find the number of join clauses associated with this join path */ int @@ -1388,7 +1388,7 @@ xfunc_num_join_clauses(JoinPath path) } /* - ** xfunc_LispRemove + ** xfunc_LispRemove ** Just like LispRemove, but it whines if the item to be removed ain't there */ LispValue @@ -1419,11 +1419,11 @@ do { \ } while(0) /* - ** xfunc_copyrel + ** xfunc_copyrel ** Just like _copyRel, but doesn't copy the paths */ bool -xfunc_copyrel(RelOptInfo from, RelOptInfo *to) +xfunc_copyrel(RelOptInfo from, RelOptInfo * to) { RelOptInfo newnode; diff --git a/src/backend/optimizer/path/allpaths.c b/src/backend/optimizer/path/allpaths.c index ba421b4f5f..8ebcc5d479 100644 --- a/src/backend/optimizer/path/allpaths.c +++ b/src/backend/optimizer/path/allpaths.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.44 1999/02/22 05:26:18 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.45 1999/05/25 16:09:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -45,10 +45,10 @@ int32 _use_geqo_rels_ = GEQO_RELS; static void set_base_rel_pathlist(Query *root, List *rels); static RelOptInfo *make_one_rel_by_joins(Query *root, List *rels, - int levels_needed); + int levels_needed); #ifdef OPTIMIZER_DEBUG -static void debug_print_rel(Query *root, RelOptInfo *rel); +static void debug_print_rel(Query *root, RelOptInfo * rel); #endif @@ -76,6 +76,7 @@ make_one_rel(Query *root, List *rels) if (levels_needed <= 1) { + /* * Unsorted single relation, no more processing is required. */ @@ -83,6 +84,7 @@ make_one_rel(Query *root, List *rels) } else { + /* * This means that joins or sorts are required. set selectivities * of clauses that have not been set by an index. @@ -117,17 +119,17 @@ set_base_rel_pathlist(Query *root, List *rels) sequential_scan_list = lcons(create_seqscan_path(rel), NIL); rel_index_scan_list = create_index_paths(root, - rel, - find_relation_indices(root, rel), - rel->restrictinfo, - rel->joininfo); + rel, + find_relation_indices(root, rel), + rel->restrictinfo, + rel->joininfo); or_index_scan_list = create_or_index_paths(root, rel, rel->restrictinfo); rel->pathlist = add_pathlist(rel, sequential_scan_list, nconc(rel_index_scan_list, - or_index_scan_list)); + or_index_scan_list)); set_cheapest(rel, rel->pathlist); @@ -171,13 +173,14 @@ make_one_rel_by_joins(Query *root, List *rels, int levels_needed) *******************************************/ if ((_use_geqo_) && length(root->base_rel_list) >= _use_geqo_rels_) return geqo(root); - + /******************************************* * rest will be deprecated in case of GEQO * *******************************************/ while (--levels_needed) { + /* * Determine all possible pairs of relations to be joined at this * level. Determine paths for joining these relation pairs and @@ -193,6 +196,7 @@ make_one_rel_by_joins(Query *root, List *rels, int levels_needed) root->join_rel_list = rels = joined_rels; #ifdef NOT_USED + /* * * for each expensive predicate in each path in each distinct * rel, * consider doing pullup -- JMH @@ -351,7 +355,7 @@ print_path(Query *root, Path *path, int indent) } static void -debug_print_rel(Query *root, RelOptInfo *rel) +debug_print_rel(Query *root, RelOptInfo * rel) { List *l; diff --git a/src/backend/optimizer/path/clausesel.c b/src/backend/optimizer/path/clausesel.c index 1eeae4c6d3..bbc9e3547e 100644 --- a/src/backend/optimizer/path/clausesel.c +++ b/src/backend/optimizer/path/clausesel.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/clausesel.c,v 1.19 1999/05/16 19:45:37 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/clausesel.c,v 1.20 1999/05/25 16:09:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -132,7 +132,7 @@ set_rest_selec(Query *root, List *restrictinfo_list) if (cost_clause <= 0 || valid_or_clause(clausenode)) { clausenode->selectivity = compute_clause_selec(root, - (Node *) clausenode->clause, + (Node *) clausenode->clause, lcons(makeFloat(cost_clause), NIL)); } } @@ -256,7 +256,7 @@ compute_selec(Query *root, List *clauses, List *or_selectivities) else if (not_clause((Node *) clause)) { /* negate this baby */ - return 1 - compute_selec(root, ((Expr *)clause)->args, or_selectivities); + return 1 - compute_selec(root, ((Expr *) clause)->args, or_selectivities); } else if (is_subplan((Node *) clause)) { diff --git a/src/backend/optimizer/path/costsize.c b/src/backend/optimizer/path/costsize.c index 22eb4d3e53..327f58cf32 100644 --- a/src/backend/optimizer/path/costsize.c +++ b/src/backend/optimizer/path/costsize.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.36 1999/05/01 19:47:41 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.37 1999/05/25 16:09:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -37,7 +37,7 @@ extern int NBuffers; static int compute_attribute_width(TargetEntry *tlistentry); -static double relation_byte_size (int tuples, int width); +static double relation_byte_size(int tuples, int width); static double base_log(double x, double b); static int compute_targetlist_width(List *targetlist); @@ -134,9 +134,10 @@ cost_index(Oid indexid, if (!_enable_indexscan_ && !is_injoin) temp += _disable_cost_; - /* We want to be sure we estimate the cost of an index scan - * as more than the cost of a sequential scan (when selec == 1.0), - * even if we don't have good stats. So, disbelieve zero index size. + /* + * We want to be sure we estimate the cost of an index scan as more + * than the cost of a sequential scan (when selec == 1.0), even if we + * don't have good stats. So, disbelieve zero index size. */ if (expected_indexpages <= 0) expected_indexpages = 1; @@ -146,11 +147,11 @@ cost_index(Oid indexid, /* expected index relation pages */ temp += expected_indexpages; - /* expected base relation pages - * XXX this isn't really right, since we will access the table - * nonsequentially and might have to fetch the same page - * more than once. This calculation assumes the buffer cache - * will prevent that from happening... + /* + * expected base relation pages XXX this isn't really right, since we + * will access the table nonsequentially and might have to fetch the + * same page more than once. This calculation assumes the buffer + * cache will prevent that from happening... */ temp += ceil(((double) selec) * ((double) relpages)); @@ -192,8 +193,10 @@ cost_sort(List *pathkeys, int tuples, int width) if (!_enable_sort_) temp += _disable_cost_; - /* We want to be sure the cost of a sort is never estimated as zero, - * even if passed-in tuple count is zero. Besides, mustn't do log(0)... + /* + * We want to be sure the cost of a sort is never estimated as zero, + * even if passed-in tuple count is zero. Besides, mustn't do + * log(0)... */ if (tuples <= 0) tuples = 1; @@ -344,10 +347,11 @@ cost_hashjoin(Cost outercost, if (!_enable_hashjoin_) temp += _disable_cost_; - /* Bias against putting larger relation on inside. + /* + * Bias against putting larger relation on inside. * - * Code used to use "outerpages < innerpages" but that has - * poor resolution when both relations are small. + * Code used to use "outerpages < innerpages" but that has poor + * resolution when both relations are small. */ if (relation_byte_size(outersize, outerwidth) < relation_byte_size(innersize, innerwidth)) @@ -362,7 +366,8 @@ cost_hashjoin(Cost outercost, /* cost of main-memory hashtable */ temp += (innerpages < NBuffers) ? innerpages : NBuffers; - /* if inner relation is too big then we will need to "batch" the join, + /* + * if inner relation is too big then we will need to "batch" the join, * which implies writing and reading most of the tuples to disk an * extra time. */ @@ -385,7 +390,7 @@ cost_hashjoin(Cost outercost, * Returns the size. */ int -compute_rel_size(RelOptInfo *rel) +compute_rel_size(RelOptInfo * rel) { Cost temp; int temp1; @@ -408,7 +413,7 @@ compute_rel_size(RelOptInfo *rel) * Returns the width of the tuple as a fixnum. */ int -compute_rel_width(RelOptInfo *rel) +compute_rel_width(RelOptInfo * rel) { return compute_targetlist_width(get_actual_tlist(rel->targetlist)); } @@ -470,11 +475,11 @@ compute_joinrel_size(JoinPath *joinpath) temp *= ((Path *) joinpath->innerjoinpath)->parent->size; temp = temp * product_selec(joinpath->pathinfo); - if (temp >= (MAXINT-1)/2) + if (temp >= (MAXINT - 1) / 2) { /* if we exceed (MAXINT-1)/2, we switch to log scale */ /* +1 prevents log(0) */ - temp1 = ceil(log(temp + 1 - (MAXINT-1)/2) + (MAXINT-1)/2); + temp1 = ceil(log(temp + 1 - (MAXINT - 1) / 2) + (MAXINT - 1) / 2); } else temp1 = ceil((double) temp); @@ -485,13 +490,13 @@ compute_joinrel_size(JoinPath *joinpath) /* * relation_byte_size - * Estimate the storage space in bytes for a given number of tuples - * of a given width (size in bytes). - * To avoid overflow with big relations, result is a double. + * Estimate the storage space in bytes for a given number of tuples + * of a given width (size in bytes). + * To avoid overflow with big relations, result is a double. */ static double -relation_byte_size (int tuples, int width) +relation_byte_size(int tuples, int width) { return ((double) tuples) * ((double) (width + sizeof(HeapTupleData))); } diff --git a/src/backend/optimizer/path/hashutils.c b/src/backend/optimizer/path/hashutils.c index f67e4eb8ec..0d4b2326ba 100644 --- a/src/backend/optimizer/path/hashutils.c +++ b/src/backend/optimizer/path/hashutils.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/hashutils.c,v 1.15 1999/04/03 00:18:27 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/hashutils.c,v 1.16 1999/05/25 16:09:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -30,7 +30,7 @@ static HashInfo *match_hashop_hashinfo(Oid hashop, List *hashinfo_list); * * 'restrictinfo_list' is the list of restrictinfo nodes * 'inner_relids' is the list of relids in the inner join relation - * (used to determine whether a join var is inner or outer) + * (used to determine whether a join var is inner or outer) * * Returns the new list of hashinfo nodes. * @@ -84,7 +84,7 @@ group_clauses_by_hashop(List *restrictinfo_list, } xhashinfo->jmethod.clauses = lcons(clause, - xhashinfo->jmethod.clauses); + xhashinfo->jmethod.clauses); xhashinfo->jmethod.jmkeys = lcons(joinkey, xhashinfo->jmethod.jmkeys); } @@ -105,7 +105,7 @@ static HashInfo * match_hashop_hashinfo(Oid hashop, List *hashinfo_list) { Oid key = 0; - HashInfo *xhashinfo = (HashInfo *) NULL; + HashInfo *xhashinfo = (HashInfo *) NULL; List *i = NIL; foreach(i, hashinfo_list) diff --git a/src/backend/optimizer/path/indxpath.c b/src/backend/optimizer/path/indxpath.c index 84ef82f310..29694ed258 100644 --- a/src/backend/optimizer/path/indxpath.c +++ b/src/backend/optimizer/path/indxpath.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.54 1999/03/18 19:59:53 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.55 1999/05/25 16:09:24 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -45,32 +45,32 @@ #include "utils/lsyscache.h" -static void match_index_orclauses(RelOptInfo *rel, RelOptInfo *index, int indexkey, +static void match_index_orclauses(RelOptInfo * rel, RelOptInfo * index, int indexkey, int xclass, List *restrictinfo_list); static bool match_index_to_operand(int indexkey, Expr *operand, - RelOptInfo *rel, RelOptInfo *index); -static List *match_index_orclause(RelOptInfo *rel, RelOptInfo *index, int indexkey, + RelOptInfo * rel, RelOptInfo * index); +static List *match_index_orclause(RelOptInfo * rel, RelOptInfo * index, int indexkey, int xclass, List *or_clauses, List *other_matching_indices); -static List *group_clauses_by_indexkey(RelOptInfo *rel, RelOptInfo *index, - int *indexkeys, Oid *classes, List *restrictinfo_list); -static List *group_clauses_by_ikey_for_joins(RelOptInfo *rel, RelOptInfo *index, +static List *group_clauses_by_indexkey(RelOptInfo * rel, RelOptInfo * index, + int *indexkeys, Oid *classes, List *restrictinfo_list); +static List *group_clauses_by_ikey_for_joins(RelOptInfo * rel, RelOptInfo * index, int *indexkeys, Oid *classes, List *join_cinfo_list, List *restr_cinfo_list); -static RestrictInfo *match_clause_to_indexkey(RelOptInfo *rel, RelOptInfo *index, int indexkey, - int xclass, RestrictInfo *restrictInfo, bool join); +static RestrictInfo *match_clause_to_indexkey(RelOptInfo * rel, RelOptInfo * index, int indexkey, + int xclass, RestrictInfo * restrictInfo, bool join); static bool pred_test(List *predicate_list, List *restrictinfo_list, List *joininfo_list); static bool one_pred_test(Expr *predicate, List *restrictinfo_list); static bool one_pred_clause_expr_test(Expr *predicate, Node *clause); static bool one_pred_clause_test(Expr *predicate, Node *clause); static bool clause_pred_clause_test(Expr *predicate, Node *clause); -static List *indexable_joinclauses(RelOptInfo *rel, RelOptInfo *index, +static List *indexable_joinclauses(RelOptInfo * rel, RelOptInfo * index, List *joininfo_list, List *restrictinfo_list); -static List *index_innerjoin(Query *root, RelOptInfo *rel, - List *clausegroup_list, RelOptInfo *index); -static List *create_index_path_group(Query *root, RelOptInfo *rel, RelOptInfo *index, - List *clausegroup_list, bool join); +static List *index_innerjoin(Query *root, RelOptInfo * rel, + List *clausegroup_list, RelOptInfo * index); +static List *create_index_path_group(Query *root, RelOptInfo * rel, RelOptInfo * index, + List *clausegroup_list, bool join); static List *add_index_paths(List *indexpaths, List *new_indexpaths); -static bool function_index_operand(Expr *funcOpnd, RelOptInfo *rel, RelOptInfo *index); +static bool function_index_operand(Expr *funcOpnd, RelOptInfo * rel, RelOptInfo * index); /* find_index_paths() @@ -100,10 +100,10 @@ static bool function_index_operand(Expr *funcOpnd, RelOptInfo *rel, RelOptInfo * */ List * create_index_paths(Query *root, - RelOptInfo *rel, - List *indices, - List *restrictinfo_list, - List *joininfo_list) + RelOptInfo * rel, + List *indices, + List *restrictinfo_list, + List *joininfo_list) { List *scanclausegroups = NIL; List *scanpaths = NIL; @@ -127,11 +127,11 @@ create_index_paths(Query *root, /* * 1. Try matching the index against subclauses of an 'or' clause. - * The fields of the restrictinfo nodes are marked with lists of the - * matching indices. No path are actually created. We currently - * only look to match the first key. We don't find multi-key - * index cases where an AND matches the first key, and the OR - * matches the second key. + * The fields of the restrictinfo nodes are marked with lists of + * the matching indices. No path are actually created. We + * currently only look to match the first key. We don't find + * multi-key index cases where an AND matches the first key, and + * the OR matches the second key. */ match_index_orclauses(rel, index, @@ -144,7 +144,7 @@ create_index_paths(Query *root, * restriction clauses, then create pathnodes corresponding to * each group of usable clauses. */ - scanclausegroups = group_clauses_by_indexkey(rel, + scanclausegroups = group_clauses_by_indexkey(rel, index, index->indexkeys, index->classlist, @@ -153,10 +153,10 @@ create_index_paths(Query *root, scanpaths = NIL; if (scanclausegroups != NIL) scanpaths = create_index_path_group(root, - rel, - index, - scanclausegroups, - false); + rel, + index, + scanclausegroups, + false); /* * 3. If this index can be used with any join clause, then create @@ -171,12 +171,12 @@ create_index_paths(Query *root, if (joinclausegroups != NIL) { joinpaths = create_index_path_group(root, rel, - index, - joinclausegroups, - true); + index, + joinclausegroups, + true); rel->innerjoin = nconc(rel->innerjoin, index_innerjoin(root, rel, - joinclausegroups, index)); + joinclausegroups, index)); } /* @@ -217,8 +217,8 @@ create_index_paths(Query *root, * */ static void -match_index_orclauses(RelOptInfo *rel, - RelOptInfo *index, +match_index_orclauses(RelOptInfo * rel, + RelOptInfo * index, int indexkey, int xclass, List *restrictinfo_list) @@ -238,9 +238,9 @@ match_index_orclauses(RelOptInfo *rel, * 'index' to the existing list where appropriate. */ restrictinfo->indexids = match_index_orclause(rel, index, indexkey, - xclass, - restrictinfo->clause->args, - restrictinfo->indexids); + xclass, + restrictinfo->clause->args, + restrictinfo->indexids); } } } @@ -253,8 +253,8 @@ match_index_orclauses(RelOptInfo *rel, static bool match_index_to_operand(int indexkey, Expr *operand, - RelOptInfo *rel, - RelOptInfo *index) + RelOptInfo * rel, + RelOptInfo * index) { bool result; @@ -296,8 +296,8 @@ match_index_to_operand(int indexkey, * match the third, g,h match the fourth, etc. */ static List * -match_index_orclause(RelOptInfo *rel, - RelOptInfo *index, +match_index_orclause(RelOptInfo * rel, + RelOptInfo * index, int indexkey, int xclass, List *or_clauses, @@ -325,8 +325,9 @@ match_index_orclause(RelOptInfo *rel, if (is_opclause(clause)) { - Expr *left = (Expr *) get_leftop((Expr *) clause); - Expr *right = (Expr *) get_rightop((Expr *) clause); + Expr *left = (Expr *) get_leftop((Expr *) clause); + Expr *right = (Expr *) get_rightop((Expr *) clause); + if (left && right && op_class(((Oper *) ((Expr *) clause)->oper)->opno, xclass, index->relam) && @@ -335,7 +336,7 @@ match_index_orclause(RelOptInfo *rel, (IsA(left, Const) && match_index_to_operand(indexkey, right, rel, index)))) lfirst(matching_indices) = lcons(index, - lfirst(matching_indices)); + lfirst(matching_indices)); } matching_indices = lnext(matching_indices); @@ -386,8 +387,8 @@ match_index_orclause(RelOptInfo *rel, * */ static List * -group_clauses_by_indexkey(RelOptInfo *rel, - RelOptInfo *index, +group_clauses_by_indexkey(RelOptInfo * rel, + RelOptInfo * index, int *indexkeys, Oid *classes, List *restrictinfo_list) @@ -448,8 +449,8 @@ group_clauses_by_indexkey(RelOptInfo *rel, * */ static List * -group_clauses_by_ikey_for_joins(RelOptInfo *rel, - RelOptInfo *index, +group_clauses_by_ikey_for_joins(RelOptInfo * rel, + RelOptInfo * index, int *indexkeys, Oid *classes, List *join_cinfo_list, @@ -570,11 +571,11 @@ group_clauses_by_ikey_for_joins(RelOptInfo *rel, * */ static RestrictInfo * -match_clause_to_indexkey(RelOptInfo *rel, - RelOptInfo *index, +match_clause_to_indexkey(RelOptInfo * rel, + RelOptInfo * index, int indexkey, int xclass, - RestrictInfo *restrictInfo, + RestrictInfo * restrictInfo, bool join) { Expr *clause = restrictInfo->clause; @@ -597,6 +598,7 @@ match_clause_to_indexkey(RelOptInfo *rel, */ if (!join) { + /* * Check for standard s-argable clause */ @@ -647,10 +649,10 @@ match_clause_to_indexkey(RelOptInfo *rel, restrict_op = oprid(newop); isIndexable = (op_class(restrict_op, xclass, index->relam) && - IndexScanableOperand(leftop, - indexkey, - rel, - index)); + IndexScanableOperand(leftop, + indexkey, + rel, + index)); if (isIndexable) ((Oper *) ((Expr *) clause)->oper)->opno = restrict_op; @@ -1181,7 +1183,7 @@ clause_pred_clause_test(Expr *predicate, Node *clause) * */ static List * -indexable_joinclauses(RelOptInfo *rel, RelOptInfo *index, +indexable_joinclauses(RelOptInfo * rel, RelOptInfo * index, List *joininfo_list, List *restrictinfo_list) { JoinInfo *joininfo = (JoinInfo *) NULL; @@ -1196,11 +1198,11 @@ indexable_joinclauses(RelOptInfo *rel, RelOptInfo *index, if (joininfo->jinfo_restrictinfo == NIL) continue; clausegroups = group_clauses_by_ikey_for_joins(rel, - index, - index->indexkeys, - index->classlist, + index, + index->indexkeys, + index->classlist, joininfo->jinfo_restrictinfo, - restrictinfo_list); + restrictinfo_list); if (clausegroups != NIL) { @@ -1253,8 +1255,8 @@ extract_restrict_clauses(List *clausegroup) * */ static List * -index_innerjoin(Query *root, RelOptInfo *rel, List *clausegroup_list, - RelOptInfo *index) +index_innerjoin(Query *root, RelOptInfo * rel, List *clausegroup_list, + RelOptInfo * index) { List *clausegroup = NIL; List *cg_list = NIL; @@ -1289,9 +1291,9 @@ index_innerjoin(Query *root, RelOptInfo *rel, List *clausegroup_list, pathnode->path.pathtype = T_IndexScan; pathnode->path.parent = rel; pathnode->path.pathorder = makeNode(PathOrder); - pathnode->path.pathorder->ordtype = SORTOP_ORDER; - pathnode->path.pathorder->ord.sortop = index->ordering; - pathnode->path.pathkeys = NIL; + pathnode->path.pathorder->ordtype = SORTOP_ORDER; + pathnode->path.pathorder->ord.sortop = index->ordering; + pathnode->path.pathkeys = NIL; pathnode->indexid = index->relids; pathnode->indexkeys = index->indexkeys; @@ -1300,27 +1302,25 @@ index_innerjoin(Query *root, RelOptInfo *rel, List *clausegroup_list, pathnode->path.joinid = ((RestrictInfo *) lfirst(clausegroup))->restrictinfojoinid; pathnode->path.path_cost = cost_index((Oid) lfirsti(index->relids), - (int) temp_pages, - temp_selec, - rel->pages, - rel->tuples, - index->pages, - index->tuples, - true); + (int) temp_pages, + temp_selec, + rel->pages, + rel->tuples, + index->pages, + index->tuples, + true); /* * copy restrictinfo list into path for expensive function * processing -- JMH, 7/7/92 */ pathnode->path.loc_restrictinfo = set_difference(copyObject((Node *) rel->restrictinfo), - clausegroup); + clausegroup); -#ifdef NOT_USED /* fix xfunc */ +#ifdef NOT_USED /* fix xfunc */ /* add in cost for expensive functions! -- JMH, 7/7/92 */ if (XfuncMode != XFUNC_OFF) - { ((Path *) pathnode)->path_cost += xfunc_get_path_cost((Path *) pathnode); - } #endif cg_list = lappend(cg_list, pathnode); } @@ -1343,10 +1343,10 @@ index_innerjoin(Query *root, RelOptInfo *rel, List *clausegroup_list, */ static List * create_index_path_group(Query *root, - RelOptInfo *rel, - RelOptInfo *index, - List *clausegroup_list, - bool join) + RelOptInfo * rel, + RelOptInfo * index, + List *clausegroup_list, + bool join) { List *clausegroup = NIL; List *ip_list = NIL; @@ -1366,7 +1366,7 @@ create_index_path_group(Query *root, restrictinfo = (RestrictInfo *) lfirst(j); if (!(is_joinable((Node *) restrictinfo->clause) && equal_path_merge_ordering(index->ordering, - restrictinfo->mergejoinorder))) + restrictinfo->mergejoinorder))) temp = false; } @@ -1386,7 +1386,7 @@ add_index_paths(List *indexpaths, List *new_indexpaths) } static bool -function_index_operand(Expr *funcOpnd, RelOptInfo *rel, RelOptInfo *index) +function_index_operand(Expr *funcOpnd, RelOptInfo * rel, RelOptInfo * index) { Oid heapRelid = (Oid) lfirsti(rel->relids); Func *function; diff --git a/src/backend/optimizer/path/joinpath.c b/src/backend/optimizer/path/joinpath.c index 9bb890c6eb..a6f22c40ed 100644 --- a/src/backend/optimizer/path/joinpath.c +++ b/src/backend/optimizer/path/joinpath.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.36 1999/05/18 21:36:10 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.37 1999/05/25 16:09:25 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -30,14 +30,14 @@ * _enable_mergejoin} */ static Path *best_innerjoin(List *join_paths, List *outer_relid); -static List *sort_inner_and_outer(RelOptInfo *joinrel, RelOptInfo *outerrel, RelOptInfo *innerrel, +static List *sort_inner_and_outer(RelOptInfo * joinrel, RelOptInfo * outerrel, RelOptInfo * innerrel, List *mergeinfo_list); -static List *match_unsorted_outer(RelOptInfo *joinrel, RelOptInfo *outerrel, RelOptInfo *innerrel, +static List *match_unsorted_outer(RelOptInfo * joinrel, RelOptInfo * outerrel, RelOptInfo * innerrel, List *outerpath_list, Path *cheapest_inner, Path *best_innerjoin, List *mergeinfo_list); -static List *match_unsorted_inner(RelOptInfo *joinrel, RelOptInfo *outerrel, RelOptInfo *innerrel, +static List *match_unsorted_inner(RelOptInfo * joinrel, RelOptInfo * outerrel, RelOptInfo * innerrel, List *innerpath_list, List *mergeinfo_list); -static List *hash_inner_and_outer(RelOptInfo *joinrel, RelOptInfo *outerrel, RelOptInfo *innerrel, +static List *hash_inner_and_outer(RelOptInfo * joinrel, RelOptInfo * outerrel, RelOptInfo * innerrel, List *hashinfo_list); /* @@ -119,13 +119,13 @@ update_rels_pathlist_for_joins(Query *root, List *joinrels) * mergejoins where the outer path is already ordered. */ pathlist = add_pathlist(joinrel, pathlist, - match_unsorted_outer(joinrel, - outerrel, - innerrel, - outerrel->pathlist, - innerrel->cheapestpath, - bestinnerjoin, - mergeinfo_list)); + match_unsorted_outer(joinrel, + outerrel, + innerrel, + outerrel->pathlist, + innerrel->cheapestpath, + bestinnerjoin, + mergeinfo_list)); /* * 3. Consider paths where the inner relation need not be @@ -134,18 +134,18 @@ update_rels_pathlist_for_joins(Query *root, List *joinrels) * (match_unsorted_outer). */ pathlist = add_pathlist(joinrel, pathlist, - match_unsorted_inner(joinrel, outerrel, - innerrel, - innerrel->pathlist, - mergeinfo_list)); + match_unsorted_inner(joinrel, outerrel, + innerrel, + innerrel->pathlist, + mergeinfo_list)); /* * 4. Consider paths where both outer and inner relations must be * hashed before being joined. */ pathlist = add_pathlist(joinrel, pathlist, - hash_inner_and_outer(joinrel, outerrel, - innerrel, hashinfo_list)); + hash_inner_and_outer(joinrel, outerrel, + innerrel, hashinfo_list)); joinrel->pathlist = pathlist; } @@ -194,9 +194,9 @@ best_innerjoin(List *join_paths, Relids outer_relids) * Returns a list of mergejoin paths. */ static List * -sort_inner_and_outer(RelOptInfo *joinrel, - RelOptInfo *outerrel, - RelOptInfo *innerrel, +sort_inner_and_outer(RelOptInfo * joinrel, + RelOptInfo * outerrel, + RelOptInfo * innerrel, List *mergeinfo_list) { List *ms_list = NIL; @@ -212,28 +212,28 @@ sort_inner_and_outer(RelOptInfo *joinrel, xmergeinfo = (MergeInfo *) lfirst(i); outerkeys = make_pathkeys_from_joinkeys(xmergeinfo->jmethod.jmkeys, - outerrel->targetlist, - OUTER); + outerrel->targetlist, + OUTER); innerkeys = make_pathkeys_from_joinkeys(xmergeinfo->jmethod.jmkeys, - innerrel->targetlist, - INNER); + innerrel->targetlist, + INNER); merge_pathkeys = new_join_pathkeys(outerkeys, joinrel->targetlist, - xmergeinfo->jmethod.clauses); + xmergeinfo->jmethod.clauses); temp_node = create_mergejoin_path(joinrel, - outerrel->size, - innerrel->size, - outerrel->width, - innerrel->width, - (Path *) outerrel->cheapestpath, - (Path *) innerrel->cheapestpath, - merge_pathkeys, - xmergeinfo->m_ordering, - xmergeinfo->jmethod.clauses, - outerkeys, - innerkeys); + outerrel->size, + innerrel->size, + outerrel->width, + innerrel->width, + (Path *) outerrel->cheapestpath, + (Path *) innerrel->cheapestpath, + merge_pathkeys, + xmergeinfo->m_ordering, + xmergeinfo->jmethod.clauses, + outerkeys, + innerkeys); ms_list = lappend(ms_list, temp_node); } @@ -268,9 +268,9 @@ sort_inner_and_outer(RelOptInfo *joinrel, * Returns a list of possible join path nodes. */ static List * -match_unsorted_outer(RelOptInfo *joinrel, - RelOptInfo *outerrel, - RelOptInfo *innerrel, +match_unsorted_outer(RelOptInfo * joinrel, + RelOptInfo * outerrel, + RelOptInfo * innerrel, List *outerpath_list, Path *cheapest_inner, Path *best_innerjoin, @@ -298,7 +298,7 @@ match_unsorted_outer(RelOptInfo *joinrel, if (outerpath_ordering) xmergeinfo = match_order_mergeinfo(outerpath_ordering, - mergeinfo_list); + mergeinfo_list); if (xmergeinfo) clauses = xmergeinfo->jmethod.clauses; @@ -308,13 +308,13 @@ match_unsorted_outer(RelOptInfo *joinrel, List *jmkeys = xmergeinfo->jmethod.jmkeys; order_joinkeys_by_pathkeys(outerpath->pathkeys, - jmkeys, - clauses, - OUTER, - &matchedJoinKeys, - &matchedJoinClauses); - merge_pathkeys = new_join_pathkeys(outerpath->pathkeys, - joinrel->targetlist, clauses); + jmkeys, + clauses, + OUTER, + &matchedJoinKeys, + &matchedJoinClauses); + merge_pathkeys = new_join_pathkeys(outerpath->pathkeys, + joinrel->targetlist, clauses); } else merge_pathkeys = outerpath->pathkeys; @@ -338,21 +338,21 @@ match_unsorted_outer(RelOptInfo *joinrel, List *varkeys = NIL; Path *mergeinnerpath = get_cheapest_path_for_joinkeys( matchedJoinKeys, - outerpath_ordering, - innerrel->pathlist, - INNER); + outerpath_ordering, + innerrel->pathlist, + INNER); /* Should we use the mergeinner, or sort the cheapest inner? */ path_is_cheaper_than_sort = (bool) (mergeinnerpath && - (mergeinnerpath->path_cost < - (cheapest_inner->path_cost + - cost_sort(matchedJoinKeys, innerrel->size, - innerrel->width)))); + (mergeinnerpath->path_cost < + (cheapest_inner->path_cost + + cost_sort(matchedJoinKeys, innerrel->size, + innerrel->width)))); if (!path_is_cheaper_than_sort) { varkeys = make_pathkeys_from_joinkeys(matchedJoinKeys, - innerrel->targetlist, - INNER); + innerrel->targetlist, + INNER); } @@ -368,18 +368,18 @@ match_unsorted_outer(RelOptInfo *joinrel, mergeinnerpath = cheapest_inner; temp_node = lcons(create_mergejoin_path(joinrel, - outerrel->size, - innerrel->size, - outerrel->width, - innerrel->width, - outerpath, - mergeinnerpath, - merge_pathkeys, - xmergeinfo->m_ordering, - matchedJoinClauses, - NIL, - varkeys), - paths); + outerrel->size, + innerrel->size, + outerrel->width, + innerrel->width, + outerpath, + mergeinnerpath, + merge_pathkeys, + xmergeinfo->m_ordering, + matchedJoinClauses, + NIL, + varkeys), + paths); } else temp_node = paths; @@ -389,7 +389,7 @@ match_unsorted_outer(RelOptInfo *joinrel, } /* - * match_unsorted_inner + * match_unsorted_inner * Find the cheapest ordered join path for a given(ordered, unsorted) * inner join path. * @@ -411,9 +411,9 @@ match_unsorted_outer(RelOptInfo *joinrel, * Returns a list of possible merge paths. */ static List * -match_unsorted_inner(RelOptInfo *joinrel, - RelOptInfo *outerrel, - RelOptInfo *innerrel, +match_unsorted_inner(RelOptInfo * joinrel, + RelOptInfo * outerrel, + RelOptInfo * innerrel, List *innerpath_list, List *mergeinfo_list) { @@ -441,11 +441,11 @@ match_unsorted_inner(RelOptInfo *joinrel, List *jmkeys = xmergeinfo->jmethod.jmkeys; order_joinkeys_by_pathkeys(innerpath->pathkeys, - jmkeys, - clauses, - INNER, - &matchedJoinKeys, - &matchedJoinClauses); + jmkeys, + clauses, + INNER, + &matchedJoinKeys, + &matchedJoinClauses); } /* @@ -459,29 +459,29 @@ match_unsorted_inner(RelOptInfo *joinrel, temp1 = outerrel->cheapestpath->path_cost + cost_sort(matchedJoinKeys, outerrel->size, outerrel->width); - if (innerpath->outerjoincost <= 0 /* unset? */ + if (innerpath->outerjoincost <= 0 /* unset? */ || innerpath->outerjoincost > temp1) { List *outerkeys = make_pathkeys_from_joinkeys(matchedJoinKeys, - outerrel->targetlist, - OUTER); + outerrel->targetlist, + OUTER); List *merge_pathkeys = new_join_pathkeys(outerkeys, - joinrel->targetlist, - clauses); + joinrel->targetlist, + clauses); mp_list = lappend(mp_list, create_mergejoin_path(joinrel, - outerrel->size, - innerrel->size, - outerrel->width, - innerrel->width, + outerrel->size, + innerrel->size, + outerrel->width, + innerrel->width, (Path *) outerrel->cheapestpath, - innerpath, - merge_pathkeys, - xmergeinfo->m_ordering, - matchedJoinClauses, - outerkeys, - NIL)); + innerpath, + merge_pathkeys, + xmergeinfo->m_ordering, + matchedJoinClauses, + outerkeys, + NIL)); } } } @@ -503,9 +503,9 @@ match_unsorted_inner(RelOptInfo *joinrel, * Returns a list of hashjoin paths. */ static List * -hash_inner_and_outer(RelOptInfo *joinrel, - RelOptInfo *outerrel, - RelOptInfo *innerrel, +hash_inner_and_outer(RelOptInfo * joinrel, + RelOptInfo * outerrel, + RelOptInfo * innerrel, List *hashinfo_list) { List *hjoin_list = NIL; @@ -520,20 +520,22 @@ hash_inner_and_outer(RelOptInfo *joinrel, HashPath *temp_node; outerkeys = make_pathkeys_from_joinkeys( - ((JoinMethod *) xhashinfo)->jmkeys, - outerrel->targetlist, - OUTER); + ((JoinMethod *) xhashinfo)->jmkeys, + outerrel->targetlist, + OUTER); innerkeys = make_pathkeys_from_joinkeys( - ((JoinMethod *) xhashinfo)->jmkeys, - innerrel->targetlist, - INNER); - /* We cannot assume that the output of the hashjoin appears in any + ((JoinMethod *) xhashinfo)->jmkeys, + innerrel->targetlist, + INNER); + + /* + * We cannot assume that the output of the hashjoin appears in any * particular order, so it should have NIL pathkeys. */ #ifdef NOT_USED hash_pathkeys = new_join_pathkeys(outerkeys, - joinrel->targetlist, - ((JoinMethod *) xhashinfo)->clauses); + joinrel->targetlist, + ((JoinMethod *) xhashinfo)->clauses); #else hash_pathkeys = NIL; #endif @@ -547,7 +549,7 @@ hash_inner_and_outer(RelOptInfo *joinrel, (Path *) innerrel->cheapestpath, hash_pathkeys, xhashinfo->hashop, - ((JoinMethod *) xhashinfo)->clauses, + ((JoinMethod *) xhashinfo)->clauses, outerkeys, innerkeys); hjoin_list = lappend(hjoin_list, temp_node); diff --git a/src/backend/optimizer/path/joinrels.c b/src/backend/optimizer/path/joinrels.c index a4e08ca649..861f3cb225 100644 --- a/src/backend/optimizer/path/joinrels.c +++ b/src/backend/optimizer/path/joinrels.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.32 1999/02/22 06:08:48 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.33 1999/05/25 16:09:26 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -26,8 +26,8 @@ static List *new_joininfo_list(List *joininfo_list, Relids join_relids); static bool nonoverlap_sets(List *s1, List *s2); static bool is_subset(List *s1, List *s2); -static void set_joinrel_size(RelOptInfo *joinrel, RelOptInfo *outer_rel, - RelOptInfo *inner_rel, JoinInfo *jinfo); +static void set_joinrel_size(RelOptInfo * joinrel, RelOptInfo * outer_rel, + RelOptInfo * inner_rel, JoinInfo * jinfo); /* * make_rels_by_joins @@ -52,18 +52,19 @@ make_rels_by_joins(Query *root, List *old_rels) RelOptInfo *old_rel = (RelOptInfo *) lfirst(r); if (!(joined_rels = make_rels_by_clause_joins(root, old_rel, - old_rel->joininfo, - NIL))) + old_rel->joininfo, + NIL))) { + /* * Oops, we have a relation that is not joined to any other * relation. Cartesian product time. */ joined_rels = make_rels_by_clauseless_joins(old_rel, - root->base_rel_list); + root->base_rel_list); joined_rels = nconc(joined_rels, make_rels_by_clauseless_joins(old_rel, - old_rels)); + old_rels)); } join_list = nconc(join_list, joined_rels); @@ -88,14 +89,14 @@ make_rels_by_joins(Query *root, List *old_rels) * Returns a list of new join relations. */ List * -make_rels_by_clause_joins(Query *root, RelOptInfo *old_rel, - List *joininfo_list, Relids only_relids) +make_rels_by_clause_joins(Query *root, RelOptInfo * old_rel, + List *joininfo_list, Relids only_relids) { List *join_list = NIL; List *i = NIL; foreach(i, joininfo_list) - { + { JoinInfo *joininfo = (JoinInfo *) lfirst(i); RelOptInfo *joined_rel; Relids unjoined_relids = joininfo->unjoined_relids; @@ -104,29 +105,29 @@ make_rels_by_clause_joins(Query *root, RelOptInfo *old_rel, { if (length(unjoined_relids) == 1 && (only_relids == NIL || - /* geqo only wants certain relids to make new rels */ + /* geqo only wants certain relids to make new rels */ intMember(lfirsti(unjoined_relids), only_relids))) { joined_rel = make_join_rel(old_rel, - get_base_rel(root, - lfirsti(unjoined_relids)), - joininfo); + get_base_rel(root, + lfirsti(unjoined_relids)), + joininfo); join_list = lappend(join_list, joined_rel); /* Right-sided plan */ if (length(old_rel->relids) > 1) { joined_rel = make_join_rel( - get_base_rel(root, lfirsti(unjoined_relids)), - old_rel, - joininfo); + get_base_rel(root, lfirsti(unjoined_relids)), + old_rel, + joininfo); join_list = lappend(join_list, joined_rel); } } - if (only_relids == NIL) /* no bushy from geqo */ + if (only_relids == NIL) /* no bushy from geqo */ { - List *r; + List *r; foreach(r, root->join_rel_list) { @@ -134,11 +135,11 @@ make_rels_by_clause_joins(Query *root, RelOptInfo *old_rel, Assert(length(join_rel->relids) > 1); if (is_subset(unjoined_relids, join_rel->relids) && - nonoverlap_sets(old_rel->relids, join_rel->relids)) + nonoverlap_sets(old_rel->relids, join_rel->relids)) { joined_rel = make_join_rel(old_rel, - join_rel, - joininfo); + join_rel, + joininfo); join_list = lappend(join_list, joined_rel); } } @@ -158,7 +159,7 @@ make_rels_by_clause_joins(Query *root, RelOptInfo *old_rel, * Returns a list of new join relations. */ List * -make_rels_by_clauseless_joins(RelOptInfo *old_rel, List *inner_rels) +make_rels_by_clauseless_joins(RelOptInfo * old_rel, List *inner_rels) { RelOptInfo *inner_rel; List *t_list = NIL; @@ -191,7 +192,7 @@ make_rels_by_clauseless_joins(RelOptInfo *old_rel, List *inner_rels) * Returns the new join relation node. */ RelOptInfo * -make_join_rel(RelOptInfo *outer_rel, RelOptInfo *inner_rel, JoinInfo *joininfo) +make_join_rel(RelOptInfo * outer_rel, RelOptInfo * inner_rel, JoinInfo * joininfo) { RelOptInfo *joinrel = makeNode(RelOptInfo); List *joinrel_joininfo_list = NIL; @@ -203,7 +204,7 @@ make_join_rel(RelOptInfo *outer_rel, RelOptInfo *inner_rel, JoinInfo *joininfo) * of the outer and inner join relations and then merging the results * together. */ - new_outer_tlist = new_join_tlist(outer_rel->targetlist, 1); + new_outer_tlist = new_join_tlist(outer_rel->targetlist, 1); new_inner_tlist = new_join_tlist(inner_rel->targetlist, length(new_outer_tlist) + 1); @@ -224,8 +225,8 @@ make_join_rel(RelOptInfo *outer_rel, RelOptInfo *inner_rel, JoinInfo *joininfo) joinrel->innerjoin = NIL; /* - * This function uses a trick to pass inner/outer rels as - * different lists, and then flattens it out later. bjm + * This function uses a trick to pass inner/outer rels as different + * lists, and then flattens it out later. bjm */ joinrel->relids = lcons(outer_rel->relids, lcons(inner_rel->relids, NIL)); @@ -236,10 +237,10 @@ make_join_rel(RelOptInfo *outer_rel, RelOptInfo *inner_rel, JoinInfo *joininfo) joinrel->restrictinfo = joininfo->jinfo_restrictinfo; joinrel_joininfo_list = new_joininfo_list( - nconc(copyObject(outer_rel->joininfo), - copyObject(inner_rel->joininfo)), - nconc(listCopy(outer_rel->relids), - listCopy(inner_rel->relids))); + nconc(copyObject(outer_rel->joininfo), + copyObject(inner_rel->joininfo)), + nconc(listCopy(outer_rel->relids), + listCopy(inner_rel->relids))); joinrel->joininfo = joinrel_joininfo_list; @@ -278,12 +279,16 @@ new_join_tlist(List *tlist, foreach(i, tlist) { xtl = lfirst(i); - /* XXX surely this is wrong? join_list is never changed? tgl 2/99 */ + + /* + * XXX surely this is wrong? join_list is never changed? tgl + * 2/99 + */ in_final_tlist = (join_list == NIL); if (in_final_tlist) { resdomno += 1; - t_list = lappend(t_list,create_tl_element(get_expr(xtl), resdomno)); + t_list = lappend(t_list, create_tl_element(get_expr(xtl), resdomno)); } } @@ -335,8 +340,8 @@ new_joininfo_list(List *joininfo_list, Relids join_relids) if (other_joininfo) { other_joininfo->jinfo_restrictinfo = (List *) - LispUnion(joininfo->jinfo_restrictinfo, - other_joininfo->jinfo_restrictinfo); + LispUnion(joininfo->jinfo_restrictinfo, + other_joininfo->jinfo_restrictinfo); } else { @@ -393,7 +398,7 @@ get_cheapest_complete_rel(List *join_rel_list) } if (final) if (final_rel == NULL || - path_is_cheaper(rel->cheapestpath, final_rel->cheapestpath)) + path_is_cheaper(rel->cheapestpath, final_rel->cheapestpath)) final_rel = rel; } @@ -431,7 +436,7 @@ is_subset(List *s1, List *s2) } static void -set_joinrel_size(RelOptInfo *joinrel, RelOptInfo *outer_rel, RelOptInfo *inner_rel, JoinInfo *jinfo) +set_joinrel_size(RelOptInfo * joinrel, RelOptInfo * outer_rel, RelOptInfo * inner_rel, JoinInfo * jinfo) { int ntuples; float selec; diff --git a/src/backend/optimizer/path/mergeutils.c b/src/backend/optimizer/path/mergeutils.c index a5bc8d9698..8d8255cabb 100644 --- a/src/backend/optimizer/path/mergeutils.c +++ b/src/backend/optimizer/path/mergeutils.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/mergeutils.c,v 1.21 1999/04/03 00:18:28 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/mergeutils.c,v 1.22 1999/05/25 16:09:27 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -37,7 +37,7 @@ * * 'restrictinfo_list' is the list of restrictinfo nodes * 'inner_relids' is the list of relids in the inner join relation - * (used to determine whether a join var is inner or outer) + * (used to determine whether a join var is inner or outer) * * Returns the new list of mergeinfo nodes. * @@ -56,6 +56,7 @@ group_clauses_by_order(List *restrictinfo_list, if (merge_ordering) { + /* * Create a new mergeinfo node and add it to 'mergeinfo_list' * if one does not yet exist for this merge ordering. @@ -63,8 +64,8 @@ group_clauses_by_order(List *restrictinfo_list, Expr *clause = restrictinfo->clause; Var *leftop = get_leftop(clause); Var *rightop = get_rightop(clause); - PathOrder *pathorder; - MergeInfo *xmergeinfo; + PathOrder *pathorder; + MergeInfo *xmergeinfo; JoinKey *jmkeys; pathorder = makeNode(PathOrder); @@ -91,9 +92,9 @@ group_clauses_by_order(List *restrictinfo_list, } xmergeinfo->jmethod.clauses = lcons(clause, - xmergeinfo->jmethod.clauses); + xmergeinfo->jmethod.clauses); xmergeinfo->jmethod.jmkeys = lcons(jmkeys, - xmergeinfo->jmethod.jmkeys); + xmergeinfo->jmethod.jmkeys); } } return mergeinfo_list; @@ -108,7 +109,7 @@ group_clauses_by_order(List *restrictinfo_list, * Returns the node if it exists. * */ -MergeInfo * +MergeInfo * match_order_mergeinfo(PathOrder *ordering, List *mergeinfo_list) { MergeOrder *xmergeorder; @@ -116,12 +117,12 @@ match_order_mergeinfo(PathOrder *ordering, List *mergeinfo_list) foreach(xmergeinfo, mergeinfo_list) { - MergeInfo *mergeinfo = (MergeInfo *) lfirst(xmergeinfo); + MergeInfo *mergeinfo = (MergeInfo *) lfirst(xmergeinfo); xmergeorder = mergeinfo->m_ordering; if ((ordering->ordtype == MERGE_ORDER && - equal_merge_ordering(ordering->ord.merge, xmergeorder)) || + equal_merge_ordering(ordering->ord.merge, xmergeorder)) || (ordering->ordtype == SORTOP_ORDER && equal_path_merge_ordering(ordering->ord.sortop, xmergeorder))) { diff --git a/src/backend/optimizer/path/orindxpath.c b/src/backend/optimizer/path/orindxpath.c index 833d00c82f..4c25721218 100644 --- a/src/backend/optimizer/path/orindxpath.c +++ b/src/backend/optimizer/path/orindxpath.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/orindxpath.c,v 1.23 1999/03/08 14:01:55 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/orindxpath.c,v 1.24 1999/05/25 16:09:27 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -31,10 +31,9 @@ #include "parser/parsetree.h" -static void -best_or_subclause_indices(Query *root, RelOptInfo *rel, List *subclauses, -List *indices, List **indexids, Cost *cost, Cost *selec); -static void best_or_subclause_index(Query *root, RelOptInfo *rel, Expr *subclause, +static void best_or_subclause_indices(Query *root, RelOptInfo * rel, List *subclauses, + List *indices, List **indexids, Cost *cost, Cost *selec); +static void best_or_subclause_index(Query *root, RelOptInfo * rel, Expr *subclause, List *indices, int *indexid, Cost *cost, Cost *selec); @@ -50,7 +49,7 @@ static void best_or_subclause_index(Query *root, RelOptInfo *rel, Expr *subclaus */ List * create_or_index_paths(Query *root, - RelOptInfo *rel, List *clauses) + RelOptInfo * rel, List *clauses) { List *t_list = NIL; List *clist; @@ -88,7 +87,7 @@ create_or_index_paths(Query *root, IndexPath *pathnode = makeNode(IndexPath); List *indexids = NIL; Cost cost; - Cost selec; + Cost selec; best_or_subclause_indices(root, rel, @@ -101,14 +100,15 @@ create_or_index_paths(Query *root, pathnode->path.pathtype = T_IndexScan; pathnode->path.parent = rel; pathnode->path.pathorder = makeNode(PathOrder); - pathnode->path.pathorder->ordtype = SORTOP_ORDER; - /* - * This is an IndexScan, but it does index lookups based - * on the order of the fields specified in the WHERE clause, - * not in any order, so the sortop is NULL. + pathnode->path.pathorder->ordtype = SORTOP_ORDER; + + /* + * This is an IndexScan, but it does index lookups based + * on the order of the fields specified in the WHERE + * clause, not in any order, so the sortop is NULL. */ - pathnode->path.pathorder->ord.sortop = NULL; - pathnode->path.pathkeys = NIL; + pathnode->path.pathorder->ord.sortop = NULL; + pathnode->path.pathkeys = NIL; pathnode->indexqual = lcons(clausenode, NIL); pathnode->indexid = indexids; @@ -119,14 +119,12 @@ create_or_index_paths(Query *root, * processing -- JMH, 7/7/92 */ pathnode->path.loc_restrictinfo = set_difference(copyObject((Node *) rel->restrictinfo), - lcons(clausenode, NIL)); + lcons(clausenode, NIL)); -#ifdef NOT_USED /* fix xfunc */ +#ifdef NOT_USED /* fix xfunc */ /* add in cost for expensive functions! -- JMH, 7/7/92 */ if (XfuncMode != XFUNC_OFF) - { ((Path *) pathnode)->path_cost += xfunc_get_path_cost((Path) pathnode); - } #endif clausenode->selectivity = (Cost) selec; t_list = lappend(t_list, pathnode); @@ -158,18 +156,18 @@ create_or_index_paths(Query *root, */ static void best_or_subclause_indices(Query *root, - RelOptInfo *rel, + RelOptInfo * rel, List *subclauses, List *indices, List **indexids, /* return value */ - Cost *cost, /* return value */ - Cost *selec) /* return value */ + Cost *cost, /* return value */ + Cost *selec) /* return value */ { - List *slist; + List *slist; *selec = (Cost) 0.0; *cost = (Cost) 0.0; - + foreach(slist, subclauses) { int best_indexid; @@ -207,7 +205,7 @@ best_or_subclause_indices(Query *root, */ static void best_or_subclause_index(Query *root, - RelOptInfo *rel, + RelOptInfo * rel, Expr *subclause, List *indices, int *retIndexid, /* return value */ diff --git a/src/backend/optimizer/path/pathkeys.c b/src/backend/optimizer/path/pathkeys.c index 09a5b8a51f..eee8a027a8 100644 --- a/src/backend/optimizer/path/pathkeys.c +++ b/src/backend/optimizer/path/pathkeys.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/pathkeys.c,v 1.9 1999/05/17 00:26:33 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/pathkeys.c,v 1.10 1999/05/25 16:09:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -26,9 +26,9 @@ #include "optimizer/ordering.h" static int match_pathkey_joinkeys(List *pathkey, List *joinkeys, - int outer_or_inner); + int outer_or_inner); static List *new_join_pathkey(List *pathkeys, List *join_rel_tlist, - List *joinclauses); + List *joinclauses); /*-------------------- @@ -41,7 +41,7 @@ static List *new_join_pathkey(List *pathkeys, List *join_rel_tlist, * of generating the relation and the resulting ordering of the tuples. * Sequential scan Paths have NIL pathkeys, indicating no known ordering. * Index scans have Path.pathkeys that represent the chosen index. - * A single-key index pathkeys would be { {tab1_indexkey1} }. For a + * A single-key index pathkeys would be { {tab1_indexkey1} }. For a * multi-key index pathkeys would be { {tab1_indexkey1}, {tab1_indexkey2} }, * indicating major sort by indexkey1 and minor sort by indexkey2. * @@ -70,12 +70,12 @@ static List *new_join_pathkey(List *pathkeys, List *join_rel_tlist, * executor might have to split the join into multiple batches. * * NestJoin does not perform sorting, and allows non-equijoins, so it does - * not allow useful pathkeys. (But couldn't we use the outer path's order?) + * not allow useful pathkeys. (But couldn't we use the outer path's order?) * * -- bjm *-------------------- */ - + /**************************************************************************** * KEY COMPARISONS ****************************************************************************/ @@ -111,11 +111,11 @@ static List *new_join_pathkey(List *pathkeys, List *join_rel_tlist, */ bool order_joinkeys_by_pathkeys(List *pathkeys, - List *joinkeys, - List *joinclauses, - int outer_or_inner, - List **matchedJoinKeysPtr, - List **matchedJoinClausesPtr) + List *joinkeys, + List *joinclauses, + int outer_or_inner, + List **matchedJoinKeysPtr, + List **matchedJoinClausesPtr) { List *matched_joinkeys = NIL; List *matched_joinclauses = NIL; @@ -123,9 +123,10 @@ order_joinkeys_by_pathkeys(List *pathkeys, List *i = NIL; int matched_joinkey_index = -1; int matched_keys = 0; + /* - * Reorder the joinkeys by picking out one that matches each pathkey, - * and create a new joinkey/joinclause list in pathkey order + * Reorder the joinkeys by picking out one that matches each pathkey, + * and create a new joinkey/joinclause list in pathkey order */ foreach(i, pathkeys) { @@ -138,34 +139,36 @@ order_joinkeys_by_pathkeys(List *pathkeys, matched_keys++; if (matchedJoinKeysPtr) { - JoinKey *joinkey = nth(matched_joinkey_index, joinkeys); + JoinKey *joinkey = nth(matched_joinkey_index, joinkeys); + matched_joinkeys = lappend(matched_joinkeys, joinkey); } - + if (matchedJoinClausesPtr) { Expr *joinclause = nth(matched_joinkey_index, joinclauses); + Assert(joinclauses); matched_joinclauses = lappend(matched_joinclauses, joinclause); } } else - /* A pathkey could not be matched. */ + /* A pathkey could not be matched. */ break; } /* - * Did we fail to match all the joinkeys? - * Extra pathkeys are no problem. + * Did we fail to match all the joinkeys? Extra pathkeys are no + * problem. */ if (matched_keys != length(joinkeys)) { - if (matchedJoinKeysPtr) - *matchedJoinKeysPtr = NIL; - if (matchedJoinClausesPtr) - *matchedJoinClausesPtr = NIL; - return false; + if (matchedJoinKeysPtr) + *matchedJoinKeysPtr = NIL; + if (matchedJoinClausesPtr) + *matchedJoinClausesPtr = NIL; + return false; } if (matchedJoinKeysPtr) @@ -190,7 +193,8 @@ match_pathkey_joinkeys(List *pathkey, { Var *key; int pos; - List *i, *x; + List *i, + *x; JoinKey *jk; foreach(i, pathkey) @@ -232,9 +236,9 @@ match_pathkey_joinkeys(List *pathkey, */ Path * get_cheapest_path_for_joinkeys(List *joinkeys, - PathOrder *ordering, - List *paths, - int outer_or_inner) + PathOrder *ordering, + List *paths, + int outer_or_inner) { Path *matched_path = NULL; List *i; @@ -243,7 +247,7 @@ get_cheapest_path_for_joinkeys(List *joinkeys, { Path *path = (Path *) lfirst(i); int better_sort; - + if (order_joinkeys_by_pathkeys(path->pathkeys, joinkeys, NIL, outer_or_inner, NULL, NULL) && pathorder_match(ordering, path->pathorder, &better_sort) && @@ -274,8 +278,8 @@ get_cheapest_path_for_joinkeys(List *joinkeys, */ List * make_pathkeys_from_joinkeys(List *joinkeys, - List *tlist, - int outer_or_inner) + List *tlist, + int outer_or_inner) { List *pathkeys = NIL; List *jk; @@ -284,7 +288,8 @@ make_pathkeys_from_joinkeys(List *joinkeys, { JoinKey *jkey = (JoinKey *) lfirst(jk); Var *key; - List *p, *p2; + List *p, + *p2; bool found = false; key = (Var *) extract_join_key(jkey, outer_or_inner); @@ -292,17 +297,19 @@ make_pathkeys_from_joinkeys(List *joinkeys, /* check to see if it is in the target list */ if (matching_tlist_var(key, tlist)) { + /* - * Include it in the pathkeys list if we haven't already done so + * Include it in the pathkeys list if we haven't already done + * so */ foreach(p, pathkeys) { List *pathkey = lfirst(p); - + foreach(p2, pathkey) { Var *pkey = lfirst(p2); - + if (equal(key, pkey)) { found = true; @@ -371,7 +378,7 @@ new_join_pathkeys(List *outer_pathkeys, * * Note that each returned pathkey is the var node found in * 'join_rel_tlist' rather than the joinclause var node. - * (Is this important?) Also, we return a fully copied list + * (Is this important?) Also, we return a fully copied list * that does not share any subnodes with existing data structures. * (Is that important, either?) * @@ -393,7 +400,7 @@ new_join_pathkey(List *pathkey, Expr *tlist_key; Assert(key); - + tlist_key = matching_tlist_var(key, join_rel_tlist); if (tlist_key && !member(tlist_key, new_pathkey)) new_pathkey = lcons(copyObject(tlist_key), new_pathkey); @@ -404,8 +411,8 @@ new_join_pathkey(List *pathkey, Expr *tlist_other_var; tlist_other_var = matching_tlist_var( - other_join_clause_var(key, joinclause), - join_rel_tlist); + other_join_clause_var(key, joinclause), + join_rel_tlist); if (tlist_other_var && !member(tlist_other_var, new_pathkey)) new_pathkey = lcons(copyObject(tlist_other_var), new_pathkey); } diff --git a/src/backend/optimizer/path/prune.c b/src/backend/optimizer/path/prune.c index 3d60c09f6c..da52363cc8 100644 --- a/src/backend/optimizer/path/prune.c +++ b/src/backend/optimizer/path/prune.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/prune.c,v 1.37 1999/02/18 00:49:21 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/prune.c,v 1.38 1999/05/25 16:09:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -24,7 +24,7 @@ #include "utils/elog.h" -static List *merge_rel_with_same_relids(RelOptInfo *rel, Relids unjoined_relids); +static List *merge_rel_with_same_relids(RelOptInfo * rel, Relids unjoined_relids); /* * merge_rels_with_same_relids @@ -59,7 +59,7 @@ merge_rels_with_same_relids(List *rel_list) * */ static List * -merge_rel_with_same_relids(RelOptInfo *rel, Relids unjoined_relids) +merge_rel_with_same_relids(RelOptInfo * rel, Relids unjoined_relids) { List *i = NIL; List *result = NIL; @@ -69,9 +69,10 @@ merge_rel_with_same_relids(RelOptInfo *rel, Relids unjoined_relids) RelOptInfo *unjoined_rel = (RelOptInfo *) lfirst(i); if (same(rel->relids, unjoined_rel->relids)) + /* - * This are on the same relations, - * so get the best of their pathlists. + * This are on the same relations, so get the best of their + * pathlists. */ rel->pathlist = add_pathlist(rel, rel->pathlist, @@ -92,7 +93,7 @@ rels_set_cheapest(List *rel_list) { List *x = NIL; RelOptInfo *rel = (RelOptInfo *) NULL; - JoinPath *cheapest; + JoinPath *cheapest; foreach(x, rel_list) { diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c index d228f9d058..c72d31ca10 100644 --- a/src/backend/optimizer/plan/createplan.c +++ b/src/backend/optimizer/plan/createplan.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.55 1999/05/18 21:34:29 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.56 1999/05/25 16:09:34 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -42,18 +42,18 @@ #define NONAME_SORT 1 -#define NONAME_MATERIAL 2 +#define NONAME_MATERIAL 2 static List *switch_outer(List *clauses); static Oid *generate_merge_input_sortorder(List *pathkeys, - MergeOrder *mergeorder); + MergeOrder *mergeorder); static Scan *create_scan_node(Path *best_path, List *tlist); static Join *create_join_node(JoinPath *best_path, List *tlist); static SeqScan *create_seqscan_node(Path *best_path, List *tlist, List *scan_clauses); static IndexScan *create_indexscan_node(IndexPath *best_path, List *tlist, List *scan_clauses); -static NestLoop *create_nestloop_node(NestPath *best_path, List *tlist, +static NestLoop *create_nestloop_node(NestPath * best_path, List *tlist, List *clauses, Plan *outer_node, List *outer_tlist, Plan *inner_node, List *inner_tlist); static MergeJoin *create_mergejoin_node(MergePath *best_path, List *tlist, @@ -64,7 +64,7 @@ static HashJoin *create_hashjoin_node(HashPath *best_path, List *tlist, Plan *inner_node, List *inner_tlist); static Node *fix_indxqual_references(Node *clause, Path *index_path); static Noname *make_noname(List *tlist, List *pathkeys, Oid *operators, - Plan *plan_node, int nonametype); + Plan *plan_node, int nonametype); static IndexScan *make_indexscan(List *qptlist, List *qpqual, Index scanrelid, List *indxid, List *indxqual, List *indxqualorig); static NestLoop *make_nestloop(List *qptlist, List *qpqual, Plan *lefttree, @@ -133,7 +133,7 @@ create_plan(Path *best_path) pages = 1; plan_node->plan_tupperpage = tuples / pages; -#ifdef NOT_USED /* fix xfunc */ +#ifdef NOT_USED /* fix xfunc */ /* sort clauses by cost/(1-selectivity) -- JMH 2/26/92 */ if (XfuncMode != XFUNC_OFF) { @@ -197,7 +197,7 @@ create_scan_node(Path *best_path, List *tlist) } /* - * create_join_node + * create_join_node * Create a join path for 'best_path' and(recursively) paths for its * inner and outer paths. * @@ -263,7 +263,7 @@ create_join_node(JoinPath *best_path, List *tlist) /* * * Expensive function pullups may have pulled local predicates * - * into this path node. Put them in the qpqual of the plan node. * + * into this path node. Put them in the qpqual of the plan node. * * JMH, 6/15/92 */ if (get_loc_restrictinfo(best_path) != NIL) @@ -400,11 +400,11 @@ create_indexscan_node(IndexPath *best_path, fixed_indxqual = (List *) fix_indxqual_references((Node *) indxqual, (Path *) best_path); scan_node = make_indexscan(tlist, - qpqual, - lfirsti(best_path->path.parent->relids), - best_path->indexid, - fixed_indxqual, - indxqual); + qpqual, + lfirsti(best_path->path.parent->relids), + best_path->indexid, + fixed_indxqual, + indxqual); scan_node->scan.plan.cost = best_path->path.path_cost; @@ -418,7 +418,7 @@ create_indexscan_node(IndexPath *best_path, *****************************************************************************/ static NestLoop * -create_nestloop_node(NestPath *best_path, +create_nestloop_node(NestPath * best_path, List *tlist, List *clauses, Plan *outer_node, @@ -471,7 +471,7 @@ create_nestloop_node(NestPath *best_path, clauses = set_difference(clauses, inner_indxqual); /* XXX */ new_inner_qual = index_outerjoin_references(inner_indxqual, - outer_node->targetlist, + outer_node->targetlist, ((Scan *) inner_node)->scanrelid); ((IndexScan *) inner_node)->indxqual = lcons(new_inner_qual, NIL); } @@ -479,10 +479,10 @@ create_nestloop_node(NestPath *best_path, else if (IsA_Join(inner_node)) { inner_node = (Plan *) make_noname(inner_tlist, - NIL, - NULL, - inner_node, - NONAME_MATERIAL); + NIL, + NULL, + inner_node, + NONAME_MATERIAL); } join_node = make_nestloop(tlist, @@ -535,8 +535,9 @@ create_mergejoin_node(MergePath *best_path, if (best_path->outersortkeys) { Oid *outer_order = generate_merge_input_sortorder( - best_path->outersortkeys, - best_path->jpath.path.pathorder->ord.merge); + best_path->outersortkeys, + best_path->jpath.path.pathorder->ord.merge); + outer_node = (Plan *) make_noname(outer_tlist, best_path->outersortkeys, outer_order, @@ -547,8 +548,9 @@ create_mergejoin_node(MergePath *best_path, if (best_path->innersortkeys) { Oid *inner_order = generate_merge_input_sortorder( - best_path->innersortkeys, - best_path->jpath.path.pathorder->ord.merge); + best_path->innersortkeys, + best_path->jpath.path.pathorder->ord.merge); + inner_node = (Plan *) make_noname(inner_tlist, best_path->innersortkeys, inner_order, @@ -595,17 +597,17 @@ create_hashjoin_node(HashPath *best_path, * and set those clauses to contain references to lower attributes. */ qpqual = join_references(set_difference(clauses, - best_path->path_hashclauses), - outer_tlist, - inner_tlist); + best_path->path_hashclauses), + outer_tlist, + inner_tlist); /* * Now set the references in the hashclauses and rearrange them so * that the outer variable is always on the left. */ hashclauses = switch_outer(join_references(best_path->path_hashclauses, - outer_tlist, - inner_tlist)); + outer_tlist, + inner_tlist)); innerhashkey = get_rightop(lfirst(hashclauses)); @@ -671,20 +673,22 @@ fix_indxqual_references(Node *clause, Path *index_path) is_funcclause((Node *) get_leftop((Expr *) clause)) && ((Func *) ((Expr *) get_leftop((Expr *) clause))->oper)->funcisindex) { - /* This looks pretty seriously wrong to me, but I'm not sure what it's - * supposed to be doing ... tgl 5/99 + + /* + * This looks pretty seriously wrong to me, but I'm not sure what + * it's supposed to be doing ... tgl 5/99 */ Var *newvar = makeVar((Index) lfirsti(index_path->parent->relids), - 1, /* func indices have one key */ - ((Func *) ((Expr *) clause)->oper)->functype, - -1, - 0, - (Index) lfirsti(index_path->parent->relids), - 0); + 1, /* func indices have one key */ + ((Func *) ((Expr *) clause)->oper)->functype, + -1, + 0, + (Index) lfirsti(index_path->parent->relids), + 0); return ((Node *) make_opclause((Oper *) ((Expr *) clause)->oper, - newvar, - get_rightop((Expr *) clause))); + newvar, + get_rightop((Expr *) clause))); } else if (IsA(clause, Expr)) @@ -696,6 +700,7 @@ fix_indxqual_references(Node *clause, Path *index_path) foreach(i, expr->args) { Node *subclause = lfirst(i); + new_subclauses = lappend(new_subclauses, fix_indxqual_references(subclause, index_path)); @@ -711,6 +716,7 @@ fix_indxqual_references(Node *clause, Path *index_path) foreach(i, (List *) clause) { Node *subclause = lfirst(i); + new_subclauses = lappend(new_subclauses, fix_indxqual_references(subclause, index_path)); @@ -768,15 +774,17 @@ switch_outer(List *clauses) foreach(i, clauses) { clause = lfirst(i); - Assert(is_opclause((Node*) clause)); + Assert(is_opclause((Node *) clause)); op = (Node *) get_rightop(clause); - Assert(op != (Node*) NULL); + Assert(op != (Node *) NULL); if (IsA(op, ArrayRef)) op = ((ArrayRef *) op)->refexpr; Assert(IsA(op, Var)); if (var_is_outer((Var *) op)) { - /* Duplicate just enough of the structure to allow commuting + + /* + * Duplicate just enough of the structure to allow commuting * the clause without changing the original list. Could use * copyObject, but a complete deep copy is overkill. */ @@ -812,13 +820,14 @@ static Oid * generate_merge_input_sortorder(List *pathkeys, MergeOrder *mergeorder) { int listlength = length(pathkeys); - Oid *result = (Oid*) palloc(sizeof(Oid) * (listlength+1)); + Oid *result = (Oid *) palloc(sizeof(Oid) * (listlength + 1)); Oid *nextsortop = result; List *p; foreach(p, pathkeys) { - Var *pkey = (Var*) lfirst((List*) lfirst(p)); + Var *pkey = (Var *) lfirst((List *) lfirst(p)); + Assert(IsA(pkey, Var)); if (pkey->vartype == mergeorder->left_type) *nextsortop++ = mergeorder->left_operator; @@ -826,7 +835,7 @@ generate_merge_input_sortorder(List *pathkeys, MergeOrder *mergeorder) *nextsortop++ = mergeorder->right_operator; else elog(ERROR, - "generate_merge_input_sortorder: can't handle data type %d", + "generate_merge_input_sortorder: can't handle data type %d", pkey->vartype); } *nextsortop++ = InvalidOid; @@ -859,12 +868,13 @@ set_noname_tlist_operators(List *tlist, List *pathkeys, Oid *operators) resdom = tlist_member((Var *) pathkey, tlist); if (resdom) { + /* - * Order the resdom pathkey and replace the operator OID for each - * key with the regproc OID. + * Order the resdom pathkey and replace the operator OID for + * each key with the regproc OID. */ resdom->reskey = keyno; - resdom->reskeyop = get_opcode(operators[keyno-1]); + resdom->reskeyop = get_opcode(operators[keyno - 1]); } keyno += 1; } @@ -878,7 +888,7 @@ set_noname_tlist_operators(List *tlist, List *pathkeys, Oid *operators) */ static void -copy_costsize (Plan *dest, Plan *src) +copy_costsize(Plan *dest, Plan *src) { if (src) { @@ -915,10 +925,10 @@ copy_costsize (Plan *dest, Plan *src) */ static Noname * make_noname(List *tlist, - List *pathkeys, - Oid *operators, - Plan *plan_node, - int nonametype) + List *pathkeys, + Oid *operators, + Plan *plan_node, + int nonametype) { List *noname_tlist; Noname *retval = NULL; @@ -931,22 +941,22 @@ make_noname(List *tlist, { case NONAME_SORT: retval = (Noname *) make_seqscan(tlist, - NIL, - _NONAME_RELATION_ID_, - (Plan *) make_sort(noname_tlist, - _NONAME_RELATION_ID_, - plan_node, - length(pathkeys))); + NIL, + _NONAME_RELATION_ID_, + (Plan *) make_sort(noname_tlist, + _NONAME_RELATION_ID_, + plan_node, + length(pathkeys))); break; case NONAME_MATERIAL: retval = (Noname *) make_seqscan(tlist, - NIL, - _NONAME_RELATION_ID_, - (Plan *) make_material(noname_tlist, - _NONAME_RELATION_ID_, - plan_node, - length(pathkeys))); + NIL, + _NONAME_RELATION_ID_, + (Plan *) make_material(noname_tlist, + _NONAME_RELATION_ID_, + plan_node, + length(pathkeys))); break; default: @@ -1014,8 +1024,9 @@ make_nestloop(List *qptlist, NestLoop *node = makeNode(NestLoop); Plan *plan = &node->join; - /* this cost estimate is entirely bogus... - * hopefully it will be overwritten by caller. + /* + * this cost estimate is entirely bogus... hopefully it will be + * overwritten by caller. */ plan->cost = (lefttree ? lefttree->cost : 0) + (righttree ? righttree->cost : 0); @@ -1039,8 +1050,9 @@ make_hashjoin(List *tlist, HashJoin *node = makeNode(HashJoin); Plan *plan = &node->join; - /* this cost estimate is entirely bogus... - * hopefully it will be overwritten by caller. + /* + * this cost estimate is entirely bogus... hopefully it will be + * overwritten by caller. */ plan->cost = (lefttree ? lefttree->cost : 0) + (righttree ? righttree->cost : 0); @@ -1082,8 +1094,9 @@ make_mergejoin(List *tlist, MergeJoin *node = makeNode(MergeJoin); Plan *plan = &node->join; - /* this cost estimate is entirely bogus... - * hopefully it will be overwritten by caller. + /* + * this cost estimate is entirely bogus... hopefully it will be + * overwritten by caller. */ plan->cost = (lefttree ? lefttree->cost : 0) + (righttree ? righttree->cost : 0); @@ -1142,7 +1155,7 @@ make_agg(List *tlist, Plan *lefttree) { Agg *node = makeNode(Agg); - copy_costsize(& node->plan, lefttree); + copy_costsize(&node->plan, lefttree); node->plan.state = (EState *) NULL; node->plan.qual = NULL; node->plan.targetlist = tlist; @@ -1162,7 +1175,7 @@ make_group(List *tlist, { Group *node = makeNode(Group); - copy_costsize(& node->plan, (Plan *) lefttree); + copy_costsize(&node->plan, (Plan *) lefttree); node->plan.state = (EState *) NULL; node->plan.qual = NULL; node->plan.targetlist = tlist; diff --git a/src/backend/optimizer/plan/initsplan.c b/src/backend/optimizer/plan/initsplan.c index 0b54bd8c4b..592f6e0203 100644 --- a/src/backend/optimizer/plan/initsplan.c +++ b/src/backend/optimizer/plan/initsplan.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.29 1999/02/22 05:26:21 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.30 1999/05/25 16:09:36 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -40,7 +40,7 @@ extern int Quiet; static void add_restrict_and_join_to_rel(Query *root, List *clause); -static void add_join_info_to_rels(Query *root, RestrictInfo *restrictinfo, +static void add_join_info_to_rels(Query *root, RestrictInfo * restrictinfo, Relids join_relids); static void add_vars_to_targetlist(Query *root, List *vars, Relids join_relids); @@ -183,6 +183,7 @@ add_restrict_and_join_to_rel(Query *root, List *clause) if (length(relids) == 1) { + /* * There is only one relation participating in 'clause', so * 'clause' must be a restriction clause. @@ -207,11 +208,13 @@ add_restrict_and_join_to_rel(Query *root, List *clause) } else { + /* * 'clause' is a join clause, since there is more than one atom in * the relid list. */ if (is_funcclause((Node *) clause)) + /* * XXX If we have a func clause set selectivity to 1/3, really * need a true selectivity function. @@ -237,8 +240,8 @@ add_restrict_and_join_to_rel(Query *root, List *clause) * */ static void -add_join_info_to_rels(Query *root, RestrictInfo *restrictinfo, - Relids join_relids) +add_join_info_to_rels(Query *root, RestrictInfo * restrictinfo, + Relids join_relids) { List *join_relid; @@ -247,7 +250,7 @@ add_join_info_to_rels(Query *root, RestrictInfo *restrictinfo, { JoinInfo *joininfo; Relids unjoined_relids = NIL; - List *rel; + List *rel; /* Get the relids not equal to the current relid */ foreach(rel, join_relids) @@ -259,7 +262,7 @@ add_join_info_to_rels(Query *root, RestrictInfo *restrictinfo, joininfo = find_joininfo_node(get_base_rel(root, lfirsti(join_relid)), unjoined_relids); joininfo->jinfo_restrictinfo = lcons(copyObject((void *) restrictinfo), - joininfo->jinfo_restrictinfo); + joininfo->jinfo_restrictinfo); } } @@ -375,7 +378,7 @@ mergejoinop(Expr *clause) rightOp; bool sortable; - if (!is_opclause((Node*) clause)) + if (!is_opclause((Node *) clause)) return NULL; left = get_leftop(clause); @@ -384,7 +387,7 @@ mergejoinop(Expr *clause) /* caution: is_opclause accepts more than I do, so check it */ if (!right) return NULL; /* unary opclauses need not apply */ - if (!IsA(left, Var) || !IsA(right, Var)) + if (!IsA(left, Var) ||!IsA(right, Var)) return NULL; opno = ((Oper *) clause->oper)->opno; @@ -422,7 +425,7 @@ hashjoinop(Expr *clause) Var *left, *right; - if (!is_opclause((Node*) clause)) + if (!is_opclause((Node *) clause)) return InvalidOid; left = get_leftop(clause); @@ -431,7 +434,7 @@ hashjoinop(Expr *clause) /* caution: is_opclause accepts more than I do, so check it */ if (!right) return InvalidOid; /* unary opclauses need not apply */ - if (!IsA(left, Var) || !IsA(right, Var)) + if (!IsA(left, Var) ||!IsA(right, Var)) return InvalidOid; return op_hashjoinable(((Oper *) clause->oper)->opno, diff --git a/src/backend/optimizer/plan/planmain.c b/src/backend/optimizer/plan/planmain.c index 0708e963b4..dae0443e1e 100644 --- a/src/backend/optimizer/plan/planmain.c +++ b/src/backend/optimizer/plan/planmain.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planmain.c,v 1.35 1999/05/03 00:38:43 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planmain.c,v 1.36 1999/05/25 16:09:36 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -154,7 +154,7 @@ query_planner(Query *root, else return (Plan *) scan; } - break; + break; default: return (Plan *) NULL; } @@ -195,9 +195,9 @@ query_planner(Query *root, * tree. -- Wei * * Note: formerly there was a test here to skip the flatten call if we - * expected union_planner to insert a Group or Agg node above our result. - * However, now union_planner tells us exactly what it wants returned, - * and we just do it. Much cleaner. + * expected union_planner to insert a Group or Agg node above our + * result. However, now union_planner tells us exactly what it wants + * returned, and we just do it. Much cleaner. */ else { @@ -207,6 +207,7 @@ query_planner(Query *root, } #ifdef NOT_USED + /* * Destructively modify the query plan's targetlist to add fjoin lists * to flatten functions that return sets of base types @@ -251,7 +252,7 @@ subplanner(Query *root, final_rel = make_one_rel(root, root->base_rel_list); -#ifdef NOT_USED /* fix xfunc */ +#ifdef NOT_USED /* fix xfunc */ /* * Perform Predicate Migration on each path, to optimize and correctly diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c index 86977028f7..65327a1263 100644 --- a/src/backend/optimizer/plan/planner.c +++ b/src/backend/optimizer/plan/planner.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.53 1999/05/17 17:03:15 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.54 1999/05/25 16:09:37 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -56,10 +56,10 @@ #include "parser/parse_oper.h" static List *make_subplanTargetList(Query *parse, List *tlist, - AttrNumber **groupColIdx); + AttrNumber **groupColIdx); static Plan *make_groupplan(List *group_tlist, bool tuplePerGroup, - List *groupClause, AttrNumber *grpColIdx, - Plan *subplan); + List *groupClause, AttrNumber *grpColIdx, + Plan *subplan); static bool need_sortplan(List *sortcls, Plan *plan); static Plan *make_sortplan(List *tlist, List *sortcls, Plan *plannode); @@ -113,12 +113,12 @@ union_planner(Query *parse) if (parse->unionClause) { - result_plan = (Plan *) plan_union_queries(parse); - /* XXX do we need to do this? bjm 12/19/97 */ - tlist = preprocess_targetlist(tlist, - parse->commandType, - parse->resultRelation, - parse->rtable); + result_plan = (Plan *) plan_union_queries(parse); + /* XXX do we need to do this? bjm 12/19/97 */ + tlist = preprocess_targetlist(tlist, + parse->commandType, + parse->resultRelation, + parse->rtable); } else if ((rt_index = first_inherit_rt_entry(rangetable)) != -1) { @@ -127,78 +127,80 @@ union_planner(Query *parse) result_plan = (Plan *) plan_inherit_queries(parse, rt_index); /* XXX do we need to do this? bjm 12/19/97 */ tlist = preprocess_targetlist(tlist, - parse->commandType, - parse->resultRelation, - parse->rtable); + parse->commandType, + parse->resultRelation, + parse->rtable); } else { - List **vpm = NULL; - List *sub_tlist; + List **vpm = NULL; + List *sub_tlist; - /* Preprocess targetlist in case we are inside an INSERT/UPDATE. */ - tlist = preprocess_targetlist(tlist, - parse->commandType, - parse->resultRelation, - parse->rtable); + /* Preprocess targetlist in case we are inside an INSERT/UPDATE. */ + tlist = preprocess_targetlist(tlist, + parse->commandType, + parse->resultRelation, + parse->rtable); - /* Add row-mark targets for UPDATE - * (should this be done in preprocess_targetlist?) - */ - if (parse->rowMark != NULL) - { - List *l; - - foreach (l, parse->rowMark) + /* + * Add row-mark targets for UPDATE (should this be done in + * preprocess_targetlist?) + */ + if (parse->rowMark != NULL) { - RowMark *rowmark = (RowMark*) lfirst(l); - TargetEntry *ctid; - Resdom *resdom; - Var *var; - char *resname; + List *l; - if (!(rowmark->info & ROW_MARK_FOR_UPDATE)) - continue; + foreach(l, parse->rowMark) + { + RowMark *rowmark = (RowMark *) lfirst(l); + TargetEntry *ctid; + Resdom *resdom; + Var *var; + char *resname; - resname = (char*) palloc(32); - sprintf(resname, "ctid%u", rowmark->rti); - resdom = makeResdom(length(tlist) + 1, - TIDOID, - -1, - resname, - 0, - 0, - true); + if (!(rowmark->info & ROW_MARK_FOR_UPDATE)) + continue; - var = makeVar(rowmark->rti, -1, TIDOID, - -1, 0, rowmark->rti, -1); + resname = (char *) palloc(32); + sprintf(resname, "ctid%u", rowmark->rti); + resdom = makeResdom(length(tlist) + 1, + TIDOID, + -1, + resname, + 0, + 0, + true); - ctid = makeTargetEntry(resdom, (Node *) var); - tlist = lappend(tlist, ctid); + var = makeVar(rowmark->rti, -1, TIDOID, + -1, 0, rowmark->rti, -1); + + ctid = makeTargetEntry(resdom, (Node *) var); + tlist = lappend(tlist, ctid); + } } - } - /* Generate appropriate target list for subplan; may be different - * from tlist if grouping or aggregation is needed. - */ - sub_tlist = make_subplanTargetList(parse, tlist, &groupColIdx); + /* + * Generate appropriate target list for subplan; may be different + * from tlist if grouping or aggregation is needed. + */ + sub_tlist = make_subplanTargetList(parse, tlist, &groupColIdx); - /* Generate the (sub) plan */ - if (parse->rtable != NULL) - { - vpm = (List **) palloc(length(parse->rtable) * sizeof(List *)); - memset(vpm, 0, length(parse->rtable) * sizeof(List *)); - } - PlannerVarParam = lcons(vpm, PlannerVarParam); - result_plan = query_planner(parse, - parse->commandType, - sub_tlist, - (List *) parse->qual); - PlannerVarParam = lnext(PlannerVarParam); - if (vpm != NULL) - pfree(vpm); + /* Generate the (sub) plan */ + if (parse->rtable != NULL) + { + vpm = (List **) palloc(length(parse->rtable) * sizeof(List *)); + memset(vpm, 0, length(parse->rtable) * sizeof(List *)); + } + PlannerVarParam = lcons(vpm, PlannerVarParam); + result_plan = query_planner(parse, + parse->commandType, + sub_tlist, + (List *) parse->qual); + PlannerVarParam = lnext(PlannerVarParam); + if (vpm != NULL) + pfree(vpm); } - + /* * If we have a GROUP BY clause, insert a group node (with the * appropriate sort node.) @@ -216,7 +218,8 @@ union_planner(Query *parse) */ tuplePerGroup = parse->hasAggs; - /* If there are aggregates then the Group node should just return + /* + * If there are aggregates then the Group node should just return * the same (simplified) tlist as the subplan, which we indicate * to make_groupplan by passing NIL. If there are no aggregates * then the Group node had better compute the final tlist. @@ -235,7 +238,7 @@ union_planner(Query *parse) */ if (parse->havingQual) { - List **vpm = NULL; + List **vpm = NULL; if (parse->rtable != NULL) { @@ -249,15 +252,20 @@ union_planner(Query *parse) if (parse->hasSubLinks) { - /* There is a subselect in the havingQual, so we have to process it - * using the same function as for a subselect in 'where' + + /* + * There is a subselect in the havingQual, so we have to + * process it using the same function as for a subselect in + * 'where' */ parse->havingQual = (Node *) SS_process_sublinks(parse->havingQual); - /* Check for ungrouped variables passed to subplans. - * (Probably this should be done by the parser, but right now - * the parser is not smart enough to tell which level the vars - * belong to?) + + /* + * Check for ungrouped variables passed to subplans. (Probably + * this should be done by the parser, but right now the parser + * is not smart enough to tell which level the vars belong + * to?) */ check_having_for_ungrouped_vars(parse->havingQual, parse->groupClause, @@ -269,7 +277,7 @@ union_planner(Query *parse) PlannerVarParam = lnext(PlannerVarParam); if (vpm != NULL) - pfree(vpm); + pfree(vpm); } /* @@ -283,22 +291,22 @@ union_planner(Query *parse) result_plan->qual = (List *) parse->havingQual; /* - * Update vars to refer to subplan result tuples, - * find Aggrefs, make sure there is an Aggref in every HAVING clause. + * Update vars to refer to subplan result tuples, find Aggrefs, + * make sure there is an Aggref in every HAVING clause. */ - if (! set_agg_tlist_references((Agg *) result_plan)) + if (!set_agg_tlist_references((Agg *) result_plan)) elog(ERROR, "SELECT/HAVING requires aggregates to be valid"); /* * Check that we actually found some aggregates, else executor * will die unpleasantly. (The rewrite module currently has bugs - * that allow hasAggs to be incorrectly set 'true' sometimes. - * It's not easy to recover here, since we've already made decisions + * that allow hasAggs to be incorrectly set 'true' sometimes. It's + * not easy to recover here, since we've already made decisions * assuming there will be an Agg node.) */ if (((Agg *) result_plan)->aggs == NIL) elog(ERROR, "union_planner: query is marked hasAggs, but I don't see any"); - } + } /* * For now, before we hand back the plan, check to see if there is a @@ -363,7 +371,7 @@ union_planner(Query *parse) * SELECT a+1, ... GROUP BY a+1 * Note, however, that other varnodes in the parent's targetlist (and * havingQual, if any) will still need to be updated to refer to outputs - * of the subplan. This routine is quite large enough already, so we do + * of the subplan. This routine is quite large enough already, so we do * that later. *--------------- */ @@ -384,13 +392,15 @@ make_subplanTargetList(Query *parse, *groupColIdx = NULL; - /* If we're not grouping or aggregating, nothing to do here; + /* + * If we're not grouping or aggregating, nothing to do here; * query_planner should receive the unmodified target list. */ if (!parse->hasAggs && !parse->groupClause && !parse->havingQual) return tlist; - /* If grouping, make a working copy of groupClause list (which we use + /* + * If grouping, make a working copy of groupClause list (which we use * just to verify that we found all the groupClause items in tlist). * Also allocate space to remember where the group columns are in the * subplan tlist. @@ -403,14 +413,14 @@ make_subplanTargetList(Query *parse, *groupColIdx = grpColIdx; } - sub_tlist = new_unsorted_tlist(tlist); /* make a modifiable copy */ + sub_tlist = new_unsorted_tlist(tlist); /* make a modifiable copy */ /* * Step 1: build grpColIdx by finding targetlist items that match * GroupBy entries. If there are aggregates, remove non-GroupBy items * from sub_tlist, and reset its resnos accordingly. When we leave an - * expression in the subplan tlist, modify the parent tlist to copy the - * value from the subplan output rather than re-evaluating it. + * expression in the subplan tlist, modify the parent tlist to copy + * the value from the subplan output rather than re-evaluating it. */ prnt_tlist = tlist; /* scans parent tlist in sync with sl */ foreach(sl, sub_tlist) @@ -434,23 +444,28 @@ make_subplanTargetList(Query *parse, resdom->reskey = keyno; resdom->reskeyop = get_opcode(grpcl->grpOpoid); grpColIdx[keyno - 1] = next_resno; - /* Remove groupclause from our list of unmatched groupclauses. - * NB: this depends on having used a shallow listCopy() above. + + /* + * Remove groupclause from our list of unmatched + * groupclauses. NB: this depends on having used a shallow + * listCopy() above. */ - glc = lremove((void*) grpcl, glc); + glc = lremove((void *) grpcl, glc); break; } } - if (! foundGroupClause) + if (!foundGroupClause) { + /* * Non-GroupBy entry: remove it from subplan if there are - * aggregates in query - it will be evaluated by Aggregate plan. - * But do not remove simple-Var entries; we'd just have to add - * them back anyway, and we risk confusing INSERT/UPDATE. + * aggregates in query - it will be evaluated by Aggregate + * plan. But do not remove simple-Var entries; we'd just have + * to add them back anyway, and we risk confusing + * INSERT/UPDATE. */ - if (parse->hasAggs && ! IsA(te->expr, Var)) + if (parse->hasAggs && !IsA(te->expr, Var)) keepInSubPlan = false; } @@ -458,15 +473,16 @@ make_subplanTargetList(Query *parse, { /* Assign new sequential resnos to subplan tlist items */ resdom->resno = next_resno++; - if (! IsA(parentte->expr, Var)) + if (!IsA(parentte->expr, Var)) { - /* Since the item is being computed in the subplan, - * we can just make a Var node to reference it in the - * outer plan, rather than recomputing it there. - * Note we use varnoold = -1 as a flag to let - * replace_vars_with_subplan_refs know it needn't change - * this Var node. - * If it's only a Var anyway, we leave it alone for now; + + /* + * Since the item is being computed in the subplan, we can + * just make a Var node to reference it in the outer plan, + * rather than recomputing it there. Note we use varnoold + * = -1 as a flag to let replace_vars_with_subplan_refs + * know it needn't change this Var node. If it's only a + * Var anyway, we leave it alone for now; * replace_vars_with_subplan_refs will fix it later. */ parentte->expr = (Node *) makeVar(1, resdom->resno, @@ -477,9 +493,11 @@ make_subplanTargetList(Query *parse, } else { - /* Remove this tlist item from the subplan, but remember the - * vars it needs. The outer tlist item probably needs changes, - * but that will happen later. + + /* + * Remove this tlist item from the subplan, but remember the + * vars it needs. The outer tlist item probably needs + * changes, but that will happen later. */ sub_tlist = lremove(te, sub_tlist); extravars = nconc(extravars, pull_var_clause(te->expr)); @@ -493,8 +511,8 @@ make_subplanTargetList(Query *parse, elog(ERROR, "make_subplanTargetList: GROUP BY attribute not found in target list"); /* - * Add subplan targets for any variables needed by removed tlist entries - * that aren't otherwise mentioned in the subplan target list. + * Add subplan targets for any variables needed by removed tlist + * entries that aren't otherwise mentioned in the subplan target list. * We'll also need targets for any variables seen only in HAVING. */ extravars = nconc(extravars, pull_var_clause(parse->havingQual)); @@ -505,9 +523,11 @@ make_subplanTargetList(Query *parse, if (tlist_member(v, sub_tlist) == NULL) { - /* Make sure sub_tlist element is a fresh object not shared with - * any other structure; not sure if anything will break if it is - * shared, but better to be safe... + + /* + * Make sure sub_tlist element is a fresh object not shared + * with any other structure; not sure if anything will break + * if it is shared, but better to be safe... */ sub_tlist = lappend(sub_tlist, create_tl_element((Var *) copyObject(v), @@ -535,9 +555,9 @@ make_groupplan(List *group_tlist, /* * Make the targetlist for the Sort node; it always just references * each of the corresponding target items of the subplan. We need to - * ensure that simple Vars in the subplan's target list are recognizable - * by replace_vars_with_subplan_refs when it's applied to the Sort/Group - * target list, so copy up their varnoold/varoattno. + * ensure that simple Vars in the subplan's target list are + * recognizable by replace_vars_with_subplan_refs when it's applied to + * the Sort/Group target list, so copy up their varnoold/varoattno. */ sort_tlist = NIL; foreach(sl, subplan->targetlist) @@ -548,7 +568,8 @@ make_groupplan(List *group_tlist, if (IsA(te->expr, Var)) { - Var *subvar = (Var *) te->expr; + Var *subvar = (Var *) te->expr; + newvar = makeVar(1, resdom->resno, resdom->restype, resdom->restypmod, 0, subvar->varnoold, subvar->varoattno); @@ -561,8 +582,8 @@ make_groupplan(List *group_tlist, } sort_tlist = lappend(sort_tlist, - makeTargetEntry((Resdom *) copyObject(resdom), - (Node *) newvar)); + makeTargetEntry((Resdom *) copyObject(resdom), + (Node *) newvar)); } /* @@ -575,20 +596,19 @@ make_groupplan(List *group_tlist, sortplan->plan.cost = subplan->cost; /* XXX assume no cost */ /* - * If the caller gave us a target list, use it after fixing the variables. - * If not, we need the same sort of "repeater" tlist as for the Sort node. + * If the caller gave us a target list, use it after fixing the + * variables. If not, we need the same sort of "repeater" tlist as for + * the Sort node. */ if (group_tlist) { - group_tlist = copyObject(group_tlist); /* necessary?? */ + group_tlist = copyObject(group_tlist); /* necessary?? */ replace_tlist_with_subplan_refs(group_tlist, (Index) 0, subplan->targetlist); } else - { group_tlist = copyObject(sort_tlist); - } /* * Make the Group node @@ -686,7 +706,7 @@ pg_checkretval(Oid rettype, List *queryTreeList) int i; /* find the final query */ - parse = (Query *) nth(length(queryTreeList)-1, queryTreeList); + parse = (Query *) nth(length(queryTreeList) - 1, queryTreeList); /* * test 1: if the last query is a utility invocation, then there had @@ -787,7 +807,7 @@ pg_checkretval(Oid rettype, List *queryTreeList) tlist = lnext(tlist); tletype = exprType(thenode); -#ifdef NOT_USED /* fix me */ +#ifdef NOT_USED /* fix me */ /* this is tedious */ if (IsA(thenode, Var)) tletype = (Oid) ((Var *) thenode)->vartype; @@ -830,11 +850,12 @@ pg_checkretval(Oid rettype, List *queryTreeList) static TargetEntry * get_matching_tle(Plan *plan, Resdom *resdom) { - List *i; - TargetEntry *tle; + List *i; + TargetEntry *tle; - foreach (i, plan->targetlist) { - tle = (TargetEntry *)lfirst(i); + foreach(i, plan->targetlist) + { + tle = (TargetEntry *) lfirst(i); if (tle->resdom->resno == resdom->resno) return tle; } @@ -853,50 +874,45 @@ static bool need_sortplan(List *sortcls, Plan *plan) { Relation indexRel; - IndexScan *indexScan; - Oid indexId; - List *i; + IndexScan *indexScan; + Oid indexId; + List *i; HeapTuple htup; - Form_pg_index index_tup; - int key_no = 0; + Form_pg_index index_tup; + int key_no = 0; /* ---------- * Must be an IndexScan * ---------- */ - if (nodeTag(plan) != T_IndexScan) { + if (nodeTag(plan) != T_IndexScan) return TRUE; - } - indexScan = (IndexScan *)plan; + indexScan = (IndexScan *) plan; /* ---------- * Should not have left- or righttree * ---------- */ - if (plan->lefttree != NULL) { + if (plan->lefttree != NULL) return TRUE; - } - if (plan->righttree != NULL) { + if (plan->righttree != NULL) return TRUE; - } /* ---------- * Must be a single index scan * ---------- */ - if (length(indexScan->indxid) != 1) { + if (length(indexScan->indxid) != 1) return TRUE; - } /* ---------- * Indices can only have up to 8 attributes. So an ORDER BY using * more that 8 attributes could never be satisfied by an index. * ---------- */ - if (length(sortcls) > 8) { + if (length(sortcls) > 8) return TRUE; - } /* ---------- * The choosen Index must be a btree @@ -905,7 +921,8 @@ need_sortplan(List *sortcls, Plan *plan) indexId = lfirsti(indexScan->indxid); indexRel = index_open(indexId); - if (strcmp(nameout(&(indexRel->rd_am->amname)), "btree") != 0) { + if (strcmp(nameout(&(indexRel->rd_am->amname)), "btree") != 0) + { heap_close(indexRel); return TRUE; } @@ -916,34 +933,36 @@ need_sortplan(List *sortcls, Plan *plan) * ---------- */ htup = SearchSysCacheTuple(INDEXRELID, - ObjectIdGetDatum(indexId), 0, 0, 0); - if (!HeapTupleIsValid(htup)) { + ObjectIdGetDatum(indexId), 0, 0, 0); + if (!HeapTupleIsValid(htup)) elog(ERROR, "cache lookup for index %u failed", indexId); - } index_tup = (Form_pg_index) GETSTRUCT(htup); /* ---------- * Check if all the sort clauses match the attributes in the index * ---------- */ - foreach (i, sortcls) { - SortClause *sortcl; - Resdom *resdom; - TargetEntry *tle; - Var *var; + foreach(i, sortcls) + { + SortClause *sortcl; + Resdom *resdom; + TargetEntry *tle; + Var *var; sortcl = (SortClause *) lfirst(i); resdom = sortcl->resdom; tle = get_matching_tle(plan, resdom); - if (tle == NULL) { + if (tle == NULL) + { /* ---------- * Could this happen? * ---------- */ return TRUE; } - if (nodeTag(tle->expr) != T_Var) { + if (nodeTag(tle->expr) != T_Var) + { /* ---------- * The target list expression isn't a var, so it * cannot be the indexed attribute @@ -951,9 +970,10 @@ need_sortplan(List *sortcls, Plan *plan) */ return TRUE; } - var = (Var *)(tle->expr); + var = (Var *) (tle->expr); - if (var->varno != indexScan->scan.scanrelid) { + if (var->varno != indexScan->scan.scanrelid) + { /* ---------- * This Var isn't from the scan relation. So it isn't * that of the index @@ -962,7 +982,8 @@ need_sortplan(List *sortcls, Plan *plan) return TRUE; } - if (var->varattno != index_tup->indkey[key_no]) { + if (var->varattno != index_tup->indkey[key_no]) + { /* ---------- * It isn't the indexed attribute. * ---------- @@ -970,7 +991,8 @@ need_sortplan(List *sortcls, Plan *plan) return TRUE; } - if (oprid(oper("<", resdom->restype, resdom->restype, FALSE)) != sortcl->opoid) { + if (oprid(oper("<", resdom->restype, resdom->restype, FALSE)) != sortcl->opoid) + { /* ---------- * Sort order isn't in ascending order. * ---------- @@ -987,4 +1009,3 @@ need_sortplan(List *sortcls, Plan *plan) */ return FALSE; } - diff --git a/src/backend/optimizer/plan/setrefs.c b/src/backend/optimizer/plan/setrefs.c index ee3250080c..31d1205a45 100644 --- a/src/backend/optimizer/plan/setrefs.c +++ b/src/backend/optimizer/plan/setrefs.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/setrefs.c,v 1.46 1999/05/12 15:01:39 wieck Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/setrefs.c,v 1.47 1999/05/25 16:09:39 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -35,13 +35,13 @@ static void set_join_tlist_references(Join *join); static void set_nonamescan_tlist_references(SeqScan *nonamescan); -static void set_noname_tlist_references(Noname *noname); +static void set_noname_tlist_references(Noname * noname); static Node *replace_clause_joinvar_refs(Node *clause, - List *outer_tlist, - List *inner_tlist); + List *outer_tlist, + List *inner_tlist); static Var *replace_joinvar_refs(Var *var, - List *outer_tlist, - List *inner_tlist); + List *outer_tlist, + List *inner_tlist); static List *tlist_noname_references(Oid nonameid, List *tlist); static bool OperandIsInner(Node *opnd, int inner_relid); static List *pull_agg_clause(Node *clause); @@ -114,11 +114,12 @@ set_join_tlist_references(Join *join) foreach(entry, qptlist) { TargetEntry *xtl = (TargetEntry *) lfirst(entry); - Node *joinvar = replace_clause_joinvar_refs(xtl->expr, - outer_tlist, - inner_tlist); + Node *joinvar = replace_clause_joinvar_refs(xtl->expr, + outer_tlist, + inner_tlist); + new_join_targetlist = lappend(new_join_targetlist, - makeTargetEntry(xtl->resdom, joinvar)); + makeTargetEntry(xtl->resdom, joinvar)); } ((Plan *) join)->targetlist = new_join_targetlist; @@ -144,7 +145,7 @@ set_nonamescan_tlist_references(SeqScan *nonamescan) Noname *noname = (Noname *) ((Plan *) nonamescan)->lefttree; ((Plan *) nonamescan)->targetlist = tlist_noname_references(noname->nonameid, - ((Plan *) nonamescan)->targetlist); + ((Plan *) nonamescan)->targetlist); set_noname_tlist_references(noname); } @@ -160,7 +161,7 @@ set_nonamescan_tlist_references(SeqScan *nonamescan) * */ static void -set_noname_tlist_references(Noname *noname) +set_noname_tlist_references(Noname * noname) { Plan *source = ((Plan *) noname)->lefttree; @@ -168,7 +169,7 @@ set_noname_tlist_references(Noname *noname) { set_tlist_references(source); ((Plan *) noname)->targetlist = copy_vars(((Plan *) noname)->targetlist, - (source)->targetlist); + (source)->targetlist); } else elog(ERROR, "calling set_noname_tlist_references with empty lefttree"); @@ -235,9 +236,9 @@ index_outerjoin_references(List *inner_indxqual, if (OperandIsInner((Node *) get_rightop(clause), inner_relid)) { Var *joinvar = (Var *) - replace_clause_joinvar_refs((Node *) get_leftop(clause), - outer_tlist, - NIL); + replace_clause_joinvar_refs((Node *) get_leftop(clause), + outer_tlist, + NIL); temp = make_opclause(replace_opid((Oper *) ((Expr *) clause)->oper), joinvar, @@ -248,9 +249,9 @@ index_outerjoin_references(List *inner_indxqual, { /* inner scan on left */ Var *joinvar = (Var *) - replace_clause_joinvar_refs((Node *) get_rightop(clause), - outer_tlist, - NIL); + replace_clause_joinvar_refs((Node *) get_rightop(clause), + outer_tlist, + NIL); temp = make_opclause(replace_opid((Oper *) ((Expr *) clause)->oper), get_leftop(clause), @@ -290,8 +291,9 @@ replace_clause_joinvar_refs(Node *clause, return NULL; if (IsA(clause, Var)) { - Var *temp = replace_joinvar_refs((Var *) clause, - outer_tlist, inner_tlist); + Var *temp = replace_joinvar_refs((Var *) clause, + outer_tlist, inner_tlist); + if (temp != NULL) return (Node *) temp; else @@ -344,32 +346,32 @@ replace_clause_joinvar_refs(Node *clause, else if (is_funcclause(clause)) { return (Node *) make_funcclause( - (Func *) ((Expr *) clause)->oper, - (List *) replace_clause_joinvar_refs( - (Node *) ((Expr *) clause)->args, - outer_tlist, - inner_tlist)); + (Func *) ((Expr *) clause)->oper, + (List *) replace_clause_joinvar_refs( + (Node *) ((Expr *) clause)->args, + outer_tlist, + inner_tlist)); } else if (not_clause(clause)) { return (Node *) make_notclause((Expr *) - replace_clause_joinvar_refs( - (Node *) get_notclausearg((Expr *) clause), - outer_tlist, - inner_tlist)); + replace_clause_joinvar_refs( + (Node *) get_notclausearg((Expr *) clause), + outer_tlist, + inner_tlist)); } else if (is_opclause(clause)) { return (Node *) make_opclause( - replace_opid((Oper *) ((Expr *) clause)->oper), - (Var *) replace_clause_joinvar_refs( - (Node *) get_leftop((Expr *) clause), - outer_tlist, - inner_tlist), - (Var *) replace_clause_joinvar_refs( - (Node *) get_rightop((Expr *) clause), - outer_tlist, - inner_tlist)); + replace_opid((Oper *) ((Expr *) clause)->oper), + (Var *) replace_clause_joinvar_refs( + (Node *) get_leftop((Expr *) clause), + outer_tlist, + inner_tlist), + (Var *) replace_clause_joinvar_refs( + (Node *) get_rightop((Expr *) clause), + outer_tlist, + inner_tlist)); } else if (IsA(clause, List)) { @@ -379,25 +381,26 @@ replace_clause_joinvar_refs(Node *clause, foreach(subclause, (List *) clause) { t_list = lappend(t_list, - replace_clause_joinvar_refs(lfirst(subclause), - outer_tlist, - inner_tlist)); + replace_clause_joinvar_refs(lfirst(subclause), + outer_tlist, + inner_tlist)); } return (Node *) t_list; } else if (is_subplan(clause)) { /* This is a tad wasteful of space, but it works... */ - Expr *newclause = (Expr *) copyObject(clause); + Expr *newclause = (Expr *) copyObject(clause); + newclause->args = (List *) replace_clause_joinvar_refs((Node *) newclause->args, outer_tlist, inner_tlist); ((SubPlan *) newclause->oper)->sublink->oper = (List *) replace_clause_joinvar_refs( - (Node *) ((SubPlan *) newclause->oper)->sublink->oper, - outer_tlist, - inner_tlist); + (Node *) ((SubPlan *) newclause->oper)->sublink->oper, + outer_tlist, + inner_tlist); return (Node *) newclause; } else if (IsA(clause, CaseExpr)) @@ -406,7 +409,8 @@ replace_clause_joinvar_refs(Node *clause, CaseExpr *newnode = makeNode(CaseExpr); newnode->casetype = oldnode->casetype; - newnode->arg = oldnode->arg; /* XXX should always be null anyway ... */ + newnode->arg = oldnode->arg; /* XXX should always be null + * anyway ... */ newnode->args = (List *) replace_clause_joinvar_refs((Node *) oldnode->args, outer_tlist, @@ -494,7 +498,7 @@ replace_joinvar_refs(Var *var, List *outer_tlist, List *inner_tlist) */ static List * tlist_noname_references(Oid nonameid, - List *tlist) + List *tlist) { List *t_list = NIL; TargetEntry *noname = (TargetEntry *) NULL; @@ -512,13 +516,13 @@ tlist_noname_references(Oid nonameid, oattno = 0; noname = makeTargetEntry(xtl->resdom, - (Node *) makeVar(nonameid, - xtl->resdom->resno, - xtl->resdom->restype, - xtl->resdom->restypmod, - 0, - nonameid, - oattno)); + (Node *) makeVar(nonameid, + xtl->resdom->resno, + xtl->resdom->restype, + xtl->resdom->restypmod, + 0, + nonameid, + oattno)); t_list = lappend(t_list, noname); } @@ -573,11 +577,12 @@ replace_tlist_with_subplan_refs(List *tlist, Index subvarno, List *subplanTargetList) { - List *t; + List *t; foreach(t, tlist) { TargetEntry *entry = (TargetEntry *) lfirst(t); + replace_vars_with_subplan_refs((Node *) get_expr(entry), subvarno, subplanTargetList); } @@ -609,19 +614,20 @@ replace_vars_with_subplan_refs(Node *clause, return; if (IsA(clause, Var)) { + /* * Ha! A Var node! * * It could be that this varnode has been created by make_groupplan - * and is already set up to reference the subplan target list. - * We recognize that case by varno = 1, varnoold = -1, - * varattno = varoattno, and varlevelsup = 0. (Probably ought to - * have an explicit flag, but this should do for now.) + * and is already set up to reference the subplan target list. We + * recognize that case by varno = 1, varnoold = -1, varattno = + * varoattno, and varlevelsup = 0. (Probably ought to have an + * explicit flag, but this should do for now.) */ - Var *var = (Var *) clause; + Var *var = (Var *) clause; TargetEntry *subplanVar; - if (var->varno == (Index) 1 && + if (var->varno == (Index) 1 && var->varnoold == ((Index) -1) && var->varattno == var->varoattno && var->varlevelsup == 0) @@ -629,7 +635,7 @@ replace_vars_with_subplan_refs(Node *clause, /* Otherwise it had better be in the subplan list. */ subplanVar = match_varid(var, subplanTargetList); - if (! subplanVar) + if (!subplanVar) elog(ERROR, "replace_vars_with_subplan_refs: variable not in target list"); /* @@ -656,10 +662,11 @@ replace_vars_with_subplan_refs(Node *clause, } else if (IsA(clause, Expr)) { + /* - * Recursively scan the arguments of an expression. - * NOTE: this must come after is_subplan() case since - * subplan is a kind of Expr node. + * Recursively scan the arguments of an expression. NOTE: this + * must come after is_subplan() case since subplan is a kind of + * Expr node. */ foreach(t, ((Expr *) clause)->args) replace_vars_with_subplan_refs(lfirst(t), @@ -671,6 +678,7 @@ replace_vars_with_subplan_refs(Node *clause, else if (IsA(clause, ArrayRef)) { ArrayRef *aref = (ArrayRef *) clause; + foreach(t, aref->refupperindexpr) replace_vars_with_subplan_refs(lfirst(t), subvarno, subplanTargetList); @@ -687,6 +695,7 @@ replace_vars_with_subplan_refs(Node *clause, foreach(t, ((CaseExpr *) clause)->args) { CaseWhen *when = (CaseWhen *) lfirst(t); + replace_vars_with_subplan_refs(when->expr, subvarno, subplanTargetList); replace_vars_with_subplan_refs(when->result, @@ -767,15 +776,16 @@ set_agg_tlist_references(Agg *aggNode) all_quals_ok = true; foreach(ql, aggNode->plan.qual) { - Node *qual = lfirst(ql); - List *qualaggs; + Node *qual = lfirst(ql); + List *qualaggs; replace_vars_with_subplan_refs(qual, (Index) 0, subplanTargetList); qualaggs = pull_agg_clause(qual); if (qualaggs == NIL) - all_quals_ok = false; /* this qual clause has no agg functions! */ + all_quals_ok = false; /* this qual clause has no agg + * functions! */ else aggNode->aggs = nconc(qualaggs, aggNode->aggs); } @@ -800,7 +810,7 @@ pull_agg_clause(Node *clause) return pull_agg_clause(((Iter *) clause)->iterexpr); else if (is_subplan(clause)) { - SubLink *sublink = ((SubPlan *) ((Expr *) clause)->oper)->sublink; + SubLink *sublink = ((SubPlan *) ((Expr *) clause)->oper)->sublink; /* * Only the lefthand side of the sublink should be checked for @@ -814,10 +824,11 @@ pull_agg_clause(Node *clause) } else if (IsA(clause, Expr)) { + /* - * Recursively scan the arguments of an expression. - * NOTE: this must come after is_subplan() case since - * subplan is a kind of Expr node. + * Recursively scan the arguments of an expression. NOTE: this + * must come after is_subplan() case since subplan is a kind of + * Expr node. */ foreach(t, ((Expr *) clause)->args) agg_list = nconc(pull_agg_clause(lfirst(t)), agg_list); @@ -830,6 +841,7 @@ pull_agg_clause(Node *clause) else if (IsA(clause, ArrayRef)) { ArrayRef *aref = (ArrayRef *) clause; + foreach(t, aref->refupperindexpr) agg_list = nconc(pull_agg_clause(lfirst(t)), agg_list); foreach(t, aref->reflowerindexpr) @@ -842,6 +854,7 @@ pull_agg_clause(Node *clause) foreach(t, ((CaseExpr *) clause)->args) { CaseWhen *when = (CaseWhen *) lfirst(t); + agg_list = nconc(agg_list, pull_agg_clause(when->expr)); agg_list = nconc(agg_list, pull_agg_clause(when->result)); } @@ -951,7 +964,7 @@ del_agg_clause(Node *clause) * GROUP BY clauses and checks for subplans in the havingQual that are being * passed ungrouped variables as parameters. In other contexts, ungrouped * vars in the havingQual will be detected by the parser (see parse_agg.c, - * exprIsAggOrGroupCol()). But that routine currently does not check subplans, + * exprIsAggOrGroupCol()). But that routine currently does not check subplans, * because the necessary info is not computed until the planner runs. * This ought to be cleaned up someday. * @@ -962,7 +975,7 @@ del_agg_clause(Node *clause) void check_having_for_ungrouped_vars(Node *clause, List *groupClause, - List *targetList) + List *targetList) { List *t; @@ -971,8 +984,10 @@ check_having_for_ungrouped_vars(Node *clause, List *groupClause, if (IsA(clause, Var)) { - /* Ignore vars elsewhere in the having clause, since the - * parser already checked 'em. + + /* + * Ignore vars elsewhere in the having clause, since the parser + * already checked 'em. */ } else if (single_node(clause)) @@ -986,20 +1001,21 @@ check_having_for_ungrouped_vars(Node *clause, List *groupClause, } else if (is_subplan(clause)) { + /* - * The args list of the subplan node represents attributes from outside - * passed into the sublink. + * The args list of the subplan node represents attributes from + * outside passed into the sublink. */ foreach(t, ((Expr *) clause)->args) { - bool contained_in_group_clause = false; + bool contained_in_group_clause = false; List *gl; foreach(gl, groupClause) { if (var_equal(lfirst(t), - get_groupclause_expr((GroupClause *) - lfirst(gl), targetList))) + get_groupclause_expr((GroupClause *) + lfirst(gl), targetList))) { contained_in_group_clause = true; break; @@ -1012,23 +1028,25 @@ check_having_for_ungrouped_vars(Node *clause, List *groupClause, } else if (IsA(clause, Expr)) { + /* - * Recursively scan the arguments of an expression. - * NOTE: this must come after is_subplan() case since - * subplan is a kind of Expr node. + * Recursively scan the arguments of an expression. NOTE: this + * must come after is_subplan() case since subplan is a kind of + * Expr node. */ foreach(t, ((Expr *) clause)->args) check_having_for_ungrouped_vars(lfirst(t), groupClause, - targetList); + targetList); } else if (IsA(clause, List)) { + /* * Recursively scan AND subclauses (see NOTE above). */ foreach(t, ((List *) clause)) check_having_for_ungrouped_vars(lfirst(t), groupClause, - targetList); + targetList); } else if (IsA(clause, Aggref)) { @@ -1045,24 +1063,25 @@ check_having_for_ungrouped_vars(Node *clause, List *groupClause, */ foreach(t, aref->refupperindexpr) check_having_for_ungrouped_vars(lfirst(t), groupClause, - targetList); + targetList); foreach(t, aref->reflowerindexpr) check_having_for_ungrouped_vars(lfirst(t), groupClause, - targetList); + targetList); check_having_for_ungrouped_vars(aref->refexpr, groupClause, - targetList); + targetList); check_having_for_ungrouped_vars(aref->refassgnexpr, groupClause, - targetList); + targetList); } else if (case_clause(clause)) { foreach(t, ((CaseExpr *) clause)->args) { CaseWhen *when = (CaseWhen *) lfirst(t); + check_having_for_ungrouped_vars(when->expr, groupClause, - targetList); + targetList); check_having_for_ungrouped_vars(when->result, groupClause, - targetList); + targetList); } check_having_for_ungrouped_vars(((CaseExpr *) clause)->defresult, groupClause, targetList); diff --git a/src/backend/optimizer/plan/subselect.c b/src/backend/optimizer/plan/subselect.c index a4b67ba6e0..82eb2efceb 100644 --- a/src/backend/optimizer/plan/subselect.c +++ b/src/backend/optimizer/plan/subselect.c @@ -338,9 +338,7 @@ SS_replace_correlation_vars(Node *expr) } } else if (IsA(expr, Iter)) - { ((Iter *) expr)->iterexpr = SS_replace_correlation_vars(((Iter *) expr)->iterexpr); - } else if (single_node(expr)) return expr; else if (or_clause(expr) || and_clause(expr) || is_opclause(expr) || @@ -398,9 +396,7 @@ SS_process_sublinks(Node *expr) ((Expr *) expr)->args = (List *) SS_process_sublinks((Node *) ((Expr *) expr)->args); else if (IsA(expr, SubLink))/* got it! */ - { expr = _make_subplan((SubLink *) expr); - } return expr; } @@ -529,13 +525,13 @@ SS_pull_subplan(Node *expr) return SS_pull_subplan(((Aggref *) expr)->target); else if (IsA(expr, ArrayRef)) { - result = SS_pull_subplan((Node *)((ArrayRef *) expr)->refupperindexpr); + result = SS_pull_subplan((Node *) ((ArrayRef *) expr)->refupperindexpr); result = nconc(result, - SS_pull_subplan((Node*) ((ArrayRef *) expr)->reflowerindexpr)); + SS_pull_subplan((Node *) ((ArrayRef *) expr)->reflowerindexpr)); result = nconc(result, SS_pull_subplan(((ArrayRef *) expr)->refexpr)); result = nconc(result, - SS_pull_subplan(((ArrayRef *) expr)->refassgnexpr)); + SS_pull_subplan(((ArrayRef *) expr)->refassgnexpr)); } else if (IsA(expr, TargetEntry)) return SS_pull_subplan(((TargetEntry *) expr)->expr); diff --git a/src/backend/optimizer/prep/prepkeyset.c b/src/backend/optimizer/prep/prepkeyset.c index 979796ffe2..914779b4f6 100644 --- a/src/backend/optimizer/prep/prepkeyset.c +++ b/src/backend/optimizer/prep/prepkeyset.c @@ -15,89 +15,90 @@ /* * Node_Copy - * a macro to simplify calling of copyObject on the specified field + * a macro to simplify calling of copyObject on the specified field */ #define Node_Copy(from, newnode, field) newnode->field = copyObject(from->field) -bool _use_keyset_query_optimizer = FALSE; +bool _use_keyset_query_optimizer = FALSE; -static int inspectOpNode(Expr *expr); -static int inspectAndNode(Expr *expr); -static int inspectOrNode(Expr *expr); -static int TotalExpr; +static int inspectOpNode(Expr *expr); +static int inspectAndNode(Expr *expr); +static int inspectOrNode(Expr *expr); +static int TotalExpr; /********************************************************************** - * This routine transforms query trees with the following form: - * SELECT a,b, ... FROM one_table WHERE - * (v1 = const1 AND v2 = const2 [ vn = constn ]) OR - * (v1 = const3 AND v2 = const4 [ vn = constn ]) OR - * (v1 = const5 AND v2 = const6 [ vn = constn ]) OR - * ... - * [(v1 = constn AND v2 = constn [ vn = constn ])] + * This routine transforms query trees with the following form: + * SELECT a,b, ... FROM one_table WHERE + * (v1 = const1 AND v2 = const2 [ vn = constn ]) OR + * (v1 = const3 AND v2 = const4 [ vn = constn ]) OR + * (v1 = const5 AND v2 = const6 [ vn = constn ]) OR + * ... + * [(v1 = constn AND v2 = constn [ vn = constn ])] * - * into + * into * - * SELECT a,b, ... FROM one_table WHERE - * (v1 = const1 AND v2 = const2 [ vn = constn ]) UNION - * SELECT a,b, ... FROM one_table WHERE - * (v1 = const3 AND v2 = const4 [ vn = constn ]) UNION - * SELECT a,b, ... FROM one_table WHERE - * (v1 = const5 AND v2 = const6 [ vn = constn ]) UNION - * ... - * SELECT a,b, ... FROM one_table WHERE - * [(v1 = constn AND v2 = constn [ vn = constn ])] + * SELECT a,b, ... FROM one_table WHERE + * (v1 = const1 AND v2 = const2 [ vn = constn ]) UNION + * SELECT a,b, ... FROM one_table WHERE + * (v1 = const3 AND v2 = const4 [ vn = constn ]) UNION + * SELECT a,b, ... FROM one_table WHERE + * (v1 = const5 AND v2 = const6 [ vn = constn ]) UNION + * ... + * SELECT a,b, ... FROM one_table WHERE + * [(v1 = constn AND v2 = constn [ vn = constn ])] * * - * To qualify for transformation the query must not be a sub select, - * a HAVING, or a GROUP BY. It must be a single table and have KSQO - * set to 'on'. + * To qualify for transformation the query must not be a sub select, + * a HAVING, or a GROUP BY. It must be a single table and have KSQO + * set to 'on'. * - * The primary use of this transformation is to avoid the exponrntial - * memory consumption of cnfify() and to make use of index access - * methods. + * The primary use of this transformation is to avoid the exponrntial + * memory consumption of cnfify() and to make use of index access + * methods. * - * daveh@insightdist.com 1998-08-31 + * daveh@insightdist.com 1998-08-31 * - * May want to also prune out duplicate terms. + * May want to also prune out duplicate terms. **********************************************************************/ void transformKeySetQuery(Query *origNode) { - /* Qualify as a key set query candidate */ - if (_use_keyset_query_optimizer == FALSE || - origNode->groupClause || - origNode->havingQual || - origNode->hasAggs || - origNode->utilityStmt || - origNode->unionClause || - origNode->unionall || - origNode->hasSubLinks || - origNode->commandType != CMD_SELECT) + /* Qualify as a key set query candidate */ + if (_use_keyset_query_optimizer == FALSE || + origNode->groupClause || + origNode->havingQual || + origNode->hasAggs || + origNode->utilityStmt || + origNode->unionClause || + origNode->unionall || + origNode->hasSubLinks || + origNode->commandType != CMD_SELECT) return; - /* Qualify single table query */ + /* Qualify single table query */ if (length(origNode->rtable) != 1) - return; - - /* Sorry about the global, not worth passing around */ - /* 9 expressions seems like a good number. More than 9 */ - /* and it starts to slow down quite a bit */ - TotalExpr = 0; - /*************************/ - /* Qualify where clause */ - /*************************/ - if ( ! inspectOrNode((Expr*)origNode->qual) || TotalExpr < 9) return; - /* Copy essential elements into a union node */ - while (((Expr*)origNode->qual)->opType == OR_EXPR) { + /* Sorry about the global, not worth passing around */ + /* 9 expressions seems like a good number. More than 9 */ + /* and it starts to slow down quite a bit */ + TotalExpr = 0; + /*************************/ + /* Qualify where clause */ + /*************************/ + if (!inspectOrNode((Expr *) origNode->qual) || TotalExpr < 9) + return; + + /* Copy essential elements into a union node */ + while (((Expr *) origNode->qual)->opType == OR_EXPR) + { Query *unionNode = makeNode(Query); - /* Pull up Expr = */ - unionNode->qual = lsecond(((Expr*)origNode->qual)->args); + /* Pull up Expr = */ + unionNode->qual = lsecond(((Expr *) origNode->qual)->args); - /* Pull up balance of tree */ - origNode->qual = lfirst(((Expr*)origNode->qual)->args); + /* Pull up balance of tree */ + origNode->qual = lfirst(((Expr *) origNode->qual)->args); unionNode->commandType = origNode->commandType; unionNode->resultRelation = origNode->resultRelation; @@ -121,37 +122,38 @@ transformKeySetQuery(Query *origNode) static int /********************************************************************** - * Checks for 1 or more OR terms w/ 1 or more AND terms. - * AND terms must be equal in size. - * Returns the number of each AND term. + * Checks for 1 or more OR terms w/ 1 or more AND terms. + * AND terms must be equal in size. + * Returns the number of each AND term. **********************************************************************/ inspectOrNode(Expr *expr) { - int rc; - Expr *firstExpr, *secondExpr; + int rc; + Expr *firstExpr, + *secondExpr; - if ( ! (expr && nodeTag(expr) == T_Expr && expr->opType == OR_EXPR)) + if (!(expr && nodeTag(expr) == T_Expr && expr->opType == OR_EXPR)) return 0; firstExpr = lfirst(expr->args); secondExpr = lsecond(expr->args); - if (nodeTag(firstExpr) != T_Expr || nodeTag(secondExpr) != T_Expr) + if (nodeTag(firstExpr) != T_Expr || nodeTag(secondExpr) != T_Expr) return 0; if (firstExpr->opType == OR_EXPR && secondExpr->opType == AND_EXPR) { - if ((rc = inspectOrNode(firstExpr)) == 0) + if ((rc = inspectOrNode(firstExpr)) == 0) return 0; - return (rc == inspectAndNode(secondExpr)) ? rc : 0; + return (rc == inspectAndNode(secondExpr)) ? rc : 0; } else if (firstExpr->opType == AND_EXPR && secondExpr->opType == AND_EXPR) { - if ((rc = inspectAndNode(firstExpr)) == 0) + if ((rc = inspectAndNode(firstExpr)) == 0) return 0; - - return (rc == inspectAndNode(secondExpr)) ? rc : 0; - + + return (rc == inspectAndNode(secondExpr)) ? rc : 0; + } return 0; @@ -160,34 +162,33 @@ inspectOrNode(Expr *expr) static int /********************************************************************** - * Check for one or more AND terms. Each sub-term must be a T_Const - * T_Var expression. - * Returns the number of AND terms. + * Check for one or more AND terms. Each sub-term must be a T_Const + * T_Var expression. + * Returns the number of AND terms. **********************************************************************/ inspectAndNode(Expr *expr) { - int rc; - Expr *firstExpr, *secondExpr; + int rc; + Expr *firstExpr, + *secondExpr; - if ( ! (expr && nodeTag(expr) == T_Expr && expr->opType == AND_EXPR)) + if (!(expr && nodeTag(expr) == T_Expr && expr->opType == AND_EXPR)) return 0; firstExpr = lfirst(expr->args); secondExpr = lsecond(expr->args); - if (nodeTag(firstExpr) != T_Expr || nodeTag(secondExpr) != T_Expr) + if (nodeTag(firstExpr) != T_Expr || nodeTag(secondExpr) != T_Expr) return 0; if (firstExpr->opType == AND_EXPR && - secondExpr->opType == OP_EXPR && inspectOpNode(secondExpr)) + secondExpr->opType == OP_EXPR && inspectOpNode(secondExpr)) { - rc = inspectAndNode(firstExpr); - return ((rc) ? (rc + 1) : 0); /* Add up the AND nodes */ + rc = inspectAndNode(firstExpr); + return ((rc) ? (rc + 1) : 0); /* Add up the AND nodes */ } - else if (firstExpr->opType == OP_EXPR && inspectOpNode(firstExpr) && - secondExpr->opType == OP_EXPR && inspectOpNode(secondExpr)) - { + else if (firstExpr->opType == OP_EXPR && inspectOpNode(firstExpr) && + secondExpr->opType == OP_EXPR && inspectOpNode(secondExpr)) return 1; - } return 0; } @@ -195,12 +196,13 @@ inspectAndNode(Expr *expr) static int /****************************************************************** - * Return TRUE if T_Var = T_Const, else FALSE - * Actually it does not test for =. Need to do this! + * Return TRUE if T_Var = T_Const, else FALSE + * Actually it does not test for =. Need to do this! ******************************************************************/ inspectOpNode(Expr *expr) { - Expr *firstExpr, *secondExpr; + Expr *firstExpr, + *secondExpr; if (nodeTag(expr) != T_Expr || expr->opType != OP_EXPR) return FALSE; @@ -209,5 +211,5 @@ inspectOpNode(Expr *expr) firstExpr = lfirst(expr->args); secondExpr = lsecond(expr->args); - return (firstExpr && secondExpr && nodeTag(firstExpr) == T_Var && nodeTag(secondExpr) == T_Const); + return (firstExpr && secondExpr && nodeTag(firstExpr) == T_Var && nodeTag(secondExpr) == T_Const); } diff --git a/src/backend/optimizer/prep/prepqual.c b/src/backend/optimizer/prep/prepqual.c index cea2939a15..aed7372704 100644 --- a/src/backend/optimizer/prep/prepqual.c +++ b/src/backend/optimizer/prep/prepqual.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepqual.c,v 1.14 1999/02/15 01:06:59 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepqual.c,v 1.15 1999/05/25 16:09:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -106,8 +106,9 @@ find_nots(Expr *qual) if (is_opclause((Node *) qual)) { - Expr *left = (Expr *) get_leftop(qual); - Expr *right = (Expr *) get_rightop(qual); + Expr *left = (Expr *) get_leftop(qual); + Expr *right = (Expr *) get_rightop(qual); + if (right) return make_clause(qual->opType, qual->oper, lcons(find_nots(left), @@ -162,8 +163,9 @@ normalize(Expr *qual) if (is_opclause((Node *) qual)) { - Expr *left = (Expr *) get_leftop(qual); - Expr *right = (Expr *) get_rightop(qual); + Expr *left = (Expr *) get_leftop(qual); + Expr *right = (Expr *) get_rightop(qual); + if (right) return make_clause(qual->opType, qual->oper, lcons(normalize(left), @@ -229,8 +231,9 @@ qual_cleanup(Expr *qual) if (is_opclause((Node *) qual)) { - Expr *left = (Expr *) get_leftop(qual); - Expr *right = (Expr *) get_rightop(qual); + Expr *left = (Expr *) get_leftop(qual); + Expr *right = (Expr *) get_rightop(qual); + if (right) return (List *) make_clause(qual->opType, qual->oper, lcons(qual_cleanup(left), @@ -295,8 +298,9 @@ pull_args(Expr *qual) if (is_opclause((Node *) qual)) { - Expr *left = (Expr *) get_leftop(qual); - Expr *right = (Expr *) get_rightop(qual); + Expr *left = (Expr *) get_leftop(qual); + Expr *right = (Expr *) get_rightop(qual); + if (right) return make_clause(qual->opType, qual->oper, lcons(pull_args(left), @@ -485,7 +489,7 @@ or_normalize(List *orlist) { return (or_normalize(lcons(distribute_args(lfirst(new_orlist), ((Expr *) distributable)->args), - lnext(new_orlist)))); + lnext(new_orlist)))); } else return orlist; @@ -537,8 +541,9 @@ remove_ands(Expr *qual) return NIL; if (is_opclause((Node *) qual)) { - Expr *left = (Expr *) get_leftop(qual); - Expr *right = (Expr *) get_rightop(qual); + Expr *left = (Expr *) get_leftop(qual); + Expr *right = (Expr *) get_rightop(qual); + if (right) return (List *) make_clause(qual->opType, qual->oper, lcons(remove_ands(left), diff --git a/src/backend/optimizer/prep/preptlist.c b/src/backend/optimizer/prep/preptlist.c index 92ab4db94d..0256fd483b 100644 --- a/src/backend/optimizer/prep/preptlist.c +++ b/src/backend/optimizer/prep/preptlist.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/preptlist.c,v 1.20 1999/05/17 17:03:18 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/preptlist.c,v 1.21 1999/05/25 16:09:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -211,8 +211,8 @@ replace_matching_resname(List *new_tlist, List *old_tlist) * locks. * * So, copy all these entries to the end of the target list and set their - * 'resjunk' value to true to show that these are special attributes and - * have to be treated specially by the executor! + * 'resjunk' value to true to show that these are special attributes + * and have to be treated specially by the executor! */ foreach(temp, old_tlist) { @@ -231,28 +231,27 @@ replace_matching_resname(List *new_tlist, List *old_tlist) } /* - * Also it is possible that the parser or rewriter added - * some junk attributes to hold GROUP BY expressions which - * are not part of the result attributes. - * We can simply identify them by looking at the resgroupref - * in the TLE's resdom, which is a unique number telling which - * TLE belongs to which GroupClause. + * Also it is possible that the parser or rewriter added some junk + * attributes to hold GROUP BY expressions which are not part of + * the result attributes. We can simply identify them by looking + * at the resgroupref in the TLE's resdom, which is a unique + * number telling which TLE belongs to which GroupClause. */ if (old_tle->resdom->resgroupref > 0) { - bool already_there = FALSE; - TargetEntry *new_tle; - Resdom *newresno; + bool already_there = FALSE; + TargetEntry *new_tle; + Resdom *newresno; /* * Check if the tle is already in the new list */ foreach(i, t_list) { - new_tle = (TargetEntry *)lfirst(i); + new_tle = (TargetEntry *) lfirst(i); - if (new_tle->resdom->resgroupref == - old_tle->resdom->resgroupref) + if (new_tle->resdom->resgroupref == + old_tle->resdom->resgroupref) { already_there = TRUE; break; @@ -349,8 +348,8 @@ new_relation_targetlist(Oid relid, Index rt_index, NodeTag node_type) TargetEntry *temp_list = NULL; temp_var = makeVar(rt_index, attno, atttype, - get_atttypmod(relid, attno), - 0, rt_index, attno); + get_atttypmod(relid, attno), + 0, rt_index, attno); temp_list = makeTargetEntry(makeResdom(attno, atttype, diff --git a/src/backend/optimizer/prep/prepunion.c b/src/backend/optimizer/prep/prepunion.c index 1bbfa9ef06..6bd493a488 100644 --- a/src/backend/optimizer/prep/prepunion.c +++ b/src/backend/optimizer/prep/prepunion.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.30 1999/02/18 00:49:32 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.31 1999/05/25 16:09:47 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -223,8 +223,8 @@ plan_inherit_queries(Query *parse, Index rt_index) List *union_relids = NIL; union_relids = find_all_inheritors(lconsi(rt_entry->relid, - NIL), - NIL); + NIL), + NIL); /* * Remove the flag for this relation, since we're about to handle it diff --git a/src/backend/optimizer/util/clauses.c b/src/backend/optimizer/util/clauses.c index 0dbd65cd5d..8d02a66e76 100644 --- a/src/backend/optimizer/util/clauses.c +++ b/src/backend/optimizer/util/clauses.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.33 1999/05/10 00:45:24 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.34 1999/05/25 16:09:50 momjian Exp $ * * HISTORY * AUTHOR DATE MAJOR EVENT @@ -84,7 +84,7 @@ bool is_opclause(Node *clause) { return (clause != NULL && - nodeTag(clause) == T_Expr && ((Expr *) clause)->opType == OP_EXPR); + nodeTag(clause) == T_Expr && ((Expr *) clause)->opType == OP_EXPR); } /* @@ -163,7 +163,7 @@ bool is_funcclause(Node *clause) { return (clause != NULL && - nodeTag(clause) == T_Expr && ((Expr *) clause)->opType == FUNC_EXPR); + nodeTag(clause) == T_Expr && ((Expr *) clause)->opType == FUNC_EXPR); } /* @@ -320,7 +320,7 @@ bool case_clause(Node *clause) { return (clause != NULL && - nodeTag(clause) == T_CaseExpr); + nodeTag(clause) == T_CaseExpr); } /***************************************************************************** @@ -369,7 +369,7 @@ pull_constant_clauses(List *quals, List **constantQual) * */ void -clause_get_relids_vars(Node *clause, Relids *relids, List **vars) +clause_get_relids_vars(Node *clause, Relids * relids, List **vars) { List *clvars = pull_var_clause(clause); List *var_list = NIL; @@ -515,9 +515,9 @@ qual_clause_p(Node *clause) return false; /* unary opclauses need not apply */ /* How about Param-s ? - vadim 02/03/98 */ - if (IsA(leftop, Var) && IsA(rightop, Const)) + if (IsA(leftop, Var) &&IsA(rightop, Const)) return true; - if (IsA(rightop, Var) && IsA(leftop, Const)) + if (IsA(rightop, Var) &&IsA(leftop, Const)) return true; return false; } @@ -646,14 +646,14 @@ get_relattval(Node *clause, if (!right) goto default_results; - if (IsA(left, Var) && IsA(right, Const)) + if (IsA(left, Var) &&IsA(right, Const)) { *relid = left->varno; *attno = left->varattno; *constval = ((Const *) right)->constvalue; *flag = (_SELEC_CONSTANT_RIGHT_ | _SELEC_IS_CONSTANT_); } - else if (IsA(left, Var) && IsA(right, Param)) + else if (IsA(left, Var) &&IsA(right, Param)) { *relid = left->varno; *attno = left->varattno; @@ -669,7 +669,7 @@ get_relattval(Node *clause, *constval = ((Const *) right)->constvalue; *flag = (_SELEC_CONSTANT_RIGHT_ | _SELEC_IS_CONSTANT_); } - else if (IsA(right, Var) && IsA(left, Const)) + else if (IsA(right, Var) &&IsA(left, Const)) { *relid = right->varno; *attno = right->varattno; @@ -723,16 +723,16 @@ get_rels_atts(Node *clause, { if (is_opclause(clause)) { - Var *left = get_leftop((Expr *) clause); - Var *right = get_rightop((Expr *) clause); + Var *left = get_leftop((Expr *) clause); + Var *right = get_rightop((Expr *) clause); if (left && right) { - bool var_left = IsA(left, Var); - bool var_right = IsA(right, Var); - bool varexpr_left = (bool) ((IsA(left, Func) || IsA(left, Oper)) && - contain_var_clause((Node *) left)); - bool varexpr_right = (bool) ((IsA(right, Func) || IsA(right, Oper)) && + bool var_left = IsA(left, Var); + bool var_right = IsA(right, Var); + bool varexpr_left = (bool) ((IsA(left, Func) ||IsA(left, Oper)) && + contain_var_clause((Node *) left)); + bool varexpr_right = (bool) ((IsA(right, Func) ||IsA(right, Oper)) && contain_var_clause((Node *) right)); if (var_left && var_right) diff --git a/src/backend/optimizer/util/indexnode.c b/src/backend/optimizer/util/indexnode.c index 64fcbbf851..7d4cf825db 100644 --- a/src/backend/optimizer/util/indexnode.c +++ b/src/backend/optimizer/util/indexnode.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/indexnode.c,v 1.14 1999/02/13 23:16:43 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/indexnode.c,v 1.15 1999/05/25 16:09:53 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -33,7 +33,7 @@ static List *find_secondary_index(Query *root, Oid relid); * */ List * -find_relation_indices(Query *root, RelOptInfo *rel) +find_relation_indices(Query *root, RelOptInfo * rel) { if (rel->indexed) return find_secondary_index(root, lfirsti(rel->relids)); diff --git a/src/backend/optimizer/util/joininfo.c b/src/backend/optimizer/util/joininfo.c index f3797aa3b9..e9d919c436 100644 --- a/src/backend/optimizer/util/joininfo.c +++ b/src/backend/optimizer/util/joininfo.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/joininfo.c,v 1.19 1999/02/22 05:26:26 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/joininfo.c,v 1.20 1999/05/25 16:09:54 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -38,11 +38,11 @@ JoinInfo * joininfo_member(List *join_relids, List *joininfo_list) { - List *i; + List *i; foreach(i, joininfo_list) { - JoinInfo *joininfo = (JoinInfo *)lfirst(i); + JoinInfo *joininfo = (JoinInfo *) lfirst(i); if (same(join_relids, joininfo->unjoined_relids)) return joininfo; @@ -62,7 +62,7 @@ joininfo_member(List *join_relids, List *joininfo_list) * */ JoinInfo * -find_joininfo_node(RelOptInfo *this_rel, Relids join_relids) +find_joininfo_node(RelOptInfo * this_rel, Relids join_relids) { JoinInfo *joininfo = joininfo_member(join_relids, this_rel->joininfo); diff --git a/src/backend/optimizer/util/keys.c b/src/backend/optimizer/util/keys.c index c921c24c0d..84528e7d06 100644 --- a/src/backend/optimizer/util/keys.c +++ b/src/backend/optimizer/util/keys.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/keys.c,v 1.19 1999/02/20 18:01:02 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/keys.c,v 1.20 1999/05/25 16:09:56 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -54,7 +54,7 @@ static bool equal_indexkey_var(int index_key, Var *var); * */ bool -match_indexkey_operand(int indexkey, Var *operand, RelOptInfo *rel) +match_indexkey_operand(int indexkey, Var *operand, RelOptInfo * rel) { if (IsA(operand, Var) && (lfirsti(rel->relids) == operand->varno) && @@ -112,7 +112,7 @@ extract_join_key(JoinKey *jk, int outer_or_inner) * * See the top of optimizer/path/pathkeys.c for a description of pathkeys. * Each pathkey is ordered by its join order, so they not pre-ordered to - * match. We must search them ourselves. + * match. We must search them ourselves. * * This gets called a lot, so it is optimized. */ @@ -128,31 +128,33 @@ pathkeys_match(List *keys1, List *keys2, int *better_key) key1 != NIL && key2 != NIL; key1 = lnext(key1), key2 = lnext(key2)) { - List *i; + List *i; if (key1_subsetof_key2) foreach(i, lfirst(key1)) + { + Var *subkey = lfirst(i); + + if (!member(subkey, lfirst(key2))) { - Var *subkey = lfirst(i); - if (!member(subkey, lfirst(key2))) - { - key1_subsetof_key2 = false; - break; - } + key1_subsetof_key2 = false; + break; } + } if (key2_subsetof_key1) foreach(i, lfirst(key2)) + { + Var *subkey = lfirst(i); + + if (!member(subkey, lfirst(key1))) { - Var *subkey = lfirst(i); - if (!member(subkey, lfirst(key1))) - { - key2_subsetof_key1 = false; - break; - } + key2_subsetof_key1 = false; + break; } + } if (!key1_subsetof_key2 && !key2_subsetof_key1) - break; /* no need to continue comparisons. */ + break; /* no need to continue comparisons. */ } if (!key1_subsetof_key2 && !key2_subsetof_key1) diff --git a/src/backend/optimizer/util/ordering.c b/src/backend/optimizer/util/ordering.c index eef0fbb314..46948609f1 100644 --- a/src/backend/optimizer/util/ordering.c +++ b/src/backend/optimizer/util/ordering.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/ordering.c,v 1.15 1999/02/13 23:16:46 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/ordering.c,v 1.16 1999/05/25 16:09:57 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -19,7 +19,7 @@ #include "optimizer/ordering.h" static bool sortops_order_match(Oid *ordering1, Oid *ordering2, - int *better_sort); + int *better_sort); /* * equal_path_ordering @@ -31,12 +31,12 @@ pathorder_match(PathOrder *path_ordering1, PathOrder *path_ordering2, int *better_sort) { - + *better_sort = 0; if (path_ordering1 == path_ordering2) return true; - + if (!path_ordering2) { *better_sort = 1; @@ -51,15 +51,13 @@ pathorder_match(PathOrder *path_ordering1, if (path_ordering1->ordtype == MERGE_ORDER && path_ordering2->ordtype == MERGE_ORDER) - { return equal(path_ordering1->ord.merge, path_ordering2->ord.merge); - } else if (path_ordering1->ordtype == SORTOP_ORDER && path_ordering2->ordtype == SORTOP_ORDER) { return sortops_order_match(path_ordering1->ord.sortop, - path_ordering2->ord.sortop, - better_sort); + path_ordering2->ord.sortop, + better_sort); } else if (path_ordering1->ordtype == MERGE_ORDER && path_ordering2->ordtype == SORTOP_ORDER) @@ -112,7 +110,7 @@ equal_path_merge_ordering(Oid *path_ordering, */ bool equal_merge_ordering(MergeOrder *merge_ordering1, - MergeOrder *merge_ordering2) + MergeOrder *merge_ordering2) { return equal(merge_ordering1, merge_ordering2); } @@ -133,7 +131,7 @@ sortops_order_match(Oid *ordering1, Oid *ordering2, int *better_sort) int i = 0; *better_sort = 0; - + if (ordering1 == ordering2) return true; @@ -142,13 +140,13 @@ sortops_order_match(Oid *ordering1, Oid *ordering2, int *better_sort) *better_sort = 1; return true; } - + if (!ordering1) { *better_sort = 2; return true; } - + while (ordering1[i] != 0 && ordering2[i] != 0) { if (ordering1[i] != ordering2[i]) @@ -167,6 +165,6 @@ sortops_order_match(Oid *ordering1, Oid *ordering2, int *better_sort) *better_sort = 2; return true; } - + return ordering1[i] == 0 && ordering2[i] == 0; } diff --git a/src/backend/optimizer/util/pathnode.c b/src/backend/optimizer/util/pathnode.c index 4e3d2fe353..7e9b8e3090 100644 --- a/src/backend/optimizer/util/pathnode.c +++ b/src/backend/optimizer/util/pathnode.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.40 1999/02/21 03:48:54 scrappy Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.41 1999/05/25 16:09:58 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -62,7 +62,7 @@ path_is_cheaper(Path *path1, Path *path2) * */ Path * -set_cheapest(RelOptInfo *parent_rel, List *pathlist) +set_cheapest(RelOptInfo * parent_rel, List *pathlist) { List *p; Path *cheapest_so_far; @@ -99,14 +99,14 @@ set_cheapest(RelOptInfo *parent_rel, List *pathlist) * */ List * -add_pathlist(RelOptInfo *parent_rel, List *unique_paths, List *new_paths) +add_pathlist(RelOptInfo * parent_rel, List *unique_paths, List *new_paths) { List *p1; foreach(p1, new_paths) { Path *new_path = (Path *) lfirst(p1); - Path *old_path; + Path *old_path; bool is_new; /* Is this new path already in unique_paths? */ @@ -174,7 +174,7 @@ better_path(Path *new_path, List *unique_paths, bool *is_new) #ifdef OPTDUP_DEBUG if (!pathkeys_match(new_path->pathkeys, path->pathkeys, &better_key) || - better_key != 0) + better_key != 0) { printf("betterkey = %d\n", better_key); printf("newpath\n"); @@ -182,13 +182,15 @@ better_path(Path *new_path, List *unique_paths, bool *is_new) printf("oldpath\n"); pprint(path->pathkeys); if (path->pathkeys && new_path->pathkeys && - length(lfirst(path->pathkeys)) >= 2/* && - length(lfirst(path->pathkeys)) < - length(lfirst(new_path->pathkeys))*/) - sleep(0); /* set breakpoint here */ + length(lfirst(path->pathkeys)) >= 2 /* && + * length(lfirst(path->pa + * thkeys)) < + * length(lfirst(new_path + ->pathkeys)) */ ) + sleep(0); /* set breakpoint here */ } if (!pathorder_match(new_path->pathorder, path->pathorder, - &better_sort) || + &better_sort) || better_sort != 0) { printf("neword\n"); @@ -199,25 +201,26 @@ better_path(Path *new_path, List *unique_paths, bool *is_new) #endif if (pathkeys_match(new_path->pathkeys, path->pathkeys, - &better_key) && + &better_key) && pathorder_match(new_path->pathorder, path->pathorder, - &better_sort)) + &better_sort)) { + /* * Replace pathkeys that match exactly, {{1,2}}, {{1,2}} - * Replace pathkeys {{1,2}} with {{1,2,3}}} if the latter is not - * more expensive and replace unordered path with ordered - * path if it is not more expensive. Favor sorted keys - * over unsorted keys in the same way. + * Replace pathkeys {{1,2}} with {{1,2,3}}} if the latter is + * not more expensive and replace unordered path with ordered + * path if it is not more expensive. Favor sorted keys over + * unsorted keys in the same way. */ - /* same keys, and new is cheaper, use it */ - if ((better_key == 0 && better_sort == 0 && + /* same keys, and new is cheaper, use it */ + if ((better_key == 0 && better_sort == 0 && new_path->path_cost < path->path_cost) || - /* new is better, and cheaper, use it */ + /* new is better, and cheaper, use it */ (((better_key == 1 && better_sort != 2) || (better_key != 2 && better_sort == 1)) && - new_path->path_cost <= path->path_cost)) + new_path->path_cost <= path->path_cost)) { #ifdef OPTDUP_DEBUG printf("replace with new %p old %p better key %d better sort %d\n", &new_path, &path, better_key, better_sort); @@ -230,14 +233,14 @@ better_path(Path *new_path, List *unique_paths, bool *is_new) return path; } - /* same keys, new is more expensive, stop */ + /* same keys, new is more expensive, stop */ if ((better_key == 0 && better_sort == 0 && new_path->path_cost >= path->path_cost) || - /* old is better, and less expensive, stop */ + /* old is better, and less expensive, stop */ (((better_key == 2 && better_sort != 1) || (better_key != 1 && better_sort == 2)) && - new_path->path_cost >= path->path_cost)) + new_path->path_cost >= path->path_cost)) { #ifdef OPTDUP_DEBUG printf("skip new %p old %p better key %d better sort %d\n", &new_path, &path, better_key, better_sort); @@ -253,11 +256,11 @@ better_path(Path *new_path, List *unique_paths, bool *is_new) } #ifdef OPTDUP_DEBUG - printf("add new %p old %p better key %d better sort %d\n", &new_path, &path, better_key, better_sort); - printf("new\n"); - pprint(new_path); + printf("add new %p old %p better key %d better sort %d\n", &new_path, &path, better_key, better_sort); + printf("new\n"); + pprint(new_path); #endif - + *is_new = true; return NULL; } @@ -275,7 +278,7 @@ better_path(Path *new_path, List *unique_paths, bool *is_new) * */ Path * -create_seqscan_path(RelOptInfo *rel) +create_seqscan_path(RelOptInfo * rel) { int relid = 0; @@ -290,7 +293,7 @@ create_seqscan_path(RelOptInfo *rel) pathnode->pathkeys = NIL; /* - * copy restrictinfo list into path for expensive function processing + * copy restrictinfo list into path for expensive function processing * JMH, 7/7/92 */ pathnode->loc_restrictinfo = (List *) copyObject((Node *) rel->restrictinfo); @@ -303,9 +306,7 @@ create_seqscan_path(RelOptInfo *rel) /* add in expensive functions cost! -- JMH, 7/7/92 */ #ifdef NOT_USED if (XfuncMode != XFUNC_OFF) - { pathnode->path_cost += xfunc_get_path_cost(pathnode); - } #endif return pathnode; } @@ -325,8 +326,8 @@ create_seqscan_path(RelOptInfo *rel) */ IndexPath * create_index_path(Query *root, - RelOptInfo *rel, - RelOptInfo *index, + RelOptInfo * rel, + RelOptInfo * index, List *restriction_clauses, bool is_join_scan) { @@ -343,11 +344,11 @@ create_index_path(Query *root, pathnode->indexqual = NIL; /* - * copy restrictinfo list into path for expensive function processing + * copy restrictinfo list into path for expensive function processing * JMH, 7/7/92 */ pathnode->path.loc_restrictinfo = set_difference((List *) copyObject((Node *) rel->restrictinfo), - (List *) restriction_clauses); + (List *) restriction_clauses); /* * The index must have an ordering for the path to have (ordering) @@ -356,7 +357,7 @@ create_index_path(Query *root, if (pathnode->path.pathorder->ord.sortop) { pathnode->path.pathkeys = collect_index_pathkeys(index->indexkeys, - rel->targetlist); + rel->targetlist); /* * Check that the keys haven't 'disappeared', since they may no @@ -381,19 +382,19 @@ create_index_path(Query *root, /* is the statement above really true? what about IndexScan as the inner of a join? */ pathnode->path.path_cost = cost_index(lfirsti(index->relids), - index->pages, - 1.0, - rel->pages, - rel->tuples, - index->pages, - index->tuples, - false); + index->pages, + 1.0, + rel->pages, + rel->tuples, + index->pages, + index->tuples, + false); #ifdef NOT_USED /* add in expensive functions cost! -- JMH, 7/7/92 */ if (XfuncMode != XFUNC_OFF) { pathnode->path_cost = (pathnode->path_cost + - xfunc_get_path_cost((Path *) pathnode)); + xfunc_get_path_cost((Path *) pathnode)); } #endif } @@ -427,24 +428,22 @@ create_index_path(Query *root, &npages, &selec); /* each clause gets an equal selectivity */ - clausesel = pow(selec, 1.0 / (double) length(restriction_clauses)); + clausesel = pow(selec, 1.0 / (double) length(restriction_clauses)); pathnode->indexqual = restriction_clauses; pathnode->path.path_cost = cost_index(lfirsti(index->relids), - (int) npages, - selec, - rel->pages, - rel->tuples, - index->pages, - index->tuples, - false); + (int) npages, + selec, + rel->pages, + rel->tuples, + index->pages, + index->tuples, + false); #ifdef NOT_USED /* add in expensive functions cost! -- JMH, 7/7/92 */ if (XfuncMode != XFUNC_OFF) - { pathnode->path_cost += xfunc_get_path_cost((Path *) pathnode); - } #endif /* @@ -474,8 +473,8 @@ create_index_path(Query *root, * */ NestPath * -create_nestloop_path(RelOptInfo *joinrel, - RelOptInfo *outer_rel, +create_nestloop_path(RelOptInfo * joinrel, + RelOptInfo * outer_rel, Path *outer_path, Path *inner_path, List *pathkeys) @@ -492,7 +491,7 @@ create_nestloop_path(RelOptInfo *joinrel, pathnode->path.outerjoincost = (Cost) 0.0; pathnode->path.loc_restrictinfo = NIL; pathnode->path.pathorder = makeNode(PathOrder); - + if (pathkeys) { pathnode->path.pathorder->ordtype = outer_path->pathorder->ordtype; @@ -508,12 +507,12 @@ create_nestloop_path(RelOptInfo *joinrel, } pathnode->path.path_cost = cost_nestloop(outer_path->path_cost, - inner_path->path_cost, - outer_rel->size, - inner_path->parent->size, - page_size(outer_rel->size, - outer_rel->width), - IsA(inner_path, IndexPath)); + inner_path->path_cost, + outer_rel->size, + inner_path->parent->size, + page_size(outer_rel->size, + outer_rel->width), + IsA(inner_path, IndexPath)); /* add in expensive function costs -- JMH 7/7/92 */ #ifdef NOT_USED if (XfuncMode != XFUNC_OFF) @@ -542,7 +541,7 @@ create_nestloop_path(RelOptInfo *joinrel, * */ MergePath * -create_mergejoin_path(RelOptInfo *joinrel, +create_mergejoin_path(RelOptInfo * joinrel, int outersize, int innersize, int outerwidth, @@ -571,19 +570,17 @@ create_mergejoin_path(RelOptInfo *joinrel, pathnode->outersortkeys = outersortkeys; pathnode->innersortkeys = innersortkeys; pathnode->jpath.path.path_cost = cost_mergejoin(outer_path->path_cost, - inner_path->path_cost, - outersortkeys, - innersortkeys, - outersize, - innersize, - outerwidth, - innerwidth); + inner_path->path_cost, + outersortkeys, + innersortkeys, + outersize, + innersize, + outerwidth, + innerwidth); /* add in expensive function costs -- JMH 7/7/92 */ #ifdef NOT_USED if (XfuncMode != XFUNC_OFF) - { pathnode->path_cost += xfunc_get_path_cost((Path *) pathnode); - } #endif return pathnode; } @@ -607,7 +604,7 @@ create_mergejoin_path(RelOptInfo *joinrel, * */ HashPath * -create_hashjoin_path(RelOptInfo *joinrel, +create_hashjoin_path(RelOptInfo * joinrel, int outersize, int innersize, int outerwidth, @@ -639,17 +636,15 @@ create_hashjoin_path(RelOptInfo *joinrel, pathnode->outerhashkeys = outerkeys; pathnode->innerhashkeys = innerkeys; pathnode->jpath.path.path_cost = cost_hashjoin(outer_path->path_cost, - inner_path->path_cost, - outerkeys, - innerkeys, - outersize, innersize, - outerwidth, innerwidth); + inner_path->path_cost, + outerkeys, + innerkeys, + outersize, innersize, + outerwidth, innerwidth); /* add in expensive function costs -- JMH 7/7/92 */ #ifdef NOT_USED if (XfuncMode != XFUNC_OFF) - { pathnode->path_cost += xfunc_get_path_cost((Path *) pathnode); - } #endif return pathnode; } diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c index a1f6026b0e..a333b5af09 100644 --- a/src/backend/optimizer/util/plancat.c +++ b/src/backend/optimizer/util/plancat.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/plancat.c,v 1.29 1999/05/10 00:45:25 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/plancat.c,v 1.30 1999/05/25 16:09:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -461,6 +461,7 @@ VersionGetParents(Oid verrelid) heap_close(relation); return list; } + #endif @@ -545,6 +546,7 @@ IndexSelectivity(Oid indexrelid, select = 1.0; for (n = 0; n < nIndexKeys; ++n) { + /* * Find the AM class for this key. * @@ -579,7 +581,7 @@ IndexSelectivity(Oid indexrelid, amopTuple = SearchSysCacheTuple(AMOPOPID, ObjectIdGetDatum(indclass), - ObjectIdGetDatum(operatorObjectIds[n]), + ObjectIdGetDatum(operatorObjectIds[n]), ObjectIdGetDatum(relam), 0); if (!HeapTupleIsValid(amopTuple)) diff --git a/src/backend/optimizer/util/relnode.c b/src/backend/optimizer/util/relnode.c index 3b7594d87f..5346a1c72a 100644 --- a/src/backend/optimizer/util/relnode.c +++ b/src/backend/optimizer/util/relnode.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/relnode.c,v 1.15 1999/02/18 00:49:38 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/relnode.c,v 1.16 1999/05/25 16:10:01 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -30,7 +30,7 @@ RelOptInfo * get_base_rel(Query *root, int relid) { - Relids relids; + Relids relids; RelOptInfo *rel; relids = lconsi(relid, NIL); @@ -63,6 +63,7 @@ get_base_rel(Query *root, int relid) */ if (relid < 0) { + /* * If the relation is a materialized relation, assume * constants for sizes. @@ -75,6 +76,7 @@ get_base_rel(Query *root, int relid) bool hasindex; int pages, tuples; + /* * Otherwise, retrieve relation characteristics from the * system catalogs. diff --git a/src/backend/optimizer/util/restrictinfo.c b/src/backend/optimizer/util/restrictinfo.c index 374533a422..5c59e0fdf8 100644 --- a/src/backend/optimizer/util/restrictinfo.c +++ b/src/backend/optimizer/util/restrictinfo.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/restrictinfo.c,v 1.2 1999/02/13 23:16:49 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/restrictinfo.c,v 1.3 1999/05/25 16:10:02 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -27,7 +27,7 @@ * */ bool -valid_or_clause(RestrictInfo *restrictinfo) +valid_or_clause(RestrictInfo * restrictinfo) { if (restrictinfo != NULL && !single_node((Node *) restrictinfo->clause) && @@ -117,7 +117,7 @@ get_relattvals(List *restrictinfo_list, } /* - * get_joinvars + * get_joinvars * Given a list of join restrictinfo nodes to be used with the index * of an inner join relation, return three lists consisting of: * the attributes corresponding to the inner join relation @@ -184,7 +184,7 @@ get_opnos(List *restrictinfo_list) { temp = (RestrictInfo *) lfirst(i); result = lappendi(result, - (((Oper *) temp->clause->oper)->opno)); + (((Oper *) temp->clause->oper)->opno)); } return result; } diff --git a/src/backend/optimizer/util/tlist.c b/src/backend/optimizer/util/tlist.c index e0620c26a3..497bb78b3b 100644 --- a/src/backend/optimizer/util/tlist.c +++ b/src/backend/optimizer/util/tlist.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/tlist.c,v 1.31 1999/05/17 17:03:23 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/tlist.c,v 1.32 1999/05/25 16:10:03 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -93,7 +93,7 @@ matching_tlist_var(Var *var, List *targetlist) * CREATES: new var_node iff no matching var_node exists in targetlist */ void -add_var_to_tlist(RelOptInfo *rel, Var *var) +add_var_to_tlist(RelOptInfo * rel, Var *var) { Expr *oldvar; @@ -114,8 +114,8 @@ add_var_to_tlist(RelOptInfo *rel, Var *var) var->varoattno); rel->targetlist = lappend(tlist, - create_tl_element(newvar, - length(tlist) + 1)); + create_tl_element(newvar, + length(tlist) + 1)); } } @@ -203,6 +203,7 @@ tlist_member(Var *var, List *tlist) foreach(i, tlist) { TargetEntry *tle = (TargetEntry *) lfirst(i); + if (var_equal(var, get_expr(tle))) return tle->resdom; } @@ -222,6 +223,7 @@ tlist_resdom(List *tlist, Resdom *resnode) { TargetEntry *tle = (TargetEntry *) lfirst(i); Resdom *resdom = tle->resdom; + /* Since resnos are supposed to be unique */ if (resnode->resno == resdom->resno) return resdom; @@ -362,7 +364,7 @@ flatten_tlist(List *tlist) TargetEntry *temp_entry = (TargetEntry *) lfirst(temp); tlist_vars = nconc(tlist_vars, - pull_var_clause((Node *) get_expr(temp_entry))); + pull_var_clause((Node *) get_expr(temp_entry))); } foreach(temp, tlist_vars) @@ -411,8 +413,8 @@ flatten_tlist_vars(List *full_tlist, List *flat_tlist) TargetEntry *tle = lfirst(x); result = lappend(result, makeTargetEntry(tle->resdom, - flatten_tlistentry((Node *) get_expr(tle), - flat_tlist))); + flatten_tlistentry((Node *) get_expr(tle), + flat_tlist))); } return result; @@ -456,10 +458,11 @@ flatten_tlistentry(Node *tlistentry, List *flat_tlist) } else if (IsA(tlistentry, Expr)) { + /* - * Recursively scan the arguments of an expression. - * NOTE: this must come after is_subplan() case since - * subplan is a kind of Expr node. + * Recursively scan the arguments of an expression. NOTE: this + * must come after is_subplan() case since subplan is a kind of + * Expr node. */ foreach(temp, ((Expr *) tlistentry)->args) lfirst(temp) = flatten_tlistentry(lfirst(temp), flat_tlist); @@ -467,8 +470,10 @@ flatten_tlistentry(Node *tlistentry, List *flat_tlist) } else if (IsA(tlistentry, Aggref)) { - /* XXX shouldn't this be recursing into the agg's target? - * Seems to work though, so will leave it alone ... tgl 5/99 + + /* + * XXX shouldn't this be recursing into the agg's target? Seems to + * work though, so will leave it alone ... tgl 5/99 */ return tlistentry; } @@ -481,7 +486,7 @@ flatten_tlistentry(Node *tlistentry, List *flat_tlist) foreach(temp, aref->reflowerindexpr) lfirst(temp) = flatten_tlistentry(lfirst(temp), flat_tlist); aref->refexpr = flatten_tlistentry(aref->refexpr, flat_tlist); - aref->refassgnexpr = flatten_tlistentry(aref->refassgnexpr,flat_tlist); + aref->refassgnexpr = flatten_tlistentry(aref->refassgnexpr, flat_tlist); return tlistentry; } @@ -491,7 +496,8 @@ flatten_tlistentry(Node *tlistentry, List *flat_tlist) foreach(temp, cexpr->args) { - CaseWhen *cwhen = (CaseWhen *) lfirst(temp); + CaseWhen *cwhen = (CaseWhen *) lfirst(temp); + cwhen->expr = flatten_tlistentry(cwhen->expr, flat_tlist); cwhen->result = flatten_tlistentry(cwhen->result, flat_tlist); } @@ -521,18 +527,18 @@ get_expr(TargetEntry *tle) Var * get_groupclause_expr(GroupClause *groupClause, List *targetList) { - List *l; - TargetEntry *tle; + List *l; + TargetEntry *tle; foreach(l, targetList) { - tle = (TargetEntry *)lfirst(l); + tle = (TargetEntry *) lfirst(l); if (tle->resdom->resgroupref == groupClause->tleGroupref) return get_expr(tle); } - elog(ERROR, - "get_groupclause_expr: GROUP BY expression not found in targetlist"); + elog(ERROR, + "get_groupclause_expr: GROUP BY expression not found in targetlist"); return NULL; } diff --git a/src/backend/optimizer/util/var.c b/src/backend/optimizer/util/var.c index b906f8e4c4..fd57067cdd 100644 --- a/src/backend/optimizer/util/var.c +++ b/src/backend/optimizer/util/var.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/var.c,v 1.18 1999/05/03 00:38:44 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/var.c,v 1.19 1999/05/25 16:10:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -102,10 +102,11 @@ contain_var_clause(Node *clause) } else if (IsA(clause, Expr)) { + /* - * Recursively scan the arguments of an expression. - * NOTE: this must come after is_subplan() case since - * subplan is a kind of Expr node. + * Recursively scan the arguments of an expression. NOTE: this + * must come after is_subplan() case since subplan is a kind of + * Expr node. */ foreach(temp, ((Expr *) clause)->args) { @@ -139,6 +140,7 @@ contain_var_clause(Node *clause) foreach(temp, ((CaseExpr *) clause)->args) { CaseWhen *when = (CaseWhen *) lfirst(temp); + if (contain_var_clause(when->expr)) return TRUE; if (contain_var_clause(when->result)) @@ -188,10 +190,11 @@ pull_var_clause(Node *clause) } else if (IsA(clause, Expr)) { + /* - * Recursively scan the arguments of an expression. - * NOTE: this must come after is_subplan() case since - * subplan is a kind of Expr node. + * Recursively scan the arguments of an expression. NOTE: this + * must come after is_subplan() case since subplan is a kind of + * Expr node. */ foreach(temp, ((Expr *) clause)->args) retval = nconc(retval, pull_var_clause(lfirst(temp))); @@ -214,6 +217,7 @@ pull_var_clause(Node *clause) foreach(temp, ((CaseExpr *) clause)->args) { CaseWhen *when = (CaseWhen *) lfirst(temp); + retval = nconc(retval, pull_var_clause(when->expr)); retval = nconc(retval, pull_var_clause(when->result)); } diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c index 14c8150ff0..243165efc6 100644 --- a/src/backend/parser/analyze.c +++ b/src/backend/parser/analyze.c @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: analyze.c,v 1.107 1999/05/23 21:41:14 tgl Exp $ + * $Id: analyze.c,v 1.108 1999/05/25 16:10:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -45,8 +45,8 @@ static Query *transformUpdateStmt(ParseState *pstate, UpdateStmt *stmt); static Query *transformCursorStmt(ParseState *pstate, SelectStmt *stmt); static Query *transformCreateStmt(ParseState *pstate, CreateStmt *stmt); -static void transformForUpdate(Query *qry, List *forUpdate); -void CheckSelectForUpdate(Query *qry); +static void transformForUpdate(Query *qry, List *forUpdate); +void CheckSelectForUpdate(Query *qry); List *extras_before = NIL; List *extras_after = NIL; @@ -62,9 +62,9 @@ List *extras_after = NIL; List * parse_analyze(List *pl, ParseState *parentParseState) { - List *result = NIL; + List *result = NIL; ParseState *pstate; - Query *parsetree; + Query *parsetree; while (pl != NIL) { @@ -76,7 +76,7 @@ parse_analyze(List *pl, ParseState *parentParseState) while (extras_before != NIL) { result = lappend(result, - transformStmt(pstate, lfirst(extras_before))); + transformStmt(pstate, lfirst(extras_before))); if (pstate->p_target_relation != NULL) heap_close(pstate->p_target_relation); extras_before = lnext(extras_before); @@ -192,8 +192,8 @@ transformStmt(ParseState *pstate, Node *parseTree) if (!((SelectStmt *) parseTree)->portalname) { result = transformSelectStmt(pstate, (SelectStmt *) parseTree); - result->limitOffset = ((SelectStmt *)parseTree)->limitOffset; - result->limitCount = ((SelectStmt *)parseTree)->limitCount; + result->limitOffset = ((SelectStmt *) parseTree)->limitOffset; + result->limitCount = ((SelectStmt *) parseTree)->limitCount; } else result = transformCursorStmt(pstate, (SelectStmt *) parseTree); @@ -276,8 +276,8 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt) int ndef = pstate->p_target_relation->rd_att->constr->num_defval; /* - * if stmt->cols == NIL then makeTargetNames returns list of all attrs. - * May have to shorten icolumns list... + * if stmt->cols == NIL then makeTargetNames returns list of all + * attrs. May have to shorten icolumns list... */ if (stmt->cols == NIL) { @@ -286,16 +286,18 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt) foreach(extrl, icolumns) { + /* - * decrements first, so if we started with zero items - * it will now be negative + * decrements first, so if we started with zero items it + * will now be negative */ if (--i <= 0) break; } + /* - * this an index into the targetList, - * so make sure we had one to start... + * this an index into the targetList, so make sure we had one + * to start... */ if (i >= 0) { @@ -303,9 +305,7 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt) lnext(extrl) = NIL; } else - { icolumns = NIL; - } } while (ndef-- > 0) @@ -378,15 +378,18 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt) /* * The INSERT INTO ... SELECT ... could have a UNION in child, so - * unionClause may be false -, */ - qry->unionall = stmt->unionall; + * unionClause may be false , + */ + qry->unionall = stmt->unionall; - /***S*I***/ - /* Just hand through the unionClause and intersectClause. - * We will handle it in the function Except_Intersect_Rewrite() */ - qry->unionClause = stmt->unionClause; - qry->intersectClause = stmt->intersectClause; + /***S*I***/ + + /* + * Just hand through the unionClause and intersectClause. We will + * handle it in the function Except_Intersect_Rewrite() + */ + qry->unionClause = stmt->unionClause; + qry->intersectClause = stmt->intersectClause; /* * If there is a havingQual but there are no aggregates, then there is @@ -508,9 +511,12 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt) Constraint *constraint; List *keys; Ident *key; - List *blist = NIL; /* "before list" of things to do before creating the table */ - List *ilist = NIL; /* "index list" of things to do after creating the table */ - IndexStmt *index, *pkey = NULL; + List *blist = NIL; /* "before list" of things to do before + * creating the table */ + List *ilist = NIL; /* "index list" of things to do after + * creating the table */ + IndexStmt *index, + *pkey = NULL; IndexElem *iparam; q = makeNode(Query); @@ -532,15 +538,15 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt) if (column->is_sequence) { - char *sname; - char *cstring; + char *sname; + char *cstring; CreateSeqStmt *sequence; sname = makeTableName(stmt->relname, column->colname, "seq", NULL); if (sname == NULL) elog(ERROR, "CREATE TABLE/SERIAL implicit sequence name must be less than %d characters" "\n\tSum of lengths of '%s' and '%s' must be less than %d", - NAMEDATALEN, stmt->relname, column->colname, (NAMEDATALEN-5)); + NAMEDATALEN, stmt->relname, column->colname, (NAMEDATALEN - 5)); constraint = makeNode(Constraint); constraint->contype = CONSTR_DEFAULT; @@ -560,7 +566,7 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt) if (constraint->name == NULL) elog(ERROR, "CREATE TABLE/SERIAL implicit index name must be less than %d characters" "\n\tSum of lengths of '%s' and '%s' must be less than %d", - NAMEDATALEN, stmt->relname, column->colname, (NAMEDATALEN-5)); + NAMEDATALEN, stmt->relname, column->colname, (NAMEDATALEN - 5)); column->constraints = lappend(column->constraints, constraint); sequence = makeNode(CreateSeqStmt); @@ -582,8 +588,11 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt) switch (constraint->contype) { case CONSTR_NULL: - /* We should mark this explicitly, - * so we can tell if NULL and NOT NULL are both specified + + /* + * We should mark this explicitly, so we + * can tell if NULL and NOT NULL are both + * specified */ if (column->is_not_null) elog(ERROR, "CREATE TABLE/(NOT) NULL conflicting declaration" @@ -611,7 +620,7 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt) if (constraint->name == NULL) elog(ERROR, "CREATE TABLE/PRIMARY KEY implicit index name must be less than %d characters" "\n\tLength of '%s' must be less than %d", - NAMEDATALEN, stmt->relname, (NAMEDATALEN-6)); + NAMEDATALEN, stmt->relname, (NAMEDATALEN - 6)); if (constraint->keys == NIL) constraint->keys = lappend(constraint->keys, column); dlist = lappend(dlist, constraint); @@ -623,7 +632,7 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt) if (constraint->name == NULL) elog(ERROR, "CREATE TABLE/UNIQUE implicit index name must be less than %d characters" "\n\tLength of '%s' must be less than %d", - NAMEDATALEN, stmt->relname, (NAMEDATALEN-5)); + NAMEDATALEN, stmt->relname, (NAMEDATALEN - 5)); if (constraint->keys == NIL) constraint->keys = lappend(constraint->keys, column); dlist = lappend(dlist, constraint); @@ -636,7 +645,7 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt) if (constraint->name == NULL) elog(ERROR, "CREATE TABLE/CHECK implicit constraint name must be less than %d characters" "\n\tSum of lengths of '%s' and '%s' must be less than %d", - NAMEDATALEN, stmt->relname, column->colname, (NAMEDATALEN-1)); + NAMEDATALEN, stmt->relname, column->colname, (NAMEDATALEN - 1)); break; default: @@ -657,8 +666,8 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt) constraint->name = makeTableName(stmt->relname, "pkey", NULL); if (constraint->name == NULL) elog(ERROR, "CREATE TABLE/PRIMARY KEY implicit index name must be less than %d characters" - "\n\tLength of '%s' must be less than %d", - NAMEDATALEN, stmt->relname, (NAMEDATALEN-5)); + "\n\tLength of '%s' must be less than %d", + NAMEDATALEN, stmt->relname, (NAMEDATALEN - 5)); dlist = lappend(dlist, constraint); break; @@ -704,12 +713,12 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt) constraint = lfirst(dlist); Assert(nodeTag(constraint) == T_Constraint); Assert((constraint->contype == CONSTR_PRIMARY) - || (constraint->contype == CONSTR_UNIQUE)); + || (constraint->contype == CONSTR_UNIQUE)); index = makeNode(IndexStmt); index->unique = TRUE; - index->primary = (constraint->contype == CONSTR_PRIMARY ? TRUE:FALSE); + index->primary = (constraint->contype == CONSTR_PRIMARY ? TRUE : FALSE); if (index->primary) { if (pkey != NULL) @@ -719,21 +728,17 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt) } if (constraint->name != NULL) - { index->idxname = constraint->name; - } else if (constraint->contype == CONSTR_PRIMARY) { index->idxname = makeTableName(stmt->relname, "pkey", NULL); if (index->idxname == NULL) elog(ERROR, "CREATE TABLE/PRIMARY KEY implicit index name must be less than %d characters" "\n\tLength of '%s' must be less than %d", - NAMEDATALEN, stmt->relname, (NAMEDATALEN-5)); + NAMEDATALEN, stmt->relname, (NAMEDATALEN - 5)); } else - { index->idxname = NULL; - } index->relname = stmt->relname; index->accessMethod = "btree"; @@ -793,16 +798,20 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt) ilist = NIL; while (dlist != NIL) { - int keep = TRUE; + int keep = TRUE; index = lfirst(dlist); - /* has a single column argument, so might be a conflicting index... */ + /* + * has a single column argument, so might be a conflicting + * index... + */ if ((index != pkey) - && (length(index->indexParams) == 1)) + && (length(index->indexParams) == 1)) { - char *pname = ((IndexElem *) lfirst(index->indexParams))->name; - char *iname = ((IndexElem *) lfirst(index->indexParams))->name; + char *pname = ((IndexElem *) lfirst(index->indexParams))->name; + char *iname = ((IndexElem *) lfirst(index->indexParams))->name; + /* same names? then don't keep... */ keep = (strcmp(iname, pname) != 0); } @@ -818,7 +827,7 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt) { index = lfirst(dlist); elog(NOTICE, "CREATE TABLE/%s will create implicit index '%s' for table '%s'", - (index->primary? "PRIMARY KEY": "UNIQUE"), + (index->primary ? "PRIMARY KEY" : "UNIQUE"), index->idxname, stmt->relname); dlist = lnext(dlist); } @@ -828,7 +837,7 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt) extras_after = ilist; return q; -} /* transformCreateStmt() */ +} /* transformCreateStmt() */ /* * transformIndexStmt - @@ -1006,11 +1015,14 @@ transformSelectStmt(ParseState *pstate, SelectStmt *stmt) */ qry->unionall = stmt->unionall; - /***S*I***/ - /* Just hand through the unionClause and intersectClause. - * We will handle it in the function Except_Intersect_Rewrite() */ - qry->unionClause = stmt->unionClause; - qry->intersectClause = stmt->intersectClause; + /***S*I***/ + + /* + * Just hand through the unionClause and intersectClause. We will + * handle it in the function Except_Intersect_Rewrite() + */ + qry->unionClause = stmt->unionClause; + qry->intersectClause = stmt->intersectClause; /* * If there is a havingQual but there are no aggregates, then there is @@ -1092,91 +1104,92 @@ transformCursorStmt(ParseState *pstate, SelectStmt *stmt) * The built up list is handed back in **select_list. * If one of the SelectStmt Nodes has the 'unionall' flag * set to true *unionall_present hands back 'true' */ -void +void create_select_list(Node *ptr, List **select_list, bool *unionall_present) { - if(IsA(ptr, SelectStmt)) { - *select_list = lappend(*select_list, ptr); - if(((SelectStmt *)ptr)->unionall == TRUE) *unionall_present = TRUE; - return; - } - - /* Recursively call for all arguments. A NOT expr has no lexpr! */ - if (((A_Expr *)ptr)->lexpr != NULL) - create_select_list(((A_Expr *)ptr)->lexpr, select_list, unionall_present); - create_select_list(((A_Expr *)ptr)->rexpr, select_list, unionall_present); + if (IsA(ptr, SelectStmt)) + { + *select_list = lappend(*select_list, ptr); + if (((SelectStmt *) ptr)->unionall == TRUE) + *unionall_present = TRUE; + return; + } + + /* Recursively call for all arguments. A NOT expr has no lexpr! */ + if (((A_Expr *) ptr)->lexpr != NULL) + create_select_list(((A_Expr *) ptr)->lexpr, select_list, unionall_present); + create_select_list(((A_Expr *) ptr)->rexpr, select_list, unionall_present); } /* Changes the A_Expr Nodes to Expr Nodes and exchanges ANDs and ORs. - * The reason for the exchange is easy: We implement INTERSECTs and EXCEPTs + * The reason for the exchange is easy: We implement INTERSECTs and EXCEPTs * by rewriting these queries to semantically equivalent queries that use - * IN and NOT IN subselects. To be able to use all three operations - * (UNIONs INTERSECTs and EXCEPTs) in one complex query we have to + * IN and NOT IN subselects. To be able to use all three operations + * (UNIONs INTERSECTs and EXCEPTs) in one complex query we have to * translate the queries into Disjunctive Normal Form (DNF). Unfortunately * there is no function 'dnfify' but there is a function 'cnfify' * which produces DNF when we exchange ANDs and ORs before calling * 'cnfify' and exchange them back in the result. * * If an EXCEPT or INTERSECT is present *intersect_present - * hands back 'true' */ -Node *A_Expr_to_Expr(Node *ptr, bool *intersect_present) + * hands back 'true' */ +Node * +A_Expr_to_Expr(Node *ptr, bool *intersect_present) { - Node *result = NULL; - - switch(nodeTag(ptr)) - { - case T_A_Expr: - { - A_Expr *a = (A_Expr *)ptr; - - switch (a->oper) - { - case AND: - { - Expr *expr = makeNode(Expr); - Node *lexpr = A_Expr_to_Expr(((A_Expr *)ptr)->lexpr, intersect_present); - Node *rexpr = A_Expr_to_Expr(((A_Expr *)ptr)->rexpr, intersect_present); + Node *result = NULL; - *intersect_present = TRUE; - - expr->typeOid = BOOLOID; - expr->opType = OR_EXPR; - expr->args = makeList(lexpr, rexpr, -1); - result = (Node *) expr; - break; - } - case OR: - { - Expr *expr = makeNode(Expr); - Node *lexpr = A_Expr_to_Expr(((A_Expr *)ptr)->lexpr, intersect_present); - Node *rexpr = A_Expr_to_Expr(((A_Expr *)ptr)->rexpr, intersect_present); + switch (nodeTag(ptr)) + { + case T_A_Expr: + { + A_Expr *a = (A_Expr *) ptr; - expr->typeOid = BOOLOID; - expr->opType = AND_EXPR; - expr->args = makeList(lexpr, rexpr, -1); - result = (Node *) expr; - break; - } - case NOT: - { - Expr *expr = makeNode(Expr); - Node *rexpr = A_Expr_to_Expr(((A_Expr *)ptr)->rexpr, intersect_present); + switch (a->oper) + { + case AND: + { + Expr *expr = makeNode(Expr); + Node *lexpr = A_Expr_to_Expr(((A_Expr *) ptr)->lexpr, intersect_present); + Node *rexpr = A_Expr_to_Expr(((A_Expr *) ptr)->rexpr, intersect_present); - expr->typeOid = BOOLOID; - expr->opType = NOT_EXPR; - expr->args = makeList(rexpr, -1); - result = (Node *) expr; - break; - } - } - break; - } - default: - { - result = ptr; - } - } - return result; + *intersect_present = TRUE; + + expr->typeOid = BOOLOID; + expr->opType = OR_EXPR; + expr->args = makeList(lexpr, rexpr, -1); + result = (Node *) expr; + break; + } + case OR: + { + Expr *expr = makeNode(Expr); + Node *lexpr = A_Expr_to_Expr(((A_Expr *) ptr)->lexpr, intersect_present); + Node *rexpr = A_Expr_to_Expr(((A_Expr *) ptr)->rexpr, intersect_present); + + expr->typeOid = BOOLOID; + expr->opType = AND_EXPR; + expr->args = makeList(lexpr, rexpr, -1); + result = (Node *) expr; + break; + } + case NOT: + { + Expr *expr = makeNode(Expr); + Node *rexpr = A_Expr_to_Expr(((A_Expr *) ptr)->rexpr, intersect_present); + + expr->typeOid = BOOLOID; + expr->opType = NOT_EXPR; + expr->args = makeList(rexpr, -1); + result = (Node *) expr; + break; + } + } + break; + } + default: + result = ptr; + } + return result; } void @@ -1196,7 +1209,7 @@ static void transformForUpdate(Query *qry, List *forUpdate) { List *rowMark = NULL; - RowMark *newrm; + RowMark *newrm; List *l; Index i; @@ -1205,37 +1218,37 @@ transformForUpdate(Query *qry, List *forUpdate) if (lfirst(forUpdate) == NULL) /* all tables */ { i = 1; - foreach (l, qry->rtable) + foreach(l, qry->rtable) { newrm = makeNode(RowMark); newrm->rti = i++; - newrm->info = ROW_MARK_FOR_UPDATE|ROW_ACL_FOR_UPDATE; + newrm->info = ROW_MARK_FOR_UPDATE | ROW_ACL_FOR_UPDATE; rowMark = lappend(rowMark, newrm); } qry->rowMark = nconc(qry->rowMark, rowMark); return; } - foreach (l, forUpdate) + foreach(l, forUpdate) { - List *l2; - List *l3; + List *l2; + List *l3; i = 1; - foreach (l2, qry->rtable) + foreach(l2, qry->rtable) { - if (strcmp(((RangeTblEntry*)lfirst(l2))->refname, lfirst(l)) == 0) + if (strcmp(((RangeTblEntry *) lfirst(l2))->refname, lfirst(l)) == 0) { - foreach (l3, rowMark) + foreach(l3, rowMark) { - if (((RowMark*)lfirst(l3))->rti == i) /* duplicate */ + if (((RowMark *) lfirst(l3))->rti == i) /* duplicate */ break; } if (l3 == NULL) { newrm = makeNode(RowMark); newrm->rti = i; - newrm->info = ROW_MARK_FOR_UPDATE|ROW_ACL_FOR_UPDATE; + newrm->info = ROW_MARK_FOR_UPDATE | ROW_ACL_FOR_UPDATE; rowMark = lappend(rowMark, newrm); } break; diff --git a/src/backend/parser/parse_agg.c b/src/backend/parser/parse_agg.c index 19dd98dfbe..559337cc2f 100644 --- a/src/backend/parser/parse_agg.c +++ b/src/backend/parser/parse_agg.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_agg.c,v 1.20 1999/05/23 21:41:14 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_agg.c,v 1.21 1999/05/25 16:10:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -33,8 +33,8 @@ static bool contain_agg_clause(Node *clause); static bool exprIsAggOrGroupCol(Node *expr, List *groupClause, List *tlist); -static bool tleIsAggOrGroupCol(TargetEntry *tle, List *groupClause, - List *tlist); +static bool tleIsAggOrGroupCol(TargetEntry *tle, List *groupClause, + List *tlist); /* * contain_agg_clause @@ -106,7 +106,7 @@ exprIsAggOrGroupCol(Node *expr, List *groupClause, List *tlist) List *gl; if (expr == NULL || IsA(expr, Const) || - IsA(expr, Param) || IsA(expr, Aggref) || + IsA(expr, Param) ||IsA(expr, Aggref) || IsA(expr, SubLink)) /* can't handle currently !!! */ return TRUE; @@ -190,11 +190,11 @@ parseCheckAggregates(ParseState *pstate, Query *qry) Assert(pstate->p_hasAggs || qry->groupClause); /* - * Aggregates must never appear in WHERE clauses. - * (Note this check should appear first to deliver an appropriate - * error message; otherwise we are likely to generate the generic - * "illegal use of aggregates in target list" message, which is - * outright misleading if the problem is in WHERE.) + * Aggregates must never appear in WHERE clauses. (Note this check + * should appear first to deliver an appropriate error message; + * otherwise we are likely to generate the generic "illegal use of + * aggregates in target list" message, which is outright misleading if + * the problem is in WHERE.) */ if (contain_agg_clause(qry->qual)) elog(ERROR, "Aggregates not allowed in WHERE clause"); @@ -219,7 +219,7 @@ parseCheckAggregates(ParseState *pstate, Query *qry) if (!exprIsAggOrGroupCol(qry->havingQual, qry->groupClause, qry->targetList)) elog(ERROR, - "Illegal use of aggregates or non-group column in HAVING clause"); + "Illegal use of aggregates or non-group column in HAVING clause"); } @@ -313,7 +313,7 @@ ParseAgg(ParseState *pstate, char *aggname, Oid basetype, basetype = aggform->aggbasetype; vartype = exprType(lfirst(target)); if ((basetype != vartype) - && (! IS_BINARY_COMPATIBLE(basetype, vartype))) + && (!IS_BINARY_COMPATIBLE(basetype, vartype))) { Type tp1, tp2; @@ -321,8 +321,8 @@ ParseAgg(ParseState *pstate, char *aggname, Oid basetype, tp1 = typeidType(basetype); tp2 = typeidType(vartype); elog(ERROR, "Aggregate type mismatch" - "\n\t%s() works on %s, not on %s", - aggname, typeTypeName(tp1), typeTypeName(tp2)); + "\n\t%s() works on %s, not on %s", + aggname, typeTypeName(tp1), typeTypeName(tp2)); } } diff --git a/src/backend/parser/parse_clause.c b/src/backend/parser/parse_clause.c index f7b6f2219d..618554e561 100644 --- a/src/backend/parser/parse_clause.c +++ b/src/backend/parser/parse_clause.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.35 1999/05/22 02:55:57 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.36 1999/05/25 16:10:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -41,13 +41,14 @@ static TargetEntry * static void parseFromClause(ParseState *pstate, List *frmList, Node **qual); -Attr *makeAttr(char *relname, char *attname); +Attr *makeAttr(char *relname, char *attname); #ifdef ENABLE_OUTER_JOINS -Node *transformUsingClause(ParseState *pstate, List *onList, char *lname, char *rname); +Node *transformUsingClause(ParseState *pstate, List *onList, char *lname, char *rname); + #endif -char *transformTableEntry(ParseState *pstate, RangeVar *r); +char *transformTableEntry(ParseState *pstate, RangeVar *r); /* @@ -67,16 +68,14 @@ makeRangeTable(ParseState *pstate, char *relname, List *frmList, Node **qual) return; if ((refnameRangeTablePosn(pstate, relname, &sublevels_up) == 0) - || (sublevels_up != 0)) + || (sublevels_up != 0)) rte = addRangeTableEntry(pstate, relname, relname, FALSE, FALSE); else rte = refnameRangeTableEntry(pstate, relname); /* This could only happen for multi-action rules */ if (pstate->p_target_relation != NULL) - { heap_close(pstate->p_target_relation); - } pstate->p_target_rangetblentry = rte; pstate->p_target_relation = heap_open(rte->relid); @@ -102,7 +101,8 @@ transformWhereClause(ParseState *pstate, Node *a_expr, Node *o_expr) if ((a_expr != NULL) && (o_expr != NULL)) { - A_Expr *a = makeNode(A_Expr); + A_Expr *a = makeNode(A_Expr); + a->oper = AND; a->opname = NULL; a->lexpr = o_expr; @@ -110,12 +110,12 @@ transformWhereClause(ParseState *pstate, Node *a_expr, Node *o_expr) expr = a; } else if (o_expr != NULL) - expr = (A_Expr *)o_expr; + expr = (A_Expr *) o_expr; else - expr = (A_Expr *)a_expr; + expr = (A_Expr *) a_expr; pstate->p_in_where_clause = true; - qual = transformExpr(pstate, (Node *)expr, EXPR_COLUMN_FIRST); + qual = transformExpr(pstate, (Node *) expr, EXPR_COLUMN_FIRST); pstate->p_in_where_clause = false; if (exprType(qual) != BOOLOID) @@ -130,6 +130,7 @@ Attr * makeAttr(char *relname, char *attname) { Attr *a = makeNode(Attr); + a->relname = relname; a->paramNo = NULL; a->attrs = lcons(makeString(attname), NIL); @@ -149,30 +150,34 @@ transformUsingClause(ParseState *pstate, List *onList, char *lname, char *rname) List *on; Node *qual; - foreach (on, onList) + foreach(on, onList) { qual = lfirst(on); - /* Ident node means it is just a column name from a real USING clause... */ + /* + * Ident node means it is just a column name from a real USING + * clause... + */ if (IsA(qual, Ident)) { - Ident *i = (Ident *)qual; + Ident *i = (Ident *) qual; Attr *lattr = makeAttr(lname, i->name); Attr *rattr = makeAttr(rname, i->name); - A_Expr *e = makeNode(A_Expr); + A_Expr *e = makeNode(A_Expr); e->oper = OP; e->opname = "="; - e->lexpr = (Node *)lattr; - e->rexpr = (Node *)rattr; + e->lexpr = (Node *) lattr; + e->rexpr = (Node *) rattr; if (expr != NULL) { - A_Expr *a = makeNode(A_Expr); + A_Expr *a = makeNode(A_Expr); + a->oper = AND; a->opname = NULL; - a->lexpr = (Node *)expr; - a->rexpr = (Node *)e; + a->lexpr = (Node *) expr; + a->rexpr = (Node *) e; expr = a; } else @@ -184,21 +189,21 @@ transformUsingClause(ParseState *pstate, List *onList, char *lname, char *rname) { if (expr != NULL) { - A_Expr *a = makeNode(A_Expr); + A_Expr *a = makeNode(A_Expr); + a->oper = AND; a->opname = NULL; - a->lexpr = (Node *)expr; - a->rexpr = (Node *)qual; + a->lexpr = (Node *) expr; + a->rexpr = (Node *) qual; expr = a; } else - { - expr = (A_Expr *)qual; - } + expr = (A_Expr *) qual; } } - return ((Node *)transformExpr(pstate, (Node *)expr, EXPR_COLUMN_FIRST)); + return ((Node *) transformExpr(pstate, (Node *) expr, EXPR_COLUMN_FIRST)); } + #endif char * @@ -213,15 +218,14 @@ transformTableEntry(ParseState *pstate, RangeVar *r) refname = relname; /* - * marks this entry to indicate it comes from the FROM clause. In - * SQL, the target list can only refer to range variables - * specified in the from clause but we follow the more powerful - * POSTQUEL semantics and automatically generate the range - * variable if not specified. However there are times we need to - * know whether the entries are legitimate. + * marks this entry to indicate it comes from the FROM clause. In SQL, + * the target list can only refer to range variables specified in the + * from clause but we follow the more powerful POSTQUEL semantics and + * automatically generate the range variable if not specified. However + * there are times we need to know whether the entries are legitimate. * - * eg. select * from foo f where f.x = 1; will generate wrong answer - * if we expand * to foo.x. + * eg. select * from foo f where f.x = 1; will generate wrong answer if + * we expand * to foo.x. */ rte = addRangeTableEntry(pstate, relname, refname, baserel->inh, TRUE); @@ -253,7 +257,8 @@ parseFromClause(ParseState *pstate, List *frmList, Node **qual) foreach(fl, frmList) { - Node *n = lfirst(fl); + Node *n = lfirst(fl); + /* * marks this entry to indicate it comes from the FROM clause. In * SQL, the target list can only refer to range variables @@ -266,34 +271,36 @@ parseFromClause(ParseState *pstate, List *frmList, Node **qual) * if we expand * to foo.x. */ if (IsA(n, RangeVar)) - { - transformTableEntry(pstate, (RangeVar *)n); - } + transformTableEntry(pstate, (RangeVar *) n); else if (IsA(n, JoinExpr)) { - JoinExpr *j = (JoinExpr *)n; + JoinExpr *j = (JoinExpr *) n; + #ifdef ENABLE_OUTER_JOINS - char *lname = transformTableEntry(pstate, (RangeVar *)j->larg); + char *lname = transformTableEntry(pstate, (RangeVar *) j->larg); + #endif char *rname; - if (IsA((Node *)j->rarg, RangeVar)) - rname = transformTableEntry(pstate, (RangeVar *)j->rarg); + if (IsA((Node *) j->rarg, RangeVar)) + rname = transformTableEntry(pstate, (RangeVar *) j->rarg); else elog(ERROR, "Nested JOINs are not yet supported"); #ifdef ENABLE_OUTER_JOINS if (j->jointype == INNER_P) { - /* This is an inner join, so rip apart the join node - * and transform into a traditional FROM list. - * NATURAL JOIN and USING clauses both change the shape - * of the result. Need to generate a list of result columns - * to use for target list expansion and validation. - * Not doing this yet though! + + /* + * This is an inner join, so rip apart the join node and + * transform into a traditional FROM list. NATURAL JOIN + * and USING clauses both change the shape of the result. + * Need to generate a list of result columns to use for + * target list expansion and validation. Not doing this + * yet though! */ if (IsA(j->quals, List)) - j->quals = lcons(transformUsingClause(pstate, (List *)j->quals, lname, rname), NIL); + j->quals = lcons(transformUsingClause(pstate, (List *) j->quals, lname, rname), NIL); Assert(qual != NULL); @@ -302,19 +309,19 @@ parseFromClause(ParseState *pstate, List *frmList, Node **qual) else elog(ERROR, "Multiple JOIN/ON clauses not handled (internal error)"); - /* if we are transforming this node back into a FROM list, + /* + * if we are transforming this node back into a FROM list, * then we will need to replace the node with two nodes. * Will need access to the previous list item to change - * the link pointer to reference these new nodes. - * Try accumulating and returning a new list. - * - thomas 1999-01-08 - * Not doing this yet though! + * the link pointer to reference these new nodes. Try + * accumulating and returning a new list. - thomas + * 1999-01-08 Not doing this yet though! */ } else if ((j->jointype == LEFT) - || (j->jointype == RIGHT) - || (j->jointype == FULL)) + || (j->jointype == RIGHT) + || (j->jointype == FULL)) elog(ERROR, "OUTER JOIN is not implemented"); else elog(ERROR, "Unrecognized JOIN clause; tag is %d (internal error)", @@ -545,7 +552,7 @@ transformGroupClause(ParseState *pstate, List *grouplist, List *targetlist) resdom->restype, false)); if (glist == NIL) { - int groupref = length(glist) + 1; + int groupref = length(glist) + 1; restarget->resdom->resgroupref = groupref; grpcl->tleGroupref = groupref; @@ -561,12 +568,12 @@ transformGroupClause(ParseState *pstate, List *grouplist, List *targetlist) GroupClause *gcl = (GroupClause *) lfirst(i); if (equal(get_groupclause_expr(gcl, targetlist), - restarget->expr)) + restarget->expr)) break; } if (i == NIL) /* not in grouplist already */ { - int groupref = length(glist) + 1; + int groupref = length(glist) + 1; restarget->resdom->resgroupref = groupref; grpcl->tleGroupref = groupref; @@ -749,21 +756,22 @@ transformUnionClause(List *unionClause, List *targetlist) /* recursion */ qlist = parse_analyze(unionClause, NULL); - foreach (qlist_item, qlist) + foreach(qlist_item, qlist) { Query *query = (Query *) lfirst(qlist_item); List *prev_target = targetlist; List *next_target; - int prev_len = 0, next_len = 0; + int prev_len = 0, + next_len = 0; foreach(prev_target, targetlist) if (!((TargetEntry *) lfirst(prev_target))->resdom->resjunk) - prev_len++; + prev_len++; foreach(next_target, query->targetList) if (!((TargetEntry *) lfirst(next_target))->resdom->resjunk) - next_len++; - + next_len++; + if (prev_len != next_len) elog(ERROR, "Each UNION clause must have the same number of columns"); diff --git a/src/backend/parser/parse_coerce.c b/src/backend/parser/parse_coerce.c index a481ecfa0a..17b06faf4b 100644 --- a/src/backend/parser/parse_coerce.c +++ b/src/backend/parser/parse_coerce.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.15 1999/05/22 04:12:26 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.16 1999/05/25 16:10:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -28,7 +28,7 @@ Oid DemoteType(Oid inType); Oid PromoteTypeToNext(Oid inType); -static Oid PreferredType(CATEGORY category, Oid type); +static Oid PreferredType(CATEGORY category, Oid type); /* coerce_type() @@ -36,7 +36,7 @@ static Oid PreferredType(CATEGORY category, Oid type); */ Node * coerce_type(ParseState *pstate, Node *node, Oid inputTypeId, Oid targetTypeId, - int32 atttypmod) + int32 atttypmod) { Node *result = NULL; Oid infunc; @@ -60,6 +60,7 @@ coerce_type(ParseState *pstate, Node *node, Oid inputTypeId, Oid targetTypeId, */ else if (inputTypeId != UNKNOWNOID) { + /* * We already know there is a function which will do this, so * let's use it @@ -77,22 +78,22 @@ coerce_type(ParseState *pstate, Node *node, Oid inputTypeId, Oid targetTypeId, { Const *con = (Const *) node; - val = (Datum) textout((struct varlena *)con->constvalue); + val = (Datum) textout((struct varlena *) con->constvalue); infunc = typeidInfunc(targetTypeId); con = makeNode(Const); con->consttype = targetTypeId; con->constlen = typeLen(typeidType(targetTypeId)); /* - * Use "-1" for varchar() type. - * For char(), we need to pad out the type with the proper - * number of spaces. This was a major problem for - * DEFAULT string constants to char() types. + * Use "-1" for varchar() type. For char(), we need to pad + * out the type with the proper number of spaces. This + * was a major problem for DEFAULT string constants to + * char() types. */ con->constvalue = (Datum) fmgr(infunc, val, - typeidTypElem(targetTypeId), - (targetTypeId != BPCHAROID) ? -1 : atttypmod); + typeidTypElem(targetTypeId), + (targetTypeId != BPCHAROID) ? -1 : atttypmod); con->constisnull = false; con->constbyval = typeByVal(typeidType(targetTypeId)); con->constisset = false; @@ -150,6 +151,7 @@ can_coerce_type(int nargs, Oid *input_typeids, Oid *func_typeids) /* don't know what to do for the input type? then quit... */ else if (input_typeids[i] == InvalidOid) return false; + /* * if not unknown input type, try for explicit conversion * using functions... @@ -298,7 +300,7 @@ PreferredType(CATEGORY category, Oid type) case (NETWORK_TYPE): result = INETOID; break; - + case (GEOMETRIC_TYPE): case (USER_TYPE): result = type; diff --git a/src/backend/parser/parse_expr.c b/src/backend/parser/parse_expr.c index 8245beed11..8ea98d2809 100644 --- a/src/backend/parser/parse_expr.c +++ b/src/backend/parser/parse_expr.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.47 1999/05/22 04:12:26 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.48 1999/05/25 16:10:16 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -152,7 +152,7 @@ transformExpr(ParseState *pstate, Node *expr, int precedence) */ idx = lnext(idx); } - result = (Node *) make_array_ref((Node *)param, pno->indirection); + result = (Node *) make_array_ref((Node *) param, pno->indirection); } else result = (Node *) param; @@ -251,7 +251,8 @@ transformExpr(ParseState *pstate, Node *expr, int precedence) { /* - * look for a column name or a relation name (the default behavior) + * look for a column name or a relation name (the default + * behavior) */ result = transformIdent(pstate, expr, precedence); break; @@ -343,28 +344,31 @@ transformExpr(ParseState *pstate, Node *expr, int precedence) if (c->arg != NULL) { /* shorthand form was specified, so expand... */ - A_Expr *a = makeNode(A_Expr); + A_Expr *a = makeNode(A_Expr); + a->oper = OP; a->opname = "="; a->lexpr = c->arg; a->rexpr = w->expr; - w->expr = (Node *)a; + w->expr = (Node *) a; } lfirst(args) = transformExpr(pstate, (Node *) w, precedence); } - /* It's not shorthand anymore, so drop the implicit argument. - * This is necessary to keep the executor from seeing an - * untransformed expression... + /* + * It's not shorthand anymore, so drop the implicit + * argument. This is necessary to keep the executor from + * seeing an untransformed expression... */ c->arg = NULL; /* transform the default clause */ if (c->defresult == NULL) { - A_Const *n = makeNode(A_Const); + A_Const *n = makeNode(A_Const); + n->val.type = T_Null; - c->defresult = (Node *)n; + c->defresult = (Node *) n; } c->defresult = transformExpr(pstate, (Node *) c->defresult, precedence); @@ -380,7 +384,7 @@ transformExpr(ParseState *pstate, Node *expr, int precedence) wtype = exprType(w->result); /* move on to next one if no new information... */ if (wtype && (wtype != UNKNOWNOID) - && (wtype != ptype)) + && (wtype != ptype)) { /* so far, only nulls so take anything... */ if (!ptype) @@ -388,15 +392,23 @@ transformExpr(ParseState *pstate, Node *expr, int precedence) ptype = wtype; pcategory = TypeCategory(ptype); } - /* both types in different categories? then not much hope... */ + + /* + * both types in different categories? then not + * much hope... + */ else if ((TypeCategory(wtype) != pcategory) - || ((TypeCategory(wtype) == USER_TYPE) - && (TypeCategory(c->casetype) == USER_TYPE))) + || ((TypeCategory(wtype) == USER_TYPE) + && (TypeCategory(c->casetype) == USER_TYPE))) { - elog(ERROR,"CASE/WHEN types '%s' and '%s' not matched", + elog(ERROR, "CASE/WHEN types '%s' and '%s' not matched", typeidTypeName(c->casetype), typeidTypeName(wtype)); } - /* new one is preferred and can convert? then take it... */ + + /* + * new one is preferred and can convert? then take + * it... + */ else if (IsPreferredType(pcategory, wtype) && can_coerce_type(1, &ptype, &wtype)) { @@ -409,21 +421,24 @@ transformExpr(ParseState *pstate, Node *expr, int precedence) /* Convert default result clause, if necessary */ if (c->casetype != ptype) { - if (! c->casetype) + if (!c->casetype) { - /* default clause is NULL, - * so assign preferred type from WHEN clauses... */ + + /* + * default clause is NULL, so assign preferred + * type from WHEN clauses... + */ c->casetype = ptype; } else if (can_coerce_type(1, &c->casetype, &ptype)) { c->defresult = coerce_type(pstate, c->defresult, - c->casetype, ptype, -1); + c->casetype, ptype, -1); c->casetype = ptype; } else { - elog(ERROR,"CASE/ELSE unable to convert to type %s", + elog(ERROR, "CASE/ELSE unable to convert to type %s", typeidTypeName(ptype)); } } @@ -431,11 +446,15 @@ transformExpr(ParseState *pstate, Node *expr, int precedence) /* Convert when clauses, if not null and if necessary */ foreach(args, c->args) { - Oid wtype; + Oid wtype; w = lfirst(args); wtype = exprType(w->result); - /* only bother with conversion if not NULL and different type... */ + + /* + * only bother with conversion if not NULL and + * different type... + */ if (wtype && (wtype != ptype)) { if (can_coerce_type(1, &wtype, &ptype)) @@ -445,7 +464,7 @@ transformExpr(ParseState *pstate, Node *expr, int precedence) } else { - elog(ERROR,"CASE/WHEN unable to convert to type %s", + elog(ERROR, "CASE/WHEN unable to convert to type %s", typeidTypeName(ptype)); } } @@ -461,14 +480,18 @@ transformExpr(ParseState *pstate, Node *expr, int precedence) w->expr = transformExpr(pstate, (Node *) w->expr, precedence); if (exprType(w->expr) != BOOLOID) - elog(ERROR,"WHEN clause must have a boolean result"); + elog(ERROR, "WHEN clause must have a boolean result"); - /* result is NULL for NULLIF() construct - thomas 1998-11-11 */ + /* + * result is NULL for NULLIF() construct - thomas + * 1998-11-11 + */ if (w->result == NULL) { - A_Const *n = makeNode(A_Const); + A_Const *n = makeNode(A_Const); + n->val.type = T_Null; - w->result = (Node *)n; + w->result = (Node *) n; } w->result = transformExpr(pstate, (Node *) w->result, precedence); result = expr; @@ -530,7 +553,7 @@ transformIdent(ParseState *pstate, Node *expr, int precedence) att->relname = rte->refname; att->attrs = lcons(makeString(ident->name), NIL); column_result = (Node *) ParseNestedFuncOrColumn(pstate, att, - &pstate->p_last_resno, precedence); + &pstate->p_last_resno, precedence); } /* try to find the ident as a relation */ @@ -602,11 +625,13 @@ exprType(Node *expr) break; case T_SubLink: { - SubLink *sublink = (SubLink *) expr; + SubLink *sublink = (SubLink *) expr; + if (sublink->subLinkType == EXPR_SUBLINK) { /* return the result type of the combining operator */ - Expr *op_expr = (Expr *) lfirst(sublink->oper); + Expr *op_expr = (Expr *) lfirst(sublink->oper); + type = op_expr->typeOid; } else diff --git a/src/backend/parser/parse_func.c b/src/backend/parser/parse_func.c index 6a4258048b..8fa8fb8b36 100644 --- a/src/backend/parser/parse_func.c +++ b/src/backend/parser/parse_func.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.45 1999/05/22 04:12:27 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.46 1999/05/25 16:10:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -77,9 +77,9 @@ static int match_argtypes(int nargs, static List *setup_tlist(char *attname, Oid relid); static List *setup_base_tlist(Oid typeid); static Oid *func_select_candidate(int nargs, Oid *input_typeids, - CandidateList candidates); -static int agg_get_candidates(char *aggname, Oid typeId, CandidateList *candidates); -static Oid agg_select_candidate(Oid typeid, CandidateList candidates); + CandidateList candidates); +static int agg_get_candidates(char *aggname, Oid typeId, CandidateList *candidates); +static Oid agg_select_candidate(Oid typeid, CandidateList candidates); #define ISCOMPLEX(type) (typeidTypeRelid(type) ? true : false) @@ -91,7 +91,7 @@ typedef struct _SuperQE } SuperQE; /* - ** ParseNestedFuncOrColumn + ** ParseNestedFuncOrColumn ** Given a nested dot expression (i.e. (relation func ... attr), build up ** a tree with of Iter and Func nodes. */ @@ -139,12 +139,12 @@ agg_get_candidates(char *aggname, Oid typeId, CandidateList *candidates) { - CandidateList current_candidate; - Relation pg_aggregate_desc; - HeapScanDesc pg_aggregate_scan; - HeapTuple tup; - Form_pg_aggregate agg; - int ncandidates = 0; + CandidateList current_candidate; + Relation pg_aggregate_desc; + HeapScanDesc pg_aggregate_scan; + HeapTuple tup; + Form_pg_aggregate agg; + int ncandidates = 0; static ScanKeyData aggKey[1] = { {0, Anum_pg_aggregate_aggname, F_NAMEEQ}}; @@ -157,7 +157,7 @@ agg_get_candidates(char *aggname, pg_aggregate_desc = heap_openr(AggregateRelationName); pg_aggregate_scan = heap_beginscan(pg_aggregate_desc, 0, - SnapshotSelf, /* ??? */ + SnapshotSelf, /* ??? */ 1, aggKey); @@ -185,12 +185,12 @@ agg_get_candidates(char *aggname, static Oid agg_select_candidate(Oid typeid, CandidateList candidates) { - CandidateList current_candidate; - CandidateList last_candidate; - Oid current_typeid; - int ncandidates; - CATEGORY category, - current_category; + CandidateList current_candidate; + CandidateList last_candidate; + Oid current_typeid; + int ncandidates; + CATEGORY category, + current_category; /* * Look for candidates which allow coersion and have a preferred type. @@ -227,13 +227,11 @@ agg_select_candidate(Oid typeid, CandidateList candidates) } /* otherwise, don't bother keeping this one around... */ else if (last_candidate != NULL) - { last_candidate->next = NULL; - } } return ((ncandidates == 1) ? candidates->args[0] : 0); -} /* agg_select_candidate() */ +} /* agg_select_candidate() */ /* @@ -352,13 +350,14 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs, } else { + /* * Parsing aggregates. */ - Type tp; - Oid basetype; - int ncandidates; - CandidateList candidates; + Type tp; + Oid basetype; + int ncandidates; + CandidateList candidates; /* * the aggregate COUNT is a special case, ignore its base @@ -378,14 +377,13 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs, fargs, precedence); /* - * No exact match yet, so see if there is another entry - * in the aggregate table which is compatible. - * - thomas 1998-12-05 + * No exact match yet, so see if there is another entry in the + * aggregate table which is compatible. - thomas 1998-12-05 */ ncandidates = agg_get_candidates(funcname, basetype, &candidates); if (ncandidates > 0) { - Oid type; + Oid type; type = agg_select_candidate(basetype, candidates); if (OidIsValid(type)) @@ -399,7 +397,7 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs, } else { - elog(ERROR,"Unable to select an aggregate function %s(%s)", + elog(ERROR, "Unable to select an aggregate function %s(%s)", funcname, typeidTypeName(basetype)); } } @@ -407,18 +405,16 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs, /* * See if this is a single argument function with the function * name also a type name and the input argument and type name - * binary compatible... - * This means that you are trying for a type conversion which does not - * need to take place, so we'll just pass through the argument itself. - * (make this clearer with some extra brackets - thomas 1998-12-05) + * binary compatible... This means that you are trying for a + * type conversion which does not need to take place, so we'll + * just pass through the argument itself. (make this clearer + * with some extra brackets - thomas 1998-12-05) */ if ((HeapTupleIsValid(tp = SearchSysCacheTuple(TYPNAME, - PointerGetDatum(funcname), + PointerGetDatum(funcname), 0, 0, 0))) && IS_BINARY_COMPATIBLE(typeTypeId(tp), basetype)) - { return ((Node *) lfirst(fargs)); - } } } @@ -440,6 +436,7 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs, if (nodeTag(pair) == T_Ident && ((Ident *) pair)->isRel) { + /* * a relation */ @@ -551,9 +548,7 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs, if (attisset) { if (!strcmp(funcname, "*")) - { funcnode->func_tlist = expandAll(pstate, relname, refname, curr_resno); - } else { funcnode->func_tlist = setup_tlist(funcname, argrelid); @@ -581,13 +576,13 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs, seqrel = textout((text *) DatumGetPointer(seq->constvalue)); /* Do we have nextval('"Aa"')? */ if (strlen(seqrel) >= 2 && - seqrel[0] == '\"' && seqrel[strlen(seqrel)-1] == '\"') + seqrel[0] == '\"' && seqrel[strlen(seqrel) - 1] == '\"') { /* strip off quotes, keep case */ - seqrel = pstrdup(seqrel+1); - seqrel[strlen(seqrel)-1] = '\0'; + seqrel = pstrdup(seqrel + 1); + seqrel[strlen(seqrel) - 1] = '\0'; pfree(DatumGetPointer(seq->constvalue)); - seq->constvalue = (Datum)textin(seqrel); + seq->constvalue = (Datum) textin(seqrel); } else { @@ -669,7 +664,7 @@ func_get_candidates(char *funcname, int nargs) Relation heapRelation; Relation idesc; ScanKeyData skey; - HeapTupleData tuple; + HeapTupleData tuple; IndexScanDesc sd; RetrieveIndexResult indexRes; Form_pg_proc pgProcP; @@ -837,9 +832,7 @@ func_select_candidate(int nargs, ncandidates++; } else - { last_candidate->next = NULL; - } } if (ncandidates == 1) @@ -870,9 +863,7 @@ func_select_candidate(int nargs, } else if ((current_category != slot_category) && IS_BUILTIN_TYPE(current_type)) - { return NULL; - } else if (current_type != slot_type) { if (IsPreferredType(slot_category, current_type)) @@ -881,16 +872,12 @@ func_select_candidate(int nargs, candidates = current_candidate; } else if (IsPreferredType(slot_category, slot_type)) - { - candidates->next = current_candidate->next; - } + candidates->next = current_candidate->next; } } if (slot_type != InvalidOid) - { input_typeids[i] = slot_type; - } } else { @@ -979,7 +966,7 @@ func_get_detail(char *funcname, ftup = SearchSysCacheTuple(PRONAME, PointerGetDatum(funcname), Int32GetDatum(nargs), - PointerGetDatum(*true_typeids), + PointerGetDatum(*true_typeids), 0); Assert(HeapTupleIsValid(ftup)); } @@ -991,8 +978,8 @@ func_get_detail(char *funcname, else if (ncandidates > 1) { *true_typeids = func_select_candidate(nargs, - current_input_typeids, - current_function_typeids); + current_input_typeids, + current_function_typeids); /* couldn't decide, so quit */ if (*true_typeids == NULL) @@ -1006,9 +993,9 @@ func_get_detail(char *funcname, else { ftup = SearchSysCacheTuple(PRONAME, - PointerGetDatum(funcname), + PointerGetDatum(funcname), Int32GetDatum(nargs), - PointerGetDatum(*true_typeids), + PointerGetDatum(*true_typeids), 0); Assert(HeapTupleIsValid(ftup)); } @@ -1304,9 +1291,9 @@ make_arguments(ParseState *pstate, if (input_typeids[i] == UNKNOWNOID && function_typeids[i] != InvalidOid) { lfirst(current_fargs) = parser_typecast2(lfirst(current_fargs), - input_typeids[i], - typeidType(function_typeids[i]), - -1); + input_typeids[i], + typeidType(function_typeids[i]), + -1); } /* types don't match? then force coersion using a function call... */ @@ -1321,7 +1308,7 @@ make_arguments(ParseState *pstate, } /* - ** setup_tlist + ** setup_tlist ** Build a tlist that says which attribute to project to. ** This routine is called by ParseFuncOrColumn() to set up a target list ** on a tuple parameter or return value. Due to a bug in 4.0, @@ -1359,7 +1346,7 @@ setup_tlist(char *attname, Oid relid) } /* - ** setup_base_tlist + ** setup_base_tlist ** Build a tlist that extracts a base type from the tuple ** returned by the executor. */ diff --git a/src/backend/parser/parse_oper.c b/src/backend/parser/parse_oper.c index 6e03951760..9f41d00b9e 100644 --- a/src/backend/parser/parse_oper.c +++ b/src/backend/parser/parse_oper.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.24 1999/05/10 00:45:29 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.25 1999/05/25 16:10:18 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -27,8 +27,8 @@ #include "storage/bufmgr.h" #include "utils/syscache.h" -static Oid * oper_select_candidate(int nargs, Oid *input_typeids, - CandidateList candidates); +static Oid *oper_select_candidate(int nargs, Oid *input_typeids, + CandidateList candidates); static int binary_oper_get_candidates(char *opname, Oid leftTypeId, Oid rightTypeId, @@ -227,9 +227,7 @@ oper_select_candidate(int nargs, } /* otherwise, don't bother keeping this one... */ else - { last_candidate->next = NULL; - } } if (ncandidates <= 1) @@ -281,18 +279,14 @@ oper_select_candidate(int nargs, ncandidates++; } else - { last_candidate->next = NULL; - } } if (ncandidates <= 1) { if (!can_coerce_type(1, &input_typeids[0], &candidates->args[0]) - || ((nargs > 1) && !can_coerce_type(1, &input_typeids[1], &candidates->args[1]))) - { + || ((nargs > 1) && !can_coerce_type(1, &input_typeids[1], &candidates->args[1]))) ncandidates = 0; - } return (ncandidates == 1) ? candidates->args : NULL; } @@ -349,9 +343,7 @@ oper_select_candidate(int nargs, slot_type = current_type; } else if (current_category != slot_category) - { return NULL; - } else if (current_type != slot_type) { if (IsPreferredType(slot_category, current_type)) @@ -366,9 +358,7 @@ oper_select_candidate(int nargs, } if (slot_type != InvalidOid) - { input_typeids[i] = slot_type; - } } else { @@ -656,9 +646,7 @@ right_oper(char *op, Oid arg) CharGetDatum('r')); } else - { tup = NULL; - } if (!HeapTupleIsValid(tup)) { @@ -717,9 +705,7 @@ left_oper(char *op, Oid arg) CharGetDatum('l')); } else - { tup = NULL; - } if (!HeapTupleIsValid(tup)) { diff --git a/src/backend/parser/parse_relation.c b/src/backend/parser/parse_relation.c index 07919e1b31..3101f7ac7a 100644 --- a/src/backend/parser/parse_relation.c +++ b/src/backend/parser/parse_relation.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.21 1999/05/22 04:12:28 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.22 1999/05/25 16:10:19 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -446,8 +446,8 @@ checkTargetTypes(ParseState *pstate, char *target_colname, if (can_coerce_type(1, &attrtype_id, &attrtype_target)) { Node *expr = coerce_type(pstate, expr, attrtype_id, - attrtype_target, - get_atttypmod(pstate->p_target_relation->rd_id, resdomno_target)); + attrtype_target, + get_atttypmod(pstate->p_target_relation->rd_id, resdomno_target)); elog(ERROR, "Type %s(%d) can be coerced to match target column %s(%d)", colname, get_atttypmod(rte->relid, resdomno_id), diff --git a/src/backend/parser/parse_target.c b/src/backend/parser/parse_target.c index 2dfe2ece57..1b821606f5 100644 --- a/src/backend/parser/parse_target.c +++ b/src/backend/parser/parse_target.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.39 1999/05/23 21:42:09 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.40 1999/05/25 16:10:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -64,10 +64,12 @@ MakeTargetEntryIdent(ParseState *pstate, if (pstate->p_is_insert && !resjunk) { - /* Assign column name of destination column to the new TLE. - * XXX this is probably WRONG in INSERT ... SELECT case, - * since handling of GROUP BY and so forth probably should use - * the source table's names not the destination's names. + + /* + * Assign column name of destination column to the new TLE. XXX + * this is probably WRONG in INSERT ... SELECT case, since + * handling of GROUP BY and so forth probably should use the + * source table's names not the destination's names. */ if (pstate->p_insert_columns != NIL) { @@ -123,8 +125,8 @@ MakeTargetEntryIdent(ParseState *pstate, if (can_coerce_type(1, &attrtype_id, &attrtype_target)) { expr = coerce_type(pstate, node, attrtype_id, - attrtype_target, - get_atttypmod(pstate->p_target_relation->rd_id, resdomno_target)); + attrtype_target, + get_atttypmod(pstate->p_target_relation->rd_id, resdomno_target)); expr = transformExpr(pstate, expr, EXPR_COLUMN_FIRST); tent = MakeTargetEntryExpr(pstate, *resname, expr, false, false); expr = tent->expr; @@ -248,7 +250,7 @@ MakeTargetEntryExpr(ParseState *pstate, if (!HeapTupleIsValid(expr)) elog(ERROR, "Attribute '%s' is of type '%s'" " but expression is of type '%s'" - "\n\tYou will need to rewrite or cast the expression", + "\n\tYou will need to rewrite or cast the expression", colname, typeidTypeName(attrtype), typeidTypeName(type_id)); @@ -326,20 +328,20 @@ static TargetEntry * MakeTargetEntryCase(ParseState *pstate, ResTarget *res) { - TargetEntry *tent; - CaseExpr *expr; - Resdom *resnode; - int resdomno; - Oid type_id; - int32 type_mod; + TargetEntry *tent; + CaseExpr *expr; + Resdom *resnode; + int resdomno; + Oid type_id; + int32 type_mod; - expr = (CaseExpr *)transformExpr(pstate, (Node *)res->val, EXPR_COLUMN_FIRST); + expr = (CaseExpr *) transformExpr(pstate, (Node *) res->val, EXPR_COLUMN_FIRST); type_id = expr->casetype; type_mod = -1; handleTargetColname(pstate, &res->name, NULL, NULL); if (res->name == NULL) - res->name = FigureColname((Node *)expr, res->val); + res->name = FigureColname((Node *) expr, res->val); resdomno = pstate->p_last_resno++; resnode = makeResdom((AttrNumber) resdomno, @@ -352,7 +354,7 @@ MakeTargetEntryCase(ParseState *pstate, tent = makeNode(TargetEntry); tent->resdom = resnode; - tent->expr = (Node *)expr; + tent->expr = (Node *) expr; return tent; } /* MakeTargetEntryCase() */ @@ -435,7 +437,7 @@ MakeTargetEntryComplex(ParseState *pstate, else { /* this is not an array assignment */ - char *colname = res->name; + char *colname = res->name; if (colname == NULL) { @@ -564,7 +566,7 @@ transformTargetList(ParseState *pstate, List *targetlist) identname = ((Ident *) res->val)->name; tent = MakeTargetEntryIdent(pstate, - (Node *) res->val, &res->name, NULL, identname, false); + (Node *) res->val, &res->name, NULL, identname, false); break; } case T_ParamNo: @@ -619,7 +621,7 @@ transformTargetList(ParseState *pstate, List *targetlist) att->relname, &pstate->p_last_resno); else lnext(tail_p_target) = expandAll(pstate, att->relname, att->relname, - &pstate->p_last_resno); + &pstate->p_last_resno); expand_star = true; } } @@ -668,9 +670,7 @@ CoerceTargetExpr(ParseState *pstate, Oid attrtype) { if (can_coerce_type(1, &type_id, &attrtype)) - { expr = coerce_type(pstate, expr, type_id, attrtype, -1); - } #ifndef DISABLE_STRING_HACKS @@ -818,6 +818,7 @@ ExpandAllTables(ParseState *pstate) rtable = pstate->p_rtable; if (pstate->p_is_rule) { + /* * skip first two entries, "*new*" and "*current*" */ @@ -876,7 +877,7 @@ FigureColname(Node *expr, Node *resval) { switch (nodeTag(expr)) { - case T_Aggref: + case T_Aggref: return (char *) ((Aggref *) expr)->aggname; case T_Expr: if (((Expr *) expr)->opType == FUNC_EXPR) @@ -887,7 +888,8 @@ FigureColname(Node *expr, Node *resval) break; case T_CaseExpr: { - char *name; + char *name; + name = FigureColname(((CaseExpr *) expr)->defresult, resval); if (!strcmp(name, "?column?")) name = "case"; diff --git a/src/backend/parser/parse_type.c b/src/backend/parser/parse_type.c index 6f77c0e876..cdec9d9aea 100644 --- a/src/backend/parser/parse_type.c +++ b/src/backend/parser/parse_type.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_type.c,v 1.20 1999/05/10 00:45:29 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_type.c,v 1.21 1999/05/25 16:10:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -172,6 +172,7 @@ typeidOutfunc(Oid type_id) outfunc = type->typoutput; return outfunc; } + #endif Oid diff --git a/src/backend/parser/parser.c b/src/backend/parser/parser.c index b105993641..48c9860159 100644 --- a/src/backend/parser/parser.c +++ b/src/backend/parser/parser.c @@ -6,7 +6,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parser.c,v 1.38 1999/05/13 07:28:39 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parser.c,v 1.39 1999/05/25 16:10:24 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -22,6 +22,7 @@ #if defined(FLEX_SCANNER) extern void DeleteBuffer(void); + #endif /* FLEX_SCANNER */ char *parseString; /* the char* which holds the string to be @@ -31,6 +32,7 @@ List *parsetree; /* result of parsing is left here */ #ifdef SETS_FIXED static void fixupsets(); static void define_sets(); + #endif /* diff --git a/src/backend/parser/scansup.c b/src/backend/parser/scansup.c index 36a5734bb3..f32aee93f8 100644 --- a/src/backend/parser/scansup.c +++ b/src/backend/parser/scansup.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/scansup.c,v 1.12 1999/02/13 23:17:12 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/scansup.c,v 1.13 1999/05/25 16:10:25 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -51,8 +51,10 @@ scanstr(char *s) { if (s[i] == '\'') { - /* Note: if scanner is working right, unescaped quotes can only - * appear in pairs, so there should be another character. + + /* + * Note: if scanner is working right, unescaped quotes can + * only appear in pairs, so there should be another character. */ i++; newStr[j] = s[i]; diff --git a/src/backend/port/dynloader/freebsd.c b/src/backend/port/dynloader/freebsd.c index 14d21fb61f..0b5e327de4 100644 --- a/src/backend/port/dynloader/freebsd.c +++ b/src/backend/port/dynloader/freebsd.c @@ -68,7 +68,7 @@ BSD44_derived_dlopen(const char *file, int num) void *vp; if ((vp = dlopen((char *) file, num)) == (void *) NULL) - sprintf(error_message, "dlopen '%s' failed. (%s)", file, dlerror() ); + sprintf(error_message, "dlopen '%s' failed. (%s)", file, dlerror()); return vp; #endif } diff --git a/src/backend/port/hpux/fixade.h b/src/backend/port/hpux/fixade.h index d76c8c256e..a85fa8b1a5 100644 --- a/src/backend/port/hpux/fixade.h +++ b/src/backend/port/hpux/fixade.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: fixade.h,v 1.6 1999/05/03 19:09:44 momjian Exp $ + * $Id: fixade.h,v 1.7 1999/05/25 16:10:36 momjian Exp $ * * NOTES * This must be included in EVERY source file. @@ -47,11 +47,11 @@ */ struct HP_WAY_BOGUS { - char hpwb_bogus[8191+1]; + char hpwb_bogus[8191 + 1]; }; struct HP_TOO_BOGUS { - int hptb_bogus[8191+1]; + int hptb_bogus[8191 + 1]; }; #endif /* BROKEN_STRUCT_INIT */ diff --git a/src/backend/port/snprintf.c b/src/backend/port/snprintf.c index 705989b6ca..0f9ed9cbc2 100644 --- a/src/backend/port/snprintf.c +++ b/src/backend/port/snprintf.c @@ -51,11 +51,13 @@ * here called long_long (or ulong_long for unsigned). */ #ifdef HAVE_LONG_LONG_INT_64 -typedef long long long_long; -typedef unsigned long long ulong_long; +typedef long long long_long; +typedef unsigned long long ulong_long; + #else -typedef long long_long; -typedef unsigned long ulong_long; +typedef long long_long; +typedef unsigned long ulong_long; + #endif /* @@ -80,7 +82,7 @@ typedef unsigned long ulong_long; * causing nast effects. **************************************************************/ -/*static char _id[] = "$Id: snprintf.c,v 1.21 1999/02/21 03:49:08 scrappy Exp $";*/ +/*static char _id[] = "$Id: snprintf.c,v 1.22 1999/05/25 16:10:28 momjian Exp $";*/ static char *end; static int SnprfOverflow; @@ -92,7 +94,7 @@ int snprintf(char *str, size_t count, const char *fmt,...) { int len; - va_list args; + va_list args; va_start(args, fmt); len = vsnprintf(str, count, fmt, args); @@ -120,11 +122,11 @@ vsnprintf(char *str, size_t count, const char *fmt, va_list args) * dopr(): poor man's version of doprintf */ -static void fmtstr (char *value, int ljust, int len, int zpad, int maxwidth); -static void fmtnum (long_long value, int base, int dosign, int ljust, int len, int zpad); -static void fmtfloat (double value, char type, int ljust, int len, int precision, int pointflag); -static void dostr (char *str, int cut); -static void dopr_outch (int c); +static void fmtstr(char *value, int ljust, int len, int zpad, int maxwidth); +static void fmtnum(long_long value, int base, int dosign, int ljust, int len, int zpad); +static void fmtfloat(double value, char type, int ljust, int len, int precision, int pointflag); +static void dostr(char *str, int cut); +static void dopr_outch(int c); static char *output; @@ -408,7 +410,7 @@ fmtnum(long_long value, int base, int dosign, int ljust, int len, int zpad) } static void -fmtfloat (double value, char type, int ljust, int len, int precision, int pointflag) +fmtfloat(double value, char type, int ljust, int len, int precision, int pointflag) { char fmt[32]; char convert[512]; diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index cf1271c7ec..46e224385b 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.104 1999/05/22 17:47:50 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.105 1999/05/25 16:10:40 momjian Exp $ * * NOTES * @@ -164,16 +164,16 @@ static IpcMemoryKey ipc_key; static int MaxBackends = DEF_MAXBACKENDS; - /* - * MaxBackends is the actual limit on the number of backends we will start. - * The default is established by configure, but it can be readjusted - * from 1..MAXBACKENDS with the postmaster -N switch. - * Note that a larger MaxBackends value will increase the size of the - * shared memory area as well as cause the postmaster to grab more - * kernel semaphores, even if you never actually use that many backends. + /* + * MaxBackends is the actual limit on the number of backends we will + * start. The default is established by configure, but it can be + * readjusted from 1..MAXBACKENDS with the postmaster -N switch. Note + * that a larger MaxBackends value will increase the size of the shared + * memory area as well as cause the postmaster to grab more kernel + * semaphores, even if you never actually use that many backends. */ -static int NextBackendTag = MAXINT; /* XXX why count down not up? */ +static int NextBackendTag = MAXINT; /* XXX why count down not up? */ static char *progname = (char *) NULL; static char **real_argv; static int real_argc; @@ -184,8 +184,10 @@ static int real_argc; static char Execfile[MAXPATHLEN] = ""; static int ServerSock_INET = INVALID_SOCK; /* stream socket server */ + #ifndef __CYGWIN32__ static int ServerSock_UNIX = INVALID_SOCK; /* stream socket server */ + #endif /* @@ -254,7 +256,7 @@ static int initMasks(fd_set *rmask, fd_set *wmask); static long PostmasterRandom(void); static void RandomSalt(char *salt); static void SignalChildren(SIGNAL_ARGS); -static int CountChildren(void); +static int CountChildren(void); #ifdef CYR_RECODE void GetCharSetByHost(char *, int, char *); @@ -474,9 +476,10 @@ PostmasterMain(int argc, char *argv[]) */ break; case 'N': + /* - * The max number of backends to start. - * Can't set to less than 1 or more than compiled-in limit. + * The max number of backends to start. Can't set to less + * than 1 or more than compiled-in limit. */ MaxBackends = atoi(optarg); if (MaxBackends < 1) @@ -793,11 +796,12 @@ ServerLoop(void) "Sorry, too many clients already"); else { + /* * If the backend start fails then keep the connection * open to report it. Otherwise, pretend there is an - * error to close the connection which will now be managed - * by the backend. + * error to close the connection which will now be + * managed by the backend. */ if (BackendStartup(port) != STATUS_OK) PacketSendError(&port->pktInfo, @@ -1337,11 +1341,12 @@ BackendStartup(Port *port) } /* - * Flush stdio channels just before fork, to avoid double-output problems. - * Ideally we'd use fflush(NULL) here, but there are still a few non-ANSI - * stdio libraries out there (like SunOS 4.1.x) that coredump if we do. - * Presently stdout and stderr are the only stdio output channels used - * by the postmaster, so fflush'ing them should be sufficient. + * Flush stdio channels just before fork, to avoid double-output + * problems. Ideally we'd use fflush(NULL) here, but there are still a + * few non-ANSI stdio libraries out there (like SunOS 4.1.x) that + * coredump if we do. Presently stdout and stderr are the only stdio + * output channels used by the postmaster, so fflush'ing them should + * be sufficient. */ fflush(stdout); fflush(stderr); @@ -1372,7 +1377,9 @@ BackendStartup(Port *port) port->sock); /* Generate a new backend tag for every backend we start */ - /* XXX theoretically this could wrap around, if you have the patience + + /* + * XXX theoretically this could wrap around, if you have the patience * to start 2^31 backends ... */ NextBackendTag -= 1; @@ -1549,10 +1556,10 @@ DoBackend(Port *port) } /* - * Pass any backend switches specified with -o in the postmaster's - * own command line. We assume these are secure. - * (It's OK to mangle ExtraOptions since we are now in the child process; - * this won't change the postmaster's copy.) + * Pass any backend switches specified with -o in the postmaster's own + * command line. We assume these are secure. (It's OK to mangle + * ExtraOptions since we are now in the child process; this won't + * change the postmaster's copy.) */ split_opts(av, &ac, ExtraOptions); @@ -1561,8 +1568,8 @@ DoBackend(Port *port) av[ac++] = protobuf; /* - * Tell the backend it is being called from the postmaster, - * and which database to use. -p marks the end of secure switches. + * Tell the backend it is being called from the postmaster, and which + * database to use. -p marks the end of secure switches. */ av[ac++] = "-p"; @@ -1700,7 +1707,7 @@ static int CountChildren(void) { Dlelem *curr; - Backend *bp; + Backend *bp; int mypid = getpid(); int cnt = 0; diff --git a/src/backend/regex/regcomp.c b/src/backend/regex/regcomp.c index b68f70c4dd..d7dded8f4b 100644 --- a/src/backend/regex/regcomp.c +++ b/src/backend/regex/regcomp.c @@ -1037,9 +1037,9 @@ int endc; /* name ended by endc,']' */ == static char othercase(int ch); */ #ifdef MULTIBYTE -static unsigned char /* if no counterpart, return ch */ +static unsigned char /* if no counterpart, return ch */ #else -static char /* if no counterpart, return ch */ +static char /* if no counterpart, return ch */ #endif othercase(ch) int ch; @@ -1047,20 +1047,20 @@ int ch; assert(pg_isalpha(ch)); if (pg_isupper(ch)) #ifdef MULTIBYTE - return (unsigned char)tolower(ch); + return (unsigned char) tolower(ch); #else return tolower(ch); #endif else if (pg_islower(ch)) #ifdef MULTIBYTE - return (unsigned char)toupper(ch); + return (unsigned char) toupper(ch); #else return toupper(ch); #endif else /* peculiar, but could happen */ #ifdef MULTIBYTE - return (unsigned char)ch; + return (unsigned char) ch; #else return ch; #endif diff --git a/src/backend/regex/retest.c b/src/backend/regex/retest.c index 13dd0761f0..4eb9b2282f 100644 --- a/src/backend/regex/retest.c +++ b/src/backend/regex/retest.c @@ -1,7 +1,7 @@ /* * a simple regexp debug program - * - * $Header: /cvsroot/pgsql/src/backend/regex/Attic/retest.c,v 1.1 1999/05/21 06:27:54 ishii Exp $ + * + * $Header: /cvsroot/pgsql/src/backend/regex/Attic/retest.c,v 1.2 1999/05/25 16:10:45 momjian Exp $ */ #include @@ -9,34 +9,38 @@ #include "postgres.h" #include -int main() +int +main() { - int sts; - regex_t re; - char buf[1024]; - char *p; + int sts; + regex_t re; + char buf[1024]; + char *p; - printf("type in regexp string: "); - if (!fgets(buf,sizeof(buf),stdin)) { - exit(0); - } - p = strchr(buf, '\n'); - if (p) *p = '\0'; + printf("type in regexp string: "); + if (!fgets(buf, sizeof(buf), stdin)) + exit(0); + p = strchr(buf, '\n'); + if (p) + *p = '\0'; - sts = pg95_regcomp(&re, buf, 1); - printf("regcomp: parses \"%s\" and returns %d\n",buf, sts); - for (;;) { - printf("type in target string: "); - if (!fgets(buf,sizeof(buf),stdin)) { - exit(0); - } - p = strchr(buf, '\n'); - if (p) *p = '\0'; + sts = pg95_regcomp(&re, buf, 1); + printf("regcomp: parses \"%s\" and returns %d\n", buf, sts); + for (;;) + { + printf("type in target string: "); + if (!fgets(buf, sizeof(buf), stdin)) + exit(0); + p = strchr(buf, '\n'); + if (p) + *p = '\0'; - sts = pg95_regexec(&re, buf, 0, 0, 0); - printf("regexec: returns %d\n", sts); - } + sts = pg95_regexec(&re, buf, 0, 0, 0); + printf("regexec: returns %d\n", sts); + } } -void elog(int lev, const char *fmt,...) -{} +void +elog(int lev, const char *fmt,...) +{ +} diff --git a/src/backend/rewrite/rewriteDefine.c b/src/backend/rewrite/rewriteDefine.c index 431006843f..4c7fed8b30 100644 --- a/src/backend/rewrite/rewriteDefine.c +++ b/src/backend/rewrite/rewriteDefine.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteDefine.c,v 1.28 1999/05/12 17:04:46 wieck Exp $ + * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteDefine.c,v 1.29 1999/05/25 16:10:48 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -238,12 +238,12 @@ DefineQueryRewrite(RuleStmt *stmt) */ if (event_type == CMD_SELECT) { - TargetEntry *tle; - Resdom *resdom; - Form_pg_attribute attr; - char *attname; + TargetEntry *tle; + Resdom *resdom; + Form_pg_attribute attr; + char *attname; int i; - char expected_name[NAMEDATALEN + 5]; + char expected_name[NAMEDATALEN + 5]; /* * So there cannot be INSTEAD NOTHING, ... @@ -259,6 +259,7 @@ DefineQueryRewrite(RuleStmt *stmt) */ if (length(action) > 1) elog(ERROR, "multiple action rules on select currently not supported"); + /* * ... the one action must be a SELECT, ... */ @@ -269,8 +270,8 @@ DefineQueryRewrite(RuleStmt *stmt) elog(ERROR, "event qualifications not supported for rules on select"); /* - * ... the targetlist of the SELECT action must - * exactly match the event relation, ... + * ... the targetlist of the SELECT action must exactly match the + * event relation, ... */ event_relation = heap_openr(event_obj->relname); if (event_relation == NULL) @@ -279,8 +280,9 @@ DefineQueryRewrite(RuleStmt *stmt) if (event_relation->rd_att->natts != length(query->targetList)) elog(ERROR, "select rules target list must match event relations structure"); - for (i = 1; i <= event_relation->rd_att->natts; i++) { - tle = (TargetEntry *)nth(i - 1, query->targetList); + for (i = 1; i <= event_relation->rd_att->natts; i++) + { + tle = (TargetEntry *) nth(i - 1, query->targetList); resdom = tle->resdom; attr = event_relation->rd_att->attrs[i - 1]; attname = nameout(&(attr->attname)); @@ -289,19 +291,20 @@ DefineQueryRewrite(RuleStmt *stmt) elog(ERROR, "select rules target entry %d has different column name from %s", i, attname); if (attr->atttypid != resdom->restype) - elog(ERROR, "select rules target entry %d has different type from attribute %s", i, attname); + elog(ERROR, "select rules target entry %d has different type from attribute %s", i, attname); if (attr->atttypmod != resdom->restypmod) - elog(ERROR, "select rules target entry %d has different size from attribute %s", i, attname); + elog(ERROR, "select rules target entry %d has different size from attribute %s", i, attname); } /* - * ... there must not be another ON SELECT - * rule already ... + * ... there must not be another ON SELECT rule already ... */ - if (event_relation->rd_rules != NULL) { - for (i = 0; i < event_relation->rd_rules->numLocks; i++) { - RewriteRule *rule; + if (event_relation->rd_rules != NULL) + { + for (i = 0; i < event_relation->rd_rules->numLocks; i++) + { + RewriteRule *rule; rule = event_relation->rd_rules->rules[i]; if (rule->event == CMD_SELECT) @@ -333,9 +336,10 @@ DefineQueryRewrite(RuleStmt *stmt) * ... and finally the rule must be named _RETviewname. */ sprintf(expected_name, "_RET%s", event_obj->relname); - if (strcmp(expected_name, stmt->rulename) != 0) { + if (strcmp(expected_name, stmt->rulename) != 0) + { elog(ERROR, "view rule for %s must be named %s", - event_obj->relname, expected_name); + event_obj->relname, expected_name); } } diff --git a/src/backend/rewrite/rewriteHandler.c b/src/backend/rewrite/rewriteHandler.c index 7769d72299..ed02edddea 100644 --- a/src/backend/rewrite/rewriteHandler.c +++ b/src/backend/rewrite/rewriteHandler.c @@ -6,7 +6,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.44 1999/05/25 13:16:10 wieck Exp $ + * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.45 1999/05/25 16:10:50 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -147,26 +147,27 @@ rangeTableEntry_used(Node *node, int rt_index, int sublevels_up) if (node == NULL) return FALSE; - switch(nodeTag(node)) { + switch (nodeTag(node)) + { case T_TargetEntry: { - TargetEntry *tle = (TargetEntry *)node; + TargetEntry *tle = (TargetEntry *) node; return rangeTableEntry_used( - (Node *)(tle->expr), - rt_index, - sublevels_up); + (Node *) (tle->expr), + rt_index, + sublevels_up); } break; case T_Aggref: { - Aggref *aggref = (Aggref *)node; + Aggref *aggref = (Aggref *) node; return rangeTableEntry_used( - (Node *)(aggref->target), - rt_index, - sublevels_up); + (Node *) (aggref->target), + rt_index, + sublevels_up); } break; @@ -175,61 +176,61 @@ rangeTableEntry_used(Node *node, int rt_index, int sublevels_up) case T_Expr: { - Expr *exp = (Expr *)node; + Expr *exp = (Expr *) node; return rangeTableEntry_used( - (Node *)(exp->args), - rt_index, - sublevels_up); + (Node *) (exp->args), + rt_index, + sublevels_up); } break; case T_Iter: { - Iter *iter = (Iter *)node; + Iter *iter = (Iter *) node; return rangeTableEntry_used( - (Node *)(iter->iterexpr), - rt_index, - sublevels_up); + (Node *) (iter->iterexpr), + rt_index, + sublevels_up); } break; case T_ArrayRef: { - ArrayRef *ref = (ArrayRef *)node; + ArrayRef *ref = (ArrayRef *) node; if (rangeTableEntry_used( - (Node *)(ref->refupperindexpr), - rt_index, - sublevels_up)) + (Node *) (ref->refupperindexpr), + rt_index, + sublevels_up)) return TRUE; - + if (rangeTableEntry_used( - (Node *)(ref->reflowerindexpr), - rt_index, - sublevels_up)) + (Node *) (ref->reflowerindexpr), + rt_index, + sublevels_up)) return TRUE; - + if (rangeTableEntry_used( - (Node *)(ref->refexpr), - rt_index, - sublevels_up)) + (Node *) (ref->refexpr), + rt_index, + sublevels_up)) return TRUE; - + if (rangeTableEntry_used( - (Node *)(ref->refassgnexpr), - rt_index, - sublevels_up)) + (Node *) (ref->refassgnexpr), + rt_index, + sublevels_up)) return TRUE; - + return FALSE; } break; case T_Var: { - Var *var = (Var *)node; + Var *var = (Var *) node; if (var->varlevelsup == sublevels_up) return var->varno == rt_index; @@ -246,13 +247,14 @@ rangeTableEntry_used(Node *node, int rt_index, int sublevels_up) case T_List: { - List *l; + List *l; - foreach (l, (List *)node) { + foreach(l, (List *) node) + { if (rangeTableEntry_used( - (Node *)lfirst(l), - rt_index, - sublevels_up)) + (Node *) lfirst(l), + rt_index, + sublevels_up)) return TRUE; } return FALSE; @@ -261,18 +263,18 @@ rangeTableEntry_used(Node *node, int rt_index, int sublevels_up) case T_SubLink: { - SubLink *sub = (SubLink *)node; + SubLink *sub = (SubLink *) node; if (rangeTableEntry_used( - (Node *)(sub->lefthand), - rt_index, - sublevels_up)) + (Node *) (sub->lefthand), + rt_index, + sublevels_up)) return TRUE; if (rangeTableEntry_used( - (Node *)(sub->subselect), - rt_index, - sublevels_up + 1)) + (Node *) (sub->subselect), + rt_index, + sublevels_up + 1)) return TRUE; return FALSE; @@ -281,18 +283,18 @@ rangeTableEntry_used(Node *node, int rt_index, int sublevels_up) case T_CaseExpr: { - CaseExpr *exp = (CaseExpr *)node; + CaseExpr *exp = (CaseExpr *) node; if (rangeTableEntry_used( - (Node *)(exp->args), - rt_index, - sublevels_up)) + (Node *) (exp->args), + rt_index, + sublevels_up)) return TRUE; if (rangeTableEntry_used( - (Node *)(exp->defresult), - rt_index, - sublevels_up)) + (Node *) (exp->defresult), + rt_index, + sublevels_up)) return TRUE; return FALSE; @@ -301,18 +303,18 @@ rangeTableEntry_used(Node *node, int rt_index, int sublevels_up) case T_CaseWhen: { - CaseWhen *when = (CaseWhen *)node; + CaseWhen *when = (CaseWhen *) node; if (rangeTableEntry_used( - (Node *)(when->expr), - rt_index, - sublevels_up)) + (Node *) (when->expr), + rt_index, + sublevels_up)) return TRUE; if (rangeTableEntry_used( - (Node *)(when->result), - rt_index, - sublevels_up)) + (Node *) (when->result), + rt_index, + sublevels_up)) return TRUE; return FALSE; @@ -321,24 +323,24 @@ rangeTableEntry_used(Node *node, int rt_index, int sublevels_up) case T_Query: { - Query *qry = (Query *)node; + Query *qry = (Query *) node; if (rangeTableEntry_used( - (Node *)(qry->targetList), - rt_index, - sublevels_up)) + (Node *) (qry->targetList), + rt_index, + sublevels_up)) return TRUE; if (rangeTableEntry_used( - (Node *)(qry->qual), - rt_index, - sublevels_up)) + (Node *) (qry->qual), + rt_index, + sublevels_up)) return TRUE; if (rangeTableEntry_used( - (Node *)(qry->havingQual), - rt_index, - sublevels_up)) + (Node *) (qry->havingQual), + rt_index, + sublevels_up)) return TRUE; return FALSE; @@ -368,28 +370,29 @@ attribute_used(Node *node, int rt_index, int attno, int sublevels_up) if (node == NULL) return FALSE; - switch(nodeTag(node)) { + switch (nodeTag(node)) + { case T_TargetEntry: { - TargetEntry *tle = (TargetEntry *)node; + TargetEntry *tle = (TargetEntry *) node; return attribute_used( - (Node *)(tle->expr), - rt_index, - attno, - sublevels_up); + (Node *) (tle->expr), + rt_index, + attno, + sublevels_up); } break; case T_Aggref: { - Aggref *aggref = (Aggref *)node; + Aggref *aggref = (Aggref *) node; return attribute_used( - (Node *)(aggref->target), - rt_index, - attno, - sublevels_up); + (Node *) (aggref->target), + rt_index, + attno, + sublevels_up); } break; @@ -398,58 +401,58 @@ attribute_used(Node *node, int rt_index, int attno, int sublevels_up) case T_Expr: { - Expr *exp = (Expr *)node; + Expr *exp = (Expr *) node; return attribute_used( - (Node *)(exp->args), - rt_index, - attno, - sublevels_up); + (Node *) (exp->args), + rt_index, + attno, + sublevels_up); } break; case T_Iter: { - Iter *iter = (Iter *)node; + Iter *iter = (Iter *) node; return attribute_used( - (Node *)(iter->iterexpr), - rt_index, - attno, - sublevels_up); + (Node *) (iter->iterexpr), + rt_index, + attno, + sublevels_up); } break; case T_ArrayRef: { - ArrayRef *ref = (ArrayRef *)node; + ArrayRef *ref = (ArrayRef *) node; if (attribute_used( - (Node *)(ref->refupperindexpr), - rt_index, - attno, - sublevels_up)) + (Node *) (ref->refupperindexpr), + rt_index, + attno, + sublevels_up)) return TRUE; if (attribute_used( - (Node *)(ref->reflowerindexpr), - rt_index, - attno, - sublevels_up)) + (Node *) (ref->reflowerindexpr), + rt_index, + attno, + sublevels_up)) return TRUE; if (attribute_used( - (Node *)(ref->refexpr), - rt_index, - attno, - sublevels_up)) + (Node *) (ref->refexpr), + rt_index, + attno, + sublevels_up)) return TRUE; if (attribute_used( - (Node *)(ref->refassgnexpr), - rt_index, - attno, - sublevels_up)) + (Node *) (ref->refassgnexpr), + rt_index, + attno, + sublevels_up)) return TRUE; return FALSE; @@ -458,7 +461,7 @@ attribute_used(Node *node, int rt_index, int attno, int sublevels_up) case T_Var: { - Var *var = (Var *)node; + Var *var = (Var *) node; if (var->varlevelsup == sublevels_up) return var->varno == rt_index; @@ -475,14 +478,15 @@ attribute_used(Node *node, int rt_index, int attno, int sublevels_up) case T_List: { - List *l; + List *l; - foreach (l, (List *)node) { + foreach(l, (List *) node) + { if (attribute_used( - (Node *)lfirst(l), - rt_index, - attno, - sublevels_up)) + (Node *) lfirst(l), + rt_index, + attno, + sublevels_up)) return TRUE; } return FALSE; @@ -491,20 +495,20 @@ attribute_used(Node *node, int rt_index, int attno, int sublevels_up) case T_SubLink: { - SubLink *sub = (SubLink *)node; + SubLink *sub = (SubLink *) node; if (attribute_used( - (Node *)(sub->lefthand), - rt_index, - attno, - sublevels_up)) + (Node *) (sub->lefthand), + rt_index, + attno, + sublevels_up)) return TRUE; if (attribute_used( - (Node *)(sub->subselect), - rt_index, - attno, - sublevels_up + 1)) + (Node *) (sub->subselect), + rt_index, + attno, + sublevels_up + 1)) return TRUE; return FALSE; @@ -513,27 +517,27 @@ attribute_used(Node *node, int rt_index, int attno, int sublevels_up) case T_Query: { - Query *qry = (Query *)node; + Query *qry = (Query *) node; if (attribute_used( - (Node *)(qry->targetList), - rt_index, - attno, - sublevels_up)) + (Node *) (qry->targetList), + rt_index, + attno, + sublevels_up)) return TRUE; if (attribute_used( - (Node *)(qry->qual), - rt_index, - attno, - sublevels_up)) + (Node *) (qry->qual), + rt_index, + attno, + sublevels_up)) return TRUE; if (attribute_used( - (Node *)(qry->havingQual), - rt_index, - attno, - sublevels_up)) + (Node *) (qry->havingQual), + rt_index, + attno, + sublevels_up)) return TRUE; return FALSE; @@ -564,61 +568,62 @@ modifyAggrefUplevel(Node *node) if (node == NULL) return; - switch(nodeTag(node)) { + switch (nodeTag(node)) + { case T_TargetEntry: { - TargetEntry *tle = (TargetEntry *)node; + TargetEntry *tle = (TargetEntry *) node; modifyAggrefUplevel( - (Node *)(tle->expr)); + (Node *) (tle->expr)); } break; case T_Aggref: { - Aggref *aggref = (Aggref *)node; + Aggref *aggref = (Aggref *) node; modifyAggrefUplevel( - (Node *)(aggref->target)); + (Node *) (aggref->target)); } break; case T_Expr: { - Expr *exp = (Expr *)node; + Expr *exp = (Expr *) node; modifyAggrefUplevel( - (Node *)(exp->args)); + (Node *) (exp->args)); } break; case T_Iter: { - Iter *iter = (Iter *)node; + Iter *iter = (Iter *) node; modifyAggrefUplevel( - (Node *)(iter->iterexpr)); + (Node *) (iter->iterexpr)); } break; case T_ArrayRef: { - ArrayRef *ref = (ArrayRef *)node; + ArrayRef *ref = (ArrayRef *) node; modifyAggrefUplevel( - (Node *)(ref->refupperindexpr)); + (Node *) (ref->refupperindexpr)); modifyAggrefUplevel( - (Node *)(ref->reflowerindexpr)); + (Node *) (ref->reflowerindexpr)); modifyAggrefUplevel( - (Node *)(ref->refexpr)); + (Node *) (ref->refexpr)); modifyAggrefUplevel( - (Node *)(ref->refassgnexpr)); + (Node *) (ref->refassgnexpr)); } break; case T_Var: { - Var *var = (Var *)node; + Var *var = (Var *) node; var->varlevelsup++; } @@ -632,41 +637,41 @@ modifyAggrefUplevel(Node *node) case T_List: { - List *l; + List *l; - foreach (l, (List *)node) + foreach(l, (List *) node) modifyAggrefUplevel( - (Node *)lfirst(l)); + (Node *) lfirst(l)); } break; case T_SubLink: { - SubLink *sub = (SubLink *)node; + SubLink *sub = (SubLink *) node; modifyAggrefUplevel( - (Node *)(sub->lefthand)); + (Node *) (sub->lefthand)); modifyAggrefUplevel( - (Node *)(sub->oper)); + (Node *) (sub->oper)); modifyAggrefUplevel( - (Node *)(sub->subselect)); + (Node *) (sub->subselect)); } break; case T_Query: { - Query *qry = (Query *)node; + Query *qry = (Query *) node; modifyAggrefUplevel( - (Node *)(qry->targetList)); + (Node *) (qry->targetList)); modifyAggrefUplevel( - (Node *)(qry->qual)); + (Node *) (qry->qual)); modifyAggrefUplevel( - (Node *)(qry->havingQual)); + (Node *) (qry->havingQual)); } break; @@ -690,33 +695,34 @@ modifyAggrefUplevel(Node *node) static void modifyAggrefChangeVarnodes(Node **nodePtr, int rt_index, int new_index, int sublevels_up) { - Node *node = *nodePtr; + Node *node = *nodePtr; if (node == NULL) return; - switch(nodeTag(node)) { + switch (nodeTag(node)) + { case T_TargetEntry: { - TargetEntry *tle = (TargetEntry *)node; + TargetEntry *tle = (TargetEntry *) node; modifyAggrefChangeVarnodes( - (Node **)(&(tle->expr)), - rt_index, - new_index, - sublevels_up); + (Node **) (&(tle->expr)), + rt_index, + new_index, + sublevels_up); } break; case T_Aggref: { - Aggref *aggref = (Aggref *)node; + Aggref *aggref = (Aggref *) node; modifyAggrefChangeVarnodes( - (Node **)(&(aggref->target)), - rt_index, - new_index, - sublevels_up); + (Node **) (&(aggref->target)), + rt_index, + new_index, + sublevels_up); } break; @@ -725,67 +731,68 @@ modifyAggrefChangeVarnodes(Node **nodePtr, int rt_index, int new_index, int subl case T_Expr: { - Expr *exp = (Expr *)node; + Expr *exp = (Expr *) node; modifyAggrefChangeVarnodes( - (Node **)(&(exp->args)), - rt_index, - new_index, - sublevels_up); + (Node **) (&(exp->args)), + rt_index, + new_index, + sublevels_up); } break; case T_Iter: { - Iter *iter = (Iter *)node; + Iter *iter = (Iter *) node; modifyAggrefChangeVarnodes( - (Node **)(&(iter->iterexpr)), - rt_index, - new_index, - sublevels_up); + (Node **) (&(iter->iterexpr)), + rt_index, + new_index, + sublevels_up); } break; case T_ArrayRef: { - ArrayRef *ref = (ArrayRef *)node; + ArrayRef *ref = (ArrayRef *) node; modifyAggrefChangeVarnodes( - (Node **)(&(ref->refupperindexpr)), - rt_index, - new_index, - sublevels_up); + (Node **) (&(ref->refupperindexpr)), + rt_index, + new_index, + sublevels_up); modifyAggrefChangeVarnodes( - (Node **)(&(ref->reflowerindexpr)), - rt_index, - new_index, - sublevels_up); + (Node **) (&(ref->reflowerindexpr)), + rt_index, + new_index, + sublevels_up); modifyAggrefChangeVarnodes( - (Node **)(&(ref->refexpr)), - rt_index, - new_index, - sublevels_up); + (Node **) (&(ref->refexpr)), + rt_index, + new_index, + sublevels_up); modifyAggrefChangeVarnodes( - (Node **)(&(ref->refassgnexpr)), - rt_index, - new_index, - sublevels_up); + (Node **) (&(ref->refassgnexpr)), + rt_index, + new_index, + sublevels_up); } break; case T_Var: { - Var *var = (Var *)node; + Var *var = (Var *) node; if (var->varlevelsup == sublevels_up && - var->varno == rt_index) { + var->varno == rt_index) + { var = copyObject(var); var->varno = new_index; var->varnoold = new_index; var->varlevelsup = 0; - *nodePtr = (Node *)var; + *nodePtr = (Node *) var; } } break; @@ -798,62 +805,62 @@ modifyAggrefChangeVarnodes(Node **nodePtr, int rt_index, int new_index, int subl case T_List: { - List *l; + List *l; - foreach (l, (List *)node) + foreach(l, (List *) node) modifyAggrefChangeVarnodes( - (Node **)(&lfirst(l)), - rt_index, - new_index, - sublevels_up); + (Node **) (&lfirst(l)), + rt_index, + new_index, + sublevels_up); } break; case T_SubLink: { - SubLink *sub = (SubLink *)node; + SubLink *sub = (SubLink *) node; modifyAggrefChangeVarnodes( - (Node **)(&(sub->lefthand)), - rt_index, - new_index, - sublevels_up); + (Node **) (&(sub->lefthand)), + rt_index, + new_index, + sublevels_up); modifyAggrefChangeVarnodes( - (Node **)(&(sub->oper)), - rt_index, - new_index, - sublevels_up); + (Node **) (&(sub->oper)), + rt_index, + new_index, + sublevels_up); modifyAggrefChangeVarnodes( - (Node **)(&(sub->subselect)), - rt_index, - new_index, - sublevels_up + 1); + (Node **) (&(sub->subselect)), + rt_index, + new_index, + sublevels_up + 1); } break; case T_Query: { - Query *qry = (Query *)node; + Query *qry = (Query *) node; modifyAggrefChangeVarnodes( - (Node **)(&(qry->targetList)), - rt_index, - new_index, - sublevels_up); + (Node **) (&(qry->targetList)), + rt_index, + new_index, + sublevels_up); modifyAggrefChangeVarnodes( - (Node **)(&(qry->qual)), - rt_index, - new_index, - sublevels_up); + (Node **) (&(qry->qual)), + rt_index, + new_index, + sublevels_up); modifyAggrefChangeVarnodes( - (Node **)(&(qry->havingQual)), - rt_index, - new_index, - sublevels_up); + (Node **) (&(qry->havingQual)), + rt_index, + new_index, + sublevels_up); } break; @@ -874,24 +881,25 @@ modifyAggrefChangeVarnodes(Node **nodePtr, int rt_index, int new_index, int subl static void modifyAggrefDropQual(Node **nodePtr, Node *orignode, Expr *expr) { - Node *node = *nodePtr; + Node *node = *nodePtr; if (node == NULL) return; - switch(nodeTag(node)) { + switch (nodeTag(node)) + { case T_Var: break; case T_Aggref: { - Aggref *aggref = (Aggref *)node; - Aggref *oaggref = (Aggref *)orignode; + Aggref *aggref = (Aggref *) node; + Aggref *oaggref = (Aggref *) orignode; modifyAggrefDropQual( - (Node **)(&(aggref->target)), - (Node *)(oaggref->target), - expr); + (Node **) (&(aggref->target)), + (Node *) (oaggref->target), + expr); } break; @@ -906,79 +914,81 @@ modifyAggrefDropQual(Node **nodePtr, Node *orignode, Expr *expr) case T_Expr: { - Expr *this_expr = (Expr *)node; - Expr *orig_expr = (Expr *)orignode; + Expr *this_expr = (Expr *) node; + Expr *orig_expr = (Expr *) orignode; - if (orig_expr == expr) { - Const *ctrue; + if (orig_expr == expr) + { + Const *ctrue; if (expr->typeOid != BOOLOID) elog(ERROR, - "aggregate expression in qualification isn't of type bool"); + "aggregate expression in qualification isn't of type bool"); ctrue = makeNode(Const); ctrue->consttype = BOOLOID; ctrue->constlen = 1; ctrue->constisnull = FALSE; - ctrue->constvalue = (Datum)TRUE; + ctrue->constvalue = (Datum) TRUE; ctrue->constbyval = TRUE; - *nodePtr = (Node *)ctrue; + *nodePtr = (Node *) ctrue; } else modifyAggrefDropQual( - (Node **)(&(this_expr->args)), - (Node *)(orig_expr->args), - expr); + (Node **) (&(this_expr->args)), + (Node *) (orig_expr->args), + expr); } break; case T_Iter: { - Iter *iter = (Iter *)node; - Iter *oiter = (Iter *)orignode; + Iter *iter = (Iter *) node; + Iter *oiter = (Iter *) orignode; modifyAggrefDropQual( - (Node **)(&(iter->iterexpr)), - (Node *)(oiter->iterexpr), - expr); + (Node **) (&(iter->iterexpr)), + (Node *) (oiter->iterexpr), + expr); } break; case T_ArrayRef: { - ArrayRef *ref = (ArrayRef *)node; - ArrayRef *oref = (ArrayRef *)orignode; + ArrayRef *ref = (ArrayRef *) node; + ArrayRef *oref = (ArrayRef *) orignode; modifyAggrefDropQual( - (Node **)(&(ref->refupperindexpr)), - (Node *)(oref->refupperindexpr), - expr); + (Node **) (&(ref->refupperindexpr)), + (Node *) (oref->refupperindexpr), + expr); modifyAggrefDropQual( - (Node **)(&(ref->reflowerindexpr)), - (Node *)(oref->reflowerindexpr), - expr); + (Node **) (&(ref->reflowerindexpr)), + (Node *) (oref->reflowerindexpr), + expr); modifyAggrefDropQual( - (Node **)(&(ref->refexpr)), - (Node *)(oref->refexpr), - expr); + (Node **) (&(ref->refexpr)), + (Node *) (oref->refexpr), + expr); modifyAggrefDropQual( - (Node **)(&(ref->refassgnexpr)), - (Node *)(oref->refassgnexpr), - expr); + (Node **) (&(ref->refassgnexpr)), + (Node *) (oref->refassgnexpr), + expr); } break; case T_List: { - List *l; - List *ol = (List *)orignode; - int li = 0; + List *l; + List *ol = (List *) orignode; + int li = 0; - foreach (l, (List *)node) { + foreach(l, (List *) node) + { modifyAggrefDropQual( - (Node **)(&(lfirst(l))), - (Node *)nth(li, ol), - expr); + (Node **) (&(lfirst(l))), + (Node *) nth(li, ol), + expr); li++; } } @@ -986,30 +996,30 @@ modifyAggrefDropQual(Node **nodePtr, Node *orignode, Expr *expr) case T_SubLink: { - SubLink *sub = (SubLink *)node; - SubLink *osub = (SubLink *)orignode; + SubLink *sub = (SubLink *) node; + SubLink *osub = (SubLink *) orignode; modifyAggrefDropQual( - (Node **)(&(sub->subselect)), - (Node *)(osub->subselect), - expr); + (Node **) (&(sub->subselect)), + (Node *) (osub->subselect), + expr); } break; case T_Query: { - Query *qry = (Query *)node; - Query *oqry = (Query *)orignode; + Query *qry = (Query *) node; + Query *oqry = (Query *) orignode; modifyAggrefDropQual( - (Node **)(&(qry->qual)), - (Node *)(oqry->qual), - expr); + (Node **) (&(qry->qual)), + (Node *) (oqry->qual), + expr); modifyAggrefDropQual( - (Node **)(&(qry->havingQual)), - (Node *)(oqry->havingQual), - expr); + (Node **) (&(qry->havingQual)), + (Node *) (oqry->havingQual), + expr); } break; @@ -1031,15 +1041,15 @@ modifyAggrefDropQual(Node **nodePtr, Node *orignode, Expr *expr) static SubLink * modifyAggrefMakeSublink(Expr *origexp, Query *parsetree) { - SubLink *sublink; - Query *subquery; - Node *subqual; - RangeTblEntry *rte; - Aggref *aggref; - Var *target; - TargetEntry *tle; - Resdom *resdom; - Expr *exp = copyObject(origexp); + SubLink *sublink; + Query *subquery; + Node *subqual; + RangeTblEntry *rte; + Aggref *aggref; + Var *target; + TargetEntry *tle; + Resdom *resdom; + Expr *exp = copyObject(origexp); if (nodeTag(nth(0, exp->args)) == T_Aggref) { @@ -1049,66 +1059,66 @@ modifyAggrefMakeSublink(Expr *origexp, Query *parsetree) elog(ERROR, "rewrite: aggregate column of view must be at rigth side in qual"); } - aggref = (Aggref *)nth(1, exp->args); - target = (Var *)(aggref->target); - rte = (RangeTblEntry *)nth(target->varno - 1, parsetree->rtable); - tle = makeNode(TargetEntry); - resdom = makeNode(Resdom); + aggref = (Aggref *) nth(1, exp->args); + target = (Var *) (aggref->target); + rte = (RangeTblEntry *) nth(target->varno - 1, parsetree->rtable); + tle = makeNode(TargetEntry); + resdom = makeNode(Resdom); aggref->usenulls = TRUE; - resdom->resno = 1; - resdom->restype = ((Oper *)(exp->oper))->opresulttype; + resdom->resno = 1; + resdom->restype = ((Oper *) (exp->oper))->opresulttype; resdom->restypmod = -1; resdom->resname = pstrdup(""); - resdom->reskey = 0; + resdom->reskey = 0; resdom->reskeyop = 0; - resdom->resjunk = false; + resdom->resjunk = false; - tle->resdom = resdom; - tle->expr = (Node *)aggref; + tle->resdom = resdom; + tle->expr = (Node *) aggref; subqual = copyObject(parsetree->qual); - modifyAggrefDropQual((Node **)&subqual, (Node *)parsetree->qual, origexp); + modifyAggrefDropQual((Node **) &subqual, (Node *) parsetree->qual, origexp); sublink = makeNode(SubLink); - sublink->subLinkType = EXPR_SUBLINK; - sublink->useor = FALSE; - sublink->lefthand = lappend(NIL, copyObject(lfirst(exp->args))); - sublink->oper = lappend(NIL, copyObject(exp)); - sublink->subselect = NULL; + sublink->subLinkType = EXPR_SUBLINK; + sublink->useor = FALSE; + sublink->lefthand = lappend(NIL, copyObject(lfirst(exp->args))); + sublink->oper = lappend(NIL, copyObject(exp)); + sublink->subselect = NULL; - subquery = makeNode(Query); - sublink->subselect = (Node *)subquery; + subquery = makeNode(Query); + sublink->subselect = (Node *) subquery; - subquery->commandType = CMD_SELECT; - subquery->utilityStmt = NULL; - subquery->resultRelation = 0; - subquery->into = NULL; - subquery->isPortal = FALSE; - subquery->isBinary = FALSE; - subquery->isTemp = FALSE; - subquery->unionall = FALSE; - subquery->uniqueFlag = NULL; - subquery->sortClause = NULL; - subquery->rtable = lappend(NIL, rte); - subquery->targetList = lappend(NIL, tle); - subquery->qual = subqual; - subquery->groupClause = NIL; - subquery->havingQual = NULL; - subquery->hasAggs = TRUE; - subquery->hasSubLinks = FALSE; - subquery->unionClause = NULL; + subquery->commandType = CMD_SELECT; + subquery->utilityStmt = NULL; + subquery->resultRelation = 0; + subquery->into = NULL; + subquery->isPortal = FALSE; + subquery->isBinary = FALSE; + subquery->isTemp = FALSE; + subquery->unionall = FALSE; + subquery->uniqueFlag = NULL; + subquery->sortClause = NULL; + subquery->rtable = lappend(NIL, rte); + subquery->targetList = lappend(NIL, tle); + subquery->qual = subqual; + subquery->groupClause = NIL; + subquery->havingQual = NULL; + subquery->hasAggs = TRUE; + subquery->hasSubLinks = FALSE; + subquery->unionClause = NULL; - modifyAggrefUplevel((Node *)sublink); + modifyAggrefUplevel((Node *) sublink); - modifyAggrefChangeVarnodes((Node **)&(sublink->lefthand), target->varno, - 1, target->varlevelsup); - modifyAggrefChangeVarnodes((Node **)&(sublink->oper), target->varno, - 1, target->varlevelsup); - modifyAggrefChangeVarnodes((Node **)&(sublink->subselect), target->varno, - 1, target->varlevelsup); + modifyAggrefChangeVarnodes((Node **) &(sublink->lefthand), target->varno, + 1, target->varlevelsup); + modifyAggrefChangeVarnodes((Node **) &(sublink->oper), target->varno, + 1, target->varlevelsup); + modifyAggrefChangeVarnodes((Node **) &(sublink->subselect), target->varno, + 1, target->varlevelsup); return sublink; } @@ -1124,12 +1134,13 @@ modifyAggrefMakeSublink(Expr *origexp, Query *parsetree) static void modifyAggrefQual(Node **nodePtr, Query *parsetree) { - Node *node = *nodePtr; + Node *node = *nodePtr; if (node == NULL) return; - switch(nodeTag(node)) { + switch (nodeTag(node)) + { case T_Var: break; @@ -1144,122 +1155,127 @@ modifyAggrefQual(Node **nodePtr, Query *parsetree) case T_Expr: { - Expr *exp = (Expr *)node; - SubLink *sub; + Expr *exp = (Expr *) node; + SubLink *sub; - if (length(exp->args) != 2) { + if (length(exp->args) != 2) + { modifyAggrefQual( - (Node **)(&(exp->args)), - parsetree); + (Node **) (&(exp->args)), + parsetree); break; } if (nodeTag(nth(0, exp->args)) != T_Aggref && - nodeTag(nth(1, exp->args)) != T_Aggref) { + nodeTag(nth(1, exp->args)) != T_Aggref) + { modifyAggrefQual( - (Node **)(&(exp->args)), - parsetree); + (Node **) (&(exp->args)), + parsetree); break; } sub = modifyAggrefMakeSublink(exp, - parsetree); + parsetree); - *nodePtr = (Node *)sub; + *nodePtr = (Node *) sub; parsetree->hasSubLinks = TRUE; } break; case T_CaseExpr: { - /* We're calling recursively, - * and this routine knows how to handle lists - * so let it do the work to handle the WHEN clauses... */ + + /* + * We're calling recursively, and this routine knows how + * to handle lists so let it do the work to handle the + * WHEN clauses... + */ modifyAggrefQual( - (Node **)(&(((CaseExpr *)node)->args)), - parsetree); + (Node **) (&(((CaseExpr *) node)->args)), + parsetree); modifyAggrefQual( - (Node **)(&(((CaseExpr *)node)->defresult)), - parsetree); + (Node **) (&(((CaseExpr *) node)->defresult)), + parsetree); } break; case T_CaseWhen: { modifyAggrefQual( - (Node **)(&(((CaseWhen *)node)->expr)), - parsetree); + (Node **) (&(((CaseWhen *) node)->expr)), + parsetree); modifyAggrefQual( - (Node **)(&(((CaseWhen *)node)->result)), - parsetree); + (Node **) (&(((CaseWhen *) node)->result)), + parsetree); } break; case T_Iter: { - Iter *iter = (Iter *)node; + Iter *iter = (Iter *) node; modifyAggrefQual( - (Node **)(&(iter->iterexpr)), - parsetree); + (Node **) (&(iter->iterexpr)), + parsetree); } break; case T_ArrayRef: { - ArrayRef *ref = (ArrayRef *)node; + ArrayRef *ref = (ArrayRef *) node; modifyAggrefQual( - (Node **)(&(ref->refupperindexpr)), - parsetree); + (Node **) (&(ref->refupperindexpr)), + parsetree); modifyAggrefQual( - (Node **)(&(ref->reflowerindexpr)), - parsetree); + (Node **) (&(ref->reflowerindexpr)), + parsetree); modifyAggrefQual( - (Node **)(&(ref->refexpr)), - parsetree); + (Node **) (&(ref->refexpr)), + parsetree); modifyAggrefQual( - (Node **)(&(ref->refassgnexpr)), - parsetree); + (Node **) (&(ref->refassgnexpr)), + parsetree); } break; case T_List: { - List *l; + List *l; - foreach (l, (List *)node) + foreach(l, (List *) node) modifyAggrefQual( - (Node **)(&(lfirst(l))), - parsetree); + (Node **) (&(lfirst(l))), + parsetree); } break; case T_SubLink: { - SubLink *sub = (SubLink *)node; + SubLink *sub = (SubLink *) node; modifyAggrefQual( - (Node **)(&(sub->subselect)), - (Query *)(sub->subselect)); + (Node **) (&(sub->subselect)), + (Query *) (sub->subselect)); } break; case T_Query: { - Query *qry = (Query *)node; + Query *qry = (Query *) node; modifyAggrefQual( - (Node **)(&(qry->qual)), - parsetree); + (Node **) (&(qry->qual)), + parsetree); modifyAggrefQual( - (Node **)(&(qry->havingQual)), - parsetree); + (Node **) (&(qry->havingQual)), + parsetree); } break; @@ -1284,12 +1300,13 @@ checkQueryHasAggs(Node *node) if (node == NULL) return FALSE; - switch(nodeTag(node)) { + switch (nodeTag(node)) + { case T_TargetEntry: { - TargetEntry *tle = (TargetEntry *)node; + TargetEntry *tle = (TargetEntry *) node; - return checkQueryHasAggs((Node *)(tle->expr)); + return checkQueryHasAggs((Node *) (tle->expr)); } break; @@ -1298,36 +1315,36 @@ checkQueryHasAggs(Node *node) case T_Expr: { - Expr *exp = (Expr *)node; + Expr *exp = (Expr *) node; - return checkQueryHasAggs((Node *)(exp->args)); + return checkQueryHasAggs((Node *) (exp->args)); } break; case T_Iter: { - Iter *iter = (Iter *)node; + Iter *iter = (Iter *) node; - return checkQueryHasAggs((Node *)(iter->iterexpr)); + return checkQueryHasAggs((Node *) (iter->iterexpr)); } break; case T_ArrayRef: { - ArrayRef *ref = (ArrayRef *)node; + ArrayRef *ref = (ArrayRef *) node; - if (checkQueryHasAggs((Node *)(ref->refupperindexpr))) + if (checkQueryHasAggs((Node *) (ref->refupperindexpr))) return TRUE; - - if (checkQueryHasAggs((Node *)(ref->reflowerindexpr))) + + if (checkQueryHasAggs((Node *) (ref->reflowerindexpr))) return TRUE; - - if (checkQueryHasAggs((Node *)(ref->refexpr))) + + if (checkQueryHasAggs((Node *) (ref->refexpr))) return TRUE; - - if (checkQueryHasAggs((Node *)(ref->refassgnexpr))) + + if (checkQueryHasAggs((Node *) (ref->refassgnexpr))) return TRUE; - + return FALSE; } break; @@ -1343,10 +1360,11 @@ checkQueryHasAggs(Node *node) case T_List: { - List *l; + List *l; - foreach (l, (List *)node) { - if (checkQueryHasAggs((Node *)lfirst(l))) + foreach(l, (List *) node) + { + if (checkQueryHasAggs((Node *) lfirst(l))) return TRUE; } return FALSE; @@ -1355,12 +1373,12 @@ checkQueryHasAggs(Node *node) case T_CaseExpr: { - CaseExpr *exp = (CaseExpr *)node; + CaseExpr *exp = (CaseExpr *) node; - if (checkQueryHasAggs((Node *)(exp->args))) + if (checkQueryHasAggs((Node *) (exp->args))) return TRUE; - if (checkQueryHasAggs((Node *)(exp->defresult))) + if (checkQueryHasAggs((Node *) (exp->defresult))) return TRUE; return FALSE; @@ -1369,12 +1387,12 @@ checkQueryHasAggs(Node *node) case T_CaseWhen: { - CaseWhen *when = (CaseWhen *)node; + CaseWhen *when = (CaseWhen *) node; - if (checkQueryHasAggs((Node *)(when->expr))) + if (checkQueryHasAggs((Node *) (when->expr))) return TRUE; - if (checkQueryHasAggs((Node *)(when->result))) + if (checkQueryHasAggs((Node *) (when->result))) return TRUE; return FALSE; @@ -1404,12 +1422,13 @@ checkQueryHasSubLink(Node *node) if (node == NULL) return FALSE; - switch(nodeTag(node)) { + switch (nodeTag(node)) + { case T_TargetEntry: { - TargetEntry *tle = (TargetEntry *)node; + TargetEntry *tle = (TargetEntry *) node; - return checkQueryHasSubLink((Node *)(tle->expr)); + return checkQueryHasSubLink((Node *) (tle->expr)); } break; @@ -1418,36 +1437,36 @@ checkQueryHasSubLink(Node *node) case T_Expr: { - Expr *exp = (Expr *)node; + Expr *exp = (Expr *) node; - return checkQueryHasSubLink((Node *)(exp->args)); + return checkQueryHasSubLink((Node *) (exp->args)); } break; case T_Iter: { - Iter *iter = (Iter *)node; + Iter *iter = (Iter *) node; - return checkQueryHasSubLink((Node *)(iter->iterexpr)); + return checkQueryHasSubLink((Node *) (iter->iterexpr)); } break; case T_ArrayRef: { - ArrayRef *ref = (ArrayRef *)node; + ArrayRef *ref = (ArrayRef *) node; - if (checkQueryHasSubLink((Node *)(ref->refupperindexpr))) + if (checkQueryHasSubLink((Node *) (ref->refupperindexpr))) return TRUE; - - if (checkQueryHasSubLink((Node *)(ref->reflowerindexpr))) + + if (checkQueryHasSubLink((Node *) (ref->reflowerindexpr))) return TRUE; - - if (checkQueryHasSubLink((Node *)(ref->refexpr))) + + if (checkQueryHasSubLink((Node *) (ref->refexpr))) return TRUE; - - if (checkQueryHasSubLink((Node *)(ref->refassgnexpr))) + + if (checkQueryHasSubLink((Node *) (ref->refassgnexpr))) return TRUE; - + return FALSE; } break; @@ -1463,10 +1482,11 @@ checkQueryHasSubLink(Node *node) case T_List: { - List *l; + List *l; - foreach (l, (List *)node) { - if (checkQueryHasSubLink((Node *)lfirst(l))) + foreach(l, (List *) node) + { + if (checkQueryHasSubLink((Node *) lfirst(l))) return TRUE; } return FALSE; @@ -1475,12 +1495,12 @@ checkQueryHasSubLink(Node *node) case T_CaseExpr: { - CaseExpr *exp = (CaseExpr *)node; + CaseExpr *exp = (CaseExpr *) node; - if (checkQueryHasSubLink((Node *)(exp->args))) + if (checkQueryHasSubLink((Node *) (exp->args))) return TRUE; - if (checkQueryHasSubLink((Node *)(exp->defresult))) + if (checkQueryHasSubLink((Node *) (exp->defresult))) return TRUE; return FALSE; @@ -1489,12 +1509,12 @@ checkQueryHasSubLink(Node *node) case T_CaseWhen: { - CaseWhen *when = (CaseWhen *)node; + CaseWhen *when = (CaseWhen *) node; - if (checkQueryHasSubLink((Node *)(when->expr))) + if (checkQueryHasSubLink((Node *) (when->expr))) return TRUE; - if (checkQueryHasSubLink((Node *)(when->result))) + if (checkQueryHasSubLink((Node *) (when->result))) return TRUE; return FALSE; @@ -1548,30 +1568,31 @@ make_null(Oid type) } -static void +static void apply_RIR_adjust_sublevel(Node *node, int sublevels_up) { if (node == NULL) return; - switch(nodeTag(node)) { + switch (nodeTag(node)) + { case T_TargetEntry: { - TargetEntry *tle = (TargetEntry *)node; + TargetEntry *tle = (TargetEntry *) node; apply_RIR_adjust_sublevel( - (Node *)(tle->expr), - sublevels_up); + (Node *) (tle->expr), + sublevels_up); } break; case T_Aggref: { - Aggref *aggref = (Aggref *)node; + Aggref *aggref = (Aggref *) node; apply_RIR_adjust_sublevel( - (Node *)(aggref->target), - sublevels_up); + (Node *) (aggref->target), + sublevels_up); } break; @@ -1580,49 +1601,49 @@ apply_RIR_adjust_sublevel(Node *node, int sublevels_up) case T_Expr: { - Expr *exp = (Expr *)node; + Expr *exp = (Expr *) node; apply_RIR_adjust_sublevel( - (Node *)(exp->args), - sublevels_up); + (Node *) (exp->args), + sublevels_up); } break; case T_Iter: { - Iter *iter = (Iter *)node; + Iter *iter = (Iter *) node; apply_RIR_adjust_sublevel( - (Node *)(iter->iterexpr), - sublevels_up); + (Node *) (iter->iterexpr), + sublevels_up); } break; case T_ArrayRef: { - ArrayRef *ref = (ArrayRef *)node; + ArrayRef *ref = (ArrayRef *) node; apply_RIR_adjust_sublevel( - (Node *)(ref->refupperindexpr), - sublevels_up); + (Node *) (ref->refupperindexpr), + sublevels_up); apply_RIR_adjust_sublevel( - (Node *)(ref->reflowerindexpr), - sublevels_up); + (Node *) (ref->reflowerindexpr), + sublevels_up); apply_RIR_adjust_sublevel( - (Node *)(ref->refexpr), - sublevels_up); + (Node *) (ref->refexpr), + sublevels_up); apply_RIR_adjust_sublevel( - (Node *)(ref->refassgnexpr), - sublevels_up); + (Node *) (ref->refassgnexpr), + sublevels_up); } break; case T_Var: { - Var *var = (Var *)node; + Var *var = (Var *) node; var->varlevelsup = sublevels_up; } @@ -1636,41 +1657,42 @@ apply_RIR_adjust_sublevel(Node *node, int sublevels_up) case T_List: { - List *l; + List *l; - foreach (l, (List *)node) { + foreach(l, (List *) node) + { apply_RIR_adjust_sublevel( - (Node *)lfirst(l), - sublevels_up); + (Node *) lfirst(l), + sublevels_up); } } break; case T_CaseExpr: { - CaseExpr *exp = (CaseExpr *)node; + CaseExpr *exp = (CaseExpr *) node; apply_RIR_adjust_sublevel( - (Node *)(exp->args), - sublevels_up); + (Node *) (exp->args), + sublevels_up); apply_RIR_adjust_sublevel( - (Node *)(exp->defresult), - sublevels_up); + (Node *) (exp->defresult), + sublevels_up); } break; case T_CaseWhen: { - CaseWhen *exp = (CaseWhen *)node; + CaseWhen *exp = (CaseWhen *) node; apply_RIR_adjust_sublevel( - (Node *)(exp->expr), - sublevels_up); + (Node *) (exp->expr), + sublevels_up); apply_RIR_adjust_sublevel( - (Node *)(exp->result), - sublevels_up); + (Node *) (exp->result), + sublevels_up); } break; @@ -1687,37 +1709,38 @@ apply_RIR_adjust_sublevel(Node *node, int sublevels_up) static void apply_RIR_view(Node **nodePtr, int rt_index, RangeTblEntry *rte, List *tlist, int *modified, int sublevels_up) { - Node *node = *nodePtr; + Node *node = *nodePtr; if (node == NULL) return; - switch(nodeTag(node)) { + switch (nodeTag(node)) + { case T_TargetEntry: { - TargetEntry *tle = (TargetEntry *)node; + TargetEntry *tle = (TargetEntry *) node; apply_RIR_view( - (Node **)(&(tle->expr)), - rt_index, - rte, - tlist, - modified, - sublevels_up); + (Node **) (&(tle->expr)), + rt_index, + rte, + tlist, + modified, + sublevels_up); } break; case T_Aggref: { - Aggref *aggref = (Aggref *)node; + Aggref *aggref = (Aggref *) node; apply_RIR_view( - (Node **)(&(aggref->target)), - rt_index, - rte, - tlist, - modified, - sublevels_up); + (Node **) (&(aggref->target)), + rt_index, + rte, + tlist, + modified, + sublevels_up); } break; @@ -1726,83 +1749,85 @@ apply_RIR_view(Node **nodePtr, int rt_index, RangeTblEntry *rte, List *tlist, in case T_Expr: { - Expr *exp = (Expr *)node; + Expr *exp = (Expr *) node; apply_RIR_view( - (Node **)(&(exp->args)), - rt_index, - rte, - tlist, - modified, - sublevels_up); + (Node **) (&(exp->args)), + rt_index, + rte, + tlist, + modified, + sublevels_up); } break; case T_Iter: { - Iter *iter = (Iter *)node; + Iter *iter = (Iter *) node; apply_RIR_view( - (Node **)(&(iter->iterexpr)), - rt_index, - rte, - tlist, - modified, - sublevels_up); + (Node **) (&(iter->iterexpr)), + rt_index, + rte, + tlist, + modified, + sublevels_up); } break; case T_ArrayRef: { - ArrayRef *ref = (ArrayRef *)node; + ArrayRef *ref = (ArrayRef *) node; apply_RIR_view( - (Node **)(&(ref->refupperindexpr)), - rt_index, - rte, - tlist, - modified, - sublevels_up); + (Node **) (&(ref->refupperindexpr)), + rt_index, + rte, + tlist, + modified, + sublevels_up); apply_RIR_view( - (Node **)(&(ref->reflowerindexpr)), - rt_index, - rte, - tlist, - modified, - sublevels_up); + (Node **) (&(ref->reflowerindexpr)), + rt_index, + rte, + tlist, + modified, + sublevels_up); apply_RIR_view( - (Node **)(&(ref->refexpr)), - rt_index, - rte, - tlist, - modified, - sublevels_up); + (Node **) (&(ref->refexpr)), + rt_index, + rte, + tlist, + modified, + sublevels_up); apply_RIR_view( - (Node **)(&(ref->refassgnexpr)), - rt_index, - rte, - tlist, - modified, - sublevels_up); + (Node **) (&(ref->refassgnexpr)), + rt_index, + rte, + tlist, + modified, + sublevels_up); } break; case T_Var: { - Var *var = (Var *)node; + Var *var = (Var *) node; if (var->varlevelsup == sublevels_up && - var->varno == rt_index) { - Node *exp; + var->varno == rt_index) + { + Node *exp; if (var->varattno < 0) elog(ERROR, "system column %s not available - %s is a view", get_attname(rte->relid, var->varattno), rte->relname); exp = FindMatchingTLEntry( - tlist, - get_attname(rte->relid, - var->varattno)); + tlist, + get_attname(rte->relid, + var->varattno)); - if (exp == NULL) { + if (exp == NULL) + { *nodePtr = make_null(var->vartype); return; } @@ -1824,122 +1849,123 @@ apply_RIR_view(Node **nodePtr, int rt_index, RangeTblEntry *rte, List *tlist, in case T_List: { - List *l; + List *l; - foreach (l, (List *)node) + foreach(l, (List *) node) apply_RIR_view( - (Node **)(&(lfirst(l))), - rt_index, - rte, - tlist, - modified, - sublevels_up); + (Node **) (&(lfirst(l))), + rt_index, + rte, + tlist, + modified, + sublevels_up); } break; case T_SubLink: { - SubLink *sub = (SubLink *)node; - List *tmp_lefthand, *tmp_oper; + SubLink *sub = (SubLink *) node; + List *tmp_lefthand, + *tmp_oper; apply_RIR_view( - (Node **)(&(sub->lefthand)), - rt_index, - rte, - tlist, - modified, - sublevels_up); + (Node **) (&(sub->lefthand)), + rt_index, + rte, + tlist, + modified, + sublevels_up); apply_RIR_view( - (Node **)(&(sub->subselect)), - rt_index, - rte, - tlist, - modified, - sublevels_up + 1); + (Node **) (&(sub->subselect)), + rt_index, + rte, + tlist, + modified, + sublevels_up + 1); /***S*I***/ - tmp_lefthand = sub->lefthand; + tmp_lefthand = sub->lefthand; foreach(tmp_oper, sub->oper) - { - lfirst(((Expr *) lfirst(tmp_oper))->args) = - lfirst(tmp_lefthand); - tmp_lefthand = lnext(tmp_lefthand); - } + { + lfirst(((Expr *) lfirst(tmp_oper))->args) = + lfirst(tmp_lefthand); + tmp_lefthand = lnext(tmp_lefthand); + } } break; case T_Query: { - Query *qry = (Query *)node; + Query *qry = (Query *) node; apply_RIR_view( - (Node **)(&(qry->targetList)), - rt_index, - rte, - tlist, - modified, - sublevels_up); + (Node **) (&(qry->targetList)), + rt_index, + rte, + tlist, + modified, + sublevels_up); apply_RIR_view( - (Node **)(&(qry->qual)), - rt_index, - rte, - tlist, - modified, - sublevels_up); + (Node **) (&(qry->qual)), + rt_index, + rte, + tlist, + modified, + sublevels_up); apply_RIR_view( - (Node **)(&(qry->havingQual)), - rt_index, - rte, - tlist, - modified, - sublevels_up); + (Node **) (&(qry->havingQual)), + rt_index, + rte, + tlist, + modified, + sublevels_up); } break; case T_CaseExpr: { - CaseExpr *exp = (CaseExpr *)node; + CaseExpr *exp = (CaseExpr *) node; apply_RIR_view( - (Node **)(&(exp->args)), - rt_index, - rte, - tlist, - modified, - sublevels_up); + (Node **) (&(exp->args)), + rt_index, + rte, + tlist, + modified, + sublevels_up); apply_RIR_view( - (Node **)(&(exp->defresult)), - rt_index, - rte, - tlist, - modified, - sublevels_up); + (Node **) (&(exp->defresult)), + rt_index, + rte, + tlist, + modified, + sublevels_up); } break; case T_CaseWhen: { - CaseWhen *exp = (CaseWhen *)node; + CaseWhen *exp = (CaseWhen *) node; apply_RIR_view( - (Node **)(&(exp->expr)), - rt_index, - rte, - tlist, - modified, - sublevels_up); + (Node **) (&(exp->expr)), + rt_index, + rte, + tlist, + modified, + sublevels_up); apply_RIR_view( - (Node **)(&(exp->result)), - rt_index, - rte, - tlist, - modified, - sublevels_up); + (Node **) (&(exp->result)), + rt_index, + rte, + tlist, + modified, + sublevels_up); } break; @@ -1950,7 +1976,7 @@ apply_RIR_view(Node **nodePtr, int rt_index, RangeTblEntry *rte, List *tlist, in } } -extern void CheckSelectForUpdate(Query *rule_action); /* in analyze.c */ +extern void CheckSelectForUpdate(Query *rule_action); /* in analyze.c */ static void ApplyRetrieveRule(Query *parsetree, @@ -2000,32 +2026,34 @@ ApplyRetrieveRule(Query *parsetree, parsetree->rtable = rtable; /* FOR UPDATE of view... */ - foreach (l, parsetree->rowMark) + foreach(l, parsetree->rowMark) { - if (((RowMark*)lfirst(l))->rti == rt_index) + if (((RowMark *) lfirst(l))->rti == rt_index) break; } - if (l != NULL) /* oh, hell -:) */ + if (l != NULL) /* oh, hell -:) */ { - RowMark *newrm; + RowMark *newrm; Index rti = 1; List *l2; CheckSelectForUpdate(rule_action); - /* - * We believe that rt_index is VIEW - nothing should be - * marked for VIEW, but ACL check must be done. - * As for real tables of VIEW - their rows must be marked, but - * we have to skip ACL check for them. + + /* + * We believe that rt_index is VIEW - nothing should be marked for + * VIEW, but ACL check must be done. As for real tables of VIEW - + * their rows must be marked, but we have to skip ACL check for + * them. */ - ((RowMark*)lfirst(l))->info &= ~ROW_MARK_FOR_UPDATE; - foreach (l2, rule_action->rtable) + ((RowMark *) lfirst(l))->info &= ~ROW_MARK_FOR_UPDATE; + foreach(l2, rule_action->rtable) { + /* - * RTable of VIEW has two entries of VIEW itself - - * we use relid to skip them. + * RTable of VIEW has two entries of VIEW itself - we use + * relid to skip them. */ - if (relation->rd_id != ((RangeTblEntry*)lfirst(l2))->relid) + if (relation->rd_id != ((RangeTblEntry *) lfirst(l2))->relid) { newrm = makeNode(RowMark); newrm->rti = rti + rt_length; @@ -2038,36 +2066,37 @@ ApplyRetrieveRule(Query *parsetree, } rule_action->rtable = rtable; - OffsetVarNodes((Node *) rule_qual, rt_length, 0); + OffsetVarNodes((Node *) rule_qual, rt_length, 0); OffsetVarNodes((Node *) rule_action, rt_length, 0); - ChangeVarNodes((Node *) rule_qual, + ChangeVarNodes((Node *) rule_qual, PRS2_CURRENT_VARNO + rt_length, rt_index, 0); ChangeVarNodes((Node *) rule_action, PRS2_CURRENT_VARNO + rt_length, rt_index, 0); if (relation_level) { - apply_RIR_view((Node **) &parsetree, rt_index, - (RangeTblEntry *)nth(rt_index - 1, rtable), - rule_action->targetList, modified, 0); - apply_RIR_view((Node **) &rule_action, rt_index, - (RangeTblEntry *)nth(rt_index - 1, rtable), - rule_action->targetList, modified, 0); + apply_RIR_view((Node **) &parsetree, rt_index, + (RangeTblEntry *) nth(rt_index - 1, rtable), + rule_action->targetList, modified, 0); + apply_RIR_view((Node **) &rule_action, rt_index, + (RangeTblEntry *) nth(rt_index - 1, rtable), + rule_action->targetList, modified, 0); } else { - HandleRIRAttributeRule(parsetree, rtable, rule_action->targetList, - rt_index, rule->attrno, modified, &badsql); + HandleRIRAttributeRule(parsetree, rtable, rule_action->targetList, + rt_index, rule->attrno, modified, &badsql); + } + if (*modified && !badsql) + { + AddQual(parsetree, rule_action->qual); + AddGroupClause(parsetree, rule_action->groupClause, + rule_action->targetList); + AddHavingQual(parsetree, rule_action->havingQual); + parsetree->hasAggs = (rule_action->hasAggs || parsetree->hasAggs); + parsetree->hasSubLinks = (rule_action->hasSubLinks || parsetree->hasSubLinks); } - if (*modified && !badsql) { - AddQual(parsetree, rule_action->qual); - AddGroupClause(parsetree, rule_action->groupClause, - rule_action->targetList); - AddHavingQual(parsetree, rule_action->havingQual); - parsetree->hasAggs = (rule_action->hasAggs || parsetree->hasAggs); - parsetree->hasSubLinks = (rule_action->hasSubLinks || parsetree->hasSubLinks); - } } @@ -2077,22 +2106,23 @@ fireRIRonSubselect(Node *node) if (node == NULL) return; - switch(nodeTag(node)) { + switch (nodeTag(node)) + { case T_TargetEntry: { - TargetEntry *tle = (TargetEntry *)node; + TargetEntry *tle = (TargetEntry *) node; fireRIRonSubselect( - (Node *)(tle->expr)); + (Node *) (tle->expr)); } break; case T_Aggref: { - Aggref *aggref = (Aggref *)node; + Aggref *aggref = (Aggref *) node; fireRIRonSubselect( - (Node *)(aggref->target)); + (Node *) (aggref->target)); } break; @@ -2101,34 +2131,34 @@ fireRIRonSubselect(Node *node) case T_Expr: { - Expr *exp = (Expr *)node; + Expr *exp = (Expr *) node; fireRIRonSubselect( - (Node *)(exp->args)); + (Node *) (exp->args)); } break; case T_Iter: { - Iter *iter = (Iter *)node; + Iter *iter = (Iter *) node; fireRIRonSubselect( - (Node *)(iter->iterexpr)); + (Node *) (iter->iterexpr)); } break; case T_ArrayRef: { - ArrayRef *ref = (ArrayRef *)node; + ArrayRef *ref = (ArrayRef *) node; fireRIRonSubselect( - (Node *)(ref->refupperindexpr)); + (Node *) (ref->refupperindexpr)); fireRIRonSubselect( - (Node *)(ref->reflowerindexpr)); + (Node *) (ref->reflowerindexpr)); fireRIRonSubselect( - (Node *)(ref->refexpr)); + (Node *) (ref->refexpr)); fireRIRonSubselect( - (Node *)(ref->refassgnexpr)); + (Node *) (ref->refassgnexpr)); } break; @@ -2143,26 +2173,26 @@ fireRIRonSubselect(Node *node) case T_List: { - List *l; + List *l; - foreach (l, (List *)node) + foreach(l, (List *) node) fireRIRonSubselect( - (Node *)(lfirst(l))); + (Node *) (lfirst(l))); } break; case T_SubLink: { - SubLink *sub = (SubLink *)node; - Query *qry; + SubLink *sub = (SubLink *) node; + Query *qry; fireRIRonSubselect( - (Node *)(sub->lefthand)); + (Node *) (sub->lefthand)); - qry = fireRIRrules((Query *)(sub->subselect)); + qry = fireRIRrules((Query *) (sub->subselect)); fireRIRonSubselect( - (Node *)qry); + (Node *) qry); sub->subselect = (Node *) qry; } @@ -2170,40 +2200,40 @@ fireRIRonSubselect(Node *node) case T_CaseExpr: { - CaseExpr *exp = (CaseExpr *)node; + CaseExpr *exp = (CaseExpr *) node; fireRIRonSubselect( - (Node *)(exp->args)); + (Node *) (exp->args)); fireRIRonSubselect( - (Node *)(exp->defresult)); + (Node *) (exp->defresult)); } break; case T_CaseWhen: { - CaseWhen *exp = (CaseWhen *)node; + CaseWhen *exp = (CaseWhen *) node; fireRIRonSubselect( - (Node *)(exp->expr)); + (Node *) (exp->expr)); fireRIRonSubselect( - (Node *)(exp->result)); + (Node *) (exp->result)); } break; case T_Query: { - Query *qry = (Query *)node; + Query *qry = (Query *) node; fireRIRonSubselect( - (Node *)(qry->targetList)); + (Node *) (qry->targetList)); fireRIRonSubselect( - (Node *)(qry->qual)); + (Node *) (qry->qual)); fireRIRonSubselect( - (Node *)(qry->havingQual)); + (Node *) (qry->havingQual)); } break; @@ -2224,30 +2254,32 @@ fireRIRonSubselect(Node *node) static Query * fireRIRrules(Query *parsetree) { - int rt_index; - RangeTblEntry *rte; + int rt_index; + RangeTblEntry *rte; Relation rel; - List *locks; - RuleLock *rules; - RewriteRule *rule; - RewriteRule RIRonly; - int modified; - int i; - List *l; + List *locks; + RuleLock *rules; + RewriteRule *rule; + RewriteRule RIRonly; + int modified; + int i; + List *l; rt_index = 0; - while(rt_index < length(parsetree->rtable)) { + while (rt_index < length(parsetree->rtable)) + { ++rt_index; rte = nth(rt_index - 1, parsetree->rtable); - if (!rangeTableEntry_used((Node *)parsetree, rt_index, 0)) + if (!rangeTableEntry_used((Node *) parsetree, rt_index, 0)) { + /* * Unused range table entries must not be marked as coming - * from a clause. Otherwise the planner will generate - * joins over relations that in fact shouldn't be scanned - * at all and the result will contain duplicates + * from a clause. Otherwise the planner will generate joins + * over relations that in fact shouldn't be scanned at all and + * the result will contain duplicates * * Jan * @@ -2255,9 +2287,10 @@ fireRIRrules(Query *parsetree) rte->inFromCl = FALSE; continue; } - + rel = heap_openr(rte->relname); - if (rel->rd_rules == NULL) { + if (rel->rd_rules == NULL) + { heap_close(rel); continue; } @@ -2268,15 +2301,16 @@ fireRIRrules(Query *parsetree) /* * Collect the RIR rules that we must apply */ - for (i = 0; i < rules->numLocks; i++) { + for (i = 0; i < rules->numLocks; i++) + { rule = rules->rules[i]; if (rule->event != CMD_SELECT) continue; - + if (rule->attrno > 0 && - !attribute_used((Node *)parsetree, - rt_index, - rule->attrno, 0)) + !attribute_used((Node *) parsetree, + rt_index, + rule->attrno, 0)) continue; locks = lappend(locks, rule); @@ -2290,20 +2324,21 @@ fireRIRrules(Query *parsetree) /* * Now apply them */ - foreach (l, locks) { + foreach(l, locks) + { rule = lfirst(l); - RIRonly.event = rule->event; - RIRonly.attrno = rule->attrno; - RIRonly.qual = rule->qual; - RIRonly.actions = rule->actions; + RIRonly.event = rule->event; + RIRonly.attrno = rule->attrno; + RIRonly.qual = rule->qual; + RIRonly.actions = rule->actions; ApplyRetrieveRule(parsetree, - &RIRonly, - rt_index, - RIRonly.attrno == -1, - rel, - &modified); + &RIRonly, + rt_index, + RIRonly.attrno == -1, + rel, + &modified); } heap_close(rel); @@ -2408,9 +2443,7 @@ fireRules(Query *parsetree, /* choose rule to fire from list of rules */ if (locks == NIL) - { return NIL; - } locks = orderRules(locks); /* real instead rules last */ foreach(i, locks) @@ -2529,9 +2562,7 @@ fireRules(Query *parsetree, rule_action->hasSubLinks = TRUE; } if (!parsetree->hasSubLinks && rule_action->hasSubLinks) - { parsetree->hasSubLinks = TRUE; - } /*-------------------------------------------------- * Step 1: @@ -2581,10 +2612,11 @@ fireRules(Query *parsetree, *-------------------------------------------------- */ info->rule_action->rtable = info->rt; + /* - ProcessRetrieveQuery(info->rule_action, info->rt, - &orig_instead_flag, TRUE); - */ + * ProcessRetrieveQuery(info->rule_action, info->rt, + * &orig_instead_flag, TRUE); + */ /*-------------------------------------------------- * Step 4 @@ -2614,19 +2646,19 @@ static List * RewriteQuery(Query *parsetree, bool *instead_flag, List **qual_products) { CmdType event; - List *product_queries = NIL; - int result_relation = 0; - RangeTblEntry *rt_entry; + List *product_queries = NIL; + int result_relation = 0; + RangeTblEntry *rt_entry; Relation rt_entry_relation = NULL; - RuleLock *rt_entry_locks = NULL; + RuleLock *rt_entry_locks = NULL; Assert(parsetree != NULL); event = parsetree->commandType; /* - * SELECT rules are handled later when we have all the - * queries that should get executed + * SELECT rules are handled later when we have all the queries that + * should get executed */ if (event == CMD_SELECT) return NIL; @@ -2646,8 +2678,7 @@ RewriteQuery(Query *parsetree, bool *instead_flag, List **qual_products) result_relation = parsetree->resultRelation; /* - * the statement is an update, insert or delete - fire rules - * on it. + * the statement is an update, insert or delete - fire rules on it. */ rt_entry = rt_fetch(result_relation, parsetree->rtable); rt_entry_relation = heap_openr(rt_entry->relname); @@ -2659,11 +2690,11 @@ RewriteQuery(Query *parsetree, bool *instead_flag, List **qual_products) List *locks = matchLocks(event, rt_entry_locks, result_relation, parsetree); product_queries = fireRules(parsetree, - result_relation, - event, - instead_flag, - locks, - qual_products); + result_relation, + event, + instead_flag, + locks, + qual_products); } return product_queries; @@ -2805,16 +2836,16 @@ RewritePreprocessQuery(Query *parsetree) static List * BasicQueryRewrite(Query *parsetree) { - List *querylist; - List *results = NIL; - List *l; - Query *query; + List *querylist; + List *results = NIL; + List *l; + Query *query; /* * Step 1 * - * There still seems something broken with the resdom numbers - * so we reassign them first. + * There still seems something broken with the resdom numbers so we + * reassign them first. */ RewritePreprocessQuery(parsetree); @@ -2830,19 +2861,21 @@ BasicQueryRewrite(Query *parsetree) * * Apply all the RIR rules on each query */ - foreach (l, querylist) { - query = fireRIRrules((Query *)lfirst(l)); + foreach(l, querylist) + { + query = fireRIRrules((Query *) lfirst(l)); + /* - * If the query was marked having aggregates, check if - * this is still true after rewriting. This check must get - * expanded when someday aggregates can appear somewhere - * else than in the targetlist or the having qual. + * If the query was marked having aggregates, check if this is + * still true after rewriting. This check must get expanded when + * someday aggregates can appear somewhere else than in the + * targetlist or the having qual. */ if (query->hasAggs) - query->hasAggs = checkQueryHasAggs((Node *)(query->targetList)) - | checkQueryHasAggs((Node *)(query->havingQual)); - query->hasSubLinks = checkQueryHasSubLink((Node *)(query->qual)) - | checkQueryHasSubLink((Node *)(query->havingQual)); + query->hasAggs = checkQueryHasAggs((Node *) (query->targetList)) + | checkQueryHasAggs((Node *) (query->havingQual)); + query->hasSubLinks = checkQueryHasSubLink((Node *) (query->qual)) + | checkQueryHasSubLink((Node *) (query->havingQual)); results = lappend(results, query); } return results; @@ -2866,8 +2899,11 @@ QueryRewrite(Query *parsetree) *rewritten_item; /***S*I***/ - /* Rewrite Union, Intersect and Except Queries - * to normal Union Queries using IN and NOT IN subselects */ + + /* + * Rewrite Union, Intersect and Except Queries to normal Union Queries + * using IN and NOT IN subselects + */ if (parsetree->intersectClause) parsetree = Except_Intersect_Rewrite(parsetree); @@ -2877,16 +2913,16 @@ QueryRewrite(Query *parsetree) /* * Rewrite the UNIONS. */ - foreach (rewritten_item, rewritten) + foreach(rewritten_item, rewritten) { Query *qry = (Query *) lfirst(rewritten_item); List *union_result = NIL; List *union_item; - foreach (union_item, qry->unionClause) + foreach(union_item, qry->unionClause) { union_result = nconc(union_result, - BasicQueryRewrite((Query *) lfirst(union_item))); + BasicQueryRewrite((Query *) lfirst(union_item))); } qry->unionClause = union_result; } @@ -2898,79 +2934,82 @@ QueryRewrite(Query *parsetree) /* This function takes two targetlists as arguments and checks if the * targetlists are compatible (i.e. both select for the same number of * attributes and the types are compatible */ -void check_targetlists_are_compatible(List *prev_target, List *current_target) +void +check_targetlists_are_compatible(List *prev_target, List *current_target) { - List *tl, *next_target; - int prev_len = 0, next_len = 0; + List *tl, + *next_target; + int prev_len = 0, + next_len = 0; - foreach(tl, prev_target) - if (!((TargetEntry *) lfirst(tl))->resdom->resjunk) + foreach(tl, prev_target) + if (!((TargetEntry *) lfirst(tl))->resdom->resjunk) prev_len++; - foreach(next_target, current_target) - if (!((TargetEntry *) lfirst(next_target))->resdom->resjunk) + foreach(next_target, current_target) + if (!((TargetEntry *) lfirst(next_target))->resdom->resjunk) next_len++; - - if (prev_len != next_len) - elog(ERROR,"Each UNION | EXCEPT | INTERSECT query must have the same number of columns."); - foreach(next_target, current_target) - { - Oid itype; - Oid otype; - - otype = ((TargetEntry *) lfirst(prev_target))->resdom->restype; - itype = ((TargetEntry *) lfirst(next_target))->resdom->restype; - - /* one or both is a NULL column? then don't convert... */ - if (otype == InvalidOid) + if (prev_len != next_len) + elog(ERROR, "Each UNION | EXCEPT | INTERSECT query must have the same number of columns."); + + foreach(next_target, current_target) { - /* propagate a known type forward, if available */ - if (itype != InvalidOid) - ((TargetEntry *) lfirst(prev_target))->resdom->restype = itype; + Oid itype; + Oid otype; + + otype = ((TargetEntry *) lfirst(prev_target))->resdom->restype; + itype = ((TargetEntry *) lfirst(next_target))->resdom->restype; + + /* one or both is a NULL column? then don't convert... */ + if (otype == InvalidOid) + { + /* propagate a known type forward, if available */ + if (itype != InvalidOid) + ((TargetEntry *) lfirst(prev_target))->resdom->restype = itype; #ifdef NOT_USED - else - { - ((TargetEntry *) lfirst(prev_target))->resdom->restype = UNKNOWNOID; - ((TargetEntry *) lfirst(next_target))->resdom->restype = UNKNOWNOID; - } + else + { + ((TargetEntry *) lfirst(prev_target))->resdom->restype = UNKNOWNOID; + ((TargetEntry *) lfirst(next_target))->resdom->restype = UNKNOWNOID; + } #endif + } + else if (itype == InvalidOid) + { + } + /* they don't match in type? then convert... */ + else if (itype != otype) + { + Node *expr; + + expr = ((TargetEntry *) lfirst(next_target))->expr; + expr = CoerceTargetExpr(NULL, expr, itype, otype); + if (expr == NULL) + { + elog(ERROR, "Unable to transform %s to %s" + "\n\tEach UNION | EXCEPT | INTERSECT clause must have compatible target types", + typeidTypeName(itype), + typeidTypeName(otype)); + } + ((TargetEntry *) lfirst(next_target))->expr = expr; + ((TargetEntry *) lfirst(next_target))->resdom->restype = otype; + } + + /* both are UNKNOWN? then evaluate as text... */ + else if (itype == UNKNOWNOID) + { + ((TargetEntry *) lfirst(next_target))->resdom->restype = TEXTOID; + ((TargetEntry *) lfirst(prev_target))->resdom->restype = TEXTOID; + } + prev_target = lnext(prev_target); } - else if (itype == InvalidOid) - { - } - /* they don't match in type? then convert... */ - else if (itype != otype) - { - Node *expr; - - expr = ((TargetEntry *) lfirst(next_target))->expr; - expr = CoerceTargetExpr(NULL, expr, itype, otype); - if (expr == NULL) - { - elog(ERROR, "Unable to transform %s to %s" - "\n\tEach UNION | EXCEPT | INTERSECT clause must have compatible target types", - typeidTypeName(itype), - typeidTypeName(otype)); - } - ((TargetEntry *) lfirst(next_target))->expr = expr; - ((TargetEntry *) lfirst(next_target))->resdom->restype = otype; - } - - /* both are UNKNOWN? then evaluate as text... */ - else if (itype == UNKNOWNOID) - { - ((TargetEntry *) lfirst(next_target))->resdom->restype = TEXTOID; - ((TargetEntry *) lfirst(prev_target))->resdom->restype = TEXTOID; - } - prev_target = lnext(prev_target); - } } /***S*I***/ /* Rewrites UNION INTERSECT and EXCEPT queries to semantiacally equivalent - * queries that use IN and NOT IN subselects. - * + * queries that use IN and NOT IN subselects. + * * The operator tree is attached to 'intersectClause' (see rule * 'SelectStmt' in gram.y) of the 'parsetree' given as an * argument. First we remember some clauses (the sortClause, the @@ -2983,233 +3022,291 @@ void check_targetlists_are_compatible(List *prev_target, List *current_target) * union list and for every OR we create an IN subselect. (NOT IN * subselects are created for OR NOT nodes). The first entry of the * union list is handed back but before that the remembered clauses - * (sortClause etc) are attached to the new top Node (Note that the + * (sortClause etc) are attached to the new top Node (Note that the * new top Node can differ from the parsetree given as argument because of * the translation to DNF. That's why we have to remember the sortClause or * unique flag!) */ Query * -Except_Intersect_Rewrite (Query *parsetree) +Except_Intersect_Rewrite(Query *parsetree) { - - SubLink *n; - Query *result, *intersect_node; - List *elist, *intersect_list = NIL, *intersect, *intersectClause; - List *union_list = NIL, *sortClause; - List *left_expr, *right_expr, *resnames = NIL; - char *op, *uniqueFlag, *into; - bool isBinary, isPortal, isTemp; - CmdType commandType = CMD_SELECT; - List *rtable_insert = NIL; - List *prev_target = NIL; + SubLink *n; + Query *result, + *intersect_node; + List *elist, + *intersect_list = NIL, + *intersect, + *intersectClause; + List *union_list = NIL, + *sortClause; + List *left_expr, + *right_expr, + *resnames = NIL; + char *op, + *uniqueFlag, + *into; + bool isBinary, + isPortal, + isTemp; + CmdType commandType = CMD_SELECT; + List *rtable_insert = NIL; - /* Remember the Resnames of the given parsetree's targetlist - * (these are the resnames of the first Select Statement of - * the query formulated by the user and he wants the columns - * named by these strings. The transformation to DNF can - * cause another Select Statment to be the top one which - * uses other names for its columns. Therefore we remeber - * the original names and attach them to the targetlist - * of the new topmost Node at the end of this function */ - foreach(elist, parsetree->targetList) - { - TargetEntry *tent = (TargetEntry *)lfirst(elist); - - resnames = lappend(resnames, tent->resdom->resname); - } - - /* If the Statement is an INSERT INTO ... (SELECT...) statement - * using UNIONs, INTERSECTs or EXCEPTs and the transformation - * to DNF makes another Node to the top node we have to transform - * the new top node to an INSERT node and the original INSERT node - * to a SELECT node */ - if (parsetree->commandType == CMD_INSERT) - { - parsetree->commandType = CMD_SELECT; - commandType = CMD_INSERT; - parsetree->resultRelation = 0; - - /* The result relation ( = the one to insert into) has to be - * attached to the rtable list of the new top node */ - rtable_insert = nth(length(parsetree->rtable) - 1, parsetree->rtable); - } - - /* Save some items, to be able to attach them to the resulting top node - * at the end of the function */ - sortClause = parsetree->sortClause; - uniqueFlag = parsetree->uniqueFlag; - into = parsetree->into; - isBinary = parsetree->isBinary; - isPortal = parsetree->isPortal; - isTemp = parsetree->isTemp; + List *prev_target = NIL; - /* The operator tree attached to parsetree->intersectClause is still 'raw' - * ( = the leaf nodes are still SelectStmt nodes instead of Query nodes) - * So step through the tree and transform the nodes using parse_analyze(). - * - * The parsetree (given as an argument to - * Except_Intersect_Rewrite()) has already been transformed and - * transforming it again would cause troubles. So we give the 'raw' - * version (of the cooked parsetree) to the function to - * prevent an additional transformation. Instead we hand back the - * 'cooked' version also given as an argument to - * intersect_tree_analyze() */ - intersectClause = - (List *)intersect_tree_analyze((Node *)parsetree->intersectClause, - (Node *)lfirst(parsetree->unionClause), - (Node *)parsetree); - - /* intersectClause is no longer needed so set it to NIL */ - parsetree->intersectClause = NIL; - /* unionClause will be needed later on but the list it delivered - * is no longer needed, so set it to NIL */ - parsetree->unionClause = NIL; - - /* Transform the operator tree to DNF (remember ANDs and ORs have been exchanged, - * that's why we get DNF by using cnfify) - * - * After the call, explicit ANDs are removed and all AND operands - * are simply items in the intersectClause list */ - intersectClause = cnfify((Expr *)intersectClause, true); - - /* For every entry of the intersectClause list we generate one entry in - * the union_list */ - foreach(intersect, intersectClause) - { - /* for every OR we create an IN subselect and for every OR NOT - * we create a NOT IN subselect, so first extract all the Select - * Query nodes from the tree (that contains only OR or OR NOTs - * any more because we did a transformation to DNF - * - * There must be at least one node that is not negated - * (i.e. just OR and not OR NOT) and this node will be the first - * in the list returned */ - intersect_list = NIL; - create_list((Node *)lfirst(intersect), &intersect_list); - - /* This one will become the Select Query node, all other - * nodes are transformed into subselects under this node! */ - intersect_node = (Query *)lfirst(intersect_list); - intersect_list = lnext(intersect_list); - - /* Check if all Select Statements use the same number of attributes and - * if all corresponding attributes are of the same type */ - if (prev_target) - check_targetlists_are_compatible(prev_target, intersect_node->targetList); - prev_target = intersect_node->targetList; - /* End of check for corresponding targetlists */ - - /* Transform all nodes remaining into subselects and add them to - * the qualifications of the Select Query node */ - while(intersect_list != NIL) { - - n = makeNode(SubLink); - - /* Here we got an OR so transform it to an IN subselect */ - if(IsA(lfirst(intersect_list), Query)) - { - /* Check if all Select Statements use the same number of attributes and - * if all corresponding attributes are of the same type */ - check_targetlists_are_compatible(prev_target, - ((Query *)lfirst(intersect_list))->targetList); - /* End of check for corresponding targetlists */ - - n->subselect = lfirst(intersect_list); - op = "="; - n->subLinkType = ANY_SUBLINK; - n->useor = false; - } - /* Here we got an OR NOT node so transform it to a NOT IN subselect */ - else - { - /* Check if all Select Statements use the same number of attributes and - * if all corresponding attributes are of the same type */ - check_targetlists_are_compatible(prev_target, - ((Query *)lfirst(((Expr *)lfirst(intersect_list))->args))->targetList); - /* End of check for corresponding targetlists */ - - n->subselect = (Node *)lfirst(((Expr *)lfirst(intersect_list))->args); - op = "<>"; - n->subLinkType = ALL_SUBLINK; - n->useor = true; - } - - /* Prepare the lefthand side of the Sublinks: All the entries of the - * targetlist must be (IN) or must not be (NOT IN) the subselect */ - foreach(elist, intersect_node->targetList) - { - Node *expr = lfirst(elist); - TargetEntry *tent = (TargetEntry *)expr; - - n->lefthand = lappend(n->lefthand, tent->expr); - } - - /* The first arguments of oper also have to be created for the - * sublink (they are the same as the lefthand side!) */ - left_expr = n->lefthand; - right_expr = ((Query *)(n->subselect))->targetList; - - foreach(elist, left_expr) - { - Node *lexpr = lfirst(elist); - Node *rexpr = lfirst(right_expr); - TargetEntry *tent = (TargetEntry *) rexpr; - Expr *op_expr; - - op_expr = make_op(op, lexpr, tent->expr); - - n->oper = lappend(n->oper, op_expr); - right_expr = lnext(right_expr); - } - - /* If the Select Query node has aggregates in use - * add all the subselects to the HAVING qual else to - * the WHERE qual */ - if(intersect_node->hasAggs == false) { - AddQual(intersect_node, (Node *)n); + /* + * Remember the Resnames of the given parsetree's targetlist (these + * are the resnames of the first Select Statement of the query + * formulated by the user and he wants the columns named by these + * strings. The transformation to DNF can cause another Select + * Statment to be the top one which uses other names for its columns. + * Therefore we remeber the original names and attach them to the + * targetlist of the new topmost Node at the end of this function + */ + foreach(elist, parsetree->targetList) + { + TargetEntry *tent = (TargetEntry *) lfirst(elist); + + resnames = lappend(resnames, tent->resdom->resname); } - else { - AddHavingQual(intersect_node, (Node *)n); - } - - /* Now we got sublinks */ - intersect_node->hasSubLinks = true; - intersect_list = lnext(intersect_list); - } - intersect_node->intersectClause = NIL; - union_list = lappend(union_list, intersect_node); - } - - /* The first entry to union_list is our new top node */ - result = (Query *)lfirst(union_list); - /* attach the rest to unionClause */ - result->unionClause = lnext(union_list); - /* Attach all the items remembered in the beginning of the function */ - result->sortClause = sortClause; - result->uniqueFlag = uniqueFlag; - result->into = into; - result->isPortal = isPortal; - result->isBinary = isBinary; - result->isTemp = isTemp; - /* The relation to insert into is attached to the range table - * of the new top node */ - if (commandType == CMD_INSERT) - { - result->rtable = lappend(result->rtable, rtable_insert); - result->resultRelation = length(result->rtable); - result->commandType = commandType; - } - /* The resnames of the originally first SelectStatement are - * attached to the new first SelectStatement */ - foreach(elist, result->targetList) - { - TargetEntry *tent = (TargetEntry *)lfirst(elist); - - tent->resdom->resname = lfirst(resnames); - resnames = lnext(resnames); - } - return result; + /* + * If the Statement is an INSERT INTO ... (SELECT...) statement using + * UNIONs, INTERSECTs or EXCEPTs and the transformation to DNF makes + * another Node to the top node we have to transform the new top node + * to an INSERT node and the original INSERT node to a SELECT node + */ + if (parsetree->commandType == CMD_INSERT) + { + parsetree->commandType = CMD_SELECT; + commandType = CMD_INSERT; + parsetree->resultRelation = 0; + + /* + * The result relation ( = the one to insert into) has to be + * attached to the rtable list of the new top node + */ + rtable_insert = nth(length(parsetree->rtable) - 1, parsetree->rtable); + } + + /* + * Save some items, to be able to attach them to the resulting top + * node at the end of the function + */ + sortClause = parsetree->sortClause; + uniqueFlag = parsetree->uniqueFlag; + into = parsetree->into; + isBinary = parsetree->isBinary; + isPortal = parsetree->isPortal; + isTemp = parsetree->isTemp; + + /* + * The operator tree attached to parsetree->intersectClause is still + * 'raw' ( = the leaf nodes are still SelectStmt nodes instead of + * Query nodes) So step through the tree and transform the nodes using + * parse_analyze(). + * + * The parsetree (given as an argument to Except_Intersect_Rewrite()) has + * already been transformed and transforming it again would cause + * troubles. So we give the 'raw' version (of the cooked parsetree) + * to the function to prevent an additional transformation. Instead we + * hand back the 'cooked' version also given as an argument to + * intersect_tree_analyze() + */ + intersectClause = + (List *) intersect_tree_analyze((Node *) parsetree->intersectClause, + (Node *) lfirst(parsetree->unionClause), + (Node *) parsetree); + + /* intersectClause is no longer needed so set it to NIL */ + parsetree->intersectClause = NIL; + + /* + * unionClause will be needed later on but the list it delivered is no + * longer needed, so set it to NIL + */ + parsetree->unionClause = NIL; + + /* + * Transform the operator tree to DNF (remember ANDs and ORs have been + * exchanged, that's why we get DNF by using cnfify) + * + * After the call, explicit ANDs are removed and all AND operands are + * simply items in the intersectClause list + */ + intersectClause = cnfify((Expr *) intersectClause, true); + + /* + * For every entry of the intersectClause list we generate one entry + * in the union_list + */ + foreach(intersect, intersectClause) + { + + /* + * for every OR we create an IN subselect and for every OR NOT we + * create a NOT IN subselect, so first extract all the Select + * Query nodes from the tree (that contains only OR or OR NOTs any + * more because we did a transformation to DNF + * + * There must be at least one node that is not negated (i.e. just OR + * and not OR NOT) and this node will be the first in the list + * returned + */ + intersect_list = NIL; + create_list((Node *) lfirst(intersect), &intersect_list); + + /* + * This one will become the Select Query node, all other nodes are + * transformed into subselects under this node! + */ + intersect_node = (Query *) lfirst(intersect_list); + intersect_list = lnext(intersect_list); + + /* + * Check if all Select Statements use the same number of + * attributes and if all corresponding attributes are of the same + * type + */ + if (prev_target) + check_targetlists_are_compatible(prev_target, intersect_node->targetList); + prev_target = intersect_node->targetList; + /* End of check for corresponding targetlists */ + + /* + * Transform all nodes remaining into subselects and add them to + * the qualifications of the Select Query node + */ + while (intersect_list != NIL) + { + + n = makeNode(SubLink); + + /* Here we got an OR so transform it to an IN subselect */ + if (IsA(lfirst(intersect_list), Query)) + { + + /* + * Check if all Select Statements use the same number of + * attributes and if all corresponding attributes are of + * the same type + */ + check_targetlists_are_compatible(prev_target, + ((Query *) lfirst(intersect_list))->targetList); + /* End of check for corresponding targetlists */ + + n->subselect = lfirst(intersect_list); + op = "="; + n->subLinkType = ANY_SUBLINK; + n->useor = false; + } + + /* + * Here we got an OR NOT node so transform it to a NOT IN + * subselect + */ + else + { + + /* + * Check if all Select Statements use the same number of + * attributes and if all corresponding attributes are of + * the same type + */ + check_targetlists_are_compatible(prev_target, + ((Query *) lfirst(((Expr *) lfirst(intersect_list))->args))->targetList); + /* End of check for corresponding targetlists */ + + n->subselect = (Node *) lfirst(((Expr *) lfirst(intersect_list))->args); + op = "<>"; + n->subLinkType = ALL_SUBLINK; + n->useor = true; + } + + /* + * Prepare the lefthand side of the Sublinks: All the entries + * of the targetlist must be (IN) or must not be (NOT IN) the + * subselect + */ + foreach(elist, intersect_node->targetList) + { + Node *expr = lfirst(elist); + TargetEntry *tent = (TargetEntry *) expr; + + n->lefthand = lappend(n->lefthand, tent->expr); + } + + /* + * The first arguments of oper also have to be created for the + * sublink (they are the same as the lefthand side!) + */ + left_expr = n->lefthand; + right_expr = ((Query *) (n->subselect))->targetList; + + foreach(elist, left_expr) + { + Node *lexpr = lfirst(elist); + Node *rexpr = lfirst(right_expr); + TargetEntry *tent = (TargetEntry *) rexpr; + Expr *op_expr; + + op_expr = make_op(op, lexpr, tent->expr); + + n->oper = lappend(n->oper, op_expr); + right_expr = lnext(right_expr); + } + + /* + * If the Select Query node has aggregates in use add all the + * subselects to the HAVING qual else to the WHERE qual + */ + if (intersect_node->hasAggs == false) + AddQual(intersect_node, (Node *) n); + else + AddHavingQual(intersect_node, (Node *) n); + + /* Now we got sublinks */ + intersect_node->hasSubLinks = true; + intersect_list = lnext(intersect_list); + } + intersect_node->intersectClause = NIL; + union_list = lappend(union_list, intersect_node); + } + + /* The first entry to union_list is our new top node */ + result = (Query *) lfirst(union_list); + /* attach the rest to unionClause */ + result->unionClause = lnext(union_list); + /* Attach all the items remembered in the beginning of the function */ + result->sortClause = sortClause; + result->uniqueFlag = uniqueFlag; + result->into = into; + result->isPortal = isPortal; + result->isBinary = isBinary; + result->isTemp = isTemp; + + /* + * The relation to insert into is attached to the range table of the + * new top node + */ + if (commandType == CMD_INSERT) + { + result->rtable = lappend(result->rtable, rtable_insert); + result->resultRelation = length(result->rtable); + result->commandType = commandType; + } + + /* + * The resnames of the originally first SelectStatement are attached + * to the new first SelectStatement + */ + foreach(elist, result->targetList) + { + TargetEntry *tent = (TargetEntry *) lfirst(elist); + + tent->resdom->resname = lfirst(resnames); + resnames = lnext(resnames); + } + return result; } /* Create a list of nodes that are either Query nodes of NOT Expr @@ -3217,74 +3314,70 @@ Except_Intersect_Rewrite (Query *parsetree) * least one non negated Query node. This node is attached to the * beginning of the list */ -void create_list(Node *ptr, List **intersect_list) +void +create_list(Node *ptr, List **intersect_list) { - List *arg; - - if(IsA(ptr,Query)) - { - /* The non negated node is attached at the beginning (lcons) */ - *intersect_list = lcons(ptr, *intersect_list); - return; - } - - if(IsA(ptr,Expr)) - { - if(((Expr *)ptr)->opType == NOT_EXPR) + List *arg; + + if (IsA(ptr, Query)) { - /* negated nodes are appended to the end (lappend) */ - *intersect_list = lappend(*intersect_list, ptr); - return; + /* The non negated node is attached at the beginning (lcons) */ + *intersect_list = lcons(ptr, *intersect_list); + return; } - else + + if (IsA(ptr, Expr)) { - foreach(arg, ((Expr *)ptr)->args) - { - create_list(lfirst(arg), intersect_list); - } - return; + if (((Expr *) ptr)->opType == NOT_EXPR) + { + /* negated nodes are appended to the end (lappend) */ + *intersect_list = lappend(*intersect_list, ptr); + return; + } + else + { + foreach(arg, ((Expr *) ptr)->args) + create_list(lfirst(arg), intersect_list); + return; + } + return; } - return; - } } /* The nodes given in 'tree' are still 'raw' so 'cook' them using parse_analyze(). * The node given in first_select has already been cooked, so don't transform - * it again but return a pointer to the previously cooked version given in 'parsetree' + * it again but return a pointer to the previously cooked version given in 'parsetree' * instead. */ -Node *intersect_tree_analyze(Node *tree, Node *first_select, Node *parsetree) +Node * +intersect_tree_analyze(Node *tree, Node *first_select, Node *parsetree) { - Node *result = (Node *) NIL; - List *arg; + Node *result = (Node *) NIL; + List *arg; if (IsA(tree, SelectStmt)) - { - /* If we get to the tree given in first_select return - * parsetree instead of performing parse_analyze() */ + { + + /* + * If we get to the tree given in first_select return parsetree + * instead of performing parse_analyze() + */ if (tree == first_select) - { result = parsetree; - } else - { - /* transform the 'raw' nodes to 'cooked' Query nodes */ - List *qtree = parse_analyze(lcons(tree, NIL), NULL); + { + /* transform the 'raw' nodes to 'cooked' Query nodes */ + List *qtree = parse_analyze(lcons(tree, NIL), NULL); + result = (Node *) lfirst(qtree); } - } - - if(IsA(tree,Expr)) - { - /* Call recursively for every argument of the node */ - foreach(arg, ((Expr *)tree)->args) - { - lfirst(arg) = intersect_tree_analyze(lfirst(arg), first_select, parsetree); } - result = tree; - } - return result; + + if (IsA(tree, Expr)) + { + /* Call recursively for every argument of the node */ + foreach(arg, ((Expr *) tree)->args) + lfirst(arg) = intersect_tree_analyze(lfirst(arg), first_select, parsetree); + result = tree; + } + return result; } - - - - diff --git a/src/backend/rewrite/rewriteManip.c b/src/backend/rewrite/rewriteManip.c index 057579669d..7be8d080ec 100644 --- a/src/backend/rewrite/rewriteManip.c +++ b/src/backend/rewrite/rewriteManip.c @@ -6,7 +6,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteManip.c,v 1.30 1999/05/12 15:01:55 wieck Exp $ + * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteManip.c,v 1.31 1999/05/25 16:10:52 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -41,26 +41,27 @@ OffsetVarNodes(Node *node, int offset, int sublevels_up) if (node == NULL) return; - switch(nodeTag(node)) { + switch (nodeTag(node)) + { case T_TargetEntry: { - TargetEntry *tle = (TargetEntry *)node; + TargetEntry *tle = (TargetEntry *) node; OffsetVarNodes( - (Node *)(tle->expr), - offset, - sublevels_up); + (Node *) (tle->expr), + offset, + sublevels_up); } break; case T_Aggref: { - Aggref *aggref = (Aggref *)node; + Aggref *aggref = (Aggref *) node; OffsetVarNodes( - (Node *)(aggref->target), - offset, - sublevels_up); + (Node *) (aggref->target), + offset, + sublevels_up); } break; @@ -69,54 +70,55 @@ OffsetVarNodes(Node *node, int offset, int sublevels_up) case T_Expr: { - Expr *exp = (Expr *)node; + Expr *exp = (Expr *) node; OffsetVarNodes( - (Node *)(exp->args), - offset, - sublevels_up); + (Node *) (exp->args), + offset, + sublevels_up); } break; case T_Iter: { - Iter *iter = (Iter *)node; + Iter *iter = (Iter *) node; OffsetVarNodes( - (Node *)(iter->iterexpr), - offset, - sublevels_up); + (Node *) (iter->iterexpr), + offset, + sublevels_up); } break; case T_ArrayRef: { - ArrayRef *ref = (ArrayRef *)node; + ArrayRef *ref = (ArrayRef *) node; OffsetVarNodes( - (Node *)(ref->refupperindexpr), - offset, - sublevels_up); + (Node *) (ref->refupperindexpr), + offset, + sublevels_up); OffsetVarNodes( - (Node *)(ref->reflowerindexpr), - offset, - sublevels_up); + (Node *) (ref->reflowerindexpr), + offset, + sublevels_up); OffsetVarNodes( - (Node *)(ref->refexpr), - offset, - sublevels_up); + (Node *) (ref->refexpr), + offset, + sublevels_up); OffsetVarNodes( - (Node *)(ref->refassgnexpr), - offset, - sublevels_up); + (Node *) (ref->refassgnexpr), + offset, + sublevels_up); } break; case T_Var: { - Var *var = (Var *)node; + Var *var = (Var *) node; - if (var->varlevelsup == sublevels_up) { + if (var->varlevelsup == sublevels_up) + { var->varno += offset; var->varnoold += offset; } @@ -131,98 +133,104 @@ OffsetVarNodes(Node *node, int offset, int sublevels_up) case T_List: { - List *l; + List *l; - foreach (l, (List *)node) + foreach(l, (List *) node) OffsetVarNodes( - (Node *)lfirst(l), - offset, - sublevels_up); + (Node *) lfirst(l), + offset, + sublevels_up); } break; case T_SubLink: { - SubLink *sub = (SubLink *)node; - List *tmp_oper, *tmp_lefthand; + SubLink *sub = (SubLink *) node; + List *tmp_oper, + *tmp_lefthand; - /* We also have to adapt the variables used in sub->lefthand - * and sub->oper */ + /* + * We also have to adapt the variables used in + * sub->lefthand and sub->oper + */ OffsetVarNodes( - (Node *)(sub->lefthand), - offset, - sublevels_up); + (Node *) (sub->lefthand), + offset, + sublevels_up); OffsetVarNodes( - (Node *)(sub->subselect), - offset, - sublevels_up + 1); + (Node *) (sub->subselect), + offset, + sublevels_up + 1); /***S*I***/ - /* Make sure the first argument of sub->oper points to the - * same var as sub->lefthand does otherwise we will - * run into troubles using aggregates (aggno will not be - * set correctly) */ - tmp_lefthand = sub->lefthand; + + /* + * Make sure the first argument of sub->oper points to the + * same var as sub->lefthand does otherwise we will run + * into troubles using aggregates (aggno will not be set + * correctly) + */ + tmp_lefthand = sub->lefthand; foreach(tmp_oper, sub->oper) - { - lfirst(((Expr *) lfirst(tmp_oper))->args) = - lfirst(tmp_lefthand); - tmp_lefthand = lnext(tmp_lefthand); - } + { + lfirst(((Expr *) lfirst(tmp_oper))->args) = + lfirst(tmp_lefthand); + tmp_lefthand = lnext(tmp_lefthand); + } } break; case T_Query: { - Query *qry = (Query *)node; + Query *qry = (Query *) node; OffsetVarNodes( - (Node *)(qry->targetList), - offset, - sublevels_up); + (Node *) (qry->targetList), + offset, + sublevels_up); OffsetVarNodes( - (Node *)(qry->qual), - offset, - sublevels_up); + (Node *) (qry->qual), + offset, + sublevels_up); OffsetVarNodes( - (Node *)(qry->havingQual), - offset, - sublevels_up); + (Node *) (qry->havingQual), + offset, + sublevels_up); } break; case T_CaseExpr: { - CaseExpr *exp = (CaseExpr *)node; + CaseExpr *exp = (CaseExpr *) node; OffsetVarNodes( - (Node *)(exp->args), - offset, - sublevels_up); + (Node *) (exp->args), + offset, + sublevels_up); OffsetVarNodes( - (Node *)(exp->defresult), - offset, - sublevels_up); + (Node *) (exp->defresult), + offset, + sublevels_up); } break; case T_CaseWhen: { - CaseWhen *exp = (CaseWhen *)node; + CaseWhen *exp = (CaseWhen *) node; OffsetVarNodes( - (Node *)(exp->expr), - offset, - sublevels_up); + (Node *) (exp->expr), + offset, + sublevels_up); OffsetVarNodes( - (Node *)(exp->result), - offset, - sublevels_up); + (Node *) (exp->result), + offset, + sublevels_up); } break; @@ -245,28 +253,29 @@ ChangeVarNodes(Node *node, int rt_index, int new_index, int sublevels_up) if (node == NULL) return; - switch(nodeTag(node)) { + switch (nodeTag(node)) + { case T_TargetEntry: { - TargetEntry *tle = (TargetEntry *)node; + TargetEntry *tle = (TargetEntry *) node; ChangeVarNodes( - (Node *)(tle->expr), - rt_index, - new_index, - sublevels_up); + (Node *) (tle->expr), + rt_index, + new_index, + sublevels_up); } break; case T_Aggref: { - Aggref *aggref = (Aggref *)node; + Aggref *aggref = (Aggref *) node; ChangeVarNodes( - (Node *)(aggref->target), - rt_index, - new_index, - sublevels_up); + (Node *) (aggref->target), + rt_index, + new_index, + sublevels_up); } break; @@ -275,61 +284,62 @@ ChangeVarNodes(Node *node, int rt_index, int new_index, int sublevels_up) case T_Expr: { - Expr *exp = (Expr *)node; + Expr *exp = (Expr *) node; ChangeVarNodes( - (Node *)(exp->args), - rt_index, - new_index, - sublevels_up); + (Node *) (exp->args), + rt_index, + new_index, + sublevels_up); } break; case T_Iter: { - Iter *iter = (Iter *)node; + Iter *iter = (Iter *) node; ChangeVarNodes( - (Node *)(iter->iterexpr), - rt_index, - new_index, - sublevels_up); + (Node *) (iter->iterexpr), + rt_index, + new_index, + sublevels_up); } break; case T_ArrayRef: { - ArrayRef *ref = (ArrayRef *)node; + ArrayRef *ref = (ArrayRef *) node; ChangeVarNodes( - (Node *)(ref->refupperindexpr), - rt_index, - new_index, - sublevels_up); + (Node *) (ref->refupperindexpr), + rt_index, + new_index, + sublevels_up); ChangeVarNodes( - (Node *)(ref->reflowerindexpr), - rt_index, - new_index, - sublevels_up); + (Node *) (ref->reflowerindexpr), + rt_index, + new_index, + sublevels_up); ChangeVarNodes( - (Node *)(ref->refexpr), - rt_index, - new_index, - sublevels_up); + (Node *) (ref->refexpr), + rt_index, + new_index, + sublevels_up); ChangeVarNodes( - (Node *)(ref->refassgnexpr), - rt_index, - new_index, - sublevels_up); + (Node *) (ref->refassgnexpr), + rt_index, + new_index, + sublevels_up); } break; case T_Var: { - Var *var = (Var *)node; + Var *var = (Var *) node; if (var->varlevelsup == sublevels_up && - var->varno == rt_index) { + var->varno == rt_index) + { var->varno = new_index; var->varnoold = new_index; } @@ -344,106 +354,110 @@ ChangeVarNodes(Node *node, int rt_index, int new_index, int sublevels_up) case T_List: { - List *l; + List *l; - foreach (l, (List *)node) + foreach(l, (List *) node) ChangeVarNodes( - (Node *)lfirst(l), - rt_index, - new_index, - sublevels_up); + (Node *) lfirst(l), + rt_index, + new_index, + sublevels_up); } break; case T_SubLink: { - SubLink *sub = (SubLink *)node; - List *tmp_oper, *tmp_lefthand; - - ChangeVarNodes( - (Node *)(sub->lefthand), - rt_index, - new_index, - sublevels_up); + SubLink *sub = (SubLink *) node; + List *tmp_oper, + *tmp_lefthand; ChangeVarNodes( - (Node *)(sub->subselect), - rt_index, - new_index, - sublevels_up + 1); - + (Node *) (sub->lefthand), + rt_index, + new_index, + sublevels_up); + + ChangeVarNodes( + (Node *) (sub->subselect), + rt_index, + new_index, + sublevels_up + 1); + /***S*I***/ - /* Make sure the first argument of sub->oper points to the - * same var as sub->lefthand does otherwise we will - * run into troubles using aggregates (aggno will not be - * set correctly) */ + + /* + * Make sure the first argument of sub->oper points to the + * same var as sub->lefthand does otherwise we will run + * into troubles using aggregates (aggno will not be set + * correctly) + */ tmp_lefthand = sub->lefthand; foreach(tmp_oper, sub->oper) - { - lfirst(((Expr *) lfirst(tmp_oper))->args) = - lfirst(tmp_lefthand); - tmp_lefthand = lnext(tmp_lefthand); - } + { + lfirst(((Expr *) lfirst(tmp_oper))->args) = + lfirst(tmp_lefthand); + tmp_lefthand = lnext(tmp_lefthand); + } } break; case T_Query: { - Query *qry = (Query *)node; + Query *qry = (Query *) node; ChangeVarNodes( - (Node *)(qry->targetList), - rt_index, - new_index, - sublevels_up); + (Node *) (qry->targetList), + rt_index, + new_index, + sublevels_up); ChangeVarNodes( - (Node *)(qry->qual), - rt_index, - new_index, - sublevels_up); + (Node *) (qry->qual), + rt_index, + new_index, + sublevels_up); ChangeVarNodes( - (Node *)(qry->havingQual), - rt_index, - new_index, - sublevels_up); + (Node *) (qry->havingQual), + rt_index, + new_index, + sublevels_up); } break; case T_CaseExpr: { - CaseExpr *exp = (CaseExpr *)node; + CaseExpr *exp = (CaseExpr *) node; ChangeVarNodes( - (Node *)(exp->args), - rt_index, - new_index, - sublevels_up); + (Node *) (exp->args), + rt_index, + new_index, + sublevels_up); ChangeVarNodes( - (Node *)(exp->defresult), - rt_index, - new_index, - sublevels_up); + (Node *) (exp->defresult), + rt_index, + new_index, + sublevels_up); } break; case T_CaseWhen: { - CaseWhen *exp = (CaseWhen *)node; + CaseWhen *exp = (CaseWhen *) node; ChangeVarNodes( - (Node *)(exp->expr), - rt_index, - new_index, - sublevels_up); + (Node *) (exp->expr), + rt_index, + new_index, + sublevels_up); ChangeVarNodes( - (Node *)(exp->result), - rt_index, - new_index, - sublevels_up); + (Node *) (exp->result), + rt_index, + new_index, + sublevels_up); } break; @@ -513,7 +527,7 @@ AddNotHavingQual(Query *parsetree, Node *havingQual) /***S*I***/ /* INTERSECT want's the original, but we need to copy - Jan */ /* copy = (Node *) make_notclause((Expr *)havingQual); */ - copy = (Node *)make_notclause( (Expr *)copyObject(havingQual)); + copy = (Node *) make_notclause((Expr *) copyObject(havingQual)); AddHavingQual(parsetree, copy); } @@ -529,7 +543,7 @@ AddNotQual(Query *parsetree, Node *qual) /***S*I***/ /* INTERSECT want's the original, but we need to copy - Jan */ /* copy = (Node *) make_notclause((Expr *)qual); */ - copy = (Node *) make_notclause((Expr *)copyObject(qual)); + copy = (Node *) make_notclause((Expr *) copyObject(qual)); AddQual(parsetree, copy); } @@ -538,24 +552,24 @@ AddNotQual(Query *parsetree, Node *qual) void AddGroupClause(Query *parsetree, List *group_by, List *tlist) { - List *l; - List *tl; - GroupClause *groupclause; - TargetEntry *tle; - int new_resno; + List *l; + List *tl; + GroupClause *groupclause; + TargetEntry *tle; + int new_resno; new_resno = length(parsetree->targetList); - foreach (l, group_by) + foreach(l, group_by) { - groupclause = (GroupClause *)copyObject(lfirst(l)); + groupclause = (GroupClause *) copyObject(lfirst(l)); tle = NULL; foreach(tl, tlist) { - if (((TargetEntry *)lfirst(tl))->resdom->resgroupref == - groupclause->tleGroupref) + if (((TargetEntry *) lfirst(tl))->resdom->resgroupref == + groupclause->tleGroupref) { - tle = (TargetEntry *)copyObject(lfirst(tl)); + tle = (TargetEntry *) copyObject(lfirst(tl)); break; } } @@ -567,7 +581,7 @@ AddGroupClause(Query *parsetree, List *group_by, List *tlist) tle->resdom->resgroupref = length(parsetree->groupClause) + 1; groupclause->tleGroupref = tle->resdom->resgroupref; - parsetree->targetList = lappend(parsetree->targetList, tle); + parsetree->targetList = lappend(parsetree->targetList, tle); parsetree->groupClause = lappend(parsetree->groupClause, groupclause); } } @@ -604,6 +618,7 @@ FixResdomTypes(List *tlist) } } } + #endif static Node * @@ -735,10 +750,10 @@ FixNew(RewriteInfo *info, Query *parsetree) { ResolveNew(info, parsetree->targetList, (Node **) &(info->rule_action->targetList), 0); - ResolveNew(info, parsetree->targetList, - (Node **) &info->rule_action->qual, 0); - ResolveNew(info, parsetree->targetList, - (Node **) &(info->rule_action->groupClause), 0); + ResolveNew(info, parsetree->targetList, + (Node **) &info->rule_action->qual, 0); + ResolveNew(info, parsetree->targetList, + (Node **) &(info->rule_action->groupClause), 0); } static void @@ -797,7 +812,7 @@ nodeHandleRIRAttributeRule(Node **nodePtr, break; case T_ArrayRef: { - ArrayRef *ref = (ArrayRef *) node; + ArrayRef *ref = (ArrayRef *) node; nodeHandleRIRAttributeRule((Node **) (&(ref->refupperindexpr)), rtable, targetlist, rt_index, attr_num, @@ -972,7 +987,7 @@ nodeHandleViewRule(Node **nodePtr, break; case T_ArrayRef: { - ArrayRef *ref = (ArrayRef *) node; + ArrayRef *ref = (ArrayRef *) node; nodeHandleViewRule((Node **) (&(ref->refupperindexpr)), rtable, targetlist, @@ -1006,6 +1021,7 @@ nodeHandleViewRule(Node **nodePtr, *nodePtr = make_null(((Var *) node)->vartype); else { + /* * This is a hack: The varlevelsup of the orignal * variable and the new one should be the same. @@ -1026,7 +1042,7 @@ nodeHandleViewRule(Node **nodePtr, ((Var *) *nodePtr)->varlevelsup = this_varlevelsup; else nodeHandleViewRule(&n, rtable, targetlist, - rt_index, modified, sublevels_up); + rt_index, modified, sublevels_up); } *modified = TRUE; } @@ -1048,17 +1064,18 @@ nodeHandleViewRule(Node **nodePtr, { SubLink *sublink = (SubLink *) node; Query *query = (Query *) sublink->subselect; - List *tmp_lefthand, *tmp_oper; - + List *tmp_lefthand, + *tmp_oper; + nodeHandleViewRule((Node **) &(query->qual), rtable, targetlist, rt_index, modified, sublevels_up + 1); /***S*H*D***/ nodeHandleViewRule((Node **) &(query->havingQual), rtable, targetlist, - rt_index, modified, sublevels_up + 1); + rt_index, modified, sublevels_up + 1); nodeHandleViewRule((Node **) &(query->targetList), rtable, targetlist, - rt_index, modified, sublevels_up + 1); + rt_index, modified, sublevels_up + 1); /* @@ -1076,21 +1093,19 @@ nodeHandleViewRule(Node **nodePtr, */ pfree(lfirst(((Expr *) lfirst(sublink->oper))->args)); lfirst(((Expr *) lfirst(sublink->oper))->args) = - lfirst(sublink->lefthand); + lfirst(sublink->lefthand); /***S*I***/ /* INTERSECT want's this - Jan */ + /* - tmp_lefthand = sublink->lefthand; - foreach(tmp_oper, sublink->oper) - { - lfirst(((Expr *) lfirst(tmp_oper))->args) = - lfirst(tmp_lefthand); - tmp_lefthand = lnext(tmp_lefthand); - } - */ - } + * tmp_lefthand = sublink->lefthand; foreach(tmp_oper, + * sublink->oper) { lfirst(((Expr *) + * lfirst(tmp_oper))->args) = lfirst(tmp_lefthand); + * tmp_lefthand = lnext(tmp_lefthand); } + */ + } break; default: /* ignore the others */ @@ -1119,5 +1134,5 @@ HandleViewRule(Query *parsetree, nodeHandleViewRule((Node **) (&(parsetree->groupClause)), rtable, targetlist, rt_index, modified, 0); } -#endif +#endif diff --git a/src/backend/rewrite/rewriteRemove.c b/src/backend/rewrite/rewriteRemove.c index ceb43cba6a..10cce0262b 100644 --- a/src/backend/rewrite/rewriteRemove.c +++ b/src/backend/rewrite/rewriteRemove.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteRemove.c,v 1.23 1999/05/10 00:45:32 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteRemove.c,v 1.24 1999/05/25 16:10:54 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -42,7 +42,7 @@ RewriteGetRuleEventRel(char *rulename) 0, 0, 0); if (!HeapTupleIsValid(htup)) elog(ERROR, "Rule or view '%s' not found", - ((!strncmp(rulename, "_RET", 4))? (rulename+4): rulename)); + ((!strncmp(rulename, "_RET", 4)) ? (rulename + 4) : rulename)); eventrel = ((Form_pg_rewrite) GETSTRUCT(htup))->ev_class; htup = SearchSysCacheTuple(RELOID, PointerGetDatum(eventrel), diff --git a/src/backend/storage/buffer/buf_init.c b/src/backend/storage/buffer/buf_init.c index 13a55f3276..2ee839d8de 100644 --- a/src/backend/storage/buffer/buf_init.c +++ b/src/backend/storage/buffer/buf_init.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_init.c,v 1.22 1999/02/22 06:16:50 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_init.c,v 1.23 1999/05/25 16:10:56 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -61,6 +61,7 @@ BufferBlock BufferBlocks; #ifndef HAS_TEST_AND_SET long *NWaitIOBackendP; + #endif extern IpcSemaphoreId WaitIOSemId; @@ -238,14 +239,14 @@ InitBufferPool(IPCKey key) WaitIOSemId = IpcSemaphoreCreate(IPCKeyGetWaitIOSemaphoreKey(key), 1, IPCProtection, 0, 1, &status); WaitCLSemId = IpcSemaphoreCreate(IPCKeyGetWaitCLSemaphoreKey(key), - 1, IPCProtection, - IpcSemaphoreDefaultStartValue, + 1, IPCProtection, + IpcSemaphoreDefaultStartValue, 1, &status); } #endif PrivateRefCount = (long *) calloc(NBuffers, sizeof(long)); LastRefCount = (long *) calloc(NBuffers, sizeof(long)); - BufferLocks = (bits8*) calloc (NBuffers, sizeof(bits8)); + BufferLocks = (bits8 *) calloc(NBuffers, sizeof(bits8)); CommitInfoNeedsSave = (long *) calloc(NBuffers, sizeof(long)); } diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c index c1040cfc16..052abe8ede 100644 --- a/src/backend/storage/buffer/bufmgr.c +++ b/src/backend/storage/buffer/bufmgr.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.51 1999/05/10 00:45:35 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.52 1999/05/25 16:10:58 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -86,6 +86,7 @@ static void WaitIO(BufferDesc *buf, SPINLOCK spinlock); #ifndef HAS_TEST_AND_SET static void SignalIO(BufferDesc *buf); extern long *NWaitIOBackendP; /* defined in buf_init.c */ + #endif /* HAS_TEST_AND_SET */ static Buffer ReadBufferWithBufferLock(Relation relation, BlockNumber blockNum, @@ -95,7 +96,7 @@ static BufferDesc *BufferAlloc(Relation reln, BlockNumber blockNum, static int FlushBuffer(Buffer buffer, bool release); static void BufferSync(void); static int BufferReplace(BufferDesc *bufHdr, bool bufferLockHeld); -void PrintBufferDescs(void); +void PrintBufferDescs(void); /* not static but used by vacuum only ... */ int BlowawayRelationBuffers(Relation rel, BlockNumber block); @@ -161,7 +162,7 @@ extern int ShowPinTrace; * defined */ /* - * ReadBuffer + * ReadBuffer * */ Buffer @@ -1116,7 +1117,7 @@ WaitIO(BufferDesc *buf, SPINLOCK spinlock) } /* - * SignalIO + * SignalIO */ static void SignalIO(BufferDesc *buf) @@ -1217,7 +1218,7 @@ BufferPoolCheckLeak() BufferDesc *buf = &(BufferDescriptors[i - 1]); elog(NOTICE, - "Buffer Leak: [%03d] (freeNext=%d, freePrev=%d, \ + "Buffer Leak: [%03d] (freeNext=%d, freePrev=%d, \ relname=%s, blockNum=%d, flags=0x%x, refcount=%d %d)", i - 1, buf->freeNext, buf->freePrev, buf->sb_relname, buf->tag.blockNum, buf->flags, @@ -1246,7 +1247,7 @@ FlushBufferPool(int StableMainMemoryFlag) } /* - * BufferGetBlockNumber + * BufferGetBlockNumber * Returns the block number associated with a buffer. * * Note: @@ -1266,7 +1267,7 @@ BufferGetBlockNumber(Buffer buffer) #ifdef NOT_USED /* - * BufferGetRelation + * BufferGetRelation * Returns the relation desciptor associated with a buffer. * * Note: @@ -1299,6 +1300,7 @@ BufferGetRelation(Buffer buffer) return relation; } + #endif /* @@ -1363,7 +1365,7 @@ BufferReplace(BufferDesc *bufHdr, bool bufferLockHeld) } /* - * RelationGetNumberOfBlocks + * RelationGetNumberOfBlocks * Returns the buffer descriptor associated with a page in a relation. * * Note: @@ -1375,7 +1377,7 @@ BlockNumber RelationGetNumberOfBlocks(Relation relation) { return ((relation->rd_myxactonly) ? relation->rd_nblocks : - smgrnblocks(DEFAULT_SMGR, relation)); + smgrnblocks(DEFAULT_SMGR, relation)); } /* --------------------------------------------------------------------- @@ -1941,8 +1943,8 @@ UnlockBuffers() { if (BufferLocks[i] == 0) continue; - - Assert(BufferIsValid(i+1)); + + Assert(BufferIsValid(i + 1)); buf = &(BufferDescriptors[i]); #ifdef HAS_TEST_AND_SET @@ -1976,7 +1978,7 @@ UnlockBuffers() } void -LockBuffer (Buffer buffer, int mode) +LockBuffer(Buffer buffer, int mode) { BufferDesc *buf; @@ -1984,31 +1986,31 @@ LockBuffer (Buffer buffer, int mode) if (BufferIsLocal(buffer)) return; - buf = &(BufferDescriptors[buffer-1]); + buf = &(BufferDescriptors[buffer - 1]); #ifdef HAS_TEST_AND_SET - S_LOCK(&(buf->cntx_lock)); + S_LOCK(&(buf->cntx_lock)); #else - IpcSemaphoreLock(WaitCLSemId, 0, IpcExclusiveLock); + IpcSemaphoreLock(WaitCLSemId, 0, IpcExclusiveLock); #endif if (mode == BUFFER_LOCK_UNLOCK) { - if (BufferLocks[buffer-1] & BL_R_LOCK) + if (BufferLocks[buffer - 1] & BL_R_LOCK) { Assert(buf->r_locks > 0); Assert(!(buf->w_lock)); - Assert(!(BufferLocks[buffer-1] & (BL_W_LOCK | BL_RI_LOCK))) - (buf->r_locks)--; - BufferLocks[buffer-1] &= ~BL_R_LOCK; + Assert(!(BufferLocks[buffer - 1] & (BL_W_LOCK | BL_RI_LOCK))) + (buf->r_locks)--; + BufferLocks[buffer - 1] &= ~BL_R_LOCK; } - else if (BufferLocks[buffer-1] & BL_W_LOCK) + else if (BufferLocks[buffer - 1] & BL_W_LOCK) { Assert(buf->w_lock); Assert(buf->r_locks == 0 && !buf->ri_lock); - Assert(!(BufferLocks[buffer-1] & (BL_R_LOCK | BL_RI_LOCK))) - buf->w_lock = false; - BufferLocks[buffer-1] &= ~BL_W_LOCK; + Assert(!(BufferLocks[buffer - 1] & (BL_R_LOCK | BL_RI_LOCK))) + buf->w_lock = false; + BufferLocks[buffer - 1] &= ~BL_W_LOCK; } else elog(ERROR, "UNLockBuffer: buffer %u is not locked", buffer); @@ -2017,7 +2019,7 @@ LockBuffer (Buffer buffer, int mode) { unsigned i = 0; - Assert(!(BufferLocks[buffer-1] & (BL_R_LOCK | BL_W_LOCK | BL_RI_LOCK))); + Assert(!(BufferLocks[buffer - 1] & (BL_R_LOCK | BL_W_LOCK | BL_RI_LOCK))); while (buf->ri_lock || buf->w_lock) { #ifdef HAS_TEST_AND_SET @@ -2027,23 +2029,23 @@ LockBuffer (Buffer buffer, int mode) #else IpcSemaphoreUnlock(WaitCLSemId, 0, IpcExclusiveLock); s_lock_sleep(i++) - IpcSemaphoreLock(WaitCLSemId, 0, IpcExclusiveLock); + IpcSemaphoreLock(WaitCLSemId, 0, IpcExclusiveLock); #endif } (buf->r_locks)++; - BufferLocks[buffer-1] |= BL_R_LOCK; + BufferLocks[buffer - 1] |= BL_R_LOCK; } else if (mode == BUFFER_LOCK_EXCLUSIVE) { unsigned i = 0; - - Assert(!(BufferLocks[buffer-1] & (BL_R_LOCK | BL_W_LOCK | BL_RI_LOCK))); + + Assert(!(BufferLocks[buffer - 1] & (BL_R_LOCK | BL_W_LOCK | BL_RI_LOCK))); while (buf->r_locks > 0 || buf->w_lock) { if (buf->r_locks > 3) { - if (!(BufferLocks[buffer-1] & BL_RI_LOCK)) - BufferLocks[buffer-1] |= BL_RI_LOCK; + if (!(BufferLocks[buffer - 1] & BL_RI_LOCK)) + BufferLocks[buffer - 1] |= BL_RI_LOCK; buf->ri_lock = true; } #ifdef HAS_TEST_AND_SET @@ -2053,24 +2055,24 @@ LockBuffer (Buffer buffer, int mode) #else IpcSemaphoreUnlock(WaitCLSemId, 0, IpcExclusiveLock); s_lock_sleep(i++) - IpcSemaphoreLock(WaitCLSemId, 0, IpcExclusiveLock); + IpcSemaphoreLock(WaitCLSemId, 0, IpcExclusiveLock); #endif } buf->w_lock = true; - BufferLocks[buffer-1] |= BL_W_LOCK; - if (BufferLocks[buffer-1] & BL_RI_LOCK) + BufferLocks[buffer - 1] |= BL_W_LOCK; + if (BufferLocks[buffer - 1] & BL_RI_LOCK) { buf->ri_lock = false; - BufferLocks[buffer-1] &= ~BL_RI_LOCK; + BufferLocks[buffer - 1] &= ~BL_RI_LOCK; } } else elog(ERROR, "LockBuffer: unknown lock mode %d", mode); #ifdef HAS_TEST_AND_SET - S_UNLOCK(&(buf->cntx_lock)); + S_UNLOCK(&(buf->cntx_lock)); #else - IpcSemaphoreUnlock(WaitCLSemId, 0, IpcExclusiveLock); + IpcSemaphoreUnlock(WaitCLSemId, 0, IpcExclusiveLock); #endif } diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index ba2026ae37..2b007b85e0 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/buffer/freelist.c,v 1.14 1999/02/13 23:17:59 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/buffer/freelist.c,v 1.15 1999/05/25 16:10:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -55,7 +55,7 @@ extern SPINLOCK BufMgrLock; /* - * AddBufferToFreelist + * AddBufferToFreelist * * In theory, this is the only routine that needs to be changed * if the buffer replacement strategy changes. Just change diff --git a/src/backend/storage/buffer/s_lock.c b/src/backend/storage/buffer/s_lock.c index 788d67dae5..4dd3008012 100644 --- a/src/backend/storage/buffer/s_lock.c +++ b/src/backend/storage/buffer/s_lock.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/buffer/Attic/s_lock.c,v 1.18 1999/03/14 16:03:00 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/buffer/Attic/s_lock.c,v 1.19 1999/05/25 16:11:00 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -100,7 +100,8 @@ s_lock(volatile slock_t *lock, const char *file, const int line) #if defined(__m68k__) static void -tas_dummy() /* really means: extern int tas(slock_t **lock); */ + tas_dummy() /* really means: extern int tas(slock_t + * **lock); */ { __asm__(" \n\ .global _tas \n\ @@ -163,7 +164,8 @@ fail: \n\ j $31 \n\ "); } -#endif /* __mips */ + +#endif /* __mips */ #else /* defined(__GNUC__) */ /*************************************************************************** diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c index 0cb0460756..eade2f1c64 100644 --- a/src/backend/storage/file/fd.c +++ b/src/backend/storage/file/fd.c @@ -6,7 +6,7 @@ * Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Id: fd.c,v 1.39 1999/05/09 00:52:07 tgl Exp $ + * $Id: fd.c,v 1.40 1999/05/25 16:11:03 momjian Exp $ * * NOTES: * @@ -103,11 +103,11 @@ typedef struct vfd unsigned short fdstate; /* bitflags for VFD's state */ /* these are the assigned bits in fdstate: */ -#define FD_DIRTY (1 << 0) /* written to, but not yet fsync'd */ -#define FD_TEMPORARY (1 << 1) /* should be unlinked when closed */ +#define FD_DIRTY (1 << 0)/* written to, but not yet fsync'd */ +#define FD_TEMPORARY (1 << 1)/* should be unlinked when closed */ File nextFree; /* link to next free VFD, if in freelist */ - File lruMoreRecently; /* doubly linked recency-of-use list */ + File lruMoreRecently;/* doubly linked recency-of-use list */ File lruLessRecently; long seekPos; /* current logical file position */ char *fileName; /* name of file, or NULL for unused VFD */ @@ -118,7 +118,7 @@ typedef struct vfd /* * Virtual File Descriptor array pointer and size. This grows as - * needed. 'File' values are indexes into this array. + * needed. 'File' values are indexes into this array. * Note that VfdCache[0] is not a usable VFD, just a list header. */ static Vfd *VfdCache; @@ -139,7 +139,7 @@ static int nfile = 0; #define MAX_ALLOCATED_FILES 32 static int numAllocatedFiles = 0; -static FILE * allocatedFiles[MAX_ALLOCATED_FILES]; +static FILE *allocatedFiles[MAX_ALLOCATED_FILES]; /* * Number of temporary files opened during the current transaction; @@ -348,7 +348,7 @@ LruInsert(File file) if (FileIsNotOpen(file)) { - while (nfile+numAllocatedFiles >= pg_nofile()) + while (nfile + numAllocatedFiles >= pg_nofile()) ReleaseLruFile(); /* @@ -434,12 +434,13 @@ AllocateVfd() if (VfdCache[0].nextFree == 0) { + /* * The free list is empty so it is time to increase the size of * the array. We choose to double it each time this happens. * However, there's not much point in starting *real* small. */ - Size newCacheSize = SizeVfdCache * 2; + Size newCacheSize = SizeVfdCache * 2; if (newCacheSize < 32) newCacheSize = 32; @@ -532,8 +533,9 @@ FileAccess(File file) file, VfdCache[file].fileName)); /* - * Is the file open? If not, open it and put it at the head of the LRU - * ring (possibly closing the least recently used file to get an FD). + * Is the file open? If not, open it and put it at the head of the + * LRU ring (possibly closing the least recently used file to get an + * FD). */ if (FileIsNotOpen(file)) @@ -589,7 +591,7 @@ fileNameOpenFile(FileName fileName, file = AllocateVfd(); vfdP = &VfdCache[file]; - while (nfile+numAllocatedFiles >= pg_nofile()) + while (nfile + numAllocatedFiles >= pg_nofile()) ReleaseLruFile(); tryAgain: @@ -659,10 +661,13 @@ PathNameOpenFile(FileName fileName, int fileFlags, int fileMode) File OpenTemporaryFile(void) { - char tempfilename[64]; - File file; + char tempfilename[64]; + File file; - /* Generate a tempfile name that's unique within the current transaction */ + /* + * Generate a tempfile name that's unique within the current + * transaction + */ snprintf(tempfilename, sizeof(tempfilename), "pg_temp%d.%ld", (int) getpid(), tempFileCounter++); @@ -723,9 +728,7 @@ FileClose(File file) * Delete the file if it was temporary */ if (VfdCache[file].fdstate & FD_TEMPORARY) - { unlink(VfdCache[file].fileName); - } /* * Return the Vfd slot to the free list @@ -817,9 +820,7 @@ FileSeek(File file, long offset, int whence) } } else - { VfdCache[file].seekPos = lseek(VfdCache[file].fd, offset, whence); - } return VfdCache[file].seekPos; } @@ -893,7 +894,7 @@ FileNameUnlink(char *filename) /* * Routines that want to use stdio (ie, FILE*) should use AllocateFile * rather than plain fopen(). This lets fd.c deal with freeing FDs if - * necessary to open the file. When done, call FreeFile rather than fclose. + * necessary to open the file. When done, call FreeFile rather than fclose. * * Note that files that will be open for any significant length of time * should NOT be handled this way, since they cannot share kernel file @@ -929,21 +930,19 @@ TryAgain: } } else - { allocatedFiles[numAllocatedFiles++] = file; - } return file; } void FreeFile(FILE *file) { - int i; + int i; DO_DB(elog(DEBUG, "FreeFile: Allocated %d.", numAllocatedFiles)); /* Remove file from list of allocated files, if it's present */ - for (i = numAllocatedFiles; --i >= 0; ) + for (i = numAllocatedFiles; --i >= 0;) { if (allocatedFiles[i] == file) { @@ -971,7 +970,7 @@ closeAllVfds() if (SizeVfdCache > 0) { - Assert(FileIsNotOpen(0)); /* Make sure ring not corrupted */ + Assert(FileIsNotOpen(0)); /* Make sure ring not corrupted */ for (i = 1; i < SizeVfdCache; i++) { if (!FileIsNotOpen(i)) @@ -995,7 +994,7 @@ AtEOXact_Files(void) if (SizeVfdCache > 0) { - Assert(FileIsNotOpen(0)); /* Make sure ring not corrupted */ + Assert(FileIsNotOpen(0)); /* Make sure ring not corrupted */ for (i = 1; i < SizeVfdCache; i++) { if ((VfdCache[i].fdstate & FD_TEMPORARY) && @@ -1005,12 +1004,11 @@ AtEOXact_Files(void) } while (numAllocatedFiles > 0) - { FreeFile(allocatedFiles[0]); - } - /* Reset the tempfile name counter to 0; not really necessary, - * but helps keep the names from growing unreasonably long. + /* + * Reset the tempfile name counter to 0; not really necessary, but + * helps keep the names from growing unreasonably long. */ tempFileCounter = 0; } @@ -1018,7 +1016,7 @@ AtEOXact_Files(void) /* * Operations on BufFiles --- a very incomplete emulation of stdio - * atop virtual Files. Currently, we only support the buffered-I/O + * atop virtual Files. Currently, we only support the buffered-I/O * aspect of stdio: a read or write of the low-level File occurs only * when the buffer is filled or emptied. This is an even bigger win * for virtual Files than ordinary kernel files, since reducing the @@ -1032,12 +1030,13 @@ AtEOXact_Files(void) * by elog(ERROR). */ -struct BufFile { - File file; /* the underlying virtual File */ - bool dirty; /* does buffer need to be written? */ - int pos; /* next read/write position in buffer */ - int nbytes; /* total # of valid bytes in buffer */ - char buffer[BLCKSZ]; +struct BufFile +{ + File file; /* the underlying virtual File */ + bool dirty; /* does buffer need to be written? */ + int pos; /* next read/write position in buffer */ + int nbytes; /* total # of valid bytes in buffer */ + char buffer[BLCKSZ]; }; @@ -1046,10 +1045,10 @@ struct BufFile { * * This is comparable to fdopen() in stdio. */ -BufFile * +BufFile * BufFileCreate(File file) { - BufFile *bfile = (BufFile *) palloc(sizeof(BufFile)); + BufFile *bfile = (BufFile *) palloc(sizeof(BufFile)); bfile->file = file; bfile->dirty = false; @@ -1065,7 +1064,7 @@ BufFileCreate(File file) * Like fclose(), this also implicitly FileCloses the underlying File. */ void -BufFileClose(BufFile *file) +BufFileClose(BufFile * file) { /* flush any unwritten data */ BufFileFlush(file); @@ -1080,10 +1079,10 @@ BufFileClose(BufFile *file) * Like fread() except we assume 1-byte element size. */ size_t -BufFileRead(BufFile *file, void *ptr, size_t size) +BufFileRead(BufFile * file, void *ptr, size_t size) { - size_t nread = 0; - size_t nthistime; + size_t nread = 0; + size_t nthistime; if (file->dirty) { @@ -1126,10 +1125,10 @@ BufFileRead(BufFile *file, void *ptr, size_t size) * Like fwrite() except we assume 1-byte element size. */ size_t -BufFileWrite(BufFile *file, void *ptr, size_t size) +BufFileWrite(BufFile * file, void *ptr, size_t size) { - size_t nwritten = 0; - size_t nthistime; + size_t nwritten = 0; + size_t nthistime; while (size > 0) { @@ -1170,7 +1169,7 @@ BufFileWrite(BufFile *file, void *ptr, size_t size) * Like fflush() */ int -BufFileFlush(BufFile *file) +BufFileFlush(BufFile * file) { if (file->dirty) { @@ -1188,7 +1187,7 @@ BufFileFlush(BufFile *file) * the new file offset (or -1 in case of error). */ long -BufFileSeek(BufFile *file, long offset, int whence) +BufFileSeek(BufFile * file, long offset, int whence) { if (BufFileFlush(file) < 0) return -1L; diff --git a/src/backend/storage/ipc/ipc.c b/src/backend/storage/ipc/ipc.c index 62a38e14aa..b9ec1d171f 100644 --- a/src/backend/storage/ipc/ipc.c +++ b/src/backend/storage/ipc/ipc.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v 1.36 1999/02/21 01:41:44 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v 1.37 1999/05/25 16:11:07 momjian Exp $ * * NOTES * @@ -680,7 +680,7 @@ struct ipcdummy SLock slocks[MAX_SPINS + 1]; }; -#define SLOCKMEMORYSIZE sizeof(struct ipcdummy) +#define SLOCKMEMORYSIZE sizeof(struct ipcdummy) void CreateAndInitSLockMemory(IPCKey key) @@ -747,4 +747,5 @@ IpcConfigTip(void) fprintf(stderr, "shared memory or System V IPC semaphore configuration.\n"); fprintf(stderr, "See the FAQ for more detailed information\n"); } + #endif diff --git a/src/backend/storage/ipc/ipci.c b/src/backend/storage/ipc/ipci.c index e7d6e702bf..6fedbcf85a 100644 --- a/src/backend/storage/ipc/ipci.c +++ b/src/backend/storage/ipc/ipci.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipci.c,v 1.23 1999/03/06 21:17:41 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipci.c,v 1.24 1999/05/25 16:11:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -25,7 +25,7 @@ #include "miscadmin.h" /* for DebugLvl */ /* - * SystemPortAddressCreateMemoryKey + * SystemPortAddressCreateMemoryKey * Returns a memory key given a port address. */ IPCKey @@ -37,7 +37,7 @@ SystemPortAddressCreateIPCKey(SystemPortAddress address) } /* - * CreateSharedMemoryAndSemaphores + * CreateSharedMemoryAndSemaphores * Creates and initializes shared memory and semaphores. */ /************************************************** @@ -75,8 +75,8 @@ CreateSharedMemoryAndSemaphores(IPCKey key, int maxBackends) /* * Size of the primary shared-memory block is estimated via - * moderately-accurate estimates for the big hogs, plus 100K for - * the stuff that's too small to bother with estimating. + * moderately-accurate estimates for the big hogs, plus 100K for the + * stuff that's too small to bother with estimating. */ size = BufferShmemSize() + LockShmemSize(maxBackends); #ifdef STABLE_MEMORY_STORAGE @@ -113,7 +113,7 @@ CreateSharedMemoryAndSemaphores(IPCKey key, int maxBackends) /* - * AttachSharedMemoryAndSemaphores + * AttachSharedMemoryAndSemaphores * Attachs existant shared memory and semaphores. */ void diff --git a/src/backend/storage/ipc/shmem.c b/src/backend/storage/ipc/shmem.c index 421cd399c6..eafe53b0bb 100644 --- a/src/backend/storage/ipc/shmem.c +++ b/src/backend/storage/ipc/shmem.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.39 1999/04/02 04:51:03 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.40 1999/05/25 16:11:11 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -106,7 +106,7 @@ ShmemIndexReset(void) } /* - * CreateSharedRegion() + * CreateSharedRegion() * * This routine is called once by the postmaster to * initialize the shared buffer pool. Assume there is @@ -348,10 +348,10 @@ ShmemInitHash(char *name, /* table string name for shmem index */ long *location; /* - * Hash tables allocated in shared memory have a fixed directory; - * it can't grow or other backends wouldn't be able to find it. - * The segbase is for calculating pointer values. - * The shared memory allocator must be specified too. + * Hash tables allocated in shared memory have a fixed directory; it + * can't grow or other backends wouldn't be able to find it. The + * segbase is for calculating pointer values. The shared memory + * allocator must be specified too. */ infoP->dsize = infoP->max_dsize = DEF_DIRSIZE; infoP->segbase = (long *) ShmemBase; @@ -360,7 +360,7 @@ ShmemInitHash(char *name, /* table string name for shmem index */ /* look it up in the shmem index */ location = ShmemInitStruct(name, - sizeof(HHDR) + DEF_DIRSIZE * sizeof(SEG_OFFSET), + sizeof(HHDR) + DEF_DIRSIZE * sizeof(SEG_OFFSET), &found); /* @@ -379,7 +379,7 @@ ShmemInitHash(char *name, /* table string name for shmem index */ /* Now provide the header and directory pointers */ infoP->hctl = (long *) location; - infoP->dir = (long *) (((char*) location) + sizeof(HHDR)); + infoP->dir = (long *) (((char *) location) + sizeof(HHDR)); return hash_create(init_size, infoP, hash_flags); } @@ -636,13 +636,13 @@ TransactionIdIsInProgress(TransactionId xid) Snapshot GetSnapshotData(bool serializable) { - Snapshot snapshot = (Snapshot) malloc(sizeof(SnapshotData)); - ShmemIndexEnt *result; - PROC *proc; - TransactionId cid = GetCurrentTransactionId(); - TransactionId xid; - uint32 count = 0; - uint32 have = 32; + Snapshot snapshot = (Snapshot) malloc(sizeof(SnapshotData)); + ShmemIndexEnt *result; + PROC *proc; + TransactionId cid = GetCurrentTransactionId(); + TransactionId xid; + uint32 count = 0; + uint32 have = 32; Assert(ShmemIndex); @@ -670,7 +670,7 @@ GetSnapshotData(bool serializable) strncmp(result->key, "PID ", 4) != 0) continue; proc = (PROC *) MAKE_PTR(result->location); - xid = proc->xid; /* we don't use spin-locking in xact.c ! */ + xid = proc->xid; /* we don't use spin-locking in xact.c ! */ if (proc == MyProc || xid < FirstTransactionId) continue; if (xid < snapshot->xmin) @@ -697,18 +697,18 @@ GetSnapshotData(bool serializable) /* * GetXmaxRecent -- returns oldest transaction that was running - * when all current transaction was started. - * It's used by vacuum to decide what deleted - * tuples must be preserved in a table. + * when all current transaction was started. + * It's used by vacuum to decide what deleted + * tuples must be preserved in a table. * * And yet another strange func for this place... - vadim 03/18/99 */ void GetXmaxRecent(TransactionId *XmaxRecent) { - ShmemIndexEnt *result; - PROC *proc; - TransactionId xmin; + ShmemIndexEnt *result; + PROC *proc; + TransactionId xmin; Assert(ShmemIndex); @@ -728,7 +728,7 @@ GetXmaxRecent(TransactionId *XmaxRecent) strncmp(result->key, "PID ", 4) != 0) continue; proc = (PROC *) MAKE_PTR(result->location); - xmin = proc->xmin; /* we don't use spin-locking in xact.c ! */ + xmin = proc->xmin; /* we don't use spin-locking in xact.c ! */ if (proc == MyProc || xmin < FirstTransactionId) continue; if (xmin < *XmaxRecent) diff --git a/src/backend/storage/ipc/sinval.c b/src/backend/storage/ipc/sinval.c index ec271bd963..3617fa345d 100644 --- a/src/backend/storage/ipc/sinval.c +++ b/src/backend/storage/ipc/sinval.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.13 1999/02/13 23:18:14 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.14 1999/05/25 16:11:12 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -87,7 +87,7 @@ InitSharedInvalidationState(void) } /* - * RegisterSharedInvalid + * RegisterSharedInvalid * Returns a new local cache invalidation state containing a new entry. * * Note: @@ -147,7 +147,7 @@ RegisterSharedInvalid(int cacheId, /* XXX */ } /* - * InvalidateSharedInvalid + * InvalidateSharedInvalid * Processes all entries in a shared cache invalidation state. */ /****************************************************************************/ diff --git a/src/backend/storage/ipc/sinvaladt.c b/src/backend/storage/ipc/sinvaladt.c index 4e5ab146bb..27393c63ef 100644 --- a/src/backend/storage/ipc/sinvaladt.c +++ b/src/backend/storage/ipc/sinvaladt.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinvaladt.c,v 1.18 1999/05/10 00:45:37 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinvaladt.c,v 1.19 1999/05/25 16:11:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -144,9 +144,7 @@ SIAssignBackendId(SISeg *segInOutP, BackendTag backendTag) for (index++; index < MAXBACKENDS; index++) { if (segInOutP->procState[index].tag == backendTag) - { elog(FATAL, "SIAssignBackendId: tag %d found twice", backendTag); - } } Assert(stateP); @@ -187,7 +185,7 @@ SISetDeadProcess(SISeg *segP, int backendId) } /* - * CleanupInvalidationState + * CleanupInvalidationState * Note: * This is a temporary hack. ExitBackend should call this instead * of exit (via on_shmem_exit). diff --git a/src/backend/storage/large_object/inv_api.c b/src/backend/storage/large_object/inv_api.c index 79df2912b9..57d03568c7 100644 --- a/src/backend/storage/large_object/inv_api.c +++ b/src/backend/storage/large_object/inv_api.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.52 1999/05/10 00:45:41 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.53 1999/05/25 16:11:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -131,7 +131,7 @@ inv_create(int flags) if (RelnameFindRelid(indname) != InvalidOid) { elog(ERROR, - "internal error: %s already exists -- cannot create large obj", + "internal error: %s already exists -- cannot create large obj", indname); } @@ -437,13 +437,13 @@ inv_tell(LargeObjectDesc *obj_desc) int inv_read(LargeObjectDesc *obj_desc, char *buf, int nbytes) { - HeapTupleData tuple; - int nread; - int off; - int ncopy; - Datum d; + HeapTupleData tuple; + int nread; + int off; + int ncopy; + Datum d; struct varlena *fsblock; - bool isNull; + bool isNull; Assert(PointerIsValid(obj_desc)); Assert(buf != NULL); @@ -499,9 +499,9 @@ inv_read(LargeObjectDesc *obj_desc, char *buf, int nbytes) int inv_write(LargeObjectDesc *obj_desc, char *buf, int nbytes) { - HeapTupleData tuple; - int nwritten; - int tuplen; + HeapTupleData tuple; + int nwritten; + int tuplen; Assert(PointerIsValid(obj_desc)); Assert(buf != NULL); @@ -549,10 +549,12 @@ inv_write(LargeObjectDesc *obj_desc, char *buf, int nbytes) } else tuplen = inv_wrold(obj_desc, buf, nbytes - nwritten, &tuple, buffer); - /* inv_wrold() has already issued WriteBuffer() - which has decremented local reference counter - (LocalRefCount). So we should not call - ReleaseBuffer() here. -- Tatsuo 99/2/4 */ + + /* + * inv_wrold() has already issued WriteBuffer() which has + * decremented local reference counter (LocalRefCount). So we + * should not call ReleaseBuffer() here. -- Tatsuo 99/2/4 + */ } /* move pointers past the amount we just wrote */ @@ -626,25 +628,26 @@ inv_fetchtup(LargeObjectDesc *obj_desc, HeapTuple tuple, Buffer *buffer) || obj_desc->offset < obj_desc->lowbyte || !ItemPointerIsValid(&(obj_desc->htid))) { - ScanKeyData skey; + ScanKeyData skey; ScanKeyEntryInitialize(&skey, 0x0, 1, F_INT4GE, - Int32GetDatum(obj_desc->offset)); + Int32GetDatum(obj_desc->offset)); /* initialize scan key if not done */ if (obj_desc->iscan == (IndexScanDesc) NULL) { + /* * As scan index may be prematurely closed (on commit), we * must use object current offset (was 0) to reinitialize the * entry [ PA ]. */ obj_desc->iscan = index_beginscan(obj_desc->index_r, - (bool) 0, (uint16) 1, - &skey); - } else { - index_rescan(obj_desc->iscan, false, &skey); - } + (bool) 0, (uint16) 1, + &skey); + } + else + index_rescan(obj_desc->iscan, false, &skey); do { res = index_getnext(obj_desc->iscan, ForwardScanDirection); @@ -671,15 +674,14 @@ inv_fetchtup(LargeObjectDesc *obj_desc, HeapTuple tuple, Buffer *buffer) } while (tuple->t_data == NULL); /* remember this tid -- we may need it for later reads/writes */ - ItemPointerCopy(&(tuple->t_self), &obj_desc->htid); + ItemPointerCopy(&(tuple->t_self), &obj_desc->htid); } else { tuple->t_self = obj_desc->htid; heap_fetch(obj_desc->heap_r, SnapshotNow, tuple, buffer); - if (tuple->t_data == NULL) { + if (tuple->t_data == NULL) elog(ERROR, "inv_fetchtup: heap_fetch failed"); - } } /* @@ -751,11 +753,13 @@ inv_wrnew(LargeObjectDesc *obj_desc, char *buf, int nbytes) nblocks = RelationGetNumberOfBlocks(hr); - if (nblocks > 0) { + if (nblocks > 0) + { buffer = ReadBuffer(hr, nblocks - 1); page = BufferGetPage(buffer); } - else { + else + { buffer = ReadBuffer(hr, P_NEW); page = BufferGetPage(buffer); PageInit(page, BufferGetPageSize(buffer), 0); @@ -794,7 +798,7 @@ inv_wrnew(LargeObjectDesc *obj_desc, char *buf, int nbytes) ntup = inv_newtuple(obj_desc, buffer, page, buf, nwritten); inv_indextup(obj_desc, ntup); - pfree (ntup); + pfree(ntup); /* new tuple is inserted */ WriteBuffer(buffer); @@ -874,11 +878,13 @@ inv_wrold(LargeObjectDesc *obj_desc, nblocks = RelationGetNumberOfBlocks(hr); - if (nblocks > 0) { + if (nblocks > 0) + { newbuf = ReadBuffer(hr, nblocks - 1); newpage = BufferGetPage(newbuf); } - else { + else + { newbuf = ReadBuffer(hr, P_NEW); newpage = BufferGetPage(newbuf); PageInit(newpage, BufferGetPageSize(newbuf), 0); @@ -966,7 +972,7 @@ inv_wrold(LargeObjectDesc *obj_desc, /* index the new tuple */ inv_indextup(obj_desc, ntup); - pfree (ntup); + pfree(ntup); /* * move the scandesc forward so we don't reread the newly inserted @@ -1002,7 +1008,7 @@ inv_newtuple(LargeObjectDesc *obj_desc, char *dbuf, int nwrite) { - HeapTuple ntup = (HeapTuple) palloc (sizeof(HeapTupleData)); + HeapTuple ntup = (HeapTuple) palloc(sizeof(HeapTupleData)); PageHeader ph; int tupsize; int hoff; @@ -1227,7 +1233,7 @@ _inv_getsize(Relation hreln, TupleDesc hdesc, Relation ireln) { IndexScanDesc iscan; RetrieveIndexResult res; - HeapTupleData tuple; + HeapTupleData tuple; Datum d; long size; bool isNull; diff --git a/src/backend/storage/lmgr/lmgr.c b/src/backend/storage/lmgr/lmgr.c index 7eb51207c7..3cebcb9ba0 100644 --- a/src/backend/storage/lmgr/lmgr.c +++ b/src/backend/storage/lmgr/lmgr.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lmgr.c,v 1.23 1999/05/07 01:23:02 vadim Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lmgr.c,v 1.24 1999/05/25 16:11:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -76,7 +76,7 @@ static MASK LockConflicts[] = { /* AccessExclusiveLock */ (1 << ExclusiveLock) | (1 << ShareRowExclusiveLock) | (1 << ShareLock) | - (1 << RowExclusiveLock) | (1 << RowShareLock) | (1 << AccessExclusiveLock) | + (1 << RowExclusiveLock) | (1 << RowShareLock) | (1 << AccessExclusiveLock) | (1 << AccessShareLock), }; @@ -92,7 +92,7 @@ static int LockPrios[] = { 7 }; -LOCKMETHOD LockTableId = (LOCKMETHOD) NULL; +LOCKMETHOD LockTableId = (LOCKMETHOD) NULL; LOCKMETHOD LongTermTableId = (LOCKMETHOD) NULL; /* @@ -104,12 +104,14 @@ InitLockTable() int lockmethod; lockmethod = LockMethodTableInit("LockTable", - LockConflicts, LockPrios, MAX_LOCKMODES - 1); + LockConflicts, LockPrios, MAX_LOCKMODES - 1); LockTableId = lockmethod; + if (!(LockTableId)) elog(ERROR, "InitLockTable: couldnt initialize lock table"); #ifdef USER_LOCKS + /* * Allocate another tableId for long-term locks */ @@ -125,7 +127,7 @@ InitLockTable() } /* - * RelationInitLockInfo + * RelationInitLockInfo * Initializes the lock information in a relation descriptor. */ void @@ -322,10 +324,10 @@ XactLockTableWait(TransactionId xid) LockAcquire(LockTableId, &tag, ShareLock); TransactionIdFlushCache(); + /* - * Transaction was committed/aborted/crashed - - * we have to update pg_log if transaction is still - * marked as running. + * Transaction was committed/aborted/crashed - we have to update + * pg_log if transaction is still marked as running. */ if (!TransactionIdDidCommit(xid) && !TransactionIdDidAbort(xid)) TransactionIdAbort(xid); diff --git a/src/backend/storage/lmgr/lock.c b/src/backend/storage/lmgr/lock.c index 09e85e5e13..9860abca7e 100644 --- a/src/backend/storage/lmgr/lock.c +++ b/src/backend/storage/lmgr/lock.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.52 1999/05/13 15:55:44 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.53 1999/05/25 16:11:21 momjian Exp $ * * NOTES * Outside modules can create a lock table and acquire/release @@ -50,7 +50,7 @@ #include "utils/trace.h" #include "utils/ps_status.h" -static int WaitOnLock(LOCKMETHOD lockmethod, LOCK *lock, LOCKMODE lockmode); +static int WaitOnLock(LOCKMETHOD lockmethod, LOCK *lock, LOCKMODE lockmode); /* * lockDebugRelation can be used to trace unconditionally a single relation, @@ -658,22 +658,22 @@ LockAcquire(LOCKMETHOD lockmethod, LOCKTAG *locktag, LOCKMODE lockmode) */ if (lockMethodTable->ctl->conflictTab[lockmode] & lock->waitMask) { - int i = 1; + int i = 1; /* - * If I don't hold locks or my locks don't conflict - * with waiters then force to sleep. + * If I don't hold locks or my locks don't conflict with waiters + * then force to sleep. */ if (result->nHolding > 0) { - for ( ; i <= lockMethodTable->ctl->numLockModes; i++) + for (; i <= lockMethodTable->ctl->numLockModes; i++) { - if (result->holders[i] > 0 && + if (result->holders[i] > 0 && lockMethodTable->ctl->conflictTab[i] & lock->waitMask) - break; /* conflict */ + break; /* conflict */ } } - + if (result->nHolding == 0 || i > lockMethodTable->ctl->numLockModes) { XID_PRINT("LockAcquire: higher priority proc waiting", @@ -718,17 +718,18 @@ LockAcquire(LOCKMETHOD lockmethod, LOCKTAG *locktag, LOCKMODE lockmode) return FALSE; } #endif + /* * Construct bitmask of locks we hold before going to sleep. */ MyProc->holdLock = 0; if (result->nHolding > 0) { - int i, - tmpMask = 2; + int i, + tmpMask = 2; - for (i = 1; i <= lockMethodTable->ctl->numLockModes; - i++, tmpMask <<= 1) + for (i = 1; i <= lockMethodTable->ctl->numLockModes; + i++, tmpMask <<= 1) { if (result->holders[i] > 0) MyProc->holdLock |= tmpMask; @@ -1166,14 +1167,15 @@ LockRelease(LOCKMETHOD lockmethod, LOCKTAG *locktag, LOCKMODE lockmode) wakeupNeeded = false; else #endif - /* - * Above is not valid any more (due to MVCC lock modes). - * Actually we should compare activeHolders[lockmode] with - * number of waiters holding lock of this type and try to - * wakeup only if these numbers are equal (and lock released - * conflicts with locks requested by waiters). For the moment - * we only check the last condition. - */ + + /* + * Above is not valid any more (due to MVCC lock modes). Actually + * we should compare activeHolders[lockmode] with number of + * waiters holding lock of this type and try to wakeup only if + * these numbers are equal (and lock released conflicts with locks + * requested by waiters). For the moment we only check the last + * condition. + */ if (lockMethodTable->ctl->conflictTab[lockmode] & lock->waitMask) wakeupNeeded = true; @@ -1238,14 +1240,12 @@ LockRelease(LOCKMETHOD lockmethod, LOCKTAG *locktag, LOCKMODE lockmode) } if (wakeupNeeded) - { ProcLockWakeup(&(lock->waitProcs), lockmethod, lock); - } else { if (((LOCKDEBUG(LOCK_LOCKMETHOD(*(lock))) >= 1) \ - && (lock->tag.relId >= lockDebugOidMin)) \ - || \ + &&(lock->tag.relId >= lockDebugOidMin)) \ + ||\ (lockDebugRelation && (lock->tag.relId == lockDebugRelation))) TPRINTF(TRACE_ALL, "LockRelease: no wakeup needed"); } @@ -1309,7 +1309,7 @@ LockReleaseAll(LOCKMETHOD lockmethod, SHM_QUEUE *lockQueue) for (;;) { - bool wakeupNeeded = false; + bool wakeupNeeded = false; /* * Sometimes the queue appears to be messed up. @@ -1377,7 +1377,7 @@ LockReleaseAll(LOCKMETHOD lockmethod, SHM_QUEUE *lockQueue) goto next_item; } TPRINTF(TRACE_USERLOCKS, - "LockReleaseAll: releasing user lock [%u] [%d,%d,%d]", + "LockReleaseAll: releasing user lock [%u] [%d,%d,%d]", lock->tag.objId.blkno, xidLook->tag.lock, xidLook->tag.pid, xidLook->tag.xid); } @@ -1391,7 +1391,7 @@ LockReleaseAll(LOCKMETHOD lockmethod, SHM_QUEUE *lockQueue) if (xidLook->tag.pid != 0) { TPRINTF(TRACE_LOCKS, - "LockReleaseAll: skiping user lock [%u] [%d,%d,%d]", + "LockReleaseAll: skiping user lock [%u] [%d,%d,%d]", lock->tag.objId.blkno, xidLook->tag.lock, xidLook->tag.pid, xidLook->tag.xid); nleft++; @@ -1415,10 +1415,11 @@ LockReleaseAll(LOCKMETHOD lockmethod, SHM_QUEUE *lockQueue) &&(lock->activeHolders[i] >= 0)); if (!lock->activeHolders[i]) lock->mask &= BITS_OFF[i]; + /* * Read comments in LockRelease */ - if (!wakeupNeeded && xidLook->holders[i] > 0 && + if (!wakeupNeeded && xidLook->holders[i] > 0 && lockMethodTable->ctl->conflictTab[i] & lock->waitMask) wakeupNeeded = true; } @@ -1521,7 +1522,7 @@ LockShmemSize(int maxBackends) int size = 0; size += MAXALIGN(sizeof(PROC_HDR)); /* ProcGlobal */ - size += MAXALIGN(maxBackends * sizeof(PROC)); /* each MyProc */ + size += MAXALIGN(maxBackends * sizeof(PROC)); /* each MyProc */ size += MAXALIGN(maxBackends * sizeof(LOCKMETHODCTL)); /* each * lockMethodTable->ctl */ @@ -1535,8 +1536,9 @@ LockShmemSize(int maxBackends) SHMEM_XIDTAB_KEYSIZE, SHMEM_XIDTAB_DATASIZE); - /* Since the lockHash entry count above is only an estimate, - * add 10% safety margin. + /* + * Since the lockHash entry count above is only an estimate, add 10% + * safety margin. */ size += size / 10; @@ -1569,21 +1571,21 @@ LockingDisabled() bool DeadLockCheck(void *proc, LOCK *findlock) { - XIDLookupEnt *xidLook = NULL; - XIDLookupEnt *tmp = NULL; - PROC *thisProc = (PROC*) proc, - *waitProc; - SHM_QUEUE *lockQueue = &(thisProc->lockQueue); - SHMEM_OFFSET end = MAKE_OFFSET(lockQueue); - LOCK *lock; - PROC_QUEUE *waitQueue; - int i, - j; - bool first_run = (thisProc == MyProc), - done; + XIDLookupEnt *xidLook = NULL; + XIDLookupEnt *tmp = NULL; + PROC *thisProc = (PROC *) proc, + *waitProc; + SHM_QUEUE *lockQueue = &(thisProc->lockQueue); + SHMEM_OFFSET end = MAKE_OFFSET(lockQueue); + LOCK *lock; + PROC_QUEUE *waitQueue; + int i, + j; + bool first_run = (thisProc == MyProc), + done; - static PROC *checked_procs[MAXBACKENDS]; - static int nprocs; + static PROC *checked_procs[MAXBACKENDS]; + static int nprocs; /* initialize at start of recursion */ if (first_run) @@ -1606,39 +1608,38 @@ DeadLockCheck(void *proc, LOCK *findlock) LOCK_PRINT("DeadLockCheck", lock, 0); - if (lock->tag.relId == 0) /* user' lock */ + if (lock->tag.relId == 0) /* user' lock */ goto nxtl; /* - * waitLock is always in lockQueue of waiting proc, - * if !first_run then upper caller will handle waitProcs - * queue of waitLock. + * waitLock is always in lockQueue of waiting proc, if !first_run + * then upper caller will handle waitProcs queue of waitLock. */ if (thisProc->waitLock == lock && !first_run) goto nxtl; /* - * If we found proc holding findlock and sleeping on some my - * other lock then we have to check does it block me or - * another waiters. + * If we found proc holding findlock and sleeping on some my other + * lock then we have to check does it block me or another waiters. */ if (lock == findlock && !first_run) { - LOCKMETHODCTL *lockctl = - LockMethodTable[DEFAULT_LOCKMETHOD]->ctl; - int lm; + LOCKMETHODCTL *lockctl = + LockMethodTable[DEFAULT_LOCKMETHOD]->ctl; + int lm; Assert(xidLook->nHolding > 0); for (lm = 1; lm <= lockctl->numLockModes; lm++) { - if (xidLook->holders[lm] > 0 && + if (xidLook->holders[lm] > 0 && lockctl->conflictTab[lm] & findlock->waitMask) return true; } + /* * Else - get the next lock from thisProc's lockQueue */ - goto nxtl; + goto nxtl; } waitQueue = &(lock->waitProcs); @@ -1653,10 +1654,10 @@ DeadLockCheck(void *proc, LOCK *findlock) waitProc = (PROC *) MAKE_PTR(waitProc->links.prev); continue; } - if (lock == findlock) /* first_run also true */ + if (lock == findlock) /* first_run also true */ { - LOCKMETHODCTL *lockctl = - LockMethodTable[DEFAULT_LOCKMETHOD]->ctl; + LOCKMETHODCTL *lockctl = + LockMethodTable[DEFAULT_LOCKMETHOD]->ctl; /* * If me blocked by his holdlock... @@ -1670,17 +1671,19 @@ DeadLockCheck(void *proc, LOCK *findlock) waitProc = (PROC *) MAKE_PTR(waitProc->links.prev); continue; } + /* - * If he isn't blocked by me and we request non-conflicting - * lock modes - no deadlock here because of he isn't - * blocked by me in any sence (explicitle or implicitly). - * Note that we don't do like test if !first_run - * (when thisProc is holder and non-waiter on lock) and so - * we call DeadLockCheck below for every waitProc in - * thisProc->lockQueue, even for waitProc-s un-blocked - * by thisProc. Should we? This could save us some time... + * If he isn't blocked by me and we request + * non-conflicting lock modes - no deadlock here because + * of he isn't blocked by me in any sence (explicitle or + * implicitly). Note that we don't do like test if + * !first_run (when thisProc is holder and non-waiter on + * lock) and so we call DeadLockCheck below for every + * waitProc in thisProc->lockQueue, even for waitProc-s + * un-blocked by thisProc. Should we? This could save us + * some time... */ - if (!(lockctl->conflictTab[waitProc->token] & MyProc->holdLock) && + if (!(lockctl->conflictTab[waitProc->token] & MyProc->holdLock) && !(lockctl->conflictTab[waitProc->token] & (1 << MyProc->token))) { waitProc = (PROC *) MAKE_PTR(waitProc->links.prev); @@ -1689,7 +1692,8 @@ DeadLockCheck(void *proc, LOCK *findlock) } /* - * Look in lockQueue of this waitProc, if didn't do this before. + * Look in lockQueue of this waitProc, if didn't do this + * before. */ for (j = 0; j < nprocs; j++) { @@ -1703,9 +1707,9 @@ DeadLockCheck(void *proc, LOCK *findlock) if (DeadLockCheck(waitProc, findlock)) { - LOCKMETHODCTL *lockctl = - LockMethodTable[DEFAULT_LOCKMETHOD]->ctl; - int holdLock; + LOCKMETHODCTL *lockctl = + LockMethodTable[DEFAULT_LOCKMETHOD]->ctl; + int holdLock; /* * Ok, but is waitProc waiting for me (thisProc) ? @@ -1715,14 +1719,16 @@ DeadLockCheck(void *proc, LOCK *findlock) Assert(first_run); holdLock = thisProc->holdLock; } - else /* should we cache holdLock ? */ + else +/* should we cache holdLock ? */ { - int lm, tmpMask = 2; + int lm, + tmpMask = 2; Assert(xidLook->nHolding > 0); - for (holdLock = 0, lm = 1; - lm <= lockctl->numLockModes; - lm++, tmpMask <<= 1) + for (holdLock = 0, lm = 1; + lm <= lockctl->numLockModes; + lm++, tmpMask <<= 1) { if (xidLook->holders[lm] > 0) holdLock |= tmpMask; @@ -1731,6 +1737,7 @@ DeadLockCheck(void *proc, LOCK *findlock) } if (lockctl->conflictTab[waitProc->token] & holdLock) { + /* * Last attempt to avoid deadlock - try to wakeup * myself. @@ -1751,6 +1758,7 @@ DeadLockCheck(void *proc, LOCK *findlock) } return true; } + /* * Hell! Is he blocked by any (other) holder ? */ @@ -1760,21 +1768,24 @@ DeadLockCheck(void *proc, LOCK *findlock) waitProc->xid, NULL) != STATUS_OK) { + /* * Blocked by others - no deadlock... */ #ifdef DEADLOCK_DEBUG - LOCK_PRINT("DeadLockCheck: blocked by others", - lock, waitProc->token); + LOCK_PRINT("DeadLockCheck: blocked by others", + lock, waitProc->token); #endif waitProc = (PROC *) MAKE_PTR(waitProc->links.prev); continue; } + /* * Well - wakeup this guy! This is the case of - * implicit blocking: thisProc blocked someone who blocked - * waitProc by the fact that he (someone) is already - * waiting for lock (we do this for anti-starving). + * implicit blocking: thisProc blocked someone who + * blocked waitProc by the fact that he/someone is + * already waiting for lock. We do this for + * anti-starving. */ GrantLock(lock, waitProc->token); waitQueue->size--; @@ -1785,7 +1796,7 @@ DeadLockCheck(void *proc, LOCK *findlock) waitProc = (PROC *) MAKE_PTR(waitProc->links.prev); } -nxtl:; +nxtl: ; if (done) break; SHMQueueFirst(&xidLook->queue, (Pointer *) &tmp, &tmp->queue); @@ -1832,7 +1843,7 @@ LockOwners(LOCKMETHOD lockmethod, LOCKTAG *locktag) if (is_user_lock) { TPRINTF(TRACE_USERLOCKS, "LockOwners: user lock tag [%u]", - locktag->objId.blkno;, + locktag->objId.blkno; } #endif @@ -1981,6 +1992,7 @@ LockOwners(LOCKMETHOD lockmethod, LOCKTAG *locktag) return array; } + #endif #ifdef DEADLOCK_DEBUG diff --git a/src/backend/storage/lmgr/multi.c b/src/backend/storage/lmgr/multi.c index 38e2d194d6..e60ba613ee 100644 --- a/src/backend/storage/lmgr/multi.c +++ b/src/backend/storage/lmgr/multi.c @@ -12,7 +12,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/Attic/multi.c,v 1.28 1999/03/28 20:32:25 vadim Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/Attic/multi.c,v 1.29 1999/05/25 16:11:22 momjian Exp $ * * NOTES: * (1) The lock.c module assumes that the caller here is doing @@ -170,6 +170,7 @@ MultiLockTuple(LockInfo lockinfo, ItemPointer tidPtr, LOCKMODE lockmode) tag.tupleId = *tidPtr; return MultiAcquire(MultiTableId, &tag, lockmode, TUPLE_LEVEL); } + #endif /* diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 4eb97b8a6a..3c0b96713a 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.55 1999/05/13 15:55:44 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.56 1999/05/25 16:11:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -46,7 +46,7 @@ * This is so that we can support more backends. (system-wide semaphore * sets run out pretty fast.) -ay 4/95 * - * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.55 1999/05/13 15:55:44 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.56 1999/05/25 16:11:23 momjian Exp $ */ #include #include @@ -150,18 +150,20 @@ InitProcGlobal(IPCKey key, int maxBackends) for (i = 0; i < MAX_PROC_SEMS / PROC_NSEMS_PER_SET; i++) ProcGlobal->freeSemMap[i] = 0; - /* Arrange to delete semas on exit --- set this up now so that - * we will clean up if pre-allocation fails... + /* + * Arrange to delete semas on exit --- set this up now so that we + * will clean up if pre-allocation fails... */ on_shmem_exit(ProcFreeAllSemaphores, NULL); - /* Pre-create the semaphores for the first maxBackends processes, + /* + * Pre-create the semaphores for the first maxBackends processes, * unless we are running as a standalone backend. */ if (key != PrivateIPCKey) { for (i = 0; - i < (maxBackends+PROC_NSEMS_PER_SET-1) / PROC_NSEMS_PER_SET; + i < (maxBackends + PROC_NSEMS_PER_SET - 1) / PROC_NSEMS_PER_SET; i++) { IPCKey semKey = ProcGlobal->currKey + i; @@ -266,10 +268,11 @@ InitProcess(IPCKey key) ProcGetNewSemKeyAndNum(&semKey, &semNum); - /* Note: because of the pre-allocation done in InitProcGlobal, - * this call should always attach to an existing semaphore. - * It will (try to) create a new group of semaphores only if - * the postmaster tries to start more backends than it said it would. + /* + * Note: because of the pre-allocation done in InitProcGlobal, + * this call should always attach to an existing semaphore. It + * will (try to) create a new group of semaphores only if the + * postmaster tries to start more backends than it said it would. */ semId = IpcSemaphoreCreate(semKey, PROC_NSEMS_PER_SET, @@ -489,7 +492,7 @@ ProcQueueInit(PROC_QUEUE *queue) */ int ProcSleep(PROC_QUEUE *waitQueue,/* lock->waitProcs */ - LOCKMETHODCTL *lockctl, + LOCKMETHODCTL * lockctl, int token, /* lockmode */ LOCK *lock) { @@ -534,23 +537,22 @@ ProcSleep(PROC_QUEUE *waitQueue,/* lock->waitProcs */ } /* if he waits for me */ else if (lockctl->conflictTab[proc->token] & MyProc->holdLock) - { break; - } /* if conflicting locks requested */ else if (lockctl->conflictTab[proc->token] & myMask) { + /* - * If I request non self-conflicting lock and there - * are others requesting the same lock just before me - - * stay here. + * If I request non self-conflicting lock and there are others + * requesting the same lock just before me - stay here. */ if (!selfConflict && prevSame) break; } + /* - * Last attempt to don't move any more: if we don't conflict - * with rest waiters in queue. + * Last attempt to don't move any more: if we don't conflict with + * rest waiters in queue. */ else if (!(lockctl->conflictTab[token] & waitMask)) break; @@ -558,7 +560,7 @@ ProcSleep(PROC_QUEUE *waitQueue,/* lock->waitProcs */ prevSame = (proc->token == token); (aheadHolders[proc->token])++; if (aheadHolders[proc->token] == lock->holders[proc->token]) - waitMask &= ~ (1 << proc->token); + waitMask &= ~(1 << proc->token); proc = (PROC *) MAKE_PTR(proc->links.prev); } @@ -885,7 +887,7 @@ ProcGetNewSemKeyAndNum(IPCKey *key, int *semNum) { int i; int32 *freeSemMap = ProcGlobal->freeSemMap; - int32 fullmask = (1 << (PROC_NSEMS_PER_SET+1)) - 1; + int32 fullmask = (1 << (PROC_NSEMS_PER_SET + 1)) - 1; /* * we hold ProcStructLock when entering this routine. We scan through @@ -906,8 +908,8 @@ ProcGetNewSemKeyAndNum(IPCKey *key, int *semNum) { /* - * a free semaphore found. Mark it as allocated. - * Also set the bit indicating whole set is allocated. + * a free semaphore found. Mark it as allocated. Also set + * the bit indicating whole set is allocated. */ freeSemMap[i] |= mask + (1 << PROC_NSEMS_PER_SET); @@ -938,9 +940,10 @@ ProcFreeSem(IpcSemaphoreKey semKey, int semNum) mask = ~(1 << semNum); freeSemMap[i] &= mask; - /* Formerly we'd release a semaphore set if it was now completely unused, - * but now we keep the semaphores to ensure we won't run out when - * starting new backends --- cf. InitProcGlobal. Note that the + /* + * Formerly we'd release a semaphore set if it was now completely + * unused, but now we keep the semaphores to ensure we won't run out + * when starting new backends --- cf. InitProcGlobal. Note that the * PROC_NSEMS_PER_SET+1'st bit of the freeSemMap entry remains set to * indicate it is still allocated; ProcFreeAllSemaphores() needs that. */ diff --git a/src/backend/storage/page/bufpage.c b/src/backend/storage/page/bufpage.c index 69074ae2ce..8c12a7652c 100644 --- a/src/backend/storage/page/bufpage.c +++ b/src/backend/storage/page/bufpage.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/page/bufpage.c,v 1.21 1999/02/13 23:18:31 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/page/bufpage.c,v 1.22 1999/05/25 16:11:25 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -35,7 +35,7 @@ static bool PageManagerShuffle = true; /* default is shuffle mode */ */ /* - * PageInit + * PageInit * Initializes the contents of a page. */ void @@ -56,7 +56,7 @@ PageInit(Page page, Size pageSize, Size specialSize) } /* - * PageAddItem + * PageAddItem * Adds item to the given page. * * Note: @@ -174,7 +174,7 @@ PageAddItem(Page page, } /* - * PageGetTempPage + * PageGetTempPage * Get a temporary page in local memory for special processing */ Page @@ -207,7 +207,7 @@ PageGetTempPage(Page page, Size specialSize) } /* - * PageRestoreTempPage + * PageRestoreTempPage * Copy temporary page back to permanent page after special processing * and release the temporary page. */ @@ -246,7 +246,7 @@ itemidcompare(const void *itemidp1, const void *itemidp2) } /* - * PageRepairFragmentation + * PageRepairFragmentation * Frees fragmented space on a page. */ void @@ -327,7 +327,7 @@ PageRepairFragmentation(Page page) } /* - * PageGetFreeSpace + * PageGetFreeSpace * Returns the size of the free (allocatable) space on a page. */ Size @@ -346,7 +346,7 @@ PageGetFreeSpace(Page page) } /* - * PageManagerModeSet + * PageManagerModeSet * * Sets mode to either: ShufflePageManagerMode (the default) or * OverwritePageManagerMode. For use by access methods code diff --git a/src/backend/storage/page/itemptr.c b/src/backend/storage/page/itemptr.c index 9e1353df5e..1ac32fd545 100644 --- a/src/backend/storage/page/itemptr.c +++ b/src/backend/storage/page/itemptr.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/page/itemptr.c,v 1.5 1999/02/13 23:18:33 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/page/itemptr.c,v 1.6 1999/05/25 16:11:27 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -19,7 +19,7 @@ #include "storage/bufpage.h" /* - * ItemPointerEquals + * ItemPointerEquals * Returns true if both item pointers point to the same item, * otherwise returns false. * diff --git a/src/backend/storage/smgr/md.c b/src/backend/storage/smgr/md.c index 84fd67510d..ce4fd6ab65 100644 --- a/src/backend/storage/smgr/md.c +++ b/src/backend/storage/smgr/md.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.43 1999/05/17 06:38:41 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.44 1999/05/25 16:11:30 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -712,9 +712,9 @@ mdtruncate(Relation reln, int nblocks) #ifndef LET_OS_MANAGE_FILESIZE int curnblk, - i, - oldsegno, - newsegno; + i, + oldsegno, + newsegno; char fname[NAMEDATALEN]; char tname[NAMEDATALEN + 10]; @@ -724,13 +724,15 @@ mdtruncate(Relation reln, int nblocks) StrNCpy(fname, RelationGetRelationName(reln)->data, NAMEDATALEN); - if (newsegno < oldsegno) { - for (i = (newsegno + 1);; i++) { + if (newsegno < oldsegno) + { + for (i = (newsegno + 1);; i++) + { sprintf(tname, "%s.%d", fname, i); if (FileNameUnlink(tname) < 0) break; } - } + } #endif fd = RelationGetFile(reln); diff --git a/src/backend/storage/smgr/mm.c b/src/backend/storage/smgr/mm.c index 2d5c1cdc4d..5bce97f93a 100644 --- a/src/backend/storage/smgr/mm.c +++ b/src/backend/storage/smgr/mm.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/smgr/Attic/mm.c,v 1.15 1999/03/06 21:17:50 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/smgr/Attic/mm.c,v 1.16 1999/05/25 16:11:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -569,15 +569,15 @@ MMShmemSize() * first compute space occupied by the (dbid,relid,blkno) hash table */ size += hash_estimate_size(MMNBUFFERS, - 0, /* MMHashEntry includes key */ - sizeof(MMHashEntry)); + 0, /* MMHashEntry includes key */ + sizeof(MMHashEntry)); /* * now do the same for the rel hash table */ size += hash_estimate_size(MMNRELATIONS, - 0, /* MMRelHashEntry includes key */ - sizeof(MMRelHashEntry)); + 0, /* MMRelHashEntry includes key */ + sizeof(MMRelHashEntry)); /* * finally, add in the memory block we use directly diff --git a/src/backend/storage/smgr/smgr.c b/src/backend/storage/smgr/smgr.c index 175cfa0f53..25644d088b 100644 --- a/src/backend/storage/smgr/smgr.c +++ b/src/backend/storage/smgr/smgr.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/smgr/smgr.c,v 1.23 1999/04/23 19:37:42 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/smgr/smgr.c,v 1.24 1999/05/25 16:11:34 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -79,6 +79,7 @@ static bool smgrwo[] = { false, /* main memory */ #endif }; + #endif static int NSmgr = lengthof(smgrsw); @@ -408,4 +409,5 @@ smgriswo(int16 smgrno) return smgrwo[smgrno]; } + #endif diff --git a/src/backend/tcop/dest.c b/src/backend/tcop/dest.c index b564ac65aa..dce9425e19 100644 --- a/src/backend/tcop/dest.c +++ b/src/backend/tcop/dest.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/tcop/dest.c,v 1.29 1999/04/28 22:17:58 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/tcop/dest.c,v 1.30 1999/05/25 16:11:37 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -60,17 +60,17 @@ static char CommandInfo[32] = {0}; * ---------------- */ static void -donothingReceive (HeapTuple tuple, TupleDesc typeinfo, DestReceiver* self) +donothingReceive(HeapTuple tuple, TupleDesc typeinfo, DestReceiver * self) { } static void -donothingSetup (DestReceiver* self, TupleDesc typeinfo) +donothingSetup(DestReceiver * self, TupleDesc typeinfo) { } static void -donothingCleanup (DestReceiver* self) +donothingCleanup(DestReceiver * self) { } @@ -149,9 +149,11 @@ BeginCommand(char *pname, if (operation == CMD_SELECT && !isIntoRel) { StringInfoData buf; + pq_beginmessage(&buf); - pq_sendbyte(&buf, 'T'); /* tuple descriptor message type */ - pq_sendint(&buf, natts, 2); /* # of attributes in tuples */ + pq_sendbyte(&buf, 'T'); /* tuple descriptor message type */ + pq_sendint(&buf, natts, 2); /* # of attributes in + * tuples */ for (i = 0; i < natts; ++i) { @@ -215,35 +217,35 @@ BeginCommand(char *pname, * DestToFunction - return appropriate receiver function set for dest * ---------------- */ -DestReceiver* +DestReceiver * DestToFunction(CommandDest dest) { switch (dest) { - case Remote: + case Remote: /* printtup wants a dynamically allocated DestReceiver */ return printtup_create_DR(); break; case RemoteInternal: - return & printtup_internalDR; + return &printtup_internalDR; break; case Local: - return & be_printtupDR; + return &be_printtupDR; break; case Debug: - return & debugtupDR; + return &debugtupDR; break; case SPI: - return & spi_printtupDR; + return &spi_printtupDR; break; case None: default: - return & donothingDR; + return &donothingDR; break; } @@ -251,7 +253,7 @@ DestToFunction(CommandDest dest) * never gets here, but DECstation lint appears to be stupid... */ - return & donothingDR; + return &donothingDR; } /* ---------------- @@ -330,13 +332,13 @@ NullCommand(CommandDest dest) { switch (dest) { - case RemoteInternal: - case Remote: + case RemoteInternal: + case Remote: /* ---------------- * tell the fe that we saw an empty query string * ---------------- */ - pq_putbytes("I", 2); /* note we send I and \0 */ + pq_putbytes("I", 2);/* note we send I and \0 */ break; case Local: @@ -362,8 +364,8 @@ ReadyForQuery(CommandDest dest) { switch (dest) { - case RemoteInternal: - case Remote: + case RemoteInternal: + case Remote: if (PG_PROTOCOL_MAJOR(FrontendProtocol) >= 2) pq_putbytes("Z", 1); /* Flush output at end of cycle in any case. */ @@ -383,7 +385,7 @@ UpdateCommandInfo(int operation, Oid lastoid, uint32 tuples) { switch (operation) { - case CMD_INSERT: + case CMD_INSERT: if (tuples > 1) lastoid = InvalidOid; sprintf(CommandInfo, " %u %u", lastoid, tuples); diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index ab29054aa7..fbafe1e6bd 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.115 1999/05/22 17:47:49 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.116 1999/05/25 16:11:40 momjian Exp $ * * NOTES * this is the "main" module of the postgres backend and @@ -141,7 +141,7 @@ static bool IsEmptyQuery = false; char relname[80]; /* current relation name */ /* note: these declarations had better match tcopprot.h */ -DLLIMPORT sigjmp_buf Warn_restart; +DLLIMPORT sigjmp_buf Warn_restart; bool InError; extern int NBuffers; @@ -389,7 +389,8 @@ List * pg_parse_and_plan(char *query_string, /* string to execute */ Oid *typev, /* argument types */ int nargs, /* number of arguments */ - List **queryListP, /* returned pointer to the parse trees */ + List **queryListP, /* returned pointer to the parse + * trees */ CommandDest dest, /* where results should go */ bool aclOverride) { @@ -404,17 +405,17 @@ pg_parse_and_plan(char *query_string, /* string to execute */ if (DebugPrintQuery) { if (DebugPrintQuery > 3) - { + { /* Print the query string as is if query debug level > 3 */ - TPRINTF(TRACE_QUERY, "query: %s", query_string); + TPRINTF(TRACE_QUERY, "query: %s", query_string); } else { /* Print condensed query string to fit in one log line */ char buff[MAX_QUERY_SIZE + 1]; char c, - *s, - *d; + *s, + *d; int n, is_space = 1; @@ -462,21 +463,24 @@ pg_parse_and_plan(char *query_string, /* string to execute */ /* ---------------- * (2) rewrite the queries, as necessary * - * rewritten queries are collected in new_list. Note there may be - * more or fewer than in the original list. + * rewritten queries are collected in new_list. Note there may be + * more or fewer than in the original list. * ---------------- */ new_list = NIL; - foreach (querytree_list_item, querytree_list) + foreach(querytree_list_item, querytree_list) { querytree = (Query *) lfirst(querytree_list_item); if (DebugPrintParse || DebugPPrintParse) { - if (DebugPPrintParse) { + if (DebugPPrintParse) + { TPRINTF(TRACE_PRETTY_PARSE, "parser outputs:"); nodeDisplay(querytree); - } else { + } + else + { TPRINTF(TRACE_PARSE, "parser outputs:"); printf("\n%s\n\n", nodeToString(querytree)); } @@ -502,7 +506,7 @@ pg_parse_and_plan(char *query_string, /* string to execute */ */ if (aclOverride) { - foreach (querytree_list_item, querytree_list) + foreach(querytree_list_item, querytree_list) { List *l; @@ -522,19 +526,22 @@ pg_parse_and_plan(char *query_string, /* string to execute */ if (DebugPrintRewrittenParsetree || DebugPPrintRewrittenParsetree) { - if (DebugPPrintRewrittenParsetree) { + if (DebugPPrintRewrittenParsetree) + { TPRINTF(TRACE_PRETTY_REWRITTEN, "after rewriting:"); - foreach (querytree_list_item, querytree_list) + foreach(querytree_list_item, querytree_list) { querytree = (Query *) lfirst(querytree_list_item); nodeDisplay(querytree); printf("\n"); } - } else { + } + else + { TPRINTF(TRACE_REWRITTEN, "after rewriting:"); - foreach (querytree_list_item, querytree_list) + foreach(querytree_list_item, querytree_list) { querytree = (Query *) lfirst(querytree_list_item); printf("\n%s\n\n", nodeToString(querytree)); @@ -542,7 +549,7 @@ pg_parse_and_plan(char *query_string, /* string to execute */ } } - foreach (querytree_list_item, querytree_list) + foreach(querytree_list_item, querytree_list) { querytree = (Query *) lfirst(querytree_list_item); @@ -594,16 +601,20 @@ pg_parse_and_plan(char *query_string, /* string to execute */ */ if (DebugPrintPlan || DebugPPrintPlan) { - if (DebugPPrintPlan) { + if (DebugPPrintPlan) + { TPRINTF(TRACE_PRETTY_PLAN, "plan:"); nodeDisplay(plan); - } else { + } + else + { TPRINTF(TRACE_PLAN, "plan:"); printf("\n%s\n\n", nodeToString(plan)); } } #endif } + /* * If the command is an utility append a null plan. This is needed * to keep the plan_list aligned with the querytree_list or the @@ -670,14 +681,16 @@ pg_exec_query_dest(char *query_string, /* string to execute */ /* OK, do it to it! */ - /* NOTE: we do not use "foreach" here because we want to be sure - * the list pointers have been advanced before the query is executed. - * We need to do that because VACUUM has a nasty little habit of doing + /* + * NOTE: we do not use "foreach" here because we want to be sure the + * list pointers have been advanced before the query is executed. We + * need to do that because VACUUM has a nasty little habit of doing * CommitTransactionCommand at startup, and that will release the * memory holding our parse/plan lists :-(. This needs a better * solution --- currently, the code will crash if someone submits * "vacuum; something-else" in a single query string. But memory - * allocation needs redesigned anyway, so this will have to do for now. + * allocation needs redesigned anyway, so this will have to do for + * now. */ while (querytree_list) @@ -717,10 +730,13 @@ pg_exec_query_dest(char *query_string, /* string to execute */ */ if (DebugPrintPlan || DebugPPrintPlan) { - if (DebugPPrintPlan) { + if (DebugPPrintPlan) + { TPRINTF(TRACE_PRETTY_PLAN, "plan:"); nodeDisplay(plan); - } else { + } + else + { TPRINTF(TRACE_PLAN, "plan:"); printf("\n%s\n\n", nodeToString(plan)); } @@ -730,7 +746,7 @@ pg_exec_query_dest(char *query_string, /* string to execute */ SetQuerySnapshot(); /* - * execute the plan + * execute the plan */ if (ShowExecutorStats) ResetUsage(); @@ -762,13 +778,13 @@ pg_exec_query_dest(char *query_string, /* string to execute */ /* -------------------------------- * signal handler routines used in PostgresMain() * - * handle_warn() catches SIGQUIT. It forces control back to the main + * handle_warn() catches SIGQUIT. It forces control back to the main * loop, just as if an internal error (elog(ERROR,...)) had occurred. * elog() used to actually use kill(2) to induce a SIGQUIT to get here! * But that's not 100% reliable on some systems, so now it does its own - * siglongjmp() instead. + * siglongjmp() instead. * We still provide the signal catcher so that an error quit can be - * forced externally. This should be done only with great caution, + * forced externally. This should be done only with great caution, * however, since an asynchronous signal could leave the system in * who-knows-what inconsistent state. * @@ -832,6 +848,7 @@ QueryCancelHandler(SIGNAL_ARGS) void CancelQuery(void) { + /* * QueryCancel flag will be reset in main loop, which we reach by * longjmp from elog(). @@ -1150,7 +1167,8 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[]) { IsUnderPostmaster = true; DBName = optarg; - secure = false; /* subsequent switches are NOT secure */ + secure = false; /* subsequent switches are NOT + * secure */ } break; @@ -1238,7 +1256,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[]) break; case 'x': -#ifdef NOT_USED /* planner/xfunc.h */ +#ifdef NOT_USED /* planner/xfunc.h */ /* * control joey hellerstein's expensive function @@ -1326,7 +1344,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[]) fprintf(stderr, "%s does not know where to find the database system " "data. You must specify the directory that contains the " "database system either by specifying the -D invocation " - "option or by setting the PGDATA environment variable.\n\n", + "option or by setting the PGDATA environment variable.\n\n", argv[0]); proc_exit(1); } @@ -1479,10 +1497,13 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[]) pqsignal(SIGINT, QueryCancelHandler); /* cancel current query */ pqsignal(SIGQUIT, handle_warn); /* handle error */ pqsignal(SIGTERM, die); - pqsignal(SIGPIPE, SIG_IGN); /* ignore failure to write to frontend */ - /* Note: if frontend closes connection, we will notice it and exit cleanly - * when control next returns to outer loop. This seems safer than forcing - * exit in the midst of output during who-knows-what operation... + pqsignal(SIGPIPE, SIG_IGN); /* ignore failure to write to frontend */ + + /* + * Note: if frontend closes connection, we will notice it and exit + * cleanly when control next returns to outer loop. This seems safer + * than forcing exit in the midst of output during who-knows-what + * operation... */ pqsignal(SIGUSR1, quickdie); pqsignal(SIGUSR2, Async_NotifyHandler); /* flush also sinval cache */ @@ -1493,6 +1514,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[]) PG_PROTOCOL_MAJOR(FrontendProtocol) >= 2) { StringInfoData buf; + pq_beginmessage(&buf); pq_sendbyte(&buf, 'K'); pq_sendint(&buf, (int32) MyProcPid, sizeof(int32)); @@ -1504,7 +1526,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[]) if (!IsUnderPostmaster) { puts("\nPOSTGRES backend interactive interface "); - puts("$Revision: 1.115 $ $Date: 1999/05/22 17:47:49 $\n"); + puts("$Revision: 1.116 $ $Date: 1999/05/25 16:11:40 $\n"); } /* ---------------- @@ -1542,14 +1564,14 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[]) /* ---------------- * (1) tell the frontend we're ready for a new query. * - * Note: this includes fflush()'ing the last of the prior output. + * Note: this includes fflush()'ing the last of the prior output. * ---------------- */ ReadyForQuery(whereToSendOutput); /* ---------------- * (2) deal with pending asynchronous NOTIFY from other backends, - * and enable async.c's signal handler to execute NOTIFY directly. + * and enable async.c's signal handler to execute NOTIFY directly. * ---------------- */ QueryCancel = false; /* forget any earlier CANCEL signal */ diff --git a/src/backend/tcop/pquery.c b/src/backend/tcop/pquery.c index 97e8663e7d..83c400188f 100644 --- a/src/backend/tcop/pquery.c +++ b/src/backend/tcop/pquery.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/tcop/pquery.c,v 1.22 1999/03/23 05:41:00 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/tcop/pquery.c,v 1.23 1999/05/25 16:11:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -41,7 +41,7 @@ static char *CreateOperationTag(int operationType); static void ProcessQueryDesc(QueryDesc *queryDesc, Node *limoffset, - Node *limcount); + Node *limcount); /* ---------------------------------------------------------------- @@ -374,5 +374,5 @@ ProcessQuery(Query *parsetree, } else ProcessQueryDesc(queryDesc, parsetree->limitOffset, - parsetree->limitCount); + parsetree->limitCount); } diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c index a7fb1ed3a3..38099254bf 100644 --- a/src/backend/tcop/utility.c +++ b/src/backend/tcop/utility.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.60 1999/05/22 19:49:42 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.61 1999/05/25 16:11:43 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -616,7 +616,7 @@ ProcessUtility(Node *parsetree, PS_SET_STATUS(commandTag = "LOAD"); CHECK_IF_ABORTED(); - closeAllVfds(); /* probably not necessary... */ + closeAllVfds(); /* probably not necessary... */ load_file(stmt->filename); } break; @@ -653,6 +653,7 @@ ProcessUtility(Node *parsetree, break; #ifdef NOT_USED + /* * ******************************** Tioga-related statements ******************************* */ diff --git a/src/backend/tioga/Varray.c b/src/backend/tioga/Varray.c index 944b7766d8..c211686c74 100644 --- a/src/backend/tioga/Varray.c +++ b/src/backend/tioga/Varray.c @@ -1,6 +1,6 @@ /* ************************************************************************ * - * Varray.c + * Varray.c * * routines to provide a generic set of functions to handle variable sized * arrays. originally by Jiang Wu diff --git a/src/backend/tioga/tgRecipe.h b/src/backend/tioga/tgRecipe.h index 70ed561c0e..858d195cfa 100644 --- a/src/backend/tioga/tgRecipe.h +++ b/src/backend/tioga/tgRecipe.h @@ -11,7 +11,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: tgRecipe.h,v 1.8 1999/02/13 23:18:55 momjian Exp $ + * $Id: tgRecipe.h,v 1.9 1999/05/25 16:11:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -35,6 +35,7 @@ typedef struct * * * + * * geo-decls.h */ #endif /* TIOGA_FRONTEND */ @@ -114,7 +115,7 @@ typedef struct _tgrecipe { TgElement elmValue; /* "inherits" TgElement attributes. */ Arr_TgNodePtr *allNodes; /* array of all nodes for this recipe. */ - Arr_TgNodePtr *rootNodes; /* array of root nodes for this recipe. + Arr_TgNodePtr *rootNodes; /* array of root nodes for this recipe. * root nodes are nodes with no parents */ Arr_TgNodePtr *eyes; /* array of pointers for the browser nodes * recipe, execution of recipe starts by diff --git a/src/backend/utils/adt/acl.c b/src/backend/utils/adt/acl.c index 2ca6170407..b1fc557498 100644 --- a/src/backend/utils/adt/acl.c +++ b/src/backend/utils/adt/acl.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.35 1999/05/12 12:47:24 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.36 1999/05/25 16:11:49 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -34,7 +34,7 @@ static char *aclparse(char *s, AclItem *aip, unsigned *modechg); /* * getid * Consumes the first alphanumeric string (identifier) found in string - * 's', ignoring any leading white space. If it finds a double quote + * 's', ignoring any leading white space. If it finds a double quote * it returns the word inside the quotes. * * RETURNS: @@ -48,7 +48,7 @@ getid(char *s, char *n) { unsigned len; char *id; - int in_quotes = 0; + int in_quotes = 0; Assert(s && n); @@ -63,7 +63,7 @@ getid(char *s, char *n) for (id = s, len = 0; isalnum(*s) || *s == '_' || in_quotes; ++len, ++s) { - if (in_quotes && *s == '"') + if (in_quotes && *s == '"') { len--; in_quotes = 0; diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c index 41f02797a7..b0e59e3ff0 100644 --- a/src/backend/utils/adt/arrayfuncs.c +++ b/src/backend/utils/adt/arrayfuncs.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.42 1999/05/10 00:45:58 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.43 1999/05/25 16:11:50 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -200,7 +200,7 @@ array_in(char *string, /* input array in external form */ /* array not a large object */ dataPtr = (char *) _ReadArrayStr(p, nitems, ndim, dim, &inputproc, typelem, typmod, typdelim, typlen, typbyval, typalign, - &nbytes); + &nbytes); nbytes += ARR_OVERHEAD(ndim); retval = (ArrayType *) palloc(nbytes); MemSet(retval, 0, nbytes); @@ -246,7 +246,7 @@ array_in(char *string, /* input array in external form */ } /*----------------------------------------------------------------------------- - * _ArrayCount + * _ArrayCount * Counts the number of dimensions and the *dim array for an array string. * The syntax for array input is C-like nested curly braces *----------------------------------------------------------------------------- @@ -1284,19 +1284,19 @@ array_assgn(ArrayType *array, * Map an arbitrary function to an array and return a new array with * same dimensions and the source elements transformed by fn(). */ -ArrayType * +ArrayType * array_map(ArrayType *v, Oid type, - char * (*fn)(), + char *(*fn) (), Oid retType, int nargs, ...) { - ArrayType *result; - void *args[4]; - char **values; - char *elt; - int *dim; + ArrayType *result; + void *args[4]; + char **values; + char *elt; + int *dim; int ndim; int nitems; int i; @@ -1308,26 +1308,23 @@ array_map(ArrayType *v, char typdelim; Oid typelem; Oid proc; - char typalign; - char *s; - char *p; + char typalign; + char *s; + char *p; va_list ap; /* Large objects not yet supported */ - if (ARR_IS_LO(v) == true) { + if (ARR_IS_LO(v) == true) elog(ERROR, "array_map: large objects not supported"); - } /* Check nargs */ - if ((nargs < 0) || (nargs > 4)) { + if ((nargs < 0) || (nargs > 4)) elog(ERROR, "array_map: invalid nargs: %d", nargs); - } /* Copy extra args to local variable */ va_start(ap, nargs); - for (i=0; i 0) { + if (inp_typlen > 0) s += inp_typlen; - } else { + else s += INTALIGN(*(int32 *) s); - } } /* - * Apply the given function to source elt and extra args. - * nargs is the number of extra args taken by fn(). + * Apply the given function to source elt and extra args. nargs is + * the number of extra args taken by fn(). */ - switch (nargs) { - case 0: - p = (char *) (*fn) (elt); - break; - case 1: - p = (char *) (*fn) (elt, args[0]); - break; - case 2: - p = (char *) (*fn) (elt, args[0], args[1]); - break; - case 3: - p = (char *) (*fn) (elt, args[0], args[1], args[2]); - break; - case 4: - default: - p = (char *) (*fn) (elt, args[0], args[1], args[2], args[3]); - break; + switch (nargs) + { + case 0: + p = (char *) (*fn) (elt); + break; + case 1: + p = (char *) (*fn) (elt, args[0]); + break; + case 2: + p = (char *) (*fn) (elt, args[0], args[1]); + break; + case 3: + p = (char *) (*fn) (elt, args[0], args[1], args[2]); + break; + case 4: + default: + p = (char *) (*fn) (elt, args[0], args[1], args[2], args[3]); + break; } /* Update values and total result size */ - if (typbyval) { + if (typbyval) + { values[i] = (char *) p; nbytes += typlen; - } else { - int len; + } + else + { + int len; + len = ((typlen > 0) ? typlen : INTALIGN(*(int32 *) p)); /* Needed because _CopyArrayEls tries to pfree items */ - if (p == elt) { + if (p == elt) + { p = (char *) palloc(len); memcpy(p, elt, len); } diff --git a/src/backend/utils/adt/cash.c b/src/backend/utils/adt/cash.c index a6e9711a46..9f74645d38 100644 --- a/src/backend/utils/adt/cash.c +++ b/src/backend/utils/adt/cash.c @@ -9,7 +9,7 @@ * workings can be found in the book "Software Solutions in C" by * Dale Schumacher, Academic Press, ISBN: 0-12-632360-7. * - * $Header: /cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.27 1998/10/12 04:07:44 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.28 1999/05/25 16:11:52 momjian Exp $ */ #include @@ -681,8 +681,8 @@ cash_words_out(Cash *value) Cash m1; Cash m2; Cash m3; - text *result; - + text *result; + /* work with positive numbers */ if (*value < 0) { diff --git a/src/backend/utils/adt/char.c b/src/backend/utils/adt/char.c index 2984555af0..4c6e371106 100644 --- a/src/backend/utils/adt/char.c +++ b/src/backend/utils/adt/char.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/char.c,v 1.21 1999/02/13 23:19:05 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/char.c,v 1.22 1999/05/25 16:11:53 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -163,10 +163,10 @@ text_char(text *arg1) text * char_text(int8 arg1) { - text *result; + text *result; - result = palloc(VARHDRSZ+1); - VARSIZE(result) = VARHDRSZ+1; + result = palloc(VARHDRSZ + 1); + VARSIZE(result) = VARHDRSZ + 1; *(VARDATA(result)) = arg1; return result; diff --git a/src/backend/utils/adt/chunk.c b/src/backend/utils/adt/chunk.c index eb692526f8..a9a49fe940 100644 --- a/src/backend/utils/adt/chunk.c +++ b/src/backend/utils/adt/chunk.c @@ -6,7 +6,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/chunk.c,v 1.19 1999/02/13 23:19:06 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/chunk.c,v 1.20 1999/05/25 16:11:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -115,7 +115,7 @@ _ChunkArray(int fd, } /*-------------------------------------------------------------------------- - * GetChunkSize + * GetChunkSize * given an access pattern and array dimensionality etc, this program * returns the dimensions of the chunk in "d" *----------------------------------------------------------------------- @@ -160,7 +160,7 @@ GetChunkSize(FILE *fd, } /*------------------------------------------------------------------------- - * _FindBestChunk + * _FindBestChunk * This routine does most of the number crunching to compute the * optimal chunk shape. * Called by GetChunkSize @@ -213,7 +213,7 @@ _FindBestChunk(int size, } /*---------------------------------------------------------------------- - * get_next + * get_next * Called by _GetBestChunk to get the next tuple in the lexicographic order *--------------------------------------------------------------------- */ @@ -420,7 +420,7 @@ seek_and_read(int pos, int size, char *buff, int fp, int from) #endif /* LOARRAY */ /*---------------------------------------------------------------------------- - * _ReadChunkArray + * _ReadChunkArray * returns the subarray specified bu the range indices "st" and "endp" * from the chunked array stored in file "fp" *--------------------------------------------------------------------------- @@ -620,7 +620,7 @@ _ReadChunkArray(int *st, } /*------------------------------------------------------------------------ - * _ReadChunkArray1El + * _ReadChunkArray1El * returns one element of the chunked array as specified by the index "st" * the chunked file descriptor is "fp" *------------------------------------------------------------------------- diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c index e582ebc2c6..7ad18a067e 100644 --- a/src/backend/utils/adt/date.c +++ b/src/backend/utils/adt/date.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.31 1999/03/14 16:44:01 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.32 1999/05/25 16:11:56 momjian Exp $ * * NOTES * This code is actually (almost) unused. @@ -988,6 +988,7 @@ isreltime(char *str) return 0; } /* isreltime() */ + #endif #ifdef NOT_USED diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c index aad1cec4eb..84163583ef 100644 --- a/src/backend/utils/adt/datetime.c +++ b/src/backend/utils/adt/datetime.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.32 1999/04/26 04:42:48 ishii Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.33 1999/05/25 16:11:58 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -311,7 +311,7 @@ abstime_date(AbsoluteTime abstime) * and then convert again to try to get the time zones correct. */ static int -date2tm(DateADT dateVal, int *tzp, struct tm *tm, double *fsec, char **tzn) +date2tm(DateADT dateVal, int *tzp, struct tm * tm, double *fsec, char **tzn) { struct tm *tx; time_t utime; @@ -358,7 +358,7 @@ date2tm(DateADT dateVal, int *tzp, struct tm *tm, double *fsec, char **tzn) /* tm_gmtoff is Sun/DEC-ism */ *tzp = -(tm->tm_gmtoff); if (tzn != NULL) - *tzn = (char *)tm->tm_zone; + *tzn = (char *) tm->tm_zone; #elif defined(HAVE_INT_TIMEZONE) #ifdef __CYGWIN__ *tzp = (tm->tm_isdst ? (_timezone - 3600) : _timezone); @@ -393,13 +393,13 @@ date2tm(DateADT dateVal, int *tzp, struct tm *tm, double *fsec, char **tzn) #ifdef DATEDEBUG #if defined(HAVE_TM_ZONE) - printf("date2tm- %d.%02d.%02d %02d:%02d:%02.0f (%d %s) dst=%d\n", - tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, (double) tm->tm_sec, - *tzp, tm->tm_zone, tm->tm_isdst); + printf("date2tm- %d.%02d.%02d %02d:%02d:%02.0f (%d %s) dst=%d\n", + tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, (double) tm->tm_sec, + *tzp, tm->tm_zone, tm->tm_isdst); #elif defined(HAVE_INT_TIMEZONE) - printf("date2tm- %d.%02d.%02d %02d:%02d:%02.0f (%d %s %s) dst=%d\n", - tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, (double) tm->tm_sec, - *tzp, tzname[0], tzname[1], tm->tm_isdst); + printf("date2tm- %d.%02d.%02d %02d:%02d:%02.0f (%d %s %s) dst=%d\n", + tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, (double) tm->tm_sec, + *tzp, tzname[0], tzname[1], tm->tm_isdst); #endif #endif diff --git a/src/backend/utils/adt/dt.c b/src/backend/utils/adt/dt.c index a055a03df8..9fb75cb568 100644 --- a/src/backend/utils/adt/dt.c +++ b/src/backend/utils/adt/dt.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/dt.c,v 1.70 1999/05/01 17:14:56 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/dt.c,v 1.71 1999/05/25 16:12:00 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -34,9 +34,9 @@ static int DecodeDate(char *str, int fmask, int *tmask, struct tm * tm); static int DecodeNumber(int flen, char *field, - int fmask, int *tmask, struct tm * tm, double *fsec, int *is2digits); + int fmask, int *tmask, struct tm * tm, double *fsec, int *is2digits); static int DecodeNumberField(int len, char *str, - int fmask, int *tmask, struct tm * tm, double *fsec, int *is2digits); + int fmask, int *tmask, struct tm * tm, double *fsec, int *is2digits); static int DecodeSpecial(int field, char *lowtoken, int *val); static int DecodeTime(char *str, int fmask, int *tmask, struct tm * tm, double *fsec); @@ -55,9 +55,9 @@ static int tm2timespan(struct tm * tm, double fsec, TimeSpan *span); #define USE_DATE_CACHE 1 #define ROUND_ALL 0 -int day_tab[2][13] = { +int day_tab[2][13] = { {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0}, - {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0}}; +{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0}}; char *months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", @@ -2090,7 +2090,7 @@ static datetkn datetktbl[] = { {"idlw", TZ, NEG(72)}, /* Intl. Date Line, West */ {LATE, RESERV, DTK_LATE}, /* "infinity" reserved for "late time" */ {INVALID, RESERV, DTK_INVALID}, - /* "invalid" reserved for invalid time */ + /* "invalid" reserved for invalid time */ {"ist", TZ, 12}, /* Israel */ {"it", TZ, 21}, /* Iran Time */ {"jan", MONTH, 1}, @@ -2438,7 +2438,7 @@ datetime2tm(DateTime dt, int *tzp, struct tm * tm, double *fsec, char **tzn) *tzp = -(tm->tm_gmtoff); /* tm_gmtoff is Sun/DEC-ism */ if (tzn != NULL) - *tzn = (char *)tm->tm_zone; + *tzn = (char *) tm->tm_zone; #elif defined(HAVE_INT_TIMEZONE) #ifdef __CYGWIN__ *tzp = (tm->tm_isdst ? (_timezone - 3600) : _timezone); @@ -2833,8 +2833,10 @@ DecodeDateTime(char **field, int *ftype, int nf, case DTK_NUMBER: flen = strlen(field[i]); - /* long numeric string and either no date or no time read yet? - * then interpret as a concatenated date or time... */ + /* + * long numeric string and either no date or no time read + * yet? then interpret as a concatenated date or time... + */ if ((flen > 4) && !((fmask & DTK_DATE_M) && (fmask & DTK_TIME_M))) { if (DecodeNumberField(flen, field[i], fmask, &tmask, tm, fsec, &is2digits) != 0) @@ -2926,10 +2928,14 @@ DecodeDateTime(char **field, int *ftype, int nf, #ifdef DATEDEBUG printf("DecodeDateTime- month field %s value is %d\n", field[i], val); #endif - /* already have a (numeric) month? then see if we can substitute... */ - if ((fmask & DTK_M(MONTH)) && (! haveTextMonth) - && (!(fmask & DTK_M(DAY))) - && ((tm->tm_mon >= 1) && (tm->tm_mon <= 31))) + + /* + * already have a (numeric) month? then see if we + * can substitute... + */ + if ((fmask & DTK_M(MONTH)) && (!haveTextMonth) + && (!(fmask & DTK_M(DAY))) + && ((tm->tm_mon >= 1) && (tm->tm_mon <= 31))) { tm->tm_mday = tm->tm_mon; tmask = DTK_M(DAY); @@ -2942,7 +2948,11 @@ DecodeDateTime(char **field, int *ftype, int nf, break; case DTZMOD: - /* daylight savings time modifier (solves "MET DST" syntax) */ + + /* + * daylight savings time modifier (solves "MET + * DST" syntax) + */ tmask |= DTK_M(DTZ); tm->tm_isdst = 1; if (tzp == NULL) @@ -3010,7 +3020,7 @@ DecodeDateTime(char **field, int *ftype, int nf, if (tm->tm_year > 0) tm->tm_year = -(tm->tm_year - 1); else - elog(ERROR,"Inconsistant use of year %04d and 'BC'", tm->tm_year); + elog(ERROR, "Inconsistant use of year %04d and 'BC'", tm->tm_year); } else if (is2digits) { @@ -3039,18 +3049,22 @@ DecodeDateTime(char **field, int *ftype, int nf, if ((fmask & DTK_DATE_M) != DTK_DATE_M) return ((fmask & DTK_TIME_M) == DTK_TIME_M) ? 1 : -1; - /* check for valid day of month, now that we know for sure the month and year... */ + /* + * check for valid day of month, now that we know for sure the + * month and year... + */ if ((tm->tm_mday < 1) || (tm->tm_mday > day_tab[isleap(tm->tm_year)][tm->tm_mon - 1])) return -1; /* timezone not specified? then find local timezone if possible */ if (((fmask & DTK_DATE_M) == DTK_DATE_M) - && (tzp != NULL) && (!(fmask & DTK_M(TZ)))) + && (tzp != NULL) && (!(fmask & DTK_M(TZ)))) { + /* - * daylight savings time modifier but no standard timezone? then - * error + * daylight savings time modifier but no standard timezone? + * then error */ if (fmask & DTK_M(DTZMOD)) return -1; @@ -3066,7 +3080,8 @@ DecodeDateTime(char **field, int *ftype, int nf, tm->tm_mon += 1; #if defined(HAVE_TM_ZONE) - *tzp = -(tm->tm_gmtoff); /* tm_gmtoff is Sun/DEC-ism */ + *tzp = -(tm->tm_gmtoff); /* tm_gmtoff is + * Sun/DEC-ism */ #elif defined(HAVE_INT_TIMEZONE) #ifdef __CYGWIN__ *tzp = ((tm->tm_isdst > 0) ? (_timezone - 3600) : _timezone); @@ -3077,7 +3092,7 @@ DecodeDateTime(char **field, int *ftype, int nf, #error USE_POSIX_TIME is defined but neither HAVE_TM_ZONE or HAVE_INT_TIMEZONE are defined #endif -#else /* !USE_POSIX_TIME */ +#else /* !USE_POSIX_TIME */ *tzp = CTimeZone; #endif } @@ -3214,8 +3229,8 @@ DecodeTimeOnly(char **field, int *ftype, int nf, int *dtype, struct tm * tm, dou tm->tm_hour += 12; if (((tm->tm_hour < 0) || (tm->tm_hour > 23)) - || ((tm->tm_min < 0) || (tm->tm_min > 59)) - || ((tm->tm_sec < 0) || ((tm->tm_sec + *fsec) >= 60))) + || ((tm->tm_min < 0) || (tm->tm_min > 59)) + || ((tm->tm_sec < 0) || ((tm->tm_sec + *fsec) >= 60))) return -1; if ((fmask & DTK_TIME_M) != DTK_TIME_M) @@ -3344,7 +3359,7 @@ DecodeDate(char *str, int fmask, int *tmask, struct tm * tm) if (tm->tm_year > 0) tm->tm_year = -(tm->tm_year - 1); else - elog(ERROR,"Inconsistant use of year %04d and 'BC'", tm->tm_year); + elog(ERROR, "Inconsistant use of year %04d and 'BC'", tm->tm_year); } else if (is2digits) { @@ -3449,11 +3464,12 @@ DecodeNumber(int flen, char *str, int fmask, &tm->tm_year, &tm->tm_mon, &tm->tm_mday); } - /* Enough digits to be unequivocal year? - * Used to test for 4 digits or more, - * but we now test first for a three-digit doy - * so anything bigger than two digits had better be - * an explicit year. - thomas 1999-01-09 + + /* + * Enough digits to be unequivocal year? Used to test for 4 digits or + * more, but we now test first for a three-digit doy so anything + * bigger than two digits had better be an explicit year. - thomas + * 1999-01-09 */ else if (flen > 2) { @@ -3464,7 +3480,7 @@ DecodeNumber(int flen, char *str, int fmask, /* already have a year? then see if we can substitute... */ if ((fmask & DTK_M(YEAR)) && (!(fmask & DTK_M(DAY))) - && ((tm->tm_year >= 1) && (tm->tm_year <= 31))) + && ((tm->tm_year >= 1) && (tm->tm_year <= 31))) { tm->tm_mday = tm->tm_year; *tmask = DTK_M(DAY); @@ -3543,7 +3559,7 @@ DecodeNumber(int flen, char *str, int fmask, */ static int DecodeNumberField(int len, char *str, int fmask, - int *tmask, struct tm * tm, double *fsec, int *is2digits) + int *tmask, struct tm * tm, double *fsec, int *is2digits) { char *cp; diff --git a/src/backend/utils/adt/float.c b/src/backend/utils/adt/float.c index 5e4e20d257..5f2a4f1523 100644 --- a/src/backend/utils/adt/float.c +++ b/src/backend/utils/adt/float.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.41 1999/04/20 00:26:32 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.42 1999/05/25 16:12:02 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -955,12 +955,12 @@ i2tof(int16 num) text * float8_text(float64 num) { - text *result; - int len; - char *str; + text *result; + int len; + char *str; str = float8out(num); - len = (strlen(str)+VARHDRSZ); + len = (strlen(str) + VARHDRSZ); result = palloc(len); @@ -978,9 +978,9 @@ float8_text(float64 num) float64 text_float8(text *string) { - float64 result; - int len; - char *str; + float64 result; + int len; + char *str; len = (VARSIZE(string) - VARHDRSZ); str = palloc(len + 1); @@ -1000,12 +1000,12 @@ text_float8(text *string) text * float4_text(float32 num) { - text *result; - int len; - char *str; + text *result; + int len; + char *str; str = float4out(num); - len = (strlen(str)+VARHDRSZ); + len = (strlen(str) + VARHDRSZ); result = palloc(len); @@ -1023,9 +1023,9 @@ float4_text(float32 num) float32 text_float4(text *string) { - float32 result; - int len; - char *str; + float32 result; + int len; + char *str; len = (VARSIZE(string) - VARHDRSZ); str = palloc(len + 1); @@ -1154,7 +1154,8 @@ dpow(float64 arg1, float64 arg2) #endif *result = (float64data) pow(tmp1, tmp2); #ifndef finite - if (errno != 0) /* on some machines both EDOM & ERANGE can occur */ + if (errno != 0) /* on some machines both EDOM & ERANGE can + * occur */ #else if (!finite(*result)) #endif diff --git a/src/backend/utils/adt/inet_net_ntop.c b/src/backend/utils/adt/inet_net_ntop.c index 8c185dc83c..11a0cb9363 100644 --- a/src/backend/utils/adt/inet_net_ntop.c +++ b/src/backend/utils/adt/inet_net_ntop.c @@ -16,7 +16,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static const char rcsid[] = "$Id: inet_net_ntop.c,v 1.5 1999/05/25 05:29:38 momjian Exp $"; +static const char rcsid[] = "$Id: inet_net_ntop.c,v 1.6 1999/05/25 16:12:04 momjian Exp $"; #endif @@ -40,9 +40,9 @@ static const char rcsid[] = "$Id: inet_net_ntop.c,v 1.5 1999/05/25 05:29:38 momj #endif static char *inet_net_ntop_ipv4(const u_char *src, int bits, - char *dst, size_t size); + char *dst, size_t size); static char *inet_cidr_ntop_ipv4(const u_char *src, int bits, - char *dst, size_t size); + char *dst, size_t size); /* * char * @@ -59,7 +59,7 @@ inet_cidr_ntop(int af, const void *src, int bits, char *dst, size_t size) { switch (af) { - case AF_INET: + case AF_INET: return (inet_cidr_ntop_ipv4(src, bits, dst, size)); default: errno = EAFNOSUPPORT; @@ -162,7 +162,7 @@ inet_net_ntop(int af, const void *src, int bits, char *dst, size_t size) { switch (af) { - case AF_INET: + case AF_INET: return (inet_net_ntop_ipv4(src, bits, dst, size)); default: errno = EAFNOSUPPORT; @@ -186,10 +186,11 @@ inet_net_ntop(int af, const void *src, int bits, char *dst, size_t size) static char * inet_net_ntop_ipv4(const u_char *src, int bits, char *dst, size_t size) { - char *odst = dst; - char *t; - size_t len = 4; - int b, tb; + char *odst = dst; + char *t; + size_t len = 4; + int b, + tb; if (bits < 0 || bits > 32) { @@ -218,7 +219,7 @@ inet_net_ntop_ipv4(const u_char *src, int bits, char *dst, size_t size) *dst++ = '.'; *dst = '\0'; } - size -= (size_t)(dst - t); + size -= (size_t) (dst - t); } /* don't print masklen if 32 bits */ @@ -232,7 +233,7 @@ inet_net_ntop_ipv4(const u_char *src, int bits, char *dst, size_t size) return (odst); - emsgsize: +emsgsize: errno = EMSGSIZE; return (NULL); } diff --git a/src/backend/utils/adt/inet_net_pton.c b/src/backend/utils/adt/inet_net_pton.c index ae3036c3ca..bcc9ff681a 100644 --- a/src/backend/utils/adt/inet_net_pton.c +++ b/src/backend/utils/adt/inet_net_pton.c @@ -16,7 +16,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static const char rcsid[] = "$Id: inet_net_pton.c,v 1.7 1999/02/03 21:17:27 momjian Exp $"; +static const char rcsid[] = "$Id: inet_net_pton.c,v 1.8 1999/05/25 16:12:05 momjian Exp $"; #endif @@ -58,8 +58,8 @@ static int inet_cidr_pton_ipv4(const char *src, u_char *dst, size_t size); * Paul Vixie (ISC), June 1996 * * Changes: - * I added the inet_cidr_pton function (also from Paul) and changed - * the names to reflect their current use. + * I added the inet_cidr_pton function (also from Paul) and changed + * the names to reflect their current use. * */ int @@ -67,10 +67,10 @@ inet_net_pton(int af, const char *src, void *dst, size_t size) { switch (af) { - case AF_INET: + case AF_INET: return size == -1 ? - inet_net_pton_ipv4(src, dst) : - inet_cidr_pton_ipv4(src, dst, size); + inet_net_pton_ipv4(src, dst) : + inet_cidr_pton_ipv4(src, dst, size); default: errno = EAFNOSUPPORT; return (-1); @@ -108,14 +108,16 @@ inet_cidr_pton_ipv4(const char *src, u_char *dst, size_t size) ch = *src++; if (ch == '0' && (src[0] == 'x' || src[0] == 'X') - && isascii(src[1]) && isxdigit(src[1])) { + && isascii(src[1]) && isxdigit(src[1])) + { /* Hexadecimal: Eat nybble string. */ if (size <= 0) goto emsgsize; dirty = 0; tmp = 0; - src++; /* skip x or X. */ - while ((ch = *src++) != '\0' && isascii(ch) && isxdigit(ch)) { + src++; /* skip x or X. */ + while ((ch = *src++) != '\0' && isascii(ch) && isxdigit(ch)) + { if (isupper(ch)) ch = tolower(ch); n = strchr(xdigits, ch) - xdigits; @@ -124,14 +126,16 @@ inet_cidr_pton_ipv4(const char *src, u_char *dst, size_t size) tmp = n; else tmp = (tmp << 4) | n; - if (++dirty == 2) { + if (++dirty == 2) + { if (size-- <= 0) goto emsgsize; *dst++ = (u_char) tmp; dirty = 0; } } - if (dirty) { /* Odd trailing nybble? */ + if (dirty) + { /* Odd trailing nybble? */ if (size-- <= 0) goto emsgsize; *dst++ = (u_char) (tmp << 4); @@ -234,27 +238,30 @@ emsgsize: /* * int * inet_net_pton(af, src, dst, *bits) - * convert network address from presentation to network format. - * accepts inet_pton()'s input for this "af" plus trailing "/CIDR". - * "dst" is assumed large enough for its "af". "bits" is set to the - * /CIDR prefix length, which can have defaults (like /32 for IPv4). + * convert network address from presentation to network format. + * accepts inet_pton()'s input for this "af" plus trailing "/CIDR". + * "dst" is assumed large enough for its "af". "bits" is set to the + * /CIDR prefix length, which can have defaults (like /32 for IPv4). * return: - * -1 if an error occurred (inspect errno; ENOENT means bad format). - * 0 if successful conversion occurred. - * note: - * 192.5.5.1/28 has a nonzero host part, which means it isn't a network - * as called for by inet_cidr_pton() but it can be a host address with - * an included netmask. + * -1 if an error occurred (inspect errno; ENOENT means bad format). + * 0 if successful conversion occurred. + * note: + * 192.5.5.1/28 has a nonzero host part, which means it isn't a network + * as called for by inet_cidr_pton() but it can be a host address with + * an included netmask. * author: - * Paul Vixie (ISC), October 1998 + * Paul Vixie (ISC), October 1998 */ static int inet_net_pton_ipv4(const char *src, u_char *dst) { static const char digits[] = "0123456789"; const u_char *odst = dst; - int n, ch, tmp, bits; - size_t size = 4; + int n, + ch, + tmp, + bits; + size_t size = 4; /* Get the mantissa. */ while (ch = *src++, (isascii(ch) && isdigit(ch))) @@ -283,7 +290,7 @@ inet_net_pton_ipv4(const char *src, u_char *dst) if (ch == '/' && isascii(src[0]) && isdigit(src[0]) && dst > odst) { /* CIDR width specifier. Nothing can follow it. */ - ch = *src++; /* Skip over the /. */ + ch = *src++; /* Skip over the /. */ bits = 0; do { @@ -325,11 +332,11 @@ inet_net_pton_ipv4(const char *src, u_char *dst) return bits; - enoent: +enoent: errno = ENOENT; return (-1); - emsgsize: +emsgsize: errno = EMSGSIZE; return (-1); } diff --git a/src/backend/utils/adt/int8.c b/src/backend/utils/adt/int8.c index 11363ba645..289aed674b 100644 --- a/src/backend/utils/adt/int8.c +++ b/src/backend/utils/adt/int8.c @@ -44,21 +44,22 @@ int8in(char *str) if (!PointerIsValid(str)) elog(ERROR, "Bad (null) int8 external representation", NULL); - /* Do our own scan, rather than relying on sscanf which might be + /* + * Do our own scan, rather than relying on sscanf which might be * broken for long long. NOTE: this will not detect int64 overflow... * but sscanf doesn't either... */ - while (*ptr && isspace(*ptr)) /* skip leading spaces */ + while (*ptr && isspace(*ptr)) /* skip leading spaces */ ptr++; - if (*ptr == '-') /* handle sign */ + if (*ptr == '-') /* handle sign */ sign = -1, ptr++; else if (*ptr == '+') ptr++; - if (! isdigit(*ptr)) /* require at least one digit */ + if (!isdigit(*ptr)) /* require at least one digit */ elog(ERROR, "Bad int8 external representation '%s'", str); - while (*ptr && isdigit(*ptr)) /* process digits */ + while (*ptr && isdigit(*ptr)) /* process digits */ tmp = tmp * 10 + (*ptr++ - '0'); - if (*ptr) /* trailing junk? */ + if (*ptr) /* trailing junk? */ elog(ERROR, "Bad int8 external representation '%s'", str); *result = (sign < 0) ? -tmp : tmp; @@ -70,7 +71,7 @@ int8in(char *str) /* int8out() */ char * -int8out(int64 *val) +int8out(int64 * val) { char *result; @@ -99,37 +100,37 @@ int8out(int64 *val) * Is val1 relop val2? */ bool -int8eq(int64 *val1, int64 *val2) +int8eq(int64 * val1, int64 * val2) { return *val1 == *val2; } /* int8eq() */ bool -int8ne(int64 *val1, int64 *val2) +int8ne(int64 * val1, int64 * val2) { return *val1 != *val2; } /* int8ne() */ bool -int8lt(int64 *val1, int64 *val2) +int8lt(int64 * val1, int64 * val2) { return *val1 < *val2; } /* int8lt() */ bool -int8gt(int64 *val1, int64 *val2) +int8gt(int64 * val1, int64 * val2) { return *val1 > *val2; } /* int8gt() */ bool -int8le(int64 *val1, int64 *val2) +int8le(int64 * val1, int64 * val2) { return *val1 <= *val2; } /* int8le() */ bool -int8ge(int64 *val1, int64 *val2) +int8ge(int64 * val1, int64 * val2) { return *val1 >= *val2; } /* int8ge() */ @@ -139,37 +140,37 @@ int8ge(int64 *val1, int64 *val2) * Is 64-bit val1 relop 32-bit val2? */ bool -int84eq(int64 *val1, int32 val2) +int84eq(int64 * val1, int32 val2) { return *val1 == val2; } /* int84eq() */ bool -int84ne(int64 *val1, int32 val2) +int84ne(int64 * val1, int32 val2) { return *val1 != val2; } /* int84ne() */ bool -int84lt(int64 *val1, int32 val2) +int84lt(int64 * val1, int32 val2) { return *val1 < val2; } /* int84lt() */ bool -int84gt(int64 *val1, int32 val2) +int84gt(int64 * val1, int32 val2) { return *val1 > val2; } /* int84gt() */ bool -int84le(int64 *val1, int32 val2) +int84le(int64 * val1, int32 val2) { return *val1 <= val2; } /* int84le() */ bool -int84ge(int64 *val1, int32 val2) +int84ge(int64 * val1, int32 val2) { return *val1 >= val2; } /* int84ge() */ @@ -179,37 +180,37 @@ int84ge(int64 *val1, int32 val2) * Is 32-bit val1 relop 64-bit val2? */ bool -int48eq(int32 val1, int64 *val2) +int48eq(int32 val1, int64 * val2) { return val1 == *val2; } /* int48eq() */ bool -int48ne(int32 val1, int64 *val2) +int48ne(int32 val1, int64 * val2) { return val1 != *val2; } /* int48ne() */ bool -int48lt(int32 val1, int64 *val2) +int48lt(int32 val1, int64 * val2) { return val1 < *val2; } /* int48lt() */ bool -int48gt(int32 val1, int64 *val2) +int48gt(int32 val1, int64 * val2) { return val1 > *val2; } /* int48gt() */ bool -int48le(int32 val1, int64 *val2) +int48le(int32 val1, int64 * val2) { return val1 <= *val2; } /* int48le() */ bool -int48ge(int32 val1, int64 *val2) +int48ge(int32 val1, int64 * val2) { return val1 >= *val2; } /* int48ge() */ @@ -220,7 +221,7 @@ int48ge(int32 val1, int64 *val2) *---------------------------------------------------------*/ int64 * -int8um(int64 *val) +int8um(int64 * val) { int64 temp = 0; int64 *result = palloc(sizeof(int64)); @@ -235,7 +236,7 @@ int8um(int64 *val) int64 * -int8pl(int64 *val1, int64 *val2) +int8pl(int64 * val1, int64 * val2) { int64 *result = palloc(sizeof(int64)); @@ -248,7 +249,7 @@ int8pl(int64 *val1, int64 *val2) } /* int8pl() */ int64 * -int8mi(int64 *val1, int64 *val2) +int8mi(int64 * val1, int64 * val2) { int64 *result = palloc(sizeof(int64)); @@ -261,7 +262,7 @@ int8mi(int64 *val1, int64 *val2) } /* int8mi() */ int64 * -int8mul(int64 *val1, int64 *val2) +int8mul(int64 * val1, int64 * val2) { int64 *result = palloc(sizeof(int64)); @@ -274,7 +275,7 @@ int8mul(int64 *val1, int64 *val2) } /* int8mul() */ int64 * -int8div(int64 *val1, int64 *val2) +int8div(int64 * val1, int64 * val2) { int64 *result = palloc(sizeof(int64)); @@ -287,7 +288,7 @@ int8div(int64 *val1, int64 *val2) } /* int8div() */ int64 * -int8larger(int64 *val1, int64 *val2) +int8larger(int64 * val1, int64 * val2) { int64 *result = palloc(sizeof(int64)); @@ -300,7 +301,7 @@ int8larger(int64 *val1, int64 *val2) } /* int8larger() */ int64 * -int8smaller(int64 *val1, int64 *val2) +int8smaller(int64 * val1, int64 * val2) { int64 *result = palloc(sizeof(int64)); @@ -314,7 +315,7 @@ int8smaller(int64 *val1, int64 *val2) int64 * -int84pl(int64 *val1, int32 val2) +int84pl(int64 * val1, int32 val2) { int64 *result = palloc(sizeof(int64)); @@ -327,7 +328,7 @@ int84pl(int64 *val1, int32 val2) } /* int84pl() */ int64 * -int84mi(int64 *val1, int32 val2) +int84mi(int64 * val1, int32 val2) { int64 *result = palloc(sizeof(int64)); @@ -340,7 +341,7 @@ int84mi(int64 *val1, int32 val2) } /* int84mi() */ int64 * -int84mul(int64 *val1, int32 val2) +int84mul(int64 * val1, int32 val2) { int64 *result = palloc(sizeof(int64)); @@ -353,7 +354,7 @@ int84mul(int64 *val1, int32 val2) } /* int84mul() */ int64 * -int84div(int64 *val1, int32 val2) +int84div(int64 * val1, int32 val2) { int64 *result = palloc(sizeof(int64)); @@ -367,7 +368,7 @@ int84div(int64 *val1, int32 val2) int64 * -int48pl(int32 val1, int64 *val2) +int48pl(int32 val1, int64 * val2) { int64 *result = palloc(sizeof(int64)); @@ -380,7 +381,7 @@ int48pl(int32 val1, int64 *val2) } /* int48pl() */ int64 * -int48mi(int32 val1, int64 *val2) +int48mi(int32 val1, int64 * val2) { int64 *result = palloc(sizeof(int64)); @@ -393,7 +394,7 @@ int48mi(int32 val1, int64 *val2) } /* int48mi() */ int64 * -int48mul(int32 val1, int64 *val2) +int48mul(int32 val1, int64 * val2) { int64 *result = palloc(sizeof(int64)); @@ -406,7 +407,7 @@ int48mul(int32 val1, int64 *val2) } /* int48mul() */ int64 * -int48div(int32 val1, int64 *val2) +int48div(int32 val1, int64 * val2) { int64 *result = palloc(sizeof(int64)); @@ -434,7 +435,7 @@ int48(int32 val) } /* int48() */ int32 -int84(int64 *val) +int84(int64 * val) { int32 result; @@ -442,6 +443,7 @@ int84(int64 *val) elog(ERROR, "Invalid (null) int64, can't convert int8 to int4", NULL); #if NOT_USED + /* * Hmm. This conditional always tests true on my i686/linux box. It's * a gcc compiler bug, or I'm missing something obvious, which is more @@ -449,8 +451,8 @@ int84(int64 *val) */ if ((*val < INT_MIN) || (*val > INT_MAX)) #endif - if ((*val < (-pow(2, 31) + 1)) || (*val > (pow(2, 31) - 1))) - elog(ERROR, "int8 conversion to int4 is out of range", NULL); + if ((*val < (-pow(2, 31) + 1)) || (*val > (pow(2, 31) - 1))) + elog(ERROR, "int8 conversion to int4 is out of range", NULL); result = *val; @@ -471,7 +473,7 @@ int28 (int16 val) } /* int28() */ int16 -int82(int64 *val) +int82(int64 * val) { int16 result; @@ -489,7 +491,7 @@ int82(int64 *val) #endif float64 -i8tod(int64 *val) +i8tod(int64 * val) { float64 result = palloc(sizeof(float64data)); @@ -533,9 +535,9 @@ text_int8(text *str) elog(ERROR, "Bad (null) int8 external representation", NULL); len = (VARSIZE(str) - VARHDRSZ); - s = palloc(len+1); + s = palloc(len + 1); memmove(s, VARDATA(str), len); - *(s+len) = '\0'; + *(s + len) = '\0'; return int8in(s); } /* text_int8() */ @@ -544,7 +546,7 @@ text_int8(text *str) /* int8_text() */ text * -int8_text(int64 *val) +int8_text(int64 * val) { text *result; @@ -564,4 +566,3 @@ int8_text(int64 *val) return result; } /* int8out() */ - diff --git a/src/backend/utils/adt/like.c b/src/backend/utils/adt/like.c index 6057fa2f15..14fc5314d0 100644 --- a/src/backend/utils/adt/like.c +++ b/src/backend/utils/adt/like.c @@ -23,7 +23,7 @@ #include "utils/builtins.h" /* where the function declarations go */ #include "mb/pg_wchar.h" -static int like(pg_wchar *text, pg_wchar *p); +static int like(pg_wchar * text, pg_wchar * p); /* * interface routines called by the function manager @@ -38,7 +38,7 @@ static int like(pg_wchar *text, pg_wchar *p); charlen - the length of the string */ static bool -fixedlen_like(char *s, struct varlena *p, int charlen) +fixedlen_like(char *s, struct varlena * p, int charlen) { pg_wchar *sterm, *pterm; @@ -83,7 +83,7 @@ fixedlen_like(char *s, struct varlena *p, int charlen) } bool -namelike(NameData *n, struct varlena *p) +namelike(NameData *n, struct varlena * p) { if (!n) return FALSE; @@ -91,13 +91,13 @@ namelike(NameData *n, struct varlena *p) } bool -namenlike(NameData *s, struct varlena *p) +namenlike(NameData *s, struct varlena * p) { return !namelike(s, p); } bool -textlike(struct varlena *s, struct varlena *p) +textlike(struct varlena * s, struct varlena * p) { if (!s) return FALSE; @@ -105,13 +105,13 @@ textlike(struct varlena *s, struct varlena *p) } bool -textnlike(struct varlena *s, struct varlena *p) +textnlike(struct varlena * s, struct varlena * p) { return !textlike(s, p); } -/* $Revision: 1.23 $ +/* $Revision: 1.24 $ ** "like.c" A first attempt at a LIKE operator for Postgres95. ** ** Originally written by Rich $alz, mirror!rs, Wed Nov 26 19:03:17 EST 1986. @@ -146,11 +146,11 @@ textnlike(struct varlena *s, struct varlena *p) ** Match text and p, return LIKE_TRUE, LIKE_FALSE, or LIKE_ABORT. */ static int -DoMatch(pg_wchar *text, pg_wchar *p) +DoMatch(pg_wchar * text, pg_wchar * p) { int matched; - for (; *p && *text; text++, p++) + for (; *p && *text; text ++, p++) { switch (*p) { @@ -159,7 +159,7 @@ DoMatch(pg_wchar *text, pg_wchar *p) p++; /* FALLTHROUGH */ default: - if (*text != *p) + if (*text !=*p) return LIKE_FALSE; break; case '_': @@ -177,16 +177,16 @@ DoMatch(pg_wchar *text, pg_wchar *p) { /* Optimization to prevent most recursion */ if ((*text == *p || - *p == '\\' || *p == '%' || *p == '_') && + *p == '\\' || *p == '%' || *p == '_') && (matched = DoMatch(text, p)) != LIKE_FALSE) return matched; - text++; + text ++; } return LIKE_ABORT; } } - if (*text != '\0') + if (*text !='\0') return LIKE_ABORT; else { @@ -203,7 +203,7 @@ DoMatch(pg_wchar *text, pg_wchar *p) ** User-level routine. Returns TRUE or FALSE. */ static int -like(pg_wchar *text, pg_wchar *p) +like(pg_wchar * text, pg_wchar * p) { if (p[0] == '%' && p[1] == '\0') return TRUE; diff --git a/src/backend/utils/adt/mac.c b/src/backend/utils/adt/mac.c index 957292af8e..48dd19db94 100644 --- a/src/backend/utils/adt/mac.c +++ b/src/backend/utils/adt/mac.c @@ -1,7 +1,7 @@ /* * PostgreSQL type definitions for MAC addresses. * - * $Id: mac.c,v 1.7 1999/03/22 05:00:57 momjian Exp $ + * $Id: mac.c,v 1.8 1999/05/25 16:12:08 momjian Exp $ */ #include @@ -13,119 +13,119 @@ #include manufacturer manufacturers[] = { - {0x00, 0x00, 0x0C, "Cisco"}, - {0x00, 0x00, 0x0E, "Fujitsu"}, - {0x00, 0x00, 0x0F, "NeXT"}, - {0x00, 0x00, 0x10, "Sytek"}, - {0x00, 0x00, 0x1D, "Cabletron"}, - {0x00, 0x00, 0x20, "DIAB"}, - {0x00, 0x00, 0x22, "Visual Technology"}, - {0x00, 0x00, 0x2A, "TRW"}, - {0x00, 0x00, 0x32, "GPT Limited"}, - {0x00, 0x00, 0x5A, "S & Koch"}, - {0x00, 0x00, 0x5E, "IANA"}, - {0x00, 0x00, 0x65, "Network General"}, - {0x00, 0x00, 0x6B, "MIPS"}, - {0x00, 0x00, 0x77, "MIPS"}, - {0x00, 0x00, 0x7A, "Ardent"}, - {0x00, 0x00, 0x89, "Cayman Systems"}, - {0x00, 0x00, 0x93, "Proteon"}, - {0x00, 0x00, 0x9F, "Ameristar Technology"}, - {0x00, 0x00, 0xA2, "Wellfleet"}, - {0x00, 0x00, 0xA3, "Network Application Technology"}, - {0x00, 0x00, 0xA6, "Network General"}, - {0x00, 0x00, 0xA7, "NCD"}, - {0x00, 0x00, 0xA9, "Network Systems"}, - {0x00, 0x00, 0xAA, "Xerox"}, - {0x00, 0x00, 0xB3, "CIMLinc"}, - {0x00, 0x00, 0xB7, "Dove Fastnet"}, - {0x00, 0x00, 0xBC, "Allen-Bradley"}, - {0x00, 0x00, 0xC0, "Western Digital"}, - {0x00, 0x00, 0xC5, "Farallon"}, - {0x00, 0x00, 0xC6, "Hewlett-Packard"}, - {0x00, 0x00, 0xC8, "Altos"}, - {0x00, 0x00, 0xC9, "Emulex"}, - {0x00, 0x00, 0xD7, "Dartmouth College"}, - {0x00, 0x00, 0xD8, "3Com (?)"}, - {0x00, 0x00, 0xDD, "Gould"}, - {0x00, 0x00, 0xDE, "Unigraph"}, - {0x00, 0x00, 0xE2, "Acer Counterpoint"}, - {0x00, 0x00, 0xEF, "Alantec"}, - {0x00, 0x00, 0xFD, "High Level Hardware"}, - {0x00, 0x01, 0x02, "BBN internal usage"}, - {0x00, 0x20, 0xAF, "3Com"}, - {0x00, 0x17, 0x00, "Kabel"}, - {0x00, 0x80, 0x64, "Wyse Technology"}, - {0x00, 0x80, 0x2B, "IMAC (?)"}, - {0x00, 0x80, 0x2D, "Xylogics, Inc."}, - {0x00, 0x80, 0x8C, "Frontier Software Development"}, - {0x00, 0x80, 0xC2, "IEEE 802.1 Committee"}, - {0x00, 0x80, 0xD3, "Shiva"}, - {0x00, 0xAA, 0x00, "Intel"}, - {0x00, 0xDD, 0x00, "Ungermann-Bass"}, - {0x00, 0xDD, 0x01, "Ungermann-Bass"}, - {0x02, 0x07, 0x01, "Racal InterLan"}, - {0x02, 0x04, 0x06, "BBN internal usage"}, - {0x02, 0x60, 0x86, "Satelcom MegaPac"}, - {0x02, 0x60, 0x8C, "3Com"}, - {0x02, 0xCF, 0x1F, "CMC"}, - {0x08, 0x00, 0x02, "3Com"}, - {0x08, 0x00, 0x03, "ACC"}, - {0x08, 0x00, 0x05, "Symbolics"}, - {0x08, 0x00, 0x08, "BBN"}, - {0x08, 0x00, 0x09, "Hewlett-Packard"}, - {0x08, 0x00, 0x0A, "Nestar Systems"}, - {0x08, 0x00, 0x0B, "Unisys"}, - {0x08, 0x00, 0x11, "Tektronix"}, - {0x08, 0x00, 0x14, "Excelan"}, - {0x08, 0x00, 0x17, "NSC"}, - {0x08, 0x00, 0x1A, "Data General"}, - {0x08, 0x00, 0x1B, "Data General"}, - {0x08, 0x00, 0x1E, "Apollo"}, - {0x08, 0x00, 0x20, "Sun"}, - {0x08, 0x00, 0x22, "NBI"}, - {0x08, 0x00, 0x25, "CDC"}, - {0x08, 0x00, 0x26, "Norsk Data"}, - {0x08, 0x00, 0x27, "PCS Computer Systems GmbH"}, - {0x08, 0x00, 0x28, "Texas Instruments"}, - {0x08, 0x00, 0x2B, "DEC"}, - {0x08, 0x00, 0x2E, "Metaphor"}, - {0x08, 0x00, 0x2F, "Prime Computer"}, - {0x08, 0x00, 0x36, "Intergraph"}, - {0x08, 0x00, 0x37, "Fujitsu-Xerox"}, - {0x08, 0x00, 0x38, "Bull"}, - {0x08, 0x00, 0x39, "Spider Systems"}, - {0x08, 0x00, 0x41, "DCA Digital Comm. Assoc."}, - {0x08, 0x00, 0x45, "Xylogics (?)"}, - {0x08, 0x00, 0x46, "Sony"}, - {0x08, 0x00, 0x47, "Sequent"}, - {0x08, 0x00, 0x49, "Univation"}, - {0x08, 0x00, 0x4C, "Encore"}, - {0x08, 0x00, 0x4E, "BICC"}, - {0x08, 0x00, 0x56, "Stanford University"}, - {0x08, 0x00, 0x58, "DECsystem 20 (?)"}, - {0x08, 0x00, 0x5A, "IBM"}, - {0x08, 0x00, 0x67, "Comdesign"}, - {0x08, 0x00, 0x68, "Ridge"}, - {0x08, 0x00, 0x69, "Silicon Graphics"}, - {0x08, 0x00, 0x6E, "Concurrent"}, - {0x08, 0x00, 0x75, "DDE"}, - {0x08, 0x00, 0x7C, "Vitalink"}, - {0x08, 0x00, 0x80, "XIOS"}, - {0x08, 0x00, 0x86, "Imagen/QMS"}, - {0x08, 0x00, 0x87, "Xyplex"}, - {0x08, 0x00, 0x89, "Kinetics"}, - {0x08, 0x00, 0x8B, "Pyramid"}, - {0x08, 0x00, 0x8D, "XyVision"}, - {0x08, 0x00, 0x90, "Retix Inc"}, - {0x48, 0x44, 0x53, "HDS (?)"}, - {0x80, 0x00, 0x10, "AT&T"}, - {0xAA, 0x00, 0x00, "DEC"}, - {0xAA, 0x00, 0x01, "DEC"}, - {0xAA, 0x00, 0x02, "DEC"}, - {0xAA, 0x00, 0x03, "DEC"}, - {0xAA, 0x00, 0x04, "DEC"}, - {0x00, 0x00, 0x00, NULL} + {0x00, 0x00, 0x0C, "Cisco"}, + {0x00, 0x00, 0x0E, "Fujitsu"}, + {0x00, 0x00, 0x0F, "NeXT"}, + {0x00, 0x00, 0x10, "Sytek"}, + {0x00, 0x00, 0x1D, "Cabletron"}, + {0x00, 0x00, 0x20, "DIAB"}, + {0x00, 0x00, 0x22, "Visual Technology"}, + {0x00, 0x00, 0x2A, "TRW"}, + {0x00, 0x00, 0x32, "GPT Limited"}, + {0x00, 0x00, 0x5A, "S & Koch"}, + {0x00, 0x00, 0x5E, "IANA"}, + {0x00, 0x00, 0x65, "Network General"}, + {0x00, 0x00, 0x6B, "MIPS"}, + {0x00, 0x00, 0x77, "MIPS"}, + {0x00, 0x00, 0x7A, "Ardent"}, + {0x00, 0x00, 0x89, "Cayman Systems"}, + {0x00, 0x00, 0x93, "Proteon"}, + {0x00, 0x00, 0x9F, "Ameristar Technology"}, + {0x00, 0x00, 0xA2, "Wellfleet"}, + {0x00, 0x00, 0xA3, "Network Application Technology"}, + {0x00, 0x00, 0xA6, "Network General"}, + {0x00, 0x00, 0xA7, "NCD"}, + {0x00, 0x00, 0xA9, "Network Systems"}, + {0x00, 0x00, 0xAA, "Xerox"}, + {0x00, 0x00, 0xB3, "CIMLinc"}, + {0x00, 0x00, 0xB7, "Dove Fastnet"}, + {0x00, 0x00, 0xBC, "Allen-Bradley"}, + {0x00, 0x00, 0xC0, "Western Digital"}, + {0x00, 0x00, 0xC5, "Farallon"}, + {0x00, 0x00, 0xC6, "Hewlett-Packard"}, + {0x00, 0x00, 0xC8, "Altos"}, + {0x00, 0x00, 0xC9, "Emulex"}, + {0x00, 0x00, 0xD7, "Dartmouth College"}, + {0x00, 0x00, 0xD8, "3Com (?)"}, + {0x00, 0x00, 0xDD, "Gould"}, + {0x00, 0x00, 0xDE, "Unigraph"}, + {0x00, 0x00, 0xE2, "Acer Counterpoint"}, + {0x00, 0x00, 0xEF, "Alantec"}, + {0x00, 0x00, 0xFD, "High Level Hardware"}, + {0x00, 0x01, 0x02, "BBN internal usage"}, + {0x00, 0x20, 0xAF, "3Com"}, + {0x00, 0x17, 0x00, "Kabel"}, + {0x00, 0x80, 0x64, "Wyse Technology"}, + {0x00, 0x80, 0x2B, "IMAC (?)"}, + {0x00, 0x80, 0x2D, "Xylogics, Inc."}, + {0x00, 0x80, 0x8C, "Frontier Software Development"}, + {0x00, 0x80, 0xC2, "IEEE 802.1 Committee"}, + {0x00, 0x80, 0xD3, "Shiva"}, + {0x00, 0xAA, 0x00, "Intel"}, + {0x00, 0xDD, 0x00, "Ungermann-Bass"}, + {0x00, 0xDD, 0x01, "Ungermann-Bass"}, + {0x02, 0x07, 0x01, "Racal InterLan"}, + {0x02, 0x04, 0x06, "BBN internal usage"}, + {0x02, 0x60, 0x86, "Satelcom MegaPac"}, + {0x02, 0x60, 0x8C, "3Com"}, + {0x02, 0xCF, 0x1F, "CMC"}, + {0x08, 0x00, 0x02, "3Com"}, + {0x08, 0x00, 0x03, "ACC"}, + {0x08, 0x00, 0x05, "Symbolics"}, + {0x08, 0x00, 0x08, "BBN"}, + {0x08, 0x00, 0x09, "Hewlett-Packard"}, + {0x08, 0x00, 0x0A, "Nestar Systems"}, + {0x08, 0x00, 0x0B, "Unisys"}, + {0x08, 0x00, 0x11, "Tektronix"}, + {0x08, 0x00, 0x14, "Excelan"}, + {0x08, 0x00, 0x17, "NSC"}, + {0x08, 0x00, 0x1A, "Data General"}, + {0x08, 0x00, 0x1B, "Data General"}, + {0x08, 0x00, 0x1E, "Apollo"}, + {0x08, 0x00, 0x20, "Sun"}, + {0x08, 0x00, 0x22, "NBI"}, + {0x08, 0x00, 0x25, "CDC"}, + {0x08, 0x00, 0x26, "Norsk Data"}, + {0x08, 0x00, 0x27, "PCS Computer Systems GmbH"}, + {0x08, 0x00, 0x28, "Texas Instruments"}, + {0x08, 0x00, 0x2B, "DEC"}, + {0x08, 0x00, 0x2E, "Metaphor"}, + {0x08, 0x00, 0x2F, "Prime Computer"}, + {0x08, 0x00, 0x36, "Intergraph"}, + {0x08, 0x00, 0x37, "Fujitsu-Xerox"}, + {0x08, 0x00, 0x38, "Bull"}, + {0x08, 0x00, 0x39, "Spider Systems"}, + {0x08, 0x00, 0x41, "DCA Digital Comm. Assoc."}, + {0x08, 0x00, 0x45, "Xylogics (?)"}, + {0x08, 0x00, 0x46, "Sony"}, + {0x08, 0x00, 0x47, "Sequent"}, + {0x08, 0x00, 0x49, "Univation"}, + {0x08, 0x00, 0x4C, "Encore"}, + {0x08, 0x00, 0x4E, "BICC"}, + {0x08, 0x00, 0x56, "Stanford University"}, + {0x08, 0x00, 0x58, "DECsystem 20 (?)"}, + {0x08, 0x00, 0x5A, "IBM"}, + {0x08, 0x00, 0x67, "Comdesign"}, + {0x08, 0x00, 0x68, "Ridge"}, + {0x08, 0x00, 0x69, "Silicon Graphics"}, + {0x08, 0x00, 0x6E, "Concurrent"}, + {0x08, 0x00, 0x75, "DDE"}, + {0x08, 0x00, 0x7C, "Vitalink"}, + {0x08, 0x00, 0x80, "XIOS"}, + {0x08, 0x00, 0x86, "Imagen/QMS"}, + {0x08, 0x00, 0x87, "Xyplex"}, + {0x08, 0x00, 0x89, "Kinetics"}, + {0x08, 0x00, 0x8B, "Pyramid"}, + {0x08, 0x00, 0x8D, "XyVision"}, + {0x08, 0x00, 0x90, "Retix Inc"}, + {0x48, 0x44, 0x53, "HDS (?)"}, + {0x80, 0x00, 0x10, "AT&T"}, + {0xAA, 0x00, 0x00, "DEC"}, + {0xAA, 0x00, 0x01, "DEC"}, + {0xAA, 0x00, 0x02, "DEC"}, + {0xAA, 0x00, 0x03, "DEC"}, + {0xAA, 0x00, 0x04, "DEC"}, + {0x00, 0x00, 0x00, NULL} }; /* diff --git a/src/backend/utils/adt/nabstime.c b/src/backend/utils/adt/nabstime.c index 11f7081942..dbbc54c3f8 100644 --- a/src/backend/utils/adt/nabstime.c +++ b/src/backend/utils/adt/nabstime.c @@ -4,7 +4,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: nabstime.c,v 1.54 1999/04/26 04:42:49 ishii Exp $ + * $Id: nabstime.c,v 1.55 1999/05/25 16:12:09 momjian Exp $ * */ #include @@ -64,13 +64,18 @@ GetCurrentAbsoluteTime(void) CDayLight = (tm->tm_isdst > 0); #ifdef NOT_USED + /* * XXX is there a better way to get local timezone string w/o * tzname? - tgl 97/03/18 */ strftime(CTZName, MAXTZLEN, "%Z", tm); #endif - /* XXX FreeBSD man pages indicate that this should work - thomas 1998-12-12 */ + + /* + * XXX FreeBSD man pages indicate that this should work - thomas + * 1998-12-12 + */ strcpy(CTZName, tm->tm_zone); #elif defined(HAVE_INT_TIMEZONE) @@ -79,10 +84,10 @@ GetCurrentAbsoluteTime(void) CDayLight = tm->tm_isdst; CTimeZone = #ifdef __CYGWIN32__ - (tm->tm_isdst ? (_timezone - 3600) : _timezone); + (tm->tm_isdst ? (_timezone - 3600) : _timezone); #else - (tm->tm_isdst ? (timezone - 3600) : timezone); -#endif + (tm->tm_isdst ? (timezone - 3600) : timezone); +#endif strcpy(CTZName, tzname[tm->tm_isdst]); #else #error USE_POSIX_TIME defined but no time zone available @@ -91,8 +96,9 @@ GetCurrentAbsoluteTime(void) CTimeZone = tb.timezone * 60; CDayLight = (tb.dstflag != 0); - /* XXX does this work to get the local timezone string in V7? - * - tgl 97/03/18 + /* + * XXX does this work to get the local timezone string in V7? - + * tgl 97/03/18 */ strftime(CTZName, MAXTZLEN, "%Z", localtime(&now)); #endif @@ -389,6 +395,7 @@ AbsoluteTimeIsAfter(AbsoluteTime time1, AbsoluteTime time2) return time1 > time2; } + #endif /* abstime_finite() diff --git a/src/backend/utils/adt/name.c b/src/backend/utils/adt/name.c index d49eb9cb23..1780df2c42 100644 --- a/src/backend/utils/adt/name.c +++ b/src/backend/utils/adt/name.c @@ -11,7 +11,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/name.c,v 1.17 1999/02/13 23:19:25 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/name.c,v 1.18 1999/05/25 16:12:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -161,6 +161,7 @@ namecmp(Name n1, Name n2) { return strncmp(n1->data, n2->data, NAMEDATALEN); } + #endif int diff --git a/src/backend/utils/adt/network.c b/src/backend/utils/adt/network.c index 12f28ccce7..cd86ec6f3d 100644 --- a/src/backend/utils/adt/network.c +++ b/src/backend/utils/adt/network.c @@ -3,7 +3,7 @@ * is for IP V4 CIDR notation, but prepared for V6: just * add the necessary bits where the comments indicate. * - * $Id: network.c,v 1.8 1999/04/15 02:20:50 thomas Exp $ + * $Id: network.c,v 1.9 1999/05/25 16:12:11 momjian Exp $ * Jon Postel RIP 16 Oct 1998 */ @@ -52,7 +52,7 @@ network_in(char *src, int type) if (!src) return NULL; - + dst = palloc(VARHDRSZ + sizeof(inet_struct)); if (dst == NULL) elog(ERROR, "unable to allocate memory in network_in()"); @@ -60,7 +60,7 @@ network_in(char *src, int type) /* First, try for an IP V4 address: */ ip_family(dst) = AF_INET; bits = inet_net_pton(ip_family(dst), src, &ip_v4addr(dst), - type ? ip_addrsize(dst) : -1); + type ? ip_addrsize(dst) : -1); if ((bits < 0) || (bits > 32)) /* Go for an IPV6 address here, before faulting out: */ elog(ERROR, "could not parse \"%s\"", src); @@ -102,10 +102,10 @@ inet_out(inet *src) /* It's an IP V4 address: */ if (ip_type(src)) dst = inet_cidr_ntop(AF_INET, &ip_v4addr(src), ip_bits(src), - tmp, sizeof(tmp)); + tmp, sizeof(tmp)); else dst = inet_net_ntop(AF_INET, &ip_v4addr(src), ip_bits(src), - tmp, sizeof(tmp)); + tmp, sizeof(tmp)); if (dst == NULL) elog(ERROR, "unable to print address (%s)", strerror(errno)); @@ -222,7 +222,7 @@ network_sub(inet *a1, inet *a2) { if (!PointerIsValid(a1) || !PointerIsValid(a2)) return FALSE; - + if ((ip_family(a1) == AF_INET) && (ip_family(a2) == AF_INET)) { return ((ip_bits(a1) > ip_bits(a2)) @@ -370,7 +370,7 @@ network_broadcast(inet *ip) if (ip_family(ip) == AF_INET) { /* It's an IP V4 address: */ - int addr; + int addr; unsigned long mask = 0xffffffff; if (ip_bits(ip) < 32) @@ -402,7 +402,7 @@ network_network(inet *ip) { text *ret; int len; - char tmp[sizeof("255.255.255.255/32")]; + char tmp[sizeof("255.255.255.255/32")]; if (!PointerIsValid(ip)) return NULL; @@ -410,8 +410,8 @@ network_network(inet *ip) if (ip_family(ip) == AF_INET) { /* It's an IP V4 address: */ - int addr = htonl(ntohl(ip_v4addr(ip)) & (0xffffffff << (32 - ip_bits(ip)))); - + int addr = htonl(ntohl(ip_v4addr(ip)) & (0xffffffff << (32 - ip_bits(ip)))); + if (inet_cidr_ntop(AF_INET, &addr, ip_bits(ip), tmp, sizeof(tmp)) == NULL) elog(ERROR, "unable to print network (%s)", strerror(errno)); diff --git a/src/backend/utils/adt/not_in.c b/src/backend/utils/adt/not_in.c index 62a76c8369..7082b0d007 100644 --- a/src/backend/utils/adt/not_in.c +++ b/src/backend/utils/adt/not_in.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/not_in.c,v 1.15 1999/03/15 03:24:32 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/not_in.c,v 1.16 1999/05/25 16:12:12 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -47,18 +47,16 @@ int4notin(int32 not_in_arg, char *relation_and_attr) int attrid; char *relation, *attribute; - char my_copy[NAMEDATALEN*2+2]; + char my_copy[NAMEDATALEN * 2 + 2]; Datum value; strncpy(my_copy, relation_and_attr, sizeof(my_copy)); - my_copy[sizeof(my_copy)-1] = '\0'; + my_copy[sizeof(my_copy) - 1] = '\0'; relation = (char *) strtok(my_copy, "."); attribute = (char *) strtok(NULL, "."); if (attribute == NULL) - { elog(ERROR, "int4notin: must provide relationname.attributename"); - } /* Open the relation and get a relation descriptor */ diff --git a/src/backend/utils/adt/numeric.c b/src/backend/utils/adt/numeric.c index b1a86986ac..e9e5a28c36 100644 --- a/src/backend/utils/adt/numeric.c +++ b/src/backend/utils/adt/numeric.c @@ -5,7 +5,7 @@ * * 1998 Jan Wieck * - * $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.13 1999/05/10 18:17:44 wieck Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.14 1999/05/25 16:12:14 momjian Exp $ * * ---------- */ @@ -41,10 +41,10 @@ #define NUMERIC_MAX_FREEBUFS 20 #ifndef MIN -# define MIN(a,b) (((a)<(b)) ? (a) : (b)) +#define MIN(a,b) (((a)<(b)) ? (a) : (b)) #endif #ifndef MAX -# define MAX(a,b) (((a)>(b)) ? (a) : (b)) +#define MAX(a,b) (((a)>(b)) ? (a) : (b)) #endif #ifndef NAN @@ -56,52 +56,54 @@ * Local data types * ---------- */ -typedef unsigned char NumericDigit; +typedef unsigned char NumericDigit; -typedef struct NumericDigitBuf { - struct NumericDigitBuf *prev; - struct NumericDigitBuf *next; - int size; -} NumericDigitBuf; +typedef struct NumericDigitBuf +{ + struct NumericDigitBuf *prev; + struct NumericDigitBuf *next; + int size; +} NumericDigitBuf; -typedef struct NumericVar { - int ndigits; - int weight; - int rscale; - int dscale; - int sign; - NumericDigitBuf *buf; - NumericDigit *digits; -} NumericVar; +typedef struct NumericVar +{ + int ndigits; + int weight; + int rscale; + int dscale; + int sign; + NumericDigitBuf *buf; + NumericDigit *digits; +} NumericVar; /* ---------- * Local data * ---------- */ -static NumericDigitBuf *digitbuf_freelist = NULL; -static NumericDigitBuf *digitbuf_usedlist = NULL; -static int digitbuf_nfree = 0; -static int global_rscale = NUMERIC_MIN_RESULT_SCALE; +static NumericDigitBuf *digitbuf_freelist = NULL; +static NumericDigitBuf *digitbuf_usedlist = NULL; +static int digitbuf_nfree = 0; +static int global_rscale = NUMERIC_MIN_RESULT_SCALE; /* ---------- * Some preinitialized variables we need often * ---------- */ -static NumericDigit const_zero_data[1] = {0}; -static NumericVar const_zero = - {0, 0, 0, 0, NUMERIC_POS, NULL, const_zero_data}; +static NumericDigit const_zero_data[1] = {0}; +static NumericVar const_zero = +{0, 0, 0, 0, NUMERIC_POS, NULL, const_zero_data}; -static NumericDigit const_one_data[1] = {1}; -static NumericVar const_one = - {1, 0, 0, 0, NUMERIC_POS, NULL, const_one_data}; +static NumericDigit const_one_data[1] = {1}; +static NumericVar const_one = +{1, 0, 0, 0, NUMERIC_POS, NULL, const_one_data}; -static NumericDigit const_two_data[1] = {2}; -static NumericVar const_two = - {1, 0, 0, 0, NUMERIC_POS, NULL, const_two_data}; +static NumericDigit const_two_data[1] = {2}; +static NumericVar const_two = +{1, 0, 0, 0, NUMERIC_POS, NULL, const_two_data}; -static NumericVar const_nan = - {0, 0, 0, 0, NUMERIC_NAN, NULL, NULL}; +static NumericVar const_nan = +{0, 0, 0, 0, NUMERIC_NAN, NULL, NULL}; @@ -112,44 +114,45 @@ static NumericVar const_nan = #ifdef NUMERIC_DEBUG static void dump_numeric(char *str, Numeric num); -static void dump_var(char *str, NumericVar *var); +static void dump_var(char *str, NumericVar * var); + #else #define dump_numeric(s,n) #define dump_var(s,v) #endif static NumericDigitBuf *digitbuf_alloc(int size); -static void digitbuf_free(NumericDigitBuf *buf); +static void digitbuf_free(NumericDigitBuf * buf); #define init_var(v) memset(v,0,sizeof(NumericVar)) -static void free_var(NumericVar *var); +static void free_var(NumericVar * var); static void free_allvars(void); -static void set_var_from_str(char *str, NumericVar *dest); -static void set_var_from_num(Numeric value, NumericVar *dest); -static void set_var_from_var(NumericVar *value, NumericVar *dest); -static Numeric make_result(NumericVar *var); +static void set_var_from_str(char *str, NumericVar * dest); +static void set_var_from_num(Numeric value, NumericVar * dest); +static void set_var_from_var(NumericVar * value, NumericVar * dest); +static Numeric make_result(NumericVar * var); -static void apply_typmod(NumericVar *var, int32 typmod); +static void apply_typmod(NumericVar * var, int32 typmod); -static int cmp_var(NumericVar *var1, NumericVar *var2); -static void add_var(NumericVar *var1, NumericVar *var2, NumericVar *result); -static void sub_var(NumericVar *var1, NumericVar *var2, NumericVar *result); -static void mul_var(NumericVar *var1, NumericVar *var2, NumericVar *result); -static void div_var(NumericVar *var1, NumericVar *var2, NumericVar *result); -static void mod_var(NumericVar *var1, NumericVar *var2, NumericVar *result); -static void ceil_var(NumericVar *var, NumericVar *result); -static void floor_var(NumericVar *var, NumericVar *result); +static int cmp_var(NumericVar * var1, NumericVar * var2); +static void add_var(NumericVar * var1, NumericVar * var2, NumericVar * result); +static void sub_var(NumericVar * var1, NumericVar * var2, NumericVar * result); +static void mul_var(NumericVar * var1, NumericVar * var2, NumericVar * result); +static void div_var(NumericVar * var1, NumericVar * var2, NumericVar * result); +static void mod_var(NumericVar * var1, NumericVar * var2, NumericVar * result); +static void ceil_var(NumericVar * var, NumericVar * result); +static void floor_var(NumericVar * var, NumericVar * result); -static void sqrt_var(NumericVar *arg, NumericVar *result); -static void exp_var(NumericVar *arg, NumericVar *result); -static void ln_var(NumericVar *arg, NumericVar *result); -static void log_var(NumericVar *base, NumericVar *num, NumericVar *result); -static void power_var(NumericVar *base, NumericVar *exp, NumericVar *result); +static void sqrt_var(NumericVar * arg, NumericVar * result); +static void exp_var(NumericVar * arg, NumericVar * result); +static void ln_var(NumericVar * arg, NumericVar * result); +static void log_var(NumericVar * base, NumericVar * num, NumericVar * result); +static void power_var(NumericVar * base, NumericVar * exp, NumericVar * result); -static int cmp_abs(NumericVar *var1, NumericVar *var2); -static void add_abs(NumericVar *var1, NumericVar *var2, NumericVar *result); -static void sub_abs(NumericVar *var1, NumericVar *var2, NumericVar *result); +static int cmp_abs(NumericVar * var1, NumericVar * var2); +static void add_abs(NumericVar * var1, NumericVar * var2, NumericVar * result); +static void sub_abs(NumericVar * var1, NumericVar * var2, NumericVar * result); @@ -216,8 +219,8 @@ numeric_in(char *str, int dummy, int32 typmod) char * numeric_out(Numeric num) { - char *str; - char *cp; + char *str; + char *cp; NumericVar x; int i; int d; @@ -257,7 +260,7 @@ numeric_out(Numeric num) */ str = palloc(x.dscale + MAX(0, x.weight) + 5); cp = str; - + /* ---------- * Output a dash for negative values * ---------- @@ -272,8 +275,8 @@ numeric_out(Numeric num) */ if (x.dscale < x.rscale && (x.dscale + x.weight + 1) < x.ndigits) { - int j; - int carry; + int j; + int carry; j = x.dscale + x.weight + 1; carry = (x.digits[j] > 4) ? 1 : 0; @@ -342,7 +345,7 @@ numeric_out(Numeric num) * * This is a special function called by the Postgres database system * before a value is stored in a tuples attribute. The precision and - * scale of the attribute have to be applied on the value. + * scale of the attribute have to be applied on the value. * ---------- */ Numeric @@ -374,9 +377,9 @@ numeric(Numeric num, int32 typmod) * copy of the input value * ---------- */ - if (typmod < (int32)(VARHDRSZ)) + if (typmod < (int32) (VARHDRSZ)) { - new = (Numeric)palloc(num->varlen); + new = (Numeric) palloc(num->varlen); memcpy(new, num, num->varlen); return new; } @@ -387,7 +390,7 @@ numeric(Numeric num, int32 typmod) */ tmp_typmod = typmod - VARHDRSZ; precision = (tmp_typmod >> 16) & 0xffff; - scale = tmp_typmod & 0xffff; + scale = tmp_typmod & 0xffff; maxweight = precision - scale; /* ---------- @@ -398,11 +401,11 @@ numeric(Numeric num, int32 typmod) */ if (num->n_weight < maxweight && scale >= num->n_rscale) { - new = (Numeric)palloc(num->varlen); + new = (Numeric) palloc(num->varlen); memcpy(new, num, num->varlen); new->n_rscale = scale; - new->n_sign_dscale = NUMERIC_SIGN(new) | - ((uint16)scale & ~NUMERIC_SIGN_MASK); + new->n_sign_dscale = NUMERIC_SIGN(new) | + ((uint16) scale & ~NUMERIC_SIGN_MASK); return new; } @@ -454,7 +457,7 @@ numeric_abs(Numeric num) * Do it the easy way directly on the packed format * ---------- */ - res = (Numeric)palloc(num->varlen); + res = (Numeric) palloc(num->varlen); memcpy(res, num, num->varlen); res->n_sign_dscale = NUMERIC_POS | NUMERIC_DSCALE(num); @@ -492,9 +495,7 @@ numeric_sign(Numeric num) * ---------- */ if (num->varlen == NUMERIC_HDRSZ) - { set_var_from_var(&const_zero, &result); - } else { /* ---------- @@ -523,7 +524,7 @@ Numeric numeric_round(Numeric num, int32 scale) { int32 typmod; - int precision; + int precision; /* ---------- * Handle NULL @@ -547,7 +548,7 @@ numeric_round(Numeric num, int32 scale) { free_allvars(); elog(ERROR, "illegal numeric scale %d - must be between 0 and %d", - scale, NUMERIC_MAX_DISPLAY_SCALE); + scale, NUMERIC_MAX_DISPLAY_SCALE); } /* ---------- @@ -569,8 +570,8 @@ numeric_round(Numeric num, int32 scale) Numeric numeric_trunc(Numeric num, int32 scale) { - Numeric res; - NumericVar arg; + Numeric res; + NumericVar arg; /* ---------- * Handle NULL @@ -594,7 +595,7 @@ numeric_trunc(Numeric num, int32 scale) { free_allvars(); elog(ERROR, "illegal numeric scale %d - must be between 0 and %d", - scale, NUMERIC_MAX_DISPLAY_SCALE); + scale, NUMERIC_MAX_DISPLAY_SCALE); } /* ---------- @@ -609,9 +610,7 @@ numeric_trunc(Numeric num, int32 scale) arg.ndigits = MIN(arg.ndigits, MAX(0, arg.weight + scale + 1)); while (arg.ndigits > 0 && arg.digits[arg.ndigits - 1] == 0) - { arg.ndigits--; - } /* ---------- * Return the truncated result @@ -1085,7 +1084,7 @@ numeric_div(Numeric num1, Numeric num2) * numeric.h): * * DR = MIN(MAX(D1 + D2, MIN_DISPLAY_SCALE)) - * SR = MIN(MAX(MAX(S1 + S2, MIN_RESULT_SCALE), DR + 4), MAX_RESULT_SCALE) + * SR = MIN(MAX(MAX(S1 + S2, MIN_RESULT_SCALE), DR + 4), MAX_RESULT_SCALE) * * By default, any result is computed with a minimum of 34 digits * after the decimal point or at least with 4 digits more than @@ -1094,7 +1093,7 @@ numeric_div(Numeric num1, Numeric num2) */ res_dscale = MAX(arg1.dscale + arg2.dscale, NUMERIC_MIN_DISPLAY_SCALE); res_dscale = MIN(res_dscale, NUMERIC_MAX_DISPLAY_SCALE); - global_rscale = MAX(arg1.rscale + arg2.rscale, + global_rscale = MAX(arg1.rscale + arg2.rscale, NUMERIC_MIN_RESULT_SCALE); global_rscale = MAX(global_rscale, res_dscale + 4); global_rscale = MIN(global_rscale, NUMERIC_MAX_RESULT_SCALE); @@ -1358,10 +1357,10 @@ numeric_larger(Numeric num1, Numeric num2) Numeric numeric_sqrt(Numeric num) { - Numeric res; - NumericVar arg; - NumericVar result; - int res_dscale; + Numeric res; + NumericVar arg; + NumericVar result; + int res_dscale; /* ---------- * Handle NULL @@ -1415,10 +1414,10 @@ numeric_sqrt(Numeric num) Numeric numeric_exp(Numeric num) { - Numeric res; - NumericVar arg; - NumericVar result; - int res_dscale; + Numeric res; + NumericVar arg; + NumericVar result; + int res_dscale; /* ---------- * Handle NULL @@ -1470,10 +1469,10 @@ numeric_exp(Numeric num) Numeric numeric_ln(Numeric num) { - Numeric res; - NumericVar arg; - NumericVar result; - int res_dscale; + Numeric res; + NumericVar arg; + NumericVar result; + int res_dscale; /* ---------- * Handle NULL @@ -1525,11 +1524,11 @@ numeric_ln(Numeric num) Numeric numeric_log(Numeric num1, Numeric num2) { - Numeric res; - NumericVar arg1; - NumericVar arg2; - NumericVar result; - int res_dscale; + Numeric res; + NumericVar arg1; + NumericVar arg2; + NumericVar result; + int res_dscale; /* ---------- * Handle NULL @@ -1588,11 +1587,11 @@ numeric_log(Numeric num1, Numeric num2) Numeric numeric_power(Numeric num1, Numeric num2) { - Numeric res; - NumericVar arg1; - NumericVar arg2; - NumericVar result; - int res_dscale; + Numeric res; + NumericVar arg1; + NumericVar arg2; + NumericVar result; + int res_dscale; /* ---------- * Handle NULL @@ -1653,7 +1652,7 @@ int4_numeric(int32 val) { Numeric res; NumericVar result; - char *tmp; + char *tmp; init_var(&result); @@ -1671,7 +1670,7 @@ int4_numeric(int32 val) int32 numeric_int4(Numeric num) { - char *tmp; + char *tmp; int32 result; if (num == NULL) @@ -1717,7 +1716,7 @@ float8_numeric(float64 val) float64 numeric_float8(Numeric num) { - char *tmp; + char *tmp; float64 result; if (num == NULL) @@ -1725,7 +1724,7 @@ numeric_float8(Numeric num) if (NUMERIC_IS_NAN(num)) { - result = (float64)palloc(sizeof(float64data)); + result = (float64) palloc(sizeof(float64data)); *result = NAN; return result; } @@ -1743,7 +1742,7 @@ float4_numeric(float32 val) { Numeric res; NumericVar result; - char *tmp; + char *tmp; if (val == NULL) return NULL; @@ -1767,7 +1766,7 @@ float4_numeric(float32 val) float32 numeric_float4(Numeric num) { - char *tmp; + char *tmp; float32 result; if (num == NULL) @@ -1775,7 +1774,7 @@ numeric_float4(Numeric num) if (NUMERIC_IS_NAN(num)) { - result = (float32)palloc(sizeof(float32data)); + result = (float32) palloc(sizeof(float32data)); *result = NAN; return result; } @@ -1805,26 +1804,28 @@ numeric_float4(Numeric num) static void dump_numeric(char *str, Numeric num) { - int i; + int i; printf("%s: NUMERIC w=%d r=%d d=%d ", str, num->n_weight, num->n_rscale, - NUMERIC_DSCALE(num)); + NUMERIC_DSCALE(num)); switch (NUMERIC_SIGN(num)) { - case NUMERIC_POS: printf("POS"); - break; - case NUMERIC_NEG: printf("NEG"); - break; - case NUMERIC_NAN: printf("NaN"); - break; - default: printf("SIGN=0x%x", NUMERIC_SIGN(num)); - break; + case NUMERIC_POS: + printf("POS"); + break; + case NUMERIC_NEG: + printf("NEG"); + break; + case NUMERIC_NAN: + printf("NaN"); + break; + default: + printf("SIGN=0x%x", NUMERIC_SIGN(num)); + break; } for (i = 0; i < num->varlen - NUMERIC_HDRSZ; i++) - { printf(" %d %d", (num->n_data[i] >> 4) & 0x0f, num->n_data[i] & 0x0f); - } printf("\n"); } @@ -1834,31 +1835,35 @@ dump_numeric(char *str, Numeric num) * ---------- */ static void -dump_var(char *str, NumericVar *var) +dump_var(char *str, NumericVar * var) { - int i; + int i; printf("%s: VAR w=%d r=%d d=%d ", str, var->weight, var->rscale, - var->dscale); + var->dscale); switch (var->sign) { - case NUMERIC_POS: printf("POS"); - break; - case NUMERIC_NEG: printf("NEG"); - break; - case NUMERIC_NAN: printf("NaN"); - break; - default: printf("SIGN=0x%x", var->sign); - break; + case NUMERIC_POS: + printf("POS"); + break; + case NUMERIC_NEG: + printf("NEG"); + break; + case NUMERIC_NAN: + printf("NaN"); + break; + default: + printf("SIGN=0x%x", var->sign); + break; } for (i = 0; i < var->ndigits; i++) printf(" %d", var->digits[i]); - + printf("\n"); } -#endif /* NUMERIC_DEBUG */ +#endif /* NUMERIC_DEBUG */ /* ---------- @@ -1868,7 +1873,7 @@ dump_var(char *str, NumericVar *var) * information (sign, scales etc.) and a digit buffer for the * value itself. All the variable level functions are written in * a style that makes it possible to give one and the same variable - * as argument and result destination. + * as argument and result destination. * * The two functions below manage unused buffers in a free list * as a try to reduce the number of malloc()/free() calls. @@ -1877,8 +1882,8 @@ dump_var(char *str, NumericVar *var) static NumericDigitBuf * digitbuf_alloc(int size) { - NumericDigitBuf *buf; - int asize; + NumericDigitBuf *buf; + int asize; /* ---------- * Lookup the free list if there is a digit buffer of @@ -1887,7 +1892,8 @@ digitbuf_alloc(int size) */ for (buf = digitbuf_freelist; buf != NULL; buf = buf->next) { - if (buf->size < size) continue; + if (buf->size < size) + continue; /* ---------- * We found a free buffer that is big enough - remove it from @@ -1930,7 +1936,7 @@ digitbuf_alloc(int size) * ---------- */ for (asize = NUMERIC_MIN_BUFSIZE; asize < size; asize *= 2); - buf = (NumericDigitBuf *)malloc(sizeof(NumericDigitBuf) + asize); + buf = (NumericDigitBuf *) malloc(sizeof(NumericDigitBuf) + asize); buf->size = asize; /* ---------- @@ -1956,9 +1962,9 @@ digitbuf_alloc(int size) * ---------- */ static void -digitbuf_free(NumericDigitBuf *buf) +digitbuf_free(NumericDigitBuf * buf) { - NumericDigitBuf *smallest; + NumericDigitBuf *smallest; if (buf == NULL) return; @@ -2042,12 +2048,12 @@ digitbuf_free(NumericDigitBuf *buf) * ---------- */ static void -free_var(NumericVar *var) +free_var(NumericVar * var) { if (var->buf != NULL) { digitbuf_free(var->buf); - var->buf = NULL; + var->buf = NULL; var->digits = NULL; } var->sign = NUMERIC_NAN; @@ -2070,8 +2076,8 @@ free_var(NumericVar *var) static void free_allvars(void) { - NumericDigitBuf *buf; - NumericDigitBuf *next; + NumericDigitBuf *buf; + NumericDigitBuf *next; buf = digitbuf_usedlist; while (buf != NULL) @@ -2090,25 +2096,26 @@ free_allvars(void) * ---------- */ static void -set_var_from_str(char *str, NumericVar *dest) +set_var_from_str(char *str, NumericVar * dest) { - char *cp = str; - bool have_dp = FALSE; - int i = 1; + char *cp = str; + bool have_dp = FALSE; + int i = 1; - while(*cp) + while (*cp) { - if (!isspace(*cp)) break; + if (!isspace(*cp)) + break; cp++; } digitbuf_free(dest->buf); - dest->buf = digitbuf_alloc(strlen(cp) + 2); - dest->digits = (NumericDigit *)(dest->buf) + sizeof(NumericDigitBuf); + dest->buf = digitbuf_alloc(strlen(cp) + 2); + dest->digits = (NumericDigit *) (dest->buf) + sizeof(NumericDigitBuf); dest->digits[0] = 0; - dest->weight = 0; - dest->dscale = 0; + dest->weight = 0; + dest->dscale = 0; switch (*cp) { @@ -2121,24 +2128,29 @@ set_var_from_str(char *str, NumericVar *dest) case '6': case '7': case '8': - case '9': dest->sign = NUMERIC_POS; - break; + case '9': + dest->sign = NUMERIC_POS; + break; - case '+': dest->sign = NUMERIC_POS; - cp++; - break; + case '+': + dest->sign = NUMERIC_POS; + cp++; + break; - case '-': dest->sign = NUMERIC_NEG; - cp++; - break; + case '-': + dest->sign = NUMERIC_NEG; + cp++; + break; - case '.': dest->sign = NUMERIC_POS; - have_dp = TRUE; - cp++; - break; + case '.': + dest->sign = NUMERIC_POS; + have_dp = TRUE; + cp++; + break; - default: free_allvars(); - elog(ERROR, "Bad numeric input format '%s'", str); + default: + free_allvars(); + elog(ERROR, "Bad numeric input format '%s'", str); } if (*cp == '.') @@ -2178,24 +2190,27 @@ set_var_from_str(char *str, NumericVar *dest) case '6': case '7': case '8': - case '9': dest->digits[i++] = *cp++ - '0'; - if (!have_dp) - dest->weight++; - else - dest->dscale++; - break; + case '9': + dest->digits[i++] = *cp++ - '0'; + if (!have_dp) + dest->weight++; + else + dest->dscale++; + break; - case '.': if (have_dp) - { - free_allvars(); - elog(ERROR, "Bad numeric input format '%s'", str); - } - have_dp = TRUE; - cp++; - break; + case '.': + if (have_dp) + { + free_allvars(); + elog(ERROR, "Bad numeric input format '%s'", str); + } + have_dp = TRUE; + cp++; + break; - default: free_allvars(); - elog(ERROR, "Bad numeric input format '%s'", str); + default: + free_allvars(); + elog(ERROR, "Bad numeric input format '%s'", str); } } dest->ndigits = i; @@ -2223,18 +2238,18 @@ set_var_from_str(char *str, NumericVar *dest) * */ static void -set_var_from_num(Numeric num, NumericVar *dest) +set_var_from_num(Numeric num, NumericVar * dest) { - NumericDigit *digit; - int i; - int n; + NumericDigit *digit; + int i; + int n; n = num->varlen - NUMERIC_HDRSZ; digitbuf_free(dest->buf); dest->buf = digitbuf_alloc(n * 2 + 2); - digit = ((NumericDigit *)(dest->buf)) + sizeof(NumericDigitBuf); + digit = ((NumericDigit *) (dest->buf)) + sizeof(NumericDigitBuf); *digit++ = 0; *digit++ = 0; dest->digits = digit; @@ -2243,7 +2258,7 @@ set_var_from_num(Numeric num, NumericVar *dest) dest->weight = num->n_weight; dest->rscale = num->n_rscale; dest->dscale = NUMERIC_DSCALE(num); - dest->sign = NUMERIC_SIGN(num); + dest->sign = NUMERIC_SIGN(num); for (i = 0; i < n; i++) { @@ -2260,18 +2275,18 @@ set_var_from_num(Numeric num, NumericVar *dest) * ---------- */ static void -set_var_from_var(NumericVar *value, NumericVar *dest) +set_var_from_var(NumericVar * value, NumericVar * dest) { - NumericDigitBuf *newbuf; - NumericDigit *newdigits; + NumericDigitBuf *newbuf; + NumericDigit *newdigits; newbuf = digitbuf_alloc(value->ndigits); - newdigits = ((NumericDigit *)newbuf) + sizeof(NumericDigitBuf); + newdigits = ((NumericDigit *) newbuf) + sizeof(NumericDigitBuf); memcpy(newdigits, value->digits, value->ndigits); digitbuf_free(dest->buf); memcpy(dest, value, sizeof(NumericVar)); - dest->buf = newbuf; + dest->buf = newbuf; dest->digits = newdigits; } @@ -2284,22 +2299,23 @@ set_var_from_var(NumericVar *value, NumericVar *dest) * ---------- */ static Numeric -make_result(NumericVar *var) +make_result(NumericVar * var) { - Numeric result; - NumericDigit *digit = var->digits; - int n; - int weight = var->weight; - int sign = var->sign; - int i, j; + Numeric result; + NumericDigit *digit = var->digits; + int n; + int weight = var->weight; + int sign = var->sign; + int i, + j; if (sign == NUMERIC_NAN) { - result = (Numeric)palloc(NUMERIC_HDRSZ); + result = (Numeric) palloc(NUMERIC_HDRSZ); - result->varlen = NUMERIC_HDRSZ; - result->n_weight = 0; - result->n_rscale = 0; + result->varlen = NUMERIC_HDRSZ; + result->n_weight = 0; + result->n_rscale = 0; result->n_sign_dscale = NUMERIC_NAN; dump_numeric("make_result()", result); @@ -2320,16 +2336,17 @@ make_result(NumericVar *var) if (n == 0) { weight = 0; - sign = NUMERIC_POS; + sign = NUMERIC_POS; } - result = (Numeric)palloc(NUMERIC_HDRSZ + (n + 1) / 2); + result = (Numeric) palloc(NUMERIC_HDRSZ + (n + 1) / 2); result->varlen = NUMERIC_HDRSZ + (n + 1) / 2; result->n_weight = weight; result->n_rscale = var->rscale; - result->n_sign_dscale = sign | ((uint16)(var->dscale) & ~NUMERIC_SIGN_MASK); + result->n_sign_dscale = sign | ((uint16) (var->dscale) & ~NUMERIC_SIGN_MASK); - i = 0; j = 0; + i = 0; + j = 0; while (j < n) { result->n_data[i] = digit[j++] << 4; @@ -2351,33 +2368,33 @@ make_result(NumericVar *var) * ---------- */ static void -apply_typmod(NumericVar *var, int32 typmod) +apply_typmod(NumericVar * var, int32 typmod) { int precision; int scale; int maxweight; int i; - if (typmod < (int32)(VARHDRSZ)) + if (typmod < (int32) (VARHDRSZ)) return; typmod -= VARHDRSZ; precision = (typmod >> 16) & 0xffff; - scale = typmod & 0xffff; + scale = typmod & 0xffff; maxweight = precision - scale; if (var->weight >= maxweight) { free_allvars(); elog(ERROR, "overflow on numeric " - "ABS(value) >= 10^%d for field with precision %d scale %d", - var->weight, precision, scale); + "ABS(value) >= 10^%d for field with precision %d scale %d", + var->weight, precision, scale); } i = scale + var->weight + 1; if (i >= 0 && var->ndigits > i) { - long carry = (var->digits[i] > 4) ? 1 : 0; + long carry = (var->digits[i] > 4) ? 1 : 0; var->ndigits = i; while (carry) @@ -2395,9 +2412,7 @@ apply_typmod(NumericVar *var, int32 typmod) } } else - { var->ndigits = MAX(0, MIN(i, var->ndigits)); - } /* ---------- * Check for overflow again - rounding could have raised the @@ -2408,8 +2423,8 @@ apply_typmod(NumericVar *var, int32 typmod) { free_allvars(); elog(ERROR, "overflow on numeric " - "ABS(value) >= 10^%d for field with precision %d scale %d", - var->weight, precision, scale); + "ABS(value) >= 10^%d for field with precision %d scale %d", + var->weight, precision, scale); } var->rscale = scale; @@ -2424,7 +2439,7 @@ apply_typmod(NumericVar *var, int32 typmod) * ---------- */ static int -cmp_var(NumericVar *var1, NumericVar *var2) +cmp_var(NumericVar * var1, NumericVar * var2) { if (var1->ndigits == 0) { @@ -2463,7 +2478,7 @@ cmp_var(NumericVar *var1, NumericVar *var2) * ---------- */ static void -add_var(NumericVar *var1, NumericVar *var2, NumericVar *result) +add_var(NumericVar * var1, NumericVar * var2, NumericVar * result) { /* ---------- * Decide on the signs of the two variables what to do @@ -2474,7 +2489,7 @@ add_var(NumericVar *var1, NumericVar *var2, NumericVar *result) if (var2->sign == NUMERIC_POS) { /* ---------- - * Both are positive + * Both are positive * result = +(ABS(var1) + ABS(var2)) * ---------- */ @@ -2490,39 +2505,39 @@ add_var(NumericVar *var1, NumericVar *var2, NumericVar *result) */ switch (cmp_abs(var1, var2)) { - case 0: /* ---------- - * ABS(var1) == ABS(var2) - * result = ZERO - * ---------- - */ - digitbuf_free(result->buf); - result->buf = digitbuf_alloc(0); - result->ndigits = 0; - result->digits = ((NumericDigit *)(result->buf)) + - sizeof(NumericDigitBuf); - result->weight = 0; - result->rscale = MAX(var1->rscale, var2->rscale); - result->dscale = MAX(var1->dscale, var2->dscale); - result->sign = NUMERIC_POS; - break; + case 0: /* ---------- + * ABS(var1) == ABS(var2) + * result = ZERO + * ---------- + */ + digitbuf_free(result->buf); + result->buf = digitbuf_alloc(0); + result->ndigits = 0; + result->digits = ((NumericDigit *) (result->buf)) + + sizeof(NumericDigitBuf); + result->weight = 0; + result->rscale = MAX(var1->rscale, var2->rscale); + result->dscale = MAX(var1->dscale, var2->dscale); + result->sign = NUMERIC_POS; + break; - case 1: /* ---------- - * ABS(var1) > ABS(var2) - * result = +(ABS(var1) - ABS(var2)) - * ---------- - */ - sub_abs(var1, var2, result); - result->sign = NUMERIC_POS; - break; + case 1: /* ---------- + * ABS(var1) > ABS(var2) + * result = +(ABS(var1) - ABS(var2)) + * ---------- + */ + sub_abs(var1, var2, result); + result->sign = NUMERIC_POS; + break; - case -1: /* ---------- - * ABS(var1) < ABS(var2) - * result = -(ABS(var2) - ABS(var1)) - * ---------- - */ - sub_abs(var2, var1, result); - result->sign = NUMERIC_NEG; - break; + case -1: /* ---------- + * ABS(var1) < ABS(var2) + * result = -(ABS(var2) - ABS(var1)) + * ---------- + */ + sub_abs(var2, var1, result); + result->sign = NUMERIC_NEG; + break; } } } @@ -2537,39 +2552,39 @@ add_var(NumericVar *var1, NumericVar *var2, NumericVar *result) */ switch (cmp_abs(var1, var2)) { - case 0: /* ---------- - * ABS(var1) == ABS(var2) - * result = ZERO - * ---------- - */ - digitbuf_free(result->buf); - result->buf = digitbuf_alloc(0); - result->ndigits = 0; - result->digits = ((NumericDigit *)(result->buf)) + - sizeof(NumericDigitBuf); - result->weight = 0; - result->rscale = MAX(var1->rscale, var2->rscale); - result->dscale = MAX(var1->dscale, var2->dscale); - result->sign = NUMERIC_POS; - break; + case 0: /* ---------- + * ABS(var1) == ABS(var2) + * result = ZERO + * ---------- + */ + digitbuf_free(result->buf); + result->buf = digitbuf_alloc(0); + result->ndigits = 0; + result->digits = ((NumericDigit *) (result->buf)) + + sizeof(NumericDigitBuf); + result->weight = 0; + result->rscale = MAX(var1->rscale, var2->rscale); + result->dscale = MAX(var1->dscale, var2->dscale); + result->sign = NUMERIC_POS; + break; - case 1: /* ---------- - * ABS(var1) > ABS(var2) - * result = -(ABS(var1) - ABS(var2)) - * ---------- - */ - sub_abs(var1, var2, result); - result->sign = NUMERIC_NEG; - break; + case 1: /* ---------- + * ABS(var1) > ABS(var2) + * result = -(ABS(var1) - ABS(var2)) + * ---------- + */ + sub_abs(var1, var2, result); + result->sign = NUMERIC_NEG; + break; - case -1: /* ---------- - * ABS(var1) < ABS(var2) - * result = +(ABS(var2) - ABS(var1)) - * ---------- - */ - sub_abs(var2, var1, result); - result->sign = NUMERIC_POS; - break; + case -1: /* ---------- + * ABS(var1) < ABS(var2) + * result = +(ABS(var2) - ABS(var1)) + * ---------- + */ + sub_abs(var2, var1, result); + result->sign = NUMERIC_POS; + break; } } else @@ -2594,7 +2609,7 @@ add_var(NumericVar *var1, NumericVar *var2, NumericVar *result) * ---------- */ static void -sub_var(NumericVar *var1, NumericVar *var2, NumericVar *result) +sub_var(NumericVar * var1, NumericVar * var2, NumericVar * result) { /* ---------- * Decide on the signs of the two variables what to do @@ -2621,39 +2636,39 @@ sub_var(NumericVar *var1, NumericVar *var2, NumericVar *result) */ switch (cmp_abs(var1, var2)) { - case 0: /* ---------- - * ABS(var1) == ABS(var2) - * result = ZERO - * ---------- - */ - digitbuf_free(result->buf); - result->buf = digitbuf_alloc(0); - result->ndigits = 0; - result->digits = ((NumericDigit *)(result->buf)) + - sizeof(NumericDigitBuf); - result->weight = 0; - result->rscale = MAX(var1->rscale, var2->rscale); - result->dscale = MAX(var1->dscale, var2->dscale); - result->sign = NUMERIC_POS; - break; + case 0: /* ---------- + * ABS(var1) == ABS(var2) + * result = ZERO + * ---------- + */ + digitbuf_free(result->buf); + result->buf = digitbuf_alloc(0); + result->ndigits = 0; + result->digits = ((NumericDigit *) (result->buf)) + + sizeof(NumericDigitBuf); + result->weight = 0; + result->rscale = MAX(var1->rscale, var2->rscale); + result->dscale = MAX(var1->dscale, var2->dscale); + result->sign = NUMERIC_POS; + break; - case 1: /* ---------- - * ABS(var1) > ABS(var2) - * result = +(ABS(var1) - ABS(var2)) - * ---------- - */ - sub_abs(var1, var2, result); - result->sign = NUMERIC_POS; - break; + case 1: /* ---------- + * ABS(var1) > ABS(var2) + * result = +(ABS(var1) - ABS(var2)) + * ---------- + */ + sub_abs(var1, var2, result); + result->sign = NUMERIC_POS; + break; - case -1: /* ---------- - * ABS(var1) < ABS(var2) - * result = -(ABS(var2) - ABS(var1)) - * ---------- - */ - sub_abs(var2, var1, result); - result->sign = NUMERIC_NEG; - break; + case -1: /* ---------- + * ABS(var1) < ABS(var2) + * result = -(ABS(var2) - ABS(var1)) + * ---------- + */ + sub_abs(var2, var1, result); + result->sign = NUMERIC_NEG; + break; } } } @@ -2668,39 +2683,39 @@ sub_var(NumericVar *var1, NumericVar *var2, NumericVar *result) */ switch (cmp_abs(var1, var2)) { - case 0: /* ---------- - * ABS(var1) == ABS(var2) - * result = ZERO - * ---------- - */ - digitbuf_free(result->buf); - result->buf = digitbuf_alloc(0); - result->ndigits = 0; - result->digits = ((NumericDigit *)(result->buf)) + - sizeof(NumericDigitBuf); - result->weight = 0; - result->rscale = MAX(var1->rscale, var2->rscale); - result->dscale = MAX(var1->dscale, var2->dscale); - result->sign = NUMERIC_POS; - break; + case 0: /* ---------- + * ABS(var1) == ABS(var2) + * result = ZERO + * ---------- + */ + digitbuf_free(result->buf); + result->buf = digitbuf_alloc(0); + result->ndigits = 0; + result->digits = ((NumericDigit *) (result->buf)) + + sizeof(NumericDigitBuf); + result->weight = 0; + result->rscale = MAX(var1->rscale, var2->rscale); + result->dscale = MAX(var1->dscale, var2->dscale); + result->sign = NUMERIC_POS; + break; - case 1: /* ---------- - * ABS(var1) > ABS(var2) - * result = -(ABS(var1) - ABS(var2)) - * ---------- - */ - sub_abs(var1, var2, result); - result->sign = NUMERIC_NEG; - break; + case 1: /* ---------- + * ABS(var1) > ABS(var2) + * result = -(ABS(var1) - ABS(var2)) + * ---------- + */ + sub_abs(var1, var2, result); + result->sign = NUMERIC_NEG; + break; - case -1: /* ---------- - * ABS(var1) < ABS(var2) - * result = +(ABS(var2) - ABS(var1)) - * ---------- - */ - sub_abs(var2, var1, result); - result->sign = NUMERIC_POS; - break; + case -1: /* ---------- + * ABS(var1) < ABS(var2) + * result = +(ABS(var2) - ABS(var1)) + * ---------- + */ + sub_abs(var2, var1, result); + result->sign = NUMERIC_POS; + break; } } else @@ -2725,17 +2740,20 @@ sub_var(NumericVar *var1, NumericVar *var2, NumericVar *result) * ---------- */ static void -mul_var(NumericVar *var1, NumericVar *var2, NumericVar *result) +mul_var(NumericVar * var1, NumericVar * var2, NumericVar * result) { - NumericDigitBuf *res_buf; - NumericDigit *res_digits; - int res_ndigits; - int res_weight; - int res_sign; - int i, ri, i1, i2; - long sum = 0; + NumericDigitBuf *res_buf; + NumericDigit *res_digits; + int res_ndigits; + int res_weight; + int res_sign; + int i, + ri, + i1, + i2; + long sum = 0; - res_weight = var1->weight + var2->weight + 2; + res_weight = var1->weight + var2->weight + 2; res_ndigits = var1->ndigits + var2->ndigits + 1; if (var1->sign == var2->sign) res_sign = NUMERIC_POS; @@ -2743,7 +2761,7 @@ mul_var(NumericVar *var1, NumericVar *var2, NumericVar *result) res_sign = NUMERIC_NEG; res_buf = digitbuf_alloc(res_ndigits); - res_digits = ((NumericDigit *)res_buf) + sizeof(NumericDigitBuf); + res_digits = ((NumericDigit *) res_buf) + sizeof(NumericDigitBuf); memset(res_digits, 0, res_ndigits); ri = res_ndigits; @@ -2782,23 +2800,21 @@ mul_var(NumericVar *var1, NumericVar *var2, NumericVar *result) res_ndigits--; } while (res_ndigits > 0 && res_digits[res_ndigits - 1] == 0) - { res_ndigits--; - } if (res_ndigits == 0) { - res_sign = NUMERIC_POS; + res_sign = NUMERIC_POS; res_weight = 0; } digitbuf_free(result->buf); - result->buf = res_buf; - result->digits = res_digits; + result->buf = res_buf; + result->digits = res_digits; result->ndigits = res_ndigits; - result->weight = res_weight; - result->rscale = global_rscale; - result->sign = res_sign; + result->weight = res_weight; + result->rscale = global_rscale; + result->sign = res_sign; } @@ -2809,24 +2825,24 @@ mul_var(NumericVar *var1, NumericVar *var2, NumericVar *result) * ---------- */ static void -div_var(NumericVar *var1, NumericVar *var2, NumericVar *result) +div_var(NumericVar * var1, NumericVar * var2, NumericVar * result) { - NumericDigit *res_digits; - int res_ndigits; - int res_sign; - int res_weight; - NumericVar dividend; - NumericVar divisor[10]; - int ndigits_tmp; - int weight_tmp; - int rscale_tmp; - int ri; - int i; - long guess; - long first_have; - long first_div; - int first_nextdigit; - int stat = 0; + NumericDigit *res_digits; + int res_ndigits; + int res_sign; + int res_weight; + NumericVar dividend; + NumericVar divisor[10]; + int ndigits_tmp; + int weight_tmp; + int rscale_tmp; + int ri; + int i; + long guess; + long first_have; + long first_div; + int first_nextdigit; + int stat = 0; /* ---------- * First of all division by zero check @@ -2858,11 +2874,11 @@ div_var(NumericVar *var1, NumericVar *var2, NumericVar *result) { digitbuf_free(result->buf); result->buf = digitbuf_alloc(0); - result->digits = ((NumericDigit *)(result->buf)) + sizeof(NumericDigitBuf); + result->digits = ((NumericDigit *) (result->buf)) + sizeof(NumericDigitBuf); result->ndigits = 0; - result->weight = 0; - result->rscale = global_rscale; - result->sign = NUMERIC_POS; + result->weight = 0; + result->rscale = global_rscale; + result->sign = NUMERIC_POS; return; } @@ -2872,21 +2888,19 @@ div_var(NumericVar *var1, NumericVar *var2, NumericVar *result) */ init_var(÷nd); for (i = 1; i < 10; i++) - { init_var(&divisor[i]); - } /* ---------- * Make a copy of the divisor which has one leading zero digit * ---------- */ - divisor[1].ndigits = ndigits_tmp; - divisor[1].rscale = var2->ndigits; - divisor[1].sign = NUMERIC_POS; - divisor[1].buf = digitbuf_alloc(ndigits_tmp); - divisor[1].digits = ((NumericDigit *)(divisor[1].buf)) + - sizeof(NumericDigitBuf); + divisor[1].ndigits = ndigits_tmp; + divisor[1].rscale = var2->ndigits; + divisor[1].sign = NUMERIC_POS; + divisor[1].buf = digitbuf_alloc(ndigits_tmp); + divisor[1].digits = ((NumericDigit *) (divisor[1].buf)) + + sizeof(NumericDigitBuf); divisor[1].digits[0] = 0; memcpy(&(divisor[1].digits[1]), var2->digits, ndigits_tmp - 1); @@ -2895,11 +2909,11 @@ div_var(NumericVar *var1, NumericVar *var2, NumericVar *result) * ---------- */ dividend.ndigits = var1->ndigits; - dividend.weight = 0; - dividend.rscale = var1->ndigits; - dividend.sign = NUMERIC_POS; - dividend.buf = digitbuf_alloc(var1->ndigits); - dividend.digits = ((NumericDigit *)(dividend.buf)) + sizeof(NumericDigitBuf); + dividend.weight = 0; + dividend.rscale = var1->ndigits; + dividend.sign = NUMERIC_POS; + dividend.buf = digitbuf_alloc(var1->ndigits); + dividend.digits = ((NumericDigit *) (dividend.buf)) + sizeof(NumericDigitBuf); memcpy(dividend.digits, var1->digits, var1->ndigits); /* ---------- @@ -2908,18 +2922,18 @@ div_var(NumericVar *var1, NumericVar *var2, NumericVar *result) */ digitbuf_free(result->buf); result->buf = digitbuf_alloc(res_ndigits + 2); - res_digits = ((NumericDigit *)(result->buf)) + sizeof(NumericDigitBuf); + res_digits = ((NumericDigit *) (result->buf)) + sizeof(NumericDigitBuf); result->digits = res_digits; result->ndigits = res_ndigits; - result->weight = res_weight; - result->rscale = global_rscale; - result->sign = res_sign; + result->weight = res_weight; + result->rscale = global_rscale; + result->sign = res_sign; res_digits[0] = 0; first_div = divisor[1].digits[1] * 10; if (ndigits_tmp > 2) first_div += divisor[1].digits[2]; - + first_have = 0; first_nextdigit = 0; @@ -2941,13 +2955,13 @@ div_var(NumericVar *var1, NumericVar *var2, NumericVar *result) { if (divisor[guess].buf == NULL) { - int i; - long sum = 0; + int i; + long sum = 0; memcpy(&divisor[guess], &divisor[1], sizeof(NumericVar)); divisor[guess].buf = digitbuf_alloc(divisor[guess].ndigits); - divisor[guess].digits = ((NumericDigit *)(divisor[guess].buf) + - sizeof(NumericDigitBuf)); + divisor[guess].digits = ((NumericDigit *) (divisor[guess].buf) + + sizeof(NumericDigitBuf)); for (i = divisor[1].ndigits - 1; i >= 0; i--) { sum += divisor[1].digits[i] * guess; @@ -2960,7 +2974,8 @@ div_var(NumericVar *var1, NumericVar *var2, NumericVar *result) divisor[guess].rscale = rscale_tmp; stat = cmp_abs(÷nd, &divisor[guess]); - if (stat >= 0) break; + if (stat >= 0) + break; guess--; } @@ -2990,12 +3005,12 @@ div_var(NumericVar *var1, NumericVar *var2, NumericVar *result) result->ndigits = ri + 1; if (ri == res_ndigits + 1) { - long carry = (res_digits[ri] > 4) ? 1 : 0; + long carry = (res_digits[ri] > 4) ? 1 : 0; result->ndigits = ri; res_digits[ri] = 0; - while(carry && ri > 0) + while (carry && ri > 0) { carry += res_digits[--ri]; res_digits[ri] = carry % 10; @@ -3010,9 +3025,7 @@ div_var(NumericVar *var1, NumericVar *var2, NumericVar *result) (result->ndigits)--; } while (result->ndigits > 0 && result->digits[result->ndigits - 1] == 0) - { (result->ndigits)--; - } if (result->ndigits == 0) result->sign = NUMERIC_POS; @@ -3033,10 +3046,10 @@ div_var(NumericVar *var1, NumericVar *var2, NumericVar *result) * ---------- */ static void -mod_var(NumericVar *var1, NumericVar *var2, NumericVar *result) +mod_var(NumericVar * var1, NumericVar * var2, NumericVar * result) { - NumericVar tmp; - int save_global_rscale; + NumericVar tmp; + int save_global_rscale; init_var(&tmp); @@ -3070,9 +3083,9 @@ mod_var(NumericVar *var1, NumericVar *var2, NumericVar *result) * ---------- */ static void -ceil_var(NumericVar *var, NumericVar *result) +ceil_var(NumericVar * var, NumericVar * result) { - NumericVar tmp; + NumericVar tmp; init_var(&tmp); set_var_from_var(var, &tmp); @@ -3095,9 +3108,9 @@ ceil_var(NumericVar *var, NumericVar *result) * ---------- */ static void -floor_var(NumericVar *var, NumericVar *result) +floor_var(NumericVar * var, NumericVar * result) { - NumericVar tmp; + NumericVar tmp; init_var(&tmp); set_var_from_var(var, &tmp); @@ -3119,14 +3132,14 @@ floor_var(NumericVar *var, NumericVar *result) * ---------- */ static void -sqrt_var(NumericVar *arg, NumericVar *result) +sqrt_var(NumericVar * arg, NumericVar * result) { - NumericVar tmp_arg; - NumericVar tmp_val; - NumericVar last_val; - int res_rscale; - int save_global_rscale; - int stat; + NumericVar tmp_arg; + NumericVar tmp_val; + NumericVar last_val; + int res_rscale; + int save_global_rscale; + int stat; save_global_rscale = global_rscale; global_rscale += 8; @@ -3137,7 +3150,7 @@ sqrt_var(NumericVar *arg, NumericVar *result) { set_var_from_var(&const_zero, result); result->rscale = res_rscale; - result->sign = NUMERIC_POS; + result->sign = NUMERIC_POS; return; } @@ -3160,14 +3173,14 @@ sqrt_var(NumericVar *arg, NumericVar *result) */ digitbuf_free(result->buf); result->buf = digitbuf_alloc(1); - result->digits = ((NumericDigit *)(result->buf)) + sizeof(NumericDigitBuf); + result->digits = ((NumericDigit *) (result->buf)) + sizeof(NumericDigitBuf); result->digits[0] = tmp_arg.digits[0] / 2; if (result->digits[0] == 0) result->digits[0] = 1; result->ndigits = 1; result->weight = tmp_arg.weight / 2; result->rscale = res_rscale; - result->sign = NUMERIC_POS; + result->sign = NUMERIC_POS; for (;;) { @@ -3176,7 +3189,8 @@ sqrt_var(NumericVar *arg, NumericVar *result) add_var(result, &tmp_val, result); div_var(result, &const_two, result); - if (cmp_var(&last_val, result) == 0) break; + if (cmp_var(&last_val, result) == 0) + break; set_var_from_var(result, &last_val); } @@ -3196,18 +3210,18 @@ sqrt_var(NumericVar *arg, NumericVar *result) * ---------- */ static void -exp_var(NumericVar *arg, NumericVar *result) +exp_var(NumericVar * arg, NumericVar * result) { - NumericVar x; - NumericVar xpow; - NumericVar ifac; - NumericVar elem; - NumericVar ni; - int d; - int i; - int ndiv2 = 0; - bool xneg = FALSE; - int save_global_rscale; + NumericVar x; + NumericVar xpow; + NumericVar ifac; + NumericVar elem; + NumericVar ni; + int d; + int i; + int ndiv2 = 0; + bool xneg = FALSE; + int save_global_rscale; init_var(&x); init_var(&xpow); @@ -3239,7 +3253,7 @@ exp_var(NumericVar *arg, NumericVar *result) global_rscale = global_rscale / 2 + save_global_rscale + 8; - while(cmp_var(&x, &const_one) > 0) + while (cmp_var(&x, &const_one) > 0) { ndiv2++; global_rscale++; @@ -3290,15 +3304,15 @@ exp_var(NumericVar *arg, NumericVar *result) * ---------- */ static void -ln_var(NumericVar *arg, NumericVar *result) +ln_var(NumericVar * arg, NumericVar * result) { - NumericVar x; - NumericVar xx; - NumericVar ni; - NumericVar elem; - NumericVar fact; - int i; - int save_global_rscale; + NumericVar x; + NumericVar xx; + NumericVar ni; + NumericVar elem; + NumericVar fact; + int i; + int save_global_rscale; if (cmp_var(arg, &const_zero) <= 0) { @@ -3368,7 +3382,7 @@ ln_var(NumericVar *arg, NumericVar *result) * ---------- */ static void -log_var(NumericVar *base, NumericVar *num, NumericVar *result) +log_var(NumericVar * base, NumericVar * num, NumericVar * result) { NumericVar ln_base; NumericVar ln_num; @@ -3379,10 +3393,10 @@ log_var(NumericVar *base, NumericVar *num, NumericVar *result) init_var(&ln_num); ln_var(base, &ln_base); - ln_var(num, &ln_num); + ln_var(num, &ln_num); global_rscale -= 8; - + div_var(&ln_num, &ln_base, result); free_var(&ln_num); @@ -3397,7 +3411,7 @@ log_var(NumericVar *base, NumericVar *num, NumericVar *result) * ---------- */ static void -power_var(NumericVar *base, NumericVar *exp, NumericVar *result) +power_var(NumericVar * base, NumericVar * exp, NumericVar * result) { NumericVar ln_base; NumericVar ln_num; @@ -3415,7 +3429,7 @@ power_var(NumericVar *base, NumericVar *exp, NumericVar *result) global_rscale = save_global_rscale; exp_var(&ln_num, result); - + free_var(&ln_num); free_var(&ln_base); @@ -3441,22 +3455,24 @@ power_var(NumericVar *base, NumericVar *exp, NumericVar *result) * ---------- */ static int -cmp_abs(NumericVar *var1, NumericVar *var2) +cmp_abs(NumericVar * var1, NumericVar * var2) { - int i1 = 0; - int i2 = 0; - int w1 = var1->weight; - int w2 = var2->weight; - int stat; + int i1 = 0; + int i2 = 0; + int w1 = var1->weight; + int w2 = var2->weight; + int stat; while (w1 > w2 && i1 < var1->ndigits) { - if (var1->digits[i1++] != 0) return 1; + if (var1->digits[i1++] != 0) + return 1; w1--; } while (w2 > w1 && i2 < var2->ndigits) { - if (var2->digits[i2++] != 0) return -1; + if (var2->digits[i2++] != 0) + return -1; w2--; } @@ -3497,16 +3513,18 @@ cmp_abs(NumericVar *var1, NumericVar *var2) * ---------- */ static void -add_abs(NumericVar *var1, NumericVar *var2, NumericVar *result) +add_abs(NumericVar * var1, NumericVar * var2, NumericVar * result) { - NumericDigitBuf *res_buf; - NumericDigit *res_digits; - int res_ndigits; - int res_weight; - int res_rscale; - int res_dscale; - int i, i1, i2; - int carry = 0; + NumericDigitBuf *res_buf; + NumericDigit *res_digits; + int res_ndigits; + int res_weight; + int res_rscale; + int res_dscale; + int i, + i1, + i2; + int carry = 0; res_weight = MAX(var1->weight, var2->weight) + 1; res_rscale = MAX(var1->rscale, var2->rscale); @@ -3514,7 +3532,7 @@ add_abs(NumericVar *var1, NumericVar *var2, NumericVar *result) res_ndigits = res_rscale + res_weight + 1; res_buf = digitbuf_alloc(res_ndigits); - res_digits = ((NumericDigit *)res_buf) + sizeof(NumericDigitBuf); + res_digits = ((NumericDigit *) res_buf) + sizeof(NumericDigitBuf); i1 = res_rscale + var1->weight + 1; i2 = res_rscale + var2->weight + 1; @@ -3538,20 +3556,18 @@ add_abs(NumericVar *var1, NumericVar *var2, NumericVar *result) res_ndigits--; } while (res_ndigits > 0 && res_digits[res_ndigits - 1] == 0) - { res_ndigits--; - } if (res_ndigits == 0) res_weight = 0; digitbuf_free(result->buf); result->ndigits = res_ndigits; - result->buf = res_buf; - result->digits = res_digits; - result->weight = res_weight; - result->rscale = res_rscale; - result->dscale = res_dscale; + result->buf = res_buf; + result->digits = res_digits; + result->weight = res_weight; + result->rscale = res_rscale; + result->dscale = res_dscale; } @@ -3566,16 +3582,18 @@ add_abs(NumericVar *var1, NumericVar *var2, NumericVar *result) * ---------- */ static void -sub_abs(NumericVar *var1, NumericVar *var2, NumericVar *result) +sub_abs(NumericVar * var1, NumericVar * var2, NumericVar * result) { - NumericDigitBuf *res_buf; - NumericDigit *res_digits; - int res_ndigits; - int res_weight; - int res_rscale; - int res_dscale; - int i, i1, i2; - int borrow = 0; + NumericDigitBuf *res_buf; + NumericDigit *res_digits; + int res_ndigits; + int res_weight; + int res_rscale; + int res_dscale; + int i, + i1, + i2; + int borrow = 0; res_weight = var1->weight; res_rscale = MAX(var1->rscale, var2->rscale); @@ -3583,7 +3601,7 @@ sub_abs(NumericVar *var1, NumericVar *var2, NumericVar *result) res_ndigits = res_rscale + res_weight + 1; res_buf = digitbuf_alloc(res_ndigits); - res_digits = ((NumericDigit *)res_buf) + sizeof(NumericDigitBuf); + res_digits = ((NumericDigit *) res_buf) + sizeof(NumericDigitBuf); i1 = res_rscale + var1->weight + 1; i2 = res_rscale + var2->weight + 1; @@ -3615,20 +3633,16 @@ sub_abs(NumericVar *var1, NumericVar *var2, NumericVar *result) res_ndigits--; } while (res_ndigits > 0 && res_digits[res_ndigits - 1] == 0) - { res_ndigits--; - } if (res_ndigits == 0) res_weight = 0; digitbuf_free(result->buf); result->ndigits = res_ndigits; - result->buf = res_buf; - result->digits = res_digits; - result->weight = res_weight; - result->rscale = res_rscale; - result->dscale = res_dscale; + result->buf = res_buf; + result->digits = res_digits; + result->weight = res_weight; + result->rscale = res_rscale; + result->dscale = res_dscale; } - - diff --git a/src/backend/utils/adt/numutils.c b/src/backend/utils/adt/numutils.c index 19a0f2d385..413d0fadd8 100644 --- a/src/backend/utils/adt/numutils.c +++ b/src/backend/utils/adt/numutils.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/numutils.c,v 1.29 1999/02/13 23:19:29 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/numutils.c,v 1.30 1999/05/25 16:12:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -55,17 +55,17 @@ pg_atoi(char *s, int size, int c) Assert(s); - errno = 0; + errno = 0; /* - * Some versions of strtol treat the empty string as an error. This + * Some versions of strtol treat the empty string as an error. This * code will explicitly return 0 for an empty string. */ - if (s == (char *)NULL) + if (s == (char *) NULL) elog(ERROR, "pg_atoi: NULL pointer!"); else if (*s == 0) - l = (long)0; + l = (long) 0; else l = strtol(s, &badp, 10); if (errno) /* strtol must set ERANGE */ diff --git a/src/backend/utils/adt/regproc.c b/src/backend/utils/adt/regproc.c index 2e6276f4e2..1db8ddcc05 100644 --- a/src/backend/utils/adt/regproc.c +++ b/src/backend/utils/adt/regproc.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.36 1999/05/10 00:45:59 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.37 1999/05/25 16:12:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -41,9 +41,9 @@ int32 regprocin(char *pro_name_or_oid) { - HeapTuple proctup = NULL; - HeapTupleData tuple; - RegProcedure result = InvalidOid; + HeapTuple proctup = NULL; + HeapTupleData tuple; + RegProcedure result = InvalidOid; if (pro_name_or_oid == NULL) return InvalidOid; @@ -52,6 +52,7 @@ regprocin(char *pro_name_or_oid) if (!IsBootstrapProcessingMode()) { + /* * we need to use the oid because there can be multiple entries * with the same name. We accept int4eq_1323 and 1323. @@ -76,23 +77,23 @@ regprocin(char *pro_name_or_oid) RetrieveIndexResult indexRes; Buffer buffer; int matches = 0; - + ScanKeyEntryInitialize(&skey[0], (bits16) 0x0, (AttrNumber) 1, (RegProcedure) F_NAMEEQ, PointerGetDatum(pro_name_or_oid)); - + hdesc = heap_openr(ProcedureRelationName); idesc = index_openr(ProcedureNameIndex); - + sd = index_beginscan(idesc, false, 1, skey); while ((indexRes = index_getnext(sd, ForwardScanDirection))) { tuple.t_self = indexRes->heap_iptr; heap_fetch(hdesc, SnapshotNow, - &tuple, - &buffer); + &tuple, + &buffer); pfree(indexRes); if (tuple.t_data != NULL) { diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index b953567ad9..62aab38901 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -3,7 +3,7 @@ * out of it's tuple * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.14 1999/05/25 08:49:33 wieck Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.15 1999/05/25 16:12:19 momjian Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -57,16 +57,17 @@ #include "catalog/pg_opclass.h" #include "fmgr.h" -#define BUFSIZE 8192 +#define BUFSIZE 8192 /* ---------- * Local data types * ---------- */ -typedef struct QryHier { - struct QryHier *parent; - Query *query; -} QryHier; +typedef struct QryHier +{ + struct QryHier *parent; + Query *query; +} QryHier; /* ---------- @@ -90,7 +91,7 @@ static char *query_getopclass = "SELECT * FROM pg_opclass WHERE oid = $1"; */ text *pg_get_ruledef(NameData *rname); text *pg_get_viewdef(NameData *rname); -text *pg_get_indexdef(Oid indexrelid); +text *pg_get_indexdef(Oid indexrelid); NameData *pg_get_userbyid(int4 uid); @@ -100,16 +101,16 @@ NameData *pg_get_userbyid(int4 uid); */ static char *make_ruledef(HeapTuple ruletup, TupleDesc rulettc); static char *make_viewdef(HeapTuple ruletup, TupleDesc rulettc); -static char *get_query_def(Query *query, QryHier *parentqh); -static char *get_select_query_def(Query *query, QryHier *qh); -static char *get_insert_query_def(Query *query, QryHier *qh); -static char *get_update_query_def(Query *query, QryHier *qh); -static char *get_delete_query_def(Query *query, QryHier *qh); -static char *get_rule_expr(QryHier *qh, int rt_index, Node *node, bool varprefix); -static char *get_func_expr(QryHier *qh, int rt_index, Expr *expr, bool varprefix); -static char *get_tle_expr(QryHier *qh, int rt_index, TargetEntry *tle, bool varprefix); +static char *get_query_def(Query *query, QryHier * parentqh); +static char *get_select_query_def(Query *query, QryHier * qh); +static char *get_insert_query_def(Query *query, QryHier * qh); +static char *get_update_query_def(Query *query, QryHier * qh); +static char *get_delete_query_def(Query *query, QryHier * qh); +static char *get_rule_expr(QryHier * qh, int rt_index, Node *node, bool varprefix); +static char *get_func_expr(QryHier * qh, int rt_index, Expr *expr, bool varprefix); +static char *get_tle_expr(QryHier * qh, int rt_index, TargetEntry *tle, bool varprefix); static char *get_const_expr(Const *constval); -static char *get_sublink_expr(QryHier *qh, int rt_index, Node *node, bool varprefix); +static char *get_sublink_expr(QryHier * qh, int rt_index, Node *node, bool varprefix); static char *get_relation_name(Oid relid); static char *get_attribute_name(Oid relid, int2 attnum); static bool check_if_rte_used(int rt_index, Node *node, int sup); @@ -314,27 +315,27 @@ pg_get_viewdef(NameData *rname) * only return the SELECT part of a view * ---------- */ -text * +text * pg_get_indexdef(Oid indexrelid) { - text *indexdef; + text *indexdef; HeapTuple ht_idx; HeapTuple ht_idxrel; HeapTuple ht_indrel; HeapTuple spi_tup; TupleDesc spi_ttc; - int spi_fno; - Form_pg_index idxrec; - Form_pg_class idxrelrec; - Form_pg_class indrelrec; + int spi_fno; + Form_pg_index idxrec; + Form_pg_class idxrelrec; + Form_pg_class indrelrec; Datum spi_args[1]; char spi_nulls[2]; - int spirc; - int len; - int keyno; + int spirc; + int len; + int keyno; char buf[BUFSIZE]; char keybuf[BUFSIZE]; - char *sep; + char *sep; /* ---------- * Connect to SPI manager @@ -371,30 +372,30 @@ pg_get_indexdef(Oid indexrelid) * ---------- */ ht_idx = SearchSysCacheTuple(INDEXRELID, - ObjectIdGetDatum(indexrelid), 0, 0, 0); + ObjectIdGetDatum(indexrelid), 0, 0, 0); if (!HeapTupleIsValid(ht_idx)) elog(ERROR, "syscache lookup for index %u failed", indexrelid); - idxrec = (Form_pg_index)GETSTRUCT(ht_idx); + idxrec = (Form_pg_index) GETSTRUCT(ht_idx); /* ---------- * Fetch the pg_class tuple of the index relation * ---------- */ ht_idxrel = SearchSysCacheTuple(RELOID, - ObjectIdGetDatum(idxrec->indexrelid), 0, 0, 0); + ObjectIdGetDatum(idxrec->indexrelid), 0, 0, 0); if (!HeapTupleIsValid(ht_idxrel)) elog(ERROR, "syscache lookup for relid %u failed", idxrec->indexrelid); - idxrelrec = (Form_pg_class)GETSTRUCT(ht_idxrel); + idxrelrec = (Form_pg_class) GETSTRUCT(ht_idxrel); /* ---------- * Fetch the pg_class tuple of the indexed relation * ---------- */ ht_indrel = SearchSysCacheTuple(RELOID, - ObjectIdGetDatum(idxrec->indrelid), 0, 0, 0); + ObjectIdGetDatum(idxrec->indrelid), 0, 0, 0); if (!HeapTupleIsValid(ht_indrel)) elog(ERROR, "syscache lookup for relid %u failed", idxrec->indrelid); - indrelrec = (Form_pg_class)GETSTRUCT(ht_indrel); + indrelrec = (Form_pg_class) GETSTRUCT(ht_indrel); /* ---------- * Get the am name for the index relation @@ -417,11 +418,11 @@ pg_get_indexdef(Oid indexrelid) * ---------- */ sprintf(buf, "CREATE %sINDEX \"%s\" ON \"%s\" USING %s (", - idxrec->indisunique ? "UNIQUE " : "", - nameout(&(idxrelrec->relname)), - nameout(&(indrelrec->relname)), - SPI_getvalue(spi_tup, spi_ttc, spi_fno)); - + idxrec->indisunique ? "UNIQUE " : "", + nameout(&(idxrelrec->relname)), + nameout(&(indrelrec->relname)), + SPI_getvalue(spi_tup, spi_ttc, spi_fno)); + /* ---------- * Collect the indexed attributes * ---------- @@ -445,7 +446,7 @@ pg_get_indexdef(Oid indexrelid) strcat(keybuf, "oid"); else strcat(keybuf, get_attribute_name(idxrec->indrelid, - idxrec->indkey[keyno])); + idxrec->indkey[keyno])); strcat(keybuf, "\""); /* ---------- @@ -478,10 +479,10 @@ pg_get_indexdef(Oid indexrelid) if (idxrec->indproc != InvalidOid) { HeapTuple proctup; - Form_pg_proc procStruct; + Form_pg_proc procStruct; proctup = SearchSysCacheTuple(PROOID, - ObjectIdGetDatum(idxrec->indproc), 0, 0, 0); + ObjectIdGetDatum(idxrec->indproc), 0, 0, 0); if (!HeapTupleIsValid(proctup)) elog(ERROR, "cache lookup for proc %u failed", idxrec->indproc); @@ -508,13 +509,11 @@ pg_get_indexdef(Oid indexrelid) strcat(buf, "\""); } else - /* ---------- - * For the others say 'attr opclass [, ...]' - * ---------- - */ - { + /* ---------- + * For the others say 'attr opclass [, ...]' + * ---------- + */ strcat(buf, keybuf); - } /* ---------- * Finish @@ -551,8 +550,8 @@ NameData * pg_get_userbyid(int4 uid) { HeapTuple usertup; - Form_pg_shadow user_rec; - NameData *result; + Form_pg_shadow user_rec; + NameData *result; /* ---------- * Allocate space for the result @@ -566,16 +565,14 @@ pg_get_userbyid(int4 uid) * ---------- */ usertup = SearchSysCacheTuple(USESYSID, - ObjectIdGetDatum(uid), 0, 0, 0); + ObjectIdGetDatum(uid), 0, 0, 0); if (HeapTupleIsValid(usertup)) { - user_rec = (Form_pg_shadow)GETSTRUCT(usertup); + user_rec = (Form_pg_shadow) GETSTRUCT(usertup); StrNCpy(result->data, (&(user_rec->usename))->data, NAMEDATALEN); } else - { - sprintf((char *)result, "unknown (UID=%d)", uid); - } + sprintf((char *) result, "unknown (UID=%d)", uid); return result; } @@ -683,12 +680,12 @@ make_ruledef(HeapTuple ruletup, TupleDesc rulettc) { Node *qual; Query *query; - QryHier qh; + QryHier qh; qual = stringToNode(ev_qual); query = (Query *) lfirst(actions); qh.parent = NULL; - qh.query = query; + qh.query = query; strcat(buf, " WHERE "); strcat(buf, get_rule_expr(&qh, 0, qual, TRUE)); @@ -809,16 +806,16 @@ make_viewdef(HeapTuple ruletup, TupleDesc rulettc) * ---------- */ static char * -get_query_def(Query *query, QryHier *parentqh) +get_query_def(Query *query, QryHier * parentqh) { QryHier qh; qh.parent = parentqh; - qh.query = query; + qh.query = query; switch (query->commandType) { - case CMD_SELECT: + case CMD_SELECT: return get_select_query_def(query, &qh); break; @@ -853,7 +850,7 @@ get_query_def(Query *query, QryHier *parentqh) * ---------- */ static char * -get_select_query_def(Query *query, QryHier *qh) +get_select_query_def(Query *query, QryHier * qh) { char buf[BUFSIZE]; char *sep; @@ -1023,7 +1020,7 @@ get_select_query_def(Query *query, QryHier *qh) * ---------- */ static char * -get_insert_query_def(Query *query, QryHier *qh) +get_insert_query_def(Query *query, QryHier * qh) { char buf[BUFSIZE]; char *sep; @@ -1133,7 +1130,7 @@ get_insert_query_def(Query *query, QryHier *qh) * ---------- */ static char * -get_update_query_def(Query *query, QryHier *qh) +get_update_query_def(Query *query, QryHier * qh) { char buf[BUFSIZE]; char *sep; @@ -1186,7 +1183,7 @@ get_update_query_def(Query *query, QryHier *qh) * ---------- */ static char * -get_delete_query_def(Query *query, QryHier *qh) +get_delete_query_def(Query *query, QryHier * qh) { char buf[BUFSIZE]; RangeTblEntry *rte; @@ -1220,7 +1217,7 @@ get_delete_query_def(Query *query, QryHier *qh) * ---------- */ static char * -get_rule_expr(QryHier *qh, int rt_index, Node *node, bool varprefix) +get_rule_expr(QryHier * qh, int rt_index, Node *node, bool varprefix) { char buf[BUFSIZE]; @@ -1254,7 +1251,7 @@ get_rule_expr(QryHier *qh, int rt_index, Node *node, bool varprefix) strcat(buf, aggref->aggname); strcat(buf, "\"("); strcat(buf, get_rule_expr(qh, rt_index, - (Node *) (aggref->target), varprefix)); + (Node *) (aggref->target), varprefix)); strcat(buf, ")"); return pstrdup(buf); } @@ -1263,15 +1260,15 @@ get_rule_expr(QryHier *qh, int rt_index, Node *node, bool varprefix) case T_GroupClause: { GroupClause *grp = (GroupClause *) node; - List *l; - TargetEntry *tle = NULL; + List *l; + TargetEntry *tle = NULL; foreach(l, qh->query->targetList) { - if (((TargetEntry *)lfirst(l))->resdom->resgroupref == - grp->tleGroupref) + if (((TargetEntry *) lfirst(l))->resdom->resgroupref == + grp->tleGroupref) { - tle = (TargetEntry *)lfirst(l); + tle = (TargetEntry *) lfirst(l); break; } } @@ -1279,7 +1276,7 @@ get_rule_expr(QryHier *qh, int rt_index, Node *node, bool varprefix) if (tle == NULL) elog(ERROR, "GROUP BY expression not found in targetlist"); - return get_rule_expr(qh, rt_index, (Node *)tle, varprefix); + return get_rule_expr(qh, rt_index, (Node *) tle, varprefix); } break; @@ -1358,9 +1355,10 @@ get_rule_expr(QryHier *qh, int rt_index, Node *node, bool varprefix) { Var *var = (Var *) node; RangeTblEntry *rte; - int sup = var->varlevelsup; + int sup = var->varlevelsup; - while(sup-- > 0) qh = qh->parent; + while (sup-- > 0) + qh = qh->parent; rte = (RangeTblEntry *) nth(var->varno - 1, qh->query->rtable); @@ -1396,9 +1394,7 @@ get_rule_expr(QryHier *qh, int rt_index, Node *node, bool varprefix) break; case T_SubLink: - { return get_sublink_expr(qh, rt_index, node, varprefix); - } break; case T_Const: @@ -1421,7 +1417,7 @@ get_rule_expr(QryHier *qh, int rt_index, Node *node, bool varprefix) * ---------- */ static char * -get_func_expr(QryHier *qh, int rt_index, Expr *expr, bool varprefix) +get_func_expr(QryHier * qh, int rt_index, Expr *expr, bool varprefix) { char buf[BUFSIZE]; HeapTuple proctup; @@ -1500,7 +1496,7 @@ get_func_expr(QryHier *qh, int rt_index, Expr *expr, bool varprefix) * ---------- */ static char * -get_tle_expr(QryHier *qh, int rt_index, TargetEntry *tle, bool varprefix) +get_tle_expr(QryHier * qh, int rt_index, TargetEntry *tle, bool varprefix) { HeapTuple proctup; Form_pg_proc procStruct; @@ -1609,14 +1605,14 @@ get_const_expr(Const *constval) * ---------- */ static char * -get_sublink_expr(QryHier *qh, int rt_index, Node *node, bool varprefix) +get_sublink_expr(QryHier * qh, int rt_index, Node *node, bool varprefix) { SubLink *sublink = (SubLink *) node; Query *query = (Query *) (sublink->subselect); - Expr *expr; + Expr *expr; List *l; char *sep; - char buf[BUFSIZE]; + char buf[BUFSIZE]; buf[0] = '\0'; @@ -1640,32 +1636,33 @@ get_sublink_expr(QryHier *qh, int rt_index, Node *node, bool varprefix) strcat(buf, " "); } - switch (sublink->subLinkType) { + switch (sublink->subLinkType) + { case EXISTS_SUBLINK: strcat(buf, "EXISTS "); break; case ANY_SUBLINK: - expr = (Expr *)lfirst(sublink->oper); + expr = (Expr *) lfirst(sublink->oper); strcat(buf, get_opname(((Oper *) (expr->oper))->opno)); strcat(buf, " ANY "); break; case ALL_SUBLINK: - expr = (Expr *)lfirst(sublink->oper); + expr = (Expr *) lfirst(sublink->oper); strcat(buf, get_opname(((Oper *) (expr->oper))->opno)); strcat(buf, " ALL "); break; case EXPR_SUBLINK: - expr = (Expr *)lfirst(sublink->oper); + expr = (Expr *) lfirst(sublink->oper); strcat(buf, get_opname(((Oper *) (expr->oper))->opno)); strcat(buf, " "); break; default: elog(ERROR, "unupported sublink type %d", - sublink->subLinkType); + sublink->subLinkType); break; } diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c index 53310bf1b3..fc65ddc3f9 100644 --- a/src/backend/utils/adt/selfuncs.c +++ b/src/backend/utils/adt/selfuncs.c @@ -12,7 +12,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.27 1999/05/10 00:46:00 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.28 1999/05/25 16:12:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -393,6 +393,7 @@ btreesel(Oid operatorObjectId, if (FunctionalSelectivity(nIndexKeys, attributeNumber)) { + /* * Need to call the functions selectivity function here. For now * simply assume it's 1/3 since functions don't currently have @@ -437,6 +438,7 @@ btreenpage(Oid operatorObjectId, if (FunctionalSelectivity(nIndexKeys, attributeNumber)) { + /* * Need to call the functions selectivity function here. For now * simply assume it's 1/3 since functions don't currently have diff --git a/src/backend/utils/adt/varchar.c b/src/backend/utils/adt/varchar.c index 1233955c4f..cb0982a52d 100644 --- a/src/backend/utils/adt/varchar.c +++ b/src/backend/utils/adt/varchar.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.45 1999/05/19 17:53:11 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.46 1999/05/25 16:12:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -82,7 +82,7 @@ bpcharin(char *s, int dummy, int32 atttypmod) len = atttypmod - VARHDRSZ; if (len > BLCKSZ - 128) - elog(ERROR, "bpcharin: length of char() must be less than %d",BLCKSZ-128); + elog(ERROR, "bpcharin: length of char() must be less than %d", BLCKSZ - 128); result = (char *) palloc(atttypmod); VARSIZE(result) = atttypmod; @@ -152,7 +152,7 @@ bpchar(char *s, int32 len) rlen = len - VARHDRSZ; if (rlen > BLCKSZ - 128) - elog(ERROR, "bpchar: length of char() must be less than %d",BLCKSZ-128); + elog(ERROR, "bpchar: length of char() must be less than %d", BLCKSZ - 128); #ifdef STRINGDEBUG printf("bpchar- convert string length %d (%d) ->%d (%d)\n", @@ -163,13 +163,15 @@ bpchar(char *s, int32 len) VARSIZE(result) = len; r = VARDATA(result); #ifdef MULTIBYTE - /* truncate multi-byte string in a way not to break - multi-byte boundary */ - if (VARSIZE(s) > len) { - slen = pg_mbcliplen(VARDATA(s), VARSIZE(s)-VARHDRSZ, rlen); - } else { + + /* + * truncate multi-byte string in a way not to break multi-byte + * boundary + */ + if (VARSIZE(s) > len) + slen = pg_mbcliplen(VARDATA(s), VARSIZE(s) - VARHDRSZ, rlen); + else slen = VARSIZE(s) - VARHDRSZ; - } #else slen = VARSIZE(s) - VARHDRSZ; #endif @@ -206,7 +208,7 @@ bpchar(char *s, int32 len) * Converts an array of char() type to a specific internal length. * len is the length specified in () plus VARHDRSZ bytes. */ -ArrayType * +ArrayType * _bpchar(ArrayType *v, int32 len) { return array_map(v, BPCHAROID, bpchar, BPCHAROID, 1, len); @@ -331,7 +333,7 @@ varcharin(char *s, int dummy, int32 atttypmod) len = atttypmod; /* clip the string at max length */ if (len > BLCKSZ - 128) - elog(ERROR, "varcharin: length of char() must be less than %d",BLCKSZ-128); + elog(ERROR, "varcharin: length of char() must be less than %d", BLCKSZ - 128); result = (char *) palloc(len); VARSIZE(result) = len; @@ -390,15 +392,18 @@ varchar(char *s, int32 slen) /* only reach here if we need to truncate string... */ #ifdef MULTIBYTE - /* truncate multi-byte string in a way not to break - multi-byte boundary */ + + /* + * truncate multi-byte string in a way not to break multi-byte + * boundary + */ len = pg_mbcliplen(VARDATA(s), slen - VARHDRSZ, slen - VARHDRSZ); slen = len + VARHDRSZ; #else len = slen - VARHDRSZ; #endif - if (len > BLCKSZ-128) + if (len > BLCKSZ - 128) elog(ERROR, "varchar: length of varchar() must be less than BLCKSZ-128"); result = (char *) palloc(slen); @@ -412,7 +417,7 @@ varchar(char *s, int32 slen) * Converts an array of varchar() type to the specified size. * len is the length specified in () plus VARHDRSZ bytes. */ -ArrayType * +ArrayType * _varchar(ArrayType *v, int32 len) { return array_map(v, VARCHAROID, varchar, VARCHAROID, 1, len); diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c index 12095816fa..b649ef225a 100644 --- a/src/backend/utils/adt/varlena.c +++ b/src/backend/utils/adt/varlena.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.47 1999/02/13 23:19:36 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.48 1999/05/25 16:12:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -314,7 +314,7 @@ textcat(text *t1, text *t2) * - string length * * If the starting position is zero or less, then return from the start of the string - * adjusting the length to be consistant with the "negative start" per SQL92. + * adjusting the length to be consistant with the "negative start" per SQL92. * If the length is less than zero, return the remaining string. * * Note that the arguments operate on octet length, @@ -352,11 +352,14 @@ text_substr(text *string, int32 m, int32 n) m = 1; n = 0; } - /* starting position before the start of the string? - * then offset into the string per SQL92 spec... */ + + /* + * starting position before the start of the string? then offset into + * the string per SQL92 spec... + */ else if (m < 1) { - n += (m-1); + n += (m - 1); m = 1; } @@ -588,10 +591,10 @@ text_ge(text *arg1, text *arg2) text * text_larger(text *arg1, text *arg2) { - text *result; - text *temp; + text *result; + text *temp; - temp = ((text_cmp(arg1, arg2) <= 0)? arg2: arg1); + temp = ((text_cmp(arg1, arg2) <= 0) ? arg2 : arg1); /* Make a copy */ @@ -604,10 +607,10 @@ text_larger(text *arg1, text *arg2) text * text_smaller(text *arg1, text *arg2) { - text *result; - text *temp; + text *result; + text *temp; - temp = ((text_cmp(arg1, arg2) > 0)? arg2: arg1); + temp = ((text_cmp(arg1, arg2) > 0) ? arg2 : arg1); /* Make a copy */ diff --git a/src/backend/utils/cache/catcache.c b/src/backend/utils/cache/catcache.c index 869df05df7..80444d0a14 100644 --- a/src/backend/utils/cache/catcache.c +++ b/src/backend/utils/cache/catcache.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.40 1999/05/10 00:46:03 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.41 1999/05/25 16:12:22 momjian Exp $ * * Notes: * XXX This needs to use exception.h to handle recovery when @@ -196,6 +196,7 @@ CatalogCacheInitializeCache(struct catcache * cache, if (cache->cc_key[i] > 0) { + /* * Yoiks. The implementation of the hashing code and the * implementation of int28's are at loggerheads. The right @@ -277,7 +278,7 @@ CatalogCacheSetId(CatCache *cacheInOutP, int id) #endif /* ---------------- - * comphash + * comphash * Compute a hash value, somehow. * * XXX explain algorithm here. diff --git a/src/backend/utils/cache/inval.c b/src/backend/utils/cache/inval.c index 40155b36aa..7cf66e2280 100644 --- a/src/backend/utils/cache/inval.c +++ b/src/backend/utils/cache/inval.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.22 1999/05/10 00:46:07 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.23 1999/05/25 16:12:23 momjian Exp $ * * Note - this code is real crufty... * @@ -106,7 +106,7 @@ InvalidationEntryAllocate(uint16 size) } /* -------------------------------- - * LocalInvalidRegister + * LocalInvalidRegister * Returns a new local cache invalidation state containing a new entry. * -------------------------------- */ @@ -117,7 +117,7 @@ LocalInvalidRegister(LocalInvalid invalid, Assert(PointerIsValid(entry)); ((InvalidationUserData *) entry)->dataP[-1] = - (InvalidationUserData *) invalid; + (InvalidationUserData *) invalid; return entry; } @@ -504,7 +504,7 @@ InitLocalInvalidateData() /* - * DiscardInvalid + * DiscardInvalid * Causes the invalidated cache state to be discarded. * * Note: @@ -527,7 +527,7 @@ DiscardInvalid() } /* - * RegisterInvalid + * RegisterInvalid * Causes registration of invalidated state with other backends iff true. * * Note: @@ -559,7 +559,7 @@ RegisterInvalid(bool send) } /* - * RelationIdInvalidateHeapTuple + * RelationIdInvalidateHeapTuple * Causes the given tuple in a relation to be invalidated. * * Note: diff --git a/src/backend/utils/cache/rel.c b/src/backend/utils/cache/rel.c index 0603f67552..f37a97b34f 100644 --- a/src/backend/utils/cache/rel.c +++ b/src/backend/utils/cache/rel.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/rel.c,v 1.4 1999/02/13 23:19:43 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/rel.c,v 1.5 1999/05/25 16:12:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -29,7 +29,7 @@ */ /* - * RelationGetIndexStrategy + * RelationGetIndexStrategy * Returns index strategy for a relation. * * Note: @@ -43,7 +43,7 @@ RelationGetIndexStrategy(Relation relation) } /* - * RelationSetIndexSupport + * RelationSetIndexSupport * Sets index strategy and support info for a relation. * * Note: diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c index 4affb0f6ae..f8c73b7b22 100644 --- a/src/backend/utils/cache/relcache.c +++ b/src/backend/utils/cache/relcache.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.61 1999/05/10 00:46:08 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.62 1999/05/25 16:12:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -396,7 +396,7 @@ scan_pg_rel_ind(RelationBuildDescInfo buildinfo) switch (buildinfo.infotype) { case INFO_RELID: - return_tuple = ClassOidIndexScan(pg_class_desc,buildinfo.i.info_id); + return_tuple = ClassOidIndexScan(pg_class_desc, buildinfo.i.info_id); break; case INFO_RELNAME: @@ -707,20 +707,20 @@ RelationBuildRuleLock(Relation relation) rule->event = (int) heap_getattr(pg_rewrite_tuple, Anum_pg_rewrite_ev_type, pg_rewrite_tupdesc, - &isnull) - 48; + &isnull) - 48; rule->attrno = (int) heap_getattr(pg_rewrite_tuple, Anum_pg_rewrite_ev_attr, pg_rewrite_tupdesc, - &isnull); + &isnull); rule->isInstead = !!heap_getattr(pg_rewrite_tuple, - Anum_pg_rewrite_is_instead, pg_rewrite_tupdesc, - &isnull); + Anum_pg_rewrite_is_instead, pg_rewrite_tupdesc, + &isnull); ruleaction = heap_getattr(pg_rewrite_tuple, - Anum_pg_rewrite_ev_action, pg_rewrite_tupdesc, - &isnull); + Anum_pg_rewrite_ev_action, pg_rewrite_tupdesc, + &isnull); rule_evqual_string = heap_getattr(pg_rewrite_tuple, - Anum_pg_rewrite_ev_qual, pg_rewrite_tupdesc, - &isnull); + Anum_pg_rewrite_ev_qual, pg_rewrite_tupdesc, + &isnull); ruleaction = PointerGetDatum(textout((struct varlena *) DatumGetPointer(ruleaction))); rule_evqual_string = PointerGetDatum(textout((struct varlena *) DatumGetPointer(rule_evqual_string))); @@ -851,9 +851,7 @@ RelationBuildDesc(RelationBuildDescInfo buildinfo) * ---------------- */ if (OidIsValid(relam)) - { relation->rd_am = (Form_pg_am) AccessMethodObjectIdGetForm(relam); - } /* ---------------- * initialize the tuple descriptor (relation->rd_att). @@ -1331,13 +1329,13 @@ RelationForgetRelation(Oid rid) MemoryContext oldcxt; List *curr; List *prev = NIL; - + oldcxt = MemoryContextSwitchTo((MemoryContext) CacheCxt); - + foreach(curr, newlyCreatedRelns) { Relation reln = lfirst(curr); - + Assert(reln != NULL && reln->rd_myxactonly); if (RelationGetRelid(reln) == rid) break; @@ -1353,7 +1351,7 @@ RelationForgetRelation(Oid rid) pfree(curr); MemoryContextSwitchTo(oldcxt); } - + RelationFlushRelation(&relation, false); } } @@ -1378,6 +1376,7 @@ RelationIdInvalidateRelationCacheByRelationId(Oid relationId) */ if (PointerIsValid(relation) && !relation->rd_myxactonly) { + /* * The boolean onlyFlushReferenceCountZero in RelationFlushReln() * should be set to true when we are incrementing the command @@ -1484,8 +1483,8 @@ RelationRegisterRelation(Relation relation) /* * we've just created the relation. It is invisible to anyone else - * before the transaction is committed. Setting rd_myxactonly allows us - * to use the local buffer manager for select/insert/etc before the + * before the transaction is committed. Setting rd_myxactonly allows + * us to use the local buffer manager for select/insert/etc before the * end of transaction. (We also need to keep track of relations * created during a transaction and does the necessary clean up at the * end of the transaction.) - ay 3/95 @@ -1634,7 +1633,7 @@ AttrDefaultFetch(Relation relation) Relation adrel; Relation irel; ScanKeyData skey; - HeapTupleData tuple; + HeapTupleData tuple; Form_pg_attrdef adform; IndexScanDesc sd; RetrieveIndexResult indexRes; @@ -1722,7 +1721,7 @@ RelCheckFetch(Relation relation) Relation rcrel; Relation irel; ScanKeyData skey; - HeapTupleData tuple; + HeapTupleData tuple; IndexScanDesc sd; RetrieveIndexResult indexRes; Name rcname; diff --git a/src/backend/utils/cache/syscache.c b/src/backend/utils/cache/syscache.c index bd583ac0ce..6eb0ed3527 100644 --- a/src/backend/utils/cache/syscache.c +++ b/src/backend/utils/cache/syscache.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.24 1999/02/13 23:19:45 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.25 1999/05/25 16:12:23 momjian Exp $ * * NOTES * These routines allow the parser/planner/executor to perform @@ -421,11 +421,11 @@ InitCatalogCache() Assert(!PointerIsValid((Pointer) SysCache[cacheId])); SysCache[cacheId] = InitSysCache(cacheinfo[cacheId].name, - cacheinfo[cacheId].indname, - cacheId, - cacheinfo[cacheId].nkeys, - cacheinfo[cacheId].key, - cacheinfo[cacheId].iScanFunc); + cacheinfo[cacheId].indname, + cacheId, + cacheinfo[cacheId].nkeys, + cacheinfo[cacheId].key, + cacheinfo[cacheId].iScanFunc); if (!PointerIsValid((char *) SysCache[cacheId])) { elog(ERROR, @@ -492,11 +492,11 @@ SearchSysCacheTuple(int cacheId,/* cache selection code */ if (!PointerIsValid(SysCache[cacheId])) { SysCache[cacheId] = InitSysCache(cacheinfo[cacheId].name, - cacheinfo[cacheId].indname, - cacheId, - cacheinfo[cacheId].nkeys, - cacheinfo[cacheId].key, - cacheinfo[cacheId].iScanFunc); + cacheinfo[cacheId].indname, + cacheId, + cacheinfo[cacheId].nkeys, + cacheinfo[cacheId].key, + cacheinfo[cacheId].iScanFunc); if (!PointerIsValid(SysCache[cacheId])) elog(ERROR, "InitCatalogCache: Can't init cache %s(%d)", diff --git a/src/backend/utils/cache/temprel.c b/src/backend/utils/cache/temprel.c index 60c949fa43..9e9faaf8ab 100644 --- a/src/backend/utils/cache/temprel.c +++ b/src/backend/utils/cache/temprel.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/temprel.c,v 1.2 1999/02/13 23:19:45 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/temprel.c,v 1.3 1999/05/25 16:12:24 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -47,16 +47,16 @@ static List *temp_rels = NIL; typedef struct TempTable { - char *user_relname; + char *user_relname; HeapTuple pg_class_tuple; -} TempTable; +} TempTable; void create_temp_relation(char *relname, HeapTuple pg_class_tuple) { MemoryContext oldcxt; - TempTable *temp_rel; + TempTable *temp_rel; oldcxt = MemoryContextSwitchTo((MemoryContext) CacheCxt); @@ -65,7 +65,7 @@ create_temp_relation(char *relname, HeapTuple pg_class_tuple) /* save user-supplied name */ strcpy(temp_rel->user_relname, relname); - + temp_rel->pg_class_tuple = heap_copytuple(pg_class_tuple); temp_rels = lcons(temp_rel, temp_rels); @@ -76,24 +76,25 @@ create_temp_relation(char *relname, HeapTuple pg_class_tuple) void remove_all_temp_relations(void) { - List *l, *next; + List *l, + *next; l = temp_rels; while (l != NIL) { - TempTable *temp_rel = lfirst(l); + TempTable *temp_rel = lfirst(l); Form_pg_class classtuple; - classtuple = (Form_pg_class)GETSTRUCT(temp_rel->pg_class_tuple); + classtuple = (Form_pg_class) GETSTRUCT(temp_rel->pg_class_tuple); - next = lnext(l); /* do this first, l is deallocated */ + next = lnext(l); /* do this first, l is deallocated */ if (classtuple->relkind != RELKIND_INDEX) { - char relname[NAMEDATALEN]; + char relname[NAMEDATALEN]; /* safe from deallocation */ - strcpy(relname, temp_rel->user_relname); + strcpy(relname, temp_rel->user_relname); heap_destroy_with_catalog(relname); } else @@ -109,15 +110,16 @@ remove_temp_relation(Oid relid) { MemoryContext oldcxt; - List *l, *prev; - + List *l, + *prev; + oldcxt = MemoryContextSwitchTo((MemoryContext) CacheCxt); prev = NIL; l = temp_rels; while (l != NIL) { - TempTable *temp_rel = lfirst(l); + TempTable *temp_rel = lfirst(l); if (temp_rel->pg_class_tuple->t_data->t_oid == relid) { @@ -152,11 +154,11 @@ remove_temp_relation(Oid relid) HeapTuple get_temp_rel_by_name(char *user_relname) { - List *l; + List *l; foreach(l, temp_rels) { - TempTable *temp_rel = lfirst(l); + TempTable *temp_rel = lfirst(l); if (strcmp(temp_rel->user_relname, user_relname) == 0) return temp_rel->pg_class_tuple; diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index 588f378b5d..283cb01b1f 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.44 1999/05/10 00:46:11 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.45 1999/05/25 16:12:24 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -55,7 +55,7 @@ static int Err_file = -1; static int ElogDebugIndentLevel = 0; /* - * elog + * elog * Old error logging function. */ void @@ -167,7 +167,7 @@ elog(int lev, const char *fmt,...) * front-end program, write to it first. This is important because * there's a bug in the socket code on ultrix. If the front end has * gone away (so the channel to it has been closed at the other end), - * then writing here can cause this backend to exit without warning + * then writing here can cause this backend to exit without warning * that is, write() does an exit(). In this case, our only hope of * finding out what's going on is if Err_file was set to some disk * log. This is a major pain. @@ -190,26 +190,32 @@ elog(int lev, const char *fmt,...) if (IsUnderPostmaster && lev > DEBUG) { /* notices are not errors, handle 'em differently */ - char msgtype; + char msgtype; + if (lev == NOTICE) msgtype = 'N'; else { - /* Abort any COPY OUT in progress when an error is detected. - * This hack is necessary because of poor design of copy protocol. + + /* + * Abort any COPY OUT in progress when an error is detected. + * This hack is necessary because of poor design of copy + * protocol. */ pq_endcopyout(true); msgtype = 'E'; } /* exclude the timestamp from msg sent to frontend */ pq_puttextmessage(msgtype, line + TIMESTAMP_SIZE); + /* * This flush is normally not necessary, since postgres.c will * flush out waiting data when control returns to the main loop. * But it seems best to leave it here, so that the client has some - * clue what happened if the backend dies before getting back to the - * main loop ... error/notice messages should not be a performance- - * critical path anyway, so an extra flush won't hurt much ... + * clue what happened if the backend dies before getting back to + * the main loop ... error/notice messages should not be a + * performance- critical path anyway, so an extra flush won't hurt + * much ... */ pq_flush(); } diff --git a/src/backend/utils/error/exc.c b/src/backend/utils/error/exc.c index aa556a6247..7384847d18 100644 --- a/src/backend/utils/error/exc.c +++ b/src/backend/utils/error/exc.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/exc.c,v 1.24 1999/02/13 23:19:48 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/exc.c,v 1.25 1999/05/25 16:12:26 momjian Exp $ * * NOTE * XXX this code needs improvement--check for state violations and @@ -48,7 +48,7 @@ extern char *ProgramName; */ /* - * EnableExceptionHandling + * EnableExceptionHandling * Enables/disables the exception handling system. * * Note: diff --git a/src/backend/utils/error/excid.c b/src/backend/utils/error/excid.c index bc92609e2b..70842f3b56 100644 --- a/src/backend/utils/error/excid.c +++ b/src/backend/utils/error/excid.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/excid.c,v 1.5 1999/02/13 23:19:48 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/excid.c,v 1.6 1999/05/25 16:12:26 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -22,19 +22,19 @@ /* - * FailedAssertion + * FailedAssertion * Indicates an Assert(...) failed. */ Exception FailedAssertion = {"Failed Assertion"}; /* - * BadState + * BadState * Indicates a function call request is inconsistent with module state. */ Exception BadState = {"Bad State for Function Call"}; /* - * BadArg + * BadArg * Indicates a function call argument or arguments is out-of-bounds. */ Exception BadArg = {"Bad Argument to Function Call"}; @@ -44,19 +44,19 @@ Exception BadArg = {"Bad Argument to Function Call"}; *****************************************************************************/ /* - * BadAllocSize + * BadAllocSize * Indicates that an allocation request is of unreasonable size. */ Exception BadAllocSize = {"Too Large Allocation Request"}; /* - * ExhaustedMemory + * ExhaustedMemory * Indicates an dynamic memory allocation failed. */ Exception ExhaustedMemory = {"Memory Allocation Failed"}; /* - * Unimplemented + * Unimplemented * Indicates a function call request requires unimplemented code. */ Exception Unimplemented = {"Unimplemented Functionality"}; diff --git a/src/backend/utils/error/format.c b/src/backend/utils/error/format.c index dcc27cec02..f56e3f05b3 100644 --- a/src/backend/utils/error/format.c +++ b/src/backend/utils/error/format.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/format.c,v 1.10 1999/02/13 23:19:49 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/format.c,v 1.11 1999/05/25 16:12:26 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -29,6 +29,7 @@ char * form(const char *fmt,...) { va_list args; + va_start(args, fmt); vsnprintf(FormBuf, FormMaxSize - 1, fmt, args); va_end(args); diff --git a/src/backend/utils/fmgr/dfmgr.c b/src/backend/utils/fmgr/dfmgr.c index 4b625bfc7c..7d9b79575f 100644 --- a/src/backend/utils/fmgr/dfmgr.c +++ b/src/backend/utils/fmgr/dfmgr.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.25 1999/05/22 19:49:41 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.26 1999/05/25 16:12:27 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -237,14 +237,14 @@ void load_file(char *filename) { DynamicFileList *file_scanner, - *p; + *p; struct stat stat_buf; int done = 0; /* - * We need to do stat() in order to determine whether this is the - * same file as a previously loaded file; it's also handy so as to - * give a good error message if bogus file name given. + * We need to do stat() in order to determine whether this is the same + * file as a previously loaded file; it's also handy so as to give a + * good error message if bogus file name given. */ if (stat(filename, &stat_buf) == -1) elog(ERROR, "LOAD: could not open file '%s': %m", filename); @@ -292,4 +292,5 @@ trigger_dynamic(char *filename, char *funcname) return trigger_fn; } + #endif diff --git a/src/backend/utils/fmgr/fmgr.c b/src/backend/utils/fmgr/fmgr.c index 09f9a16113..d5b24cf341 100644 --- a/src/backend/utils/fmgr/fmgr.c +++ b/src/backend/utils/fmgr/fmgr.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.27 1999/05/10 04:02:05 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.28 1999/05/25 16:12:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -81,8 +81,10 @@ fmgr_pl(char *arg0,...) static char * fmgr_untrusted(char *arg0,...) { - /* Currently these are unsupported. Someday we might do something like - * forking a subprocess to execute 'em. + + /* + * Currently these are unsupported. Someday we might do something + * like forking a subprocess to execute 'em. */ elog(ERROR, "Untrusted functions not supported."); return NULL; /* keep compiler happy */ @@ -96,9 +98,11 @@ fmgr_untrusted(char *arg0,...) static char * fmgr_sql(char *arg0,...) { + /* - * XXX It'd be really nice to support SQL functions anywhere that builtins - * are supported. What would we have to do? What pitfalls are there? + * XXX It'd be really nice to support SQL functions anywhere that + * builtins are supported. What would we have to do? What pitfalls + * are there? */ elog(ERROR, "SQL-language function not supported in this context."); return NULL; /* keep compiler happy */ @@ -215,14 +219,18 @@ fmgr_info(Oid procedureId, FmgrInfo *finfo) if ((fcp = fmgr_isbuiltin(procedureId)) != NULL) { - /* Fast path for builtin functions: don't bother consulting pg_proc */ + + /* + * Fast path for builtin functions: don't bother consulting + * pg_proc + */ finfo->fn_addr = fcp->func; finfo->fn_nargs = fcp->nargs; } else { procedureTuple = SearchSysCacheTuple(PROOID, - ObjectIdGetDatum(procedureId), + ObjectIdGetDatum(procedureId), 0, 0, 0); if (!HeapTupleIsValid(procedureTuple)) { @@ -240,14 +248,16 @@ fmgr_info(Oid procedureId, FmgrInfo *finfo) switch (language) { case INTERNALlanguageId: + /* - * For an ordinary builtin function, we should never get here - * because the isbuiltin() search above will have succeeded. - * However, if the user has done a CREATE FUNCTION to create - * an alias for a builtin function, we end up here. In that - * case we have to look up the function by name. The name - * of the internal function is stored in prosrc (it doesn't - * have to be the same as the name of the alias!) + * For an ordinary builtin function, we should never get + * here because the isbuiltin() search above will have + * succeeded. However, if the user has done a CREATE + * FUNCTION to create an alias for a builtin function, we + * end up here. In that case we have to look up the + * function by name. The name of the internal function is + * stored in prosrc (it doesn't have to be the same as the + * name of the alias!) */ prosrc = textout(&(procedureStruct->prosrc)); finfo->fn_addr = fmgr_lookupByName(prosrc); diff --git a/src/backend/utils/hash/dynahash.c b/src/backend/utils/hash/dynahash.c index dd601bee74..933533b754 100644 --- a/src/backend/utils/hash/dynahash.c +++ b/src/backend/utils/hash/dynahash.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/hash/dynahash.c,v 1.21 1999/03/07 23:03:32 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/hash/dynahash.c,v 1.22 1999/05/25 16:12:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -175,8 +175,10 @@ hash_create(int nelem, HASHCTL *info, int flags) if (flags & HASH_SHARED_MEM) { - /* ctl structure is preallocated for shared memory tables. - * Note that HASH_DIRSIZE had better be set as well. + + /* + * ctl structure is preallocated for shared memory tables. Note + * that HASH_DIRSIZE had better be set as well. */ hashp->hctl = (HHDR *) info->hctl; @@ -296,9 +298,9 @@ init_htab(HTAB *hashp, int nelem) hctl = hashp->hctl; /* - * Divide number of elements by the fill factor to determine a - * desired number of buckets. Allocate space for the next greater - * power of two number of buckets + * Divide number of elements by the fill factor to determine a desired + * number of buckets. Allocate space for the next greater power of + * two number of buckets */ nelem = (nelem - 1) / hctl->ffactor + 1; @@ -308,14 +310,15 @@ init_htab(HTAB *hashp, int nelem) hctl->high_mask = (nbuckets << 1) - 1; /* - * Figure number of directory segments needed, round up to a power of 2 + * Figure number of directory segments needed, round up to a power of + * 2 */ nsegs = (nbuckets - 1) / hctl->ssize + 1; nsegs = 1 << my_log2(nsegs); /* - * Make sure directory is big enough. - * If pre-allocated directory is too small, choke (caller screwed up). + * Make sure directory is big enough. If pre-allocated directory is + * too small, choke (caller screwed up). */ if (nsegs > hctl->dsize) { @@ -371,12 +374,12 @@ init_htab(HTAB *hashp, int nelem) long hash_estimate_size(long num_entries, long keysize, long datasize) { - long size = 0; - long nBuckets, - nSegments, - nDirEntries, - nRecordAllocs, - recordSize; + long size = 0; + long nBuckets, + nSegments, + nDirEntries, + nRecordAllocs, + recordSize; /* estimate number of buckets wanted */ nBuckets = 1L << my_log2((num_entries - 1) / DEF_FFACTOR + 1); @@ -388,7 +391,7 @@ hash_estimate_size(long num_entries, long keysize, long datasize) nDirEntries <<= 1; /* dir_alloc doubles dsize at each call */ /* fixed control info */ - size += MAXALIGN(sizeof(HHDR)); /* but not HTAB, per above */ + size += MAXALIGN(sizeof(HHDR)); /* but not HTAB, per above */ /* directory */ size += MAXALIGN(nDirEntries * sizeof(SEG_OFFSET)); /* segments */ @@ -665,8 +668,10 @@ hash_search(HTAB *hashp, */ if (++hctl->nkeys / (hctl->max_bucket + 1) > hctl->ffactor) { - /* NOTE: failure to expand table is not a fatal error, - * it just means we have to run at higher fill factor than we wanted. + + /* + * NOTE: failure to expand table is not a fatal error, it just + * means we have to run at higher fill factor than we wanted. */ expand_table(hashp); } @@ -778,7 +783,7 @@ expand_table(HTAB *hashp) { /* Allocate new segment if necessary -- could fail if dir full */ if (new_segnum >= hctl->dsize) - if (! dir_realloc(hashp)) + if (!dir_realloc(hashp)) return 0; if (!(hashp->dir[new_segnum] = seg_alloc(hashp))) return 0; @@ -872,7 +877,7 @@ seg_alloc(HTAB *hashp) SEG_OFFSET segOffset; segp = (SEGMENT) hashp->alloc((unsigned long) - sizeof(BUCKET_INDEX) * hashp->hctl->ssize); + sizeof(BUCKET_INDEX) * hashp->hctl->ssize); if (!segp) return 0; @@ -917,8 +922,9 @@ bucket_alloc(HTAB *hashp) lastIndex = hashp->hctl->freeBucketIndex; hashp->hctl->freeBucketIndex = tmpIndex; - /* initialize each bucket to point to the one behind it. - * NOTE: loop sets last bucket incorrectly; we fix below. + /* + * initialize each bucket to point to the one behind it. NOTE: loop + * sets last bucket incorrectly; we fix below. */ for (i = 0; i < BUCKET_ALLOC_INCR; i++) { diff --git a/src/backend/utils/init/enbl.c b/src/backend/utils/init/enbl.c index b772ba0d10..78c5ab1040 100644 --- a/src/backend/utils/init/enbl.c +++ b/src/backend/utils/init/enbl.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/init/Attic/enbl.c,v 1.6 1999/02/13 23:19:59 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/init/Attic/enbl.c,v 1.7 1999/05/25 16:12:33 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -15,7 +15,7 @@ #include "utils/module.h" /* where the declarations go */ /* - * BypassEnable + * BypassEnable * False iff enable/disable processing is required given on and "*countP." * * Note: diff --git a/src/backend/utils/init/findbe.c b/src/backend/utils/init/findbe.c index ada3f65c41..783f8ac1b9 100644 --- a/src/backend/utils/init/findbe.c +++ b/src/backend/utils/init/findbe.c @@ -1,12 +1,12 @@ /*------------------------------------------------------------------------- * - * findbe.c + * findbe.c * * Copyright (c) 1994, Regents of the University of California * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/init/Attic/findbe.c,v 1.13 1999/02/13 23:20:00 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/init/Attic/findbe.c,v 1.14 1999/05/25 16:12:33 momjian Exp $ * *------------------------------------------------------------------------- */ diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c index 588cb060fd..1d4225e582 100644 --- a/src/backend/utils/init/globals.c +++ b/src/backend/utils/init/globals.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.29 1999/05/22 17:47:46 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.30 1999/05/25 16:12:34 momjian Exp $ * * NOTES * Globals used all over the place should be declared here and not @@ -46,6 +46,7 @@ struct Port *MyProcPort; long MyCancelKey; char *DataDir = NULL; + /* * The PGDATA directory user says to use, or defaults to via environment * variable. NULL if no option given and no environment variable set diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c index ce6c4ca321..86328bbd56 100644 --- a/src/backend/utils/init/miscinit.c +++ b/src/backend/utils/init/miscinit.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.28 1999/05/22 17:47:46 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.29 1999/05/25 16:12:35 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -40,7 +40,7 @@ #include "storage/ipc.h" /* for proc_exit */ /* - * EnableAbortEnvVarName + * EnableAbortEnvVarName * Enables system abort iff set to a non-empty string in environment. */ #define EnableAbortEnvVarName "POSTGRESABORT" @@ -69,7 +69,7 @@ unsigned char RecodeBackTable[128]; */ /* - * ExitPostgres + * ExitPostgres * Exit POSTGRES with a status code. * * Note: @@ -89,7 +89,7 @@ ExitPostgres(ExitStatus status) } /* - * AbortPostgres + * AbortPostgres * Abort POSTGRES dumping core. * * Note: @@ -138,6 +138,7 @@ StatusPostmasterExit(int status) /* someday, do some real cleanup and then call the LISP exit */ proc_exit(status); } + #endif @@ -149,7 +150,7 @@ static ProcessingMode Mode = NoProcessing; #ifdef NOT_USED /* - * IsNoProcessingMode + * IsNoProcessingMode * True iff processing mode is NoProcessing. */ bool @@ -157,10 +158,11 @@ IsNoProcessingMode() { return (bool) (Mode == NoProcessing); } + #endif /* - * IsBootstrapProcessingMode + * IsBootstrapProcessingMode * True iff processing mode is BootstrapProcessing. */ bool @@ -170,7 +172,7 @@ IsBootstrapProcessingMode() } /* - * IsInitProcessingMode + * IsInitProcessingMode * True iff processing mode is InitProcessing. */ bool @@ -180,7 +182,7 @@ IsInitProcessingMode() } /* - * IsNormalProcessingMode + * IsNormalProcessingMode * True iff processing mode is NormalProcessing. */ bool @@ -190,7 +192,7 @@ IsNormalProcessingMode() } /* - * SetProcessingMode + * SetProcessingMode * Sets mode of processing as specified. * * Exceptions: diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c index e93480da1d..0c2711483f 100644 --- a/src/backend/utils/init/postinit.c +++ b/src/backend/utils/init/postinit.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.39 1999/02/22 19:55:43 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.40 1999/05/25 16:12:36 momjian Exp $ * * NOTES * InitPostgres() is the function called from PostgresMain @@ -143,7 +143,7 @@ InitMyDatabaseInfo(char *name) /* - * DoChdirAndInitDatabaseNameAndPath + * DoChdirAndInitDatabaseNameAndPath * Set current directory to the database directory for the database * named . * Also set global variables DatabasePath and DatabaseName to those @@ -415,7 +415,7 @@ InitStdio() } /* -------------------------------- - * InitPostgres + * InitPostgres * Initialize POSTGRES. * * Note: diff --git a/src/backend/utils/mb/alt.c b/src/backend/utils/mb/alt.c index 54f69cc594..3d1439a5a3 100644 --- a/src/backend/utils/mb/alt.c +++ b/src/backend/utils/mb/alt.c @@ -4,63 +4,69 @@ * * Tatsuo Ishii * - * $Id: alt.c,v 1.1 1999/03/24 07:01:36 ishii Exp $ + * $Id: alt.c,v 1.2 1999/05/25 16:12:38 momjian Exp $ */ #include main() { - int i; - char koitab[128],alttab[128]; - char buf[4096]; - int koi,alt; + int i; + char koitab[128], + alttab[128]; + char buf[4096]; + int koi, + alt; - for (i=0;i<128;i++) { - koitab[i] = alttab[i] = 0; - } + for (i = 0; i < 128; i++) + koitab[i] = alttab[i] = 0; - while (fgets(buf,sizeof(buf),stdin) != NULL) { - if (*buf == '#') { - continue; - } - sscanf(buf,"%d %d",&koi,&alt); - if (koi < 128 || koi > 255 || alt < 128 || alt > 255) { - fprintf(stderr,"invalid value %d\n",koi); - exit(1); - } - koitab[koi-128] = alt; - alttab[alt-128] = koi; - } + while (fgets(buf, sizeof(buf), stdin) != NULL) + { + if (*buf == '#') + continue; + sscanf(buf, "%d %d", &koi, &alt); + if (koi < 128 || koi > 255 || alt < 128 || alt > 255) + { + fprintf(stderr, "invalid value %d\n", koi); + exit(1); + } + koitab[koi - 128] = alt; + alttab[alt - 128] = koi; + } - i = 0; - printf("static char koi2alt[] = {\n"); - while (i < 128) { - int j = 0; - while (j < 8) { - printf("0x%02x",koitab[i++]); - j++; - if (i >= 128) { - break; - } - printf(", "); - } - printf("\n"); - } - printf("};\n"); + i = 0; + printf("static char koi2alt[] = {\n"); + while (i < 128) + { + int j = 0; - i = 0; - printf("static char alt2koi[] = {\n"); - while (i < 128) { - int j = 0; - while (j < 8) { - printf("0x%02x",alttab[i++]); - j++; - if (i >= 128) { - break; - } - printf(", "); - } - printf("\n"); - } - printf("};\n"); + while (j < 8) + { + printf("0x%02x", koitab[i++]); + j++; + if (i >= 128) + break; + printf(", "); + } + printf("\n"); + } + printf("};\n"); + + i = 0; + printf("static char alt2koi[] = {\n"); + while (i < 128) + { + int j = 0; + + while (j < 8) + { + printf("0x%02x", alttab[i++]); + j++; + if (i >= 128) + break; + printf(", "); + } + printf("\n"); + } + printf("};\n"); } diff --git a/src/backend/utils/mb/big5.c b/src/backend/utils/mb/big5.c index 105854d247..d35ee71b9f 100644 --- a/src/backend/utils/mb/big5.c +++ b/src/backend/utils/mb/big5.c @@ -4,344 +4,372 @@ * This program is partially copied from lv(Multilingual file viewer) * and slightly modified. lv is written and copyrighted by NARITA Tomio * (nrt@web.ad.jp). - * + * * 1999/1/15 Tatsuo Ishii * - * $Id: big5.c,v 1.1 1999/02/02 18:51:22 momjian Exp $ + * $Id: big5.c,v 1.2 1999/05/25 16:12:40 momjian Exp $ */ #include "mb/pg_wchar.h" -typedef struct { - unsigned short code, peer; -} codes_t; +typedef struct +{ + unsigned short code, + peer; +} codes_t; /* map Big5 Level 1 to CNS 11643-1992 Plane 1 */ -static codes_t big5Level1ToCnsPlane1[ 25 ] = { /* range */ - { 0xA140, 0x2121 }, - { 0xA1F6, 0x2258 }, - { 0xA1F7, 0x2257 }, - { 0xA1F8, 0x2259 }, - { 0xA2AF, 0x2421 }, - { 0xA3C0, 0x4221 }, - { 0xa3e1, 0x0000 }, - { 0xA440, 0x4421 }, - { 0xACFE, 0x5753 }, - { 0xacff, 0x0000 }, - { 0xAD40, 0x5323 }, - { 0xAFD0, 0x5754 }, - { 0xBBC8, 0x6B51 }, - { 0xBE52, 0x6B50 }, - { 0xBE53, 0x6F5C }, - { 0xC1AB, 0x7536 }, - { 0xC2CB, 0x7535 }, - { 0xC2CC, 0x7737 }, - { 0xC361, 0x782E }, - { 0xC3B9, 0x7865 }, - { 0xC3BA, 0x7864 }, - { 0xC3BB, 0x7866 }, - { 0xC456, 0x782D }, - { 0xC457, 0x7962 }, - { 0xc67f, 0x0000 } +static codes_t big5Level1ToCnsPlane1[25] = { /* range */ + {0xA140, 0x2121}, + {0xA1F6, 0x2258}, + {0xA1F7, 0x2257}, + {0xA1F8, 0x2259}, + {0xA2AF, 0x2421}, + {0xA3C0, 0x4221}, + {0xa3e1, 0x0000}, + {0xA440, 0x4421}, + {0xACFE, 0x5753}, + {0xacff, 0x0000}, + {0xAD40, 0x5323}, + {0xAFD0, 0x5754}, + {0xBBC8, 0x6B51}, + {0xBE52, 0x6B50}, + {0xBE53, 0x6F5C}, + {0xC1AB, 0x7536}, + {0xC2CB, 0x7535}, + {0xC2CC, 0x7737}, + {0xC361, 0x782E}, + {0xC3B9, 0x7865}, + {0xC3BA, 0x7864}, + {0xC3BB, 0x7866}, + {0xC456, 0x782D}, + {0xC457, 0x7962}, + {0xc67f, 0x0000} }; /* map CNS 11643-1992 Plane 1 to Big5 Level 1 */ -static codes_t cnsPlane1ToBig5Level1[ 26 ] = { /* range */ - { 0x2121, 0xA140 }, - { 0x2257, 0xA1F7 }, - { 0x2258, 0xA1F6 }, - { 0x2259, 0xA1F8 }, - { 0x234f, 0x0000 }, - { 0x2421, 0xA2AF }, - { 0x2571, 0x0000 }, - { 0x4221, 0xA3C0 }, - { 0x4242, 0x0000 }, - { 0x4421, 0xA440 }, - { 0x5323, 0xAD40 }, - { 0x5753, 0xACFE }, - { 0x5754, 0xAFD0 }, - { 0x6B50, 0xBE52 }, - { 0x6B51, 0xBBC8 }, - { 0x6F5C, 0xBE53 }, - { 0x7535, 0xC2CB }, - { 0x7536, 0xC1AB }, - { 0x7737, 0xC2CC }, - { 0x782D, 0xC456 }, - { 0x782E, 0xC361 }, - { 0x7864, 0xC3BA }, - { 0x7865, 0xC3B9 }, - { 0x7866, 0xC3BB }, - { 0x7962, 0xC457 }, - { 0x7d4c, 0x0000 } +static codes_t cnsPlane1ToBig5Level1[26] = { /* range */ + {0x2121, 0xA140}, + {0x2257, 0xA1F7}, + {0x2258, 0xA1F6}, + {0x2259, 0xA1F8}, + {0x234f, 0x0000}, + {0x2421, 0xA2AF}, + {0x2571, 0x0000}, + {0x4221, 0xA3C0}, + {0x4242, 0x0000}, + {0x4421, 0xA440}, + {0x5323, 0xAD40}, + {0x5753, 0xACFE}, + {0x5754, 0xAFD0}, + {0x6B50, 0xBE52}, + {0x6B51, 0xBBC8}, + {0x6F5C, 0xBE53}, + {0x7535, 0xC2CB}, + {0x7536, 0xC1AB}, + {0x7737, 0xC2CC}, + {0x782D, 0xC456}, + {0x782E, 0xC361}, + {0x7864, 0xC3BA}, + {0x7865, 0xC3B9}, + {0x7866, 0xC3BB}, + {0x7962, 0xC457}, + {0x7d4c, 0x0000} }; /* map Big5 Level 2 to CNS 11643-1992 Plane 2 */ -static codes_t big5Level2ToCnsPlane2[ 48 ] = { /* range */ - { 0xC940, 0x2121 }, - { 0xc94a, 0x0000 }, - { 0xC94B, 0x212B }, - { 0xC96C, 0x214D }, - { 0xC9BE, 0x214C }, - { 0xC9BF, 0x217D }, - { 0xC9ED, 0x224E }, - { 0xCAF7, 0x224D }, - { 0xCAF8, 0x2439 }, - { 0xD77A, 0x3F6A }, - { 0xD77B, 0x387E }, - { 0xDBA7, 0x3F6B }, - { 0xDDFC, 0x4176 }, - { 0xDDFD, 0x4424 }, - { 0xE8A3, 0x554C }, - { 0xE976, 0x5723 }, - { 0xEB5B, 0x5A29 }, - { 0xEBF1, 0x554B }, - { 0xEBF2, 0x5B3F }, - { 0xECDE, 0x5722 }, - { 0xECDF, 0x5C6A }, - { 0xEDAA, 0x5D75 }, - { 0xEEEB, 0x642F }, - { 0xEEEC, 0x6039 }, - { 0xF056, 0x5D74 }, - { 0xF057, 0x6243 }, - { 0xF0CB, 0x5A28 }, - { 0xF0CC, 0x6337 }, - { 0xF163, 0x6430 }, - { 0xF16B, 0x6761 }, - { 0xF16C, 0x6438 }, - { 0xF268, 0x6934 }, - { 0xF269, 0x6573 }, - { 0xF2C3, 0x664E }, - { 0xF375, 0x6762 }, - { 0xF466, 0x6935 }, - { 0xF4B5, 0x664D }, - { 0xF4B6, 0x6962 }, - { 0xF4FD, 0x6A4C }, - { 0xF663, 0x6A4B }, - { 0xF664, 0x6C52 }, - { 0xF977, 0x7167 }, - { 0xF9C4, 0x7166 }, - { 0xF9C5, 0x7234 }, - { 0xF9C6, 0x7240 }, - { 0xF9C7, 0x7235 }, - { 0xF9D2, 0x7241 }, - { 0xf9d6, 0x0000 } +static codes_t big5Level2ToCnsPlane2[48] = { /* range */ + {0xC940, 0x2121}, + {0xc94a, 0x0000}, + {0xC94B, 0x212B}, + {0xC96C, 0x214D}, + {0xC9BE, 0x214C}, + {0xC9BF, 0x217D}, + {0xC9ED, 0x224E}, + {0xCAF7, 0x224D}, + {0xCAF8, 0x2439}, + {0xD77A, 0x3F6A}, + {0xD77B, 0x387E}, + {0xDBA7, 0x3F6B}, + {0xDDFC, 0x4176}, + {0xDDFD, 0x4424}, + {0xE8A3, 0x554C}, + {0xE976, 0x5723}, + {0xEB5B, 0x5A29}, + {0xEBF1, 0x554B}, + {0xEBF2, 0x5B3F}, + {0xECDE, 0x5722}, + {0xECDF, 0x5C6A}, + {0xEDAA, 0x5D75}, + {0xEEEB, 0x642F}, + {0xEEEC, 0x6039}, + {0xF056, 0x5D74}, + {0xF057, 0x6243}, + {0xF0CB, 0x5A28}, + {0xF0CC, 0x6337}, + {0xF163, 0x6430}, + {0xF16B, 0x6761}, + {0xF16C, 0x6438}, + {0xF268, 0x6934}, + {0xF269, 0x6573}, + {0xF2C3, 0x664E}, + {0xF375, 0x6762}, + {0xF466, 0x6935}, + {0xF4B5, 0x664D}, + {0xF4B6, 0x6962}, + {0xF4FD, 0x6A4C}, + {0xF663, 0x6A4B}, + {0xF664, 0x6C52}, + {0xF977, 0x7167}, + {0xF9C4, 0x7166}, + {0xF9C5, 0x7234}, + {0xF9C6, 0x7240}, + {0xF9C7, 0x7235}, + {0xF9D2, 0x7241}, + {0xf9d6, 0x0000} }; /* map CNS 11643-1992 Plane 2 to Big5 Level 2 */ -static codes_t cnsPlane2ToBig5Level2[ 49 ] = { /* range */ - { 0x2121, 0xC940 }, - { 0x212B, 0xC94B }, - { 0x214C, 0xC9BE }, - { 0x214D, 0xC96C }, - { 0x217D, 0xC9BF }, - { 0x224D, 0xCAF7 }, - { 0x224E, 0xC9ED }, - { 0x2439, 0xCAF8 }, - { 0x387E, 0xD77B }, - { 0x3F6A, 0xD77A }, - { 0x3F6B, 0xDBA7 }, - { 0x4424, 0x0000 }, - { 0x4176, 0xDDFC }, - { 0x4177, 0x0000 }, - { 0x4424, 0xDDFD }, - { 0x554B, 0xEBF1 }, - { 0x554C, 0xE8A3 }, - { 0x5722, 0xECDE }, - { 0x5723, 0xE976 }, - { 0x5A28, 0xF0CB }, - { 0x5A29, 0xEB5B }, - { 0x5B3F, 0xEBF2 }, - { 0x5C6A, 0xECDF }, - { 0x5D74, 0xF056 }, - { 0x5D75, 0xEDAA }, - { 0x6039, 0xEEEC }, - { 0x6243, 0xF057 }, - { 0x6337, 0xF0CC }, - { 0x642F, 0xEEEB }, - { 0x6430, 0xF163 }, - { 0x6438, 0xF16C }, - { 0x6573, 0xF269 }, - { 0x664D, 0xF4B5 }, - { 0x664E, 0xF2C3 }, - { 0x6761, 0xF16B }, - { 0x6762, 0xF375 }, - { 0x6934, 0xF268 }, - { 0x6935, 0xF466 }, - { 0x6962, 0xF4B6 }, - { 0x6A4B, 0xF663 }, - { 0x6A4C, 0xF4FD }, - { 0x6C52, 0xF664 }, - { 0x7166, 0xF9C4 }, - { 0x7167, 0xF977 }, - { 0x7234, 0xF9C5 }, - { 0x7235, 0xF9C7 }, - { 0x7240, 0xF9C6 }, - { 0x7241, 0xF9D2 }, - { 0x7245, 0x0000 } +static codes_t cnsPlane2ToBig5Level2[49] = { /* range */ + {0x2121, 0xC940}, + {0x212B, 0xC94B}, + {0x214C, 0xC9BE}, + {0x214D, 0xC96C}, + {0x217D, 0xC9BF}, + {0x224D, 0xCAF7}, + {0x224E, 0xC9ED}, + {0x2439, 0xCAF8}, + {0x387E, 0xD77B}, + {0x3F6A, 0xD77A}, + {0x3F6B, 0xDBA7}, + {0x4424, 0x0000}, + {0x4176, 0xDDFC}, + {0x4177, 0x0000}, + {0x4424, 0xDDFD}, + {0x554B, 0xEBF1}, + {0x554C, 0xE8A3}, + {0x5722, 0xECDE}, + {0x5723, 0xE976}, + {0x5A28, 0xF0CB}, + {0x5A29, 0xEB5B}, + {0x5B3F, 0xEBF2}, + {0x5C6A, 0xECDF}, + {0x5D74, 0xF056}, + {0x5D75, 0xEDAA}, + {0x6039, 0xEEEC}, + {0x6243, 0xF057}, + {0x6337, 0xF0CC}, + {0x642F, 0xEEEB}, + {0x6430, 0xF163}, + {0x6438, 0xF16C}, + {0x6573, 0xF269}, + {0x664D, 0xF4B5}, + {0x664E, 0xF2C3}, + {0x6761, 0xF16B}, + {0x6762, 0xF375}, + {0x6934, 0xF268}, + {0x6935, 0xF466}, + {0x6962, 0xF4B6}, + {0x6A4B, 0xF663}, + {0x6A4C, 0xF4FD}, + {0x6C52, 0xF664}, + {0x7166, 0xF9C4}, + {0x7167, 0xF977}, + {0x7234, 0xF9C5}, + {0x7235, 0xF9C7}, + {0x7240, 0xF9C6}, + {0x7241, 0xF9D2}, + {0x7245, 0x0000} }; /* Big Five Level 1 Correspondence to CNS 11643-1992 Plane 4 */ static unsigned short b1c4[][2] = { - {0xC879, 0x2123}, - {0xC87B, 0x2124}, - {0xC87D, 0x212A}, - {0xC8A2, 0x2152} + {0xC879, 0x2123}, + {0xC87B, 0x2124}, + {0xC87D, 0x212A}, + {0xC8A2, 0x2152} }; /* Big Five Level 2 Correspondence to CNS 11643-1992 Plane 3 */ static unsigned short b2c3[][2] = { - {0xF9D6, 0x4337}, - {0xF9D7, 0x4F50}, - {0xF9D8, 0x444E}, - {0xF9D9, 0x504A}, - {0xF9DA, 0x2C5D}, - {0xF9DB, 0x3D7E}, - {0xF9DC, 0x4B5C} + {0xF9D6, 0x4337}, + {0xF9D7, 0x4F50}, + {0xF9D8, 0x444E}, + {0xF9D9, 0x504A}, + {0xF9DA, 0x2C5D}, + {0xF9DB, 0x3D7E}, + {0xF9DC, 0x4B5C} }; static unsigned short BinarySearchRange -(codes_t *array, int high, unsigned short code ) + (codes_t * array, int high, unsigned short code) { - int low, mid, distance, tmp; + int low, + mid, + distance, + tmp; - low = 0; - mid = high >> 1; + low = 0; + mid = high >> 1; + + for (; low <= high; mid = (low + high) >> 1) + { + if ((array[mid].code <= code) && (array[mid + 1].code > code)) + { + if (0 == array[mid].peer) + return 0; + if (code >= 0xa140 U) + { + /* big5 to cns */ + tmp = ((code & 0xff00) - (array[mid].code & 0xff00)) >> 8; + high = code & 0x00ff; + low = array[mid].code & 0x00ff; + + /* + * NOTE: big5 high_byte: 0xa1-0xfe, low_byte: 0x40-0x7e, + * 0xa1-0xfe (radicals: 0x00-0x3e, 0x3f-0x9c) big5 radix + * is 0x9d. [region_low, region_high] + * We should remember big5 has two different regions + * (above). There is a bias for the distance between these + * regions. 0xa1 - 0x7e + bias = 1 (Distance between 0xa1 + * and 0x7e is 1.) bias = - 0x22. + */ + distance = tmp * 0x9d + high - low + + (high >= 0xa1 ? (low >= 0xa1 ? 0 : -0x22) + : (low >= 0xa1 ? +0x22 : 0)); + + /* + * NOTE: we have to convert the distance into a code + * point. The code point's low_byte is 0x21 plus mod_0x5e. + * In the first, we extract the mod_0x5e of the starting + * code point, subtracting 0x21, and add distance to it. + * Then we calculate again mod_0x5e of them, and restore + * the final codepoint, adding 0x21. + */ + tmp = (array[mid].peer & 0x00ff) + distance - 0x21; + tmp = (array[mid].peer & 0xff00) + ((tmp / 0x5e) << 8) + + 0x21 + tmp % 0x5e; + return tmp; + } + else + { + /* cns to big5 */ + tmp = ((code & 0xff00) - (array[mid].code & 0xff00)) >> 8; + + /* + * NOTE: ISO charsets ranges between 0x21-0xfe + * (94charset). Its radix is 0x5e. But there is no + * distance bias like big5. + */ + distance = tmp * 0x5e + + ((int) (code & 0x00ff) - (int) (array[mid].code & 0x00ff)); + + /* + * NOTE: Similar to big5 to cns conversion, we extract + * mod_0x9d and restore mod_0x9d into a code point. + */ + low = array[mid].peer & 0x00ff; + tmp = low + distance - (low >= 0xa1 ? 0x62 : 0x40); + low = tmp % 0x9d; + tmp = (array[mid].peer & 0xff00) + ((tmp / 0x9d) << 8) + + (low > 0x3e ? 0x62 : 0x40) + low; + return tmp; + } + } + else if (array[mid].code > code) + high = mid - 1; + else + low = mid + 1; + } - for( ; low <= high ; mid = ( low + high ) >> 1 ){ - if( ( array[ mid ].code <= code ) && ( array[ mid + 1 ].code > code ) ){ - if( 0 == array[ mid ].peer ) return 0; - if( code >= 0xa140U ){ - /* big5 to cns */ - tmp = ( ( code & 0xff00 ) - ( array[ mid ].code & 0xff00 ) ) >> 8; - high = code & 0x00ff; - low = array[ mid ].code & 0x00ff; - /* - * NOTE: big5 high_byte: 0xa1-0xfe, low_byte: 0x40-0x7e, 0xa1-0xfe - * (radicals: 0x00-0x3e, 0x3f-0x9c) - * big5 radix is 0x9d. [region_low, region_high] - * We should remember big5 has two different regions (above). - * There is a bias for the distance between these regions. - * 0xa1 - 0x7e + bias = 1 (Distance between 0xa1 and 0x7e is 1.) - * bias = - 0x22. - */ - distance = tmp * 0x9d + high - low + - ( high >= 0xa1 ? ( low >= 0xa1 ? 0 : - 0x22 ) - : ( low >= 0xa1 ? + 0x22 : 0 ) ); - /* - * NOTE: we have to convert the distance into a code point. - * The code point's low_byte is 0x21 plus mod_0x5e. - * In the first, we extract the mod_0x5e of the starting - * code point, subtracting 0x21, and add distance to it. - * Then we calculate again mod_0x5e of them, and restore - * the final codepoint, adding 0x21. - */ - tmp = ( array[ mid ].peer & 0x00ff ) + distance - 0x21; - tmp = ( array[ mid ].peer & 0xff00 ) + ( ( tmp / 0x5e ) << 8 ) - + 0x21 + tmp % 0x5e; - return tmp; - } else { - /* cns to big5 */ - tmp = ( ( code & 0xff00 ) - ( array[ mid ].code & 0xff00 ) ) >> 8; - /* - * NOTE: ISO charsets ranges between 0x21-0xfe (94charset). - * Its radix is 0x5e. But there is no distance bias like big5. - */ - distance = tmp * 0x5e - + ( (int)( code & 0x00ff ) - (int)( array[ mid ].code & 0x00ff ) ); - /* - * NOTE: Similar to big5 to cns conversion, we extract mod_0x9d and - * restore mod_0x9d into a code point. - */ - low = array[ mid ].peer & 0x00ff; - tmp = low + distance - ( low >= 0xa1 ? 0x62 : 0x40 ); - low = tmp % 0x9d; - tmp = ( array[ mid ].peer & 0xff00 ) + ( ( tmp / 0x9d ) << 8 ) - + ( low > 0x3e ? 0x62 : 0x40 ) + low; - return tmp; - } - } else if( array[ mid ].code > code ){ - high = mid - 1; - } else { - low = mid + 1; - } - } - - return 0; } -unsigned short BIG5toCNS(unsigned short big5, unsigned char *lc ) +unsigned short +BIG5toCNS(unsigned short big5, unsigned char *lc) { - unsigned short cns = 0; - int i; + unsigned short cns = 0; + int i; - if( big5 < 0xc940U ){ - /* level 1 */ + if (big5 < 0xc940 U) + { + /* level 1 */ - for (i=0;i @@ -28,9 +28,8 @@ pg_char_to_encoding(const char *s) { pg_encoding_conv_tbl *p = pg_conv_tbl; - if (!s) { + if (!s) return (-1); - } for (; p->encoding >= 0; p++) { diff --git a/src/backend/utils/mb/conv.c b/src/backend/utils/mb/conv.c index ca79706bd5..002a484545 100644 --- a/src/backend/utils/mb/conv.c +++ b/src/backend/utils/mb/conv.c @@ -2,7 +2,7 @@ * conversion between client encoding and server internal encoding * (currently mule internal code (mic) is used) * Tatsuo Ishii - * $Id: conv.c,v 1.7 1999/04/25 18:09:54 tgl Exp $ + * $Id: conv.c,v 1.8 1999/05/25 16:12:41 momjian Exp $ */ #include #include @@ -375,43 +375,52 @@ mic2euc_tw(unsigned char *mic, unsigned char *p, int len) static void big52mic(unsigned char *big5, unsigned char *p, int len) { - unsigned short c1; - unsigned short big5buf, cnsBuf; - unsigned char lc; - char bogusBuf[2]; - int i; + unsigned short c1; + unsigned short big5buf, + cnsBuf; + unsigned char lc; + char bogusBuf[2]; + int i; - while (len > 0 && (c1 = *big5++)) - { - if (c1 <= 0x007fU) { /* ASCII */ - len--; - *p++ = c1; - } else { - len -= 2; - big5buf = c1 << 8; - c1 = *big5++; - big5buf |= c1; - cnsBuf = BIG5toCNS(big5buf, &lc); - if (lc != 0) { - if (lc == LC_CNS11643_3 || lc == LC_CNS11643_4) { - *p++ = 0x9d; /* LCPRV2 */ - } - *p++ = lc; /* Plane No. */ - *p++ = (cnsBuf >> 8) & 0x00ff; - *p++ = cnsBuf & 0x00ff; - } else { /* cannot convert */ - big5 -= 2; - *p++ = '('; - for (i=0;i<2;i++) { - sprintf(bogusBuf,"%02x",*big5++); - *p++ = bogusBuf[0]; - *p++ = bogusBuf[1]; - } - *p++ = ')'; + while (len > 0 && (c1 = *big5++)) + { + if (c1 <= 0x007f U) + { /* ASCII */ + len--; + *p++ = c1; + } + else + { + len -= 2; + big5buf = c1 << 8; + c1 = *big5++; + big5buf |= c1; + cnsBuf = BIG5toCNS(big5buf, &lc); + if (lc != 0) + { + if (lc == LC_CNS11643_3 || lc == LC_CNS11643_4) + { + *p++ = 0x9d;/* LCPRV2 */ + } + *p++ = lc; /* Plane No. */ + *p++ = (cnsBuf >> 8) & 0x00ff; + *p++ = cnsBuf & 0x00ff; + } + else + { /* cannot convert */ + big5 -= 2; + *p++ = '('; + for (i = 0; i < 2; i++) + { + sprintf(bogusBuf, "%02x", *big5++); + *p++ = bogusBuf[0]; + *p++ = bogusBuf[1]; + } + *p++ = ')'; + } + } } - } - } - *p = '\0'; + *p = '\0'; } /* @@ -420,41 +429,46 @@ big52mic(unsigned char *big5, unsigned char *p, int len) static void mic2big5(unsigned char *mic, unsigned char *p, int len) { - int l; - unsigned short c1; - unsigned short big5buf, cnsBuf; + int l; + unsigned short c1; + unsigned short big5buf, + cnsBuf; - while (len > 0 && (c1 = *mic)) - { - l = pg_mic_mblen(mic++); - len -= l; + while (len > 0 && (c1 = *mic)) + { + l = pg_mic_mblen(mic++); + len -= l; - /* 0x9d means LCPRV2 */ - if (c1 == LC_CNS11643_1 || c1 == LC_CNS11643_2 || c1 == 0x9d) - { - if (c1 == 0x9d) { - c1 = *mic++; /* get plane no. */ - } - cnsBuf = (*mic++)<<8; - cnsBuf |= (*mic++) & 0x00ff; - big5buf = CNStoBIG5(cnsBuf, c1); - if (big5buf == 0) { /* cannot convert to Big5! */ - mic -= l; - printBogusChar(&mic, &p); - } else { - *p++ = (big5buf >> 8) & 0x00ff; - *p++ = big5buf & 0x00ff; - } + /* 0x9d means LCPRV2 */ + if (c1 == LC_CNS11643_1 || c1 == LC_CNS11643_2 || c1 == 0x9d) + { + if (c1 == 0x9d) + { + c1 = *mic++; /* get plane no. */ + } + cnsBuf = (*mic++) << 8; + cnsBuf |= (*mic++) & 0x00ff; + big5buf = CNStoBIG5(cnsBuf, c1); + if (big5buf == 0) + { /* cannot convert to Big5! */ + mic -= l; + printBogusChar(&mic, &p); + } + else + { + *p++ = (big5buf >> 8) & 0x00ff; + *p++ = big5buf & 0x00ff; + } + } + else if (c1 <= 0x7f) /* ASCII */ + *p++ = c1; + else + { /* cannot convert to Big5! */ + mic--; + printBogusChar(&mic, &p); + } } - else if (c1 <= 0x7f) /* ASCII */ - { - *p++ = c1; - } else { /* cannot convert to Big5! */ - mic--; - printBogusChar(&mic, &p); - } - } - *p = '\0'; + *p = '\0'; } /* @@ -543,6 +557,7 @@ mic2latin4(unsigned char *mic, unsigned char *p, int len) { mic2latin(mic, p, len, LC_ISO8859_4); } + #ifdef NOT_USED static void latin52mic(unsigned char *l, unsigned char *p, int len) @@ -554,6 +569,7 @@ mic2latin5(unsigned char *mic, unsigned char *p, int len) { mic2latin(mic, p, len, LC_ISO8859_5); } + #endif /* @@ -590,7 +606,7 @@ mic2ascii(unsigned char *mic, unsigned char *p, int len) *p = '\0'; } -/* +/* * Cyrillic support * currently supported Cyrillic encodings: * @@ -601,18 +617,18 @@ mic2ascii(unsigned char *mic, unsigned char *p, int len) * Alternativny Variant (MS-DOS CP866) */ -/* koi2mic: KOI8-R to Mule internal code */ +/* koi2mic: KOI8-R to Mule internal code */ static void koi2mic(unsigned char *l, unsigned char *p, int len) { - latin2mic(l, p, len, LC_KOI8_R); + latin2mic(l, p, len, LC_KOI8_R); } /* mic2koi: Mule internal code to KOI8-R */ static void mic2koi(unsigned char *mic, unsigned char *p, int len) { - mic2latin(mic, p, len, LC_KOI8_R); + mic2latin(mic, p, len, LC_KOI8_R); } /* @@ -625,30 +641,36 @@ mic2koi(unsigned char *mic, unsigned char *p, int len) */ static void latin2mic_with_table( - unsigned char *l, /* local charset string (source) */ - unsigned char *p, /* pointer to store mule internal code - (destination) */ - int len, /* length of l */ - int lc, /* leading character of p */ - unsigned char *tab /* code conversion table */ - ) + unsigned char *l, /* local charset string (source) */ + unsigned char *p, /* pointer to store mule internal + * code (destination) */ + int len, /* length of l */ + int lc, /* leading character of p */ + unsigned char *tab /* code conversion table */ +) { - unsigned char c1,c2; - - while (len-- > 0 && (c1 = *l++)) { - if (c1 < 128) { - *p++ = c1; - } else { - c2 = tab[c1 - 128]; - if (c2) { - *p++ = lc; - *p++ = c2; - } else { - *p++ = ' '; /* cannot convert */ - } - } - } - *p = '\0'; + unsigned char c1, + c2; + + while (len-- > 0 && (c1 = *l++)) + { + if (c1 < 128) + *p++ = c1; + else + { + c2 = tab[c1 - 128]; + if (c2) + { + *p++ = lc; + *p++ = c2; + } + else + { + *p++ = ' '; /* cannot convert */ + } + } + } + *p = '\0'; } /* @@ -656,190 +678,202 @@ latin2mic_with_table( * conversion from the mule internal code to a local charset * with a encoding conversion table. * the table is ordered according to the second byte of the mule - * internal code starting from 128 (0x80). + * internal code starting from 128 (0x80). * each entry in the table * holds the corresponding code point for the local code. */ static void mic2latin_with_table( - unsigned char *mic, /* mule internal code (source) */ - unsigned char *p, /* local code (destination) */ - int len, /* length of p */ - int lc, /* leading character */ - unsigned char *tab /* code conversion table */ - ) + unsigned char *mic, /* mule internal code + * (source) */ + unsigned char *p, /* local code (destination) */ + int len, /* length of p */ + int lc, /* leading character */ + unsigned char *tab /* code conversion table */ +) { - unsigned char c1,c2; + unsigned char c1, + c2; - while (len-- > 0 && (c1 = *mic++)) { - if (c1 < 128) { - *p++ = c1; - } else if (c1 == lc) { - c1 = *mic++; - len--; - c2 = tab[c1 - 128]; - if (c2) { - *p++ = c2; - } else { - *p++ = ' '; /* cannot convert */ - } - } else { - *p++ = ' '; /* bogus character */ - } - } - *p = '\0'; + while (len-- > 0 && (c1 = *mic++)) + { + if (c1 < 128) + *p++ = c1; + else if (c1 == lc) + { + c1 = *mic++; + len--; + c2 = tab[c1 - 128]; + if (c2) + *p++ = c2; + else + { + *p++ = ' '; /* cannot convert */ + } + } + else + { + *p++ = ' '; /* bogus character */ + } + } + *p = '\0'; } -/* iso2mic: ISO-8859-5 to Mule internal code */ +/* iso2mic: ISO-8859-5 to Mule internal code */ static void iso2mic(unsigned char *l, unsigned char *p, int len) { - static char iso2koi[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xe1, 0xe2, 0xf7, 0xe7, 0xe4, 0xe5, 0xf6, 0xfa, - 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, - 0xf2, 0xf3, 0xf4, 0xf5, 0xe6, 0xe8, 0xe3, 0xfe, - 0xfb, 0xfd, 0xff, 0xf9, 0xf8, 0xfc, 0xe0, 0xf1, - 0xc1, 0xc2, 0xd7, 0xc7, 0xc4, 0xc5, 0xd6, 0xda, - 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, - 0xd2, 0xd3, 0xd4, 0xd5, 0xc6, 0xc8, 0xc3, 0xde, - 0xdb, 0xdd, 0xdf, 0xd9, 0xd8, 0xdc, 0xc0, 0xd1, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; - latin2mic_with_table(l, p, len, LC_KOI8_R, iso2koi); + static char iso2koi[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xe1, 0xe2, 0xf7, 0xe7, 0xe4, 0xe5, 0xf6, 0xfa, + 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, + 0xf2, 0xf3, 0xf4, 0xf5, 0xe6, 0xe8, 0xe3, 0xfe, + 0xfb, 0xfd, 0xff, 0xf9, 0xf8, 0xfc, 0xe0, 0xf1, + 0xc1, 0xc2, 0xd7, 0xc7, 0xc4, 0xc5, 0xd6, 0xda, + 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, + 0xd2, 0xd3, 0xd4, 0xd5, 0xc6, 0xc8, 0xc3, 0xde, + 0xdb, 0xdd, 0xdf, 0xd9, 0xd8, 0xdc, 0xc0, 0xd1, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + + latin2mic_with_table(l, p, len, LC_KOI8_R, iso2koi); } /* mic2iso: Mule internal code to ISO8859-5 */ static void mic2iso(unsigned char *mic, unsigned char *p, int len) { - static char koi2iso[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xee, 0xd0, 0xd1, 0xe6, 0xd4, 0xd5, 0xe4, 0xd3, - 0xe5, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, - 0xdf, 0xef, 0xe0, 0xe1, 0xe2, 0xe3, 0xd6, 0xd2, - 0xec, 0xeb, 0xd7, 0xe8, 0xed, 0xe9, 0xe7, 0xea, - 0xce, 0xb0, 0xb1, 0xc6, 0xb4, 0xb5, 0xc4, 0xb3, - 0xc5, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, - 0xbf, 0xcf, 0xc0, 0xc1, 0xc2, 0xc3, 0xb6, 0xb2, - 0xcc, 0xcb, 0xb7, 0xc8, 0xcd, 0xc9, 0xc7, 0xca - }; + static char koi2iso[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xee, 0xd0, 0xd1, 0xe6, 0xd4, 0xd5, 0xe4, 0xd3, + 0xe5, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, + 0xdf, 0xef, 0xe0, 0xe1, 0xe2, 0xe3, 0xd6, 0xd2, + 0xec, 0xeb, 0xd7, 0xe8, 0xed, 0xe9, 0xe7, 0xea, + 0xce, 0xb0, 0xb1, 0xc6, 0xb4, 0xb5, 0xc4, 0xb3, + 0xc5, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, + 0xbf, 0xcf, 0xc0, 0xc1, 0xc2, 0xc3, 0xb6, 0xb2, + 0xcc, 0xcb, 0xb7, 0xc8, 0xcd, 0xc9, 0xc7, 0xca + }; - mic2latin_with_table(mic, p, len, LC_KOI8_R, koi2iso); + mic2latin_with_table(mic, p, len, LC_KOI8_R, koi2iso); } -/* win2mic: CP1251 to Mule internal code */ +/* win2mic: CP1251 to Mule internal code */ static void win2mic(unsigned char *l, unsigned char *p, int len) { - static char win2koi[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xbd, 0x00, 0x00, - 0xb3, 0x00, 0xb4, 0x00, 0x00, 0x00, 0x00, 0xb7, - 0x00, 0x00, 0xb6, 0xa6, 0xad, 0x00, 0x00, 0x00, - 0xa3, 0x00, 0xa4, 0x00, 0x00, 0x00, 0x00, 0xa7, - 0xe1, 0xe2, 0xf7, 0xe7, 0xe4, 0xe5, 0xf6, 0xfa, - 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, - 0xf2, 0xf3, 0xf4, 0xf5, 0xe6, 0xe8, 0xe3, 0xfe, - 0xfb, 0xfd, 0xff, 0xf9, 0xf8, 0xfc, 0xe0, 0xf1, - 0xc1, 0xc2, 0xd7, 0xc7, 0xc4, 0xc5, 0xd6, 0xda, - 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, - 0xd2, 0xd3, 0xd4, 0xd5, 0xc6, 0xc8, 0xc3, 0xde, - 0xdb, 0xdd, 0xdf, 0xd9, 0xd8, 0xdc, 0xc0, 0xd1 - }; - latin2mic_with_table(l, p, len, LC_KOI8_R, win2koi); + static char win2koi[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xbd, 0x00, 0x00, + 0xb3, 0x00, 0xb4, 0x00, 0x00, 0x00, 0x00, 0xb7, + 0x00, 0x00, 0xb6, 0xa6, 0xad, 0x00, 0x00, 0x00, + 0xa3, 0x00, 0xa4, 0x00, 0x00, 0x00, 0x00, 0xa7, + 0xe1, 0xe2, 0xf7, 0xe7, 0xe4, 0xe5, 0xf6, 0xfa, + 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, + 0xf2, 0xf3, 0xf4, 0xf5, 0xe6, 0xe8, 0xe3, 0xfe, + 0xfb, 0xfd, 0xff, 0xf9, 0xf8, 0xfc, 0xe0, 0xf1, + 0xc1, 0xc2, 0xd7, 0xc7, 0xc4, 0xc5, 0xd6, 0xda, + 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, + 0xd2, 0xd3, 0xd4, 0xd5, 0xc6, 0xc8, 0xc3, 0xde, + 0xdb, 0xdd, 0xdf, 0xd9, 0xd8, 0xdc, 0xc0, 0xd1 + }; + + latin2mic_with_table(l, p, len, LC_KOI8_R, win2koi); } /* mic2win: Mule internal code to CP1251 */ static void mic2win(unsigned char *mic, unsigned char *p, int len) { - static char koi2win[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xb8, 0xba, 0x00, 0xb3, 0xbf, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xb4, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xa8, 0xaa, 0x00, 0xb2, 0xaf, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xa5, 0x00, 0x00, - 0xfe, 0xe0, 0xe1, 0xf6, 0xe4, 0xe5, 0xf4, 0xe3, - 0xf5, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, - 0xef, 0xff, 0xf0, 0xf1, 0xf2, 0xf3, 0xe6, 0xe2, - 0xfc, 0xfb, 0xe7, 0xf8, 0xfd, 0xf9, 0xf7, 0xfa, - 0xde, 0xc0, 0xc1, 0xd6, 0xc4, 0xc5, 0xd4, 0xc3, - 0xd5, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, - 0xcf, 0xdf, 0xd0, 0xd1, 0xd2, 0xd3, 0xc6, 0xc2, - 0xdc, 0xdb, 0xc7, 0xd8, 0xdd, 0xd9, 0xd7, 0xda - }; - mic2latin_with_table(mic, p, len, LC_KOI8_R, koi2win); + static char koi2win[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xb8, 0xba, 0x00, 0xb3, 0xbf, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xb4, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xa8, 0xaa, 0x00, 0xb2, 0xaf, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xa5, 0x00, 0x00, + 0xfe, 0xe0, 0xe1, 0xf6, 0xe4, 0xe5, 0xf4, 0xe3, + 0xf5, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, + 0xef, 0xff, 0xf0, 0xf1, 0xf2, 0xf3, 0xe6, 0xe2, + 0xfc, 0xfb, 0xe7, 0xf8, 0xfd, 0xf9, 0xf7, 0xfa, + 0xde, 0xc0, 0xc1, 0xd6, 0xc4, 0xc5, 0xd4, 0xc3, + 0xd5, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, + 0xcf, 0xdf, 0xd0, 0xd1, 0xd2, 0xd3, 0xc6, 0xc2, + 0xdc, 0xdb, 0xc7, 0xd8, 0xdd, 0xd9, 0xd7, 0xda + }; + + mic2latin_with_table(mic, p, len, LC_KOI8_R, koi2win); } -/* alt2mic: CP866 to Mule internal code */ +/* alt2mic: CP866 to Mule internal code */ static void alt2mic(unsigned char *l, unsigned char *p, int len) { - static char alt2koi[] = { - 0xe1, 0xe2, 0xf7, 0xe7, 0xe4, 0xe5, 0xf6, 0xfa, - 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, - 0xf2, 0xf3, 0xf4, 0xf5, 0xe6, 0xe8, 0xe3, 0xfe, - 0xfb, 0xfd, 0xff, 0xf9, 0xf8, 0xfc, 0xe0, 0xf1, - 0xc1, 0xc2, 0xd7, 0xc7, 0xc4, 0xc5, 0xd6, 0xda, - 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xbd, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xd2, 0xd3, 0xd4, 0xd5, 0xc6, 0xc8, 0xc3, 0xde, - 0xdb, 0xdd, 0xdf, 0xd9, 0xd8, 0xdc, 0xc0, 0xd1, - 0xb3, 0xa3, 0xb4, 0xa4, 0xb7, 0xa7, 0x00, 0x00, - 0xb6, 0xa6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; - latin2mic_with_table(l, p, len, LC_KOI8_R, alt2koi); + static char alt2koi[] = { + 0xe1, 0xe2, 0xf7, 0xe7, 0xe4, 0xe5, 0xf6, 0xfa, + 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, + 0xf2, 0xf3, 0xf4, 0xf5, 0xe6, 0xe8, 0xe3, 0xfe, + 0xfb, 0xfd, 0xff, 0xf9, 0xf8, 0xfc, 0xe0, 0xf1, + 0xc1, 0xc2, 0xd7, 0xc7, 0xc4, 0xc5, 0xd6, 0xda, + 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xbd, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xd2, 0xd3, 0xd4, 0xd5, 0xc6, 0xc8, 0xc3, 0xde, + 0xdb, 0xdd, 0xdf, 0xd9, 0xd8, 0xdc, 0xc0, 0xd1, + 0xb3, 0xa3, 0xb4, 0xa4, 0xb7, 0xa7, 0x00, 0x00, + 0xb6, 0xa6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + + latin2mic_with_table(l, p, len, LC_KOI8_R, alt2koi); } /* mic2alt: Mule internal code to CP866 */ static void mic2alt(unsigned char *mic, unsigned char *p, int len) { - static char koi2alt[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xf1, 0xf3, 0x00, 0xf9, 0xf5, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xad, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xf0, 0xf2, 0x00, 0xf8, 0xf4, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xbd, 0x00, 0x00, - 0xee, 0xa0, 0xa1, 0xe6, 0xa4, 0xa5, 0xe4, 0xa3, - 0xe5, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, - 0xaf, 0xef, 0xe0, 0xe1, 0xe2, 0xe3, 0xa6, 0xa2, - 0xec, 0xeb, 0xa7, 0xe8, 0xed, 0xe9, 0xe7, 0xea, - 0x9e, 0x80, 0x81, 0x96, 0x84, 0x85, 0x94, 0x83, - 0x95, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, - 0x8f, 0x9f, 0x90, 0x91, 0x92, 0x93, 0x86, 0x82, - 0x9c, 0x9b, 0x87, 0x98, 0x9d, 0x99, 0x97, 0x9a - }; - mic2latin_with_table(mic, p, len, LC_KOI8_R, koi2alt); + static char koi2alt[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xf1, 0xf3, 0x00, 0xf9, 0xf5, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xad, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xf0, 0xf2, 0x00, 0xf8, 0xf4, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xbd, 0x00, 0x00, + 0xee, 0xa0, 0xa1, 0xe6, 0xa4, 0xa5, 0xe4, 0xa3, + 0xe5, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, + 0xaf, 0xef, 0xe0, 0xe1, 0xe2, 0xe3, 0xa6, 0xa2, + 0xec, 0xeb, 0xa7, 0xe8, 0xed, 0xe9, 0xe7, 0xea, + 0x9e, 0x80, 0x81, 0x96, 0x84, 0x85, 0x94, 0x83, + 0x95, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, + 0x8f, 0x9f, 0x90, 0x91, 0x92, 0x93, 0x86, 0x82, + 0x9c, 0x9b, 0x87, 0x98, 0x9d, 0x99, 0x97, 0x9a + }; + + mic2latin_with_table(mic, p, len, LC_KOI8_R, koi2alt); } /* @@ -858,8 +892,8 @@ pg_encoding_conv_tbl pg_conv_tbl[] = { {LATIN2, "LATIN2", 0, latin22mic, mic2latin2}, /* ISO 8859 Latin 2 */ {LATIN3, "LATIN3", 0, latin32mic, mic2latin3}, /* ISO 8859 Latin 3 */ {LATIN4, "LATIN4", 0, latin42mic, mic2latin4}, /* ISO 8859 Latin 4 */ - {LATIN5, "LATIN5", 0, iso2mic, mic2iso}, /* ISO 8859 Latin 5 */ - {KOI8, "KOI8", 0, koi2mic, mic2koi}, /* KOI8-R */ + {LATIN5, "LATIN5", 0, iso2mic, mic2iso}, /* ISO 8859 Latin 5 */ + {KOI8, "KOI8", 0, koi2mic, mic2koi}, /* KOI8-R */ {WIN, "WIN", 0, win2mic, mic2win}, /* CP1251 */ {ALT, "ALT", 0, alt2mic, mic2alt}, /* CP866 */ {SJIS, "SJIS", 1, sjis2mic, mic2sjis}, /* SJIS */ diff --git a/src/backend/utils/mb/iso.c b/src/backend/utils/mb/iso.c index 4141578a3b..a2903895b0 100644 --- a/src/backend/utils/mb/iso.c +++ b/src/backend/utils/mb/iso.c @@ -4,63 +4,69 @@ * * Tatsuo Ishii * - * $Id: iso.c,v 1.1 1999/03/24 07:01:37 ishii Exp $ + * $Id: iso.c,v 1.2 1999/05/25 16:12:42 momjian Exp $ */ #include main() { - int i; - char koitab[128],isotab[128]; - char buf[4096]; - int koi,iso; + int i; + char koitab[128], + isotab[128]; + char buf[4096]; + int koi, + iso; - for (i=0;i<128;i++) { - koitab[i] = isotab[i] = 0; - } + for (i = 0; i < 128; i++) + koitab[i] = isotab[i] = 0; - while (fgets(buf,sizeof(buf),stdin) != NULL) { - if (*buf == '#') { - continue; - } - sscanf(buf,"%d %x",&koi,&iso); - if (koi < 128 || koi > 255 || iso < 128 || iso > 255) { - fprintf(stderr,"invalid value %d\n",koi); - exit(1); - } - koitab[koi-128] = iso; - isotab[iso-128] = koi; - } + while (fgets(buf, sizeof(buf), stdin) != NULL) + { + if (*buf == '#') + continue; + sscanf(buf, "%d %x", &koi, &iso); + if (koi < 128 || koi > 255 || iso < 128 || iso > 255) + { + fprintf(stderr, "invalid value %d\n", koi); + exit(1); + } + koitab[koi - 128] = iso; + isotab[iso - 128] = koi; + } - i = 0; - printf("static char koi2iso[] = {\n"); - while (i < 128) { - int j = 0; - while (j < 8) { - printf("0x%02x",koitab[i++]); - j++; - if (i >= 128) { - break; - } - printf(", "); - } - printf("\n"); - } - printf("};\n"); + i = 0; + printf("static char koi2iso[] = {\n"); + while (i < 128) + { + int j = 0; - i = 0; - printf("static char iso2koi[] = {\n"); - while (i < 128) { - int j = 0; - while (j < 8) { - printf("0x%02x",isotab[i++]); - j++; - if (i >= 128) { - break; - } - printf(", "); - } - printf("\n"); - } - printf("};\n"); + while (j < 8) + { + printf("0x%02x", koitab[i++]); + j++; + if (i >= 128) + break; + printf(", "); + } + printf("\n"); + } + printf("};\n"); + + i = 0; + printf("static char iso2koi[] = {\n"); + while (i < 128) + { + int j = 0; + + while (j < 8) + { + printf("0x%02x", isotab[i++]); + j++; + if (i >= 128) + break; + printf(", "); + } + printf("\n"); + } + printf("};\n"); } diff --git a/src/backend/utils/mb/mbutils.c b/src/backend/utils/mb/mbutils.c index f354ccc96a..d5831b14e6 100644 --- a/src/backend/utils/mb/mbutils.c +++ b/src/backend/utils/mb/mbutils.c @@ -3,14 +3,14 @@ * client encoding and server internal encoding. * (currently mule internal code (mic) is used) * Tatsuo Ishii - * $Id: mbutils.c,v 1.5 1999/02/02 18:51:23 momjian Exp $ */ + * $Id: mbutils.c,v 1.6 1999/05/25 16:12:43 momjian Exp $ */ #include #include #include "mb/pg_wchar.h" -static int client_encoding = -1; +static int client_encoding = -1; static void (*client_to_mic) ();/* something to MIC */ static void (*client_from_mic) (); /* MIC to something */ static void (*server_to_mic) ();/* something to MIC */ @@ -213,16 +213,14 @@ pg_mbcliplen(const unsigned char *mbstr, int len, int limit) int clen = 0; int l; - while (*mbstr && len > 0) + while (*mbstr && len > 0) { l = pg_mblen(mbstr); - if ((clen + l) > limit) { + if ((clen + l) > limit) break; - } clen += l; - if (clen == limit) { + if (clen == limit) break; - } len -= l; mbstr += l; } diff --git a/src/backend/utils/mb/variable.c b/src/backend/utils/mb/variable.c index 0b2ffacd64..2452518e12 100644 --- a/src/backend/utils/mb/variable.c +++ b/src/backend/utils/mb/variable.c @@ -2,7 +2,7 @@ * This file contains some public functions * related to show/set/reset variable commands. * Tatsuo Ishii - * $Id: variable.c,v 1.3 1999/05/13 10:28:26 ishii Exp $ + * $Id: variable.c,v 1.4 1999/05/25 16:12:44 momjian Exp $ */ #include "mb/pg_wchar.h" @@ -13,12 +13,12 @@ parse_client_encoding(const char *value) int encoding; encoding = pg_valid_client_encoding(value); - if (encoding < 0) { - if (value) { + if (encoding < 0) + { + if (value) elog(ERROR, "Client encoding %s is not supported", value); - } else { + else elog(ERROR, "No client encoding is specified"); - } } else { diff --git a/src/backend/utils/mb/wchar.c b/src/backend/utils/mb/wchar.c index 2fc856d1b5..0d557e30f6 100644 --- a/src/backend/utils/mb/wchar.c +++ b/src/backend/utils/mb/wchar.c @@ -1,7 +1,7 @@ /* * conversion functions between pg_wchar and multi-byte streams. * Tatsuo Ishii - * $Id: wchar.c,v 1.7 1999/04/25 20:35:51 tgl Exp $ + * $Id: wchar.c,v 1.8 1999/05/25 16:12:45 momjian Exp $ */ #include "mb/pg_wchar.h" @@ -428,33 +428,33 @@ pg_wchar_tbl pg_wchar_table[] = { {pg_euctw2wchar_with_len, pg_euctw_mblen}, /* 4 */ {pg_utf2wchar_with_len, pg_utf_mblen}, /* 5 */ {pg_mule2wchar_with_len, pg_mule_mblen}, /* 6 */ - {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 7 */ - {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 8 */ - {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 9 */ - {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 10 */ - {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 11 */ - {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 12 */ - {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 13 */ - {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 14 */ - {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 15 */ - {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 16 */ - {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 17 */ - {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 18 */ - {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 19 */ - {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 20 */ - {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 21 */ - {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 22 */ - {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 23 */ - {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 24 */ - {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 25 */ - {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 26 */ - {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 27 */ - {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 28 */ - {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 29 */ - {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 30 */ - {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 31 */ - {0, pg_sjis_mblen}, /* 32 */ - {0, pg_big5_mblen} /* 33 */ + {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 7 */ + {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 8 */ + {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 9 */ + {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 10 */ + {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 11 */ + {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 12 */ + {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 13 */ + {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 14 */ + {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 15 */ + {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 16 */ + {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 17 */ + {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 18 */ + {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 19 */ + {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 20 */ + {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 21 */ + {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 22 */ + {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 23 */ + {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 24 */ + {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 25 */ + {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 26 */ + {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 27 */ + {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 28 */ + {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 29 */ + {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 30 */ + {pg_latin12wchar_with_len, pg_latin1_mblen}, /* 31 */ + {0, pg_sjis_mblen}, /* 32 */ + {0, pg_big5_mblen} /* 33 */ }; /* returns the byte length of a word for mule internal code */ diff --git a/src/backend/utils/mb/win.c b/src/backend/utils/mb/win.c index 272c6a638c..8db62b49b3 100644 --- a/src/backend/utils/mb/win.c +++ b/src/backend/utils/mb/win.c @@ -4,63 +4,69 @@ * * Tatsuo Ishii * - * $Id: win.c,v 1.1 1999/03/24 07:01:37 ishii Exp $ + * $Id: win.c,v 1.2 1999/05/25 16:12:45 momjian Exp $ */ #include main() { - int i; - char koitab[128],wintab[128]; - char buf[4096]; - int koi,win; + int i; + char koitab[128], + wintab[128]; + char buf[4096]; + int koi, + win; - for (i=0;i<128;i++) { - koitab[i] = wintab[i] = 0; - } + for (i = 0; i < 128; i++) + koitab[i] = wintab[i] = 0; - while (fgets(buf,sizeof(buf),stdin) != NULL) { - if (*buf == '#') { - continue; - } - sscanf(buf,"%d %d",&koi,&win); - if (koi < 128 || koi > 255 || win < 128 || win > 255) { - fprintf(stderr,"invalid value %d\n",koi); - exit(1); - } - koitab[koi-128] = win; - wintab[win-128] = koi; - } + while (fgets(buf, sizeof(buf), stdin) != NULL) + { + if (*buf == '#') + continue; + sscanf(buf, "%d %d", &koi, &win); + if (koi < 128 || koi > 255 || win < 128 || win > 255) + { + fprintf(stderr, "invalid value %d\n", koi); + exit(1); + } + koitab[koi - 128] = win; + wintab[win - 128] = koi; + } - i = 0; - printf("static char koi2win[] = {\n"); - while (i < 128) { - int j = 0; - while (j < 8) { - printf("0x%02x",koitab[i++]); - j++; - if (i >= 128) { - break; - } - printf(", "); - } - printf("\n"); - } - printf("};\n"); + i = 0; + printf("static char koi2win[] = {\n"); + while (i < 128) + { + int j = 0; - i = 0; - printf("static char win2koi[] = {\n"); - while (i < 128) { - int j = 0; - while (j < 8) { - printf("0x%02x",wintab[i++]); - j++; - if (i >= 128) { - break; - } - printf(", "); - } - printf("\n"); - } - printf("};\n"); + while (j < 8) + { + printf("0x%02x", koitab[i++]); + j++; + if (i >= 128) + break; + printf(", "); + } + printf("\n"); + } + printf("};\n"); + + i = 0; + printf("static char win2koi[] = {\n"); + while (i < 128) + { + int j = 0; + + while (j < 8) + { + printf("0x%02x", wintab[i++]); + j++; + if (i >= 128) + break; + printf(", "); + } + printf("\n"); + } + printf("};\n"); } diff --git a/src/backend/utils/misc/database.c b/src/backend/utils/misc/database.c index d72ebd347b..e9ea619349 100644 --- a/src/backend/utils/misc/database.c +++ b/src/backend/utils/misc/database.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.23 1999/02/13 23:20:03 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.24 1999/05/25 16:12:47 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -188,7 +188,7 @@ GetRawDatabaseInfo(char *name, int4 *owner, Oid *db_id, char *path, int *encodin int nbytes; int max, i; - HeapTupleData tup; + HeapTupleData tup; Page pg; PageHeader ph; char *dbfname; diff --git a/src/backend/utils/misc/trace.c b/src/backend/utils/misc/trace.c index 871e1d436a..3ba1626c03 100644 --- a/src/backend/utils/misc/trace.c +++ b/src/backend/utils/misc/trace.c @@ -132,10 +132,10 @@ tprintf(int flag, const char *fmt,...) * Print a timestamp and a message to stdout or to syslog. */ int -tprintf1(const char *fmt, ... ) +tprintf1(const char *fmt,...) { va_list ap; - char line[ELOG_MAXLEN+TIMESTAMP_SIZE+1]; + char line[ELOG_MAXLEN + TIMESTAMP_SIZE + 1]; va_start(ap, fmt); #ifdef ELOG_TIMESTAMPS @@ -145,10 +145,11 @@ tprintf1(const char *fmt, ... ) va_end(ap); #ifdef USE_SYSLOG - write_syslog(LOG_INFO, line+TIMESTAMP_SIZE); + write_syslog(LOG_INFO, line + TIMESTAMP_SIZE); #endif - if (UseSyslog <= 1) { + if (UseSyslog <= 1) + { puts(line); fflush(stdout); } @@ -193,7 +194,7 @@ eprintf(const char *fmt,...) void write_syslog(int level, char *line) { - static int openlog_done = 0; + static int openlog_done = 0; if (UseSyslog >= 1) { @@ -348,9 +349,10 @@ read_pg_options(SIGNAL_ARGS) char *s, *p; - if (!DataDir) { - fprintf(stderr, "read_pg_options: DataDir not defined\n"); - return; + if (!DataDir) + { + fprintf(stderr, "read_pg_options: DataDir not defined\n"); + return; } snprintf(buffer, BUF_SIZE - 1, "%s/%s", DataDir, "pg_options"); diff --git a/src/backend/utils/mmgr/aset.c b/src/backend/utils/mmgr/aset.c index 04bdba9329..1060f7b6de 100644 --- a/src/backend/utils/mmgr/aset.c +++ b/src/backend/utils/mmgr/aset.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/aset.c,v 1.15 1999/05/22 23:19:37 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/aset.c,v 1.16 1999/05/25 16:12:51 momjian Exp $ * * NOTE: * This is a new (Feb. 05, 1999) implementation of the allocation set @@ -51,7 +51,7 @@ */ #define ALLOC_MINBITS 4 /* smallest chunk size is 16 bytes */ -#define ALLOC_SMALLCHUNK_LIMIT (1 << (ALLOCSET_NUM_FREELISTS-2+ALLOC_MINBITS)) +#define ALLOC_SMALLCHUNK_LIMIT (1 << (ALLOCSET_NUM_FREELISTS-2+ALLOC_MINBITS)) /* Size of largest chunk that we use a fixed size for */ /*-------------------- @@ -65,8 +65,8 @@ *-------------------- */ -#define ALLOC_MIN_BLOCK_SIZE 8192 -#define ALLOC_MAX_BLOCK_SIZE (8 * 1024 * 1024) +#define ALLOC_MIN_BLOCK_SIZE 8192 +#define ALLOC_MAX_BLOCK_SIZE (8 * 1024 * 1024) #define ALLOC_BLOCKHDRSZ MAXALIGN(sizeof(AllocBlockData)) @@ -91,12 +91,12 @@ static inline int AllocSetFreeIndex(Size size) { - int idx = 0; + int idx = 0; if (size > 0) { size = (size - 1) >> ALLOC_MINBITS; - while (size != 0 && idx < ALLOCSET_NUM_FREELISTS-1) + while (size != 0 && idx < ALLOCSET_NUM_FREELISTS - 1) { idx++; size >>= 1; @@ -105,7 +105,7 @@ AllocSetFreeIndex(Size size) return idx; } - + /* * Public routines @@ -119,7 +119,7 @@ AllocSetFreeIndex(Size size) */ /* - * AllocSetInit + * AllocSetInit * Initializes given allocation set. * * Note: @@ -147,7 +147,7 @@ AllocSetInit(AllocSet set, AllocMode mode, Size limit) /* - * AllocSetReset + * AllocSetReset * Frees memory which is allocated in the given set. * * Exceptions: @@ -156,8 +156,8 @@ AllocSetInit(AllocSet set, AllocMode mode, Size limit) void AllocSetReset(AllocSet set) { - AllocBlock block = set->blocks; - AllocBlock next; + AllocBlock block = set->blocks; + AllocBlock next; AssertArg(AllocSetIsValid(set)); @@ -172,7 +172,7 @@ AllocSetReset(AllocSet set) } /* - * AllocSetContains + * AllocSetContains * True iff allocation set contains given allocation element. * * Exceptions: @@ -189,7 +189,7 @@ AllocSetContains(AllocSet set, AllocPointer pointer) } /* - * AllocSetAlloc + * AllocSetAlloc * Returns pointer to allocated memory of given size; memory is added * to the set. * @@ -200,22 +200,22 @@ AllocSetContains(AllocSet set, AllocPointer pointer) AllocPointer AllocSetAlloc(AllocSet set, Size size) { - AllocBlock block; - AllocChunk chunk; - AllocChunk freeref = NULL; - int fidx; - Size chunk_size; - Size blksize; + AllocBlock block; + AllocChunk chunk; + AllocChunk freeref = NULL; + int fidx; + Size chunk_size; + Size blksize; AssertArg(AllocSetIsValid(set)); /* - * Lookup in the corresponding free list if there is a - * free chunk we could reuse + * Lookup in the corresponding free list if there is a free chunk we + * could reuse * */ fidx = AllocSetFreeIndex(size); - for (chunk = set->freelist[fidx]; chunk; chunk = (AllocChunk)chunk->aset) + for (chunk = set->freelist[fidx]; chunk; chunk = (AllocChunk) chunk->aset) { if (chunk->size >= size) break; @@ -223,18 +223,18 @@ AllocSetAlloc(AllocSet set, Size size) } /* - * If one is found, remove it from the free list, make it again - * a member of the alloc set and return it's data address. + * If one is found, remove it from the free list, make it again a + * member of the alloc set and return it's data address. * */ if (chunk != NULL) { if (freeref == NULL) - set->freelist[fidx] = (AllocChunk)chunk->aset; + set->freelist[fidx] = (AllocChunk) chunk->aset; else freeref->aset = chunk->aset; - chunk->aset = (void *)set; + chunk->aset = (void *) set; return AllocChunkGetPointer(chunk); } @@ -248,8 +248,8 @@ AllocSetAlloc(AllocSet set, Size size) Assert(chunk_size >= size); /* - * If there is enough room in the active allocation block, - * always allocate the chunk there. + * If there is enough room in the active allocation block, always + * allocate the chunk there. */ if ((block = set->blocks) != NULL) @@ -261,8 +261,8 @@ AllocSetAlloc(AllocSet set, Size size) } /* - * Otherwise, if requested size exceeds smallchunk limit, - * allocate an entire separate block for this allocation + * Otherwise, if requested size exceeds smallchunk limit, allocate an + * entire separate block for this allocation * */ if (block == NULL && size > ALLOC_SMALLCHUNK_LIMIT) @@ -272,9 +272,9 @@ AllocSetAlloc(AllocSet set, Size size) if (block == NULL) elog(FATAL, "Memory exhausted in AllocSetAlloc()"); block->aset = set; - block->freeptr = block->endptr = ((char *)block) + blksize; + block->freeptr = block->endptr = ((char *) block) + blksize; - chunk = (AllocChunk) (((char *)block) + ALLOC_BLOCKHDRSZ); + chunk = (AllocChunk) (((char *) block) + ALLOC_BLOCKHDRSZ); chunk->aset = set; chunk->size = chunk_size; @@ -310,8 +310,11 @@ AllocSetAlloc(AllocSet set, Size size) { /* Get size of prior block */ blksize = set->blocks->endptr - ((char *) set->blocks); - /* Special case: if very first allocation was for a large chunk, - * could have a funny-sized top block. Do something reasonable. + + /* + * Special case: if very first allocation was for a large + * chunk, could have a funny-sized top block. Do something + * reasonable. */ if (blksize < ALLOC_MIN_BLOCK_SIZE) blksize = ALLOC_MIN_BLOCK_SIZE; @@ -321,12 +324,13 @@ AllocSetAlloc(AllocSet set, Size size) blksize = ALLOC_MAX_BLOCK_SIZE; /* Try to allocate it */ block = (AllocBlock) malloc(blksize); + /* * We could be asking for pretty big blocks here, so cope if * malloc fails. But give up if there's less than a meg or so * available... */ - while (block == NULL && blksize > 1024*1024) + while (block == NULL && blksize > 1024 * 1024) { blksize >>= 1; block = (AllocBlock) malloc(blksize); @@ -336,8 +340,8 @@ AllocSetAlloc(AllocSet set, Size size) if (block == NULL) elog(FATAL, "Memory exhausted in AllocSetAlloc()"); block->aset = set; - block->freeptr = ((char *)block) + ALLOC_BLOCKHDRSZ; - block->endptr = ((char *)block) + blksize; + block->freeptr = ((char *) block) + ALLOC_BLOCKHDRSZ; + block->endptr = ((char *) block) + blksize; block->next = set->blocks; set->blocks = block; @@ -346,8 +350,8 @@ AllocSetAlloc(AllocSet set, Size size) /* * OK, do the allocation */ - chunk = (AllocChunk)(block->freeptr); - chunk->aset = (void *)set; + chunk = (AllocChunk) (block->freeptr); + chunk->aset = (void *) set; chunk->size = chunk_size; block->freeptr += (chunk_size + ALLOC_CHUNKHDRSZ); Assert(block->freeptr <= block->endptr); @@ -356,7 +360,7 @@ AllocSetAlloc(AllocSet set, Size size) } /* - * AllocSetFree + * AllocSetFree * Frees allocated memory; memory is removed from the set. * * Exceptions: @@ -367,8 +371,8 @@ AllocSetAlloc(AllocSet set, Size size) void AllocSetFree(AllocSet set, AllocPointer pointer) { - int fidx; - AllocChunk chunk; + int fidx; + AllocChunk chunk; /* AssertArg(AllocSetIsValid(set)); */ /* AssertArg(AllocPointerIsValid(pointer)); */ @@ -377,12 +381,12 @@ AllocSetFree(AllocSet set, AllocPointer pointer) chunk = AllocPointerGetChunk(pointer); fidx = AllocSetFreeIndex(chunk->size); - chunk->aset = (void *)set->freelist[fidx]; + chunk->aset = (void *) set->freelist[fidx]; set->freelist[fidx] = chunk; } /* - * AllocSetRealloc + * AllocSetRealloc * Returns new pointer to allocated memory of given size; this memory * is added to the set. Memory associated with given pointer is copied * into the new memory, and the old memory is freed. @@ -404,8 +408,8 @@ AllocSetRealloc(AllocSet set, AllocPointer pointer, Size size) AssertArg(AllocSetContains(set, pointer)); /* - * Chunk sizes are aligned to power of 2 on AllocSetAlloc(). - * Maybe the allocated area already is >= the new size. + * Chunk sizes are aligned to power of 2 on AllocSetAlloc(). Maybe the + * allocated area already is >= the new size. * */ oldsize = AllocPointerGetSize(pointer); @@ -425,7 +429,7 @@ AllocSetRealloc(AllocSet set, AllocPointer pointer, Size size) } /* - * AllocSetDump + * AllocSetDump * Displays allocated set. */ void diff --git a/src/backend/utils/mmgr/mcxt.c b/src/backend/utils/mmgr/mcxt.c index 401ef7c6c0..98cd5b6f16 100644 --- a/src/backend/utils/mmgr/mcxt.c +++ b/src/backend/utils/mmgr/mcxt.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/mcxt.c,v 1.13 1999/03/22 16:45:27 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/mcxt.c,v 1.14 1999/05/25 16:12:53 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -54,7 +54,7 @@ static OrderedSetData ActiveGlobalMemorySetData; /* uninitialized */ #define PSIZESPACE(LEN) ((LEN) + sizeof (int32)) /* - * AllocSizeIsValid + * AllocSizeIsValid * True iff 0 < size and size <= MaxAllocSize. */ #define AllocSizeIsValid(size) (0 < (size) && (size) <= MaxAllocSize) @@ -64,7 +64,7 @@ static OrderedSetData ActiveGlobalMemorySetData; /* uninitialized */ *****************************************************************************/ /* - * CurrentMemoryContext + * CurrentMemoryContext * Memory context for general global allocations. */ DLLIMPORT MemoryContext CurrentMemoryContext = NULL; @@ -106,14 +106,14 @@ static struct MemoryContextMethodsData GlobalContextMethodsData = { static struct GlobalMemoryData TopGlobalMemoryData = { T_GlobalMemory, /* NodeTag tag */ &GlobalContextMethodsData, /* ContextMethods method */ - { NULL, { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }}, - /* free AllocSet */ + {NULL, {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}}, + /* free AllocSet */ "TopGlobal", /* char* name */ {0} /* uninitialized OrderedElemData elemD */ }; /* - * TopMemoryContext + * TopMemoryContext * Memory context for general global allocations. * * Note: @@ -131,7 +131,7 @@ MemoryContext TopMemoryContext = (MemoryContext) &TopGlobalMemoryData; */ /* - * EnableMemoryContext + * EnableMemoryContext * Enables/disables memory management and global contexts. * * Note: @@ -207,7 +207,7 @@ EnableMemoryContext(bool on) } /* - * MemoryContextAlloc + * MemoryContextAlloc * Returns pointer to aligned allocated memory in the given context. * * Note: @@ -231,7 +231,7 @@ MemoryContextAlloc(MemoryContext context, Size size) } /* - * MemoryContextFree + * MemoryContextFree * Frees allocated memory referenced by pointer in the given context. * * Note: @@ -252,7 +252,7 @@ MemoryContextFree(MemoryContext context, Pointer pointer) } /* - * MemoryContextRelloc + * MemoryContextRelloc * Returns pointer to aligned allocated memory in the given context. * * Note: @@ -278,7 +278,7 @@ MemoryContextRealloc(MemoryContext context, } /* - * MemoryContextGetName + * MemoryContextGetName * Returns pointer to aligned allocated memory in the given context. * * Note: @@ -301,7 +301,7 @@ MemoryContextGetName(MemoryContext context) #endif /* - * PointerGetAllocSize + * PointerGetAllocSize * Returns size of aligned allocated memory given pointer to it. * * Note: @@ -324,7 +324,7 @@ PointerGetAllocSize(Pointer pointer) #endif /* - * MemoryContextSwitchTo + * MemoryContextSwitchTo * Returns the current context; installs the given context. * * Note: @@ -351,7 +351,7 @@ MemoryContextSwitchTo(MemoryContext context) * External Functions */ /* - * CreateGlobalMemory + * CreateGlobalMemory * Returns new global memory context. * * Note: @@ -385,7 +385,7 @@ CreateGlobalMemory(char *name) /* XXX MemoryContextName */ } /* - * GlobalMemoryDestroy + * GlobalMemoryDestroy * Destroys given global memory context. * * Exceptions: @@ -413,7 +413,7 @@ GlobalMemoryDestroy(GlobalMemory context) *****************************************************************************/ /* - * GlobalMemoryAlloc + * GlobalMemoryAlloc * Returns pointer to aligned space in the global context. * * Exceptions: @@ -426,7 +426,7 @@ GlobalMemoryAlloc(GlobalMemory this, Size size) } /* - * GlobalMemoryFree + * GlobalMemoryFree * Frees allocated memory in the global context. * * Exceptions: @@ -441,7 +441,7 @@ GlobalMemoryFree(GlobalMemory this, } /* - * GlobalMemoryRealloc + * GlobalMemoryRealloc * Returns pointer to aligned space in the global context. * * Note: @@ -461,7 +461,7 @@ GlobalMemoryRealloc(GlobalMemory this, } /* - * GlobalMemoryGetName + * GlobalMemoryGetName * Returns name string for context. * * Exceptions: @@ -474,7 +474,7 @@ GlobalMemoryGetName(GlobalMemory this) } /* - * GlobalMemoryDump + * GlobalMemoryDump * Dumps global memory context for debugging. * * Exceptions: @@ -499,7 +499,7 @@ GlobalMemoryDump(GlobalMemory this) } /* - * DumpGlobalMemories + * DumpGlobalMemories * Dumps all global memory contexts for debugging. * * Exceptions: diff --git a/src/backend/utils/mmgr/oset.c b/src/backend/utils/mmgr/oset.c index 493197e8ea..8aca4a2ec0 100644 --- a/src/backend/utils/mmgr/oset.c +++ b/src/backend/utils/mmgr/oset.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/Attic/oset.c,v 1.11 1999/02/13 23:20:10 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/Attic/oset.c,v 1.12 1999/05/25 16:12:54 momjian Exp $ * * NOTE * XXX This is a preliminary implementation which lacks fail-fast @@ -24,7 +24,7 @@ static void OrderedElemPush(OrderedElem elem); static void OrderedElemPushHead(OrderedElem elem); /* - * OrderedElemGetBase + * OrderedElemGetBase * Returns base of enclosing structure. */ static Pointer @@ -37,7 +37,7 @@ OrderedElemGetBase(OrderedElem elem) } /* - * OrderedSetInit + * OrderedSetInit */ void OrderedSetInit(OrderedSet set, Offset offset) @@ -49,7 +49,7 @@ OrderedSetInit(OrderedSet set, Offset offset) } /* - * OrderedSetContains + * OrderedSetContains * True iff ordered set contains given element. */ bool @@ -59,7 +59,7 @@ OrderedSetContains(OrderedSet set, OrderedElem elem) } /* - * OrderedSetGetHead + * OrderedSetGetHead */ Pointer OrderedSetGetHead(OrderedSet set) @@ -73,7 +73,7 @@ OrderedSetGetHead(OrderedSet set) } /* - * OrderedSetGetTail + * OrderedSetGetTail */ #ifdef NOT_USED Pointer @@ -90,7 +90,7 @@ OrderedSetGetTail(OrderedSet set) #endif /* - * OrderedElemGetPredecessor + * OrderedElemGetPredecessor */ Pointer OrderedElemGetPredecessor(OrderedElem elem) @@ -102,7 +102,7 @@ OrderedElemGetPredecessor(OrderedElem elem) } /* - * OrderedElemGetSuccessor + * OrderedElemGetSuccessor */ Pointer OrderedElemGetSuccessor(OrderedElem elem) @@ -114,7 +114,7 @@ OrderedElemGetSuccessor(OrderedElem elem) } /* - * OrderedElemPop + * OrderedElemPop */ void OrderedElemPop(OrderedElem elem) @@ -127,7 +127,7 @@ OrderedElemPop(OrderedElem elem) } /* - * OrderedElemPushInto + * OrderedElemPushInto */ void OrderedElemPushInto(OrderedElem elem, OrderedSet set) @@ -140,7 +140,7 @@ OrderedElemPushInto(OrderedElem elem, OrderedSet set) } /* - * OrderedElemPush + * OrderedElemPush */ static void OrderedElemPush(OrderedElem elem) @@ -149,7 +149,7 @@ OrderedElemPush(OrderedElem elem) } /* - * OrderedElemPushHead + * OrderedElemPushHead */ static void OrderedElemPushHead(OrderedElem elem) diff --git a/src/backend/utils/mmgr/palloc.c b/src/backend/utils/mmgr/palloc.c index 2653401b2a..bf36908973 100644 --- a/src/backend/utils/mmgr/palloc.c +++ b/src/backend/utils/mmgr/palloc.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/Attic/palloc.c,v 1.11 1999/02/13 23:20:11 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/Attic/palloc.c,v 1.12 1999/05/25 16:12:54 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -36,7 +36,7 @@ char * pstrdup(char *string) { - char *nstr; + char *nstr; int len; nstr = palloc(len = strlen(string) + 1); @@ -44,4 +44,3 @@ pstrdup(char *string) return nstr; } - diff --git a/src/backend/utils/mmgr/portalmem.c b/src/backend/utils/mmgr/portalmem.c index 4068b13467..d4cc93482f 100644 --- a/src/backend/utils/mmgr/portalmem.c +++ b/src/backend/utils/mmgr/portalmem.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/portalmem.c,v 1.18 1999/02/13 23:20:12 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/portalmem.c,v 1.19 1999/05/25 16:12:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -50,7 +50,7 @@ * * Here is an old comment taken from nodes/memnodes.h * - * MemoryContext + * MemoryContext * A logical context in which memory allocations occur. * * The types of memory contexts can be thought of as members of the @@ -517,7 +517,7 @@ DumpPortals() * ---------------------------------------------------------------- */ /* - * EnablePortalManager + * EnablePortalManager * Enables/disables the portal management module. */ void @@ -579,7 +579,7 @@ EnablePortalManager(bool on) } /* - * GetPortalByName + * GetPortalByName * Returns a portal given a portal name; returns blank portal given * NULL; returns invalid portal if portal not found. * @@ -606,7 +606,7 @@ GetPortalByName(char *name) } /* - * BlankPortalAssignName + * BlankPortalAssignName * Returns former blank portal as portal with given name. * * Side effect: @@ -659,7 +659,7 @@ BlankPortalAssignName(char *name) /* XXX PortalName */ } /* - * PortalSetQuery + * PortalSetQuery * Attaches a "query" to portal. * * Exceptions: @@ -686,7 +686,7 @@ PortalSetQuery(Portal portal, } /* - * PortalGetQueryDesc + * PortalGetQueryDesc * Returns query attached to portal. * * Exceptions: @@ -703,7 +703,7 @@ PortalGetQueryDesc(Portal portal) } /* - * PortalGetState + * PortalGetState * Returns state attached to portal. * * Exceptions: @@ -720,7 +720,7 @@ PortalGetState(Portal portal) } /* - * CreatePortal + * CreatePortal * Returns a new portal given a name. * * Note: @@ -784,7 +784,7 @@ CreatePortal(char *name) /* XXX PortalName */ } /* - * PortalDestroy + * PortalDestroy * Destroys portal. * * Exceptions: @@ -813,22 +813,22 @@ PortalDestroy(Portal *portalP) AllocSetReset(&portal->variable.setData); /* XXX log */ /* - * In the case of a transaction abort it is possible that - * we get called while one of the memory contexts of the portal - * we're destroying is the current memory context. - * - * Don't know how to handle that cleanly because it is required - * to be in that context right now. This portal struct remains - * allocated in the PortalMemory context until backend dies. + * In the case of a transaction abort it is possible that we get + * called while one of the memory contexts of the portal we're + * destroying is the current memory context. * - * Not happy with that, but it's better to loose some bytes of - * memory than to have the backend dump core. + * Don't know how to handle that cleanly because it is required to be in + * that context right now. This portal struct remains allocated in the + * PortalMemory context until backend dies. + * + * Not happy with that, but it's better to loose some bytes of memory + * than to have the backend dump core. * * --- Feb. 04, 1999 Jan Wieck */ - if (CurrentMemoryContext == (MemoryContext)PortalGetHeapMemory(portal)) + if (CurrentMemoryContext == (MemoryContext) PortalGetHeapMemory(portal)) return; - if (CurrentMemoryContext == (MemoryContext)PortalGetVariableMemory(portal)) + if (CurrentMemoryContext == (MemoryContext) PortalGetVariableMemory(portal)) return; if (portal != BlankPortal) @@ -836,7 +836,7 @@ PortalDestroy(Portal *portalP) } /* ---------------- - * PortalResetHeapMemory + * PortalResetHeapMemory * Resets portal's heap memory context. * * Someday, Reset, Start, and End can be optimized by keeping a global @@ -873,7 +873,7 @@ PortalResetHeapMemory(Portal portal) } /* - * StartPortalAllocMode + * StartPortalAllocMode * Starts a new block of portal heap allocation using mode and limit; * the current block is disabled until EndPortalAllocMode is called. * @@ -904,7 +904,7 @@ StartPortalAllocMode(AllocMode mode, Size limit) /* allocate and initialize new block */ context->block = MemoryContextAlloc( (MemoryContext) PortalHeapMemoryGetVariableMemory(context), - sizeof(HeapMemoryBlockData)); + sizeof(HeapMemoryBlockData)); /* XXX careful, context->block has never been stacked => bad state */ @@ -912,7 +912,7 @@ StartPortalAllocMode(AllocMode mode, Size limit) } /* - * EndPortalAllocMode + * EndPortalAllocMode * Ends current block of portal heap allocation; previous block is * reenabled. * @@ -944,7 +944,7 @@ EndPortalAllocMode() } /* - * PortalGetVariableMemory + * PortalGetVariableMemory * Returns variable memory context for a given portal. * * Exceptions: @@ -958,7 +958,7 @@ PortalGetVariableMemory(Portal portal) } /* - * PortalGetHeapMemory + * PortalGetHeapMemory * Returns heap memory context for a given portal. * * Exceptions: @@ -972,7 +972,7 @@ PortalGetHeapMemory(Portal portal) } /* - * PortalVariableMemoryGetPortal + * PortalVariableMemoryGetPortal * Returns portal containing given variable memory context. * * Exceptions: @@ -986,7 +986,7 @@ PortalVariableMemoryGetPortal(PortalVariableMemory context) } /* - * PortalHeapMemoryGetPortal + * PortalHeapMemoryGetPortal * Returns portal containing given heap memory context. * * Exceptions: @@ -1000,7 +1000,7 @@ PortalHeapMemoryGetPortal(PortalHeapMemory context) } /* - * PortalVariableMemoryGetHeapMemory + * PortalVariableMemoryGetHeapMemory * Returns heap memory context associated with given variable memory. * * Exceptions: @@ -1019,7 +1019,7 @@ PortalVariableMemoryGetHeapMemory(PortalVariableMemory context) #endif /* - * PortalHeapMemoryGetVariableMemory + * PortalHeapMemoryGetVariableMemory * Returns variable memory context associated with given heap memory. * * Exceptions: diff --git a/src/backend/utils/sort/psort.c b/src/backend/utils/sort/psort.c index d35141ad77..497dceff07 100644 --- a/src/backend/utils/sort/psort.c +++ b/src/backend/utils/sort/psort.c @@ -4,7 +4,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: psort.c,v 1.51 1999/05/09 00:53:22 tgl Exp $ + * $Id: psort.c,v 1.52 1999/05/25 16:12:59 momjian Exp $ * * NOTES * Sorts the first relation into the second relation. @@ -55,9 +55,9 @@ #include "utils/rel.h" static bool createfirstrun(Sort *node); -static bool createrun(Sort *node, BufFile *file); -static void destroytape(BufFile *file); -static void dumptuples(BufFile *file, Sort *node); +static bool createrun(Sort *node, BufFile * file); +static void destroytape(BufFile * file); +static void dumptuples(BufFile * file, Sort *node); static BufFile *gettape(void); static void initialrun(Sort *node); static void inittapes(Sort *node); @@ -320,15 +320,11 @@ initialrun(Sort *node) tp->tp_dummy--; PS(node)->TotalDummy--; if (tp->tp_dummy < (tp + 1)->tp_dummy) - { tp++; - } - else + else { if (tp->tp_dummy != 0) - { tp = PS(node)->Tape; - } else { PS(node)->Level++; @@ -337,13 +333,13 @@ initialrun(Sort *node) tp - PS(node)->Tape < PS(node)->TapeRange; tp++) { PS(node)->TotalDummy += (tp->tp_dummy = baseruns - + (tp + 1)->tp_fib - - tp->tp_fib); + + (tp + 1)->tp_fib + - tp->tp_fib); tp->tp_fib = baseruns + (tp + 1)->tp_fib; } - tp = PS(node)->Tape;/* D4 */ - } /* D3 */ + tp = PS(node)->Tape; /* D4 */ + } /* D3 */ } if (extrapasses) { @@ -354,9 +350,7 @@ initialrun(Sort *node) continue; } else - { break; - } } if ((bool) createrun(node, tp->tp_file) == false) extrapasses = 1 + (PS(node)->Tuples != NULL); @@ -479,7 +473,7 @@ createfirstrun(Sort *node) * Tuples contains the tuples for the following run upon exit */ static bool -createrun(Sort *node, BufFile *file) +createrun(Sort *node, BufFile * file) { HeapTuple lasttuple; HeapTuple tup; @@ -554,9 +548,7 @@ createrun(Sort *node, BufFile *file) memtuples[t_last] = tup; } else - { puttuple(&PS(node)->Tuples, tup, 0, &PS(node)->treeContext); - } } if (lasttuple != NULL) { @@ -627,7 +619,7 @@ merge(Sort *node, struct tape * dest) struct tape *lasttp; /* (TAPE[P]) */ struct tape *tp; struct leftist *tuples; - BufFile *destfile; + BufFile *destfile; int times; /* runs left to merge */ int outdummy; /* complete dummy runs */ short fromtape; @@ -644,10 +636,9 @@ merge(Sort *node, struct tape * dest) tp->tp_fib += times; /* Tape[].tp_fib (A[]) is set to proper exit values */ - if (PS(node)->TotalDummy < PS(node)->TapeRange) /* no complete dummy runs */ - { + if (PS(node)->TotalDummy < PS(node)->TapeRange) /* no complete dummy + * runs */ outdummy = 0; - } else { outdummy = PS(node)->TotalDummy; /* a large positive number */ @@ -729,7 +720,7 @@ merge(Sort *node, struct tape * dest) * dumptuples - stores all the tuples in tree into file */ static void -dumptuples(BufFile *file, Sort *node) +dumptuples(BufFile * file, Sort *node) { struct leftist *tp; struct leftist *newp; @@ -812,7 +803,7 @@ psort_grabtuple(Sort *node, bool *should_free) * file */ BufFileSeek(PS(node)->psort_grab_file, - PS(node)->psort_current - sizeof(tlendummy), SEEK_SET); + PS(node)->psort_current - sizeof(tlendummy), SEEK_SET); GETLEN(tuplen, PS(node)->psort_grab_file); if (PS(node)->psort_current < tuplen) elog(ERROR, "psort_grabtuple: too big last tuple len in backward scan"); @@ -845,7 +836,7 @@ psort_grabtuple(Sort *node, bool *should_free) PS(node)->psort_current -= tuplen; /* move to position of end tlen of prev tuple */ BufFileSeek(PS(node)->psort_grab_file, - PS(node)->psort_current - sizeof(tlendummy), SEEK_SET); + PS(node)->psort_current - sizeof(tlendummy), SEEK_SET); GETLEN(tuplen, PS(node)->psort_grab_file); if (PS(node)->psort_current < tuplen + sizeof(tlendummy)) elog(ERROR, "psort_grabtuple: too big tuple len in backward scan"); @@ -1005,7 +996,7 @@ gettape() * destroytape - unlinks the tape */ static void -destroytape(BufFile *file) +destroytape(BufFile * file) { BufFileClose(file); } diff --git a/src/backend/utils/time/tqual.c b/src/backend/utils/time/tqual.c index bdcd1afdba..104e57b919 100644 --- a/src/backend/utils/time/tqual.c +++ b/src/backend/utils/time/tqual.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.28 1999/04/12 16:57:27 vadim Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.29 1999/05/25 16:13:02 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -26,11 +26,11 @@ extern bool PostgresIsInitialized; -SnapshotData SnapshotDirtyData; -Snapshot SnapshotDirty = &SnapshotDirtyData; +SnapshotData SnapshotDirtyData; +Snapshot SnapshotDirty = &SnapshotDirtyData; -Snapshot QuerySnapshot = NULL; -Snapshot SerializableSnapshot = NULL; +Snapshot QuerySnapshot = NULL; +Snapshot SerializableSnapshot = NULL; /* * XXX Transaction system override hacks start here @@ -59,7 +59,7 @@ setheapoverride(bool on) */ /* - * HeapTupleSatisfiesItself + * HeapTupleSatisfiesItself * True iff heap tuple is valid for "itself." * "{it}self" means valid as of everything that's happened * in the current transaction, _including_ the current command. @@ -91,7 +91,7 @@ HeapTupleSatisfiesItself(HeapTupleHeader tuple) if (tuple->t_infomask & HEAP_MOVED_OFF) { - if (TransactionIdDidCommit((TransactionId)tuple->t_cmin)) + if (TransactionIdDidCommit((TransactionId) tuple->t_cmin)) { tuple->t_infomask |= HEAP_XMIN_INVALID; return false; @@ -99,7 +99,7 @@ HeapTupleSatisfiesItself(HeapTupleHeader tuple) } else if (tuple->t_infomask & HEAP_MOVED_IN) { - if (!TransactionIdDidCommit((TransactionId)tuple->t_cmin)) + if (!TransactionIdDidCommit((TransactionId) tuple->t_cmin)) { tuple->t_infomask |= HEAP_XMIN_INVALID; return false; @@ -130,7 +130,7 @@ HeapTupleSatisfiesItself(HeapTupleHeader tuple) { if (tuple->t_infomask & HEAP_MARKED_FOR_UPDATE) return true; - return false; /* updated by other */ + return false; /* updated by other */ } if (TransactionIdIsCurrentTransactionId(tuple->t_xmax)) @@ -157,7 +157,7 @@ HeapTupleSatisfiesItself(HeapTupleHeader tuple) } /* - * HeapTupleSatisfiesNow + * HeapTupleSatisfiesNow * True iff heap tuple is valid "now." * "now" means valid including everything that's happened * in the current transaction _up to, but not including,_ @@ -218,7 +218,7 @@ HeapTupleSatisfiesNow(HeapTupleHeader tuple) if (tuple->t_infomask & HEAP_MOVED_OFF) { - if (TransactionIdDidCommit((TransactionId)tuple->t_cmin)) + if (TransactionIdDidCommit((TransactionId) tuple->t_cmin)) { tuple->t_infomask |= HEAP_XMIN_INVALID; return false; @@ -226,7 +226,7 @@ HeapTupleSatisfiesNow(HeapTupleHeader tuple) } else if (tuple->t_infomask & HEAP_MOVED_IN) { - if (!TransactionIdDidCommit((TransactionId)tuple->t_cmin)) + if (!TransactionIdDidCommit((TransactionId) tuple->t_cmin)) { tuple->t_infomask |= HEAP_XMIN_INVALID; return false; @@ -300,19 +300,19 @@ HeapTupleSatisfiesNow(HeapTupleHeader tuple) int HeapTupleSatisfiesUpdate(HeapTuple tuple) { - HeapTupleHeader th = tuple->t_data; + HeapTupleHeader th = tuple->t_data; if (AMI_OVERRIDE) return HeapTupleMayBeUpdated; if (!(th->t_infomask & HEAP_XMIN_COMMITTED)) { - if (th->t_infomask & HEAP_XMIN_INVALID) /* xid invalid or aborted */ + if (th->t_infomask & HEAP_XMIN_INVALID) /* xid invalid or aborted */ return HeapTupleInvisible; if (th->t_infomask & HEAP_MOVED_OFF) { - if (TransactionIdDidCommit((TransactionId)th->t_cmin)) + if (TransactionIdDidCommit((TransactionId) th->t_cmin)) { th->t_infomask |= HEAP_XMIN_INVALID; return HeapTupleInvisible; @@ -320,7 +320,7 @@ HeapTupleSatisfiesUpdate(HeapTuple tuple) } else if (th->t_infomask & HEAP_MOVED_IN) { - if (!TransactionIdDidCommit((TransactionId)th->t_cmin)) + if (!TransactionIdDidCommit((TransactionId) th->t_cmin)) { th->t_infomask |= HEAP_XMIN_INVALID; return HeapTupleInvisible; @@ -329,9 +329,10 @@ HeapTupleSatisfiesUpdate(HeapTuple tuple) else if (TransactionIdIsCurrentTransactionId(th->t_xmin)) { if (CommandIdGEScanCommandId(th->t_cmin) && !heapisoverride()) - return HeapTupleInvisible; /* inserted after scan started */ + return HeapTupleInvisible; /* inserted after scan + * started */ - if (th->t_infomask & HEAP_XMAX_INVALID) /* xid invalid */ + if (th->t_infomask & HEAP_XMAX_INVALID) /* xid invalid */ return HeapTupleMayBeUpdated; Assert(TransactionIdIsCurrentTransactionId(th->t_xmax)); @@ -340,14 +341,16 @@ HeapTupleSatisfiesUpdate(HeapTuple tuple) return HeapTupleMayBeUpdated; if (CommandIdGEScanCommandId(th->t_cmax)) - return HeapTupleSelfUpdated;/* updated after scan started */ + return HeapTupleSelfUpdated; /* updated after scan + * started */ else - return HeapTupleInvisible; /* updated before scan started */ + return HeapTupleInvisible; /* updated before scan + * started */ } else if (!TransactionIdDidCommit(th->t_xmin)) { if (TransactionIdDidAbort(th->t_xmin)) - th->t_infomask |= HEAP_XMIN_INVALID; /* aborted */ + th->t_infomask |= HEAP_XMIN_INVALID; /* aborted */ return HeapTupleInvisible; } th->t_infomask |= HEAP_XMIN_COMMITTED; @@ -355,14 +358,14 @@ HeapTupleSatisfiesUpdate(HeapTuple tuple) /* by here, the inserting transaction has committed */ - if (th->t_infomask & HEAP_XMAX_INVALID) /* xid invalid or aborted */ + if (th->t_infomask & HEAP_XMAX_INVALID) /* xid invalid or aborted */ return HeapTupleMayBeUpdated; if (th->t_infomask & HEAP_XMAX_COMMITTED) { if (th->t_infomask & HEAP_MARKED_FOR_UPDATE) return HeapTupleMayBeUpdated; - return HeapTupleUpdated; /* updated by other */ + return HeapTupleUpdated;/* updated by other */ } if (TransactionIdIsCurrentTransactionId(th->t_xmax)) @@ -370,7 +373,8 @@ HeapTupleSatisfiesUpdate(HeapTuple tuple) if (th->t_infomask & HEAP_MARKED_FOR_UPDATE) return HeapTupleMayBeUpdated; if (CommandIdGEScanCommandId(th->t_cmax)) - return HeapTupleSelfUpdated;/* updated after scan started */ + return HeapTupleSelfUpdated; /* updated after scan + * started */ else return HeapTupleInvisible; /* updated before scan started */ } @@ -392,7 +396,7 @@ HeapTupleSatisfiesUpdate(HeapTuple tuple) if (th->t_infomask & HEAP_MARKED_FOR_UPDATE) return HeapTupleMayBeUpdated; - return HeapTupleUpdated; /* updated by other */ + return HeapTupleUpdated; /* updated by other */ } bool @@ -411,13 +415,14 @@ HeapTupleSatisfiesDirty(HeapTupleHeader tuple) if (tuple->t_infomask & HEAP_MOVED_OFF) { + /* * HeapTupleSatisfiesDirty is used by unique btree-s and so * may be used while vacuuming. */ - if (TransactionIdIsCurrentTransactionId((TransactionId)tuple->t_cmin)) + if (TransactionIdIsCurrentTransactionId((TransactionId) tuple->t_cmin)) return false; - if (TransactionIdDidCommit((TransactionId)tuple->t_cmin)) + if (TransactionIdDidCommit((TransactionId) tuple->t_cmin)) { tuple->t_infomask |= HEAP_XMIN_INVALID; return false; @@ -426,9 +431,9 @@ HeapTupleSatisfiesDirty(HeapTupleHeader tuple) } else if (tuple->t_infomask & HEAP_MOVED_IN) { - if (!TransactionIdIsCurrentTransactionId((TransactionId)tuple->t_cmin)) + if (!TransactionIdIsCurrentTransactionId((TransactionId) tuple->t_cmin)) { - if (TransactionIdDidCommit((TransactionId)tuple->t_cmin)) + if (TransactionIdDidCommit((TransactionId) tuple->t_cmin)) tuple->t_infomask |= HEAP_XMIN_COMMITTED; else { @@ -457,7 +462,7 @@ HeapTupleSatisfiesDirty(HeapTupleHeader tuple) return false; } SnapshotDirty->xmin = tuple->t_xmin; - return true; /* in insertion by other */ + return true; /* in insertion by other */ } else tuple->t_infomask |= HEAP_XMIN_COMMITTED; @@ -473,7 +478,7 @@ HeapTupleSatisfiesDirty(HeapTupleHeader tuple) if (tuple->t_infomask & HEAP_MARKED_FOR_UPDATE) return true; SnapshotDirty->tid = tuple->t_ctid; - return false; /* updated by other */ + return false; /* updated by other */ } if (TransactionIdIsCurrentTransactionId(tuple->t_xmax)) @@ -488,7 +493,7 @@ HeapTupleSatisfiesDirty(HeapTupleHeader tuple) } /* running xact */ SnapshotDirty->xmax = tuple->t_xmax; - return true; /* in updation by other */ + return true; /* in updation by other */ } /* xmax transaction committed */ @@ -498,7 +503,7 @@ HeapTupleSatisfiesDirty(HeapTupleHeader tuple) return true; SnapshotDirty->tid = tuple->t_ctid; - return false; /* updated by other */ + return false; /* updated by other */ } bool @@ -514,7 +519,7 @@ HeapTupleSatisfiesSnapshot(HeapTupleHeader tuple, Snapshot snapshot) if (tuple->t_infomask & HEAP_MOVED_OFF) { - if (TransactionIdDidCommit((TransactionId)tuple->t_cmin)) + if (TransactionIdDidCommit((TransactionId) tuple->t_cmin)) { tuple->t_infomask |= HEAP_XMIN_INVALID; return false; @@ -522,7 +527,7 @@ HeapTupleSatisfiesSnapshot(HeapTupleHeader tuple, Snapshot snapshot) } else if (tuple->t_infomask & HEAP_MOVED_IN) { - if (!TransactionIdDidCommit((TransactionId)tuple->t_cmin)) + if (!TransactionIdDidCommit((TransactionId) tuple->t_cmin)) { tuple->t_infomask |= HEAP_XMIN_INVALID; return false; @@ -555,17 +560,17 @@ HeapTupleSatisfiesSnapshot(HeapTupleHeader tuple, Snapshot snapshot) tuple->t_infomask |= HEAP_XMIN_COMMITTED; } - /* - * By here, the inserting transaction has committed - - * have to check when... + /* + * By here, the inserting transaction has committed - have to check + * when... */ if (tuple->t_xmin >= snapshot->xmax) return false; if (tuple->t_xmin >= snapshot->xmin) { - uint32 i; - + uint32 i; + for (i = 0; i < snapshot->xcnt; i++) { if (tuple->t_xmin == snapshot->xip[i]) @@ -584,15 +589,15 @@ HeapTupleSatisfiesSnapshot(HeapTupleHeader tuple, Snapshot snapshot) if (TransactionIdIsCurrentTransactionId(tuple->t_xmax)) { if (CommandIdGEScanCommandId(tuple->t_cmax)) - return true; /* deleted after scan started */ + return true; /* deleted after scan started */ else - return false; /* deleted before scan started */ + return false; /* deleted before scan started */ } if (!TransactionIdDidCommit(tuple->t_xmax)) { if (TransactionIdDidAbort(tuple->t_xmax)) - tuple->t_infomask |= HEAP_XMAX_INVALID; /* aborted */ + tuple->t_infomask |= HEAP_XMAX_INVALID; /* aborted */ return true; } @@ -604,8 +609,8 @@ HeapTupleSatisfiesSnapshot(HeapTupleHeader tuple, Snapshot snapshot) return true; if (tuple->t_xmax >= snapshot->xmin) { - uint32 i; - + uint32 i; + for (i = 0; i < snapshot->xcnt; i++) { if (tuple->t_xmax == snapshot->xip[i]) diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 7cb1242e1d..3ad451408b 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.29 1999/02/13 23:20:22 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.30 1999/05/25 16:13:05 momjian Exp $ * * Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2 * @@ -101,7 +101,7 @@ findOprByOid(OprInfo *oprinfo, int numOprs, const char *oid) /* - * findParentsByOid + * findParentsByOid * given the oid of a class, return the names of its parent classes * and assign the number of parents to the last argument. * @@ -146,7 +146,7 @@ findParentsByOid(TableInfo *tblinfo, int numTables, fprintf(stderr, "failed sanity check, parent oid %s of table %s (oid %s) was not found\n", inhinfo[i].inhparent, - (selfInd >= 0) ? tblinfo[selfInd].relname : "", + (selfInd >= 0) ? tblinfo[selfInd].relname : "", oid); exit(2); } @@ -495,8 +495,8 @@ findFuncByName(FuncInfo *finfo, int numFuncs, const char *name) * checks input string for non-lowercase characters * returns pointer to input string or string surrounded by double quotes * - * Note that the returned string should be used immediately since it - * uses a static buffer to hold the string. Non-reentrant but faster? + * Note that the returned string should be used immediately since it + * uses a static buffer to hold the string. Non-reentrant but faster? */ const char * fmtId(const char *rawid, bool force_quotes) @@ -504,7 +504,7 @@ fmtId(const char *rawid, bool force_quotes) const char *cp; static char id[MAXQUERYLEN]; - if (! force_quotes) + if (!force_quotes) for (cp = rawid; *cp != '\0'; cp++) if (!(islower(*cp) || isdigit(*cp) || (*cp == '_'))) break; diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 89b9d77b66..dc9991c099 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -21,7 +21,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.107 1999/05/15 22:18:50 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.108 1999/05/25 16:13:06 momjian Exp $ * * Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb * @@ -56,7 +56,7 @@ #include #include #include -#include /* for MAXHOSTNAMELEN on most */ +#include /* for MAXHOSTNAMELEN on most */ #ifdef solaris_sparc #include /* for MAXHOSTNAMELEN on some */ #endif @@ -87,7 +87,7 @@ static void dumpACL(FILE *fout, TableInfo tbinfo); static void dumpTriggers(FILE *fout, const char *tablename, TableInfo *tblinfo, int numTables); static void dumpRules(FILE *fout, const char *tablename, - TableInfo *tblinfo, int numTables); + TableInfo *tblinfo, int numTables); static char *checkForQuote(const char *s); static void clearTableInfo(TableInfo *, int); static void dumpOneFunc(FILE *fout, FuncInfo *finfo, int i, @@ -100,26 +100,26 @@ static void AddAcl(char *aclbuf, const char *keyword); static char *GetPrivileges(const char *s); static void becomeUser(FILE *fout, const char *username); -extern char *optarg; +extern char *optarg; extern int optind, - opterr; + opterr; /* global decls */ bool g_verbose; /* User wants verbose narration of our - * activities. */ -int g_last_builtin_oid; /* value of the last builtin oid */ -FILE *g_fout; /* the script file */ -PGconn *g_conn; /* the database connection */ + * activities. */ +int g_last_builtin_oid; /* value of the last builtin oid */ +FILE *g_fout; /* the script file */ +PGconn *g_conn; /* the database connection */ -bool force_quotes; /* User wants to suppress double-quotes */ -int dumpData; /* dump data using proper insert strings */ -int attrNames; /* put attr names into insert strings */ -int schemaOnly; -int dataOnly; -int aclsOption; +bool force_quotes; /* User wants to suppress double-quotes */ +int dumpData; /* dump data using proper insert strings */ +int attrNames; /* put attr names into insert strings */ +int schemaOnly; +int dataOnly; +int aclsOption; bool drop_schema; -char g_opaque_type[10]; /* name for the opaque type */ +char g_opaque_type[10]; /* name for the opaque type */ /* placeholders for the delimiters for comments */ char g_comment_start[10]; @@ -139,15 +139,15 @@ usage(const char *progname) "\t -d \t\t dump data as proper insert strings\n"); fprintf(stderr, "\t -D \t\t dump data as inserts" - " with attribute names\n"); + " with attribute names\n"); fprintf(stderr, "\t -f filename \t\t script output filename\n"); fprintf(stderr, "\t -h hostname \t\t server host name\n"); fprintf(stderr, - "\t -n \t\t suppress most quotes around identifiers\n"); + "\t -n \t\t suppress most quotes around identifiers\n"); fprintf(stderr, - "\t -N \t\t enable most quotes around identifiers\n"); + "\t -N \t\t enable most quotes around identifiers\n"); fprintf(stderr, "\t -o \t\t dump object id's (oids)\n"); fprintf(stderr, @@ -186,8 +186,8 @@ exit_nicely(PGconn *conn) static bool isViewRule(char *relname) { - PGresult *res; - int ntups; + PGresult *res; + int ntups; char query[MAXQUERYLEN]; res = PQexec(g_conn, "begin"); @@ -318,7 +318,7 @@ static void dumpClasses_dumpData(FILE *fout, const char *classname, const TableInfo tblinfo, bool oids) { - PGresult *res; + PGresult *res; char q[MAXQUERYLEN]; int tuple; int field; @@ -369,19 +369,22 @@ dumpClasses_dumpData(FILE *fout, const char *classname, PQgetvalue(res, tuple, field)); break; default: - /* All other types are printed as string literals, - * with appropriate escaping of special characters. - * Quote mark ' goes to '' per SQL standard, - * other stuff goes to \ sequences. + + /* + * All other types are printed as string literals, + * with appropriate escaping of special + * characters. Quote mark ' goes to '' per SQL + * standard, other stuff goes to \ sequences. */ expsrc = PQgetvalue(res, tuple, field); expdest = q; for (; *expsrc; expsrc++) { - char ch = *expsrc; + char ch = *expsrc; + if (ch == '\\' || ch == '\'') { - *expdest++ = ch; /* double it */ + *expdest++ = ch; /* double it */ *expdest++ = ch; } else if (ch < '\040') @@ -418,7 +421,7 @@ dumpClasses(const TableInfo *tblinfo, const int numTables, FILE *fout, { int i; - char *all_only; + char *all_only; if (onlytable == NULL) all_only = "all"; @@ -479,11 +482,12 @@ static void prompt_for_password(char *username, char *password) { char buf[512]; - int length; + int length; #ifdef HAVE_TERMIOS_H - struct termios t_orig, - t; + struct termios t_orig, + t; + #endif printf("Username: "); @@ -531,21 +535,21 @@ prompt_for_password(char *username, char *password) int main(int argc, char **argv) { - int c; - const char *progname; - const char *filename = NULL; - const char *dbname = NULL; - const char *pghost = NULL; - const char *pgport = NULL; - char *tablename = NULL; - int oids = 0; - TableInfo *tblinfo; - int numTables; + int c; + const char *progname; + const char *filename = NULL; + const char *dbname = NULL; + const char *pghost = NULL; + const char *pgport = NULL; + char *tablename = NULL; + int oids = 0; + TableInfo *tblinfo; + int numTables; char connect_string[512] = ""; char tmp_string[128]; char username[100]; char password[100]; - int use_password = 0; + int use_password = 0; g_verbose = false; force_quotes = true; @@ -566,7 +570,8 @@ main(int argc, char **argv) case 'a': /* Dump data only */ dataOnly = 1; break; - case 'c': /* clean (i.e., drop) schema prior to create */ + case 'c': /* clean (i.e., drop) schema prior to + * create */ drop_schema = true; break; case 'd': /* dump data as proper insert strings */ @@ -583,7 +588,8 @@ main(int argc, char **argv) case 'h': /* server host */ pghost = optarg; break; - case 'n': /* Do not force double-quotes on identifiers */ + case 'n': /* Do not force double-quotes on + * identifiers */ force_quotes = false; break; case 'N': /* Force double-quotes on identifiers */ @@ -603,12 +609,16 @@ main(int argc, char **argv) int i; tablename = strdup(optarg); - /* quoted string? Then strip quotes and preserve case... */ + + /* + * quoted string? Then strip quotes and preserve + * case... + */ if (tablename[0] == '"') { strcpy(tablename, &tablename[1]); - if (*(tablename+strlen(tablename)-1) == '"') - *(tablename+strlen(tablename)-1) = '\0'; + if (*(tablename + strlen(tablename) - 1) == '"') + *(tablename + strlen(tablename) - 1) = '\0'; } /* otherwise, convert table name to lowercase... */ else @@ -742,11 +752,11 @@ main(int argc, char **argv) TypeInfo * getTypes(int *numTypes) { - PGresult *res; + PGresult *res; int ntups; int i; - char query[MAXQUERYLEN]; - TypeInfo *tinfo; + char query[MAXQUERYLEN]; + TypeInfo *tinfo; int i_oid; int i_typowner; @@ -871,12 +881,12 @@ getTypes(int *numTypes) OprInfo * getOperators(int *numOprs) { - PGresult *res; + PGresult *res; int ntups; int i; - char query[MAXQUERYLEN]; + char query[MAXQUERYLEN]; - OprInfo *oprinfo; + OprInfo *oprinfo; int i_oid; int i_oprname; @@ -1214,11 +1224,11 @@ clearAggInfo(AggInfo *agginfo, int numArgs) AggInfo * getAggregates(int *numAggs) { - PGresult *res; + PGresult *res; int ntups; int i; - char query[MAXQUERYLEN]; - AggInfo *agginfo; + char query[MAXQUERYLEN]; + AggInfo *agginfo; int i_oid; int i_aggname; @@ -1308,11 +1318,11 @@ getAggregates(int *numAggs) FuncInfo * getFuncs(int *numFuncs) { - PGresult *res; + PGresult *res; int ntups; int i; - char query[MAXQUERYLEN]; - FuncInfo *finfo; + char query[MAXQUERYLEN]; + FuncInfo *finfo; int i_oid; int i_proname; @@ -1408,11 +1418,11 @@ getFuncs(int *numFuncs) TableInfo * getTables(int *numTables, FuncInfo *finfo, int numFuncs) { - PGresult *res; + PGresult *res; int ntups; int i; - char query[MAXQUERYLEN]; - TableInfo *tblinfo; + char query[MAXQUERYLEN]; + TableInfo *tblinfo; int i_oid; int i_relname; @@ -1479,16 +1489,17 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs) tblinfo[i].ncheck = atoi(PQgetvalue(res, i, i_relchecks)); tblinfo[i].ntrig = atoi(PQgetvalue(res, i, i_reltriggers)); - /* Exclude inherited CHECKs from CHECK constraints total. - * If a constraint matches by name and condition with a constraint + /* + * Exclude inherited CHECKs from CHECK constraints total. If a + * constraint matches by name and condition with a constraint * belonging to a parent class, we assume it was inherited. */ if (tblinfo[i].ncheck > 0) { - PGresult *res2; + PGresult *res2; int ntups2; - if (g_verbose) + if (g_verbose) fprintf(stderr, "%s excluding inherited CHECK constraints " "for relation: '%s' %s\n", g_comment_start, @@ -1647,15 +1658,15 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs) } tgfunc = finfo[findx].proname; -#if 0 +#if 0 /* XXX - how to emit this DROP TRIGGER? */ if (drop_schema) - { - sprintf(query, "DROP TRIGGER %s ON %s;\n", - fmtId(PQgetvalue(res2, i2, i_tgname), force_quotes), - fmtId(tblinfo[i].relname, force_quotes)); - fputs(query, fout); - } + { + sprintf(query, "DROP TRIGGER %s ON %s;\n", + fmtId(PQgetvalue(res2, i2, i_tgname), force_quotes), + fmtId(tblinfo[i].relname, force_quotes)); + fputs(query, fout); + } #endif sprintf(query, "CREATE TRIGGER %s ", fmtId(PQgetvalue(res2, i2, i_tgname), force_quotes)); @@ -1686,7 +1697,7 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs) strcat(query, " UPDATE"); } sprintf(query, "%s ON %s FOR EACH ROW EXECUTE PROCEDURE %s (", - query, fmtId(tblinfo[i].relname, force_quotes), tgfunc); + query, fmtId(tblinfo[i].relname, force_quotes), tgfunc); for (findx = 0; findx < tgnargs; findx++) { char *s, @@ -1753,11 +1764,11 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs) InhInfo * getInherits(int *numInherits) { - PGresult *res; + PGresult *res; int ntups; int i; - char query[MAXQUERYLEN]; - InhInfo *inhinfo; + char query[MAXQUERYLEN]; + InhInfo *inhinfo; int i_inhrel; int i_inhparent; @@ -1818,13 +1829,13 @@ getTableAttrs(TableInfo *tblinfo, int numTables) { int i, j; - char q[MAXQUERYLEN]; + char q[MAXQUERYLEN]; int i_attname; int i_typname; int i_atttypmod; int i_attnotnull; int i_atthasdef; - PGresult *res; + PGresult *res; int ntups; for (i = 0; i < numTables; i++) @@ -1929,10 +1940,10 @@ IndInfo * getIndices(int *numIndices) { int i; - char query[MAXQUERYLEN]; - PGresult *res; + char query[MAXQUERYLEN]; + PGresult *res; int ntups; - IndInfo *indinfo; + IndInfo *indinfo; int i_indexrelname; int i_indrelname; @@ -2020,7 +2031,7 @@ dumpTypes(FILE *fout, FuncInfo *finfo, int numFuncs, TypeInfo *tinfo, int numTypes) { int i; - char q[MAXQUERYLEN]; + char q[MAXQUERYLEN]; int funcInd; for (i = 0; i < numTypes; i++) @@ -2054,10 +2065,10 @@ dumpTypes(FILE *fout, FuncInfo *finfo, int numFuncs, becomeUser(fout, tinfo[i].usename); if (drop_schema) - { - sprintf(q, "DROP TYPE %s;\n", fmtId(tinfo[i].typname, force_quotes)); - fputs(q, fout); - } + { + sprintf(q, "DROP TYPE %s;\n", fmtId(tinfo[i].typname, force_quotes)); + fputs(q, fout); + } sprintf(q, "CREATE TYPE %s " @@ -2092,23 +2103,23 @@ dumpTypes(FILE *fout, FuncInfo *finfo, int numFuncs, /* * dumpProcLangs - * writes out to fout the queries to recreate user-defined procedural languages + * writes out to fout the queries to recreate user-defined procedural languages * */ void dumpProcLangs(FILE *fout, FuncInfo *finfo, int numFuncs, - TypeInfo *tinfo, int numTypes) + TypeInfo *tinfo, int numTypes) { - PGresult *res; - char query[MAXQUERYLEN]; + PGresult *res; + char query[MAXQUERYLEN]; int ntups; int i_lanname; int i_lanpltrusted; int i_lanplcallfoid; int i_lancompiler; - char *lanname; - char *lancompiler; - char *lanplcallfoid; + char *lanname; + char *lancompiler; + char *lanplcallfoid; int i, fidx; @@ -2132,12 +2143,13 @@ dumpProcLangs(FILE *fout, FuncInfo *finfo, int numFuncs, } ntups = PQntuples(res); - i_lanname = PQfnumber(res, "lanname"); - i_lanpltrusted = PQfnumber(res, "lanpltrusted"); - i_lanplcallfoid = PQfnumber(res, "lanplcallfoid"); - i_lancompiler = PQfnumber(res, "lancompiler"); + i_lanname = PQfnumber(res, "lanname"); + i_lanpltrusted = PQfnumber(res, "lanpltrusted"); + i_lanplcallfoid = PQfnumber(res, "lanplcallfoid"); + i_lancompiler = PQfnumber(res, "lancompiler"); - for (i = 0; i < ntups; i++) { + for (i = 0; i < ntups; i++) + { lanplcallfoid = PQgetvalue(res, i, i_lanplcallfoid); for (fidx = 0; fidx < numFuncs; fidx++) { @@ -2156,14 +2168,14 @@ dumpProcLangs(FILE *fout, FuncInfo *finfo, int numFuncs, lancompiler = checkForQuote(PQgetvalue(res, i, i_lancompiler)); if (drop_schema) - fprintf(fout, "DROP PROCEDURAL LANGUAGE '%s';\n", lanname); + fprintf(fout, "DROP PROCEDURAL LANGUAGE '%s';\n", lanname); fprintf(fout, "CREATE %sPROCEDURAL LANGUAGE '%s' " - "HANDLER %s LANCOMPILER '%s';\n", - (PQgetvalue(res, i, i_lanpltrusted)[0] == 't') ? "TRUSTED " : "", - lanname, - fmtId(finfo[fidx].proname, force_quotes), - lancompiler); + "HANDLER %s LANCOMPILER '%s';\n", + (PQgetvalue(res, i, i_lanpltrusted)[0] == 't') ? "TRUSTED " : "", + lanname, + fmtId(finfo[fidx].proname, force_quotes), + lancompiler); free(lanname); free(lancompiler); @@ -2202,8 +2214,8 @@ dumpOneFunc(FILE *fout, FuncInfo *finfo, int i, TypeInfo *tinfo, int numTypes) { char q[MAXQUERYLEN]; - int j; - char *func_def; + int j; + char *func_def; char func_lang[NAMEDATALEN + 1]; if (finfo[i].dumped) @@ -2230,9 +2242,9 @@ dumpOneFunc(FILE *fout, FuncInfo *finfo, int i, } else { - PGresult *res; - int nlangs; - int i_lanname; + PGresult *res; + int nlangs; + int i_lanname; char query[256]; res = PQexec(g_conn, "begin"); @@ -2274,21 +2286,21 @@ dumpOneFunc(FILE *fout, FuncInfo *finfo, int i, } if (drop_schema) - { - sprintf(q, "DROP FUNCTION %s (", fmtId(finfo[i].proname, force_quotes)); - for (j = 0; j < finfo[i].nargs; j++) - { - char *typname; - - typname = findTypeByOid(tinfo, numTypes, finfo[i].argtypes[j]); - sprintf(q, "%s%s%s", - q, - (j > 0) ? "," : "", - fmtId(typname, false)); - } - sprintf (q, "%s);\n", q); - fputs(q, fout); - } + { + sprintf(q, "DROP FUNCTION %s (", fmtId(finfo[i].proname, force_quotes)); + for (j = 0; j < finfo[i].nargs; j++) + { + char *typname; + + typname = findTypeByOid(tinfo, numTypes, finfo[i].argtypes[j]); + sprintf(q, "%s%s%s", + q, + (j > 0) ? "," : "", + fmtId(typname, false)); + } + sprintf(q, "%s);\n", q); + fputs(q, fout); + } sprintf(q, "CREATE FUNCTION %s (", fmtId(finfo[i].proname, force_quotes)); for (j = 0; j < finfo[i].nargs; j++) @@ -2304,7 +2316,7 @@ dumpOneFunc(FILE *fout, FuncInfo *finfo, int i, sprintf(q, "%s ) RETURNS %s%s AS '%s' LANGUAGE '%s';\n", q, (finfo[i].retset) ? " SETOF " : "", - fmtId(findTypeByOid(tinfo, numTypes, finfo[i].prorettype), false), + fmtId(findTypeByOid(tinfo, numTypes, finfo[i].prorettype), false), func_def, func_lang); fputs(q, fout); @@ -2320,7 +2332,7 @@ void dumpOprs(FILE *fout, OprInfo *oprinfo, int numOperators, TypeInfo *tinfo, int numTypes) { - int i; + int i; char q[MAXQUERYLEN]; char leftarg[MAXQUERYLEN]; char rightarg[MAXQUERYLEN]; @@ -2356,13 +2368,13 @@ dumpOprs(FILE *fout, OprInfo *oprinfo, int numOperators, strcmp(oprinfo[i].oprkind, "b") == 0) { sprintf(leftarg, ",\n\tLEFTARG = %s ", - fmtId(findTypeByOid(tinfo, numTypes, oprinfo[i].oprleft), false)); + fmtId(findTypeByOid(tinfo, numTypes, oprinfo[i].oprleft), false)); } if (strcmp(oprinfo[i].oprkind, "l") == 0 || strcmp(oprinfo[i].oprkind, "b") == 0) { sprintf(rightarg, ",\n\tRIGHTARG = %s ", - fmtId(findTypeByOid(tinfo, numTypes, oprinfo[i].oprright), false)); + fmtId(findTypeByOid(tinfo, numTypes, oprinfo[i].oprright), false)); } if (strcmp(oprinfo[i].oprcom, "0") == 0) commutator[0] = '\0'; @@ -2390,23 +2402,23 @@ dumpOprs(FILE *fout, OprInfo *oprinfo, int numOperators, sort1[0] = '\0'; else sprintf(sort1, ",\n\tSORT1 = %s ", - findOprByOid(oprinfo, numOperators, oprinfo[i].oprlsortop)); + findOprByOid(oprinfo, numOperators, oprinfo[i].oprlsortop)); if (strcmp(oprinfo[i].oprrsortop, "0") == 0) sort2[0] = '\0'; else sprintf(sort2, ",\n\tSORT2 = %s ", - findOprByOid(oprinfo, numOperators, oprinfo[i].oprrsortop)); + findOprByOid(oprinfo, numOperators, oprinfo[i].oprrsortop)); becomeUser(fout, oprinfo[i].usename); if (drop_schema) - { - sprintf(q, "DROP OPERATOR %s (%s, %s);\n", oprinfo[i].oprname, - fmtId(findTypeByOid(tinfo, numTypes, oprinfo[i].oprleft), false), - fmtId(findTypeByOid(tinfo, numTypes, oprinfo[i].oprright), false)); - fputs(q, fout); - } + { + sprintf(q, "DROP OPERATOR %s (%s, %s);\n", oprinfo[i].oprname, + fmtId(findTypeByOid(tinfo, numTypes, oprinfo[i].oprleft), false), + fmtId(findTypeByOid(tinfo, numTypes, oprinfo[i].oprright), false)); + fputs(q, fout); + } sprintf(q, "CREATE OPERATOR %s " @@ -2418,7 +2430,7 @@ dumpOprs(FILE *fout, OprInfo *oprinfo, int numOperators, commutator, negator, restrictor, - (strcmp(oprinfo[i].oprcanhash, "t") == 0) ? ",\n\tHASHES" : "", + (strcmp(oprinfo[i].oprcanhash, "t") == 0) ? ",\n\tHASHES" : "", join, sort1, sort2); @@ -2436,14 +2448,14 @@ void dumpAggs(FILE *fout, AggInfo *agginfo, int numAggs, TypeInfo *tinfo, int numTypes) { - int i; + int i; char q[MAXQUERYLEN]; char sfunc1[MAXQUERYLEN]; char sfunc2[MAXQUERYLEN]; char basetype[MAXQUERYLEN]; char finalfunc[MAXQUERYLEN]; char comma1[2], - comma2[2]; + comma2[2]; for (i = 0; i < numAggs; i++) { @@ -2453,7 +2465,7 @@ dumpAggs(FILE *fout, AggInfo *agginfo, int numAggs, sprintf(basetype, "BASETYPE = %s, ", - fmtId(findTypeByOid(tinfo, numTypes, agginfo[i].aggbasetype), false)); + fmtId(findTypeByOid(tinfo, numTypes, agginfo[i].aggbasetype), false)); if (strcmp(agginfo[i].aggtransfn1, "-") == 0) sfunc1[0] = '\0'; @@ -2505,11 +2517,11 @@ dumpAggs(FILE *fout, AggInfo *agginfo, int numAggs, becomeUser(fout, agginfo[i].usename); if (drop_schema) - { - sprintf(q, "DROP AGGREGATE %s %s;\n", agginfo[i].aggname, - fmtId(findTypeByOid(tinfo, numTypes, agginfo[i].aggbasetype), false)); - fputs(q, fout); - } + { + sprintf(q, "DROP AGGREGATE %s %s;\n", agginfo[i].aggname, + fmtId(findTypeByOid(tinfo, numTypes, agginfo[i].aggbasetype), false)); + fputs(q, fout); + } sprintf(q, "CREATE AGGREGATE %s ( %s %s%s %s%s %s );\n", agginfo[i].aggname, @@ -2534,7 +2546,7 @@ dumpAggs(FILE *fout, AggInfo *agginfo, int numAggs, * Caller must make aclbuf big enough for all possible keywords. */ static void -AddAcl (char *aclbuf, const char *keyword) +AddAcl(char *aclbuf, const char *keyword) { if (*aclbuf) strcat(aclbuf, ","); @@ -2582,15 +2594,16 @@ dumpACL(FILE *fout, TableInfo tbinfo) { const char *acls = tbinfo.relacl; char *aclbuf, - *tok, - *eqpos, - *priv; + *tok, + *eqpos, + *priv; if (strlen(acls) == 0) return; /* table has default permissions */ - /* Revoke Default permissions for PUBLIC. - * Is this actually necessary, or is it just a waste of time? + /* + * Revoke Default permissions for PUBLIC. Is this actually necessary, + * or is it just a waste of time? */ fprintf(fout, "REVOKE ALL on %s from PUBLIC;\n", @@ -2602,8 +2615,10 @@ dumpACL(FILE *fout, TableInfo tbinfo) /* Scan comma-separated ACL items */ for (tok = strtok(aclbuf, ","); tok != NULL; tok = strtok(NULL, ",")) { - /* Token may start with '{' and/or '"'. Actually only the start of - * the string should have '{', but we don't verify that. + + /* + * Token may start with '{' and/or '"'. Actually only the start + * of the string should have '{', but we don't verify that. */ if (*tok == '{') tok++; @@ -2612,21 +2627,26 @@ dumpACL(FILE *fout, TableInfo tbinfo) /* User name is string up to = in tok */ eqpos = strchr(tok, '='); - if (! eqpos) + if (!eqpos) { fprintf(stderr, "Could not parse ACL list for '%s'...Exiting!\n", tbinfo.relname); exit_nicely(g_conn); } - /* Parse the privileges (right-hand side). Skip if there are none. */ + /* + * Parse the privileges (right-hand side). Skip if there are + * none. + */ priv = GetPrivileges(eqpos + 1); if (*priv) { fprintf(fout, "GRANT %s on %s to ", priv, fmtId(tbinfo.relname, force_quotes)); - /* Note: fmtId() can only be called once per printf, so don't + + /* + * Note: fmtId() can only be called once per printf, so don't * try to merge printing of username into the above printf. */ if (eqpos == tok) @@ -2661,30 +2681,32 @@ dumpTables(FILE *fout, TableInfo *tblinfo, int numTables, int i, j, k; - char q[MAXQUERYLEN]; - char *serialSeq = NULL; /* implicit sequence name created by SERIAL datatype */ - const char *serialSeqSuffix = "_id_seq"; /* suffix for implicit SERIAL sequences */ - char **parentRels; /* list of names of parent relations */ + char q[MAXQUERYLEN]; + char *serialSeq = NULL; /* implicit sequence name created + * by SERIAL datatype */ + const char *serialSeqSuffix = "_id_seq"; /* suffix for implicit + * SERIAL sequences */ + char **parentRels; /* list of names of parent relations */ int numParents; - int actual_atts; /* number of attrs in this CREATE statment */ - int32 tmp_typmod; + int actual_atts; /* number of attrs in this CREATE statment */ + int32 tmp_typmod; int precision; int scale; /* First - dump SEQUENCEs */ if (tablename) - { - serialSeq = malloc (strlen (tablename) + strlen (serialSeqSuffix) + 1); - strcpy (serialSeq, tablename); - strcat (serialSeq, serialSeqSuffix); - } + { + serialSeq = malloc(strlen(tablename) + strlen(serialSeqSuffix) + 1); + strcpy(serialSeq, tablename); + strcat(serialSeq, serialSeqSuffix); + } for (i = 0; i < numTables; i++) { if (!(tblinfo[i].sequence)) continue; if (!tablename || (!strcmp(tblinfo[i].relname, tablename)) - || (serialSeq && !strcmp(tblinfo[i].relname,serialSeq))) + || (serialSeq && !strcmp(tblinfo[i].relname, serialSeq))) { becomeUser(fout, tblinfo[i].usename); dumpSequence(fout, tblinfo[i]); @@ -2693,7 +2715,7 @@ dumpTables(FILE *fout, TableInfo *tblinfo, int numTables, } } if (tablename) - free (serialSeq); + free(serialSeq); for (i = 0; i < numTables; i++) { @@ -2704,10 +2726,10 @@ dumpTables(FILE *fout, TableInfo *tblinfo, int numTables, { /* Skip VIEW relations */ + /* - if (isViewRule(tblinfo[i].relname)) - continue; - */ + * if (isViewRule(tblinfo[i].relname)) continue; + */ parentRels = tblinfo[i].parentRels; numParents = tblinfo[i].numParents; @@ -2715,10 +2737,10 @@ dumpTables(FILE *fout, TableInfo *tblinfo, int numTables, becomeUser(fout, tblinfo[i].usename); if (drop_schema) - { - sprintf(q, "DROP TABLE %s;\n", fmtId(tblinfo[i].relname, force_quotes)); - fputs(q, fout); - } + { + sprintf(q, "DROP TABLE %s;\n", fmtId(tblinfo[i].relname, force_quotes)); + fputs(q, fout); + } sprintf(q, "CREATE TABLE %s (\n\t", fmtId(tblinfo[i].relname, force_quotes)); actual_atts = 0; @@ -2734,7 +2756,8 @@ dumpTables(FILE *fout, TableInfo *tblinfo, int numTables, /* Show lengths on bpchar and varchar */ if (!strcmp(tblinfo[i].typnames[j], "bpchar")) { - int len = (tblinfo[i].atttypmod[j] - VARHDRSZ); + int len = (tblinfo[i].atttypmod[j] - VARHDRSZ); + sprintf(q + strlen(q), "character"); if (len > 1) sprintf(q + strlen(q), "(%d)", @@ -2756,14 +2779,16 @@ dumpTables(FILE *fout, TableInfo *tblinfo, int numTables, { tmp_typmod = tblinfo[i].atttypmod[j] - VARHDRSZ; precision = (tmp_typmod >> 16) & 0xffff; - scale = tmp_typmod & 0xffff; + scale = tmp_typmod & 0xffff; sprintf(q + strlen(q), "(%d,%d)", - precision, scale); + precision, scale); } } - /* char is an internal single-byte data type; - * Let's make sure we force it through with quotes. - * - thomas 1998-12-13 + + /* + * char is an internal single-byte data type; Let's + * make sure we force it through with quotes. - thomas + * 1998-12-13 */ else if (!strcmp(tblinfo[i].typnames[j], "char")) { @@ -2827,15 +2852,15 @@ dumpIndices(FILE *fout, IndInfo *indinfo, int numIndices, int i, k; int tableInd; - char attlist[1000]; - char *classname[INDEX_MAX_KEYS]; - char *funcname; /* the name of the function to comput the - * index key from */ + char attlist[1000]; + char *classname[INDEX_MAX_KEYS]; + char *funcname; /* the name of the function to comput the + * index key from */ int indkey, indclass; int nclass; - char q[MAXQUERYLEN], + char q[MAXQUERYLEN], id1[MAXQUERYLEN], id2[MAXQUERYLEN]; PGresult *res; @@ -2920,7 +2945,7 @@ dumpIndices(FILE *fout, IndInfo *indinfo, int numIndices, attname = tblinfo[tableInd].attnames[indkey]; if (funcname) sprintf(attlist + strlen(attlist), "%s%s", - (k == 0) ? "" : ", ", fmtId(attname, force_quotes)); + (k == 0) ? "" : ", ", fmtId(attname, force_quotes)); else { if (k >= nclass) @@ -2940,9 +2965,11 @@ dumpIndices(FILE *fout, IndInfo *indinfo, int numIndices, if (!tablename || (!strcmp(indinfo[i].indrelname, tablename))) { - /* We make the index belong to the owner of its table, - * which is not necessarily right but should answer 99% of the - * time. Would have to add owner name to IndInfo to do it right. + + /* + * We make the index belong to the owner of its table, which + * is not necessarily right but should answer 99% of the time. + * Would have to add owner name to IndInfo to do it right. */ becomeUser(fout, tblinfo[tableInd].usename); @@ -2950,10 +2977,10 @@ dumpIndices(FILE *fout, IndInfo *indinfo, int numIndices, strcpy(id2, fmtId(indinfo[i].indrelname, force_quotes)); if (drop_schema) - { - sprintf(q, "DROP INDEX %s;\n", id1); - fputs(q, fout); - } + { + sprintf(q, "DROP INDEX %s;\n", id1); + fputs(q, fout); + } fprintf(fout, "CREATE %s INDEX %s on %s using %s (", (strcmp(indinfo[i].indisunique, "t") == 0) ? "UNIQUE" : "", @@ -2976,7 +3003,7 @@ dumpIndices(FILE *fout, IndInfo *indinfo, int numIndices, } /* - * dumpTuples + * dumpTuples * prints out the tuples in ASCII representation. The output is a valid * input to COPY FROM stdin. * @@ -2995,7 +3022,7 @@ dumpTuples(PGresult *res, FILE *fout, int *attrmap) k; int m, n; - char **outVals = NULL; /* values to copy out */ + char **outVals = NULL; /* values to copy out */ n = PQntuples(res); m = PQnfields(res); @@ -3048,7 +3075,7 @@ dumpTuples(PGresult *res, FILE *fout, int *attrmap) static void setMaxOid(FILE *fout) { - PGresult *res; + PGresult *res; Oid max_oid; res = PQexec(g_conn, "CREATE TABLE pgdump_oid (dummy int4)"); @@ -3101,7 +3128,7 @@ setMaxOid(FILE *fout) static int findLastBuiltinOid(void) { - PGresult *res; + PGresult *res; int ntups; int last_oid; @@ -3133,9 +3160,9 @@ findLastBuiltinOid(void) static char * checkForQuote(const char *s) { - char *r; + char *r; char c; - char *result; + char *result; int j = 0; @@ -3164,16 +3191,16 @@ checkForQuote(const char *s) static void dumpSequence(FILE *fout, TableInfo tbinfo) { - PGresult *res; - int4 last, + PGresult *res; + int4 last, incby, maxv, minv, cache; - char cycled, + char cycled, called, - *t; - char query[MAXQUERYLEN]; + *t; + char query[MAXQUERYLEN]; sprintf(query, "SELECT sequence_name, last_value, increment_by, max_value, " @@ -3216,15 +3243,15 @@ dumpSequence(FILE *fout, TableInfo tbinfo) PQclear(res); if (drop_schema) - { - sprintf(query, "DROP SEQUENCE %s;\n", fmtId(tbinfo.relname, force_quotes)); - fputs(query, fout); - } + { + sprintf(query, "DROP SEQUENCE %s;\n", fmtId(tbinfo.relname, force_quotes)); + fputs(query, fout); + } sprintf(query, "CREATE SEQUENCE %s start %d increment %d maxvalue %d " "minvalue %d cache %d %s;\n", - fmtId(tbinfo.relname, force_quotes), last, incby, maxv, minv, cache, + fmtId(tbinfo.relname, force_quotes), last, incby, maxv, minv, cache, (cycled == 't') ? "cycle" : ""); fputs(query, fout); @@ -3264,15 +3291,15 @@ dumpTriggers(FILE *fout, const char *tablename, static void dumpRules(FILE *fout, const char *tablename, - TableInfo *tblinfo, int numTables) + TableInfo *tblinfo, int numTables) { - PGresult *res; - int nrules; - int i, - t; + PGresult *res; + int nrules; + int i, + t; char query[MAXQUERYLEN]; - int i_definition; + int i_definition; if (g_verbose) fprintf(stderr, "%s dumping out rules %s\n", @@ -3319,9 +3346,7 @@ dumpRules(FILE *fout, const char *tablename, * Dump them out */ for (i = 0; i < nrules; i++) - { fprintf(fout, "%s\n", PQgetvalue(res, i, i_definition)); - } PQclear(res); diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h index f88ec2203a..1d83387a14 100644 --- a/src/bin/pg_dump/pg_dump.h +++ b/src/bin/pg_dump/pg_dump.h @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_dump.h,v 1.37 1998/12/13 23:41:32 thomas Exp $ + * $Id: pg_dump.h,v 1.38 1999/05/25 16:13:09 momjian Exp $ * * Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2 * @@ -211,7 +211,7 @@ extern IndInfo *getIndices(int *numIndices); extern void dumpTypes(FILE *fout, FuncInfo *finfo, int numFuncs, TypeInfo *tinfo, int numTypes); extern void dumpProcLangs(FILE *fout, FuncInfo *finfo, int numFuncs, - TypeInfo *tinfo, int numTypes); + TypeInfo *tinfo, int numTypes); extern void dumpFuncs(FILE *fout, FuncInfo *finfo, int numFuncs, TypeInfo *tinfo, int numTypes); extern void dumpAggs(FILE *fout, AggInfo *agginfo, int numAggregates, diff --git a/src/bin/pgtclsh/pgtclAppInit.c b/src/bin/pgtclsh/pgtclAppInit.c index 57b4158941..1b8e3c1274 100644 --- a/src/bin/pgtclsh/pgtclAppInit.c +++ b/src/bin/pgtclsh/pgtclAppInit.c @@ -1,5 +1,5 @@ /* - * pgtclAppInit.c + * pgtclAppInit.c * * a skeletal Tcl_AppInit that provides pgtcl initialization * to create a tclsh that can talk to pglite backends @@ -30,7 +30,7 @@ int *tclDummyMathPtr = (int *) matherr; /* *---------------------------------------------------------------------- * - * main + * main * * This is the main program for the application. * @@ -56,7 +56,7 @@ main(int argc, char **argv) /* *---------------------------------------------------------------------- * - * Tcl_AppInit + * Tcl_AppInit * * This procedure performs application-specific initialization. * Most applications, especially those that incorporate additional diff --git a/src/bin/pgtclsh/pgtkAppInit.c b/src/bin/pgtclsh/pgtkAppInit.c index 46af3ffaa9..27e177b77f 100644 --- a/src/bin/pgtclsh/pgtkAppInit.c +++ b/src/bin/pgtclsh/pgtkAppInit.c @@ -1,5 +1,5 @@ /* - * pgtkAppInit.c + * pgtkAppInit.c * * a skeletal Tcl_AppInit that provides pgtcl initialization * to create a tclsh that can talk to pglite backends @@ -29,7 +29,7 @@ int *tclDummyMathPtr = (int *) matherr; /* *---------------------------------------------------------------------- * - * main + * main * * This is the main program for the application. * @@ -55,7 +55,7 @@ main(int argc, char **argv) /* *---------------------------------------------------------------------- * - * Tcl_AppInit + * Tcl_AppInit * * This procedure performs application-specific initialization. * Most applications, especially those that incorporate additional diff --git a/src/bin/psql/psql.c b/src/bin/psql/psql.c index 4b1b5b00b7..c80d2d9e8c 100644 --- a/src/bin/psql/psql.c +++ b/src/bin/psql/psql.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.178 1999/05/12 23:26:03 tgl Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.179 1999/05/25 16:13:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -89,7 +89,8 @@ char *__progname = "psql"; #ifdef MULTIBYTE /* flag to indicate if PGCLIENTENCODING has been set by a user */ -static char *has_client_encoding = 0; +static char *has_client_encoding = 0; + #endif /* This prompt string is assumed to have at least 3 characters by code in MainLoop(). @@ -133,7 +134,7 @@ typedef struct _psqlSettings bool notty; /* input or output is not a tty */ bool pipe; /* queryFout is from a popen() */ bool echoQuery; /* echo the query before sending it */ - bool echoAllQueries; /* echo all queries before sending it*/ + bool echoAllQueries; /* echo all queries before sending it */ bool quiet; /* run quietly, no messages, no promt */ bool singleStep; /* prompt before for each query */ bool singleLineMode; /* query terminated by newline */ @@ -149,8 +150,9 @@ typedef struct _psqlSettings * of passing them around through many function parameter lists seems * worse. */ -static FILE * cur_cmd_source = NULL; /* current source of command input */ -static bool cur_cmd_interactive = false; /* is it an interactive source? */ +static FILE *cur_cmd_source = NULL; /* current source of command input */ +static bool cur_cmd_interactive = false; /* is it an interactive + * source? */ #ifdef TIOCGWINSZ @@ -176,7 +178,7 @@ static int tableList(PsqlSettings *pset, bool deep_tablelist, static int tableDesc(PsqlSettings *pset, char *table, FILE *fout); static int objectDescription(PsqlSettings *pset, char *object); static int rightsList(PsqlSettings *pset); -static void emitNtimes (FILE *fout, const char *str, int N); +static void emitNtimes(FILE *fout, const char *str, int N); static void prompt_for_password(char *username, char *password); static char *gets_noreadline(char *prompt, FILE *source); @@ -184,7 +186,7 @@ static char *gets_readline(char *prompt, FILE *source); static char *gets_fromFile(char *prompt, FILE *source); static int listAllDbs(PsqlSettings *pset); static bool SendQuery(PsqlSettings *pset, const char *query, - FILE *copy_in_stream, FILE *copy_out_stream); + FILE *copy_in_stream, FILE *copy_out_stream); static int HandleSlashCmds(PsqlSettings *pset, char *line, char *query); static int MainLoop(PsqlSettings *pset, char *query, FILE *source); static FILE *setFout(PsqlSettings *pset, char *fname); @@ -314,12 +316,12 @@ PSQLexec(PsqlSettings *pset, char *query) { PGresult *res; - if (pset->echoAllQueries) - { - fprintf(stderr, "QUERY: %s\n", query); - fprintf(stderr, "\n"); - fflush(stderr); - } + if (pset->echoAllQueries) + { + fprintf(stderr, "QUERY: %s\n", query); + fprintf(stderr, "\n"); + fflush(stderr); + } res = PQexec(pset->db, query); if (!res) @@ -489,8 +491,11 @@ tableList(PsqlSettings *pset, bool deep_tablelist, char info_type, perror("malloc"); /* load table table */ - /* Put double quotes around the table name to allow for mixed-case - * and whitespaces in the table name. - BGA 1998-11-14 + + /* + * Put double quotes around the table name to allow for + * mixed-case and whitespaces in the table name. - BGA + * 1998-11-14 */ for (i = 0; i < nColumns; i++) { @@ -532,7 +537,7 @@ tableList(PsqlSettings *pset, bool deep_tablelist, char info_type, fprintf(fout, "\n"); } fprintf(fout, " +------------------+----------------------------------+----------+\n"); - fprintf(fout, "\n") ; + fprintf(fout, "\n"); PQclear(res); } if (usePipe) @@ -623,10 +628,11 @@ rightsList(PsqlSettings *pset) /* choose column widths */ maxCol1Len = strlen("Relation"); - maxCol2Len = strlen("Grant/Revoke Permissions"); + maxCol2Len = strlen("Grant/Revoke Permissions"); for (i = 0; i < PQntuples(res); i++) { - int l = strlen(PQgetvalue(res, i, 0)); + int l = strlen(PQgetvalue(res, i, 0)); + if (l > maxCol1Len) maxCol1Len = l; l = strlen(PQgetvalue(res, i, 1)); @@ -638,17 +644,17 @@ rightsList(PsqlSettings *pset) fprintf(fout, "Database = %s\n", PQdb(pset->db)); fprintf(fout, " +"); - emitNtimes(fout, "-", maxCol1Len+2); + emitNtimes(fout, "-", maxCol1Len + 2); fprintf(fout, "+"); - emitNtimes(fout, "-", maxCol2Len+2); + emitNtimes(fout, "-", maxCol2Len + 2); fprintf(fout, "+\n"); fprintf(fout, " | %-*s | %-*s |\n", maxCol1Len, "Relation", maxCol2Len, "Grant/Revoke Permissions"); fprintf(fout, " +"); - emitNtimes(fout, "-", maxCol1Len+2); + emitNtimes(fout, "-", maxCol1Len + 2); fprintf(fout, "+"); - emitNtimes(fout, "-", maxCol2Len+2); + emitNtimes(fout, "-", maxCol2Len + 2); fprintf(fout, "+\n"); /* next, print out the instances */ @@ -660,9 +666,9 @@ rightsList(PsqlSettings *pset) } fprintf(fout, " +"); - emitNtimes(fout, "-", maxCol1Len+2); + emitNtimes(fout, "-", maxCol1Len + 2); fprintf(fout, "+"); - emitNtimes(fout, "-", maxCol2Len+2); + emitNtimes(fout, "-", maxCol2Len + 2); fprintf(fout, "+\n"); PQclear(res); @@ -681,12 +687,13 @@ rightsList(PsqlSettings *pset) } } -static void emitNtimes (FILE *fout, const char *str, int N) +static void +emitNtimes(FILE *fout, const char *str, int N) { - int i; - for (i = 0; i < N; i++) { + int i; + + for (i = 0; i < N; i++) fputs(str, fout); - } } /* @@ -783,8 +790,8 @@ tableDesc(PsqlSettings *pset, char *table, FILE *fout) } /* - * Extract the veiw name and veiw definition from pg_views. - * -Ryan 2/14/99 + * Extract the veiw name and veiw definition from pg_views. -Ryan + * 2/14/99 */ descbuf[0] = '\0'; @@ -793,22 +800,23 @@ tableDesc(PsqlSettings *pset, char *table, FILE *fout) strcat(descbuf, "WHERE viewname like '"); strcat(descbuf, table); strcat(descbuf, "' "); - if(!(res2 = PSQLexec(pset, descbuf))) - return -1; + if (!(res2 = PSQLexec(pset, descbuf))) + return -1; /* * Display the information */ - if(PQntuples(res2)) { - /* - * display the query. -o * -Ryan 2/14/99 - */ - fprintf(fout, "View = %s\n", table); - fprintf(fout, "Query = %s\n", PQgetvalue(res2, 0, 1)); - } else { - fprintf(fout, "Table = %s\n", table); + if (PQntuples(res2)) + { + + /* + * display the query. o * -Ryan 2/14/99 + */ + fprintf(fout, "View = %s\n", table); + fprintf(fout, "Query = %s\n", PQgetvalue(res2, 0, 1)); } + else + fprintf(fout, "Table = %s\n", table); PQclear(res2); fprintf(fout, "+----------------------------------+----------------------------------+-------+\n"); @@ -1130,11 +1138,11 @@ gets_fromFile(char *prompt, FILE *source) return NULL; } - line[MAX_QUERY_BUFFER - 1] = '\0'; /* this is unnecessary, I think */ - if (strlen(line) == MAX_QUERY_BUFFER-1) + line[MAX_QUERY_BUFFER - 1] = '\0'; /* this is unnecessary, I think */ + if (strlen(line) == MAX_QUERY_BUFFER - 1) { fprintf(stderr, "line read exceeds maximum length. Truncating at %d\n", - MAX_QUERY_BUFFER-1); + MAX_QUERY_BUFFER - 1); } return line; } @@ -1240,7 +1248,7 @@ SendQuery(PsqlSettings *pset, const char *query, success = handleCopyIn(pset->db, false, copy_in_stream); else success = handleCopyIn(pset->db, - cur_cmd_interactive && !pset->quiet, + cur_cmd_interactive && !pset->quiet, cur_cmd_source); break; case PGRES_NONFATAL_ERROR: @@ -1508,8 +1516,8 @@ do_copy(const char *args, PsqlSettings *pset) bool success;/* The query succeeded at the backend */ success = SendQuery(pset, query, - from ? copystream : (FILE*) NULL, - !from ? copystream : (FILE*) NULL); + from ? copystream : (FILE *) NULL, + !from ? copystream : (FILE *) NULL); fclose(copystream); if (!pset->quiet) { @@ -1553,14 +1561,19 @@ do_connect(const char *new_dbname, pwparam = PQpass(olddb); #ifdef MULTIBYTE - /* PGCLIENTENCODING may be set by the previous connection. - if a user does not explicitly set PGCLIENTENCODING, - we should discard PGCLIENTENCODING so that - libpq could get the backend encoding as the default - PGCLIENTENCODING value. -- 1998/12/12 Tatsuo Ishii */ - - if (!has_client_encoding) { - static const char ev[] = "PGCLIENTENCODING="; + + /* + * PGCLIENTENCODING may be set by the previous connection. if a + * user does not explicitly set PGCLIENTENCODING, we should + * discard PGCLIENTENCODING so that libpq could get the backend + * encoding as the default PGCLIENTENCODING value. -- 1998/12/12 + * Tatsuo Ishii + */ + + if (!has_client_encoding) + { + static const char ev[] = "PGCLIENTENCODING="; + putenv(ev); } #endif @@ -2451,6 +2464,7 @@ MainLoop(PsqlSettings *pset, char *query, FILE *source) bool was_bslash; /* backslash */ int paren_level; char *query_start; + /* Stack the prior command source */ FILE *prev_cmd_source = cur_cmd_source; bool prev_cmd_interactive = cur_cmd_interactive; @@ -2583,13 +2597,15 @@ MainLoop(PsqlSettings *pset, char *query, FILE *source) else { int i; + /* - * The current character is at line[i], the prior character - * at line[i - prevlen], the next character at line[i + thislen]. + * The current character is at line[i], the prior character at + * line[i - prevlen], the next character at line[i + thislen]. */ #ifdef MULTIBYTE int prevlen = 0; int thislen = (len > 0) ? PQmblen(line) : 0; + #define ADVANCE_I (prevlen = thislen, i += thislen, thislen = PQmblen(line+i)) #else #define prevlen 1 @@ -2713,18 +2729,19 @@ MainLoop(PsqlSettings *pset, char *query, FILE *source) /* handle \p\g and other backslash combinations */ while (query_start[0] != '\0') { - char hold_char; + char hold_char; #ifndef WIN32 /* I believe \w \dos\system\x would cause a problem */ /* do we have '\p\g' or '\p \g' ? */ if (strlen(query_start) > 2 && - query_start[2 + strspn(query_start + 2, " \t")] == '\\') + query_start[2 + strspn(query_start + 2, " \t")] == '\\') { hold_char = query_start[2 + strspn(query_start + 2, " \t")]; query_start[2 + strspn(query_start + 2, " \t")] = '\0'; } - else /* spread over #endif */ + else +/* spread over #endif */ #endif hold_char = '\0'; @@ -2815,10 +2832,11 @@ main(int argc, char **argv) int c; char *home = NULL; /* Used to store $HOME */ - char *version = NULL; /* PostgreSQL version */ + char *version = NULL; /* PostgreSQL version */ - /* initialize cur_cmd_source in case we do not use MainLoop ... - * some systems fail if we try to use a static initializer for this :-( + /* + * initialize cur_cmd_source in case we do not use MainLoop ... some + * systems fail if we try to use a static initializer for this :-( */ cur_cmd_source = stdin; cur_cmd_interactive = false; @@ -2969,10 +2987,10 @@ main(int argc, char **argv) printf(" Please read the file COPYRIGHT for copyright terms " "of POSTGRESQL\n"); - if ( (version = selectVersion(&settings)) != NULL ) - printf("[%s]\n", version); + if ((version = selectVersion(&settings)) != NULL) + printf("[%s]\n", version); - printf("\n"); + printf("\n"); printf(" type \\? for help on slash commands\n"); printf(" type \\q to quit\n"); printf(" type \\g or terminate with semicolon to execute query\n"); @@ -3082,7 +3100,7 @@ handleCopyOut(PGconn *conn, FILE *copystream) } } fflush(copystream); - return ! PQendcopy(conn); + return !PQendcopy(conn); } @@ -3138,7 +3156,7 @@ handleCopyIn(PGconn *conn, const bool mustprompt, FILE *copystream) } PQputline(conn, "\n"); } - return ! PQendcopy(conn); + return !PQendcopy(conn); } @@ -3246,23 +3264,24 @@ static char * selectVersion(PsqlSettings *pset) { #define PGVERSIONBUFSZ 128 - static char version[PGVERSIONBUFSZ+1]; + static char version[PGVERSIONBUFSZ + 1]; PGresult *res; char *query = "select version();"; - if (!(res = PQexec(pset->db, query))) return(NULL); + if (!(res = PQexec(pset->db, query))) + return (NULL); if (PQresultStatus(res) == PGRES_COMMAND_OK || - PQresultStatus(res) == PGRES_TUPLES_OK ) + PQresultStatus(res) == PGRES_TUPLES_OK) { - strncpy(version, PQgetvalue(res,0,0), PGVERSIONBUFSZ); + strncpy(version, PQgetvalue(res, 0, 0), PGVERSIONBUFSZ); version[PGVERSIONBUFSZ] = '\0'; PQclear(res); - return(version); - } - else + return (version); + } + else { PQclear(res); - return(NULL); + return (NULL); } } diff --git a/src/include/access/attnum.h b/src/include/access/attnum.h index 25e20f4909..ef09c3706d 100644 --- a/src/include/access/attnum.h +++ b/src/include/access/attnum.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: attnum.h,v 1.9 1999/02/13 23:20:49 momjian Exp $ + * $Id: attnum.h,v 1.10 1999/05/25 16:13:26 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -26,21 +26,21 @@ typedef int16 AttrNumber; * ---------------- */ /* - * AttributeNumberIsValid + * AttributeNumberIsValid * True iff the attribute number is valid. */ #define AttributeNumberIsValid(attributeNumber) \ ((bool) ((attributeNumber) != InvalidAttrNumber)) /* - * AttrNumberIsForUserDefinedAttr + * AttrNumberIsForUserDefinedAttr * True iff the attribute number corresponds to an user defined attribute. */ #define AttrNumberIsForUserDefinedAttr(attributeNumber) \ ((bool) ((attributeNumber) > 0)) /* - * AttrNumberGetAttrOffset + * AttrNumberGetAttrOffset * Returns the attribute offset for an attribute number. * * Note: @@ -53,7 +53,7 @@ typedef int16 AttrNumber; ) /* - * AttributeOffsetGetAttributeNumber + * AttributeOffsetGetAttributeNumber * Returns the attribute number for an attribute offset. */ #define AttrOffsetGetAttrNumber(attributeOffset) \ diff --git a/src/include/access/hash.h b/src/include/access/hash.h index f3227f5944..6250ead85a 100644 --- a/src/include/access/hash.h +++ b/src/include/access/hash.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: hash.h,v 1.22 1999/04/15 02:23:37 thomas Exp $ + * $Id: hash.h,v 1.23 1999/05/25 16:13:27 momjian Exp $ * * NOTES * modeled after Margo Seltzer's hash implementation for unix. @@ -265,7 +265,7 @@ extern void hashdelete(Relation rel, ItemPointer tid); /* hashfunc.c */ extern uint32 hashint2(int16 key); extern uint32 hashint4(uint32 key); -extern uint32 hashint8(int64 *key); +extern uint32 hashint8(int64 * key); extern uint32 hashfloat4(float32 keyp); extern uint32 hashfloat8(float64 keyp); extern uint32 hashoid(Oid key); diff --git a/src/include/access/heapam.h b/src/include/access/heapam.h index c205cab52d..9681bc759d 100644 --- a/src/include/access/heapam.h +++ b/src/include/access/heapam.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: heapam.h,v 1.41 1999/02/13 23:20:52 momjian Exp $ + * $Id: heapam.h,v 1.42 1999/05/25 16:13:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -149,7 +149,7 @@ fastgetattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, (attnum) == 1) ? ( (Datum) fetchatt(&((tupleDesc)->attrs[(attnum) - 1]), - (char *) (tup)->t_data + (tup)->t_data->t_hoff + + (char *) (tup)->t_data + (tup)->t_data->t_hoff + ( ((attnum) != 1) ? (tupleDesc)->attrs[(attnum) - 1]->attcacheoff @@ -256,8 +256,8 @@ extern HeapTuple heap_getnext(HeapScanDesc scandesc, int backw); extern void heap_fetch(Relation relation, Snapshot snapshot, HeapTuple tup, Buffer *userbuf); extern Oid heap_insert(Relation relation, HeapTuple tup); extern int heap_delete(Relation relation, ItemPointer tid, ItemPointer ctid); -extern int heap_replace(Relation relation, ItemPointer otid, HeapTuple tup, - ItemPointer ctid); +extern int heap_replace(Relation relation, ItemPointer otid, HeapTuple tup, + ItemPointer ctid); extern int heap_mark4update(Relation relation, HeapTuple tup, Buffer *userbuf); extern void heap_markpos(HeapScanDesc scan); extern void heap_restrpos(HeapScanDesc scan); diff --git a/src/include/access/hio.h b/src/include/access/hio.h index 0d84d50e26..bf5164b5e8 100644 --- a/src/include/access/hio.h +++ b/src/include/access/hio.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: hio.h,v 1.10 1999/02/13 23:20:53 momjian Exp $ + * $Id: hio.h,v 1.11 1999/05/25 16:13:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -17,8 +17,8 @@ #include -extern void RelationPutHeapTuple(Relation relation, Buffer buffer, - HeapTuple tuple); +extern void RelationPutHeapTuple(Relation relation, Buffer buffer, + HeapTuple tuple); extern void RelationPutHeapTupleAtEnd(Relation relation, HeapTuple tuple); #endif /* HIO_H */ diff --git a/src/include/access/htup.h b/src/include/access/htup.h index 5e748f4fcf..4586f6118a 100644 --- a/src/include/access/htup.h +++ b/src/include/access/htup.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: htup.h,v 1.14 1999/03/28 20:32:30 vadim Exp $ + * $Id: htup.h,v 1.15 1999/05/25 16:13:31 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -48,7 +48,7 @@ typedef struct HeapTupleHeaderData /* bit map of domains */ /* MORE DATA FOLLOWS AT END OF STRUCT */ -} HeapTupleHeaderData; +} HeapTupleHeaderData; typedef HeapTupleHeaderData *HeapTupleHeader; @@ -68,22 +68,22 @@ extern long heap_sysoffset[]; * * 1. t_len moved off on-disk tuple data - ItemIdData is used to get len; * 2. t_ctid above is not self tuple TID now - it may point to - * updated version of tuple (required by MVCC); - * 3. someday someone let tuple to cross block boundaries - - * he have to add something below... + * updated version of tuple (required by MVCC); + * 3. someday someone let tuple to cross block boundaries - + * he have to add something below... */ typedef struct HeapTupleData { - uint32 t_len; /* length of *t_data */ - ItemPointerData t_self; /* SelfItemPointer */ - HeapTupleHeader t_data; /* */ + uint32 t_len; /* length of *t_data */ + ItemPointerData t_self; /* SelfItemPointer */ + HeapTupleHeader t_data; /* */ } HeapTupleData; - + typedef HeapTupleData *HeapTuple; -#define HEAPTUPLESIZE DOUBLEALIGN(sizeof(HeapTupleData)) - - +#define HEAPTUPLESIZE DOUBLEALIGN(sizeof(HeapTupleData)) + + /* ---------------- * support macros * ---------------- @@ -118,8 +118,10 @@ typedef HeapTupleData *HeapTuple; #define HEAP_XMAX_INVALID 0x0800 /* t_xmax invalid/aborted */ #define HEAP_MARKED_FOR_UPDATE 0x1000 /* marked for UPDATE */ #define HEAP_UPDATED 0x2000 /* this is UPDATEd version of row */ -#define HEAP_MOVED_OFF 0x4000 /* removed or moved to another place by vacuum */ -#define HEAP_MOVED_IN 0x8000 /* moved from another place by vacuum */ +#define HEAP_MOVED_OFF 0x4000 /* removed or moved to another + * place by vacuum */ +#define HEAP_MOVED_IN 0x8000 /* moved from another place by + * vacuum */ #define HEAP_XACT_MASK 0xFF00 /* */ diff --git a/src/include/access/istrat.h b/src/include/access/istrat.h index 8d3dd069ea..6f45129158 100644 --- a/src/include/access/istrat.h +++ b/src/include/access/istrat.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: istrat.h,v 1.12 1999/02/13 23:20:55 momjian Exp $ + * $Id: istrat.h,v 1.13 1999/05/25 16:13:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -17,14 +17,14 @@ #include /* - * StrategyNumberIsValid + * StrategyNumberIsValid * True iff the strategy number is valid. */ #define StrategyNumberIsValid(strategyNumber) \ ((bool) ((strategyNumber) != InvalidStrategy)) /* - * StrategyNumberIsInBounds + * StrategyNumberIsInBounds * True iff strategy number is within given bounds. * * Note: @@ -36,13 +36,13 @@ (strategyNumber) <= (maxStrategyNumber))) /* - * StrategyMapIsValid + * StrategyMapIsValid * True iff the index strategy mapping is valid. */ #define StrategyMapIsValid(map) PointerIsValid(map) /* - * IndexStrategyIsValid + * IndexStrategyIsValid * True iff the index strategy is valid. */ #define IndexStrategyIsValid(s) PointerIsValid(s) diff --git a/src/include/access/nbtree.h b/src/include/access/nbtree.h index b1c54366d8..a25e0c2c43 100644 --- a/src/include/access/nbtree.h +++ b/src/include/access/nbtree.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: nbtree.h,v 1.24 1999/03/28 20:32:34 vadim Exp $ + * $Id: nbtree.h,v 1.25 1999/05/25 16:13:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -42,7 +42,7 @@ typedef struct BTPageOpaqueData { BlockNumber btpo_prev; BlockNumber btpo_next; - BlockNumber btpo_parent; + BlockNumber btpo_parent; uint16 btpo_flags; #define BTP_LEAF (1 << 0) diff --git a/src/include/access/printtup.h b/src/include/access/printtup.h index f5de892d93..6b5a538b5e 100644 --- a/src/include/access/printtup.h +++ b/src/include/access/printtup.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: printtup.h,v 1.8 1999/02/13 23:20:56 momjian Exp $ + * $Id: printtup.h,v 1.9 1999/05/25 16:13:33 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -15,17 +15,17 @@ #include -extern DestReceiver* printtup_create_DR(void); +extern DestReceiver *printtup_create_DR(void); extern void showatts(char *name, TupleDesc attinfo); extern void debugtup(HeapTuple tuple, TupleDesc typeinfo, - DestReceiver* self); + DestReceiver * self); extern void printtup_internal(HeapTuple tuple, TupleDesc typeinfo, - DestReceiver* self); + DestReceiver * self); /* XXX this one is really in executor/spi.c */ extern void spi_printtup(HeapTuple tuple, TupleDesc tupdesc, - DestReceiver* self); + DestReceiver * self); -extern int getTypeOutAndElem(Oid type, Oid* typOutput, Oid* typElem); +extern int getTypeOutAndElem(Oid type, Oid *typOutput, Oid *typElem); #endif /* PRINTTUP_H */ diff --git a/src/include/access/relscan.h b/src/include/access/relscan.h index 5b33e7ca12..4481c575e6 100644 --- a/src/include/access/relscan.h +++ b/src/include/access/relscan.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: relscan.h,v 1.14 1999/02/13 23:20:56 momjian Exp $ + * $Id: relscan.h,v 1.15 1999/05/25 16:13:33 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -22,40 +22,40 @@ typedef ItemPointerData MarkData; typedef struct HeapScanDescData { - Relation rs_rd; /* pointer to relation descriptor */ - HeapTupleData rs_ptup; /* previous tuple in scan */ - HeapTupleData rs_ctup; /* current tuple in scan */ - HeapTupleData rs_ntup; /* next tuple in scan */ - Buffer rs_pbuf; /* previous buffer in scan */ - Buffer rs_cbuf; /* current buffer in scan */ - Buffer rs_nbuf; /* next buffer in scan */ - ItemPointerData rs_mptid; /* marked previous tid */ - ItemPointerData rs_mctid; /* marked current tid */ - ItemPointerData rs_mntid; /* marked next tid */ - ItemPointerData rs_mcd; /* marked current delta XXX ??? */ - Snapshot rs_snapshot; /* snapshot to see */ - bool rs_atend; /* restart scan at end? */ - uint16 rs_cdelta; /* current delta in chain */ - uint16 rs_nkeys; /* number of attributes in keys */ - ScanKey rs_key; /* key descriptors */ + Relation rs_rd; /* pointer to relation descriptor */ + HeapTupleData rs_ptup; /* previous tuple in scan */ + HeapTupleData rs_ctup; /* current tuple in scan */ + HeapTupleData rs_ntup; /* next tuple in scan */ + Buffer rs_pbuf; /* previous buffer in scan */ + Buffer rs_cbuf; /* current buffer in scan */ + Buffer rs_nbuf; /* next buffer in scan */ + ItemPointerData rs_mptid; /* marked previous tid */ + ItemPointerData rs_mctid; /* marked current tid */ + ItemPointerData rs_mntid; /* marked next tid */ + ItemPointerData rs_mcd; /* marked current delta XXX ??? */ + Snapshot rs_snapshot; /* snapshot to see */ + bool rs_atend; /* restart scan at end? */ + uint16 rs_cdelta; /* current delta in chain */ + uint16 rs_nkeys; /* number of attributes in keys */ + ScanKey rs_key; /* key descriptors */ } HeapScanDescData; typedef HeapScanDescData *HeapScanDesc; typedef struct IndexScanDescData { - Relation relation; /* relation descriptor */ - void *opaque; /* am-specific slot */ + Relation relation; /* relation descriptor */ + void *opaque; /* am-specific slot */ ItemPointerData previousItemData; /* previous index pointer */ ItemPointerData currentItemData; /* current index pointer */ ItemPointerData nextItemData; /* next index pointer */ MarkData previousMarkData; /* marked previous pointer */ - MarkData currentMarkData; /* marked current pointer */ - MarkData nextMarkData; /* marked next pointer */ - uint8 flags; /* scan position flags */ - bool scanFromEnd; /* restart scan at end? */ - uint16 numberOfKeys; /* number of key attributes */ - ScanKey keyData; /* key descriptor */ + MarkData currentMarkData;/* marked current pointer */ + MarkData nextMarkData; /* marked next pointer */ + uint8 flags; /* scan position flags */ + bool scanFromEnd; /* restart scan at end? */ + uint16 numberOfKeys; /* number of key attributes */ + ScanKey keyData; /* key descriptor */ } IndexScanDescData; typedef IndexScanDescData *IndexScanDesc; @@ -69,13 +69,13 @@ typedef IndexScanDescData *IndexScanDesc; typedef IndexScanDesc *IndexScanDescPtr; /* - * HeapScanIsValid + * HeapScanIsValid * True iff the heap scan is valid. */ #define HeapScanIsValid(scan) PointerIsValid(scan) /* - * IndexScanIsValid + * IndexScanIsValid * True iff the index scan is valid. */ #define IndexScanIsValid(scan) PointerIsValid(scan) diff --git a/src/include/access/sdir.h b/src/include/access/sdir.h index 42654765bf..4f317f5eb0 100644 --- a/src/include/access/sdir.h +++ b/src/include/access/sdir.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: sdir.h,v 1.5 1999/02/13 23:20:58 momjian Exp $ + * $Id: sdir.h,v 1.6 1999/05/25 16:13:34 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -26,7 +26,7 @@ typedef enum ScanDirection } ScanDirection; /* - * ScanDirectionIsValid + * ScanDirectionIsValid * True iff scan direction is valid. */ #define ScanDirectionIsValid(direction) \ @@ -34,21 +34,21 @@ typedef enum ScanDirection direction <= ForwardScanDirection)) /* - * ScanDirectionIsBackward + * ScanDirectionIsBackward * True iff scan direction is backward. */ #define ScanDirectionIsBackward(direction) \ ((bool) (direction == BackwardScanDirection)) /* - * ScanDirectionIsNoMovement + * ScanDirectionIsNoMovement * True iff scan direction indicates no movement. */ #define ScanDirectionIsNoMovement(direction) \ ((bool) (direction == NoMovementScanDirection)) /* - * ScanDirectionIsForward + * ScanDirectionIsForward * True iff scan direction is forward. */ #define ScanDirectionIsForward(direction) \ diff --git a/src/include/access/strat.h b/src/include/access/strat.h index 4f47c0e224..0fa3cf62fd 100644 --- a/src/include/access/strat.h +++ b/src/include/access/strat.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: strat.h,v 1.12 1999/02/13 23:20:58 momjian Exp $ + * $Id: strat.h,v 1.13 1999/05/25 16:13:35 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -31,6 +31,7 @@ typedef struct StrategyTransformMapData * * * + * * STRUCTURE */ typedef StrategyTransformMapData *StrategyTransformMap; @@ -70,7 +71,7 @@ typedef struct StrategyEvaluationData typedef StrategyEvaluationData *StrategyEvaluation; /* - * StrategyTransformMapIsValid + * StrategyTransformMapIsValid * Returns true iff strategy transformation map is valid. */ #define StrategyTransformMapIsValid(transform) PointerIsValid(transform) diff --git a/src/include/access/transam.h b/src/include/access/transam.h index a7f911e50a..221a7456f9 100644 --- a/src/include/access/transam.h +++ b/src/include/access/transam.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: transam.h,v 1.19 1999/02/13 23:20:59 momjian Exp $ + * $Id: transam.h,v 1.20 1999/05/25 16:13:35 momjian Exp $ * * NOTES * Transaction System Version 101 now support proper oid @@ -145,7 +145,7 @@ extern bool TransactionIdDidCommit(TransactionId transactionId); extern bool TransactionIdDidAbort(TransactionId transactionId); extern void TransactionIdCommit(TransactionId transactionId); extern void TransactionIdAbort(TransactionId transactionId); -extern void TransactionIdFlushCache(void); +extern void TransactionIdFlushCache(void); /* in transam/transsup.c */ extern void AmiTransactionOverride(bool flag); diff --git a/src/include/access/tupmacs.h b/src/include/access/tupmacs.h index 6dd499c60b..3f2d6e8d96 100644 --- a/src/include/access/tupmacs.h +++ b/src/include/access/tupmacs.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: tupmacs.h,v 1.9 1999/03/25 03:49:26 tgl Exp $ + * $Id: tupmacs.h,v 1.10 1999/05/25 16:13:36 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -63,7 +63,7 @@ ) /* att_align aligns the given offset as needed for a datum of length attlen - * and alignment requirement attalign. In practice we don't need the length. + * and alignment requirement attalign. In practice we don't need the length. * The attalign cases are tested in what is hopefully something like their * frequency of occurrence. */ @@ -89,5 +89,5 @@ (cur_offset) + VARSIZE(DatumGetPointer(attval)) \ ) \ ) - + #endif diff --git a/src/include/c.h b/src/include/c.h index 4e604a88ef..4b7f7aa03d 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: c.h,v 1.54 1999/04/02 05:10:14 tgl Exp $ + * $Id: c.h,v 1.55 1999/05/25 16:13:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -61,14 +61,15 @@ * ---------------------------------------------------------------- */ /* - * bool + * bool * Boolean value, either true or false. * */ #ifndef __cplusplus #ifndef bool typedef char bool; -#endif /* ndef bool */ + +#endif /* ndef bool */ #endif /* not C++ */ #define false ((bool) 0) #define true ((bool) 1) @@ -83,7 +84,7 @@ typedef bool *BoolPtr; #endif /* FALSE */ /* - * NULL + * NULL * Null pointer. */ #ifndef NULL @@ -105,9 +106,9 @@ typedef bool *BoolPtr; */ /* - * CppAsString + * CppAsString * Convert the argument to a string, using the C preprocessor. - * CppConcat + * CppConcat * Concatenate two arguments together, using the C preprocessor. * * Note: the standard Autoconf macro AC_C_STRINGIZE actually only checks @@ -139,7 +140,7 @@ typedef bool *BoolPtr; * dummyret is used to set return values in macros that use ?: to make * assignments. gcc wants these to be void, other compilers like char */ -#ifdef __GNUC__ /* GNU cc */ +#ifdef __GNUC__ /* GNU cc */ #define dummyret void #else #define dummyret char @@ -151,7 +152,7 @@ typedef bool *BoolPtr; */ /* - * Pointer + * Pointer * Variable holding address of any memory resident object. * * XXX Pointer arithmetic is done with this, so it can't be void * @@ -160,7 +161,7 @@ typedef bool *BoolPtr; typedef char *Pointer; /* - * intN + * intN * Signed integer, EXACTLY N BITS IN SIZE, * used for numerical computations and the * frontend/backend protocol. @@ -170,7 +171,7 @@ typedef signed short int16; /* == 16 bits */ typedef signed int int32; /* == 32 bits */ /* - * uintN + * uintN * Unsigned integer, EXACTLY N BITS IN SIZE, * used for numerical computations and the * frontend/backend protocol. @@ -180,7 +181,7 @@ typedef unsigned short uint16; /* == 16 bits */ typedef unsigned int uint32; /* == 32 bits */ /* - * floatN + * floatN * Floating point number, AT LEAST N BITS IN SIZE, * used for numerical computations. * @@ -193,7 +194,7 @@ typedef float *float32; typedef double *float64; /* - * boolN + * boolN * Boolean value, AT LEAST N BITS IN SIZE. */ typedef uint8 bool8; /* >= 8 bits */ @@ -201,7 +202,7 @@ typedef uint16 bool16; /* >= 16 bits */ typedef uint32 bool32; /* >= 32 bits */ /* - * bitsN + * bitsN * Unit of bitwise operation, AT LEAST N BITS IN SIZE. */ typedef uint8 bits8; /* >= 8 bits */ @@ -209,7 +210,7 @@ typedef uint16 bits16; /* >= 16 bits */ typedef uint32 bits32; /* >= 32 bits */ /* - * wordN + * wordN * Unit of storage, AT LEAST N BITS IN SIZE, * used to fetch/store data. */ @@ -218,13 +219,13 @@ typedef uint16 word16; /* >= 16 bits */ typedef uint32 word32; /* >= 32 bits */ /* - * Size + * Size * Size of any memory resident object, as returned by sizeof. */ typedef size_t Size; /* - * Index + * Index * Index into any memory resident array. * * Note: @@ -239,7 +240,7 @@ typedef struct } IntArray; /* - * Offset + * Offset * Offset into any memory resident array. * * Note: @@ -253,7 +254,7 @@ typedef signed int Offset; * ---------------------------------------------------------------- */ /* - * datum.h + * datum.h * POSTGRES abstract data type datum representation definitions. * * Note: @@ -288,133 +289,133 @@ typedef Datum *DatumPtr; #define SET_4_BYTES(value) (((Datum) (value)) & 0xffffffff) /* - * DatumGetChar + * DatumGetChar * Returns character value of a datum. */ #define DatumGetChar(X) ((char) GET_1_BYTE(X)) /* - * CharGetDatum + * CharGetDatum * Returns datum representation for a character. */ #define CharGetDatum(X) ((Datum) SET_1_BYTE(X)) /* - * Int8GetDatum + * Int8GetDatum * Returns datum representation for an 8-bit integer. */ #define Int8GetDatum(X) ((Datum) SET_1_BYTE(X)) /* - * DatumGetUInt8 + * DatumGetUInt8 * Returns 8-bit unsigned integer value of a datum. */ #define DatumGetUInt8(X) ((uint8) GET_1_BYTE(X)) /* - * UInt8GetDatum + * UInt8GetDatum * Returns datum representation for an 8-bit unsigned integer. */ #define UInt8GetDatum(X) ((Datum) SET_1_BYTE(X)) /* - * DatumGetInt16 + * DatumGetInt16 * Returns 16-bit integer value of a datum. */ #define DatumGetInt16(X) ((int16) GET_2_BYTES(X)) /* - * Int16GetDatum + * Int16GetDatum * Returns datum representation for a 16-bit integer. */ #define Int16GetDatum(X) ((Datum) SET_2_BYTES(X)) /* - * DatumGetUInt16 + * DatumGetUInt16 * Returns 16-bit unsigned integer value of a datum. */ #define DatumGetUInt16(X) ((uint16) GET_2_BYTES(X)) /* - * UInt16GetDatum + * UInt16GetDatum * Returns datum representation for a 16-bit unsigned integer. */ #define UInt16GetDatum(X) ((Datum) SET_2_BYTES(X)) /* - * DatumGetInt32 + * DatumGetInt32 * Returns 32-bit integer value of a datum. */ #define DatumGetInt32(X) ((int32) GET_4_BYTES(X)) /* - * Int32GetDatum + * Int32GetDatum * Returns datum representation for a 32-bit integer. */ #define Int32GetDatum(X) ((Datum) SET_4_BYTES(X)) /* - * DatumGetUInt32 + * DatumGetUInt32 * Returns 32-bit unsigned integer value of a datum. */ #define DatumGetUInt32(X) ((uint32) GET_4_BYTES(X)) /* - * UInt32GetDatum + * UInt32GetDatum * Returns datum representation for a 32-bit unsigned integer. */ #define UInt32GetDatum(X) ((Datum) SET_4_BYTES(X)) /* - * DatumGetObjectId + * DatumGetObjectId * Returns object identifier value of a datum. */ #define DatumGetObjectId(X) ((Oid) GET_4_BYTES(X)) /* - * ObjectIdGetDatum + * ObjectIdGetDatum * Returns datum representation for an object identifier. */ #define ObjectIdGetDatum(X) ((Datum) SET_4_BYTES(X)) /* - * DatumGetPointer + * DatumGetPointer * Returns pointer value of a datum. */ #define DatumGetPointer(X) ((Pointer) X) /* - * PointerGetDatum + * PointerGetDatum * Returns datum representation for a pointer. */ #define PointerGetDatum(X) ((Datum) X) /* - * DatumGetName + * DatumGetName * Returns name value of a datum. */ #define DatumGetName(X) ((Name) DatumGetPointer((Datum) X)) /* - * NameGetDatum + * NameGetDatum * Returns datum representation for a name. */ @@ -422,7 +423,7 @@ typedef Datum *DatumPtr; /* - * DatumGetFloat32 + * DatumGetFloat32 * Returns 32-bit floating point value of a datum. * This is really a pointer, of course. */ @@ -430,7 +431,7 @@ typedef Datum *DatumPtr; #define DatumGetFloat32(X) ((float32) DatumGetPointer((Datum) X)) /* - * Float32GetDatum + * Float32GetDatum * Returns datum representation for a 32-bit floating point number. * This is really a pointer, of course. */ @@ -438,7 +439,7 @@ typedef Datum *DatumPtr; #define Float32GetDatum(X) PointerGetDatum((Pointer) X) /* - * DatumGetFloat64 + * DatumGetFloat64 * Returns 64-bit floating point value of a datum. * This is really a pointer, of course. */ @@ -446,7 +447,7 @@ typedef Datum *DatumPtr; #define DatumGetFloat64(X) ((float64) DatumGetPointer(X)) /* - * Float64GetDatum + * Float64GetDatum * Returns datum representation for a 64-bit floating point number. * This is really a pointer, of course. */ @@ -458,19 +459,19 @@ typedef Datum *DatumPtr; * ---------------------------------------------------------------- */ /* - * BoolIsValid + * BoolIsValid * True iff bool is valid. */ #define BoolIsValid(boolean) ((boolean) == false || (boolean) == true) /* - * PointerIsValid + * PointerIsValid * True iff pointer is valid. */ #define PointerIsValid(pointer) (bool)((void*)(pointer) != NULL) /* - * PointerIsInBounds + * PointerIsInBounds * True iff pointer is within given bounds. * * Note: @@ -481,7 +482,7 @@ typedef Datum *DatumPtr; ((min) <= (pointer) && (pointer) < (max)) /* - * PointerIsAligned + * PointerIsAligned * True iff pointer is properly aligned to point to the given type. */ #define PointerIsAligned(pointer, type) \ @@ -492,7 +493,7 @@ typedef Datum *DatumPtr; * ---------------------------------------------------------------- */ /* - * offsetof + * offsetof * Offset of a structure/union field within that structure/union. * * XXX This is supposed to be part of stddef.h, but isn't on @@ -503,13 +504,13 @@ typedef Datum *DatumPtr; #endif /* offsetof */ /* - * lengthof + * lengthof * Number of elements in an array. */ #define lengthof(array) (sizeof (array) / sizeof ((array)[0])) /* - * endof + * endof * Address of the element one past the last in an array. */ #define endof(array) (&array[lengthof(array)]) @@ -537,7 +538,7 @@ typedef struct Exception */ /* - * Trap + * Trap * Generates an exception if the given condition is true. * */ @@ -583,7 +584,7 @@ extern int assert_enabled; #endif /* USE_ASSERT_CHECKING */ /* - * LogTrap + * LogTrap * Generates an exception with a message if the given condition is true. * */ @@ -634,25 +635,25 @@ extern int assertTest(int val); * ---------------------------------------------------------------- */ /* - * Max + * Max * Return the maximum of two numbers. */ #define Max(x, y) ((x) > (y) ? (x) : (y)) /* - * Min + * Min * Return the minimum of two numbers. */ #define Min(x, y) ((x) < (y) ? (x) : (y)) /* - * Abs + * Abs * Return the absolute value of the argument. */ #define Abs(x) ((x) >= 0 ? (x) : -(x)) /* - * StrNCpy + * StrNCpy * Does string copy, and forces terminating NULL */ /* we do this so if the macro is used in an if action, it will work */ @@ -772,24 +773,26 @@ extern char *form(const char *fmt,...); #endif #ifdef BUILDING_DLL #define DLLIMPORT __declspec (dllexport) -#else /* not BUILDING_DLL */ +#else /* not BUILDING_DLL */ #define DLLIMPORT __declspec (dllimport) #endif -#else /* not CYGWIN */ +#else /* not CYGWIN */ #define DLLIMPORT #endif /* Provide prototypes for routines not present in a particular machine's - * standard C library. It'd be better to put these in config.h, but + * standard C library. It'd be better to put these in config.h, but * in config.h we haven't yet included anything that defines size_t... */ #ifndef HAVE_SNPRINTF -extern int snprintf(char *str, size_t count, const char *fmt, ...); +extern int snprintf(char *str, size_t count, const char *fmt,...); + #endif #ifndef HAVE_VSNPRINTF -extern int vsnprintf(char *str, size_t count, const char *fmt, va_list args); +extern int vsnprintf(char *str, size_t count, const char *fmt, va_list args); + #endif /* ---------------- diff --git a/src/include/catalog/heap.h b/src/include/catalog/heap.h index 177e9217ce..f10340a2a4 100644 --- a/src/include/catalog/heap.h +++ b/src/include/catalog/heap.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: heap.h,v 1.18 1999/02/13 23:21:03 momjian Exp $ + * $Id: heap.h,v 1.19 1999/05/25 16:13:39 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -17,7 +17,7 @@ extern Oid RelnameFindRelid(char *relname); extern Relation heap_create(char *relname, TupleDesc att, - bool isnoname, bool istemp); + bool isnoname, bool istemp); extern Oid heap_create_with_catalog(char *relname, TupleDesc tupdesc, char relkind, bool istemp); diff --git a/src/include/catalog/index.h b/src/include/catalog/index.h index fb157c6344..95cdf8845f 100644 --- a/src/include/catalog/index.h +++ b/src/include/catalog/index.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: index.h,v 1.15 1999/02/13 23:21:03 momjian Exp $ + * $Id: index.h,v 1.16 1999/05/25 16:13:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -39,7 +39,7 @@ extern void index_create(char *heapRelationName, Node *predicate, bool islossy, bool unique, - bool primary); + bool primary); extern void index_destroy(Oid indexId); diff --git a/src/include/catalog/pg_attribute.h b/src/include/catalog/pg_attribute.h index e3aef0a5d9..466a0a2215 100644 --- a/src/include/catalog/pg_attribute.h +++ b/src/include/catalog/pg_attribute.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_attribute.h,v 1.46 1999/03/28 02:01:38 tgl Exp $ + * $Id: pg_attribute.h,v 1.47 1999/05/25 16:13:42 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -369,9 +369,9 @@ DATA(insert OID = 0 ( 1249 cmax 29 0 4 -6 0 -1 -1 t f i f f)); { 1259, {"relnatts"}, 21, 0, 2, 10, 0, -1, -1, '\001', '\0', 's', '\0', '\0' }, \ { 1259, {"relchecks"}, 21, 0, 2, 11, 0, -1, -1, '\001', '\0', 's', '\0', '\0' }, \ { 1259, {"reltriggers"}, 21, 0, 2, 12, 0, -1, -1, '\001', '\0', 's', '\0', '\0' }, \ -{ 1259, {"relukeys"}, 21, 0, 2, 13, 0, -1, -1, '\001', '\0', 's', '\0', '\0' }, \ -{ 1259, {"relfkeys"}, 21, 0, 2, 14, 0, -1, -1, '\001', '\0', 's', '\0', '\0' }, \ -{ 1259, {"relrefs"}, 21, 0, 2, 15, 0, -1, -1, '\001', '\0', 's', '\0', '\0' }, \ +{ 1259, {"relukeys"}, 21, 0, 2, 13, 0, -1, -1, '\001', '\0', 's', '\0', '\0' }, \ +{ 1259, {"relfkeys"}, 21, 0, 2, 14, 0, -1, -1, '\001', '\0', 's', '\0', '\0' }, \ +{ 1259, {"relrefs"}, 21, 0, 2, 15, 0, -1, -1, '\001', '\0', 's', '\0', '\0' }, \ { 1259, {"relhaspkey"}, 16, 0, 1, 16, 0, -1, -1, '\001', '\0', 'c', '\0', '\0' }, \ { 1259, {"relhasrules"}, 16, 0, 1, 17, 0, -1, -1, '\001', '\0', 'c', '\0', '\0' }, \ { 1259, {"relacl"}, 1034, 0, -1, 18, 0, -1, -1, '\0', '\0', 'i', '\0', '\0' } diff --git a/src/include/catalog/pg_class.h b/src/include/catalog/pg_class.h index 246970db81..5647707a20 100644 --- a/src/include/catalog/pg_class.h +++ b/src/include/catalog/pg_class.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_class.h,v 1.28 1999/03/28 02:01:38 tgl Exp $ + * $Id: pg_class.h,v 1.29 1999/05/25 16:13:44 momjian Exp $ * * NOTES * ``pg_relation'' is being replaced by ``pg_class''. currently @@ -144,7 +144,7 @@ DATA(insert OID = 1264 ( pg_variable 90 PGUID 0 0 0 f t s 1 0 0 0 0 0 f f _n DESCR(""); DATA(insert OID = 1269 ( pg_log 99 PGUID 0 0 0 f t s 1 0 0 0 0 0 f f _null_ )); DESCR(""); -DATA(insert OID = 376 ( pg_xactlock 0 PGUID 0 0 0 f t s 1 0 0 0 0 0 f f _null_ )); +DATA(insert OID = 376 ( pg_xactlock 0 PGUID 0 0 0 f t s 1 0 0 0 0 0 f f _null_ )); DESCR(""); DATA(insert OID = 1215 ( pg_attrdef 109 PGUID 0 0 0 t t r 4 0 0 0 0 0 f f _null_ )); DESCR(""); diff --git a/src/include/catalog/pg_index.h b/src/include/catalog/pg_index.h index 38bb948a66..ee0fa2284f 100644 --- a/src/include/catalog/pg_index.h +++ b/src/include/catalog/pg_index.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_index.h,v 1.11 1999/02/13 23:21:10 momjian Exp $ + * $Id: pg_index.h,v 1.12 1999/05/25 16:13:45 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -53,8 +53,8 @@ CATALOG(pg_index) bool indhaskeytype; /* does key type != attribute type? */ bool indisunique; /* is this a unique index? */ bool indisprimary; /* is this index for primary key */ - Oid indreference; /* oid of index of referenced relation - * (ie - this index for foreign key */ + Oid indreference; /* oid of index of referenced relation (ie + * - this index for foreign key */ text indpred; /* query plan for partial index predicate */ } FormData_pg_index; diff --git a/src/include/catalog/pg_opclass.h b/src/include/catalog/pg_opclass.h index cc18de9fd0..591021fbb4 100644 --- a/src/include/catalog/pg_opclass.h +++ b/src/include/catalog/pg_opclass.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_opclass.h,v 1.18 1999/03/28 02:01:38 tgl Exp $ + * $Id: pg_opclass.h,v 1.19 1999/05/25 16:13:45 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -109,11 +109,11 @@ DATA(insert OID = 1312 ( datetime_ops 1184 )); DESCR(""); DATA(insert OID = 1313 ( timespan_ops 1186 )); DESCR(""); -DATA(insert OID = 810 ( macaddr_ops 829 )); +DATA(insert OID = 810 ( macaddr_ops 829 )); DESCR(""); -DATA(insert OID = 935 ( network_ops 869 )); +DATA(insert OID = 935 ( network_ops 869 )); DESCR(""); -DATA(insert OID = 652 ( network_ops 650 )); +DATA(insert OID = 652 ( network_ops 650 )); DESCR(""); #endif /* PG_OPCLASS_H */ diff --git a/src/include/catalog/pg_operator.h b/src/include/catalog/pg_operator.h index 01b929fc15..1dec2cfcd9 100644 --- a/src/include/catalog/pg_operator.h +++ b/src/include/catalog/pg_operator.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_operator.h,v 1.56 1999/04/10 23:53:00 tgl Exp $ + * $Id: pg_operator.h,v 1.57 1999/05/25 16:13:46 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -197,7 +197,7 @@ DATA(insert OID = 527 ( "/" PGUID 0 b t f 21 21 21 0 0 0 0 int2div DATA(insert OID = 528 ( "/" PGUID 0 b t f 23 23 23 0 0 0 0 int4div - - )); DATA(insert OID = 529 ( "%" PGUID 0 b t f 21 21 21 0 0 0 0 int2mod - - )); DATA(insert OID = 530 ( "%" PGUID 0 b t f 23 23 23 0 0 0 0 int4mod - - )); -DATA(insert OID = 531 ( "<>" PGUID 0 b t f 25 25 16 531 98 0 0 textne neqsel neqjoinsel )); +DATA(insert OID = 531 ( "<>" PGUID 0 b t f 25 25 16 531 98 0 0 textne neqsel neqjoinsel )); DATA(insert OID = 532 ( "=" PGUID 0 b t f 21 23 16 533 538 95 97 int24eq eqsel eqjoinsel )); DATA(insert OID = 533 ( "=" PGUID 0 b t f 23 21 16 532 539 97 95 int42eq eqsel eqjoinsel )); DATA(insert OID = 534 ( "<" PGUID 0 b t f 21 23 16 537 542 0 0 int24lt intltsel intltjoinsel )); @@ -476,7 +476,7 @@ DATA(insert OID = 1116 ( "+" PGUID 0 b t f 700 701 701 1126 0 0 0 float48pl DATA(insert OID = 1117 ( "-" PGUID 0 b t f 700 701 701 0 0 0 0 float48mi - - )); DATA(insert OID = 1118 ( "/" PGUID 0 b t f 700 701 701 0 0 0 0 float48div - - )); DATA(insert OID = 1119 ( "*" PGUID 0 b t f 700 701 701 1129 0 0 0 float48mul - - )); -DATA(insert OID = 1120 ( "=" PGUID 0 b t f 700 701 16 1130 1121 622 672 float48eq eqsel eqjoinsel )); +DATA(insert OID = 1120 ( "=" PGUID 0 b t f 700 701 16 1130 1121 622 672 float48eq eqsel eqjoinsel )); DATA(insert OID = 1121 ( "<>" PGUID 0 b t f 700 701 16 1131 1120 0 0 float48ne neqsel neqjoinsel )); DATA(insert OID = 1122 ( "<" PGUID 0 b t f 700 701 16 1133 1125 0 0 float48lt intltsel intltjoinsel )); DATA(insert OID = 1123 ( ">" PGUID 0 b t f 700 701 16 1132 1124 0 0 float48gt intgtsel intgtjoinsel )); @@ -571,29 +571,29 @@ DATA(insert OID = 1513 ( "&&" PGUID 0 b t f 718 718 16 0 0 0 0 circle DATA(insert OID = 1514 ( ">^" PGUID 0 b t f 718 718 16 0 0 0 0 circle_above - - )); DATA(insert OID = 1515 ( "<^" PGUID 0 b t f 718 718 16 0 0 0 0 circle_below - - )); -DATA(insert OID = 1516 ( "+" PGUID 0 b t f 718 600 718 0 0 0 0 circle_add_pt - - )); +DATA(insert OID = 1516 ( "+" PGUID 0 b t f 718 600 718 0 0 0 0 circle_add_pt - - )); DATA(insert OID = 1517 ( "-" PGUID 0 b t f 718 600 718 0 0 0 0 circle_sub_pt - - )); -DATA(insert OID = 1518 ( "*" PGUID 0 b t f 718 600 718 0 0 0 0 circle_mul_pt - - )); +DATA(insert OID = 1518 ( "*" PGUID 0 b t f 718 600 718 0 0 0 0 circle_mul_pt - - )); DATA(insert OID = 1519 ( "/" PGUID 0 b t f 718 600 718 0 0 0 0 circle_div_pt - - )); DATA(insert OID = 1520 ( "<->" PGUID 0 b t f 718 718 701 1520 0 0 0 circle_distance - - )); DATA(insert OID = 1521 ( "#" PGUID 0 l t f 0 604 23 0 0 0 0 poly_npoints - - )); -DATA(insert OID = 1522 ( "<->" PGUID 0 b t f 600 718 701 0 0 0 0 dist_pc - - )); -DATA(insert OID = 1523 ( "<->" PGUID 0 b t f 718 604 701 0 0 0 0 dist_cpoly - - )); +DATA(insert OID = 1522 ( "<->" PGUID 0 b t f 600 718 701 0 0 0 0 dist_pc - - )); +DATA(insert OID = 1523 ( "<->" PGUID 0 b t f 718 604 701 0 0 0 0 dist_cpoly - - )); /* additional geometric operators - thomas 1997-07-09 */ -DATA(insert OID = 1524 ( "<->" PGUID 0 b t f 628 603 701 0 0 0 0 dist_lb - - )); +DATA(insert OID = 1524 ( "<->" PGUID 0 b t f 628 603 701 0 0 0 0 dist_lb - - )); DATA(insert OID = 1525 ( "?#" PGUID 0 b t f 601 601 16 1525 0 0 0 lseg_intersect - - )); DATA(insert OID = 1526 ( "?||" PGUID 0 b t f 601 601 16 1526 0 0 0 lseg_parallel - - )); DATA(insert OID = 1527 ( "?-|" PGUID 0 b t f 601 601 16 1527 0 0 0 lseg_perp - - )); -DATA(insert OID = 1528 ( "?-" PGUID 0 l t f 0 601 16 0 0 0 0 lseg_horizontal - - )); -DATA(insert OID = 1529 ( "?|" PGUID 0 l t f 0 601 16 0 0 0 0 lseg_vertical - - )); +DATA(insert OID = 1528 ( "?-" PGUID 0 l t f 0 601 16 0 0 0 0 lseg_horizontal - - )); +DATA(insert OID = 1529 ( "?|" PGUID 0 l t f 0 601 16 0 0 0 0 lseg_vertical - - )); DATA(insert OID = 1535 ( "=" PGUID 0 b t f 601 601 16 1535 1586 0 0 lseg_eq eqsel eqjoinsel )); DATA(insert OID = 1536 ( "#" PGUID 0 b t f 601 601 600 1536 0 0 0 lseg_interpt - - )); -DATA(insert OID = 1537 ( "?#" PGUID 0 b t f 601 628 16 0 0 0 0 inter_sl - - )); -DATA(insert OID = 1538 ( "?#" PGUID 0 b t f 601 603 16 0 0 0 0 inter_sb - - )); -DATA(insert OID = 1539 ( "?#" PGUID 0 b t f 628 603 16 0 0 0 0 inter_lb - - )); +DATA(insert OID = 1537 ( "?#" PGUID 0 b t f 601 628 16 0 0 0 0 inter_sl - - )); +DATA(insert OID = 1538 ( "?#" PGUID 0 b t f 601 603 16 0 0 0 0 inter_sb - - )); +DATA(insert OID = 1539 ( "?#" PGUID 0 b t f 628 603 16 0 0 0 0 inter_lb - - )); DATA(insert OID = 1546 ( "@" PGUID 0 b t f 600 628 16 0 0 0 0 on_pl - - )); DATA(insert OID = 1547 ( "@" PGUID 0 b t f 600 601 16 0 0 0 0 on_ps - - )); @@ -622,8 +622,8 @@ DATA(insert OID = 1591 ( "@-@" PGUID 0 l t f 0 601 701 0 0 0 0 lseg_leng DATA(insert OID = 1611 ( "?#" PGUID 0 b t f 628 628 16 1611 0 0 0 line_intersect - - )); DATA(insert OID = 1612 ( "?||" PGUID 0 b t f 628 628 16 1612 0 0 0 line_parallel - - )); DATA(insert OID = 1613 ( "?-|" PGUID 0 b t f 628 628 16 1613 0 0 0 line_perp - - )); -DATA(insert OID = 1614 ( "?-" PGUID 0 l t f 0 628 16 0 0 0 0 line_horizontal - - )); -DATA(insert OID = 1615 ( "?|" PGUID 0 l t f 0 628 16 0 0 0 0 line_vertical - - )); +DATA(insert OID = 1614 ( "?-" PGUID 0 l t f 0 628 16 0 0 0 0 line_horizontal - - )); +DATA(insert OID = 1615 ( "?|" PGUID 0 l t f 0 628 16 0 0 0 0 line_vertical - - )); DATA(insert OID = 1616 ( "=" PGUID 0 b t f 628 628 16 1616 0 0 0 line_eq eqsel eqjoinsel )); DATA(insert OID = 1617 ( "#" PGUID 0 b t f 628 628 600 1617 0 0 0 line_interpt - - )); @@ -642,10 +642,10 @@ DATA(insert OID = 1203 ( "<" PGUID 0 b t f 869 869 16 1205 1206 0 0 network DATA(insert OID = 1204 ( "<=" PGUID 0 b t f 869 869 16 1206 1205 0 0 network_le intltsel intltjoinsel )); DATA(insert OID = 1205 ( ">" PGUID 0 b t f 869 869 16 1203 1204 0 0 network_gt intgtsel intgtjoinsel )); DATA(insert OID = 1206 ( ">=" PGUID 0 b t f 869 869 16 1204 1203 0 0 network_ge intgtsel intgtjoinsel )); -DATA(insert OID = 931 ( "<<" PGUID 0 b t f 869 869 16 933 934 0 0 network_sub - - )); -DATA(insert OID = 932 ( "<<=" PGUID 0 b t f 869 869 16 934 933 0 0 network_subeq - - )); -DATA(insert OID = 933 ( ">>" PGUID 0 b t f 869 869 16 931 932 0 0 network_sup - - )); -DATA(insert OID = 934 ( ">>=" PGUID 0 b t f 869 869 16 932 931 0 0 network_supeq - - )); +DATA(insert OID = 931 ( "<<" PGUID 0 b t f 869 869 16 933 934 0 0 network_sub - - )); +DATA(insert OID = 932 ( "<<=" PGUID 0 b t f 869 869 16 934 933 0 0 network_subeq - - )); +DATA(insert OID = 933 ( ">>" PGUID 0 b t f 869 869 16 931 932 0 0 network_sup - - )); +DATA(insert OID = 934 ( ">>=" PGUID 0 b t f 869 869 16 932 931 0 0 network_supeq - - )); /* CIDR type */ DATA(insert OID = 820 ( "=" PGUID 0 b t f 650 650 16 820 821 0 0 network_eq eqsel eqjoinsel )); @@ -654,24 +654,24 @@ DATA(insert OID = 822 ( "<" PGUID 0 b t f 650 650 16 824 825 0 0 network_lt DATA(insert OID = 823 ( "<=" PGUID 0 b t f 650 650 16 825 824 0 0 network_le intltsel intltjoinsel )); DATA(insert OID = 824 ( ">" PGUID 0 b t f 650 650 16 822 823 0 0 network_gt intgtsel intgtjoinsel )); DATA(insert OID = 825 ( ">=" PGUID 0 b t f 650 650 16 823 822 0 0 network_ge intgtsel intgtjoinsel )); -DATA(insert OID = 826 ( "<<" PGUID 0 b t f 650 650 16 828 1004 0 0 network_sub - - )); -DATA(insert OID = 827 ( "<<=" PGUID 0 b t f 650 650 16 1004 828 0 0 network_subeq - - )); -DATA(insert OID = 828 ( ">>" PGUID 0 b t f 650 650 16 826 827 0 0 network_sup - - )); -DATA(insert OID = 1004 ( ">>=" PGUID 0 b t f 650 650 16 827 826 0 0 network_supeq - - )); +DATA(insert OID = 826 ( "<<" PGUID 0 b t f 650 650 16 828 1004 0 0 network_sub - - )); +DATA(insert OID = 827 ( "<<=" PGUID 0 b t f 650 650 16 1004 828 0 0 network_subeq - - )); +DATA(insert OID = 828 ( ">>" PGUID 0 b t f 650 650 16 826 827 0 0 network_sup - - )); +DATA(insert OID = 1004 ( ">>=" PGUID 0 b t f 650 650 16 827 826 0 0 network_supeq - - )); /* NUMERIC type - OID's 1700-1799 */ DATA(insert OID = 1752 ( "=" PGUID 0 b t f 1700 1700 16 1752 1753 1754 1754 numeric_eq eqsel eqjoinsel )); -DATA(insert OID = 1753 ( "<>" PGUID 0 b t f 1700 1700 16 1753 1752 0 0 numeric_ne neqsel neqjoinsel )); -DATA(insert OID = 1754 ( "<" PGUID 0 b t f 1700 1700 16 1756 1757 0 0 numeric_lt intltsel intltjoinsel )); -DATA(insert OID = 1755 ( "<=" PGUID 0 b t f 1700 1700 16 1757 1756 0 0 numeric_le intltsel intltjoinsel )); -DATA(insert OID = 1756 ( ">" PGUID 0 b t f 1700 1700 16 1754 1755 0 0 numeric_gt intgtsel intgtjoinsel )); -DATA(insert OID = 1757 ( ">=" PGUID 0 b t f 1700 1700 16 1755 1754 0 0 numeric_ge intgtsel intgtjoinsel )); -DATA(insert OID = 1758 ( "+" PGUID 0 b t f 1700 1700 1700 1758 0 0 0 numeric_add - - )); -DATA(insert OID = 1759 ( "-" PGUID 0 b t f 1700 1700 1700 0 0 0 0 numeric_sub - - )); -DATA(insert OID = 1760 ( "*" PGUID 0 b t f 1700 1700 1700 1760 0 0 0 numeric_mul - - )); -DATA(insert OID = 1761 ( "/" PGUID 0 b t f 1700 1700 1700 0 0 0 0 numeric_div - - )); -DATA(insert OID = 1762 ( "%" PGUID 0 b t f 1700 1700 1700 0 0 0 0 numeric_mod - - )); -DATA(insert OID = 1763 ( "@" PGUID 0 l t f 0 1700 1700 0 0 0 0 numeric_abs - - )); +DATA(insert OID = 1753 ( "<>" PGUID 0 b t f 1700 1700 16 1753 1752 0 0 numeric_ne neqsel neqjoinsel )); +DATA(insert OID = 1754 ( "<" PGUID 0 b t f 1700 1700 16 1756 1757 0 0 numeric_lt intltsel intltjoinsel )); +DATA(insert OID = 1755 ( "<=" PGUID 0 b t f 1700 1700 16 1757 1756 0 0 numeric_le intltsel intltjoinsel )); +DATA(insert OID = 1756 ( ">" PGUID 0 b t f 1700 1700 16 1754 1755 0 0 numeric_gt intgtsel intgtjoinsel )); +DATA(insert OID = 1757 ( ">=" PGUID 0 b t f 1700 1700 16 1755 1754 0 0 numeric_ge intgtsel intgtjoinsel )); +DATA(insert OID = 1758 ( "+" PGUID 0 b t f 1700 1700 1700 1758 0 0 0 numeric_add - - )); +DATA(insert OID = 1759 ( "-" PGUID 0 b t f 1700 1700 1700 0 0 0 0 numeric_sub - - )); +DATA(insert OID = 1760 ( "*" PGUID 0 b t f 1700 1700 1700 1760 0 0 0 numeric_mul - - )); +DATA(insert OID = 1761 ( "/" PGUID 0 b t f 1700 1700 1700 0 0 0 0 numeric_div - - )); +DATA(insert OID = 1762 ( "%" PGUID 0 b t f 1700 1700 1700 0 0 0 0 numeric_mod - - )); +DATA(insert OID = 1763 ( "@" PGUID 0 l t f 0 1700 1700 0 0 0 0 numeric_abs - - )); diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h index 5c2aedbb9a..292f8fac38 100644 --- a/src/include/catalog/pg_proc.h +++ b/src/include/catalog/pg_proc.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_proc.h,v 1.98 1999/05/09 02:22:16 tgl Exp $ + * $Id: pg_proc.h,v 1.99 1999/05/25 16:13:47 momjian Exp $ * * NOTES * The script catalog/genbki.sh reads this file and generates .bki @@ -295,7 +295,7 @@ DATA(insert OID = 138 ( box_center PGUID 11 f t f 1 f 600 "603" 100 1 0 100 DESCR("center of"); DATA(insert OID = 139 ( areasel PGUID 11 f t f 5 f 701 "26 26 21 0 23" 100 0 0 100 areasel - )); DESCR("selectivity"); -DATA(insert OID = 140 ( areajoinsel PGUID 11 f t f 5 f 701 "26 26 21 26 21" 100 0 0 100 areajoinsel - )); +DATA(insert OID = 140 ( areajoinsel PGUID 11 f t f 5 f 701 "26 26 21 26 21" 100 0 0 100 areajoinsel - )); DESCR("selectivity"); DATA(insert OID = 141 ( int4mul PGUID 11 f t f 2 f 23 "23 23" 100 0 0 100 int4mul - )); DESCR("multiply"); @@ -1077,9 +1077,9 @@ DESCR("convert text to int2"); DATA(insert OID = 819 ( text_int4 PGUID 11 f t f 1 f 23 "25" 100 0 0 100 text_int4 -)); DESCR("convert text to int4"); -DATA(insert OID = 838 ( text_float8 PGUID 11 f t f 1 f 701 "25" 100 0 0 100 text_float8 -)); +DATA(insert OID = 838 ( text_float8 PGUID 11 f t f 1 f 701 "25" 100 0 0 100 text_float8 -)); DESCR("convert text to float8"); -DATA(insert OID = 839 ( text_float4 PGUID 11 f t f 1 f 700 "25" 100 0 0 100 text_float4 -)); +DATA(insert OID = 839 ( text_float4 PGUID 11 f t f 1 f 700 "25" 100 0 0 100 text_float4 -)); DESCR("convert text to float4"); DATA(insert OID = 840 ( float8_text PGUID 11 f t f 1 f 25 "701" 100 0 0 100 float8_text -)); DESCR("convert float8 to text"); @@ -1300,11 +1300,11 @@ DATA(insert OID = 1037 ( aclcontains PGUID 11 f t f 2 f 16 "1034 1033" 100 0 DESCR("matches regex., case-sensitive"); DATA(insert OID = 1038 ( seteval PGUID 11 f t f 1 f 23 "26" 100 0 0 100 seteval - )); DESCR(""); -DATA(insert OID = 1044 ( bpcharin PGUID 11 f t f 3 f 1042 "0 0 23" 100 0 0 100 bpcharin - )); +DATA(insert OID = 1044 ( bpcharin PGUID 11 f t f 3 f 1042 "0 0 23" 100 0 0 100 bpcharin - )); DESCR("(internal)"); DATA(insert OID = 1045 ( bpcharout PGUID 11 f t f 1 f 23 "0" 100 0 0 100 bpcharout - )); DESCR("(internal)"); -DATA(insert OID = 1046 ( varcharin PGUID 11 f t f 3 f 1043 "0 0 23" 100 0 0 100 varcharin - )); +DATA(insert OID = 1046 ( varcharin PGUID 11 f t f 3 f 1043 "0 0 23" 100 0 0 100 varcharin - )); DESCR("(internal)"); DATA(insert OID = 1047 ( varcharout PGUID 11 f t f 1 f 23 "0" 100 0 0 100 varcharout - )); DESCR("(internal)"); @@ -2030,9 +2030,9 @@ DESCR("is line vertical?"); DATA(insert OID = 1603 ( isparallel PGUID 11 f t f 2 f 16 "628 628" 100 0 0 100 line_parallel - )); DESCR("are lines parallel?"); -DATA(insert OID = 1604 ( float8 PGUID 11 f t f 1 f 701 "25" 100 0 0 100 text_float8 - )); +DATA(insert OID = 1604 ( float8 PGUID 11 f t f 1 f 701 "25" 100 0 0 100 text_float8 - )); DESCR("convert text to float8"); -DATA(insert OID = 1605 ( float4 PGUID 11 f t f 1 f 700 "25" 100 0 0 100 text_float4 - )); +DATA(insert OID = 1605 ( float4 PGUID 11 f t f 1 f 700 "25" 100 0 0 100 text_float4 - )); DESCR("convert text to float4"); DATA(insert OID = 1606 ( text PGUID 11 f t f 1 f 25 "701" 100 0 0 100 float8_text - )); DESCR("convert float8 to text"); @@ -2041,11 +2041,11 @@ DESCR("convert float4 to text"); DATA(insert OID = 1619 ( varchar PGUID 11 f t f 1 f 1043 "23" 100 0 0 100 int4_text - )); DESCR("convert int4 to varchar"); -DATA(insert OID = 1620 ( int4 PGUID 11 f t f 1 f 23 "1043" 100 0 0 100 text_int4 - )); +DATA(insert OID = 1620 ( int4 PGUID 11 f t f 1 f 23 "1043" 100 0 0 100 text_int4 - )); DESCR("convert varchar to int4"); -DATA(insert OID = 1621 ( text PGUID 11 f t f 1 f 25 "20" 100 0 0 100 int8_text - )); +DATA(insert OID = 1621 ( text PGUID 11 f t f 1 f 25 "20" 100 0 0 100 int8_text - )); DESCR("convert int8 to text"); -DATA(insert OID = 1622 ( int8 PGUID 11 f t f 1 f 20 "25" 100 0 0 100 text_int8 - )); +DATA(insert OID = 1622 ( int8 PGUID 11 f t f 1 f 20 "25" 100 0 0 100 text_int8 - )); DESCR("convert text to int8"); DATA(insert OID = 1623 ( varchar PGUID 11 f t f 1 f 1043 "20" 100 0 0 100 int8_text - )); DESCR("convert int8 to varchar"); @@ -2116,21 +2116,21 @@ DESCR("(internal)"); DATA(insert OID = 437 ( macaddr_out PGUID 11 f t f 1 f 23 "0" 100 0 0 100 macaddr_out - )); DESCR("(internal)"); -DATA(insert OID = 830 ( macaddr_eq PGUID 11 f t f 2 f 16 "829 829" 100 0 0 100 macaddr_eq - )); +DATA(insert OID = 830 ( macaddr_eq PGUID 11 f t f 2 f 16 "829 829" 100 0 0 100 macaddr_eq - )); DESCR("equal"); -DATA(insert OID = 831 ( macaddr_lt PGUID 11 f t f 2 f 16 "829 829" 100 0 0 100 macaddr_lt - )); +DATA(insert OID = 831 ( macaddr_lt PGUID 11 f t f 2 f 16 "829 829" 100 0 0 100 macaddr_lt - )); DESCR("less-than"); -DATA(insert OID = 832 ( macaddr_le PGUID 11 f t f 2 f 16 "829 829" 100 0 0 100 macaddr_le - )); +DATA(insert OID = 832 ( macaddr_le PGUID 11 f t f 2 f 16 "829 829" 100 0 0 100 macaddr_le - )); DESCR("less-than-or-equal"); -DATA(insert OID = 833 ( macaddr_gt PGUID 11 f t f 2 f 16 "829 829" 100 0 0 100 macaddr_gt - )); +DATA(insert OID = 833 ( macaddr_gt PGUID 11 f t f 2 f 16 "829 829" 100 0 0 100 macaddr_gt - )); DESCR("greater-than"); -DATA(insert OID = 834 ( macaddr_ge PGUID 11 f t f 2 f 16 "829 829" 100 0 0 100 macaddr_ge - )); +DATA(insert OID = 834 ( macaddr_ge PGUID 11 f t f 2 f 16 "829 829" 100 0 0 100 macaddr_ge - )); DESCR("greater-than-or-equal"); -DATA(insert OID = 835 ( macaddr_ne PGUID 11 f t f 2 f 16 "829 829" 100 0 0 100 macaddr_ne - )); +DATA(insert OID = 835 ( macaddr_ne PGUID 11 f t f 2 f 16 "829 829" 100 0 0 100 macaddr_ne - )); DESCR("not equal"); -DATA(insert OID = 836 ( macaddr_cmp PGUID 11 f t f 2 f 23 "829 829" 100 0 0 100 macaddr_cmp - )); +DATA(insert OID = 836 ( macaddr_cmp PGUID 11 f t f 2 f 23 "829 829" 100 0 0 100 macaddr_cmp - )); DESCR("less-equal-greater"); -DATA(insert OID = 837 ( macaddr_manuf PGUID 11 f t f 1 f 25 "829" 100 0 0 100 macaddr_manuf - )); +DATA(insert OID = 837 ( macaddr_manuf PGUID 11 f t f 1 f 25 "829" 100 0 0 100 macaddr_manuf - )); DESCR("MAC manufacturer"); /* for inet type support */ @@ -2140,33 +2140,33 @@ DATA(insert OID = 911 ( inet_out PGUID 11 f t f 1 f 23 "0" 100 0 0 100 inet_ DESCR("(internal)"); /* for cidr type support */ -DATA(insert OID = 1267 ( cidr_in PGUID 11 f t f 1 f 650 "0" 100 0 0 100 cidr_in - )); +DATA(insert OID = 1267 ( cidr_in PGUID 11 f t f 1 f 650 "0" 100 0 0 100 cidr_in - )); DESCR("(internal)"); DATA(insert OID = 1416 ( cidr_out PGUID 11 f t f 1 f 23 "0" 100 0 0 100 cidr_out - )); DESCR("(internal)"); /* these are used for both inet and cidr */ -DATA(insert OID = 920 ( network_eq PGUID 11 f t f 2 f 16 "869 869" 100 0 0 100 network_eq - )); +DATA(insert OID = 920 ( network_eq PGUID 11 f t f 2 f 16 "869 869" 100 0 0 100 network_eq - )); DESCR("equal"); -DATA(insert OID = 921 ( network_lt PGUID 11 f t f 2 f 16 "869 869" 100 0 0 100 network_lt - )); +DATA(insert OID = 921 ( network_lt PGUID 11 f t f 2 f 16 "869 869" 100 0 0 100 network_lt - )); DESCR("less-than"); -DATA(insert OID = 922 ( network_le PGUID 11 f t f 2 f 16 "869 869" 100 0 0 100 network_le - )); +DATA(insert OID = 922 ( network_le PGUID 11 f t f 2 f 16 "869 869" 100 0 0 100 network_le - )); DESCR("less-than-or-equal"); -DATA(insert OID = 923 ( network_gt PGUID 11 f t f 2 f 16 "869 869" 100 0 0 100 network_gt - )); +DATA(insert OID = 923 ( network_gt PGUID 11 f t f 2 f 16 "869 869" 100 0 0 100 network_gt - )); DESCR("greater-than"); -DATA(insert OID = 924 ( network_ge PGUID 11 f t f 2 f 16 "869 869" 100 0 0 100 network_ge - )); +DATA(insert OID = 924 ( network_ge PGUID 11 f t f 2 f 16 "869 869" 100 0 0 100 network_ge - )); DESCR("greater-than-or-equal"); -DATA(insert OID = 925 ( network_ne PGUID 11 f t f 2 f 16 "869 869" 100 0 0 100 network_ne - )); +DATA(insert OID = 925 ( network_ne PGUID 11 f t f 2 f 16 "869 869" 100 0 0 100 network_ne - )); DESCR("not equal"); -DATA(insert OID = 926 ( network_cmp PGUID 11 f t f 2 f 23 "869 869" 100 0 0 100 network_cmp - )); +DATA(insert OID = 926 ( network_cmp PGUID 11 f t f 2 f 23 "869 869" 100 0 0 100 network_cmp - )); DESCR("less-equal-greater"); -DATA(insert OID = 927 ( network_sub PGUID 11 f t f 2 f 16 "869 869" 100 0 0 100 network_sub - )); +DATA(insert OID = 927 ( network_sub PGUID 11 f t f 2 f 16 "869 869" 100 0 0 100 network_sub - )); DESCR("is-subnet"); -DATA(insert OID = 928 ( network_subeq PGUID 11 f t f 2 f 16 "869 869" 100 0 0 100 network_subeq - )); +DATA(insert OID = 928 ( network_subeq PGUID 11 f t f 2 f 16 "869 869" 100 0 0 100 network_subeq - )); DESCR("is-subnet-or-equal"); -DATA(insert OID = 929 ( network_sup PGUID 11 f t f 2 f 16 "869 869" 100 0 0 100 network_sup - )); +DATA(insert OID = 929 ( network_sup PGUID 11 f t f 2 f 16 "869 869" 100 0 0 100 network_sup - )); DESCR("is-supernet"); -DATA(insert OID = 930 ( network_supeq PGUID 11 f t f 2 f 16 "869 869" 100 0 0 100 network_supeq - )); +DATA(insert OID = 930 ( network_supeq PGUID 11 f t f 2 f 16 "869 869" 100 0 0 100 network_supeq - )); DESCR("is-supernet-or-equal"); /* inet/cidr versions */ @@ -2200,33 +2200,33 @@ DATA(insert OID = 1702 ( numeric_out PGUID 11 f t f 1 f 23 "0" 100 0 0 100 nu DESCR("(internal)"); DATA(insert OID = 1703 ( numeric PGUID 11 f t f 2 f 1700 "1700 23" 100 0 0 100 numeric - )); DESCR("(internal)"); -DATA(insert OID = 1704 ( numeric_abs PGUID 11 f t f 1 f 1700 "1700" 100 0 0 100 numeric_abs - )); +DATA(insert OID = 1704 ( numeric_abs PGUID 11 f t f 1 f 1700 "1700" 100 0 0 100 numeric_abs - )); DESCR("absolute value"); -DATA(insert OID = 1705 ( abs PGUID 11 f t f 1 f 1700 "1700" 100 0 0 100 numeric_abs - )); +DATA(insert OID = 1705 ( abs PGUID 11 f t f 1 f 1700 "1700" 100 0 0 100 numeric_abs - )); DESCR("absolute value"); -DATA(insert OID = 1706 ( numeric_sign PGUID 11 f t f 1 f 1700 "1700" 100 0 0 100 numeric_sign - )); +DATA(insert OID = 1706 ( numeric_sign PGUID 11 f t f 1 f 1700 "1700" 100 0 0 100 numeric_sign - )); DESCR("sign of value"); -DATA(insert OID = 1707 ( sign PGUID 11 f t f 1 f 1700 "1700" 100 0 0 100 numeric_sign - )); +DATA(insert OID = 1707 ( sign PGUID 11 f t f 1 f 1700 "1700" 100 0 0 100 numeric_sign - )); DESCR("sign of value"); DATA(insert OID = 1708 ( numeric_round PGUID 11 f t f 2 f 1700 "1700 23" 100 0 0 100 numeric_round - )); DESCR("value rounded to 'scale'"); DATA(insert OID = 1709 ( round PGUID 11 f t f 2 f 1700 "1700 23" 100 0 0 100 numeric_round - )); DESCR("value rounded to 'scale'"); -DATA(insert OID = 1710 ( round PGUID 14 f t f 1 f 1700 "1700" 100 0 0 100 "select numeric_round($1,0)" - )); +DATA(insert OID = 1710 ( round PGUID 14 f t f 1 f 1700 "1700" 100 0 0 100 "select numeric_round($1,0)" - )); DESCR("value rounded to 'scale' of zero"); DATA(insert OID = 1711 ( numeric_trunc PGUID 11 f t f 2 f 1700 "1700 23" 100 0 0 100 numeric_trunc - )); DESCR("value truncated to 'scale'"); DATA(insert OID = 1712 ( trunc PGUID 11 f t f 2 f 1700 "1700 23" 100 0 0 100 numeric_trunc - )); DESCR("value truncated to 'scale'"); -DATA(insert OID = 1713 ( trunc PGUID 14 f t f 1 f 1700 "1700" 100 0 0 100 "select numeric_trunc($1,0)" - )); +DATA(insert OID = 1713 ( trunc PGUID 14 f t f 1 f 1700 "1700" 100 0 0 100 "select numeric_trunc($1,0)" - )); DESCR("value truncated to 'scale' of zero"); -DATA(insert OID = 1714 ( numeric_ceil PGUID 11 f t f 1 f 1700 "1700" 100 0 0 100 numeric_ceil - )); +DATA(insert OID = 1714 ( numeric_ceil PGUID 11 f t f 1 f 1700 "1700" 100 0 0 100 numeric_ceil - )); DESCR("smallest integer >= value"); -DATA(insert OID = 1715 ( ceil PGUID 11 f t f 1 f 1700 "1700" 100 0 0 100 numeric_ceil - )); +DATA(insert OID = 1715 ( ceil PGUID 11 f t f 1 f 1700 "1700" 100 0 0 100 numeric_ceil - )); DESCR("smallest integer >= value"); -DATA(insert OID = 1716 ( numeric_floor PGUID 11 f t f 1 f 1700 "1700" 100 0 0 100 numeric_floor - )); +DATA(insert OID = 1716 ( numeric_floor PGUID 11 f t f 1 f 1700 "1700" 100 0 0 100 numeric_floor - )); DESCR("largest integer <= value"); -DATA(insert OID = 1717 ( floor PGUID 11 f t f 1 f 1700 "1700" 100 0 0 100 numeric_floor - )); +DATA(insert OID = 1717 ( floor PGUID 11 f t f 1 f 1700 "1700" 100 0 0 100 numeric_floor - )); DESCR("largest integer <= value"); DATA(insert OID = 1718 ( numeric_eq PGUID 11 f t f 2 f 16 "1700 1700" 100 0 0 100 numeric_eq - )); DESCR("equal"); @@ -2252,17 +2252,17 @@ DATA(insert OID = 1728 ( numeric_mod PGUID 11 f t f 2 f 1700 "1700 1700" 100 0 DESCR("modulus"); DATA(insert OID = 1729 ( mod PGUID 11 f t f 2 f 1700 "1700 1700" 100 0 0 100 numeric_mod - )); DESCR("modulus"); -DATA(insert OID = 1730 ( numeric_sqrt PGUID 11 f t f 1 f 1700 "1700" 100 0 0 100 numeric_sqrt - )); +DATA(insert OID = 1730 ( numeric_sqrt PGUID 11 f t f 1 f 1700 "1700" 100 0 0 100 numeric_sqrt - )); DESCR("square root"); -DATA(insert OID = 1731 ( sqrt PGUID 11 f t f 1 f 1700 "1700" 100 0 0 100 numeric_sqrt - )); +DATA(insert OID = 1731 ( sqrt PGUID 11 f t f 1 f 1700 "1700" 100 0 0 100 numeric_sqrt - )); DESCR("square root"); -DATA(insert OID = 1732 ( numeric_exp PGUID 11 f t f 1 f 1700 "1700" 100 0 0 100 numeric_exp - )); +DATA(insert OID = 1732 ( numeric_exp PGUID 11 f t f 1 f 1700 "1700" 100 0 0 100 numeric_exp - )); DESCR("e raised to the power of n"); -DATA(insert OID = 1733 ( exp PGUID 11 f t f 1 f 1700 "1700" 100 0 0 100 numeric_exp - )); +DATA(insert OID = 1733 ( exp PGUID 11 f t f 1 f 1700 "1700" 100 0 0 100 numeric_exp - )); DESCR("e raised to the power of n"); -DATA(insert OID = 1734 ( numeric_ln PGUID 11 f t f 1 f 1700 "1700" 100 0 0 100 numeric_ln - )); +DATA(insert OID = 1734 ( numeric_ln PGUID 11 f t f 1 f 1700 "1700" 100 0 0 100 numeric_ln - )); DESCR("natural logarithm of n"); -DATA(insert OID = 1735 ( ln PGUID 11 f t f 1 f 1700 "1700" 100 0 0 100 numeric_ln - )); +DATA(insert OID = 1735 ( ln PGUID 11 f t f 1 f 1700 "1700" 100 0 0 100 numeric_ln - )); DESCR("natural logarithm of n"); DATA(insert OID = 1736 ( numeric_log PGUID 11 f t f 2 f 1700 "1700 1700" 100 0 0 100 numeric_log - )); DESCR("logarithm base m of n"); @@ -2296,9 +2296,9 @@ DATA(insert OID = 1750 ( numeric_float8 PGUID 11 f t f 1 f 701 "1700" 100 0 0 DESCR("(internal)"); DATA(insert OID = 1751 ( float8 PGUID 11 f t f 1 f 701 "1700" 100 0 0 100 numeric_float8 - )); DESCR("(internal)"); -DATA(insert OID = 1764 ( numeric_inc PGUID 11 f t f 1 f 1700 "1700" 100 0 0 100 numeric_inc - )); +DATA(insert OID = 1764 ( numeric_inc PGUID 11 f t f 1 f 1700 "1700" 100 0 0 100 numeric_inc - )); DESCR("increment by one"); -DATA(insert OID = 1765 ( numeric_dec PGUID 11 f t f 1 f 1700 "1700" 100 0 0 100 numeric_dec - )); +DATA(insert OID = 1765 ( numeric_dec PGUID 11 f t f 1 f 1700 "1700" 100 0 0 100 numeric_dec - )); DESCR("decrement by one"); DATA(insert OID = 1766 ( numeric_smaller PGUID 11 f t f 2 f 1700 "1700 1700" 100 0 0 100 numeric_smaller - )); DESCR("smaller of two numbers"); diff --git a/src/include/catalog/pg_type.h b/src/include/catalog/pg_type.h index 06e3733f80..0bd12530c9 100644 --- a/src/include/catalog/pg_type.h +++ b/src/include/catalog/pg_type.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_type.h,v 1.61 1999/05/10 04:02:07 momjian Exp $ + * $Id: pg_type.h,v 1.62 1999/05/25 16:13:48 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -54,19 +54,20 @@ CATALOG(pg_type) BOOTSTRAP /* * typbyval determines whether internal Postgres routines pass a value * of this type by value or by reference. Only char, short, and int- - * equivalent items can be passed by value, so if the type is not - * 1, 2, or 4 bytes long, Postgres does not have the option of passing - * by value and so typbyval had better be FALSE. Variable-length types - * are always passed by reference. - * Note that typbyval can be false even if the length would allow - * pass-by-value; this is currently true for type float4, for example. + * equivalent items can be passed by value, so if the type is not 1, + * 2, or 4 bytes long, Postgres does not have the option of passing by + * value and so typbyval had better be FALSE. Variable-length types + * are always passed by reference. Note that typbyval can be false + * even if the length would allow pass-by-value; this is currently + * true for type float4, for example. */ char typtype; /* - * typtype is 'b' for a basic type and 'c' for a catalog type (ie a class). - * If typtype is 'c', typrelid is the OID of the class' entry in pg_class. - * (Why do we need an entry in pg_type for classes, anyway?) + * typtype is 'b' for a basic type and 'c' for a catalog type (ie a + * class). If typtype is 'c', typrelid is the OID of the class' entry + * in pg_class. (Why do we need an entry in pg_type for classes, + * anyway?) */ bool typisdefined; char typdelim; @@ -301,7 +302,7 @@ DESCR("money '$d,ddd.cc'"); DATA(insert OID = 791 ( _money PGUID -1 -1 f b t \054 0 790 array_in array_out array_in array_out i _null_ )); /* OIDS 800 - 899 */ -DATA(insert OID = 829 ( macaddr PGUID 6 -1 f b t \054 0 0 macaddr_in macaddr_out macaddr_in macaddr_out i _null_ )); +DATA(insert OID = 829 ( macaddr PGUID 6 -1 f b t \054 0 0 macaddr_in macaddr_out macaddr_in macaddr_out i _null_ )); DESCR("MAC address"); DATA(insert OID = 869 ( inet PGUID -1 -1 f b t \054 0 0 inet_in inet_out inet_in inet_out i _null_ )); DESCR("Host address"); @@ -344,7 +345,7 @@ DATA(insert OID = 1027 ( _polygon PGUID -1 -1 f b t \054 0 604 array_in array DATA(insert OID = 1033 ( aclitem PGUID 8 -1 f b t \054 0 0 aclitemin aclitemout aclitemin aclitemout i _null_ )); DESCR("access control list"); DATA(insert OID = 1034 ( _aclitem PGUID -1 -1 f b t \054 0 1033 array_in array_out array_in array_out i _null_ )); -DATA(insert OID = 1040 ( _macaddr PGUID -1 -1 f b t \054 0 829 array_in array_out array_in array_out i _null_ )); +DATA(insert OID = 1040 ( _macaddr PGUID -1 -1 f b t \054 0 829 array_in array_out array_in array_out i _null_ )); DATA(insert OID = 1041 ( _inet PGUID -1 -1 f b t \054 0 869 array_in array_out array_in array_out i _null_ )); DATA(insert OID = 651 ( _cidr PGUID -1 -1 f b t \054 0 650 array_in array_out array_in array_out i _null_ )); DATA(insert OID = 1042 ( bpchar PGUID -1 -1 f b t \054 0 18 bpcharin bpcharout bpcharin bpcharout i _null_ )); diff --git a/src/include/commands/command.h b/src/include/commands/command.h index 8929363aa2..68bdd93e15 100644 --- a/src/include/commands/command.h +++ b/src/include/commands/command.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: command.h,v 1.12 1999/02/13 23:21:18 momjian Exp $ + * $Id: command.h,v 1.13 1999/05/25 16:13:49 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -18,7 +18,7 @@ extern MemoryContext PortalExecutorHeapMemory; /* - * PerformPortalFetch + * PerformPortalFetch * Performs the POSTQUEL function FETCH. Fetches count (or all if 0) * tuples in portal with name in the forward direction iff goForward. * @@ -30,7 +30,7 @@ extern void PerformPortalFetch(char *name, bool forward, int count, char *tag, CommandDest dest); /* - * PerformPortalClose + * PerformPortalClose * Performs the POSTQUEL function CLOSE. */ extern void PerformPortalClose(char *name, CommandDest dest); @@ -38,12 +38,12 @@ extern void PerformPortalClose(char *name, CommandDest dest); extern void PortalCleanup(Portal portal); /* - * PerformAddAttribute + * PerformAddAttribute * Performs the POSTQUEL function ADD. */ extern void PerformAddAttribute(char *relationName, char *userName, bool inh, ColumnDef *colDef); -extern void LockTableCommand(LockStmt *lockstmt); +extern void LockTableCommand(LockStmt * lockstmt); #endif /* COMMAND_H */ diff --git a/src/include/commands/vacuum.h b/src/include/commands/vacuum.h index 3b76f3da35..8efe1ba386 100644 --- a/src/include/commands/vacuum.h +++ b/src/include/commands/vacuum.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: vacuum.h,v 1.18 1999/03/28 20:32:38 vadim Exp $ + * $Id: vacuum.h,v 1.19 1999/05/25 16:13:50 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -97,33 +97,33 @@ typedef VRelListData *VRelList; typedef struct VTupleLinkData { - ItemPointerData new_tid; - ItemPointerData this_tid; -} VTupleLinkData; + ItemPointerData new_tid; + ItemPointerData this_tid; +} VTupleLinkData; typedef VTupleLinkData *VTupleLink; typedef struct VTupleMoveData { - ItemPointerData tid; /* tuple ID */ - VPageDescr vpd; /* where to move */ - bool cleanVpd; /* clean vpd before using */ -} VTupleMoveData; + ItemPointerData tid; /* tuple ID */ + VPageDescr vpd; /* where to move */ + bool cleanVpd; /* clean vpd before using */ +} VTupleMoveData; typedef VTupleMoveData *VTupleMove; typedef struct VRelStats { - Oid relid; - int num_tuples; - int num_pages; - Size min_tlen; - Size max_tlen; - bool hasindex; - int va_natts; /* number of attrs being analyzed */ - VacAttrStats *vacattrstats; - int num_vtlinks; - VTupleLink vtlinks; + Oid relid; + int num_tuples; + int num_pages; + Size min_tlen; + Size max_tlen; + bool hasindex; + int va_natts; /* number of attrs being analyzed */ + VacAttrStats *vacattrstats; + int num_vtlinks; + VTupleLink vtlinks; } VRelStats; extern bool VacuumRunning; diff --git a/src/include/executor/executor.h b/src/include/executor/executor.h index 456bade979..d9bce44a03 100644 --- a/src/include/executor/executor.h +++ b/src/include/executor/executor.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: executor.h,v 1.32 1999/04/16 21:27:23 tgl Exp $ + * $Id: executor.h,v 1.33 1999/05/25 16:13:53 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -83,14 +83,16 @@ extern HeapTuple ExecRemoveJunk(JunkFilter *junkfilter, TupleTableSlot *slot); * prototypes from functions in execMain.c */ extern TupleDesc ExecutorStart(QueryDesc *queryDesc, EState *estate); -extern TupleTableSlot *ExecutorRun(QueryDesc *queryDesc, EState *estate, - int feature, Node *limoffset, Node *limcount); +extern TupleTableSlot *ExecutorRun(QueryDesc *queryDesc, EState *estate, + int feature, Node *limoffset, Node *limcount); extern void ExecutorEnd(QueryDesc *queryDesc, EState *estate); -extern void ExecConstraints(char *caller, Relation rel, HeapTuple tuple, - EState *estate); +extern void ExecConstraints(char *caller, Relation rel, HeapTuple tuple, + EState *estate); + #ifdef QUERY_LIMIT -extern int ExecutorLimit(int limit); -extern int ExecutorGetLimit(void); +extern int ExecutorLimit(int limit); +extern int ExecutorGetLimit(void); + #endif /* diff --git a/src/include/executor/hashjoin.h b/src/include/executor/hashjoin.h index 751b5efee1..493210ba01 100644 --- a/src/include/executor/hashjoin.h +++ b/src/include/executor/hashjoin.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: hashjoin.h,v 1.11 1999/05/18 21:33:04 tgl Exp $ + * $Id: hashjoin.h,v 1.12 1999/05/25 16:13:54 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -21,7 +21,7 @@ * hash-join hash table structures * * Each active hashjoin has a HashJoinTable control block which is - * palloc'd in the executor's context. All other storage needed for + * palloc'd in the executor's context. All other storage needed for * the hashjoin is kept in a private "named portal", one for each hashjoin. * This makes it easy and fast to release the storage when we don't need it * anymore. @@ -41,9 +41,10 @@ typedef struct HashJoinTupleData { - struct HashJoinTupleData *next; /* link to next tuple in same bucket */ - HeapTupleData htup; /* tuple header */ -} HashJoinTupleData; + struct HashJoinTupleData *next; /* link to next tuple in same + * bucket */ + HeapTupleData htup; /* tuple header */ +} HashJoinTupleData; typedef HashJoinTupleData *HashJoinTuple; @@ -51,40 +52,45 @@ typedef struct HashTableData { int nbuckets; /* buckets in use during this batch */ int totalbuckets; /* total number of (virtual) buckets */ - HashJoinTuple *buckets; /* buckets[i] is head of list of tuples */ + HashJoinTuple *buckets; /* buckets[i] is head of list of tuples */ /* buckets array is per-batch storage, as are all the tuples */ int nbatch; /* number of batches; 0 means 1-pass join */ int curbatch; /* current batch #, or 0 during 1st pass */ - /* all these arrays are allocated for the life of the hash join, - * but only if nbatch > 0: + /* + * all these arrays are allocated for the life of the hash join, but + * only if nbatch > 0: */ - BufFile **innerBatchFile; /* buffered virtual temp file per batch */ - BufFile **outerBatchFile; /* buffered virtual temp file per batch */ - long *outerBatchSize; /* count of tuples in each outer batch file */ - long *innerBatchSize; /* count of tuples in each inner batch file */ + BufFile **innerBatchFile; /* buffered virtual temp file per batch */ + BufFile **outerBatchFile; /* buffered virtual temp file per batch */ + long *outerBatchSize; /* count of tuples in each outer batch + * file */ + long *innerBatchSize; /* count of tuples in each inner batch + * file */ - /* During 1st scan of inner relation, we get tuples from executor. - * If nbatch > 0 then tuples that don't belong in first nbuckets logical - * buckets get dumped into inner-batch temp files. - * The same statements apply for the 1st scan of the outer relation, - * except we write tuples to outer-batch temp files. - * If nbatch > 0 then we do the following for each batch: - * 1. Read tuples from inner batch file, load into hash buckets. - * 2. Read tuples from outer batch file, match to hash buckets and output. + /* + * During 1st scan of inner relation, we get tuples from executor. If + * nbatch > 0 then tuples that don't belong in first nbuckets logical + * buckets get dumped into inner-batch temp files. The same statements + * apply for the 1st scan of the outer relation, except we write + * tuples to outer-batch temp files. If nbatch > 0 then we do the + * following for each batch: 1. Read tuples from inner batch file, + * load into hash buckets. 2. Read tuples from outer batch file, match + * to hash buckets and output. */ - /* Ugly kluge: myPortal ought to be declared as type Portal (ie, PortalD*) - * but if we try to include utils/portal.h here, we end up with a - * circular dependency of include files! Until the various node.h files - * are restructured in a cleaner way, we have to fake it. The most - * reliable fake seems to be to declare myPortal as void * and then - * cast it to the right things in nodeHash.c. + /* + * Ugly kluge: myPortal ought to be declared as type Portal (ie, + * PortalD*) but if we try to include utils/portal.h here, we end up + * with a circular dependency of include files! Until the various + * node.h files are restructured in a cleaner way, we have to fake it. + * The most reliable fake seems to be to declare myPortal as void * + * and then cast it to the right things in nodeHash.c. */ - void *myPortal; /* where to keep working storage */ - MemoryContext hashCxt; /* context for whole-hash-join storage */ - MemoryContext batchCxt; /* context for this-batch-only storage */ + void *myPortal; /* where to keep working storage */ + MemoryContext hashCxt; /* context for whole-hash-join storage */ + MemoryContext batchCxt; /* context for this-batch-only storage */ } HashTableData; typedef HashTableData *HashJoinTable; diff --git a/src/include/executor/nodeGroup.h b/src/include/executor/nodeGroup.h index 8239b865e1..5bc3c33679 100644 --- a/src/include/executor/nodeGroup.h +++ b/src/include/executor/nodeGroup.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: nodeGroup.h,v 1.9 1999/02/13 23:21:25 momjian Exp $ + * $Id: nodeGroup.h,v 1.10 1999/05/25 16:13:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -22,6 +22,7 @@ extern bool ExecInitGroup(Group *node, EState *estate, Plan *parent); extern int ExecCountSlotsGroup(Group *node); extern void ExecEndGroup(Group *node); extern void ExecReScanGroup(Group *node, ExprContext *exprCtxt, Plan *parent); + /***S*I***/ extern void ExecReScanGroup(Group *node, ExprContext *exprCtxt, Plan *parent); diff --git a/src/include/executor/nodeHash.h b/src/include/executor/nodeHash.h index 2e19824257..4544d6416e 100644 --- a/src/include/executor/nodeHash.h +++ b/src/include/executor/nodeHash.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: nodeHash.h,v 1.12 1999/05/18 21:33:05 tgl Exp $ + * $Id: nodeHash.h,v 1.13 1999/05/25 16:13:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -27,11 +27,11 @@ extern void ExecEndHash(Hash *node); extern HashJoinTable ExecHashTableCreate(Hash *node); extern void ExecHashTableDestroy(HashJoinTable hashtable); extern void ExecHashTableInsert(HashJoinTable hashtable, ExprContext *econtext, - Var *hashkey); + Var *hashkey); extern int ExecHashGetBucket(HashJoinTable hashtable, ExprContext *econtext, - Var *hashkey); + Var *hashkey); extern HeapTuple ExecScanHashBucket(HashJoinState *hjstate, List *hjclauses, - ExprContext *econtext); + ExprContext *econtext); extern void ExecHashTableReset(HashJoinTable hashtable, long ntuples); extern void ExecReScanHash(Hash *node, ExprContext *exprCtxt, Plan *parent); diff --git a/src/include/executor/nodeHashjoin.h b/src/include/executor/nodeHashjoin.h index 7b6c8a6e84..a6fff84b68 100644 --- a/src/include/executor/nodeHashjoin.h +++ b/src/include/executor/nodeHashjoin.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: nodeHashjoin.h,v 1.12 1999/05/18 21:33:05 tgl Exp $ + * $Id: nodeHashjoin.h,v 1.13 1999/05/25 16:13:56 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -21,7 +21,7 @@ extern TupleTableSlot *ExecHashJoin(HashJoin *node); extern bool ExecInitHashJoin(HashJoin *node, EState *estate, Plan *parent); extern int ExecCountSlotsHashJoin(HashJoin *node); extern void ExecEndHashJoin(HashJoin *node); -extern void ExecHashJoinSaveTuple(HeapTuple heapTuple, BufFile *file); +extern void ExecHashJoinSaveTuple(HeapTuple heapTuple, BufFile * file); extern void ExecReScanHashJoin(HashJoin *node, ExprContext *exprCtxt, Plan *parent); #endif /* NODEHASHJOIN_H */ diff --git a/src/include/executor/nodeNestloop.h b/src/include/executor/nodeNestloop.h index 82f9e79372..7a70189672 100644 --- a/src/include/executor/nodeNestloop.h +++ b/src/include/executor/nodeNestloop.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: nodeNestloop.h,v 1.9 1999/02/13 23:21:27 momjian Exp $ + * $Id: nodeNestloop.h,v 1.10 1999/05/25 16:13:56 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -22,6 +22,6 @@ extern bool ExecInitNestLoop(NestLoop *node, EState *estate, Plan *parent); extern int ExecCountSlotsNestLoop(NestLoop *node); extern void ExecEndNestLoop(NestLoop *node); extern void ExecReScanNestLoop(NestLoop *node, ExprContext *exprCtxt, - Plan *parent); + Plan *parent); #endif /* NODENESTLOOP_H */ diff --git a/src/include/executor/spi.h b/src/include/executor/spi.h index 104bf24aac..ea9bda89b8 100644 --- a/src/include/executor/spi.h +++ b/src/include/executor/spi.h @@ -68,12 +68,12 @@ typedef struct extern DLLIMPORT uint32 SPI_processed; extern DLLIMPORT SPITupleTable *SPI_tuptable; -extern DLLIMPORT int SPI_result; +extern DLLIMPORT int SPI_result; extern int SPI_connect(void); extern int SPI_finish(void); -extern void SPI_push(void); -extern void SPI_pop(void); +extern void SPI_push(void); +extern void SPI_pop(void); extern int SPI_exec(char *src, int tcount); extern int SPI_execp(void *plan, Datum *values, char *Nulls, int tcount); extern void *SPI_prepare(char *src, int nargs, Oid *argtypes); diff --git a/src/include/executor/spi_priv.h b/src/include/executor/spi_priv.h index ece8a5a1c7..2046dd45cb 100644 --- a/src/include/executor/spi_priv.h +++ b/src/include/executor/spi_priv.h @@ -3,7 +3,7 @@ * spi.c * Server Programming Interface private declarations * - * $Header: /cvsroot/pgsql/src/include/executor/spi_priv.h,v 1.3 1999/05/13 07:28:58 tgl Exp $ + * $Header: /cvsroot/pgsql/src/include/executor/spi_priv.h,v 1.4 1999/05/25 16:13:57 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -35,4 +35,4 @@ typedef struct #define _SPI_CPLAN_PROCXT 1 #define _SPI_CPLAN_TOPCXT 2 -#endif /* SPI_PRIV_H */ +#endif /* SPI_PRIV_H */ diff --git a/src/include/executor/tuptable.h b/src/include/executor/tuptable.h index 8ca01ef8e6..de582ba387 100644 --- a/src/include/executor/tuptable.h +++ b/src/include/executor/tuptable.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: tuptable.h,v 1.11 1999/02/23 07:36:31 thomas Exp $ + * $Id: tuptable.h,v 1.12 1999/05/25 16:13:58 momjian Exp $ * * NOTES * The tuple table interface is getting pretty ugly. @@ -51,13 +51,13 @@ */ typedef struct TupleTableSlot { - NodeTag type; - HeapTuple val; - bool ttc_shouldFree; - bool ttc_descIsNew; - TupleDesc ttc_tupleDescriptor; - Buffer ttc_buffer; - int ttc_whichplan; + NodeTag type; + HeapTuple val; + bool ttc_shouldFree; + bool ttc_descIsNew; + TupleDesc ttc_tupleDescriptor; + Buffer ttc_buffer; + int ttc_whichplan; } TupleTableSlot; /* ---------------- diff --git a/src/include/lib/fstack.h b/src/include/lib/fstack.h index bf2e051561..4432b4186d 100644 --- a/src/include/lib/fstack.h +++ b/src/include/lib/fstack.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: fstack.h,v 1.7 1999/02/13 23:21:30 momjian Exp $ + * $Id: fstack.h,v 1.8 1999/05/25 16:13:58 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -27,7 +27,7 @@ /* - * FixedItem + * FixedItem * Fixed format stackable item chain component. * * Note: @@ -43,7 +43,7 @@ struct FixedItemData }; /* - * FixedStack + * FixedStack * Fixed format stack. */ typedef struct FixedStackData @@ -56,7 +56,7 @@ typedef struct FixedStackData typedef FixedStackData *FixedStack; /* - * FixedStackInit + * FixedStackInit * Iniitializes stack for structures with given fixed component offset. * * Exceptions: @@ -65,7 +65,7 @@ typedef FixedStackData *FixedStack; extern void FixedStackInit(FixedStack stack, Offset offset); /* - * FixedStackPop + * FixedStackPop * Returns pointer to top structure on stack or NULL if empty stack. * * Exceptions: @@ -74,7 +74,7 @@ extern void FixedStackInit(FixedStack stack, Offset offset); Pointer FixedStackPop(FixedStack stack); /* - * FixedStackPush + * FixedStackPush * Places structure associated with pointer onto top of stack. * * Exceptions: @@ -84,7 +84,7 @@ Pointer FixedStackPop(FixedStack stack); extern void FixedStackPush(FixedStack stack, Pointer pointer); /* - * FixedStackGetTop + * FixedStackGetTop * Returns pointer to top structure of a stack. This item is not poped. * * Note: @@ -97,7 +97,7 @@ extern void FixedStackPush(FixedStack stack, Pointer pointer); extern Pointer FixedStackGetTop(FixedStack stack); /* - * FixedStackGetNext + * FixedStackGetNext * Returns pointer to next structure after pointer of a stack. * * Note: diff --git a/src/include/lib/stringinfo.h b/src/include/lib/stringinfo.h index 6b86fd6552..dbf901c67e 100644 --- a/src/include/lib/stringinfo.h +++ b/src/include/lib/stringinfo.h @@ -9,7 +9,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: stringinfo.h,v 1.11 1999/04/25 03:19:27 tgl Exp $ + * $Id: stringinfo.h,v 1.12 1999/05/25 16:13:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -55,7 +55,7 @@ typedef StringInfoData *StringInfo; * * NOTE: some routines build up a string using StringInfo, and then * release the StringInfoData but return the data string itself to their - * caller. At that point the data string looks like a plain palloc'd + * caller. At that point the data string looks like a plain palloc'd * string. *------------------------- */ @@ -82,7 +82,7 @@ extern void initStringInfo(StringInfo str); * CAUTION: the current implementation has a 1K limit on the amount of text * generated in a single call (not on the total string length). */ -extern void appendStringInfo(StringInfo str, const char *fmt, ...); +extern void appendStringInfo(StringInfo str, const char *fmt,...); /*------------------------ * appendStringInfoChar @@ -97,7 +97,7 @@ extern void appendStringInfoChar(StringInfo str, char ch); * if necessary. */ extern void appendBinaryStringInfo(StringInfo str, - const char *data, int datalen); + const char *data, int datalen); /*------------------------ * stringStringInfo diff --git a/src/include/libpq/libpq.h b/src/include/libpq/libpq.h index 873992739e..cd9f1ccde6 100644 --- a/src/include/libpq/libpq.h +++ b/src/include/libpq/libpq.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: libpq.h,v 1.28 1999/04/25 03:19:13 tgl Exp $ + * $Id: libpq.h,v 1.29 1999/05/25 16:14:00 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -22,7 +22,7 @@ /* ---------------- - * PQArgBlock + * PQArgBlock * Information (pointer to array of this structure) required * for the PQfn() call. * ---------------- @@ -39,7 +39,7 @@ typedef struct } PQArgBlock; /* ---------------- - * TypeBlock + * TypeBlock * Information about an attribute. * ---------------- */ @@ -53,7 +53,7 @@ typedef struct TypeBlock } TypeBlock; /* ---------------- - * TupleBlock + * TupleBlock * Data of a tuple. * ---------------- */ @@ -69,7 +69,7 @@ typedef struct TupleBlock } TupleBlock; /* ---------------- - * GroupBuffer + * GroupBuffer * A group of tuples with the same attributes. * ---------------- */ @@ -83,7 +83,7 @@ typedef struct GroupBuffer } GroupBuffer; /* ---------------- - * PortalBuffer + * PortalBuffer * Data structure of a portal buffer. * ---------------- */ @@ -96,7 +96,7 @@ typedef struct PortalBuffer } PortalBuffer; /* ---------------- - * PortalEntry + * PortalEntry * an entry in the global portal table * * Note: the portalcxt is only meaningful for PQcalls made from @@ -220,7 +220,7 @@ extern PortalEntry *be_newportal(void); extern void be_typeinit(PortalEntry *entry, TupleDesc attrs, int natts); extern void be_printtup(HeapTuple tuple, TupleDesc typeinfo, - DestReceiver* self); + DestReceiver * self); /* in be-pqexec.c */ @@ -246,7 +246,7 @@ extern int pq_peekbyte(void); extern int pq_putbytes(const char *s, size_t len); extern int pq_flush(void); extern int pq_putmessage(char msgtype, const char *s, size_t len); -extern void pq_startcopyout(void); -extern void pq_endcopyout(bool errorAbort); +extern void pq_startcopyout(void); +extern void pq_endcopyout(bool errorAbort); #endif /* LIBPQ_H */ diff --git a/src/include/libpq/pqformat.h b/src/include/libpq/pqformat.h index b546c36c5e..4daf7179cf 100644 --- a/src/include/libpq/pqformat.h +++ b/src/include/libpq/pqformat.h @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pqformat.h,v 1.3 1999/04/25 21:50:58 tgl Exp $ + * $Id: pqformat.h,v 1.4 1999/05/25 16:14:01 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -17,12 +17,12 @@ #define pq_beginmessage(buf) initStringInfo(buf) -extern void pq_sendbyte(StringInfo buf, int byt); -extern void pq_sendbytes(StringInfo buf, const char *data, int datalen); -extern void pq_sendcountedtext(StringInfo buf, const char *str, int slen); -extern void pq_sendstring(StringInfo buf, const char *str); -extern void pq_sendint(StringInfo buf, int i, int b); -extern void pq_endmessage(StringInfo buf); +extern void pq_sendbyte(StringInfo buf, int byt); +extern void pq_sendbytes(StringInfo buf, const char *data, int datalen); +extern void pq_sendcountedtext(StringInfo buf, const char *str, int slen); +extern void pq_sendstring(StringInfo buf, const char *str); +extern void pq_sendint(StringInfo buf, int i, int b); +extern void pq_endmessage(StringInfo buf); extern int pq_puttextmessage(char msgtype, const char *str); diff --git a/src/include/mb/pg_wchar.h b/src/include/mb/pg_wchar.h index 55e19a1a53..5e28b9a4f3 100644 --- a/src/include/mb/pg_wchar.h +++ b/src/include/mb/pg_wchar.h @@ -1,4 +1,4 @@ -/* $Id: pg_wchar.h,v 1.7 1999/03/24 06:53:28 ishii Exp $ */ +/* $Id: pg_wchar.h,v 1.8 1999/05/25 16:14:04 momjian Exp $ */ #ifndef PG_WCHAR_H #define PG_WCHAR_H @@ -61,7 +61,7 @@ typedef unsigned int pg_wchar; #define LC_ISO8859_5 0x8d /* ISO8859 Latin 5 */ #define LC_JISX0201K 0x89 /* Japanese 1 byte kana */ #define LC_JISX0201R 0x8a /* Japanese 1 byte Roman */ -#define LC_KOI8_R 0x8c /* Cyrillic KOI8-R */ +#define LC_KOI8_R 0x8c /* Cyrillic KOI8-R */ #define LC_GB2312_80 0x91 /* Chinese */ #define LC_JISX0208 0x92 /* Japanese Kanji */ #define LC_KS5601 0x93 /* Korean */ diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h index a77ae25e3c..9a1b8334d4 100644 --- a/src/include/miscadmin.h +++ b/src/include/miscadmin.h @@ -11,7 +11,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: miscadmin.h,v 1.38 1999/05/22 17:47:47 tgl Exp $ + * $Id: miscadmin.h,v 1.39 1999/05/25 16:13:23 momjian Exp $ * * NOTES * some of the information in this file will be moved to @@ -93,8 +93,8 @@ extern char CTZName[]; extern char FloatFormat[]; extern char DateFormat[]; -extern bool disableFsync; -extern bool allowSystemTableMods; +extern bool disableFsync; +extern bool allowSystemTableMods; extern int SortMem; extern Oid LastOidProcessed; /* for query rewrite */ diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h index cdc713eafe..134fa3e833 100644 --- a/src/include/nodes/execnodes.h +++ b/src/include/nodes/execnodes.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: execnodes.h,v 1.28 1999/05/18 21:34:26 tgl Exp $ + * $Id: execnodes.h,v 1.29 1999/05/25 16:14:07 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -194,28 +194,28 @@ typedef struct JunkFilter */ typedef struct EState { - NodeTag type; - ScanDirection es_direction; - Snapshot es_snapshot; - List *es_range_table; - RelationInfo *es_result_relation_info; - List **es_result_relation_constraints; - Relation es_into_relation_descriptor; - ParamListInfo es_param_list_info; - ParamExecData *es_param_exec_vals; /* this is for subselects */ - int es_BaseId; - TupleTable es_tupleTable; - JunkFilter *es_junkFilter; - int *es_refcount; - uint32 es_processed; /* # of tuples processed */ - Oid es_lastoid; /* last oid processed (by INSERT) */ - List *es_rowMark; /* not good place, but there is no other */ + NodeTag type; + ScanDirection es_direction; + Snapshot es_snapshot; + List *es_range_table; + RelationInfo *es_result_relation_info; + List **es_result_relation_constraints; + Relation es_into_relation_descriptor; + ParamListInfo es_param_list_info; + ParamExecData *es_param_exec_vals; /* this is for subselects */ + int es_BaseId; + TupleTable es_tupleTable; + JunkFilter *es_junkFilter; + int *es_refcount; + uint32 es_processed; /* # of tuples processed */ + Oid es_lastoid; /* last oid processed (by INSERT) */ + List *es_rowMark; /* not good place, but there is no other */ /* Below is to re-evaluate plan qual in READ COMMITTED mode */ - struct Plan *es_origPlan; - Pointer es_evalPlanQual; - bool *es_evTupleNull; - HeapTuple *es_evTuple; - bool es_useEvalPlan; + struct Plan *es_origPlan; + Pointer es_evalPlanQual; + bool *es_evTupleNull; + HeapTuple *es_evTuple; + bool es_useEvalPlan; } EState; /* ---------------- @@ -404,16 +404,16 @@ typedef struct CommonScanState */ typedef struct IndexScanState { - CommonState cstate; /* its first field is NodeTag */ - int iss_NumIndices; - int iss_IndexPtr; - int iss_MarkIndexPtr; - ScanKey *iss_ScanKeys; - int *iss_NumScanKeys; - Pointer iss_RuntimeKeyInfo; - RelationPtr iss_RelationDescs; - IndexScanDescPtr iss_ScanDescs; - HeapTupleData iss_htup; + CommonState cstate; /* its first field is NodeTag */ + int iss_NumIndices; + int iss_IndexPtr; + int iss_MarkIndexPtr; + ScanKey *iss_ScanKeys; + int *iss_NumScanKeys; + Pointer iss_RuntimeKeyInfo; + RelationPtr iss_RelationDescs; + IndexScanDescPtr iss_ScanDescs; + HeapTupleData iss_htup; } IndexScanState; @@ -517,10 +517,10 @@ typedef struct MergeJoinState typedef struct HashJoinState { JoinState jstate; /* its first field is NodeTag */ - HashJoinTable hj_HashTable; - int hj_CurBucketNo; - HashJoinTuple hj_CurTuple; - Var *hj_InnerHashKey; + HashJoinTable hj_HashTable; + int hj_CurBucketNo; + HashJoinTuple hj_CurTuple; + Var *hj_InnerHashKey; TupleTableSlot *hj_OuterTupleSlot; TupleTableSlot *hj_HashTupleSlot; } HashJoinState; @@ -689,16 +689,17 @@ typedef struct HashState */ typedef struct TeeState { - CommonState cstate; /* its first field is NodeTag */ - int tee_leftPlace, - tee_rightPlace, - tee_lastPlace; - char *tee_bufferRelname; - Relation tee_bufferRel; + CommonState cstate; /* its first field is NodeTag */ + int tee_leftPlace, + tee_rightPlace, + tee_lastPlace; + char *tee_bufferRelname; + Relation tee_bufferRel; MemoryContext tee_mcxt; - HeapScanDesc tee_leftScanDesc, - tee_rightScanDesc; + HeapScanDesc tee_leftScanDesc, + tee_rightScanDesc; } TeeState; + #endif #endif /* EXECNODES_H */ diff --git a/src/include/nodes/makefuncs.h b/src/include/nodes/makefuncs.h index 178afdff18..4cc34024a7 100644 --- a/src/include/nodes/makefuncs.h +++ b/src/include/nodes/makefuncs.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: makefuncs.h,v 1.17 1999/05/17 17:03:42 momjian Exp $ + * $Id: makefuncs.h,v 1.18 1999/05/25 16:14:08 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -18,35 +18,35 @@ #include extern Oper *makeOper(Oid opno, - Oid opid, - Oid opresulttype, - int opsize, - FunctionCachePtr op_fcache); + Oid opid, + Oid opresulttype, + int opsize, + FunctionCachePtr op_fcache); extern Var *makeVar(Index varno, - AttrNumber varattno, - Oid vartype, - int32 vartypmod, - Index varlevelsup, - Index varnoold, - AttrNumber varoattno); + AttrNumber varattno, + Oid vartype, + int32 vartypmod, + Index varlevelsup, + Index varnoold, + AttrNumber varoattno); extern TargetEntry *makeTargetEntry(Resdom *resdom, Node *expr); extern Resdom *makeResdom(AttrNumber resno, - Oid restype, - int32 restypmod, - char *resname, - Index reskey, - Oid reskeyop, - bool resjunk); + Oid restype, + int32 restypmod, + char *resname, + Index reskey, + Oid reskeyop, + bool resjunk); extern Const *makeConst(Oid consttype, - int constlen, - Datum constvalue, - bool constisnull, - bool constbyval, - bool constisset, - bool constiscast); + int constlen, + Datum constvalue, + bool constisnull, + bool constbyval, + bool constisset, + bool constiscast); #endif /* MAKEFUNC_H */ diff --git a/src/include/nodes/memnodes.h b/src/include/nodes/memnodes.h index a44e1fb31a..7259cb1b0f 100644 --- a/src/include/nodes/memnodes.h +++ b/src/include/nodes/memnodes.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: memnodes.h,v 1.11 1999/03/07 23:03:31 tgl Exp $ + * $Id: memnodes.h,v 1.12 1999/05/25 16:14:09 momjian Exp $ * * XXX the typedefs in this file are different from the other ???nodes.h; * they are pointers to structures instead of the structures themselves. @@ -23,7 +23,7 @@ #include /* - * MemoryContext + * MemoryContext * A logical context in which memory allocations occur. * * The types of memory contexts can be thought of as members of the @@ -95,7 +95,7 @@ typedef struct PortalHeapMemoryData } *PortalHeapMemory; /* - * MemoryContextIsValid + * MemoryContextIsValid * True iff memory context is valid. */ #define MemoryContextIsValid(context) \ diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h index fed516ccfb..441ffd9b01 100644 --- a/src/include/nodes/parsenodes.h +++ b/src/include/nodes/parsenodes.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: parsenodes.h,v 1.72 1999/05/12 15:02:04 wieck Exp $ + * $Id: parsenodes.h,v 1.73 1999/05/25 16:14:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -60,8 +60,8 @@ typedef struct Query * BY */ Node *havingQual; /* qualification of each group */ - /***S*I***/ - List *intersectClause; + /***S*I***/ + List *intersectClause; List *unionClause; /* unions are linked under the previous * query */ @@ -590,7 +590,7 @@ typedef struct LockStmt NodeTag type; char *relname; /* relation to lock */ int mode; /* lock mode */ -} LockStmt; +} LockStmt; /***************************************************************************** * Optimizable Statements @@ -614,7 +614,7 @@ typedef struct InsertStmt List *unionClause; /* union subselect parameters */ bool unionall; /* union without unique sort */ /***S*I***/ - List *intersectClause; + List *intersectClause; List *forUpdate; /* FOR UPDATE clause */ } InsertStmt; @@ -748,7 +748,7 @@ typedef struct CaseExpr Node *arg; /* implicit equality comparison argument */ List *args; /* the arguments (list of WHEN clauses) */ Node *defresult; /* the default result (ELSE clause) */ -} CaseExpr; +} CaseExpr; /* * CaseWhen - an argument to a CASE expression @@ -758,7 +758,7 @@ typedef struct CaseWhen NodeTag type; Node *expr; /* comparison expression */ Node *result; /* substitution result */ -} CaseWhen; +} CaseWhen; /* * ColumnDef - column definition (used in various creates) @@ -896,7 +896,7 @@ typedef struct JoinExpr RangeVar *larg; Node *rarg; List *quals; -} JoinExpr; +} JoinExpr; /**************************************************************************** @@ -964,14 +964,14 @@ typedef struct GroupClause Index tleGroupref; /* reference into targetlist */ } GroupClause; -#define ROW_MARK_FOR_UPDATE (1 << 0) -#define ROW_ACL_FOR_UPDATE (1 << 1) +#define ROW_MARK_FOR_UPDATE (1 << 0) +#define ROW_ACL_FOR_UPDATE (1 << 1) typedef struct RowMark { - NodeTag type; - Index rti; /* index in Query->rtable */ - bits8 info; /* as above */ -} RowMark; + NodeTag type; + Index rti; /* index in Query->rtable */ + bits8 info; /* as above */ +} RowMark; #endif /* PARSENODES_H */ diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h index 0805665b06..ffa45b0bfe 100644 --- a/src/include/nodes/plannodes.h +++ b/src/include/nodes/plannodes.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: plannodes.h,v 1.25 1999/05/18 21:34:26 tgl Exp $ + * $Id: plannodes.h,v 1.26 1999/05/25 16:14:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -264,7 +264,7 @@ typedef struct Noname Plan plan; Oid nonameid; int keycount; -} Noname; +} Noname; /* ---------------- * materialization node @@ -339,6 +339,7 @@ typedef struct Tee * Tee may be different than the parent * plans */ } Tee; + #endif /* --------------------- diff --git a/src/include/nodes/primnodes.h b/src/include/nodes/primnodes.h index d19673f635..8028e07a94 100644 --- a/src/include/nodes/primnodes.h +++ b/src/include/nodes/primnodes.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: primnodes.h,v 1.27 1999/05/17 17:03:44 momjian Exp $ + * $Id: primnodes.h,v 1.28 1999/05/25 16:14:11 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -273,7 +273,7 @@ typedef struct Aggref Node *target; int aggno; bool usenulls; -} Aggref; +} Aggref; /* ---------------- * SubLink diff --git a/src/include/nodes/relation.h b/src/include/nodes/relation.h index 2d47243c40..4f45a6cafc 100644 --- a/src/include/nodes/relation.h +++ b/src/include/nodes/relation.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: relation.h,v 1.30 1999/05/12 15:02:08 wieck Exp $ + * $Id: relation.h,v 1.31 1999/05/25 16:14:12 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -84,7 +84,7 @@ typedef struct RelOptInfo /* materialization information */ List *targetlist; List *pathlist; /* Path structures */ - struct Path *cheapestpath; + struct Path *cheapestpath; bool pruneable; /* used solely by indices: */ @@ -100,7 +100,7 @@ typedef struct RelOptInfo List *restrictinfo; /* RestrictInfo structures */ List *joininfo; /* JoinInfo structures */ List *innerjoin; -} RelOptInfo; +} RelOptInfo; extern Var *get_expr(TargetEntry *foo); extern Var *get_groupclause_expr(GroupClause *groupClause, List *targetList); @@ -129,7 +129,7 @@ typedef struct PathOrder { Oid *sortop; MergeOrder *merge; - } ord; + } ord; } PathOrder; typedef struct Path @@ -141,12 +141,12 @@ typedef struct Path NodeTag pathtype; - PathOrder *pathorder; + PathOrder *pathorder; - List *pathkeys; /* This is a List of List of Var nodes. - * See the top of optimizer/path/pathkeys.c - * for more information. - */ + List *pathkeys; /* This is a List of List of Var nodes. + * See the top of + * optimizer/path/pathkeys.c for more + * information. */ Cost outerjoincost; Relids joinid; List *loc_restrictinfo; @@ -157,7 +157,8 @@ typedef struct IndexPath Path path; List *indexid; List *indexqual; - int *indexkeys; /* to transform heap attnos into index ones */ + int *indexkeys; /* to transform heap attnos into index + * ones */ } IndexPath; typedef struct NestPath @@ -166,7 +167,7 @@ typedef struct NestPath List *pathinfo; Path *outerjoinpath; Path *innerjoinpath; -} NestPath; +} NestPath; typedef NestPath JoinPath; @@ -222,7 +223,7 @@ typedef struct RestrictInfo /* hashjoin only */ Oid hashjoinoperator; Relids restrictinfojoinid; -} RestrictInfo; +} RestrictInfo; typedef struct JoinMethod { @@ -235,13 +236,13 @@ typedef struct HashInfo { JoinMethod jmethod; Oid hashop; -} HashInfo; +} HashInfo; typedef struct MergeInfo { JoinMethod jmethod; MergeOrder *m_ordering; -} MergeInfo; +} MergeInfo; typedef struct JoinInfo { @@ -250,7 +251,7 @@ typedef struct JoinInfo List *jinfo_restrictinfo; bool mergejoinable; bool hashjoinable; -} JoinInfo; +} JoinInfo; typedef struct Iter { @@ -261,10 +262,10 @@ typedef struct Iter } Iter; /* - * Stream: + * Stream: * A stream represents a root-to-leaf path in a plan tree (i.e. a tree of * JoinPaths and Paths). The stream includes pointers to all Path nodes, - * as well as to any clauses that reside above Path nodes. This structure + * as well as to any clauses that reside above Path nodes. This structure * is used to make Path nodes and clauses look similar, so that Predicate * Migration can run. * diff --git a/src/include/optimizer/clauses.h b/src/include/optimizer/clauses.h index 6332729d45..5766e8933e 100644 --- a/src/include/optimizer/clauses.h +++ b/src/include/optimizer/clauses.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: clauses.h,v 1.16 1999/02/18 00:49:46 momjian Exp $ + * $Id: clauses.h,v 1.17 1999/05/25 16:14:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -38,7 +38,7 @@ extern Expr *make_andclause(List *andclauses); extern bool case_clause(Node *clause); extern List *pull_constant_clauses(List *quals, List **constantQual); -extern void clause_get_relids_vars(Node *clause, Relids *relids, List **vars); +extern void clause_get_relids_vars(Node *clause, Relids * relids, List **vars); extern int NumRelids(Node *clause); extern bool contains_not(Node *clause); extern bool is_joinable(Node *clause); diff --git a/src/include/optimizer/cost.h b/src/include/optimizer/cost.h index 2b752711a6..5146900e4d 100644 --- a/src/include/optimizer/cost.h +++ b/src/include/optimizer/cost.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: cost.h,v 1.18 1999/05/01 19:47:39 tgl Exp $ + * $Id: cost.h,v 1.19 1999/05/25 16:14:16 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -43,8 +43,8 @@ extern Cost cost_mergejoin(Cost outercost, Cost innercost, extern Cost cost_hashjoin(Cost outercost, Cost innercost, List *outerkeys, List *innerkeys, int outersize, int innersize, int outerwidth, int innerwidth); -extern int compute_rel_size(RelOptInfo *rel); -extern int compute_rel_width(RelOptInfo *rel); +extern int compute_rel_size(RelOptInfo * rel); +extern int compute_rel_width(RelOptInfo * rel); extern int compute_joinrel_size(JoinPath *joinpath); extern int page_size(int tuples, int width); diff --git a/src/include/optimizer/geqo.h b/src/include/optimizer/geqo.h index aba1d86096..c2eba47503 100644 --- a/src/include/optimizer/geqo.h +++ b/src/include/optimizer/geqo.h @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: geqo.h,v 1.14 1999/05/17 00:25:32 tgl Exp $ + * $Id: geqo.h,v 1.15 1999/05/25 16:14:16 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -57,10 +57,10 @@ /* should be 1.5 <= SELECTION_BIAS <= 2.0 */ /* parameter values set in geqo_params.c */ -extern int PoolSize; -extern int Generations; -extern long RandomSeed; -extern double SelectionBias; +extern int PoolSize; +extern int Generations; +extern long RandomSeed; +extern double SelectionBias; /* routines in geqo_main.c */ extern RelOptInfo *geqo(Query *root); @@ -72,6 +72,6 @@ extern void geqo_params(int string_length); extern void geqo_eval_startup(void); extern Cost geqo_eval(Query *root, Gene *tour, int num_gene); extern RelOptInfo *gimme_tree(Query *root, Gene *tour, int rel_count, - int num_gene, RelOptInfo *old_rel); + int num_gene, RelOptInfo * old_rel); #endif /* GEQO_H */ diff --git a/src/include/optimizer/geqo_misc.h b/src/include/optimizer/geqo_misc.h index 2039703b60..1e610ba8d0 100644 --- a/src/include/optimizer/geqo_misc.h +++ b/src/include/optimizer/geqo_misc.h @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: geqo_misc.h,v 1.9 1999/02/13 23:21:46 momjian Exp $ + * $Id: geqo_misc.h,v 1.10 1999/05/25 16:14:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -31,7 +31,7 @@ extern void print_pool(FILE *fp, Pool *pool, int start, int stop); extern void print_gen(FILE *fp, Pool *pool, int generation); extern void print_edge_table(FILE *fp, Edge *edge_table, int num_gene); -extern void geqo_print_rel(Query *root, RelOptInfo *rel); +extern void geqo_print_rel(Query *root, RelOptInfo * rel); extern void geqo_print_path(Query *root, Path *path, int indent); extern void geqo_print_joinclauses(Query *root, List *clauses); diff --git a/src/include/optimizer/internal.h b/src/include/optimizer/internal.h index 0241a3f98f..51e15d2507 100644 --- a/src/include/optimizer/internal.h +++ b/src/include/optimizer/internal.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: internal.h,v 1.19 1999/05/16 19:45:36 tgl Exp $ + * $Id: internal.h,v 1.20 1999/05/25 16:14:18 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -27,7 +27,7 @@ * System-dependent tuning constants * */ -#define _CPU_PAGE_WEIGHT_ 0.033 /* CPU-heap-to-page cost weighting factor */ +#define _CPU_PAGE_WEIGHT_ 0.033/* CPU-heap-to-page cost weighting factor */ #define _CPU_INDEX_PAGE_WEIGHT_ 0.017 /* CPU-index-to-page cost * weighting factor */ #define _MAX_KEYS_ INDEX_MAX_KEYS /* maximum number of keys in an diff --git a/src/include/optimizer/joininfo.h b/src/include/optimizer/joininfo.h index a38af83c5c..2b4e214e24 100644 --- a/src/include/optimizer/joininfo.h +++ b/src/include/optimizer/joininfo.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: joininfo.h,v 1.10 1999/02/13 23:21:49 momjian Exp $ + * $Id: joininfo.h,v 1.11 1999/05/25 16:14:19 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -18,7 +18,7 @@ #include "nodes/primnodes.h" extern JoinInfo *joininfo_member(List *join_relids, List *joininfo_list); -extern JoinInfo *find_joininfo_node(RelOptInfo *this_rel, List *join_relids); +extern JoinInfo *find_joininfo_node(RelOptInfo * this_rel, List *join_relids); extern Var *other_join_clause_var(Var *var, Expr *clause); #endif /* JOININFO_H */ diff --git a/src/include/optimizer/keys.h b/src/include/optimizer/keys.h index fad0117c3a..cccdb7bfbb 100644 --- a/src/include/optimizer/keys.h +++ b/src/include/optimizer/keys.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: keys.h,v 1.13 1999/02/19 02:05:18 momjian Exp $ + * $Id: keys.h,v 1.14 1999/05/25 16:14:19 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -16,7 +16,7 @@ #include "nodes/nodes.h" #include "nodes/relation.h" -extern bool match_indexkey_operand(int indexkey, Var *operand, RelOptInfo *rel); +extern bool match_indexkey_operand(int indexkey, Var *operand, RelOptInfo * rel); extern Var *extract_join_key(JoinKey *jk, int outer_or_inner); extern bool pathkeys_match(List *keys1, List *keys2, int *better_key); extern List *collect_index_pathkeys(int *index_keys, List *tlist); diff --git a/src/include/optimizer/ordering.h b/src/include/optimizer/ordering.h index 1b642127e4..30b262b9e3 100644 --- a/src/include/optimizer/ordering.h +++ b/src/include/optimizer/ordering.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: ordering.h,v 1.13 1999/02/13 23:21:49 momjian Exp $ + * $Id: ordering.h,v 1.14 1999/05/25 16:14:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -16,10 +16,10 @@ #include extern bool pathorder_match(PathOrder *path_ordering1, - PathOrder *path_ordering2, int *better_sort); + PathOrder *path_ordering2, int *better_sort); extern bool equal_path_merge_ordering(Oid *path_ordering, MergeOrder *merge_ordering); extern bool equal_merge_ordering(MergeOrder *merge_ordering1, - MergeOrder *merge_ordering2); + MergeOrder *merge_ordering2); #endif /* ORDERING_H */ diff --git a/src/include/optimizer/pathnode.h b/src/include/optimizer/pathnode.h index 1a52453d0d..2a864d591a 100644 --- a/src/include/optimizer/pathnode.h +++ b/src/include/optimizer/pathnode.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pathnode.h,v 1.15 1999/02/18 00:49:46 momjian Exp $ + * $Id: pathnode.h,v 1.16 1999/05/25 16:14:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -21,22 +21,22 @@ * prototypes for pathnode.c */ extern bool path_is_cheaper(Path *path1, Path *path2); -extern Path *set_cheapest(RelOptInfo *parent_rel, List *pathlist); -extern List *add_pathlist(RelOptInfo *parent_rel, List *unique_paths, +extern Path *set_cheapest(RelOptInfo * parent_rel, List *pathlist); +extern List *add_pathlist(RelOptInfo * parent_rel, List *unique_paths, List *new_paths); -extern Path *create_seqscan_path(RelOptInfo *rel); -extern IndexPath *create_index_path(Query *root, RelOptInfo *rel, RelOptInfo *index, +extern Path *create_seqscan_path(RelOptInfo * rel); +extern IndexPath *create_index_path(Query *root, RelOptInfo * rel, RelOptInfo * index, List *restriction_clauses, bool is_join_scan); -extern NestPath *create_nestloop_path(RelOptInfo *joinrel, RelOptInfo *outer_rel, +extern NestPath *create_nestloop_path(RelOptInfo * joinrel, RelOptInfo * outer_rel, Path *outer_path, Path *inner_path, List *pathkeys); -extern MergePath *create_mergejoin_path(RelOptInfo *joinrel, int outersize, +extern MergePath *create_mergejoin_path(RelOptInfo * joinrel, int outersize, int innersize, int outerwidth, int innerwidth, Path *outer_path, Path *inner_path, List *pathkeys, MergeOrder *order, List *mergeclauses, List *outersortkeys, List *innersortkeys); -extern HashPath *create_hashjoin_path(RelOptInfo *joinrel, int outersize, +extern HashPath *create_hashjoin_path(RelOptInfo * joinrel, int outersize, int innersize, int outerwidth, int innerwidth, Path *outer_path, - Path *inner_path, List *pathkeys, Oid operator, List *hashclauses, + Path *inner_path, List *pathkeys, Oid operator, List *hashclauses, List *outerkeys, List *innerkeys); /* @@ -49,6 +49,6 @@ extern RelOptInfo *get_join_rel(Query *root, Relids relid); /* * prototypes for indexnode.h */ -extern List *find_relation_indices(Query *root, RelOptInfo *rel); +extern List *find_relation_indices(Query *root, RelOptInfo * rel); #endif /* PATHNODE_H */ diff --git a/src/include/optimizer/paths.h b/src/include/optimizer/paths.h index 603efd7e52..1a92130e86 100644 --- a/src/include/optimizer/paths.h +++ b/src/include/optimizer/paths.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: paths.h,v 1.27 1999/04/03 00:18:26 tgl Exp $ + * $Id: paths.h,v 1.28 1999/05/25 16:14:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -27,9 +27,9 @@ extern RelOptInfo *make_one_rel(Query *root, List *rels); * indxpath.h * routines to generate index paths */ -extern List *create_index_paths(Query *root, RelOptInfo *rel, List *indices, - List *restrictinfo_list, - List *joininfo_list); +extern List *create_index_paths(Query *root, RelOptInfo * rel, List *indices, + List *restrictinfo_list, + List *joininfo_list); /* * joinpath.h @@ -41,27 +41,27 @@ extern void update_rels_pathlist_for_joins(Query *root, List *joinrels); /* * orindxpath.h */ -extern List *create_or_index_paths(Query *root, RelOptInfo *rel, List *clauses); +extern List *create_or_index_paths(Query *root, RelOptInfo * rel, List *clauses); /* * hashutils.h * routines to deal with hash keys and clauses */ extern List *group_clauses_by_hashop(List *restrictinfo_list, - Relids inner_relids); + Relids inner_relids); /* * joinutils.h * generic join method key/clause routines */ extern bool order_joinkeys_by_pathkeys(List *pathkeys, - List *joinkeys, List *joinclauses, int outer_or_inner, - List **matchedJoinKeysPtr, - List **matchedJoinClausesPtr); + List *joinkeys, List *joinclauses, int outer_or_inner, + List **matchedJoinKeysPtr, + List **matchedJoinClausesPtr); extern List *make_pathkeys_from_joinkeys(List *joinkeys, List *tlist, - int outer_or_inner); + int outer_or_inner); extern Path *get_cheapest_path_for_joinkeys(List *joinkeys, - PathOrder *ordering, List *paths, int outer_or_inner); + PathOrder *ordering, List *paths, int outer_or_inner); extern List *new_join_pathkeys(List *outer_pathkeys, List *join_rel_tlist, List *joinclauses); @@ -70,20 +70,20 @@ extern List *new_join_pathkeys(List *outer_pathkeys, * routines to deal with merge keys and clauses */ extern List *group_clauses_by_order(List *restrictinfo_list, - Relids inner_relids); + Relids inner_relids); extern MergeInfo *match_order_mergeinfo(PathOrder *ordering, - List *mergeinfo_list); + List *mergeinfo_list); /* * joinrels.h * routines to determine which relations to join */ extern List *make_rels_by_joins(Query *root, List *old_rels); -extern List *make_rels_by_clause_joins(Query *root, RelOptInfo *old_rel, - List *joininfo_list, Relids only_relids); -extern List *make_rels_by_clauseless_joins(RelOptInfo *old_rel, - List *inner_rels); -extern RelOptInfo *make_join_rel(RelOptInfo *outer_rel, RelOptInfo *inner_rel, JoinInfo *joininfo); +extern List *make_rels_by_clause_joins(Query *root, RelOptInfo * old_rel, + List *joininfo_list, Relids only_relids); +extern List *make_rels_by_clauseless_joins(RelOptInfo * old_rel, + List *inner_rels); +extern RelOptInfo *make_join_rel(RelOptInfo * outer_rel, RelOptInfo * inner_rel, JoinInfo * joininfo); extern List *new_join_tlist(List *tlist, int first_resdomno); extern RelOptInfo *get_cheapest_complete_rel(List *join_rel_list); diff --git a/src/include/optimizer/planmain.h b/src/include/optimizer/planmain.h index e3848330db..71c11b7b87 100644 --- a/src/include/optimizer/planmain.h +++ b/src/include/optimizer/planmain.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: planmain.h,v 1.25 1999/05/12 15:02:22 wieck Exp $ + * $Id: planmain.h,v 1.26 1999/05/25 16:14:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -51,20 +51,20 @@ extern void add_missing_vars_to_tlist(Query *root, List *tlist); */ extern void set_tlist_references(Plan *plan); extern List *join_references(List *clauses, List *outer_tlist, - List *inner_tlist); + List *inner_tlist); extern List *index_outerjoin_references(List *inner_indxqual, List *outer_tlist, Index inner_relid); extern void replace_tlist_with_subplan_refs(List *tlist, - Index subvarno, - List *subplanTargetList); + Index subvarno, + List *subplanTargetList); extern void replace_vars_with_subplan_refs(Node *clause, - Index subvarno, - List *subplanTargetList); + Index subvarno, + List *subplanTargetList); extern bool set_agg_tlist_references(Agg *aggNode); extern void del_agg_tlist_references(List *tlist); extern void check_having_for_ungrouped_vars(Node *clause, - List *groupClause, - List *targetList); + List *groupClause, + List *targetList); extern void transformKeySetQuery(Query *origNode); #endif /* PLANMAIN_H */ diff --git a/src/include/optimizer/restrictinfo.h b/src/include/optimizer/restrictinfo.h index 88cedc3f68..9b1346c31d 100644 --- a/src/include/optimizer/restrictinfo.h +++ b/src/include/optimizer/restrictinfo.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: restrictinfo.h,v 1.2 1999/02/13 23:21:52 momjian Exp $ + * $Id: restrictinfo.h,v 1.3 1999/05/25 16:14:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -16,7 +16,7 @@ #include "nodes/pg_list.h" #include "nodes/relation.h" -extern bool valid_or_clause(RestrictInfo *restrictinfo); +extern bool valid_or_clause(RestrictInfo * restrictinfo); extern List *get_actual_clauses(List *restrictinfo_list); extern void get_relattvals(List *restrictinfo_list, List **attnos, List **values, List **flags); diff --git a/src/include/optimizer/tlist.h b/src/include/optimizer/tlist.h index 9066478183..b4d3d21256 100644 --- a/src/include/optimizer/tlist.h +++ b/src/include/optimizer/tlist.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: tlist.h,v 1.16 1999/02/15 05:56:07 momjian Exp $ + * $Id: tlist.h,v 1.17 1999/05/25 16:14:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -19,7 +19,7 @@ extern TargetEntry *tlistentry_member(Var *var, List *targetlist); extern Expr *matching_tlist_var(Var *var, List *targetlist); -extern void add_var_to_tlist(RelOptInfo *rel, Var *var); +extern void add_var_to_tlist(RelOptInfo * rel, Var *var); extern TargetEntry *create_tl_element(Var *var, int resdomno); extern List *get_actual_tlist(List *tlist); extern Resdom *tlist_member(Var *var, List *tlist); diff --git a/src/include/optimizer/xfunc.h b/src/include/optimizer/xfunc.h index e96c547481..7c5082746c 100644 --- a/src/include/optimizer/xfunc.h +++ b/src/include/optimizer/xfunc.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: xfunc.h,v 1.16 1999/02/18 00:49:48 momjian Exp $ + * $Id: xfunc.h,v 1.17 1999/05/25 16:14:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -49,10 +49,10 @@ extern int XfuncMode; /* defined in tcop/postgres.c */ #define is_join(pathnode) (length(get_relids(get_parent(pathnode))) > 1 ? 1 : 0) /* function prototypes from planner/path/xfunc.c */ -extern void xfunc_trypullup(RelOptInfo *rel); +extern void xfunc_trypullup(RelOptInfo * rel); extern int xfunc_shouldpull(Path *childpath, JoinPath *parentpath, - int whichchild, RestrictInfo *maxcinfopt); -extern RestrictInfo *xfunc_pullup(Path *childpath, JoinPath *parentpath, RestrictInfo *cinfo, + int whichchild, RestrictInfo * maxcinfopt); +extern RestrictInfo *xfunc_pullup(Path *childpath, JoinPath *parentpath, RestrictInfo * cinfo, int whichchild, int clausetype); extern Cost xfunc_rank(Expr *clause); extern Cost xfunc_expense(Query *queryInfo, Expr *clause); @@ -69,7 +69,7 @@ extern List *xfunc_primary_join(JoinPath *pathnode); extern Cost xfunc_get_path_cost(Path *pathnode); extern Cost xfunc_total_path_cost(JoinPath *pathnode); extern Cost xfunc_expense_per_tuple(JoinPath *joinnode, int whichchild); -extern void xfunc_fixvars(Expr *clause, RelOptInfo *rel, int varno); +extern void xfunc_fixvars(Expr *clause, RelOptInfo * rel, int varno); extern int xfunc_cinfo_compare(void *arg1, void *arg2); extern int xfunc_clause_compare(void *arg1, void *arg2); extern void xfunc_disjunct_sort(List *clause_list); @@ -78,7 +78,7 @@ extern int xfunc_func_width(RegProcedure funcid, List *args); extern int xfunc_tuple_width(Relation rd); extern int xfunc_num_join_clauses(JoinPath *path); extern List *xfunc_LispRemove(List *foo, List *bar); -extern bool xfunc_copyrel(RelOptInfo *from, RelOptInfo ** to); +extern bool xfunc_copyrel(RelOptInfo * from, RelOptInfo ** to); /* * function prototypes for path/predmig.c diff --git a/src/include/parser/analyze.h b/src/include/parser/analyze.h index af775c84f8..74f48ef431 100644 --- a/src/include/parser/analyze.h +++ b/src/include/parser/analyze.h @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: analyze.h,v 1.6 1999/05/13 07:29:17 tgl Exp $ + * $Id: analyze.h,v 1.7 1999/05/25 16:14:24 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -15,6 +15,7 @@ #include extern List *parse_analyze(List *pl, ParseState *parentParseState); + /***S*I***/ extern void create_select_list(Node *ptr, List **select_list, bool *unionall_present); extern Node *A_Expr_to_Expr(Node *ptr, bool *intersect_present); diff --git a/src/include/parser/parse_agg.h b/src/include/parser/parse_agg.h index e68e5ac735..125b110977 100644 --- a/src/include/parser/parse_agg.h +++ b/src/include/parser/parse_agg.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: parse_agg.h,v 1.8 1999/01/24 00:28:37 momjian Exp $ + * $Id: parse_agg.h,v 1.9 1999/05/25 16:14:26 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -18,7 +18,7 @@ #include #include -extern void AddAggToParseState(ParseState *pstate, Aggref *aggref); +extern void AddAggToParseState(ParseState *pstate, Aggref * aggref); extern void parseCheckAggregates(ParseState *pstate, Query *qry); extern Aggref *ParseAgg(ParseState *pstate, char *aggname, Oid basetype, List *target, int precedence); diff --git a/src/include/parser/parse_coerce.h b/src/include/parser/parse_coerce.h index d8cc6b7697..2a664ed8c1 100644 --- a/src/include/parser/parse_coerce.h +++ b/src/include/parser/parse_coerce.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: parse_coerce.h,v 1.10 1999/05/22 04:12:29 momjian Exp $ + * $Id: parse_coerce.h,v 1.11 1999/05/25 16:14:26 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -67,8 +67,8 @@ typedef enum CATEGORY * This allows us to cheat and directly exchange values without * going through the trouble of calling a conversion function. * Remove equivalencing of FLOAT8 and DATETIME. They really are not - * close enough in behavior, with the DATETIME reserved values - * and special formatting. - thomas 1999-01-24 + * close enough in behavior, with the DATETIME reserved values + * and special formatting. - thomas 1999-01-24 */ #define IS_BINARY_COMPATIBLE(a,b) \ (((a) == BPCHAROID && (b) == TEXTOID) \ @@ -122,6 +122,6 @@ extern CATEGORY TypeCategory(Oid type); extern bool can_coerce_type(int nargs, Oid *input_typeids, Oid *func_typeids); extern Node *coerce_type(ParseState *pstate, Node *node, Oid inputTypeId, - Oid targetTypeId, int32 atttypmod); + Oid targetTypeId, int32 atttypmod); #endif /* PARSE_COERCE_H */ diff --git a/src/include/parser/parse_func.h b/src/include/parser/parse_func.h index e21c2e6c06..b83929358c 100644 --- a/src/include/parser/parse_func.h +++ b/src/include/parser/parse_func.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: parse_func.h,v 1.14 1999/02/13 23:21:57 momjian Exp $ + * $Id: parse_func.h,v 1.15 1999/05/25 16:14:27 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -42,14 +42,12 @@ typedef struct _CandidateList struct _CandidateList *next; } *CandidateList; -extern Node * -ParseNestedFuncOrColumn(ParseState *pstate, Attr *attr, +extern Node *ParseNestedFuncOrColumn(ParseState *pstate, Attr *attr, int *curr_resno, int precedence); -extern Node * -ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs, +extern Node *ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs, int *curr_resno, int precedence); extern void -func_error(char *caller, char *funcname, int nargs, Oid *argtypes, char *msg); + func_error(char *caller, char *funcname, int nargs, Oid *argtypes, char *msg); #endif /* PARSE_FUNC_H */ diff --git a/src/include/port/bsd.h b/src/include/port/bsd.h index f24f4f83b5..68858e5ff1 100644 --- a/src/include/port/bsd.h +++ b/src/include/port/bsd.h @@ -31,10 +31,12 @@ #if defined(__powerpc__) #define HAS_TEST_AND_SET typedef unsigned int slock_t; + #endif #if defined(__mips__) /* # undef HAS_TEST_AND_SET */ #endif #if !defined(__powerpc__) typedef unsigned char slock_t; + #endif diff --git a/src/include/port/svr4.h b/src/include/port/svr4.h index 4d76f28da7..a460c825c6 100644 --- a/src/include/port/svr4.h +++ b/src/include/port/svr4.h @@ -13,4 +13,5 @@ #include typedef abilock_t slock_t; + #endif diff --git a/src/include/port/win.h b/src/include/port/win.h index b82984e1e3..15a89a0e43 100644 --- a/src/include/port/win.h +++ b/src/include/port/win.h @@ -6,6 +6,6 @@ typedef unsigned char slock_t; #define O_DIROPEN 0x100000 /* should be in sys/fcntl.h */ #endif -#define tzname _tzname /* should be in time.h?*/ +#define tzname _tzname /* should be in time.h? */ #define USE_POSIX_TIME -#define HAVE_INT_TIMEZONE /* has int _timezone */ +#define HAVE_INT_TIMEZONE /* has int _timezone */ diff --git a/src/include/rewrite/rewriteHandler.h b/src/include/rewrite/rewriteHandler.h index dfa4cc5711..be2feae6ca 100644 --- a/src/include/rewrite/rewriteHandler.h +++ b/src/include/rewrite/rewriteHandler.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: rewriteHandler.h,v 1.8 1999/02/13 23:22:00 momjian Exp $ + * $Id: rewriteHandler.h,v 1.9 1999/05/25 16:14:34 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -34,9 +34,11 @@ typedef struct _rewrite_meta_knowledge RewriteInfo; extern List *QueryRewrite(Query *parsetree); + /***S*I***/ extern Query *Except_Intersect_Rewrite(Query *parsetree); extern void create_list(Node *ptr, List **intersect_list); extern Node *intersect_tree_analyze(Node *tree, Node *first_select, Node *parsetree); extern void check_targetlists_are_compatible(List *prev_target, List *current_target); + #endif /* REWRITEHANDLER_H */ diff --git a/src/include/rewrite/rewriteManip.h b/src/include/rewrite/rewriteManip.h index e41a226708..c258bb1103 100644 --- a/src/include/rewrite/rewriteManip.h +++ b/src/include/rewrite/rewriteManip.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: rewriteManip.h,v 1.14 1999/05/12 15:02:28 wieck Exp $ + * $Id: rewriteManip.h,v 1.15 1999/05/25 16:14:35 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -25,7 +25,7 @@ void AddQual(Query *parsetree, Node *qual); void AddHavingQual(Query *parsetree, Node *havingQual); void AddNotQual(Query *parsetree, Node *qual); -void AddNotHavingQual(Query *parsetree, Node *havingQual); +void AddNotHavingQual(Query *parsetree, Node *havingQual); void AddGroupClause(Query *parsetree, List *group_by, List *tlist); void FixNew(RewriteInfo *info, Query *parsetree); diff --git a/src/include/storage/block.h b/src/include/storage/block.h index ac0df00de5..a2650c82a4 100644 --- a/src/include/storage/block.h +++ b/src/include/storage/block.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: block.h,v 1.8 1999/02/13 23:22:02 momjian Exp $ + * $Id: block.h,v 1.9 1999/05/25 16:14:36 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -61,21 +61,21 @@ typedef BlockIdData *BlockId; /* block identifier */ */ /* - * BlockNumberIsValid + * BlockNumberIsValid * True iff blockNumber is valid. */ #define BlockNumberIsValid(blockNumber) \ ((bool) ((int32) (blockNumber) != InvalidBlockNumber)) /* - * BlockIdIsValid + * BlockIdIsValid * True iff the block identifier is valid. */ #define BlockIdIsValid(blockId) \ ((bool) PointerIsValid(blockId)) /* - * BlockIdSet + * BlockIdSet * Sets a block identifier to the specified value. */ #define BlockIdSet(blockId, blockNumber) \ @@ -86,7 +86,7 @@ typedef BlockIdData *BlockId; /* block identifier */ ) /* - * BlockIdCopy + * BlockIdCopy * Copy a block identifier. */ #define BlockIdCopy(toBlockId, fromBlockId) \ @@ -98,7 +98,7 @@ typedef BlockIdData *BlockId; /* block identifier */ ) /* - * BlockIdEquals + * BlockIdEquals * Check for block number equality. */ #define BlockIdEquals(blockId1, blockId2) \ @@ -106,7 +106,7 @@ typedef BlockIdData *BlockId; /* block identifier */ (blockId1)->bi_lo == (blockId2)->bi_lo) /* - * BlockIdGetBlockNumber + * BlockIdGetBlockNumber * Retrieve the block number from a block identifier. */ #define BlockIdGetBlockNumber(blockId) \ diff --git a/src/include/storage/buf.h b/src/include/storage/buf.h index a38ee2315e..0ce0edb907 100644 --- a/src/include/storage/buf.h +++ b/src/include/storage/buf.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: buf.h,v 1.5 1999/02/13 23:22:03 momjian Exp $ + * $Id: buf.h,v 1.6 1999/05/25 16:14:38 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -19,19 +19,19 @@ typedef long Buffer; /* - * BufferIsInvalid + * BufferIsInvalid * True iff the buffer is invalid. */ #define BufferIsInvalid(buffer) ((buffer) == InvalidBuffer) /* - * BufferIsUnknown + * BufferIsUnknown * True iff the buffer is unknown. */ #define BufferIsUnknown(buffer) ((buffer) == UnknownBuffer) /* - * BufferIsLocal + * BufferIsLocal * True iff the buffer is local (not visible to other servers). */ #define BufferIsLocal(buffer) ((buffer) < 0) diff --git a/src/include/storage/buf_internals.h b/src/include/storage/buf_internals.h index ed625f525c..7d257e33e6 100644 --- a/src/include/storage/buf_internals.h +++ b/src/include/storage/buf_internals.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: buf_internals.h,v 1.28 1999/02/13 23:22:03 momjian Exp $ + * $Id: buf_internals.h,v 1.29 1999/05/25 16:14:38 momjian Exp $ * * NOTE * If BUFFERPAGE0 is defined, then 0 will be used as a @@ -106,17 +106,17 @@ struct sbufdesc bool w_lock; /* context exclusively locked */ char sb_dbname[NAMEDATALEN]; /* name of db in which buf belongs */ - char sb_relname[NAMEDATALEN];/* name of reln */ + char sb_relname[NAMEDATALEN]; /* name of reln */ }; /* * Buffer lock infos in BufferLocks below. * We have to free these locks in elog(ERROR)... */ -#define BL_IO_IN_PROGRESS (1 << 0) /* unimplemented */ -#define BL_R_LOCK (1 << 1) -#define BL_RI_LOCK (1 << 2) -#define BL_W_LOCK (1 << 3) +#define BL_IO_IN_PROGRESS (1 << 0) /* unimplemented */ +#define BL_R_LOCK (1 << 1) +#define BL_RI_LOCK (1 << 2) +#define BL_W_LOCK (1 << 3) /* * mao tracing buffer allocation diff --git a/src/include/storage/bufmgr.h b/src/include/storage/bufmgr.h index e9ba960a06..55b735a6a9 100644 --- a/src/include/storage/bufmgr.h +++ b/src/include/storage/bufmgr.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: bufmgr.h,v 1.25 1999/02/13 23:22:04 momjian Exp $ + * $Id: bufmgr.h,v 1.26 1999/05/25 16:14:39 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -55,7 +55,7 @@ typedef bits16 BufferLock; #define BufferDescriptorGetBuffer(bdesc) ((bdesc)->buf_id + 1) /* - * BufferIsPinned + * BufferIsPinned * True iff the buffer is pinned (and therefore valid) * * Note: @@ -76,13 +76,13 @@ extern int ShowPinTrace; /* * Buffer context lock modes */ -#define BUFFER_LOCK_UNLOCK 0 -#define BUFFER_LOCK_SHARE 1 -#define BUFFER_LOCK_EXCLUSIVE 2 +#define BUFFER_LOCK_UNLOCK 0 +#define BUFFER_LOCK_SHARE 1 +#define BUFFER_LOCK_EXCLUSIVE 2 /* - * BufferIsValid + * BufferIsValid * True iff the refcnt of the local buffer is > 0 * Note: * BufferIsValid(InvalidBuffer) is False. @@ -117,7 +117,7 @@ extern int ShowPinTrace; ) /* - * BufferGetBlock + * BufferGetBlock * Returns a reference to a disk page image associated with a buffer. * * Note: diff --git a/src/include/storage/bufpage.h b/src/include/storage/bufpage.h index 47c0a2c611..5c8574a450 100644 --- a/src/include/storage/bufpage.h +++ b/src/include/storage/bufpage.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: bufpage.h,v 1.21 1999/02/13 23:22:04 momjian Exp $ + * $Id: bufpage.h,v 1.22 1999/05/25 16:14:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -75,7 +75,7 @@ */ /* - * PageIsValid + * PageIsValid * True iff page is valid. */ #define PageIsValid(page) PointerIsValid(page) @@ -154,7 +154,7 @@ typedef enum */ /* - * PageIsUsed + * PageIsUsed * True iff the page size is used. * * Note: @@ -167,7 +167,7 @@ typedef enum ) /* - * PageIsEmpty + * PageIsEmpty * returns true iff no itemid has been allocated on the page */ #define PageIsEmpty(page) \ @@ -175,14 +175,14 @@ typedef enum (sizeof(PageHeaderData) - sizeof(ItemIdData)) ? true : false) /* - * PageIsNew + * PageIsNew * returns true iff page is not initialized (by PageInit) */ #define PageIsNew(page) (((PageHeader) (page))->pd_upper == 0) /* - * PageGetItemId + * PageGetItemId * Returns an item identifier of a page. */ #define PageGetItemId(page, offsetNumber) \ @@ -194,7 +194,7 @@ typedef enum */ /* - * PageSizeIsValid + * PageSizeIsValid * True iff the page size is valid. * * XXX currently all page sizes are "valid" but we only actually @@ -206,7 +206,7 @@ typedef enum #define PageSizeIsValid(pageSize) ((pageSize) == BLCKSZ) /* - * PageGetPageSize + * PageGetPageSize * Returns the page size of a page. * * this can only be called on a formatted page (unlike @@ -217,7 +217,7 @@ typedef enum ((Size) ((PageHeader) (page))->pd_opaque.od_pagesize) /* - * PageSetPageSize + * PageSetPageSize * Sets the page size of a page. */ #define PageSetPageSize(page, size) \ @@ -228,7 +228,7 @@ typedef enum * ---------------- */ /* - * PageGetSpecialSize + * PageGetSpecialSize * Returns size of special space on a page. * * Note: @@ -238,7 +238,7 @@ typedef enum ((uint16) (PageGetPageSize(page) - ((PageHeader)(page))->pd_special)) /* - * PageGetSpecialPointer + * PageGetSpecialPointer * Returns pointer to special space on a page. * * Note: @@ -251,7 +251,7 @@ typedef enum ) /* - * PageGetItem + * PageGetItem * Retrieves an item on the given page. * * Note: @@ -266,7 +266,7 @@ typedef enum ) /* - * BufferGetPageSize + * BufferGetPageSize * Returns the page size within a buffer. * * Notes: @@ -283,13 +283,13 @@ typedef enum ) /* - * BufferGetPage + * BufferGetPage * Returns the page associated with a buffer. */ #define BufferGetPage(buffer) ((Page)BufferGetBlock(buffer)) /* - * PageGetMaxOffsetNumber + * PageGetMaxOffsetNumber * Returns the maximum offset number used by the given page. * * NOTE: The offset is invalid if the page is non-empty. diff --git a/src/include/storage/fd.h b/src/include/storage/fd.h index a867775743..0493b3ccc7 100644 --- a/src/include/storage/fd.h +++ b/src/include/storage/fd.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: fd.h,v 1.13 1999/05/09 00:52:06 tgl Exp $ + * $Id: fd.h,v 1.14 1999/05/25 16:14:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -91,11 +91,11 @@ extern void FreeFile(FILE *); * atop virtual Files... */ extern BufFile *BufFileCreate(File file); -extern void BufFileClose(BufFile *file); -extern size_t BufFileRead(BufFile *file, void *ptr, size_t size); -extern size_t BufFileWrite(BufFile *file, void *ptr, size_t size); -extern int BufFileFlush(BufFile *file); -extern long BufFileSeek(BufFile *file, long offset, int whence); +extern void BufFileClose(BufFile * file); +extern size_t BufFileRead(BufFile * file, void *ptr, size_t size); +extern size_t BufFileWrite(BufFile * file, void *ptr, size_t size); +extern int BufFileFlush(BufFile * file); +extern long BufFileSeek(BufFile * file, long offset, int whence); /* Miscellaneous support routines */ extern int FileNameUnlink(char *filename); diff --git a/src/include/storage/itemid.h b/src/include/storage/itemid.h index 88d856a35c..c6bea0eea9 100644 --- a/src/include/storage/itemid.h +++ b/src/include/storage/itemid.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: itemid.h,v 1.8 1999/02/13 23:22:06 momjian Exp $ + * $Id: itemid.h,v 1.9 1999/05/25 16:14:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -57,13 +57,13 @@ typedef struct ItemIdData *ItemId; ((itemId)->lp_flags) /* - * ItemIdIsValid + * ItemIdIsValid * True iff disk item identifier is valid. */ #define ItemIdIsValid(itemId) PointerIsValid(itemId) /* - * ItemIdIsUsed + * ItemIdIsUsed * True iff disk item identifier is in use. * * Note: diff --git a/src/include/storage/itemptr.h b/src/include/storage/itemptr.h index 3e3c1d2a55..4f6a131f74 100644 --- a/src/include/storage/itemptr.h +++ b/src/include/storage/itemptr.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: itemptr.h,v 1.10 1999/02/13 23:22:06 momjian Exp $ + * $Id: itemptr.h,v 1.11 1999/05/25 16:14:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -37,14 +37,14 @@ typedef ItemPointerData *ItemPointer; */ /* - * ItemPointerIsValid + * ItemPointerIsValid * True iff the disk item pointer is not NULL. */ #define ItemPointerIsValid(pointer) \ ((bool) (PointerIsValid(pointer) && ((pointer)->ip_posid != 0))) /* - * ItemPointerGetBlockNumber + * ItemPointerGetBlockNumber * Returns the block number of a disk item pointer. */ #define ItemPointerGetBlockNumber(pointer) \ @@ -54,7 +54,7 @@ typedef ItemPointerData *ItemPointer; ) /* - * ItemPointerGetOffsetNumber + * ItemPointerGetOffsetNumber * Returns the offset number of a disk item pointer. */ #define ItemPointerGetOffsetNumber(pointer) \ @@ -64,7 +64,7 @@ typedef ItemPointerData *ItemPointer; ) /* - * ItemPointerSet + * ItemPointerSet * Sets a disk item pointer to the specified block and offset. */ #define ItemPointerSet(pointer, blockNumber, offNum) \ @@ -75,7 +75,7 @@ typedef ItemPointerData *ItemPointer; ) /* - * ItemPointerSetBlockNumber + * ItemPointerSetBlockNumber * Sets a disk item pointer to the specified block. */ #define ItemPointerSetBlockNumber(pointer, blockNumber) \ @@ -85,7 +85,7 @@ typedef ItemPointerData *ItemPointer; ) /* - * ItemPointerSetOffsetNumber + * ItemPointerSetOffsetNumber * Sets a disk item pointer to the specified offset. */ #define ItemPointerSetOffsetNumber(pointer, offsetNumber) \ @@ -95,7 +95,7 @@ typedef ItemPointerData *ItemPointer; ) /* - * ItemPointerCopy + * ItemPointerCopy * Copies the contents of one disk item pointer to another. */ #define ItemPointerCopy(fromPointer, toPointer) \ @@ -106,7 +106,7 @@ typedef ItemPointerData *ItemPointer; ) /* - * ItemPointerSetInvalid + * ItemPointerSetInvalid * Sets a disk item pointer to be invalid. */ #define ItemPointerSetInvalid(pointer) \ diff --git a/src/include/storage/lock.h b/src/include/storage/lock.h index ab084eb94f..744ff537c0 100644 --- a/src/include/storage/lock.h +++ b/src/include/storage/lock.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: lock.h,v 1.26 1999/05/13 15:55:44 momjian Exp $ + * $Id: lock.h,v 1.27 1999/05/25 16:14:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -64,8 +64,8 @@ typedef struct LTAG Oid dbId; union { - BlockNumber blkno; - TransactionId xid; + BlockNumber blkno; + TransactionId xid; } objId; uint16 lockmethod; /* needed by user locks */ } LOCKTAG; @@ -124,7 +124,7 @@ typedef struct LOCKMETHODTABLE * we store is the number of locks of each type (holders) and the * total number of locks (nHolding) held by the transaction. * - * NOTE: + * NOTE: * There were some problems with the fact that currently TransactionIdData * is a 5 byte entity and compilers long word aligning of structure fields. * If the 3 byte padding is put in front of the actual xid data then the diff --git a/src/include/storage/off.h b/src/include/storage/off.h index ee3434c4f9..63a3e1b54c 100644 --- a/src/include/storage/off.h +++ b/src/include/storage/off.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: off.h,v 1.6 1999/02/13 23:22:08 momjian Exp $ + * $Id: off.h,v 1.7 1999/05/25 16:14:43 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -32,7 +32,7 @@ typedef uint16 OffsetNumber; */ /* - * OffsetNumberIsValid + * OffsetNumberIsValid * True iff the offset number is valid. */ #define OffsetNumberIsValid(offsetNumber) \ @@ -40,8 +40,8 @@ typedef uint16 OffsetNumber; (offsetNumber <= MaxOffsetNumber))) /* - * OffsetNumberNext - * OffsetNumberPrev + * OffsetNumberNext + * OffsetNumberPrev * Increments/decrements the argument. These macros look pointless * but they help us disambiguate the different manipulations on * OffsetNumbers (e.g., sometimes we substract one from an diff --git a/src/include/storage/page.h b/src/include/storage/page.h index d661266ffe..4ee4e06d38 100644 --- a/src/include/storage/page.h +++ b/src/include/storage/page.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: page.h,v 1.5 1999/02/13 23:22:09 momjian Exp $ + * $Id: page.h,v 1.6 1999/05/25 16:14:43 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -16,7 +16,7 @@ typedef Pointer Page; /* - * PageIsValid + * PageIsValid * True iff page is valid. */ #define PageIsValid(page) PointerIsValid(page) diff --git a/src/include/storage/pagenum.h b/src/include/storage/pagenum.h index 56ccf1c1ab..91cf23b5ce 100644 --- a/src/include/storage/pagenum.h +++ b/src/include/storage/pagenum.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pagenum.h,v 1.7 1999/02/13 23:22:09 momjian Exp $ + * $Id: pagenum.h,v 1.8 1999/05/25 16:14:43 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -21,7 +21,7 @@ typedef uint32 LogicalPageNumber; #define InvalidLogicalPageNumber 0 /* - * LogicalPageNumberIsValid + * LogicalPageNumberIsValid * True iff the logical page number is valid. */ #define LogicalPageNumberIsValid(pageNumber) \ diff --git a/src/include/storage/pos.h b/src/include/storage/pos.h index fa6feb148c..91d85c68c5 100644 --- a/src/include/storage/pos.h +++ b/src/include/storage/pos.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pos.h,v 1.6 1999/02/13 23:22:09 momjian Exp $ + * $Id: pos.h,v 1.7 1999/05/25 16:14:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -32,28 +32,28 @@ typedef PositionIdData *PositionId; */ /* - * PositionIdIsValid + * PositionIdIsValid * True iff the position identifier is valid. */ #define PositionIdIsValid(positionId) \ PointerIsValid(positionId) /* - * PositionIdSetInvalid + * PositionIdSetInvalid * Make an invalid position. */ #define PositionIdSetInvalid(positionId) \ *(positionId) = (bits16) 0 /* - * PositionIdSet + * PositionIdSet * Sets a position identifier to the specified value. */ #define PositionIdSet(positionId, offsetNumber) \ *(positionId) = (offsetNumber) /* - * PositionIdGetOffsetNumber + * PositionIdGetOffsetNumber * Retrieve the offset number from a position identifier. */ #define PositionIdGetOffsetNumber(positionId) \ diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 3dcf1e281b..0caef8fa90 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: proc.h,v 1.22 1999/05/13 15:55:45 momjian Exp $ + * $Id: proc.h,v 1.23 1999/05/25 16:14:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -76,7 +76,9 @@ typedef struct procglobal SHMEM_OFFSET freeProcs; IPCKey currKey; int32 freeSemMap[MAX_PROC_SEMS / PROC_NSEMS_PER_SET]; - /* In each freeSemMap entry, the PROC_NSEMS_PER_SET lsbs flag whether + + /* + * In each freeSemMap entry, the PROC_NSEMS_PER_SET lsbs flag whether * individual semaphores are in use, and the next higher bit is set to * show that the entire set is allocated. */ @@ -117,8 +119,8 @@ extern bool ProcRemove(int pid); /* make static in storage/lmgr/proc.c -- jolly */ extern void ProcQueueInit(PROC_QUEUE *queue); -extern int ProcSleep(PROC_QUEUE *queue, LOCKMETHODCTL *lockctl, int token, - LOCK *lock); +extern int ProcSleep(PROC_QUEUE *queue, LOCKMETHODCTL * lockctl, int token, + LOCK *lock); extern PROC *ProcWakeup(PROC *proc, int errType); extern int ProcLockWakeup(PROC_QUEUE *queue, LOCKMETHOD lockmethod, LOCK *lock); diff --git a/src/include/storage/shmem.h b/src/include/storage/shmem.h index 7f5ed84aac..e39e3e3bd7 100644 --- a/src/include/storage/shmem.h +++ b/src/include/storage/shmem.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: shmem.h,v 1.16 1999/04/02 04:51:05 tgl Exp $ + * $Id: shmem.h,v 1.17 1999/05/25 16:14:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -71,7 +71,7 @@ extern SHMEM_OFFSET ShmemPIDDestroy(int pid); extern long *ShmemInitStruct(char *name, unsigned long size, bool *foundPtr); extern bool TransactionIdIsInProgress(TransactionId xid); -extern void GetXmaxRecent(TransactionId *XmaxRecent); +extern void GetXmaxRecent(TransactionId *XmaxRecent); typedef int TableID; diff --git a/src/include/storage/sinvaladt.h b/src/include/storage/sinvaladt.h index 522eb5e220..d92969a85b 100644 --- a/src/include/storage/sinvaladt.h +++ b/src/include/storage/sinvaladt.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: sinvaladt.h,v 1.12 1999/02/19 06:06:39 tgl Exp $ + * $Id: sinvaladt.h,v 1.13 1999/05/25 16:14:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -70,8 +70,7 @@ typedef struct SISeg Offset endEntryChain; /* (offset relative to B) */ int numEntries; int maxNumEntries; - ProcState procState[MAXBACKENDS]; /* reflects the - * invalidation state */ + ProcState procState[MAXBACKENDS]; /* reflects the invalidation state */ /* here starts the entry section, controlled by offsets */ } SISeg; diff --git a/src/include/tcop/dest.h b/src/include/tcop/dest.h index 941e913eaa..dd5e447bcc 100644 --- a/src/include/tcop/dest.h +++ b/src/include/tcop/dest.h @@ -33,7 +33,7 @@ * The DestReceiver object returned by DestToFunction may be a statically * allocated object (for destination types that require no local state) * or can be a palloc'd object that has DestReceiver as its first field - * and contains additional fields (see printtup.c for an example). These + * and contains additional fields (see printtup.c for an example). These * additional fields are then accessible to the DestReceiver functions * by casting the DestReceiver* pointer passed to them. * The palloc'd object is pfree'd by the DestReceiver's cleanup function. @@ -44,7 +44,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: dest.h,v 1.18 1999/02/13 23:22:11 momjian Exp $ + * $Id: dest.h,v 1.19 1999/05/25 16:14:47 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -78,22 +78,23 @@ typedef enum */ typedef struct _DestReceiver DestReceiver; -struct _DestReceiver { +struct _DestReceiver +{ /* Called for each tuple to be output: */ - void (*receiveTuple) (HeapTuple tuple, TupleDesc typeinfo, - DestReceiver* self); + void (*receiveTuple) (HeapTuple tuple, TupleDesc typeinfo, + DestReceiver * self); /* Initialization and teardown: */ - void (*setup) (DestReceiver* self, TupleDesc typeinfo); - void (*cleanup) (DestReceiver* self); + void (*setup) (DestReceiver * self, TupleDesc typeinfo); + void (*cleanup) (DestReceiver * self); /* Private fields might appear beyond this point... */ }; /* The primary destination management functions */ extern void BeginCommand(char *pname, int operation, TupleDesc attinfo, - bool isIntoRel, bool isIntoPortal, char *tag, - CommandDest dest); -extern DestReceiver* DestToFunction(CommandDest dest); + bool isIntoRel, bool isIntoPortal, char *tag, + CommandDest dest); +extern DestReceiver *DestToFunction(CommandDest dest); extern void EndCommand(char *commandTag, CommandDest dest); /* Additional functions that go with destination management, more or less. */ diff --git a/src/include/tcop/tcopprot.h b/src/include/tcop/tcopprot.h index 41bcaa43f3..535d974b9a 100644 --- a/src/include/tcop/tcopprot.h +++ b/src/include/tcop/tcopprot.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: tcopprot.h,v 1.19 1999/05/13 07:29:22 tgl Exp $ + * $Id: tcopprot.h,v 1.20 1999/05/25 16:14:48 momjian Exp $ * * OLD COMMENTS * This file was created so that other c files could get the two @@ -22,7 +22,7 @@ #include "executor/execdesc.h" #include "parser/parse_node.h" -/* Autoconf's test for HAVE_SIGSETJMP fails on Linux 2.0.x because the test +/* Autoconf's test for HAVE_SIGSETJMP fails on Linux 2.0.x because the test * explicitly disallows sigsetjmp being a #define, which is how it * is declared in Linux. So, to avoid compiler warnings about * sigsetjmp() being redefined, let's not redefine unless necessary. @@ -36,13 +36,13 @@ #define sigsetjmp(x,y) setjmp(x) #define siglongjmp longjmp #endif -extern DLLIMPORT sigjmp_buf Warn_restart; +extern DLLIMPORT sigjmp_buf Warn_restart; extern bool InError; #ifndef BOOTSTRAP_INCLUDE extern List *pg_parse_and_plan(char *query_string, Oid *typev, int nargs, - List **queryListP, CommandDest dest, - bool aclOverride); + List **queryListP, CommandDest dest, + bool aclOverride); extern void pg_exec_query(char *query_string); extern void pg_exec_query_acl_override(char *query_string); extern void diff --git a/src/include/utils/array.h b/src/include/utils/array.h index f0566ca6f9..e6c8c6c311 100644 --- a/src/include/utils/array.h +++ b/src/include/utils/array.h @@ -10,7 +10,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: array.h,v 1.17 1999/05/03 23:48:25 tgl Exp $ + * $Id: array.h,v 1.18 1999/05/25 16:14:49 momjian Exp $ * * NOTES * XXX the data array should be LONGALIGN'd -- notice that the array @@ -127,8 +127,8 @@ extern char *array_assgn(ArrayType *array, int n, int *upperIndx, int *lowerIndx, ArrayType *newArr, int reftype, int len, bool *isNull); extern ArrayType *array_map(ArrayType *v, Oid type, - char * (*fn)(), - Oid retType, int nargs, ...); + char *(*fn) (), + Oid retType, int nargs,...); extern int array_eq(ArrayType *array1, ArrayType *array2); extern int _LOtransfer(char **destfd, int size, int nitems, char **srcfd, int isSrcLO, int isDestLO); diff --git a/src/include/utils/bit.h b/src/include/utils/bit.h index 1431a2d227..ed3355df4e 100644 --- a/src/include/utils/bit.h +++ b/src/include/utils/bit.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: bit.h,v 1.5 1999/02/13 23:22:15 momjian Exp $ + * $Id: bit.h,v 1.6 1999/05/25 16:14:51 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -19,19 +19,19 @@ typedef uint32 BitIndex; #define BitsPerByte 8 /* - * BitArraySetBit + * BitArraySetBit * Sets (to 1) the value of a bit in a bit array. */ extern void BitArraySetBit(BitArray bitArray, BitIndex bitIndex); /* - * BitArrayClearBit + * BitArrayClearBit * Clears (to 0) the value of a bit in a bit array. */ extern void BitArrayClearBit(BitArray bitArray, BitIndex bitIndex); /* - * BitArrayBitIsSet + * BitArrayBitIsSet * True iff the bit is set (1) in a bit array. */ extern bool BitArrayBitIsSet(BitArray bitArray, BitIndex bitIndex); diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h index 71fb63c77f..0fe0487b47 100644 --- a/src/include/utils/builtins.h +++ b/src/include/utils/builtins.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: builtins.h,v 1.78 1999/05/03 19:10:31 momjian Exp $ + * $Id: builtins.h,v 1.79 1999/05/25 16:14:52 momjian Exp $ * * NOTES * This should normally only be included by fmgr.h. @@ -63,7 +63,7 @@ extern int8 charmul(int8 arg1, int8 arg2); extern int8 chardiv(int8 arg1, int8 arg2); extern bool cideq(int8 arg1, int8 arg2); extern int8 text_char(text *arg1); -extern text* char_text(int8 arg1); +extern text *char_text(int8 arg1); /* int.c */ extern int32 int2in(char *num); @@ -164,7 +164,7 @@ extern void ltoa(int32 l, char *a); */ extern int32 btint2cmp(int16 a, int16 b); extern int32 btint4cmp(int32 a, int32 b); -extern int32 btint8cmp(int64 *a, int64 *b); +extern int32 btint8cmp(int64 * a, int64 * b); extern int32 btint24cmp(int16 a, int32 b); extern int32 btint42cmp(int32 a, int16 b); extern int32 btfloat4cmp(float32 a, float32 b); @@ -524,50 +524,50 @@ extern text *translate(text *string, char from, char to); /* acl.c */ /* inet_net_ntop.c */ -char *inet_net_ntop(int af, const void *src, int bits, char *dst, size_t size); -char *inet_cidr_ntop(int af, const void *src, int bits, char *dst, size_t size); +char *inet_net_ntop(int af, const void *src, int bits, char *dst, size_t size); +char *inet_cidr_ntop(int af, const void *src, int bits, char *dst, size_t size); /* inet_net_pton.c */ -int inet_net_pton(int af, const char *src, void *dst, size_t size); +int inet_net_pton(int af, const char *src, void *dst, size_t size); /* network.c */ inet *inet_in(char *str); -char *inet_out(inet * addr); +char *inet_out(inet *addr); inet *cidr_in(char *str); char *cidr_out(inet *addr); -bool network_lt(inet * a1, inet * a2); -bool network_le(inet * a1, inet * a2); -bool network_eq(inet * a1, inet * a2); -bool network_ge(inet * a1, inet * a2); -bool network_gt(inet * a1, inet * a2); -bool network_ne(inet * a1, inet * a2); -bool network_sub(inet * a1, inet * a2); -bool network_subeq(inet * a1, inet * a2); -bool network_sup(inet * a1, inet * a2); -bool network_supeq(inet * a1, inet * a2); -int4 network_cmp(inet * a1, inet * a2); +bool network_lt(inet *a1, inet *a2); +bool network_le(inet *a1, inet *a2); +bool network_eq(inet *a1, inet *a2); +bool network_ge(inet *a1, inet *a2); +bool network_gt(inet *a1, inet *a2); +bool network_ne(inet *a1, inet *a2); +bool network_sub(inet *a1, inet *a2); +bool network_subeq(inet *a1, inet *a2); +bool network_sup(inet *a1, inet *a2); +bool network_supeq(inet *a1, inet *a2); +int4 network_cmp(inet *a1, inet *a2); -text *network_network(inet * addr); -text *network_netmask(inet * addr); -int4 network_masklen(inet * addr); -text *network_broadcast(inet * addr); -text *network_host(inet * addr); +text *network_network(inet *addr); +text *network_netmask(inet *addr); +int4 network_masklen(inet *addr); +text *network_broadcast(inet *addr); +text *network_host(inet *addr); /* mac.c */ macaddr *macaddr_in(char *str); -char *macaddr_out(macaddr * addr); -bool macaddr_lt(macaddr * a1, macaddr * a2); -bool macaddr_le(macaddr * a1, macaddr * a2); -bool macaddr_eq(macaddr * a1, macaddr * a2); -bool macaddr_ge(macaddr * a1, macaddr * a2); -bool macaddr_gt(macaddr * a1, macaddr * a2); -bool macaddr_ne(macaddr * a1, macaddr * a2); -int4 macaddr_cmp(macaddr * a1, macaddr * a2); -text *macaddr_manuf(macaddr * addr); +char *macaddr_out(macaddr *addr); +bool macaddr_lt(macaddr *a1, macaddr *a2); +bool macaddr_le(macaddr *a1, macaddr *a2); +bool macaddr_eq(macaddr *a1, macaddr *a2); +bool macaddr_ge(macaddr *a1, macaddr *a2); +bool macaddr_gt(macaddr *a1, macaddr *a2); +bool macaddr_ne(macaddr *a1, macaddr *a2); +int4 macaddr_cmp(macaddr *a1, macaddr *a2); +text *macaddr_manuf(macaddr *addr); /* numeric.c */ Numeric numeric_in(char *str, int dummy, int32 typmod); -char *numeric_out(Numeric num); +char *numeric_out(Numeric num); Numeric numeric(Numeric num, int32 typmod); Numeric numeric_abs(Numeric num); Numeric numeric_sign(Numeric num); @@ -604,7 +604,3 @@ float64 numeric_float8(Numeric num); #endif /* BUILTINS_H */ - - - - diff --git a/src/include/utils/dt.h b/src/include/utils/dt.h index 9bd391b550..d217c8aa87 100644 --- a/src/include/utils/dt.h +++ b/src/include/utils/dt.h @@ -8,7 +8,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: dt.h,v 1.39 1999/04/15 02:24:23 thomas Exp $ + * $Id: dt.h,v 1.40 1999/05/25 16:14:53 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -268,13 +268,13 @@ extern int datetime_is_epoch(double j); * Include check for leap year. */ -extern int day_tab[2][13]; +extern int day_tab[2][13]; #define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0)) /* Julian date support for date2j() and j2date() * Set the minimum year to one greater than the year of the first valid day - * to avoid having to check year and day both. - tgl 97/05/08 + * to avoid having to check year and day both. - tgl 97/05/08 */ #define JULIAN_MINYEAR (-4713) diff --git a/src/include/utils/geo_decls.h b/src/include/utils/geo_decls.h index 808f5210e1..34cd7f29f0 100644 --- a/src/include/utils/geo_decls.h +++ b/src/include/utils/geo_decls.h @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: geo_decls.h,v 1.22 1999/03/28 01:56:11 tgl Exp $ + * $Id: geo_decls.h,v 1.23 1999/05/25 16:14:54 momjian Exp $ * * NOTE * These routines do *not* use the float types from adt/. @@ -363,6 +363,6 @@ extern double circle_dt(CIRCLE *circle1, CIRCLE *circle2); extern float64 areasel(Oid opid, Oid relid, AttrNumber attno, char *value, int32 flag); extern float64 areajoinsel(Oid opid, Oid relid1, AttrNumber attno1, - Oid relid2, AttrNumber attno2); + Oid relid2, AttrNumber attno2); #endif /* GEO_DECLS_H */ diff --git a/src/include/utils/hsearch.h b/src/include/utils/hsearch.h index 4e5676eb88..c717d9bd48 100644 --- a/src/include/utils/hsearch.h +++ b/src/include/utils/hsearch.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: hsearch.h,v 1.11 1999/02/22 06:16:46 tgl Exp $ + * $Id: hsearch.h,v 1.12 1999/05/25 16:14:54 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -18,7 +18,7 @@ * Constants * * A hash table has a top-level "directory", each of whose entries points - * to a "segment" of ssize bucket headers. The maximum number of hash + * to a "segment" of ssize bucket headers. The maximum number of hash * buckets is thus dsize * ssize (but dsize may be expansible). Of course, * the number of records in the table can be larger, but we don't want a * whole lot of records per bucket or performance goes down. @@ -27,11 +27,11 @@ * expanded because it must stay at a fixed address. */ #define DEF_SEGSIZE 256 -#define DEF_SEGSIZE_SHIFT 8 /* log2(SEGSIZE) */ +#define DEF_SEGSIZE_SHIFT 8/* log2(SEGSIZE) */ #define DEF_DIRSIZE 256 -#define DEF_FFACTOR 1 /* default fill factor */ +#define DEF_FFACTOR 1/* default fill factor */ -#define PRIME1 37 /* for the hash function */ +#define PRIME1 37 /* for the hash function */ #define PRIME2 1048583 @@ -64,7 +64,8 @@ typedef struct hashhdr long nsegs; /* Number of allocated segments */ long keysize; /* hash key length in bytes */ long datasize; /* elem data length in bytes */ - long max_dsize; /* 'dsize' limit if directory is fixed size */ + long max_dsize; /* 'dsize' limit if directory is fixed + * size */ BUCKET_INDEX freeBucketIndex; /* index of first free bucket */ #ifdef HASH_STATISTICS diff --git a/src/include/utils/inet.h b/src/include/utils/inet.h index 23ac35582c..252d1dd105 100644 --- a/src/include/utils/inet.h +++ b/src/include/utils/inet.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: inet.h,v 1.3 1999/02/13 23:22:23 momjian Exp $ + * $Id: inet.h,v 1.4 1999/05/25 16:14:54 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -24,7 +24,7 @@ typedef struct unsigned char type; union { - unsigned int ipv4_addr; /* network byte order */ + unsigned int ipv4_addr; /* network byte order */ /* add IPV6 address type here */ } addr; } inet_struct; @@ -42,7 +42,7 @@ typedef struct macaddr unsigned char d; unsigned char e; unsigned char f; -} macaddr; +} macaddr; typedef struct manufacturer @@ -51,9 +51,8 @@ typedef struct manufacturer unsigned char b; unsigned char c; char *name; -} manufacturer; +} manufacturer; extern manufacturer manufacturers[]; #endif /* MAC_H */ - diff --git a/src/include/utils/int8.h b/src/include/utils/int8.h index db2e9edb52..6a1f134bbf 100644 --- a/src/include/utils/int8.h +++ b/src/include/utils/int8.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: int8.h,v 1.12 1999/03/15 01:43:05 tgl Exp $ + * $Id: int8.h,v 1.13 1999/05/25 16:14:55 momjian Exp $ * * NOTES * These data types are supported on all 64-bit architectures, and may @@ -94,13 +94,13 @@ extern int32 int84(int64 * val); #if NOT_USED extern int64 *int28 (int16 val); extern int16 int82(int64 * val); + #endif extern float64 i8tod(int64 * val); extern int64 *dtoi8(float64 val); -extern text *int8_text(int64 *val); +extern text *int8_text(int64 * val); extern int64 *text_int8(text *str); #endif /* INT8_H */ - diff --git a/src/include/utils/mcxt.h b/src/include/utils/mcxt.h index cce6ec865b..ed8ae2e332 100644 --- a/src/include/utils/mcxt.h +++ b/src/include/utils/mcxt.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: mcxt.h,v 1.14 1999/03/22 16:45:28 momjian Exp $ + * $Id: mcxt.h,v 1.15 1999/05/25 16:14:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -27,7 +27,7 @@ extern MemoryContext TopMemoryContext; /* - * MaxAllocSize + * MaxAllocSize * Arbitrary limit on size of allocations. * * Note: diff --git a/src/include/utils/memutils.h b/src/include/utils/memutils.h index e95aec57c9..59f473b910 100644 --- a/src/include/utils/memutils.h +++ b/src/include/utils/memutils.h @@ -15,7 +15,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: memutils.h,v 1.24 1999/05/22 23:19:36 tgl Exp $ + * $Id: memutils.h,v 1.25 1999/05/25 16:14:56 momjian Exp $ * * NOTES * some of the information in this file will be moved to @@ -133,13 +133,13 @@ extern void OrderedElemPushInto(OrderedElem elem, OrderedSet Set); */ /* - * AllocPointer + * AllocPointer * Aligned pointer which may be a member of an allocation set. */ typedef Pointer AllocPointer; /* - * AllocMode + * AllocMode * Mode of allocation for an allocation set. * * Note: @@ -156,56 +156,58 @@ typedef enum AllocMode #define DefaultAllocMode DynamicAllocMode /* - * AllocBlock + * AllocBlock * Small pieces of memory are taken from bigger blocks of * memory with a size aligned to a power of two. These * pieces are not free's separately, instead they are reused * for the next allocation of a fitting size. */ -typedef struct AllocBlockData { - struct AllocSetData *aset; - struct AllocBlockData *next; - char *freeptr; - char *endptr; -} AllocBlockData; +typedef struct AllocBlockData +{ + struct AllocSetData *aset; + struct AllocBlockData *next; + char *freeptr; + char *endptr; +} AllocBlockData; typedef AllocBlockData *AllocBlock; /* - * AllocChunk + * AllocChunk * The prefix of each piece of memory in an AllocBlock */ -typedef struct AllocChunkData { +typedef struct AllocChunkData +{ /* aset is the owning aset if allocated, or the freelist link if free */ - void *aset; + void *aset; /* size is always the chunk size */ - Size size; -} AllocChunkData; + Size size; +} AllocChunkData; typedef AllocChunkData *AllocChunk; /* - * AllocSet + * AllocSet * Allocation set. */ typedef struct AllocSetData { - struct AllocBlockData *blocks; + struct AllocBlockData *blocks; #define ALLOCSET_NUM_FREELISTS 8 - struct AllocChunkData *freelist[ALLOCSET_NUM_FREELISTS]; + struct AllocChunkData *freelist[ALLOCSET_NUM_FREELISTS]; /* Note: this will change in the future to support other modes */ } AllocSetData; typedef AllocSetData *AllocSet; /* - * AllocPointerIsValid + * AllocPointerIsValid * True iff pointer is valid allocation pointer. */ #define AllocPointerIsValid(pointer) PointerIsValid(pointer) /* - * AllocSetIsValid + * AllocSetIsValid * True iff set is valid allocation set. */ #define AllocSetIsValid(set) PointerIsValid(set) @@ -238,7 +240,7 @@ extern void AllocSetDump(AllocSet set); typedef int LibCCopyLength; /* - * MemoryCopy + * MemoryCopy * Copies fixed length block of memory to another. */ #define MemoryCopy(toBuffer, fromBuffer, length)\ diff --git a/src/include/utils/nabstime.h b/src/include/utils/nabstime.h index fca6b62877..ace0e135fd 100644 --- a/src/include/utils/nabstime.h +++ b/src/include/utils/nabstime.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: nabstime.h,v 1.19 1999/03/14 16:44:02 momjian Exp $ + * $Id: nabstime.h,v 1.20 1999/05/25 16:14:56 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -25,7 +25,7 @@ */ /* The original typedefs are bogus - they assume that the system's 'time_t' * type is of size 32-bits. Under AlphaLinux, time_t is a long int, which - * is 64-bits. Therefore, typedef these both as simply 'time_t', and let + * is 64-bits. Therefore, typedef these both as simply 'time_t', and let * the OS define what the size really is. -- RME 3/5/99 */ typedef time_t AbsoluteTime; @@ -96,7 +96,7 @@ typedef TimeIntervalData *TimeInterval; extern AbsoluteTime GetCurrentAbsoluteTime(void); /* - * getSystemTime + * getSystemTime * Returns system time. */ #define getSystemTime() \ diff --git a/src/include/utils/numeric.h b/src/include/utils/numeric.h index 24c85a5659..888677f71a 100644 --- a/src/include/utils/numeric.h +++ b/src/include/utils/numeric.h @@ -5,7 +5,7 @@ * * 1998 Jan Wieck * - * $Header: /cvsroot/pgsql/src/include/utils/numeric.h,v 1.4 1999/02/13 23:22:26 momjian Exp $ + * $Header: /cvsroot/pgsql/src/include/utils/numeric.h,v 1.5 1999/05/25 16:14:56 momjian Exp $ * * ---------- */ @@ -24,10 +24,10 @@ #define NUMERIC_DEFAULT_PRECISION 30 #define NUMERIC_DEFAULT_SCALE 6 -#define NUMERIC_MAX_DISPLAY_SCALE NUMERIC_MAX_PRECISION -#define NUMERIC_MIN_DISPLAY_SCALE NUMERIC_DEFAULT_SCALE + 4 +#define NUMERIC_MAX_DISPLAY_SCALE NUMERIC_MAX_PRECISION +#define NUMERIC_MIN_DISPLAY_SCALE NUMERIC_DEFAULT_SCALE + 4 -#define NUMERIC_MAX_RESULT_SCALE (NUMERIC_MAX_PRECISION * 2) +#define NUMERIC_MAX_RESULT_SCALE (NUMERIC_MAX_PRECISION * 2) #define NUMERIC_MIN_RESULT_SCALE (NUMERIC_DEFAULT_PRECISION + 4) #define NUMERIC_UNPACKED_DATASIZE (NUMERIC_MAX_PRECISION * 2 + 4) @@ -38,12 +38,12 @@ * ---------- */ #define NUMERIC_SIGN_MASK 0xC000 -#define NUMERIC_POS 0x0000 +#define NUMERIC_POS 0x0000 #define NUMERIC_NEG 0x4000 #define NUMERIC_NAN 0xC000 #define NUMERIC_SIGN(n) ((n)->n_sign_dscale & NUMERIC_SIGN_MASK) #define NUMERIC_DSCALE(n) ((n)->n_sign_dscale & ~NUMERIC_SIGN_MASK) -#define NUMERIC_IS_NAN(n) (NUMERIC_SIGN(n) != NUMERIC_POS && \ +#define NUMERIC_IS_NAN(n) (NUMERIC_SIGN(n) != NUMERIC_POS && \ NUMERIC_SIGN(n) != NUMERIC_NEG) @@ -51,17 +51,17 @@ * The Numeric data type stored in the database * ---------- */ -typedef struct NumericData { - int32 varlen; /* Variable size */ - int16 n_weight; /* Weight of 1st digit */ - uint16 n_rscale; /* Result scale */ - uint16 n_sign_dscale; /* Sign + display scale */ - unsigned char n_data[1]; /* Digit data */ -} NumericData; +typedef struct NumericData +{ + int32 varlen; /* Variable size */ + int16 n_weight; /* Weight of 1st digit */ + uint16 n_rscale; /* Result scale */ + uint16 n_sign_dscale; /* Sign + display scale */ + unsigned char n_data[1]; /* Digit data */ +} NumericData; typedef NumericData *Numeric; #define NUMERIC_HDRSZ (sizeof(int32) + sizeof(uint16) * 3) -#endif /* _PG_NUMERIC_H_ */ - +#endif /* _PG_NUMERIC_H_ */ diff --git a/src/include/utils/palloc.h b/src/include/utils/palloc.h index 5c9a31a450..69ad079bb2 100644 --- a/src/include/utils/palloc.h +++ b/src/include/utils/palloc.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: palloc.h,v 1.8 1999/02/13 23:22:26 momjian Exp $ + * $Id: palloc.h,v 1.9 1999/05/25 16:14:56 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -17,23 +17,23 @@ #ifdef PALLOC_IS_MALLOC -# define palloc(s) malloc(s) -# define pfree(p) free(p) -# define repalloc(p,s) realloc((p),(s)) +#define palloc(s) malloc(s) +#define pfree(p) free(p) +#define repalloc(p,s) realloc((p),(s)) -#else /* ! PALLOC_IS_MALLOC */ +#else /* ! PALLOC_IS_MALLOC */ /* ---------- * In the case we use memory contexts, use macro's for palloc() etc. * ---------- */ -# include "utils/mcxt.h" +#include "utils/mcxt.h" -# define palloc(s) ((void *)MemoryContextAlloc(CurrentMemoryContext,(Size)(s))) -# define pfree(p) MemoryContextFree(CurrentMemoryContext,(Pointer)(p)) -# define repalloc(p,s) ((void *)MemoryContextRealloc(CurrentMemoryContext,(Pointer)(p),(Size)(s))) +#define palloc(s) ((void *)MemoryContextAlloc(CurrentMemoryContext,(Size)(s))) +#define pfree(p) MemoryContextFree(CurrentMemoryContext,(Pointer)(p)) +#define repalloc(p,s) ((void *)MemoryContextRealloc(CurrentMemoryContext,(Pointer)(p),(Size)(s))) -#endif /* PALLOC_IS_MALLOC */ +#endif /* PALLOC_IS_MALLOC */ /* like strdup except uses palloc */ extern char *pstrdup(char *pointer); diff --git a/src/include/utils/portal.h b/src/include/utils/portal.h index 59e82868ff..9d2677c454 100644 --- a/src/include/utils/portal.h +++ b/src/include/utils/portal.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: portal.h,v 1.12 1999/02/13 23:22:27 momjian Exp $ + * $Id: portal.h,v 1.13 1999/05/25 16:14:57 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -53,7 +53,7 @@ struct PortalD }; /* - * PortalIsValid + * PortalIsValid * True iff portal is valid. */ #define PortalIsValid(p) PointerIsValid(p) diff --git a/src/include/utils/psort.h b/src/include/utils/psort.h index 32661031a5..b9590cef61 100644 --- a/src/include/utils/psort.h +++ b/src/include/utils/psort.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: psort.h,v 1.18 1999/05/09 00:53:18 tgl Exp $ + * $Id: psort.h,v 1.19 1999/05/25 16:14:57 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -24,7 +24,7 @@ struct tape { int tp_dummy; /* (D) */ int tp_fib; /* (A) */ - BufFile *tp_file; /* (TAPE) */ + BufFile *tp_file; /* (TAPE) */ struct tape *tp_prev; }; @@ -56,7 +56,7 @@ typedef struct Psortstate struct leftist *Tuples; - BufFile *psort_grab_file; + BufFile *psort_grab_file; long psort_current; /* could be file offset, or array index */ long psort_saved; /* could be file offset, or array index */ bool using_tape_files; diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h index 9eba94a9da..4b2ee9de96 100644 --- a/src/include/utils/rel.h +++ b/src/include/utils/rel.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: rel.h,v 1.22 1999/02/13 23:22:29 momjian Exp $ + * $Id: rel.h,v 1.23 1999/05/25 16:14:57 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -52,7 +52,7 @@ typedef struct RelationData bool rd_myxactonly; /* uses the local buffer mgr */ bool rd_isnailed; /* rel is nailed in cache */ bool rd_isnoname; /* rel has no name */ - bool rd_nonameunlinked; /* noname rel already unlinked */ + bool rd_nonameunlinked; /* noname rel already unlinked */ Form_pg_am rd_am; /* AM tuple */ Form_pg_class rd_rel; /* RELATION tuple */ Oid rd_id; /* relations's object id */ @@ -77,13 +77,13 @@ typedef Relation *RelationPtr; #define InvalidRelation ((Relation)NULL) /* - * RelationIsValid + * RelationIsValid * True iff relation descriptor is valid. */ #define RelationIsValid(relation) PointerIsValid(relation) /* - * RelationGetSystemPort + * RelationGetSystemPort * Returns system port of a relation. * * Note: @@ -92,14 +92,14 @@ typedef Relation *RelationPtr; #define RelationGetSystemPort(relation) ((relation)->rd_fd) /* - * RelationGetLockInfo + * RelationGetLockInfo * Returns the lock information structure in the reldesc * */ #define RelationGetLockInfo(relation) ((relation)->lockInfo) /* - * RelationHasReferenceCountZero + * RelationHasReferenceCountZero * True iff relation reference count is zero. * * Note: @@ -109,25 +109,25 @@ typedef Relation *RelationPtr; ((bool)((relation)->rd_refcnt == 0)) /* - * RelationSetReferenceCount + * RelationSetReferenceCount * Sets relation reference count. */ #define RelationSetReferenceCount(relation,count) ((relation)->rd_refcnt = count) /* - * RelationIncrementReferenceCount + * RelationIncrementReferenceCount * Increments relation reference count. */ #define RelationIncrementReferenceCount(relation) ((relation)->rd_refcnt += 1); /* - * RelationDecrementReferenceCount + * RelationDecrementReferenceCount * Decrements relation reference count. */ #define RelationDecrementReferenceCount(relation) ((relation)->rd_refcnt -= 1) /* - * RelationGetForm + * RelationGetForm * Returns relation attribute values for a relation. * * Note: @@ -137,7 +137,7 @@ typedef Relation *RelationPtr; /* - * RelationGetRelid + * RelationGetRelid * * returns the object id of the relation * @@ -145,7 +145,7 @@ typedef Relation *RelationPtr; #define RelationGetRelid(relation) ((relation)->rd_id) /* - * RelationGetFile + * RelationGetFile * * Returns the open File decscriptor */ @@ -153,21 +153,21 @@ typedef Relation *RelationPtr; /* - * RelationGetRelationName + * RelationGetRelationName * * Returns a Relation Name */ #define RelationGetRelationName(relation) (&(relation)->rd_rel->relname) /* - * RelationGetRelationName + * RelationGetRelationName * * Returns a the number of attributes. */ #define RelationGetNumberOfAttributes(relation) ((relation)->rd_rel->relnatts) /* - * RelationGetDescr + * RelationGetDescr * Returns tuple descriptor for a relation. * * Note: diff --git a/src/include/utils/temprel.h b/src/include/utils/temprel.h index 2953a943cc..1b83223510 100644 --- a/src/include/utils/temprel.h +++ b/src/include/utils/temprel.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: temprel.h,v 1.2 1999/02/13 23:22:32 momjian Exp $ + * $Id: temprel.h,v 1.3 1999/05/25 16:14:57 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -16,10 +16,9 @@ #include "access/htup.h" #include "access/attnum.h" -void create_temp_relation(char *relname, HeapTuple pg_class_tuple); -void remove_all_temp_relations(void); -void remove_temp_relation(Oid relid); -HeapTuple get_temp_rel_by_name(char *user_relname); +void create_temp_relation(char *relname, HeapTuple pg_class_tuple); +void remove_all_temp_relations(void); +void remove_temp_relation(Oid relid); +HeapTuple get_temp_rel_by_name(char *user_relname); #endif /* TEMPREL_H */ - diff --git a/src/include/utils/tqual.h b/src/include/utils/tqual.h index 5fe617b8c0..1cc67f0ea5 100644 --- a/src/include/utils/tqual.h +++ b/src/include/utils/tqual.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: tqual.h,v 1.20 1999/02/13 23:22:33 momjian Exp $ + * $Id: tqual.h,v 1.21 1999/05/25 16:14:58 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -18,11 +18,11 @@ typedef struct SnapshotData { - TransactionId xmin; /* XID < xmin are visible to me */ - TransactionId xmax; /* XID >= xmax are invisible to me */ - uint32 xcnt; /* # of xact below */ - TransactionId *xip; /* array of xacts in progress */ - ItemPointerData tid; /* required for Dirty snapshot -:( */ + TransactionId xmin; /* XID < xmin are visible to me */ + TransactionId xmax; /* XID >= xmax are invisible to me */ + uint32 xcnt; /* # of xact below */ + TransactionId *xip; /* array of xacts in progress */ + ItemPointerData tid; /* required for Dirty snapshot -:( */ } SnapshotData; typedef SnapshotData *Snapshot; @@ -30,9 +30,9 @@ typedef SnapshotData *Snapshot; #define SnapshotNow ((Snapshot) 0x0) #define SnapshotSelf ((Snapshot) 0x1) -extern Snapshot SnapshotDirty; -extern Snapshot QuerySnapshot; -extern Snapshot SerializableSnapshot; +extern Snapshot SnapshotDirty; +extern Snapshot QuerySnapshot; +extern Snapshot SerializableSnapshot; #define IsSnapshotNow(snapshot) ((Snapshot) snapshot == SnapshotNow) #define IsSnapshotSelf(snapshot) ((Snapshot) snapshot == SnapshotSelf) @@ -42,7 +42,7 @@ extern TransactionId HeapSpecialTransactionId; extern CommandId HeapSpecialCommandId; /* - * HeapTupleSatisfiesVisibility + * HeapTupleSatisfiesVisibility * True iff heap tuple satsifies a time qual. * * Note: @@ -87,22 +87,22 @@ extern CommandId HeapSpecialCommandId; ) \ ) -#define HeapTupleMayBeUpdated 0 -#define HeapTupleInvisible 1 +#define HeapTupleMayBeUpdated 0 +#define HeapTupleInvisible 1 #define HeapTupleSelfUpdated 2 #define HeapTupleUpdated 3 #define HeapTupleBeingUpdated 4 -extern bool HeapTupleSatisfiesItself(HeapTupleHeader tuple); -extern bool HeapTupleSatisfiesNow(HeapTupleHeader tuple); -extern bool HeapTupleSatisfiesDirty(HeapTupleHeader tuple); -extern bool HeapTupleSatisfiesSnapshot(HeapTupleHeader tuple, Snapshot snapshot); -extern int HeapTupleSatisfiesUpdate(HeapTuple tuple); +extern bool HeapTupleSatisfiesItself(HeapTupleHeader tuple); +extern bool HeapTupleSatisfiesNow(HeapTupleHeader tuple); +extern bool HeapTupleSatisfiesDirty(HeapTupleHeader tuple); +extern bool HeapTupleSatisfiesSnapshot(HeapTupleHeader tuple, Snapshot snapshot); +extern int HeapTupleSatisfiesUpdate(HeapTuple tuple); extern void setheapoverride(bool on); extern Snapshot GetSnapshotData(bool serializable); -extern void SetQuerySnapshot(void); -extern void FreeXactSnapshot(void); +extern void SetQuerySnapshot(void); +extern void FreeXactSnapshot(void); #endif /* TQUAL_H */ diff --git a/src/include/utils/trace.h b/src/include/utils/trace.h index 29bda72486..8dce7013d4 100644 --- a/src/include/utils/trace.h +++ b/src/include/utils/trace.h @@ -27,7 +27,7 @@ char *tprintf_timestamp(void); #define TIMESTAMP_SIZE 0 #endif -extern int tprintf1(const char *fmt, ...); +extern int tprintf1(const char *fmt,...); extern int tprintf(int flag, const char *fmt,...); extern int eprintf(const char *fmt,...); extern int option_flag(int flag); @@ -77,12 +77,12 @@ extern int pg_options[NUM_PG_OPTIONS]; #ifdef __GNUC__ #define PRINTF(args...) tprintf1(args) -#define EPRINTF(args...) eprintf(args) +#define EPRINTF(args...) eprintf(args) #define TPRINTF(flag, args...) tprintf(flag, args) #else #define PRINTF tprintf1 #define EPRINTF eprintf -#define TPRINTF tprintf +#define TPRINTF tprintf #endif #endif /* TRACE_H */ diff --git a/src/interfaces/ecpg/include/ecpglib.h b/src/interfaces/ecpg/include/ecpglib.h index bac46c849b..9ceb691695 100644 --- a/src/interfaces/ecpg/include/ecpglib.h +++ b/src/interfaces/ecpg/include/ecpglib.h @@ -15,8 +15,8 @@ extern "C" bool ECPGdisconnect(int, const char *); bool ECPGprepare(int, char *, char *); bool ECPGdeallocate(int, char *); - char *ECPGprepared_statement(char *); - + char *ECPGprepared_statement(char *); + void ECPGlog(const char *format,...); #ifdef LIBPQ_FE_H diff --git a/src/interfaces/ecpg/lib/ecpglib.c b/src/interfaces/ecpg/lib/ecpglib.c index 5314a0a90d..88c3057d9a 100644 --- a/src/interfaces/ecpg/lib/ecpglib.c +++ b/src/interfaces/ecpg/lib/ecpglib.c @@ -52,12 +52,12 @@ struct sqlca sqlca = static struct connection { - char *name; - PGconn *connection; - bool committed; - int autocommit; + char *name; + PGconn *connection; + bool committed; + int autocommit; struct connection *next; -} *all_connections = NULL, *actual_connection = NULL; +} *all_connections = NULL, *actual_connection = NULL; struct variable { @@ -77,7 +77,7 @@ struct variable struct statement { - int lineno; + int lineno; char *command; struct connection *connection; struct variable *inlist; @@ -86,16 +86,16 @@ struct statement struct prepared_statement { - char *name; - struct statement *stmt; - struct prepared_statement *next; -} *prep_stmts = NULL; + char *name; + struct statement *stmt; + struct prepared_statement *next; +} *prep_stmts = NULL; struct auto_mem { - void *pointer; + void *pointer; struct auto_mem *next; -} *auto_allocs = NULL; +} *auto_allocs = NULL; static int simple_debug = 0; static FILE *debugstream = NULL; @@ -105,23 +105,23 @@ register_error(long code, char *fmt,...) { va_list args; struct auto_mem *am; - + sqlca.sqlcode = code; va_start(args, fmt); vsprintf(sqlca.sqlerrm.sqlerrmc, fmt, args); va_end(args); sqlca.sqlerrm.sqlerrml = strlen(sqlca.sqlerrm.sqlerrmc); - + /* free all memory we have allocated for the user */ for (am = auto_allocs; am;) { struct auto_mem *act = am; - - am = am->next; + + am = am->next; free(act->pointer); free(act); } - + auto_allocs = NULL; } @@ -129,10 +129,10 @@ static struct connection * get_connection(const char *connection_name) { struct connection *con = all_connections; - + if (connection_name == NULL || strcmp(connection_name, "CURRENT") == 0) return actual_connection; - + for (; con && strcmp(connection_name, con->name) != 0; con = con->next); if (con) return con; @@ -161,7 +161,7 @@ ECPGfinish(struct connection * act) if (actual_connection == act) actual_connection = all_connections; - + free(act->name); free(act); } @@ -180,7 +180,7 @@ ecpg_alloc(long size, int lineno) register_error(ECPG_OUT_OF_MEMORY, "Out of memory in line %d", lineno); return NULL; } - + memset(new, '\0', size); return (new); } @@ -204,7 +204,7 @@ static void add_mem(void *ptr, int lineno) { struct auto_mem *am = (struct auto_mem *) ecpg_alloc(sizeof(struct auto_mem), lineno); - + am->next = auto_allocs; auto_allocs = am; } @@ -251,7 +251,7 @@ quote_strings(char *arg, int lineno) char *res = (char *) ecpg_alloc(2 * strlen(arg) + 1, lineno); int i, ri; - bool string = false; + bool string = false; if (!res) return (res); @@ -277,7 +277,7 @@ quote_strings(char *arg, int lineno) } /* - * create a list of variables + * create a list of variables * The variables are listed with input variables preceeding outputvariables * The end of each group is marked by an end marker. * per variable we list: @@ -291,11 +291,11 @@ quote_strings(char *arg, int lineno) * ind_type - type of indicator variable * ind_value - pointer to indicator variable * ind_varcharsize - empty - * ind_arraysize - arraysize of indicator array + * ind_arraysize - arraysize of indicator array * ind_offset - indicator offset */ static bool -create_statement(int lineno, struct connection *connection, struct statement ** stmt, char *query, va_list ap) +create_statement(int lineno, struct connection * connection, struct statement ** stmt, char *query, va_list ap) { struct variable **list = &((*stmt)->inlist); enum ECPGttype type; @@ -325,8 +325,8 @@ create_statement(int lineno, struct connection *connection, struct statement ** var->type = type; var->pointer = va_arg(ap, void *); - - /* if variable is NULL, the statement hasn't been prepared */ + + /* if variable is NULL, the statement hasn't been prepared */ if (var->pointer == NULL) { ECPGlog("create_statement: invalid statement name\n"); @@ -334,16 +334,16 @@ create_statement(int lineno, struct connection *connection, struct statement ** free(var); return false; } - + var->varcharsize = va_arg(ap, long); var->arrsize = va_arg(ap, long); var->offset = va_arg(ap, long); if (var->arrsize == 0 || var->varcharsize == 0) - var->value = *((void **)(var->pointer)); + var->value = *((void **) (var->pointer)); else var->value = var->pointer; - + var->ind_type = va_arg(ap, enum ECPGttype); var->ind_value = va_arg(ap, void *); var->ind_varcharsize = va_arg(ap, long); @@ -366,16 +366,16 @@ create_statement(int lineno, struct connection *connection, struct statement ** } static void -free_variable(struct variable *var) +free_variable(struct variable * var) { - struct variable *var_next; + struct variable *var_next; - if( var == (struct variable *)NULL ) - return; + if (var == (struct variable *) NULL) + return; var_next = var->next; free(var); - while(var_next) + while (var_next) { var = var_next; var_next = var->next; @@ -384,9 +384,9 @@ free_variable(struct variable *var) } static void -free_statement(struct statement *stmt) +free_statement(struct statement * stmt) { - if( stmt == (struct statement *)NULL ) + if (stmt == (struct statement *) NULL) return; free_variable(stmt->inlist); free_variable(stmt->outlist); @@ -396,20 +396,20 @@ free_statement(struct statement *stmt) static char * next_insert(char *text) { - char *ptr = text; - bool string = false; - + char *ptr = text; + bool string = false; + for (; *ptr != '\0' && (*ptr != '?' || string); ptr++) if (*ptr == '\'') string = string ? false : true; - + return (*ptr == '\0') ? NULL : ptr; } static bool ECPGexecute(struct statement * stmt) { - bool status = false; + bool status = false; char *copiedquery; PGresult *results; PGnotify *notify; @@ -626,7 +626,7 @@ ECPGexecute(struct statement * stmt) strcat(newcopy, copiedquery + (p - newcopy) - + sizeof("?") - 1 /* don't count the '\0' */); + + sizeof("?") - 1 /* don't count the '\0' */ ); } /* @@ -675,7 +675,7 @@ ECPGexecute(struct statement * stmt) ECPGlog("ECPGexecute line %d: error: %s", stmt->lineno, PQerrorMessage(stmt->connection->connection)); register_error(ECPG_PGSQL, "Postgres error: %s line %d.", - PQerrorMessage(stmt->connection->connection), stmt->lineno); + PQerrorMessage(stmt->connection->connection), stmt->lineno); } else { @@ -729,39 +729,39 @@ ECPGexecute(struct statement * stmt) /* * allocate memory for NULL pointers - */ + */ if ((var->arrsize == 0 || var->varcharsize == 0) && var->value == NULL) { - int len = 0; - - switch(var->type) - { - case ECPGt_char: - case ECPGt_unsigned_char: - var->varcharsize = 0; - /* check strlen for each tuple */ - for (act_tuple = 0; act_tuple < ntuples; act_tuple++) - { - int len = strlen(PQgetvalue(results, act_tuple, act_field)) + 1; - - if (len > var->varcharsize) - var->varcharsize = len; - } - var->offset *= var->varcharsize; - len = var->offset * ntuples; - break; - case ECPGt_varchar: - len = ntuples * (var->varcharsize + sizeof (int)); - break; - default: - len = var->offset * ntuples; - break; - } - var->value = (void *) ecpg_alloc(len, stmt->lineno); - *((void **) var->pointer) = var->value; - add_mem(var->value, stmt->lineno); + int len = 0; + + switch (var->type) + { + case ECPGt_char: + case ECPGt_unsigned_char: + var->varcharsize = 0; + /* check strlen for each tuple */ + for (act_tuple = 0; act_tuple < ntuples; act_tuple++) + { + int len = strlen(PQgetvalue(results, act_tuple, act_field)) + 1; + + if (len > var->varcharsize) + var->varcharsize = len; + } + var->offset *= var->varcharsize; + len = var->offset * ntuples; + break; + case ECPGt_varchar: + len = ntuples * (var->varcharsize + sizeof(int)); + break; + default: + len = var->offset * ntuples; + break; + } + var->value = (void *) ecpg_alloc(len, stmt->lineno); + *((void **) var->pointer) = var->value; + add_mem(var->value, stmt->lineno); } - + for (act_tuple = 0; act_tuple < ntuples && status; act_tuple++) { pval = PQgetvalue(results, act_tuple, act_field); @@ -1034,7 +1034,7 @@ ECPGexecute(struct statement * stmt) default: ECPGlog("ECPGexecute line %d: Got something else, postgres error.\n", stmt->lineno); - register_error(ECPG_PGSQL, "Postgres error: %s line %d.", + register_error(ECPG_PGSQL, "Postgres error: %s line %d.", PQerrorMessage(stmt->connection->connection), stmt->lineno); status = false; break; @@ -1067,7 +1067,7 @@ ECPGdo(int lineno, const char *connection_name, char *query,...) register_error(ECPG_NO_CONN, "No such connection %s in line %d.", connection_name ? connection_name : "NULL", lineno); return (false); } - + va_start(args, query); if (create_statement(lineno, con, &stmt, query, args) == false) return (false); @@ -1096,7 +1096,7 @@ ECPGstatus(int lineno, const char *connection_name) register_error(ECPG_NO_CONN, "No such connection %s in line %d", connection_name ? connection_name : "NULL", lineno); return (false); } - + /* are we connected? */ if (con->connection == NULL) { @@ -1113,7 +1113,7 @@ ECPGtrans(int lineno, const char *connection_name, const char *transaction) { PGresult *res; struct connection *con = get_connection(connection_name); - + if (con == NULL) { register_error(ECPG_NO_CONN, "No such connection %s in line %d", connection_name ? connection_name : "NULL", lineno); @@ -1135,15 +1135,15 @@ ECPGtrans(int lineno, const char *connection_name, const char *transaction) if (strcmp(transaction, "commit") == 0 || strcmp(transaction, "rollback") == 0) { struct prepared_statement *this; - + con->committed = true; /* deallocate all prepared statements */ for (this = prep_stmts; this != NULL; this = this->next) { - bool b = ECPGdeallocate(lineno, this->name); - - if (!b) + bool b = ECPGdeallocate(lineno, this->name); + + if (!b) return false; } } @@ -1193,7 +1193,7 @@ ECPGsetcommit(int lineno, const char *mode, const char *connection_name) register_error(ECPG_NO_CONN, "No such connection %s in line %d", connection_name ? connection_name : "NULL", lineno); return false; } - + return true; } @@ -1251,7 +1251,7 @@ ECPGconnect(int lineno, const char *dbname, const char *user, const char *passwd register_error(ECPG_CONNECT, "connect: could not open database %s.", dbname ? dbname : "NULL"); return false; } - + this->committed = true; this->autocommit = autocommit; @@ -1276,7 +1276,7 @@ ECPGdisconnect(int lineno, const char *connection_name) else { con = get_connection(connection_name); - + if (con == NULL) { ECPGlog("disconnect: not connected to connection %s\n", connection_name ? connection_name : "NULL"); @@ -1333,27 +1333,27 @@ isvarchar(unsigned char c) { if (isalnum(c)) return true; - + if (c == '_' || c == '>' || c == '-' || c == '.') return true; - + if (c >= 128) return true; - - return(false); + + return (false); } static void replace_variables(char *text) { - char *ptr = text; - bool string = false; - + char *ptr = text; + bool string = false; + for (; *ptr != '\0'; ptr++) { if (*ptr == '\'') string = string ? false : true; - + if (!string && *ptr == ':') { *ptr = '?'; @@ -1369,21 +1369,21 @@ ECPGprepare(int lineno, char *name, char *variable) { struct statement *stmt; struct prepared_statement *this; - + /* check if we already have prepared this statement */ - for (this = prep_stmts; this != NULL && strcmp(this->name, name) != 0; this = this->next); + for (this = prep_stmts; this != NULL && strcmp(this->name, name) != 0; this = this->next); if (this) { - bool b = ECPGdeallocate(lineno, name); - - if (!b) + bool b = ECPGdeallocate(lineno, name); + + if (!b) return false; } - + this = (struct prepared_statement *) ecpg_alloc(sizeof(struct prepared_statement), lineno); if (!this) return false; - + stmt = (struct statement *) ecpg_alloc(sizeof(struct statement), lineno); if (!stmt) { @@ -1393,13 +1393,13 @@ ECPGprepare(int lineno, char *name, char *variable) /* create statement */ stmt->lineno = lineno; - stmt->connection = NULL; - stmt->command = ecpg_strdup(variable, lineno); - stmt->inlist = stmt->outlist = NULL; - - /* if we have C variables in our statment replace them with '?' */ - replace_variables(stmt->command); - + stmt->connection = NULL; + stmt->command = ecpg_strdup(variable, lineno); + stmt->inlist = stmt->outlist = NULL; + + /* if we have C variables in our statment replace them with '?' */ + replace_variables(stmt->command); + /* add prepared statement to our list */ this->name = ecpg_strdup(name, lineno); this->stmt = stmt; @@ -1417,10 +1417,11 @@ ECPGprepare(int lineno, char *name, char *variable) bool ECPGdeallocate(int lineno, char *name) { - struct prepared_statement *this, *prev; + struct prepared_statement *this, + *prev; /* check if we really have prepared this statement */ - for (this = prep_stmts, prev = NULL; this != NULL && strcmp(this->name, name) != 0; prev = this, this = this->next); + for (this = prep_stmts, prev = NULL; this != NULL && strcmp(this->name, name) != 0; prev = this, this = this->next); if (this) { /* okay, free all the resources */ @@ -1431,7 +1432,7 @@ ECPGdeallocate(int lineno, char *name) prev->next = this->next; else prep_stmts = this->next; - + return true; } ECPGlog("deallocate_prepare: invalid statement name %s\n", name); @@ -1444,8 +1445,7 @@ char * ECPGprepared_statement(char *name) { struct prepared_statement *this; - + for (this = prep_stmts; this != NULL && strcmp(this->name, name) != 0; this = this->next); return (this) ? this->stmt->command : NULL; } - diff --git a/src/interfaces/ecpg/lib/typename.c b/src/interfaces/ecpg/lib/typename.c index af87b160aa..8a9923d940 100644 --- a/src/interfaces/ecpg/lib/typename.c +++ b/src/interfaces/ecpg/lib/typename.c @@ -8,7 +8,7 @@ ECPGtype_name(enum ECPGttype typ) { switch (typ) { - case ECPGt_char: + case ECPGt_char: return "char"; case ECPGt_unsigned_char: return "unsigned char"; diff --git a/src/interfaces/ecpg/preproc/ecpg.c b/src/interfaces/ecpg/preproc/ecpg.c index b385b2a197..aa6c2c274b 100644 --- a/src/interfaces/ecpg/preproc/ecpg.c +++ b/src/interfaces/ecpg/preproc/ecpg.c @@ -157,12 +157,13 @@ main(int argc, char *const argv[]) struct cursor *ptr; struct _defines *defptr; struct typedefs *typeptr; - + /* remove old cursor definitions if any are still there */ for (ptr = cur; ptr != NULL;) { struct cursor *this = ptr; - struct arguments *l1, *l2; + struct arguments *l1, + *l2; free(ptr->command); free(ptr->connection); @@ -191,7 +192,7 @@ main(int argc, char *const argv[]) defptr = defptr->next; free(this); } - + /* and old typedefs */ for (typeptr = types; typeptr != NULL;) { @@ -203,7 +204,7 @@ main(int argc, char *const argv[]) typeptr = typeptr->next; free(this); } - + /* initialize lex */ lex_init(); diff --git a/src/interfaces/ecpg/preproc/extern.h b/src/interfaces/ecpg/preproc/extern.h index 3892014ed3..52a3896f53 100644 --- a/src/interfaces/ecpg/preproc/extern.h +++ b/src/interfaces/ecpg/preproc/extern.h @@ -5,8 +5,10 @@ /* variables */ extern int braces_open, - autocommit, struct_level; -extern char *yytext, errortext[128]; + autocommit, + struct_level; +extern char *yytext, + errortext[128]; extern int yylineno, yyleng; extern FILE *yyin, @@ -36,9 +38,9 @@ extern void yyerror(char *); /* return codes */ #define OK 0 -#define PARSE_ERROR -1 +#define PARSE_ERROR -1 #define ILLEGAL_OPTION -2 -#define INDICATOR_NOT_ARRAY -3 +#define INDICATOR_NOT_ARRAY -3 #define NO_INCLUDE_FILE ENOENT #define OUT_OF_MEMORY ENOMEM diff --git a/src/interfaces/ecpg/preproc/type.c b/src/interfaces/ecpg/preproc/type.c index 3c5d2f3ed0..30580a775c 100644 --- a/src/interfaces/ecpg/preproc/type.c +++ b/src/interfaces/ecpg/preproc/type.c @@ -123,7 +123,7 @@ get_type(enum ECPGttype typ) { switch (typ) { - case ECPGt_char: + case ECPGt_char: return ("ECPGt_char"); break; case ECPGt_unsigned_char: @@ -161,14 +161,15 @@ get_type(enum ECPGttype typ) case ECPGt_NO_INDICATOR: /* no indicator */ return ("ECPGt_NO_INDICATOR"); break; - case ECPGt_char_variable: /* string that should not be quoted */ + case ECPGt_char_variable: /* string that should not be + * quoted */ return ("ECPGt_char_variable"); break; default: sprintf(errortext, "illegal variable type %d\n", typ); yyerror(errortext); } - + return NULL; } @@ -208,16 +209,16 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * typ, const char *in switch (typ->u.element->typ) { case ECPGt_array: - yyerror("No nested arrays allowed (except strings)"); /* array of array */ + yyerror("No nested arrays allowed (except strings)"); /* array of array */ break; case ECPGt_struct: case ECPGt_union: - ECPGdump_a_struct(o, name, ind_name, typ->size, typ->u.element, ind_typ->u.element, NULL, prefix, ind_prefix); + ECPGdump_a_struct(o, name, ind_name, typ->size, typ->u.element, ind_typ->u.element, NULL, prefix, ind_prefix); break; - default: + default: if (!IS_SIMPLE_TYPE(typ->u.element->typ)) yyerror("Internal error: unknown datatype, please inform pgsql-bugs@postgresql.org"); - + ECPGdump_a_simple(o, name, typ->u.element->typ, typ->u.element->size, typ->size, NULL, prefix); if (ind_typ->typ == ECPGt_NO_INDICATOR) @@ -227,17 +228,17 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * typ, const char *in if (ind_typ->typ != ECPGt_array) { fprintf(stderr, "Indicator for an array has to be array too.\n"); - exit(INDICATOR_NOT_ARRAY); - } + exit(INDICATOR_NOT_ARRAY); + } ECPGdump_a_simple(o, ind_name, ind_typ->u.element->typ, - ind_typ->u.element->size, ind_typ->size, NULL, prefix); + ind_typ->u.element->size, ind_typ->size, NULL, prefix); } } break; case ECPGt_struct: ECPGdump_a_struct(o, name, ind_name, 1, typ, ind_typ, NULL, prefix, ind_prefix); break; - case ECPGt_union: /* cannot dump a complete union */ + case ECPGt_union: /* cannot dump a complete union */ yyerror("Type of union has to be specified"); break; case ECPGt_char_variable: @@ -364,12 +365,12 @@ ECPGfree_type(struct ECPGtype * typ) { if (!IS_SIMPLE_TYPE(typ->typ)) { - switch(typ->typ) + switch (typ->typ) { - case ECPGt_array: + case ECPGt_array: switch (typ->u.element->typ) { - case ECPGt_array: + case ECPGt_array: yyerror("internal error, found multi-dimensional array\n"); break; case ECPGt_struct: @@ -378,7 +379,7 @@ ECPGfree_type(struct ECPGtype * typ) ECPGfree_struct_member(typ->u.element->u.members); free(typ->u.members); break; - default: + default: if (!IS_SIMPLE_TYPE(typ->u.element->typ)) yyerror("Internal error: unknown datatype, please inform pgsql-bugs@postgresql.org"); diff --git a/src/interfaces/ecpg/preproc/type.h b/src/interfaces/ecpg/preproc/type.h index ed97b2e667..7cdc476e83 100644 --- a/src/interfaces/ecpg/preproc/type.h +++ b/src/interfaces/ecpg/preproc/type.h @@ -30,7 +30,7 @@ struct ECPGtype *ECPGmake_simple_type(enum ECPGttype, long); struct ECPGtype *ECPGmake_varchar_type(enum ECPGttype, long); struct ECPGtype *ECPGmake_array_type(struct ECPGtype *, long); struct ECPGtype *ECPGmake_struct_type(struct ECPGstruct_member *, enum ECPGttype type); -struct ECPGstruct_member * ECPGstruct_member_dup(struct ECPGstruct_member *); +struct ECPGstruct_member *ECPGstruct_member_dup(struct ECPGstruct_member *); /* Frees a type. */ void ECPGfree_struct_member(struct ECPGstruct_member *); @@ -71,7 +71,7 @@ enum WHEN_TYPE struct when { - enum WHEN_TYPE code; + enum WHEN_TYPE code; char *command; char *str; }; @@ -85,10 +85,10 @@ struct index struct this_type { - enum ECPGttype type_enum; - char *type_str; - int type_dimension; - int type_index; + enum ECPGttype type_enum; + char *type_str; + int type_dimension; + int type_index; }; struct _include_path @@ -109,8 +109,8 @@ struct cursor struct typedefs { - char *name; - struct this_type *type; + char *name; + struct this_type *type; struct ECPGstruct_member *struct_member_list; struct typedefs *next; }; diff --git a/src/interfaces/ecpg/test/header_test.h b/src/interfaces/ecpg/test/header_test.h index d6a84322b1..b93221c339 100644 --- a/src/interfaces/ecpg/test/header_test.h +++ b/src/interfaces/ecpg/test/header_test.h @@ -1,15 +1,19 @@ exec sql include sqlca; -exec sql whenever sqlerror do PrintAndStop(); -exec sql whenever sqlwarning do warn(); +exec sql whenever sqlerror +do + PrintAndStop(); +exec sql whenever sqlwarning +do + warn(); -void PrintAndStop(void) +void PrintAndStop(void) { sqlprint(); exit(-1); } -void warn(void) +void warn(void) { fprintf(stderr, "Warning: At least one column was truncated\n"); } diff --git a/src/interfaces/libpgtcl/pgtclCmds.c b/src/interfaces/libpgtcl/pgtclCmds.c index 99b6f925e6..0c2b184ed6 100644 --- a/src/interfaces/libpgtcl/pgtclCmds.c +++ b/src/interfaces/libpgtcl/pgtclCmds.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclCmds.c,v 1.42 1999/05/10 00:46:22 momjian Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclCmds.c,v 1.43 1999/05/25 16:15:06 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -28,7 +28,7 @@ #define DIGIT(c) ((c) - '0') /* - * translate_escape() + * translate_escape() * * This function performs in-place translation of a single C-style * escape sequence pointed by p. Curly braces { } and double-quote @@ -132,7 +132,7 @@ translate_escape(char *p, int isArray) } /* - * tcl_value() + * tcl_value() * * This function does in-line conversion of a value returned by libpq * into a tcl string or into a tcl list if the value looks like the @@ -219,7 +219,7 @@ tcl_value(char *value) return value; } -#endif /* TCL_ARRAYS */ +#endif /* TCL_ARRAYS */ /********************************** @@ -241,12 +241,13 @@ Pg_conndefaults(ClientData cData, Tcl_Interp * interp, int argc, char **argv) { PQconninfoOption *option; Tcl_DString result; - char ibuf[32]; + char ibuf[32]; Tcl_DStringInit(&result); for (option = PQconndefaults(); option->keyword != NULL; option++) { - char * val = option->val ? option->val : ""; + char *val = option->val ? option->val : ""; + sprintf(ibuf, "%d", option->dispsize); Tcl_DStringStartSublist(&result); Tcl_DStringAppendElement(&result, option->keyword); @@ -359,7 +360,7 @@ Pg_connect(ClientData cData, Tcl_Interp * interp, int argc, char *argv[]) conn = PQsetdb(pghost, pgport, pgoptions, pgtty, dbName); } - if (PQstatus(conn) == CONNECTION_OK) + if (PQstatus(conn) == CONNECTION_OK) { PgSetConnectionId(interp, conn); return TCL_OK; @@ -367,7 +368,7 @@ Pg_connect(ClientData cData, Tcl_Interp * interp, int argc, char *argv[]) else { Tcl_AppendResult(interp, "Connection to database failed\n", - PQerrorMessage(conn), 0); + PQerrorMessage(conn), 0); PQfinish(conn); return TCL_ERROR; } @@ -452,6 +453,7 @@ Pg_exec(ClientData cData, Tcl_Interp * interp, int argc, char *argv[]) int rId = PgSetResultId(interp, argv[1], result); ExecStatusType rStat = PQresultStatus(result); + if (rStat == PGRES_COPY_IN || rStat == PGRES_COPY_OUT) { connid->res_copyStatus = RES_COPY_INPROGRESS; @@ -473,11 +475,11 @@ Pg_exec(ClientData cData, Tcl_Interp * interp, int argc, char *argv[]) syntax: - pg_result result ?option? + pg_result result ?option? the options are: - -status the status of the result + -status the status of the result -error the error message, if the status indicates error; otherwise an empty string @@ -491,11 +493,11 @@ Pg_exec(ClientData cData, Tcl_Interp * interp, int argc, char *argv[]) -numAttrs returns the number of attributes returned by the query -assign arrayName - assign the results to an array, using subscripts of the form - (tupno,attributeName) + assign the results to an array, using subscripts of the form + (tupno,attributeName) -assignbyidx arrayName ?appendstr? - assign the results to an array using the first field's value + assign the results to an array using the first field's value as a key. All but the first field of each tuple are stored, using subscripts of the form (field0value,attributeNameappendstr) @@ -504,17 +506,17 @@ Pg_exec(ClientData cData, Tcl_Interp * interp, int argc, char *argv[]) returns the values of the tuple in a list -tupleArray tupleNumber arrayName - stores the values of the tuple in array arrayName, indexed + stores the values of the tuple in array arrayName, indexed by the attributes returned -attributes - returns a list of the name/type pairs of the tuple attributes + returns a list of the name/type pairs of the tuple attributes -lAttributes - returns a list of the {name type len} entries of the tuple + returns a list of the {name type len} entries of the tuple attributes - -clear clear the result buffer. Do not reuse after this + -clear clear the result buffer. Do not reuse after this **********************************/ int @@ -526,12 +528,12 @@ Pg_result(ClientData cData, Tcl_Interp * interp, int argc, char *argv[]) int tupno; char *arrVar; char nameBuffer[256]; - const char *appendstr; + const char *appendstr; if (argc < 3 || argc > 5) { Tcl_AppendResult(interp, "Wrong # of arguments\n", 0); - goto Pg_result_errReturn; /* append help info */ + goto Pg_result_errReturn; /* append help info */ } result = PgGetResultId(interp, argv[1]); @@ -550,7 +552,7 @@ Pg_result(ClientData cData, Tcl_Interp * interp, int argc, char *argv[]) } else if (strcmp(opt, "-error") == 0) { - Tcl_SetResult(interp, (char*) PQresultErrorMessage(result), + Tcl_SetResult(interp, (char *) PQresultErrorMessage(result), TCL_STATIC); return TCL_OK; } @@ -588,11 +590,10 @@ Pg_result(ClientData cData, Tcl_Interp * interp, int argc, char *argv[]) /* * this assignment assigns the table of result tuples into a giant - * array with the name given in the argument. - * The indices of the array are of the form (tupno,attrName). - * Note we expect field names not to - * exceed a few dozen characters, so truncating to prevent buffer - * overflow shouldn't be a problem. + * array with the name given in the argument. The indices of the + * array are of the form (tupno,attrName). Note we expect field + * names not to exceed a few dozen characters, so truncating to + * prevent buffer overflow shouldn't be a problem. */ for (tupno = 0; tupno < PQntuples(result); tupno++) { @@ -616,7 +617,7 @@ Pg_result(ClientData cData, Tcl_Interp * interp, int argc, char *argv[]) { if (argc != 4 && argc != 5) { - Tcl_AppendResult(interp, "-assignbyidx option requires an array name and optionally an append string",0); + Tcl_AppendResult(interp, "-assignbyidx option requires an array name and optionally an append string", 0); return TCL_ERROR; } arrVar = argv[3]; @@ -624,25 +625,27 @@ Pg_result(ClientData cData, Tcl_Interp * interp, int argc, char *argv[]) /* * this assignment assigns the table of result tuples into a giant - * array with the name given in the argument. The indices of the array - * are of the form (field0Value,attrNameappendstr). - * Here, we still assume PQfname won't exceed 200 characters, - * but we dare not make the same assumption about the data in field 0 - * nor the append string. + * array with the name given in the argument. The indices of the + * array are of the form (field0Value,attrNameappendstr). Here, we + * still assume PQfname won't exceed 200 characters, but we dare + * not make the same assumption about the data in field 0 nor the + * append string. */ for (tupno = 0; tupno < PQntuples(result); tupno++) { - const char *field0 = + const char *field0 = #ifdef TCL_ARRAYS - tcl_value(PQgetvalue(result, tupno, 0)); + tcl_value(PQgetvalue(result, tupno, 0)); + #else - PQgetvalue(result, tupno, 0); + PQgetvalue(result, tupno, 0); + #endif - char *workspace = malloc(strlen(field0) + strlen(appendstr) + 210); + char *workspace = malloc(strlen(field0) + strlen(appendstr) + 210); for (i = 1; i < PQnfields(result); i++) { - sprintf(workspace, "%s,%.200s%s", field0, PQfname(result,i), + sprintf(workspace, "%s,%.200s%s", field0, PQfname(result, i), appendstr); if (Tcl_SetVar2(interp, arrVar, workspace, #ifdef TCL_ARRAYS @@ -676,9 +679,7 @@ Pg_result(ClientData cData, Tcl_Interp * interp, int argc, char *argv[]) } #ifdef TCL_ARRAYS for (i = 0; i < PQnfields(result); i++) - { Tcl_AppendElement(interp, tcl_value(PQgetvalue(result, tupno, i))); - } #else for (i = 0; i < PQnfields(result); i++) Tcl_AppendElement(interp, PQgetvalue(result, tupno, i)); @@ -739,7 +740,7 @@ Pg_result(ClientData cData, Tcl_Interp * interp, int argc, char *argv[]) else { Tcl_AppendResult(interp, "Invalid option\n", 0); - goto Pg_result_errReturn; /* append help info */ + goto Pg_result_errReturn; /* append help info */ } @@ -1298,7 +1299,7 @@ Pg_select(ClientData cData, Tcl_Interp * interp, int argc, char **argv) if (PQresultStatus(result) != PGRES_TUPLES_OK) { /* query failed, or it wasn't SELECT */ - Tcl_SetResult(interp, (char*) PQresultErrorMessage(result), + Tcl_SetResult(interp, (char *) PQresultErrorMessage(result), TCL_VOLATILE); PQclear(result); return TCL_ERROR; @@ -1374,7 +1375,7 @@ Pg_select(ClientData cData, Tcl_Interp * interp, int argc, char **argv) */ static int -Pg_have_listener (Pg_ConnectionId *connid, const char * relname) +Pg_have_listener(Pg_ConnectionId * connid, const char *relname) { Pg_TclNotifies *notifies; Tcl_HashEntry *entry; @@ -1388,7 +1389,7 @@ Pg_have_listener (Pg_ConnectionId *connid, const char * relname) if (interp == NULL) continue; /* ignore deleted interpreter */ - entry = Tcl_FindHashEntry(¬ifies->notify_hash, (char*) relname); + entry = Tcl_FindHashEntry(¬ifies->notify_hash, (char *) relname); if (entry == NULL) continue; /* no pg_listen in this interpreter */ @@ -1491,14 +1492,15 @@ Pg_listen(ClientData cData, Tcl_Interp * interp, int argc, char *argv[]) if (callback) { + /* * Create or update a callback for a relation */ - int alreadyHadListener = Pg_have_listener(connid, caserelname); + int alreadyHadListener = Pg_have_listener(connid, caserelname); entry = Tcl_CreateHashEntry(¬ifies->notify_hash, caserelname, &new); /* If update, free the old callback string */ - if (! new) + if (!new) ckfree((char *) Tcl_GetHashValue(entry)); /* Store the new callback string */ Tcl_SetHashValue(entry, callback); @@ -1509,10 +1511,11 @@ Pg_listen(ClientData cData, Tcl_Interp * interp, int argc, char *argv[]) /* * Send a LISTEN command if this is the first listener. */ - if (! alreadyHadListener) + if (!alreadyHadListener) { - char *cmd = (char *) - ckalloc((unsigned) (strlen(origrelname) + 8)); + char *cmd = (char *) + ckalloc((unsigned) (strlen(origrelname) + 8)); + sprintf(cmd, "LISTEN %s", origrelname); result = PQexec(conn, cmd); ckfree(cmd); @@ -1533,6 +1536,7 @@ Pg_listen(ClientData cData, Tcl_Interp * interp, int argc, char *argv[]) } else { + /* * Remove a callback for a relation */ @@ -1545,15 +1549,17 @@ Pg_listen(ClientData cData, Tcl_Interp * interp, int argc, char *argv[]) } ckfree((char *) Tcl_GetHashValue(entry)); Tcl_DeleteHashEntry(entry); + /* - * Send an UNLISTEN command if that was the last listener. - * Note: we don't attempt to turn off the notify mechanism - * if no LISTENs remain active; not worth the trouble. + * Send an UNLISTEN command if that was the last listener. Note: + * we don't attempt to turn off the notify mechanism if no LISTENs + * remain active; not worth the trouble. */ - if (! Pg_have_listener(connid, caserelname)) + if (!Pg_have_listener(connid, caserelname)) { - char *cmd = (char *) - ckalloc((unsigned) (strlen(origrelname) + 10)); + char *cmd = (char *) + ckalloc((unsigned) (strlen(origrelname) + 10)); + sprintf(cmd, "UNLISTEN %s", origrelname); result = PQexec(conn, cmd); ckfree(cmd); diff --git a/src/interfaces/libpgtcl/pgtclCmds.h b/src/interfaces/libpgtcl/pgtclCmds.h index 767c266b05..495bf19e33 100644 --- a/src/interfaces/libpgtcl/pgtclCmds.h +++ b/src/interfaces/libpgtcl/pgtclCmds.h @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pgtclCmds.h,v 1.13 1999/02/13 23:22:38 momjian Exp $ + * $Id: pgtclCmds.h,v 1.14 1999/05/25 16:15:07 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -54,7 +54,7 @@ typedef struct Pg_ConnectionId_s Pg_TclNotifies *notify_list;/* head of list of notify info */ int notifier_running; /* notify event source is live */ - int notifier_socket; /* PQsocket on which notifier is listening */ + int notifier_socket;/* PQsocket on which notifier is listening */ } Pg_ConnectionId; /* Values of res_copyStatus */ diff --git a/src/interfaces/libpgtcl/pgtclId.c b/src/interfaces/libpgtcl/pgtclId.c index ae5e9ba1b9..b8d30ce4f4 100644 --- a/src/interfaces/libpgtcl/pgtclId.c +++ b/src/interfaces/libpgtcl/pgtclId.c @@ -12,7 +12,7 @@ * Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclId.c,v 1.18 1999/02/13 23:22:38 momjian Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclId.c,v 1.19 1999/05/25 16:15:07 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -34,7 +34,7 @@ PgEndCopy(Pg_ConnectionId * connid, int *errorCodePtr) { PQclear(connid->results[connid->res_copy]); connid->results[connid->res_copy] = - PQmakeEmptyPGresult(connid->conn, PGRES_BAD_RESPONSE); + PQmakeEmptyPGresult(connid->conn, PGRES_BAD_RESPONSE); connid->res_copy = -1; *errorCodePtr = EIO; return -1; @@ -43,51 +43,53 @@ PgEndCopy(Pg_ConnectionId * connid, int *errorCodePtr) { PQclear(connid->results[connid->res_copy]); connid->results[connid->res_copy] = - PQmakeEmptyPGresult(connid->conn, PGRES_COMMAND_OK); + PQmakeEmptyPGresult(connid->conn, PGRES_COMMAND_OK); connid->res_copy = -1; return 0; } } /* - * Called when reading data (via gets) for a copy to stdout. + * Called when reading data (via gets) for a copy to stdout. */ -int PgInputProc(DRIVER_INPUT_PROTO) +int +PgInputProc(DRIVER_INPUT_PROTO) { - Pg_ConnectionId *connid; - PGconn *conn; - int avail; + Pg_ConnectionId *connid; + PGconn *conn; + int avail; - connid = (Pg_ConnectionId *)cData; - conn = connid->conn; + connid = (Pg_ConnectionId *) cData; + conn = connid->conn; - if (connid->res_copy < 0 || - PQresultStatus(connid->results[connid->res_copy]) != PGRES_COPY_OUT) + if (connid->res_copy < 0 || + PQresultStatus(connid->results[connid->res_copy]) != PGRES_COPY_OUT) { *errorCodePtr = EBUSY; return -1; - } + } - /* Read any newly arrived data into libpq's buffer, - * thereby clearing the socket's read-ready condition. - */ - if (! PQconsumeInput(conn)) + /* + * Read any newly arrived data into libpq's buffer, thereby clearing + * the socket's read-ready condition. + */ + if (!PQconsumeInput(conn)) { *errorCodePtr = EIO; return -1; - } + } - /* Move data from libpq's buffer to Tcl's. */ + /* Move data from libpq's buffer to Tcl's. */ - avail = PQgetlineAsync(conn, buf, bufSize); + avail = PQgetlineAsync(conn, buf, bufSize); - if (avail < 0) + if (avail < 0) { - /* Endmarker detected, change state and return 0 */ - return PgEndCopy(connid, errorCodePtr); - } + /* Endmarker detected, change state and return 0 */ + return PgEndCopy(connid, errorCodePtr); + } - return avail; + return avail; } /* @@ -103,13 +105,13 @@ PgOutputProc(DRIVER_OUTPUT_PROTO) conn = connid->conn; if (connid->res_copy < 0 || - PQresultStatus(connid->results[connid->res_copy]) != PGRES_COPY_IN) + PQresultStatus(connid->results[connid->res_copy]) != PGRES_COPY_IN) { *errorCodePtr = EBUSY; return -1; } - if (PQputnbytes(conn, buf, bufSize)) + if (PQputnbytes(conn, buf, bufSize)) { *errorCodePtr = EIO; return -1; @@ -358,7 +360,7 @@ getresid(Tcl_Interp * interp, char *id, Pg_ConnectionId ** connid_p) connid = (Pg_ConnectionId *) Tcl_GetChannelInstanceData(conn_chan); - if (resid < 0 || resid >= connid->res_max || connid->results[resid] == NULL) + if (resid < 0 || resid >= connid->res_max || connid->results[resid] == NULL) { Tcl_SetResult(interp, "Invalid result handle", TCL_STATIC); return -1; @@ -450,7 +452,7 @@ error_out: the channel can outlive the interpreter it was created by!) Upon closure of the channel, we immediately delete the file event handler for it, which has the effect of disabling any file-ready events that might - be hanging about in the Tcl event queue. But for interpreter deletion, + be hanging about in the Tcl event queue. But for interpreter deletion, we just set any matching interp pointers in the Pg_TclNotifies list to NULL. The list item stays around until the connection is deleted. (This avoids trouble with walking through a list whose members may get deleted under us.) @@ -459,10 +461,10 @@ error_out: libpgtcl currently claims to work with Tcl 7.5, 7.6, and 8.0, and each of 'em is different. Worse, the Tcl_File type went away in 8.0, which means there is no longer any platform-independent way of waiting for file ready. - So we now have to use a Unix-specific interface. Grumble. + So we now have to use a Unix-specific interface. Grumble. In the current design, Pg_Notify_FileHandler is a file handler that - we establish by calling Tcl_CreateFileHandler(). It gets invoked from + we establish by calling Tcl_CreateFileHandler(). It gets invoked from the Tcl event loop whenever the underlying PGconn's socket is read-ready. We suck up any available data (to clear the OS-level read-ready condition) and then transfer any available PGnotify events into the Tcl event queue. @@ -473,8 +475,8 @@ error_out: typedef struct { - Tcl_Event header; /* Standard Tcl event info */ - PGnotify info; /* Notify name from SQL server */ + Tcl_Event header; /* Standard Tcl event info */ + PGnotify info; /* Notify name from SQL server */ Pg_ConnectionId *connid; /* Connection for server */ } NotifyEvent; @@ -620,7 +622,7 @@ PgNotifyInterpDelete(ClientData clientData, Tcl_Interp * interp) * Therefore we daren't tell Tcl_DeleteEvents to actually delete anything! * We simply use it as a way of scanning the event queue. Events matching * the about-to-be-deleted connid are marked dead by setting their connid - * fields to NULL. Then Pg_Notify_EventProc will do nothing when those + * fields to NULL. Then Pg_Notify_EventProc will do nothing when those * events are executed. */ static int @@ -631,6 +633,7 @@ NotifyEventDeleteProc(Tcl_Event * evPtr, ClientData clientData) if (evPtr->proc == Pg_Notify_EventProc) { NotifyEvent *event = (NotifyEvent *) evPtr; + if (event->connid == connid) event->connid = NULL; } @@ -644,13 +647,14 @@ NotifyEventDeleteProc(Tcl_Event * evPtr, ClientData clientData) */ static void -Pg_Notify_FileHandler (ClientData clientData, int mask) +Pg_Notify_FileHandler(ClientData clientData, int mask) { Pg_ConnectionId *connid = (Pg_ConnectionId *) clientData; /* * Consume any data available from the SQL server (this just buffers - * it internally to libpq; but it will clear the read-ready condition). + * it internally to libpq; but it will clear the read-ready + * condition). */ PQconsumeInput(connid->conn); @@ -667,7 +671,7 @@ Pg_Notify_FileHandler (ClientData clientData, int mask) * notifier is run until the connection is closed. * * FIXME: if PQreset is executed on the underlying PGconn, the active - * socket number could change. How and when should we test for this + * socket number could change. How and when should we test for this * and update the Tcl file handler linkage? (For that matter, we'd * also have to reissue LISTEN commands for active LISTENs, since the * new backend won't know about 'em. I'm leaving this problem for @@ -680,18 +684,20 @@ PgStartNotifyEventSource(Pg_ConnectionId * connid) /* Start the notify event source if it isn't already running */ if (!connid->notifier_running) { - int pqsock = PQsocket(connid->conn); + int pqsock = PQsocket(connid->conn); + if (pqsock >= 0) { #if TCL_MAJOR_VERSION >= 8 /* In Tcl 8, Tcl_CreateFileHandler takes a socket directly. */ Tcl_CreateFileHandler(pqsock, TCL_READABLE, - Pg_Notify_FileHandler, (ClientData) connid); + Pg_Notify_FileHandler, (ClientData) connid); #else /* In Tcl 7.5 and 7.6, we need to gin up a Tcl_File. */ - Tcl_File tclfile = Tcl_GetFile((ClientData) pqsock, TCL_UNIX_FD); + Tcl_File tclfile = Tcl_GetFile((ClientData) pqsock, TCL_UNIX_FD); + Tcl_CreateFileHandler(tclfile, TCL_READABLE, - Pg_Notify_FileHandler, (ClientData) connid); + Pg_Notify_FileHandler, (ClientData) connid); #endif connid->notifier_running = 1; connid->notifier_socket = pqsock; @@ -710,8 +716,9 @@ PgStopNotifyEventSource(Pg_ConnectionId * connid) Tcl_DeleteFileHandler(connid->notifier_socket); #else /* In Tcl 7.5 and 7.6, we need to gin up a Tcl_File. */ - Tcl_File tclfile = Tcl_GetFile((ClientData) connid->notifier_socket, - TCL_UNIX_FD); + Tcl_File tclfile = Tcl_GetFile((ClientData) connid->notifier_socket, + TCL_UNIX_FD); + Tcl_DeleteFileHandler(tclfile); #endif connid->notifier_running = 0; diff --git a/src/interfaces/libpgtcl/pgtclId.h b/src/interfaces/libpgtcl/pgtclId.h index f2877b8059..046ab39a08 100644 --- a/src/interfaces/libpgtcl/pgtclId.h +++ b/src/interfaces/libpgtcl/pgtclId.h @@ -9,7 +9,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pgtclId.h,v 1.10 1999/02/13 23:22:39 momjian Exp $ + * $Id: pgtclId.h,v 1.11 1999/05/25 16:15:08 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -34,7 +34,7 @@ extern void PgSetConnectionId(Tcl_Interp * interp, PGconn *conn); #endif extern PGconn *PgGetConnectionId(Tcl_Interp * interp, char *id, - Pg_ConnectionId **); + Pg_ConnectionId **); extern PgDelConnectionId(DRIVER_DEL_PROTO); extern int PgOutputProc(DRIVER_OUTPUT_PROTO); extern PgInputProc(DRIVER_INPUT_PROTO); @@ -56,6 +56,7 @@ extern void PgNotifyInterpDelete(ClientData clientData, Tcl_Interp * interp); #if HAVE_TCL_GETFILEPROC extern Tcl_File PgGetFileProc(ClientData cData, int direction); + #endif extern Tcl_ChannelType Pg_ConnType; diff --git a/src/interfaces/libpq/fe-auth.c b/src/interfaces/libpq/fe-auth.c index 5ecb4f517a..534e8eda58 100644 --- a/src/interfaces/libpq/fe-auth.c +++ b/src/interfaces/libpq/fe-auth.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.28 1999/05/10 00:46:25 momjian Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.29 1999/05/25 16:15:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -92,7 +92,7 @@ static struct authsvc authsvcs[] = { {"password", STARTUP_PASSWORD_MSG, 0} }; -static int n_authsvcs = sizeof(authsvcs) / sizeof(struct authsvc); +static int n_authsvcs = sizeof(authsvcs) / sizeof(struct authsvc); #ifdef KRB4 /*---------------------------------------------------------------- @@ -144,8 +144,8 @@ pg_krb4_init() static char * pg_krb4_authname(char *PQerrormsg) { - char instance[INST_SZ+1]; - char realm[REALM_SZ+1]; + char instance[INST_SZ + 1]; + char realm[REALM_SZ + 1]; int status; static char name[SNAME_SZ + 1] = ""; @@ -299,7 +299,7 @@ pg_krb5_init(void) if (code = krb5_cc_resolve(tktbuf, &ccache)) { (void) sprintf(PQerrormsg, - "pg_krb5_init: Kerberos error %d in krb5_cc_resolve\n", code); + "pg_krb5_init: Kerberos error %d in krb5_cc_resolve\n", code); com_err("pg_krb5_init", code, "in krb5_cc_resolve"); return (krb5_ccache) NULL; } @@ -328,14 +328,14 @@ pg_krb5_authname(const char *PQerrormsg) if (code = krb5_cc_get_principal(ccache, &principal)) { (void) sprintf(PQerrormsg, - "pg_krb5_authname: Kerberos error %d in krb5_cc_get_principal\n", code); + "pg_krb5_authname: Kerberos error %d in krb5_cc_get_principal\n", code); com_err("pg_krb5_authname", code, "in krb5_cc_get_principal"); return (char *) NULL; } if (code = krb5_unparse_name(principal, &authname)) { (void) sprintf(PQerrormsg, - "pg_krb5_authname: Kerberos error %d in krb5_unparse_name\n", code); + "pg_krb5_authname: Kerberos error %d in krb5_unparse_name\n", code); com_err("pg_krb5_authname", code, "in krb5_unparse_name"); krb5_free_principal(principal); return (char *) NULL; @@ -384,7 +384,7 @@ pg_krb5_sendauth(const char *PQerrormsg, int sock, if (code = krb5_cc_get_principal(ccache, &client)) { (void) sprintf(PQerrormsg, - "pg_krb5_sendauth: Kerberos error %d in krb5_cc_get_principal\n", code); + "pg_krb5_sendauth: Kerberos error %d in krb5_cc_get_principal\n", code); com_err("pg_krb5_sendauth", code, "in krb5_cc_get_principal"); return STATUS_ERROR; } @@ -411,7 +411,7 @@ pg_krb5_sendauth(const char *PQerrormsg, int sock, if (code = krb5_parse_name(servbuf, &server)) { (void) sprintf(PQerrormsg, - "pg_krb5_sendauth: Kerberos error %d in krb5_parse_name\n", code); + "pg_krb5_sendauth: Kerberos error %d in krb5_parse_name\n", code); com_err("pg_krb5_sendauth", code, "in krb5_parse_name"); krb5_free_principal(client); return STATUS_ERROR; @@ -443,7 +443,7 @@ pg_krb5_sendauth(const char *PQerrormsg, int sock, else { (void) sprintf(PQerrormsg, - "pg_krb5_sendauth: Kerberos error %d in krb5_sendauth\n", code); + "pg_krb5_sendauth: Kerberos error %d in krb5_sendauth\n", code); com_err("pg_krb5_sendauth", code, "in krb5_sendauth"); } } @@ -544,7 +544,7 @@ fe_sendauth(AuthRequest areq, PGconn *conn, const char *hostname, * Set/return the authentication service currently selected for use by the * frontend. (You can only use one in the frontend, obviously.) */ -static int pg_authsvc = -1; +static int pg_authsvc = -1; void fe_setauthsvc(const char *name, char *PQerrormsg) @@ -618,7 +618,7 @@ fe_getauthname(char *PQerrormsg) default: (void) sprintf(PQerrormsg, "fe_getauthname: invalid authentication system: %d\n", - authsvc); + authsvc); break; } diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index fb78b1ee37..92e2a46434 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.96 1999/05/03 19:10:40 momjian Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.97 1999/05/25 16:15:11 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -503,7 +503,7 @@ connectDB(PGconn *conn) struct hostent *hp; StartupPacket sp; AuthRequest areq; - SOCKET_SIZE_TYPE laddrlen; + SOCKET_SIZE_TYPE laddrlen; int portno, family; char beresp; @@ -586,7 +586,7 @@ connectDB(PGconn *conn) strerror(errno), (family == AF_INET) ? " (with -i)" : "", conn->pghost ? conn->pghost : "localhost", - (family == AF_INET) ? "TCP/IP port" : "Unix socket", + (family == AF_INET) ? "TCP/IP port" : "Unix socket", conn->pgport); goto connect_errReturn; } diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c index 7c1540ae15..475a51bc4a 100644 --- a/src/interfaces/libpq/fe-exec.c +++ b/src/interfaces/libpq/fe-exec.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.79 1999/05/12 04:38:24 tgl Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.80 1999/05/25 16:15:12 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -75,7 +75,7 @@ static int getNotice(PGconn *conn); * doesn't tell us up front how many tuples will be returned.) * All other subsidiary storage for a PGresult is kept in PGresult_data blocks * of size PGRESULT_DATA_BLOCKSIZE. The overhead at the start of each block - * is just a link to the next one, if any. Free-space management info is + * is just a link to the next one, if any. Free-space management info is * kept in the owning PGresult. * A query returning a small amount of data will thus require three malloc * calls: one for the PGresult, one for the tuples pointer array, and one @@ -90,10 +90,10 @@ static int getNotice(PGconn *conn); * PGRESULT_DATA_BLOCKSIZE: size of a standard allocation block, in bytes * PGRESULT_ALIGN_BOUNDARY: assumed alignment requirement for binary data * PGRESULT_SEP_ALLOC_THRESHOLD: objects bigger than this are given separate - * blocks, instead of being crammed into a regular allocation block. + * blocks, instead of being crammed into a regular allocation block. * Requirements for correct function are: * PGRESULT_ALIGN_BOUNDARY must be a multiple of the alignment requirements - * of all machine data types. (Currently this is set from configure + * of all machine data types. (Currently this is set from configure * tests, so it should be OK automatically.) * PGRESULT_SEP_ALLOC_THRESHOLD + PGRESULT_BLOCK_OVERHEAD <= * PGRESULT_DATA_BLOCKSIZE @@ -110,7 +110,7 @@ static int getNotice(PGconn *conn); #define MAX(a,b) ((a) > (b) ? (a) : (b)) #define PGRESULT_DATA_BLOCKSIZE 2048 -#define PGRESULT_ALIGN_BOUNDARY MAXIMUM_ALIGNOF /* from configure */ +#define PGRESULT_ALIGN_BOUNDARY MAXIMUM_ALIGNOF /* from configure */ #define PGRESULT_BLOCK_OVERHEAD MAX(sizeof(PGresult_data), PGRESULT_ALIGN_BOUNDARY) #define PGRESULT_SEP_ALLOC_THRESHOLD (PGRESULT_DATA_BLOCKSIZE / 2) @@ -126,7 +126,7 @@ static int getNotice(PGconn *conn); * and the Perl5 interface, so maybe it's not so unreasonable. */ -PGresult * +PGresult * PQmakeEmptyPGresult(PGconn *conn, ExecStatusType status) { PGresult *result; @@ -180,21 +180,23 @@ PQmakeEmptyPGresult(PGconn *conn, ExecStatusType status) void * pqResultAlloc(PGresult *res, int nBytes, int isBinary) { - char *space; - PGresult_data *block; + char *space; + PGresult_data *block; - if (! res) + if (!res) return NULL; if (nBytes <= 0) return res->null_field; - /* If alignment is needed, round up the current position to an + /* + * If alignment is needed, round up the current position to an * alignment boundary. */ if (isBinary) { - int offset = res->curOffset % PGRESULT_ALIGN_BOUNDARY; + int offset = res->curOffset % PGRESULT_ALIGN_BOUNDARY; + if (offset) { res->curOffset += PGRESULT_ALIGN_BOUNDARY - offset; @@ -211,20 +213,24 @@ pqResultAlloc(PGresult *res, int nBytes, int isBinary) return space; } - /* If the requested object is very large, give it its own block; this - * avoids wasting what might be most of the current block to start a new - * block. (We'd have to special-case requests bigger than the block size - * anyway.) The object is always given binary alignment in this case. + /* + * If the requested object is very large, give it its own block; this + * avoids wasting what might be most of the current block to start a + * new block. (We'd have to special-case requests bigger than the + * block size anyway.) The object is always given binary alignment in + * this case. */ if (nBytes >= PGRESULT_SEP_ALLOC_THRESHOLD) { block = (PGresult_data *) malloc(nBytes + PGRESULT_BLOCK_OVERHEAD); - if (! block) + if (!block) return NULL; space = block->space + PGRESULT_BLOCK_OVERHEAD; if (res->curBlock) { - /* Tuck special block below the active block, so that we don't + + /* + * Tuck special block below the active block, so that we don't * have to waste the free space in the active block. */ block->next = res->curBlock->next; @@ -235,14 +241,14 @@ pqResultAlloc(PGresult *res, int nBytes, int isBinary) /* Must set up the new block as the first active block. */ block->next = NULL; res->curBlock = block; - res->spaceLeft = 0; /* be sure it's marked full */ + res->spaceLeft = 0; /* be sure it's marked full */ } return space; } /* Otherwise, start a new block. */ block = (PGresult_data *) malloc(PGRESULT_DATA_BLOCKSIZE); - if (! block) + if (!block) return NULL; block->next = res->curBlock; res->curBlock = block; @@ -272,7 +278,8 @@ pqResultAlloc(PGresult *res, int nBytes, int isBinary) char * pqResultStrdup(PGresult *res, const char *str) { - char *space = (char*) pqResultAlloc(res, strlen(str)+1, FALSE); + char *space = (char *) pqResultAlloc(res, strlen(str) + 1, FALSE); + if (space) strcpy(space, str); return space; @@ -300,13 +307,14 @@ pqSetResultError(PGresult *res, const char *msg) void PQclear(PGresult *res) { - PGresult_data *block; + PGresult_data *block; if (!res) return; /* Free all the subsidiary blocks */ - while ((block = res->curBlock) != NULL) { + while ((block = res->curBlock) != NULL) + { res->curBlock = block->next; free(block); } @@ -343,6 +351,7 @@ addTuple(PGresult *res, PGresAttValue *tup) { if (res->ntups >= res->tupArrSize) { + /* * Try to grow the array. * @@ -351,19 +360,19 @@ addTuple(PGresult *res, PGresAttValue *tup) * While ANSI says that realloc() should act like malloc() in that * case, some old C libraries (like SunOS 4.1.x) coredump instead. * On failure realloc is supposed to return NULL without damaging - * the existing allocation. - * Note that the positions beyond res->ntups are garbage, not - * necessarily NULL. + * the existing allocation. Note that the positions beyond + * res->ntups are garbage, not necessarily NULL. */ - int newSize = (res->tupArrSize > 0) ? res->tupArrSize * 2 : 128; - PGresAttValue ** newTuples; + int newSize = (res->tupArrSize > 0) ? res->tupArrSize * 2 : 128; + PGresAttValue **newTuples; + if (res->tuples == NULL) newTuples = (PGresAttValue **) malloc(newSize * sizeof(PGresAttValue *)); else newTuples = (PGresAttValue **) realloc(res->tuples, newSize * sizeof(PGresAttValue *)); - if (! newTuples) + if (!newTuples) return FALSE; /* malloc or realloc failed */ res->tupArrSize = newSize; res->tuples = newTuples; @@ -537,7 +546,7 @@ parseInput(PGconn *conn) case 'C': /* command complete */ if (conn->result == NULL) conn->result = PQmakeEmptyPGresult(conn, - PGRES_COMMAND_OK); + PGRES_COMMAND_OK); if (pqGets(conn->result->cmdStatus, CMDSTATUS_LEN, conn)) return; conn->asyncStatus = PGASYNC_READY; @@ -567,7 +576,7 @@ parseInput(PGconn *conn) } if (conn->result == NULL) conn->result = PQmakeEmptyPGresult(conn, - PGRES_EMPTY_QUERY); + PGRES_EMPTY_QUERY); conn->asyncStatus = PGASYNC_READY; break; case 'K': /* secret key data from the backend */ @@ -653,7 +662,7 @@ parseInput(PGconn *conn) sprintf(conn->errorMessage, "unknown protocol character '%c' read from backend. " "(The protocol character is the first character the " - "backend sends in response to a query it receives).\n", + "backend sends in response to a query it receives).\n", id); /* Discard the unexpected message; good idea?? */ conn->inStart = conn->inEnd; @@ -724,12 +733,13 @@ getRowDescriptions(PGconn *conn) PQclear(result); return EOF; } + /* * Since pqGetInt treats 2-byte integers as unsigned, we need to * coerce the special value "-1" to signed form. (-1 is sent for * variable-length fields.) Formerly, libpq effectively did a - * sign-extension on the 2-byte value by storing it in a signed short. - * Now we only coerce the single value 65535 == -1; values + * sign-extension on the 2-byte value by storing it in a signed + * short. Now we only coerce the single value 65535 == -1; values * 32768..65534 are taken as valid field lengths. */ if (typlen == 0xFFFF) @@ -825,7 +835,7 @@ getAnotherTuple(PGconn *conn, int binary) vlen = 0; if (tup[i].value == NULL) { - tup[i].value = (char *) pqResultAlloc(result, vlen+1, binary); + tup[i].value = (char *) pqResultAlloc(result, vlen + 1, binary); if (tup[i].value == NULL) goto outOfMemory; } @@ -850,7 +860,7 @@ getAnotherTuple(PGconn *conn, int binary) } /* Success! Store the completed tuple in the result */ - if (! addTuple(result, tup)) + if (!addTuple(result, tup)) goto outOfMemory; /* and reset for a new message */ conn->curTuple = NULL; @@ -928,23 +938,25 @@ PQgetResult(PGconn *conn) res = NULL; /* query is complete */ break; case PGASYNC_READY: + /* - * conn->result is the PGresult to return. If it is NULL - * (which probably shouldn't happen) we assume there is - * an appropriate error message in conn->errorMessage. + * conn->result is the PGresult to return. If it is NULL + * (which probably shouldn't happen) we assume there is an + * appropriate error message in conn->errorMessage. */ res = conn->result; - conn->result = NULL; /* handing over ownership to caller */ + conn->result = NULL;/* handing over ownership to caller */ conn->curTuple = NULL; /* just in case */ if (!res) - { res = PQmakeEmptyPGresult(conn, PGRES_FATAL_ERROR); - } else { - /* Make sure PQerrorMessage agrees with result; it could be - * that we have done other operations that changed - * errorMessage since the result's error message was saved. + + /* + * Make sure PQerrorMessage agrees with result; it could + * be that we have done other operations that changed + * errorMessage since the result's error message was + * saved. */ strcpy(conn->errorMessage, PQresultErrorMessage(res)); } @@ -1186,13 +1198,13 @@ PQgetline(PGconn *conn, char *s, int maxlen) * then return to normal processing. * * RETURNS: - * -1 if the end-of-copy-data marker has been recognized - * 0 if no data is available - * >0 the number of bytes returned. + * -1 if the end-of-copy-data marker has been recognized + * 0 if no data is available + * >0 the number of bytes returned. * The data returned will not extend beyond a newline character. If possible * a whole line will be returned at one time. But if the buffer offered by * the caller is too small to hold a line sent by the backend, then a partial - * data line will be returned. This can be detected by testing whether the + * data line will be returned. This can be detected by testing whether the * last returned byte is '\n' or not. * The returned string is *not* null-terminated. */ @@ -1200,18 +1212,17 @@ PQgetline(PGconn *conn, char *s, int maxlen) int PQgetlineAsync(PGconn *conn, char *buffer, int bufsize) { - int avail; + int avail; if (!conn || conn->asyncStatus != PGASYNC_COPY_OUT) return -1; /* we are not doing a copy... */ /* - * Move data from libpq's buffer to the caller's. - * We want to accept data only in units of whole lines, - * not partial lines. This ensures that we can recognize - * the terminator line "\\.\n". (Otherwise, if it happened - * to cross a packet/buffer boundary, we might hand the first - * one or two characters off to the caller, which we shouldn't.) + * Move data from libpq's buffer to the caller's. We want to accept + * data only in units of whole lines, not partial lines. This ensures + * that we can recognize the terminator line "\\.\n". (Otherwise, if + * it happened to cross a packet/buffer boundary, we might hand the + * first one or two characters off to the caller, which we shouldn't.) */ conn->inCursor = conn->inStart; @@ -1219,7 +1230,8 @@ PQgetlineAsync(PGconn *conn, char *buffer, int bufsize) avail = bufsize; while (avail > 0 && conn->inCursor < conn->inEnd) { - char c = conn->inBuffer[conn->inCursor++]; + char c = conn->inBuffer[conn->inCursor++]; + *buffer++ = c; --avail; if (c == '\n') @@ -1227,7 +1239,7 @@ PQgetlineAsync(PGconn *conn, char *buffer, int bufsize) /* Got a complete line; mark the data removed from libpq */ conn->inStart = conn->inCursor; /* Is it the endmarker line? */ - if (bufsize-avail == 3 && buffer[-3] == '\\' && buffer[-2] == '.') + if (bufsize - avail == 3 && buffer[-3] == '\\' && buffer[-2] == '.') return -1; /* No, return the data line to the caller */ return bufsize - avail; @@ -1235,13 +1247,13 @@ PQgetlineAsync(PGconn *conn, char *buffer, int bufsize) } /* - * We don't have a complete line. - * We'd prefer to leave it in libpq's buffer until the rest arrives, - * but there is a special case: what if the line is longer than the - * buffer the caller is offering us? In that case we'd better hand over - * a partial line, else we'd get into an infinite loop. - * Do this in a way that ensures we can't misrecognize a terminator - * line later: leave last 3 characters in libpq buffer. + * We don't have a complete line. We'd prefer to leave it in libpq's + * buffer until the rest arrives, but there is a special case: what if + * the line is longer than the buffer the caller is offering us? In + * that case we'd better hand over a partial line, else we'd get into + * an infinite loop. Do this in a way that ensures we can't + * misrecognize a terminator line later: leave last 3 characters in + * libpq buffer. */ if (avail == 0 && bufsize > 3) { @@ -1737,13 +1749,13 @@ PQoidStatus(PGresult *res) /*---------- * The cmdStatus string looks like - * INSERT oid count\0 + * INSERT oid count\0 * In order to be able to return an ordinary C string without * damaging the result for PQcmdStatus or PQcmdTuples, we copy * the oid part of the string to just after the null, so that * cmdStatus looks like - * INSERT oid count\0oid\0 - * ^ our return value points here + * INSERT oid count\0oid\0 + * ^ our return value points here * Pretty klugy eh? This routine should've just returned an Oid value. *---------- */ @@ -1802,7 +1814,7 @@ PQcmdTuples(PGresult *res) if (res->conn) { sprintf(res->conn->errorMessage, - "PQcmdTuples (INSERT) -- there's no # of tuples\n"); + "PQcmdTuples (INSERT) -- there's no # of tuples\n"); DONOTICE(res->conn, res->conn->errorMessage); } return ""; diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c index 726279291a..fd33052f7c 100644 --- a/src/interfaces/libpq/fe-misc.c +++ b/src/interfaces/libpq/fe-misc.c @@ -24,7 +24,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.23 1999/02/22 05:26:53 momjian Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.24 1999/05/25 16:15:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -471,6 +471,7 @@ pqFlush(PGconn *conn) /* Prevent being SIGPIPEd if backend has closed the connection. */ #ifndef WIN32 pqsigfunc oldsighandler = pqsignal(SIGPIPE, SIG_IGN); + #endif int sent = send(conn->sock, ptr, len, 0); @@ -481,10 +482,11 @@ pqFlush(PGconn *conn) if (sent < 0) { + /* - * Anything except EAGAIN or EWOULDBLOCK is trouble. - * If it's EPIPE or ECONNRESET, assume we've lost the - * backend connection permanently. + * Anything except EAGAIN or EWOULDBLOCK is trouble. If it's + * EPIPE or ECONNRESET, assume we've lost the backend + * connection permanently. */ switch (errno) { @@ -504,7 +506,7 @@ pqFlush(PGconn *conn) "pqFlush() -- backend closed the channel unexpectedly.\n" "\tThis probably means the backend terminated abnormally" " before or while processing the request.\n"); - conn->status = CONNECTION_BAD; /* No more connection */ + conn->status = CONNECTION_BAD; /* No more connection */ #ifdef WIN32 closesocket(conn->sock); #else @@ -514,7 +516,7 @@ pqFlush(PGconn *conn) return EOF; default: sprintf(conn->errorMessage, - "pqFlush() -- couldn't send data: errno=%d\n%s\n", + "pqFlush() -- couldn't send data: errno=%d\n%s\n", errno, strerror(errno)); /* We don't assume it's a fatal error... */ return EOF; diff --git a/src/interfaces/libpq/fe-print.c b/src/interfaces/libpq/fe-print.c index 25e58bc950..d5793af085 100644 --- a/src/interfaces/libpq/fe-print.c +++ b/src/interfaces/libpq/fe-print.c @@ -9,7 +9,7 @@ * didn't really belong there. * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-print.c,v 1.22 1999/05/03 19:10:41 momjian Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-print.c,v 1.23 1999/05/25 16:15:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -520,7 +520,7 @@ PQmblen(unsigned char *s) return 1; } -#endif /* MULTIBYTE */ +#endif /* MULTIBYTE */ static void do_field(PQprintOpt *po, PGresult *res, @@ -556,6 +556,7 @@ do_field(PQprintOpt *po, PGresult *res, if (!skipit) { char ch = 0; + #ifdef MULTIBYTE int len; @@ -567,10 +568,11 @@ do_field(PQprintOpt *po, PGresult *res, #endif { ch = *p; + /* - * Consensus on pgsql-interfaces (as of Aug 1998) seems to be that - * the print functions ought not insert backslashes. If you like - * them, you can re-enable this next bit. + * Consensus on pgsql-interfaces (as of Aug 1998) seems to be + * that the print functions ought not insert backslashes. If + * you like them, you can re-enable this next bit. */ #ifdef GRATUITOUS_BACKSLASHES if ((fs_len == 1 && (ch == *(po->fieldSep))) || @@ -587,9 +589,10 @@ do_field(PQprintOpt *po, PGresult *res, fieldNotNum[j] = 1; } *o = '\0'; + /* * Above loop will believe E in first column is numeric; also, we - * insist on a digit in the last column for a numeric. This test + * insist on a digit in the last column for a numeric. This test * is still not bulletproof but it handles most cases. */ if (po->align && diff --git a/src/interfaces/libpq/libpq-fe.h b/src/interfaces/libpq/libpq-fe.h index 6655592d67..acbf539cd7 100644 --- a/src/interfaces/libpq/libpq-fe.h +++ b/src/interfaces/libpq/libpq-fe.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: libpq-fe.h,v 1.49 1999/02/13 23:22:42 momjian Exp $ + * $Id: libpq-fe.h,v 1.50 1999/05/25 16:15:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -36,10 +36,11 @@ extern "C" typedef enum { PGRES_EMPTY_QUERY = 0, - PGRES_COMMAND_OK, /* a query command that doesn't return anything - * was executed properly by the backend */ - PGRES_TUPLES_OK, /* a query command that returns tuples - * was executed properly by the backend, + PGRES_COMMAND_OK, /* a query command that doesn't return + * anything was executed properly by the + * backend */ + PGRES_TUPLES_OK, /* a query command that returns tuples was + * executed properly by the backend, * PGresult contains the result tuples */ PGRES_COPY_OUT, /* Copy Out data transfer in progress */ PGRES_COPY_IN, /* Copy In data transfer in progress */ @@ -52,7 +53,7 @@ extern "C" /* String descriptions of the ExecStatusTypes. * NB: direct use of this array is now deprecated; call PQresStatus() instead. */ - extern const char * const pgresStatus[]; + extern const char *const pgresStatus[]; /* PGconn encapsulates a connection to the backend. * The contents of this struct are not supposed to be known to applications. @@ -76,21 +77,21 @@ extern "C" { char relname[NAMEDATALEN]; /* name of relation * containing data */ - int be_pid; /* process id of backend */ + int be_pid; /* process id of backend */ } PGnotify; /* PQnoticeProcessor is the function type for the notice-message callback. */ - typedef void (*PQnoticeProcessor) (void * arg, const char * message); + typedef void (*PQnoticeProcessor) (void *arg, const char *message); /* Print options for PQprint() */ - - /* - * We can't use the conventional "bool", because we are designed to be - * included in a user's program, and user may already have that type - * defined. Pqbool, on the other hand, is unlikely to be used. - */ - typedef char pqbool; + + /* + * We can't use the conventional "bool", because we are designed to be + * included in a user's program, and user may already have that type + * defined. Pqbool, on the other hand, is unlikely to be used. + */ + typedef char pqbool; typedef struct _PQprintOpt { @@ -115,16 +116,16 @@ extern "C" typedef struct _PQconninfoOption { char *keyword; /* The keyword of the option */ - char *envvar; /* Fallback environment variable name */ + char *envvar; /* Fallback environment variable name */ char *compiled; /* Fallback compiled in default value */ char *val; /* Options value */ char *label; /* Label for field in connect dialog */ char *dispchar; /* Character to display for this field */ - /* in a connect dialog. Values are: */ - /* "" Display entered value as is */ - /* "*" Password field - hide value */ - /* "D" Debug options - don't */ - /* create a field by default */ + /* in a connect dialog. Values are: */ + /* "" Display entered value as is */ + /* "*" Password field - hide value */ + /* "D" Debug options - don't */ + /* create a field by default */ int dispsize; /* Field size in characters for dialog */ } PQconninfoOption; @@ -154,8 +155,8 @@ extern "C" extern PGconn *PQconnectdb(const char *conninfo); extern PGconn *PQsetdbLogin(const char *pghost, const char *pgport, const char *pgoptions, const char *pgtty, - const char *dbName, - const char *login, const char *pwd); + const char *dbName, + const char *login, const char *pwd); #define PQsetdb(M_PGHOST,M_PGPORT,M_PGOPT,M_PGTTY,M_DBNAME) \ PQsetdbLogin(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME, NULL, NULL) @@ -193,8 +194,8 @@ extern "C" /* Override default notice processor */ extern void PQsetNoticeProcessor(PGconn *conn, - PQnoticeProcessor proc, - void *arg); + PQnoticeProcessor proc, + void *arg); /* === in fe-exec.c === */ @@ -222,12 +223,12 @@ extern "C" * use */ extern PGresult *PQfn(PGconn *conn, - int fnid, - int *result_buf, - int *result_len, - int result_is_int, - PQArgBlock *args, - int nargs); + int fnid, + int *result_buf, + int *result_len, + int result_is_int, + PQArgBlock *args, + int nargs); /* Accessor functions for PGresult objects */ extern ExecStatusType PQresultStatus(PGresult *res); @@ -251,39 +252,40 @@ extern "C" /* Delete a PGresult */ extern void PQclear(PGresult *res); - /* Make an empty PGresult with given status (some apps find this useful). - * If conn is not NULL and status indicates an error, the conn's - * errorMessage is copied. + /* + * Make an empty PGresult with given status (some apps find this + * useful). If conn is not NULL and status indicates an error, the + * conn's errorMessage is copied. */ - extern PGresult * PQmakeEmptyPGresult(PGconn *conn, ExecStatusType status); + extern PGresult *PQmakeEmptyPGresult(PGconn *conn, ExecStatusType status); /* === in fe-print.c === */ - extern void PQprint(FILE *fout, /* output stream */ - PGresult *res, - PQprintOpt *ps); /* option structure */ + extern void PQprint(FILE *fout, /* output stream */ + PGresult *res, + PQprintOpt *ps); /* option structure */ /* * PQdisplayTuples() is a better version of PQprintTuples(), but both * are obsoleted by PQprint(). */ extern void PQdisplayTuples(PGresult *res, - FILE *fp, /* where to send the - * output */ - int fillAlign, /* pad the fields with - * spaces */ - const char *fieldSep, /* field separator */ - int printHeader, /* display headers? */ - int quiet); + FILE *fp, /* where to send the + * output */ + int fillAlign, /* pad the fields with + * spaces */ + const char *fieldSep, /* field separator */ + int printHeader, /* display headers? */ + int quiet); extern void PQprintTuples(PGresult *res, - FILE *fout, /* output stream */ - int printAttName, /* print attribute names - * or not */ - int terseOutput, /* delimiter bars or - * not? */ - int width); /* width of column, if - * 0, use variable width */ + FILE *fout, /* output stream */ + int printAttName, /* print attribute names + * or not */ + int terseOutput, /* delimiter bars or + * not? */ + int width); /* width of column, if + * 0, use variable width */ /* Determine length of multibyte encoded char at *s */ extern int PQmblen(unsigned char *s); diff --git a/src/interfaces/libpq/libpq-int.h b/src/interfaces/libpq/libpq-int.h index aaeffa3459..351d9fac2b 100644 --- a/src/interfaces/libpq/libpq-int.h +++ b/src/interfaces/libpq/libpq-int.h @@ -11,7 +11,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: libpq-int.h,v 1.7 1999/05/03 19:10:42 momjian Exp $ + * $Id: libpq-int.h,v 1.8 1999/05/25 16:15:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -62,23 +62,23 @@ * Note that space[k] refers to the k'th byte starting from the physical * head of the block. */ - typedef union pgresult_data PGresult_data; +typedef union pgresult_data PGresult_data; - union pgresult_data - { - PGresult_data *next; /* link to next block, or NULL */ - char space[1]; /* dummy for accessing block as bytes */ - }; +union pgresult_data +{ + PGresult_data *next; /* link to next block, or NULL */ + char space[1]; /* dummy for accessing block as bytes */ +}; /* Data about a single attribute (column) of a query result */ - typedef struct pgresAttDesc - { - char *name; /* type name */ - Oid typid; /* type id */ - int typlen; /* type size */ - int atttypmod; /* type-specific modifier info */ - } PGresAttDesc; +typedef struct pgresAttDesc +{ + char *name; /* type name */ + Oid typid; /* type id */ + int typlen; /* type size */ + int atttypmod; /* type-specific modifier info */ +} PGresAttDesc; /* Data for a single attribute of a single tuple */ @@ -98,123 +98,128 @@ #define NULL_LEN (-1) /* pg_result len for NULL value */ - typedef struct pgresAttValue - { - int len; /* length in bytes of the value */ - char *value; /* actual value, plus terminating zero byte */ - } PGresAttValue; +typedef struct pgresAttValue +{ + int len; /* length in bytes of the value */ + char *value; /* actual value, plus terminating zero + * byte */ +} PGresAttValue; - struct pg_result - { - int ntups; - int numAttributes; - PGresAttDesc *attDescs; - PGresAttValue **tuples; /* each PGresTuple is an array of +struct pg_result +{ + int ntups; + int numAttributes; + PGresAttDesc *attDescs; + PGresAttValue **tuples; /* each PGresTuple is an array of * PGresAttValue's */ - int tupArrSize; /* size of tuples array allocated */ - ExecStatusType resultStatus; - char cmdStatus[CMDSTATUS_LEN]; /* cmd status from the + int tupArrSize; /* size of tuples array allocated */ + ExecStatusType resultStatus; + char cmdStatus[CMDSTATUS_LEN]; /* cmd status from the * last insert query */ - int binary; /* binary tuple values if binary == 1, + int binary; /* binary tuple values if binary == 1, * otherwise ASCII */ - PGconn *conn; /* connection we did the query on, if any */ - char *errMsg; /* error message, or NULL if no error */ + PGconn *conn; /* connection we did the query on, if any */ + char *errMsg; /* error message, or NULL if no error */ - /* All NULL attributes in the query result point to this null string */ - char null_field[1]; + /* All NULL attributes in the query result point to this null string */ + char null_field[1]; - /* Space management information. Note that attDescs and errMsg, - * if not null, point into allocated blocks. But tuples points - * to a separately malloc'd block, so that we can realloc it. - */ - PGresult_data *curBlock; /* most recently allocated block */ - int curOffset; /* start offset of free space in block */ - int spaceLeft; /* number of free bytes remaining in block */ - }; + /* + * Space management information. Note that attDescs and errMsg, if + * not null, point into allocated blocks. But tuples points to a + * separately malloc'd block, so that we can realloc it. + */ + PGresult_data *curBlock; /* most recently allocated block */ + int curOffset; /* start offset of free space in block */ + int spaceLeft; /* number of free bytes remaining in block */ +}; /* PGAsyncStatusType defines the state of the query-execution state machine */ - typedef enum - { - PGASYNC_IDLE, /* nothing's happening, dude */ - PGASYNC_BUSY, /* query in progress */ - PGASYNC_READY, /* result ready for PQgetResult */ - PGASYNC_COPY_IN, /* Copy In data transfer in progress */ - PGASYNC_COPY_OUT /* Copy Out data transfer in progress */ - } PGAsyncStatusType; +typedef enum +{ + PGASYNC_IDLE, /* nothing's happening, dude */ + PGASYNC_BUSY, /* query in progress */ + PGASYNC_READY, /* result ready for PQgetResult */ + PGASYNC_COPY_IN, /* Copy In data transfer in progress */ + PGASYNC_COPY_OUT /* Copy Out data transfer in progress */ +} PGAsyncStatusType; /* large-object-access data ... allocated only if large-object code is used. */ - typedef struct pgLobjfuncs - { - Oid fn_lo_open; /* OID of backend function lo_open */ - Oid fn_lo_close;/* OID of backend function lo_close */ - Oid fn_lo_creat;/* OID of backend function lo_creat */ - Oid fn_lo_unlink; /* OID of backend function - * lo_unlink */ - Oid fn_lo_lseek;/* OID of backend function lo_lseek */ - Oid fn_lo_tell; /* OID of backend function lo_tell */ - Oid fn_lo_read; /* OID of backend function LOread */ - Oid fn_lo_write;/* OID of backend function LOwrite */ - } PGlobjfuncs; +typedef struct pgLobjfuncs +{ + Oid fn_lo_open; /* OID of backend function lo_open */ + Oid fn_lo_close; /* OID of backend function lo_close */ + Oid fn_lo_creat; /* OID of backend function lo_creat */ + Oid fn_lo_unlink; /* OID of backend function lo_unlink */ + Oid fn_lo_lseek; /* OID of backend function lo_lseek */ + Oid fn_lo_tell; /* OID of backend function lo_tell */ + Oid fn_lo_read; /* OID of backend function LOread */ + Oid fn_lo_write; /* OID of backend function LOwrite */ +} PGlobjfuncs; /* PGconn stores all the state data associated with a single connection * to a backend. */ - struct pg_conn - { - /* Saved values of connection options */ - char *pghost; /* the machine on which the server is +struct pg_conn +{ + /* Saved values of connection options */ + char *pghost; /* the machine on which the server is * running */ - char *pgport; /* the server's communication port */ - char *pgtty; /* tty on which the backend messages is + char *pgport; /* the server's communication port */ + char *pgtty; /* tty on which the backend messages is * displayed (NOT ACTUALLY USED???) */ - char *pgoptions; /* options to start the backend with */ - char *dbName; /* database name */ - char *pguser; /* Postgres username and password, if any */ - char *pgpass; + char *pgoptions; /* options to start the backend with */ + char *dbName; /* database name */ + char *pguser; /* Postgres username and password, if any */ + char *pgpass; - /* Optional file to write trace info to */ - FILE *Pfdebug; + /* Optional file to write trace info to */ + FILE *Pfdebug; - /* Callback procedure for notice/error message processing */ - PQnoticeProcessor noticeHook; - void *noticeArg; + /* Callback procedure for notice/error message processing */ + PQnoticeProcessor noticeHook; + void *noticeArg; - /* Status indicators */ - ConnStatusType status; - PGAsyncStatusType asyncStatus; - Dllist *notifyList; /* Notify msgs not yet handed to application */ + /* Status indicators */ + ConnStatusType status; + PGAsyncStatusType asyncStatus; + Dllist *notifyList; /* Notify msgs not yet handed to + * application */ - /* Connection data */ - int sock; /* Unix FD for socket, -1 if not connected */ - SockAddr laddr; /* Local address */ - SockAddr raddr; /* Remote address */ - int raddr_len; /* Length of remote address */ + /* Connection data */ + int sock; /* Unix FD for socket, -1 if not connected */ + SockAddr laddr; /* Local address */ + SockAddr raddr; /* Remote address */ + int raddr_len; /* Length of remote address */ - /* Miscellaneous stuff */ - int be_pid; /* PID of backend --- needed for cancels */ - int be_key; /* key of backend --- needed for cancels */ - char salt[2]; /* password salt received from backend */ - PGlobjfuncs *lobjfuncs; /* private state for large-object access fns */ + /* Miscellaneous stuff */ + int be_pid; /* PID of backend --- needed for cancels */ + int be_key; /* key of backend --- needed for cancels */ + char salt[2]; /* password salt received from backend */ + PGlobjfuncs *lobjfuncs; /* private state for large-object access + * fns */ - /* Buffer for data received from backend and not yet processed */ - char *inBuffer; /* currently allocated buffer */ - int inBufSize; /* allocated size of buffer */ - int inStart; /* offset to first unconsumed data in buffer */ - int inCursor; /* next byte to tentatively consume */ - int inEnd; /* offset to first position after avail data */ + /* Buffer for data received from backend and not yet processed */ + char *inBuffer; /* currently allocated buffer */ + int inBufSize; /* allocated size of buffer */ + int inStart; /* offset to first unconsumed data in + * buffer */ + int inCursor; /* next byte to tentatively consume */ + int inEnd; /* offset to first position after avail + * data */ - /* Buffer for data not yet sent to backend */ - char *outBuffer; /* currently allocated buffer */ - int outBufSize; /* allocated size of buffer */ - int outCount; /* number of chars waiting in buffer */ + /* Buffer for data not yet sent to backend */ + char *outBuffer; /* currently allocated buffer */ + int outBufSize; /* allocated size of buffer */ + int outCount; /* number of chars waiting in buffer */ - /* Status for asynchronous result construction */ - PGresult *result; /* result being constructed */ - PGresAttValue *curTuple; /* tuple currently being read */ + /* Status for asynchronous result construction */ + PGresult *result; /* result being constructed */ + PGresAttValue *curTuple; /* tuple currently being read */ - /* Message space. Placed last for code-size reasons. */ - char errorMessage[ERROR_MSG_LENGTH]; - }; + /* Message space. Placed last for code-size reasons. */ + char errorMessage[ERROR_MSG_LENGTH]; +}; /* ---------------- * Internal functions of libpq @@ -232,8 +237,8 @@ extern int pqPacketSend(PGconn *conn, const char *buf, size_t len); /* === in fe-exec.c === */ extern void pqSetResultError(PGresult *res, const char *msg); -extern void * pqResultAlloc(PGresult *res, int nBytes, int isBinary); -extern char * pqResultStrdup(PGresult *res, const char *str); +extern void *pqResultAlloc(PGresult *res, int nBytes, int isBinary); +extern char *pqResultStrdup(PGresult *res, const char *str); extern void pqClearAsyncResult(PGconn *conn); /* === in fe-misc.c === */ diff --git a/src/interfaces/libpq/libpqdll.c b/src/interfaces/libpq/libpqdll.c index 5407c54e40..f0241acf78 100644 --- a/src/interfaces/libpq/libpqdll.c +++ b/src/interfaces/libpq/libpqdll.c @@ -6,13 +6,18 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) { - WSADATA wsaData; - switch (fdwReason) { + WSADATA wsaData; + + switch (fdwReason) + { case DLL_PROCESS_ATTACH: - if (WSAStartup(MAKEWORD(1,1),&wsaData)) + if (WSAStartup(MAKEWORD(1, 1), &wsaData)) { - /* No really good way to do error handling here, - * since we don't know how we were loaded */ + + /* + * No really good way to do error handling here, since we + * don't know how we were loaded + */ return FALSE; } break; diff --git a/src/interfaces/python/pgmodule.c b/src/interfaces/python/pgmodule.c index 17be50889a..254fb1e798 100644 --- a/src/interfaces/python/pgmodule.c +++ b/src/interfaces/python/pgmodule.c @@ -3,27 +3,27 @@ * D'Arcy J.M. Cain, (darcy@druid.net). Based heavily on code written by * Pascal Andre, andre@chimay.via.ecp.fr. Copyright (c) 1995, Pascal Andre * (andre@via.ecp.fr). - * + * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose, without fee, and without a written * agreement is hereby granted, provided that the above copyright notice and * this paragraph and the following two paragraphs appear in all copies or in * any new file that contains a substantial portion of this file. - * + * * IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, * SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE * AUTHOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE * AUTHOR HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, * ENHANCEMENTS, OR MODIFICATIONS. - * + * * Further modifications copyright 1997, 1998, 1999 by D'Arcy J.M. Cain * (darcy@druid.net) subject to the same terms and conditions as above. - * + * */ #include @@ -36,22 +36,22 @@ /* really bad stuff here - I'm so naughty */ /* If you need to you can run mkdefines to get */ /* current defines but it should not have changed */ -#define INT2OID 21 -#define INT4OID 23 -#define OIDOID 26 -#define FLOAT4OID 700 -#define FLOAT8OID 701 -#define CASHOID 790 +#define INT2OID 21 +#define INT4OID 23 +#define OIDOID 26 +#define FLOAT4OID 700 +#define FLOAT8OID 701 +#define CASHOID 790 -static PyObject *PGError; -static const char *PyPgVersion = "3.0 beta"; +static PyObject *PGError; +static const char *PyPgVersion = "3.0 beta"; /* taken from fileobject.c */ #define BUF(v) PyString_AS_STRING((PyStringObject *)(v)) /* default values */ -#define MODULE_NAME "pgsql" -#define ARRAYSIZE 1 +#define MODULE_NAME "pgsql" +#define ARRAYSIZE 1 /* flags for object validity checks */ #define CHECK_OPEN 1 @@ -63,16 +63,16 @@ static const char *PyPgVersion = "3.0 beta"; #define MAX_BUFFER_SIZE 8192 /* maximum transaction size */ #ifndef NO_DIRECT -#define DIRECT_ACCESS 1 /* enables direct access functions */ -#endif /* NO_DIRECT */ +#define DIRECT_ACCESS 1 /* enables direct access functions */ +#endif /* NO_DIRECT */ #ifndef NO_LARGE -#define LARGE_OBJECTS 1 /* enables large objects support */ -#endif /* NO_LARGE */ +#define LARGE_OBJECTS 1 /* enables large objects support */ +#endif /* NO_LARGE */ #ifndef NO_DEF_VAR -#define DEFAULT_VARS 1 /* enables default variables use */ -#endif /* NO_DEF_VAR */ +#define DEFAULT_VARS 1 /* enables default variables use */ +#endif /* NO_DEF_VAR */ /* --------------------------------------------------------------------- */ @@ -80,15 +80,15 @@ static const char *PyPgVersion = "3.0 beta"; #ifdef DEFAULT_VARS -static PyObject *pg_default_host; /* default database host */ -static PyObject *pg_default_base; /* default database name */ -static PyObject *pg_default_opt; /* default connection options */ -static PyObject *pg_default_tty; /* default debug tty */ -static PyObject *pg_default_port; /* default connection port */ -static PyObject *pg_default_user; /* default username */ -static PyObject *pg_default_passwd; /* default password */ +static PyObject *pg_default_host; /* default database host */ +static PyObject *pg_default_base; /* default database name */ +static PyObject *pg_default_opt;/* default connection options */ +static PyObject *pg_default_tty;/* default debug tty */ +static PyObject *pg_default_port; /* default connection port */ +static PyObject *pg_default_user; /* default username */ +static PyObject *pg_default_passwd; /* default password */ -#endif /* DEFAULT_VARS */ +#endif /* DEFAULT_VARS */ /* --------------------------------------------------------------------- */ /* OBJECTS DECLARATION */ @@ -98,9 +98,9 @@ static PyObject *pg_default_passwd; /* default password */ typedef struct { PyObject_HEAD - int valid; /* validity flag */ - PGconn *cnx; /* PostGres connection handle */ -} pgobject; + int valid; /* validity flag */ + PGconn *cnx; /* PostGres connection handle */ +} pgobject; staticforward PyTypeObject PgType; @@ -111,8 +111,8 @@ staticforward PyTypeObject PgType; typedef struct { PyObject_HEAD - PGresult *last_result; /* last result content */ -} pgqueryobject; + PGresult *last_result; /* last result content */ +} pgqueryobject; staticforward PyTypeObject PgQueryType; @@ -124,15 +124,15 @@ staticforward PyTypeObject PgQueryType; typedef struct { PyObject_HEAD - pgobject *pgcnx; /* parent connection object */ - Oid lo_oid; /* large object oid */ - int lo_fd; /* large object fd */ -} pglargeobject; + pgobject * pgcnx; /* parent connection object */ + Oid lo_oid; /* large object oid */ + int lo_fd; /* large object fd */ +} pglargeobject; staticforward PyTypeObject PglargeType; #define is_pglargeobject(v) ((v)->ob_type == &PglargeType) -#endif /* LARGE_OBJECTS */ +#endif /* LARGE_OBJECTS */ /* --------------------------------------------------------------------- */ /* INTERNAL FUNCTIONS */ @@ -141,7 +141,8 @@ staticforward PyTypeObject PglargeType; static int check_cnx_obj(pgobject * self) { - if (!self->valid) { + if (!self->valid) + { PyErr_SetString(PGError, "connection has been closed"); return 0; } @@ -183,7 +184,7 @@ check_lo_obj(pglargeobject * self, int level) return 1; } -#endif /* LARGE_OBJECTS */ +#endif /* LARGE_OBJECTS */ /* --------------------------------------------------------------------- */ /* PG CONNECTION OBJECT IMPLEMENTATION */ @@ -194,17 +195,17 @@ check_lo_obj(pglargeobject * self, int level) static pglargeobject * pglarge_new(pgobject * pgcnx, Oid oid) { - pglargeobject * npglo; + pglargeobject *npglo; if ((npglo = PyObject_NEW(pglargeobject, &PglargeType)) == NULL) - return NULL; - + return NULL; + Py_XINCREF(pgcnx); npglo->pgcnx = pgcnx; npglo->lo_fd = -1; npglo->lo_oid = oid; - return npglo; + return npglo; } /* destructor */ @@ -220,13 +221,14 @@ pglarge_dealloc(pglargeobject * self) /* opens large object */ static char pglarge_open__doc__[] = - "open(mode) -- open access to large object with specified mode " - "(INV_READ, INV_WRITE constants defined by module)."; +"open(mode) -- open access to large object with specified mode " +"(INV_READ, INV_WRITE constants defined by module)."; static PyObject * pglarge_open(pglargeobject * self, PyObject * args) { - int mode, fd; + int mode, + fd; /* check validity */ if (!check_lo_obj(self, CHECK_CLOSE)) @@ -254,8 +256,8 @@ pglarge_open(pglargeobject * self, PyObject * args) /* close large object */ static char pglarge_close__doc__[] = - "close() -- close access to large object data."; - +"close() -- close access to large object data."; + static PyObject * pglarge_close(pglargeobject * self, PyObject * args) { @@ -263,7 +265,7 @@ pglarge_close(pglargeobject * self, PyObject * args) if (!PyArg_ParseTuple(args, "")) { PyErr_SetString(PyExc_SyntaxError, - "method close() takes no parameters."); + "method close() takes no parameters."); return NULL; } @@ -286,14 +288,14 @@ pglarge_close(pglargeobject * self, PyObject * args) /* reads from large object */ static char pglarge_read__doc__[] = - "read(integer) -- read from large object to sized string. " - "Object must be opened in read mode before calling this method."; +"read(integer) -- read from large object to sized string. " +"Object must be opened in read mode before calling this method."; static PyObject * pglarge_read(pglargeobject * self, PyObject * args) { - int size; - PyObject *buffer; + int size; + PyObject *buffer; /* checks validity */ if (!check_lo_obj(self, CHECK_OPEN)) @@ -329,14 +331,14 @@ pglarge_read(pglargeobject * self, PyObject * args) /* write to large object */ static char pglarge_write__doc__[] = - "write(string) -- write sized string to large object. " - "Object must be opened in read mode before calling this method."; - +"write(string) -- write sized string to large object. " +"Object must be opened in read mode before calling this method."; + static PyObject * pglarge_write(pglargeobject * self, PyObject * args) { - char *buffer; - int size; + char *buffer; + int size; /* checks validity */ if (!check_lo_obj(self, CHECK_OPEN)) @@ -346,13 +348,13 @@ pglarge_write(pglargeobject * self, PyObject * args) if (!PyArg_ParseTuple(args, "s", &buffer)) { PyErr_SetString(PyExc_TypeError, - "write(buffer), with buffer (sized string)."); + "write(buffer), with buffer (sized string)."); return NULL; } /* sends query */ if ((size = lo_write(self->pgcnx->cnx, self->lo_fd, buffer, - strlen(buffer))) < strlen(buffer)) + strlen(buffer))) < strlen(buffer)) { PyErr_SetString(PyExc_IOError, "buffer truncated during write."); return NULL; @@ -365,15 +367,17 @@ pglarge_write(pglargeobject * self, PyObject * args) /* go to position in large object */ static char pglarge_seek__doc__[] = - "seek(off, whence) -- move to specified position. Object must be opened " - "before calling this method. whence can be SEEK_SET, SEEK_CUR or SEEK_END, " - "constants defined by module."; +"seek(off, whence) -- move to specified position. Object must be opened " +"before calling this method. whence can be SEEK_SET, SEEK_CUR or SEEK_END, " +"constants defined by module."; static PyObject * pglarge_lseek(pglargeobject * self, PyObject * args) { /* offset and whence are initialized to keep compiler happy */ - int ret, offset = 0, whence = 0; + int ret, + offset = 0, + whence = 0; /* checks validity */ if (!check_lo_obj(self, CHECK_OPEN)) @@ -383,7 +387,7 @@ pglarge_lseek(pglargeobject * self, PyObject * args) if (!PyArg_ParseTuple(args, "ii", &offset, &whence)) { PyErr_SetString(PyExc_TypeError, - "lseek(offset, whence), with offset and whence (integers)."); + "lseek(offset, whence), with offset and whence (integers)."); return NULL; } @@ -400,19 +404,20 @@ pglarge_lseek(pglargeobject * self, PyObject * args) /* gets large object size */ static char pglarge_size__doc__[] = - "size() -- return large object size. " - "Object must be opened before calling this method."; +"size() -- return large object size. " +"Object must be opened before calling this method."; static PyObject * pglarge_size(pglargeobject * self, PyObject * args) { - int start, end; + int start, + end; /* checks args */ if (!PyArg_ParseTuple(args, "")) { PyErr_SetString(PyExc_SyntaxError, - "method size() takes no parameters."); + "method size() takes no parameters."); return NULL; } @@ -435,10 +440,10 @@ pglarge_size(pglargeobject * self, PyObject * args) } /* move back to start position */ - if ((start = lo_lseek(self->pgcnx->cnx,self->lo_fd,start,SEEK_SET)) == -1) + if ((start = lo_lseek(self->pgcnx->cnx, self->lo_fd, start, SEEK_SET)) == -1) { PyErr_SetString(PyExc_IOError, - "error while moving back to first position."); + "error while moving back to first position."); return NULL; } @@ -448,19 +453,19 @@ pglarge_size(pglargeobject * self, PyObject * args) /* gets large object cursor position */ static char pglarge_tell__doc__[] = - "tell() -- give current position in large object. " - "Object must be opened before calling this method."; +"tell() -- give current position in large object. " +"Object must be opened before calling this method."; static PyObject * pglarge_tell(pglargeobject * self, PyObject * args) { - int start; + int start; /* checks args */ if (!PyArg_ParseTuple(args, "")) { PyErr_SetString(PyExc_SyntaxError, - "method tell() takes no parameters."); + "method tell() takes no parameters."); return NULL; } @@ -481,13 +486,13 @@ pglarge_tell(pglargeobject * self, PyObject * args) /* exports large object as unix file */ static char pglarge_export__doc__[] = - "export(string) -- export large object data to specified file. " - "Object must be closed when calling this method."; +"export(string) -- export large object data to specified file. " +"Object must be closed when calling this method."; static PyObject * pglarge_export(pglargeobject * self, PyObject * args) { - char *name; + char *name; /* checks validity */ if (!check_lo_obj(self, CHECK_CLOSE)) @@ -497,7 +502,7 @@ pglarge_export(pglargeobject * self, PyObject * args) if (!PyArg_ParseTuple(args, "s", &name)) { PyErr_SetString(PyExc_TypeError, - "export(filename), with filename (string)."); + "export(filename), with filename (string)."); return NULL; } @@ -514,8 +519,8 @@ pglarge_export(pglargeobject * self, PyObject * args) /* deletes a large object */ static char pglarge_unlink__doc__[] = - "unlink() -- destroy large object. " - "Object must be closed when calling this method."; +"unlink() -- destroy large object. " +"Object must be closed when calling this method."; static PyObject * pglarge_unlink(pglargeobject * self, PyObject * args) @@ -524,7 +529,7 @@ pglarge_unlink(pglargeobject * self, PyObject * args) if (!PyArg_ParseTuple(args, "")) { PyErr_SetString(PyExc_SyntaxError, - "method unlink() takes no parameters."); + "method unlink() takes no parameters."); return NULL; } @@ -546,15 +551,15 @@ pglarge_unlink(pglargeobject * self, PyObject * args) /* large object methods */ static struct PyMethodDef pglarge_methods[] = { - {"open", (PyCFunction) pglarge_open, 1, pglarge_open__doc__ }, - {"close", (PyCFunction) pglarge_close, 1, pglarge_close__doc__ }, - {"read", (PyCFunction) pglarge_read, 1, pglarge_read__doc__ }, - {"write", (PyCFunction) pglarge_write, 1, pglarge_write__doc__ }, - {"seek", (PyCFunction) pglarge_lseek, 1, pglarge_seek__doc__ }, - {"size", (PyCFunction) pglarge_size, 1, pglarge_size__doc__ }, - {"tell", (PyCFunction) pglarge_tell, 1, pglarge_tell__doc__ }, - {"export", (PyCFunction) pglarge_export, 1, pglarge_export__doc__ }, - {"unlink", (PyCFunction) pglarge_unlink, 1, pglarge_unlink__doc__ }, + {"open", (PyCFunction) pglarge_open, 1, pglarge_open__doc__}, + {"close", (PyCFunction) pglarge_close, 1, pglarge_close__doc__}, + {"read", (PyCFunction) pglarge_read, 1, pglarge_read__doc__}, + {"write", (PyCFunction) pglarge_write, 1, pglarge_write__doc__}, + {"seek", (PyCFunction) pglarge_lseek, 1, pglarge_seek__doc__}, + {"size", (PyCFunction) pglarge_size, 1, pglarge_size__doc__}, + {"tell", (PyCFunction) pglarge_tell, 1, pglarge_tell__doc__}, + {"export", (PyCFunction) pglarge_export, 1, pglarge_export__doc__}, + {"unlink", (PyCFunction) pglarge_unlink, 1, pglarge_unlink__doc__}, {NULL, NULL} }; @@ -594,7 +599,7 @@ pglarge_getattr(pglargeobject * self, char *name) /* attributes list */ if (!strcmp(name, "__members__")) { - PyObject *list = PyList_New(3); + PyObject *list = PyList_New(3); if (list) { @@ -608,11 +613,11 @@ pglarge_getattr(pglargeobject * self, char *name) /* module name */ if (!strcmp(name, "__module__")) - return PyString_FromString(MODULE_NAME); + return PyString_FromString(MODULE_NAME); /* class name */ if (!strcmp(name, "__class__")) - return PyString_FromString("pglarge"); + return PyString_FromString("pglarge"); /* seeks name in methods (fallback) */ return Py_FindMethod(pglarge_methods, (PyObject *) self, name); @@ -622,18 +627,18 @@ pglarge_getattr(pglargeobject * self, char *name) static int pglarge_print(pglargeobject * self, FILE *fp, int flags) { - char print_buffer[128]; + char print_buffer[128]; - if (self->lo_fd >= 0) + if (self->lo_fd >= 0) { - snprintf(print_buffer, sizeof(print_buffer), - "Opened large object, oid %ld", (long)self->lo_oid); + snprintf(print_buffer, sizeof(print_buffer), + "Opened large object, oid %ld", (long) self->lo_oid); fputs(print_buffer, fp); - } - else + } + else { - snprintf(print_buffer, sizeof(print_buffer), - "Closed large object, oid %ld", (long)self->lo_oid); + snprintf(print_buffer, sizeof(print_buffer), + "Closed large object, oid %ld", (long) self->lo_oid); fputs(print_buffer, fp); } @@ -643,25 +648,25 @@ pglarge_print(pglargeobject * self, FILE *fp, int flags) /* object type definition */ staticforward PyTypeObject PglargeType = { PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - "pglarge", /* tp_name */ - sizeof(pglargeobject), /* tp_basicsize */ - 0, /* tp_itemsize */ + 0, /* ob_size */ + "pglarge", /* tp_name */ + sizeof(pglargeobject), /* tp_basicsize */ + 0, /* tp_itemsize */ /* methods */ - (destructor) pglarge_dealloc, /* tp_dealloc */ - (printfunc) pglarge_print, /* tp_print */ - (getattrfunc) pglarge_getattr, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ + (destructor) pglarge_dealloc, /* tp_dealloc */ + (printfunc) pglarge_print, /* tp_print */ + (getattrfunc) pglarge_getattr, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_compare */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ }; -#endif /* LARGE_OBJECTS */ +#endif /* LARGE_OBJECTS */ /* --------------------------------------------------------------------- */ @@ -669,29 +674,35 @@ staticforward PyTypeObject PglargeType = { /* connects to a database */ static char connect__doc__[] = - "connect(dbname, host, port, opt, tty) -- connect to a PostgreSQL database " - "using specified parameters (optionals, keywords aware)."; +"connect(dbname, host, port, opt, tty) -- connect to a PostgreSQL database " +"using specified parameters (optionals, keywords aware)."; static PyObject * -pgconnect(pgobject *self, PyObject *args, PyObject *dict) +pgconnect(pgobject * self, PyObject * args, PyObject * dict) { - static const char *kwlist[] = { "dbname", "host", "port", "opt", - "tty", "user", "passwd" , NULL }; - char *pghost, *pgopt, *pgtty, *pgdbname, *pguser, *pgpasswd; - int pgport; - char port_buffer[20]; - pgobject *npgobj; + static const char *kwlist[] = {"dbname", "host", "port", "opt", + "tty", "user", "passwd", NULL}; + char *pghost, + *pgopt, + *pgtty, + *pgdbname, + *pguser, + *pgpasswd; + int pgport; + char port_buffer[20]; + pgobject *npgobj; pghost = pgopt = pgtty = pgdbname = pguser = pgpasswd = NULL; pgport = -1; - /* parses standard arguments - * With the right compiler warnings, this will issue a diagnostic. - * There is really no way around it. If I don't declare kwlist as - * const char *kwlist[] then it complains when I try to assign all - * those constant strings to it. */ + /* + * parses standard arguments With the right compiler warnings, this + * will issue a diagnostic. There is really no way around it. If I + * don't declare kwlist as const char *kwlist[] then it complains when + * I try to assign all those constant strings to it. + */ if (!PyArg_ParseTupleAndKeywords(args, dict, "|zzlzzzz", kwlist, - &pgdbname, &pghost, &pgport, &pgopt, &pgtty, &pguser, &pgpasswd)) + &pgdbname, &pghost, &pgport, &pgopt, &pgtty, &pguser, &pgpasswd)) return NULL; #ifdef DEFAULT_VARS @@ -716,7 +727,7 @@ pgconnect(pgobject *self, PyObject *args, PyObject *dict) if ((!pgpasswd) && (pg_default_passwd != Py_None)) pgpasswd = PyString_AsString(pg_default_passwd); -#endif /* DEFAULT_VARS */ +#endif /* DEFAULT_VARS */ if ((npgobj = PyObject_NEW(pgobject, &PgType)) == NULL) return NULL; @@ -726,11 +737,11 @@ pgconnect(pgobject *self, PyObject *args, PyObject *dict) bzero(port_buffer, sizeof(port_buffer)); sprintf(port_buffer, "%d", pgport); npgobj->cnx = PQsetdbLogin(pghost, port_buffer, pgopt, pgtty, pgdbname, - pguser, pgpasswd); + pguser, pgpasswd); } else npgobj->cnx = PQsetdbLogin(pghost, NULL, pgopt, pgtty, pgdbname, - pguser, pgpasswd); + pguser, pgpasswd); if (PQstatus(npgobj->cnx) == CONNECTION_BAD) { @@ -755,13 +766,13 @@ pg_dealloc(pgobject * self) } /* close without deleting */ -static char pg_close__doc__[] = - "close() -- close connection. All instances of the connection object and " - "derived objects (queries and large objects) can no longer be used after " - "this call."; +static char pg_close__doc__[] = +"close() -- close connection. All instances of the connection object and " +"derived objects (queries and large objects) can no longer be used after " +"this call."; static PyObject * -pg_close(pgobject *self, PyObject *args) +pg_close(pgobject * self, PyObject * args) { /* gets args */ if (!PyArg_ParseTuple(args, "")) @@ -776,7 +787,7 @@ pg_close(pgobject *self, PyObject *args) self->cnx = NULL; Py_INCREF(Py_None); return Py_None; -} +} static void pgquery_dealloc(pgqueryobject * self) @@ -788,10 +799,10 @@ pgquery_dealloc(pgqueryobject * self) } /* resets connection */ -static char pg_reset__doc__[] = - "reset() -- reset connection with current parameters. All derived queries " - "and large objects derived from this connection will not be usable after " - "this call."; +static char pg_reset__doc__[] = +"reset() -- reset connection with current parameters. All derived queries " +"and large objects derived from this connection will not be usable after " +"this call."; static PyObject * pg_reset(pgobject * self, PyObject * args) @@ -806,7 +817,7 @@ pg_reset(pgobject * self, PyObject * args) if (!PyArg_ParseTuple(args, "")) { PyErr_SetString(PyExc_SyntaxError, - "method reset() takes no parameters."); + "method reset() takes no parameters."); return NULL; } @@ -817,8 +828,8 @@ pg_reset(pgobject * self, PyObject * args) } /* get connection socket */ -static char pg_fileno__doc__[] = - "fileno() -- return database connection socket file handle."; +static char pg_fileno__doc__[] = +"fileno() -- return database connection socket file handle."; static PyObject * pg_fileno(pgobject * self, PyObject * args) @@ -833,7 +844,7 @@ pg_fileno(pgobject * self, PyObject * args) if (!PyArg_ParseTuple(args, "")) { PyErr_SetString(PyExc_SyntaxError, - "method fileno() takes no parameters."); + "method fileno() takes no parameters."); return NULL; } @@ -846,7 +857,7 @@ pg_fileno(pgobject * self, PyObject * args) /* get number of rows */ static char pgquery_ntuples__doc__[] = - "ntuples() -- returns number of tuples returned by query."; +"ntuples() -- returns number of tuples returned by query."; static PyObject * pgquery_ntuples(pgqueryobject * self, PyObject * args) @@ -855,29 +866,31 @@ pgquery_ntuples(pgqueryobject * self, PyObject * args) if (!PyArg_ParseTuple(args, "")) { PyErr_SetString(PyExc_SyntaxError, - "method ntuples() takes no parameters."); + "method ntuples() takes no parameters."); return NULL; } return PyInt_FromLong((long) PQntuples(self->last_result)); -} +} /* list fields names from query result */ static char pgquery_listfields__doc__[] = - "listfields() -- Lists field names from result."; +"listfields() -- Lists field names from result."; static PyObject * pgquery_listfields(pgqueryobject * self, PyObject * args) { - int i, n; - char *name; - PyObject *fieldstuple, *str; + int i, + n; + char *name; + PyObject *fieldstuple, + *str; /* checks args */ if (!PyArg_ParseTuple(args, "")) { PyErr_SetString(PyExc_SyntaxError, - "method listfields() takes no parameters."); + "method listfields() takes no parameters."); return NULL; } @@ -897,19 +910,19 @@ pgquery_listfields(pgqueryobject * self, PyObject * args) /* get field name from last result */ static char pgquery_fieldname__doc__[] = - "fieldname() -- returns name of field from result from its position."; +"fieldname() -- returns name of field from result from its position."; static PyObject * pgquery_fieldname(pgqueryobject * self, PyObject * args) { - int i; - char *name; + int i; + char *name; /* gets args */ if (!PyArg_ParseTuple(args, "i", &i)) { PyErr_SetString(PyExc_TypeError, - "fieldname(number), with number(integer)."); + "fieldname(number), with number(integer)."); return NULL; } @@ -927,13 +940,13 @@ pgquery_fieldname(pgqueryobject * self, PyObject * args) /* gets fields number from name in last result */ static char pgquery_fieldnum__doc__[] = - "fieldnum() -- returns position in query for field from its name."; +"fieldnum() -- returns position in query for field from its name."; static PyObject * pgquery_fieldnum(pgqueryobject * self, PyObject * args) { - char *name; - int num; + char *name; + int num; /* gets args */ if (!PyArg_ParseTuple(args, "s", &name)) @@ -954,21 +967,27 @@ pgquery_fieldnum(pgqueryobject * self, PyObject * args) /* retrieves last result */ static char pgquery_getresult__doc__[] = - "getresult() -- Gets the result of a query. The result is returned " - "as a list of rows, each one a list of fields in the order returned " - "by the server."; +"getresult() -- Gets the result of a query. The result is returned " +"as a list of rows, each one a list of fields in the order returned " +"by the server."; static PyObject * pgquery_getresult(pgqueryobject * self, PyObject * args) { - PyObject *rowtuple, *reslist, *val; - int i, j, m, n, *typ; + PyObject *rowtuple, + *reslist, + *val; + int i, + j, + m, + n, + *typ; /* checks args (args == NULL for an internal call) */ if ((args != NULL) && (!PyArg_ParseTuple(args, ""))) { PyErr_SetString(PyExc_SyntaxError, - "method getresult() takes no parameters."); + "method getresult() takes no parameters."); return NULL; } @@ -1013,9 +1032,9 @@ pgquery_getresult(pgqueryobject * self, PyObject * args) rowtuple = PyTuple_New(n); for (j = 0; j < n; j++) { - int k; - char *s = PQgetvalue(self->last_result, i, j); - char cashbuf[64]; + int k; + char *s = PQgetvalue(self->last_result, i, j); + char cashbuf[64]; switch (typ[j]) { @@ -1027,8 +1046,9 @@ pgquery_getresult(pgqueryobject * self, PyObject * args) val = PyFloat_FromDouble(strtod(s, NULL)); break; - case 3: /* get rid of the '$' and commas */ - if (*s == '$') /* there's talk of getting rid of it */ + case 3: /* get rid of the '$' and commas */ + if (*s == '$') /* there's talk of getting rid of + * it */ s++; if ((s[0] == '-' || s[0] == '(') && s[1] == '$') @@ -1062,21 +1082,27 @@ pgquery_getresult(pgqueryobject * self, PyObject * args) /* retrieves last result as a list of dictionaries*/ static char pgquery_dictresult__doc__[] = - "dictresult() -- Gets the result of a query. The result is returned " - "as a list of rows, each one a dictionary with the field names used " - "as the labels."; +"dictresult() -- Gets the result of a query. The result is returned " +"as a list of rows, each one a dictionary with the field names used " +"as the labels."; static PyObject * pgquery_dictresult(pgqueryobject * self, PyObject * args) { - PyObject *dict, *reslist, *val; - int i, j, m, n, *typ; + PyObject *dict, + *reslist, + *val; + int i, + j, + m, + n, + *typ; /* checks args (args == NULL for an internal call) */ if ((args != NULL) && (!PyArg_ParseTuple(args, ""))) { PyErr_SetString(PyExc_SyntaxError, - "method getresult() takes no parameters."); + "method getresult() takes no parameters."); return NULL; } @@ -1121,9 +1147,9 @@ pgquery_dictresult(pgqueryobject * self, PyObject * args) dict = PyDict_New(); for (j = 0; j < n; j++) { - int k; - char *s = PQgetvalue(self->last_result, i, j); - char cashbuf[64]; + int k; + char *s = PQgetvalue(self->last_result, i, j); + char cashbuf[64]; switch (typ[j]) { @@ -1135,8 +1161,9 @@ pgquery_dictresult(pgqueryobject * self, PyObject * args) val = PyFloat_FromDouble(strtod(s, NULL)); break; - case 3: /* get rid of the '$' and commas */ - if (*s == '$') /* there's talk of getting rid of it */ + case 3: /* get rid of the '$' and commas */ + if (*s == '$') /* there's talk of getting rid of + * it */ s++; if ((s[0] == '-' || s[0] == '(') && s[1] == '$') @@ -1170,15 +1197,16 @@ pgquery_dictresult(pgqueryobject * self, PyObject * args) } /* gets asynchronous notify */ -static char pg_getnotify__doc__[] = - "getnotify() -- get database notify for this connection."; +static char pg_getnotify__doc__[] = +"getnotify() -- get database notify for this connection."; static PyObject * pg_getnotify(pgobject * self, PyObject * args) { - PGnotify *notify; - PGresult *result; - PyObject *notify_result, *temp; + PGnotify *notify; + PGresult *result; + PyObject *notify_result, + *temp; if (!self->cnx) { @@ -1190,12 +1218,16 @@ pg_getnotify(pgobject * self, PyObject * args) if (!PyArg_ParseTuple(args, "")) { PyErr_SetString(PyExc_SyntaxError, - "method getnotify() takes no parameters."); + "method getnotify() takes no parameters."); return NULL; } /* gets notify and builds result */ - /* notifies only come back as result of a query, so I send an empty query */ + + /* + * notifies only come back as result of a query, so I send an empty + * query + */ result = PQexec(self->cnx, " "); if ((notify = PQnotifies(self->cnx)) != NULL) @@ -1221,15 +1253,15 @@ pg_getnotify(pgobject * self, PyObject * args) /* database query */ static char pg_query__doc__[] = - "query() -- creates a new query object for this connection."; +"query() -- creates a new query object for this connection."; static PyObject * pg_query(pgobject * self, PyObject * args) { - char *query; - PGresult *result; - pgqueryobject *npgobj; - int status; + char *query; + PGresult *result; + pgqueryobject *npgobj; + int status; if (!self->cnx) { @@ -1271,7 +1303,7 @@ pg_query(pgobject * self, PyObject * args) case PGRES_NONFATAL_ERROR: PyErr_SetString(PGError, PQerrorMessage(self->cnx)); break; - case PGRES_COMMAND_OK: /* could be an INSERT */ + case PGRES_COMMAND_OK: /* could be an INSERT */ if (*(str = PQoidStatus(result)) == 0) /* nope */ { Py_INCREF(Py_None); @@ -1281,13 +1313,13 @@ pg_query(pgobject * self, PyObject * args) /* otherwise, return the oid */ return PyInt_FromLong(strtol(str, NULL, 10)); - case PGRES_COPY_OUT: /* no data will be received */ + case PGRES_COPY_OUT: /* no data will be received */ case PGRES_COPY_IN: Py_INCREF(Py_None); return Py_None; default: PyErr_SetString(PGError, "internal error: " - "unknown result status."); + "unknown result status."); break; } @@ -1304,13 +1336,13 @@ pg_query(pgobject * self, PyObject * args) #ifdef DIRECT_ACCESS static char pg_putline__doc__[] = - "putline() -- sends a line directly to the backend"; +"putline() -- sends a line directly to the backend"; /* direct acces function : putline */ static PyObject * pg_putline(pgobject * self, PyObject * args) { - char *line; + char *line; if (!self->cnx) { @@ -1333,14 +1365,14 @@ pg_putline(pgobject * self, PyObject * args) /* direct access function : getline */ static char pg_getline__doc__[] = - "getline() -- gets a line directly from the backend."; +"getline() -- gets a line directly from the backend."; static PyObject * pg_getline(pgobject * self, PyObject * args) { - char line[MAX_BUFFER_SIZE]; - PyObject *str = NULL; /* GCC */ - int ret; + char line[MAX_BUFFER_SIZE]; + PyObject *str = NULL; /* GCC */ + int ret; if (!self->cnx) { @@ -1352,7 +1384,7 @@ pg_getline(pgobject * self, PyObject * args) if (!PyArg_ParseTuple(args, "")) { PyErr_SetString(PyExc_SyntaxError, - "method getline() takes no parameters."); + "method getline() takes no parameters."); return NULL; } @@ -1377,7 +1409,7 @@ pg_getline(pgobject * self, PyObject * args) /* direct access function : end copy */ static char pg_endcopy__doc__[] = - "endcopy() -- synchronizes client and server"; +"endcopy() -- synchronizes client and server"; static PyObject * pg_endcopy(pgobject * self, PyObject * args) @@ -1392,7 +1424,7 @@ pg_endcopy(pgobject * self, PyObject * args) if (!PyArg_ParseTuple(args, "")) { PyErr_SetString(PyExc_SyntaxError, - "method endcopy() takes no parameters."); + "method endcopy() takes no parameters."); return NULL; } @@ -1401,16 +1433,17 @@ pg_endcopy(pgobject * self, PyObject * args) Py_INCREF(Py_None); return Py_None; } -#endif /* DIRECT_ACCESS */ + +#endif /* DIRECT_ACCESS */ static PyObject * -pgquery_print(pgqueryobject *self, FILE *fp, int flags) +pgquery_print(pgqueryobject * self, FILE *fp, int flags) { - PQprintOpt op; + PQprintOpt op; memset(&op, 0, sizeof(op)); - op.align = 1; + op.align = 1; op.header = 1; op.fieldSep = "|"; op.pager = 1; @@ -1419,20 +1452,25 @@ pgquery_print(pgqueryobject *self, FILE *fp, int flags) } /* insert table */ -static char pg_inserttable__doc__[] = - "inserttable(string, list) -- insert list in table. The fields in the list " - "must be in the same order as in the table."; +static char pg_inserttable__doc__[] = +"inserttable(string, list) -- insert list in table. The fields in the list " +"must be in the same order as in the table."; static PyObject * pg_inserttable(pgobject * self, PyObject * args) { - PGresult *result; - char *table, *buffer, *temp; - char temp_buffer[256]; - PyObject *list, *sublist, *item; - PyObject *(*getitem) (PyObject *, int); - PyObject *(*getsubitem) (PyObject *, int); - int i, j; + PGresult *result; + char *table, + *buffer, + *temp; + char temp_buffer[256]; + PyObject *list, + *sublist, + *item; + PyObject *(*getitem) (PyObject *, int); + PyObject *(*getsubitem) (PyObject *, int); + int i, + j; if (!self->cnx) { @@ -1444,8 +1482,8 @@ pg_inserttable(pgobject * self, PyObject * args) if (!PyArg_ParseTuple(args, "sO:filter", &table, &list)) { PyErr_SetString(PyExc_TypeError, - "tableinsert(table, content), with table (string) " - "and content (list)."); + "tableinsert(table, content), with table (string) " + "and content (list)."); return NULL; } @@ -1457,7 +1495,7 @@ pg_inserttable(pgobject * self, PyObject * args) else { PyErr_SetString(PyExc_TypeError, - "second arg must be some kind of array."); + "second arg must be some kind of array."); return NULL; } @@ -1467,7 +1505,7 @@ pg_inserttable(pgobject * self, PyObject * args) if (!PyTuple_Check(sublist) && !PyList_Check(sublist)) { PyErr_SetString(PyExc_TypeError, - "second arg must contain some kind of arrays."); + "second arg must contain some kind of arrays."); return NULL; } } @@ -1509,7 +1547,7 @@ pg_inserttable(pgobject * self, PyObject * args) PyArg_ParseTuple(item, "s", &temp); else if (PyInt_Check(item)) { - int k; + int k; PyArg_ParseTuple(item, "i", &k); sprintf(temp_buffer, "%d", k); @@ -1517,7 +1555,7 @@ pg_inserttable(pgobject * self, PyObject * args) } else if (PyLong_Check(item)) { - long k; + long k; PyArg_ParseTuple(item, "l", &k); sprintf(temp_buffer, "%ld", k); @@ -1525,7 +1563,7 @@ pg_inserttable(pgobject * self, PyObject * args) } else if (PyFloat_Check(item)) { - double k; + double k; PyArg_ParseTuple(item, "d", &k); sprintf(temp_buffer, "%g", k); @@ -1535,8 +1573,8 @@ pg_inserttable(pgobject * self, PyObject * args) { free(buffer); PyErr_SetString(PyExc_ValueError, - "items must be strings, integers, " - "longs or double (real)."); + "items must be strings, integers, " + "longs or double (real)."); return NULL; } @@ -1565,49 +1603,50 @@ pg_inserttable(pgobject * self, PyObject * args) } /* creates large object */ -static char pg_locreate__doc__[] = - "locreate() -- creates a new large object in the database."; +static char pg_locreate__doc__[] = +"locreate() -- creates a new large object in the database."; -static PyObject * +static PyObject * pg_locreate(pgobject * self, PyObject * args) { - int mode; - Oid lo_oid; + int mode; + Oid lo_oid; /* checks validity */ if (!check_cnx_obj(self)) - return NULL; + return NULL; /* gets arguments */ if (!PyArg_ParseTuple(args, "i", &mode)) { PyErr_SetString(PyExc_TypeError, - "locreate(mode), with mode (integer)."); + "locreate(mode), with mode (integer)."); return NULL; } /* creates large object */ lo_oid = lo_creat(self->cnx, mode); - if (lo_oid == 0) { + if (lo_oid == 0) + { PyErr_SetString(PGError, "can't create large object."); return NULL; - } + } return (PyObject *) pglarge_new(self, lo_oid); } /* init from already known oid */ -static char pg_getlo__doc__[] = - "getlo(long) -- create a large object instance for the specified oid."; +static char pg_getlo__doc__[] = +"getlo(long) -- create a large object instance for the specified oid."; static PyObject * pg_getlo(pgobject * self, PyObject * args) { - int lo_oid; + int lo_oid; /* checks validity */ if (!check_cnx_obj(self)) - return NULL; + return NULL; /* gets arguments */ if (!PyArg_ParseTuple(args, "i", &lo_oid)) @@ -1627,18 +1666,18 @@ pg_getlo(pgobject * self, PyObject * args) } /* import unix file */ -static char pg_loimport__doc__[] = - "loimport(string) -- create a new large object from specified file."; +static char pg_loimport__doc__[] = +"loimport(string) -- create a new large object from specified file."; static PyObject * pg_loimport(pgobject * self, PyObject * args) { - char *name; - Oid lo_oid; + char *name; + Oid lo_oid; /* checks validity */ if (!check_cnx_obj(self)) - return NULL; + return NULL; /* gets arguments */ if (!PyArg_ParseTuple(args, "s", &name)) @@ -1661,24 +1700,24 @@ pg_loimport(pgobject * self, PyObject * args) /* connection object methods */ static struct PyMethodDef pgobj_methods[] = { - {"query", (PyCFunction) pg_query, 1, pg_query__doc__ }, - {"reset", (PyCFunction) pg_reset, 1, pg_reset__doc__ }, - {"close", (PyCFunction) pg_close, 1, pg_close__doc__ }, - {"fileno", (PyCFunction) pg_fileno,1, pg_fileno__doc__ }, - {"getnotify", (PyCFunction) pg_getnotify, 1, pg_getnotify__doc__ }, - {"inserttable", (PyCFunction) pg_inserttable, 1, pg_inserttable__doc__ }, + {"query", (PyCFunction) pg_query, 1, pg_query__doc__}, + {"reset", (PyCFunction) pg_reset, 1, pg_reset__doc__}, + {"close", (PyCFunction) pg_close, 1, pg_close__doc__}, + {"fileno", (PyCFunction) pg_fileno, 1, pg_fileno__doc__}, + {"getnotify", (PyCFunction) pg_getnotify, 1, pg_getnotify__doc__}, + {"inserttable", (PyCFunction) pg_inserttable, 1, pg_inserttable__doc__}, #ifdef DIRECT_ACCESS - {"putline", (PyCFunction) pg_putline, 1, pg_putline__doc__ }, - {"getline", (PyCFunction) pg_getline, 1, pg_getline__doc__ }, - {"endcopy", (PyCFunction) pg_endcopy, 1, pg_endcopy__doc__ }, -#endif /* DIRECT_ACCESS */ + {"putline", (PyCFunction) pg_putline, 1, pg_putline__doc__}, + {"getline", (PyCFunction) pg_getline, 1, pg_getline__doc__}, + {"endcopy", (PyCFunction) pg_endcopy, 1, pg_endcopy__doc__}, +#endif /* DIRECT_ACCESS */ #ifdef LARGE_OBJECTS - {"locreate", (PyCFunction) pg_locreate, 1, pg_locreate__doc__ }, - {"getlo", (PyCFunction) pg_getlo, 1, pg_getlo__doc__ }, - {"loimport", (PyCFunction) pg_loimport, 1, pg_loimport__doc__ }, -#endif /* LARGE_OBJECTS */ + {"locreate", (PyCFunction) pg_locreate, 1, pg_locreate__doc__}, + {"getlo", (PyCFunction) pg_getlo, 1, pg_getlo__doc__}, + {"loimport", (PyCFunction) pg_loimport, 1, pg_loimport__doc__}, +#endif /* LARGE_OBJECTS */ {NULL, NULL} /* sentinel */ }; @@ -1687,9 +1726,12 @@ static struct PyMethodDef pgobj_methods[] = { static PyObject * pg_getattr(pgobject * self, char *name) { - /* Although we could check individually, there are only a few - attributes that don't require a live connection and unless - someone has an urgent need, this will have to do */ + + /* + * Although we could check individually, there are only a few + * attributes that don't require a live connection and unless someone + * has an urgent need, this will have to do + */ if (!self->cnx) { PyErr_SetString(PyExc_TypeError, "Connection is not valid"); @@ -1701,7 +1743,8 @@ pg_getattr(pgobject * self, char *name) /* postmaster host */ if (!strcmp(name, "host")) { - char *r = PQhost(self->cnx); + char *r = PQhost(self->cnx); + return r ? PyString_FromString(r) : PyString_FromString("localhost"); } @@ -1732,12 +1775,12 @@ pg_getattr(pgobject * self, char *name) /* provided user name */ if (!strcmp(name, "user")) return PyString_FromString("Deprecated facility"); - /* return PyString_FromString(fe_getauthname("")); */ + /* return PyString_FromString(fe_getauthname("")); */ /* attributes list */ if (!strcmp(name, "__members__")) { - PyObject *list = PyList_New(8); + PyObject *list = PyList_New(8); if (list) { @@ -1780,16 +1823,16 @@ staticforward PyTypeObject PgType = { /* query object methods */ static struct PyMethodDef pgquery_methods[] = { - {"getresult", (PyCFunction) pgquery_getresult, 1, pgquery_getresult__doc__}, - {"dictresult", (PyCFunction) pgquery_dictresult, 1, pgquery_dictresult__doc__}, - {"fieldname", (PyCFunction) pgquery_fieldname, 1, pgquery_fieldname__doc__}, - {"fieldnum", (PyCFunction) pgquery_fieldnum, 1, pgquery_fieldnum__doc__}, - {"listfields", (PyCFunction) pgquery_listfields, 1, pgquery_listfields__doc__}, - {"ntuples", (PyCFunction) pgquery_ntuples, 1, pgquery_ntuples__doc__}, + {"getresult", (PyCFunction) pgquery_getresult, 1, pgquery_getresult__doc__}, + {"dictresult", (PyCFunction) pgquery_dictresult, 1, pgquery_dictresult__doc__}, + {"fieldname", (PyCFunction) pgquery_fieldname, 1, pgquery_fieldname__doc__}, + {"fieldnum", (PyCFunction) pgquery_fieldnum, 1, pgquery_fieldnum__doc__}, + {"listfields", (PyCFunction) pgquery_listfields, 1, pgquery_listfields__doc__}, + {"ntuples", (PyCFunction) pgquery_ntuples, 1, pgquery_ntuples__doc__}, {NULL, NULL} }; -/* gets query object attributes */ +/* gets query object attributes */ static PyObject * pgquery_getattr(pgqueryobject * self, char *name) { @@ -1800,21 +1843,21 @@ pgquery_getattr(pgqueryobject * self, char *name) /* query type definition */ staticforward PyTypeObject PgQueryType = { PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - "pgqueryobject", /* tp_name */ - sizeof(pgqueryobject), /* tp_basicsize */ - 0, /* tp_itemsize */ + 0, /* ob_size */ + "pgqueryobject", /* tp_name */ + sizeof(pgqueryobject), /* tp_basicsize */ + 0, /* tp_itemsize */ /* methods */ - (destructor) pgquery_dealloc, /* tp_dealloc */ - (printfunc) pgquery_print, /* tp_print */ - (getattrfunc) pgquery_getattr, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ + (destructor) pgquery_dealloc, /* tp_dealloc */ + (printfunc) pgquery_print, /* tp_print */ + (getattrfunc) pgquery_getattr, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_compare */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ }; @@ -1827,16 +1870,16 @@ staticforward PyTypeObject PgQueryType = { /* gets default host */ static char getdefhost__doc__[] = - "get_defhost() -- return default database host."; +"get_defhost() -- return default database host."; -static PyObject * -pggetdefhost(PyObject *self, PyObject *args) +static PyObject * +pggetdefhost(PyObject * self, PyObject * args) { /* checks args */ if (!PyArg_ParseTuple(args, "")) { PyErr_SetString(PyExc_SyntaxError, - "method get_defhost() takes no parameter."); + "method get_defhost() takes no parameter."); return NULL; } @@ -1846,19 +1889,19 @@ pggetdefhost(PyObject *self, PyObject *args) /* sets default host */ static char setdefhost__doc__[] = - "set_defhost(string) -- set default database host. Return previous value."; +"set_defhost(string) -- set default database host. Return previous value."; -static PyObject * -pgsetdefhost(PyObject * self, PyObject *args) +static PyObject * +pgsetdefhost(PyObject * self, PyObject * args) { - char *temp = NULL; - PyObject *old; + char *temp = NULL; + PyObject *old; /* gets arguments */ if (!PyArg_ParseTuple(args, "z", &temp)) { PyErr_SetString(PyExc_TypeError, - "set_defhost(name), with name (string/None)."); + "set_defhost(name), with name (string/None)."); return NULL; } @@ -1878,16 +1921,16 @@ pgsetdefhost(PyObject * self, PyObject *args) /* gets default base */ static char getdefbase__doc__[] = - "get_defbase() -- return default database name."; +"get_defbase() -- return default database name."; -static PyObject * -pggetdefbase(PyObject * self, PyObject *args) +static PyObject * +pggetdefbase(PyObject * self, PyObject * args) { /* checks args */ if (!PyArg_ParseTuple(args, "")) { PyErr_SetString(PyExc_SyntaxError, - "method get_defbase() takes no parameter."); + "method get_defbase() takes no parameter."); return NULL; } @@ -1897,19 +1940,19 @@ pggetdefbase(PyObject * self, PyObject *args) /* sets default base */ static char setdefbase__doc__[] = - "set_defbase(string) -- set default database name. Return previous value"; +"set_defbase(string) -- set default database name. Return previous value"; -static PyObject * -pgsetdefbase(PyObject * self, PyObject *args) +static PyObject * +pgsetdefbase(PyObject * self, PyObject * args) { - char *temp = NULL; - PyObject *old; + char *temp = NULL; + PyObject *old; /* gets arguments */ if (!PyArg_ParseTuple(args, "z", &temp)) { PyErr_SetString(PyExc_TypeError, - "set_defbase(name), with name (string/None)."); + "set_defbase(name), with name (string/None)."); return NULL; } @@ -1929,16 +1972,16 @@ pgsetdefbase(PyObject * self, PyObject *args) /* gets default options */ static char getdefopt__doc__[] = - "get_defopt() -- return default database options."; +"get_defopt() -- return default database options."; -static PyObject * -pggetdefopt(PyObject * self, PyObject *args) +static PyObject * +pggetdefopt(PyObject * self, PyObject * args) { /* checks args */ if (!PyArg_ParseTuple(args, "")) { PyErr_SetString(PyExc_SyntaxError, - "method get_defopt() takes no parameter."); + "method get_defopt() takes no parameter."); return NULL; } @@ -1948,19 +1991,19 @@ pggetdefopt(PyObject * self, PyObject *args) /* sets default opt */ static char setdefopt__doc__[] = - "set_defopt(string) -- set default database options. Return previous value."; +"set_defopt(string) -- set default database options. Return previous value."; -static PyObject * -pgsetdefopt(PyObject * self, PyObject *args) +static PyObject * +pgsetdefopt(PyObject * self, PyObject * args) { - char *temp = NULL; - PyObject *old; + char *temp = NULL; + PyObject *old; /* gets arguments */ if (!PyArg_ParseTuple(args, "z", &temp)) { PyErr_SetString(PyExc_TypeError, - "set_defopt(name), with name (string/None)."); + "set_defopt(name), with name (string/None)."); return NULL; } @@ -1980,16 +2023,16 @@ pgsetdefopt(PyObject * self, PyObject *args) /* gets default tty */ static char getdeftty__doc__[] = - "get_deftty() -- return default database debug terminal."; +"get_deftty() -- return default database debug terminal."; -static PyObject * -pggetdeftty(PyObject * self, PyObject *args) +static PyObject * +pggetdeftty(PyObject * self, PyObject * args) { /* checks args */ if (!PyArg_ParseTuple(args, "")) { PyErr_SetString(PyExc_SyntaxError, - "method get_deftty() takes no parameter."); + "method get_deftty() takes no parameter."); return NULL; } @@ -1999,20 +2042,20 @@ pggetdeftty(PyObject * self, PyObject *args) /* sets default tty */ static char setdeftty__doc__[] = - "set_deftty(string) -- set default database debug terminal. " - "Return previous value."; +"set_deftty(string) -- set default database debug terminal. " +"Return previous value."; -static PyObject * -pgsetdeftty(PyObject * self, PyObject *args) +static PyObject * +pgsetdeftty(PyObject * self, PyObject * args) { - char *temp = NULL; - PyObject *old; + char *temp = NULL; + PyObject *old; /* gets arguments */ if (!PyArg_ParseTuple(args, "z", &temp)) { PyErr_SetString(PyExc_TypeError, - "set_deftty(name), with name (string/None)."); + "set_deftty(name), with name (string/None)."); return NULL; } @@ -2032,16 +2075,16 @@ pgsetdeftty(PyObject * self, PyObject *args) /* gets default username */ static char getdefuser__doc__[] = - "get_defuser() -- return default database username."; +"get_defuser() -- return default database username."; -static PyObject * -pggetdefuser(PyObject * self, PyObject *args) +static PyObject * +pggetdefuser(PyObject * self, PyObject * args) { /* checks args */ if (!PyArg_ParseTuple(args, "")) { PyErr_SetString(PyExc_SyntaxError, - "method get_defuser() takes no parameter."); + "method get_defuser() takes no parameter."); return NULL; } @@ -2052,19 +2095,19 @@ pggetdefuser(PyObject * self, PyObject *args) /* sets default username */ static char setdefuser__doc__[] = - "set_defuser() -- set default database username. Return previous value."; +"set_defuser() -- set default database username. Return previous value."; -static PyObject * -pgsetdefuser(PyObject * self, PyObject *args) +static PyObject * +pgsetdefuser(PyObject * self, PyObject * args) { - char *temp = NULL; - PyObject *old; + char *temp = NULL; + PyObject *old; /* gets arguments */ if (!PyArg_ParseTuple(args, "z", &temp)) { PyErr_SetString(PyExc_TypeError, - "set_defuser(name), with name (string/None)."); + "set_defuser(name), with name (string/None)."); return NULL; } @@ -2084,20 +2127,19 @@ pgsetdefuser(PyObject * self, PyObject *args) /* sets default password */ static char setdefpasswd__doc__[] = - "set_defpasswd() -- set default database password."; +"set_defpasswd() -- set default database password."; -static PyObject * -pgsetdefpasswd(PyObject * self, PyObject *args) +static PyObject * +pgsetdefpasswd(PyObject * self, PyObject * args) { - char *temp = NULL; - PyObject *old; + char *temp = NULL; + PyObject *old; /* gets arguments */ if (!PyArg_ParseTuple(args, "z", &temp)) { PyErr_SetString(PyExc_TypeError, - "set_defpasswd(password), with password (string/ -None)."); + "set_defpasswd(password), with password (string/None)."); return NULL; } @@ -2112,22 +2154,22 @@ None)."); pg_default_passwd = Py_None; } - Py_INCREF(Py_None); + Py_INCREF(Py_None); return Py_None; } /* gets default port */ static char getdefport__doc__[] = - "get_defport() -- return default database port."; +"get_defport() -- return default database port."; -static PyObject * -pggetdefport(PyObject * self, PyObject *args) +static PyObject * +pggetdefport(PyObject * self, PyObject * args) { /* checks args */ if (!PyArg_ParseTuple(args, "")) { PyErr_SetString(PyExc_SyntaxError, - "method get_defport() takes no parameter."); + "method get_defport() takes no parameter."); return NULL; } @@ -2137,19 +2179,19 @@ pggetdefport(PyObject * self, PyObject *args) /* sets default port */ static char setdefport__doc__[] = - "set_defport(integer) -- set default database port. Return previous value."; +"set_defport(integer) -- set default database port. Return previous value."; -static PyObject * -pgsetdefport(PyObject * self, PyObject *args) +static PyObject * +pgsetdefport(PyObject * self, PyObject * args) { - long int port = -2; - PyObject *old; + long int port = -2; + PyObject *old; /* gets arguments */ if ((!PyArg_ParseTuple(args, "l", &port)) || (port < -1)) { PyErr_SetString(PyExc_TypeError, "set_defport(port), with port " - "(positive integer/-1)."); + "(positive integer/-1)."); return NULL; } @@ -2167,39 +2209,41 @@ pgsetdefport(PyObject * self, PyObject *args) return old; } -#endif /* DEFAULT_VARS */ +#endif /* DEFAULT_VARS */ /* List of functions defined in the module */ static struct PyMethodDef pg_methods[] = { - {"connect", (PyCFunction) pgconnect, 3, connect__doc__ }, + {"connect", (PyCFunction) pgconnect, 3, connect__doc__}, #ifdef DEFAULT_VARS - {"get_defhost", pggetdefhost, 1, getdefhost__doc__ }, - {"set_defhost", pgsetdefhost, 1, setdefhost__doc__ }, - {"get_defbase", pggetdefbase, 1, getdefbase__doc__ }, - {"set_defbase", pgsetdefbase, 1, setdefbase__doc__ }, - {"get_defopt", pggetdefopt, 1, getdefopt__doc__ }, - {"set_defopt", pgsetdefopt, 1, setdefopt__doc__ }, - {"get_deftty", pggetdeftty, 1, getdeftty__doc__ }, - {"set_deftty", pgsetdeftty, 1, setdeftty__doc__ }, - {"get_defport", pggetdefport, 1, getdefport__doc__ }, - {"set_defport", pgsetdefport, 1, setdefport__doc__ }, - {"get_defuser", pggetdefuser, 1, getdefuser__doc__ }, - {"set_defuser", pgsetdefuser, 1, setdefuser__doc__ }, - {"set_defpasswd", pgsetdefpasswd, 1, setdefpasswd__doc__ }, -#endif /* DEFAULT_VARS */ + {"get_defhost", pggetdefhost, 1, getdefhost__doc__}, + {"set_defhost", pgsetdefhost, 1, setdefhost__doc__}, + {"get_defbase", pggetdefbase, 1, getdefbase__doc__}, + {"set_defbase", pgsetdefbase, 1, setdefbase__doc__}, + {"get_defopt", pggetdefopt, 1, getdefopt__doc__}, + {"set_defopt", pgsetdefopt, 1, setdefopt__doc__}, + {"get_deftty", pggetdeftty, 1, getdeftty__doc__}, + {"set_deftty", pgsetdeftty, 1, setdeftty__doc__}, + {"get_defport", pggetdefport, 1, getdefport__doc__}, + {"set_defport", pgsetdefport, 1, setdefport__doc__}, + {"get_defuser", pggetdefuser, 1, getdefuser__doc__}, + {"set_defuser", pgsetdefuser, 1, setdefuser__doc__}, + {"set_defpasswd", pgsetdefpasswd, 1, setdefpasswd__doc__}, +#endif /* DEFAULT_VARS */ {NULL, NULL} /* sentinel */ }; -static char pg__doc__[] = "Python interface to PostgreSQL DB"; +static char pg__doc__[] = "Python interface to PostgreSQL DB"; /* Initialization function for the module */ -void init_pg(void); /* Python doesn't prototype this */ +void init_pg(void); /* Python doesn't prototype this */ void init_pg(void) { - PyObject *mod, *dict, *v; + PyObject *mod, + *dict, + *v; /* Initialize here because some WIN platforms get confused otherwise */ PglargeType.ob_type = PgType.ob_type = PgQueryType.ob_type = &PyType_Type; @@ -2227,18 +2271,25 @@ init_pg(void) PyDict_SetItemString(dict, "SEEK_SET", PyInt_FromLong(SEEK_SET)); PyDict_SetItemString(dict, "SEEK_CUR", PyInt_FromLong(SEEK_CUR)); PyDict_SetItemString(dict, "SEEK_END", PyInt_FromLong(SEEK_END)); -#endif /* LARGE_OBJECTS */ +#endif /* LARGE_OBJECTS */ #ifdef DEFAULT_VARS /* prepares default values */ - Py_INCREF(Py_None); pg_default_host = Py_None; - Py_INCREF(Py_None); pg_default_base = Py_None; - Py_INCREF(Py_None); pg_default_opt = Py_None; - Py_INCREF(Py_None); pg_default_port = Py_None; - Py_INCREF(Py_None); pg_default_tty = Py_None; - Py_INCREF(Py_None); pg_default_user = Py_None; - Py_INCREF(Py_None); pg_default_passwd = Py_None; -#endif /* DEFAULT_VARS */ + Py_INCREF(Py_None); + pg_default_host = Py_None; + Py_INCREF(Py_None); + pg_default_base = Py_None; + Py_INCREF(Py_None); + pg_default_opt = Py_None; + Py_INCREF(Py_None); + pg_default_port = Py_None; + Py_INCREF(Py_None); + pg_default_tty = Py_None; + Py_INCREF(Py_None); + pg_default_user = Py_None; + Py_INCREF(Py_None); + pg_default_passwd = Py_None; +#endif /* DEFAULT_VARS */ /* Check for errors */ if (PyErr_Occurred()) diff --git a/src/pl/plpgsql/src/pl_comp.c b/src/pl/plpgsql/src/pl_comp.c index d494b5fe4c..ea53442678 100644 --- a/src/pl/plpgsql/src/pl_comp.c +++ b/src/pl/plpgsql/src/pl_comp.c @@ -3,7 +3,7 @@ * procedural language * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.6 1999/05/10 00:46:29 momjian Exp $ + * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.7 1999/05/25 16:15:17 momjian Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -1060,7 +1060,7 @@ plpgsql_parse_dblwordtype(char *string) * ---------- */ attrtup = SearchSysCacheTuple(ATTNAME, - ObjectIdGetDatum(classtup->t_data->t_oid), + ObjectIdGetDatum(classtup->t_data->t_oid), PointerGetDatum(word2), 0, 0); if (!HeapTupleIsValid(attrtup)) { @@ -1174,7 +1174,7 @@ plpgsql_parse_wordrowtype(char *string) * ---------- */ attrtup = SearchSysCacheTuple(ATTNUM, - ObjectIdGetDatum(classtup->t_data->t_oid), + ObjectIdGetDatum(classtup->t_data->t_oid), (Datum) (i + 1), 0, 0); if (!HeapTupleIsValid(attrtup)) { diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c index 250171b873..48ff11a040 100644 --- a/src/pl/plpgsql/src/pl_exec.c +++ b/src/pl/plpgsql/src/pl_exec.c @@ -3,7 +3,7 @@ * procedural language * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.10 1999/05/10 00:46:30 momjian Exp $ + * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.11 1999/05/25 16:15:17 momjian Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -102,14 +102,14 @@ static int exec_stmt_execsql(PLpgSQL_execstate * estate, PLpgSQL_stmt_execsql * stmt); static void exec_prepare_plan(PLpgSQL_execstate * estate, - PLpgSQL_expr * expr); -static bool exec_simple_check_node(Node * node); + PLpgSQL_expr * expr); +static bool exec_simple_check_node(Node *node); static void exec_simple_check_plan(PLpgSQL_expr * expr); static void exec_eval_clear_fcache(Node *node); -static Datum exec_eval_simple_expr(PLpgSQL_execstate * estate, - PLpgSQL_expr * expr, - bool *isNull, - Oid *rettype); +static Datum exec_eval_simple_expr(PLpgSQL_execstate * estate, + PLpgSQL_expr * expr, + bool *isNull, + Oid *rettype); static void exec_assign_expr(PLpgSQL_execstate * estate, PLpgSQL_datum * target, @@ -1656,7 +1656,7 @@ exec_stmt_raise(PLpgSQL_execstate * estate, PLpgSQL_stmt_raise * stmt) */ static void exec_prepare_plan(PLpgSQL_execstate * estate, - PLpgSQL_expr * expr) + PLpgSQL_expr * expr) { PLpgSQL_var *var; PLpgSQL_rec *rec; @@ -2164,10 +2164,10 @@ exec_run_select(PLpgSQL_execstate * estate, * ---------- */ static Datum -exec_eval_simple_expr(PLpgSQL_execstate * estate, - PLpgSQL_expr * expr, - bool *isNull, - Oid *rettype) +exec_eval_simple_expr(PLpgSQL_execstate * estate, + PLpgSQL_expr * expr, + bool *isNull, + Oid *rettype) { Datum retval; PLpgSQL_var *var; @@ -2180,7 +2180,7 @@ exec_eval_simple_expr(PLpgSQL_execstate * estate, int i; bool isnull; bool isdone; - ExprContext *econtext; + ExprContext *econtext; ParamListInfo paramLI; /* ---------- @@ -2189,7 +2189,7 @@ exec_eval_simple_expr(PLpgSQL_execstate * estate, */ econtext = makeNode(ExprContext); paramLI = (ParamListInfo) palloc((expr->nparams + 1) * - sizeof(ParamListInfoData)); + sizeof(ParamListInfoData)); econtext->ecxt_param_list_info = paramLI; /* ---------- @@ -2200,7 +2200,7 @@ exec_eval_simple_expr(PLpgSQL_execstate * estate, for (i = 0; i < expr->nparams; i++, paramLI++) { paramLI->kind = PARAM_NUM; - paramLI->id = i + 1; + paramLI->id = i + 1; switch (estate->datums[expr->params[i]]->dtype) { @@ -2269,9 +2269,9 @@ exec_eval_simple_expr(PLpgSQL_execstate * estate, */ SPI_push(); retval = ExecEvalExpr(expr->plan_simple_expr, - econtext, - isNull, - &isdone); + econtext, + isNull, + &isdone); SPI_pop(); /* ---------- @@ -2414,39 +2414,45 @@ exec_cast_value(Datum value, Oid valtype, * ---------- */ static bool -exec_simple_check_node(Node * node) +exec_simple_check_node(Node *node) { switch (nodeTag(node)) { - case T_Expr: { - Expr *expr = (Expr *)node; - List *l; + case T_Expr: + { + Expr *expr = (Expr *) node; + List *l; - switch (expr->opType) - { - case OP_EXPR: - case FUNC_EXPR: - case OR_EXPR: - case AND_EXPR: - case NOT_EXPR: break; + switch (expr->opType) + { + case OP_EXPR: + case FUNC_EXPR: + case OR_EXPR: + case AND_EXPR: + case NOT_EXPR: + break; - default: return FALSE; - } + default: + return FALSE; + } - foreach (l, expr->args) - { - if (!exec_simple_check_node(lfirst(l))) - return FALSE; - } + foreach(l, expr->args) + { + if (!exec_simple_check_node(lfirst(l))) + return FALSE; + } - return TRUE; - } + return TRUE; + } - case T_Param: return TRUE; + case T_Param: + return TRUE; - case T_Const: return TRUE; + case T_Const: + return TRUE; - default: return FALSE; + default: + return FALSE; } } @@ -2460,21 +2466,21 @@ exec_simple_check_node(Node * node) static void exec_simple_check_plan(PLpgSQL_expr * expr) { - _SPI_plan *spi_plan = (_SPI_plan *)expr->plan; - Plan *plan; - TargetEntry *tle; + _SPI_plan *spi_plan = (_SPI_plan *) expr->plan; + Plan *plan; + TargetEntry *tle; expr->plan_simple_expr = NULL; /* ---------- * 1. We can only evaluate queries that resulted in one single - * execution plan + * execution plan * ---------- */ if (spi_plan->ptlist == NULL || length(spi_plan->ptlist) != 1) return; - plan = (Plan *)lfirst(spi_plan->ptlist); + plan = (Plan *) lfirst(spi_plan->ptlist); /* ---------- * 2. It must be a RESULT plan --> no scan's required @@ -2492,7 +2498,7 @@ exec_simple_check_plan(PLpgSQL_expr * expr) /* ---------- * 4. Don't know if all these can break us, so let SPI handle - * those plans + * those plans * ---------- */ if (plan->qual != NULL || plan->lefttree != NULL || plan->righttree != NULL) @@ -2500,10 +2506,10 @@ exec_simple_check_plan(PLpgSQL_expr * expr) /* ---------- * 5. Check that all the nodes in the expression are one of - * Expr, Param or Const. + * Expr, Param or Const. * ---------- */ - tle = (TargetEntry *)lfirst(plan->targetlist); + tle = (TargetEntry *) lfirst(plan->targetlist); if (!exec_simple_check_node(tle->expr)) return; @@ -2516,18 +2522,22 @@ exec_simple_check_plan(PLpgSQL_expr * expr) switch (nodeTag(tle->expr)) { - case T_Expr: expr->plan_simple_type = - ((Expr *)(tle->expr))->typeOid; - break; + case T_Expr: + expr->plan_simple_type = + ((Expr *) (tle->expr))->typeOid; + break; - case T_Param: expr->plan_simple_type = - ((Param *)(tle->expr))->paramtype; - break; + case T_Param: + expr->plan_simple_type = + ((Param *) (tle->expr))->paramtype; + break; - case T_Const: expr->plan_simple_type = ((Const *)(tle->expr))->consttype; - break; + case T_Const: + expr->plan_simple_type = ((Const *) (tle->expr))->consttype; + break; - default: expr->plan_simple_type = InvalidOid; + default: + expr->plan_simple_type = InvalidOid; } return; @@ -2544,26 +2554,29 @@ exec_simple_check_plan(PLpgSQL_expr * expr) static void exec_eval_clear_fcache(Node *node) { - Expr *expr; - List *l; + Expr *expr; + List *l; if (nodeTag(node) != T_Expr) return; - expr = (Expr *)node; + expr = (Expr *) node; - switch(expr->opType) + switch (expr->opType) { - case OP_EXPR: ((Oper *)(expr->oper))->op_fcache = NULL; - break; + case OP_EXPR: + ((Oper *) (expr->oper))->op_fcache = NULL; + break; - case FUNC_EXPR: ((Func *)(expr->oper))->func_fcache = NULL; - break; + case FUNC_EXPR: + ((Func *) (expr->oper))->func_fcache = NULL; + break; - default: break; + default: + break; } - foreach (l, expr->args) + foreach(l, expr->args) exec_eval_clear_fcache(lfirst(l)); } diff --git a/src/pl/plpgsql/src/pl_funcs.c b/src/pl/plpgsql/src/pl_funcs.c index 5416d0d689..b2ddd3cfd9 100644 --- a/src/pl/plpgsql/src/pl_funcs.c +++ b/src/pl/plpgsql/src/pl_funcs.c @@ -3,7 +3,7 @@ * procedural language * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_funcs.c,v 1.4 1999/05/10 00:46:31 momjian Exp $ + * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_funcs.c,v 1.5 1999/05/25 16:15:18 momjian Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -328,8 +328,8 @@ plpgsql_ns_rename(char *oldname, char *newname) char * plpgsql_tolower(char *s) { - char *ret; - char *cp; + char *ret; + char *cp; ret = palloc(strlen(s) + 1); cp = ret; diff --git a/src/pl/tcl/pltcl.c b/src/pl/tcl/pltcl.c index dc11a7111a..3e40b82ecd 100644 --- a/src/pl/tcl/pltcl.c +++ b/src/pl/tcl/pltcl.c @@ -3,7 +3,7 @@ * procedural language (PL) * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.9 1999/04/20 02:19:59 tgl Exp $ + * $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.10 1999/05/25 16:15:19 momjian Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -1041,9 +1041,8 @@ pltcl_trigger_handler(FmgrInfo *proinfo) if (SPI_finish() != SPI_OK_FINISH) elog(ERROR, "pltcl: SPI_finish() failed"); - if (strcmp(pltcl_safe_interp->result, "OK") == 0) { + if (strcmp(pltcl_safe_interp->result, "OK") == 0) return rettup; - } if (strcmp(pltcl_safe_interp->result, "SKIP") == 0) { return (HeapTuple) NULL;; diff --git a/src/test/examples/testlo.c b/src/test/examples/testlo.c index 672a78ae88..e0b2e9bbc8 100644 --- a/src/test/examples/testlo.c +++ b/src/test/examples/testlo.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/test/examples/testlo.c,v 1.12 1999/05/20 09:30:36 ishii Exp $ + * $Header: /cvsroot/pgsql/src/test/examples/testlo.c,v 1.13 1999/05/25 16:15:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -83,9 +83,7 @@ pickout(PGconn *conn, Oid lobjId, int start, int len) lobj_fd = lo_open(conn, lobjId, INV_READ); if (lobj_fd < 0) - { fprintf(stderr, "can't open large object %u", lobjId); - } lo_lseek(conn, lobj_fd, start, SEEK_SET); buf = malloc(len + 1); @@ -113,9 +111,7 @@ overwrite(PGconn *conn, Oid lobjId, int start, int len) lobj_fd = lo_open(conn, lobjId, INV_READ); if (lobj_fd < 0) - { fprintf(stderr, "can't open large object %u", lobjId); - } lo_lseek(conn, lobj_fd, start, SEEK_SET); buf = malloc(len + 1); @@ -154,9 +150,7 @@ exportFile(PGconn *conn, Oid lobjId, char *filename) */ lobj_fd = lo_open(conn, lobjId, INV_READ); if (lobj_fd < 0) - { fprintf(stderr, "can't open large object %u", lobjId); - } /* * open the file to be written to diff --git a/src/test/examples/testlo2.c b/src/test/examples/testlo2.c index 6345f2cc03..168dd51e3d 100644 --- a/src/test/examples/testlo2.c +++ b/src/test/examples/testlo2.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/test/examples/Attic/testlo2.c,v 1.11 1999/05/20 09:30:36 ishii Exp $ + * $Header: /cvsroot/pgsql/src/test/examples/Attic/testlo2.c,v 1.12 1999/05/25 16:15:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -79,9 +79,7 @@ pickout(PGconn *conn, Oid lobjId, int start, int len) lobj_fd = lo_open(conn, lobjId, INV_READ); if (lobj_fd < 0) - { fprintf(stderr, "can't open large object %u", lobjId); - } lo_lseek(conn, lobj_fd, start, SEEK_SET); buf = malloc(len + 1); @@ -109,9 +107,7 @@ overwrite(PGconn *conn, Oid lobjId, int start, int len) lobj_fd = lo_open(conn, lobjId, INV_READ); if (lobj_fd < 0) - { fprintf(stderr, "can't open large object %u", lobjId); - } lo_lseek(conn, lobj_fd, start, SEEK_SET); buf = malloc(len + 1); @@ -150,9 +146,7 @@ exportFile(PGconn *conn, Oid lobjId, char *filename) */ lobj_fd = lo_open(conn, lobjId, INV_READ); if (lobj_fd < 0) - { fprintf(stderr, "can't open large object %u", lobjId); - } /* * open the file to be written to diff --git a/src/test/regress/regress.c b/src/test/regress/regress.c index 9674c52d2d..6cfa26017e 100644 --- a/src/test/regress/regress.c +++ b/src/test/regress/regress.c @@ -1,5 +1,5 @@ /* - * $Header: /cvsroot/pgsql/src/test/regress/regress.c,v 1.31 1999/05/03 19:10:48 momjian Exp $ + * $Header: /cvsroot/pgsql/src/test/regress/regress.c,v 1.32 1999/05/25 16:15:26 momjian Exp $ */ #include /* faked on sunos */ @@ -390,11 +390,11 @@ funny_dup17() if (SPI_processed > 0) { selected = int4in( - SPI_getvalue( - SPI_tuptable->vals[0], - SPI_tuptable->tupdesc, - 1 - ) + SPI_getvalue( + SPI_tuptable->vals[0], + SPI_tuptable->tupdesc, + 1 + ) ); } diff --git a/src/tools/pgindent/README b/src/tools/pgindent/README index d0f3324d6c..446010c9c5 100644 --- a/src/tools/pgindent/README +++ b/src/tools/pgindent/README @@ -3,7 +3,7 @@ This can format all PostgreSQL *.c and *.h files, excluding libpq++, On 09/06/1997, from the top directory, I ran: - find . -name '*.[ch]' -type f -print | egrep -v '++|/odbc/|s_lock.h' | xargs -n100 pgindent + find . -name '*.[ch]' -type f -print | egrep -v '\+\+|/odbc/|s_lock.h' | xargs -n100 pgindent The stock BSD indent has two bugs. First, a comment after the word 'else' causes the rest of the file to be ignored. Second, it silently ignores diff --git a/src/tutorial/funcs.c b/src/tutorial/funcs.c index cda3ef112a..bb0efacb64 100644 --- a/src/tutorial/funcs.c +++ b/src/tutorial/funcs.c @@ -18,11 +18,11 @@ */ int add_one(int arg); -Point *makepoint(Point *pointx, Point *pointy ); +Point *makepoint(Point *pointx, Point *pointy); text *copytext(text *t); -bool c_overpaid(TupleTableSlot *t, /* the current instance of EMP */ - int4 limit); +bool c_overpaid(TupleTableSlot *t, /* the current instance of EMP */ + int4 limit); @@ -33,9 +33,9 @@ add_one(int arg) } Point * -makepoint(Point *pointx, Point *pointy ) +makepoint(Point *pointx, Point *pointy) { - Point *new_point = (Point *) palloc(sizeof(Point)); + Point *new_point = (Point *) palloc(sizeof(Point)); new_point->x = pointx->x; new_point->y = pointy->y; @@ -67,7 +67,7 @@ copytext(text *t) } bool -c_overpaid(TupleTableSlot *t, /* the current instance of EMP */ +c_overpaid(TupleTableSlot *t, /* the current instance of EMP */ int4 limit) { bool isnull = false; diff --git a/src/utils/dllinit.c b/src/utils/dllinit.c index c86a5274ae..3e8fb861a0 100644 --- a/src/utils/dllinit.c +++ b/src/utils/dllinit.c @@ -1,17 +1,17 @@ -/* dllinit.c -- Portable DLL initialization. +/* dllinit.c -- Portable DLL initialization. Copyright (C) 1998 Free Software Foundation, Inc. Contributed by Mumit Khan (khan@xraylith.wisc.edu). - I've used DllMain as the DLL "main" since that's the most common + I've used DllMain as the DLL "main" since that's the most common usage. MSVC and Mingw32 both default to DllMain as the standard - callback from the linker entry point. Cygwin32 b19+ uses essentially + callback from the linker entry point. Cygwin32 b19+ uses essentially the same, albeit slightly differently implemented, scheme. Please - see DECLARE_CYGWIN_DLL macro in for more + see DECLARE_CYGWIN_DLL macro in for more info on how Cygwin32 uses the callback function. - The real entry point is typically always defined by the runtime - library, and usually never overridden by (casual) user. What you can - override however is the callback routine that the entry point calls, + The real entry point is typically always defined by the runtime + library, and usually never overridden by (casual) user. What you can + override however is the callback routine that the entry point calls, and this file provides such a callback function, DllMain. Mingw32: The default entry point for mingw32 is DllMainCRTStartup @@ -40,17 +40,17 @@ #undef WIN32_LEAN_AND_MEAN #include -BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, - LPVOID reserved /* Not used. */ ); +BOOL APIENTRY DllMain(HINSTANCE hInst, DWORD reason, + LPVOID reserved /* Not used. */ ); #ifdef __CYGWIN32__ #include -DECLARE_CYGWIN_DLL( DllMain ); +DECLARE_CYGWIN_DLL(DllMain); /* save hInstance from DllMain */ -HINSTANCE __hDllInstance_base; +HINSTANCE __hDllInstance_base; -#endif /* __CYGWIN32__ */ +#endif /* __CYGWIN32__ */ struct _reent *_impure_ptr; @@ -59,47 +59,46 @@ extern struct _reent *__imp_reent_data; /* *---------------------------------------------------------------------- * - * DllMain + * DllMain * - * This routine is called by the Mingw32, Cygwin32 or VC++ C run - * time library init code, or the Borland DllEntryPoint routine. It - * is responsible for initializing various dynamically loaded + * This routine is called by the Mingw32, Cygwin32 or VC++ C run + * time library init code, or the Borland DllEntryPoint routine. It + * is responsible for initializing various dynamically loaded * libraries. * * Results: - * TRUE on sucess, FALSE on failure. + * TRUE on sucess, FALSE on failure. * * Side effects: * *---------------------------------------------------------------------- */ -BOOL APIENTRY -DllMain ( - HINSTANCE hInst /* Library instance handle. */ , - DWORD reason /* Reason this function is being called. */ , - LPVOID reserved /* Not used. */ ) +BOOL APIENTRY +DllMain( + HINSTANCE hInst /* Library instance handle. */ , + DWORD reason /* Reason this function is being called. */ , + LPVOID reserved /* Not used. */ ) { #ifdef __CYGWIN32__ - __hDllInstance_base = hInst; -#endif /* __CYGWIN32__ */ + __hDllInstance_base = hInst; +#endif /* __CYGWIN32__ */ - _impure_ptr = __imp_reent_data; - - switch (reason) - { - case DLL_PROCESS_ATTACH: - break; + _impure_ptr = __imp_reent_data; - case DLL_PROCESS_DETACH: - break; + switch (reason) + { + case DLL_PROCESS_ATTACH: + break; - case DLL_THREAD_ATTACH: - break; + case DLL_PROCESS_DETACH: + break; - case DLL_THREAD_DETACH: - break; - } - return TRUE; + case DLL_THREAD_ATTACH: + break; + + case DLL_THREAD_DETACH: + break; + } + return TRUE; } - diff --git a/src/utils/getopt.c b/src/utils/getopt.c index c36550422d..8aa46c72f7 100644 --- a/src/utils/getopt.c +++ b/src/utils/getopt.c @@ -51,7 +51,7 @@ char *optarg; /* argument associated with option */ #define EMSG "" /* - * getopt + * getopt * Parse argc/argv argument vector. */ int diff --git a/src/win32/endian.h b/src/win32/endian.h index 6ba49cd2f2..b8a646ab9f 100644 --- a/src/win32/endian.h +++ b/src/win32/endian.h @@ -4,5 +4,3 @@ /* JKR added file, all hacks will be in the files added, not in EGCS */ #include - -#endif \ No newline at end of file diff --git a/src/win32/tcp.h b/src/win32/tcp.h index 5fc85d9447..48de4ad556 100644 --- a/src/win32/tcp.h +++ b/src/win32/tcp.h @@ -1,6 +1,6 @@ -#ifndef _INET_TCP_ -#define _INET_TCP_ +#ifndef _INET_TCP_ +#define _INET_TCP_ /* JKR added file, all hacks will be in the files added, not in EGCS */ -#endif /* _INET_TCP_ */ +#endif /* _INET_TCP_ */ diff --git a/src/win32/un.h b/src/win32/un.h index a914c22afc..ca43303fa5 100644 --- a/src/win32/un.h +++ b/src/win32/un.h @@ -1,11 +1,10 @@ -#ifndef _SYS_UN_H -#define _SYS_UN_H +#ifndef _SYS_UN_H +#define _SYS_UN_H /* JKR added file, all hacks will be in the files added, not in EGCS */ -struct sockaddr_un { - short sun_family; /* AF_UNIX */ - char sun_path[108]; /* path name (gag) */ +struct sockaddr_un +{ + short sun_family; /* AF_UNIX */ + char sun_path[108]; /* path name (gag) */ }; - -#endif /* _SYS_UN_H */ \ No newline at end of file