From 1dc34982511d91ef8a2b71bdcb870f067c1b3da9 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Sat, 15 Oct 2005 02:49:52 +0000 Subject: [PATCH] Standard pgindent run for 8.1. --- contrib/btree_gist/btree_cash.c | 10 +- contrib/btree_gist/btree_date.c | 16 +- contrib/btree_gist/btree_float4.c | 6 +- contrib/btree_gist/btree_float8.c | 6 +- contrib/btree_gist/btree_inet.c | 8 +- contrib/btree_gist/btree_int2.c | 10 +- contrib/btree_gist/btree_int4.c | 12 +- contrib/btree_gist/btree_int8.c | 12 +- contrib/btree_gist/btree_interval.c | 12 +- contrib/btree_gist/btree_macaddr.c | 10 +- contrib/btree_gist/btree_oid.c | 6 +- contrib/btree_gist/btree_text.c | 10 +- contrib/btree_gist/btree_time.c | 26 +- contrib/btree_gist/btree_ts.c | 54 +- contrib/btree_gist/btree_utils_num.h | 10 +- contrib/btree_gist/btree_utils_var.c | 148 +- contrib/btree_gist/btree_utils_var.h | 3 +- contrib/chkpass/chkpass.c | 6 +- contrib/cube/cube.c | 55 +- contrib/dbase/dbf.c | 11 +- contrib/dbase/dbf.h | 12 +- contrib/dbase/dbf2pg.c | 26 +- contrib/dblink/dblink.c | 99 +- contrib/dbmirror/pending.c | 12 +- contrib/earthdistance/earthdistance.c | 2 +- contrib/fulltextindex/fti.c | 12 +- contrib/fuzzystrmatch/dmetaphone.c | 71 +- contrib/fuzzystrmatch/fuzzystrmatch.c | 73 +- contrib/intagg/int_aggregate.c | 24 +- contrib/intarray/_int_gist.c | 39 +- contrib/intarray/_int_op.c | 8 +- contrib/intarray/_intbig_gist.c | 2 +- contrib/ltree/_ltree_op.c | 2 +- contrib/ltree/lquery_op.c | 4 +- contrib/ltree/ltree.h | 2 +- contrib/ltree/ltree_gist.c | 16 +- contrib/ltree/ltree_io.c | 6 +- contrib/mSQL-interface/mpgsql.c | 4 +- contrib/oid2name/oid2name.c | 122 +- contrib/pg_buffercache/pg_buffercache_pages.c | 93 +- contrib/pg_trgm/trgm_op.c | 4 +- contrib/pgbench/pgbench.c | 197 +- contrib/pgcrypto/crypt-blowfish.c | 3 +- contrib/pgcrypto/crypt-des.c | 48 +- contrib/pgcrypto/crypt-gensalt.c | 8 +- contrib/pgcrypto/crypt-md5.c | 8 +- contrib/pgcrypto/fortuna.c | 146 +- contrib/pgcrypto/fortuna.h | 7 +- contrib/pgcrypto/internal.c | 75 +- contrib/pgcrypto/mbuf.c | 45 +- contrib/pgcrypto/mbuf.h | 45 +- contrib/pgcrypto/md5.h | 2 +- contrib/pgcrypto/openssl.c | 34 +- contrib/pgcrypto/pgcrypto.c | 4 +- contrib/pgcrypto/pgp-armor.c | 26 +- contrib/pgcrypto/pgp-cfb.c | 59 +- contrib/pgcrypto/pgp-compress.c | 60 +- contrib/pgcrypto/pgp-decrypt.c | 281 +- contrib/pgcrypto/pgp-encrypt.c | 101 +- contrib/pgcrypto/pgp-info.c | 52 +- contrib/pgcrypto/pgp-mpi-internal.c | 18 +- contrib/pgcrypto/pgp-mpi-openssl.c | 180 +- contrib/pgcrypto/pgp-mpi.c | 53 +- contrib/pgcrypto/pgp-pgsql.c | 199 +- contrib/pgcrypto/pgp-pubdec.c | 72 +- contrib/pgcrypto/pgp-pubenc.c | 62 +- contrib/pgcrypto/pgp-pubkey.c | 167 +- contrib/pgcrypto/pgp-s2k.c | 39 +- contrib/pgcrypto/pgp.c | 41 +- contrib/pgcrypto/pgp.h | 201 +- contrib/pgcrypto/px-crypt.c | 7 +- contrib/pgcrypto/px-crypt.h | 10 +- contrib/pgcrypto/px.c | 34 +- contrib/pgcrypto/px.h | 23 +- contrib/pgcrypto/random.c | 57 +- contrib/pgcrypto/rijndael.c | 4 +- contrib/pgcrypto/sha2.c | 477 +-- contrib/pgcrypto/sha2.h | 66 +- contrib/pgstattuple/pgstattuple.c | 12 +- contrib/seg/seg.c | 71 +- contrib/spi/autoinc.c | 4 +- contrib/spi/insert_username.c | 4 +- contrib/spi/moddatetime.c | 9 +- contrib/spi/refint.c | 72 +- contrib/spi/timetravel.c | 23 +- contrib/tablefunc/tablefunc.c | 145 +- contrib/tsearch2/dict.c | 18 +- contrib/tsearch2/dict.h | 30 +- contrib/tsearch2/dict_ex.c | 2 +- contrib/tsearch2/dict_ispell.c | 18 +- contrib/tsearch2/dict_snowball.c | 2 +- contrib/tsearch2/dict_syn.c | 4 +- contrib/tsearch2/gistidx.c | 36 +- contrib/tsearch2/gistidx.h | 6 +- contrib/tsearch2/ispell/spell.c | 62 +- contrib/tsearch2/ispell/spell.h | 10 +- contrib/tsearch2/prs_dcfg.c | 16 +- contrib/tsearch2/query.c | 35 +- contrib/tsearch2/rank.c | 95 +- contrib/tsearch2/snowball/api.c | 122 +- contrib/tsearch2/snowball/api.h | 27 +- contrib/tsearch2/snowball/english_stem.c | 2610 +++++++++------- contrib/tsearch2/snowball/english_stem.h | 11 +- contrib/tsearch2/snowball/header.h | 62 +- contrib/tsearch2/snowball/russian_stem.c | 1479 +++++---- contrib/tsearch2/snowball/russian_stem.h | 11 +- contrib/tsearch2/snowball/utilities.c | 876 ++++-- contrib/tsearch2/stopword.c | 4 +- contrib/tsearch2/ts_cfg.c | 62 +- contrib/tsearch2/ts_stat.c | 8 +- contrib/tsearch2/tsvector.c | 26 +- contrib/tsearch2/tsvector.h | 14 +- contrib/tsearch2/tsvector_op.c | 2 +- contrib/tsearch2/wparser.c | 16 +- contrib/tsearch2/wparser_def.c | 2 +- contrib/vacuumlo/vacuumlo.c | 19 +- contrib/xml2/xpath.c | 64 +- contrib/xml2/xslt_proc.c | 2 +- src/backend/access/common/heaptuple.c | 188 +- src/backend/access/common/indextuple.c | 37 +- src/backend/access/common/printtup.c | 21 +- src/backend/access/common/tupdesc.c | 52 +- src/backend/access/gist/gistproc.c | 4 +- src/backend/access/hash/hash.c | 63 +- src/backend/access/hash/hashfunc.c | 31 +- src/backend/access/hash/hashinsert.c | 29 +- src/backend/access/hash/hashovfl.c | 58 +- src/backend/access/hash/hashpage.c | 134 +- src/backend/access/hash/hashscan.c | 8 +- src/backend/access/hash/hashsearch.c | 38 +- src/backend/access/heap/heapam.c | 428 ++- src/backend/access/heap/hio.c | 91 +- src/backend/access/heap/tuptoaster.c | 98 +- src/backend/access/index/genam.c | 12 +- src/backend/access/index/indexam.c | 85 +- src/backend/access/nbtree/nbtinsert.c | 268 +- src/backend/access/nbtree/nbtpage.c | 194 +- src/backend/access/nbtree/nbtree.c | 180 +- src/backend/access/nbtree/nbtsearch.c | 279 +- src/backend/access/nbtree/nbtsort.c | 138 +- src/backend/access/nbtree/nbtutils.c | 86 +- src/backend/access/nbtree/nbtxlog.c | 20 +- src/backend/access/rtree/rtget.c | 40 +- src/backend/access/rtree/rtproc.c | 6 +- src/backend/access/rtree/rtree.c | 184 +- src/backend/access/rtree/rtscan.c | 21 +- src/backend/access/transam/clog.c | 22 +- src/backend/access/transam/multixact.c | 380 +-- src/backend/access/transam/slru.c | 132 +- src/backend/access/transam/subtrans.c | 21 +- src/backend/access/transam/transam.c | 40 +- src/backend/access/transam/twophase.c | 310 +- src/backend/access/transam/twophase_rmgr.c | 38 +- src/backend/access/transam/varsup.c | 138 +- src/backend/access/transam/xact.c | 639 ++-- src/backend/access/transam/xlog.c | 1129 ++++--- src/backend/access/transam/xlogutils.c | 28 +- src/backend/bootstrap/bootstrap.c | 49 +- src/backend/catalog/aclchk.c | 279 +- src/backend/catalog/catalog.c | 20 +- src/backend/catalog/dependency.c | 179 +- src/backend/catalog/heap.c | 258 +- src/backend/catalog/index.c | 326 +- src/backend/catalog/indexing.c | 10 +- src/backend/catalog/namespace.c | 258 +- src/backend/catalog/pg_aggregate.c | 80 +- src/backend/catalog/pg_constraint.c | 51 +- src/backend/catalog/pg_conversion.c | 19 +- src/backend/catalog/pg_depend.c | 35 +- src/backend/catalog/pg_operator.c | 62 +- src/backend/catalog/pg_proc.c | 90 +- src/backend/catalog/pg_shdepend.c | 217 +- src/backend/catalog/pg_type.c | 41 +- src/backend/commands/aggregatecmds.c | 53 +- src/backend/commands/alter.c | 18 +- src/backend/commands/analyze.c | 305 +- src/backend/commands/async.c | 213 +- src/backend/commands/cluster.c | 184 +- src/backend/commands/comment.c | 62 +- src/backend/commands/conversioncmds.c | 21 +- src/backend/commands/copy.c | 539 ++-- src/backend/commands/dbcommands.c | 186 +- src/backend/commands/define.c | 8 +- src/backend/commands/explain.c | 90 +- src/backend/commands/functioncmds.c | 114 +- src/backend/commands/indexcmds.c | 166 +- src/backend/commands/lockcmds.c | 10 +- src/backend/commands/opclasscmds.c | 76 +- src/backend/commands/operatorcmds.c | 27 +- src/backend/commands/portalcmds.c | 77 +- src/backend/commands/prepare.c | 82 +- src/backend/commands/proclang.c | 52 +- src/backend/commands/schemacmds.c | 57 +- src/backend/commands/sequence.c | 86 +- src/backend/commands/tablecmds.c | 954 +++--- src/backend/commands/tablespace.c | 139 +- src/backend/commands/trigger.c | 386 ++- src/backend/commands/typecmds.c | 255 +- src/backend/commands/user.c | 174 +- src/backend/commands/vacuum.c | 605 ++-- src/backend/commands/vacuumlazy.c | 190 +- src/backend/commands/variable.c | 110 +- src/backend/commands/view.c | 77 +- src/backend/executor/execAmi.c | 21 +- src/backend/executor/execGrouping.c | 34 +- src/backend/executor/execJunk.c | 32 +- src/backend/executor/execMain.c | 341 +- src/backend/executor/execProcnode.c | 20 +- src/backend/executor/execQual.c | 443 ++- src/backend/executor/execScan.c | 43 +- src/backend/executor/execTuples.c | 58 +- src/backend/executor/execUtils.c | 106 +- src/backend/executor/functions.c | 204 +- src/backend/executor/instrument.c | 6 +- src/backend/executor/nodeAgg.c | 255 +- src/backend/executor/nodeAppend.c | 51 +- src/backend/executor/nodeBitmapAnd.c | 18 +- src/backend/executor/nodeBitmapHeapscan.c | 69 +- src/backend/executor/nodeBitmapIndexscan.c | 48 +- src/backend/executor/nodeBitmapOr.c | 14 +- src/backend/executor/nodeFunctionscan.c | 31 +- src/backend/executor/nodeGroup.c | 31 +- src/backend/executor/nodeHash.c | 84 +- src/backend/executor/nodeHashjoin.c | 162 +- src/backend/executor/nodeIndexscan.c | 155 +- src/backend/executor/nodeLimit.c | 36 +- src/backend/executor/nodeMaterial.c | 46 +- src/backend/executor/nodeMergejoin.c | 289 +- src/backend/executor/nodeNestloop.c | 61 +- src/backend/executor/nodeResult.c | 32 +- src/backend/executor/nodeSeqscan.c | 60 +- src/backend/executor/nodeSetOp.c | 24 +- src/backend/executor/nodeSort.c | 25 +- src/backend/executor/nodeSubplan.c | 243 +- src/backend/executor/nodeSubqueryscan.c | 26 +- src/backend/executor/nodeTidscan.c | 31 +- src/backend/executor/nodeUnique.c | 34 +- src/backend/executor/spi.c | 118 +- src/backend/lib/dllist.c | 6 +- src/backend/lib/stringinfo.c | 39 +- src/backend/libpq/auth.c | 93 +- src/backend/libpq/be-fsstubs.c | 45 +- src/backend/libpq/be-secure.c | 70 +- src/backend/libpq/crypt.c | 8 +- src/backend/libpq/hba.c | 106 +- src/backend/libpq/md5.c | 6 +- src/backend/libpq/pqcomm.c | 112 +- src/backend/libpq/pqformat.c | 11 +- src/backend/libpq/pqsignal.c | 11 +- src/backend/main/main.c | 114 +- src/backend/nodes/bitmapset.c | 8 +- src/backend/nodes/copyfuncs.c | 19 +- src/backend/nodes/equalfuncs.c | 61 +- src/backend/nodes/list.c | 24 +- src/backend/nodes/makefuncs.c | 15 +- src/backend/nodes/outfuncs.c | 27 +- src/backend/nodes/print.c | 6 +- src/backend/nodes/read.c | 21 +- src/backend/nodes/readfuncs.c | 50 +- src/backend/nodes/tidbitmap.c | 108 +- src/backend/optimizer/geqo/geqo_erx.c | 45 +- src/backend/optimizer/geqo/geqo_eval.c | 91 +- src/backend/optimizer/geqo/geqo_main.c | 9 +- src/backend/optimizer/geqo/geqo_misc.c | 10 +- src/backend/optimizer/geqo/geqo_pool.c | 20 +- .../optimizer/geqo/geqo_recombination.c | 10 +- src/backend/optimizer/geqo/geqo_selection.c | 15 +- src/backend/optimizer/path/allpaths.c | 127 +- src/backend/optimizer/path/clausesel.c | 88 +- src/backend/optimizer/path/costsize.c | 470 ++- src/backend/optimizer/path/indxpath.c | 371 +-- src/backend/optimizer/path/joinpath.c | 171 +- src/backend/optimizer/path/joinrels.c | 135 +- src/backend/optimizer/path/orindxpath.c | 34 +- src/backend/optimizer/path/pathkeys.c | 291 +- src/backend/optimizer/path/tidpath.c | 6 +- src/backend/optimizer/plan/createplan.c | 401 ++- src/backend/optimizer/plan/initsplan.c | 231 +- src/backend/optimizer/plan/planagg.c | 126 +- src/backend/optimizer/plan/planmain.c | 124 +- src/backend/optimizer/plan/planner.c | 354 +-- src/backend/optimizer/plan/setrefs.c | 158 +- src/backend/optimizer/plan/subselect.c | 264 +- src/backend/optimizer/prep/prepjointree.c | 164 +- src/backend/optimizer/prep/prepqual.c | 61 +- src/backend/optimizer/prep/preptlist.c | 105 +- src/backend/optimizer/prep/prepunion.c | 189 +- src/backend/optimizer/util/clauses.c | 367 ++- src/backend/optimizer/util/pathnode.c | 175 +- src/backend/optimizer/util/plancat.c | 132 +- src/backend/optimizer/util/predtest.c | 122 +- src/backend/optimizer/util/relnode.c | 84 +- src/backend/optimizer/util/restrictinfo.c | 67 +- src/backend/optimizer/util/tlist.c | 4 +- src/backend/optimizer/util/var.c | 38 +- src/backend/parser/analyze.c | 534 ++-- src/backend/parser/keywords.c | 6 +- src/backend/parser/parse_agg.c | 79 +- src/backend/parser/parse_clause.c | 257 +- src/backend/parser/parse_coerce.c | 246 +- src/backend/parser/parse_expr.c | 176 +- src/backend/parser/parse_func.c | 241 +- src/backend/parser/parse_node.c | 38 +- src/backend/parser/parse_oper.c | 108 +- src/backend/parser/parse_relation.c | 156 +- src/backend/parser/parse_target.c | 113 +- src/backend/parser/parse_type.c | 18 +- src/backend/parser/scansup.c | 24 +- src/backend/port/beos/sem.c | 22 +- src/backend/port/beos/shm.c | 11 +- src/backend/port/beos/support.c | 18 +- src/backend/port/dynloader/aix.c | 48 +- src/backend/port/dynloader/aix.h | 4 +- src/backend/port/dynloader/bsdi.c | 11 +- src/backend/port/dynloader/bsdi.h | 3 +- src/backend/port/dynloader/hpux.c | 4 +- src/backend/port/dynloader/linux.c | 11 +- src/backend/port/dynloader/ultrix4.c | 10 +- src/backend/port/dynloader/win32.c | 48 +- src/backend/port/ipc_test.c | 6 +- src/backend/port/posix_sema.c | 75 +- src/backend/port/qnx4/sem.c | 7 +- src/backend/port/qnx4/shm.c | 14 +- src/backend/port/sysv_sema.c | 126 +- src/backend/port/sysv_shmem.c | 96 +- src/backend/port/win32/error.c | 4 +- src/backend/port/win32/security.c | 38 +- src/backend/port/win32/sema.c | 6 +- src/backend/port/win32/shmem.c | 4 +- src/backend/port/win32/signal.c | 32 +- src/backend/port/win32/socket.c | 14 +- src/backend/postmaster/autovacuum.c | 270 +- src/backend/postmaster/bgwriter.c | 109 +- src/backend/postmaster/fork_process.c | 35 +- src/backend/postmaster/pgarch.c | 53 +- src/backend/postmaster/pgstat.c | 471 ++- src/backend/postmaster/postmaster.c | 685 ++-- src/backend/postmaster/syslogger.c | 120 +- src/backend/regex/regc_color.c | 6 +- src/backend/regex/regc_cvec.c | 5 +- src/backend/regex/regc_lex.c | 11 +- src/backend/regex/regc_locale.c | 12 +- src/backend/regex/regc_nfa.c | 19 +- src/backend/regex/regcomp.c | 37 +- src/backend/regex/rege_dfa.c | 8 +- src/backend/regex/regexec.c | 17 +- src/backend/rewrite/rewriteDefine.c | 124 +- src/backend/rewrite/rewriteHandler.c | 321 +- src/backend/rewrite/rewriteManip.c | 104 +- src/backend/rewrite/rewriteRemove.c | 10 +- src/backend/rewrite/rewriteSupport.c | 5 +- src/backend/storage/buffer/buf_init.c | 6 +- src/backend/storage/buffer/buf_table.c | 8 +- src/backend/storage/buffer/bufmgr.c | 284 +- src/backend/storage/buffer/freelist.c | 38 +- src/backend/storage/buffer/localbuf.c | 24 +- src/backend/storage/file/buffile.c | 37 +- src/backend/storage/file/fd.c | 93 +- src/backend/storage/freespace/freespace.c | 179 +- src/backend/storage/ipc/ipc.c | 23 +- src/backend/storage/ipc/ipci.c | 19 +- src/backend/storage/ipc/pmsignal.c | 8 +- src/backend/storage/ipc/procarray.c | 129 +- src/backend/storage/ipc/shmem.c | 51 +- src/backend/storage/ipc/sinval.c | 99 +- src/backend/storage/ipc/sinvaladt.c | 22 +- src/backend/storage/large_object/inv_api.c | 37 +- src/backend/storage/lmgr/deadlock.c | 99 +- src/backend/storage/lmgr/lmgr.c | 34 +- src/backend/storage/lmgr/lock.c | 270 +- src/backend/storage/lmgr/lwlock.c | 93 +- src/backend/storage/lmgr/proc.c | 225 +- src/backend/storage/lmgr/s_lock.c | 120 +- src/backend/storage/lmgr/spin.c | 11 +- src/backend/storage/page/bufpage.c | 64 +- src/backend/storage/smgr/md.c | 171 +- src/backend/storage/smgr/smgr.c | 128 +- src/backend/tcop/dest.c | 7 +- src/backend/tcop/fastpath.c | 43 +- src/backend/tcop/postgres.c | 644 ++-- src/backend/tcop/pquery.c | 220 +- src/backend/tcop/utility.c | 92 +- src/backend/utils/adt/acl.c | 266 +- src/backend/utils/adt/array_userfuncs.c | 43 +- src/backend/utils/adt/arrayfuncs.c | 342 +- src/backend/utils/adt/ascii.c | 6 +- src/backend/utils/adt/cash.c | 24 +- src/backend/utils/adt/char.c | 8 +- src/backend/utils/adt/date.c | 195 +- src/backend/utils/adt/datetime.c | 337 +- src/backend/utils/adt/datum.c | 11 +- src/backend/utils/adt/dbsize.c | 142 +- src/backend/utils/adt/encode.c | 8 +- src/backend/utils/adt/float.c | 122 +- src/backend/utils/adt/format_type.c | 42 +- src/backend/utils/adt/formatting.c | 339 +- src/backend/utils/adt/genfile.c | 57 +- src/backend/utils/adt/geo_ops.c | 135 +- src/backend/utils/adt/inet_net_ntop.c | 20 +- src/backend/utils/adt/inet_net_pton.c | 5 +- src/backend/utils/adt/int.c | 148 +- src/backend/utils/adt/int8.c | 140 +- src/backend/utils/adt/like.c | 46 +- src/backend/utils/adt/like_match.c | 42 +- src/backend/utils/adt/lockfuncs.c | 29 +- src/backend/utils/adt/mac.c | 6 +- src/backend/utils/adt/misc.c | 21 +- src/backend/utils/adt/nabstime.c | 147 +- src/backend/utils/adt/name.c | 6 +- src/backend/utils/adt/network.c | 28 +- src/backend/utils/adt/numeric.c | 328 +- src/backend/utils/adt/numutils.c | 16 +- src/backend/utils/adt/oid.c | 28 +- src/backend/utils/adt/oracle_compat.c | 74 +- src/backend/utils/adt/pg_locale.c | 27 +- src/backend/utils/adt/pg_lzcompress.c | 102 +- src/backend/utils/adt/pgstatfuncs.c | 12 +- src/backend/utils/adt/quote.c | 6 +- src/backend/utils/adt/regexp.c | 63 +- src/backend/utils/adt/regproc.c | 133 +- src/backend/utils/adt/ri_triggers.c | 504 ++- src/backend/utils/adt/rowtypes.c | 61 +- src/backend/utils/adt/ruleutils.c | 367 ++- src/backend/utils/adt/selfuncs.c | 748 +++-- src/backend/utils/adt/timestamp.c | 509 +-- src/backend/utils/adt/varbit.c | 50 +- src/backend/utils/adt/varchar.c | 44 +- src/backend/utils/adt/varlena.c | 214 +- src/backend/utils/cache/catcache.c | 195 +- src/backend/utils/cache/inval.c | 93 +- src/backend/utils/cache/lsyscache.c | 40 +- src/backend/utils/cache/relcache.c | 408 ++- src/backend/utils/cache/syscache.c | 77 +- src/backend/utils/cache/typcache.c | 41 +- src/backend/utils/error/assert.c | 6 +- src/backend/utils/error/elog.c | 198 +- src/backend/utils/fmgr/dfmgr.c | 16 +- src/backend/utils/fmgr/fmgr.c | 99 +- src/backend/utils/fmgr/funcapi.c | 83 +- src/backend/utils/hash/dynahash.c | 78 +- src/backend/utils/hash/hashfn.c | 8 +- src/backend/utils/hash/pg_crc.c | 6 +- src/backend/utils/init/flatfiles.c | 193 +- src/backend/utils/init/miscinit.c | 153 +- src/backend/utils/init/postinit.c | 115 +- src/backend/utils/mb/conv.c | 13 +- .../euc_jp_and_sjis/euc_jp_and_sjis.c | 14 +- .../conversion_procs/euc_tw_and_big5/big5.c | 35 +- .../utf8_and_cyrillic/utf8_and_cyrillic.c | 6 +- .../utf8_and_euc_cn/utf8_and_euc_cn.c | 4 +- .../utf8_and_euc_jp/utf8_and_euc_jp.c | 4 +- .../utf8_and_euc_kr/utf8_and_euc_kr.c | 4 +- .../utf8_and_euc_tw/utf8_and_euc_tw.c | 4 +- .../utf8_and_gb18030/utf8_and_gb18030.c | 4 +- .../utf8_and_iso8859/utf8_and_iso8859.c | 4 +- .../utf8_and_johab/utf8_and_johab.c | 4 +- .../utf8_and_win1250/utf8_and_win1250.c | 4 +- .../utf8_and_win1252/utf8_and_win1252.c | 4 +- .../utf8_and_win1256/utf8_and_win1256.c | 4 +- .../utf8_and_win1258/utf8_and_win1258.c | 4 +- .../utf8_and_win874/utf8_and_win874.c | 4 +- src/backend/utils/mb/encnames.c | 22 +- src/backend/utils/mb/mbutils.c | 30 +- src/backend/utils/mb/wchar.c | 121 +- src/backend/utils/misc/guc.c | 436 ++- src/backend/utils/misc/pg_rusage.c | 6 +- src/backend/utils/misc/ps_status.c | 48 +- src/backend/utils/misc/superuser.c | 8 +- src/backend/utils/mmgr/aset.c | 128 +- src/backend/utils/mmgr/mcxt.c | 39 +- src/backend/utils/mmgr/portalmem.c | 107 +- src/backend/utils/resowner/resowner.c | 68 +- src/backend/utils/sort/logtape.c | 104 +- src/backend/utils/sort/tuplesort.c | 326 +- src/backend/utils/sort/tuplestore.c | 90 +- src/backend/utils/time/tqual.c | 64 +- src/bin/initdb/initdb.c | 246 +- src/bin/pg_config/pg_config.c | 81 +- src/bin/pg_controldata/pg_controldata.c | 14 +- src/bin/pg_ctl/pg_ctl.c | 70 +- src/bin/pg_dump/common.c | 25 +- src/bin/pg_dump/dumputils.c | 63 +- src/bin/pg_dump/pg_backup.h | 19 +- src/bin/pg_dump/pg_backup_archiver.c | 182 +- src/bin/pg_dump/pg_backup_archiver.h | 38 +- src/bin/pg_dump/pg_backup_custom.c | 37 +- src/bin/pg_dump/pg_backup_db.c | 81 +- src/bin/pg_dump/pg_backup_files.c | 4 +- src/bin/pg_dump/pg_backup_null.c | 5 +- src/bin/pg_dump/pg_backup_tar.c | 76 +- src/bin/pg_dump/pg_dump.c | 678 ++-- src/bin/pg_dump/pg_dump.h | 13 +- src/bin/pg_dump/pg_dump_sort.c | 113 +- src/bin/pg_dump/pg_dumpall.c | 76 +- src/bin/pg_dump/pg_restore.c | 12 +- src/bin/pg_resetxlog/pg_resetxlog.c | 59 +- src/bin/pgevent/pgevent.c | 10 +- src/bin/psql/command.c | 85 +- src/bin/psql/common.c | 134 +- src/bin/psql/common.h | 4 +- src/bin/psql/copy.c | 19 +- src/bin/psql/describe.c | 229 +- src/bin/psql/help.c | 140 +- src/bin/psql/input.c | 8 +- src/bin/psql/large_obj.c | 8 +- src/bin/psql/mainloop.c | 40 +- src/bin/psql/mbprint.c | 22 +- src/bin/psql/print.c | 224 +- src/bin/psql/print.h | 29 +- src/bin/psql/prompt.c | 9 +- src/bin/psql/settings.h | 11 +- src/bin/psql/startup.c | 49 +- src/bin/psql/stringutils.c | 35 +- src/bin/psql/tab-complete.c | 2773 ++++++++++++++--- src/bin/psql/variables.c | 6 +- src/bin/scripts/common.c | 8 +- src/bin/scripts/common.h | 18 +- src/bin/scripts/createlang.c | 12 +- src/bin/scripts/createuser.c | 6 +- src/bin/scripts/droplang.c | 34 +- src/bin/scripts/reindexdb.c | 96 +- src/include/access/genam.h | 10 +- src/include/access/gist.h | 23 +- src/include/access/gist_private.h | 213 +- src/include/access/hash.h | 24 +- src/include/access/heapam.h | 43 +- src/include/access/hio.h | 4 +- src/include/access/htup.h | 24 +- src/include/access/itup.h | 6 +- src/include/access/multixact.h | 20 +- src/include/access/nbtree.h | 9 +- src/include/access/relscan.h | 8 +- src/include/access/slru.h | 28 +- src/include/access/transam.h | 12 +- src/include/access/tupmacs.h | 4 +- src/include/access/twophase.h | 8 +- src/include/access/twophase_rmgr.h | 10 +- src/include/access/xact.h | 4 +- src/include/access/xlog.h | 13 +- src/include/c.h | 14 +- src/include/catalog/catalog.h | 6 +- src/include/catalog/dependency.h | 23 +- src/include/catalog/heap.h | 5 +- src/include/catalog/index.h | 14 +- src/include/catalog/indexing.h | 142 +- src/include/catalog/namespace.h | 4 +- src/include/catalog/pg_aggregate.h | 8 +- src/include/catalog/pg_am.h | 18 +- src/include/catalog/pg_amop.h | 124 +- src/include/catalog/pg_attribute.h | 56 +- src/include/catalog/pg_authid.h | 8 +- src/include/catalog/pg_autovacuum.h | 16 +- src/include/catalog/pg_cast.h | 18 +- src/include/catalog/pg_class.h | 8 +- src/include/catalog/pg_constraint.h | 25 +- src/include/catalog/pg_control.h | 45 +- src/include/catalog/pg_database.h | 4 +- src/include/catalog/pg_index.h | 12 +- src/include/catalog/pg_inherits.h | 4 +- src/include/catalog/pg_language.h | 4 +- src/include/catalog/pg_listener.h | 4 +- src/include/catalog/pg_namespace.h | 4 +- src/include/catalog/pg_operator.h | 28 +- src/include/catalog/pg_proc.h | 1102 +++---- src/include/catalog/pg_shdepend.h | 12 +- src/include/catalog/pg_statistic.h | 28 +- src/include/catalog/pg_type.h | 66 +- src/include/commands/async.h | 4 +- src/include/commands/cluster.h | 4 +- src/include/commands/dbcommands.h | 10 +- src/include/commands/defrem.h | 8 +- src/include/commands/tablecmds.h | 10 +- src/include/commands/tablespace.h | 6 +- src/include/commands/trigger.h | 14 +- src/include/commands/typecmds.h | 4 +- src/include/commands/vacuum.h | 14 +- src/include/commands/variable.h | 4 +- src/include/executor/execdebug.h | 3 +- src/include/executor/executor.h | 30 +- src/include/executor/functions.h | 6 +- src/include/executor/hashjoin.h | 25 +- src/include/executor/instrument.h | 10 +- src/include/executor/nodeHash.h | 18 +- src/include/executor/nodeHashjoin.h | 4 +- src/include/executor/nodeIndexscan.h | 8 +- src/include/executor/spi.h | 20 +- src/include/executor/spi_priv.h | 4 +- src/include/executor/tuptable.h | 17 +- src/include/fmgr.h | 19 +- src/include/funcapi.h | 90 +- src/include/getaddrinfo.h | 10 +- src/include/lib/dllist.h | 6 +- src/include/libpq/auth.h | 4 +- src/include/libpq/be-fsstubs.h | 4 +- src/include/libpq/hba.h | 10 +- src/include/libpq/libpq-be.h | 47 +- src/include/libpq/libpq.h | 4 +- src/include/libpq/pqcomm.h | 6 +- src/include/mb/pg_wchar.h | 34 +- src/include/miscadmin.h | 13 +- src/include/nodes/execnodes.h | 61 +- src/include/nodes/makefuncs.h | 8 +- src/include/nodes/nodes.h | 31 +- src/include/nodes/parsenodes.h | 111 +- src/include/nodes/pg_list.h | 3 +- src/include/nodes/plannodes.h | 63 +- src/include/nodes/primnodes.h | 89 +- src/include/nodes/relation.h | 108 +- src/include/nodes/tidbitmap.h | 6 +- src/include/optimizer/clauses.h | 16 +- src/include/optimizer/cost.h | 4 +- src/include/optimizer/geqo.h | 7 +- src/include/optimizer/pathnode.h | 16 +- src/include/optimizer/paths.h | 12 +- src/include/optimizer/planmain.h | 14 +- src/include/optimizer/planner.h | 4 +- src/include/optimizer/predtest.h | 6 +- src/include/optimizer/prep.h | 4 +- src/include/optimizer/restrictinfo.h | 10 +- src/include/optimizer/subselect.h | 4 +- src/include/parser/parse_node.h | 9 +- src/include/parser/parse_target.h | 4 +- src/include/parser/parsetree.h | 4 +- src/include/pgstat.h | 47 +- src/include/pgtime.h | 18 +- src/include/port.h | 32 +- src/include/port/darwin.h | 1 - src/include/port/hpux.h | 2 - src/include/port/ultrix4.h | 3 +- src/include/port/win32.h | 11 +- src/include/port/win32/sys/socket.h | 2 +- src/include/postmaster/autovacuum.h | 22 +- src/include/postmaster/fork_process.h | 4 +- src/include/postmaster/syslogger.h | 3 +- src/include/regex/regcustom.h | 11 +- src/include/regex/regex.h | 8 +- src/include/regex/regguts.h | 14 +- src/include/storage/backendid.h | 5 +- src/include/storage/buf_internals.h | 25 +- src/include/storage/bufmgr.h | 4 +- src/include/storage/fd.h | 4 +- src/include/storage/itemptr.h | 5 +- src/include/storage/lmgr.h | 21 +- src/include/storage/lock.h | 45 +- src/include/storage/lwlock.h | 5 +- src/include/storage/pg_shmem.h | 4 +- src/include/storage/proc.h | 16 +- src/include/storage/procarray.h | 4 +- src/include/storage/sinval.h | 8 +- src/include/storage/sinvaladt.h | 9 +- src/include/storage/smgr.h | 4 +- src/include/tcop/dest.h | 4 +- src/include/tcop/pquery.h | 4 +- src/include/tcop/tcopprot.h | 4 +- src/include/utils/acl.h | 10 +- src/include/utils/array.h | 4 +- src/include/utils/builtins.h | 4 +- src/include/utils/catcache.h | 65 +- src/include/utils/date.h | 13 +- src/include/utils/datetime.h | 30 +- src/include/utils/elog.h | 32 +- src/include/utils/flatfiles.h | 8 +- src/include/utils/fmgrtab.h | 5 +- src/include/utils/guc.h | 10 +- src/include/utils/hsearch.h | 15 +- src/include/utils/inval.h | 4 +- src/include/utils/lsyscache.h | 6 +- src/include/utils/nabstime.h | 4 +- src/include/utils/palloc.h | 5 +- src/include/utils/pg_crc.h | 10 +- src/include/utils/portal.h | 45 +- src/include/utils/rel.h | 25 +- src/include/utils/relcache.h | 6 +- src/include/utils/selfuncs.h | 4 +- src/include/utils/syscache.h | 4 +- src/include/utils/timestamp.h | 35 +- src/include/utils/tqual.h | 6 +- src/include/utils/typcache.h | 12 +- src/interfaces/ecpg/compatlib/informix.c | 59 +- src/interfaces/ecpg/ecpglib/connect.c | 37 +- src/interfaces/ecpg/ecpglib/data.c | 26 +- src/interfaces/ecpg/ecpglib/error.c | 16 +- src/interfaces/ecpg/ecpglib/execute.c | 53 +- src/interfaces/ecpg/ecpglib/extern.h | 3 +- src/interfaces/ecpg/ecpglib/memory.c | 4 +- src/interfaces/ecpg/ecpglib/misc.c | 19 +- src/interfaces/ecpg/ecpglib/prepare.c | 12 +- src/interfaces/ecpg/include/ecpgtype.h | 8 +- .../ecpg/include/pgtypes_interval.h | 11 +- src/interfaces/ecpg/include/pgtypes_numeric.h | 18 +- .../ecpg/include/pgtypes_timestamp.h | 5 +- src/interfaces/ecpg/pgtypeslib/common.c | 3 +- src/interfaces/ecpg/pgtypeslib/datetime.c | 74 +- src/interfaces/ecpg/pgtypeslib/dt.h | 29 +- src/interfaces/ecpg/pgtypeslib/dt_common.c | 326 +- src/interfaces/ecpg/pgtypeslib/extern.h | 8 +- src/interfaces/ecpg/pgtypeslib/interval.c | 58 +- src/interfaces/ecpg/pgtypeslib/numeric.c | 90 +- src/interfaces/ecpg/pgtypeslib/timestamp.c | 175 +- src/interfaces/ecpg/preproc/ecpg.c | 8 +- src/interfaces/ecpg/preproc/ecpg_keywords.c | 18 +- src/interfaces/ecpg/preproc/keywords.c | 729 +++-- src/interfaces/ecpg/preproc/type.c | 18 +- src/interfaces/ecpg/preproc/type.h | 13 +- src/interfaces/ecpg/preproc/variable.c | 20 +- src/interfaces/libpq/fe-auth.c | 36 +- src/interfaces/libpq/fe-auth.h | 4 +- src/interfaces/libpq/fe-connect.c | 381 ++- src/interfaces/libpq/fe-exec.c | 200 +- src/interfaces/libpq/fe-lobj.c | 49 +- src/interfaces/libpq/fe-misc.c | 146 +- src/interfaces/libpq/fe-print.c | 37 +- src/interfaces/libpq/fe-protocol2.c | 189 +- src/interfaces/libpq/fe-protocol3.c | 198 +- src/interfaces/libpq/fe-secure.c | 160 +- src/interfaces/libpq/libpq-fe.h | 46 +- src/interfaces/libpq/libpq-int.h | 99 +- src/interfaces/libpq/pqexpbuffer.c | 33 +- src/interfaces/libpq/pthread-win32.h | 14 +- src/interfaces/libpq/win32.c | 4 +- src/pl/plperl/plperl.c | 245 +- src/pl/plperl/ppport.h | 14 +- src/pl/plperl/spi_internal.h | 6 +- src/pl/plpgsql/src/pl_comp.c | 268 +- src/pl/plpgsql/src/pl_exec.c | 887 +++--- src/pl/plpgsql/src/pl_funcs.c | 134 +- src/pl/plpgsql/src/pl_handler.c | 8 +- src/pl/plpgsql/src/plpgsql.h | 131 +- src/pl/plpython/plpython.c | 100 +- src/pl/tcl/pltcl.c | 137 +- src/port/copydir.c | 8 +- src/port/crypt.c | 25 +- src/port/dirmod.c | 50 +- src/port/exec.c | 65 +- src/port/getaddrinfo.c | 32 +- src/port/getopt.c | 3 +- src/port/getopt_long.c | 4 +- src/port/getrusage.c | 26 +- src/port/inet_aton.c | 10 +- src/port/isinf.c | 8 +- src/port/memcmp.c | 14 +- src/port/noblock.c | 5 +- src/port/open.c | 24 +- src/port/path.c | 75 +- src/port/qsort.c | 14 +- src/port/snprintf.c | 39 +- src/port/sprompt.c | 7 +- src/port/strtol.c | 23 +- src/port/thread.c | 7 +- src/port/unsetenv.c | 25 +- src/test/examples/testlibpq.c | 17 +- src/test/examples/testlibpq2.c | 18 +- src/test/examples/testlibpq3.c | 31 +- src/test/examples/testlibpq4.c | 11 +- src/test/regress/regress.c | 24 +- src/timezone/ialloc.c | 8 +- src/timezone/localtime.c | 172 +- src/timezone/pgtz.c | 227 +- src/timezone/pgtz.h | 13 +- src/timezone/scheck.c | 10 +- src/timezone/strftime.c | 51 +- src/timezone/tzfile.h | 17 +- src/timezone/zic.c | 221 +- src/tools/entab/entab.c | 6 +- src/tools/entab/halt.c | 4 +- src/tools/findoidjoins/findoidjoins.c | 8 +- src/tools/fsync/test_fsync.c | 3 +- src/tools/thread/thread_test.c | 95 +- src/tutorial/beard.c | 4 +- src/tutorial/funcs_new.c | 3 +- 770 files changed, 34334 insertions(+), 32507 deletions(-) diff --git a/contrib/btree_gist/btree_cash.c b/contrib/btree_gist/btree_cash.c index cef6103734..13f8200fb7 100644 --- a/contrib/btree_gist/btree_cash.c +++ b/contrib/btree_gist/btree_cash.c @@ -125,10 +125,10 @@ Datum gbt_cash_penalty(PG_FUNCTION_ARGS) { cashKEY *origentry = (cashKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(0))->key); - cashKEY *newentry = (cashKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key); - float *result = (float *) PG_GETARG_POINTER(2); + cashKEY *newentry = (cashKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key); + float *result = (float *) PG_GETARG_POINTER(2); - penalty_num(result,origentry->lower,origentry->upper,newentry->lower,newentry->upper); + penalty_num(result, origentry->lower, origentry->upper, newentry->lower, newentry->upper); PG_RETURN_POINTER(result); @@ -138,8 +138,8 @@ Datum gbt_cash_picksplit(PG_FUNCTION_ARGS) { PG_RETURN_POINTER(gbt_num_picksplit( - (GistEntryVector *) PG_GETARG_POINTER(0), - (GIST_SPLITVEC *) PG_GETARG_POINTER(1), + (GistEntryVector *) PG_GETARG_POINTER(0), + (GIST_SPLITVEC *) PG_GETARG_POINTER(1), &tinfo )); } diff --git a/contrib/btree_gist/btree_date.c b/contrib/btree_gist/btree_date.c index d3ce33c717..b14888889d 100644 --- a/contrib/btree_gist/btree_date.c +++ b/contrib/btree_gist/btree_date.c @@ -148,15 +148,15 @@ gbt_date_penalty(PG_FUNCTION_ARGS) diff = DatumGetInt32(DirectFunctionCall2( date_mi, - DateADTGetDatum(newentry->upper), - DateADTGetDatum(origentry->upper))); + DateADTGetDatum(newentry->upper), + DateADTGetDatum(origentry->upper))); res = Max(diff, 0); diff = DatumGetInt32(DirectFunctionCall2( date_mi, - DateADTGetDatum(origentry->lower), - DateADTGetDatum(newentry->lower))); + DateADTGetDatum(origentry->lower), + DateADTGetDatum(newentry->lower))); res += Max(diff, 0); @@ -166,8 +166,8 @@ gbt_date_penalty(PG_FUNCTION_ARGS) { diff = DatumGetInt32(DirectFunctionCall2( date_mi, - DateADTGetDatum(origentry->upper), - DateADTGetDatum(origentry->lower))); + DateADTGetDatum(origentry->upper), + DateADTGetDatum(origentry->lower))); *result += FLT_MIN; *result += (float) (res / ((double) (res + diff))); *result *= (FLT_MAX / (((GISTENTRY *) PG_GETARG_POINTER(0))->rel->rd_att->natts + 1)); @@ -181,8 +181,8 @@ Datum gbt_date_picksplit(PG_FUNCTION_ARGS) { PG_RETURN_POINTER(gbt_num_picksplit( - (GistEntryVector *) PG_GETARG_POINTER(0), - (GIST_SPLITVEC *) PG_GETARG_POINTER(1), + (GistEntryVector *) PG_GETARG_POINTER(0), + (GIST_SPLITVEC *) PG_GETARG_POINTER(1), &tinfo )); } diff --git a/contrib/btree_gist/btree_float4.c b/contrib/btree_gist/btree_float4.c index 9d6c174773..a4c941f835 100644 --- a/contrib/btree_gist/btree_float4.c +++ b/contrib/btree_gist/btree_float4.c @@ -127,7 +127,7 @@ gbt_float4_penalty(PG_FUNCTION_ARGS) float4KEY *newentry = (float4KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key); float *result = (float *) PG_GETARG_POINTER(2); - penalty_num(result,origentry->lower,origentry->upper,newentry->lower,newentry->upper); + penalty_num(result, origentry->lower, origentry->upper, newentry->lower, newentry->upper); PG_RETURN_POINTER(result); @@ -137,8 +137,8 @@ Datum gbt_float4_picksplit(PG_FUNCTION_ARGS) { PG_RETURN_POINTER(gbt_num_picksplit( - (GistEntryVector *) PG_GETARG_POINTER(0), - (GIST_SPLITVEC *) PG_GETARG_POINTER(1), + (GistEntryVector *) PG_GETARG_POINTER(0), + (GIST_SPLITVEC *) PG_GETARG_POINTER(1), &tinfo )); } diff --git a/contrib/btree_gist/btree_float8.c b/contrib/btree_gist/btree_float8.c index 7345d37b21..1b87b4ee1b 100644 --- a/contrib/btree_gist/btree_float8.c +++ b/contrib/btree_gist/btree_float8.c @@ -129,7 +129,7 @@ gbt_float8_penalty(PG_FUNCTION_ARGS) float8KEY *newentry = (float8KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key); float *result = (float *) PG_GETARG_POINTER(2); - penalty_num(result,origentry->lower,origentry->upper,newentry->lower,newentry->upper); + penalty_num(result, origentry->lower, origentry->upper, newentry->lower, newentry->upper); PG_RETURN_POINTER(result); @@ -139,8 +139,8 @@ Datum gbt_float8_picksplit(PG_FUNCTION_ARGS) { PG_RETURN_POINTER(gbt_num_picksplit( - (GistEntryVector *) PG_GETARG_POINTER(0), - (GIST_SPLITVEC *) PG_GETARG_POINTER(1), + (GistEntryVector *) PG_GETARG_POINTER(0), + (GIST_SPLITVEC *) PG_GETARG_POINTER(1), &tinfo )); } diff --git a/contrib/btree_gist/btree_inet.c b/contrib/btree_gist/btree_inet.c index 3719d3bb1a..5f27a007f5 100644 --- a/contrib/btree_gist/btree_inet.c +++ b/contrib/btree_gist/btree_inet.c @@ -194,8 +194,8 @@ gbt_inet_penalty(PG_FUNCTION_ARGS) inetKEY *newentry = (inetKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key); float *result = (float *) PG_GETARG_POINTER(2); - penalty_num(result,origentry->lower,origentry->upper,newentry->lower,newentry->upper); - + penalty_num(result, origentry->lower, origentry->upper, newentry->lower, newentry->upper); + PG_RETURN_POINTER(result); } @@ -204,8 +204,8 @@ Datum gbt_inet_picksplit(PG_FUNCTION_ARGS) { PG_RETURN_POINTER(gbt_num_picksplit( - (GistEntryVector *) PG_GETARG_POINTER(0), - (GIST_SPLITVEC *) PG_GETARG_POINTER(1), + (GistEntryVector *) PG_GETARG_POINTER(0), + (GIST_SPLITVEC *) PG_GETARG_POINTER(1), &tinfo )); } diff --git a/contrib/btree_gist/btree_int2.c b/contrib/btree_gist/btree_int2.c index 8bbdb1d802..5e2a66526e 100644 --- a/contrib/btree_gist/btree_int2.c +++ b/contrib/btree_gist/btree_int2.c @@ -128,10 +128,10 @@ Datum gbt_int2_penalty(PG_FUNCTION_ARGS) { int16KEY *origentry = (int16KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(0))->key); - int16KEY *newentry = (int16KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key); - float *result = (float *) PG_GETARG_POINTER(2); + int16KEY *newentry = (int16KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key); + float *result = (float *) PG_GETARG_POINTER(2); - penalty_num(result,origentry->lower,origentry->upper,newentry->lower,newentry->upper); + penalty_num(result, origentry->lower, origentry->upper, newentry->lower, newentry->upper); PG_RETURN_POINTER(result); } @@ -140,8 +140,8 @@ Datum gbt_int2_picksplit(PG_FUNCTION_ARGS) { PG_RETURN_POINTER(gbt_num_picksplit( - (GistEntryVector *) PG_GETARG_POINTER(0), - (GIST_SPLITVEC *) PG_GETARG_POINTER(1), + (GistEntryVector *) PG_GETARG_POINTER(0), + (GIST_SPLITVEC *) PG_GETARG_POINTER(1), &tinfo )); } diff --git a/contrib/btree_gist/btree_int4.c b/contrib/btree_gist/btree_int4.c index 43a4cbe6be..6a69b85bdd 100644 --- a/contrib/btree_gist/btree_int4.c +++ b/contrib/btree_gist/btree_int4.c @@ -126,10 +126,10 @@ Datum gbt_int4_penalty(PG_FUNCTION_ARGS) { int32KEY *origentry = (int32KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(0))->key); - int32KEY *newentry = (int32KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key); - float *result = (float *) PG_GETARG_POINTER(2); - - penalty_num(result,origentry->lower,origentry->upper,newentry->lower,newentry->upper); + int32KEY *newentry = (int32KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key); + float *result = (float *) PG_GETARG_POINTER(2); + + penalty_num(result, origentry->lower, origentry->upper, newentry->lower, newentry->upper); PG_RETURN_POINTER(result); } @@ -138,8 +138,8 @@ Datum gbt_int4_picksplit(PG_FUNCTION_ARGS) { PG_RETURN_POINTER(gbt_num_picksplit( - (GistEntryVector *) PG_GETARG_POINTER(0), - (GIST_SPLITVEC *) PG_GETARG_POINTER(1), + (GistEntryVector *) PG_GETARG_POINTER(0), + (GIST_SPLITVEC *) PG_GETARG_POINTER(1), &tinfo )); } diff --git a/contrib/btree_gist/btree_int8.c b/contrib/btree_gist/btree_int8.c index 7de02dbca7..83275f2c7a 100644 --- a/contrib/btree_gist/btree_int8.c +++ b/contrib/btree_gist/btree_int8.c @@ -125,11 +125,11 @@ Datum gbt_int8_penalty(PG_FUNCTION_ARGS) { int64KEY *origentry = (int64KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(0))->key); - int64KEY *newentry = (int64KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key); - float *result = (float *) PG_GETARG_POINTER(2); + int64KEY *newentry = (int64KEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key); + float *result = (float *) PG_GETARG_POINTER(2); + + penalty_num(result, origentry->lower, origentry->upper, newentry->lower, newentry->upper); - penalty_num(result,origentry->lower,origentry->upper,newentry->lower,newentry->upper); - PG_RETURN_POINTER(result); } @@ -137,8 +137,8 @@ Datum gbt_int8_picksplit(PG_FUNCTION_ARGS) { PG_RETURN_POINTER(gbt_num_picksplit( - (GistEntryVector *) PG_GETARG_POINTER(0), - (GIST_SPLITVEC *) PG_GETARG_POINTER(1), + (GistEntryVector *) PG_GETARG_POINTER(0), + (GIST_SPLITVEC *) PG_GETARG_POINTER(1), &tinfo )); } diff --git a/contrib/btree_gist/btree_interval.c b/contrib/btree_gist/btree_interval.c index 3c671a3f04..b7776295a0 100644 --- a/contrib/btree_gist/btree_interval.c +++ b/contrib/btree_gist/btree_interval.c @@ -63,8 +63,8 @@ gbt_intvkey_cmp(const void *a, const void *b) { return DatumGetInt32( DirectFunctionCall2(interval_cmp, - IntervalPGetDatum(((Nsrt *) a)->t), - IntervalPGetDatum(((Nsrt *) b)->t) + IntervalPGetDatum(((Nsrt *) a)->t), + IntervalPGetDatum(((Nsrt *) b)->t) ) ); } @@ -78,7 +78,7 @@ intr2num(const Interval *i) /* * INTERVALSIZE should be the actual size-on-disk of an Interval, as shown - * in pg_type. This might be less than sizeof(Interval) if the compiler + * in pg_type. This might be less than sizeof(Interval) if the compiler * insists on adding alignment padding at the end of the struct. */ #define INTERVALSIZE 16 @@ -202,7 +202,7 @@ gbt_intv_penalty(PG_FUNCTION_ARGS) inew[0] = intr2num(&newentry->lower); inew[1] = intr2num(&newentry->upper); - penalty_num(result,iorg[0],iorg[1],inew[0],inew[1]); + penalty_num(result, iorg[0], iorg[1], inew[0], inew[1]); PG_RETURN_POINTER(result); @@ -212,8 +212,8 @@ Datum gbt_intv_picksplit(PG_FUNCTION_ARGS) { PG_RETURN_POINTER(gbt_num_picksplit( - (GistEntryVector *) PG_GETARG_POINTER(0), - (GIST_SPLITVEC *) PG_GETARG_POINTER(1), + (GistEntryVector *) PG_GETARG_POINTER(0), + (GIST_SPLITVEC *) PG_GETARG_POINTER(1), &tinfo )); } diff --git a/contrib/btree_gist/btree_macaddr.c b/contrib/btree_gist/btree_macaddr.c index ee56f0fac1..52cf4cb1d4 100644 --- a/contrib/btree_gist/btree_macaddr.c +++ b/contrib/btree_gist/btree_macaddr.c @@ -63,8 +63,8 @@ gbt_macadkey_cmp(const void *a, const void *b) return DatumGetInt32( DirectFunctionCall2( macaddr_cmp, - PointerGetDatum(&((Nsrt *) a)->t[0]), - PointerGetDatum(&((Nsrt *) b)->t[0]) + PointerGetDatum(&((Nsrt *) a)->t[0]), + PointerGetDatum(&((Nsrt *) b)->t[0]) ) ); } @@ -157,7 +157,7 @@ gbt_macad_penalty(PG_FUNCTION_ARGS) inew[0] = mac_2_uint64(&newentry->lower); inew[1] = mac_2_uint64(&newentry->upper); - penalty_num(result,iorg[0],iorg[1],inew[0],inew[1]); + penalty_num(result, iorg[0], iorg[1], inew[0], inew[1]); PG_RETURN_POINTER(result); @@ -167,8 +167,8 @@ Datum gbt_macad_picksplit(PG_FUNCTION_ARGS) { PG_RETURN_POINTER(gbt_num_picksplit( - (GistEntryVector *) PG_GETARG_POINTER(0), - (GIST_SPLITVEC *) PG_GETARG_POINTER(1), + (GistEntryVector *) PG_GETARG_POINTER(0), + (GIST_SPLITVEC *) PG_GETARG_POINTER(1), &tinfo )); } diff --git a/contrib/btree_gist/btree_oid.c b/contrib/btree_gist/btree_oid.c index d76d876372..979d728a73 100644 --- a/contrib/btree_gist/btree_oid.c +++ b/contrib/btree_gist/btree_oid.c @@ -129,7 +129,7 @@ gbt_oid_penalty(PG_FUNCTION_ARGS) oidKEY *newentry = (oidKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key); float *result = (float *) PG_GETARG_POINTER(2); - penalty_num(result,origentry->lower,origentry->upper,newentry->lower,newentry->upper); + penalty_num(result, origentry->lower, origentry->upper, newentry->lower, newentry->upper); PG_RETURN_POINTER(result); } @@ -138,8 +138,8 @@ Datum gbt_oid_picksplit(PG_FUNCTION_ARGS) { PG_RETURN_POINTER(gbt_num_picksplit( - (GistEntryVector *) PG_GETARG_POINTER(0), - (GIST_SPLITVEC *) PG_GETARG_POINTER(1), + (GistEntryVector *) PG_GETARG_POINTER(0), + (GIST_SPLITVEC *) PG_GETARG_POINTER(1), &tinfo )); } diff --git a/contrib/btree_gist/btree_text.c b/contrib/btree_gist/btree_text.c index 1275df6aef..6ab77f86ae 100644 --- a/contrib/btree_gist/btree_text.c +++ b/contrib/btree_gist/btree_text.c @@ -87,7 +87,7 @@ gbt_text_compress(PG_FUNCTION_ARGS) { GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); - if ( tinfo.eml == 0 ) + if (tinfo.eml == 0) { tinfo.eml = pg_database_encoding_max_length(); } @@ -102,7 +102,7 @@ gbt_bpchar_compress(PG_FUNCTION_ARGS) GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); GISTENTRY *retval; - if ( tinfo.eml == 0 ) + if (tinfo.eml == 0) { tinfo.eml = pg_database_encoding_max_length(); } @@ -111,7 +111,7 @@ gbt_bpchar_compress(PG_FUNCTION_ARGS) { Datum d = DirectFunctionCall1(rtrim1, entry->key); - GISTENTRY trim; + GISTENTRY trim; gistentryinit(trim, d, entry->rel, entry->page, @@ -136,7 +136,7 @@ gbt_text_consistent(PG_FUNCTION_ARGS) bool retval = FALSE; GBT_VARKEY_R r = gbt_var_key_readable(key); - if ( tinfo.eml == 0 ) + if (tinfo.eml == 0) { tinfo.eml = pg_database_encoding_max_length(); } @@ -158,7 +158,7 @@ gbt_bpchar_consistent(PG_FUNCTION_ARGS) bool retval; GBT_VARKEY_R r = gbt_var_key_readable(key); - if ( tinfo.eml == 0 ) + if (tinfo.eml == 0) { tinfo.eml = pg_database_encoding_max_length(); } diff --git a/contrib/btree_gist/btree_time.c b/contrib/btree_gist/btree_time.c index 02f2664349..c6a5697af0 100644 --- a/contrib/btree_gist/btree_time.c +++ b/contrib/btree_gist/btree_time.c @@ -36,7 +36,7 @@ static bool gbt_timegt(const void *a, const void *b) { return DatumGetBool( - DirectFunctionCall2(time_gt, PointerGetDatum(a), PointerGetDatum(b)) + DirectFunctionCall2(time_gt, PointerGetDatum(a), PointerGetDatum(b)) ); } @@ -44,7 +44,7 @@ static bool gbt_timege(const void *a, const void *b) { return DatumGetBool( - DirectFunctionCall2(time_ge, PointerGetDatum(a), PointerGetDatum(b)) + DirectFunctionCall2(time_ge, PointerGetDatum(a), PointerGetDatum(b)) ); } @@ -52,7 +52,7 @@ static bool gbt_timeeq(const void *a, const void *b) { return DatumGetBool( - DirectFunctionCall2(time_eq, PointerGetDatum(a), PointerGetDatum(b)) + DirectFunctionCall2(time_eq, PointerGetDatum(a), PointerGetDatum(b)) ); } @@ -60,7 +60,7 @@ static bool gbt_timele(const void *a, const void *b) { return DatumGetBool( - DirectFunctionCall2(time_le, PointerGetDatum(a), PointerGetDatum(b)) + DirectFunctionCall2(time_le, PointerGetDatum(a), PointerGetDatum(b)) ); } @@ -68,7 +68,7 @@ static bool gbt_timelt(const void *a, const void *b) { return DatumGetBool( - DirectFunctionCall2(time_lt, PointerGetDatum(a), PointerGetDatum(b)) + DirectFunctionCall2(time_lt, PointerGetDatum(a), PointerGetDatum(b)) ); } @@ -212,15 +212,15 @@ gbt_time_penalty(PG_FUNCTION_ARGS) intr = DatumGetIntervalP(DirectFunctionCall2( time_mi_time, - P_TimeADTGetDatum(newentry->upper), - P_TimeADTGetDatum(origentry->upper))); + P_TimeADTGetDatum(newentry->upper), + P_TimeADTGetDatum(origentry->upper))); res = INTERVAL_TO_SEC(intr); res = Max(res, 0); intr = DatumGetIntervalP(DirectFunctionCall2( time_mi_time, - P_TimeADTGetDatum(origentry->lower), - P_TimeADTGetDatum(newentry->lower))); + P_TimeADTGetDatum(origentry->lower), + P_TimeADTGetDatum(newentry->lower))); res2 = INTERVAL_TO_SEC(intr); res2 = Max(res2, 0); @@ -232,8 +232,8 @@ gbt_time_penalty(PG_FUNCTION_ARGS) { intr = DatumGetIntervalP(DirectFunctionCall2( time_mi_time, - P_TimeADTGetDatum(origentry->upper), - P_TimeADTGetDatum(origentry->lower))); + P_TimeADTGetDatum(origentry->upper), + P_TimeADTGetDatum(origentry->lower))); *result += FLT_MIN; *result += (float) (res / (res + INTERVAL_TO_SEC(intr))); *result *= (FLT_MAX / (((GISTENTRY *) PG_GETARG_POINTER(0))->rel->rd_att->natts + 1)); @@ -247,8 +247,8 @@ Datum gbt_time_picksplit(PG_FUNCTION_ARGS) { PG_RETURN_POINTER(gbt_num_picksplit( - (GistEntryVector *) PG_GETARG_POINTER(0), - (GIST_SPLITVEC *) PG_GETARG_POINTER(1), + (GistEntryVector *) PG_GETARG_POINTER(0), + (GIST_SPLITVEC *) PG_GETARG_POINTER(1), &tinfo )); } diff --git a/contrib/btree_gist/btree_ts.c b/contrib/btree_gist/btree_ts.c index 119c45093e..9f305119d8 100644 --- a/contrib/btree_gist/btree_ts.c +++ b/contrib/btree_gist/btree_ts.c @@ -32,13 +32,13 @@ Datum gbt_ts_penalty(PG_FUNCTION_ARGS); Datum gbt_ts_same(PG_FUNCTION_ARGS); -#define P_TimestampGetDatum(x) PointerGetDatum( &(x) ) +#define P_TimestampGetDatum(x) PointerGetDatum( &(x) ) static bool gbt_tsgt(const void *a, const void *b) { return DatumGetBool( - DirectFunctionCall2(timestamp_gt, PointerGetDatum(a), PointerGetDatum(b)) + DirectFunctionCall2(timestamp_gt, PointerGetDatum(a), PointerGetDatum(b)) ); } @@ -46,7 +46,7 @@ static bool gbt_tsge(const void *a, const void *b) { return DatumGetBool( - DirectFunctionCall2(timestamp_ge, PointerGetDatum(a), PointerGetDatum(b)) + DirectFunctionCall2(timestamp_ge, PointerGetDatum(a), PointerGetDatum(b)) ); } @@ -54,7 +54,7 @@ static bool gbt_tseq(const void *a, const void *b) { return DatumGetBool( - DirectFunctionCall2(timestamp_eq, PointerGetDatum(a), PointerGetDatum(b)) + DirectFunctionCall2(timestamp_eq, PointerGetDatum(a), PointerGetDatum(b)) ); } @@ -62,7 +62,7 @@ static bool gbt_tsle(const void *a, const void *b) { return DatumGetBool( - DirectFunctionCall2(timestamp_le, PointerGetDatum(a), PointerGetDatum(b)) + DirectFunctionCall2(timestamp_le, PointerGetDatum(a), PointerGetDatum(b)) ); } @@ -70,7 +70,7 @@ static bool gbt_tslt(const void *a, const void *b) { return DatumGetBool( - DirectFunctionCall2(timestamp_lt, PointerGetDatum(a), PointerGetDatum(b)) + DirectFunctionCall2(timestamp_lt, PointerGetDatum(a), PointerGetDatum(b)) ); } @@ -114,7 +114,7 @@ tstz_to_ts_gmt(Timestamp *gmt, TimestampTz *ts) *gmt = *ts; DecodeSpecial(0, "gmt", &val); - if ( *ts < DT_NOEND && *ts > DT_NOBEGIN ) + if (*ts < DT_NOEND && *ts > DT_NOBEGIN) { tz = val * 60; @@ -217,10 +217,10 @@ gbt_ts_union(PG_FUNCTION_ARGS) #define penalty_check_max_float(val) do { \ - if ( val > FLT_MAX ) \ - val = FLT_MAX; \ - if ( val < -FLT_MAX ) \ - val = -FLT_MAX; \ + if ( val > FLT_MAX ) \ + val = FLT_MAX; \ + if ( val < -FLT_MAX ) \ + val = -FLT_MAX; \ } while(false); @@ -232,24 +232,24 @@ gbt_ts_penalty(PG_FUNCTION_ARGS) tsKEY *newentry = (tsKEY *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key); float *result = (float *) PG_GETARG_POINTER(2); - double orgdbl[2], - newdbl[2]; + double orgdbl[2], + newdbl[2]; /* - We are allways using "double" timestamps here. - Precision should be good enough. - */ - orgdbl[0] = ( (double) origentry->lower ) ; - orgdbl[1] = ( (double) origentry->upper ) ; - newdbl[0] = ( (double) newentry->lower ) ; - newdbl[1] = ( (double) newentry->upper ) ; + * We are allways using "double" timestamps here. Precision should be good + * enough. + */ + orgdbl[0] = ((double) origentry->lower); + orgdbl[1] = ((double) origentry->upper); + newdbl[0] = ((double) newentry->lower); + newdbl[1] = ((double) newentry->upper); - penalty_check_max_float( orgdbl[0] ); - penalty_check_max_float( orgdbl[1] ); - penalty_check_max_float( newdbl[0] ); - penalty_check_max_float( newdbl[1] ); + penalty_check_max_float(orgdbl[0]); + penalty_check_max_float(orgdbl[1]); + penalty_check_max_float(newdbl[0]); + penalty_check_max_float(newdbl[1]); - penalty_num(result,orgdbl[0],orgdbl[1],newdbl[0],newdbl[1]); + penalty_num(result, orgdbl[0], orgdbl[1], newdbl[0], newdbl[1]); PG_RETURN_POINTER(result); @@ -260,8 +260,8 @@ Datum gbt_ts_picksplit(PG_FUNCTION_ARGS) { PG_RETURN_POINTER(gbt_num_picksplit( - (GistEntryVector *) PG_GETARG_POINTER(0), - (GIST_SPLITVEC *) PG_GETARG_POINTER(1), + (GistEntryVector *) PG_GETARG_POINTER(0), + (GIST_SPLITVEC *) PG_GETARG_POINTER(1), &tinfo )); } diff --git a/contrib/btree_gist/btree_utils_num.h b/contrib/btree_gist/btree_utils_num.h index 94d4bf7437..322c5759e4 100644 --- a/contrib/btree_gist/btree_utils_num.h +++ b/contrib/btree_gist/btree_utils_num.h @@ -48,17 +48,17 @@ typedef struct * Note: The factor 0.49 in following macro avoids floating point overflows */ #define penalty_num(result,olower,oupper,nlower,nupper) do { \ - double tmp = 0.0F; \ - (*(result)) = 0.0F; \ + double tmp = 0.0F; \ + (*(result)) = 0.0F; \ if ( (nupper) > (oupper) ) \ tmp += ( ((double)nupper)*0.49F - ((double)oupper)*0.49F ); \ if ( (olower) > (nlower) ) \ tmp += ( ((double)olower)*0.49F - ((double)nlower)*0.49F ); \ if (tmp > 0.0F) \ { \ - (*(result)) += FLT_MIN; \ - (*(result)) += (float) ( ((double)(tmp)) / ( (double)(tmp) + ( ((double)(oupper))*0.49F - ((double)(olower))*0.49F ) ) ); \ - (*(result)) *= (FLT_MAX / (((GISTENTRY *) PG_GETARG_POINTER(0))->rel->rd_att->natts + 1)); \ + (*(result)) += FLT_MIN; \ + (*(result)) += (float) ( ((double)(tmp)) / ( (double)(tmp) + ( ((double)(oupper))*0.49F - ((double)(olower))*0.49F ) ) ); \ + (*(result)) *= (FLT_MAX / (((GISTENTRY *) PG_GETARG_POINTER(0))->rel->rd_att->natts + 1)); \ } \ } while (0); diff --git a/contrib/btree_gist/btree_utils_var.c b/contrib/btree_gist/btree_utils_var.c index 8de39bb327..20a1e427f2 100644 --- a/contrib/btree_gist/btree_utils_var.c +++ b/contrib/btree_gist/btree_utils_var.c @@ -4,14 +4,14 @@ #include "utils/builtins.h" PG_FUNCTION_INFO_V1(gbt_var_decompress); -Datum gbt_var_decompress(PG_FUNCTION_ARGS); +Datum gbt_var_decompress(PG_FUNCTION_ARGS); Datum gbt_var_decompress(PG_FUNCTION_ARGS) { GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0); - GBT_VARKEY *key = (GBT_VARKEY *) DatumGetPointer(PG_DETOAST_DATUM(entry->key)); + GBT_VARKEY *key = (GBT_VARKEY *) DatumGetPointer(PG_DETOAST_DATUM(entry->key)); if (key != (GBT_VARKEY *) DatumGetPointer(entry->key)) { @@ -92,45 +92,47 @@ static int32 gbt_var_node_cp_len(const GBT_VARKEY * node, const gbtree_vinfo * tinfo) { - GBT_VARKEY_R r = gbt_var_key_readable(node); - int32 i = 0; - int32 l = 0; - int32 t1len = VARSIZE(r.lower) - VARHDRSZ ; - int32 t2len = VARSIZE(r.upper) - VARHDRSZ ; - int32 ml = Min(t1len, t2len); + GBT_VARKEY_R r = gbt_var_key_readable(node); + int32 i = 0; + int32 l = 0; + int32 t1len = VARSIZE(r.lower) - VARHDRSZ; + int32 t2len = VARSIZE(r.upper) - VARHDRSZ; + int32 ml = Min(t1len, t2len); - char *p1 = VARDATA(r.lower); - char *p2 = VARDATA(r.upper); + char *p1 = VARDATA(r.lower); + char *p2 = VARDATA(r.upper); - if ( ml == 0 ) - return 0; + if (ml == 0) + return 0; - while ( i < ml ) + while (i < ml) { - if ( tinfo->eml > 1 && l == 0 ) - { + if (tinfo->eml > 1 && l == 0) + { - if ( ( l = pg_mblen(p1) ) != pg_mblen(p2) ) - { - return i; - } - } - if (*p1 != *p2) - { - if( tinfo->eml > 1 ) - { - return (i-l+1); - } else { - return i; - } - } + if ((l = pg_mblen(p1)) != pg_mblen(p2)) + { + return i; + } + } + if (*p1 != *p2) + { + if (tinfo->eml > 1) + { + return (i - l + 1); + } + else + { + return i; + } + } - p1++; - p2++; - l--; - i++; + p1++; + p2++; + l--; + i++; } - return (ml); /* lower == upper */ + return (ml); /* lower == upper */ } @@ -141,35 +143,37 @@ static bool gbt_bytea_pf_match(const bytea *pf, const bytea *query, const gbtree_vinfo * tinfo) { - bool out = FALSE; - int32 k = 0; - int32 qlen = VARSIZE(query) - VARHDRSZ ; - int32 nlen = VARSIZE(pf) - VARHDRSZ ; + bool out = FALSE; + int32 k = 0; + int32 qlen = VARSIZE(query) - VARHDRSZ; + int32 nlen = VARSIZE(pf) - VARHDRSZ; if (nlen <= qlen) { - char *q = VARDATA(query); - char *n = VARDATA(pf); + char *q = VARDATA(query); + char *n = VARDATA(pf); - if ( tinfo->eml > 1 ) - { - out = ( varstr_cmp(q, nlen, n, nlen) == 0 ); - } else { - out = TRUE; - for (k = 0; k < nlen; k++) - { - if (*n != *q) - { - out = FALSE; - break; - } - if (k < (nlen - 1)) - { - q++; - n++; - } - } - } + if (tinfo->eml > 1) + { + out = (varstr_cmp(q, nlen, n, nlen) == 0); + } + else + { + out = TRUE; + for (k = 0; k < nlen; k++) + { + if (*n != *q) + { + out = FALSE; + break; + } + if (k < (nlen - 1)) + { + q++; + n++; + } + } + } } return out; @@ -184,10 +188,10 @@ static bool gbt_var_node_pf_match(const GBT_VARKEY_R * node, const bytea *query, const gbtree_vinfo * tinfo) { - return ( tinfo->trnc && ( - gbt_bytea_pf_match(node->lower, query, tinfo) || - gbt_bytea_pf_match(node->upper, query, tinfo) - ) ); + return (tinfo->trnc && ( + gbt_bytea_pf_match(node->lower, query, tinfo) || + gbt_bytea_pf_match(node->upper, query, tinfo) + )); } @@ -201,18 +205,18 @@ gbt_var_node_truncate(const GBT_VARKEY * node, int32 cpf_length, const gbtree_vi { GBT_VARKEY *out = NULL; GBT_VARKEY_R r = gbt_var_key_readable(node); - int32 len1 = VARSIZE(r.lower) - VARHDRSZ; - int32 len2 = VARSIZE(r.upper) - VARHDRSZ; - int32 si = 0; + int32 len1 = VARSIZE(r.lower) - VARHDRSZ; + int32 len2 = VARSIZE(r.upper) - VARHDRSZ; + int32 si = 0; - len1 = Min(len1,(cpf_length + 1)); - len2 = Min(len2,(cpf_length + 1)); + len1 = Min(len1, (cpf_length + 1)); + len2 = Min(len2, (cpf_length + 1)); si = 2 * VARHDRSZ + INTALIGN(VARHDRSZ + len1) + len2; out = (GBT_VARKEY *) palloc(si); out->vl_len = si; - memcpy((void *) &(((char *) out)[VARHDRSZ]), (void *) r.lower, len1 + VARHDRSZ ); - memcpy((void *) &(((char *) out)[VARHDRSZ + INTALIGN(VARHDRSZ + len1)]), (void *) r.upper, len2 + VARHDRSZ ); + memcpy((void *) &(((char *) out)[VARHDRSZ]), (void *) r.lower, len1 + VARHDRSZ); + memcpy((void *) &(((char *) out)[VARHDRSZ + INTALIGN(VARHDRSZ + len1)]), (void *) r.upper, len2 + VARHDRSZ); *((int32 *) &(((char *) out)[VARHDRSZ])) = len1 + VARHDRSZ; *((int32 *) &(((char *) out)[VARHDRSZ + INTALIGN(VARHDRSZ + len1)])) = len2 + VARHDRSZ; @@ -568,8 +572,8 @@ gbt_var_consistent( else retval = ( ( - (*tinfo->f_cmp) (key->lower, (bytea *) query) <= 0 && - (*tinfo->f_cmp) ((bytea *) query, (void *) key->upper) <= 0 + (*tinfo->f_cmp) (key->lower, (bytea *) query) <= 0 && + (*tinfo->f_cmp) ((bytea *) query, (void *) key->upper) <= 0 ) || gbt_var_node_pf_match(key, query, tinfo) ); break; diff --git a/contrib/btree_gist/btree_utils_var.h b/contrib/btree_gist/btree_utils_var.h index e4d48d3910..9b7be0de0d 100644 --- a/contrib/btree_gist/btree_utils_var.h +++ b/contrib/btree_gist/btree_utils_var.h @@ -28,7 +28,8 @@ typedef struct /* Attribs */ enum gbtree_type t; /* data type */ - int32 eml; /* cached pg_database_encoding_max_length (0: undefined) */ + int32 eml; /* cached pg_database_encoding_max_length (0: + * undefined) */ bool trnc; /* truncate (=compress) key */ /* Methods */ diff --git a/contrib/chkpass/chkpass.c b/contrib/chkpass/chkpass.c index 8dda0bc4ad..8b77fb2a3a 100644 --- a/contrib/chkpass/chkpass.c +++ b/contrib/chkpass/chkpass.c @@ -4,7 +4,7 @@ * darcy@druid.net * http://www.druid.net/darcy/ * - * $PostgreSQL: pgsql/contrib/chkpass/chkpass.c,v 1.13 2005/01/29 22:35:01 tgl Exp $ + * $PostgreSQL: pgsql/contrib/chkpass/chkpass.c,v 1.14 2005/10/15 02:49:04 momjian Exp $ * best viewed with tabs set to 4 */ @@ -90,8 +90,8 @@ chkpass_in(PG_FUNCTION_ARGS) mysalt[0] = salt_chars[random() & 0x3f]; mysalt[1] = salt_chars[random() & 0x3f]; - mysalt[2] = 0; /* technically the terminator is not - * necessary but I like to play safe */ + mysalt[2] = 0; /* technically the terminator is not necessary + * but I like to play safe */ strcpy(result->password, crypt(str, mysalt)); PG_RETURN_POINTER(result); } diff --git a/contrib/cube/cube.c b/contrib/cube/cube.c index cc6e1a39fe..fca03f02d7 100644 --- a/contrib/cube/cube.c +++ b/contrib/cube/cube.c @@ -115,7 +115,7 @@ NDBOX * cube(text *str) { return cube_in(DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(str)))); + PointerGetDatum(str)))); } char * @@ -219,7 +219,7 @@ g_cube_union(GistEntryVector *entryvec, int *sizep) for (i = 1; i < entryvec->n; i++) { out = g_cube_binary_union(tmp, (NDBOX *) - DatumGetPointer(entryvec->vector[i].key), + DatumGetPointer(entryvec->vector[i].key), sizep); tmp = out; } @@ -329,8 +329,7 @@ g_cube_picksplit(GistEntryVector *entryvec, size_waste = size_union - size_inter; /* - * are these a more promising split than what we've already - * seen? + * are these a more promising split than what we've already seen? */ if (size_waste > waste || firsttime) @@ -356,24 +355,24 @@ g_cube_picksplit(GistEntryVector *entryvec, rt_cube_size(datum_r, &size_r); /* - * Now split up the regions between the two seeds. An important - * property of this split algorithm is that the split vector v has the - * indices of items to be split in order in its left and right - * vectors. We exploit this property by doing a merge in the code - * that actually splits the page. + * Now split up the regions between the two seeds. An important property + * of this split algorithm is that the split vector v has the indices of + * items to be split in order in its left and right vectors. We exploit + * this property by doing a merge in the code that actually splits the + * page. * - * For efficiency, we also place the new index tuple in this loop. This - * is handled at the very end, when we have placed all the existing - * tuples and i == maxoff + 1. + * For efficiency, we also place the new index tuple in this loop. This is + * handled at the very end, when we have placed all the existing tuples + * and i == maxoff + 1. */ maxoff = OffsetNumberNext(maxoff); for (i = FirstOffsetNumber; i <= maxoff; i = OffsetNumberNext(i)) { /* - * If we've already decided where to place this item, just put it - * on the right list. Otherwise, we need to figure out which page - * needs the least enlargement in order to store the item. + * If we've already decided where to place this item, just put it on + * the right list. Otherwise, we need to figure out which page needs + * the least enlargement in order to store the item. */ if (i == seed_1) @@ -542,8 +541,8 @@ cube_union(NDBOX * a, NDBOX * b) } /* - * use the potentially smaller of the two boxes (b) to fill in the - * result, padding absent dimensions with zeroes + * use the potentially smaller of the two boxes (b) to fill in the result, + * padding absent dimensions with zeroes */ for (i = 0; i < b->dim; i++) { @@ -562,7 +561,7 @@ cube_union(NDBOX * a, NDBOX * b) result->x[i] = Min(Min(a->x[i], a->x[i + a->dim]), result->x[i]); result->x[i + a->dim] = Max(Max(a->x[i], - a->x[i + a->dim]), result->x[i + a->dim]); + a->x[i + a->dim]), result->x[i + a->dim]); } return (result); @@ -620,12 +619,11 @@ cube_inter(NDBOX * a, NDBOX * b) result->x[i] = Max(Min(a->x[i], a->x[i + a->dim]), result->x[i]); result->x[i + a->dim] = Min(Max(a->x[i], - a->x[i + a->dim]), result->x[i + a->dim]); + a->x[i + a->dim]), result->x[i + a->dim]); } /* - * Is it OK to return a non-null intersection for non-overlapping - * boxes? + * Is it OK to return a non-null intersection for non-overlapping boxes? */ return (result); } @@ -713,8 +711,8 @@ cube_cmp(NDBOX * a, NDBOX * b) } /* - * if all common dimensions are equal, the cube with more - * dimensions wins + * if all common dimensions are equal, the cube with more dimensions + * wins */ return 1; } @@ -736,8 +734,8 @@ cube_cmp(NDBOX * a, NDBOX * b) } /* - * if all common dimensions are equal, the cube with more - * dimensions wins + * if all common dimensions are equal, the cube with more dimensions + * wins */ return -1; } @@ -797,10 +795,9 @@ cube_contains(NDBOX * a, NDBOX * b) if (a->dim < b->dim) { /* - * the further comparisons will make sense if the excess - * dimensions of (b) were zeroes Since both UL and UR coordinates - * must be zero, we can check them all without worrying about - * which is which. + * the further comparisons will make sense if the excess dimensions of + * (b) were zeroes Since both UL and UR coordinates must be zero, we + * can check them all without worrying about which is which. */ for (i = a->dim; i < b->dim; i++) { diff --git a/contrib/dbase/dbf.c b/contrib/dbase/dbf.c index 6a13aac972..4c79a07d60 100644 --- a/contrib/dbase/dbf.c +++ b/contrib/dbase/dbf.c @@ -88,10 +88,10 @@ dbf_open(char *file, int flags) dbh->db_nfields = (dbh->db_hlen - sizeof(dbf_header)) / sizeof(dbf_field); /* - * dbh->db_hlen - sizeof(dbf_header) isn't the correct size, cos - * dbh->hlen is in fact a little more cos of the 0x0D (and possibly - * another byte, 0x4E, I have seen this somewhere). Because of - * rounding everything turns out right :) + * dbh->db_hlen - sizeof(dbf_header) isn't the correct size, cos dbh->hlen + * is in fact a little more cos of the 0x0D (and possibly another byte, + * 0x4E, I have seen this somewhere). Because of rounding everything turns + * out right :) */ if ((fields = (f_descr *) calloc(dbh->db_nfields, sizeof(f_descr))) @@ -155,8 +155,7 @@ dbf_write_head(dbhead * dbh) now = time((time_t *) NULL); dbf_time = localtime(&now); head.dbh_year = dbf_time->tm_year; - head.dbh_month = dbf_time->tm_mon + 1; /* Months since January + - * 1 */ + head.dbh_month = dbf_time->tm_mon + 1; /* Months since January + 1 */ head.dbh_day = dbf_time->tm_mday; put_long(head.dbh_records, dbh->db_records); diff --git a/contrib/dbase/dbf.h b/contrib/dbase/dbf.h index 9a5a2bee83..d9c88ed35b 100644 --- a/contrib/dbase/dbf.h +++ b/contrib/dbase/dbf.h @@ -9,7 +9,7 @@ #define _DBF_H #ifdef _WIN32 -#include /* we need it to define u_char type */ +#include /* we need it to define u_char type */ #endif #include @@ -64,8 +64,7 @@ typedef struct u_char dbf_type; /* field-type */ u_char dbf_reserved[4]; /* some reserved stuff */ u_char dbf_flen; /* field-length */ - u_char dbf_dec; /* number of decimal positions if type is - * 'N' */ + u_char dbf_dec; /* number of decimal positions if type is 'N' */ u_char dbf_stub[14]; /* stuff we don't need */ } dbf_field; @@ -89,15 +88,14 @@ typedef struct u_char db_year; /* last update as YYMMDD */ u_char db_month; u_char db_day; - u_long db_hlen; /* length of the diskheader, for - * calculating the offsets */ + u_long db_hlen; /* length of the diskheader, for calculating + * the offsets */ u_long db_records; /* number of records */ u_long db_currec; /* current record-number starting at 0 */ u_short db_rlen; /* length of the record */ u_char db_nfields; /* number of fields */ u_char *db_buff; /* record-buffer to save malloc()'s */ - f_descr *db_fields; /* pointer to an array of field- - * descriptions */ + f_descr *db_fields; /* pointer to an array of field- descriptions */ } dbhead; /* structure that contains everything a user wants from a field, including diff --git a/contrib/dbase/dbf2pg.c b/contrib/dbase/dbf2pg.c index c3e50dc4ac..7d42798dbe 100644 --- a/contrib/dbase/dbf2pg.c +++ b/contrib/dbase/dbf2pg.c @@ -169,7 +169,7 @@ usage(void) { printf("dbf2pg\n" "usage: dbf2pg [-u | -l] [-h hostname] [-W] [-U username]\n" - " [-B transaction_size] [-F charset_from [-T charset_to]]\n" + " [-B transaction_size] [-F charset_from [-T charset_to]]\n" " [-s oldname=[newname][,oldname=[newname][...]]] [-d dbase]\n" " [-t table] [-c | -D] [-f] [-v[v]] dbf-file\n"); } @@ -251,7 +251,7 @@ do_create(PGconn *conn, char *table, dbhead * dbh) printf("Building CREATE-clause\n"); if (!(query = (char *) malloc( - (dbh->db_nfields * 40) + 29 + strlen(table)))) + (dbh->db_nfields * 40) + 29 + strlen(table)))) { fprintf(stderr, "Memory allocation error in function do_create\n"); PQfinish(conn); @@ -359,9 +359,8 @@ do_inserts(PGconn *conn, char *table, dbhead * dbh) } /* - * make sure we can build the COPY query, note that we don't need to - * just add this value, since the COPY query is a separate query (see - * below) + * make sure we can build the COPY query, note that we don't need to just + * add this value, since the COPY query is a separate query (see below) */ if (h < 17 + strlen(table)) h = 17 + strlen(table); @@ -370,7 +369,7 @@ do_inserts(PGconn *conn, char *table, dbhead * dbh) { PQfinish(conn); fprintf(stderr, - "Memory allocation error in function do_inserts (query)\n"); + "Memory allocation error in function do_inserts (query)\n"); close(dbh->db_fd); free(dbh); exit(1); @@ -386,12 +385,10 @@ do_inserts(PGconn *conn, char *table, dbhead * dbh) exit(1); } - if (end == 0) /* "end" is a user option, if not - * specified, */ + if (end == 0) /* "end" is a user option, if not specified, */ end = dbh->db_records; /* then all records are processed. */ - if (t_block == 0) /* user not specified transaction block - * size */ + if (t_block == 0) /* user not specified transaction block size */ t_block = end - begin; /* then we set it to be the full data */ for (i = begin; i < end; i++) @@ -426,9 +423,8 @@ do_inserts(PGconn *conn, char *table, dbhead * dbh) j = 0; /* counter for fields in the output */ for (h = 0; h < dbh->db_nfields; h++) { - if (!strlen(fields[h].db_name)) /* When the new fieldname - * is empty, the field is - * skipped */ + if (!strlen(fields[h].db_name)) /* When the new fieldname is + * empty, the field is skipped */ continue; else j++; @@ -639,8 +635,8 @@ main(int argc, char **argv) usage(); /* - * FIXME: Ivan thinks this is bad: printf("unknown - * argument: %s\n", argv[0]); + * FIXME: Ivan thinks this is bad: printf("unknown argument: + * %s\n", argv[0]); */ exit(1); break; diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c index c1d70ebf22..c11b15860a 100644 --- a/contrib/dblink/dblink.c +++ b/contrib/dblink/dblink.c @@ -60,10 +60,9 @@ typedef struct remoteConn { - PGconn *conn; /* Hold the remote connection */ - int autoXactCursors; /* Indicates the number of open cursors, - * non-zero means we opened the xact - * ourselves */ + PGconn *conn; /* Hold the remote connection */ + int autoXactCursors;/* Indicates the number of open cursors, + * non-zero means we opened the xact ourselves */ } remoteConn; /* @@ -71,7 +70,7 @@ typedef struct remoteConn */ static remoteConn *getConnectionByName(const char *name); static HTAB *createConnHash(void); -static void createNewConnection(const char *name, remoteConn *rconn); +static void createNewConnection(const char *name, remoteConn * rconn); static void deleteConnection(const char *name); static char **get_pkey_attnames(Oid relid, int16 *numatts); static char *get_sql_insert(Oid relid, int2vector *pkattnums, int16 pknumatts, char **src_pkattvals, char **tgt_pkattvals); @@ -224,9 +223,9 @@ dblink_connect(PG_FUNCTION_ARGS) pfree(rconn); ereport(ERROR, - (errcode(ERRCODE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION), - errmsg("could not establish connection"), - errdetail("%s", msg))); + (errcode(ERRCODE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION), + errmsg("could not establish connection"), + errdetail("%s", msg))); } if (connname) @@ -514,8 +513,7 @@ dblink_fetch(PG_FUNCTION_ARGS) funcctx = SRF_FIRSTCALL_INIT(); /* - * switch to memory context appropriate for multiple function - * calls + * switch to memory context appropriate for multiple function calls */ oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); @@ -664,8 +662,7 @@ dblink_record(PG_FUNCTION_ARGS) funcctx = SRF_FIRSTCALL_INIT(); /* - * switch to memory context appropriate for multiple function - * calls + * switch to memory context appropriate for multiple function calls */ oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); @@ -730,8 +727,8 @@ dblink_record(PG_FUNCTION_ARGS) TEXTOID, -1, 0); /* - * and save a copy of the command status string to return as - * our result tuple + * and save a copy of the command status string to return as our + * result tuple */ sql_cmd_status = PQcmdStatus(res); funcctx->max_calls = 1; @@ -766,8 +763,8 @@ dblink_record(PG_FUNCTION_ARGS) /* failed to determine actual type of RECORD */ ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("function returning record called in context " - "that cannot accept type record"))); + errmsg("function returning record called in context " + "that cannot accept type record"))); break; default: /* result type isn't composite */ @@ -935,8 +932,8 @@ dblink_exec(PG_FUNCTION_ARGS) { PQclear(res); ereport(ERROR, - (errcode(ERRCODE_S_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED), - errmsg("statement returning results not allowed"))); + (errcode(ERRCODE_S_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED), + errmsg("statement returning results not allowed"))); } /* if needed, close the connection to the database and cleanup */ @@ -975,8 +972,7 @@ dblink_get_pkey(PG_FUNCTION_ARGS) funcctx = SRF_FIRSTCALL_INIT(); /* - * switch to memory context appropriate for multiple function - * calls + * switch to memory context appropriate for multiple function calls */ oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); @@ -989,8 +985,7 @@ dblink_get_pkey(PG_FUNCTION_ARGS) GET_STR(PG_GETARG_TEXT_P(0))))); /* - * need a tuple descriptor representing one INT and one TEXT - * column + * need a tuple descriptor representing one INT and one TEXT column */ tupdesc = CreateTemplateTupleDesc(2, false); TupleDescInitEntry(tupdesc, (AttrNumber) 1, "position", @@ -999,8 +994,8 @@ dblink_get_pkey(PG_FUNCTION_ARGS) TEXTOID, -1, 0); /* - * Generate attribute metadata needed later to produce tuples from - * raw C strings + * Generate attribute metadata needed later to produce tuples from raw + * C strings */ attinmeta = TupleDescGetAttInMetadata(tupdesc); funcctx->attinmeta = attinmeta; @@ -1145,8 +1140,8 @@ dblink_build_sql_insert(PG_FUNCTION_ARGS) tgt_pkattvals_arry = PG_GETARG_ARRAYTYPE_P(4); /* - * Source array is made up of key values that will be used to locate - * the tuple of interest from the local system. + * Source array is made up of key values that will be used to locate the + * tuple of interest from the local system. */ src_ndim = ARR_NDIM(src_pkattvals_arry); src_dim = ARR_DIMS(src_pkattvals_arry); @@ -1158,8 +1153,8 @@ dblink_build_sql_insert(PG_FUNCTION_ARGS) if (src_nitems != pknumatts) ereport(ERROR, (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR), - errmsg("source key array length must match number of key " \ - "attributes"))); + errmsg("source key array length must match number of key " \ + "attributes"))); /* * get array of pointers to c-strings from the input source array @@ -1178,8 +1173,8 @@ dblink_build_sql_insert(PG_FUNCTION_ARGS) } /* - * Target array is made up of key values that will be used to build - * the SQL string for use on the remote system. + * Target array is made up of key values that will be used to build the + * SQL string for use on the remote system. */ tgt_ndim = ARR_NDIM(tgt_pkattvals_arry); tgt_dim = ARR_DIMS(tgt_pkattvals_arry); @@ -1191,8 +1186,8 @@ dblink_build_sql_insert(PG_FUNCTION_ARGS) if (tgt_nitems != pknumatts) ereport(ERROR, (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR), - errmsg("target key array length must match number of key " \ - "attributes"))); + errmsg("target key array length must match number of key " \ + "attributes"))); /* * get array of pointers to c-strings from the input target array @@ -1291,8 +1286,8 @@ dblink_build_sql_delete(PG_FUNCTION_ARGS) tgt_pkattvals_arry = PG_GETARG_ARRAYTYPE_P(3); /* - * Target array is made up of key values that will be used to build - * the SQL string for use on the remote system. + * Target array is made up of key values that will be used to build the + * SQL string for use on the remote system. */ tgt_ndim = ARR_NDIM(tgt_pkattvals_arry); tgt_dim = ARR_DIMS(tgt_pkattvals_arry); @@ -1304,8 +1299,8 @@ dblink_build_sql_delete(PG_FUNCTION_ARGS) if (tgt_nitems != pknumatts) ereport(ERROR, (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR), - errmsg("target key array length must match number of key " \ - "attributes"))); + errmsg("target key array length must match number of key " \ + "attributes"))); /* * get array of pointers to c-strings from the input target array @@ -1414,8 +1409,8 @@ dblink_build_sql_update(PG_FUNCTION_ARGS) tgt_pkattvals_arry = PG_GETARG_ARRAYTYPE_P(4); /* - * Source array is made up of key values that will be used to locate - * the tuple of interest from the local system. + * Source array is made up of key values that will be used to locate the + * tuple of interest from the local system. */ src_ndim = ARR_NDIM(src_pkattvals_arry); src_dim = ARR_DIMS(src_pkattvals_arry); @@ -1427,8 +1422,8 @@ dblink_build_sql_update(PG_FUNCTION_ARGS) if (src_nitems != pknumatts) ereport(ERROR, (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR), - errmsg("source key array length must match number of key " \ - "attributes"))); + errmsg("source key array length must match number of key " \ + "attributes"))); /* * get array of pointers to c-strings from the input source array @@ -1447,8 +1442,8 @@ dblink_build_sql_update(PG_FUNCTION_ARGS) } /* - * Target array is made up of key values that will be used to build - * the SQL string for use on the remote system. + * Target array is made up of key values that will be used to build the + * SQL string for use on the remote system. */ tgt_ndim = ARR_NDIM(tgt_pkattvals_arry); tgt_dim = ARR_DIMS(tgt_pkattvals_arry); @@ -1460,8 +1455,8 @@ dblink_build_sql_update(PG_FUNCTION_ARGS) if (tgt_nitems != pknumatts) ereport(ERROR, (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR), - errmsg("target key array length must match number of key " \ - "attributes"))); + errmsg("target key array length must match number of key " \ + "attributes"))); /* * get array of pointers to c-strings from the input target array @@ -1610,7 +1605,7 @@ get_sql_insert(Oid relid, int2vector *pkattnums, int16 pknumatts, char **src_pka appendStringInfo(str, ","); appendStringInfo(str, "%s", - quote_ident_cstr(NameStr(tupdesc->attrs[i]->attname))); + quote_ident_cstr(NameStr(tupdesc->attrs[i]->attname))); needComma = true; } @@ -1688,7 +1683,7 @@ get_sql_delete(Oid relid, int2vector *pkattnums, int16 pknumatts, char **tgt_pka appendStringInfo(str, " AND "); appendStringInfo(str, "%s", - quote_ident_cstr(NameStr(tupdesc->attrs[pkattnum - 1]->attname))); + quote_ident_cstr(NameStr(tupdesc->attrs[pkattnum - 1]->attname))); if (tgt_pkattvals != NULL) val = pstrdup(tgt_pkattvals[i]); @@ -1756,7 +1751,7 @@ get_sql_update(Oid relid, int2vector *pkattnums, int16 pknumatts, char **src_pka appendStringInfo(str, ", "); appendStringInfo(str, "%s = ", - quote_ident_cstr(NameStr(tupdesc->attrs[i]->attname))); + quote_ident_cstr(NameStr(tupdesc->attrs[i]->attname))); if (tgt_pkattvals != NULL) key = get_attnum_pk_pos(pkattnums, pknumatts, i + 1); @@ -1788,7 +1783,7 @@ get_sql_update(Oid relid, int2vector *pkattnums, int16 pknumatts, char **src_pka appendStringInfo(str, " AND "); appendStringInfo(str, "%s", - quote_ident_cstr(NameStr(tupdesc->attrs[pkattnum - 1]->attname))); + quote_ident_cstr(NameStr(tupdesc->attrs[pkattnum - 1]->attname))); if (tgt_pkattvals != NULL) val = pstrdup(tgt_pkattvals[i]); @@ -1894,8 +1889,8 @@ get_tuple_of_interest(Oid relid, int2vector *pkattnums, int16 pknumatts, char ** elog(ERROR, "SPI connect failure - returned %d", ret); /* - * Build sql statement to look up tuple of interest Use src_pkattvals - * as the criteria. + * Build sql statement to look up tuple of interest Use src_pkattvals as + * the criteria. */ appendStringInfo(str, "SELECT * FROM %s WHERE ", relname); @@ -1907,7 +1902,7 @@ get_tuple_of_interest(Oid relid, int2vector *pkattnums, int16 pknumatts, char ** appendStringInfo(str, " AND "); appendStringInfo(str, "%s", - quote_ident_cstr(NameStr(tupdesc->attrs[pkattnum - 1]->attname))); + quote_ident_cstr(NameStr(tupdesc->attrs[pkattnum - 1]->attname))); val = pstrdup(src_pkattvals[i]); if (val != NULL) @@ -2045,7 +2040,7 @@ createConnHash(void) } static void -createNewConnection(const char *name, remoteConn *rconn) +createNewConnection(const char *name, remoteConn * rconn) { remoteConnHashEnt *hentry; bool found; diff --git a/contrib/dbmirror/pending.c b/contrib/dbmirror/pending.c index 36f5837bbd..f0204f73aa 100644 --- a/contrib/dbmirror/pending.c +++ b/contrib/dbmirror/pending.c @@ -1,7 +1,7 @@ /**************************************************************************** * pending.c - * $Id: pending.c,v 1.22 2005/10/02 23:50:05 tgl Exp $ - * $PostgreSQL: pgsql/contrib/dbmirror/pending.c,v 1.22 2005/10/02 23:50:05 tgl Exp $ + * $Id: pending.c,v 1.23 2005/10/15 02:49:04 momjian Exp $ + * $PostgreSQL: pgsql/contrib/dbmirror/pending.c,v 1.23 2005/10/15 02:49:04 momjian Exp $ * * This file contains a trigger for Postgresql-7.x to record changes to tables * to a pending table for mirroring. @@ -115,7 +115,7 @@ recordchange(PG_FUNCTION_ARGS) if (SPI_connect() < 0) { ereport(ERROR, (errcode(ERRCODE_CONNECTION_FAILURE), - errmsg("dbmirror:recordchange could not connect to SPI"))); + errmsg("dbmirror:recordchange could not connect to SPI"))); return -1; } trigdata = (TriggerData *) fcinfo->context; @@ -155,7 +155,7 @@ recordchange(PG_FUNCTION_ARGS) else { ereport(ERROR, (errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION), - errmsg("dbmirror:recordchange Unknown operation"))); + errmsg("dbmirror:recordchange Unknown operation"))); } @@ -219,7 +219,7 @@ storePending(char *cpTableName, HeapTuple tBeforeTuple, vpPlan = SPI_prepare(cpQueryBase, 3, taPlanArgTypes); if (vpPlan == NULL) ereport(ERROR, (errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION), - errmsg("dbmirror:storePending error creating plan"))); + errmsg("dbmirror:storePending error creating plan"))); saPlanData[0] = PointerGetDatum(cpTableName); @@ -662,7 +662,7 @@ saveSequenceUpdate(Oid relid, int64 nextValue, bool iscalled) if (SPI_connect() < 0) ereport(ERROR, (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION), - errmsg("dbmirror:savesequenceupdate could not connect to SPI"))); + errmsg("dbmirror:savesequenceupdate could not connect to SPI"))); insertPlan = SPI_prepare(insertQuery, 2, insertArgTypes); insertDataPlan = SPI_prepare(insertDataQuery, 1, insertDataArgTypes); diff --git a/contrib/earthdistance/earthdistance.c b/contrib/earthdistance/earthdistance.c index 28ce40378c..f91eeb5392 100644 --- a/contrib/earthdistance/earthdistance.c +++ b/contrib/earthdistance/earthdistance.c @@ -67,7 +67,7 @@ geo_distance(Point *pt1, Point *pt2) longdiff = TWO_PI - longdiff; sino = sqrt(sin(fabs(lat1 - lat2) / 2.) * sin(fabs(lat1 - lat2) / 2.) + - cos(lat1) * cos(lat2) * sin(longdiff / 2.) * sin(longdiff / 2.)); + cos(lat1) * cos(lat2) * sin(longdiff / 2.) * sin(longdiff / 2.)); if (sino > 1.) sino = 1.; *resultp = 2. * EARTH_RADIUS * asin(sino); diff --git a/contrib/fulltextindex/fti.c b/contrib/fulltextindex/fti.c index e5095ff1a1..a3ac6da586 100644 --- a/contrib/fulltextindex/fti.c +++ b/contrib/fulltextindex/fti.c @@ -339,8 +339,8 @@ fti(PG_FUNCTION_ARGS) ret = SPI_execp(*(plan->splan), values, NULL, 0); if (ret != SPI_OK_INSERT) ereport(ERROR, - (errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION), - errmsg("error executing insert"))); + (errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION), + errmsg("error executing insert"))); } pfree(buff); pfree(data); @@ -367,9 +367,8 @@ breakup(char *string, char *substring) 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' + * 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((unsigned char) *last_start)) { @@ -379,8 +378,7 @@ breakup(char *string, char *substring) cur_pos = last_start; } - cur_pos--; /* substrings are at minimum 2 characters - * long */ + cur_pos--; /* substrings are at minimum 2 characters long */ if (isalnum((unsigned char) *cur_pos)) { diff --git a/contrib/fuzzystrmatch/dmetaphone.c b/contrib/fuzzystrmatch/dmetaphone.c index c8d9c8979b..216f39b7a7 100644 --- a/contrib/fuzzystrmatch/dmetaphone.c +++ b/contrib/fuzzystrmatch/dmetaphone.c @@ -48,8 +48,8 @@ /* - * $Revision: 1.5 $ - * $Id: dmetaphone.c,v 1.5 2005/09/30 22:38:44 momjian Exp $ + * $Revision: 1.6 $ + * $Id: dmetaphone.c,v 1.6 2005/10/15 02:49:05 momjian Exp $ */ @@ -154,10 +154,10 @@ dmetaphone(PG_FUNCTION_ARGS) alen = VARSIZE(arg) - VARHDRSZ; /* - * Postgres' string values might not have trailing nuls. The VARSIZE - * will not include the nul in any case so we copy things out and add - * a trailing nul. When we copy back we ignore the nul (and we don't - * make space for it). + * Postgres' string values might not have trailing nuls. The VARSIZE will + * not include the nul in any case so we copy things out and add a + * trailing nul. When we copy back we ignore the nul (and we don't make + * space for it). */ aptr = palloc(alen + 1); @@ -236,7 +236,6 @@ dmetaphone_alt(PG_FUNCTION_ARGS) */ #define META_FREE(x) /* pfree((x)) */ - #else /* not defined DMETAPHONE_MAIN */ /* use the standard malloc library when not running in PostgreSQL */ @@ -512,8 +511,8 @@ DoubleMetaphone(char *str, char **codes) && StringAt(original, (current - 1), 3, "ACH", "") && ((GetAt(original, current + 2) != 'I') && ((GetAt(original, current + 2) != 'E') - || StringAt(original, (current - 2), 6, "BACHER", - "MACHER", "")))) + || StringAt(original, (current - 2), 6, "BACHER", + "MACHER", "")))) { MetaphAdd(primary, "K"); MetaphAdd(secondary, "K"); @@ -582,9 +581,9 @@ DoubleMetaphone(char *str, char **codes) /* * e.g., 'wachtler', 'wechsler', but not 'tichner' */ - && StringAt(original, (current + 2), 1, "L", "R", - "N", "M", "B", "H", "F", "V", "W", - " ", ""))) + && StringAt(original, (current + 2), 1, "L", "R", + "N", "M", "B", "H", "F", "V", "W", + " ", ""))) { MetaphAdd(primary, "K"); MetaphAdd(secondary, "K"); @@ -639,14 +638,14 @@ DoubleMetaphone(char *str, char **codes) { /* 'bellocchio' but not 'bacchus' */ if (StringAt(original, (current + 2), 1, "I", "E", "H", "") - && !StringAt(original, (current + 2), 2, "HU", "")) + && !StringAt(original, (current + 2), 2, "HU", "")) { /* 'accident', 'accede' 'succeed' */ if ( ((current == 1) && (GetAt(original, current - 1) == 'A')) - || StringAt(original, (current - 1), 5, "UCCEE", - "UCCES", "")) + || StringAt(original, (current - 1), 5, "UCCEE", + "UCCES", "")) { MetaphAdd(primary, "KS"); MetaphAdd(secondary, "KS"); @@ -787,8 +786,8 @@ DoubleMetaphone(char *str, char **codes) } /* - * Parker's rule (with some further refinements) - - * e.g., 'hugh' + * Parker's rule (with some further refinements) - e.g., + * 'hugh' */ if ( ((current > 1) @@ -873,9 +872,9 @@ DoubleMetaphone(char *str, char **codes) /* -ges-,-gep-,-gel-, -gie- at beginning */ if ((current == 0) && ((GetAt(original, current + 1) == 'Y') - || StringAt(original, (current + 1), 2, "ES", "EP", - "EB", "EL", "EY", "IB", "IL", "IN", "IE", - "EI", "ER", ""))) + || StringAt(original, (current + 1), 2, "ES", "EP", + "EB", "EL", "EY", "IB", "IL", "IN", "IE", + "EI", "ER", ""))) { MetaphAdd(primary, "K"); MetaphAdd(secondary, "J"); @@ -1002,7 +1001,7 @@ DoubleMetaphone(char *str, char **codes) else { if (!StringAt(original, (current + 1), 1, "L", "T", - "K", "S", "N", "M", "B", "Z", "") + "K", "S", "N", "M", "B", "Z", "") && !StringAt(original, (current - 1), 1, "S", "K", "L", "")) { @@ -1035,10 +1034,10 @@ DoubleMetaphone(char *str, char **codes) if (((current == (length - 3)) && StringAt(original, (current - 1), 4, "ILLO", "ILLA", "ALLE", "")) - || ((StringAt(original, (last - 1), 2, "AS", "OS", "") - || StringAt(original, last, 1, "A", "O", "")) - && StringAt(original, (current - 1), 4, - "ALLE", ""))) + || ((StringAt(original, (last - 1), 2, "AS", "OS", "") + || StringAt(original, last, 1, "A", "O", "")) + && StringAt(original, (current - 1), 4, + "ALLE", ""))) { MetaphAdd(primary, "L"); MetaphAdd(secondary, ""); @@ -1056,7 +1055,7 @@ DoubleMetaphone(char *str, char **codes) case 'M': if ((StringAt(original, (current - 1), 3, "UMB", "") && (((current + 1) == last) - || StringAt(original, (current + 2), 2, "ER", ""))) + || StringAt(original, (current + 2), 2, "ER", ""))) /* 'dumb','thumb' */ || (GetAt(original, current + 1) == 'M')) current += 2; @@ -1113,7 +1112,7 @@ DoubleMetaphone(char *str, char **codes) if ((current == last) && !SlavoGermanic(original) && StringAt(original, (current - 2), 2, "IE", "") - && !StringAt(original, (current - 4), 2, "ME", "MA", "")) + && !StringAt(original, (current - 4), 2, "ME", "MA", "")) { MetaphAdd(primary, ""); MetaphAdd(secondary, "R"); @@ -1152,8 +1151,8 @@ DoubleMetaphone(char *str, char **codes) { /* germanic */ if (StringAt - (original, (current + 1), 4, "HEIM", "HOEK", "HOLM", - "HOLZ", "")) + (original, (current + 1), 4, "HEIM", "HOEK", "HOLM", + "HOLZ", "")) { MetaphAdd(primary, "S"); MetaphAdd(secondary, "S"); @@ -1187,8 +1186,8 @@ DoubleMetaphone(char *str, char **codes) /* * german & anglicisations, e.g. 'smith' match 'schmidt', - * 'snider' match 'schneider' also, -sz- in slavic - * language although in hungarian it is pronounced 's' + * 'snider' match 'schneider' also, -sz- in slavic language + * although in hungarian it is pronounced 's' */ if (((current == 0) && StringAt(original, (current + 1), 1, @@ -1264,7 +1263,7 @@ DoubleMetaphone(char *str, char **codes) /* french e.g. 'resnais', 'artois' */ if ((current == last) - && StringAt(original, (current - 2), 2, "AI", "OI", "")) + && StringAt(original, (current - 2), 2, "AI", "OI", "")) { MetaphAdd(primary, ""); MetaphAdd(secondary, "S"); @@ -1365,8 +1364,8 @@ DoubleMetaphone(char *str, char **codes) /* Arnow should match Arnoff */ if (((current == last) && IsVowel(original, current - 1)) - || StringAt(original, (current - 1), 5, "EWSKI", "EWSKY", - "OWSKI", "OWSKY", "") + || StringAt(original, (current - 1), 5, "EWSKI", "EWSKY", + "OWSKI", "OWSKY", "") || StringAt(original, 0, 3, "SCH", "")) { MetaphAdd(primary, ""); @@ -1442,8 +1441,8 @@ DoubleMetaphone(char *str, char **codes) } /* - * printf("PRIMARY: %s\n", primary->str); printf("SECONDARY: - * %s\n", secondary->str); + * printf("PRIMARY: %s\n", primary->str); printf("SECONDARY: %s\n", + * secondary->str); */ } diff --git a/contrib/fuzzystrmatch/fuzzystrmatch.c b/contrib/fuzzystrmatch/fuzzystrmatch.c index 8ffc02ffa3..e76e5038c2 100644 --- a/contrib/fuzzystrmatch/fuzzystrmatch.c +++ b/contrib/fuzzystrmatch/fuzzystrmatch.c @@ -65,10 +65,10 @@ levenshtein(PG_FUNCTION_ARGS) int j; /* - * Fetch the arguments. str_s is referred to as the "source" cols = - * length of source + 1 to allow for the initialization column str_t - * is referred to as the "target", rows = length of target + 1 rows = - * length of target + 1 to allow for the initialization row + * Fetch the arguments. str_s is referred to as the "source" cols = length + * of source + 1 to allow for the initialization column str_t is referred + * to as the "target", rows = length of target + 1 rows = length of target + * + 1 to allow for the initialization row */ str_s = DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(PG_GETARG_TEXT_P(0)))); str_t = DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(PG_GETARG_TEXT_P(1)))); @@ -78,10 +78,9 @@ levenshtein(PG_FUNCTION_ARGS) /* * Restrict the length of the strings being compared to something - * reasonable because we will have to perform rows * cols - * calculations. If longer strings need to be compared, increase - * MAX_LEVENSHTEIN_STRLEN to suit (but within your tolerance for speed - * and memory usage). + * reasonable because we will have to perform rows * cols calculations. If + * longer strings need to be compared, increase MAX_LEVENSHTEIN_STRLEN to + * suit (but within your tolerance for speed and memory usage). */ if ((cols > MAX_LEVENSHTEIN_STRLEN + 1) || (rows > MAX_LEVENSHTEIN_STRLEN + 1)) ereport(ERROR, @@ -90,9 +89,9 @@ levenshtein(PG_FUNCTION_ARGS) MAX_LEVENSHTEIN_STRLEN))); /* - * If either rows or cols is 0, the answer is the other value. This - * makes sense since it would take that many insertions the build a - * matching string + * If either rows or cols is 0, the answer is the other value. This makes + * sense since it would take that many insertions the build a matching + * string */ if (cols == 0) @@ -102,9 +101,8 @@ levenshtein(PG_FUNCTION_ARGS) PG_RETURN_INT32(cols); /* - * Allocate two vectors of integers. One will be used for the "upper" - * row, the other for the "lower" row. Initialize the "upper" row to - * 0..cols + * Allocate two vectors of integers. One will be used for the "upper" row, + * the other for the "lower" row. Initialize the "upper" row to 0..cols */ u_cells = palloc(sizeof(int) * cols); for (i = 0; i < cols; i++) @@ -119,14 +117,13 @@ levenshtein(PG_FUNCTION_ARGS) str_s0 = str_s; /* - * Loop through the rows, starting at row 1. Row 0 is used for the - * initial "upper" row. + * Loop through the rows, starting at row 1. Row 0 is used for the initial + * "upper" row. */ for (j = 1; j < rows; j++) { /* - * We'll always start with col 1, and initialize lower row col 0 - * to j + * We'll always start with col 1, and initialize lower row col 0 to j */ l_cells[0] = j; @@ -140,8 +137,7 @@ levenshtein(PG_FUNCTION_ARGS) /* * The "cost" value is 0 if the character at the current col * position in the source string, matches the character at the - * current row position in the target string; cost is 1 - * otherwise. + * current row position in the target string; cost is 1 otherwise. */ c = ((CHAREQ(str_s, str_t)) ? 0 : 1); @@ -172,8 +168,8 @@ levenshtein(PG_FUNCTION_ARGS) } /* - * Lower row now becomes the upper row, and the upper row gets - * reused as the new lower row. + * Lower row now becomes the upper row, and the upper row gets reused + * as the new lower row. */ tmp = u_cells; u_cells = l_cells; @@ -301,8 +297,8 @@ Lookahead(char *word, int how_far) for (idx = 0; word[idx] != '\0' && idx < how_far; idx++); /* Edge forward in the string... */ - letter_ahead = word[idx]; /* idx will be either == to how_far or at - * the end of the string */ + letter_ahead = word[idx]; /* idx will be either == to how_far or at the + * end of the string */ return letter_ahead; } @@ -453,11 +449,11 @@ _metaphone( /* - * THOUGHT: It would be nice if, rather than having things - * like... well, SCI. For SCI you encode the S, then have to - * remember to skip the C. So the phonome SCI invades both S and - * C. It would be better, IMHO, to skip the C from the S part of - * the encoding. Hell, I'm trying it. + * THOUGHT: It would be nice if, rather than having things like... + * well, SCI. For SCI you encode the S, then have to remember to skip + * the C. So the phonome SCI invades both S and C. It would be + * better, IMHO, to skip the C from the S part of the encoding. Hell, + * I'm trying it. */ /* Ignore non-alphas */ @@ -478,9 +474,9 @@ _metaphone( break; /* - * 'sh' if -CIA- or -CH, but not SCH, except SCHW. (SCHW - * is handled in S) S if -CI-, -CE- or -CY- dropped if - * -SCI-, SCE-, -SCY- (handed in S) else K + * 'sh' if -CIA- or -CH, but not SCH, except SCHW. (SCHW is + * handled in S) S if -CI-, -CE- or -CY- dropped if -SCI-, + * SCE-, -SCY- (handed in S) else K */ case 'C': if (MAKESOFT(Next_Letter)) @@ -534,8 +530,8 @@ _metaphone( /* * F if in -GH and not B--GH, D--GH, -H--GH, -H---GH else * dropped if -GNED, -GN, else dropped if -DGE-, -DGI- or - * -DGY- (handled in D) else J if in -GE-, -GI, -GY and - * not GG else K + * -DGY- (handled in D) else J if in -GE-, -GI, -GY and not GG + * else K */ case 'G': if (Next_Letter == 'H') @@ -761,14 +757,17 @@ PG_FUNCTION_INFO_V1(difference); Datum difference(PG_FUNCTION_ARGS) { - char sndx1[SOUNDEX_LEN+1], sndx2[SOUNDEX_LEN+1]; - int i, result; + char sndx1[SOUNDEX_LEN + 1], + sndx2[SOUNDEX_LEN + 1]; + int i, + result; _soundex(_textout(PG_GETARG_TEXT_P(0)), sndx1); _soundex(_textout(PG_GETARG_TEXT_P(1)), sndx2); result = 0; - for (i=0; iitems >= p->lower) { - PGARRAY *pn; + PGARRAY *pn; int n = p->lower * 2; int cbNew = PGARRAY_SIZE(n); @@ -117,9 +117,10 @@ GetPGArray(PGARRAY *p, AggState *aggstate, bool fAdd) * memory allocation context */ static PGARRAY * -ShrinkPGArray(PGARRAY *p) +ShrinkPGArray(PGARRAY * p) { PGARRAY *pnew; + /* get target size */ int cb = PGARRAY_SIZE(p->items); @@ -158,11 +159,11 @@ int_agg_state(PG_FUNCTION_ARGS) if (!PG_ARGISNULL(1)) { - int4 value = PG_GETARG_INT32(1); + int4 value = PG_GETARG_INT32(1); - if (!p) /* internal error */ + if (!p) /* internal error */ elog(ERROR, "no aggregate storage"); - else if (p->items >= p->lower) /* internal error */ + else if (p->items >= p->lower) /* internal error */ elog(ERROR, "aggregate storage too small"); else p->array[p->items++] = value; @@ -212,7 +213,7 @@ int_enum(PG_FUNCTION_ARGS) if (!rsi || !IsA(rsi, ReturnSetInfo)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("int_enum called in context that cannot accept a set"))); + errmsg("int_enum called in context that cannot accept a set"))); if (!p) { @@ -223,7 +224,7 @@ int_enum(PG_FUNCTION_ARGS) if (!fcinfo->flinfo->fn_extra) { /* Allocate working state */ - MemoryContext oldcontext; + MemoryContext oldcontext; oldcontext = MemoryContextSwitchTo(fcinfo->flinfo->fn_mcxt); @@ -250,7 +251,8 @@ int_enum(PG_FUNCTION_ARGS) fcinfo->flinfo->fn_extra = (void *) pc; MemoryContextSwitchTo(oldcontext); } - else /* use existing working state */ + else + /* use existing working state */ pc = (CTX *) fcinfo->flinfo->fn_extra; /* Are we done yet? */ diff --git a/contrib/intarray/_int_gist.c b/contrib/intarray/_int_gist.c index 2d5e82a459..4f777bc40b 100644 --- a/contrib/intarray/_int_gist.c +++ b/contrib/intarray/_int_gist.c @@ -38,8 +38,8 @@ g_int_consistent(PG_FUNCTION_ARGS) if (strategy == BooleanSearchStrategy) PG_RETURN_BOOL(execconsistent((QUERYTYPE *) query, - (ArrayType *) DatumGetPointer(entry->key), - ISLEAFKEY((ArrayType *) DatumGetPointer(entry->key)))); + (ArrayType *) DatumGetPointer(entry->key), + ISLEAFKEY((ArrayType *) DatumGetPointer(entry->key)))); /* XXX are we sure it's safe to scribble on the query object here? */ /* XXX what about toasted input? */ @@ -73,7 +73,7 @@ g_int_consistent(PG_FUNCTION_ARGS) case RTContainedByStrategyNumber: if (GIST_LEAF(entry)) retval = inner_int_contains(query, - (ArrayType *) DatumGetPointer(entry->key)); + (ArrayType *) DatumGetPointer(entry->key)); else retval = inner_int_overlap((ArrayType *) DatumGetPointer(entry->key), query); @@ -134,7 +134,7 @@ g_int_compress(PG_FUNCTION_ARGS) r->flags |= LEAFKEY; retval = palloc(sizeof(GISTENTRY)); gistentryinit(*retval, PointerGetDatum(r), - entry->rel, entry->page, entry->offset, VARSIZE(r), FALSE); + entry->rel, entry->page, entry->offset, VARSIZE(r), FALSE); PG_RETURN_POINTER(retval); } @@ -175,7 +175,7 @@ g_int_compress(PG_FUNCTION_ARGS) r = resize_intArrayType(r, len); retval = palloc(sizeof(GISTENTRY)); gistentryinit(*retval, PointerGetDatum(r), - entry->rel, entry->page, entry->offset, VARSIZE(r), FALSE); + entry->rel, entry->page, entry->offset, VARSIZE(r), FALSE); PG_RETURN_POINTER(retval); } else @@ -211,7 +211,7 @@ g_int_decompress(PG_FUNCTION_ARGS) { retval = palloc(sizeof(GISTENTRY)); gistentryinit(*retval, PointerGetDatum(in), - entry->rel, entry->page, entry->offset, VARSIZE(in), FALSE); + entry->rel, entry->page, entry->offset, VARSIZE(in), FALSE); PG_RETURN_POINTER(retval); } @@ -233,7 +233,7 @@ g_int_decompress(PG_FUNCTION_ARGS) pfree(in); retval = palloc(sizeof(GISTENTRY)); gistentryinit(*retval, PointerGetDatum(r), - entry->rel, entry->page, entry->offset, VARSIZE(r), FALSE); + entry->rel, entry->page, entry->offset, VARSIZE(r), FALSE); PG_RETURN_POINTER(retval); } @@ -378,8 +378,7 @@ g_int_picksplit(PG_FUNCTION_ARGS) pfree(inter_d); /* - * are these a more promising split that what we've already - * seen? + * are these a more promising split that what we've already seen? */ if (size_waste > waste || firsttime) @@ -430,15 +429,15 @@ g_int_picksplit(PG_FUNCTION_ARGS) qsort((void *) costvector, maxoff, sizeof(SPLITCOST), comparecost); /* - * Now split up the regions between the two seeds. An important - * property of this split algorithm is that the split vector v has the - * indices of items to be split in order in its left and right - * vectors. We exploit this property by doing a merge in the code - * that actually splits the page. + * Now split up the regions between the two seeds. An important property + * of this split algorithm is that the split vector v has the indices of + * items to be split in order in its left and right vectors. We exploit + * this property by doing a merge in the code that actually splits the + * page. * - * For efficiency, we also place the new index tuple in this loop. This - * is handled at the very end, when we have placed all the existing - * tuples and i == maxoff + 1. + * For efficiency, we also place the new index tuple in this loop. This is + * handled at the very end, when we have placed all the existing tuples + * and i == maxoff + 1. */ @@ -447,9 +446,9 @@ g_int_picksplit(PG_FUNCTION_ARGS) i = costvector[j].pos; /* - * If we've already decided where to place this item, just put it - * on the right list. Otherwise, we need to figure out which page - * needs the least enlargement in order to store the item. + * If we've already decided where to place this item, just put it on + * the right list. Otherwise, we need to figure out which page needs + * the least enlargement in order to store the item. */ if (i == seed_1) diff --git a/contrib/intarray/_int_op.c b/contrib/intarray/_int_op.c index 9f30bb2173..70951bfd47 100644 --- a/contrib/intarray/_int_op.c +++ b/contrib/intarray/_int_op.c @@ -24,8 +24,8 @@ _int_contained(PG_FUNCTION_ARGS) PG_RETURN_BOOL(DatumGetBool( DirectFunctionCall2( _int_contains, - PointerGetDatum(PG_GETARG_POINTER(1)), - PointerGetDatum(PG_GETARG_POINTER(0)) + PointerGetDatum(PG_GETARG_POINTER(1)), + PointerGetDatum(PG_GETARG_POINTER(0)) ) )); } @@ -54,8 +54,8 @@ _int_different(PG_FUNCTION_ARGS) PG_RETURN_BOOL(!DatumGetBool( DirectFunctionCall2( _int_same, - PointerGetDatum(PG_GETARG_POINTER(0)), - PointerGetDatum(PG_GETARG_POINTER(1)) + PointerGetDatum(PG_GETARG_POINTER(0)), + PointerGetDatum(PG_GETARG_POINTER(1)) ) )); } diff --git a/contrib/intarray/_intbig_gist.c b/contrib/intarray/_intbig_gist.c index 07a051dd50..237281aec5 100644 --- a/contrib/intarray/_intbig_gist.c +++ b/contrib/intarray/_intbig_gist.c @@ -487,7 +487,7 @@ g_intbig_consistent(PG_FUNCTION_ARGS) if (strategy == BooleanSearchStrategy) { PG_RETURN_BOOL(signconsistent((QUERYTYPE *) query, - GETSIGN(DatumGetPointer(entry->key)), + GETSIGN(DatumGetPointer(entry->key)), false)); } diff --git a/contrib/ltree/_ltree_op.c b/contrib/ltree/_ltree_op.c index 3890769ce1..729d19c082 100644 --- a/contrib/ltree/_ltree_op.c +++ b/contrib/ltree/_ltree_op.c @@ -53,7 +53,7 @@ array_iterator(ArrayType *la, PGCALL2 callback, void *param, ltree ** found) while (num > 0) { if (DatumGetBool(DirectFunctionCall2(callback, - PointerGetDatum(item), PointerGetDatum(param)))) + PointerGetDatum(item), PointerGetDatum(param)))) { if (found) diff --git a/contrib/ltree/lquery_op.c b/contrib/ltree/lquery_op.c index 81a1b788aa..54466a5b6b 100644 --- a/contrib/ltree/lquery_op.c +++ b/contrib/ltree/lquery_op.c @@ -101,7 +101,7 @@ checkLevel(lquery_level * curq, ltree_level * curt) else if ( ( curvar->len == curt->len || - (curt->len > curvar->len && (curvar->flag & LVAR_ANYEND)) + (curt->len > curvar->len && (curvar->flag & LVAR_ANYEND)) ) && (*cmpptr) (curvar->name, curt->name, curvar->len) == 0) { @@ -332,7 +332,7 @@ lt_q_regex(PG_FUNCTION_ARGS) while (num > 0) { if (DatumGetBool(DirectFunctionCall2(ltq_regex, - PointerGetDatum(tree), PointerGetDatum(query)))) + PointerGetDatum(tree), PointerGetDatum(query)))) { res = true; diff --git a/contrib/ltree/ltree.h b/contrib/ltree/ltree.h index 2057751cfe..0400db8b77 100644 --- a/contrib/ltree/ltree.h +++ b/contrib/ltree/ltree.h @@ -157,7 +157,7 @@ bool ltree_execute(ITEM * curitem, void *checkval, int ltree_compare(const ltree * a, const ltree * b); bool inner_isparent(const ltree * c, const ltree * p); bool compare_subnode(ltree_level * t, char *q, int len, - int (*cmpptr) (const char *, const char *, size_t), bool anyend); + int (*cmpptr) (const char *, const char *, size_t), bool anyend); ltree *lca_inner(ltree ** a, int len); #define PG_GETARG_LTREE(x) ((ltree*)DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(x)))) diff --git a/contrib/ltree/ltree_gist.c b/contrib/ltree/ltree_gist.c index 693244d9da..7e7ede0285 100644 --- a/contrib/ltree/ltree_gist.c +++ b/contrib/ltree/ltree_gist.c @@ -647,9 +647,9 @@ ltree_consistent(PG_FUNCTION_ARGS) res = (ltree_compare((ltree *) query, LTG_NODE(key)) == 0); else res = ( - ltree_compare((ltree *) query, LTG_GETLNODE(key)) >= 0 + ltree_compare((ltree *) query, LTG_GETLNODE(key)) >= 0 && - ltree_compare((ltree *) query, LTG_GETRNODE(key)) <= 0 + ltree_compare((ltree *) query, LTG_GETRNODE(key)) <= 0 ); break; case BTGreaterEqualStrategyNumber: @@ -677,8 +677,8 @@ ltree_consistent(PG_FUNCTION_ARGS) case 13: if (GIST_LEAF(entry)) res = DatumGetBool(DirectFunctionCall2(ltq_regex, - PointerGetDatum(LTG_NODE(key)), - PointerGetDatum((lquery *) query) + PointerGetDatum(LTG_NODE(key)), + PointerGetDatum((lquery *) query) )); else res = (gist_qe(key, (lquery *) query) && gist_between(key, (lquery *) query)); @@ -687,8 +687,8 @@ ltree_consistent(PG_FUNCTION_ARGS) case 15: if (GIST_LEAF(entry)) res = DatumGetBool(DirectFunctionCall2(ltxtq_exec, - PointerGetDatum(LTG_NODE(key)), - PointerGetDatum((lquery *) query) + PointerGetDatum(LTG_NODE(key)), + PointerGetDatum((lquery *) query) )); else res = gist_qtxt(key, (ltxtquery *) query); @@ -697,8 +697,8 @@ ltree_consistent(PG_FUNCTION_ARGS) case 17: if (GIST_LEAF(entry)) res = DatumGetBool(DirectFunctionCall2(lt_q_regex, - PointerGetDatum(LTG_NODE(key)), - PointerGetDatum((ArrayType *) query) + PointerGetDatum(LTG_NODE(key)), + PointerGetDatum((ArrayType *) query) )); else res = arrq_cons(key, (ArrayType *) query); diff --git a/contrib/ltree/ltree_io.c b/contrib/ltree/ltree_io.c index d0a8c20903..ccc6fc8ff7 100644 --- a/contrib/ltree/ltree_io.c +++ b/contrib/ltree/ltree_io.c @@ -82,7 +82,7 @@ ltree_in(PG_FUNCTION_ARGS) errmsg("name of level is too long"), errdetail("name length is %d, must " \ "be < 256, in position %d", - lptr->len, (int) (lptr->start - buf)))); + lptr->len, (int) (lptr->start - buf)))); totallen += MAXALIGN(lptr->len + LEVEL_HDRSIZE); lptr++; @@ -284,7 +284,7 @@ lquery_in(PG_FUNCTION_ARGS) errmsg("name of level is too long"), errdetail("name length is %d, must " \ "be < 256, in position %d", - lptr->len, (int) (lptr->start - buf)))); + lptr->len, (int) (lptr->start - buf)))); state = LQPRS_WAITVAR; } @@ -300,7 +300,7 @@ lquery_in(PG_FUNCTION_ARGS) errmsg("name of level is too long"), errdetail("name length is %d, must " \ "be < 256, in position %d", - lptr->len, (int) (lptr->start - buf)))); + lptr->len, (int) (lptr->start - buf)))); state = LQPRS_WAITLEVEL; curqlevel = NEXTLEV(curqlevel); diff --git a/contrib/mSQL-interface/mpgsql.c b/contrib/mSQL-interface/mpgsql.c index cd3daba337..1f43f61ea1 100644 --- a/contrib/mSQL-interface/mpgsql.c +++ b/contrib/mSQL-interface/mpgsql.c @@ -264,7 +264,7 @@ msqlListTables(int a) char tbuf[BUFSIZ]; snprintf(tbuf, BUFSIZ, - "select relname from pg_class where relkind='r' and relowner=%d", + "select relname from pg_class where relkind='r' and relowner=%d", geteuid()); if (msqlQuery(a, tbuf) > 0) { @@ -288,7 +288,7 @@ msqlListIndex(int a, char *b, char *c) char tbuf[BUFSIZ]; snprintf(tbuf, BUFSIZ, - "select relname from pg_class where relkind='i' and relowner=%d", + "select relname from pg_class where relkind='i' and relowner=%d", geteuid()); if (msqlQuery(a, tbuf) > 0) { diff --git a/contrib/oid2name/oid2name.c b/contrib/oid2name/oid2name.c index 9bea98b507..069c1708d6 100644 --- a/contrib/oid2name/oid2name.c +++ b/contrib/oid2name/oid2name.c @@ -17,10 +17,10 @@ /* an extensible array to keep track of elements to show */ typedef struct { - char **array; - int num; - int alloc; -} eary; + char **array; + int num; + int alloc; +} eary; /* these are the opts structures for command line params */ struct options @@ -36,19 +36,19 @@ struct options bool extended; bool tablespaces; - char *dbname; - char *hostname; - char *port; - char *username; - char *password; + char *dbname; + char *hostname; + char *port; + char *username; + char *password; }; /* function prototypes */ void get_opts(int, char **, struct options *); void *myalloc(size_t size); char *mystrdup(const char *str); -void add_one_elt(char *eltname, eary *eary); -char *get_comma_elts(eary *eary); +void add_one_elt(char *eltname, eary * eary); +char *get_comma_elts(eary * eary); PGconn *sql_conn(struct options *); int sql_exec(PGconn *, const char *sql, bool quiet); void sql_exec_dumpalldbs(PGconn *, struct options *); @@ -95,7 +95,7 @@ get_opts(int argc, char **argv, struct options * my_opts) add_one_elt(optarg, my_opts->oids); break; - /* specify one filenode to show*/ + /* specify one filenode to show */ case 'f': add_one_elt(optarg, my_opts->filenodes); break; @@ -149,23 +149,23 @@ get_opts(int argc, char **argv, struct options * my_opts) case '?': case 'h': fprintf(stderr, -"Usage: oid2name [-s|-d database] [-S][-i][-q][-x] [-t table|-o oid|-f file] ...\n" -" default action show all database Oids\n" -" -d database database to connect to\n" -" -s show all tablespaces\n" -" -S show system objects too\n" -" -i show indexes and sequences too\n" -" -x extended (show additional columns)\n" -" -q quiet (don't show headers)\n" -" -t show info for table named
\n" -" -o show info for table with Oid \n" -" -f show info for table with filenode \n" -" -H host connect to remote host\n" -" -p port host port to connect to\n" -" -U username username to connect with\n" -" -P password password for username\n" -" (see also $PGPASSWORD and ~/.pgpass)\n" -); + "Usage: oid2name [-s|-d database] [-S][-i][-q][-x] [-t table|-o oid|-f file] ...\n" + " default action show all database Oids\n" + " -d database database to connect to\n" + " -s show all tablespaces\n" + " -S show system objects too\n" + " -i show indexes and sequences too\n" + " -x extended (show additional columns)\n" + " -q quiet (don't show headers)\n" + " -t
show info for table named
\n" + " -o show info for table with Oid \n" + " -f show info for table with filenode \n" + " -H host connect to remote host\n" + " -p port host port to connect to\n" + " -U username username to connect with\n" + " -P password password for username\n" + " (see also $PGPASSWORD and ~/.pgpass)\n" + ); exit(1); break; } @@ -175,7 +175,8 @@ get_opts(int argc, char **argv, struct options * my_opts) void * myalloc(size_t size) { - void *ptr = malloc(size); + void *ptr = malloc(size); + if (!ptr) { fprintf(stderr, "out of memory"); @@ -187,7 +188,8 @@ myalloc(size_t size) char * mystrdup(const char *str) { - char *result = strdup(str); + char *result = strdup(str); + if (!result) { fprintf(stderr, "out of memory"); @@ -202,7 +204,7 @@ mystrdup(const char *str) * Add one element to a (possibly empty) eary struct. */ void -add_one_elt(char *eltname, eary *eary) +add_one_elt(char *eltname, eary * eary) { if (eary->alloc == 0) { @@ -233,11 +235,12 @@ add_one_elt(char *eltname, eary *eary) * SQL statement. */ char * -get_comma_elts(eary *eary) +get_comma_elts(eary * eary) { - char *ret, - *ptr; - int i, length = 0; + char *ret, + *ptr; + int i, + length = 0; if (eary->num == 0) return mystrdup(""); @@ -272,9 +275,9 @@ sql_conn(struct options * my_opts) /* login */ conn = PQsetdbLogin(my_opts->hostname, - my_opts->port, - NULL, /* options */ - NULL, /* tty */ + my_opts->port, + NULL, /* options */ + NULL, /* tty */ my_opts->dbname, my_opts->username, my_opts->password); @@ -303,7 +306,9 @@ sql_exec(PGconn *conn, const char *todo, bool quiet) int nfields; int nrows; - int i, j, l; + int i, + j, + l; int *length; char *pad; @@ -334,7 +339,7 @@ sql_exec(PGconn *conn, const char *todo, bool quiet) { for (j = 0; j < nfields; j++) { - l = strlen(PQgetvalue(res, i, j)); + l = strlen(PQgetvalue(res, i, j)); if (l > length[j]) length[j] = strlen(PQgetvalue(res, i, j)); } @@ -372,36 +377,36 @@ sql_exec(PGconn *conn, const char *todo, bool quiet) } /* - * Dump all databases. There are no system objects to worry about. + * Dump all databases. There are no system objects to worry about. */ void -sql_exec_dumpalldbs(PGconn *conn, struct options *opts) +sql_exec_dumpalldbs(PGconn *conn, struct options * opts) { char todo[1024]; /* get the oid and database name from the system pg_database table */ snprintf(todo, sizeof(todo), "SELECT d.oid AS \"Oid\", datname AS \"Database Name\", " - "spcname AS \"Tablespace\" FROM pg_database d JOIN pg_tablespace t ON " + "spcname AS \"Tablespace\" FROM pg_database d JOIN pg_tablespace t ON " "(dattablespace = t.oid) ORDER BY 2"); sql_exec(conn, todo, opts->quiet); } -/* +/* * Dump all tables, indexes and sequences in the current database. */ void -sql_exec_dumpalltables(PGconn *conn, struct options *opts) +sql_exec_dumpalltables(PGconn *conn, struct options * opts) { char todo[1024]; char *addfields = ",c.oid AS \"Oid\", nspname AS \"Schema\", spcname as \"Tablespace\" "; snprintf(todo, sizeof(todo), - "SELECT relfilenode as \"Filenode\", relname as \"Table Name\" %s " + "SELECT relfilenode as \"Filenode\", relname as \"Table Name\" %s " "FROM pg_class c " - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace " - " LEFT JOIN pg_catalog.pg_database d ON d.datname = current_database()," + " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace " + " LEFT JOIN pg_catalog.pg_database d ON d.datname = current_database()," " pg_catalog.pg_tablespace t " "WHERE relkind IN ('r'%s) AND " " %s" @@ -412,7 +417,7 @@ sql_exec_dumpalltables(PGconn *conn, struct options *opts) "ORDER BY relname", opts->extended ? addfields : "", opts->indexes ? ", 'i', 'S', 't'" : "", - opts->systables ? "" : "n.nspname NOT IN ('pg_catalog', 'pg_toast', 'information_schema') AND"); + opts->systables ? "" : "n.nspname NOT IN ('pg_catalog', 'pg_toast', 'information_schema') AND"); sql_exec(conn, todo, opts->quiet); } @@ -422,11 +427,14 @@ sql_exec_dumpalltables(PGconn *conn, struct options *opts) * given objects in the current database. */ void -sql_exec_searchtables(PGconn *conn, struct options *opts) +sql_exec_searchtables(PGconn *conn, struct options * opts) { char *todo; - char *qualifiers, *ptr; - char *comma_oids, *comma_filenodes, *comma_tables; + char *qualifiers, + *ptr; + char *comma_oids, + *comma_filenodes, + *comma_tables; bool written = false; char *addfields = ",c.oid AS \"Oid\", nspname AS \"Schema\", spcname as \"Tablespace\" "; @@ -465,9 +473,9 @@ sql_exec_searchtables(PGconn *conn, struct options *opts) /* now build the query */ todo = (char *) myalloc(650 + strlen(qualifiers)); snprintf(todo, 650 + strlen(qualifiers), - "SELECT relfilenode as \"Filenode\", relname as \"Table Name\" %s\n" + "SELECT relfilenode as \"Filenode\", relname as \"Table Name\" %s\n" "FROM pg_class c \n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace \n" + " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace \n" " LEFT JOIN pg_catalog.pg_database d ON d.datname = current_database(),\n" " pg_catalog.pg_tablespace t \n" "WHERE relkind IN ('r', 'i', 'S', 't') AND \n" @@ -486,9 +494,9 @@ sql_exec_searchtables(PGconn *conn, struct options *opts) } void -sql_exec_dumpalltbspc(PGconn *conn, struct options *opts) +sql_exec_dumpalltbspc(PGconn *conn, struct options * opts) { - char todo[1024]; + char todo[1024]; snprintf(todo, sizeof(todo), "SELECT oid AS \"Oid\", spcname as \"Tablespace Name\"\n" diff --git a/contrib/pg_buffercache/pg_buffercache_pages.c b/contrib/pg_buffercache/pg_buffercache_pages.c index e511c0df9a..a0ae43f77d 100644 --- a/contrib/pg_buffercache/pg_buffercache_pages.c +++ b/contrib/pg_buffercache/pg_buffercache_pages.c @@ -1,9 +1,9 @@ /*------------------------------------------------------------------------- * * pg_buffercache_pages.c - * display some contents of the buffer cache + * display some contents of the buffer cache * - * $PostgreSQL: pgsql/contrib/pg_buffercache/pg_buffercache_pages.c,v 1.5 2005/10/12 16:45:13 tgl Exp $ + * $PostgreSQL: pgsql/contrib/pg_buffercache/pg_buffercache_pages.c,v 1.6 2005/10/15 02:49:05 momjian Exp $ *------------------------------------------------------------------------- */ #include "postgres.h" @@ -17,11 +17,11 @@ #define NUM_BUFFERCACHE_PAGES_ELEM 6 #if defined(WIN32) || defined(__CYGWIN__) -extern DLLIMPORT BufferDesc *BufferDescriptors; -extern DLLIMPORT volatile uint32 InterruptHoldoffCount; +extern DLLIMPORT BufferDesc *BufferDescriptors; +extern DLLIMPORT volatile uint32 InterruptHoldoffCount; #endif -Datum pg_buffercache_pages(PG_FUNCTION_ARGS); +Datum pg_buffercache_pages(PG_FUNCTION_ARGS); /* @@ -34,24 +34,24 @@ typedef struct Oid relfilenode; Oid reltablespace; Oid reldatabase; - BlockNumber blocknum; + BlockNumber blocknum; bool isvalid; bool isdirty; -} BufferCachePagesRec; +} BufferCachePagesRec; /* * Function context for data persisting over repeated calls. */ -typedef struct +typedef struct { - AttInMetadata *attinmeta; - BufferCachePagesRec *record; - char *values[NUM_BUFFERCACHE_PAGES_ELEM]; + AttInMetadata *attinmeta; + BufferCachePagesRec *record; + char *values[NUM_BUFFERCACHE_PAGES_ELEM]; -} BufferCachePagesContext; +} BufferCachePagesContext; /* @@ -63,44 +63,44 @@ Datum pg_buffercache_pages(PG_FUNCTION_ARGS) { - FuncCallContext *funcctx; - Datum result; - MemoryContext oldcontext; - BufferCachePagesContext *fctx; /* User function context. */ - TupleDesc tupledesc; - HeapTuple tuple; + FuncCallContext *funcctx; + Datum result; + MemoryContext oldcontext; + BufferCachePagesContext *fctx; /* User function context. */ + TupleDesc tupledesc; + HeapTuple tuple; if (SRF_IS_FIRSTCALL()) { uint32 i; - volatile BufferDesc *bufHdr; + volatile BufferDesc *bufHdr; funcctx = SRF_FIRSTCALL_INIT(); /* Switch context when allocating stuff to be used in later calls */ oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); - + /* Construct a tuple to return. */ tupledesc = CreateTemplateTupleDesc(NUM_BUFFERCACHE_PAGES_ELEM, false); TupleDescInitEntry(tupledesc, (AttrNumber) 1, "bufferid", - INT4OID, -1, 0); + INT4OID, -1, 0); TupleDescInitEntry(tupledesc, (AttrNumber) 2, "relfilenode", - OIDOID, -1, 0); + OIDOID, -1, 0); TupleDescInitEntry(tupledesc, (AttrNumber) 3, "reltablespace", - OIDOID, -1, 0); + OIDOID, -1, 0); TupleDescInitEntry(tupledesc, (AttrNumber) 4, "reldatabase", - OIDOID, -1, 0); + OIDOID, -1, 0); TupleDescInitEntry(tupledesc, (AttrNumber) 5, "relblocknumber", - INT8OID, -1, 0); + INT8OID, -1, 0); TupleDescInitEntry(tupledesc, (AttrNumber) 6, "isdirty", - BOOLOID, -1, 0); + BOOLOID, -1, 0); /* Generate attribute metadata needed later to produce tuples */ funcctx->attinmeta = TupleDescGetAttInMetadata(tupledesc); - /* - * Create a function context for cross-call persistence - * and initialize the buffer counters. + /* + * Create a function context for cross-call persistence and initialize + * the buffer counters. */ fctx = (BufferCachePagesContext *) palloc(sizeof(BufferCachePagesContext)); funcctx->max_calls = NBuffers; @@ -118,12 +118,12 @@ pg_buffercache_pages(PG_FUNCTION_ARGS) fctx->values[4] = (char *) palloc(3 * sizeof(uint32) + 1); fctx->values[5] = (char *) palloc(2); - + /* Return to original context when allocating transient memory */ MemoryContextSwitchTo(oldcontext); - /* + /* * Lock Buffer map and scan though all the buffers, saving the * relevant fields in the fctx->record structure. */ @@ -140,7 +140,7 @@ pg_buffercache_pages(PG_FUNCTION_ARGS) fctx->record[i].reldatabase = bufHdr->tag.rnode.dbNode; fctx->record[i].blocknum = bufHdr->tag.blockNum; - if (bufHdr->flags & BM_DIRTY) + if (bufHdr->flags & BM_DIRTY) fctx->record[i].isdirty = true; else fctx->record[i].isdirty = false; @@ -159,34 +159,34 @@ pg_buffercache_pages(PG_FUNCTION_ARGS) } funcctx = SRF_PERCALL_SETUP(); - + /* Get the saved state */ fctx = funcctx->user_fctx; if (funcctx->call_cntr < funcctx->max_calls) { - uint32 i = funcctx->call_cntr; - char *values[NUM_BUFFERCACHE_PAGES_ELEM]; + uint32 i = funcctx->call_cntr; + char *values[NUM_BUFFERCACHE_PAGES_ELEM]; int j; - - /* - * Use a temporary values array, initially pointing to - * fctx->values, so it can be reassigned w/o losing the storage - * for subsequent calls. + + /* + * Use a temporary values array, initially pointing to fctx->values, + * so it can be reassigned w/o losing the storage for subsequent + * calls. */ for (j = 0; j < NUM_BUFFERCACHE_PAGES_ELEM; j++) { values[j] = fctx->values[j]; } - + /* - * Set all fields except the bufferid to null if the buffer is - * unused or not valid. + * Set all fields except the bufferid to null if the buffer is unused + * or not valid. */ if (fctx->record[i].blocknum == InvalidBlockNumber || - fctx->record[i].isvalid == false ) + fctx->record[i].isvalid == false) { sprintf(values[0], "%u", fctx->record[i].bufferid); @@ -205,7 +205,7 @@ pg_buffercache_pages(PG_FUNCTION_ARGS) sprintf(values[2], "%u", fctx->record[i].reltablespace); sprintf(values[3], "%u", fctx->record[i].reldatabase); sprintf(values[4], "%u", fctx->record[i].blocknum); - if (fctx->record[i].isdirty) + if (fctx->record[i].isdirty) { strcpy(values[5], "t"); } @@ -213,7 +213,7 @@ pg_buffercache_pages(PG_FUNCTION_ARGS) { strcpy(values[5], "f"); } - + } @@ -228,4 +228,3 @@ pg_buffercache_pages(PG_FUNCTION_ARGS) SRF_RETURN_DONE(funcctx); } - diff --git a/contrib/pg_trgm/trgm_op.c b/contrib/pg_trgm/trgm_op.c index 57fb944a56..407b317f28 100644 --- a/contrib/pg_trgm/trgm_op.c +++ b/contrib/pg_trgm/trgm_op.c @@ -300,8 +300,8 @@ similarity_op(PG_FUNCTION_ARGS) { float4 res = DatumGetFloat4(DirectFunctionCall2( similarity, - PG_GETARG_DATUM(0), - PG_GETARG_DATUM(1) + PG_GETARG_DATUM(0), + PG_GETARG_DATUM(1) )); PG_RETURN_BOOL(res >= trgm_limit); diff --git a/contrib/pgbench/pgbench.c b/contrib/pgbench/pgbench.c index 1b3d6bb09e..4ec056b343 100644 --- a/contrib/pgbench/pgbench.c +++ b/contrib/pgbench/pgbench.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.42 2005/10/07 15:34:17 tgl Exp $ + * $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.43 2005/10/15 02:49:06 momjian Exp $ * * pgbench: a simple benchmark program for PostgreSQL * written by Tatsuo Ishii @@ -55,8 +55,7 @@ extern int optind; #define MAXCLIENTS 1024 /* max number of clients allowed */ int nclients = 1; /* default number of simulated clients */ -int nxacts = 10; /* default number of transactions per - * clients */ +int nxacts = 10; /* default number of transactions per clients */ /* * scaling factor. for example, tps = 10 will make 1000000 tuples of @@ -78,8 +77,7 @@ bool use_log; /* log transaction latencies to a file */ int remains; /* number of remaining clients */ -int is_connect; /* establish connection for each - * transaction */ +int is_connect; /* establish connection for each transaction */ char *pghost = ""; char *pgport = NULL; @@ -92,8 +90,8 @@ char *dbName; /* variable definitions */ typedef struct { - char *name; /* variable name */ - char *value; /* its value */ + char *name; /* variable name */ + char *value; /* its value */ } Variable; /* @@ -107,8 +105,8 @@ typedef struct int state; /* state No. */ int cnt; /* xacts count */ int ecnt; /* error count */ - int listen; /* 0 indicates that an async query has - * been sent */ + int listen; /* 0 indicates that an async query has been + * sent */ Variable *variables; /* array of variable definitions */ int nvariables; struct timeval txn_begin; /* used for measuring latencies */ @@ -124,48 +122,48 @@ typedef struct typedef struct { - int type; /* command type (SQL_COMMAND or META_COMMAND) */ - int argc; /* number of commands */ - char *argv[MAX_ARGS]; /* command list */ + int type; /* command type (SQL_COMMAND or META_COMMAND) */ + int argc; /* number of commands */ + char *argv[MAX_ARGS]; /* command list */ } Command; #define MAX_FILES 128 /* max number of SQL script files allowed */ -Command **sql_files[MAX_FILES]; /* SQL script files */ -int num_files; /* its number */ +Command **sql_files[MAX_FILES]; /* SQL script files */ +int num_files; /* its number */ /* default scenario */ static char *tpc_b = { -"\\setrandom aid 1 100000\n" -"\\setrandom bid 1 1\n" -"\\setrandom tid 1 10\n" -"\\setrandom delta 1 10000\n" -"BEGIN;\n" -"UPDATE accounts SET abalance = abalance + :delta WHERE aid = :aid;\n" -"SELECT abalance FROM accounts WHERE aid = :aid;\n" -"UPDATE tellers SET tbalance = tbalance + :delta WHERE tid = :tid;\n" -"UPDATE branches SET bbalance = bbalance + :delta WHERE bid = :bid;\n" -"INSERT INTO history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);\n" -"END;\n" + "\\setrandom aid 1 100000\n" + "\\setrandom bid 1 1\n" + "\\setrandom tid 1 10\n" + "\\setrandom delta 1 10000\n" + "BEGIN;\n" + "UPDATE accounts SET abalance = abalance + :delta WHERE aid = :aid;\n" + "SELECT abalance FROM accounts WHERE aid = :aid;\n" + "UPDATE tellers SET tbalance = tbalance + :delta WHERE tid = :tid;\n" + "UPDATE branches SET bbalance = bbalance + :delta WHERE bid = :bid;\n" + "INSERT INTO history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);\n" + "END;\n" }; /* -N case */ static char *simple_update = { -"\\setrandom aid 1 100000\n" -"\\setrandom bid 1 1\n" -"\\setrandom tid 1 10\n" -"\\setrandom delta 1 10000\n" -"BEGIN;\n" -"UPDATE accounts SET abalance = abalance + :delta WHERE aid = :aid;\n" -"SELECT abalance FROM accounts WHERE aid = :aid;\n" -"INSERT INTO history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);\n" -"END;\n" + "\\setrandom aid 1 100000\n" + "\\setrandom bid 1 1\n" + "\\setrandom tid 1 10\n" + "\\setrandom delta 1 10000\n" + "BEGIN;\n" + "UPDATE accounts SET abalance = abalance + :delta WHERE aid = :aid;\n" + "SELECT abalance FROM accounts WHERE aid = :aid;\n" + "INSERT INTO history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);\n" + "END;\n" }; /* -S case */ static char *select_only = { -"\\setrandom aid 1 100000\n" -"SELECT abalance FROM accounts WHERE aid = :aid;\n" + "\\setrandom aid 1 100000\n" + "SELECT abalance FROM accounts WHERE aid = :aid;\n" }; static void @@ -262,7 +260,7 @@ compareVariables(const void *v1, const void *v2) static char * getVariable(CState * st, char *name) { - Variable key = { name }, *var; + Variable key = {name}, *var; /* On some versions of Solaris, bsearch of zero items dumps core */ if (st->nvariables <= 0) @@ -282,7 +280,7 @@ getVariable(CState * st, char *name) static int putVariable(CState * st, char *name, char *value) { - Variable key = { name }, *var; + Variable key = {name}, *var; /* On some versions of Solaris, bsearch of zero items dumps core */ if (st->nvariables > 0) @@ -300,7 +298,7 @@ putVariable(CState * st, char *name, char *value) if (st->variables) newvars = (Variable *) realloc(st->variables, - (st->nvariables + 1) * sizeof(Variable)); + (st->nvariables + 1) * sizeof(Variable)); else newvars = (Variable *) malloc(sizeof(Variable)); @@ -341,15 +339,19 @@ putVariable(CState * st, char *name, char *value) static char * assignVariables(CState * st, char *sql) { - int i, j; - char *p, *name, *val; + int i, + j; + char *p, + *name, + *val; void *tmp; i = 0; while ((p = strchr(&sql[i], ':')) != NULL) { i = j = p - sql; - do { + do + { i++; } while (isalnum((unsigned char) sql[i]) || sql[i] == '_'); if (i == j + 1) @@ -403,7 +405,7 @@ doCustom(CState * state, int n, int debug) { PGresult *res; CState *st = &state[n]; - Command **commands; + Command **commands; commands = sql_files[st->use_file]; @@ -414,20 +416,19 @@ doCustom(CState * state, int n, int debug) if (debug) fprintf(stderr, "client %d receiving\n", n); if (!PQconsumeInput(st->con)) - { /* there's something wrong */ + { /* there's something wrong */ fprintf(stderr, "Client %d aborted in state %d. Probably the backend died while processing.\n", n, st->state); - remains--; /* I've aborted */ + remains--; /* I've aborted */ PQfinish(st->con); st->con = NULL; return; } if (PQisBusy(st->con)) - return; /* don't have the whole result yet */ + return; /* don't have the whole result yet */ } /* - * transaction finished: record the time it took in the - * log + * transaction finished: record the time it took in the log */ if (use_log && commands[st->state + 1] == NULL) { @@ -468,7 +469,7 @@ doCustom(CState * state, int n, int debug) if (++st->cnt >= nxacts) { - remains--; /* I've done */ + remains--; /* I've done */ if (st->con != NULL) { PQfinish(st->con); @@ -483,7 +484,7 @@ doCustom(CState * state, int n, int debug) if (commands[st->state] == NULL) { st->state = 0; - st->use_file = getrand(0, num_files-1); + st->use_file = getrand(0, num_files - 1); } } @@ -525,13 +526,14 @@ doCustom(CState * state, int n, int debug) } else { - st->listen = 1; /* flags that should be listened */ + st->listen = 1; /* flags that should be listened */ } free(sql); } else if (commands[st->state]->type == META_COMMAND) { - int argc = commands[st->state]->argc, i; + int argc = commands[st->state]->argc, + i; char **argv = commands[st->state]->argv; if (debug) @@ -748,28 +750,29 @@ init(void) PQfinish(con); } -static Command* +static Command * process_commands(char *buf) { const char delim[] = " \f\n\r\t\v"; - Command *my_commands; + Command *my_commands; int j; - char *p, *tok; + char *p, + *tok; if ((p = strchr(buf, '\n')) != NULL) - *p = '\0'; + *p = '\0'; p = buf; while (isspace((unsigned char) *p)) - p++; + p++; if (*p == '\0' || strncmp(p, "--", 2) == 0) { return NULL; } - my_commands = (Command *)malloc(sizeof(Command)); + my_commands = (Command *) malloc(sizeof(Command)); if (my_commands == NULL) { return NULL; @@ -794,10 +797,11 @@ process_commands(char *buf) j++; tok = strtok(NULL, delim); } - + if (strcasecmp(my_commands->argv[0], "setrandom") == 0) { - int min, max; + int min, + max; if (my_commands->argc < 4) { @@ -806,8 +810,8 @@ process_commands(char *buf) } for (j = 4; j < my_commands->argc; j++) - fprintf(stderr, "%s: extra argument \"%s\" ignored\n", - my_commands->argv[0], my_commands->argv[j]); + fprintf(stderr, "%s: extra argument \"%s\" ignored\n", + my_commands->argv[0], my_commands->argv[j]); if ((min = atoi(my_commands->argv[2])) < 0) { @@ -825,7 +829,7 @@ process_commands(char *buf) } else { - fprintf(stderr, "invalid command %s\n", my_commands->argv[0]); + fprintf(stderr, "invalid command %s\n", my_commands->argv[0]); return NULL; } } @@ -847,11 +851,11 @@ process_file(char *filename) { #define COMMANDS_ALLOC_NUM 128 - Command **my_commands; + Command **my_commands; FILE *fd; int lineno; char buf[BUFSIZ]; - int alloc_num; + int alloc_num; if (num_files >= MAX_FILES) { @@ -860,7 +864,7 @@ process_file(char *filename) } alloc_num = COMMANDS_ALLOC_NUM; - my_commands = (Command **)malloc(sizeof(Command **)*alloc_num); + my_commands = (Command **) malloc(sizeof(Command **) * alloc_num); if (my_commands == NULL) return false; @@ -876,7 +880,7 @@ process_file(char *filename) while (fgets(buf, sizeof(buf), fd) != NULL) { - Command *commands; + Command *commands; commands = process_commands(buf); if (commands == NULL) @@ -913,25 +917,25 @@ process_builtin(char *tb) { #define COMMANDS_ALLOC_NUM 128 - Command **my_commands; + Command **my_commands; int lineno; char buf[BUFSIZ]; - int alloc_num; + int alloc_num; if (*tb == '\0') return NULL; alloc_num = COMMANDS_ALLOC_NUM; - my_commands = malloc(sizeof(Command **)*alloc_num); + my_commands = malloc(sizeof(Command **) * alloc_num); if (my_commands == NULL) return NULL; lineno = 0; - for(;;) + for (;;) { - char *p; - Command *commands; + char *p; + Command *commands; p = buf; while (*tb && *tb != '\n') @@ -1016,20 +1020,18 @@ main(int argc, char **argv) { int c; int is_init_mode = 0; /* initialize mode? */ - int is_no_vacuum = 0; /* no vacuum at all before - * testing? */ + int is_no_vacuum = 0; /* no vacuum at all before testing? */ int is_full_vacuum = 0; /* do full vacuum before testing? */ int debug = 0; /* debug flag */ - int ttype = 0; /* transaction type. 0: TPC-B, 1: SELECT - * only, 2: skip update of branches and - * tellers */ + int ttype = 0; /* transaction type. 0: TPC-B, 1: SELECT only, + * 2: skip update of branches and tellers */ char *filename = NULL; static CState *state; /* status of clients */ struct timeval tv1; /* start up time */ - struct timeval tv2; /* after establishing all connections to - * the backend */ + struct timeval tv2; /* after establishing all connections to the + * backend */ struct timeval tv3; /* end time */ int i; @@ -1105,7 +1107,8 @@ main(int argc, char **argv) fprintf(stderr, "Use limit/ulimt to increase the limit before using pgbench.\n"); exit(1); } -#endif /* #if !(defined(__CYGWIN__) || defined(__MINGW32__)) */ +#endif /* #if !(defined(__CYGWIN__) || + * defined(__MINGW32__)) */ break; case 'C': is_connect = 1; @@ -1305,35 +1308,35 @@ main(int argc, char **argv) /* process bultin SQL scripts */ switch (ttype) { - char buf[128]; + char buf[128]; case 0: sql_files[0] = process_builtin(tpc_b); - snprintf(buf, sizeof(buf), "%d", 100000*tps); + snprintf(buf, sizeof(buf), "%d", 100000 * tps); sql_files[0][0]->argv[3] = strdup(buf); - snprintf(buf, sizeof(buf), "%d", 1*tps); + snprintf(buf, sizeof(buf), "%d", 1 * tps); sql_files[0][1]->argv[3] = strdup(buf); - snprintf(buf, sizeof(buf), "%d", 10*tps); + snprintf(buf, sizeof(buf), "%d", 10 * tps); sql_files[0][2]->argv[3] = strdup(buf); - snprintf(buf, sizeof(buf), "%d", 10000*tps); + snprintf(buf, sizeof(buf), "%d", 10000 * tps); sql_files[0][3]->argv[3] = strdup(buf); num_files = 1; break; case 1: sql_files[0] = process_builtin(select_only); - snprintf(buf, sizeof(buf), "%d", 100000*tps); + snprintf(buf, sizeof(buf), "%d", 100000 * tps); sql_files[0][0]->argv[3] = strdup(buf); num_files = 1; break; case 2: sql_files[0] = process_builtin(simple_update); - snprintf(buf, sizeof(buf), "%d", 100000*tps); + snprintf(buf, sizeof(buf), "%d", 100000 * tps); sql_files[0][0]->argv[3] = strdup(buf); - snprintf(buf, sizeof(buf), "%d", 1*tps); + snprintf(buf, sizeof(buf), "%d", 1 * tps); sql_files[0][1]->argv[3] = strdup(buf); - snprintf(buf, sizeof(buf), "%d", 10*tps); + snprintf(buf, sizeof(buf), "%d", 10 * tps); sql_files[0][2]->argv[3] = strdup(buf); - snprintf(buf, sizeof(buf), "%d", 10000*tps); + snprintf(buf, sizeof(buf), "%d", 10000 * tps); sql_files[0][3]->argv[3] = strdup(buf); num_files = 1; break; @@ -1344,7 +1347,7 @@ main(int argc, char **argv) /* send start up queries in async manner */ for (i = 0; i < nclients; i++) { - state[i].use_file = getrand(0, num_files-1); + state[i].use_file = getrand(0, num_files - 1); doCustom(state, i, debug); } @@ -1366,9 +1369,9 @@ main(int argc, char **argv) maxsock = -1; for (i = 0; i < nclients; i++) { - Command **commands = sql_files[state[i].use_file]; + Command **commands = sql_files[state[i].use_file]; - if (state[i].con && commands[state[i].state]->type != META_COMMAND) + if (state[i].con && commands[state[i].state]->type != META_COMMAND) { int sock = PQsocket(state[i].con); @@ -1396,7 +1399,7 @@ main(int argc, char **argv) exit(1); } else if (nsocks == 0) - { /* timeout */ + { /* timeout */ fprintf(stderr, "select timeout\n"); for (i = 0; i < nclients; i++) { @@ -1410,10 +1413,10 @@ main(int argc, char **argv) /* ok, backend returns reply */ for (i = 0; i < nclients; i++) { - Command **commands = sql_files[state[i].use_file]; + Command **commands = sql_files[state[i].use_file]; if (state[i].con && (FD_ISSET(PQsocket(state[i].con), &input_mask) - || commands[state[i].state]->type == META_COMMAND)) + || commands[state[i].state]->type == META_COMMAND)) { doCustom(state, i, debug); } diff --git a/contrib/pgcrypto/crypt-blowfish.c b/contrib/pgcrypto/crypt-blowfish.c index a882cf4c87..42a694b62f 100644 --- a/contrib/pgcrypto/crypt-blowfish.c +++ b/contrib/pgcrypto/crypt-blowfish.c @@ -520,7 +520,6 @@ extern void _BF_body_r(BF_ctx * ctx); #define BF_body() \ _BF_body_r(&data.ctx); - #else #define BF_body() \ @@ -712,7 +711,7 @@ _crypt_blowfish_rn(const char *key, const char *setting, memcpy(output, setting, 7 + 22 - 1); output[7 + 22 - 1] = BF_itoa64[(int) - BF_atoi64[(int) setting[7 + 22 - 1] - 0x20] & 0x30]; + BF_atoi64[(int) setting[7 + 22 - 1] - 0x20] & 0x30]; /* This has to be bug-compatible with the original implementation, so * only encode 23 of the 24 bytes. :-) */ diff --git a/contrib/pgcrypto/crypt-des.c b/contrib/pgcrypto/crypt-des.c index 74768e73a7..6ed7188f4a 100644 --- a/contrib/pgcrypto/crypt-des.c +++ b/contrib/pgcrypto/crypt-des.c @@ -246,8 +246,8 @@ des_init(void) } /* - * Convert the inverted S-boxes into 4 arrays of 8 bits. Each will - * handle 12 bits of the S-box input. + * Convert the inverted S-boxes into 4 arrays of 8 bits. Each will handle + * 12 bits of the S-box input. */ for (b = 0; b < 4; b++) for (i = 0; i < 64; i++) @@ -267,8 +267,8 @@ des_init(void) } /* - * Invert the key permutation and initialise the inverted key - * compression permutation. + * Invert the key permutation and initialise the inverted key compression + * permutation. */ for (i = 0; i < 56; i++) { @@ -284,8 +284,8 @@ des_init(void) inv_comp_perm[comp_perm[i] - 1] = i; /* - * Set up the OR-mask arrays for the initial and final permutations, - * and for the key initial and compression permutations. + * Set up the OR-mask arrays for the initial and final permutations, and + * for the key initial and compression permutations. */ for (k = 0; k < 8; k++) { @@ -347,8 +347,8 @@ des_init(void) } /* - * Invert the P-box permutation, and convert into OR-masks for - * handling the output of the S-box arrays setup above. + * Invert the P-box permutation, and convert into OR-masks for handling + * the output of the S-box arrays setup above. */ for (i = 0; i < 32; i++) un_pbox[pbox[i] - 1] = i; @@ -411,9 +411,9 @@ des_setkey(const char *key) && rawkey1 == old_rawkey1) { /* - * Already setup for this key. This optimisation fails on a zero - * key (which is weak and has bad parity anyway) in order to - * simplify the starting conditions. + * Already setup for this key. This optimisation fails on a zero key + * (which is weak and has bad parity anyway) in order to simplify the + * starting conditions. */ return (0); } @@ -560,16 +560,16 @@ do_des(uint32 l_in, uint32 r_in, uint32 *l_out, uint32 *r_out, int count) | ((r & 0x80000000) >> 31); /* - * Do salting for crypt() and friends, and XOR with the - * permuted key. + * Do salting for crypt() and friends, and XOR with the permuted + * key. */ f = (r48l ^ r48r) & saltbits; r48l ^= f ^ *kl++; r48r ^= f ^ *kr++; /* - * Do sbox lookups (which shrink it back to 32 bits) and do - * the pbox permutation at the same time. + * Do sbox lookups (which shrink it back to 32 bits) and do the + * pbox permutation at the same time. */ f = psbox[0][m_sbox[0][r48l >> 12]] | psbox[1][m_sbox[1][r48l & 0xfff]] @@ -660,8 +660,8 @@ px_crypt_des(const char *key, const char *setting) /* - * Copy the key, shifting each character up by one bit and padding - * with zeros. + * Copy the key, shifting each character up by one bit and padding with + * zeros. */ q = (uint8 *) keybuf; while (q - (uint8 *) keybuf - 8) @@ -706,10 +706,10 @@ px_crypt_des(const char *key, const char *setting) strncpy(output, setting, 9); /* - * Double check that we weren't given a short setting. If we were, - * the above code will probably have created wierd values for - * count and salt, but we don't really care. Just make sure the - * output string doesn't have an extra NUL in it. + * Double check that we weren't given a short setting. If we were, the + * above code will probably have created wierd values for count and + * salt, but we don't really care. Just make sure the output string + * doesn't have an extra NUL in it. */ output[9] = '\0'; p = output + strlen(output); @@ -728,9 +728,9 @@ px_crypt_des(const char *key, const char *setting) output[0] = setting[0]; /* - * If the encrypted password that the salt was extracted from is - * only 1 character long, the salt will be corrupted. We need to - * ensure that the output string doesn't have an extra NUL in it! + * If the encrypted password that the salt was extracted from is only + * 1 character long, the salt will be corrupted. We need to ensure + * that the output string doesn't have an extra NUL in it! */ output[1] = setting[1] ? setting[1] : output[0]; diff --git a/contrib/pgcrypto/crypt-gensalt.c b/contrib/pgcrypto/crypt-gensalt.c index 8713b99a16..656ab03ef7 100644 --- a/contrib/pgcrypto/crypt-gensalt.c +++ b/contrib/pgcrypto/crypt-gensalt.c @@ -22,7 +22,7 @@ unsigned char _crypt_itoa64[64 + 1] = char * _crypt_gensalt_traditional_rn(unsigned long count, - const char *input, int size, char *output, int output_size) + const char *input, int size, char *output, int output_size) { if (size < 2 || output_size < 2 + 1 || (count && count != 25)) { @@ -40,7 +40,7 @@ _crypt_gensalt_traditional_rn(unsigned long count, char * _crypt_gensalt_extended_rn(unsigned long count, - const char *input, int size, char *output, int output_size) + const char *input, int size, char *output, int output_size) { unsigned long value; @@ -76,7 +76,7 @@ _crypt_gensalt_extended_rn(unsigned long count, char * _crypt_gensalt_md5_rn(unsigned long count, - const char *input, int size, char *output, int output_size) + const char *input, int size, char *output, int output_size) { unsigned long value; @@ -158,7 +158,7 @@ BF_encode(char *dst, const BF_word * src, int size) char * _crypt_gensalt_blowfish_rn(unsigned long count, - const char *input, int size, char *output, int output_size) + const char *input, int size, char *output, int output_size) { if (size < 16 || output_size < 7 + 22 + 1 || (count && (count < 4 || count > 31))) diff --git a/contrib/pgcrypto/crypt-md5.c b/contrib/pgcrypto/crypt-md5.c index dceb599775..a9f22c412a 100644 --- a/contrib/pgcrypto/crypt-md5.c +++ b/contrib/pgcrypto/crypt-md5.c @@ -8,7 +8,7 @@ * * $FreeBSD: src/lib/libcrypt/crypt-md5.c,v 1.5 1999/12/17 20:21:45 peter Exp $ * - * $PostgreSQL: pgsql/contrib/pgcrypto/crypt-md5.c,v 1.5 2005/09/24 19:14:04 tgl Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/crypt-md5.c,v 1.6 2005/10/15 02:49:06 momjian Exp $ */ #include "postgres.h" @@ -24,9 +24,9 @@ char * px_crypt_md5(const char *pw, const char *salt, char *passwd, unsigned dstlen) { - static char *magic = "$1$"; /* This string is magic for this - * algorithm. Having it this way, we can - * get get better later on */ + static char *magic = "$1$"; /* This string is magic for this algorithm. + * Having it this way, we can get get better + * later on */ static char *p; static const char *sp, *ep; diff --git a/contrib/pgcrypto/fortuna.c b/contrib/pgcrypto/fortuna.c index 4645076109..1b13337301 100644 --- a/contrib/pgcrypto/fortuna.c +++ b/contrib/pgcrypto/fortuna.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/fortuna.c,v 1.4 2005/07/18 17:12:54 tgl Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/fortuna.c,v 1.5 2005/10/15 02:49:06 momjian Exp $ */ #include "postgres.h" @@ -43,16 +43,16 @@ * Why Fortuna-like: There does not seem to be any definitive reference * on Fortuna in the net. Instead this implementation is based on * following references: - * + * * http://en.wikipedia.org/wiki/Fortuna_(PRNG) - * - Wikipedia article + * - Wikipedia article * http://jlcooke.ca/random/ - * - Jean-Luc Cooke Fortuna-based /dev/random driver for Linux. + * - Jean-Luc Cooke Fortuna-based /dev/random driver for Linux. */ /* * There is some confusion about whether and how to carry forward - * the state of the pools. Seems like original Fortuna does not + * the state of the pools. Seems like original Fortuna does not * do it, resetting hash after each request. I guess expecting * feeding to happen more often that requesting. This is absolutely * unsuitable for pgcrypto, as nothing asynchronous happens here. @@ -76,7 +76,7 @@ * How many pools. * * Original Fortuna uses 32 pools, that means 32'th pool is - * used not earlier than in 13th year. This is a waste in + * used not earlier than in 13th year. This is a waste in * pgcrypto, as we have very low-frequancy seeding. Here * is preferable to have all entropy usable in reasonable time. * @@ -89,12 +89,12 @@ #define NUM_POOLS 23 /* in microseconds */ -#define RESEED_INTERVAL 100000 /* 0.1 sec */ +#define RESEED_INTERVAL 100000 /* 0.1 sec */ /* for one big request, reseed after this many bytes */ #define RESEED_BYTES (1024*1024) -/* +/* * Skip reseed if pool 0 has less than this many * bytes added since last reseed. */ @@ -114,17 +114,18 @@ #define MD_CTX SHA256_CTX #define CIPH_CTX rijndael_ctx -struct fortuna_state { - uint8 counter[CIPH_BLOCK]; - uint8 result[CIPH_BLOCK]; - uint8 key[BLOCK]; - MD_CTX pool[NUM_POOLS]; - CIPH_CTX ciph; - unsigned reseed_count; - struct timeval last_reseed_time; - unsigned pool0_bytes; - unsigned rnd_pos; - int counter_init; +struct fortuna_state +{ + uint8 counter[CIPH_BLOCK]; + uint8 result[CIPH_BLOCK]; + uint8 key[BLOCK]; + MD_CTX pool[NUM_POOLS]; + CIPH_CTX ciph; + unsigned reseed_count; + struct timeval last_reseed_time; + unsigned pool0_bytes; + unsigned rnd_pos; + int counter_init; }; typedef struct fortuna_state FState; @@ -137,29 +138,35 @@ typedef struct fortuna_state FState; * - No memory allocations. */ -static void ciph_init(CIPH_CTX *ctx, const uint8 *key, int klen) +static void +ciph_init(CIPH_CTX * ctx, const uint8 *key, int klen) { - rijndael_set_key(ctx, (const uint32 *)key, klen, 1); + rijndael_set_key(ctx, (const uint32 *) key, klen, 1); } -static void ciph_encrypt(CIPH_CTX *ctx, const uint8 *in, uint8 *out) +static void +ciph_encrypt(CIPH_CTX * ctx, const uint8 *in, uint8 *out) { - rijndael_encrypt(ctx, (const uint32 *)in, (uint32 *)out); + rijndael_encrypt(ctx, (const uint32 *) in, (uint32 *) out); } -static void md_init(MD_CTX *ctx) +static void +md_init(MD_CTX * ctx) { SHA256_Init(ctx); } -static void md_update(MD_CTX *ctx, const uint8 *data, int len) +static void +md_update(MD_CTX * ctx, const uint8 *data, int len) { SHA256_Update(ctx, data, len); } -static void md_result(MD_CTX *ctx, uint8 *dst) +static void +md_result(MD_CTX * ctx, uint8 *dst) { - SHA256_CTX tmp; + SHA256_CTX tmp; + memcpy(&tmp, ctx, sizeof(*ctx)); SHA256_Final(dst, &tmp); memset(&tmp, 0, sizeof(tmp)); @@ -168,9 +175,11 @@ static void md_result(MD_CTX *ctx, uint8 *dst) /* * initialize state */ -static void init_state(FState *st) +static void +init_state(FState * st) { - int i; + int i; + memset(st, 0, sizeof(*st)); for (i = 0; i < NUM_POOLS; i++) md_init(&st->pool[i]); @@ -180,9 +189,11 @@ static void init_state(FState *st) * Endianess does not matter. * It just needs to change without repeating. */ -static void inc_counter(FState *st) +static void +inc_counter(FState * st) { - uint32 *val = (uint32*)st->counter; + uint32 *val = (uint32 *) st->counter; + if (++val[0]) return; if (++val[1]) @@ -195,7 +206,8 @@ static void inc_counter(FState *st) /* * This is called 'cipher in counter mode'. */ -static void encrypt_counter(FState *st, uint8 *dst) +static void +encrypt_counter(FState * st, uint8 *dst) { ciph_encrypt(&st->ciph, st->counter, dst); inc_counter(st); @@ -206,12 +218,13 @@ static void encrypt_counter(FState *st, uint8 *dst) * The time between reseed must be at least RESEED_INTERVAL * microseconds. */ -static int too_often(FState *st) +static int +too_often(FState * st) { - int ok; + int ok; struct timeval tv; struct timeval *last = &st->last_reseed_time; - + gettimeofday(&tv, NULL); ok = 0; @@ -229,19 +242,19 @@ static int too_often(FState *st) /* * generate new key from all the pools */ -static void reseed(FState *st) +static void +reseed(FState * st) { - unsigned k; - unsigned n; - MD_CTX key_md; - uint8 buf[BLOCK]; + unsigned k; + unsigned n; + MD_CTX key_md; + uint8 buf[BLOCK]; /* set pool as empty */ st->pool0_bytes = 0; /* - * Both #0 and #1 reseed would use only pool 0. - * Just skip #0 then. + * Both #0 and #1 reseed would use only pool 0. Just skip #0 then. */ n = ++st->reseed_count; @@ -249,7 +262,8 @@ static void reseed(FState *st) * The goal: use k-th pool only 1/(2^k) of the time. */ md_init(&key_md); - for (k = 0; k < NUM_POOLS; k++) { + for (k = 0; k < NUM_POOLS; k++) + { md_result(&st->pool[k], buf); md_update(&key_md, buf, BLOCK); @@ -272,11 +286,12 @@ static void reseed(FState *st) } /* - * Pick a random pool. This uses key bytes as random source. + * Pick a random pool. This uses key bytes as random source. */ -static unsigned get_rand_pool(FState *st) +static unsigned +get_rand_pool(FState * st) { - unsigned rnd; + unsigned rnd; /* * This slightly prefers lower pools - thats OK. @@ -293,11 +308,12 @@ static unsigned get_rand_pool(FState *st) /* * update pools */ -static void add_entropy(FState *st, const uint8 *data, unsigned len) +static void +add_entropy(FState * st, const uint8 *data, unsigned len) { - unsigned pos; - uint8 hash[BLOCK]; - MD_CTX md; + unsigned pos; + uint8 hash[BLOCK]; + MD_CTX md; /* hash given data */ md_init(&md); @@ -305,14 +321,13 @@ static void add_entropy(FState *st, const uint8 *data, unsigned len) md_result(&md, hash); /* - * Make sure the pool 0 is initialized, - * then update randomly. + * Make sure the pool 0 is initialized, then update randomly. */ if (st->reseed_count == 0 && st->pool0_bytes < POOL0_FILL) pos = 0; else pos = get_rand_pool(st); - md_update( &st->pool[pos], hash, BLOCK); + md_update(&st->pool[pos], hash, BLOCK); if (pos == 0) st->pool0_bytes += len; @@ -324,7 +339,8 @@ static void add_entropy(FState *st, const uint8 *data, unsigned len) /* * Just take 2 next blocks as new key */ -static void rekey(FState *st) +static void +rekey(FState * st) { encrypt_counter(st, st->key); encrypt_counter(st, st->key + CIPH_BLOCK); @@ -336,7 +352,8 @@ static void rekey(FState *st) * In case it does not, slow down the attacker by initialising * the couter to random value. */ -static void init_counter(FState *st) +static void +init_counter(FState * st) { /* Use next block as counter. */ encrypt_counter(st, st->counter); @@ -348,10 +365,11 @@ static void init_counter(FState *st) st->counter_init = 1; } -static void extract_data(FState *st, unsigned count, uint8 *dst) +static void +extract_data(FState * st, unsigned count, uint8 *dst) { - unsigned n; - unsigned block_nr = 0; + unsigned n; + unsigned block_nr = 0; /* Can we reseed? */ if (st->pool0_bytes >= POOL0_FILL && !too_often(st)) @@ -361,7 +379,8 @@ static void extract_data(FState *st, unsigned count, uint8 *dst) if (!st->counter_init) init_counter(st); - while (count > 0) { + while (count > 0) + { /* produce bytes */ encrypt_counter(st, st->result); @@ -391,9 +410,10 @@ static void extract_data(FState *st, unsigned count, uint8 *dst) */ static FState main_state; -static int init_done = 0; +static int init_done = 0; -void fortuna_add_entropy(const uint8 *data, unsigned len) +void +fortuna_add_entropy(const uint8 *data, unsigned len) { if (!init_done) { @@ -405,7 +425,8 @@ void fortuna_add_entropy(const uint8 *data, unsigned len) add_entropy(&main_state, data, len); } -void fortuna_get_bytes(unsigned len, uint8 *dst) +void +fortuna_get_bytes(unsigned len, uint8 *dst) { if (!init_done) { @@ -416,4 +437,3 @@ void fortuna_get_bytes(unsigned len, uint8 *dst) return; extract_data(&main_state, len, dst); } - diff --git a/contrib/pgcrypto/fortuna.h b/contrib/pgcrypto/fortuna.h index 12e0c56832..b4d7064dec 100644 --- a/contrib/pgcrypto/fortuna.h +++ b/contrib/pgcrypto/fortuna.h @@ -26,14 +26,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/fortuna.h,v 1.2 2005/07/18 17:12:54 tgl Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/fortuna.h,v 1.3 2005/10/15 02:49:06 momjian Exp $ */ #ifndef __FORTUNA_H #define __FORTUNA_H -void fortuna_get_bytes(unsigned len, uint8 *dst); -void fortuna_add_entropy(const uint8 *data, unsigned len); +void fortuna_get_bytes(unsigned len, uint8 *dst); +void fortuna_add_entropy(const uint8 *data, unsigned len); #endif - diff --git a/contrib/pgcrypto/internal.c b/contrib/pgcrypto/internal.c index bfe4eeb2b7..f5dd11c90b 100644 --- a/contrib/pgcrypto/internal.c +++ b/contrib/pgcrypto/internal.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/internal.c,v 1.22 2005/07/18 17:12:54 tgl Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/internal.c,v 1.23 2005/10/15 02:49:06 momjian Exp $ */ #include "postgres.h" @@ -52,7 +52,7 @@ /* * The chance is x/256 that the reseed happens. */ -#define SYSTEM_RESEED_CHANCE (4) /* 256/4 * 10min ~ 10h */ +#define SYSTEM_RESEED_CHANCE (4) /* 256/4 * 10min ~ 10h */ /* * If this much time has passed, force reseed. @@ -88,13 +88,13 @@ struct int_digest }; static const struct int_digest -int_digest_list[] = { - { "md5", init_md5 }, - { "sha1", init_sha1 }, - { "sha256", init_sha256 }, - { "sha384", init_sha384 }, - { "sha512", init_sha512 }, - { NULL, NULL } + int_digest_list[] = { + {"md5", init_md5}, + {"sha1", init_sha1}, + {"sha256", init_sha256}, + {"sha384", init_sha384}, + {"sha512", init_sha512}, + {NULL, NULL} }; /* MD5 */ @@ -210,7 +210,7 @@ int_sha256_block_len(PX_MD * h) static void int_sha256_update(PX_MD * h, const uint8 *data, unsigned dlen) { - SHA256_CTX *ctx = (SHA256_CTX *) h->p.ptr; + SHA256_CTX *ctx = (SHA256_CTX *) h->p.ptr; SHA256_Update(ctx, data, dlen); } @@ -218,7 +218,7 @@ int_sha256_update(PX_MD * h, const uint8 *data, unsigned dlen) static void int_sha256_reset(PX_MD * h) { - SHA256_CTX *ctx = (SHA256_CTX *) h->p.ptr; + SHA256_CTX *ctx = (SHA256_CTX *) h->p.ptr; SHA256_Init(ctx); } @@ -226,7 +226,7 @@ int_sha256_reset(PX_MD * h) static void int_sha256_finish(PX_MD * h, uint8 *dst) { - SHA256_CTX *ctx = (SHA256_CTX *) h->p.ptr; + SHA256_CTX *ctx = (SHA256_CTX *) h->p.ptr; SHA256_Final(dst, ctx); } @@ -234,12 +234,13 @@ int_sha256_finish(PX_MD * h, uint8 *dst) static void int_sha256_free(PX_MD * h) { - SHA256_CTX *ctx = (SHA256_CTX *) h->p.ptr; + SHA256_CTX *ctx = (SHA256_CTX *) h->p.ptr; memset(ctx, 0, sizeof(*ctx)); px_free(ctx); px_free(h); } + /* SHA384 */ static unsigned @@ -257,7 +258,7 @@ int_sha384_block_len(PX_MD * h) static void int_sha384_update(PX_MD * h, const uint8 *data, unsigned dlen) { - SHA384_CTX *ctx = (SHA384_CTX *) h->p.ptr; + SHA384_CTX *ctx = (SHA384_CTX *) h->p.ptr; SHA384_Update(ctx, data, dlen); } @@ -265,7 +266,7 @@ int_sha384_update(PX_MD * h, const uint8 *data, unsigned dlen) static void int_sha384_reset(PX_MD * h) { - SHA384_CTX *ctx = (SHA384_CTX *) h->p.ptr; + SHA384_CTX *ctx = (SHA384_CTX *) h->p.ptr; SHA384_Init(ctx); } @@ -273,7 +274,7 @@ int_sha384_reset(PX_MD * h) static void int_sha384_finish(PX_MD * h, uint8 *dst) { - SHA384_CTX *ctx = (SHA384_CTX *) h->p.ptr; + SHA384_CTX *ctx = (SHA384_CTX *) h->p.ptr; SHA384_Final(dst, ctx); } @@ -281,7 +282,7 @@ int_sha384_finish(PX_MD * h, uint8 *dst) static void int_sha384_free(PX_MD * h) { - SHA384_CTX *ctx = (SHA384_CTX *) h->p.ptr; + SHA384_CTX *ctx = (SHA384_CTX *) h->p.ptr; memset(ctx, 0, sizeof(*ctx)); px_free(ctx); @@ -305,7 +306,7 @@ int_sha512_block_len(PX_MD * h) static void int_sha512_update(PX_MD * h, const uint8 *data, unsigned dlen) { - SHA512_CTX *ctx = (SHA512_CTX *) h->p.ptr; + SHA512_CTX *ctx = (SHA512_CTX *) h->p.ptr; SHA512_Update(ctx, data, dlen); } @@ -313,7 +314,7 @@ int_sha512_update(PX_MD * h, const uint8 *data, unsigned dlen) static void int_sha512_reset(PX_MD * h) { - SHA512_CTX *ctx = (SHA512_CTX *) h->p.ptr; + SHA512_CTX *ctx = (SHA512_CTX *) h->p.ptr; SHA512_Init(ctx); } @@ -321,7 +322,7 @@ int_sha512_reset(PX_MD * h) static void int_sha512_finish(PX_MD * h, uint8 *dst) { - SHA512_CTX *ctx = (SHA512_CTX *) h->p.ptr; + SHA512_CTX *ctx = (SHA512_CTX *) h->p.ptr; SHA512_Final(dst, ctx); } @@ -329,7 +330,7 @@ int_sha512_finish(PX_MD * h, uint8 *dst) static void int_sha512_free(PX_MD * h) { - SHA512_CTX *ctx = (SHA512_CTX *) h->p.ptr; + SHA512_CTX *ctx = (SHA512_CTX *) h->p.ptr; memset(ctx, 0, sizeof(*ctx)); px_free(ctx); @@ -381,7 +382,7 @@ init_sha1(PX_MD * md) static void init_sha256(PX_MD * md) { - SHA256_CTX *ctx; + SHA256_CTX *ctx; ctx = px_alloc(sizeof(*ctx)); memset(ctx, 0, sizeof(*ctx)); @@ -401,7 +402,7 @@ init_sha256(PX_MD * md) static void init_sha384(PX_MD * md) { - SHA384_CTX *ctx; + SHA384_CTX *ctx; ctx = px_alloc(sizeof(*ctx)); memset(ctx, 0, sizeof(*ctx)); @@ -421,7 +422,7 @@ init_sha384(PX_MD * md) static void init_sha512(PX_MD * md) { - SHA512_CTX *ctx; + SHA512_CTX *ctx; ctx = px_alloc(sizeof(*ctx)); memset(ctx, 0, sizeof(*ctx)); @@ -752,12 +753,12 @@ struct int_cipher }; static const struct int_cipher -int_ciphers[] = { - { "bf-cbc", bf_cbc_load }, - { "bf-ecb", bf_ecb_load }, - { "aes-128-cbc", rj_128_cbc }, - { "aes-128-ecb", rj_128_ecb }, - { NULL, NULL } + int_ciphers[] = { + {"bf-cbc", bf_cbc_load}, + {"bf-ecb", bf_ecb_load}, + {"aes-128-cbc", rj_128_cbc}, + {"aes-128-ecb", rj_128_ecb}, + {NULL, NULL} }; static const PX_Alias int_aliases[] = { @@ -828,7 +829,7 @@ px_find_cipher(const char *name, PX_Cipher ** res) int px_get_pseudo_random_bytes(uint8 *dst, unsigned count) { - int i; + int i; for (i = 0; i < count; i++) *dst++ = random(); @@ -838,12 +839,13 @@ px_get_pseudo_random_bytes(uint8 *dst, unsigned count) static time_t seed_time = 0; static time_t check_time = 0; -static void system_reseed(void) +static void +system_reseed(void) { - uint8 buf[1024]; - int n; - time_t t; - int skip = 1; + uint8 buf[1024]; + int n; + time_t t; + int skip = 1; t = time(NULL); @@ -890,4 +892,3 @@ px_add_entropy(const uint8 *data, unsigned count) fortuna_add_entropy(data, count); return 0; } - diff --git a/contrib/pgcrypto/mbuf.c b/contrib/pgcrypto/mbuf.c index ac59d7fc97..c6a1b99100 100644 --- a/contrib/pgcrypto/mbuf.c +++ b/contrib/pgcrypto/mbuf.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/mbuf.c,v 1.2 2005/07/11 15:07:59 tgl Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/mbuf.c,v 1.3 2005/10/15 02:49:06 momjian Exp $ */ #include "postgres.h" @@ -166,7 +166,8 @@ mbuf_grab(MBuf * mbuf, int len, uint8 **data_p) return len; } -int mbuf_rewind(MBuf *mbuf) +int +mbuf_rewind(MBuf * mbuf) { mbuf->read_pos = mbuf->data; return 0; @@ -175,7 +176,7 @@ int mbuf_rewind(MBuf *mbuf) int mbuf_steal_data(MBuf * mbuf, uint8 **data_p) { - int len = mbuf_size(mbuf); + int len = mbuf_size(mbuf); mbuf->no_write = 1; mbuf->own_data = 0; @@ -193,7 +194,7 @@ mbuf_steal_data(MBuf * mbuf, uint8 **data_p) struct PullFilter { - PullFilter *src; + PullFilter *src; const PullFilterOps *op; int buflen; uint8 *buf; @@ -204,7 +205,7 @@ struct PullFilter int pullf_create(PullFilter ** pf_p, const PullFilterOps * op, void *init_arg, PullFilter * src) { - PullFilter *pf; + PullFilter *pf; void *priv; int res; @@ -260,13 +261,14 @@ pullf_free(PullFilter * pf) int pullf_read(PullFilter * pf, int len, uint8 **data_p) { - int res; + int res; + if (pf->op->pull) { if (pf->buflen && len > pf->buflen) len = pf->buflen; res = pf->op->pull(pf->priv, pf->src, len, data_p, - pf->buf, pf->buflen); + pf->buf, pf->buflen); } else res = pullf_read(pf->src, len, data_p); @@ -276,8 +278,9 @@ pullf_read(PullFilter * pf, int len, uint8 **data_p) int pullf_read_max(PullFilter * pf, int len, uint8 **data_p, uint8 *tmpbuf) { - int res, total; - uint8 *tmp; + int res, + total; + uint8 *tmp; res = pullf_read(pf, len, data_p); if (res <= 0 || res == len) @@ -288,8 +291,9 @@ pullf_read_max(PullFilter * pf, int len, uint8 **data_p, uint8 *tmpbuf) *data_p = tmpbuf; len -= res; total = res; - - while (len > 0) { + + while (len > 0) + { res = pullf_read(pf, len, &tmp); if (res < 0) { @@ -308,10 +312,12 @@ pullf_read_max(PullFilter * pf, int len, uint8 **data_p, uint8 *tmpbuf) /* * caller wants exatly len bytes and dont bother with references */ -int pullf_read_fixed(PullFilter *src, int len, uint8 *dst) +int +pullf_read_fixed(PullFilter * src, int len, uint8 *dst) { - int res; - uint8 *p; + int res; + uint8 *p; + res = pullf_read_max(src, len, &p, dst); if (res < 0) return res; @@ -330,9 +336,10 @@ int pullf_read_fixed(PullFilter *src, int len, uint8 *dst) */ static int pull_from_mbuf(void *arg, PullFilter * src, int len, - uint8 **data_p, uint8 *buf, int buflen) + uint8 **data_p, uint8 *buf, int buflen) { MBuf *mbuf = arg; + return mbuf_grab(mbuf, len, data_p); } @@ -364,7 +371,7 @@ struct PushFilter int pushf_create(PushFilter ** mp_p, const PushFilterOps * op, void *init_arg, PushFilter * next) { - PushFilter *mp; + PushFilter *mp; void *priv; int res; @@ -419,7 +426,7 @@ pushf_free(PushFilter * mp) void pushf_free_all(PushFilter * mp) { - PushFilter *tmp; + PushFilter *tmp; while (mp) { @@ -549,8 +556,8 @@ static const struct PushFilterOps mbuf_filter = { NULL, push_into_mbuf, NULL, NULL }; -int pushf_create_mbuf_writer(PushFilter **res, MBuf *dst) +int +pushf_create_mbuf_writer(PushFilter ** res, MBuf * dst) { return pushf_create(res, &mbuf_filter, dst, NULL); } - diff --git a/contrib/pgcrypto/mbuf.h b/contrib/pgcrypto/mbuf.h index 6042a4fc2e..91ef821ed4 100644 --- a/contrib/pgcrypto/mbuf.h +++ b/contrib/pgcrypto/mbuf.h @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/mbuf.h,v 1.1 2005/07/10 13:46:28 momjian Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/mbuf.h,v 1.2 2005/10/15 02:49:06 momjian Exp $ */ #ifndef __PX_MBUF_H @@ -40,32 +40,36 @@ typedef struct PullFilterOps PullFilterOps; struct PushFilterOps { - /* should return needed buffer size, 0- no buffering, <0 on error - * if NULL, no buffering, and priv=init_arg + /* + * should return needed buffer size, 0- no buffering, <0 on error if NULL, + * no buffering, and priv=init_arg */ int (*init) (PushFilter * next, void *init_arg, void **priv_p); - /* send data to next. should consume all? - * if null, it will be simply copied (in-place) - * returns 0 on error + + /* + * send data to next. should consume all? if null, it will be simply + * copied (in-place) returns 0 on error */ int (*push) (PushFilter * next, void *priv, - const uint8 *src, int len); + const uint8 *src, int len); int (*flush) (PushFilter * next, void *priv); void (*free) (void *priv); }; struct PullFilterOps { - /* should return needed buffer size, 0- no buffering, <0 on error - * if NULL, no buffering, and priv=init_arg + /* + * should return needed buffer size, 0- no buffering, <0 on error if NULL, + * no buffering, and priv=init_arg */ int (*init) (void **priv_p, void *init_arg, PullFilter * src); - /* request data from src, put result ptr to data_p - * can use ptr from src or use buf as work area - * if NULL in-place copy + + /* + * request data from src, put result ptr to data_p can use ptr from src or + * use buf as work area if NULL in-place copy */ int (*pull) (void *priv, PullFilter * src, int len, - uint8 **data_p, uint8 *buf, int buflen); + uint8 **data_p, uint8 *buf, int buflen); void (*free) (void *priv); }; @@ -86,8 +90,8 @@ int mbuf_free(MBuf * mbuf); /* * Push filter */ -int pushf_create(PushFilter ** res, const PushFilterOps * ops, void *init_arg, - PushFilter * next); +int pushf_create(PushFilter ** res, const PushFilterOps * ops, void *init_arg, + PushFilter * next); int pushf_write(PushFilter * mp, const uint8 *data, int len); void pushf_free_all(PushFilter * mp); void pushf_free(PushFilter * mp); @@ -98,13 +102,13 @@ int pushf_create_mbuf_writer(PushFilter ** mp_p, MBuf * mbuf); /* * Pull filter */ -int pullf_create(PullFilter ** res, const PullFilterOps * ops, - void *init_arg, PullFilter * src); +int pullf_create(PullFilter ** res, const PullFilterOps * ops, + void *init_arg, PullFilter * src); int pullf_read(PullFilter * mp, int len, uint8 **data_p); -int pullf_read_max(PullFilter * mp, int len, - uint8 **data_p, uint8 *tmpbuf); +int pullf_read_max(PullFilter * mp, int len, + uint8 **data_p, uint8 *tmpbuf); void pullf_free(PullFilter * mp); -int pullf_read_fixed(PullFilter *src, int len, uint8 *dst); +int pullf_read_fixed(PullFilter * src, int len, uint8 *dst); int pullf_create_mbuf_reader(PullFilter ** pf_p, MBuf * mbuf); @@ -118,4 +122,3 @@ int pullf_create_mbuf_reader(PullFilter ** pf_p, MBuf * mbuf); } while (0) #endif /* __PX_MBUF_H */ - diff --git a/contrib/pgcrypto/md5.h b/contrib/pgcrypto/md5.h index 9e32be2f08..933dcaa9b9 100644 --- a/contrib/pgcrypto/md5.h +++ b/contrib/pgcrypto/md5.h @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/contrib/pgcrypto/md5.h,v 1.8 2003/11/29 22:39:28 pgsql Exp $ */ +/* $PostgreSQL: pgsql/contrib/pgcrypto/md5.h,v 1.9 2005/10/15 02:49:06 momjian Exp $ */ /* $KAME: md5.h,v 1.3 2000/02/22 14:01:18 itojun Exp $ */ /* diff --git a/contrib/pgcrypto/openssl.c b/contrib/pgcrypto/openssl.c index 67358c941f..a4840227ad 100644 --- a/contrib/pgcrypto/openssl.c +++ b/contrib/pgcrypto/openssl.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/openssl.c,v 1.25 2005/07/12 20:27:42 tgl Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/openssl.c,v 1.26 2005/10/15 02:49:06 momjian Exp $ */ #include "postgres.h" @@ -47,14 +47,13 @@ #define MAX_IV (128/8) /* - * Does OpenSSL support AES? + * Does OpenSSL support AES? */ #if OPENSSL_VERSION_NUMBER >= 0x00907000L /* Yes, it does. */ #include - -#else /* old OPENSSL */ +#else /* old OPENSSL */ /* * No, it does not. So use included rijndael code to emulate it. @@ -91,8 +90,7 @@ memcpy(iv, (src) + (len) - 16, 16); \ } \ } while (0) - -#endif /* old OPENSSL */ +#endif /* old OPENSSL */ /* * Compatibility with older OpenSSL API for DES. @@ -157,8 +155,8 @@ digest_finish(PX_MD * h, uint8 *dst) EVP_DigestFinal(ctx, dst, NULL); /* - * Some builds of 0.9.7x clear all of ctx in EVP_DigestFinal. - * Fix it by reinitializing ctx. + * Some builds of 0.9.7x clear all of ctx in EVP_DigestFinal. Fix it by + * reinitializing ctx. */ EVP_DigestInit(ctx, md); } @@ -246,7 +244,9 @@ typedef struct } des; struct { - DES_key_schedule k1, k2, k3; + DES_key_schedule k1, + k2, + k3; } des3; CAST_KEY cast_key; AES_KEY aes_key; @@ -597,12 +597,12 @@ ossl_aes_init(PX_Cipher * c, const uint8 *key, unsigned klen, const uint8 *iv) ossldata *od = c->ptr; unsigned bs = gen_ossl_block_size(c); - if (klen <= 128/8) - od->klen = 128/8; - else if (klen <= 192/8) - od->klen = 192/8; - else if (klen <= 256/8) - od->klen = 256/8; + if (klen <= 128 / 8) + od->klen = 128 / 8; + else if (klen <= 192 / 8) + od->klen = 192 / 8; + else if (klen <= 256 / 8) + od->klen = 256 / 8; else return PXE_KEY_TOO_BIG; @@ -825,7 +825,8 @@ static int openssl_random_init = 0; * OpenSSL random should re-feeded occasionally. From /dev/urandom * preferably. */ -static void init_openssl_rand(void) +static void +init_openssl_rand(void) { if (RAND_get_rand_method() == NULL) RAND_set_rand_method(RAND_SSLeay()); @@ -871,4 +872,3 @@ px_add_entropy(const uint8 *data, unsigned count) RAND_add(data, count, 0); return 0; } - diff --git a/contrib/pgcrypto/pgcrypto.c b/contrib/pgcrypto/pgcrypto.c index 4888fb8725..cc3814aacd 100644 --- a/contrib/pgcrypto/pgcrypto.c +++ b/contrib/pgcrypto/pgcrypto.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/pgcrypto.c,v 1.19 2005/09/24 19:14:04 tgl Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/pgcrypto.c,v 1.20 2005/10/15 02:49:06 momjian Exp $ */ #include "postgres.h" @@ -244,7 +244,7 @@ pg_gen_salt_rounds(PG_FUNCTION_ARGS) if (len < 0) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("gen_salt: %s", px_strerror(len)))); + errmsg("gen_salt: %s", px_strerror(len)))); res = (text *) palloc(len + VARHDRSZ); VARATT_SIZEP(res) = len + VARHDRSZ; diff --git a/contrib/pgcrypto/pgp-armor.c b/contrib/pgcrypto/pgp-armor.c index b379b2538e..7963ccc329 100644 --- a/contrib/pgcrypto/pgp-armor.c +++ b/contrib/pgcrypto/pgp-armor.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-armor.c,v 1.2 2005/07/11 15:07:59 tgl Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-armor.c,v 1.3 2005/10/15 02:49:06 momjian Exp $ */ #include "postgres.h" @@ -40,7 +40,7 @@ */ static const unsigned char _base64[] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; +"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; static int b64_encode(const uint8 *src, unsigned len, uint8 *dst) @@ -96,13 +96,13 @@ static int b64_decode(const uint8 *src, unsigned len, uint8 *dst) { const uint8 *srcend = src + len, - *s = src; + *s = src; uint8 *p = dst; char c; unsigned b = 0; unsigned long buf = 0; int pos = 0, - end = 0; + end = 0; while (s < srcend) { @@ -242,11 +242,13 @@ static const uint8 * find_str(const uint8 *data, const uint8 *data_end, const char *str, int strlen) { const uint8 *p = data; + if (!strlen) return NULL; if (data_end - data < strlen) return NULL; - while (p < data_end) { + while (p < data_end) + { p = memchr(p, str[0], data_end - p); if (p == NULL) return NULL; @@ -261,7 +263,7 @@ find_str(const uint8 *data, const uint8 *data_end, const char *str, int strlen) static int find_header(const uint8 *data, const uint8 *datend, - const uint8 **start_p, int is_end) + const uint8 **start_p, int is_end) { const uint8 *p = data; static const char *start_sep = "-----BEGIN"; @@ -285,7 +287,7 @@ find_header(const uint8 *data, const uint8 *datend, /* check if header text ok */ for (; p < datend && *p != '-'; p++) { - /* various junk can be there, but definitely not line-feed */ + /* various junk can be there, but definitely not line-feed */ if (*p >= ' ') continue; return PXE_PGP_CORRUPT_ARMOR; @@ -313,7 +315,8 @@ pgp_armor_decode(const uint8 *src, unsigned len, uint8 *dst) const uint8 *p = src; const uint8 *data_end = src + len; long crc; - const uint8 *base64_start, *armor_end; + const uint8 *base64_start, + *armor_end; const uint8 *base64_end = NULL; uint8 buf[4]; int hlen; @@ -329,7 +332,7 @@ pgp_armor_decode(const uint8 *src, unsigned len, uint8 *dst) hlen = find_header(p, data_end, &armor_end, 1); if (hlen <= 0) goto out; - + /* skip comments - find empty line */ while (p < armor_end && *p != '\n' && *p != '\r') { @@ -341,7 +344,7 @@ pgp_armor_decode(const uint8 *src, unsigned len, uint8 *dst) p++; } base64_start = p; - + /* find crc pos */ for (p = armor_end; p >= base64_start; p--) if (*p == '=') @@ -355,7 +358,7 @@ pgp_armor_decode(const uint8 *src, unsigned len, uint8 *dst) /* decode crc */ if (b64_decode(p + 1, 4, buf) != 3) goto out; - crc = (((long)buf[0]) << 16) + (((long)buf[1]) << 8) + (long)buf[2]; + crc = (((long) buf[0]) << 16) + (((long) buf[1]) << 8) + (long) buf[2]; /* decode data */ res = b64_decode(base64_start, base64_end - base64_start, dst); @@ -378,4 +381,3 @@ pgp_armor_dec_len(unsigned len) { return b64_dec_len(len); } - diff --git a/contrib/pgcrypto/pgp-cfb.c b/contrib/pgcrypto/pgp-cfb.c index 52e56acfc0..811bb7c2c3 100644 --- a/contrib/pgcrypto/pgp-cfb.c +++ b/contrib/pgcrypto/pgp-cfb.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-cfb.c,v 1.2 2005/07/11 15:07:59 tgl Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-cfb.c,v 1.3 2005/10/15 02:49:06 momjian Exp $ */ #include "postgres.h" @@ -35,7 +35,7 @@ #include "px.h" #include "pgp.h" -typedef int (*mix_data_t)(PGP_CFB *ctx, const uint8 *data, int len, uint8 *dst); +typedef int (*mix_data_t) (PGP_CFB * ctx, const uint8 *data, int len, uint8 *dst); struct PGP_CFB { @@ -50,12 +50,12 @@ struct PGP_CFB }; int -pgp_cfb_create(PGP_CFB **ctx_p, int algo, const uint8 *key, int key_len, - int resync, uint8 *iv) +pgp_cfb_create(PGP_CFB ** ctx_p, int algo, const uint8 *key, int key_len, + int resync, uint8 *iv) { - int res; - PX_Cipher *ciph; - PGP_CFB *ctx; + int res; + PX_Cipher *ciph; + PGP_CFB *ctx; res = pgp_load_cipher(algo, &ciph); if (res < 0) @@ -82,7 +82,7 @@ pgp_cfb_create(PGP_CFB **ctx_p, int algo, const uint8 *key, int key_len, } void -pgp_cfb_free(PGP_CFB *ctx) +pgp_cfb_free(PGP_CFB * ctx) { px_cipher_free(ctx->ciph); memset(ctx, 0, sizeof(*ctx)); @@ -90,12 +90,13 @@ pgp_cfb_free(PGP_CFB *ctx) } /* - * Data processing for normal CFB. (PGP_PKT_SYMENCRYPTED_DATA_MDC) + * Data processing for normal CFB. (PGP_PKT_SYMENCRYPTED_DATA_MDC) */ static int -mix_encrypt_normal(PGP_CFB *ctx, const uint8 *data, int len, uint8 *dst) +mix_encrypt_normal(PGP_CFB * ctx, const uint8 *data, int len, uint8 *dst) { - int i; + int i; + for (i = ctx->pos; i < ctx->pos + len; i++) *dst++ = ctx->encbuf[i] = ctx->fre[i] ^ (*data++); ctx->pos += len; @@ -103,9 +104,10 @@ mix_encrypt_normal(PGP_CFB *ctx, const uint8 *data, int len, uint8 *dst) } static int -mix_decrypt_normal(PGP_CFB *ctx, const uint8 *data, int len, uint8 *dst) +mix_decrypt_normal(PGP_CFB * ctx, const uint8 *data, int len, uint8 *dst) { - int i; + int i; + for (i = ctx->pos; i < ctx->pos + len; i++) { ctx->encbuf[i] = *data++; @@ -122,9 +124,11 @@ mix_decrypt_normal(PGP_CFB *ctx, const uint8 *data, int len, uint8 *dst) * thus its all concentrated here. */ static int -mix_encrypt_resync(PGP_CFB *ctx, const uint8 *data, int len, uint8 *dst) +mix_encrypt_resync(PGP_CFB * ctx, const uint8 *data, int len, uint8 *dst) { - int i,n; + int i, + n; + /* block #2 is 2 bytes long */ if (ctx->block_no == 2) { @@ -152,9 +156,11 @@ mix_encrypt_resync(PGP_CFB *ctx, const uint8 *data, int len, uint8 *dst) } static int -mix_decrypt_resync(PGP_CFB *ctx, const uint8 *data, int len, uint8 *dst) +mix_decrypt_resync(PGP_CFB * ctx, const uint8 *data, int len, uint8 *dst) { - int i,n; + int i, + n; + /* block #2 is 2 bytes long */ if (ctx->block_no == 2) { @@ -190,11 +196,11 @@ mix_decrypt_resync(PGP_CFB *ctx, const uint8 *data, int len, uint8 *dst) * common code for both encrypt and decrypt. */ static int -cfb_process(PGP_CFB *ctx, const uint8 *data, int len, uint8 *dst, - mix_data_t mix_data) +cfb_process(PGP_CFB * ctx, const uint8 *data, int len, uint8 *dst, + mix_data_t mix_data) { - int n; - int res; + int n; + int res; while (len > 0 && ctx->pos > 0) { @@ -243,16 +249,17 @@ cfb_process(PGP_CFB *ctx, const uint8 *data, int len, uint8 *dst, */ int -pgp_cfb_encrypt(PGP_CFB *ctx, const uint8 *data, int len, uint8 *dst) +pgp_cfb_encrypt(PGP_CFB * ctx, const uint8 *data, int len, uint8 *dst) { - mix_data_t mix = ctx->resync ? mix_encrypt_resync : mix_encrypt_normal; + mix_data_t mix = ctx->resync ? mix_encrypt_resync : mix_encrypt_normal; + return cfb_process(ctx, data, len, dst, mix); } int -pgp_cfb_decrypt(PGP_CFB *ctx, const uint8 *data, int len, uint8 *dst) +pgp_cfb_decrypt(PGP_CFB * ctx, const uint8 *data, int len, uint8 *dst) { - mix_data_t mix = ctx->resync ? mix_decrypt_resync : mix_decrypt_normal; + mix_data_t mix = ctx->resync ? mix_decrypt_resync : mix_decrypt_normal; + return cfb_process(ctx, data, len, dst, mix); } - diff --git a/contrib/pgcrypto/pgp-compress.c b/contrib/pgcrypto/pgp-compress.c index da0ba9a18c..d30155b28e 100644 --- a/contrib/pgcrypto/pgp-compress.c +++ b/contrib/pgcrypto/pgp-compress.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-compress.c,v 1.4 2005/07/18 17:09:01 tgl Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-compress.c,v 1.5 2005/10/15 02:49:06 momjian Exp $ */ #include "postgres.h" @@ -180,12 +180,12 @@ compress_free(void *priv) } static const PushFilterOps -compress_filter = { + compress_filter = { compress_init, compress_process, compress_flush, compress_free }; int -pgp_compress_filter(PushFilter **res, PGP_Context *ctx, PushFilter *dst) +pgp_compress_filter(PushFilter ** res, PGP_Context * ctx, PushFilter * dst) { return pushf_create(res, &compress_filter, ctx, dst); } @@ -195,8 +195,8 @@ pgp_compress_filter(PushFilter **res, PGP_Context *ctx, PushFilter *dst) */ struct DecomprData { - int buf_len; /* = ZIP_OUT_BUF */ - int buf_data; /* available data */ + int buf_len; /* = ZIP_OUT_BUF */ + int buf_data; /* available data */ uint8 *pos; z_stream stream; int eof; @@ -204,14 +204,14 @@ struct DecomprData }; static int -decompress_init(void **priv_p, void *arg, PullFilter *src) +decompress_init(void **priv_p, void *arg, PullFilter * src) { PGP_Context *ctx = arg; struct DecomprData *dec; - int res; + int res; if (ctx->compress_algo != PGP_COMPR_ZLIB - && ctx->compress_algo != PGP_COMPR_ZIP) + && ctx->compress_algo != PGP_COMPR_ZIP) return PXE_PGP_UNSUPPORTED_COMPR; dec = px_alloc(sizeof(*dec)); @@ -232,15 +232,16 @@ decompress_init(void **priv_p, void *arg, PullFilter *src) px_debug("decompress_init: inflateInit error"); return PXE_PGP_COMPRESSION_ERROR; } - + return 0; } -static int decompress_read(void *priv, PullFilter *src, int len, - uint8 **data_p, uint8 *buf, int buflen) +static int +decompress_read(void *priv, PullFilter * src, int len, + uint8 **data_p, uint8 *buf, int buflen) { - int res; - int flush; + int res; + int flush; struct DecomprData *dec = priv; restart: @@ -256,24 +257,26 @@ restart: if (dec->eof) return 0; - - if (dec->stream.avail_in == 0) { - uint8 *tmp; + + if (dec->stream.avail_in == 0) + { + uint8 *tmp; + res = pullf_read(src, 8192, &tmp); if (res < 0) return res; dec->stream.next_in = tmp; dec->stream.avail_in = res; } - + dec->stream.next_out = dec->buf; dec->stream.avail_out = dec->buf_len; dec->pos = dec->buf; /* - * Z_SYNC_FLUSH is tell zlib to output as much as possible. - * It should do it anyway (Z_NO_FLUSH), but seems to reserve - * the right not to. So lets follow the API. + * Z_SYNC_FLUSH is tell zlib to output as much as possible. It should do + * it anyway (Z_NO_FLUSH), but seems to reserve the right not to. So lets + * follow the API. */ flush = dec->stream.avail_in ? Z_SYNC_FLUSH : Z_FINISH; res = inflate(&dec->stream, flush); @@ -289,39 +292,38 @@ restart: goto restart; } -static void decompress_free(void *priv) +static void +decompress_free(void *priv) { struct DecomprData *dec = priv; + inflateEnd(&dec->stream); memset(dec, 0, sizeof(*dec)); px_free(dec); } static const PullFilterOps -decompress_filter = { + decompress_filter = { decompress_init, decompress_read, decompress_free }; int -pgp_decompress_filter(PullFilter **res, PGP_Context *ctx, PullFilter *src) +pgp_decompress_filter(PullFilter ** res, PGP_Context * ctx, PullFilter * src) { return pullf_create(res, &decompress_filter, ctx, src); } - -#else /* DISABLE_ZLIB */ +#else /* DISABLE_ZLIB */ int -pgp_compress_filter(PushFilter **res, PGP_Context *ctx, PushFilter *dst) +pgp_compress_filter(PushFilter ** res, PGP_Context * ctx, PushFilter * dst) { return PXE_PGP_UNSUPPORTED_COMPR; } int -pgp_decompress_filter(PullFilter **res, PGP_Context *ctx, PullFilter *src) +pgp_decompress_filter(PullFilter ** res, PGP_Context * ctx, PullFilter * src) { return PXE_PGP_UNSUPPORTED_COMPR; } #endif - - diff --git a/contrib/pgcrypto/pgp-decrypt.c b/contrib/pgcrypto/pgp-decrypt.c index 16ae78200b..63f832e2ce 100644 --- a/contrib/pgcrypto/pgp-decrypt.c +++ b/contrib/pgcrypto/pgp-decrypt.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-decrypt.c,v 1.5 2005/09/24 19:14:04 tgl Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-decrypt.c,v 1.6 2005/10/15 02:49:06 momjian Exp $ */ #include "postgres.h" @@ -80,7 +80,7 @@ parse_new_len(PullFilter * src, int *len_p) len = 1 << (b & 0x1F); pkttype = PKT_STREAM; } - + if (len < 0 || len > MAX_CHUNK) { px_debug("parse_new_len: weird length"); @@ -130,7 +130,7 @@ pgp_parse_pkt_hdr(PullFilter * src, uint8 *tag, int *len_p, int allow_ctx) { int lentype; int res; - uint8 *p; + uint8 *p; /* EOF is normal here, thus we dont use GETBYTE */ res = pullf_read(src, 1, &p); @@ -165,15 +165,17 @@ pgp_parse_pkt_hdr(PullFilter * src, uint8 *tag, int *len_p, int allow_ctx) /* * Packet reader */ -struct PktData { - int type; - int len; +struct PktData +{ + int type; + int len; }; -static int pktreader_pull(void *priv, PullFilter *src, int len, - uint8 **data_p, uint8 *buf, int buflen) +static int +pktreader_pull(void *priv, PullFilter * src, int len, + uint8 **data_p, uint8 *buf, int buflen) { - int res; + int res; struct PktData *pkt = priv; /* PKT_CONTEXT means: whatever there is */ @@ -207,6 +209,7 @@ static void pktreader_free(void *priv) { struct PktData *pkt = priv; + memset(pkt, 0, sizeof(*pkt)); px_free(pkt); } @@ -217,11 +220,12 @@ static struct PullFilterOps pktreader_filter = { /* needs helper function to pass several parameters */ int -pgp_create_pkt_reader(PullFilter **pf_p, PullFilter *src, int len, - int pkttype, PGP_Context *ctx) +pgp_create_pkt_reader(PullFilter ** pf_p, PullFilter * src, int len, + int pkttype, PGP_Context * ctx) { - int res; + int res; struct PktData *pkt = px_alloc(sizeof(*pkt)); + pkt->type = pkttype; pkt->len = len; res = pullf_create(pf_p, &pktreader_filter, pkt, src); @@ -234,13 +238,14 @@ pgp_create_pkt_reader(PullFilter **pf_p, PullFilter *src, int len, * Prefix check filter */ -static int prefix_init(void **priv_p, void *arg, PullFilter *src) +static int +prefix_init(void **priv_p, void *arg, PullFilter * src) { PGP_Context *ctx = arg; - int len; - int res; - uint8 *buf; - uint8 tmpbuf[PGP_MAX_BLOCK + 2]; + int len; + int res; + uint8 *buf; + uint8 tmpbuf[PGP_MAX_BLOCK + 2]; len = pgp_get_cipher_block_size(ctx->cipher_algo); if (len > sizeof(tmpbuf)) @@ -259,20 +264,19 @@ static int prefix_init(void **priv_p, void *arg, PullFilter *src) if (buf[len - 2] != buf[len] || buf[len - 1] != buf[len + 1]) { px_debug("prefix_init: corrupt prefix"); + /* - * The original purpose of the 2-byte check was - * to show user a friendly "wrong key" message. - * This made following possible: + * The original purpose of the 2-byte check was to show user a + * friendly "wrong key" message. This made following possible: * - * "An Attack on CFB Mode Encryption As Used By OpenPGP" - * by Serge Mister and Robert Zuccherato + * "An Attack on CFB Mode Encryption As Used By OpenPGP" by Serge Mister + * and Robert Zuccherato * - * To avoid being 'oracle', we delay reporting, which - * basically means we prefer to run into corrupt packet - * header. + * To avoid being 'oracle', we delay reporting, which basically means we + * prefer to run into corrupt packet header. * - * We _could_ throw PXE_PGP_CORRUPT_DATA here, but - * there is possibility of attack via timing, so we don't. + * We _could_ throw PXE_PGP_CORRUPT_DATA here, but there is possibility + * of attack via timing, so we don't. */ ctx->corrupt_prefix = 1; } @@ -289,9 +293,10 @@ static struct PullFilterOps prefix_filter = { * Decrypt filter */ -static int decrypt_init(void **priv_p, void *arg, PullFilter *src) +static int +decrypt_init(void **priv_p, void *arg, PullFilter * src) { - PGP_CFB *cfb = arg; + PGP_CFB *cfb = arg; *priv_p = cfb; @@ -299,15 +304,17 @@ static int decrypt_init(void **priv_p, void *arg, PullFilter *src) return 4096; } -static int decrypt_read(void *priv, PullFilter *src, int len, - uint8 **data_p, uint8 *buf, int buflen) +static int +decrypt_read(void *priv, PullFilter * src, int len, + uint8 **data_p, uint8 *buf, int buflen) { - PGP_CFB *cfb = priv; - uint8 *tmp; - int res; + PGP_CFB *cfb = priv; + uint8 *tmp; + int res; res = pullf_read(src, len, &tmp); - if (res > 0) { + if (res > 0) + { pgp_cfb_decrypt(cfb, tmp, res, buf); *data_p = buf; } @@ -323,28 +330,33 @@ struct PullFilterOps pgp_decrypt_filter = { * MDC hasher filter */ -static int mdc_init(void **priv_p, void *arg, PullFilter *src) +static int +mdc_init(void **priv_p, void *arg, PullFilter * src) { PGP_Context *ctx = arg; + *priv_p = ctx; return pgp_load_digest(PGP_DIGEST_SHA1, &ctx->mdc_ctx); } -static void mdc_free(void *priv) +static void +mdc_free(void *priv) { PGP_Context *ctx = priv; + if (ctx->use_mdcbuf_filter) return; px_md_free(ctx->mdc_ctx); ctx->mdc_ctx = NULL; } -static int mdc_finish(PGP_Context *ctx, PullFilter *src, - int len, uint8 **data_p) +static int +mdc_finish(PGP_Context * ctx, PullFilter * src, + int len, uint8 **data_p) { - int res; - uint8 hash[20]; - uint8 tmpbuf[22]; + int res; + uint8 hash[20]; + uint8 tmpbuf[22]; if (len + 1 > sizeof(tmpbuf)) return PXE_BUG; @@ -362,7 +374,7 @@ static int mdc_finish(PGP_Context *ctx, PullFilter *src, } return 0; } - + /* safety check */ if (ctx->in_mdc_pkt > 1) { @@ -370,14 +382,14 @@ static int mdc_finish(PGP_Context *ctx, PullFilter *src, return PXE_PGP_CORRUPT_DATA; } ctx->in_mdc_pkt++; - + /* is the packet sane? */ if (res != 20) { px_debug("mdc_finish: read failed, res=%d", res); return PXE_PGP_CORRUPT_DATA; } - + /* * ok, we got the hash, now check */ @@ -394,10 +406,11 @@ static int mdc_finish(PGP_Context *ctx, PullFilter *src, return len; } -static int mdc_read(void *priv, PullFilter *src, int len, - uint8 **data_p, uint8 *buf, int buflen) +static int +mdc_read(void *priv, PullFilter * src, int len, + uint8 **data_p, uint8 *buf, int buflen) { - int res; + int res; PGP_Context *ctx = priv; /* skip this filter? */ @@ -434,18 +447,20 @@ static struct PullFilterOps mdc_filter = { * packet, which is silly. */ #define MDCBUF_LEN 8192 -struct MDCBufData { +struct MDCBufData +{ PGP_Context *ctx; - int eof; - int buflen; - int avail; - uint8 *pos; - int mdc_avail; - uint8 mdc_buf[22]; - uint8 buf[MDCBUF_LEN]; + int eof; + int buflen; + int avail; + uint8 *pos; + int mdc_avail; + uint8 mdc_buf[22]; + uint8 buf[MDCBUF_LEN]; }; -static int mdcbuf_init(void **priv_p, void *arg, PullFilter *src) +static int +mdcbuf_init(void **priv_p, void *arg, PullFilter * src) { PGP_Context *ctx = arg; struct MDCBufData *st; @@ -462,10 +477,11 @@ static int mdcbuf_init(void **priv_p, void *arg, PullFilter *src) return 0; } -static int mdcbuf_finish(struct MDCBufData *st) +static int +mdcbuf_finish(struct MDCBufData * st) { - uint8 hash[20]; - int res; + uint8 hash[20]; + int res; st->eof = 1; @@ -486,25 +502,29 @@ static int mdcbuf_finish(struct MDCBufData *st) return res; } -static void mdcbuf_load_data(struct MDCBufData *st, uint8 *src, int len) +static void +mdcbuf_load_data(struct MDCBufData * st, uint8 *src, int len) { - uint8 *dst = st->pos + st->avail; + uint8 *dst = st->pos + st->avail; + memcpy(dst, src, len); px_md_update(st->ctx->mdc_ctx, src, len); st->avail += len; } -static void mdcbuf_load_mdc(struct MDCBufData *st, uint8 *src, int len) +static void +mdcbuf_load_mdc(struct MDCBufData * st, uint8 *src, int len) { memmove(st->mdc_buf + st->mdc_avail, src, len); st->mdc_avail += len; } -static int mdcbuf_refill(struct MDCBufData *st, PullFilter *src) +static int +mdcbuf_refill(struct MDCBufData * st, PullFilter * src) { - uint8 *data; - int res; - int need; + uint8 *data; + int res; + int need; /* put avail data in start */ if (st->avail > 0 && st->pos != st->buf) @@ -530,7 +550,8 @@ static int mdcbuf_refill(struct MDCBufData *st, PullFilter *src) } else { - int canmove = st->mdc_avail + res - 22; + int canmove = st->mdc_avail + res - 22; + if (canmove > 0) { mdcbuf_load_data(st, st->mdc_buf, canmove); @@ -542,11 +563,12 @@ static int mdcbuf_refill(struct MDCBufData *st, PullFilter *src) return 0; } -static int mdcbuf_read(void *priv, PullFilter *src, int len, - uint8 **data_p, uint8 *buf, int buflen) +static int +mdcbuf_read(void *priv, PullFilter * src, int len, + uint8 **data_p, uint8 *buf, int buflen) { struct MDCBufData *st = priv; - int res; + int res; if (!st->eof && len > st->avail) { @@ -568,6 +590,7 @@ static void mdcbuf_free(void *priv) { struct MDCBufData *st = priv; + px_md_free(st->ctx->mdc_ctx); st->ctx->mdc_ctx = NULL; memset(st, 0, sizeof(*st)); @@ -583,29 +606,30 @@ static struct PullFilterOps mdcbuf_filter = { * Decrypt separate session key */ static int -decrypt_key(PGP_Context *ctx, const uint8 *src, int len) +decrypt_key(PGP_Context * ctx, const uint8 *src, int len) { - int res; - uint8 algo; - PGP_CFB *cfb; - + int res; + uint8 algo; + PGP_CFB *cfb; + res = pgp_cfb_create(&cfb, ctx->s2k_cipher_algo, - ctx->s2k.key, ctx->s2k.key_len, 0, NULL); + ctx->s2k.key, ctx->s2k.key_len, 0, NULL); if (res < 0) return res; pgp_cfb_decrypt(cfb, src, 1, &algo); - src ++; - len --; + src++; + len--; pgp_cfb_decrypt(cfb, src, len, ctx->sess_key); pgp_cfb_free(cfb); ctx->sess_key_len = len; ctx->cipher_algo = algo; - if (pgp_get_cipher_key_size(algo) != len) { + if (pgp_get_cipher_key_size(algo) != len) + { px_debug("sesskey bad len: algo=%d, expected=%d, got=%d", - algo, pgp_get_cipher_key_size(algo), len); + algo, pgp_get_cipher_key_size(algo), len); return PXE_PGP_CORRUPT_DATA; } return 0; @@ -643,7 +667,7 @@ parse_symenc_sesskey(PGP_Context * ctx, PullFilter * src) * generate key from password */ res = pgp_s2k_process(&ctx->s2k, ctx->s2k_cipher_algo, - ctx->sym_key, ctx->sym_key_len); + ctx->sym_key, ctx->sym_key_len); if (res < 0) return res; @@ -684,21 +708,23 @@ parse_symenc_sesskey(PGP_Context * ctx, PullFilter * src) } static int -copy_crlf(MBuf *dst, uint8 *data, int len, int *got_cr) +copy_crlf(MBuf * dst, uint8 *data, int len, int *got_cr) { - uint8 *data_end = data + len; - uint8 tmpbuf[1024]; - uint8 *tmp_end = tmpbuf + sizeof(tmpbuf); - uint8 *p; - int res; + uint8 *data_end = data + len; + uint8 tmpbuf[1024]; + uint8 *tmp_end = tmpbuf + sizeof(tmpbuf); + uint8 *p; + int res; p = tmpbuf; - if (*got_cr) { + if (*got_cr) + { if (*data != '\n') *p++ = '\r'; *got_cr = 0; } - while (data < data_end) { + while (data < data_end) + { if (*data == '\r') { if (data + 1 < data_end) @@ -779,8 +805,9 @@ parse_literal_data(PGP_Context * ctx, MBuf * dst, PullFilter * pkt) ctx->unicode_mode = (type == 'u') ? 1 : 0; /* read data */ - while (1) { - res = pullf_read(pkt, 32*1024, &buf); + while (1) + { + res = pullf_read(pkt, 32 * 1024, &buf); if (res <= 0) break; @@ -797,8 +824,8 @@ parse_literal_data(PGP_Context * ctx, MBuf * dst, PullFilter * pkt) } /* process_data_packets and parse_compressed_data call each other */ -static int process_data_packets(PGP_Context * ctx, MBuf * dst, - PullFilter * src, int allow_compr, int need_mdc); +static int process_data_packets(PGP_Context * ctx, MBuf * dst, + PullFilter * src, int allow_compr, int need_mdc); static int parse_compressed_data(PGP_Context * ctx, MBuf * dst, PullFilter * pkt) @@ -822,7 +849,7 @@ parse_compressed_data(PGP_Context * ctx, MBuf * dst, PullFilter * pkt) if (res >= 0) { res = process_data_packets(ctx, dst, pf_decompr, - NO_COMPR, NO_MDC); + NO_COMPR, NO_MDC); pullf_free(pf_decompr); } break; @@ -850,7 +877,7 @@ process_data_packets(PGP_Context * ctx, MBuf * dst, PullFilter * src, int got_data = 0; int got_mdc = 0; PullFilter *pkt = NULL; - uint8 *tmp; + uint8 *tmp; while (1) { @@ -951,12 +978,12 @@ static int parse_symenc_data(PGP_Context * ctx, PullFilter * pkt, MBuf * dst) { int res; - PGP_CFB *cfb = NULL; + PGP_CFB *cfb = NULL; PullFilter *pf_decrypt = NULL; PullFilter *pf_prefix = NULL; res = pgp_cfb_create(&cfb, ctx->cipher_algo, - ctx->sess_key, ctx->sess_key_len, 1, NULL); + ctx->sess_key, ctx->sess_key_len, 1, NULL); if (res < 0) goto out; @@ -985,11 +1012,11 @@ static int parse_symenc_mdc_data(PGP_Context * ctx, PullFilter * pkt, MBuf * dst) { int res; - PGP_CFB *cfb = NULL; + PGP_CFB *cfb = NULL; PullFilter *pf_decrypt = NULL; PullFilter *pf_prefix = NULL; PullFilter *pf_mdc = NULL; - uint8 ver; + uint8 ver; GETBYTE(pkt, ver); if (ver != 1) @@ -999,7 +1026,7 @@ parse_symenc_mdc_data(PGP_Context * ctx, PullFilter * pkt, MBuf * dst) } res = pgp_cfb_create(&cfb, ctx->cipher_algo, - ctx->sess_key, ctx->sess_key_len, 0, NULL); + ctx->sess_key, ctx->sess_key_len, 0, NULL); if (res < 0) goto out; @@ -1034,49 +1061,52 @@ out: * skip over packet contents */ int -pgp_skip_packet(PullFilter *pkt) +pgp_skip_packet(PullFilter * pkt) { - int res = 1; - uint8 *tmp; - while (res > 0) - res = pullf_read(pkt, 32*1024, &tmp); - return res < 0 ? res : 0; + int res = 1; + uint8 *tmp; + + while (res > 0) + res = pullf_read(pkt, 32 * 1024, &tmp); + return res < 0 ? res : 0; } /* * expect to be at packet end, any data is error */ int -pgp_expect_packet_end(PullFilter *pkt) +pgp_expect_packet_end(PullFilter * pkt) { - int res = 1; - uint8 *tmp; - while (res > 0) + int res = 1; + uint8 *tmp; + + while (res > 0) { - res = pullf_read(pkt, 32*1024, &tmp); + res = pullf_read(pkt, 32 * 1024, &tmp); if (res > 0) { px_debug("pgp_expect_packet_end: got data"); return PXE_PGP_CORRUPT_DATA; } } - return res < 0 ? res : 0; + return res < 0 ? res : 0; } int pgp_decrypt(PGP_Context * ctx, MBuf * msrc, MBuf * mdst) { - int res; + int res; PullFilter *src = NULL; PullFilter *pkt = NULL; - uint8 tag; - int len; - int got_key = 0; - int got_data = 0; + uint8 tag; + int len; + int got_key = 0; + int got_data = 0; res = pullf_create_mbuf_reader(&src, msrc); - while (res >= 0) { + while (res >= 0) + { res = pgp_parse_pkt_hdr(src, &tag, &len, NO_CTX_SIZE); if (res <= 0) break; @@ -1086,7 +1116,8 @@ pgp_decrypt(PGP_Context * ctx, MBuf * msrc, MBuf * mdst) break; res = PXE_PGP_CORRUPT_DATA; - switch (tag) { + switch (tag) + { case PGP_PKT_MARKER: res = pgp_skip_packet(pkt); break; @@ -1097,10 +1128,11 @@ pgp_decrypt(PGP_Context * ctx, MBuf * msrc, MBuf * mdst) break; case PGP_PKT_SYMENCRYPTED_SESSKEY: if (got_key) - /* Theoretically, there could be several keys, - * both public and symmetric, all of which - * encrypt same session key. Decrypt should try - * with each one, before failing. + + /* + * Theoretically, there could be several keys, both public + * and symmetric, all of which encrypt same session key. + * Decrypt should try with each one, before failing. */ px_debug("pgp_decrypt: using first of several keys"); else @@ -1154,4 +1186,3 @@ pgp_decrypt(PGP_Context * ctx, MBuf * msrc, MBuf * mdst) return res; } - diff --git a/contrib/pgcrypto/pgp-encrypt.c b/contrib/pgcrypto/pgp-encrypt.c index 06f46efc62..e2c928154b 100644 --- a/contrib/pgcrypto/pgp-encrypt.c +++ b/contrib/pgcrypto/pgp-encrypt.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-encrypt.c,v 1.2 2005/07/11 15:07:59 tgl Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-encrypt.c,v 1.3 2005/10/15 02:49:06 momjian Exp $ */ #include "postgres.h" @@ -65,9 +65,11 @@ render_newlen(uint8 *h, int len) return h; } -static int write_tag_only(PushFilter *dst, int tag) +static int +write_tag_only(PushFilter * dst, int tag) { - uint8 hdr = 0xC0 | tag; + uint8 hdr = 0xC0 | tag; + return pushf_write(dst, &hdr, 1); } @@ -121,7 +123,7 @@ mdc_flush(PushFilter * dst, void *priv) * create mdc pkt */ pkt[0] = 0xD3; - pkt[1] = 0x14; /* MDC_DIGEST_LEN */ + pkt[1] = 0x14; /* MDC_DIGEST_LEN */ px_md_update(md, pkt, 2); px_md_finish(md, pkt + 2); @@ -150,7 +152,7 @@ static const PushFilterOps mdc_filter = { struct EncStat { PGP_CFB *ciph; - uint8 buf[ENCBUF]; + uint8 buf[ENCBUF]; }; static int @@ -158,28 +160,29 @@ encrypt_init(PushFilter * next, void *init_arg, void **priv_p) { struct EncStat *st; PGP_Context *ctx = init_arg; - PGP_CFB *ciph; - int resync = 1; - int res; + PGP_CFB *ciph; + int resync = 1; + int res; /* should we use newer packet format? */ if (ctx->disable_mdc == 0) { - uint8 ver = 1; + uint8 ver = 1; + resync = 0; res = pushf_write(next, &ver, 1); if (res < 0) return res; } res = pgp_cfb_create(&ciph, ctx->cipher_algo, - ctx->sess_key, ctx->sess_key_len, resync, NULL); + ctx->sess_key, ctx->sess_key_len, resync, NULL); if (res < 0) return res; st = px_alloc(sizeof(*st)); memset(st, 0, sizeof(*st)); st->ciph = ciph; - + *priv_p = st; return ENCBUF; } @@ -189,11 +192,12 @@ encrypt_process(PushFilter * next, void *priv, const uint8 *data, int len) { int res; struct EncStat *st = priv; - int avail = len; + int avail = len; while (avail > 0) { - int tmplen = avail > ENCBUF ? ENCBUF : avail; + int tmplen = avail > ENCBUF ? ENCBUF : avail; + res = pgp_cfb_encrypt(st->ciph, data, tmplen, st->buf); if (res < 0) return res; @@ -303,9 +307,11 @@ static const PushFilterOps pkt_stream_filter = { pkt_stream_init, pkt_stream_process, pkt_stream_flush, pkt_stream_free }; -int pgp_create_pkt_writer(PushFilter *dst, int tag, PushFilter **res_p) +int +pgp_create_pkt_writer(PushFilter * dst, int tag, PushFilter ** res_p) { - int res; + int res; + res = write_tag_only(dst, tag); if (res < 0) return res; @@ -320,17 +326,19 @@ int pgp_create_pkt_writer(PushFilter *dst, int tag, PushFilter **res_p) static int crlf_process(PushFilter * dst, void *priv, const uint8 *data, int len) { - const uint8 * data_end = data + len; - const uint8 * p2, * p1 = data; - int line_len; - static const uint8 crlf[] = { '\r', '\n' }; - int res = 0; + const uint8 *data_end = data + len; + const uint8 *p2, + *p1 = data; + int line_len; + static const uint8 crlf[] = {'\r', '\n'}; + int res = 0; + while (p1 < data_end) { p2 = memchr(p1, '\n', data_end - p1); if (p2 == NULL) p2 = data_end; - + line_len = p2 - p1; /* write data */ @@ -363,13 +371,13 @@ static const PushFilterOps crlf_filter = { * Initialize literal data packet */ static int -init_litdata_packet(PushFilter **pf_res, PGP_Context *ctx, PushFilter *dst) +init_litdata_packet(PushFilter ** pf_res, PGP_Context * ctx, PushFilter * dst) { int res; int hdrlen; uint8 hdr[6]; uint32 t; - PushFilter *pkt; + PushFilter *pkt; int type; /* @@ -382,10 +390,10 @@ init_litdata_packet(PushFilter **pf_res, PGP_Context *ctx, PushFilter *dst) type = 'b'; /* - * Store the creation time into packet. - * The goal is to have as few known bytes as possible. + * Store the creation time into packet. The goal is to have as few known + * bytes as possible. */ - t = (uint32)time(NULL); + t = (uint32) time(NULL); hdr[0] = type; hdr[1] = 0; @@ -418,10 +426,10 @@ init_litdata_packet(PushFilter **pf_res, PGP_Context *ctx, PushFilter *dst) * Initialize compression filter */ static int -init_compress(PushFilter **pf_res, PGP_Context *ctx, PushFilter *dst) +init_compress(PushFilter ** pf_res, PGP_Context * ctx, PushFilter * dst) { - int res; - uint8 type = ctx->compress_algo; + int res; + uint8 type = ctx->compress_algo; PushFilter *pkt; res = write_tag_only(dst, PGP_PKT_COMPRESSED_DATA); @@ -446,7 +454,7 @@ init_compress(PushFilter **pf_res, PGP_Context *ctx, PushFilter *dst) * Initialize encdata packet */ static int -init_encdata_packet(PushFilter **pf_res, PGP_Context *ctx, PushFilter *dst) +init_encdata_packet(PushFilter ** pf_res, PGP_Context * ctx, PushFilter * dst) { int res; int tag; @@ -467,7 +475,7 @@ init_encdata_packet(PushFilter **pf_res, PGP_Context *ctx, PushFilter *dst) * write prefix */ static int -write_prefix(PGP_Context *ctx, PushFilter * dst) +write_prefix(PGP_Context * ctx, PushFilter * dst) { uint8 prefix[PGP_MAX_BLOCK + 2]; int res, @@ -491,17 +499,17 @@ write_prefix(PGP_Context *ctx, PushFilter * dst) */ static int -symencrypt_sesskey(PGP_Context *ctx, uint8 *dst) +symencrypt_sesskey(PGP_Context * ctx, uint8 *dst) { - int res; - PGP_CFB *cfb; - uint8 algo = ctx->cipher_algo; + int res; + PGP_CFB *cfb; + uint8 algo = ctx->cipher_algo; res = pgp_cfb_create(&cfb, ctx->s2k_cipher_algo, - ctx->s2k.key, ctx->s2k.key_len, 0, NULL); + ctx->s2k.key, ctx->s2k.key_len, 0, NULL); if (res < 0) return res; - + pgp_cfb_encrypt(cfb, &algo, 1, dst); pgp_cfb_encrypt(cfb, ctx->sess_key, ctx->sess_key_len, dst + 1); @@ -511,12 +519,12 @@ symencrypt_sesskey(PGP_Context *ctx, uint8 *dst) /* 5.3: Symmetric-Key Encrypted Session-Key */ static int -write_symenc_sesskey(PGP_Context *ctx, PushFilter *dst) +write_symenc_sesskey(PGP_Context * ctx, PushFilter * dst) { uint8 pkt[256]; int pktlen; int res; - uint8 *p = pkt; + uint8 *p = pkt; *p++ = 4; /* 5.3 - version number */ *p++ = ctx->s2k_cipher_algo; @@ -564,13 +572,14 @@ init_s2k_key(PGP_Context * ctx) return res; return pgp_s2k_process(&ctx->s2k, ctx->s2k_cipher_algo, - ctx->sym_key, ctx->sym_key_len); + ctx->sym_key, ctx->sym_key_len); } static int -init_sess_key(PGP_Context *ctx) +init_sess_key(PGP_Context * ctx) { - int res; + int res; + if (ctx->use_sess_key || ctx->pub_key) { ctx->sess_key_len = pgp_get_cipher_key_size(ctx->cipher_algo); @@ -596,7 +605,8 @@ pgp_encrypt(PGP_Context * ctx, MBuf * src, MBuf * dst) int res; int len; uint8 *buf; - PushFilter *pf, *pf_tmp; + PushFilter *pf, + *pf_tmp; /* * do we have any key @@ -618,7 +628,7 @@ pgp_encrypt(PGP_Context * ctx, MBuf * src, MBuf * dst) if (res < 0) goto out; } - + res = init_sess_key(ctx); if (res < 0) goto out; @@ -674,7 +684,7 @@ pgp_encrypt(PGP_Context * ctx, MBuf * src, MBuf * dst) goto out; pf = pf_tmp; - + /* text conversion? */ if (ctx->text_mode && ctx->convert_crlf) { @@ -696,4 +706,3 @@ out: pushf_free_all(pf); return res; } - diff --git a/contrib/pgcrypto/pgp-info.c b/contrib/pgcrypto/pgp-info.c index 89737f51f6..9f887ec6d9 100644 --- a/contrib/pgcrypto/pgp-info.c +++ b/contrib/pgcrypto/pgp-info.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-info.c,v 1.3 2005/08/13 02:06:20 momjian Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-info.c,v 1.4 2005/10/15 02:49:06 momjian Exp $ */ #include "postgres.h" @@ -34,9 +34,10 @@ #include "mbuf.h" #include "pgp.h" -static int read_pubkey_keyid(PullFilter *pkt, uint8 *keyid_buf) +static int +read_pubkey_keyid(PullFilter * pkt, uint8 *keyid_buf) { - int res; + int res; PGP_PubKey *pk = NULL; res = _pgp_read_public_key(pkt, &pk); @@ -66,10 +67,11 @@ err: return res; } -static int read_pubenc_keyid(PullFilter *pkt, uint8 *keyid_buf) +static int +read_pubenc_keyid(PullFilter * pkt, uint8 *keyid_buf) { - uint8 ver; - int res; + uint8 ver; + int res; GETBYTE(pkt, ver); if (ver != 3) @@ -87,45 +89,50 @@ static const char hextbl[] = "0123456789ABCDEF"; static int print_key(uint8 *keyid, char *dst) { - int i; - unsigned c; - for (i = 0; i < 8; i++) { + int i; + unsigned c; + + for (i = 0; i < 8; i++) + { c = keyid[i]; *dst++ = hextbl[(c >> 4) & 0x0F]; *dst++ = hextbl[c & 0x0F]; } *dst = 0; - return 8*2; + return 8 * 2; } -static const uint8 any_key[] = -{ 0, 0, 0, 0, 0, 0, 0, 0 }; +static const uint8 any_key[] = +{0, 0, 0, 0, 0, 0, 0, 0}; /* * dst should have room for 17 bytes */ int -pgp_get_keyid(MBuf *pgp_data, char *dst) +pgp_get_keyid(MBuf * pgp_data, char *dst) { - int res; + int res; PullFilter *src; PullFilter *pkt = NULL; - int len; - uint8 tag; - int got_pub_key=0, got_symenc_key=0, got_pubenc_key=0; - int got_data=0; - uint8 keyid_buf[8]; - int got_main_key=0; + int len; + uint8 tag; + int got_pub_key = 0, + got_symenc_key = 0, + got_pubenc_key = 0; + int got_data = 0; + uint8 keyid_buf[8]; + int got_main_key = 0; res = pullf_create_mbuf_reader(&src, pgp_data); if (res < 0) return res; - while (1) { + while (1) + { res = pgp_parse_pkt_hdr(src, &tag, &len, 0); if (res <= 0) - break; + break; res = pgp_create_pkt_reader(&pkt, src, len, res, NULL); if (res < 0) break; @@ -226,4 +233,3 @@ pgp_get_keyid(MBuf *pgp_data, char *dst) return res; } - diff --git a/contrib/pgcrypto/pgp-mpi-internal.c b/contrib/pgcrypto/pgp-mpi-internal.c index 5cdc0e1b9d..3a81ed46a7 100644 --- a/contrib/pgcrypto/pgp-mpi-internal.c +++ b/contrib/pgcrypto/pgp-mpi-internal.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-mpi-internal.c,v 1.3 2005/08/13 02:06:20 momjian Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-mpi-internal.c,v 1.4 2005/10/15 02:49:06 momjian Exp $ */ #include "postgres.h" @@ -35,27 +35,27 @@ #include "pgp.h" int -pgp_elgamal_encrypt(PGP_PubKey *pk, PGP_MPI *_m, - PGP_MPI **c1_p, PGP_MPI **c2_p) +pgp_elgamal_encrypt(PGP_PubKey * pk, PGP_MPI * _m, + PGP_MPI ** c1_p, PGP_MPI ** c2_p) { return PXE_PGP_NO_BIGNUM; } int -pgp_elgamal_decrypt(PGP_PubKey *pk, PGP_MPI *_c1, PGP_MPI *_c2, - PGP_MPI **msg_p) +pgp_elgamal_decrypt(PGP_PubKey * pk, PGP_MPI * _c1, PGP_MPI * _c2, + PGP_MPI ** msg_p) { return PXE_PGP_NO_BIGNUM; } -int pgp_rsa_encrypt(PGP_PubKey *pk, PGP_MPI *m, PGP_MPI **c) +int +pgp_rsa_encrypt(PGP_PubKey * pk, PGP_MPI * m, PGP_MPI ** c) { return PXE_PGP_NO_BIGNUM; } -int pgp_rsa_decrypt(PGP_PubKey *pk, PGP_MPI *c, PGP_MPI **m) +int +pgp_rsa_decrypt(PGP_PubKey * pk, PGP_MPI * c, PGP_MPI ** m) { return PXE_PGP_NO_BIGNUM; } - - diff --git a/contrib/pgcrypto/pgp-mpi-openssl.c b/contrib/pgcrypto/pgp-mpi-openssl.c index 3ae40ee075..0e692e35d2 100644 --- a/contrib/pgcrypto/pgp-mpi-openssl.c +++ b/contrib/pgcrypto/pgp-mpi-openssl.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-mpi-openssl.c,v 1.3 2005/08/13 02:06:20 momjian Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-mpi-openssl.c,v 1.4 2005/10/15 02:49:06 momjian Exp $ */ #include "postgres.h" @@ -37,15 +37,16 @@ #include "pgp.h" static BIGNUM * -mpi_to_bn(PGP_MPI *n) +mpi_to_bn(PGP_MPI * n) { - BIGNUM *bn = BN_bin2bn(n->data, n->bytes, NULL); + BIGNUM *bn = BN_bin2bn(n->data, n->bytes, NULL); + if (!bn) return NULL; if (BN_num_bits(bn) != n->bits) { px_debug("mpi_to_bn: bignum conversion failed: mpi=%d, bn=%d", - n->bits, BN_num_bits(bn)); + n->bits, BN_num_bits(bn)); BN_clear_free(bn); return NULL; } @@ -55,8 +56,8 @@ mpi_to_bn(PGP_MPI *n) static PGP_MPI * bn_to_mpi(BIGNUM *bn) { - int res; - PGP_MPI *n; + int res; + PGP_MPI *n; res = pgp_mpi_alloc(BN_num_bits(bn), &n); if (res < 0) @@ -65,7 +66,7 @@ bn_to_mpi(BIGNUM *bn) if (BN_num_bytes(bn) != n->bytes) { px_debug("bn_to_mpi: bignum conversion failed: bn=%d, mpi=%d", - BN_num_bytes(bn), n->bytes); + BN_num_bytes(bn), n->bytes); pgp_mpi_free(n); return NULL; } @@ -81,7 +82,7 @@ bn_to_mpi(BIGNUM *bn) * * Until I research it further, I just mimic gpg behaviour. * It has a special mapping table, for values <= 5120, - * above that it uses 'arbitrary high number'. Following + * above that it uses 'arbitrary high number'. Following * algorihm hovers 10-70 bits above gpg values. And for * larger p, it uses gpg's algorihm. * @@ -98,20 +99,20 @@ decide_k_bits(int p_bits) } int -pgp_elgamal_encrypt(PGP_PubKey *pk, PGP_MPI *_m, - PGP_MPI **c1_p, PGP_MPI **c2_p) +pgp_elgamal_encrypt(PGP_PubKey * pk, PGP_MPI * _m, + PGP_MPI ** c1_p, PGP_MPI ** c2_p) { - int res = PXE_PGP_MATH_FAILED; - int k_bits; - BIGNUM *m = mpi_to_bn(_m); - BIGNUM *p = mpi_to_bn(pk->pub.elg.p); - BIGNUM *g = mpi_to_bn(pk->pub.elg.g); - BIGNUM *y = mpi_to_bn(pk->pub.elg.y); - BIGNUM *k = BN_new(); - BIGNUM *yk = BN_new(); - BIGNUM *c1 = BN_new(); - BIGNUM *c2 = BN_new(); - BN_CTX *tmp = BN_CTX_new(); + int res = PXE_PGP_MATH_FAILED; + int k_bits; + BIGNUM *m = mpi_to_bn(_m); + BIGNUM *p = mpi_to_bn(pk->pub.elg.p); + BIGNUM *g = mpi_to_bn(pk->pub.elg.g); + BIGNUM *y = mpi_to_bn(pk->pub.elg.y); + BIGNUM *k = BN_new(); + BIGNUM *yk = BN_new(); + BIGNUM *c1 = BN_new(); + BIGNUM *c2 = BN_new(); + BN_CTX *tmp = BN_CTX_new(); if (!m || !p || !g || !y || !k || !yk || !c1 || !c2 || !tmp) goto err; @@ -124,8 +125,7 @@ pgp_elgamal_encrypt(PGP_PubKey *pk, PGP_MPI *_m, goto err; /* - * c1 = g^k - * c2 = m * y^k + * c1 = g^k c2 = m * y^k */ if (!BN_mod_exp(c1, g, k, p, tmp)) goto err; @@ -140,35 +140,44 @@ pgp_elgamal_encrypt(PGP_PubKey *pk, PGP_MPI *_m, if (*c1_p && *c2_p) res = 0; err: - if (tmp) BN_CTX_free(tmp); - if (c2) BN_clear_free(c2); - if (c1) BN_clear_free(c1); - if (yk) BN_clear_free(yk); - if (k) BN_clear_free(k); - if (y) BN_clear_free(y); - if (g) BN_clear_free(g); - if (p) BN_clear_free(p); - if (m) BN_clear_free(m); + if (tmp) + BN_CTX_free(tmp); + if (c2) + BN_clear_free(c2); + if (c1) + BN_clear_free(c1); + if (yk) + BN_clear_free(yk); + if (k) + BN_clear_free(k); + if (y) + BN_clear_free(y); + if (g) + BN_clear_free(g); + if (p) + BN_clear_free(p); + if (m) + BN_clear_free(m); return res; } int -pgp_elgamal_decrypt(PGP_PubKey *pk, PGP_MPI *_c1, PGP_MPI *_c2, - PGP_MPI **msg_p) +pgp_elgamal_decrypt(PGP_PubKey * pk, PGP_MPI * _c1, PGP_MPI * _c2, + PGP_MPI ** msg_p) { - int res = PXE_PGP_MATH_FAILED; - BIGNUM *c1 = mpi_to_bn(_c1); - BIGNUM *c2 = mpi_to_bn(_c2); - BIGNUM *p = mpi_to_bn(pk->pub.elg.p); - BIGNUM *x = mpi_to_bn(pk->sec.elg.x); - BIGNUM *c1x = BN_new(); - BIGNUM *div = BN_new(); - BIGNUM *m = BN_new(); - BN_CTX *tmp = BN_CTX_new(); + int res = PXE_PGP_MATH_FAILED; + BIGNUM *c1 = mpi_to_bn(_c1); + BIGNUM *c2 = mpi_to_bn(_c2); + BIGNUM *p = mpi_to_bn(pk->pub.elg.p); + BIGNUM *x = mpi_to_bn(pk->sec.elg.x); + BIGNUM *c1x = BN_new(); + BIGNUM *div = BN_new(); + BIGNUM *m = BN_new(); + BN_CTX *tmp = BN_CTX_new(); if (!c1 || !c2 || !p || !x || !c1x || !div || !m || !tmp) goto err; - + /* * m = c2 / (c1^x) */ @@ -184,26 +193,34 @@ pgp_elgamal_decrypt(PGP_PubKey *pk, PGP_MPI *_c1, PGP_MPI *_c2, if (*msg_p) res = 0; err: - if (tmp) BN_CTX_free(tmp); - if (m) BN_clear_free(m); - if (div) BN_clear_free(div); - if (c1x) BN_clear_free(c1x); - if (x) BN_clear_free(x); - if (p) BN_clear_free(p); - if (c2) BN_clear_free(c2); - if (c1) BN_clear_free(c1); + if (tmp) + BN_CTX_free(tmp); + if (m) + BN_clear_free(m); + if (div) + BN_clear_free(div); + if (c1x) + BN_clear_free(c1x); + if (x) + BN_clear_free(x); + if (p) + BN_clear_free(p); + if (c2) + BN_clear_free(c2); + if (c1) + BN_clear_free(c1); return res; } int -pgp_rsa_encrypt(PGP_PubKey *pk, PGP_MPI *_m, PGP_MPI **c_p) +pgp_rsa_encrypt(PGP_PubKey * pk, PGP_MPI * _m, PGP_MPI ** c_p) { - int res = PXE_PGP_MATH_FAILED; - BIGNUM *m = mpi_to_bn(_m); - BIGNUM *e = mpi_to_bn(pk->pub.rsa.e); - BIGNUM *n = mpi_to_bn(pk->pub.rsa.n); - BIGNUM *c = BN_new(); - BN_CTX *tmp = BN_CTX_new(); + int res = PXE_PGP_MATH_FAILED; + BIGNUM *m = mpi_to_bn(_m); + BIGNUM *e = mpi_to_bn(pk->pub.rsa.e); + BIGNUM *n = mpi_to_bn(pk->pub.rsa.n); + BIGNUM *c = BN_new(); + BN_CTX *tmp = BN_CTX_new(); if (!m || !e || !n || !c || !tmp) goto err; @@ -218,23 +235,28 @@ pgp_rsa_encrypt(PGP_PubKey *pk, PGP_MPI *_m, PGP_MPI **c_p) if (*c_p) res = 0; err: - if (tmp) BN_CTX_free(tmp); - if (c) BN_clear_free(c); - if (n) BN_clear_free(n); - if (e) BN_clear_free(e); - if (m) BN_clear_free(m); + if (tmp) + BN_CTX_free(tmp); + if (c) + BN_clear_free(c); + if (n) + BN_clear_free(n); + if (e) + BN_clear_free(e); + if (m) + BN_clear_free(m); return res; } int -pgp_rsa_decrypt(PGP_PubKey *pk, PGP_MPI *_c, PGP_MPI **m_p) +pgp_rsa_decrypt(PGP_PubKey * pk, PGP_MPI * _c, PGP_MPI ** m_p) { - int res = PXE_PGP_MATH_FAILED; - BIGNUM *c = mpi_to_bn(_c); - BIGNUM *d = mpi_to_bn(pk->sec.rsa.d); - BIGNUM *n = mpi_to_bn(pk->pub.rsa.n); - BIGNUM *m = BN_new(); - BN_CTX *tmp = BN_CTX_new(); + int res = PXE_PGP_MATH_FAILED; + BIGNUM *c = mpi_to_bn(_c); + BIGNUM *d = mpi_to_bn(pk->sec.rsa.d); + BIGNUM *n = mpi_to_bn(pk->pub.rsa.n); + BIGNUM *m = BN_new(); + BN_CTX *tmp = BN_CTX_new(); if (!m || !d || !n || !c || !tmp) goto err; @@ -249,11 +271,15 @@ pgp_rsa_decrypt(PGP_PubKey *pk, PGP_MPI *_c, PGP_MPI **m_p) if (*m_p) res = 0; err: - if (tmp) BN_CTX_free(tmp); - if (m) BN_clear_free(m); - if (n) BN_clear_free(n); - if (d) BN_clear_free(d); - if (c) BN_clear_free(c); + if (tmp) + BN_CTX_free(tmp); + if (m) + BN_clear_free(m); + if (n) + BN_clear_free(n); + if (d) + BN_clear_free(d); + if (c) + BN_clear_free(c); return res; } - diff --git a/contrib/pgcrypto/pgp-mpi.c b/contrib/pgcrypto/pgp-mpi.c index 1e19ed7fb4..da0edb1361 100644 --- a/contrib/pgcrypto/pgp-mpi.c +++ b/contrib/pgcrypto/pgp-mpi.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-mpi.c,v 1.3 2005/08/13 02:06:20 momjian Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-mpi.c,v 1.4 2005/10/15 02:49:06 momjian Exp $ */ #include "postgres.h" @@ -34,10 +34,12 @@ #include "mbuf.h" #include "pgp.h" -int pgp_mpi_alloc(int bits, PGP_MPI **mpi) +int +pgp_mpi_alloc(int bits, PGP_MPI ** mpi) { - PGP_MPI *n; - int len = (bits + 7) / 8; + PGP_MPI *n; + int len = (bits + 7) / 8; + if (bits < 0 || bits > 0xFFFF) { px_debug("pgp_mpi_alloc: unreasonable request: bits=%d", bits); @@ -46,15 +48,16 @@ int pgp_mpi_alloc(int bits, PGP_MPI **mpi) n = px_alloc(sizeof(*n) + len); n->bits = bits; n->bytes = len; - n->data = (uint8*)(n) + sizeof(*n); + n->data = (uint8 *) (n) + sizeof(*n); *mpi = n; return 0; } -int pgp_mpi_create(uint8 *data, int bits, PGP_MPI **mpi) +int +pgp_mpi_create(uint8 *data, int bits, PGP_MPI ** mpi) { - int res; - PGP_MPI *n; + int res; + PGP_MPI *n; res = pgp_mpi_alloc(bits, &n); if (res < 0) @@ -64,7 +67,8 @@ int pgp_mpi_create(uint8 *data, int bits, PGP_MPI **mpi) return 0; } -int pgp_mpi_free(PGP_MPI *mpi) +int +pgp_mpi_free(PGP_MPI * mpi) { if (mpi == NULL) return 0; @@ -73,17 +77,18 @@ int pgp_mpi_free(PGP_MPI *mpi) return 0; } -int pgp_mpi_read(PullFilter *src, PGP_MPI **mpi) +int +pgp_mpi_read(PullFilter * src, PGP_MPI ** mpi) { - int res; - uint8 hdr[2]; - int bits; - PGP_MPI *n; + int res; + uint8 hdr[2]; + int bits; + PGP_MPI *n; res = pullf_read_fixed(src, 2, hdr); if (res < 0) return res; - bits = ((unsigned)hdr[0] << 8) + hdr[1]; + bits = ((unsigned) hdr[0] << 8) + hdr[1]; res = pgp_mpi_alloc(bits, &n); if (res < 0) @@ -97,10 +102,11 @@ int pgp_mpi_read(PullFilter *src, PGP_MPI **mpi) return res; } -int pgp_mpi_write(PushFilter *dst, PGP_MPI *n) +int +pgp_mpi_write(PushFilter * dst, PGP_MPI * n) { - int res; - uint8 buf[2]; + int res; + uint8 buf[2]; buf[0] = n->bits >> 8; buf[1] = n->bits & 0xFF; @@ -110,9 +116,10 @@ int pgp_mpi_write(PushFilter *dst, PGP_MPI *n) return res; } -int pgp_mpi_hash(PX_MD *md, PGP_MPI *n) +int +pgp_mpi_hash(PX_MD * md, PGP_MPI * n) { - uint8 buf[2]; + uint8 buf[2]; buf[0] = n->bits >> 8; buf[1] = n->bits & 0xFF; @@ -122,9 +129,10 @@ int pgp_mpi_hash(PX_MD *md, PGP_MPI *n) return 0; } -unsigned pgp_mpi_cksum(unsigned cksum, PGP_MPI *n) +unsigned +pgp_mpi_cksum(unsigned cksum, PGP_MPI * n) { - int i; + int i; cksum += n->bits >> 8; cksum += n->bits & 0xFF; @@ -133,4 +141,3 @@ unsigned pgp_mpi_cksum(unsigned cksum, PGP_MPI *n) return cksum & 0xFFFF; } - diff --git a/contrib/pgcrypto/pgp-pgsql.c b/contrib/pgcrypto/pgp-pgsql.c index e0172fde90..afb926c528 100644 --- a/contrib/pgcrypto/pgp-pgsql.c +++ b/contrib/pgcrypto/pgp-pgsql.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-pgsql.c,v 1.5 2005/09/24 19:14:04 tgl Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-pgsql.c,v 1.6 2005/10/15 02:49:06 momjian Exp $ */ #include "postgres.h" @@ -42,20 +42,20 @@ /* * public functions */ -Datum pgp_sym_encrypt_text(PG_FUNCTION_ARGS); -Datum pgp_sym_encrypt_bytea(PG_FUNCTION_ARGS); -Datum pgp_sym_decrypt_text(PG_FUNCTION_ARGS); -Datum pgp_sym_decrypt_bytea(PG_FUNCTION_ARGS); +Datum pgp_sym_encrypt_text(PG_FUNCTION_ARGS); +Datum pgp_sym_encrypt_bytea(PG_FUNCTION_ARGS); +Datum pgp_sym_decrypt_text(PG_FUNCTION_ARGS); +Datum pgp_sym_decrypt_bytea(PG_FUNCTION_ARGS); -Datum pgp_pub_encrypt_text(PG_FUNCTION_ARGS); -Datum pgp_pub_encrypt_bytea(PG_FUNCTION_ARGS); -Datum pgp_pub_decrypt_text(PG_FUNCTION_ARGS); -Datum pgp_pub_decrypt_bytea(PG_FUNCTION_ARGS); +Datum pgp_pub_encrypt_text(PG_FUNCTION_ARGS); +Datum pgp_pub_encrypt_bytea(PG_FUNCTION_ARGS); +Datum pgp_pub_decrypt_text(PG_FUNCTION_ARGS); +Datum pgp_pub_decrypt_bytea(PG_FUNCTION_ARGS); -Datum pgp_key_id_w(PG_FUNCTION_ARGS); +Datum pgp_key_id_w(PG_FUNCTION_ARGS); -Datum pg_armor(PG_FUNCTION_ARGS); -Datum pg_dearmor(PG_FUNCTION_ARGS); +Datum pg_armor(PG_FUNCTION_ARGS); +Datum pg_dearmor(PG_FUNCTION_ARGS); /* function headers */ @@ -89,9 +89,10 @@ PG_FUNCTION_INFO_V1(pg_dearmor); /* * Mix a block of data into RNG. */ -static void add_block_entropy(PX_MD *md, text *data) +static void +add_block_entropy(PX_MD * md, text *data) { - uint8 sha1[20]; + uint8 sha1[20]; px_md_reset(md); px_md_update(md, (uint8 *) VARDATA(data), VARSIZE(data) - VARHDRSZ); @@ -103,13 +104,14 @@ static void add_block_entropy(PX_MD *md, text *data) } /* - * Mix user data into RNG. It is for user own interests to have + * Mix user data into RNG. It is for user own interests to have * RNG state shuffled. */ -static void add_entropy(text *data1, text *data2, text *data3) +static void +add_entropy(text *data1, text *data2, text *data3) { - PX_MD *md; - uint8 rnd[3]; + PX_MD *md; + uint8 rnd[3]; if (!data1 && !data2 && !data3) return; @@ -122,9 +124,9 @@ static void add_entropy(text *data1, text *data2, text *data3) /* * Try to make the feeding unpredictable. - * - * Prefer data over keys, as it's rather likely - * that key is same in several calls. + * + * Prefer data over keys, as it's rather likely that key is same in several + * calls. */ /* chance: 7/8 */ @@ -146,14 +148,15 @@ static void add_entropy(text *data1, text *data2, text *data3) /* * returns src in case of no conversion or error */ -static text *convert_charset(text *src, int cset_from, int cset_to) +static text * +convert_charset(text *src, int cset_from, int cset_to) { - int src_len = VARSIZE(src) - VARHDRSZ; - int dst_len; + int src_len = VARSIZE(src) - VARHDRSZ; + int dst_len; unsigned char *dst; unsigned char *csrc = (unsigned char *) VARDATA(src); - text *res; - + text *res; + dst = pg_do_encoding_conversion(csrc, src_len, cset_from, cset_to); if (dst == csrc) return src; @@ -166,12 +169,14 @@ static text *convert_charset(text *src, int cset_from, int cset_to) return res; } -static text *convert_from_utf8(text *src) +static text * +convert_from_utf8(text *src) { return convert_charset(src, PG_UTF8, GetDatabaseEncoding()); } -static text *convert_to_utf8(text *src) +static text * +convert_to_utf8(text *src) { return convert_charset(src, GetDatabaseEncoding(), PG_UTF8); } @@ -186,20 +191,22 @@ clear_and_pfree(text *p) /* * expect-* arguments storage */ -struct debug_expect { - int debug; - int expect; - int cipher_algo; - int s2k_mode; - int s2k_cipher_algo; - int s2k_digest_algo; - int compress_algo; - int use_sess_key; - int disable_mdc; - int unicode_mode; +struct debug_expect +{ + int debug; + int expect; + int cipher_algo; + int s2k_mode; + int s2k_cipher_algo; + int s2k_digest_algo; + int compress_algo; + int use_sess_key; + int disable_mdc; + int unicode_mode; }; -static void fill_expect(struct debug_expect *ex, int text_mode) +static void +fill_expect(struct debug_expect * ex, int text_mode) { ex->debug = 0; ex->expect = 0; @@ -222,7 +229,8 @@ static void fill_expect(struct debug_expect *ex, int text_mode) if (ex->arg >= 0 && ex->arg != ctx->arg) EX_MSG(arg); \ } while (0) -static void check_expect(PGP_Context *ctx, struct debug_expect *ex) +static void +check_expect(PGP_Context * ctx, struct debug_expect * ex) { EX_CHECK(cipher_algo); EX_CHECK(s2k_mode); @@ -235,15 +243,18 @@ static void check_expect(PGP_Context *ctx, struct debug_expect *ex) EX_CHECK(unicode_mode); } -static void show_debug(const char *msg) +static void +show_debug(const char *msg) { ereport(NOTICE, (errmsg("dbg: %s", msg))); } -static int set_arg(PGP_Context *ctx, char *key, char*val, - struct debug_expect *ex) +static int +set_arg(PGP_Context * ctx, char *key, char *val, + struct debug_expect * ex) { - int res = 0; + int res = 0; + if (strcmp(key, "cipher-algo") == 0) res = pgp_set_cipher_algo(ctx, val); else if (strcmp(key, "disable-mdc") == 0) @@ -314,11 +325,12 @@ static int set_arg(PGP_Context *ctx, char *key, char*val, } /* - * Find next word. Handle ',' and '=' as words. Skip whitespace. + * Find next word. Handle ',' and '=' as words. Skip whitespace. * Put word info into res_p, res_len. * Returns ptr to next word. */ -static char *getword(char *p, char **res_p, int *res_len) +static char * +getword(char *p, char **res_p, int *res_len) { /* whitespace at start */ while (*p && (*p == ' ' || *p == '\t' || *p == '\n')) @@ -330,12 +342,12 @@ static char *getword(char *p, char **res_p, int *res_len) p++; else while (*p && !(*p == ' ' || *p == '\t' || *p == '\n' - || *p == '=' || *p == ',')) + || *p == '=' || *p == ',')) p++; /* word end */ *res_len = p - *res_p; - + /* whitespace at end */ while (*p && (*p == ' ' || *p == '\t' || *p == '\n')) p++; @@ -346,11 +358,15 @@ static char *getword(char *p, char **res_p, int *res_len) /* * Convert to lowercase asciiz string. */ -static char *downcase_convert(const uint8 *s, int len) +static char * +downcase_convert(const uint8 *s, int len) { - int c, i; - char *res = palloc(len + 1); - for (i = 0; i < len; i++) { + int c, + i; + char *res = palloc(len + 1); + + for (i = 0; i < len; i++) + { c = s[i]; if (c >= 'A' && c <= 'Z') c += 'a' - 'A'; @@ -360,14 +376,17 @@ static char *downcase_convert(const uint8 *s, int len) return res; } -static int parse_args(PGP_Context *ctx, uint8 *args, int arg_len, - struct debug_expect *ex) +static int +parse_args(PGP_Context * ctx, uint8 *args, int arg_len, + struct debug_expect * ex) { - char *str = downcase_convert(args, arg_len); - char *key, *val; - int key_len, val_len; - int res = 0; - char *p = str; + char *str = downcase_convert(args, arg_len); + char *key, + *val; + int key_len, + val_len; + int res = 0; + char *p = str; while (*p) { @@ -403,10 +422,10 @@ create_mbuf_from_vardata(text *data) } static void -init_work(PGP_Context **ctx_p, int is_text, - text *args, struct debug_expect *ex) +init_work(PGP_Context ** ctx_p, int is_text, + text *args, struct debug_expect * ex) { - int err = pgp_init(ctx_p); + int err = pgp_init(ctx_p); fill_expect(ex, is_text); @@ -429,17 +448,18 @@ init_work(PGP_Context **ctx_p, int is_text, static bytea * encrypt_internal(int is_pubenc, int is_text, - text *data, text *key, text *args) + text *data, text *key, text *args) { - MBuf *src, *dst; - uint8 tmp[VARHDRSZ]; - uint8 *restmp; - bytea *res; - int res_len; + MBuf *src, + *dst; + uint8 tmp[VARHDRSZ]; + uint8 *restmp; + bytea *res; + int res_len; PGP_Context *ctx; - int err; + int err; struct debug_expect ex; - text *tmp_data = NULL; + text *tmp_data = NULL; /* * Add data and key info RNG. @@ -470,15 +490,16 @@ encrypt_internal(int is_pubenc, int is_text, */ if (is_pubenc) { - MBuf *kbuf = create_mbuf_from_vardata(key); + MBuf *kbuf = create_mbuf_from_vardata(key); + err = pgp_set_pubkey(ctx, kbuf, - NULL, 0, 0); + NULL, 0, 0); mbuf_free(kbuf); } else err = pgp_set_symkey(ctx, (uint8 *) VARDATA(key), VARSIZE(key) - VARHDRSZ); - + /* * encrypt */ @@ -520,17 +541,18 @@ encrypt_internal(int is_pubenc, int is_text, static bytea * decrypt_internal(int is_pubenc, int need_text, text *data, - text *key, text *keypsw, text *args) + text *key, text *keypsw, text *args) { - int err; - MBuf *src = NULL, *dst = NULL; - uint8 tmp[VARHDRSZ]; - uint8 *restmp; - bytea *res; - int res_len; + int err; + MBuf *src = NULL, + *dst = NULL; + uint8 tmp[VARHDRSZ]; + uint8 *restmp; + bytea *res; + int res_len; PGP_Context *ctx = NULL; struct debug_expect ex; - int got_unicode = 0; + int got_unicode = 0; init_work(&ctx, need_text, args, &ex); @@ -543,15 +565,16 @@ decrypt_internal(int is_pubenc, int need_text, text *data, * reserve room for header */ mbuf_append(dst, tmp, VARHDRSZ); - + /* * set key */ if (is_pubenc) { - uint8 *psw = NULL; - int psw_len = 0; - MBuf *kbuf; + uint8 *psw = NULL; + int psw_len = 0; + MBuf *kbuf; + if (keypsw) { psw = (uint8 *) VARDATA(keypsw); @@ -608,7 +631,8 @@ out: if (need_text && got_unicode) { - text *utf = convert_from_utf8(res); + text *utf = convert_from_utf8(res); + if (utf != res) { clear_and_pfree(res); @@ -927,4 +951,3 @@ pgp_key_id_w(PG_FUNCTION_ARGS) PG_FREE_IF_COPY(data, 0); PG_RETURN_TEXT_P(res); } - diff --git a/contrib/pgcrypto/pgp-pubdec.c b/contrib/pgcrypto/pgp-pubdec.c index 04e98ceacb..600a1e2531 100644 --- a/contrib/pgcrypto/pgp-pubdec.c +++ b/contrib/pgcrypto/pgp-pubdec.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-pubdec.c,v 1.4 2005/08/13 02:06:20 momjian Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-pubdec.c,v 1.5 2005/10/15 02:49:06 momjian Exp $ */ #include "postgres.h" @@ -35,24 +35,25 @@ #include "pgp.h" /* - * padded msg = 02 || PS || 00 || M + * padded msg = 02 || PS || 00 || M * PS - pad bytes * M - msg */ static uint8 * check_eme_pkcs1_v15(uint8 *data, int len) { - uint8 *data_end = data + len; - uint8 *p = data; - int rnd = 0; + uint8 *data_end = data + len; + uint8 *p = data; + int rnd = 0; if (len < 1 + 8 + 1) return NULL; if (*p++ != 2) return NULL; - - while (p < data_end && *p) { + + while (p < data_end && *p) + { p++; rnd++; } @@ -73,8 +74,9 @@ check_eme_pkcs1_v15(uint8 *data, int len) static int control_cksum(uint8 *msg, int msglen) { - int i; - unsigned my_cksum, got_cksum; + int i; + unsigned my_cksum, + got_cksum; if (msglen < 3) return PXE_PGP_WRONG_KEY; @@ -83,8 +85,9 @@ control_cksum(uint8 *msg, int msglen) for (i = 1; i < msglen - 2; i++) my_cksum += msg[i]; my_cksum &= 0xFFFF; - got_cksum = ((unsigned)(msg[msglen-2]) << 8) + msg[msglen-1]; - if (my_cksum != got_cksum) { + got_cksum = ((unsigned) (msg[msglen - 2]) << 8) + msg[msglen - 1]; + if (my_cksum != got_cksum) + { px_debug("pubenc cksum failed"); return PXE_PGP_WRONG_KEY; } @@ -92,11 +95,11 @@ control_cksum(uint8 *msg, int msglen) } static int -decrypt_elgamal(PGP_PubKey *pk, PullFilter *pkt, PGP_MPI **m_p) +decrypt_elgamal(PGP_PubKey * pk, PullFilter * pkt, PGP_MPI ** m_p) { - int res; - PGP_MPI *c1 = NULL; - PGP_MPI *c2 = NULL; + int res; + PGP_MPI *c1 = NULL; + PGP_MPI *c2 = NULL; if (pk->algo != PGP_PUB_ELG_ENCRYPT) return PXE_PGP_WRONG_KEY; @@ -119,13 +122,13 @@ out: } static int -decrypt_rsa(PGP_PubKey *pk, PullFilter *pkt, PGP_MPI **m_p) +decrypt_rsa(PGP_PubKey * pk, PullFilter * pkt, PGP_MPI ** m_p) { - int res; - PGP_MPI *c; + int res; + PGP_MPI *c; if (pk->algo != PGP_PUB_RSA_ENCRYPT - && pk->algo != PGP_PUB_RSA_ENCRYPT_SIGN) + && pk->algo != PGP_PUB_RSA_ENCRYPT_SIGN) return PXE_PGP_WRONG_KEY; /* read rsa encrypted data */ @@ -142,28 +145,30 @@ decrypt_rsa(PGP_PubKey *pk, PullFilter *pkt, PGP_MPI **m_p) /* key id is missing - user is expected to try all keys */ static const uint8 -any_key[] = {0, 0, 0, 0, 0, 0, 0, 0}; + any_key[] = {0, 0, 0, 0, 0, 0, 0, 0}; int -pgp_parse_pubenc_sesskey(PGP_Context *ctx, PullFilter *pkt) +pgp_parse_pubenc_sesskey(PGP_Context * ctx, PullFilter * pkt) { - int ver; - int algo; - int res; - uint8 key_id[8]; + int ver; + int algo; + int res; + uint8 key_id[8]; PGP_PubKey *pk; - uint8 *msg; - int msglen; - PGP_MPI *m; + uint8 *msg; + int msglen; + PGP_MPI *m; pk = ctx->pub_key; - if (pk == NULL) { + if (pk == NULL) + { px_debug("no pubkey?"); return PXE_BUG; } GETBYTE(pkt, ver); - if (ver != 3) { + if (ver != 3) + { px_debug("unknown pubenc_sesskey pkt ver=%d", ver); return PXE_PGP_CORRUPT_DATA; } @@ -175,7 +180,7 @@ pgp_parse_pubenc_sesskey(PGP_Context *ctx, PullFilter *pkt) if (res < 0) return res; if (memcmp(key_id, any_key, 8) != 0 - && memcmp(key_id, pk->key_id, 8) != 0) + && memcmp(key_id, pk->key_id, 8) != 0) { px_debug("key_id's does not match"); return PXE_PGP_WRONG_KEY; @@ -204,7 +209,8 @@ pgp_parse_pubenc_sesskey(PGP_Context *ctx, PullFilter *pkt) * extract message */ msg = check_eme_pkcs1_v15(m->data, m->bytes); - if (msg == NULL) { + if (msg == NULL) + { px_debug("check_eme_pkcs1_v15 failed"); res = PXE_PGP_WRONG_KEY; goto out; @@ -228,5 +234,3 @@ out: return res; return pgp_expect_packet_end(pkt); } - - diff --git a/contrib/pgcrypto/pgp-pubenc.c b/contrib/pgcrypto/pgp-pubenc.c index 3b2dd85c48..de729476f5 100644 --- a/contrib/pgcrypto/pgp-pubenc.c +++ b/contrib/pgcrypto/pgp-pubenc.c @@ -1,6 +1,6 @@ /* * pgp-pubenc.c - * Encrypt session key with public key. + * Encrypt session key with public key. * * Copyright (c) 2005 Marko Kreen * All rights reserved. @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-pubenc.c,v 1.3 2005/08/13 02:06:20 momjian Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-pubenc.c,v 1.4 2005/10/15 02:49:06 momjian Exp $ */ #include "postgres.h" @@ -40,9 +40,10 @@ static int pad_eme_pkcs1_v15(uint8 *data, int data_len, int res_len, uint8 **res_p) { - int res; - uint8 *buf, *p; - int pad_len = res_len - 2 - data_len; + int res; + uint8 *buf, + *p; + int pad_len = res_len - 2 - data_len; if (pad_len < 8) return PXE_BUG; @@ -76,7 +77,7 @@ pad_eme_pkcs1_v15(uint8 *data, int data_len, int res_len, uint8 **res_p) px_free(buf); return res; } - + buf[pad_len + 1] = 0; memcpy(buf + pad_len + 2, data, data_len); *res_p = buf; @@ -85,19 +86,20 @@ pad_eme_pkcs1_v15(uint8 *data, int data_len, int res_len, uint8 **res_p) } static int -create_secmsg(PGP_Context *ctx, PGP_MPI **msg_p, int full_bytes) +create_secmsg(PGP_Context * ctx, PGP_MPI ** msg_p, int full_bytes) { - uint8 *secmsg; - int res, i; - unsigned cksum = 0; - int klen = ctx->sess_key_len; - uint8 *padded = NULL; - PGP_MPI *m = NULL; + uint8 *secmsg; + int res, + i; + unsigned cksum = 0; + int klen = ctx->sess_key_len; + uint8 *padded = NULL; + PGP_MPI *m = NULL; /* calc checksum */ for (i = 0; i < klen; i++) cksum += ctx->sess_key[i]; - + /* * create "secret message" */ @@ -114,7 +116,8 @@ create_secmsg(PGP_Context *ctx, PGP_MPI **msg_p, int full_bytes) if (res >= 0) { /* first byte will be 0x02 */ - int full_bits = full_bytes * 8 - 6; + int full_bits = full_bytes * 8 - 6; + res = pgp_mpi_create(padded, full_bits, &m); } @@ -133,10 +136,12 @@ create_secmsg(PGP_Context *ctx, PGP_MPI **msg_p, int full_bytes) } static int -encrypt_and_write_elgamal(PGP_Context *ctx, PGP_PubKey *pk, PushFilter *pkt) +encrypt_and_write_elgamal(PGP_Context * ctx, PGP_PubKey * pk, PushFilter * pkt) { - int res; - PGP_MPI *m = NULL, *c1 = NULL, *c2 = NULL; + int res; + PGP_MPI *m = NULL, + *c1 = NULL, + *c2 = NULL; /* create padded msg */ res = create_secmsg(ctx, &m, pk->pub.elg.p->bytes - 1); @@ -162,10 +167,11 @@ err: } static int -encrypt_and_write_rsa(PGP_Context *ctx, PGP_PubKey *pk, PushFilter *pkt) +encrypt_and_write_rsa(PGP_Context * ctx, PGP_PubKey * pk, PushFilter * pkt) { - int res; - PGP_MPI *m = NULL, *c = NULL; + int res; + PGP_MPI *m = NULL, + *c = NULL; /* create padded msg */ res = create_secmsg(ctx, &m, pk->pub.rsa.n->bytes - 1); @@ -186,15 +192,17 @@ err: return res; } -int pgp_write_pubenc_sesskey(PGP_Context *ctx, PushFilter *dst) +int +pgp_write_pubenc_sesskey(PGP_Context * ctx, PushFilter * dst) { - int res; + int res; PGP_PubKey *pk = ctx->pub_key; - uint8 ver = 3; + uint8 ver = 3; PushFilter *pkt = NULL; - uint8 algo = pk->algo; + uint8 algo = pk->algo; - if (pk == NULL) { + if (pk == NULL) + { px_debug("no pubkey?\n"); return PXE_BUG; } @@ -238,5 +246,3 @@ err: return res; } - - diff --git a/contrib/pgcrypto/pgp-pubkey.c b/contrib/pgcrypto/pgp-pubkey.c index 9eb3c23c08..3904561806 100644 --- a/contrib/pgcrypto/pgp-pubkey.c +++ b/contrib/pgcrypto/pgp-pubkey.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-pubkey.c,v 1.3 2005/08/13 02:06:20 momjian Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-pubkey.c,v 1.4 2005/10/15 02:49:06 momjian Exp $ */ #include "postgres.h" @@ -34,16 +34,19 @@ #include "mbuf.h" #include "pgp.h" -int pgp_key_alloc(PGP_PubKey **pk_p) +int +pgp_key_alloc(PGP_PubKey ** pk_p) { PGP_PubKey *pk; + pk = px_alloc(sizeof(*pk)); memset(pk, 0, sizeof(*pk)); *pk_p = pk; return 0; } -void pgp_key_free(PGP_PubKey *pk) +void +pgp_key_free(PGP_PubKey * pk) { if (pk == NULL) return; @@ -79,13 +82,13 @@ void pgp_key_free(PGP_PubKey *pk) } static int -calc_key_id(PGP_PubKey *pk) +calc_key_id(PGP_PubKey * pk) { - int res; - PX_MD *md; - int len; - uint8 hdr[3]; - uint8 hash[20]; + int res; + PX_MD *md; + int len; + uint8 hdr[3]; + uint8 hash[20]; res = pgp_load_digest(PGP_DIGEST_SHA1, &md); if (res < 0) @@ -121,7 +124,7 @@ calc_key_id(PGP_PubKey *pk) px_md_update(md, &pk->ver, 1); px_md_update(md, pk->time, 4); px_md_update(md, &pk->algo, 1); - + switch (pk->algo) { case PGP_PUB_ELG_ENCRYPT: @@ -152,9 +155,10 @@ calc_key_id(PGP_PubKey *pk) return 0; } -int _pgp_read_public_key(PullFilter *pkt, PGP_PubKey **pk_p) +int +_pgp_read_public_key(PullFilter * pkt, PGP_PubKey ** pk_p) { - int res; + int res; PGP_PubKey *pk; res = pgp_key_alloc(&pk); @@ -163,11 +167,12 @@ int _pgp_read_public_key(PullFilter *pkt, PGP_PubKey **pk_p) /* get version */ GETBYTE(pkt, pk->ver); - if (pk->ver != 4) { + if (pk->ver != 4) + { res = PXE_PGP_NOT_V4_KEYPKT; goto out; } - + /* read time */ res = pullf_read_fixed(pkt, 4, pk->time); if (res < 0) @@ -176,16 +181,21 @@ int _pgp_read_public_key(PullFilter *pkt, PGP_PubKey **pk_p) /* pubkey algorithm */ GETBYTE(pkt, pk->algo); - switch (pk->algo) { + switch (pk->algo) + { case PGP_PUB_DSA_SIGN: res = pgp_mpi_read(pkt, &pk->pub.dsa.p); - if (res < 0) break; + if (res < 0) + break; res = pgp_mpi_read(pkt, &pk->pub.dsa.q); - if (res < 0) break; + if (res < 0) + break; res = pgp_mpi_read(pkt, &pk->pub.dsa.g); - if (res < 0) break; + if (res < 0) + break; res = pgp_mpi_read(pkt, &pk->pub.dsa.y); - if (res < 0) break; + if (res < 0) + break; res = calc_key_id(pk); break; @@ -194,9 +204,11 @@ int _pgp_read_public_key(PullFilter *pkt, PGP_PubKey **pk_p) case PGP_PUB_RSA_ENCRYPT: case PGP_PUB_RSA_ENCRYPT_SIGN: res = pgp_mpi_read(pkt, &pk->pub.rsa.n); - if (res < 0) break; + if (res < 0) + break; res = pgp_mpi_read(pkt, &pk->pub.rsa.e); - if (res < 0) break; + if (res < 0) + break; res = calc_key_id(pk); @@ -206,11 +218,14 @@ int _pgp_read_public_key(PullFilter *pkt, PGP_PubKey **pk_p) case PGP_PUB_ELG_ENCRYPT: res = pgp_mpi_read(pkt, &pk->pub.elg.p); - if (res < 0) break; + if (res < 0) + break; res = pgp_mpi_read(pkt, &pk->pub.elg.g); - if (res < 0) break; + if (res < 0) + break; res = pgp_mpi_read(pkt, &pk->pub.elg.y); - if (res < 0) break; + if (res < 0) + break; res = calc_key_id(pk); @@ -236,12 +251,12 @@ out: #define HIDE_SHA1 254 static int -check_key_sha1(PullFilter *src, PGP_PubKey *pk) +check_key_sha1(PullFilter * src, PGP_PubKey * pk) { - int res; - uint8 got_sha1[20]; - uint8 my_sha1[20]; - PX_MD *md; + int res; + uint8 got_sha1[20]; + uint8 my_sha1[20]; + PX_MD *md; res = pullf_read_fixed(src, 20, got_sha1); if (res < 0) @@ -282,17 +297,18 @@ err: } static int -check_key_cksum(PullFilter *src, PGP_PubKey *pk) +check_key_cksum(PullFilter * src, PGP_PubKey * pk) { - int res; - unsigned got_cksum, my_cksum = 0; - uint8 buf[2]; + int res; + unsigned got_cksum, + my_cksum = 0; + uint8 buf[2]; res = pullf_read_fixed(src, 2, buf); if (res < 0) return res; - got_cksum = ((unsigned)buf[0] << 8) + buf[1]; + got_cksum = ((unsigned) buf[0] << 8) + buf[1]; switch (pk->algo) { case PGP_PUB_ELG_ENCRYPT: @@ -318,17 +334,19 @@ check_key_cksum(PullFilter *src, PGP_PubKey *pk) return 0; } -static int process_secret_key(PullFilter *pkt, PGP_PubKey **pk_p, - const uint8 *key, int key_len) +static int +process_secret_key(PullFilter * pkt, PGP_PubKey ** pk_p, + const uint8 *key, int key_len) { - int res; - int hide_type; - int cipher_algo; - int bs; - uint8 iv[512]; - PullFilter *pf_decrypt = NULL, *pf_key; - PGP_CFB *cfb = NULL; - PGP_S2K s2k; + int res; + int hide_type; + int cipher_algo; + int bs; + uint8 iv[512]; + PullFilter *pf_decrypt = NULL, + *pf_key; + PGP_CFB *cfb = NULL; + PGP_S2K s2k; PGP_PubKey *pk; /* first read public key part */ @@ -340,7 +358,8 @@ static int process_secret_key(PullFilter *pkt, PGP_PubKey **pk_p, * is secret key encrypted? */ GETBYTE(pkt, hide_type); - if (hide_type == HIDE_SHA1 || hide_type == HIDE_CKSUM) { + if (hide_type == HIDE_SHA1 || hide_type == HIDE_CKSUM) + { if (key == NULL) return PXE_PGP_NEED_SECRET_PSW; GETBYTE(pkt, cipher_algo); @@ -351,15 +370,17 @@ static int process_secret_key(PullFilter *pkt, PGP_PubKey **pk_p, res = pgp_s2k_process(&s2k, cipher_algo, key, key_len); if (res < 0) return res; - + bs = pgp_get_cipher_block_size(cipher_algo); - if (bs == 0) { + if (bs == 0) + { px_debug("unknown cipher algo=%d", cipher_algo); return PXE_PGP_UNSUPPORTED_CIPHER; } res = pullf_read_fixed(pkt, bs, iv); if (res < 0) return res; + /* * create decrypt filter */ @@ -370,26 +391,35 @@ static int process_secret_key(PullFilter *pkt, PGP_PubKey **pk_p, if (res < 0) return res; pf_key = pf_decrypt; - } else if (hide_type == HIDE_CLEAR) { + } + else if (hide_type == HIDE_CLEAR) + { pf_key = pkt; - } else { + } + else + { px_debug("unknown hide type"); return PXE_PGP_KEYPKT_CORRUPT; } /* read secret key */ - switch (pk->algo) { + switch (pk->algo) + { case PGP_PUB_RSA_SIGN: case PGP_PUB_RSA_ENCRYPT: case PGP_PUB_RSA_ENCRYPT_SIGN: res = pgp_mpi_read(pkt, &pk->sec.rsa.d); - if (res < 0) break; + if (res < 0) + break; res = pgp_mpi_read(pkt, &pk->sec.rsa.p); - if (res < 0) break; + if (res < 0) + break; res = pgp_mpi_read(pkt, &pk->sec.rsa.q); - if (res < 0) break; + if (res < 0) + break; res = pgp_mpi_read(pkt, &pk->sec.rsa.u); - if (res < 0) break; + if (res < 0) + break; break; case PGP_PUB_ELG_ENCRYPT: res = pgp_mpi_read(pf_key, &pk->sec.elg.x); @@ -426,31 +456,33 @@ static int process_secret_key(PullFilter *pkt, PGP_PubKey **pk_p, } static int -internal_read_key(PullFilter *src, PGP_PubKey **pk_p, - const uint8 *psw, int psw_len, int pubtype) +internal_read_key(PullFilter * src, PGP_PubKey ** pk_p, + const uint8 *psw, int psw_len, int pubtype) { PullFilter *pkt = NULL; - int res; - uint8 tag; - int len; + int res; + uint8 tag; + int len; PGP_PubKey *enc_key = NULL; PGP_PubKey *pk = NULL; - int got_main_key = 0; + int got_main_key = 0; /* * Search for encryption key. * * Error out on anything fancy. */ - while (1) { + while (1) + { res = pgp_parse_pkt_hdr(src, &tag, &len, 0); if (res <= 0) break; res = pgp_create_pkt_reader(&pkt, src, len, res, NULL); if (res < 0) break; - - switch (tag) { + + switch (tag) + { case PGP_PKT_PUBLIC_KEY: case PGP_PKT_SECRET_KEY: if (got_main_key) @@ -489,7 +521,7 @@ internal_read_key(PullFilter *src, PGP_PubKey **pk_p, res = PXE_PGP_UNEXPECTED_PKT; } pullf_free(pkt); - pkt = NULL; + pkt = NULL; if (pk != NULL) { @@ -531,10 +563,10 @@ internal_read_key(PullFilter *src, PGP_PubKey **pk_p, } int -pgp_set_pubkey(PGP_Context *ctx, MBuf *keypkt, - const uint8 *key, int key_len, int pubtype) +pgp_set_pubkey(PGP_Context * ctx, MBuf * keypkt, + const uint8 *key, int key_len, int pubtype) { - int res; + int res; PullFilter *src; PGP_PubKey *pk = NULL; @@ -550,4 +582,3 @@ pgp_set_pubkey(PGP_Context *ctx, MBuf *keypkt, return res < 0 ? res : 0; } - diff --git a/contrib/pgcrypto/pgp-s2k.c b/contrib/pgcrypto/pgp-s2k.c index cbde42a13b..84def87db6 100644 --- a/contrib/pgcrypto/pgp-s2k.c +++ b/contrib/pgcrypto/pgp-s2k.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-s2k.c,v 1.3 2005/07/18 17:12:54 tgl Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-s2k.c,v 1.4 2005/10/15 02:49:06 momjian Exp $ */ #include "postgres.h" @@ -36,7 +36,7 @@ #include "pgp.h" static int -calc_s2k_simple(PGP_S2K * s2k, PX_MD *md, const uint8 *key, +calc_s2k_simple(PGP_S2K * s2k, PX_MD * md, const uint8 *key, unsigned key_len) { unsigned md_bs, @@ -81,7 +81,7 @@ calc_s2k_simple(PGP_S2K * s2k, PX_MD *md, const uint8 *key, } static int -calc_s2k_salted(PGP_S2K * s2k, PX_MD *md, const uint8 *key, unsigned key_len) +calc_s2k_salted(PGP_S2K * s2k, PX_MD * md, const uint8 *key, unsigned key_len) { unsigned md_bs, md_rlen; @@ -126,8 +126,8 @@ calc_s2k_salted(PGP_S2K * s2k, PX_MD *md, const uint8 *key, unsigned key_len) } static int -calc_s2k_iter_salted(PGP_S2K * s2k, PX_MD *md, const uint8 *key, - unsigned key_len) +calc_s2k_iter_salted(PGP_S2K * s2k, PX_MD * md, const uint8 *key, + unsigned key_len) { unsigned md_bs, md_rlen; @@ -200,7 +200,7 @@ calc_s2k_iter_salted(PGP_S2K * s2k, PX_MD *md, const uint8 *key, /* * Decide S2K_ISALTED iteration count - * + * * Too small: weak * Too big: slow * gpg defaults to 96 => 65536 iters @@ -213,15 +213,16 @@ decide_count(unsigned rand_byte) } int -pgp_s2k_fill(PGP_S2K *s2k, int mode,int digest_algo) +pgp_s2k_fill(PGP_S2K * s2k, int mode, int digest_algo) { - int res = 0; - uint8 tmp; + int res = 0; + uint8 tmp; s2k->mode = mode; s2k->digest_algo = digest_algo; - switch (s2k->mode) { + switch (s2k->mode) + { case 0: break; case 1: @@ -243,13 +244,14 @@ pgp_s2k_fill(PGP_S2K *s2k, int mode,int digest_algo) } int -pgp_s2k_read(PullFilter *src, PGP_S2K *s2k) +pgp_s2k_read(PullFilter * src, PGP_S2K * s2k) { - int res = 0; + int res = 0; GETBYTE(src, s2k->mode); GETBYTE(src, s2k->digest_algo); - switch (s2k->mode) { + switch (s2k->mode) + { case 0: break; case 1: @@ -267,10 +269,11 @@ pgp_s2k_read(PullFilter *src, PGP_S2K *s2k) return res; } -int pgp_s2k_process(PGP_S2K *s2k, int cipher, const uint8 *key, int key_len) +int +pgp_s2k_process(PGP_S2K * s2k, int cipher, const uint8 *key, int key_len) { - int res; - PX_MD *md; + int res; + PX_MD *md; s2k->key_len = pgp_get_cipher_key_size(cipher); if (s2k->key_len <= 0) @@ -280,7 +283,8 @@ int pgp_s2k_process(PGP_S2K *s2k, int cipher, const uint8 *key, int key_len) if (res < 0) return res; - switch (s2k->mode) { + switch (s2k->mode) + { case 0: res = calc_s2k_simple(s2k, md, key, key_len); break; @@ -296,4 +300,3 @@ int pgp_s2k_process(PGP_S2K *s2k, int cipher, const uint8 *key, int key_len) px_md_free(md); return res; } - diff --git a/contrib/pgcrypto/pgp.c b/contrib/pgcrypto/pgp.c index c9bf8d7d28..e9e732e4be 100644 --- a/contrib/pgcrypto/pgp.c +++ b/contrib/pgcrypto/pgp.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/pgp.c,v 1.2 2005/07/11 15:07:59 tgl Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/pgp.c,v 1.3 2005/10/15 02:49:06 momjian Exp $ */ #include "postgres.h" @@ -62,8 +62,8 @@ struct cipher_info const char *name; int code; const char *int_name; - int key_len; - int block_len; + int key_len; + int block_len; }; static const struct digest_info digest_list[] = { @@ -78,15 +78,15 @@ static const struct digest_info digest_list[] = { }; static const struct cipher_info cipher_list[] = { - {"3des", PGP_SYM_DES3, "3des-ecb", 192/8, 64/8}, - {"cast5", PGP_SYM_CAST5, "cast5-ecb", 128/8, 64/8}, - {"bf", PGP_SYM_BLOWFISH, "bf-ecb", 128/8, 64/8}, - {"blowfish", PGP_SYM_BLOWFISH, "bf-ecb", 128/8, 64/8}, - {"aes", PGP_SYM_AES_128, "aes-ecb", 128/8, 128/8}, - {"aes128", PGP_SYM_AES_128, "aes-ecb", 128/8, 128/8}, - {"aes192", PGP_SYM_AES_192, "aes-ecb", 192/8, 128/8}, - {"aes256", PGP_SYM_AES_256, "aes-ecb", 256/8, 128/8}, - {"twofish", PGP_SYM_TWOFISH, "twofish-ecb", 256/8, 128/8}, + {"3des", PGP_SYM_DES3, "3des-ecb", 192 / 8, 64 / 8}, + {"cast5", PGP_SYM_CAST5, "cast5-ecb", 128 / 8, 64 / 8}, + {"bf", PGP_SYM_BLOWFISH, "bf-ecb", 128 / 8, 64 / 8}, + {"blowfish", PGP_SYM_BLOWFISH, "bf-ecb", 128 / 8, 64 / 8}, + {"aes", PGP_SYM_AES_128, "aes-ecb", 128 / 8, 128 / 8}, + {"aes128", PGP_SYM_AES_128, "aes-ecb", 128 / 8, 128 / 8}, + {"aes192", PGP_SYM_AES_192, "aes-ecb", 192 / 8, 128 / 8}, + {"aes256", PGP_SYM_AES_256, "aes-ecb", 256 / 8, 128 / 8}, + {"twofish", PGP_SYM_TWOFISH, "twofish-ecb", 256 / 8, 128 / 8}, {NULL, 0, NULL} }; @@ -94,6 +94,7 @@ static const struct cipher_info * get_cipher_info(int code) { const struct cipher_info *i; + for (i = cipher_list; i->name; i++) if (i->code == code) return i; @@ -104,6 +105,7 @@ int pgp_get_digest_code(const char *name) { const struct digest_info *i; + for (i = digest_list; i->name; i++) if (pg_strcasecmp(i->name, name) == 0) return i->code; @@ -114,6 +116,7 @@ int pgp_get_cipher_code(const char *name) { const struct cipher_info *i; + for (i = cipher_list; i->name; i++) if (pg_strcasecmp(i->name, name) == 0) return i->code; @@ -124,6 +127,7 @@ const char * pgp_get_digest_name(int code) { const struct digest_info *i; + for (i = digest_list; i->name; i++) if (i->code == code) return i->name; @@ -134,6 +138,7 @@ const char * pgp_get_cipher_name(int code) { const struct cipher_info *i = get_cipher_info(code); + if (i != NULL) return i->name; return NULL; @@ -143,6 +148,7 @@ int pgp_get_cipher_key_size(int code) { const struct cipher_info *i = get_cipher_info(code); + if (i != NULL) return i->key_len; return 0; @@ -152,6 +158,7 @@ int pgp_get_cipher_block_size(int code) { const struct cipher_info *i = get_cipher_info(code); + if (i != NULL) return i->block_len; return 0; @@ -300,6 +307,7 @@ int pgp_set_cipher_algo(PGP_Context * ctx, const char *name) { int code = pgp_get_cipher_code(name); + if (code < 0) return code; ctx->cipher_algo = code; @@ -310,6 +318,7 @@ int pgp_set_s2k_cipher_algo(PGP_Context * ctx, const char *name) { int code = pgp_get_cipher_code(name); + if (code < 0) return code; ctx->s2k_cipher_algo = code; @@ -320,6 +329,7 @@ int pgp_set_s2k_digest_algo(PGP_Context * ctx, const char *name) { int code = pgp_get_digest_code(name); + if (code < 0) return code; ctx->s2k_digest_algo = code; @@ -327,20 +337,20 @@ pgp_set_s2k_digest_algo(PGP_Context * ctx, const char *name) } int -pgp_get_unicode_mode(PGP_Context *ctx) +pgp_get_unicode_mode(PGP_Context * ctx) { return ctx->unicode_mode; } int -pgp_set_unicode_mode(PGP_Context *ctx, int mode) +pgp_set_unicode_mode(PGP_Context * ctx, int mode) { ctx->unicode_mode = mode ? 1 : 0; return 0; } int -pgp_set_symkey(PGP_Context *ctx, const uint8 *key, int len) +pgp_set_symkey(PGP_Context * ctx, const uint8 *key, int len) { if (key == NULL || len < 1) return PXE_ARGUMENT_ERROR; @@ -348,4 +358,3 @@ pgp_set_symkey(PGP_Context *ctx, const uint8 *key, int len) ctx->sym_key_len = len; return 0; } - diff --git a/contrib/pgcrypto/pgp.h b/contrib/pgcrypto/pgp.h index 769a248d18..d23086f533 100644 --- a/contrib/pgcrypto/pgp.h +++ b/contrib/pgcrypto/pgp.h @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/pgp.h,v 1.3 2005/08/13 02:06:20 momjian Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/pgp.h,v 1.4 2005/10/15 02:49:06 momjian Exp $ */ enum @@ -55,7 +55,7 @@ enum PGP_PKT_USER_ATTR = 17, PGP_PKT_SYMENCRYPTED_DATA_MDC = 18, PGP_PKT_MDC = 19, - PGP_PKT_PRIV_61 = 61 /* occurs in gpg secring */ + PGP_PKT_PRIV_61 = 61 /* occurs in gpg secring */ } PGP_PKT_TYPE; enum @@ -93,11 +93,11 @@ enum enum { PGP_DIGEST_MD5 = 1, /* should, deprecated */ - PGP_DIGEST_SHA1 = 2, /* must */ + PGP_DIGEST_SHA1 = 2, /* must */ PGP_DIGEST_RIPEMD160 = 3, - PGP_DIGEST_XSHA = 4, /* obsolete */ + PGP_DIGEST_XSHA = 4, /* obsolete */ PGP_DIGEST_MD2 = 5, /* obsolete */ - PGP_DIGEST_TIGER192 = 6, /* obsolete */ + PGP_DIGEST_TIGER192 = 6, /* obsolete */ PGP_DIGEST_HAVAL5_160 = 7, /* obsolete */ PGP_DIGEST_SHA256 = 8, PGP_DIGEST_SHA384 = 9, @@ -114,14 +114,15 @@ typedef struct PGP_PubKey PGP_PubKey; typedef struct PGP_Context PGP_Context; typedef struct PGP_S2K PGP_S2K; -struct PGP_S2K { - uint8 mode; - uint8 digest_algo; - uint8 salt[8]; - uint8 iter; +struct PGP_S2K +{ + uint8 mode; + uint8 digest_algo; + uint8 salt[8]; + uint8 iter; /* calculated: */ - uint8 key[PGP_MAX_KEY]; - uint8 key_len; + uint8 key[PGP_MAX_KEY]; + uint8 key_len; }; @@ -151,9 +152,9 @@ struct PGP_Context int in_mdc_pkt; int use_mdcbuf_filter; PX_MD *mdc_ctx; - - PGP_PubKey *pub_key; /* ctx owns it*/ - const uint8 *sym_key; /* ctx does not own it */ + + PGP_PubKey *pub_key; /* ctx owns it */ + const uint8 *sym_key; /* ctx does not own it */ int sym_key_len; /* @@ -163,54 +164,64 @@ struct PGP_Context unsigned sess_key_len; }; -struct PGP_MPI { - uint8 *data; - int bits; - int bytes; +struct PGP_MPI +{ + uint8 *data; + int bits; + int bytes; }; -struct PGP_PubKey { - uint8 ver; - uint8 time[4]; - uint8 algo; +struct PGP_PubKey +{ + uint8 ver; + uint8 time[4]; + uint8 algo; /* public part */ - union { - struct { - PGP_MPI *p; - PGP_MPI *g; - PGP_MPI *y; - } elg; - struct { - PGP_MPI *n; - PGP_MPI *e; - } rsa; - struct { - PGP_MPI *p; - PGP_MPI *q; - PGP_MPI *g; - PGP_MPI *y; - } dsa; - } pub; + union + { + struct + { + PGP_MPI *p; + PGP_MPI *g; + PGP_MPI *y; + } elg; + struct + { + PGP_MPI *n; + PGP_MPI *e; + } rsa; + struct + { + PGP_MPI *p; + PGP_MPI *q; + PGP_MPI *g; + PGP_MPI *y; + } dsa; + } pub; /* secret part */ - union { - struct { - PGP_MPI *x; - } elg; - struct { - PGP_MPI *d; - PGP_MPI *p; - PGP_MPI *q; - PGP_MPI *u; - } rsa; - struct { - PGP_MPI *x; - } dsa; - } sec; + union + { + struct + { + PGP_MPI *x; + } elg; + struct + { + PGP_MPI *d; + PGP_MPI *p; + PGP_MPI *q; + PGP_MPI *u; + } rsa; + struct + { + PGP_MPI *x; + } dsa; + } sec; - uint8 key_id[8]; - int can_encrypt; + uint8 key_id[8]; + int can_encrypt; }; int pgp_init(PGP_Context ** ctx); @@ -236,11 +247,11 @@ int pgp_set_text_mode(PGP_Context * ctx, int mode); int pgp_set_unicode_mode(PGP_Context * ctx, int mode); int pgp_get_unicode_mode(PGP_Context * ctx); -int pgp_set_symkey(PGP_Context *ctx, const uint8 *key, int klen); -int pgp_set_pubkey(PGP_Context *ctx, MBuf *keypkt, - const uint8 *key, int klen, int pubtype); +int pgp_set_symkey(PGP_Context * ctx, const uint8 *key, int klen); +int pgp_set_pubkey(PGP_Context * ctx, MBuf * keypkt, + const uint8 *key, int klen, int pubtype); -int pgp_get_keyid(MBuf *pgp_data, char *dst); +int pgp_get_keyid(MBuf * pgp_data, char *dst); /* internal functions */ @@ -249,55 +260,55 @@ int pgp_load_cipher(int c, PX_Cipher ** res); int pgp_get_cipher_key_size(int c); int pgp_get_cipher_block_size(int c); -int pgp_s2k_fill(PGP_S2K *s2k, int mode, int digest_algo); -int pgp_s2k_read(PullFilter *src, PGP_S2K *s2k); -int pgp_s2k_process(PGP_S2K *s2k, int cipher, const uint8 *key, int klen); +int pgp_s2k_fill(PGP_S2K * s2k, int mode, int digest_algo); +int pgp_s2k_read(PullFilter * src, PGP_S2K * s2k); +int pgp_s2k_process(PGP_S2K * s2k, int cipher, const uint8 *key, int klen); typedef struct PGP_CFB PGP_CFB; -int pgp_cfb_create(PGP_CFB **ctx_p, int algo, - const uint8 *key, int key_len, int recync, uint8 *iv); -void pgp_cfb_free(PGP_CFB *ctx); -int pgp_cfb_encrypt(PGP_CFB *ctx, const uint8 *data, int len, uint8 *dst); -int pgp_cfb_decrypt(PGP_CFB *ctx, const uint8 *data, int len, uint8 *dst); +int +pgp_cfb_create(PGP_CFB ** ctx_p, int algo, + const uint8 *key, int key_len, int recync, uint8 *iv); +void pgp_cfb_free(PGP_CFB * ctx); +int pgp_cfb_encrypt(PGP_CFB * ctx, const uint8 *data, int len, uint8 *dst); +int pgp_cfb_decrypt(PGP_CFB * ctx, const uint8 *data, int len, uint8 *dst); int pgp_armor_encode(const uint8 *src, unsigned len, uint8 *dst); int pgp_armor_decode(const uint8 *src, unsigned len, uint8 *dst); unsigned pgp_armor_enc_len(unsigned len); unsigned pgp_armor_dec_len(unsigned len); -int pgp_compress_filter(PushFilter **res, PGP_Context *ctx, PushFilter *dst); -int pgp_decompress_filter(PullFilter **res, PGP_Context *ctx, PullFilter *src); +int pgp_compress_filter(PushFilter ** res, PGP_Context * ctx, PushFilter * dst); +int pgp_decompress_filter(PullFilter ** res, PGP_Context * ctx, PullFilter * src); -int pgp_key_alloc(PGP_PubKey **pk_p); -void pgp_key_free(PGP_PubKey *pk); -int _pgp_read_public_key(PullFilter *pkt, PGP_PubKey **pk_p); +int pgp_key_alloc(PGP_PubKey ** pk_p); +void pgp_key_free(PGP_PubKey * pk); +int _pgp_read_public_key(PullFilter * pkt, PGP_PubKey ** pk_p); -int pgp_parse_pubenc_sesskey(PGP_Context *ctx, PullFilter *pkt); -int pgp_create_pkt_reader(PullFilter **pf_p, PullFilter *src, int len, - int pkttype, PGP_Context *ctx); +int pgp_parse_pubenc_sesskey(PGP_Context * ctx, PullFilter * pkt); +int pgp_create_pkt_reader(PullFilter ** pf_p, PullFilter * src, int len, + int pkttype, PGP_Context * ctx); int pgp_parse_pkt_hdr(PullFilter * src, uint8 *tag, int *len_p, - int allow_ctx); + int allow_ctx); -int pgp_skip_packet(PullFilter *pkt); -int pgp_expect_packet_end(PullFilter *pkt); +int pgp_skip_packet(PullFilter * pkt); +int pgp_expect_packet_end(PullFilter * pkt); -int pgp_write_pubenc_sesskey(PGP_Context *ctx, PushFilter *dst); -int pgp_create_pkt_writer(PushFilter *dst, int tag, PushFilter **res_p); +int pgp_write_pubenc_sesskey(PGP_Context * ctx, PushFilter * dst); +int pgp_create_pkt_writer(PushFilter * dst, int tag, PushFilter ** res_p); -int pgp_mpi_alloc(int bits, PGP_MPI **mpi); -int pgp_mpi_create(uint8 *data, int bits, PGP_MPI **mpi); -int pgp_mpi_free(PGP_MPI *mpi); -int pgp_mpi_read(PullFilter *src, PGP_MPI **mpi); -int pgp_mpi_write(PushFilter *dst, PGP_MPI *n); -int pgp_mpi_hash(PX_MD *md, PGP_MPI *n); -unsigned pgp_mpi_cksum(unsigned cksum, PGP_MPI *n); +int pgp_mpi_alloc(int bits, PGP_MPI ** mpi); +int pgp_mpi_create(uint8 *data, int bits, PGP_MPI ** mpi); +int pgp_mpi_free(PGP_MPI * mpi); +int pgp_mpi_read(PullFilter * src, PGP_MPI ** mpi); +int pgp_mpi_write(PushFilter * dst, PGP_MPI * n); +int pgp_mpi_hash(PX_MD * md, PGP_MPI * n); +unsigned pgp_mpi_cksum(unsigned cksum, PGP_MPI * n); -int pgp_elgamal_encrypt(PGP_PubKey *pk, PGP_MPI *m, - PGP_MPI **c1, PGP_MPI **c2); -int pgp_elgamal_decrypt(PGP_PubKey *pk, PGP_MPI *c1, PGP_MPI *c2, - PGP_MPI **m); -int pgp_rsa_encrypt(PGP_PubKey *pk, PGP_MPI *m, PGP_MPI **c); -int pgp_rsa_decrypt(PGP_PubKey *pk, PGP_MPI *c, PGP_MPI **m); +int pgp_elgamal_encrypt(PGP_PubKey * pk, PGP_MPI * m, + PGP_MPI ** c1, PGP_MPI ** c2); +int pgp_elgamal_decrypt(PGP_PubKey * pk, PGP_MPI * c1, PGP_MPI * c2, + PGP_MPI ** m); +int pgp_rsa_encrypt(PGP_PubKey * pk, PGP_MPI * m, PGP_MPI ** c); +int pgp_rsa_decrypt(PGP_PubKey * pk, PGP_MPI * c, PGP_MPI ** m); extern struct PullFilterOps pgp_decrypt_filter; - diff --git a/contrib/pgcrypto/px-crypt.c b/contrib/pgcrypto/px-crypt.c index 0b818ffeee..e21acb73c6 100644 --- a/contrib/pgcrypto/px-crypt.c +++ b/contrib/pgcrypto/px-crypt.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/px-crypt.c,v 1.14 2005/09/24 19:14:04 tgl Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/px-crypt.c,v 1.15 2005/10/15 02:49:06 momjian Exp $ */ #include "postgres.h" @@ -77,9 +77,9 @@ struct px_crypt_algo }; static const struct px_crypt_algo -px_crypt_list[] = { + px_crypt_list[] = { {"$2a$", 4, run_crypt_bf}, - {"$2$", 3, NULL}, /* N/A */ + {"$2$", 3, NULL}, /* N/A */ {"$1$", 3, run_crypt_md5}, {"_", 1, run_crypt_des}, {"", 0, run_crypt_des}, @@ -164,4 +164,3 @@ px_gen_salt(const char *salt_type, char *buf, int rounds) return strlen(p); } - diff --git a/contrib/pgcrypto/px-crypt.h b/contrib/pgcrypto/px-crypt.h index 94f5232ec2..957b30e5dc 100644 --- a/contrib/pgcrypto/px-crypt.h +++ b/contrib/pgcrypto/px-crypt.h @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/px-crypt.h,v 1.8 2005/08/13 02:06:20 momjian Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/px-crypt.h,v 1.9 2005/10/15 02:49:06 momjian Exp $ */ #ifndef _PX_CRYPT_H @@ -65,13 +65,13 @@ extern char px_crypt_a64[]; /* crypt-gensalt.c */ char *_crypt_gensalt_traditional_rn(unsigned long count, - const char *input, int size, char *output, int output_size); + const char *input, int size, char *output, int output_size); char *_crypt_gensalt_extended_rn(unsigned long count, - const char *input, int size, char *output, int output_size); + const char *input, int size, char *output, int output_size); char *_crypt_gensalt_md5_rn(unsigned long count, - const char *input, int size, char *output, int output_size); + const char *input, int size, char *output, int output_size); char *_crypt_gensalt_blowfish_rn(unsigned long count, - const char *input, int size, char *output, int output_size); + const char *input, int size, char *output, int output_size); /* disable 'extended DES crypt' */ /* #define DISABLE_XDES */ diff --git a/contrib/pgcrypto/px.c b/contrib/pgcrypto/px.c index 2b1fd2fe58..0374b1c027 100644 --- a/contrib/pgcrypto/px.c +++ b/contrib/pgcrypto/px.c @@ -26,15 +26,16 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/px.c,v 1.14 2005/08/13 02:06:20 momjian Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/px.c,v 1.15 2005/10/15 02:49:06 momjian Exp $ */ #include "postgres.h" #include "px.h" -struct error_desc { - int err; +struct error_desc +{ + int err; const char *desc; }; @@ -67,14 +68,14 @@ static const struct error_desc px_err_list[] = { {PXE_PGP_UNEXPECTED_PKT, "Unexpected packet in key data"}, {PXE_PGP_NO_BIGNUM, "public-key functions disabled - " - "pgcrypto needs OpenSSL for bignums"}, + "pgcrypto needs OpenSSL for bignums"}, {PXE_PGP_MATH_FAILED, "Math operation failed"}, {PXE_PGP_SHORT_ELGAMAL_KEY, "Elgamal keys must be at least 1024 bits long"}, {PXE_PGP_RSA_UNSUPPORTED, "pgcrypto does not support RSA keys"}, {PXE_PGP_UNKNOWN_PUBALGO, "Unknown public-key encryption algorithm"}, {PXE_PGP_WRONG_KEY, "Wrong key"}, {PXE_PGP_MULTIPLE_KEYS, - "Several keys given - pgcrypto does not handle keyring"}, + "Several keys given - pgcrypto does not handle keyring"}, {PXE_PGP_EXPECT_PUBLIC_KEY, "Refusing to encrypt with secret key"}, {PXE_PGP_EXPECT_SECRET_KEY, "Cannot decrypt with public key"}, {PXE_PGP_NOT_V4_KEYPKT, "Only V4 key packets are supported"}, @@ -87,13 +88,15 @@ static const struct error_desc px_err_list[] = { /* fake this as PXE_PGP_CORRUPT_DATA */ {PXE_MBUF_SHORT_READ, "Corrupt data"}, - + {0, NULL}, }; -const char *px_strerror(int err) +const char * +px_strerror(int err) { const struct error_desc *e; + for (e = px_err_list; e->desc; e++) if (e->err == err) return e->desc; @@ -113,19 +116,24 @@ px_resolve_alias(const PX_Alias * list, const char *name) return name; } -static void (*debug_handler)(const char *) = NULL; +static void (*debug_handler) (const char *) = NULL; -void px_set_debug_handler(void (*handler)(const char *)) +void +px_set_debug_handler(void (*handler) (const char *)) { debug_handler = handler; } -void px_debug(const char *fmt, ...) +void +px_debug(const char *fmt,...) { - va_list ap; + va_list ap; + va_start(ap, fmt); - if (debug_handler) { - char buf[512]; + if (debug_handler) + { + char buf[512]; + vsnprintf(buf, sizeof(buf), fmt, ap); debug_handler(buf); } diff --git a/contrib/pgcrypto/px.h b/contrib/pgcrypto/px.h index a58b51e711..bf53ec0e65 100644 --- a/contrib/pgcrypto/px.h +++ b/contrib/pgcrypto/px.h @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/px.h,v 1.15 2005/08/13 02:06:20 momjian Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/px.h,v 1.16 2005/10/15 02:49:06 momjian Exp $ */ #ifndef __PX_H @@ -90,12 +90,12 @@ void px_free(void *p); #define PXE_PGP_CORRUPT_DATA -100 #define PXE_PGP_CORRUPT_ARMOR -101 -#define PXE_PGP_UNSUPPORTED_COMPR -102 -#define PXE_PGP_UNSUPPORTED_CIPHER -103 -#define PXE_PGP_UNSUPPORTED_HASH -104 -#define PXE_PGP_COMPRESSION_ERROR -105 -#define PXE_PGP_NOT_TEXT -106 -#define PXE_PGP_UNEXPECTED_PKT -107 +#define PXE_PGP_UNSUPPORTED_COMPR -102 +#define PXE_PGP_UNSUPPORTED_CIPHER -103 +#define PXE_PGP_UNSUPPORTED_HASH -104 +#define PXE_PGP_COMPRESSION_ERROR -105 +#define PXE_PGP_NOT_TEXT -106 +#define PXE_PGP_UNEXPECTED_PKT -107 #define PXE_PGP_NO_BIGNUM -108 #define PXE_PGP_MATH_FAILED -109 #define PXE_PGP_SHORT_ELGAMAL_KEY -110 @@ -110,7 +110,7 @@ void px_free(void *p); #define PXE_PGP_NO_USABLE_KEY -119 #define PXE_PGP_NEED_SECRET_PSW -120 #define PXE_PGP_BAD_S2K_MODE -121 -#define PXE_PGP_UNSUPPORTED_PUBALGO -122 +#define PXE_PGP_UNSUPPORTED_PUBALGO -122 #define PXE_PGP_MULTIPLE_SUBKEYS -123 @@ -132,7 +132,7 @@ struct px_digest union { unsigned code; - void *ptr; + void *ptr; } p; }; @@ -207,9 +207,10 @@ const char *px_strerror(int err); const char *px_resolve_alias(const PX_Alias * aliases, const char *name); -void px_set_debug_handler(void (*handler)(const char *)); +void px_set_debug_handler(void (*handler) (const char *)); + #ifdef PX_DEBUG -void px_debug(const char *fmt, ...); +void px_debug(const char *fmt,...); #else #define px_debug(...) #endif diff --git a/contrib/pgcrypto/random.c b/contrib/pgcrypto/random.c index 242eb175da..ad2077244a 100644 --- a/contrib/pgcrypto/random.c +++ b/contrib/pgcrypto/random.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/contrib/pgcrypto/random.c,v 1.15 2005/07/18 17:09:01 tgl Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/random.c,v 1.16 2005/10/15 02:49:06 momjian Exp $ */ #include "postgres.h" @@ -95,7 +95,6 @@ try_dev_random(uint8 *dst) dst += res; return dst; } - #endif /* @@ -111,22 +110,23 @@ try_dev_random(uint8 *dst) /* * this function is from libtomcrypt - * + * * try to use Microsoft crypto API */ -static uint8 * try_win32_genrand(uint8 *dst) +static uint8 * +try_win32_genrand(uint8 *dst) { - int res; - HCRYPTPROV h = 0; + int res; + HCRYPTPROV h = 0; res = CryptAcquireContext(&h, NULL, MS_DEF_PROV, PROV_RSA_FULL, - (CRYPT_VERIFYCONTEXT | CRYPT_MACHINE_KEYSET)); + (CRYPT_VERIFYCONTEXT | CRYPT_MACHINE_KEYSET)); if (!res) res = CryptAcquireContext(&h, NULL, MS_DEF_PROV, PROV_RSA_FULL, - CRYPT_VERIFYCONTEXT | CRYPT_MACHINE_KEYSET | CRYPT_NEWKEYSET); + CRYPT_VERIFYCONTEXT | CRYPT_MACHINE_KEYSET | CRYPT_NEWKEYSET); if (!res) return dst; - + res = CryptGenRandom(h, RND_BYTES, dst); if (res == TRUE) dst += RND_BYTES; @@ -135,9 +135,10 @@ static uint8 * try_win32_genrand(uint8 *dst) return dst; } -static uint8 * try_win32_perfc(uint8 *dst) +static uint8 * +try_win32_perfc(uint8 *dst) { - int res; + int res; LARGE_INTEGER time; res = QueryPerformanceCounter(&time); @@ -147,8 +148,7 @@ static uint8 * try_win32_perfc(uint8 *dst) memcpy(dst, &time, sizeof(time)); return dst + sizeof(time); } - -#endif /* WIN32 */ +#endif /* WIN32 */ /* @@ -174,33 +174,34 @@ static uint8 * try_win32_perfc(uint8 *dst) static uint8 * try_unix_std(uint8 *dst) { - pid_t pid; - int x; - PX_MD *md; + pid_t pid; + int x; + PX_MD *md; struct timeval tv; - int res; + int res; /* process id */ pid = getpid(); - memcpy(dst, (uint8*)&pid, sizeof(pid)); + memcpy(dst, (uint8 *) &pid, sizeof(pid)); dst += sizeof(pid); /* time */ gettimeofday(&tv, NULL); - memcpy(dst, (uint8*)&tv, sizeof(tv)); + memcpy(dst, (uint8 *) &tv, sizeof(tv)); dst += sizeof(tv); /* pointless, but should not hurt */ x = random(); - memcpy(dst, (uint8*)&x, sizeof(x)); + memcpy(dst, (uint8 *) &x, sizeof(x)); dst += sizeof(x); /* let's be desperate */ res = px_find_digest("sha1", &md); - if (res >= 0) { - uint8 *ptr; - uint8 stack[8192]; - int alloc = 32*1024; + if (res >= 0) + { + uint8 *ptr; + uint8 stack[8192]; + int alloc = 32 * 1024; px_md_update(md, stack, sizeof(stack)); ptr = px_alloc(alloc); @@ -215,7 +216,6 @@ try_unix_std(uint8 *dst) return dst; } - #endif /* @@ -223,9 +223,11 @@ try_unix_std(uint8 *dst) * * dst should have room for 1024 bytes. */ -unsigned px_acquire_system_randomness(uint8 *dst) +unsigned +px_acquire_system_randomness(uint8 *dst) { - uint8 *p = dst; + uint8 *p = dst; + #ifdef TRY_DEV_RANDOM p = try_dev_random(p); #endif @@ -240,4 +242,3 @@ unsigned px_acquire_system_randomness(uint8 *dst) #endif return p - dst; } - diff --git a/contrib/pgcrypto/rijndael.c b/contrib/pgcrypto/rijndael.c index fbf74cabe9..c75f1d1d71 100644 --- a/contrib/pgcrypto/rijndael.c +++ b/contrib/pgcrypto/rijndael.c @@ -1,6 +1,6 @@ /* $OpenBSD: rijndael.c,v 1.6 2000/12/09 18:51:34 markus Exp $ */ -/* $PostgreSQL: pgsql/contrib/pgcrypto/rijndael.c,v 1.11 2005/07/11 15:07:59 tgl Exp $ */ +/* $PostgreSQL: pgsql/contrib/pgcrypto/rijndael.c,v 1.12 2005/10/15 02:49:06 momjian Exp $ */ /* This is an independent implementation of the encryption algorithm: */ /* */ @@ -91,7 +91,6 @@ static void gen_tabs(void); #include "rijndael.tbl" #define tab_gen 1 - #else /* !PRE_CALC_TABLES */ static u1byte pow_tab[256]; @@ -143,7 +142,6 @@ static u4byte tab_gen = 0; il_tab[1][byte((bi)[((n) + 3) & 3],1)] ^ \ il_tab[2][byte((bi)[((n) + 2) & 3],2)] ^ \ il_tab[3][byte((bi)[((n) + 1) & 3],3)] ^ *((k) + (n)) - #else #define ls_box(x) \ diff --git a/contrib/pgcrypto/sha2.c b/contrib/pgcrypto/sha2.c index adabdea139..46f44679bd 100644 --- a/contrib/pgcrypto/sha2.c +++ b/contrib/pgcrypto/sha2.c @@ -3,7 +3,7 @@ /* * FILE: sha2.c * AUTHOR: Aaron D. Gifford - * + * * Copyright (c) 2000-2001, Aaron D. Gifford * All rights reserved. * @@ -11,18 +11,18 @@ * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holder nor the names of contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTOR(S) BE LIABLE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTOR(S) BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) @@ -33,7 +33,7 @@ * * $From: sha2.c,v 1.1 2001/11/08 00:01:51 adg Exp adg $ * - * $PostgreSQL: pgsql/contrib/pgcrypto/sha2.c,v 1.4 2005/07/12 20:27:42 tgl Exp $ + * $PostgreSQL: pgsql/contrib/pgcrypto/sha2.c,v 1.5 2005/10/15 02:49:06 momjian Exp $ */ #include "postgres.h" @@ -48,11 +48,11 @@ * loop version for the hash transform rounds (defined using macros * later in this file). Either define on the command line, for example: * - * cc -DSHA2_UNROLL_TRANSFORM -o sha2 sha2.c sha2prog.c + * cc -DSHA2_UNROLL_TRANSFORM -o sha2 sha2.c sha2prog.c * * or define below: * - * #define SHA2_UNROLL_TRANSFORM + * #define SHA2_UNROLL_TRANSFORM * */ @@ -69,16 +69,16 @@ * If your system does not define the above, then you can do so by * hand like this: * - * #define LITTLE_ENDIAN 1234 - * #define BIG_ENDIAN 4321 + * #define LITTLE_ENDIAN 1234 + * #define BIG_ENDIAN 4321 * * And for little-endian machines, add: * - * #define BYTE_ORDER LITTLE_ENDIAN + * #define BYTE_ORDER LITTLE_ENDIAN * * Or for big-endian machines: * - * #define BYTE_ORDER BIG_ENDIAN + * #define BYTE_ORDER BIG_ENDIAN * * The FreeBSD machine this was written on defines BYTE_ORDER * appropriately by including (which in turn includes @@ -108,11 +108,11 @@ uint64 tmp = (w); \ tmp = (tmp >> 32) | (tmp << 32); \ tmp = ((tmp & 0xff00ff00ff00ff00ULL) >> 8) | \ - ((tmp & 0x00ff00ff00ff00ffULL) << 8); \ + ((tmp & 0x00ff00ff00ff00ffULL) << 8); \ (x) = ((tmp & 0xffff0000ffff0000ULL) >> 16) | \ - ((tmp & 0x0000ffff0000ffffULL) << 16); \ + ((tmp & 0x0000ffff0000ffffULL) << 16); \ } -#endif /* BYTE_ORDER == LITTLE_ENDIAN */ +#endif /* BYTE_ORDER == LITTLE_ENDIAN */ /* * Macro for incrementally adding the unsigned 64-bit integer n to the @@ -130,13 +130,13 @@ /* * Bit shifting and rotation (used by the six SHA-XYZ logical functions: * - * NOTE: The naming of R and S appears backwards here (R is a SHIFT and - * S is a ROTATION) because the SHA-256/384/512 description document - * (see http://csrc.nist.gov/cryptval/shs/sha256-384-512.pdf) uses this - * same "backwards" definition. + * NOTE: The naming of R and S appears backwards here (R is a SHIFT and + * S is a ROTATION) because the SHA-256/384/512 description document + * (see http://csrc.nist.gov/cryptval/shs/sha256-384-512.pdf) uses this + * same "backwards" definition. */ /* Shift-right (used in SHA-256, SHA-384, and SHA-512): */ -#define R(b,x) ((x) >> (b)) +#define R(b,x) ((x) >> (b)) /* 32-bit Rotate-right (used in SHA-256): */ #define S32(b,x) (((x) >> (b)) | ((x) << (32 - (b)))) /* 64-bit Rotate-right (used in SHA-384 and SHA-512): */ @@ -163,9 +163,9 @@ * library -- they are intended for private internal visibility/use * only. */ -void SHA512_Last(SHA512_CTX *); -void SHA256_Transform(SHA256_CTX *, const uint8 *); -void SHA512_Transform(SHA512_CTX *, const uint8 *); +void SHA512_Last(SHA512_CTX *); +void SHA256_Transform(SHA256_CTX *, const uint8 *); +void SHA512_Transform(SHA512_CTX *, const uint8 *); /*** SHA-XYZ INITIAL HASH VALUES AND CONSTANTS ************************/ @@ -272,7 +272,7 @@ static const uint64 sha512_initial_hash_value[8] = { /*** SHA-256: *********************************************************/ void -SHA256_Init(SHA256_CTX *context) +SHA256_Init(SHA256_CTX * context) { if (context == NULL) return; @@ -285,36 +285,46 @@ SHA256_Init(SHA256_CTX *context) /* Unrolled SHA-256 round macros: */ -#define ROUND256_0_TO_15(a,b,c,d,e,f,g,h) do { \ - W256[j] = (uint32)data[3] | ((uint32)data[2] << 8) | \ - ((uint32)data[1] << 16) | ((uint32)data[0] << 24); \ - data += 4; \ +#define ROUND256_0_TO_15(a,b,c,d,e,f,g,h) do { \ + W256[j] = (uint32)data[3] | ((uint32)data[2] << 8) | \ + ((uint32)data[1] << 16) | ((uint32)data[0] << 24); \ + data += 4; \ T1 = (h) + Sigma1_256((e)) + Ch((e), (f), (g)) + K256[j] + W256[j]; \ - (d) += T1; \ - (h) = T1 + Sigma0_256((a)) + Maj((a), (b), (c)); \ - j++; \ + (d) += T1; \ + (h) = T1 + Sigma0_256((a)) + Maj((a), (b), (c)); \ + j++; \ } while(0) -#define ROUND256(a,b,c,d,e,f,g,h) do { \ - s0 = W256[(j+1)&0x0f]; \ - s0 = sigma0_256(s0); \ - s1 = W256[(j+14)&0x0f]; \ - s1 = sigma1_256(s1); \ - T1 = (h) + Sigma1_256((e)) + Ch((e), (f), (g)) + K256[j] + \ - (W256[j&0x0f] += s1 + W256[(j+9)&0x0f] + s0); \ - (d) += T1; \ - (h) = T1 + Sigma0_256((a)) + Maj((a), (b), (c)); \ - j++; \ +#define ROUND256(a,b,c,d,e,f,g,h) do { \ + s0 = W256[(j+1)&0x0f]; \ + s0 = sigma0_256(s0); \ + s1 = W256[(j+14)&0x0f]; \ + s1 = sigma1_256(s1); \ + T1 = (h) + Sigma1_256((e)) + Ch((e), (f), (g)) + K256[j] + \ + (W256[j&0x0f] += s1 + W256[(j+9)&0x0f] + s0); \ + (d) += T1; \ + (h) = T1 + Sigma0_256((a)) + Maj((a), (b), (c)); \ + j++; \ } while(0) void -SHA256_Transform(SHA256_CTX *context, const uint8 *data) +SHA256_Transform(SHA256_CTX * context, const uint8 *data) { - uint32 a, b, c, d, e, f, g, h, s0, s1; - uint32 T1, *W256; - int j; + uint32 a, + b, + c, + d, + e, + f, + g, + h, + s0, + s1; + uint32 T1, + *W256; + int j; - W256 = (uint32 *)context->buffer; + W256 = (uint32 *) context->buffer; /* Initialize registers with the prev. intermediate value */ a = context->state[0]; @@ -327,28 +337,30 @@ SHA256_Transform(SHA256_CTX *context, const uint8 *data) h = context->state[7]; j = 0; - do { + do + { /* Rounds 0 to 15 (unrolled): */ - ROUND256_0_TO_15(a,b,c,d,e,f,g,h); - ROUND256_0_TO_15(h,a,b,c,d,e,f,g); - ROUND256_0_TO_15(g,h,a,b,c,d,e,f); - ROUND256_0_TO_15(f,g,h,a,b,c,d,e); - ROUND256_0_TO_15(e,f,g,h,a,b,c,d); - ROUND256_0_TO_15(d,e,f,g,h,a,b,c); - ROUND256_0_TO_15(c,d,e,f,g,h,a,b); - ROUND256_0_TO_15(b,c,d,e,f,g,h,a); + ROUND256_0_TO_15(a, b, c, d, e, f, g, h); + ROUND256_0_TO_15(h, a, b, c, d, e, f, g); + ROUND256_0_TO_15(g, h, a, b, c, d, e, f); + ROUND256_0_TO_15(f, g, h, a, b, c, d, e); + ROUND256_0_TO_15(e, f, g, h, a, b, c, d); + ROUND256_0_TO_15(d, e, f, g, h, a, b, c); + ROUND256_0_TO_15(c, d, e, f, g, h, a, b); + ROUND256_0_TO_15(b, c, d, e, f, g, h, a); } while (j < 16); /* Now for the remaining rounds to 64: */ - do { - ROUND256(a,b,c,d,e,f,g,h); - ROUND256(h,a,b,c,d,e,f,g); - ROUND256(g,h,a,b,c,d,e,f); - ROUND256(f,g,h,a,b,c,d,e); - ROUND256(e,f,g,h,a,b,c,d); - ROUND256(d,e,f,g,h,a,b,c); - ROUND256(c,d,e,f,g,h,a,b); - ROUND256(b,c,d,e,f,g,h,a); + do + { + ROUND256(a, b, c, d, e, f, g, h); + ROUND256(h, a, b, c, d, e, f, g); + ROUND256(g, h, a, b, c, d, e, f); + ROUND256(f, g, h, a, b, c, d, e); + ROUND256(e, f, g, h, a, b, c, d); + ROUND256(d, e, f, g, h, a, b, c); + ROUND256(c, d, e, f, g, h, a, b); + ROUND256(b, c, d, e, f, g, h, a); } while (j < 64); /* Compute the current intermediate hash value */ @@ -364,17 +376,27 @@ SHA256_Transform(SHA256_CTX *context, const uint8 *data) /* Clean up */ a = b = c = d = e = f = g = h = T1 = 0; } - -#else /* SHA2_UNROLL_TRANSFORM */ +#else /* SHA2_UNROLL_TRANSFORM */ void -SHA256_Transform(SHA256_CTX *context, const uint8 *data) +SHA256_Transform(SHA256_CTX * context, const uint8 *data) { - uint32 a, b, c, d, e, f, g, h, s0, s1; - uint32 T1, T2, *W256; - int j; + uint32 a, + b, + c, + d, + e, + f, + g, + h, + s0, + s1; + uint32 T1, + T2, + *W256; + int j; - W256 = (uint32 *)context->buffer; + W256 = (uint32 *) context->buffer; /* Initialize registers with the prev. intermediate value */ a = context->state[0]; @@ -387,9 +409,10 @@ SHA256_Transform(SHA256_CTX *context, const uint8 *data) h = context->state[7]; j = 0; - do { - W256[j] = (uint32)data[3] | ((uint32)data[2] << 8) | - ((uint32)data[1] << 16) | ((uint32)data[0] << 24); + do + { + W256[j] = (uint32) data[3] | ((uint32) data[2] << 8) | + ((uint32) data[1] << 16) | ((uint32) data[0] << 24); data += 4; /* Apply the SHA-256 compression function to update a..h */ T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] + W256[j]; @@ -406,16 +429,17 @@ SHA256_Transform(SHA256_CTX *context, const uint8 *data) j++; } while (j < 16); - do { + do + { /* Part of the message block expansion: */ - s0 = W256[(j+1)&0x0f]; + s0 = W256[(j + 1) & 0x0f]; s0 = sigma0_256(s0); - s1 = W256[(j+14)&0x0f]; + s1 = W256[(j + 14) & 0x0f]; s1 = sigma1_256(s1); /* Apply the SHA-256 compression function to update a..h */ - T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] + - (W256[j&0x0f] += s1 + W256[(j+9)&0x0f] + s0); + T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] + + (W256[j & 0x0f] += s1 + W256[(j + 9) & 0x0f] + s0); T2 = Sigma0_256(a) + Maj(a, b, c); h = g; g = f; @@ -442,31 +466,35 @@ SHA256_Transform(SHA256_CTX *context, const uint8 *data) /* Clean up */ a = b = c = d = e = f = g = h = T1 = T2 = 0; } - -#endif /* SHA2_UNROLL_TRANSFORM */ +#endif /* SHA2_UNROLL_TRANSFORM */ void -SHA256_Update(SHA256_CTX *context, const uint8 *data, size_t len) +SHA256_Update(SHA256_CTX * context, const uint8 *data, size_t len) { - size_t freespace, usedspace; + size_t freespace, + usedspace; /* Calling with no data is valid (we do nothing) */ if (len == 0) return; usedspace = (context->bitcount >> 3) % SHA256_BLOCK_LENGTH; - if (usedspace > 0) { + if (usedspace > 0) + { /* Calculate how much free space is available in the buffer */ freespace = SHA256_BLOCK_LENGTH - usedspace; - if (len >= freespace) { + if (len >= freespace) + { /* Fill the buffer completely and process it */ memcpy(&context->buffer[usedspace], data, freespace); context->bitcount += freespace << 3; len -= freespace; data += freespace; SHA256_Transform(context, context->buffer); - } else { + } + else + { /* The buffer is not yet full */ memcpy(&context->buffer[usedspace], data, len); context->bitcount += len << 3; @@ -475,14 +503,16 @@ SHA256_Update(SHA256_CTX *context, const uint8 *data, size_t len) return; } } - while (len >= SHA256_BLOCK_LENGTH) { + while (len >= SHA256_BLOCK_LENGTH) + { /* Process as many complete blocks as we can */ SHA256_Transform(context, data); context->bitcount += SHA256_BLOCK_LENGTH << 3; len -= SHA256_BLOCK_LENGTH; data += SHA256_BLOCK_LENGTH; } - if (len > 0) { + if (len > 0) + { /* There's left-overs, so save 'em */ memcpy(context->buffer, data, len); context->bitcount += len << 3; @@ -492,26 +522,32 @@ SHA256_Update(SHA256_CTX *context, const uint8 *data, size_t len) } void -SHA256_Final(uint8 digest[], SHA256_CTX *context) +SHA256_Final(uint8 digest[], SHA256_CTX * context) { - unsigned int usedspace; + unsigned int usedspace; /* If no digest buffer is passed, we don't bother doing this: */ - if (digest != NULL) { + if (digest != NULL) + { usedspace = (context->bitcount >> 3) % SHA256_BLOCK_LENGTH; #if BYTE_ORDER == LITTLE_ENDIAN /* Convert FROM host byte order */ - REVERSE64(context->bitcount,context->bitcount); + REVERSE64(context->bitcount, context->bitcount); #endif - if (usedspace > 0) { + if (usedspace > 0) + { /* Begin padding with a 1 bit: */ context->buffer[usedspace++] = 0x80; - if (usedspace <= SHA256_SHORT_BLOCK_LENGTH) { + if (usedspace <= SHA256_SHORT_BLOCK_LENGTH) + { /* Set-up for the last transform: */ memset(&context->buffer[usedspace], 0, SHA256_SHORT_BLOCK_LENGTH - usedspace); - } else { - if (usedspace < SHA256_BLOCK_LENGTH) { + } + else + { + if (usedspace < SHA256_BLOCK_LENGTH) + { memset(&context->buffer[usedspace], 0, SHA256_BLOCK_LENGTH - usedspace); } /* Do second-to-last transform: */ @@ -520,7 +556,9 @@ SHA256_Final(uint8 digest[], SHA256_CTX *context) /* And set-up for the last transform: */ memset(context->buffer, 0, SHA256_SHORT_BLOCK_LENGTH); } - } else { + } + else + { /* Set-up for the last transform: */ memset(context->buffer, 0, SHA256_SHORT_BLOCK_LENGTH); @@ -528,7 +566,7 @@ SHA256_Final(uint8 digest[], SHA256_CTX *context) *context->buffer = 0x80; } /* Set the bit count: */ - *(uint64 *)&context->buffer[SHA256_SHORT_BLOCK_LENGTH] = context->bitcount; + *(uint64 *) &context->buffer[SHA256_SHORT_BLOCK_LENGTH] = context->bitcount; /* Final transform: */ SHA256_Transform(context, context->buffer); @@ -536,9 +574,11 @@ SHA256_Final(uint8 digest[], SHA256_CTX *context) #if BYTE_ORDER == LITTLE_ENDIAN { /* Convert TO host byte order */ - int j; - for (j = 0; j < 8; j++) { - REVERSE32(context->state[j],context->state[j]); + int j; + + for (j = 0; j < 8; j++) + { + REVERSE32(context->state[j], context->state[j]); } } #endif @@ -553,50 +593,60 @@ SHA256_Final(uint8 digest[], SHA256_CTX *context) /*** SHA-512: *********************************************************/ void -SHA512_Init(SHA512_CTX *context) +SHA512_Init(SHA512_CTX * context) { if (context == NULL) return; memcpy(context->state, sha512_initial_hash_value, SHA512_DIGEST_LENGTH); memset(context->buffer, 0, SHA512_BLOCK_LENGTH); - context->bitcount[0] = context->bitcount[1] = 0; + context->bitcount[0] = context->bitcount[1] = 0; } #ifdef SHA2_UNROLL_TRANSFORM /* Unrolled SHA-512 round macros: */ -#define ROUND512_0_TO_15(a,b,c,d,e,f,g,h) do { \ - W512[j] = (uint64)data[7] | ((uint64)data[6] << 8) | \ - ((uint64)data[5] << 16) | ((uint64)data[4] << 24) | \ - ((uint64)data[3] << 32) | ((uint64)data[2] << 40) | \ - ((uint64)data[1] << 48) | ((uint64)data[0] << 56); \ - data += 8; \ +#define ROUND512_0_TO_15(a,b,c,d,e,f,g,h) do { \ + W512[j] = (uint64)data[7] | ((uint64)data[6] << 8) | \ + ((uint64)data[5] << 16) | ((uint64)data[4] << 24) | \ + ((uint64)data[3] << 32) | ((uint64)data[2] << 40) | \ + ((uint64)data[1] << 48) | ((uint64)data[0] << 56); \ + data += 8; \ T1 = (h) + Sigma1_512((e)) + Ch((e), (f), (g)) + K512[j] + W512[j]; \ - (d) += T1; \ - (h) = T1 + Sigma0_512((a)) + Maj((a), (b), (c)); \ - j++; \ + (d) += T1; \ + (h) = T1 + Sigma0_512((a)) + Maj((a), (b), (c)); \ + j++; \ } while(0) -#define ROUND512(a,b,c,d,e,f,g,h) do { \ - s0 = W512[(j+1)&0x0f]; \ - s0 = sigma0_512(s0); \ - s1 = W512[(j+14)&0x0f]; \ - s1 = sigma1_512(s1); \ - T1 = (h) + Sigma1_512((e)) + Ch((e), (f), (g)) + K512[j] + \ - (W512[j&0x0f] += s1 + W512[(j+9)&0x0f] + s0); \ - (d) += T1; \ - (h) = T1 + Sigma0_512((a)) + Maj((a), (b), (c)); \ - j++; \ +#define ROUND512(a,b,c,d,e,f,g,h) do { \ + s0 = W512[(j+1)&0x0f]; \ + s0 = sigma0_512(s0); \ + s1 = W512[(j+14)&0x0f]; \ + s1 = sigma1_512(s1); \ + T1 = (h) + Sigma1_512((e)) + Ch((e), (f), (g)) + K512[j] + \ + (W512[j&0x0f] += s1 + W512[(j+9)&0x0f] + s0); \ + (d) += T1; \ + (h) = T1 + Sigma0_512((a)) + Maj((a), (b), (c)); \ + j++; \ } while(0) void -SHA512_Transform(SHA512_CTX *context, const uint8 *data) +SHA512_Transform(SHA512_CTX * context, const uint8 *data) { - uint64 a, b, c, d, e, f, g, h, s0, s1; - uint64 T1, *W512 = (uint64 *)context->buffer; - int j; + uint64 a, + b, + c, + d, + e, + f, + g, + h, + s0, + s1; + uint64 T1, + *W512 = (uint64 *) context->buffer; + int j; /* Initialize registers with the prev. intermediate value */ a = context->state[0]; @@ -609,27 +659,29 @@ SHA512_Transform(SHA512_CTX *context, const uint8 *data) h = context->state[7]; j = 0; - do { - ROUND512_0_TO_15(a,b,c,d,e,f,g,h); - ROUND512_0_TO_15(h,a,b,c,d,e,f,g); - ROUND512_0_TO_15(g,h,a,b,c,d,e,f); - ROUND512_0_TO_15(f,g,h,a,b,c,d,e); - ROUND512_0_TO_15(e,f,g,h,a,b,c,d); - ROUND512_0_TO_15(d,e,f,g,h,a,b,c); - ROUND512_0_TO_15(c,d,e,f,g,h,a,b); - ROUND512_0_TO_15(b,c,d,e,f,g,h,a); + do + { + ROUND512_0_TO_15(a, b, c, d, e, f, g, h); + ROUND512_0_TO_15(h, a, b, c, d, e, f, g); + ROUND512_0_TO_15(g, h, a, b, c, d, e, f); + ROUND512_0_TO_15(f, g, h, a, b, c, d, e); + ROUND512_0_TO_15(e, f, g, h, a, b, c, d); + ROUND512_0_TO_15(d, e, f, g, h, a, b, c); + ROUND512_0_TO_15(c, d, e, f, g, h, a, b); + ROUND512_0_TO_15(b, c, d, e, f, g, h, a); } while (j < 16); /* Now for the remaining rounds up to 79: */ - do { - ROUND512(a,b,c,d,e,f,g,h); - ROUND512(h,a,b,c,d,e,f,g); - ROUND512(g,h,a,b,c,d,e,f); - ROUND512(f,g,h,a,b,c,d,e); - ROUND512(e,f,g,h,a,b,c,d); - ROUND512(d,e,f,g,h,a,b,c); - ROUND512(c,d,e,f,g,h,a,b); - ROUND512(b,c,d,e,f,g,h,a); + do + { + ROUND512(a, b, c, d, e, f, g, h); + ROUND512(h, a, b, c, d, e, f, g); + ROUND512(g, h, a, b, c, d, e, f); + ROUND512(f, g, h, a, b, c, d, e); + ROUND512(e, f, g, h, a, b, c, d); + ROUND512(d, e, f, g, h, a, b, c); + ROUND512(c, d, e, f, g, h, a, b); + ROUND512(b, c, d, e, f, g, h, a); } while (j < 80); /* Compute the current intermediate hash value */ @@ -645,15 +697,25 @@ SHA512_Transform(SHA512_CTX *context, const uint8 *data) /* Clean up */ a = b = c = d = e = f = g = h = T1 = 0; } - -#else /* SHA2_UNROLL_TRANSFORM */ +#else /* SHA2_UNROLL_TRANSFORM */ void -SHA512_Transform(SHA512_CTX *context, const uint8 *data) +SHA512_Transform(SHA512_CTX * context, const uint8 *data) { - uint64 a, b, c, d, e, f, g, h, s0, s1; - uint64 T1, T2, *W512 = (uint64 *)context->buffer; - int j; + uint64 a, + b, + c, + d, + e, + f, + g, + h, + s0, + s1; + uint64 T1, + T2, + *W512 = (uint64 *) context->buffer; + int j; /* Initialize registers with the prev. intermediate value */ a = context->state[0]; @@ -666,11 +728,12 @@ SHA512_Transform(SHA512_CTX *context, const uint8 *data) h = context->state[7]; j = 0; - do { - W512[j] = (uint64)data[7] | ((uint64)data[6] << 8) | - ((uint64)data[5] << 16) | ((uint64)data[4] << 24) | - ((uint64)data[3] << 32) | ((uint64)data[2] << 40) | - ((uint64)data[1] << 48) | ((uint64)data[0] << 56); + do + { + W512[j] = (uint64) data[7] | ((uint64) data[6] << 8) | + ((uint64) data[5] << 16) | ((uint64) data[4] << 24) | + ((uint64) data[3] << 32) | ((uint64) data[2] << 40) | + ((uint64) data[1] << 48) | ((uint64) data[0] << 56); data += 8; /* Apply the SHA-512 compression function to update a..h */ T1 = h + Sigma1_512(e) + Ch(e, f, g) + K512[j] + W512[j]; @@ -687,16 +750,17 @@ SHA512_Transform(SHA512_CTX *context, const uint8 *data) j++; } while (j < 16); - do { + do + { /* Part of the message block expansion: */ - s0 = W512[(j+1)&0x0f]; + s0 = W512[(j + 1) & 0x0f]; s0 = sigma0_512(s0); - s1 = W512[(j+14)&0x0f]; - s1 = sigma1_512(s1); + s1 = W512[(j + 14) & 0x0f]; + s1 = sigma1_512(s1); /* Apply the SHA-512 compression function to update a..h */ T1 = h + Sigma1_512(e) + Ch(e, f, g) + K512[j] + - (W512[j&0x0f] += s1 + W512[(j+9)&0x0f] + s0); + (W512[j & 0x0f] += s1 + W512[(j + 9) & 0x0f] + s0); T2 = Sigma0_512(a) + Maj(a, b, c); h = g; g = f; @@ -723,31 +787,35 @@ SHA512_Transform(SHA512_CTX *context, const uint8 *data) /* Clean up */ a = b = c = d = e = f = g = h = T1 = T2 = 0; } - -#endif /* SHA2_UNROLL_TRANSFORM */ +#endif /* SHA2_UNROLL_TRANSFORM */ void -SHA512_Update(SHA512_CTX *context, const uint8 *data, size_t len) +SHA512_Update(SHA512_CTX * context, const uint8 *data, size_t len) { - size_t freespace, usedspace; + size_t freespace, + usedspace; /* Calling with no data is valid (we do nothing) */ if (len == 0) return; usedspace = (context->bitcount[0] >> 3) % SHA512_BLOCK_LENGTH; - if (usedspace > 0) { + if (usedspace > 0) + { /* Calculate how much free space is available in the buffer */ freespace = SHA512_BLOCK_LENGTH - usedspace; - if (len >= freespace) { + if (len >= freespace) + { /* Fill the buffer completely and process it */ memcpy(&context->buffer[usedspace], data, freespace); ADDINC128(context->bitcount, freespace << 3); len -= freespace; data += freespace; SHA512_Transform(context, context->buffer); - } else { + } + else + { /* The buffer is not yet full */ memcpy(&context->buffer[usedspace], data, len); ADDINC128(context->bitcount, len << 3); @@ -756,14 +824,16 @@ SHA512_Update(SHA512_CTX *context, const uint8 *data, size_t len) return; } } - while (len >= SHA512_BLOCK_LENGTH) { + while (len >= SHA512_BLOCK_LENGTH) + { /* Process as many complete blocks as we can */ SHA512_Transform(context, data); ADDINC128(context->bitcount, SHA512_BLOCK_LENGTH << 3); len -= SHA512_BLOCK_LENGTH; data += SHA512_BLOCK_LENGTH; } - if (len > 0) { + if (len > 0) + { /* There's left-overs, so save 'em */ memcpy(context->buffer, data, len); ADDINC128(context->bitcount, len << 3); @@ -773,25 +843,30 @@ SHA512_Update(SHA512_CTX *context, const uint8 *data, size_t len) } void -SHA512_Last(SHA512_CTX *context) +SHA512_Last(SHA512_CTX * context) { - unsigned int usedspace; + unsigned int usedspace; usedspace = (context->bitcount[0] >> 3) % SHA512_BLOCK_LENGTH; #if BYTE_ORDER == LITTLE_ENDIAN /* Convert FROM host byte order */ - REVERSE64(context->bitcount[0],context->bitcount[0]); - REVERSE64(context->bitcount[1],context->bitcount[1]); + REVERSE64(context->bitcount[0], context->bitcount[0]); + REVERSE64(context->bitcount[1], context->bitcount[1]); #endif - if (usedspace > 0) { + if (usedspace > 0) + { /* Begin padding with a 1 bit: */ context->buffer[usedspace++] = 0x80; - if (usedspace <= SHA512_SHORT_BLOCK_LENGTH) { + if (usedspace <= SHA512_SHORT_BLOCK_LENGTH) + { /* Set-up for the last transform: */ memset(&context->buffer[usedspace], 0, SHA512_SHORT_BLOCK_LENGTH - usedspace); - } else { - if (usedspace < SHA512_BLOCK_LENGTH) { + } + else + { + if (usedspace < SHA512_BLOCK_LENGTH) + { memset(&context->buffer[usedspace], 0, SHA512_BLOCK_LENGTH - usedspace); } /* Do second-to-last transform: */ @@ -800,7 +875,9 @@ SHA512_Last(SHA512_CTX *context) /* And set-up for the last transform: */ memset(context->buffer, 0, SHA512_BLOCK_LENGTH - 2); } - } else { + } + else + { /* Prepare for final transform: */ memset(context->buffer, 0, SHA512_SHORT_BLOCK_LENGTH); @@ -808,27 +885,30 @@ SHA512_Last(SHA512_CTX *context) *context->buffer = 0x80; } /* Store the length of input data (in bits): */ - *(uint64 *)&context->buffer[SHA512_SHORT_BLOCK_LENGTH] = context->bitcount[1]; - *(uint64 *)&context->buffer[SHA512_SHORT_BLOCK_LENGTH+8] = context->bitcount[0]; + *(uint64 *) &context->buffer[SHA512_SHORT_BLOCK_LENGTH] = context->bitcount[1]; + *(uint64 *) &context->buffer[SHA512_SHORT_BLOCK_LENGTH + 8] = context->bitcount[0]; /* Final transform: */ SHA512_Transform(context, context->buffer); } void -SHA512_Final(uint8 digest[], SHA512_CTX *context) +SHA512_Final(uint8 digest[], SHA512_CTX * context) { /* If no digest buffer is passed, we don't bother doing this: */ - if (digest != NULL) { + if (digest != NULL) + { SHA512_Last(context); /* Save the hash data for output: */ #if BYTE_ORDER == LITTLE_ENDIAN { /* Convert TO host byte order */ - int j; - for (j = 0; j < 8; j++) { - REVERSE64(context->state[j],context->state[j]); + int j; + + for (j = 0; j < 8; j++) + { + REVERSE64(context->state[j], context->state[j]); } } #endif @@ -842,7 +922,7 @@ SHA512_Final(uint8 digest[], SHA512_CTX *context) /*** SHA-384: *********************************************************/ void -SHA384_Init(SHA384_CTX *context) +SHA384_Init(SHA384_CTX * context) { if (context == NULL) return; @@ -852,25 +932,28 @@ SHA384_Init(SHA384_CTX *context) } void -SHA384_Update(SHA384_CTX *context, const uint8 *data, size_t len) +SHA384_Update(SHA384_CTX * context, const uint8 *data, size_t len) { - SHA512_Update((SHA512_CTX *)context, data, len); + SHA512_Update((SHA512_CTX *) context, data, len); } void -SHA384_Final(uint8 digest[], SHA384_CTX *context) +SHA384_Final(uint8 digest[], SHA384_CTX * context) { /* If no digest buffer is passed, we don't bother doing this: */ - if (digest != NULL) { - SHA512_Last((SHA512_CTX *)context); + if (digest != NULL) + { + SHA512_Last((SHA512_CTX *) context); /* Save the hash data for output: */ #if BYTE_ORDER == LITTLE_ENDIAN { /* Convert TO host byte order */ - int j; - for (j = 0; j < 6; j++) { - REVERSE64(context->state[j],context->state[j]); + int j; + + for (j = 0; j < 6; j++) + { + REVERSE64(context->state[j], context->state[j]); } } #endif diff --git a/contrib/pgcrypto/sha2.h b/contrib/pgcrypto/sha2.h index 2dfb13ceb1..824bcefd29 100644 --- a/contrib/pgcrypto/sha2.h +++ b/contrib/pgcrypto/sha2.h @@ -1,10 +1,10 @@ -/* $PostgreSQL: pgsql/contrib/pgcrypto/sha2.h,v 1.1 2005/07/10 13:46:29 momjian Exp $ */ +/* $PostgreSQL: pgsql/contrib/pgcrypto/sha2.h,v 1.2 2005/10/15 02:49:06 momjian Exp $ */ /* $OpenBSD: sha2.h,v 1.2 2004/04/28 23:11:57 millert Exp $ */ /* * FILE: sha2.h * AUTHOR: Aaron D. Gifford - * + * * Copyright (c) 2000-2001, Aaron D. Gifford * All rights reserved. * @@ -12,18 +12,18 @@ * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holder nor the names of contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTOR(S) BE LIABLE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTOR(S) BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) @@ -42,39 +42,41 @@ /*** SHA-256/384/512 Various Length Definitions ***********************/ #define SHA256_BLOCK_LENGTH 64 #define SHA256_DIGEST_LENGTH 32 -#define SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1) +#define SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1) #define SHA384_BLOCK_LENGTH 128 #define SHA384_DIGEST_LENGTH 48 -#define SHA384_DIGEST_STRING_LENGTH (SHA384_DIGEST_LENGTH * 2 + 1) +#define SHA384_DIGEST_STRING_LENGTH (SHA384_DIGEST_LENGTH * 2 + 1) #define SHA512_BLOCK_LENGTH 128 #define SHA512_DIGEST_LENGTH 64 -#define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1) +#define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1) /*** SHA-256/384/512 Context Structures *******************************/ -typedef struct _SHA256_CTX { - uint32 state[8]; - uint64 bitcount; - uint8 buffer[SHA256_BLOCK_LENGTH]; -} SHA256_CTX; -typedef struct _SHA512_CTX { - uint64 state[8]; - uint64 bitcount[2]; - uint8 buffer[SHA512_BLOCK_LENGTH]; -} SHA512_CTX; +typedef struct _SHA256_CTX +{ + uint32 state[8]; + uint64 bitcount; + uint8 buffer[SHA256_BLOCK_LENGTH]; +} SHA256_CTX; +typedef struct _SHA512_CTX +{ + uint64 state[8]; + uint64 bitcount[2]; + uint8 buffer[SHA512_BLOCK_LENGTH]; +} SHA512_CTX; typedef SHA512_CTX SHA384_CTX; -void SHA256_Init(SHA256_CTX *); -void SHA256_Update(SHA256_CTX *, const uint8 *, size_t); -void SHA256_Final(uint8[SHA256_DIGEST_LENGTH], SHA256_CTX *); +void SHA256_Init(SHA256_CTX *); +void SHA256_Update(SHA256_CTX *, const uint8 *, size_t); +void SHA256_Final(uint8[SHA256_DIGEST_LENGTH], SHA256_CTX *); -void SHA384_Init(SHA384_CTX *); -void SHA384_Update(SHA384_CTX *, const uint8 *, size_t); -void SHA384_Final(uint8[SHA384_DIGEST_LENGTH], SHA384_CTX *); +void SHA384_Init(SHA384_CTX *); +void SHA384_Update(SHA384_CTX *, const uint8 *, size_t); +void SHA384_Final(uint8[SHA384_DIGEST_LENGTH], SHA384_CTX *); -void SHA512_Init(SHA512_CTX *); -void SHA512_Update(SHA512_CTX *, const uint8 *, size_t); -void SHA512_Final(uint8[SHA512_DIGEST_LENGTH], SHA512_CTX *); +void SHA512_Init(SHA512_CTX *); +void SHA512_Update(SHA512_CTX *, const uint8 *, size_t); +void SHA512_Final(uint8[SHA512_DIGEST_LENGTH], SHA512_CTX *); -#endif /* _SHA2_H */ +#endif /* _SHA2_H */ diff --git a/contrib/pgstattuple/pgstattuple.c b/contrib/pgstattuple/pgstattuple.c index 3056bd8978..cb79fadedb 100644 --- a/contrib/pgstattuple/pgstattuple.c +++ b/contrib/pgstattuple/pgstattuple.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/pgstattuple/pgstattuple.c,v 1.19 2005/05/30 23:09:06 tgl Exp $ + * $PostgreSQL: pgsql/contrib/pgstattuple/pgstattuple.c,v 1.20 2005/10/15 02:49:06 momjian Exp $ * * Copyright (c) 2001,2002 Tatsuo Ishii * @@ -123,8 +123,8 @@ pgstattuple_real(Relation rel, FunctionCallInfo fcinfo) tupdesc = CreateTupleDescCopy(tupdesc); /* - * Generate attribute metadata needed later to produce tuples from raw - * C strings + * Generate attribute metadata needed later to produce tuples from raw C + * strings */ attinmeta = TupleDescGetAttInMetadata(tupdesc); @@ -197,9 +197,9 @@ pgstattuple_real(Relation rel, FunctionCallInfo fcinfo) } /* - * Prepare a values array for constructing the tuple. This should be - * an array of C strings which will be processed later by the - * appropriate "in" functions. + * Prepare a values array for constructing the tuple. This should be an + * array of C strings which will be processed later by the appropriate + * "in" functions. */ values = (char **) palloc(NCOLUMNS * sizeof(char *)); for (i = 0; i < NCOLUMNS; i++) diff --git a/contrib/seg/seg.c b/contrib/seg/seg.c index 5bdad542e4..52f65b062c 100644 --- a/contrib/seg/seg.c +++ b/contrib/seg/seg.c @@ -124,8 +124,7 @@ seg_out(SEG * seg) if (seg->lower == seg->upper && seg->l_ext == seg->u_ext) { /* - * indicates that this interval was built by seg_in off a single - * point + * indicates that this interval was built by seg_in off a single point */ p += restore(p, seg->lower, seg->l_sigd); } @@ -349,8 +348,7 @@ gseg_picksplit(GistEntryVector *entryvec, size_waste = size_union - size_inter; /* - * are these a more promising split that what we've already - * seen? + * are these a more promising split that what we've already seen? */ if (size_waste > waste || firsttime) { @@ -375,24 +373,24 @@ gseg_picksplit(GistEntryVector *entryvec, rt_seg_size(datum_r, &size_r); /* - * Now split up the regions between the two seeds. An important - * property of this split algorithm is that the split vector v has the - * indices of items to be split in order in its left and right - * vectors. We exploit this property by doing a merge in the code - * that actually splits the page. + * Now split up the regions between the two seeds. An important property + * of this split algorithm is that the split vector v has the indices of + * items to be split in order in its left and right vectors. We exploit + * this property by doing a merge in the code that actually splits the + * page. * - * For efficiency, we also place the new index tuple in this loop. This - * is handled at the very end, when we have placed all the existing - * tuples and i == maxoff + 1. + * For efficiency, we also place the new index tuple in this loop. This is + * handled at the very end, when we have placed all the existing tuples + * and i == maxoff + 1. */ maxoff = OffsetNumberNext(maxoff); for (i = FirstOffsetNumber; i <= maxoff; i = OffsetNumberNext(i)) { /* - * If we've already decided where to place this item, just put it - * on the right list. Otherwise, we need to figure out which page - * needs the least enlargement in order to store the item. + * If we've already decided where to place this item, just put it on + * the right list. Otherwise, we need to figure out which page needs + * the least enlargement in order to store the item. */ if (i == seed_1) @@ -742,8 +740,8 @@ seg_cmp(SEG * a, SEG * b) * a->lower == b->lower, so consider type of boundary. * * A '-' lower bound is < any other kind (this could only be relevant if - * -HUGE_VAL is used as a regular data value). A '<' lower bound is < - * any other kind except '-'. A '>' lower bound is > any other kind. + * -HUGE_VAL is used as a regular data value). A '<' lower bound is < any + * other kind except '-'. A '>' lower bound is > any other kind. */ if (a->l_ext != b->l_ext) { @@ -764,8 +762,7 @@ seg_cmp(SEG * a, SEG * b) /* * For other boundary types, consider # of significant digits first. */ - if (a->l_sigd < b->l_sigd) /* (a) is blurred and is likely to include - * (b) */ + if (a->l_sigd < b->l_sigd) /* (a) is blurred and is likely to include (b) */ return -1; if (a->l_sigd > b->l_sigd) /* (a) is less blurred and is likely to be * included in (b) */ @@ -800,8 +797,8 @@ seg_cmp(SEG * a, SEG * b) * a->upper == b->upper, so consider type of boundary. * * A '-' upper bound is > any other kind (this could only be relevant if - * HUGE_VAL is used as a regular data value). A '<' upper bound is < - * any other kind. A '>' upper bound is > any other kind except '-'. + * HUGE_VAL is used as a regular data value). A '<' upper bound is < any + * other kind. A '>' upper bound is > any other kind except '-'. */ if (a->u_ext != b->u_ext) { @@ -820,11 +817,10 @@ seg_cmp(SEG * a, SEG * b) } /* - * For other boundary types, consider # of significant digits first. - * Note result here is converse of the lower-boundary case. + * For other boundary types, consider # of significant digits first. Note + * result here is converse of the lower-boundary case. */ - if (a->u_sigd < b->u_sigd) /* (a) is blurred and is likely to include - * (b) */ + if (a->u_sigd < b->u_sigd) /* (a) is blurred and is likely to include (b) */ return 1; if (a->u_sigd > b->u_sigd) /* (a) is less blurred and is likely to be * included in (b) */ @@ -908,17 +904,17 @@ restore(char *result, float val, int n) sign; /* - * put a cap on the number of siugnificant digits to avoid nonsense in - * the output + * put a cap on the number of siugnificant digits to avoid nonsense in the + * output */ n = Min(n, FLT_DIG); /* remember the sign */ sign = (val < 0 ? 1 : 0); - efmt[5] = '0' + (n - 1) % 10; /* makes %-15.(n-1)e -- this - * format guarantees that the - * exponent is always present */ + efmt[5] = '0' + (n - 1) % 10; /* makes %-15.(n-1)e -- this format + * guarantees that the exponent is + * always present */ sprintf(result, efmt, val); @@ -940,8 +936,8 @@ restore(char *result, float val, int n) if (Abs(exp) <= 4) { /* - * remove the decimal point from the mantyssa and write the - * digits to the buf array + * remove the decimal point from the mantyssa and write the digits + * to the buf array */ for (p = result + sign, i = 10, dp = 0; *p != 'e'; p++, i++) { @@ -960,10 +956,9 @@ restore(char *result, float val, int n) if (dp - 10 + exp >= n) { /* - * the decimal point is behind the last significant - * digit; the digits in between must be converted to - * the exponent and the decimal point placed after the - * first digit + * the decimal point is behind the last significant digit; + * the digits in between must be converted to the exponent + * and the decimal point placed after the first digit */ exp = dp - 10 + exp - n; buf[10 + n] = '\0'; @@ -978,8 +973,8 @@ restore(char *result, float val, int n) } /* - * adjust the exponent by the number of digits after - * the decimal point + * adjust the exponent by the number of digits after the + * decimal point */ if (n > 1) sprintf(&buf[11 + n], "e%d", exp + n - 1); diff --git a/contrib/spi/autoinc.c b/contrib/spi/autoinc.c index b6e0c64331..bad7c52735 100644 --- a/contrib/spi/autoinc.c +++ b/contrib/spi/autoinc.c @@ -73,8 +73,8 @@ autoinc(PG_FUNCTION_ARGS) if (SPI_gettypeid(tupdesc, attnum) != INT4OID) ereport(ERROR, (errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION), - errmsg("attribute \"%s\" of \"%s\" must be type INT4", - args[i], relname))); + errmsg("attribute \"%s\" of \"%s\" must be type INT4", + args[i], relname))); val = DatumGetInt32(SPI_getbinval(rettuple, tupdesc, attnum, &isnull)); diff --git a/contrib/spi/insert_username.c b/contrib/spi/insert_username.c index 237b14d25c..ce8c21f9be 100644 --- a/contrib/spi/insert_username.c +++ b/contrib/spi/insert_username.c @@ -65,7 +65,7 @@ insert_username(PG_FUNCTION_ARGS) if (attnum < 0) ereport(ERROR, (errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION), - errmsg("\"%s\" has no attribute \"%s\"", relname, args[0]))); + errmsg("\"%s\" has no attribute \"%s\"", relname, args[0]))); if (SPI_gettypeid(tupdesc, attnum) != TEXTOID) ereport(ERROR, @@ -75,7 +75,7 @@ insert_username(PG_FUNCTION_ARGS) /* create fields containing name */ newval = DirectFunctionCall1(textin, - CStringGetDatum(GetUserNameFromId(GetUserId()))); + CStringGetDatum(GetUserNameFromId(GetUserId()))); /* construct new tuple */ rettuple = SPI_modifytuple(rel, rettuple, 1, &attnum, &newval, NULL); diff --git a/contrib/spi/moddatetime.c b/contrib/spi/moddatetime.c index f3a97e1c81..14556a8514 100644 --- a/contrib/spi/moddatetime.c +++ b/contrib/spi/moddatetime.c @@ -76,9 +76,8 @@ moddatetime(PG_FUNCTION_ARGS) Int32GetDatum(-1)); /* - * This gets the position in the tuple 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 tuple 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]); @@ -100,8 +99,8 @@ moddatetime(PG_FUNCTION_ARGS) if (SPI_gettypeid(tupdesc, attnum) != TIMESTAMPOID) ereport(ERROR, (errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION), - errmsg("attribute \"%s\" of \"%s\" must be type TIMESTAMP", - args[0], relname))); + errmsg("attribute \"%s\" of \"%s\" must be type TIMESTAMP", + args[0], relname))); /* 1 is the number of items in the arrays attnum and newdt. attnum is the positional number of the field to be updated. diff --git a/contrib/spi/refint.c b/contrib/spi/refint.c index bc358f6eb4..8163f8ebaf 100644 --- a/contrib/spi/refint.c +++ b/contrib/spi/refint.c @@ -114,8 +114,8 @@ check_primary_key(PG_FUNCTION_ARGS) kvals = (Datum *) palloc(nkeys * sizeof(Datum)); /* - * Construct ident string as TriggerName $ TriggeredRelationId and try - * to find prepared execution plan. + * Construct ident string as TriggerName $ TriggeredRelationId and try to + * find prepared execution plan. */ snprintf(ident, sizeof(ident), "%s$%u", trigger->tgname, rel->rd_id); plan = find_plan(ident, &PPlans, &nPPlans); @@ -134,16 +134,16 @@ check_primary_key(PG_FUNCTION_ARGS) if (fnumber < 0) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_COLUMN), - errmsg("there is no attribute \"%s\" in relation \"%s\"", - args[i], SPI_getrelname(rel)))); + errmsg("there is no attribute \"%s\" in relation \"%s\"", + args[i], SPI_getrelname(rel)))); /* Well, get binary (in internal format) value of column */ kvals[i] = SPI_getbinval(tuple, tupdesc, fnumber, &isnull); /* - * If it's NULL then nothing to do! DON'T FORGET call SPI_finish - * ()! DON'T FORGET return tuple! Executor inserts tuple you're - * returning! If you return NULL then nothing will be inserted! + * If it's NULL then nothing to do! DON'T FORGET call SPI_finish ()! + * DON'T FORGET return tuple! Executor inserts tuple you're returning! + * If you return NULL then nothing will be inserted! */ if (isnull) { @@ -164,14 +164,14 @@ check_primary_key(PG_FUNCTION_ARGS) char sql[8192]; /* - * Construct query: SELECT 1 FROM _referenced_relation_ WHERE - * Pkey1 = $1 [AND Pkey2 = $2 [...]] + * Construct query: SELECT 1 FROM _referenced_relation_ WHERE Pkey1 = + * $1 [AND Pkey2 = $2 [...]] */ snprintf(sql, sizeof(sql), "select 1 from %s where ", relname); for (i = 0; i < nkeys; i++) { snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), "%s = $%d %s", - args[i + nkeys + 1], i + 1, (i < nkeys - 1) ? "and " : ""); + args[i + nkeys + 1], i + 1, (i < nkeys - 1) ? "and " : ""); } /* Prepare plan for query */ @@ -181,9 +181,8 @@ check_primary_key(PG_FUNCTION_ARGS) elog(ERROR, "check_primary_key: SPI_prepare returned %d", SPI_result); /* - * Remember that SPI_prepare places plan in current memory context - * - so, we have to save plan in Top memory context for latter - * use. + * Remember that SPI_prepare places plan in current memory context - + * so, we have to save plan in Top memory context for latter use. */ pplan = SPI_saveplan(pplan); if (pplan == NULL) @@ -252,8 +251,7 @@ check_foreign_key(PG_FUNCTION_ARGS) EPlan *plan; /* prepared plan(s) */ Oid *argtypes = NULL; /* key types to prepare execution plan */ bool isnull; /* to know is some column NULL or not */ - bool isequal = true; /* are keys in both tuples equal (in - * UPDATE) */ + bool isequal = true; /* are keys in both tuples equal (in UPDATE) */ char ident[2 * NAMEDATALEN]; /* to identify myself */ int is_update = 0; int ret; @@ -287,9 +285,8 @@ check_foreign_key(PG_FUNCTION_ARGS) trigtuple = trigdata->tg_trigtuple; /* - * But if this is UPDATE then we have to return tg_newtuple. Also, if - * key in tg_newtuple is the same as in tg_trigtuple then nothing to - * do. + * But if this is UPDATE then we have to return tg_newtuple. Also, if key + * in tg_newtuple is the same as in tg_trigtuple then nothing to do. */ is_update = 0; if (TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event)) @@ -337,8 +334,8 @@ check_foreign_key(PG_FUNCTION_ARGS) kvals = (Datum *) palloc(nkeys * sizeof(Datum)); /* - * Construct ident string as TriggerName $ TriggeredRelationId and try - * to find prepared execution plan(s). + * Construct ident string as TriggerName $ TriggeredRelationId and try to + * find prepared execution plan(s). */ snprintf(ident, sizeof(ident), "%s$%u", trigger->tgname, rel->rd_id); plan = find_plan(ident, &FPlans, &nFPlans); @@ -365,16 +362,16 @@ check_foreign_key(PG_FUNCTION_ARGS) if (fnumber < 0) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_COLUMN), - errmsg("there is no attribute \"%s\" in relation \"%s\"", - args[i], SPI_getrelname(rel)))); + errmsg("there is no attribute \"%s\" in relation \"%s\"", + args[i], SPI_getrelname(rel)))); /* Well, get binary (in internal format) value of column */ kvals[i] = SPI_getbinval(trigtuple, tupdesc, fnumber, &isnull); /* - * If it's NULL then nothing to do! DON'T FORGET call SPI_finish - * ()! DON'T FORGET return tuple! Executor inserts tuple you're - * returning! If you return NULL then nothing will be inserted! + * If it's NULL then nothing to do! DON'T FORGET call SPI_finish ()! + * DON'T FORGET return tuple! Executor inserts tuple you're returning! + * If you return NULL then nothing will be inserted! */ if (isnull) { @@ -383,9 +380,9 @@ check_foreign_key(PG_FUNCTION_ARGS) } /* - * If UPDATE then get column value from new tuple being inserted - * and compare is this the same as old one. For the moment we use - * string presentation of values... + * If UPDATE then get column value from new tuple being inserted and + * compare is this the same as old one. For the moment we use string + * presentation of values... */ if (newtuple != NULL) { @@ -473,7 +470,7 @@ check_foreign_key(PG_FUNCTION_ARGS) type = SPI_gettype(tupdesc, fn); if ((strcmp(type, "text") && strcmp(type, "varchar") && - strcmp(type, "char") && strcmp(type, "bpchar") && + strcmp(type, "char") && strcmp(type, "bpchar") && strcmp(type, "date") && strcmp(type, "timestamp")) == 0) is_char_type = 1; #ifdef DEBUG_QUERY @@ -482,8 +479,7 @@ check_foreign_key(PG_FUNCTION_ARGS) #endif /* - * is_char_type =1 i set ' ' for define a new - * value + * is_char_type =1 i set ' ' for define a new value */ snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), " %s = %s%s%s %s ", @@ -503,8 +499,8 @@ check_foreign_key(PG_FUNCTION_ARGS) /* * For 'S'etnull action we construct UPDATE query - UPDATE * _referencing_relation_ SET Fkey1 null [, Fkey2 null [...]] - * WHERE Fkey1 = $1 [AND Fkey2 = $2 [...]] - to set key - * columns in all referencing tuples to NULL. + * WHERE Fkey1 = $1 [AND Fkey2 = $2 [...]] - to set key columns in + * all referencing tuples to NULL. */ else if (action == 's') { @@ -532,9 +528,9 @@ check_foreign_key(PG_FUNCTION_ARGS) elog(ERROR, "check_foreign_key: SPI_prepare returned %d", SPI_result); /* - * Remember that SPI_prepare places plan in current memory - * context - so, we have to save plan in Top memory context - * for latter use. + * Remember that SPI_prepare places plan in current memory context + * - so, we have to save plan in Top memory context for latter + * use. */ pplan = SPI_saveplan(pplan); if (pplan == NULL) @@ -566,8 +562,8 @@ check_foreign_key(PG_FUNCTION_ARGS) for (r = 0; r < nrefs; r++) { /* - * For 'R'estrict we may to execute plan for one tuple only, for - * other actions - for all tuples. + * For 'R'estrict we may to execute plan for one tuple only, for other + * actions - for all tuples. */ int tcount = (action == 'r') ? 1 : 0; diff --git a/contrib/spi/timetravel.c b/contrib/spi/timetravel.c index 0eae24a576..84a1153854 100644 --- a/contrib/spi/timetravel.c +++ b/contrib/spi/timetravel.c @@ -245,8 +245,8 @@ timetravel(PG_FUNCTION_ARGS) elog(ERROR, "timetravel (%s): %s must be NOT NULL", relname, args[a_time_off]); /* - * If DELETE/UPDATE of tuple with stop_date neq INFINITY then say - * upper Executor to skip operation for this tuple + * If DELETE/UPDATE of tuple with stop_date neq INFINITY then say upper + * Executor to skip operation for this tuple */ if (newtuple != NULL) { /* UPDATE */ @@ -263,8 +263,7 @@ timetravel(PG_FUNCTION_ARGS) relname, args[a_time_on], args[a_time_off]); } if (oldtimeoff != NOEND_ABSTIME) - { /* current record is a deleted/updated - * record */ + { /* current record is a deleted/updated record */ pfree(relname); return PointerGetDatum(NULL); } @@ -285,8 +284,7 @@ timetravel(PG_FUNCTION_ARGS) } /* change date column(s) */ - cvals[attnum[a_time_off] - 1] = newtimeoff; /* stop_date eq current - * date */ + cvals[attnum[a_time_off] - 1] = newtimeoff; /* stop_date eq current date */ cnulls[attnum[a_time_off] - 1] = ' '; if (!newtuple) @@ -299,8 +297,8 @@ timetravel(PG_FUNCTION_ARGS) } /* - * Construct ident string as TriggerName $ TriggeredRelationId and try - * to find prepared execution plan. + * Construct ident string as TriggerName $ TriggeredRelationId and try to + * find prepared execution plan. */ snprintf(ident, sizeof(ident), "%s$%u", trigger->tgname, rel->rd_id); plan = find_plan(ident, &Plans, &nPlans); @@ -339,9 +337,8 @@ timetravel(PG_FUNCTION_ARGS) elog(ERROR, "timetravel (%s): SPI_prepare returned %d", relname, SPI_result); /* - * Remember that SPI_prepare places plan in current memory context - * - so, we have to save plan in Top memory context for latter - * use. + * Remember that SPI_prepare places plan in current memory context - + * so, we have to save plan in Top memory context for latter use. */ pplan = SPI_saveplan(pplan); if (pplan == NULL) @@ -398,8 +395,8 @@ timetravel(PG_FUNCTION_ARGS) rettuple = SPI_modifytuple(rel, newtuple, chnattrs, chattrs, newvals, newnulls); /* - * SPI_copytuple allocates tmptuple in upper executor context - - * have to free allocation using SPI_pfree + * SPI_copytuple allocates tmptuple in upper executor context - have + * to free allocation using SPI_pfree */ /* SPI_pfree(tmptuple); */ } diff --git a/contrib/tablefunc/tablefunc.c b/contrib/tablefunc/tablefunc.c index 97163c81a4..7f67f37b00 100644 --- a/contrib/tablefunc/tablefunc.c +++ b/contrib/tablefunc/tablefunc.c @@ -184,8 +184,7 @@ normal_rand(PG_FUNCTION_ARGS) funcctx = SRF_FIRSTCALL_INIT(); /* - * switch to memory context appropriate for multiple function - * calls + * switch to memory context appropriate for multiple function calls */ oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); @@ -196,10 +195,10 @@ normal_rand(PG_FUNCTION_ARGS) fctx = (normal_rand_fctx *) palloc(sizeof(normal_rand_fctx)); /* - * Use fctx to keep track of upper and lower bounds from call to - * call. It will also be used to carry over the spare value we get - * from the Box-Muller algorithm so that we only actually - * calculate a new value every other call. + * Use fctx to keep track of upper and lower bounds from call to call. + * It will also be used to carry over the spare value we get from the + * Box-Muller algorithm so that we only actually calculate a new value + * every other call. */ fctx->mean = PG_GETARG_FLOAT8(1); fctx->stddev = PG_GETARG_FLOAT8(2); @@ -254,7 +253,7 @@ normal_rand(PG_FUNCTION_ARGS) SRF_RETURN_NEXT(funcctx, Float8GetDatum(result)); } else - /* do when there is no more left */ + /* do when there is no more left */ SRF_RETURN_DONE(funcctx); } @@ -331,8 +330,8 @@ get_normal_pair(float8 *x1, float8 *x2) * 1. SQL result must be ordered by 1,2. * 2. The number of values columns depends on the tuple description * of the function's declared return type. The return type's columns - * must match the datatypes of the SQL query's result. The datatype - * of the category column can be anything, however. + * must match the datatypes of the SQL query's result. The datatype + * of the category column can be anything, however. * 3. Missing values (i.e. not enough adjacent rows of same rowid to * fill the number of result values columns) are filled in with nulls. * 4. Extra values (i.e. too many adjacent rows of same rowid to fill @@ -368,8 +367,7 @@ crosstab(PG_FUNCTION_ARGS) funcctx = SRF_FIRSTCALL_INIT(); /* - * switch to memory context appropriate for multiple function - * calls + * switch to memory context appropriate for multiple function calls */ oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); @@ -394,7 +392,7 @@ crosstab(PG_FUNCTION_ARGS) * 1. rowname * the label or identifier for each row in the final result * 2. category - * the label or identifier for each column in the final result + * the label or identifier for each column in the final result * 3. values * the value for each column in the final result *---------- @@ -404,7 +402,7 @@ crosstab(PG_FUNCTION_ARGS) (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("invalid source data SQL statement"), errdetail("The provided SQL must return 3 " - "columns: rowid, category, and values."))); + "columns: rowid, category, and values."))); } else { @@ -439,8 +437,8 @@ crosstab(PG_FUNCTION_ARGS) tupdesc = CreateTupleDescCopy(tupdesc); /* - * Check that return tupdesc is compatible with the data we got - * from SPI, at least based on number and type of attributes + * Check that return tupdesc is compatible with the data we got from + * SPI, at least based on number and type of attributes */ if (!compatCrosstabTupleDescs(tupdesc, spi_tupdesc)) ereport(ERROR, @@ -449,8 +447,8 @@ crosstab(PG_FUNCTION_ARGS) "incompatible"))); /* - * Generate attribute metadata needed later to produce tuples from - * raw C strings + * Generate attribute metadata needed later to produce tuples from raw + * C strings */ attinmeta = TupleDescGetAttInMetadata(tupdesc); funcctx->attinmeta = attinmeta; @@ -530,11 +528,10 @@ crosstab(PG_FUNCTION_ARGS) rowid = SPI_getvalue(spi_tuple, spi_tupdesc, 1); /* - * If this is the first pass through the values for this - * rowid set it, otherwise make sure it hasn't changed on - * us. Also check to see if the rowid is the same as that - * of the last tuple sent -- if so, skip this tuple - * entirely + * If this is the first pass through the values for this rowid + * set it, otherwise make sure it hasn't changed on us. Also + * check to see if the rowid is the same as that of the last + * tuple sent -- if so, skip this tuple entirely */ if (i == 0) values[0] = pstrdup(rowid); @@ -550,16 +547,15 @@ crosstab(PG_FUNCTION_ARGS) * Get the next category item value, which is alway * attribute number three. * - * Be careful to sssign the value to the array index - * based on which category we are presently - * processing. + * Be careful to sssign the value to the array index based on + * which category we are presently processing. */ values[1 + i] = SPI_getvalue(spi_tuple, spi_tupdesc, 3); /* - * increment the counter since we consume a row for - * each category, but not for last pass because the - * API will do that for us + * increment the counter since we consume a row for each + * category, but not for last pass because the API will do + * that for us */ if (i < (num_categories - 1)) call_cntr = ++funcctx->call_cntr; @@ -567,9 +563,9 @@ crosstab(PG_FUNCTION_ARGS) else { /* - * We'll fill in NULLs for the missing values, but we - * need to decrement the counter since this sql result - * row doesn't belong to the current output tuple. + * We'll fill in NULLs for the missing values, but we need + * to decrement the counter since this sql result row + * doesn't belong to the current output tuple. */ call_cntr = --funcctx->call_cntr; break; @@ -584,8 +580,8 @@ crosstab(PG_FUNCTION_ARGS) if (values[0] != NULL) { /* - * switch to memory context appropriate for multiple - * function calls + * switch to memory context appropriate for multiple function + * calls */ oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); @@ -612,8 +608,8 @@ crosstab(PG_FUNCTION_ARGS) else { /* - * Skipping this tuple entirely, but we need to advance - * the counter like the API would if we had returned one. + * Skipping this tuple entirely, but we need to advance the + * counter like the API would if we had returned one. */ call_cntr = ++funcctx->call_cntr; @@ -631,7 +627,7 @@ crosstab(PG_FUNCTION_ARGS) } } else - /* do when there is no more left */ + /* do when there is no more left */ { /* release SPI related resources */ SPI_finish(); @@ -730,10 +726,10 @@ crosstab_hash(PG_FUNCTION_ARGS) /* * SFRM_Materialize mode expects us to return a NULL Datum. The actual - * tuples are in our tuplestore and passed back through - * rsinfo->setResult. rsinfo->setDesc is set to the tuple description - * that we actually used to build our tuples with, so the caller can - * verify we did what it was expecting. + * tuples are in our tuplestore and passed back through rsinfo->setResult. + * rsinfo->setDesc is set to the tuple description that we actually used + * to build our tuples with, so the caller can verify we did what it was + * expecting. */ rsinfo->setDesc = tupdesc; MemoryContextSwitchTo(oldcontext); @@ -758,8 +754,8 @@ load_categories_hash(char *cats_sql, MemoryContext per_query_ctx) ctl.entrysize = sizeof(crosstab_HashEnt); /* - * use INIT_CATS, defined above as a guess of how many hash table - * entries to create, initially + * use INIT_CATS, defined above as a guess of how many hash table entries + * to create, initially */ crosstab_HashTable = hash_create("crosstab hash", INIT_CATS, &ctl, HASH_ELEM); @@ -780,8 +776,8 @@ load_categories_hash(char *cats_sql, MemoryContext per_query_ctx) int i; /* - * The provided categories SQL query must always return one - * column: category - the label or identifier for each column + * The provided categories SQL query must always return one column: + * category - the label or identifier for each column */ if (spi_tupdesc->natts != 1) ereport(ERROR, @@ -872,26 +868,24 @@ get_crosstab_tuplestore(char *sql, } /* - * The provided SQL query must always return at least three - * columns: + * The provided SQL query must always return at least three columns: * - * 1. rowname the label for each row - column 1 in the final result - * 2. category the label for each value-column in the final - * result 3. value the values used to populate the - * value-columns + * 1. rowname the label for each row - column 1 in the final result 2. + * category the label for each value-column in the final result 3. + * value the values used to populate the value-columns * * If there are more than three columns, the last two are taken as - * "category" and "values". The first column is taken as - * "rowname". Additional columns (2 thru N-2) are assumed the same - * for the same "rowname", and are copied into the result tuple - * from the first time we encounter a particular rowname. + * "category" and "values". The first column is taken as "rowname". + * Additional columns (2 thru N-2) are assumed the same for the same + * "rowname", and are copied into the result tuple from the first time + * we encounter a particular rowname. */ if (ncols < 3) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("invalid source data SQL statement"), errdetail("The provided SQL must return 3 " \ - " columns; rowid, category, and values."))); + " columns; rowid, category, and values."))); result_ncols = (ncols - 2) + num_categories; @@ -902,7 +896,7 @@ get_crosstab_tuplestore(char *sql, errmsg("invalid return type"), errdetail("query-specified return " \ "tuple has %d columns but crosstab " \ - "returns %d", tupdesc->natts, result_ncols))); + "returns %d", tupdesc->natts, result_ncols))); /* allocate space */ values = (char **) palloc(result_ncols * sizeof(char *)); @@ -933,14 +927,13 @@ get_crosstab_tuplestore(char *sql, if ((lastrowid == NULL) || (strcmp(rowid, lastrowid) != 0)) { /* - * a new row means we need to flush the old one first, - * unless we're on the very first row + * a new row means we need to flush the old one first, unless + * we're on the very first row */ if (lastrowid != NULL) { /* - * switch to appropriate context while storing the - * tuple + * switch to appropriate context while storing the tuple */ SPIcontext = MemoryContextSwitchTo(per_query_ctx); @@ -1103,10 +1096,10 @@ connectby_text(PG_FUNCTION_ARGS) /* * SFRM_Materialize mode expects us to return a NULL Datum. The actual - * tuples are in our tuplestore and passed back through - * rsinfo->setResult. rsinfo->setDesc is set to the tuple description - * that we actually used to build our tuples with, so the caller can - * verify we did what it was expecting. + * tuples are in our tuplestore and passed back through rsinfo->setResult. + * rsinfo->setDesc is set to the tuple description that we actually used + * to build our tuples with, so the caller can verify we did what it was + * expecting. */ return (Datum) 0; } @@ -1182,10 +1175,10 @@ connectby_text_serial(PG_FUNCTION_ARGS) /* * SFRM_Materialize mode expects us to return a NULL Datum. The actual - * tuples are in our tuplestore and passed back through - * rsinfo->setResult. rsinfo->setDesc is set to the tuple description - * that we actually used to build our tuples with, so the caller can - * verify we did what it was expecting. + * tuples are in our tuplestore and passed back through rsinfo->setResult. + * rsinfo->setDesc is set to the tuple description that we actually used + * to build our tuples with, so the caller can verify we did what it was + * expecting. */ return (Datum) 0; } @@ -1382,16 +1375,16 @@ build_tuplestore_recursively(char *key_fld, { /* * Check that return tupdesc is compatible with the one we got - * from the query, but only at level 0 -- no need to check - * more than once + * from the query, but only at level 0 -- no need to check more + * than once */ if (!compatConnectbyTupleDescs(tupdesc, spi_tupdesc)) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("invalid return type"), - errdetail("Return and SQL tuple descriptions are " \ - "incompatible."))); + errdetail("Return and SQL tuple descriptions are " \ + "incompatible."))); } for (i = 0; i < proc; i++) @@ -1576,7 +1569,7 @@ compatConnectbyTupleDescs(TupleDesc ret_tupdesc, TupleDesc sql_tupdesc) (errcode(ERRCODE_SYNTAX_ERROR), errmsg("invalid return type"), errdetail("SQL parent key field datatype does " \ - "not match return parent key field datatype."))); + "not match return parent key field datatype."))); /* OK, the two tupdescs are compatible for our purposes */ return true; @@ -1605,9 +1598,9 @@ compatCrosstabTupleDescs(TupleDesc ret_tupdesc, TupleDesc sql_tupdesc) "return rowid datatype."))); /* - * - attribute [1] of the sql tuple is the category; no need to check - * it - attribute [2] of the sql tuple should match attributes [1] to - * [natts] of the return tuple + * - attribute [1] of the sql tuple is the category; no need to check it - + * attribute [2] of the sql tuple should match attributes [1] to [natts] + * of the return tuple */ sql_attr = sql_tupdesc->attrs[2]; for (i = 1; i < ret_tupdesc->natts; i++) diff --git a/contrib/tsearch2/dict.c b/contrib/tsearch2/dict.c index de81846e37..f221d174ef 100644 --- a/contrib/tsearch2/dict.c +++ b/contrib/tsearch2/dict.c @@ -91,9 +91,9 @@ reset_dict(void) static int comparedict(const void *a, const void *b) { - if ( ((DictInfo *) a)->dict_id == ((DictInfo *) b)->dict_id ) + if (((DictInfo *) a)->dict_id == ((DictInfo *) b)->dict_id) return 0; - return ( ((DictInfo *) a)->dict_id < ((DictInfo *) b)->dict_id ) ? -1 : 1; + return (((DictInfo *) a)->dict_id < ((DictInfo *) b)->dict_id) ? -1 : 1; } DictInfo * @@ -184,8 +184,8 @@ lexize(PG_FUNCTION_ARGS) { text *in = PG_GETARG_TEXT_P(1); DictInfo *dict; - TSLexeme *res, - *ptr; + TSLexeme *res, + *ptr; Datum *da; ArrayType *a; @@ -193,11 +193,11 @@ lexize(PG_FUNCTION_ARGS) dict = finddict(PG_GETARG_OID(0)); ptr = res = (TSLexeme *) DatumGetPointer( - FunctionCall3(&(dict->lexize_info), - PointerGetDatum(dict->dictionary), - PointerGetDatum(VARDATA(in)), - Int32GetDatum(VARSIZE(in) - VARHDRSZ) - ) + FunctionCall3(&(dict->lexize_info), + PointerGetDatum(dict->dictionary), + PointerGetDatum(VARDATA(in)), + Int32GetDatum(VARSIZE(in) - VARHDRSZ) + ) ); PG_FREE_IF_COPY(in, 1); if (!res) diff --git a/contrib/tsearch2/dict.h b/contrib/tsearch2/dict.h index a21086a49d..0227bb4845 100644 --- a/contrib/tsearch2/dict.h +++ b/contrib/tsearch2/dict.h @@ -39,26 +39,22 @@ typedef struct void parse_cfgdict(text *in, Map ** m); /* return struct for any lexize function */ -typedef struct { - /* number of variant of split word , for example - Word 'fotballklubber' (norwegian) has two varian to split: - ( fotball, klubb ) and ( fot, ball, klubb ). So, dictionary - should return: - nvariant lexeme - 1 fotball - 1 klubb - 2 fot - 2 ball - 2 klubb - - */ - uint16 nvariant; +typedef struct +{ + /* + * number of variant of split word , for example Word 'fotballklubber' + * (norwegian) has two varian to split: ( fotball, klubb ) and ( fot, + * ball, klubb ). So, dictionary should return: nvariant lexeme 1 + * fotball 1 klubb 2 fot 2 ball 2 klubb + * + */ + uint16 nvariant; /* currently unused */ - uint16 flags; + uint16 flags; /* C-string */ - char *lexeme; -} TSLexeme; + char *lexeme; +} TSLexeme; #endif diff --git a/contrib/tsearch2/dict_ex.c b/contrib/tsearch2/dict_ex.c index cee2d1e976..8ec3950f9f 100644 --- a/contrib/tsearch2/dict_ex.c +++ b/contrib/tsearch2/dict_ex.c @@ -52,7 +52,7 @@ dex_lexize(PG_FUNCTION_ARGS) char *txt = pnstrdup(in, PG_GETARG_INT32(2)); TSLexeme *res = palloc(sizeof(TSLexeme) * 2); - memset(res,0,sizeof(TSLexeme) * 2); + memset(res, 0, sizeof(TSLexeme) * 2); if (*txt == '\0' || searchstoplist(&(d->stoplist), txt)) { diff --git a/contrib/tsearch2/dict_ispell.c b/contrib/tsearch2/dict_ispell.c index 12d9205a4e..28ce70a285 100644 --- a/contrib/tsearch2/dict_ispell.c +++ b/contrib/tsearch2/dict_ispell.c @@ -66,8 +66,8 @@ spell_init(PG_FUNCTION_ARGS) { freeDictISpell(d); ereport(ERROR, - (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), - errmsg("dictionary already loaded"))); + (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), + errmsg("dictionary already loaded"))); } if (NIImportDictionary(&(d->obj), pcfg->value)) { @@ -85,8 +85,8 @@ spell_init(PG_FUNCTION_ARGS) { freeDictISpell(d); ereport(ERROR, - (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), - errmsg("affixes already loaded"))); + (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), + errmsg("affixes already loaded"))); } if (NIImportAffixes(&(d->obj), pcfg->value)) { @@ -106,8 +106,8 @@ spell_init(PG_FUNCTION_ARGS) { freeDictISpell(d); ereport(ERROR, - (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), - errmsg("stop words already loaded"))); + (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), + errmsg("stop words already loaded"))); } readstoplist(tmp, &(d->stoplist)); sortstoplist(&(d->stoplist)); @@ -157,9 +157,9 @@ spell_lexize(PG_FUNCTION_ARGS) DictISpell *d = (DictISpell *) PG_GETARG_POINTER(0); char *in = (char *) PG_GETARG_POINTER(1); char *txt; - TSLexeme *res; - TSLexeme *ptr, - *cptr; + TSLexeme *res; + TSLexeme *ptr, + *cptr; if (!PG_GETARG_INT32(2)) PG_RETURN_POINTER(NULL); diff --git a/contrib/tsearch2/dict_snowball.c b/contrib/tsearch2/dict_snowball.c index 5a83fb45d3..0c08c293d3 100644 --- a/contrib/tsearch2/dict_snowball.c +++ b/contrib/tsearch2/dict_snowball.c @@ -102,7 +102,7 @@ snb_lexize(PG_FUNCTION_ARGS) DictSnowball *d = (DictSnowball *) PG_GETARG_POINTER(0); char *in = (char *) PG_GETARG_POINTER(1); char *txt = pnstrdup(in, PG_GETARG_INT32(2)); - TSLexeme *res = palloc(sizeof(TSLexeme) * 2); + TSLexeme *res = palloc(sizeof(TSLexeme) * 2); memset(res, 0, sizeof(TSLexeme) * 2); if (*txt == '\0' || searchstoplist(&(d->stoplist), txt)) diff --git a/contrib/tsearch2/dict_syn.c b/contrib/tsearch2/dict_syn.c index d3e884212b..f328152080 100644 --- a/contrib/tsearch2/dict_syn.c +++ b/contrib/tsearch2/dict_syn.c @@ -159,7 +159,7 @@ syn_lexize(PG_FUNCTION_ARGS) char *in = (char *) PG_GETARG_POINTER(1); Syn key, *found; - TSLexeme *res = NULL; + TSLexeme *res = NULL; if (!PG_GETARG_INT32(2)) PG_RETURN_POINTER(NULL); @@ -174,7 +174,7 @@ syn_lexize(PG_FUNCTION_ARGS) PG_RETURN_POINTER(NULL); res = palloc(sizeof(TSLexeme) * 2); - memset(res,0,sizeof(TSLexeme) * 2); + memset(res, 0, sizeof(TSLexeme) * 2); res[0].lexeme = pstrdup(found->out); PG_RETURN_POINTER(res); diff --git a/contrib/tsearch2/gistidx.c b/contrib/tsearch2/gistidx.c index 653a476536..c0d15de691 100644 --- a/contrib/tsearch2/gistidx.c +++ b/contrib/tsearch2/gistidx.c @@ -65,30 +65,32 @@ gtsvector_in(PG_FUNCTION_ARGS) PG_RETURN_DATUM(0); } -#define SINGOUTSTR "%d true bits, %d false bits" -#define ARROUTSTR "%d unique words" +#define SINGOUTSTR "%d true bits, %d false bits" +#define ARROUTSTR "%d unique words" #define EXTRALEN ( 2*13 ) -static int outbuf_maxlen = 0; +static int outbuf_maxlen = 0; Datum gtsvector_out(PG_FUNCTION_ARGS) { GISTTYPE *key = (GISTTYPE *) DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_POINTER(0))); - char *outbuf; + char *outbuf; - if ( outbuf_maxlen==0 ) - outbuf_maxlen = 2*EXTRALEN + Max( strlen(SINGOUTSTR), strlen(ARROUTSTR) ) + 1; - outbuf = palloc( outbuf_maxlen ); + if (outbuf_maxlen == 0) + outbuf_maxlen = 2 * EXTRALEN + Max(strlen(SINGOUTSTR), strlen(ARROUTSTR)) + 1; + outbuf = palloc(outbuf_maxlen); - if ( ISARRKEY(key) ) - sprintf( outbuf, ARROUTSTR, (int) ARRNELEM(key) ); - else { - int cnttrue = ( ISALLTRUE(key) ) ? SIGLENBIT : sizebitvec(GETSIGN(key)); - sprintf( outbuf, SINGOUTSTR, cnttrue, (int) SIGLENBIT - cnttrue ); - } + if (ISARRKEY(key)) + sprintf(outbuf, ARROUTSTR, (int) ARRNELEM(key)); + else + { + int cnttrue = (ISALLTRUE(key)) ? SIGLENBIT : sizebitvec(GETSIGN(key)); - PG_FREE_IF_COPY(key,0); + sprintf(outbuf, SINGOUTSTR, cnttrue, (int) SIGLENBIT - cnttrue); + } + + PG_FREE_IF_COPY(key, 0); PG_RETURN_POINTER(outbuf); } @@ -165,8 +167,8 @@ gtsvector_compress(PG_FUNCTION_ARGS) if (len != val->size) { /* - * there is a collision of hash-function; len is always less - * than val->size + * there is a collision of hash-function; len is always less than + * val->size */ len = CALCGTSIZE(ARRKEY, len); res = (GISTTYPE *) repalloc((void *) res, len); @@ -280,7 +282,7 @@ gtsvector_consistent(PG_FUNCTION_ARGS) { QUERYTYPE *query = (QUERYTYPE *) PG_GETARG_POINTER(1); GISTTYPE *key = (GISTTYPE *) DatumGetPointer( - ((GISTENTRY *) PG_GETARG_POINTER(0))->key + ((GISTENTRY *) PG_GETARG_POINTER(0))->key ); if (!query->size) diff --git a/contrib/tsearch2/gistidx.h b/contrib/tsearch2/gistidx.h index b4422a306a..7e243534fb 100644 --- a/contrib/tsearch2/gistidx.h +++ b/contrib/tsearch2/gistidx.h @@ -10,8 +10,8 @@ */ #define BITBYTE 8 -#define SIGLENINT 63 /* >121 => key will toast, so it will not - * work !!! */ +#define SIGLENINT 63 /* >121 => key will toast, so it will not work + * !!! */ #define SIGLEN ( sizeof(int4) * SIGLENINT ) #define SIGLENBIT (SIGLEN * BITBYTE) @@ -55,7 +55,7 @@ typedef struct #define ISSIGNKEY(x) ( ((GISTTYPE*)(x))->flag & SIGNKEY ) #define ISALLTRUE(x) ( ((GISTTYPE*)(x))->flag & ALLISTRUE ) -#define GTHDRSIZE ( sizeof(int4) * 2 ) +#define GTHDRSIZE ( sizeof(int4) * 2 ) #define CALCGTSIZE(flag, len) ( GTHDRSIZE + ( ( (flag) & ARRKEY ) ? ((len)*sizeof(int4)) : (((flag) & ALLISTRUE) ? 0 : SIGLEN) ) ) #define GETSIGN(x) ( (BITVECP)( (char*)(x)+GTHDRSIZE ) ) diff --git a/contrib/tsearch2/ispell/spell.c b/contrib/tsearch2/ispell/spell.c index 872e7f972b..9999983cc8 100644 --- a/contrib/tsearch2/ispell/spell.c +++ b/contrib/tsearch2/ispell/spell.c @@ -153,7 +153,7 @@ NIImportDictionary(IspellDict * Conf, const char *filename) return (1); while (fgets(str, sizeof(str), dict)) { - char *s; + char *s; const char *flag; flag = NULL; @@ -266,7 +266,7 @@ NIAddAffix(IspellDict * Conf, int flag, char flagflags, const char *mask, const { Conf->Affix[Conf->naffixes].issimple = 0; Conf->Affix[Conf->naffixes].isregis = 0; - Conf->Affix[Conf->naffixes].mask = (char*)malloc( strlen(mask) + 2 ); + Conf->Affix[Conf->naffixes].mask = (char *) malloc(strlen(mask) + 2); if (type == FF_SUFFIX) sprintf(Conf->Affix[Conf->naffixes].mask, "%s$", mask); else @@ -489,8 +489,8 @@ mkSPNode(IspellDict * Conf, int low, int high, int level) if (data->isword && data->affix != Conf->Spell[i].p.d.affix) { /* - * fprintf(stderr,"Word already exists: %s (affixes: - * '%s' and '%s')\n", Conf->Spell[i].word, + * fprintf(stderr,"Word already exists: %s (affixes: '%s' + * and '%s')\n", Conf->Spell[i].word, * Conf->AffixData[data->affix], * Conf->AffixData[Conf->Spell[i].p.d.affix] ); */ @@ -806,7 +806,8 @@ CheckAffix(const char *word, size_t len, AFFIX * Affix, char flagflags, char *ne pfree(mask); if (err) { - char regerrstr[ERRSTRSIZE]; + char regerrstr[ERRSTRSIZE]; + pg_regerror(err, &(Affix->reg.regex), regerrstr, ERRSTRSIZE); elog(ERROR, "Regex error in '%s': %s", Affix->mask, regerrstr); } @@ -1037,8 +1038,7 @@ SplitToVariants(IspellDict * Conf, SPNode * snode, SplitVar * orig, char *word, while (level > startpos && (lenaff = CheckCompoundAffixes(&caff, word + level, wordlen - level)) > 0) { /* - * there is one of compound suffixes, so check word for - * existings + * there is one of compound suffixes, so check word for existings */ char buf[MAXNORMLEN]; char **subres; @@ -1128,20 +1128,24 @@ TSLexeme * NINormalizeWord(IspellDict * Conf, char *word) { char **res = NormalizeSubWord(Conf, word, 0); - TSLexeme *lcur=NULL, *lres=NULL; - uint16 NVariant=1; + TSLexeme *lcur = NULL, + *lres = NULL; + uint16 NVariant = 1; - if (res) { - char **ptr = res; - lcur = lres = (TSLexeme*)palloc( MAX_NORM * sizeof(TSLexeme) ); - while(*ptr) { - lcur->lexeme=*ptr; - lcur->flags=0; + if (res) + { + char **ptr = res; + + lcur = lres = (TSLexeme *) palloc(MAX_NORM * sizeof(TSLexeme)); + while (*ptr) + { + lcur->lexeme = *ptr; + lcur->flags = 0; lcur->nvariant = NVariant++; lcur++; ptr++; } - lcur->lexeme=NULL; + lcur->lexeme = NULL; pfree(res); } @@ -1162,29 +1166,31 @@ NINormalizeWord(IspellDict * Conf, char *word) { char **subptr = subres; - if ( !lcur ) - lcur = lres = (TSLexeme*)palloc( MAX_NORM * sizeof(TSLexeme) ); - - while(*subptr) { - for(i=0;instem-1;i++) { - lcur->lexeme=(subptr==subres) ? var->stem[ i ] : pstrdup(var->stem[ i ]); - lcur->flags=0; + if (!lcur) + lcur = lres = (TSLexeme *) palloc(MAX_NORM * sizeof(TSLexeme)); + + while (*subptr) + { + for (i = 0; i < var->nstem - 1; i++) + { + lcur->lexeme = (subptr == subres) ? var->stem[i] : pstrdup(var->stem[i]); + lcur->flags = 0; lcur->nvariant = NVariant; lcur++; } - lcur->lexeme=*subptr; - lcur->flags=0; + lcur->lexeme = *subptr; + lcur->flags = 0; lcur->nvariant = NVariant; lcur++; subptr++; NVariant++; - } + } - lcur->lexeme=NULL; + lcur->lexeme = NULL; pfree(subres); var->stem[0] = NULL; - pfree( var->stem[ var->nstem-1 ] ); + pfree(var->stem[var->nstem - 1]); } } diff --git a/contrib/tsearch2/ispell/spell.h b/contrib/tsearch2/ispell/spell.h index a3695113a1..ee86eac985 100644 --- a/contrib/tsearch2/ispell/spell.h +++ b/contrib/tsearch2/ispell/spell.h @@ -7,7 +7,7 @@ #include "regis.h" #include "dict.h" - + struct SPNode; @@ -55,9 +55,9 @@ typedef struct aff_struct isregis:1, unused:1, replen:16; - char *mask; - char *find; - char *repl; + char *mask; + char *find; + char *repl; union { regex_t regex; @@ -117,7 +117,7 @@ typedef struct } IspellDict; -TSLexeme *NINormalizeWord(IspellDict * Conf, char *word); +TSLexeme *NINormalizeWord(IspellDict * Conf, char *word); int NIImportAffixes(IspellDict * Conf, const char *filename); int NIImportDictionary(IspellDict * Conf, const char *filename); diff --git a/contrib/tsearch2/prs_dcfg.c b/contrib/tsearch2/prs_dcfg.c index af83b6506d..240aaa4497 100644 --- a/contrib/tsearch2/prs_dcfg.c +++ b/contrib/tsearch2/prs_dcfg.c @@ -73,8 +73,8 @@ parse_cfgdict(text *in, Map ** m) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("syntax error"), - errdetail("Syntax error in position %d near \"%c\"", - (int) (ptr - VARDATA(in)), *ptr))); + errdetail("Syntax error in position %d near \"%c\"", + (int) (ptr - VARDATA(in)), *ptr))); } else if (state == CS_INKEY) { @@ -92,8 +92,8 @@ parse_cfgdict(text *in, Map ** m) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("syntax error"), - errdetail("Syntax error in position %d near \"%c\"", - (int) (ptr - VARDATA(in)), *ptr))); + errdetail("Syntax error in position %d near \"%c\"", + (int) (ptr - VARDATA(in)), *ptr))); } else if (state == CS_WAITEQ) { @@ -103,8 +103,8 @@ parse_cfgdict(text *in, Map ** m) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("syntax error"), - errdetail("Syntax error in position %d near \"%c\"", - (int) (ptr - VARDATA(in)), *ptr))); + errdetail("Syntax error in position %d near \"%c\"", + (int) (ptr - VARDATA(in)), *ptr))); } else if (state == CS_WAITVALUE) { @@ -149,8 +149,8 @@ parse_cfgdict(text *in, Map ** m) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("syntax error"), - errdetail("Syntax error in position %d near \"%c\"", - (int) (ptr - VARDATA(in)), *ptr))); + errdetail("Syntax error in position %d near \"%c\"", + (int) (ptr - VARDATA(in)), *ptr))); } else if (state == CS_INESC) state = CS_INVALUE; diff --git a/contrib/tsearch2/query.c b/contrib/tsearch2/query.c index 9681272925..d8b8d4c80d 100644 --- a/contrib/tsearch2/query.c +++ b/contrib/tsearch2/query.c @@ -265,7 +265,11 @@ pushval_morph(QPRS_STATE * state, int typeval, char *strval, int lenval, int2 we { int4 count = 0; PRSTEXT prs; - uint32 variant, pos, cntvar=0, cntpos=0, cnt=0; + uint32 variant, + pos, + cntvar = 0, + cntpos = 0, + cnt = 0; prs.lenwords = 32; prs.curwords = 0; @@ -274,39 +278,44 @@ pushval_morph(QPRS_STATE * state, int typeval, char *strval, int lenval, int2 we parsetext_v2(findcfg(state->cfg_id), &prs, strval, lenval); - if ( prs.curwords>0 ) { + if (prs.curwords > 0) + { - while (count < prs.curwords) { + while (count < prs.curwords) + { pos = prs.words[count].pos.pos; - cntvar=0; - while(count < prs.curwords && pos==prs.words[count].pos.pos) { + cntvar = 0; + while (count < prs.curwords && pos == prs.words[count].pos.pos) + { variant = prs.words[count].nvariant; - cnt=0; - while(count < prs.curwords && pos==prs.words[count].pos.pos && variant==prs.words[count].nvariant) { - + cnt = 0; + while (count < prs.curwords && pos == prs.words[count].pos.pos && variant == prs.words[count].nvariant) + { + pushval_asis(state, VAL, prs.words[count].word, prs.words[count].len, weight); pfree(prs.words[count].word); - if ( cnt ) + if (cnt) pushquery(state, OPR, (int4) '&', 0, 0, 0); cnt++; count++; } - if ( cntvar ) + if (cntvar) pushquery(state, OPR, (int4) '|', 0, 0, 0); cntvar++; } - if (cntpos) + if (cntpos) pushquery(state, OPR, (int4) '&', 0, 0, 0); - + cntpos++; } pfree(prs.words); - } else + } + else pushval_asis(state, VALSTOP, NULL, 0, 0); } diff --git a/contrib/tsearch2/rank.c b/contrib/tsearch2/rank.c index 046b062b97..081b084087 100644 --- a/contrib/tsearch2/rank.c +++ b/contrib/tsearch2/rank.c @@ -45,6 +45,7 @@ static float weights[] = {0.1, 0.2, 0.4, 1.0}; static float calc_rank_or(float *w, tsvector * t, QUERYTYPE * q); static float calc_rank_and(float *w, tsvector * t, QUERYTYPE * q); + /* * Returns a weight of a word collocation */ @@ -115,44 +116,52 @@ find_wordentry(tsvector * t, QUERYTYPE * q, ITEM * item) } -static char * SortAndUniqOperand=NULL; +static char *SortAndUniqOperand = NULL; static int -compareITEM( const void * a, const void * b ) { - if ( (*(ITEM**)a)->length == (*(ITEM**)b)->length ) - return strncmp( SortAndUniqOperand + (*(ITEM**)a)->distance, - SortAndUniqOperand + (*(ITEM**)b)->distance, - (*(ITEM**)b)->length ); +compareITEM(const void *a, const void *b) +{ + if ((*(ITEM **) a)->length == (*(ITEM **) b)->length) + return strncmp(SortAndUniqOperand + (*(ITEM **) a)->distance, + SortAndUniqOperand + (*(ITEM **) b)->distance, + (*(ITEM **) b)->length); - return ((*(ITEM**)a)->length > (*(ITEM**)b)->length) ? 1 : -1; + return ((*(ITEM **) a)->length > (*(ITEM **) b)->length) ? 1 : -1; } - -static ITEM** -SortAndUniqItems( char *operand, ITEM *item, int *size ) { - ITEM **res, **ptr, **prevptr; - ptr = res = (ITEM**) palloc( sizeof(ITEM*) * *size ); +static ITEM ** +SortAndUniqItems(char *operand, ITEM * item, int *size) +{ + ITEM **res, + **ptr, + **prevptr; - while( (*size)-- ) { - if ( item->type == VAL ) { + ptr = res = (ITEM **) palloc(sizeof(ITEM *) * *size); + + while ((*size)--) + { + if (item->type == VAL) + { *ptr = item; ptr++; - } + } item++; } - *size = ptr-res; - if ( *size < 2 ) + *size = ptr - res; + if (*size < 2) return res; - SortAndUniqOperand=operand; - qsort( res, *size, sizeof(ITEM**), compareITEM ); + SortAndUniqOperand = operand; + qsort(res, *size, sizeof(ITEM **), compareITEM); ptr = res + 1; prevptr = res; - while( ptr - res < *size ) { - if ( compareITEM( (void*) ptr, (void*) prevptr ) != 0 ) { + while (ptr - res < *size) + { + if (compareITEM((void *) ptr, (void *) prevptr) != 0) + { prevptr++; *prevptr = *ptr; } @@ -183,18 +192,19 @@ calc_rank_and(float *w, tsvector * t, QUERYTYPE * q) lenct, dist; float res = -1.0; - ITEM **item; - int size = q->size; + ITEM **item; + int size = q->size; - item = SortAndUniqItems( GETOPERAND(q), GETQUERY(q), &size); - if ( size < 2 ) { + item = SortAndUniqItems(GETOPERAND(q), GETQUERY(q), &size); + if (size < 2) + { pfree(item); return calc_rank_or(w, t, q); - } + } pos = (uint16 **) palloc(sizeof(uint16 *) * q->size); memset(pos, 0, sizeof(uint16 *) * q->size); *(uint16 *) POSNULL = lengthof(POSNULL) - 1; - WEP_SETPOS(POSNULL[1], MAXENTRYPOS-1); + WEP_SETPOS(POSNULL[1], MAXENTRYPOS - 1); for (i = 0; i < size; i++) { @@ -220,7 +230,7 @@ calc_rank_and(float *w, tsvector * t, QUERYTYPE * q) { for (p = 0; p < lenct; p++) { - dist = Abs((int)WEP_GETPOS(post[l]) - (int)WEP_GETPOS(ct[p])); + dist = Abs((int) WEP_GETPOS(post[l]) - (int) WEP_GETPOS(ct[p])); if (dist || (dist == 0 && (pos[i] == (uint16 *) POSNULL || pos[k] == (uint16 *) POSNULL))) { float curw; @@ -248,11 +258,11 @@ calc_rank_or(float *w, tsvector * t, QUERYTYPE * q) j, i; float res = -1.0; - ITEM **item; - int size = q->size; + ITEM **item; + int size = q->size; *(uint16 *) POSNULL = lengthof(POSNULL) - 1; - item = SortAndUniqItems( GETOPERAND(q), GETQUERY(q), &size); + item = SortAndUniqItems(GETOPERAND(q), GETQUERY(q), &size); for (i = 0; i < size; i++) { @@ -279,7 +289,7 @@ calc_rank_or(float *w, tsvector * t, QUERYTYPE * q) res = 1.0 - (1.0 - res) * (1.0 - wpos(post[j])); } } - pfree( item ); + pfree(item); return res; } @@ -288,7 +298,7 @@ calc_rank(float *w, tsvector * t, QUERYTYPE * q, int4 method) { ITEM *item = GETQUERY(q); float res = 0.0; - int len; + int len; if (!t->size || !q->size) return 0.0; @@ -304,11 +314,12 @@ calc_rank(float *w, tsvector * t, QUERYTYPE * q, int4 method) case 0: break; case 1: - res /= log( (float)(cnt_length(t)+1) ) / log(2.0); + res /= log((float) (cnt_length(t) + 1)) / log(2.0); break; case 2: len = cnt_length(t); - if ( len > 0 ) res /= (float)len; + if (len > 0) + res /= (float) len; break; default: /* internal error */ @@ -406,7 +417,7 @@ checkcondition_DR(void *checkval, ITEM * val) while (ptr - ((ChkDocR *) checkval)->doc < ((ChkDocR *) checkval)->len) { - if ( val == ptr->item || compareITEM( &val, &(ptr->item) ) == 0 ) + if (val == ptr->item || compareITEM(&val, &(ptr->item)) == 0) return true; ptr++; } @@ -496,12 +507,11 @@ Cover(DocRepresentation * doc, int len, QUERYTYPE * query, int *pos, int *p, int ch.doc = f; ch.len = (doc + lastpos) - f + 1; *pos = f - doc + 1; - SortAndUniqOperand = GETOPERAND(query); + SortAndUniqOperand = GETOPERAND(query); if (TS_execute(GETQUERY(query), &ch, false, checkcondition_DR)) { /* - * elog(NOTICE,"OP:%d NP:%d P:%d Q:%d", *pos, lastpos, *p, - * *q); + * elog(NOTICE,"OP:%d NP:%d P:%d Q:%d", *pos, lastpos, *p, *q); */ return true; } @@ -611,11 +621,12 @@ rank_cd(PG_FUNCTION_ARGS) case 0: break; case 1: - res /= log( (float)(cnt_length(txt)+1) ); + res /= log((float) (cnt_length(txt) + 1)); break; case 2: len = cnt_length(txt); - if ( len > 0 ) res /= (float)len; + if (len > 0) + res /= (float) len; break; default: /* internal error */ @@ -638,7 +649,7 @@ rank_cd_def(PG_FUNCTION_ARGS) Int32GetDatum(-1), PG_GETARG_DATUM(0), PG_GETARG_DATUM(1), - (PG_NARGS() == 3) ? PG_GETARG_DATUM(2) : Int32GetDatum(DEF_NORM_METHOD) + (PG_NARGS() == 3) ? PG_GETARG_DATUM(2) : Int32GetDatum(DEF_NORM_METHOD) )); } diff --git a/contrib/tsearch2/snowball/api.c b/contrib/tsearch2/snowball/api.c index 9dd5a3b8fa..78e4fe0eef 100644 --- a/contrib/tsearch2/snowball/api.c +++ b/contrib/tsearch2/snowball/api.c @@ -1,69 +1,85 @@ -#include /* for calloc, free */ +#include /* for calloc, free */ #include "header.h" -extern struct SN_env * SN_create_env(int S_size, int I_size, int B_size) +extern struct SN_env * +SN_create_env(int S_size, int I_size, int B_size) { - struct SN_env * z = (struct SN_env *) calloc(1, sizeof(struct SN_env)); - if (z == NULL) return NULL; - z->p = create_s(); - if (z->p == NULL) goto error; - if (S_size) - { - int i; - z->S = (symbol * *) calloc(S_size, sizeof(symbol *)); - if (z->S == NULL) goto error; + struct SN_env *z = (struct SN_env *) calloc(1, sizeof(struct SN_env)); - for (i = 0; i < S_size; i++) - { - z->S[i] = create_s(); - if (z->S[i] == NULL) goto error; - } - z->S_size = S_size; - } + if (z == NULL) + return NULL; + z->p = create_s(); + if (z->p == NULL) + goto error; + if (S_size) + { + int i; - if (I_size) - { - z->I = (int *) calloc(I_size, sizeof(int)); - if (z->I == NULL) goto error; - z->I_size = I_size; - } + z->S = (symbol * *) calloc(S_size, sizeof(symbol *)); + if (z->S == NULL) + goto error; - if (B_size) - { - z->B = (symbol *) calloc(B_size, sizeof(symbol)); - if (z->B == NULL) goto error; - z->B_size = B_size; - } + for (i = 0; i < S_size; i++) + { + z->S[i] = create_s(); + if (z->S[i] == NULL) + goto error; + } + z->S_size = S_size; + } - return z; + if (I_size) + { + z->I = (int *) calloc(I_size, sizeof(int)); + if (z->I == NULL) + goto error; + z->I_size = I_size; + } + + if (B_size) + { + z->B = (symbol *) calloc(B_size, sizeof(symbol)); + if (z->B == NULL) + goto error; + z->B_size = B_size; + } + + return z; error: - SN_close_env(z); - return NULL; + SN_close_env(z); + return NULL; } -extern void SN_close_env(struct SN_env * z) +extern void +SN_close_env(struct SN_env * z) { - if (z == NULL) return; - if (z->S_size) - { - int i; - for (i = 0; i < z->S_size; i++) - { - lose_s(z->S[i]); - } - free(z->S); - } - if (z->I_size) free(z->I); - if (z->B_size) free(z->B); - if (z->p) lose_s(z->p); - free(z); + if (z == NULL) + return; + if (z->S_size) + { + int i; + + for (i = 0; i < z->S_size; i++) + { + lose_s(z->S[i]); + } + free(z->S); + } + if (z->I_size) + free(z->I); + if (z->B_size) + free(z->B); + if (z->p) + lose_s(z->p); + free(z); } -extern int SN_set_current(struct SN_env * z, int size, const symbol * s) +extern int +SN_set_current(struct SN_env * z, int size, const symbol * s) { - int err = replace_s(z, 0, z->l, size, s, NULL); - z->c = 0; - return err; -} + int err = replace_s(z, 0, z->l, size, s, NULL); + z->c = 0; + return err; +} diff --git a/contrib/tsearch2/snowball/api.h b/contrib/tsearch2/snowball/api.h index adc2282e32..fb0a69469c 100644 --- a/contrib/tsearch2/snowball/api.h +++ b/contrib/tsearch2/snowball/api.h @@ -11,17 +11,24 @@ typedef unsigned char symbol; */ -struct SN_env { - symbol * p; - int c; int a; int l; int lb; int bra; int ket; - int S_size; int I_size; int B_size; - symbol * * S; - int * I; - symbol * B; +struct SN_env +{ + symbol *p; + int c; + int a; + int l; + int lb; + int bra; + int ket; + int S_size; + int I_size; + int B_size; + symbol **S; + int *I; + symbol *B; }; -extern struct SN_env * SN_create_env(int S_size, int I_size, int B_size); +extern struct SN_env *SN_create_env(int S_size, int I_size, int B_size); extern void SN_close_env(struct SN_env * z); -extern int SN_set_current(struct SN_env * z, int size, const symbol * s); - +extern int SN_set_current(struct SN_env * z, int size, const symbol * s); diff --git a/contrib/tsearch2/snowball/english_stem.c b/contrib/tsearch2/snowball/english_stem.c index 54eb25f86f..de4f99114f 100644 --- a/contrib/tsearch2/snowball/english_stem.c +++ b/contrib/tsearch2/snowball/english_stem.c @@ -3,1154 +3,1618 @@ #include "header.h" -extern int english_ISO_8859_1_stem(struct SN_env * z); -static int r_exception2(struct SN_env * z); -static int r_exception1(struct SN_env * z); -static int r_Step_5(struct SN_env * z); -static int r_Step_4(struct SN_env * z); -static int r_Step_3(struct SN_env * z); -static int r_Step_2(struct SN_env * z); -static int r_Step_1c(struct SN_env * z); -static int r_Step_1b(struct SN_env * z); -static int r_Step_1a(struct SN_env * z); -static int r_R2(struct SN_env * z); -static int r_R1(struct SN_env * z); -static int r_shortv(struct SN_env * z); -static int r_mark_regions(struct SN_env * z); -static int r_postlude(struct SN_env * z); -static int r_prelude(struct SN_env * z); +extern int english_ISO_8859_1_stem(struct SN_env * z); +static int r_exception2(struct SN_env * z); +static int r_exception1(struct SN_env * z); +static int r_Step_5(struct SN_env * z); +static int r_Step_4(struct SN_env * z); +static int r_Step_3(struct SN_env * z); +static int r_Step_2(struct SN_env * z); +static int r_Step_1c(struct SN_env * z); +static int r_Step_1b(struct SN_env * z); +static int r_Step_1a(struct SN_env * z); +static int r_R2(struct SN_env * z); +static int r_R1(struct SN_env * z); +static int r_shortv(struct SN_env * z); +static int r_mark_regions(struct SN_env * z); +static int r_postlude(struct SN_env * z); +static int r_prelude(struct SN_env * z); -extern struct SN_env * english_ISO_8859_1_create_env(void); +extern struct SN_env *english_ISO_8859_1_create_env(void); extern void english_ISO_8859_1_close_env(struct SN_env * z); -static symbol s_0_0[6] = { 'c', 'o', 'm', 'm', 'u', 'n' }; -static symbol s_0_1[5] = { 'g', 'e', 'n', 'e', 'r' }; +static symbol s_0_0[6] = {'c', 'o', 'm', 'm', 'u', 'n'}; +static symbol s_0_1[5] = {'g', 'e', 'n', 'e', 'r'}; static struct among a_0[2] = { -/* 0 */ { 6, s_0_0, -1, -1, 0}, -/* 1 */ { 5, s_0_1, -1, -1, 0} + /* 0 */ {6, s_0_0, -1, -1, 0}, + /* 1 */ {5, s_0_1, -1, -1, 0} }; -static symbol s_1_0[1] = { '\'' }; -static symbol s_1_1[3] = { '\'', 's', '\'' }; -static symbol s_1_2[2] = { '\'', 's' }; +static symbol s_1_0[1] = {'\''}; +static symbol s_1_1[3] = {'\'', 's', '\''}; +static symbol s_1_2[2] = {'\'', 's'}; static struct among a_1[3] = { -/* 0 */ { 1, s_1_0, -1, 1, 0}, -/* 1 */ { 3, s_1_1, 0, 1, 0}, -/* 2 */ { 2, s_1_2, -1, 1, 0} + /* 0 */ {1, s_1_0, -1, 1, 0}, + /* 1 */ {3, s_1_1, 0, 1, 0}, + /* 2 */ {2, s_1_2, -1, 1, 0} }; -static symbol s_2_0[3] = { 'i', 'e', 'd' }; -static symbol s_2_1[1] = { 's' }; -static symbol s_2_2[3] = { 'i', 'e', 's' }; -static symbol s_2_3[4] = { 's', 's', 'e', 's' }; -static symbol s_2_4[2] = { 's', 's' }; -static symbol s_2_5[2] = { 'u', 's' }; +static symbol s_2_0[3] = {'i', 'e', 'd'}; +static symbol s_2_1[1] = {'s'}; +static symbol s_2_2[3] = {'i', 'e', 's'}; +static symbol s_2_3[4] = {'s', 's', 'e', 's'}; +static symbol s_2_4[2] = {'s', 's'}; +static symbol s_2_5[2] = {'u', 's'}; static struct among a_2[6] = { -/* 0 */ { 3, s_2_0, -1, 2, 0}, -/* 1 */ { 1, s_2_1, -1, 3, 0}, -/* 2 */ { 3, s_2_2, 1, 2, 0}, -/* 3 */ { 4, s_2_3, 1, 1, 0}, -/* 4 */ { 2, s_2_4, 1, -1, 0}, -/* 5 */ { 2, s_2_5, 1, -1, 0} + /* 0 */ {3, s_2_0, -1, 2, 0}, + /* 1 */ {1, s_2_1, -1, 3, 0}, + /* 2 */ {3, s_2_2, 1, 2, 0}, + /* 3 */ {4, s_2_3, 1, 1, 0}, + /* 4 */ {2, s_2_4, 1, -1, 0}, + /* 5 */ {2, s_2_5, 1, -1, 0} }; -static symbol s_3_1[2] = { 'b', 'b' }; -static symbol s_3_2[2] = { 'd', 'd' }; -static symbol s_3_3[2] = { 'f', 'f' }; -static symbol s_3_4[2] = { 'g', 'g' }; -static symbol s_3_5[2] = { 'b', 'l' }; -static symbol s_3_6[2] = { 'm', 'm' }; -static symbol s_3_7[2] = { 'n', 'n' }; -static symbol s_3_8[2] = { 'p', 'p' }; -static symbol s_3_9[2] = { 'r', 'r' }; -static symbol s_3_10[2] = { 'a', 't' }; -static symbol s_3_11[2] = { 't', 't' }; -static symbol s_3_12[2] = { 'i', 'z' }; +static symbol s_3_1[2] = {'b', 'b'}; +static symbol s_3_2[2] = {'d', 'd'}; +static symbol s_3_3[2] = {'f', 'f'}; +static symbol s_3_4[2] = {'g', 'g'}; +static symbol s_3_5[2] = {'b', 'l'}; +static symbol s_3_6[2] = {'m', 'm'}; +static symbol s_3_7[2] = {'n', 'n'}; +static symbol s_3_8[2] = {'p', 'p'}; +static symbol s_3_9[2] = {'r', 'r'}; +static symbol s_3_10[2] = {'a', 't'}; +static symbol s_3_11[2] = {'t', 't'}; +static symbol s_3_12[2] = {'i', 'z'}; static struct among a_3[13] = { -/* 0 */ { 0, 0, -1, 3, 0}, -/* 1 */ { 2, s_3_1, 0, 2, 0}, -/* 2 */ { 2, s_3_2, 0, 2, 0}, -/* 3 */ { 2, s_3_3, 0, 2, 0}, -/* 4 */ { 2, s_3_4, 0, 2, 0}, -/* 5 */ { 2, s_3_5, 0, 1, 0}, -/* 6 */ { 2, s_3_6, 0, 2, 0}, -/* 7 */ { 2, s_3_7, 0, 2, 0}, -/* 8 */ { 2, s_3_8, 0, 2, 0}, -/* 9 */ { 2, s_3_9, 0, 2, 0}, -/* 10 */ { 2, s_3_10, 0, 1, 0}, -/* 11 */ { 2, s_3_11, 0, 2, 0}, -/* 12 */ { 2, s_3_12, 0, 1, 0} + /* 0 */ {0, 0, -1, 3, 0}, + /* 1 */ {2, s_3_1, 0, 2, 0}, + /* 2 */ {2, s_3_2, 0, 2, 0}, + /* 3 */ {2, s_3_3, 0, 2, 0}, + /* 4 */ {2, s_3_4, 0, 2, 0}, + /* 5 */ {2, s_3_5, 0, 1, 0}, + /* 6 */ {2, s_3_6, 0, 2, 0}, + /* 7 */ {2, s_3_7, 0, 2, 0}, + /* 8 */ {2, s_3_8, 0, 2, 0}, + /* 9 */ {2, s_3_9, 0, 2, 0}, + /* 10 */ {2, s_3_10, 0, 1, 0}, + /* 11 */ {2, s_3_11, 0, 2, 0}, + /* 12 */ {2, s_3_12, 0, 1, 0} }; -static symbol s_4_0[2] = { 'e', 'd' }; -static symbol s_4_1[3] = { 'e', 'e', 'd' }; -static symbol s_4_2[3] = { 'i', 'n', 'g' }; -static symbol s_4_3[4] = { 'e', 'd', 'l', 'y' }; -static symbol s_4_4[5] = { 'e', 'e', 'd', 'l', 'y' }; -static symbol s_4_5[5] = { 'i', 'n', 'g', 'l', 'y' }; +static symbol s_4_0[2] = {'e', 'd'}; +static symbol s_4_1[3] = {'e', 'e', 'd'}; +static symbol s_4_2[3] = {'i', 'n', 'g'}; +static symbol s_4_3[4] = {'e', 'd', 'l', 'y'}; +static symbol s_4_4[5] = {'e', 'e', 'd', 'l', 'y'}; +static symbol s_4_5[5] = {'i', 'n', 'g', 'l', 'y'}; static struct among a_4[6] = { -/* 0 */ { 2, s_4_0, -1, 2, 0}, -/* 1 */ { 3, s_4_1, 0, 1, 0}, -/* 2 */ { 3, s_4_2, -1, 2, 0}, -/* 3 */ { 4, s_4_3, -1, 2, 0}, -/* 4 */ { 5, s_4_4, 3, 1, 0}, -/* 5 */ { 5, s_4_5, -1, 2, 0} + /* 0 */ {2, s_4_0, -1, 2, 0}, + /* 1 */ {3, s_4_1, 0, 1, 0}, + /* 2 */ {3, s_4_2, -1, 2, 0}, + /* 3 */ {4, s_4_3, -1, 2, 0}, + /* 4 */ {5, s_4_4, 3, 1, 0}, + /* 5 */ {5, s_4_5, -1, 2, 0} }; -static symbol s_5_0[4] = { 'a', 'n', 'c', 'i' }; -static symbol s_5_1[4] = { 'e', 'n', 'c', 'i' }; -static symbol s_5_2[3] = { 'o', 'g', 'i' }; -static symbol s_5_3[2] = { 'l', 'i' }; -static symbol s_5_4[3] = { 'b', 'l', 'i' }; -static symbol s_5_5[4] = { 'a', 'b', 'l', 'i' }; -static symbol s_5_6[4] = { 'a', 'l', 'l', 'i' }; -static symbol s_5_7[5] = { 'f', 'u', 'l', 'l', 'i' }; -static symbol s_5_8[6] = { 'l', 'e', 's', 's', 'l', 'i' }; -static symbol s_5_9[5] = { 'o', 'u', 's', 'l', 'i' }; -static symbol s_5_10[5] = { 'e', 'n', 't', 'l', 'i' }; -static symbol s_5_11[5] = { 'a', 'l', 'i', 't', 'i' }; -static symbol s_5_12[6] = { 'b', 'i', 'l', 'i', 't', 'i' }; -static symbol s_5_13[5] = { 'i', 'v', 'i', 't', 'i' }; -static symbol s_5_14[6] = { 't', 'i', 'o', 'n', 'a', 'l' }; -static symbol s_5_15[7] = { 'a', 't', 'i', 'o', 'n', 'a', 'l' }; -static symbol s_5_16[5] = { 'a', 'l', 'i', 's', 'm' }; -static symbol s_5_17[5] = { 'a', 't', 'i', 'o', 'n' }; -static symbol s_5_18[7] = { 'i', 'z', 'a', 't', 'i', 'o', 'n' }; -static symbol s_5_19[4] = { 'i', 'z', 'e', 'r' }; -static symbol s_5_20[4] = { 'a', 't', 'o', 'r' }; -static symbol s_5_21[7] = { 'i', 'v', 'e', 'n', 'e', 's', 's' }; -static symbol s_5_22[7] = { 'f', 'u', 'l', 'n', 'e', 's', 's' }; -static symbol s_5_23[7] = { 'o', 'u', 's', 'n', 'e', 's', 's' }; +static symbol s_5_0[4] = {'a', 'n', 'c', 'i'}; +static symbol s_5_1[4] = {'e', 'n', 'c', 'i'}; +static symbol s_5_2[3] = {'o', 'g', 'i'}; +static symbol s_5_3[2] = {'l', 'i'}; +static symbol s_5_4[3] = {'b', 'l', 'i'}; +static symbol s_5_5[4] = {'a', 'b', 'l', 'i'}; +static symbol s_5_6[4] = {'a', 'l', 'l', 'i'}; +static symbol s_5_7[5] = {'f', 'u', 'l', 'l', 'i'}; +static symbol s_5_8[6] = {'l', 'e', 's', 's', 'l', 'i'}; +static symbol s_5_9[5] = {'o', 'u', 's', 'l', 'i'}; +static symbol s_5_10[5] = {'e', 'n', 't', 'l', 'i'}; +static symbol s_5_11[5] = {'a', 'l', 'i', 't', 'i'}; +static symbol s_5_12[6] = {'b', 'i', 'l', 'i', 't', 'i'}; +static symbol s_5_13[5] = {'i', 'v', 'i', 't', 'i'}; +static symbol s_5_14[6] = {'t', 'i', 'o', 'n', 'a', 'l'}; +static symbol s_5_15[7] = {'a', 't', 'i', 'o', 'n', 'a', 'l'}; +static symbol s_5_16[5] = {'a', 'l', 'i', 's', 'm'}; +static symbol s_5_17[5] = {'a', 't', 'i', 'o', 'n'}; +static symbol s_5_18[7] = {'i', 'z', 'a', 't', 'i', 'o', 'n'}; +static symbol s_5_19[4] = {'i', 'z', 'e', 'r'}; +static symbol s_5_20[4] = {'a', 't', 'o', 'r'}; +static symbol s_5_21[7] = {'i', 'v', 'e', 'n', 'e', 's', 's'}; +static symbol s_5_22[7] = {'f', 'u', 'l', 'n', 'e', 's', 's'}; +static symbol s_5_23[7] = {'o', 'u', 's', 'n', 'e', 's', 's'}; static struct among a_5[24] = { -/* 0 */ { 4, s_5_0, -1, 3, 0}, -/* 1 */ { 4, s_5_1, -1, 2, 0}, -/* 2 */ { 3, s_5_2, -1, 13, 0}, -/* 3 */ { 2, s_5_3, -1, 16, 0}, -/* 4 */ { 3, s_5_4, 3, 12, 0}, -/* 5 */ { 4, s_5_5, 4, 4, 0}, -/* 6 */ { 4, s_5_6, 3, 8, 0}, -/* 7 */ { 5, s_5_7, 3, 14, 0}, -/* 8 */ { 6, s_5_8, 3, 15, 0}, -/* 9 */ { 5, s_5_9, 3, 10, 0}, -/* 10 */ { 5, s_5_10, 3, 5, 0}, -/* 11 */ { 5, s_5_11, -1, 8, 0}, -/* 12 */ { 6, s_5_12, -1, 12, 0}, -/* 13 */ { 5, s_5_13, -1, 11, 0}, -/* 14 */ { 6, s_5_14, -1, 1, 0}, -/* 15 */ { 7, s_5_15, 14, 7, 0}, -/* 16 */ { 5, s_5_16, -1, 8, 0}, -/* 17 */ { 5, s_5_17, -1, 7, 0}, -/* 18 */ { 7, s_5_18, 17, 6, 0}, -/* 19 */ { 4, s_5_19, -1, 6, 0}, -/* 20 */ { 4, s_5_20, -1, 7, 0}, -/* 21 */ { 7, s_5_21, -1, 11, 0}, -/* 22 */ { 7, s_5_22, -1, 9, 0}, -/* 23 */ { 7, s_5_23, -1, 10, 0} + /* 0 */ {4, s_5_0, -1, 3, 0}, + /* 1 */ {4, s_5_1, -1, 2, 0}, + /* 2 */ {3, s_5_2, -1, 13, 0}, + /* 3 */ {2, s_5_3, -1, 16, 0}, + /* 4 */ {3, s_5_4, 3, 12, 0}, + /* 5 */ {4, s_5_5, 4, 4, 0}, + /* 6 */ {4, s_5_6, 3, 8, 0}, + /* 7 */ {5, s_5_7, 3, 14, 0}, + /* 8 */ {6, s_5_8, 3, 15, 0}, + /* 9 */ {5, s_5_9, 3, 10, 0}, + /* 10 */ {5, s_5_10, 3, 5, 0}, + /* 11 */ {5, s_5_11, -1, 8, 0}, + /* 12 */ {6, s_5_12, -1, 12, 0}, + /* 13 */ {5, s_5_13, -1, 11, 0}, + /* 14 */ {6, s_5_14, -1, 1, 0}, + /* 15 */ {7, s_5_15, 14, 7, 0}, + /* 16 */ {5, s_5_16, -1, 8, 0}, + /* 17 */ {5, s_5_17, -1, 7, 0}, + /* 18 */ {7, s_5_18, 17, 6, 0}, + /* 19 */ {4, s_5_19, -1, 6, 0}, + /* 20 */ {4, s_5_20, -1, 7, 0}, + /* 21 */ {7, s_5_21, -1, 11, 0}, + /* 22 */ {7, s_5_22, -1, 9, 0}, + /* 23 */ {7, s_5_23, -1, 10, 0} }; -static symbol s_6_0[5] = { 'i', 'c', 'a', 't', 'e' }; -static symbol s_6_1[5] = { 'a', 't', 'i', 'v', 'e' }; -static symbol s_6_2[5] = { 'a', 'l', 'i', 'z', 'e' }; -static symbol s_6_3[5] = { 'i', 'c', 'i', 't', 'i' }; -static symbol s_6_4[4] = { 'i', 'c', 'a', 'l' }; -static symbol s_6_5[6] = { 't', 'i', 'o', 'n', 'a', 'l' }; -static symbol s_6_6[7] = { 'a', 't', 'i', 'o', 'n', 'a', 'l' }; -static symbol s_6_7[3] = { 'f', 'u', 'l' }; -static symbol s_6_8[4] = { 'n', 'e', 's', 's' }; +static symbol s_6_0[5] = {'i', 'c', 'a', 't', 'e'}; +static symbol s_6_1[5] = {'a', 't', 'i', 'v', 'e'}; +static symbol s_6_2[5] = {'a', 'l', 'i', 'z', 'e'}; +static symbol s_6_3[5] = {'i', 'c', 'i', 't', 'i'}; +static symbol s_6_4[4] = {'i', 'c', 'a', 'l'}; +static symbol s_6_5[6] = {'t', 'i', 'o', 'n', 'a', 'l'}; +static symbol s_6_6[7] = {'a', 't', 'i', 'o', 'n', 'a', 'l'}; +static symbol s_6_7[3] = {'f', 'u', 'l'}; +static symbol s_6_8[4] = {'n', 'e', 's', 's'}; static struct among a_6[9] = { -/* 0 */ { 5, s_6_0, -1, 4, 0}, -/* 1 */ { 5, s_6_1, -1, 6, 0}, -/* 2 */ { 5, s_6_2, -1, 3, 0}, -/* 3 */ { 5, s_6_3, -1, 4, 0}, -/* 4 */ { 4, s_6_4, -1, 4, 0}, -/* 5 */ { 6, s_6_5, -1, 1, 0}, -/* 6 */ { 7, s_6_6, 5, 2, 0}, -/* 7 */ { 3, s_6_7, -1, 5, 0}, -/* 8 */ { 4, s_6_8, -1, 5, 0} + /* 0 */ {5, s_6_0, -1, 4, 0}, + /* 1 */ {5, s_6_1, -1, 6, 0}, + /* 2 */ {5, s_6_2, -1, 3, 0}, + /* 3 */ {5, s_6_3, -1, 4, 0}, + /* 4 */ {4, s_6_4, -1, 4, 0}, + /* 5 */ {6, s_6_5, -1, 1, 0}, + /* 6 */ {7, s_6_6, 5, 2, 0}, + /* 7 */ {3, s_6_7, -1, 5, 0}, + /* 8 */ {4, s_6_8, -1, 5, 0} }; -static symbol s_7_0[2] = { 'i', 'c' }; -static symbol s_7_1[4] = { 'a', 'n', 'c', 'e' }; -static symbol s_7_2[4] = { 'e', 'n', 'c', 'e' }; -static symbol s_7_3[4] = { 'a', 'b', 'l', 'e' }; -static symbol s_7_4[4] = { 'i', 'b', 'l', 'e' }; -static symbol s_7_5[3] = { 'a', 't', 'e' }; -static symbol s_7_6[3] = { 'i', 'v', 'e' }; -static symbol s_7_7[3] = { 'i', 'z', 'e' }; -static symbol s_7_8[3] = { 'i', 't', 'i' }; -static symbol s_7_9[2] = { 'a', 'l' }; -static symbol s_7_10[3] = { 'i', 's', 'm' }; -static symbol s_7_11[3] = { 'i', 'o', 'n' }; -static symbol s_7_12[2] = { 'e', 'r' }; -static symbol s_7_13[3] = { 'o', 'u', 's' }; -static symbol s_7_14[3] = { 'a', 'n', 't' }; -static symbol s_7_15[3] = { 'e', 'n', 't' }; -static symbol s_7_16[4] = { 'm', 'e', 'n', 't' }; -static symbol s_7_17[5] = { 'e', 'm', 'e', 'n', 't' }; +static symbol s_7_0[2] = {'i', 'c'}; +static symbol s_7_1[4] = {'a', 'n', 'c', 'e'}; +static symbol s_7_2[4] = {'e', 'n', 'c', 'e'}; +static symbol s_7_3[4] = {'a', 'b', 'l', 'e'}; +static symbol s_7_4[4] = {'i', 'b', 'l', 'e'}; +static symbol s_7_5[3] = {'a', 't', 'e'}; +static symbol s_7_6[3] = {'i', 'v', 'e'}; +static symbol s_7_7[3] = {'i', 'z', 'e'}; +static symbol s_7_8[3] = {'i', 't', 'i'}; +static symbol s_7_9[2] = {'a', 'l'}; +static symbol s_7_10[3] = {'i', 's', 'm'}; +static symbol s_7_11[3] = {'i', 'o', 'n'}; +static symbol s_7_12[2] = {'e', 'r'}; +static symbol s_7_13[3] = {'o', 'u', 's'}; +static symbol s_7_14[3] = {'a', 'n', 't'}; +static symbol s_7_15[3] = {'e', 'n', 't'}; +static symbol s_7_16[4] = {'m', 'e', 'n', 't'}; +static symbol s_7_17[5] = {'e', 'm', 'e', 'n', 't'}; static struct among a_7[18] = { -/* 0 */ { 2, s_7_0, -1, 1, 0}, -/* 1 */ { 4, s_7_1, -1, 1, 0}, -/* 2 */ { 4, s_7_2, -1, 1, 0}, -/* 3 */ { 4, s_7_3, -1, 1, 0}, -/* 4 */ { 4, s_7_4, -1, 1, 0}, -/* 5 */ { 3, s_7_5, -1, 1, 0}, -/* 6 */ { 3, s_7_6, -1, 1, 0}, -/* 7 */ { 3, s_7_7, -1, 1, 0}, -/* 8 */ { 3, s_7_8, -1, 1, 0}, -/* 9 */ { 2, s_7_9, -1, 1, 0}, -/* 10 */ { 3, s_7_10, -1, 1, 0}, -/* 11 */ { 3, s_7_11, -1, 2, 0}, -/* 12 */ { 2, s_7_12, -1, 1, 0}, -/* 13 */ { 3, s_7_13, -1, 1, 0}, -/* 14 */ { 3, s_7_14, -1, 1, 0}, -/* 15 */ { 3, s_7_15, -1, 1, 0}, -/* 16 */ { 4, s_7_16, 15, 1, 0}, -/* 17 */ { 5, s_7_17, 16, 1, 0} + /* 0 */ {2, s_7_0, -1, 1, 0}, + /* 1 */ {4, s_7_1, -1, 1, 0}, + /* 2 */ {4, s_7_2, -1, 1, 0}, + /* 3 */ {4, s_7_3, -1, 1, 0}, + /* 4 */ {4, s_7_4, -1, 1, 0}, + /* 5 */ {3, s_7_5, -1, 1, 0}, + /* 6 */ {3, s_7_6, -1, 1, 0}, + /* 7 */ {3, s_7_7, -1, 1, 0}, + /* 8 */ {3, s_7_8, -1, 1, 0}, + /* 9 */ {2, s_7_9, -1, 1, 0}, + /* 10 */ {3, s_7_10, -1, 1, 0}, + /* 11 */ {3, s_7_11, -1, 2, 0}, + /* 12 */ {2, s_7_12, -1, 1, 0}, + /* 13 */ {3, s_7_13, -1, 1, 0}, + /* 14 */ {3, s_7_14, -1, 1, 0}, + /* 15 */ {3, s_7_15, -1, 1, 0}, + /* 16 */ {4, s_7_16, 15, 1, 0}, + /* 17 */ {5, s_7_17, 16, 1, 0} }; -static symbol s_8_0[1] = { 'e' }; -static symbol s_8_1[1] = { 'l' }; +static symbol s_8_0[1] = {'e'}; +static symbol s_8_1[1] = {'l'}; static struct among a_8[2] = { -/* 0 */ { 1, s_8_0, -1, 1, 0}, -/* 1 */ { 1, s_8_1, -1, 2, 0} + /* 0 */ {1, s_8_0, -1, 1, 0}, + /* 1 */ {1, s_8_1, -1, 2, 0} }; -static symbol s_9_0[7] = { 's', 'u', 'c', 'c', 'e', 'e', 'd' }; -static symbol s_9_1[7] = { 'p', 'r', 'o', 'c', 'e', 'e', 'd' }; -static symbol s_9_2[6] = { 'e', 'x', 'c', 'e', 'e', 'd' }; -static symbol s_9_3[7] = { 'c', 'a', 'n', 'n', 'i', 'n', 'g' }; -static symbol s_9_4[6] = { 'i', 'n', 'n', 'i', 'n', 'g' }; -static symbol s_9_5[7] = { 'e', 'a', 'r', 'r', 'i', 'n', 'g' }; -static symbol s_9_6[7] = { 'h', 'e', 'r', 'r', 'i', 'n', 'g' }; -static symbol s_9_7[6] = { 'o', 'u', 't', 'i', 'n', 'g' }; +static symbol s_9_0[7] = {'s', 'u', 'c', 'c', 'e', 'e', 'd'}; +static symbol s_9_1[7] = {'p', 'r', 'o', 'c', 'e', 'e', 'd'}; +static symbol s_9_2[6] = {'e', 'x', 'c', 'e', 'e', 'd'}; +static symbol s_9_3[7] = {'c', 'a', 'n', 'n', 'i', 'n', 'g'}; +static symbol s_9_4[6] = {'i', 'n', 'n', 'i', 'n', 'g'}; +static symbol s_9_5[7] = {'e', 'a', 'r', 'r', 'i', 'n', 'g'}; +static symbol s_9_6[7] = {'h', 'e', 'r', 'r', 'i', 'n', 'g'}; +static symbol s_9_7[6] = {'o', 'u', 't', 'i', 'n', 'g'}; static struct among a_9[8] = { -/* 0 */ { 7, s_9_0, -1, -1, 0}, -/* 1 */ { 7, s_9_1, -1, -1, 0}, -/* 2 */ { 6, s_9_2, -1, -1, 0}, -/* 3 */ { 7, s_9_3, -1, -1, 0}, -/* 4 */ { 6, s_9_4, -1, -1, 0}, -/* 5 */ { 7, s_9_5, -1, -1, 0}, -/* 6 */ { 7, s_9_6, -1, -1, 0}, -/* 7 */ { 6, s_9_7, -1, -1, 0} + /* 0 */ {7, s_9_0, -1, -1, 0}, + /* 1 */ {7, s_9_1, -1, -1, 0}, + /* 2 */ {6, s_9_2, -1, -1, 0}, + /* 3 */ {7, s_9_3, -1, -1, 0}, + /* 4 */ {6, s_9_4, -1, -1, 0}, + /* 5 */ {7, s_9_5, -1, -1, 0}, + /* 6 */ {7, s_9_6, -1, -1, 0}, + /* 7 */ {6, s_9_7, -1, -1, 0} }; -static symbol s_10_0[5] = { 'a', 'n', 'd', 'e', 's' }; -static symbol s_10_1[5] = { 'a', 't', 'l', 'a', 's' }; -static symbol s_10_2[4] = { 'b', 'i', 'a', 's' }; -static symbol s_10_3[6] = { 'c', 'o', 's', 'm', 'o', 's' }; -static symbol s_10_4[5] = { 'd', 'y', 'i', 'n', 'g' }; -static symbol s_10_5[5] = { 'e', 'a', 'r', 'l', 'y' }; -static symbol s_10_6[6] = { 'g', 'e', 'n', 't', 'l', 'y' }; -static symbol s_10_7[4] = { 'h', 'o', 'w', 'e' }; -static symbol s_10_8[4] = { 'i', 'd', 'l', 'y' }; -static symbol s_10_9[5] = { 'l', 'y', 'i', 'n', 'g' }; -static symbol s_10_10[4] = { 'n', 'e', 'w', 's' }; -static symbol s_10_11[4] = { 'o', 'n', 'l', 'y' }; -static symbol s_10_12[6] = { 's', 'i', 'n', 'g', 'l', 'y' }; -static symbol s_10_13[5] = { 's', 'k', 'i', 'e', 's' }; -static symbol s_10_14[4] = { 's', 'k', 'i', 's' }; -static symbol s_10_15[3] = { 's', 'k', 'y' }; -static symbol s_10_16[5] = { 't', 'y', 'i', 'n', 'g' }; -static symbol s_10_17[4] = { 'u', 'g', 'l', 'y' }; +static symbol s_10_0[5] = {'a', 'n', 'd', 'e', 's'}; +static symbol s_10_1[5] = {'a', 't', 'l', 'a', 's'}; +static symbol s_10_2[4] = {'b', 'i', 'a', 's'}; +static symbol s_10_3[6] = {'c', 'o', 's', 'm', 'o', 's'}; +static symbol s_10_4[5] = {'d', 'y', 'i', 'n', 'g'}; +static symbol s_10_5[5] = {'e', 'a', 'r', 'l', 'y'}; +static symbol s_10_6[6] = {'g', 'e', 'n', 't', 'l', 'y'}; +static symbol s_10_7[4] = {'h', 'o', 'w', 'e'}; +static symbol s_10_8[4] = {'i', 'd', 'l', 'y'}; +static symbol s_10_9[5] = {'l', 'y', 'i', 'n', 'g'}; +static symbol s_10_10[4] = {'n', 'e', 'w', 's'}; +static symbol s_10_11[4] = {'o', 'n', 'l', 'y'}; +static symbol s_10_12[6] = {'s', 'i', 'n', 'g', 'l', 'y'}; +static symbol s_10_13[5] = {'s', 'k', 'i', 'e', 's'}; +static symbol s_10_14[4] = {'s', 'k', 'i', 's'}; +static symbol s_10_15[3] = {'s', 'k', 'y'}; +static symbol s_10_16[5] = {'t', 'y', 'i', 'n', 'g'}; +static symbol s_10_17[4] = {'u', 'g', 'l', 'y'}; static struct among a_10[18] = { -/* 0 */ { 5, s_10_0, -1, -1, 0}, -/* 1 */ { 5, s_10_1, -1, -1, 0}, -/* 2 */ { 4, s_10_2, -1, -1, 0}, -/* 3 */ { 6, s_10_3, -1, -1, 0}, -/* 4 */ { 5, s_10_4, -1, 3, 0}, -/* 5 */ { 5, s_10_5, -1, 9, 0}, -/* 6 */ { 6, s_10_6, -1, 7, 0}, -/* 7 */ { 4, s_10_7, -1, -1, 0}, -/* 8 */ { 4, s_10_8, -1, 6, 0}, -/* 9 */ { 5, s_10_9, -1, 4, 0}, -/* 10 */ { 4, s_10_10, -1, -1, 0}, -/* 11 */ { 4, s_10_11, -1, 10, 0}, -/* 12 */ { 6, s_10_12, -1, 11, 0}, -/* 13 */ { 5, s_10_13, -1, 2, 0}, -/* 14 */ { 4, s_10_14, -1, 1, 0}, -/* 15 */ { 3, s_10_15, -1, -1, 0}, -/* 16 */ { 5, s_10_16, -1, 5, 0}, -/* 17 */ { 4, s_10_17, -1, 8, 0} + /* 0 */ {5, s_10_0, -1, -1, 0}, + /* 1 */ {5, s_10_1, -1, -1, 0}, + /* 2 */ {4, s_10_2, -1, -1, 0}, + /* 3 */ {6, s_10_3, -1, -1, 0}, + /* 4 */ {5, s_10_4, -1, 3, 0}, + /* 5 */ {5, s_10_5, -1, 9, 0}, + /* 6 */ {6, s_10_6, -1, 7, 0}, + /* 7 */ {4, s_10_7, -1, -1, 0}, + /* 8 */ {4, s_10_8, -1, 6, 0}, + /* 9 */ {5, s_10_9, -1, 4, 0}, + /* 10 */ {4, s_10_10, -1, -1, 0}, + /* 11 */ {4, s_10_11, -1, 10, 0}, + /* 12 */ {6, s_10_12, -1, 11, 0}, + /* 13 */ {5, s_10_13, -1, 2, 0}, + /* 14 */ {4, s_10_14, -1, 1, 0}, + /* 15 */ {3, s_10_15, -1, -1, 0}, + /* 16 */ {5, s_10_16, -1, 5, 0}, + /* 17 */ {4, s_10_17, -1, 8, 0} }; -static unsigned char g_v[] = { 17, 65, 16, 1 }; +static unsigned char g_v[] = {17, 65, 16, 1}; -static unsigned char g_v_WXY[] = { 1, 17, 65, 208, 1 }; +static unsigned char g_v_WXY[] = {1, 17, 65, 208, 1}; -static unsigned char g_valid_LI[] = { 55, 141, 2 }; +static unsigned char g_valid_LI[] = {55, 141, 2}; -static symbol s_0[] = { '\'' }; -static symbol s_1[] = { 'y' }; -static symbol s_2[] = { 'Y' }; -static symbol s_3[] = { 'y' }; -static symbol s_4[] = { 'Y' }; -static symbol s_5[] = { 's', 's' }; -static symbol s_6[] = { 'i', 'e' }; -static symbol s_7[] = { 'i' }; -static symbol s_8[] = { 'e', 'e' }; -static symbol s_9[] = { 'e' }; -static symbol s_10[] = { 'e' }; -static symbol s_11[] = { 'y' }; -static symbol s_12[] = { 'Y' }; -static symbol s_13[] = { 'i' }; -static symbol s_14[] = { 't', 'i', 'o', 'n' }; -static symbol s_15[] = { 'e', 'n', 'c', 'e' }; -static symbol s_16[] = { 'a', 'n', 'c', 'e' }; -static symbol s_17[] = { 'a', 'b', 'l', 'e' }; -static symbol s_18[] = { 'e', 'n', 't' }; -static symbol s_19[] = { 'i', 'z', 'e' }; -static symbol s_20[] = { 'a', 't', 'e' }; -static symbol s_21[] = { 'a', 'l' }; -static symbol s_22[] = { 'f', 'u', 'l' }; -static symbol s_23[] = { 'o', 'u', 's' }; -static symbol s_24[] = { 'i', 'v', 'e' }; -static symbol s_25[] = { 'b', 'l', 'e' }; -static symbol s_26[] = { 'l' }; -static symbol s_27[] = { 'o', 'g' }; -static symbol s_28[] = { 'f', 'u', 'l' }; -static symbol s_29[] = { 'l', 'e', 's', 's' }; -static symbol s_30[] = { 't', 'i', 'o', 'n' }; -static symbol s_31[] = { 'a', 't', 'e' }; -static symbol s_32[] = { 'a', 'l' }; -static symbol s_33[] = { 'i', 'c' }; -static symbol s_34[] = { 's' }; -static symbol s_35[] = { 't' }; -static symbol s_36[] = { 'l' }; -static symbol s_37[] = { 's', 'k', 'i' }; -static symbol s_38[] = { 's', 'k', 'y' }; -static symbol s_39[] = { 'd', 'i', 'e' }; -static symbol s_40[] = { 'l', 'i', 'e' }; -static symbol s_41[] = { 't', 'i', 'e' }; -static symbol s_42[] = { 'i', 'd', 'l' }; -static symbol s_43[] = { 'g', 'e', 'n', 't', 'l' }; -static symbol s_44[] = { 'u', 'g', 'l', 'i' }; -static symbol s_45[] = { 'e', 'a', 'r', 'l', 'i' }; -static symbol s_46[] = { 'o', 'n', 'l', 'i' }; -static symbol s_47[] = { 's', 'i', 'n', 'g', 'l' }; -static symbol s_48[] = { 'Y' }; -static symbol s_49[] = { 'y' }; +static symbol s_0[] = {'\''}; +static symbol s_1[] = {'y'}; +static symbol s_2[] = {'Y'}; +static symbol s_3[] = {'y'}; +static symbol s_4[] = {'Y'}; +static symbol s_5[] = {'s', 's'}; +static symbol s_6[] = {'i', 'e'}; +static symbol s_7[] = {'i'}; +static symbol s_8[] = {'e', 'e'}; +static symbol s_9[] = {'e'}; +static symbol s_10[] = {'e'}; +static symbol s_11[] = {'y'}; +static symbol s_12[] = {'Y'}; +static symbol s_13[] = {'i'}; +static symbol s_14[] = {'t', 'i', 'o', 'n'}; +static symbol s_15[] = {'e', 'n', 'c', 'e'}; +static symbol s_16[] = {'a', 'n', 'c', 'e'}; +static symbol s_17[] = {'a', 'b', 'l', 'e'}; +static symbol s_18[] = {'e', 'n', 't'}; +static symbol s_19[] = {'i', 'z', 'e'}; +static symbol s_20[] = {'a', 't', 'e'}; +static symbol s_21[] = {'a', 'l'}; +static symbol s_22[] = {'f', 'u', 'l'}; +static symbol s_23[] = {'o', 'u', 's'}; +static symbol s_24[] = {'i', 'v', 'e'}; +static symbol s_25[] = {'b', 'l', 'e'}; +static symbol s_26[] = {'l'}; +static symbol s_27[] = {'o', 'g'}; +static symbol s_28[] = {'f', 'u', 'l'}; +static symbol s_29[] = {'l', 'e', 's', 's'}; +static symbol s_30[] = {'t', 'i', 'o', 'n'}; +static symbol s_31[] = {'a', 't', 'e'}; +static symbol s_32[] = {'a', 'l'}; +static symbol s_33[] = {'i', 'c'}; +static symbol s_34[] = {'s'}; +static symbol s_35[] = {'t'}; +static symbol s_36[] = {'l'}; +static symbol s_37[] = {'s', 'k', 'i'}; +static symbol s_38[] = {'s', 'k', 'y'}; +static symbol s_39[] = {'d', 'i', 'e'}; +static symbol s_40[] = {'l', 'i', 'e'}; +static symbol s_41[] = {'t', 'i', 'e'}; +static symbol s_42[] = {'i', 'd', 'l'}; +static symbol s_43[] = {'g', 'e', 'n', 't', 'l'}; +static symbol s_44[] = {'u', 'g', 'l', 'i'}; +static symbol s_45[] = {'e', 'a', 'r', 'l', 'i'}; +static symbol s_46[] = {'o', 'n', 'l', 'i'}; +static symbol s_47[] = {'s', 'i', 'n', 'g', 'l'}; +static symbol s_48[] = {'Y'}; +static symbol s_49[] = {'y'}; -static int r_prelude(struct SN_env * z) { - z->B[0] = 0; /* unset Y_found, line 26 */ - { int c = z->c; /* do, line 27 */ - z->bra = z->c; /* [, line 27 */ - if (!(eq_s(z, 1, s_0))) goto lab0; - z->ket = z->c; /* ], line 27 */ - { int ret; - ret = slice_del(z); /* delete, line 27 */ - if (ret < 0) return ret; - } - lab0: - z->c = c; - } - { int c = z->c; /* do, line 28 */ - z->bra = z->c; /* [, line 28 */ - if (!(eq_s(z, 1, s_1))) goto lab1; - z->ket = z->c; /* ], line 28 */ - if (!(in_grouping(z, g_v, 97, 121))) goto lab1; - { int ret; - ret = slice_from_s(z, 1, s_2); /* <-, line 28 */ - if (ret < 0) return ret; - } - z->B[0] = 1; /* set Y_found, line 28 */ - lab1: - z->c = c; - } - { int c = z->c; /* do, line 29 */ - while(1) { /* repeat, line 29 */ - int c = z->c; - while(1) { /* goto, line 29 */ - int c = z->c; - if (!(in_grouping(z, g_v, 97, 121))) goto lab4; - z->bra = z->c; /* [, line 29 */ - if (!(eq_s(z, 1, s_3))) goto lab4; - z->ket = z->c; /* ], line 29 */ - z->c = c; - break; - lab4: - z->c = c; - if (z->c >= z->l) goto lab3; - z->c++; /* goto, line 29 */ - } - { int ret; - ret = slice_from_s(z, 1, s_4); /* <-, line 29 */ - if (ret < 0) return ret; - } - z->B[0] = 1; /* set Y_found, line 29 */ - continue; - lab3: - z->c = c; - break; - } - z->c = c; - } - return 1; -} +static int +r_prelude(struct SN_env * z) +{ + z->B[0] = 0; /* unset Y_found, line 26 */ + { + int c = z->c; /* do, line 27 */ -static int r_mark_regions(struct SN_env * z) { - z->I[0] = z->l; - z->I[1] = z->l; - { int c = z->c; /* do, line 35 */ - { int c = z->c; /* or, line 40 */ - if (!(find_among(z, a_0, 2))) goto lab2; /* among, line 36 */ - goto lab1; - lab2: - z->c = c; - while(1) { /* gopast, line 40 */ - if (!(in_grouping(z, g_v, 97, 121))) goto lab3; - break; - lab3: - if (z->c >= z->l) goto lab0; - z->c++; /* gopast, line 40 */ - } - while(1) { /* gopast, line 40 */ - if (!(out_grouping(z, g_v, 97, 121))) goto lab4; - break; - lab4: - if (z->c >= z->l) goto lab0; - z->c++; /* gopast, line 40 */ - } - } - lab1: - z->I[0] = z->c; /* setmark p1, line 41 */ - while(1) { /* gopast, line 42 */ - if (!(in_grouping(z, g_v, 97, 121))) goto lab5; - break; - lab5: - if (z->c >= z->l) goto lab0; - z->c++; /* gopast, line 42 */ - } - while(1) { /* gopast, line 42 */ - if (!(out_grouping(z, g_v, 97, 121))) goto lab6; - break; - lab6: - if (z->c >= z->l) goto lab0; - z->c++; /* gopast, line 42 */ - } - z->I[1] = z->c; /* setmark p2, line 42 */ - lab0: - z->c = c; - } - return 1; -} + z->bra = z->c; /* [, line 27 */ + if (!(eq_s(z, 1, s_0))) + goto lab0; + z->ket = z->c; /* ], line 27 */ + { + int ret; -static int r_shortv(struct SN_env * z) { - { int m = z->l - z->c; (void) m; /* or, line 50 */ - if (!(out_grouping_b(z, g_v_WXY, 89, 121))) goto lab1; - if (!(in_grouping_b(z, g_v, 97, 121))) goto lab1; - if (!(out_grouping_b(z, g_v, 97, 121))) goto lab1; - goto lab0; - lab1: - z->c = z->l - m; - if (!(out_grouping_b(z, g_v, 97, 121))) return 0; - if (!(in_grouping_b(z, g_v, 97, 121))) return 0; - if (z->c > z->lb) return 0; /* atlimit, line 51 */ - } + ret = slice_del(z); /* delete, line 27 */ + if (ret < 0) + return ret; + } lab0: - return 1; + z->c = c; + } + { + int c = z->c; /* do, line 28 */ + + z->bra = z->c; /* [, line 28 */ + if (!(eq_s(z, 1, s_1))) + goto lab1; + z->ket = z->c; /* ], line 28 */ + if (!(in_grouping(z, g_v, 97, 121))) + goto lab1; + { + int ret; + + ret = slice_from_s(z, 1, s_2); /* <-, line 28 */ + if (ret < 0) + return ret; + } + z->B[0] = 1; /* set Y_found, line 28 */ +lab1: + z->c = c; + } + { + int c = z->c; /* do, line 29 */ + + while (1) + { /* repeat, line 29 */ + int c = z->c; + + while (1) + { /* goto, line 29 */ + int c = z->c; + + if (!(in_grouping(z, g_v, 97, 121))) + goto lab4; + z->bra = z->c; /* [, line 29 */ + if (!(eq_s(z, 1, s_3))) + goto lab4; + z->ket = z->c; /* ], line 29 */ + z->c = c; + break; + lab4: + z->c = c; + if (z->c >= z->l) + goto lab3; + z->c++; /* goto, line 29 */ + } + { + int ret; + + ret = slice_from_s(z, 1, s_4); /* <-, line 29 */ + if (ret < 0) + return ret; + } + z->B[0] = 1; /* set Y_found, line 29 */ + continue; + lab3: + z->c = c; + break; + } + z->c = c; + } + return 1; } -static int r_R1(struct SN_env * z) { - if (!(z->I[0] <= z->c)) return 0; - return 1; -} +static int +r_mark_regions(struct SN_env * z) +{ + z->I[0] = z->l; + z->I[1] = z->l; + { + int c = z->c; /* do, line 35 */ -static int r_R2(struct SN_env * z) { - if (!(z->I[1] <= z->c)) return 0; - return 1; -} + { + int c = z->c; /* or, line 40 */ -static int r_Step_1a(struct SN_env * z) { - int among_var; - { int m = z->l - z->c; (void) m; /* try, line 58 */ - z->ket = z->c; /* [, line 59 */ - among_var = find_among_b(z, a_1, 3); /* substring, line 59 */ - if (!(among_var)) { z->c = z->l - m; goto lab0; } - z->bra = z->c; /* ], line 59 */ - switch(among_var) { - case 0: { z->c = z->l - m; goto lab0; } - case 1: - { int ret; - ret = slice_del(z); /* delete, line 61 */ - if (ret < 0) return ret; - } - break; - } - lab0: - ; - } - z->ket = z->c; /* [, line 64 */ - among_var = find_among_b(z, a_2, 6); /* substring, line 64 */ - if (!(among_var)) return 0; - z->bra = z->c; /* ], line 64 */ - switch(among_var) { - case 0: return 0; - case 1: - { int ret; - ret = slice_from_s(z, 2, s_5); /* <-, line 65 */ - if (ret < 0) return ret; - } - break; - case 2: - { int m = z->l - z->c; (void) m; /* or, line 67 */ - if (z->c <= z->lb) goto lab2; - z->c--; /* next, line 67 */ - if (z->c > z->lb) goto lab2; /* atlimit, line 67 */ - { int ret; - ret = slice_from_s(z, 2, s_6); /* <-, line 67 */ - if (ret < 0) return ret; - } - goto lab1; - lab2: - z->c = z->l - m; - { int ret; - ret = slice_from_s(z, 1, s_7); /* <-, line 67 */ - if (ret < 0) return ret; - } - } - lab1: - break; - case 3: - if (z->c <= z->lb) return 0; - z->c--; /* next, line 68 */ - while(1) { /* gopast, line 68 */ - if (!(in_grouping_b(z, g_v, 97, 121))) goto lab3; - break; - lab3: - if (z->c <= z->lb) return 0; - z->c--; /* gopast, line 68 */ - } - { int ret; - ret = slice_del(z); /* delete, line 68 */ - if (ret < 0) return ret; - } - break; - } - return 1; -} - -static int r_Step_1b(struct SN_env * z) { - int among_var; - z->ket = z->c; /* [, line 74 */ - among_var = find_among_b(z, a_4, 6); /* substring, line 74 */ - if (!(among_var)) return 0; - z->bra = z->c; /* ], line 74 */ - switch(among_var) { - case 0: return 0; - case 1: - { int ret = r_R1(z); - if (ret == 0) return 0; /* call R1, line 76 */ - if (ret < 0) return ret; - } - { int ret; - ret = slice_from_s(z, 2, s_8); /* <-, line 76 */ - if (ret < 0) return ret; - } - break; - case 2: - { int m_test = z->l - z->c; /* test, line 79 */ - while(1) { /* gopast, line 79 */ - if (!(in_grouping_b(z, g_v, 97, 121))) goto lab0; - break; - lab0: - if (z->c <= z->lb) return 0; - z->c--; /* gopast, line 79 */ - } - z->c = z->l - m_test; - } - { int ret; - ret = slice_del(z); /* delete, line 79 */ - if (ret < 0) return ret; - } - { int m_test = z->l - z->c; /* test, line 80 */ - among_var = find_among_b(z, a_3, 13); /* substring, line 80 */ - if (!(among_var)) return 0; - z->c = z->l - m_test; - } - switch(among_var) { - case 0: return 0; - case 1: - { int ret; - { int c = z->c; - ret = insert_s(z, z->c, z->c, 1, s_9); /* <+, line 82 */ - z->c = c; - } - if (ret < 0) return ret; - } - break; - case 2: - z->ket = z->c; /* [, line 85 */ - if (z->c <= z->lb) return 0; - z->c--; /* next, line 85 */ - z->bra = z->c; /* ], line 85 */ - { int ret; - ret = slice_del(z); /* delete, line 85 */ - if (ret < 0) return ret; - } - break; - case 3: - if (z->c != z->I[0]) return 0; /* atmark, line 86 */ - { int m_test = z->l - z->c; /* test, line 86 */ - { int ret = r_shortv(z); - if (ret == 0) return 0; /* call shortv, line 86 */ - if (ret < 0) return ret; - } - z->c = z->l - m_test; - } - { int ret; - { int c = z->c; - ret = insert_s(z, z->c, z->c, 1, s_10); /* <+, line 86 */ - z->c = c; - } - if (ret < 0) return ret; - } - break; - } - break; - } - return 1; -} - -static int r_Step_1c(struct SN_env * z) { - z->ket = z->c; /* [, line 93 */ - { int m = z->l - z->c; (void) m; /* or, line 93 */ - if (!(eq_s_b(z, 1, s_11))) goto lab1; - goto lab0; - lab1: - z->c = z->l - m; - if (!(eq_s_b(z, 1, s_12))) return 0; - } + if (!(find_among(z, a_0, 2))) + goto lab2; /* among, line 36 */ + goto lab1; + lab2: + z->c = c; + while (1) + { /* gopast, line 40 */ + if (!(in_grouping(z, g_v, 97, 121))) + goto lab3; + break; + lab3: + if (z->c >= z->l) + goto lab0; + z->c++; /* gopast, line 40 */ + } + while (1) + { /* gopast, line 40 */ + if (!(out_grouping(z, g_v, 97, 121))) + goto lab4; + break; + lab4: + if (z->c >= z->l) + goto lab0; + z->c++; /* gopast, line 40 */ + } + } +lab1: + z->I[0] = z->c; /* setmark p1, line 41 */ + while (1) + { /* gopast, line 42 */ + if (!(in_grouping(z, g_v, 97, 121))) + goto lab5; + break; + lab5: + if (z->c >= z->l) + goto lab0; + z->c++; /* gopast, line 42 */ + } + while (1) + { /* gopast, line 42 */ + if (!(out_grouping(z, g_v, 97, 121))) + goto lab6; + break; + lab6: + if (z->c >= z->l) + goto lab0; + z->c++; /* gopast, line 42 */ + } + z->I[1] = z->c; /* setmark p2, line 42 */ lab0: - z->bra = z->c; /* ], line 93 */ - if (!(out_grouping_b(z, g_v, 97, 121))) return 0; - { int m = z->l - z->c; (void) m; /* not, line 94 */ - if (z->c > z->lb) goto lab2; /* atlimit, line 94 */ - return 0; - lab2: - z->c = z->l - m; - } - { int ret; - ret = slice_from_s(z, 1, s_13); /* <-, line 95 */ - if (ret < 0) return ret; - } - return 1; + z->c = c; + } + return 1; } -static int r_Step_2(struct SN_env * z) { - int among_var; - z->ket = z->c; /* [, line 99 */ - among_var = find_among_b(z, a_5, 24); /* substring, line 99 */ - if (!(among_var)) return 0; - z->bra = z->c; /* ], line 99 */ - { int ret = r_R1(z); - if (ret == 0) return 0; /* call R1, line 99 */ - if (ret < 0) return ret; - } - switch(among_var) { - case 0: return 0; - case 1: - { int ret; - ret = slice_from_s(z, 4, s_14); /* <-, line 100 */ - if (ret < 0) return ret; - } - break; - case 2: - { int ret; - ret = slice_from_s(z, 4, s_15); /* <-, line 101 */ - if (ret < 0) return ret; - } - break; - case 3: - { int ret; - ret = slice_from_s(z, 4, s_16); /* <-, line 102 */ - if (ret < 0) return ret; - } - break; - case 4: - { int ret; - ret = slice_from_s(z, 4, s_17); /* <-, line 103 */ - if (ret < 0) return ret; - } - break; - case 5: - { int ret; - ret = slice_from_s(z, 3, s_18); /* <-, line 104 */ - if (ret < 0) return ret; - } - break; - case 6: - { int ret; - ret = slice_from_s(z, 3, s_19); /* <-, line 106 */ - if (ret < 0) return ret; - } - break; - case 7: - { int ret; - ret = slice_from_s(z, 3, s_20); /* <-, line 108 */ - if (ret < 0) return ret; - } - break; - case 8: - { int ret; - ret = slice_from_s(z, 2, s_21); /* <-, line 110 */ - if (ret < 0) return ret; - } - break; - case 9: - { int ret; - ret = slice_from_s(z, 3, s_22); /* <-, line 111 */ - if (ret < 0) return ret; - } - break; - case 10: - { int ret; - ret = slice_from_s(z, 3, s_23); /* <-, line 113 */ - if (ret < 0) return ret; - } - break; - case 11: - { int ret; - ret = slice_from_s(z, 3, s_24); /* <-, line 115 */ - if (ret < 0) return ret; - } - break; - case 12: - { int ret; - ret = slice_from_s(z, 3, s_25); /* <-, line 117 */ - if (ret < 0) return ret; - } - break; - case 13: - if (!(eq_s_b(z, 1, s_26))) return 0; - { int ret; - ret = slice_from_s(z, 2, s_27); /* <-, line 118 */ - if (ret < 0) return ret; - } - break; - case 14: - { int ret; - ret = slice_from_s(z, 3, s_28); /* <-, line 119 */ - if (ret < 0) return ret; - } - break; - case 15: - { int ret; - ret = slice_from_s(z, 4, s_29); /* <-, line 120 */ - if (ret < 0) return ret; - } - break; - case 16: - if (!(in_grouping_b(z, g_valid_LI, 99, 116))) return 0; - { int ret; - ret = slice_del(z); /* delete, line 121 */ - if (ret < 0) return ret; - } - break; - } - return 1; -} +static int +r_shortv(struct SN_env * z) +{ + { + int m = z->l - z->c; -static int r_Step_3(struct SN_env * z) { - int among_var; - z->ket = z->c; /* [, line 126 */ - among_var = find_among_b(z, a_6, 9); /* substring, line 126 */ - if (!(among_var)) return 0; - z->bra = z->c; /* ], line 126 */ - { int ret = r_R1(z); - if (ret == 0) return 0; /* call R1, line 126 */ - if (ret < 0) return ret; - } - switch(among_var) { - case 0: return 0; - case 1: - { int ret; - ret = slice_from_s(z, 4, s_30); /* <-, line 127 */ - if (ret < 0) return ret; - } - break; - case 2: - { int ret; - ret = slice_from_s(z, 3, s_31); /* <-, line 128 */ - if (ret < 0) return ret; - } - break; - case 3: - { int ret; - ret = slice_from_s(z, 2, s_32); /* <-, line 129 */ - if (ret < 0) return ret; - } - break; - case 4: - { int ret; - ret = slice_from_s(z, 2, s_33); /* <-, line 131 */ - if (ret < 0) return ret; - } - break; - case 5: - { int ret; - ret = slice_del(z); /* delete, line 133 */ - if (ret < 0) return ret; - } - break; - case 6: - { int ret = r_R2(z); - if (ret == 0) return 0; /* call R2, line 135 */ - if (ret < 0) return ret; - } - { int ret; - ret = slice_del(z); /* delete, line 135 */ - if (ret < 0) return ret; - } - break; - } - return 1; -} - -static int r_Step_4(struct SN_env * z) { - int among_var; - z->ket = z->c; /* [, line 140 */ - among_var = find_among_b(z, a_7, 18); /* substring, line 140 */ - if (!(among_var)) return 0; - z->bra = z->c; /* ], line 140 */ - { int ret = r_R2(z); - if (ret == 0) return 0; /* call R2, line 140 */ - if (ret < 0) return ret; - } - switch(among_var) { - case 0: return 0; - case 1: - { int ret; - ret = slice_del(z); /* delete, line 143 */ - if (ret < 0) return ret; - } - break; - case 2: - { int m = z->l - z->c; (void) m; /* or, line 144 */ - if (!(eq_s_b(z, 1, s_34))) goto lab1; - goto lab0; - lab1: - z->c = z->l - m; - if (!(eq_s_b(z, 1, s_35))) return 0; - } - lab0: - { int ret; - ret = slice_del(z); /* delete, line 144 */ - if (ret < 0) return ret; - } - break; - } - return 1; -} - -static int r_Step_5(struct SN_env * z) { - int among_var; - z->ket = z->c; /* [, line 149 */ - among_var = find_among_b(z, a_8, 2); /* substring, line 149 */ - if (!(among_var)) return 0; - z->bra = z->c; /* ], line 149 */ - switch(among_var) { - case 0: return 0; - case 1: - { int m = z->l - z->c; (void) m; /* or, line 150 */ - { int ret = r_R2(z); - if (ret == 0) goto lab1; /* call R2, line 150 */ - if (ret < 0) return ret; - } - goto lab0; - lab1: - z->c = z->l - m; - { int ret = r_R1(z); - if (ret == 0) return 0; /* call R1, line 150 */ - if (ret < 0) return ret; - } - { int m = z->l - z->c; (void) m; /* not, line 150 */ - { int ret = r_shortv(z); - if (ret == 0) goto lab2; /* call shortv, line 150 */ - if (ret < 0) return ret; - } - return 0; - lab2: - z->c = z->l - m; - } - } - lab0: - { int ret; - ret = slice_del(z); /* delete, line 150 */ - if (ret < 0) return ret; - } - break; - case 2: - { int ret = r_R2(z); - if (ret == 0) return 0; /* call R2, line 151 */ - if (ret < 0) return ret; - } - if (!(eq_s_b(z, 1, s_36))) return 0; - { int ret; - ret = slice_del(z); /* delete, line 151 */ - if (ret < 0) return ret; - } - break; - } - return 1; -} - -static int r_exception2(struct SN_env * z) { - z->ket = z->c; /* [, line 157 */ - if (!(find_among_b(z, a_9, 8))) return 0; /* substring, line 157 */ - z->bra = z->c; /* ], line 157 */ - if (z->c > z->lb) return 0; /* atlimit, line 157 */ - return 1; -} - -static int r_exception1(struct SN_env * z) { - int among_var; - z->bra = z->c; /* [, line 169 */ - among_var = find_among(z, a_10, 18); /* substring, line 169 */ - if (!(among_var)) return 0; - z->ket = z->c; /* ], line 169 */ - if (z->c < z->l) return 0; /* atlimit, line 169 */ - switch(among_var) { - case 0: return 0; - case 1: - { int ret; - ret = slice_from_s(z, 3, s_37); /* <-, line 173 */ - if (ret < 0) return ret; - } - break; - case 2: - { int ret; - ret = slice_from_s(z, 3, s_38); /* <-, line 174 */ - if (ret < 0) return ret; - } - break; - case 3: - { int ret; - ret = slice_from_s(z, 3, s_39); /* <-, line 175 */ - if (ret < 0) return ret; - } - break; - case 4: - { int ret; - ret = slice_from_s(z, 3, s_40); /* <-, line 176 */ - if (ret < 0) return ret; - } - break; - case 5: - { int ret; - ret = slice_from_s(z, 3, s_41); /* <-, line 177 */ - if (ret < 0) return ret; - } - break; - case 6: - { int ret; - ret = slice_from_s(z, 3, s_42); /* <-, line 181 */ - if (ret < 0) return ret; - } - break; - case 7: - { int ret; - ret = slice_from_s(z, 5, s_43); /* <-, line 182 */ - if (ret < 0) return ret; - } - break; - case 8: - { int ret; - ret = slice_from_s(z, 4, s_44); /* <-, line 183 */ - if (ret < 0) return ret; - } - break; - case 9: - { int ret; - ret = slice_from_s(z, 5, s_45); /* <-, line 184 */ - if (ret < 0) return ret; - } - break; - case 10: - { int ret; - ret = slice_from_s(z, 4, s_46); /* <-, line 185 */ - if (ret < 0) return ret; - } - break; - case 11: - { int ret; - ret = slice_from_s(z, 5, s_47); /* <-, line 186 */ - if (ret < 0) return ret; - } - break; - } - return 1; -} - -static int r_postlude(struct SN_env * z) { - if (!(z->B[0])) return 0; /* Boolean test Y_found, line 202 */ - while(1) { /* repeat, line 202 */ - int c = z->c; - while(1) { /* goto, line 202 */ - int c = z->c; - z->bra = z->c; /* [, line 202 */ - if (!(eq_s(z, 1, s_48))) goto lab1; - z->ket = z->c; /* ], line 202 */ - z->c = c; - break; - lab1: - z->c = c; - if (z->c >= z->l) goto lab0; - z->c++; /* goto, line 202 */ - } - { int ret; - ret = slice_from_s(z, 1, s_49); /* <-, line 202 */ - if (ret < 0) return ret; - } - continue; - lab0: - z->c = c; - break; - } - return 1; -} - -extern int english_ISO_8859_1_stem(struct SN_env * z) { - { int c = z->c; /* or, line 206 */ - { int ret = r_exception1(z); - if (ret == 0) goto lab1; /* call exception1, line 206 */ - if (ret < 0) return ret; - } - goto lab0; - lab1: - z->c = c; - { int c = z->c; /* not, line 207 */ - { int c = z->c + 3; - if (0 > c || c > z->l) goto lab3; - z->c = c; /* hop, line 207 */ - } - goto lab2; - lab3: - z->c = c; - } - goto lab0; - lab2: - z->c = c; - { int c = z->c; /* do, line 208 */ - { int ret = r_prelude(z); - if (ret == 0) goto lab4; /* call prelude, line 208 */ - if (ret < 0) return ret; - } - lab4: - z->c = c; - } - { int c = z->c; /* do, line 209 */ - { int ret = r_mark_regions(z); - if (ret == 0) goto lab5; /* call mark_regions, line 209 */ - if (ret < 0) return ret; - } - lab5: - z->c = c; - } - z->lb = z->c; z->c = z->l; /* backwards, line 210 */ - - { int m = z->l - z->c; (void) m; /* do, line 212 */ - { int ret = r_Step_1a(z); - if (ret == 0) goto lab6; /* call Step_1a, line 212 */ - if (ret < 0) return ret; - } - lab6: - z->c = z->l - m; - } - { int m = z->l - z->c; (void) m; /* or, line 214 */ - { int ret = r_exception2(z); - if (ret == 0) goto lab8; /* call exception2, line 214 */ - if (ret < 0) return ret; - } - goto lab7; - lab8: - z->c = z->l - m; - { int m = z->l - z->c; (void) m; /* do, line 216 */ - { int ret = r_Step_1b(z); - if (ret == 0) goto lab9; /* call Step_1b, line 216 */ - if (ret < 0) return ret; - } - lab9: - z->c = z->l - m; - } - { int m = z->l - z->c; (void) m; /* do, line 217 */ - { int ret = r_Step_1c(z); - if (ret == 0) goto lab10; /* call Step_1c, line 217 */ - if (ret < 0) return ret; - } - lab10: - z->c = z->l - m; - } - { int m = z->l - z->c; (void) m; /* do, line 219 */ - { int ret = r_Step_2(z); - if (ret == 0) goto lab11; /* call Step_2, line 219 */ - if (ret < 0) return ret; - } - lab11: - z->c = z->l - m; - } - { int m = z->l - z->c; (void) m; /* do, line 220 */ - { int ret = r_Step_3(z); - if (ret == 0) goto lab12; /* call Step_3, line 220 */ - if (ret < 0) return ret; - } - lab12: - z->c = z->l - m; - } - { int m = z->l - z->c; (void) m; /* do, line 221 */ - { int ret = r_Step_4(z); - if (ret == 0) goto lab13; /* call Step_4, line 221 */ - if (ret < 0) return ret; - } - lab13: - z->c = z->l - m; - } - { int m = z->l - z->c; (void) m; /* do, line 223 */ - { int ret = r_Step_5(z); - if (ret == 0) goto lab14; /* call Step_5, line 223 */ - if (ret < 0) return ret; - } - lab14: - z->c = z->l - m; - } - } - lab7: - z->c = z->lb; - { int c = z->c; /* do, line 226 */ - { int ret = r_postlude(z); - if (ret == 0) goto lab15; /* call postlude, line 226 */ - if (ret < 0) return ret; - } - lab15: - z->c = c; - } - } + (void) m; /* or, line 50 */ + if (!(out_grouping_b(z, g_v_WXY, 89, 121))) + goto lab1; + if (!(in_grouping_b(z, g_v, 97, 121))) + goto lab1; + if (!(out_grouping_b(z, g_v, 97, 121))) + goto lab1; + goto lab0; +lab1: + z->c = z->l - m; + if (!(out_grouping_b(z, g_v, 97, 121))) + return 0; + if (!(in_grouping_b(z, g_v, 97, 121))) + return 0; + if (z->c > z->lb) + return 0; /* atlimit, line 51 */ + } lab0: - return 1; + return 1; } -extern struct SN_env * english_ISO_8859_1_create_env(void) { return SN_create_env(0, 2, 1); } +static int +r_R1(struct SN_env * z) +{ + if (!(z->I[0] <= z->c)) + return 0; + return 1; +} -extern void english_ISO_8859_1_close_env(struct SN_env * z) { SN_close_env(z); } +static int +r_R2(struct SN_env * z) +{ + if (!(z->I[1] <= z->c)) + return 0; + return 1; +} +static int +r_Step_1a(struct SN_env * z) +{ + int among_var; + + { + int m = z->l - z->c; + + (void) m; /* try, line 58 */ + z->ket = z->c; /* [, line 59 */ + among_var = find_among_b(z, a_1, 3); /* substring, line 59 */ + if (!(among_var)) + { + z->c = z->l - m; + goto lab0; + } + z->bra = z->c; /* ], line 59 */ + switch (among_var) + { + case 0: + { + z->c = z->l - m; + goto lab0; + } + case 1: + { + int ret; + + ret = slice_del(z); /* delete, line 61 */ + if (ret < 0) + return ret; + } + break; + } +lab0: + ; + } + z->ket = z->c; /* [, line 64 */ + among_var = find_among_b(z, a_2, 6); /* substring, line 64 */ + if (!(among_var)) + return 0; + z->bra = z->c; /* ], line 64 */ + switch (among_var) + { + case 0: + return 0; + case 1: + { + int ret; + + ret = slice_from_s(z, 2, s_5); /* <-, line 65 */ + if (ret < 0) + return ret; + } + break; + case 2: + { + int m = z->l - z->c; + + (void) m; /* or, line 67 */ + if (z->c <= z->lb) + goto lab2; + z->c--; /* next, line 67 */ + if (z->c > z->lb) + goto lab2; /* atlimit, line 67 */ + { + int ret; + + ret = slice_from_s(z, 2, s_6); /* <-, line 67 */ + if (ret < 0) + return ret; + } + goto lab1; + lab2: + z->c = z->l - m; + { + int ret; + + ret = slice_from_s(z, 1, s_7); /* <-, line 67 */ + if (ret < 0) + return ret; + } + } + lab1: + break; + case 3: + if (z->c <= z->lb) + return 0; + z->c--; /* next, line 68 */ + while (1) + { /* gopast, line 68 */ + if (!(in_grouping_b(z, g_v, 97, 121))) + goto lab3; + break; + lab3: + if (z->c <= z->lb) + return 0; + z->c--; /* gopast, line 68 */ + } + { + int ret; + + ret = slice_del(z); /* delete, line 68 */ + if (ret < 0) + return ret; + } + break; + } + return 1; +} + +static int +r_Step_1b(struct SN_env * z) +{ + int among_var; + + z->ket = z->c; /* [, line 74 */ + among_var = find_among_b(z, a_4, 6); /* substring, line 74 */ + if (!(among_var)) + return 0; + z->bra = z->c; /* ], line 74 */ + switch (among_var) + { + case 0: + return 0; + case 1: + { + int ret = r_R1(z); + + if (ret == 0) + return 0; /* call R1, line 76 */ + if (ret < 0) + return ret; + } + { + int ret; + + ret = slice_from_s(z, 2, s_8); /* <-, line 76 */ + if (ret < 0) + return ret; + } + break; + case 2: + { + int m_test = z->l - z->c; /* test, line 79 */ + + while (1) + { /* gopast, line 79 */ + if (!(in_grouping_b(z, g_v, 97, 121))) + goto lab0; + break; + lab0: + if (z->c <= z->lb) + return 0; + z->c--; /* gopast, line 79 */ + } + z->c = z->l - m_test; + } + { + int ret; + + ret = slice_del(z); /* delete, line 79 */ + if (ret < 0) + return ret; + } + { + int m_test = z->l - z->c; /* test, line 80 */ + + among_var = find_among_b(z, a_3, 13); /* substring, line 80 */ + if (!(among_var)) + return 0; + z->c = z->l - m_test; + } + switch (among_var) + { + case 0: + return 0; + case 1: + { + int ret; + + { + int c = z->c; + + ret = insert_s(z, z->c, z->c, 1, s_9); /* <+, line 82 */ + z->c = c; + } + if (ret < 0) + return ret; + } + break; + case 2: + z->ket = z->c; /* [, line 85 */ + if (z->c <= z->lb) + return 0; + z->c--; /* next, line 85 */ + z->bra = z->c; /* ], line 85 */ + { + int ret; + + ret = slice_del(z); /* delete, line 85 */ + if (ret < 0) + return ret; + } + break; + case 3: + if (z->c != z->I[0]) + return 0; /* atmark, line 86 */ + { + int m_test = z->l - z->c; /* test, line 86 */ + + { + int ret = r_shortv(z); + + if (ret == 0) + return 0; /* call shortv, line 86 */ + if (ret < 0) + return ret; + } + z->c = z->l - m_test; + } + { + int ret; + + { + int c = z->c; + + ret = insert_s(z, z->c, z->c, 1, s_10); /* <+, line 86 */ + z->c = c; + } + if (ret < 0) + return ret; + } + break; + } + break; + } + return 1; +} + +static int +r_Step_1c(struct SN_env * z) +{ + z->ket = z->c; /* [, line 93 */ + { + int m = z->l - z->c; + + (void) m; /* or, line 93 */ + if (!(eq_s_b(z, 1, s_11))) + goto lab1; + goto lab0; +lab1: + z->c = z->l - m; + if (!(eq_s_b(z, 1, s_12))) + return 0; + } +lab0: + z->bra = z->c; /* ], line 93 */ + if (!(out_grouping_b(z, g_v, 97, 121))) + return 0; + { + int m = z->l - z->c; + + (void) m; /* not, line 94 */ + if (z->c > z->lb) + goto lab2; /* atlimit, line 94 */ + return 0; +lab2: + z->c = z->l - m; + } + { + int ret; + + ret = slice_from_s(z, 1, s_13); /* <-, line 95 */ + if (ret < 0) + return ret; + } + return 1; +} + +static int +r_Step_2(struct SN_env * z) +{ + int among_var; + + z->ket = z->c; /* [, line 99 */ + among_var = find_among_b(z, a_5, 24); /* substring, line 99 */ + if (!(among_var)) + return 0; + z->bra = z->c; /* ], line 99 */ + { + int ret = r_R1(z); + + if (ret == 0) + return 0; /* call R1, line 99 */ + if (ret < 0) + return ret; + } + switch (among_var) + { + case 0: + return 0; + case 1: + { + int ret; + + ret = slice_from_s(z, 4, s_14); /* <-, line 100 */ + if (ret < 0) + return ret; + } + break; + case 2: + { + int ret; + + ret = slice_from_s(z, 4, s_15); /* <-, line 101 */ + if (ret < 0) + return ret; + } + break; + case 3: + { + int ret; + + ret = slice_from_s(z, 4, s_16); /* <-, line 102 */ + if (ret < 0) + return ret; + } + break; + case 4: + { + int ret; + + ret = slice_from_s(z, 4, s_17); /* <-, line 103 */ + if (ret < 0) + return ret; + } + break; + case 5: + { + int ret; + + ret = slice_from_s(z, 3, s_18); /* <-, line 104 */ + if (ret < 0) + return ret; + } + break; + case 6: + { + int ret; + + ret = slice_from_s(z, 3, s_19); /* <-, line 106 */ + if (ret < 0) + return ret; + } + break; + case 7: + { + int ret; + + ret = slice_from_s(z, 3, s_20); /* <-, line 108 */ + if (ret < 0) + return ret; + } + break; + case 8: + { + int ret; + + ret = slice_from_s(z, 2, s_21); /* <-, line 110 */ + if (ret < 0) + return ret; + } + break; + case 9: + { + int ret; + + ret = slice_from_s(z, 3, s_22); /* <-, line 111 */ + if (ret < 0) + return ret; + } + break; + case 10: + { + int ret; + + ret = slice_from_s(z, 3, s_23); /* <-, line 113 */ + if (ret < 0) + return ret; + } + break; + case 11: + { + int ret; + + ret = slice_from_s(z, 3, s_24); /* <-, line 115 */ + if (ret < 0) + return ret; + } + break; + case 12: + { + int ret; + + ret = slice_from_s(z, 3, s_25); /* <-, line 117 */ + if (ret < 0) + return ret; + } + break; + case 13: + if (!(eq_s_b(z, 1, s_26))) + return 0; + { + int ret; + + ret = slice_from_s(z, 2, s_27); /* <-, line 118 */ + if (ret < 0) + return ret; + } + break; + case 14: + { + int ret; + + ret = slice_from_s(z, 3, s_28); /* <-, line 119 */ + if (ret < 0) + return ret; + } + break; + case 15: + { + int ret; + + ret = slice_from_s(z, 4, s_29); /* <-, line 120 */ + if (ret < 0) + return ret; + } + break; + case 16: + if (!(in_grouping_b(z, g_valid_LI, 99, 116))) + return 0; + { + int ret; + + ret = slice_del(z); /* delete, line 121 */ + if (ret < 0) + return ret; + } + break; + } + return 1; +} + +static int +r_Step_3(struct SN_env * z) +{ + int among_var; + + z->ket = z->c; /* [, line 126 */ + among_var = find_among_b(z, a_6, 9); /* substring, line 126 */ + if (!(among_var)) + return 0; + z->bra = z->c; /* ], line 126 */ + { + int ret = r_R1(z); + + if (ret == 0) + return 0; /* call R1, line 126 */ + if (ret < 0) + return ret; + } + switch (among_var) + { + case 0: + return 0; + case 1: + { + int ret; + + ret = slice_from_s(z, 4, s_30); /* <-, line 127 */ + if (ret < 0) + return ret; + } + break; + case 2: + { + int ret; + + ret = slice_from_s(z, 3, s_31); /* <-, line 128 */ + if (ret < 0) + return ret; + } + break; + case 3: + { + int ret; + + ret = slice_from_s(z, 2, s_32); /* <-, line 129 */ + if (ret < 0) + return ret; + } + break; + case 4: + { + int ret; + + ret = slice_from_s(z, 2, s_33); /* <-, line 131 */ + if (ret < 0) + return ret; + } + break; + case 5: + { + int ret; + + ret = slice_del(z); /* delete, line 133 */ + if (ret < 0) + return ret; + } + break; + case 6: + { + int ret = r_R2(z); + + if (ret == 0) + return 0; /* call R2, line 135 */ + if (ret < 0) + return ret; + } + { + int ret; + + ret = slice_del(z); /* delete, line 135 */ + if (ret < 0) + return ret; + } + break; + } + return 1; +} + +static int +r_Step_4(struct SN_env * z) +{ + int among_var; + + z->ket = z->c; /* [, line 140 */ + among_var = find_among_b(z, a_7, 18); /* substring, line 140 */ + if (!(among_var)) + return 0; + z->bra = z->c; /* ], line 140 */ + { + int ret = r_R2(z); + + if (ret == 0) + return 0; /* call R2, line 140 */ + if (ret < 0) + return ret; + } + switch (among_var) + { + case 0: + return 0; + case 1: + { + int ret; + + ret = slice_del(z); /* delete, line 143 */ + if (ret < 0) + return ret; + } + break; + case 2: + { + int m = z->l - z->c; + + (void) m; /* or, line 144 */ + if (!(eq_s_b(z, 1, s_34))) + goto lab1; + goto lab0; + lab1: + z->c = z->l - m; + if (!(eq_s_b(z, 1, s_35))) + return 0; + } + lab0: + { + int ret; + + ret = slice_del(z); /* delete, line 144 */ + if (ret < 0) + return ret; + } + break; + } + return 1; +} + +static int +r_Step_5(struct SN_env * z) +{ + int among_var; + + z->ket = z->c; /* [, line 149 */ + among_var = find_among_b(z, a_8, 2); /* substring, line 149 */ + if (!(among_var)) + return 0; + z->bra = z->c; /* ], line 149 */ + switch (among_var) + { + case 0: + return 0; + case 1: + { + int m = z->l - z->c; + + (void) m; /* or, line 150 */ + { + int ret = r_R2(z); + + if (ret == 0) + goto lab1; /* call R2, line 150 */ + if (ret < 0) + return ret; + } + goto lab0; + lab1: + z->c = z->l - m; + { + int ret = r_R1(z); + + if (ret == 0) + return 0; /* call R1, line 150 */ + if (ret < 0) + return ret; + } + { + int m = z->l - z->c; + + (void) m; /* not, line 150 */ + { + int ret = r_shortv(z); + + if (ret == 0) + goto lab2; /* call shortv, line 150 */ + if (ret < 0) + return ret; + } + return 0; + lab2: + z->c = z->l - m; + } + } + lab0: + { + int ret; + + ret = slice_del(z); /* delete, line 150 */ + if (ret < 0) + return ret; + } + break; + case 2: + { + int ret = r_R2(z); + + if (ret == 0) + return 0; /* call R2, line 151 */ + if (ret < 0) + return ret; + } + if (!(eq_s_b(z, 1, s_36))) + return 0; + { + int ret; + + ret = slice_del(z); /* delete, line 151 */ + if (ret < 0) + return ret; + } + break; + } + return 1; +} + +static int +r_exception2(struct SN_env * z) +{ + z->ket = z->c; /* [, line 157 */ + if (!(find_among_b(z, a_9, 8))) + return 0; /* substring, line 157 */ + z->bra = z->c; /* ], line 157 */ + if (z->c > z->lb) + return 0; /* atlimit, line 157 */ + return 1; +} + +static int +r_exception1(struct SN_env * z) +{ + int among_var; + + z->bra = z->c; /* [, line 169 */ + among_var = find_among(z, a_10, 18); /* substring, line 169 */ + if (!(among_var)) + return 0; + z->ket = z->c; /* ], line 169 */ + if (z->c < z->l) + return 0; /* atlimit, line 169 */ + switch (among_var) + { + case 0: + return 0; + case 1: + { + int ret; + + ret = slice_from_s(z, 3, s_37); /* <-, line 173 */ + if (ret < 0) + return ret; + } + break; + case 2: + { + int ret; + + ret = slice_from_s(z, 3, s_38); /* <-, line 174 */ + if (ret < 0) + return ret; + } + break; + case 3: + { + int ret; + + ret = slice_from_s(z, 3, s_39); /* <-, line 175 */ + if (ret < 0) + return ret; + } + break; + case 4: + { + int ret; + + ret = slice_from_s(z, 3, s_40); /* <-, line 176 */ + if (ret < 0) + return ret; + } + break; + case 5: + { + int ret; + + ret = slice_from_s(z, 3, s_41); /* <-, line 177 */ + if (ret < 0) + return ret; + } + break; + case 6: + { + int ret; + + ret = slice_from_s(z, 3, s_42); /* <-, line 181 */ + if (ret < 0) + return ret; + } + break; + case 7: + { + int ret; + + ret = slice_from_s(z, 5, s_43); /* <-, line 182 */ + if (ret < 0) + return ret; + } + break; + case 8: + { + int ret; + + ret = slice_from_s(z, 4, s_44); /* <-, line 183 */ + if (ret < 0) + return ret; + } + break; + case 9: + { + int ret; + + ret = slice_from_s(z, 5, s_45); /* <-, line 184 */ + if (ret < 0) + return ret; + } + break; + case 10: + { + int ret; + + ret = slice_from_s(z, 4, s_46); /* <-, line 185 */ + if (ret < 0) + return ret; + } + break; + case 11: + { + int ret; + + ret = slice_from_s(z, 5, s_47); /* <-, line 186 */ + if (ret < 0) + return ret; + } + break; + } + return 1; +} + +static int +r_postlude(struct SN_env * z) +{ + if (!(z->B[0])) + return 0; /* Boolean test Y_found, line 202 */ + while (1) + { /* repeat, line 202 */ + int c = z->c; + + while (1) + { /* goto, line 202 */ + int c = z->c; + + z->bra = z->c; /* [, line 202 */ + if (!(eq_s(z, 1, s_48))) + goto lab1; + z->ket = z->c; /* ], line 202 */ + z->c = c; + break; + lab1: + z->c = c; + if (z->c >= z->l) + goto lab0; + z->c++; /* goto, line 202 */ + } + { + int ret; + + ret = slice_from_s(z, 1, s_49); /* <-, line 202 */ + if (ret < 0) + return ret; + } + continue; +lab0: + z->c = c; + break; + } + return 1; +} + +extern int +english_ISO_8859_1_stem(struct SN_env * z) +{ + { + int c = z->c; /* or, line 206 */ + + { + int ret = r_exception1(z); + + if (ret == 0) + goto lab1; /* call exception1, line 206 */ + if (ret < 0) + return ret; + } + goto lab0; +lab1: + z->c = c; + { + int c = z->c; /* not, line 207 */ + + { + int c = z->c + 3; + + if (0 > c || c > z->l) + goto lab3; + z->c = c; /* hop, line 207 */ + } + goto lab2; + lab3: + z->c = c; + } + goto lab0; +lab2: + z->c = c; + { + int c = z->c; /* do, line 208 */ + + { + int ret = r_prelude(z); + + if (ret == 0) + goto lab4; /* call prelude, line 208 */ + if (ret < 0) + return ret; + } + lab4: + z->c = c; + } + { + int c = z->c; /* do, line 209 */ + + { + int ret = r_mark_regions(z); + + if (ret == 0) + goto lab5; /* call mark_regions, line 209 */ + if (ret < 0) + return ret; + } + lab5: + z->c = c; + } + z->lb = z->c; + z->c = z->l; /* backwards, line 210 */ + + { + int m = z->l - z->c; + + (void) m; /* do, line 212 */ + { + int ret = r_Step_1a(z); + + if (ret == 0) + goto lab6; /* call Step_1a, line 212 */ + if (ret < 0) + return ret; + } + lab6: + z->c = z->l - m; + } + { + int m = z->l - z->c; + + (void) m; /* or, line 214 */ + { + int ret = r_exception2(z); + + if (ret == 0) + goto lab8; /* call exception2, line 214 */ + if (ret < 0) + return ret; + } + goto lab7; + lab8: + z->c = z->l - m; + { + int m = z->l - z->c; + + (void) m; /* do, line 216 */ + { + int ret = r_Step_1b(z); + + if (ret == 0) + goto lab9; /* call Step_1b, line 216 */ + if (ret < 0) + return ret; + } + lab9: + z->c = z->l - m; + } + { + int m = z->l - z->c; + + (void) m; /* do, line 217 */ + { + int ret = r_Step_1c(z); + + if (ret == 0) + goto lab10; /* call Step_1c, line 217 */ + if (ret < 0) + return ret; + } + lab10: + z->c = z->l - m; + } + { + int m = z->l - z->c; + + (void) m; /* do, line 219 */ + { + int ret = r_Step_2(z); + + if (ret == 0) + goto lab11; /* call Step_2, line 219 */ + if (ret < 0) + return ret; + } + lab11: + z->c = z->l - m; + } + { + int m = z->l - z->c; + + (void) m; /* do, line 220 */ + { + int ret = r_Step_3(z); + + if (ret == 0) + goto lab12; /* call Step_3, line 220 */ + if (ret < 0) + return ret; + } + lab12: + z->c = z->l - m; + } + { + int m = z->l - z->c; + + (void) m; /* do, line 221 */ + { + int ret = r_Step_4(z); + + if (ret == 0) + goto lab13; /* call Step_4, line 221 */ + if (ret < 0) + return ret; + } + lab13: + z->c = z->l - m; + } + { + int m = z->l - z->c; + + (void) m; /* do, line 223 */ + { + int ret = r_Step_5(z); + + if (ret == 0) + goto lab14; /* call Step_5, line 223 */ + if (ret < 0) + return ret; + } + lab14: + z->c = z->l - m; + } + } +lab7: + z->c = z->lb; + { + int c = z->c; /* do, line 226 */ + + { + int ret = r_postlude(z); + + if (ret == 0) + goto lab15; /* call postlude, line 226 */ + if (ret < 0) + return ret; + } + lab15: + z->c = c; + } + } +lab0: + return 1; +} + +extern struct SN_env *english_ISO_8859_1_create_env(void) +{ + return SN_create_env(0, 2, 1); +} + +extern void english_ISO_8859_1_close_env(struct SN_env * z) +{ + SN_close_env(z); +} diff --git a/contrib/tsearch2/snowball/english_stem.h b/contrib/tsearch2/snowball/english_stem.h index e685dcf7ef..8a3c3816d6 100644 --- a/contrib/tsearch2/snowball/english_stem.h +++ b/contrib/tsearch2/snowball/english_stem.h @@ -2,15 +2,16 @@ /* This file was generated automatically by the Snowball to ANSI C compiler */ #ifdef __cplusplus -extern "C" { +extern "C" +{ #endif -extern struct SN_env * english_ISO_8859_1_create_env(void); -extern void english_ISO_8859_1_close_env(struct SN_env * z); + extern struct SN_env *english_ISO_8859_1_create_env(void); + extern void english_ISO_8859_1_close_env(struct SN_env * z); -extern int english_ISO_8859_1_stem(struct SN_env * z); + extern int english_ISO_8859_1_stem(struct SN_env * z); #ifdef __cplusplus } -#endif +#endif diff --git a/contrib/tsearch2/snowball/header.h b/contrib/tsearch2/snowball/header.h index c0721d6fd3..ad07388154 100644 --- a/contrib/tsearch2/snowball/header.h +++ b/contrib/tsearch2/snowball/header.h @@ -8,51 +8,51 @@ #define HEAD 2*sizeof(int) -#define SIZE(p) ((int *)(p))[-1] +#define SIZE(p) ((int *)(p))[-1] #define SET_SIZE(p, n) ((int *)(p))[-1] = n #define CAPACITY(p) ((int *)(p))[-2] struct among -{ int s_size; /* number of chars in string */ - symbol * s; /* search string */ - int substring_i;/* index to longest matching substring */ - int result; /* result of the lookup */ - int (* function)(struct SN_env *); +{ + int s_size; /* number of chars in string */ + symbol *s; /* search string */ + int substring_i; /* index to longest matching substring */ + int result; /* result of the lookup */ + int (*function) (struct SN_env *); }; -extern symbol * create_s(void); +extern symbol *create_s(void); extern void lose_s(symbol * p); -extern int skip_utf8(const symbol * p, int c, int lb, int l, int n); +extern int skip_utf8(const symbol * p, int c, int lb, int l, int n); -extern int in_grouping_U(struct SN_env * z, unsigned char * s, int min, int max); -extern int in_grouping_b_U(struct SN_env * z, unsigned char * s, int min, int max); -extern int out_grouping_U(struct SN_env * z, unsigned char * s, int min, int max); -extern int out_grouping_b_U(struct SN_env * z, unsigned char * s, int min, int max); +extern int in_grouping_U(struct SN_env * z, unsigned char *s, int min, int max); +extern int in_grouping_b_U(struct SN_env * z, unsigned char *s, int min, int max); +extern int out_grouping_U(struct SN_env * z, unsigned char *s, int min, int max); +extern int out_grouping_b_U(struct SN_env * z, unsigned char *s, int min, int max); -extern int in_grouping(struct SN_env * z, unsigned char * s, int min, int max); -extern int in_grouping_b(struct SN_env * z, unsigned char * s, int min, int max); -extern int out_grouping(struct SN_env * z, unsigned char * s, int min, int max); -extern int out_grouping_b(struct SN_env * z, unsigned char * s, int min, int max); +extern int in_grouping(struct SN_env * z, unsigned char *s, int min, int max); +extern int in_grouping_b(struct SN_env * z, unsigned char *s, int min, int max); +extern int out_grouping(struct SN_env * z, unsigned char *s, int min, int max); +extern int out_grouping_b(struct SN_env * z, unsigned char *s, int min, int max); -extern int eq_s(struct SN_env * z, int s_size, symbol * s); -extern int eq_s_b(struct SN_env * z, int s_size, symbol * s); -extern int eq_v(struct SN_env * z, symbol * p); -extern int eq_v_b(struct SN_env * z, symbol * p); +extern int eq_s(struct SN_env * z, int s_size, symbol * s); +extern int eq_s_b(struct SN_env * z, int s_size, symbol * s); +extern int eq_v(struct SN_env * z, symbol * p); +extern int eq_v_b(struct SN_env * z, symbol * p); -extern int find_among(struct SN_env * z, struct among * v, int v_size); -extern int find_among_b(struct SN_env * z, struct among * v, int v_size); +extern int find_among(struct SN_env * z, struct among * v, int v_size); +extern int find_among_b(struct SN_env * z, struct among * v, int v_size); -extern int replace_s(struct SN_env * z, int c_bra, int c_ket, int s_size, const symbol * s, int * adjustment); -extern int slice_from_s(struct SN_env * z, int s_size, symbol * s); -extern int slice_from_v(struct SN_env * z, symbol * p); -extern int slice_del(struct SN_env * z); +extern int replace_s(struct SN_env * z, int c_bra, int c_ket, int s_size, const symbol * s, int *adjustment); +extern int slice_from_s(struct SN_env * z, int s_size, symbol * s); +extern int slice_from_v(struct SN_env * z, symbol * p); +extern int slice_del(struct SN_env * z); -extern int insert_s(struct SN_env * z, int bra, int ket, int s_size, symbol * s); -extern int insert_v(struct SN_env * z, int bra, int ket, symbol * p); +extern int insert_s(struct SN_env * z, int bra, int ket, int s_size, symbol * s); +extern int insert_v(struct SN_env * z, int bra, int ket, symbol * p); -extern symbol * slice_to(struct SN_env * z, symbol * p); -extern symbol * assign_to(struct SN_env * z, symbol * p); +extern symbol *slice_to(struct SN_env * z, symbol * p); +extern symbol *assign_to(struct SN_env * z, symbol * p); extern void debug(struct SN_env * z, int number, int line_count); - diff --git a/contrib/tsearch2/snowball/russian_stem.c b/contrib/tsearch2/snowball/russian_stem.c index b9b453da86..213e88f7b9 100644 --- a/contrib/tsearch2/snowball/russian_stem.c +++ b/contrib/tsearch2/snowball/russian_stem.c @@ -3,699 +3,924 @@ #include "header.h" -extern int russian_KOI8_R_stem(struct SN_env * z); -static int r_tidy_up(struct SN_env * z); -static int r_derivational(struct SN_env * z); -static int r_noun(struct SN_env * z); -static int r_verb(struct SN_env * z); -static int r_reflexive(struct SN_env * z); -static int r_adjectival(struct SN_env * z); -static int r_adjective(struct SN_env * z); -static int r_perfective_gerund(struct SN_env * z); -static int r_R2(struct SN_env * z); -static int r_mark_regions(struct SN_env * z); +extern int russian_KOI8_R_stem(struct SN_env * z); +static int r_tidy_up(struct SN_env * z); +static int r_derivational(struct SN_env * z); +static int r_noun(struct SN_env * z); +static int r_verb(struct SN_env * z); +static int r_reflexive(struct SN_env * z); +static int r_adjectival(struct SN_env * z); +static int r_adjective(struct SN_env * z); +static int r_perfective_gerund(struct SN_env * z); +static int r_R2(struct SN_env * z); +static int r_mark_regions(struct SN_env * z); -extern struct SN_env * russian_KOI8_R_create_env(void); +extern struct SN_env *russian_KOI8_R_create_env(void); extern void russian_KOI8_R_close_env(struct SN_env * z); -static symbol s_0_0[3] = { 0xD7, 0xDB, 0xC9 }; -static symbol s_0_1[4] = { 0xC9, 0xD7, 0xDB, 0xC9 }; -static symbol s_0_2[4] = { 0xD9, 0xD7, 0xDB, 0xC9 }; -static symbol s_0_3[1] = { 0xD7 }; -static symbol s_0_4[2] = { 0xC9, 0xD7 }; -static symbol s_0_5[2] = { 0xD9, 0xD7 }; -static symbol s_0_6[5] = { 0xD7, 0xDB, 0xC9, 0xD3, 0xD8 }; -static symbol s_0_7[6] = { 0xC9, 0xD7, 0xDB, 0xC9, 0xD3, 0xD8 }; -static symbol s_0_8[6] = { 0xD9, 0xD7, 0xDB, 0xC9, 0xD3, 0xD8 }; +static symbol s_0_0[3] = {0xD7, 0xDB, 0xC9}; +static symbol s_0_1[4] = {0xC9, 0xD7, 0xDB, 0xC9}; +static symbol s_0_2[4] = {0xD9, 0xD7, 0xDB, 0xC9}; +static symbol s_0_3[1] = {0xD7}; +static symbol s_0_4[2] = {0xC9, 0xD7}; +static symbol s_0_5[2] = {0xD9, 0xD7}; +static symbol s_0_6[5] = {0xD7, 0xDB, 0xC9, 0xD3, 0xD8}; +static symbol s_0_7[6] = {0xC9, 0xD7, 0xDB, 0xC9, 0xD3, 0xD8}; +static symbol s_0_8[6] = {0xD9, 0xD7, 0xDB, 0xC9, 0xD3, 0xD8}; static struct among a_0[9] = { -/* 0 */ { 3, s_0_0, -1, 1, 0}, -/* 1 */ { 4, s_0_1, 0, 2, 0}, -/* 2 */ { 4, s_0_2, 0, 2, 0}, -/* 3 */ { 1, s_0_3, -1, 1, 0}, -/* 4 */ { 2, s_0_4, 3, 2, 0}, -/* 5 */ { 2, s_0_5, 3, 2, 0}, -/* 6 */ { 5, s_0_6, -1, 1, 0}, -/* 7 */ { 6, s_0_7, 6, 2, 0}, -/* 8 */ { 6, s_0_8, 6, 2, 0} + /* 0 */ {3, s_0_0, -1, 1, 0}, + /* 1 */ {4, s_0_1, 0, 2, 0}, + /* 2 */ {4, s_0_2, 0, 2, 0}, + /* 3 */ {1, s_0_3, -1, 1, 0}, + /* 4 */ {2, s_0_4, 3, 2, 0}, + /* 5 */ {2, s_0_5, 3, 2, 0}, + /* 6 */ {5, s_0_6, -1, 1, 0}, + /* 7 */ {6, s_0_7, 6, 2, 0}, + /* 8 */ {6, s_0_8, 6, 2, 0} }; -static symbol s_1_0[2] = { 0xC0, 0xC0 }; -static symbol s_1_1[2] = { 0xC5, 0xC0 }; -static symbol s_1_2[2] = { 0xCF, 0xC0 }; -static symbol s_1_3[2] = { 0xD5, 0xC0 }; -static symbol s_1_4[2] = { 0xC5, 0xC5 }; -static symbol s_1_5[2] = { 0xC9, 0xC5 }; -static symbol s_1_6[2] = { 0xCF, 0xC5 }; -static symbol s_1_7[2] = { 0xD9, 0xC5 }; -static symbol s_1_8[2] = { 0xC9, 0xC8 }; -static symbol s_1_9[2] = { 0xD9, 0xC8 }; -static symbol s_1_10[3] = { 0xC9, 0xCD, 0xC9 }; -static symbol s_1_11[3] = { 0xD9, 0xCD, 0xC9 }; -static symbol s_1_12[2] = { 0xC5, 0xCA }; -static symbol s_1_13[2] = { 0xC9, 0xCA }; -static symbol s_1_14[2] = { 0xCF, 0xCA }; -static symbol s_1_15[2] = { 0xD9, 0xCA }; -static symbol s_1_16[2] = { 0xC5, 0xCD }; -static symbol s_1_17[2] = { 0xC9, 0xCD }; -static symbol s_1_18[2] = { 0xCF, 0xCD }; -static symbol s_1_19[2] = { 0xD9, 0xCD }; -static symbol s_1_20[3] = { 0xC5, 0xC7, 0xCF }; -static symbol s_1_21[3] = { 0xCF, 0xC7, 0xCF }; -static symbol s_1_22[2] = { 0xC1, 0xD1 }; -static symbol s_1_23[2] = { 0xD1, 0xD1 }; -static symbol s_1_24[3] = { 0xC5, 0xCD, 0xD5 }; -static symbol s_1_25[3] = { 0xCF, 0xCD, 0xD5 }; +static symbol s_1_0[2] = {0xC0, 0xC0}; +static symbol s_1_1[2] = {0xC5, 0xC0}; +static symbol s_1_2[2] = {0xCF, 0xC0}; +static symbol s_1_3[2] = {0xD5, 0xC0}; +static symbol s_1_4[2] = {0xC5, 0xC5}; +static symbol s_1_5[2] = {0xC9, 0xC5}; +static symbol s_1_6[2] = {0xCF, 0xC5}; +static symbol s_1_7[2] = {0xD9, 0xC5}; +static symbol s_1_8[2] = {0xC9, 0xC8}; +static symbol s_1_9[2] = {0xD9, 0xC8}; +static symbol s_1_10[3] = {0xC9, 0xCD, 0xC9}; +static symbol s_1_11[3] = {0xD9, 0xCD, 0xC9}; +static symbol s_1_12[2] = {0xC5, 0xCA}; +static symbol s_1_13[2] = {0xC9, 0xCA}; +static symbol s_1_14[2] = {0xCF, 0xCA}; +static symbol s_1_15[2] = {0xD9, 0xCA}; +static symbol s_1_16[2] = {0xC5, 0xCD}; +static symbol s_1_17[2] = {0xC9, 0xCD}; +static symbol s_1_18[2] = {0xCF, 0xCD}; +static symbol s_1_19[2] = {0xD9, 0xCD}; +static symbol s_1_20[3] = {0xC5, 0xC7, 0xCF}; +static symbol s_1_21[3] = {0xCF, 0xC7, 0xCF}; +static symbol s_1_22[2] = {0xC1, 0xD1}; +static symbol s_1_23[2] = {0xD1, 0xD1}; +static symbol s_1_24[3] = {0xC5, 0xCD, 0xD5}; +static symbol s_1_25[3] = {0xCF, 0xCD, 0xD5}; static struct among a_1[26] = { -/* 0 */ { 2, s_1_0, -1, 1, 0}, -/* 1 */ { 2, s_1_1, -1, 1, 0}, -/* 2 */ { 2, s_1_2, -1, 1, 0}, -/* 3 */ { 2, s_1_3, -1, 1, 0}, -/* 4 */ { 2, s_1_4, -1, 1, 0}, -/* 5 */ { 2, s_1_5, -1, 1, 0}, -/* 6 */ { 2, s_1_6, -1, 1, 0}, -/* 7 */ { 2, s_1_7, -1, 1, 0}, -/* 8 */ { 2, s_1_8, -1, 1, 0}, -/* 9 */ { 2, s_1_9, -1, 1, 0}, -/* 10 */ { 3, s_1_10, -1, 1, 0}, -/* 11 */ { 3, s_1_11, -1, 1, 0}, -/* 12 */ { 2, s_1_12, -1, 1, 0}, -/* 13 */ { 2, s_1_13, -1, 1, 0}, -/* 14 */ { 2, s_1_14, -1, 1, 0}, -/* 15 */ { 2, s_1_15, -1, 1, 0}, -/* 16 */ { 2, s_1_16, -1, 1, 0}, -/* 17 */ { 2, s_1_17, -1, 1, 0}, -/* 18 */ { 2, s_1_18, -1, 1, 0}, -/* 19 */ { 2, s_1_19, -1, 1, 0}, -/* 20 */ { 3, s_1_20, -1, 1, 0}, -/* 21 */ { 3, s_1_21, -1, 1, 0}, -/* 22 */ { 2, s_1_22, -1, 1, 0}, -/* 23 */ { 2, s_1_23, -1, 1, 0}, -/* 24 */ { 3, s_1_24, -1, 1, 0}, -/* 25 */ { 3, s_1_25, -1, 1, 0} + /* 0 */ {2, s_1_0, -1, 1, 0}, + /* 1 */ {2, s_1_1, -1, 1, 0}, + /* 2 */ {2, s_1_2, -1, 1, 0}, + /* 3 */ {2, s_1_3, -1, 1, 0}, + /* 4 */ {2, s_1_4, -1, 1, 0}, + /* 5 */ {2, s_1_5, -1, 1, 0}, + /* 6 */ {2, s_1_6, -1, 1, 0}, + /* 7 */ {2, s_1_7, -1, 1, 0}, + /* 8 */ {2, s_1_8, -1, 1, 0}, + /* 9 */ {2, s_1_9, -1, 1, 0}, + /* 10 */ {3, s_1_10, -1, 1, 0}, + /* 11 */ {3, s_1_11, -1, 1, 0}, + /* 12 */ {2, s_1_12, -1, 1, 0}, + /* 13 */ {2, s_1_13, -1, 1, 0}, + /* 14 */ {2, s_1_14, -1, 1, 0}, + /* 15 */ {2, s_1_15, -1, 1, 0}, + /* 16 */ {2, s_1_16, -1, 1, 0}, + /* 17 */ {2, s_1_17, -1, 1, 0}, + /* 18 */ {2, s_1_18, -1, 1, 0}, + /* 19 */ {2, s_1_19, -1, 1, 0}, + /* 20 */ {3, s_1_20, -1, 1, 0}, + /* 21 */ {3, s_1_21, -1, 1, 0}, + /* 22 */ {2, s_1_22, -1, 1, 0}, + /* 23 */ {2, s_1_23, -1, 1, 0}, + /* 24 */ {3, s_1_24, -1, 1, 0}, + /* 25 */ {3, s_1_25, -1, 1, 0} }; -static symbol s_2_0[2] = { 0xC5, 0xCD }; -static symbol s_2_1[2] = { 0xCE, 0xCE }; -static symbol s_2_2[2] = { 0xD7, 0xDB }; -static symbol s_2_3[3] = { 0xC9, 0xD7, 0xDB }; -static symbol s_2_4[3] = { 0xD9, 0xD7, 0xDB }; -static symbol s_2_5[1] = { 0xDD }; -static symbol s_2_6[2] = { 0xC0, 0xDD }; -static symbol s_2_7[3] = { 0xD5, 0xC0, 0xDD }; +static symbol s_2_0[2] = {0xC5, 0xCD}; +static symbol s_2_1[2] = {0xCE, 0xCE}; +static symbol s_2_2[2] = {0xD7, 0xDB}; +static symbol s_2_3[3] = {0xC9, 0xD7, 0xDB}; +static symbol s_2_4[3] = {0xD9, 0xD7, 0xDB}; +static symbol s_2_5[1] = {0xDD}; +static symbol s_2_6[2] = {0xC0, 0xDD}; +static symbol s_2_7[3] = {0xD5, 0xC0, 0xDD}; static struct among a_2[8] = { -/* 0 */ { 2, s_2_0, -1, 1, 0}, -/* 1 */ { 2, s_2_1, -1, 1, 0}, -/* 2 */ { 2, s_2_2, -1, 1, 0}, -/* 3 */ { 3, s_2_3, 2, 2, 0}, -/* 4 */ { 3, s_2_4, 2, 2, 0}, -/* 5 */ { 1, s_2_5, -1, 1, 0}, -/* 6 */ { 2, s_2_6, 5, 1, 0}, -/* 7 */ { 3, s_2_7, 6, 2, 0} + /* 0 */ {2, s_2_0, -1, 1, 0}, + /* 1 */ {2, s_2_1, -1, 1, 0}, + /* 2 */ {2, s_2_2, -1, 1, 0}, + /* 3 */ {3, s_2_3, 2, 2, 0}, + /* 4 */ {3, s_2_4, 2, 2, 0}, + /* 5 */ {1, s_2_5, -1, 1, 0}, + /* 6 */ {2, s_2_6, 5, 1, 0}, + /* 7 */ {3, s_2_7, 6, 2, 0} }; -static symbol s_3_0[2] = { 0xD3, 0xD1 }; -static symbol s_3_1[2] = { 0xD3, 0xD8 }; +static symbol s_3_0[2] = {0xD3, 0xD1}; +static symbol s_3_1[2] = {0xD3, 0xD8}; static struct among a_3[2] = { -/* 0 */ { 2, s_3_0, -1, 1, 0}, -/* 1 */ { 2, s_3_1, -1, 1, 0} + /* 0 */ {2, s_3_0, -1, 1, 0}, + /* 1 */ {2, s_3_1, -1, 1, 0} }; -static symbol s_4_0[1] = { 0xC0 }; -static symbol s_4_1[2] = { 0xD5, 0xC0 }; -static symbol s_4_2[2] = { 0xCC, 0xC1 }; -static symbol s_4_3[3] = { 0xC9, 0xCC, 0xC1 }; -static symbol s_4_4[3] = { 0xD9, 0xCC, 0xC1 }; -static symbol s_4_5[2] = { 0xCE, 0xC1 }; -static symbol s_4_6[3] = { 0xC5, 0xCE, 0xC1 }; -static symbol s_4_7[3] = { 0xC5, 0xD4, 0xC5 }; -static symbol s_4_8[3] = { 0xC9, 0xD4, 0xC5 }; -static symbol s_4_9[3] = { 0xCA, 0xD4, 0xC5 }; -static symbol s_4_10[4] = { 0xC5, 0xCA, 0xD4, 0xC5 }; -static symbol s_4_11[4] = { 0xD5, 0xCA, 0xD4, 0xC5 }; -static symbol s_4_12[2] = { 0xCC, 0xC9 }; -static symbol s_4_13[3] = { 0xC9, 0xCC, 0xC9 }; -static symbol s_4_14[3] = { 0xD9, 0xCC, 0xC9 }; -static symbol s_4_15[1] = { 0xCA }; -static symbol s_4_16[2] = { 0xC5, 0xCA }; -static symbol s_4_17[2] = { 0xD5, 0xCA }; -static symbol s_4_18[1] = { 0xCC }; -static symbol s_4_19[2] = { 0xC9, 0xCC }; -static symbol s_4_20[2] = { 0xD9, 0xCC }; -static symbol s_4_21[2] = { 0xC5, 0xCD }; -static symbol s_4_22[2] = { 0xC9, 0xCD }; -static symbol s_4_23[2] = { 0xD9, 0xCD }; -static symbol s_4_24[1] = { 0xCE }; -static symbol s_4_25[2] = { 0xC5, 0xCE }; -static symbol s_4_26[2] = { 0xCC, 0xCF }; -static symbol s_4_27[3] = { 0xC9, 0xCC, 0xCF }; -static symbol s_4_28[3] = { 0xD9, 0xCC, 0xCF }; -static symbol s_4_29[2] = { 0xCE, 0xCF }; -static symbol s_4_30[3] = { 0xC5, 0xCE, 0xCF }; -static symbol s_4_31[3] = { 0xCE, 0xCE, 0xCF }; -static symbol s_4_32[2] = { 0xC0, 0xD4 }; -static symbol s_4_33[3] = { 0xD5, 0xC0, 0xD4 }; -static symbol s_4_34[2] = { 0xC5, 0xD4 }; -static symbol s_4_35[3] = { 0xD5, 0xC5, 0xD4 }; -static symbol s_4_36[2] = { 0xC9, 0xD4 }; -static symbol s_4_37[2] = { 0xD1, 0xD4 }; -static symbol s_4_38[2] = { 0xD9, 0xD4 }; -static symbol s_4_39[2] = { 0xD4, 0xD8 }; -static symbol s_4_40[3] = { 0xC9, 0xD4, 0xD8 }; -static symbol s_4_41[3] = { 0xD9, 0xD4, 0xD8 }; -static symbol s_4_42[3] = { 0xC5, 0xDB, 0xD8 }; -static symbol s_4_43[3] = { 0xC9, 0xDB, 0xD8 }; -static symbol s_4_44[2] = { 0xCE, 0xD9 }; -static symbol s_4_45[3] = { 0xC5, 0xCE, 0xD9 }; +static symbol s_4_0[1] = {0xC0}; +static symbol s_4_1[2] = {0xD5, 0xC0}; +static symbol s_4_2[2] = {0xCC, 0xC1}; +static symbol s_4_3[3] = {0xC9, 0xCC, 0xC1}; +static symbol s_4_4[3] = {0xD9, 0xCC, 0xC1}; +static symbol s_4_5[2] = {0xCE, 0xC1}; +static symbol s_4_6[3] = {0xC5, 0xCE, 0xC1}; +static symbol s_4_7[3] = {0xC5, 0xD4, 0xC5}; +static symbol s_4_8[3] = {0xC9, 0xD4, 0xC5}; +static symbol s_4_9[3] = {0xCA, 0xD4, 0xC5}; +static symbol s_4_10[4] = {0xC5, 0xCA, 0xD4, 0xC5}; +static symbol s_4_11[4] = {0xD5, 0xCA, 0xD4, 0xC5}; +static symbol s_4_12[2] = {0xCC, 0xC9}; +static symbol s_4_13[3] = {0xC9, 0xCC, 0xC9}; +static symbol s_4_14[3] = {0xD9, 0xCC, 0xC9}; +static symbol s_4_15[1] = {0xCA}; +static symbol s_4_16[2] = {0xC5, 0xCA}; +static symbol s_4_17[2] = {0xD5, 0xCA}; +static symbol s_4_18[1] = {0xCC}; +static symbol s_4_19[2] = {0xC9, 0xCC}; +static symbol s_4_20[2] = {0xD9, 0xCC}; +static symbol s_4_21[2] = {0xC5, 0xCD}; +static symbol s_4_22[2] = {0xC9, 0xCD}; +static symbol s_4_23[2] = {0xD9, 0xCD}; +static symbol s_4_24[1] = {0xCE}; +static symbol s_4_25[2] = {0xC5, 0xCE}; +static symbol s_4_26[2] = {0xCC, 0xCF}; +static symbol s_4_27[3] = {0xC9, 0xCC, 0xCF}; +static symbol s_4_28[3] = {0xD9, 0xCC, 0xCF}; +static symbol s_4_29[2] = {0xCE, 0xCF}; +static symbol s_4_30[3] = {0xC5, 0xCE, 0xCF}; +static symbol s_4_31[3] = {0xCE, 0xCE, 0xCF}; +static symbol s_4_32[2] = {0xC0, 0xD4}; +static symbol s_4_33[3] = {0xD5, 0xC0, 0xD4}; +static symbol s_4_34[2] = {0xC5, 0xD4}; +static symbol s_4_35[3] = {0xD5, 0xC5, 0xD4}; +static symbol s_4_36[2] = {0xC9, 0xD4}; +static symbol s_4_37[2] = {0xD1, 0xD4}; +static symbol s_4_38[2] = {0xD9, 0xD4}; +static symbol s_4_39[2] = {0xD4, 0xD8}; +static symbol s_4_40[3] = {0xC9, 0xD4, 0xD8}; +static symbol s_4_41[3] = {0xD9, 0xD4, 0xD8}; +static symbol s_4_42[3] = {0xC5, 0xDB, 0xD8}; +static symbol s_4_43[3] = {0xC9, 0xDB, 0xD8}; +static symbol s_4_44[2] = {0xCE, 0xD9}; +static symbol s_4_45[3] = {0xC5, 0xCE, 0xD9}; static struct among a_4[46] = { -/* 0 */ { 1, s_4_0, -1, 2, 0}, -/* 1 */ { 2, s_4_1, 0, 2, 0}, -/* 2 */ { 2, s_4_2, -1, 1, 0}, -/* 3 */ { 3, s_4_3, 2, 2, 0}, -/* 4 */ { 3, s_4_4, 2, 2, 0}, -/* 5 */ { 2, s_4_5, -1, 1, 0}, -/* 6 */ { 3, s_4_6, 5, 2, 0}, -/* 7 */ { 3, s_4_7, -1, 1, 0}, -/* 8 */ { 3, s_4_8, -1, 2, 0}, -/* 9 */ { 3, s_4_9, -1, 1, 0}, -/* 10 */ { 4, s_4_10, 9, 2, 0}, -/* 11 */ { 4, s_4_11, 9, 2, 0}, -/* 12 */ { 2, s_4_12, -1, 1, 0}, -/* 13 */ { 3, s_4_13, 12, 2, 0}, -/* 14 */ { 3, s_4_14, 12, 2, 0}, -/* 15 */ { 1, s_4_15, -1, 1, 0}, -/* 16 */ { 2, s_4_16, 15, 2, 0}, -/* 17 */ { 2, s_4_17, 15, 2, 0}, -/* 18 */ { 1, s_4_18, -1, 1, 0}, -/* 19 */ { 2, s_4_19, 18, 2, 0}, -/* 20 */ { 2, s_4_20, 18, 2, 0}, -/* 21 */ { 2, s_4_21, -1, 1, 0}, -/* 22 */ { 2, s_4_22, -1, 2, 0}, -/* 23 */ { 2, s_4_23, -1, 2, 0}, -/* 24 */ { 1, s_4_24, -1, 1, 0}, -/* 25 */ { 2, s_4_25, 24, 2, 0}, -/* 26 */ { 2, s_4_26, -1, 1, 0}, -/* 27 */ { 3, s_4_27, 26, 2, 0}, -/* 28 */ { 3, s_4_28, 26, 2, 0}, -/* 29 */ { 2, s_4_29, -1, 1, 0}, -/* 30 */ { 3, s_4_30, 29, 2, 0}, -/* 31 */ { 3, s_4_31, 29, 1, 0}, -/* 32 */ { 2, s_4_32, -1, 1, 0}, -/* 33 */ { 3, s_4_33, 32, 2, 0}, -/* 34 */ { 2, s_4_34, -1, 1, 0}, -/* 35 */ { 3, s_4_35, 34, 2, 0}, -/* 36 */ { 2, s_4_36, -1, 2, 0}, -/* 37 */ { 2, s_4_37, -1, 2, 0}, -/* 38 */ { 2, s_4_38, -1, 2, 0}, -/* 39 */ { 2, s_4_39, -1, 1, 0}, -/* 40 */ { 3, s_4_40, 39, 2, 0}, -/* 41 */ { 3, s_4_41, 39, 2, 0}, -/* 42 */ { 3, s_4_42, -1, 1, 0}, -/* 43 */ { 3, s_4_43, -1, 2, 0}, -/* 44 */ { 2, s_4_44, -1, 1, 0}, -/* 45 */ { 3, s_4_45, 44, 2, 0} + /* 0 */ {1, s_4_0, -1, 2, 0}, + /* 1 */ {2, s_4_1, 0, 2, 0}, + /* 2 */ {2, s_4_2, -1, 1, 0}, + /* 3 */ {3, s_4_3, 2, 2, 0}, + /* 4 */ {3, s_4_4, 2, 2, 0}, + /* 5 */ {2, s_4_5, -1, 1, 0}, + /* 6 */ {3, s_4_6, 5, 2, 0}, + /* 7 */ {3, s_4_7, -1, 1, 0}, + /* 8 */ {3, s_4_8, -1, 2, 0}, + /* 9 */ {3, s_4_9, -1, 1, 0}, + /* 10 */ {4, s_4_10, 9, 2, 0}, + /* 11 */ {4, s_4_11, 9, 2, 0}, + /* 12 */ {2, s_4_12, -1, 1, 0}, + /* 13 */ {3, s_4_13, 12, 2, 0}, + /* 14 */ {3, s_4_14, 12, 2, 0}, + /* 15 */ {1, s_4_15, -1, 1, 0}, + /* 16 */ {2, s_4_16, 15, 2, 0}, + /* 17 */ {2, s_4_17, 15, 2, 0}, + /* 18 */ {1, s_4_18, -1, 1, 0}, + /* 19 */ {2, s_4_19, 18, 2, 0}, + /* 20 */ {2, s_4_20, 18, 2, 0}, + /* 21 */ {2, s_4_21, -1, 1, 0}, + /* 22 */ {2, s_4_22, -1, 2, 0}, + /* 23 */ {2, s_4_23, -1, 2, 0}, + /* 24 */ {1, s_4_24, -1, 1, 0}, + /* 25 */ {2, s_4_25, 24, 2, 0}, + /* 26 */ {2, s_4_26, -1, 1, 0}, + /* 27 */ {3, s_4_27, 26, 2, 0}, + /* 28 */ {3, s_4_28, 26, 2, 0}, + /* 29 */ {2, s_4_29, -1, 1, 0}, + /* 30 */ {3, s_4_30, 29, 2, 0}, + /* 31 */ {3, s_4_31, 29, 1, 0}, + /* 32 */ {2, s_4_32, -1, 1, 0}, + /* 33 */ {3, s_4_33, 32, 2, 0}, + /* 34 */ {2, s_4_34, -1, 1, 0}, + /* 35 */ {3, s_4_35, 34, 2, 0}, + /* 36 */ {2, s_4_36, -1, 2, 0}, + /* 37 */ {2, s_4_37, -1, 2, 0}, + /* 38 */ {2, s_4_38, -1, 2, 0}, + /* 39 */ {2, s_4_39, -1, 1, 0}, + /* 40 */ {3, s_4_40, 39, 2, 0}, + /* 41 */ {3, s_4_41, 39, 2, 0}, + /* 42 */ {3, s_4_42, -1, 1, 0}, + /* 43 */ {3, s_4_43, -1, 2, 0}, + /* 44 */ {2, s_4_44, -1, 1, 0}, + /* 45 */ {3, s_4_45, 44, 2, 0} }; -static symbol s_5_0[1] = { 0xC0 }; -static symbol s_5_1[2] = { 0xC9, 0xC0 }; -static symbol s_5_2[2] = { 0xD8, 0xC0 }; -static symbol s_5_3[1] = { 0xC1 }; -static symbol s_5_4[1] = { 0xC5 }; -static symbol s_5_5[2] = { 0xC9, 0xC5 }; -static symbol s_5_6[2] = { 0xD8, 0xC5 }; -static symbol s_5_7[2] = { 0xC1, 0xC8 }; -static symbol s_5_8[2] = { 0xD1, 0xC8 }; -static symbol s_5_9[3] = { 0xC9, 0xD1, 0xC8 }; -static symbol s_5_10[1] = { 0xC9 }; -static symbol s_5_11[2] = { 0xC5, 0xC9 }; -static symbol s_5_12[2] = { 0xC9, 0xC9 }; -static symbol s_5_13[3] = { 0xC1, 0xCD, 0xC9 }; -static symbol s_5_14[3] = { 0xD1, 0xCD, 0xC9 }; -static symbol s_5_15[4] = { 0xC9, 0xD1, 0xCD, 0xC9 }; -static symbol s_5_16[1] = { 0xCA }; -static symbol s_5_17[2] = { 0xC5, 0xCA }; -static symbol s_5_18[3] = { 0xC9, 0xC5, 0xCA }; -static symbol s_5_19[2] = { 0xC9, 0xCA }; -static symbol s_5_20[2] = { 0xCF, 0xCA }; -static symbol s_5_21[2] = { 0xC1, 0xCD }; -static symbol s_5_22[2] = { 0xC5, 0xCD }; -static symbol s_5_23[3] = { 0xC9, 0xC5, 0xCD }; -static symbol s_5_24[2] = { 0xCF, 0xCD }; -static symbol s_5_25[2] = { 0xD1, 0xCD }; -static symbol s_5_26[3] = { 0xC9, 0xD1, 0xCD }; -static symbol s_5_27[1] = { 0xCF }; -static symbol s_5_28[1] = { 0xD1 }; -static symbol s_5_29[2] = { 0xC9, 0xD1 }; -static symbol s_5_30[2] = { 0xD8, 0xD1 }; -static symbol s_5_31[1] = { 0xD5 }; -static symbol s_5_32[2] = { 0xC5, 0xD7 }; -static symbol s_5_33[2] = { 0xCF, 0xD7 }; -static symbol s_5_34[1] = { 0xD8 }; -static symbol s_5_35[1] = { 0xD9 }; +static symbol s_5_0[1] = {0xC0}; +static symbol s_5_1[2] = {0xC9, 0xC0}; +static symbol s_5_2[2] = {0xD8, 0xC0}; +static symbol s_5_3[1] = {0xC1}; +static symbol s_5_4[1] = {0xC5}; +static symbol s_5_5[2] = {0xC9, 0xC5}; +static symbol s_5_6[2] = {0xD8, 0xC5}; +static symbol s_5_7[2] = {0xC1, 0xC8}; +static symbol s_5_8[2] = {0xD1, 0xC8}; +static symbol s_5_9[3] = {0xC9, 0xD1, 0xC8}; +static symbol s_5_10[1] = {0xC9}; +static symbol s_5_11[2] = {0xC5, 0xC9}; +static symbol s_5_12[2] = {0xC9, 0xC9}; +static symbol s_5_13[3] = {0xC1, 0xCD, 0xC9}; +static symbol s_5_14[3] = {0xD1, 0xCD, 0xC9}; +static symbol s_5_15[4] = {0xC9, 0xD1, 0xCD, 0xC9}; +static symbol s_5_16[1] = {0xCA}; +static symbol s_5_17[2] = {0xC5, 0xCA}; +static symbol s_5_18[3] = {0xC9, 0xC5, 0xCA}; +static symbol s_5_19[2] = {0xC9, 0xCA}; +static symbol s_5_20[2] = {0xCF, 0xCA}; +static symbol s_5_21[2] = {0xC1, 0xCD}; +static symbol s_5_22[2] = {0xC5, 0xCD}; +static symbol s_5_23[3] = {0xC9, 0xC5, 0xCD}; +static symbol s_5_24[2] = {0xCF, 0xCD}; +static symbol s_5_25[2] = {0xD1, 0xCD}; +static symbol s_5_26[3] = {0xC9, 0xD1, 0xCD}; +static symbol s_5_27[1] = {0xCF}; +static symbol s_5_28[1] = {0xD1}; +static symbol s_5_29[2] = {0xC9, 0xD1}; +static symbol s_5_30[2] = {0xD8, 0xD1}; +static symbol s_5_31[1] = {0xD5}; +static symbol s_5_32[2] = {0xC5, 0xD7}; +static symbol s_5_33[2] = {0xCF, 0xD7}; +static symbol s_5_34[1] = {0xD8}; +static symbol s_5_35[1] = {0xD9}; static struct among a_5[36] = { -/* 0 */ { 1, s_5_0, -1, 1, 0}, -/* 1 */ { 2, s_5_1, 0, 1, 0}, -/* 2 */ { 2, s_5_2, 0, 1, 0}, -/* 3 */ { 1, s_5_3, -1, 1, 0}, -/* 4 */ { 1, s_5_4, -1, 1, 0}, -/* 5 */ { 2, s_5_5, 4, 1, 0}, -/* 6 */ { 2, s_5_6, 4, 1, 0}, -/* 7 */ { 2, s_5_7, -1, 1, 0}, -/* 8 */ { 2, s_5_8, -1, 1, 0}, -/* 9 */ { 3, s_5_9, 8, 1, 0}, -/* 10 */ { 1, s_5_10, -1, 1, 0}, -/* 11 */ { 2, s_5_11, 10, 1, 0}, -/* 12 */ { 2, s_5_12, 10, 1, 0}, -/* 13 */ { 3, s_5_13, 10, 1, 0}, -/* 14 */ { 3, s_5_14, 10, 1, 0}, -/* 15 */ { 4, s_5_15, 14, 1, 0}, -/* 16 */ { 1, s_5_16, -1, 1, 0}, -/* 17 */ { 2, s_5_17, 16, 1, 0}, -/* 18 */ { 3, s_5_18, 17, 1, 0}, -/* 19 */ { 2, s_5_19, 16, 1, 0}, -/* 20 */ { 2, s_5_20, 16, 1, 0}, -/* 21 */ { 2, s_5_21, -1, 1, 0}, -/* 22 */ { 2, s_5_22, -1, 1, 0}, -/* 23 */ { 3, s_5_23, 22, 1, 0}, -/* 24 */ { 2, s_5_24, -1, 1, 0}, -/* 25 */ { 2, s_5_25, -1, 1, 0}, -/* 26 */ { 3, s_5_26, 25, 1, 0}, -/* 27 */ { 1, s_5_27, -1, 1, 0}, -/* 28 */ { 1, s_5_28, -1, 1, 0}, -/* 29 */ { 2, s_5_29, 28, 1, 0}, -/* 30 */ { 2, s_5_30, 28, 1, 0}, -/* 31 */ { 1, s_5_31, -1, 1, 0}, -/* 32 */ { 2, s_5_32, -1, 1, 0}, -/* 33 */ { 2, s_5_33, -1, 1, 0}, -/* 34 */ { 1, s_5_34, -1, 1, 0}, -/* 35 */ { 1, s_5_35, -1, 1, 0} + /* 0 */ {1, s_5_0, -1, 1, 0}, + /* 1 */ {2, s_5_1, 0, 1, 0}, + /* 2 */ {2, s_5_2, 0, 1, 0}, + /* 3 */ {1, s_5_3, -1, 1, 0}, + /* 4 */ {1, s_5_4, -1, 1, 0}, + /* 5 */ {2, s_5_5, 4, 1, 0}, + /* 6 */ {2, s_5_6, 4, 1, 0}, + /* 7 */ {2, s_5_7, -1, 1, 0}, + /* 8 */ {2, s_5_8, -1, 1, 0}, + /* 9 */ {3, s_5_9, 8, 1, 0}, + /* 10 */ {1, s_5_10, -1, 1, 0}, + /* 11 */ {2, s_5_11, 10, 1, 0}, + /* 12 */ {2, s_5_12, 10, 1, 0}, + /* 13 */ {3, s_5_13, 10, 1, 0}, + /* 14 */ {3, s_5_14, 10, 1, 0}, + /* 15 */ {4, s_5_15, 14, 1, 0}, + /* 16 */ {1, s_5_16, -1, 1, 0}, + /* 17 */ {2, s_5_17, 16, 1, 0}, + /* 18 */ {3, s_5_18, 17, 1, 0}, + /* 19 */ {2, s_5_19, 16, 1, 0}, + /* 20 */ {2, s_5_20, 16, 1, 0}, + /* 21 */ {2, s_5_21, -1, 1, 0}, + /* 22 */ {2, s_5_22, -1, 1, 0}, + /* 23 */ {3, s_5_23, 22, 1, 0}, + /* 24 */ {2, s_5_24, -1, 1, 0}, + /* 25 */ {2, s_5_25, -1, 1, 0}, + /* 26 */ {3, s_5_26, 25, 1, 0}, + /* 27 */ {1, s_5_27, -1, 1, 0}, + /* 28 */ {1, s_5_28, -1, 1, 0}, + /* 29 */ {2, s_5_29, 28, 1, 0}, + /* 30 */ {2, s_5_30, 28, 1, 0}, + /* 31 */ {1, s_5_31, -1, 1, 0}, + /* 32 */ {2, s_5_32, -1, 1, 0}, + /* 33 */ {2, s_5_33, -1, 1, 0}, + /* 34 */ {1, s_5_34, -1, 1, 0}, + /* 35 */ {1, s_5_35, -1, 1, 0} }; -static symbol s_6_0[3] = { 0xCF, 0xD3, 0xD4 }; -static symbol s_6_1[4] = { 0xCF, 0xD3, 0xD4, 0xD8 }; +static symbol s_6_0[3] = {0xCF, 0xD3, 0xD4}; +static symbol s_6_1[4] = {0xCF, 0xD3, 0xD4, 0xD8}; static struct among a_6[2] = { -/* 0 */ { 3, s_6_0, -1, 1, 0}, -/* 1 */ { 4, s_6_1, -1, 1, 0} + /* 0 */ {3, s_6_0, -1, 1, 0}, + /* 1 */ {4, s_6_1, -1, 1, 0} }; -static symbol s_7_0[4] = { 0xC5, 0xCA, 0xDB, 0xC5 }; -static symbol s_7_1[1] = { 0xCE }; -static symbol s_7_2[1] = { 0xD8 }; -static symbol s_7_3[3] = { 0xC5, 0xCA, 0xDB }; +static symbol s_7_0[4] = {0xC5, 0xCA, 0xDB, 0xC5}; +static symbol s_7_1[1] = {0xCE}; +static symbol s_7_2[1] = {0xD8}; +static symbol s_7_3[3] = {0xC5, 0xCA, 0xDB}; static struct among a_7[4] = { -/* 0 */ { 4, s_7_0, -1, 1, 0}, -/* 1 */ { 1, s_7_1, -1, 2, 0}, -/* 2 */ { 1, s_7_2, -1, 3, 0}, -/* 3 */ { 3, s_7_3, -1, 1, 0} + /* 0 */ {4, s_7_0, -1, 1, 0}, + /* 1 */ {1, s_7_1, -1, 2, 0}, + /* 2 */ {1, s_7_2, -1, 3, 0}, + /* 3 */ {3, s_7_3, -1, 1, 0} }; -static unsigned char g_v[] = { 35, 130, 34, 18 }; +static unsigned char g_v[] = {35, 130, 34, 18}; -static symbol s_0[] = { 0xC1 }; -static symbol s_1[] = { 0xD1 }; -static symbol s_2[] = { 0xC1 }; -static symbol s_3[] = { 0xD1 }; -static symbol s_4[] = { 0xC1 }; -static symbol s_5[] = { 0xD1 }; -static symbol s_6[] = { 0xCE }; -static symbol s_7[] = { 0xCE }; -static symbol s_8[] = { 0xCE }; -static symbol s_9[] = { 0xC9 }; +static symbol s_0[] = {0xC1}; +static symbol s_1[] = {0xD1}; +static symbol s_2[] = {0xC1}; +static symbol s_3[] = {0xD1}; +static symbol s_4[] = {0xC1}; +static symbol s_5[] = {0xD1}; +static symbol s_6[] = {0xCE}; +static symbol s_7[] = {0xCE}; +static symbol s_8[] = {0xCE}; +static symbol s_9[] = {0xC9}; -static int r_mark_regions(struct SN_env * z) { - z->I[0] = z->l; - z->I[1] = z->l; - { int c = z->c; /* do, line 63 */ - while(1) { /* gopast, line 64 */ - if (!(in_grouping(z, g_v, 192, 220))) goto lab1; - break; - lab1: - if (z->c >= z->l) goto lab0; - z->c++; /* gopast, line 64 */ - } - z->I[0] = z->c; /* setmark pV, line 64 */ - while(1) { /* gopast, line 64 */ - if (!(out_grouping(z, g_v, 192, 220))) goto lab2; - break; - lab2: - if (z->c >= z->l) goto lab0; - z->c++; /* gopast, line 64 */ - } - while(1) { /* gopast, line 65 */ - if (!(in_grouping(z, g_v, 192, 220))) goto lab3; - break; - lab3: - if (z->c >= z->l) goto lab0; - z->c++; /* gopast, line 65 */ - } - while(1) { /* gopast, line 65 */ - if (!(out_grouping(z, g_v, 192, 220))) goto lab4; - break; - lab4: - if (z->c >= z->l) goto lab0; - z->c++; /* gopast, line 65 */ - } - z->I[1] = z->c; /* setmark p2, line 65 */ - lab0: - z->c = c; - } - return 1; +static int +r_mark_regions(struct SN_env * z) +{ + z->I[0] = z->l; + z->I[1] = z->l; + { + int c = z->c; /* do, line 63 */ + + while (1) + { /* gopast, line 64 */ + if (!(in_grouping(z, g_v, 192, 220))) + goto lab1; + break; + lab1: + if (z->c >= z->l) + goto lab0; + z->c++; /* gopast, line 64 */ + } + z->I[0] = z->c; /* setmark pV, line 64 */ + while (1) + { /* gopast, line 64 */ + if (!(out_grouping(z, g_v, 192, 220))) + goto lab2; + break; + lab2: + if (z->c >= z->l) + goto lab0; + z->c++; /* gopast, line 64 */ + } + while (1) + { /* gopast, line 65 */ + if (!(in_grouping(z, g_v, 192, 220))) + goto lab3; + break; + lab3: + if (z->c >= z->l) + goto lab0; + z->c++; /* gopast, line 65 */ + } + while (1) + { /* gopast, line 65 */ + if (!(out_grouping(z, g_v, 192, 220))) + goto lab4; + break; + lab4: + if (z->c >= z->l) + goto lab0; + z->c++; /* gopast, line 65 */ + } + z->I[1] = z->c; /* setmark p2, line 65 */ +lab0: + z->c = c; + } + return 1; } -static int r_R2(struct SN_env * z) { - if (!(z->I[1] <= z->c)) return 0; - return 1; +static int +r_R2(struct SN_env * z) +{ + if (!(z->I[1] <= z->c)) + return 0; + return 1; } -static int r_perfective_gerund(struct SN_env * z) { - int among_var; - z->ket = z->c; /* [, line 74 */ - among_var = find_among_b(z, a_0, 9); /* substring, line 74 */ - if (!(among_var)) return 0; - z->bra = z->c; /* ], line 74 */ - switch(among_var) { - case 0: return 0; - case 1: - { int m = z->l - z->c; (void) m; /* or, line 78 */ - if (!(eq_s_b(z, 1, s_0))) goto lab1; - goto lab0; - lab1: - z->c = z->l - m; - if (!(eq_s_b(z, 1, s_1))) return 0; - } - lab0: - { int ret; - ret = slice_del(z); /* delete, line 78 */ - if (ret < 0) return ret; - } - break; - case 2: - { int ret; - ret = slice_del(z); /* delete, line 85 */ - if (ret < 0) return ret; - } - break; - } - return 1; +static int +r_perfective_gerund(struct SN_env * z) +{ + int among_var; + + z->ket = z->c; /* [, line 74 */ + among_var = find_among_b(z, a_0, 9); /* substring, line 74 */ + if (!(among_var)) + return 0; + z->bra = z->c; /* ], line 74 */ + switch (among_var) + { + case 0: + return 0; + case 1: + { + int m = z->l - z->c; + + (void) m; /* or, line 78 */ + if (!(eq_s_b(z, 1, s_0))) + goto lab1; + goto lab0; + lab1: + z->c = z->l - m; + if (!(eq_s_b(z, 1, s_1))) + return 0; + } + lab0: + { + int ret; + + ret = slice_del(z); /* delete, line 78 */ + if (ret < 0) + return ret; + } + break; + case 2: + { + int ret; + + ret = slice_del(z); /* delete, line 85 */ + if (ret < 0) + return ret; + } + break; + } + return 1; } -static int r_adjective(struct SN_env * z) { - int among_var; - z->ket = z->c; /* [, line 90 */ - among_var = find_among_b(z, a_1, 26); /* substring, line 90 */ - if (!(among_var)) return 0; - z->bra = z->c; /* ], line 90 */ - switch(among_var) { - case 0: return 0; - case 1: - { int ret; - ret = slice_del(z); /* delete, line 99 */ - if (ret < 0) return ret; - } - break; - } - return 1; +static int +r_adjective(struct SN_env * z) +{ + int among_var; + + z->ket = z->c; /* [, line 90 */ + among_var = find_among_b(z, a_1, 26); /* substring, line 90 */ + if (!(among_var)) + return 0; + z->bra = z->c; /* ], line 90 */ + switch (among_var) + { + case 0: + return 0; + case 1: + { + int ret; + + ret = slice_del(z); /* delete, line 99 */ + if (ret < 0) + return ret; + } + break; + } + return 1; } -static int r_adjectival(struct SN_env * z) { - int among_var; - { int ret = r_adjective(z); - if (ret == 0) return 0; /* call adjective, line 104 */ - if (ret < 0) return ret; - } - { int m = z->l - z->c; (void) m; /* try, line 111 */ - z->ket = z->c; /* [, line 112 */ - among_var = find_among_b(z, a_2, 8); /* substring, line 112 */ - if (!(among_var)) { z->c = z->l - m; goto lab0; } - z->bra = z->c; /* ], line 112 */ - switch(among_var) { - case 0: { z->c = z->l - m; goto lab0; } - case 1: - { int m = z->l - z->c; (void) m; /* or, line 117 */ - if (!(eq_s_b(z, 1, s_2))) goto lab2; - goto lab1; - lab2: - z->c = z->l - m; - if (!(eq_s_b(z, 1, s_3))) { z->c = z->l - m; goto lab0; } - } - lab1: - { int ret; - ret = slice_del(z); /* delete, line 117 */ - if (ret < 0) return ret; - } - break; - case 2: - { int ret; - ret = slice_del(z); /* delete, line 124 */ - if (ret < 0) return ret; - } - break; - } - lab0: - ; - } - return 1; +static int +r_adjectival(struct SN_env * z) +{ + int among_var; + + { + int ret = r_adjective(z); + + if (ret == 0) + return 0; /* call adjective, line 104 */ + if (ret < 0) + return ret; + } + { + int m = z->l - z->c; + + (void) m; /* try, line 111 */ + z->ket = z->c; /* [, line 112 */ + among_var = find_among_b(z, a_2, 8); /* substring, line 112 */ + if (!(among_var)) + { + z->c = z->l - m; + goto lab0; + } + z->bra = z->c; /* ], line 112 */ + switch (among_var) + { + case 0: + { + z->c = z->l - m; + goto lab0; + } + case 1: + { + int m = z->l - z->c; + + (void) m; /* or, line 117 */ + if (!(eq_s_b(z, 1, s_2))) + goto lab2; + goto lab1; + lab2: + z->c = z->l - m; + if (!(eq_s_b(z, 1, s_3))) + { + z->c = z->l - m; + goto lab0; + } + } + lab1: + { + int ret; + + ret = slice_del(z); /* delete, line 117 */ + if (ret < 0) + return ret; + } + break; + case 2: + { + int ret; + + ret = slice_del(z); /* delete, line 124 */ + if (ret < 0) + return ret; + } + break; + } +lab0: + ; + } + return 1; } -static int r_reflexive(struct SN_env * z) { - int among_var; - z->ket = z->c; /* [, line 131 */ - among_var = find_among_b(z, a_3, 2); /* substring, line 131 */ - if (!(among_var)) return 0; - z->bra = z->c; /* ], line 131 */ - switch(among_var) { - case 0: return 0; - case 1: - { int ret; - ret = slice_del(z); /* delete, line 134 */ - if (ret < 0) return ret; - } - break; - } - return 1; +static int +r_reflexive(struct SN_env * z) +{ + int among_var; + + z->ket = z->c; /* [, line 131 */ + among_var = find_among_b(z, a_3, 2); /* substring, line 131 */ + if (!(among_var)) + return 0; + z->bra = z->c; /* ], line 131 */ + switch (among_var) + { + case 0: + return 0; + case 1: + { + int ret; + + ret = slice_del(z); /* delete, line 134 */ + if (ret < 0) + return ret; + } + break; + } + return 1; } -static int r_verb(struct SN_env * z) { - int among_var; - z->ket = z->c; /* [, line 139 */ - among_var = find_among_b(z, a_4, 46); /* substring, line 139 */ - if (!(among_var)) return 0; - z->bra = z->c; /* ], line 139 */ - switch(among_var) { - case 0: return 0; - case 1: - { int m = z->l - z->c; (void) m; /* or, line 145 */ - if (!(eq_s_b(z, 1, s_4))) goto lab1; - goto lab0; - lab1: - z->c = z->l - m; - if (!(eq_s_b(z, 1, s_5))) return 0; - } - lab0: - { int ret; - ret = slice_del(z); /* delete, line 145 */ - if (ret < 0) return ret; - } - break; - case 2: - { int ret; - ret = slice_del(z); /* delete, line 153 */ - if (ret < 0) return ret; - } - break; - } - return 1; +static int +r_verb(struct SN_env * z) +{ + int among_var; + + z->ket = z->c; /* [, line 139 */ + among_var = find_among_b(z, a_4, 46); /* substring, line 139 */ + if (!(among_var)) + return 0; + z->bra = z->c; /* ], line 139 */ + switch (among_var) + { + case 0: + return 0; + case 1: + { + int m = z->l - z->c; + + (void) m; /* or, line 145 */ + if (!(eq_s_b(z, 1, s_4))) + goto lab1; + goto lab0; + lab1: + z->c = z->l - m; + if (!(eq_s_b(z, 1, s_5))) + return 0; + } + lab0: + { + int ret; + + ret = slice_del(z); /* delete, line 145 */ + if (ret < 0) + return ret; + } + break; + case 2: + { + int ret; + + ret = slice_del(z); /* delete, line 153 */ + if (ret < 0) + return ret; + } + break; + } + return 1; } -static int r_noun(struct SN_env * z) { - int among_var; - z->ket = z->c; /* [, line 162 */ - among_var = find_among_b(z, a_5, 36); /* substring, line 162 */ - if (!(among_var)) return 0; - z->bra = z->c; /* ], line 162 */ - switch(among_var) { - case 0: return 0; - case 1: - { int ret; - ret = slice_del(z); /* delete, line 169 */ - if (ret < 0) return ret; - } - break; - } - return 1; +static int +r_noun(struct SN_env * z) +{ + int among_var; + + z->ket = z->c; /* [, line 162 */ + among_var = find_among_b(z, a_5, 36); /* substring, line 162 */ + if (!(among_var)) + return 0; + z->bra = z->c; /* ], line 162 */ + switch (among_var) + { + case 0: + return 0; + case 1: + { + int ret; + + ret = slice_del(z); /* delete, line 169 */ + if (ret < 0) + return ret; + } + break; + } + return 1; } -static int r_derivational(struct SN_env * z) { - int among_var; - z->ket = z->c; /* [, line 178 */ - among_var = find_among_b(z, a_6, 2); /* substring, line 178 */ - if (!(among_var)) return 0; - z->bra = z->c; /* ], line 178 */ - { int ret = r_R2(z); - if (ret == 0) return 0; /* call R2, line 178 */ - if (ret < 0) return ret; - } - switch(among_var) { - case 0: return 0; - case 1: - { int ret; - ret = slice_del(z); /* delete, line 181 */ - if (ret < 0) return ret; - } - break; - } - return 1; +static int +r_derivational(struct SN_env * z) +{ + int among_var; + + z->ket = z->c; /* [, line 178 */ + among_var = find_among_b(z, a_6, 2); /* substring, line 178 */ + if (!(among_var)) + return 0; + z->bra = z->c; /* ], line 178 */ + { + int ret = r_R2(z); + + if (ret == 0) + return 0; /* call R2, line 178 */ + if (ret < 0) + return ret; + } + switch (among_var) + { + case 0: + return 0; + case 1: + { + int ret; + + ret = slice_del(z); /* delete, line 181 */ + if (ret < 0) + return ret; + } + break; + } + return 1; } -static int r_tidy_up(struct SN_env * z) { - int among_var; - z->ket = z->c; /* [, line 186 */ - among_var = find_among_b(z, a_7, 4); /* substring, line 186 */ - if (!(among_var)) return 0; - z->bra = z->c; /* ], line 186 */ - switch(among_var) { - case 0: return 0; - case 1: - { int ret; - ret = slice_del(z); /* delete, line 190 */ - if (ret < 0) return ret; - } - z->ket = z->c; /* [, line 191 */ - if (!(eq_s_b(z, 1, s_6))) return 0; - z->bra = z->c; /* ], line 191 */ - if (!(eq_s_b(z, 1, s_7))) return 0; - { int ret; - ret = slice_del(z); /* delete, line 191 */ - if (ret < 0) return ret; - } - break; - case 2: - if (!(eq_s_b(z, 1, s_8))) return 0; - { int ret; - ret = slice_del(z); /* delete, line 194 */ - if (ret < 0) return ret; - } - break; - case 3: - { int ret; - ret = slice_del(z); /* delete, line 196 */ - if (ret < 0) return ret; - } - break; - } - return 1; +static int +r_tidy_up(struct SN_env * z) +{ + int among_var; + + z->ket = z->c; /* [, line 186 */ + among_var = find_among_b(z, a_7, 4); /* substring, line 186 */ + if (!(among_var)) + return 0; + z->bra = z->c; /* ], line 186 */ + switch (among_var) + { + case 0: + return 0; + case 1: + { + int ret; + + ret = slice_del(z); /* delete, line 190 */ + if (ret < 0) + return ret; + } + z->ket = z->c; /* [, line 191 */ + if (!(eq_s_b(z, 1, s_6))) + return 0; + z->bra = z->c; /* ], line 191 */ + if (!(eq_s_b(z, 1, s_7))) + return 0; + { + int ret; + + ret = slice_del(z); /* delete, line 191 */ + if (ret < 0) + return ret; + } + break; + case 2: + if (!(eq_s_b(z, 1, s_8))) + return 0; + { + int ret; + + ret = slice_del(z); /* delete, line 194 */ + if (ret < 0) + return ret; + } + break; + case 3: + { + int ret; + + ret = slice_del(z); /* delete, line 196 */ + if (ret < 0) + return ret; + } + break; + } + return 1; } -extern int russian_KOI8_R_stem(struct SN_env * z) { - { int c = z->c; /* do, line 203 */ - { int ret = r_mark_regions(z); - if (ret == 0) goto lab0; /* call mark_regions, line 203 */ - if (ret < 0) return ret; - } - lab0: - z->c = c; - } - z->lb = z->c; z->c = z->l; /* backwards, line 204 */ +extern int +russian_KOI8_R_stem(struct SN_env * z) +{ + { + int c = z->c; /* do, line 203 */ - { int m3; /* setlimit, line 204 */ - int m = z->l - z->c; (void) m; - if (z->c < z->I[0]) return 0; - z->c = z->I[0]; /* tomark, line 204 */ - m3 = z->lb; z->lb = z->c; - z->c = z->l - m; - { int m = z->l - z->c; (void) m; /* do, line 205 */ - { int m = z->l - z->c; (void) m; /* or, line 206 */ - { int ret = r_perfective_gerund(z); - if (ret == 0) goto lab3; /* call perfective_gerund, line 206 */ - if (ret < 0) return ret; - } - goto lab2; - lab3: - z->c = z->l - m; - { int m = z->l - z->c; (void) m; /* try, line 207 */ - { int ret = r_reflexive(z); - if (ret == 0) { z->c = z->l - m; goto lab4; } /* call reflexive, line 207 */ - if (ret < 0) return ret; - } - lab4: - ; - } - { int m = z->l - z->c; (void) m; /* or, line 208 */ - { int ret = r_adjectival(z); - if (ret == 0) goto lab6; /* call adjectival, line 208 */ - if (ret < 0) return ret; - } - goto lab5; - lab6: - z->c = z->l - m; - { int ret = r_verb(z); - if (ret == 0) goto lab7; /* call verb, line 208 */ - if (ret < 0) return ret; - } - goto lab5; - lab7: - z->c = z->l - m; - { int ret = r_noun(z); - if (ret == 0) goto lab1; /* call noun, line 208 */ - if (ret < 0) return ret; - } - } - lab5: - ; - } - lab2: - lab1: - z->c = z->l - m; - } - { int m = z->l - z->c; (void) m; /* try, line 211 */ - z->ket = z->c; /* [, line 211 */ - if (!(eq_s_b(z, 1, s_9))) { z->c = z->l - m; goto lab8; } - z->bra = z->c; /* ], line 211 */ - { int ret; - ret = slice_del(z); /* delete, line 211 */ - if (ret < 0) return ret; - } - lab8: - ; - } - { int m = z->l - z->c; (void) m; /* do, line 214 */ - { int ret = r_derivational(z); - if (ret == 0) goto lab9; /* call derivational, line 214 */ - if (ret < 0) return ret; - } - lab9: - z->c = z->l - m; - } - { int m = z->l - z->c; (void) m; /* do, line 215 */ - { int ret = r_tidy_up(z); - if (ret == 0) goto lab10; /* call tidy_up, line 215 */ - if (ret < 0) return ret; - } - lab10: - z->c = z->l - m; - } - z->lb = m3; - } - z->c = z->lb; - return 1; + { + int ret = r_mark_regions(z); + + if (ret == 0) + goto lab0; /* call mark_regions, line 203 */ + if (ret < 0) + return ret; + } +lab0: + z->c = c; + } + z->lb = z->c; + z->c = z->l; /* backwards, line 204 */ + + { + int m3; /* setlimit, line 204 */ + int m = z->l - z->c; + + (void) m; + if (z->c < z->I[0]) + return 0; + z->c = z->I[0]; /* tomark, line 204 */ + m3 = z->lb; + z->lb = z->c; + z->c = z->l - m; + { + int m = z->l - z->c; + + (void) m; /* do, line 205 */ + { + int m = z->l - z->c; + + (void) m; /* or, line 206 */ + { + int ret = r_perfective_gerund(z); + + if (ret == 0) + goto lab3; /* call perfective_gerund, line 206 */ + if (ret < 0) + return ret; + } + goto lab2; + lab3: + z->c = z->l - m; + { + int m = z->l - z->c; + + (void) m; /* try, line 207 */ + { + int ret = r_reflexive(z); + + if (ret == 0) + { + z->c = z->l - m; + goto lab4; + } /* call reflexive, line 207 */ + if (ret < 0) + return ret; + } + lab4: + ; + } + { + int m = z->l - z->c; + + (void) m; /* or, line 208 */ + { + int ret = r_adjectival(z); + + if (ret == 0) + goto lab6; /* call adjectival, line 208 */ + if (ret < 0) + return ret; + } + goto lab5; + lab6: + z->c = z->l - m; + { + int ret = r_verb(z); + + if (ret == 0) + goto lab7; /* call verb, line 208 */ + if (ret < 0) + return ret; + } + goto lab5; + lab7: + z->c = z->l - m; + { + int ret = r_noun(z); + + if (ret == 0) + goto lab1; /* call noun, line 208 */ + if (ret < 0) + return ret; + } + } + lab5: + ; + } + lab2: + lab1: + z->c = z->l - m; + } + { + int m = z->l - z->c; + + (void) m; /* try, line 211 */ + z->ket = z->c; /* [, line 211 */ + if (!(eq_s_b(z, 1, s_9))) + { + z->c = z->l - m; + goto lab8; + } + z->bra = z->c; /* ], line 211 */ + { + int ret; + + ret = slice_del(z); /* delete, line 211 */ + if (ret < 0) + return ret; + } + lab8: + ; + } + { + int m = z->l - z->c; + + (void) m; /* do, line 214 */ + { + int ret = r_derivational(z); + + if (ret == 0) + goto lab9; /* call derivational, line 214 */ + if (ret < 0) + return ret; + } + lab9: + z->c = z->l - m; + } + { + int m = z->l - z->c; + + (void) m; /* do, line 215 */ + { + int ret = r_tidy_up(z); + + if (ret == 0) + goto lab10; /* call tidy_up, line 215 */ + if (ret < 0) + return ret; + } + lab10: + z->c = z->l - m; + } + z->lb = m3; + } + z->c = z->lb; + return 1; } -extern struct SN_env * russian_KOI8_R_create_env(void) { return SN_create_env(0, 2, 0); } - -extern void russian_KOI8_R_close_env(struct SN_env * z) { SN_close_env(z); } +extern struct SN_env *russian_KOI8_R_create_env(void) +{ + return SN_create_env(0, 2, 0); +} +extern void russian_KOI8_R_close_env(struct SN_env * z) +{ + SN_close_env(z); +} diff --git a/contrib/tsearch2/snowball/russian_stem.h b/contrib/tsearch2/snowball/russian_stem.h index de2179d29f..84941b037f 100644 --- a/contrib/tsearch2/snowball/russian_stem.h +++ b/contrib/tsearch2/snowball/russian_stem.h @@ -2,15 +2,16 @@ /* This file was generated automatically by the Snowball to ANSI C compiler */ #ifdef __cplusplus -extern "C" { +extern "C" +{ #endif -extern struct SN_env * russian_KOI8_R_create_env(void); -extern void russian_KOI8_R_close_env(struct SN_env * z); + extern struct SN_env *russian_KOI8_R_create_env(void); + extern void russian_KOI8_R_close_env(struct SN_env * z); -extern int russian_KOI8_R_stem(struct SN_env * z); + extern int russian_KOI8_R_stem(struct SN_env * z); #ifdef __cplusplus } -#endif +#endif diff --git a/contrib/tsearch2/snowball/utilities.c b/contrib/tsearch2/snowball/utilities.c index a6bfa5c76a..f06e5bb7a1 100644 --- a/contrib/tsearch2/snowball/utilities.c +++ b/contrib/tsearch2/snowball/utilities.c @@ -9,19 +9,26 @@ #define CREATE_SIZE 1 -extern symbol * create_s(void) { - symbol * p; - void * mem = malloc(HEAD + (CREATE_SIZE + 1) * sizeof(symbol)); - if (mem == NULL) return NULL; - p = (symbol *) (HEAD + (char *) mem); - CAPACITY(p) = CREATE_SIZE; - SET_SIZE(p, CREATE_SIZE); - return p; +extern symbol * +create_s(void) +{ + symbol *p; + void *mem = malloc(HEAD + (CREATE_SIZE + 1) * sizeof(symbol)); + + if (mem == NULL) + return NULL; + p = (symbol *) (HEAD + (char *) mem); + CAPACITY(p) = CREATE_SIZE; + SET_SIZE(p, CREATE_SIZE); + return p; } -extern void lose_s(symbol * p) { - if (p == NULL) return; - free((char *) p - HEAD); +extern void +lose_s(symbol * p) +{ + if (p == NULL) + return; + free((char *) p - HEAD); } /* @@ -32,280 +39,435 @@ extern void lose_s(symbol * p) { -- used to implement hop and next in the utf8 case. */ -extern int skip_utf8(const symbol * p, int c, int lb, int l, int n) { - int b; - if (n >= 0) { - for (; n > 0; n--) { - if (c >= l) return -1; - b = p[c++]; - if (b >= 0xC0) { /* 1100 0000 */ - while (c < l) { - b = p[c]; - if (b >= 0xC0 || b < 0x80) break; - /* break unless b is 10------ */ - c++; - } - } - } - } else { - for (; n < 0; n++) { - if (c <= lb) return -1; - b = p[--c]; - if (b >= 0x80) { /* 1000 0000 */ - while (c > lb) { - b = p[c]; - if (b >= 0xC0) break; /* 1100 0000 */ - c--; - } - } - } - } - return c; +extern int +skip_utf8(const symbol * p, int c, int lb, int l, int n) +{ + int b; + + if (n >= 0) + { + for (; n > 0; n--) + { + if (c >= l) + return -1; + b = p[c++]; + if (b >= 0xC0) + { /* 1100 0000 */ + while (c < l) + { + b = p[c]; + if (b >= 0xC0 || b < 0x80) + break; + /* break unless b is 10------ */ + c++; + } + } + } + } + else + { + for (; n < 0; n++) + { + if (c <= lb) + return -1; + b = p[--c]; + if (b >= 0x80) + { /* 1000 0000 */ + while (c > lb) + { + b = p[c]; + if (b >= 0xC0) + break; /* 1100 0000 */ + c--; + } + } + } + } + return c; } /* Code for character groupings: utf8 cases */ -static int get_utf8(const symbol * p, int c, int l, int * slot) { - int b0, b1; - if (c >= l) return 0; - b0 = p[c++]; - if (b0 < 0xC0 || c == l) { /* 1100 0000 */ - * slot = b0; return 1; - } - b1 = p[c++]; - if (b0 < 0xE0 || c == l) { /* 1110 0000 */ - * slot = (b0 & 0x1F) << 6 | (b1 & 0x3F); return 2; - } - * slot = (b0 & 0xF) << 12 | (b1 & 0x3F) << 6 | (*p & 0x3F); return 3; +static int +get_utf8(const symbol * p, int c, int l, int *slot) +{ + int b0, + b1; + + if (c >= l) + return 0; + b0 = p[c++]; + if (b0 < 0xC0 || c == l) + { /* 1100 0000 */ + *slot = b0; + return 1; + } + b1 = p[c++]; + if (b0 < 0xE0 || c == l) + { /* 1110 0000 */ + *slot = (b0 & 0x1F) << 6 | (b1 & 0x3F); + return 2; + } + *slot = (b0 & 0xF) << 12 | (b1 & 0x3F) << 6 | (*p & 0x3F); + return 3; } -static int get_b_utf8(const symbol * p, int c, int lb, int * slot) { - int b0, b1; - if (c <= lb) return 0; - b0 = p[--c]; - if (b0 < 0x80 || c == lb) { /* 1000 0000 */ - * slot = b0; return 1; - } - b1 = p[--c]; - if (b1 >= 0xC0 || c == lb) { /* 1100 0000 */ - * slot = (b1 & 0x1F) << 6 | (b0 & 0x3F); return 2; - } - * slot = (*p & 0xF) << 12 | (b1 & 0x3F) << 6 | (b0 & 0x3F); return 3; +static int +get_b_utf8(const symbol * p, int c, int lb, int *slot) +{ + int b0, + b1; + + if (c <= lb) + return 0; + b0 = p[--c]; + if (b0 < 0x80 || c == lb) + { /* 1000 0000 */ + *slot = b0; + return 1; + } + b1 = p[--c]; + if (b1 >= 0xC0 || c == lb) + { /* 1100 0000 */ + *slot = (b1 & 0x1F) << 6 | (b0 & 0x3F); + return 2; + } + *slot = (*p & 0xF) << 12 | (b1 & 0x3F) << 6 | (b0 & 0x3F); + return 3; } -extern int in_grouping_U(struct SN_env * z, unsigned char * s, int min, int max) { - int ch; - int w = get_utf8(z->p, z->c, z->l, & ch); - unless (w) return 0; - if (ch > max || (ch -= min) < 0 || (s[ch >> 3] & (0X1 << (ch & 0X7))) == 0) return 0; - z->c += w; return 1; +extern int +in_grouping_U(struct SN_env * z, unsigned char *s, int min, int max) +{ + int ch; + int w = get_utf8(z->p, z->c, z->l, &ch); + + unless(w) return 0; + if (ch > max || (ch -= min) < 0 || (s[ch >> 3] & (0X1 << (ch & 0X7))) == 0) + return 0; + z->c += w; + return 1; } -extern int in_grouping_b_U(struct SN_env * z, unsigned char * s, int min, int max) { - int ch; - int w = get_b_utf8(z->p, z->c, z->lb, & ch); - unless (w) return 0; - if (ch > max || (ch -= min) < 0 || (s[ch >> 3] & (0X1 << (ch & 0X7))) == 0) return 0; - z->c -= w; return 1; +extern int +in_grouping_b_U(struct SN_env * z, unsigned char *s, int min, int max) +{ + int ch; + int w = get_b_utf8(z->p, z->c, z->lb, &ch); + + unless(w) return 0; + if (ch > max || (ch -= min) < 0 || (s[ch >> 3] & (0X1 << (ch & 0X7))) == 0) + return 0; + z->c -= w; + return 1; } -extern int out_grouping_U(struct SN_env * z, unsigned char * s, int min, int max) { - int ch; - int w = get_utf8(z->p, z->c, z->l, & ch); - unless (w) return 0; - unless (ch > max || (ch -= min) < 0 || (s[ch >> 3] & (0X1 << (ch & 0X7))) == 0) return 0; - z->c += w; return 1; +extern int +out_grouping_U(struct SN_env * z, unsigned char *s, int min, int max) +{ + int ch; + int w = get_utf8(z->p, z->c, z->l, &ch); + + unless(w) return 0; + unless(ch > max || (ch -= min) < 0 || (s[ch >> 3] & (0X1 << (ch & 0X7))) == 0) return 0; + z->c += w; + return 1; } -extern int out_grouping_b_U(struct SN_env * z, unsigned char * s, int min, int max) { - int ch; - int w = get_b_utf8(z->p, z->c, z->lb, & ch); - unless (w) return 0; - unless (ch > max || (ch -= min) < 0 || (s[ch >> 3] & (0X1 << (ch & 0X7))) == 0) return 0; - z->c -= w; return 1; +extern int +out_grouping_b_U(struct SN_env * z, unsigned char *s, int min, int max) +{ + int ch; + int w = get_b_utf8(z->p, z->c, z->lb, &ch); + + unless(w) return 0; + unless(ch > max || (ch -= min) < 0 || (s[ch >> 3] & (0X1 << (ch & 0X7))) == 0) return 0; + z->c -= w; + return 1; } /* Code for character groupings: non-utf8 cases */ -extern int in_grouping(struct SN_env * z, unsigned char * s, int min, int max) { - int ch; - if (z->c >= z->l) return 0; - ch = z->p[z->c]; - if (ch > max || (ch -= min) < 0 || (s[ch >> 3] & (0X1 << (ch & 0X7))) == 0) return 0; - z->c++; return 1; +extern int +in_grouping(struct SN_env * z, unsigned char *s, int min, int max) +{ + int ch; + + if (z->c >= z->l) + return 0; + ch = z->p[z->c]; + if (ch > max || (ch -= min) < 0 || (s[ch >> 3] & (0X1 << (ch & 0X7))) == 0) + return 0; + z->c++; + return 1; } -extern int in_grouping_b(struct SN_env * z, unsigned char * s, int min, int max) { - int ch; - if (z->c <= z->lb) return 0; - ch = z->p[z->c - 1]; - if (ch > max || (ch -= min) < 0 || (s[ch >> 3] & (0X1 << (ch & 0X7))) == 0) return 0; - z->c--; return 1; +extern int +in_grouping_b(struct SN_env * z, unsigned char *s, int min, int max) +{ + int ch; + + if (z->c <= z->lb) + return 0; + ch = z->p[z->c - 1]; + if (ch > max || (ch -= min) < 0 || (s[ch >> 3] & (0X1 << (ch & 0X7))) == 0) + return 0; + z->c--; + return 1; } -extern int out_grouping(struct SN_env * z, unsigned char * s, int min, int max) { - int ch; - if (z->c >= z->l) return 0; - ch = z->p[z->c]; - unless (ch > max || (ch -= min) < 0 || (s[ch >> 3] & (0X1 << (ch & 0X7))) == 0) return 0; - z->c++; return 1; +extern int +out_grouping(struct SN_env * z, unsigned char *s, int min, int max) +{ + int ch; + + if (z->c >= z->l) + return 0; + ch = z->p[z->c]; + unless(ch > max || (ch -= min) < 0 || (s[ch >> 3] & (0X1 << (ch & 0X7))) == 0) return 0; + z->c++; + return 1; } -extern int out_grouping_b(struct SN_env * z, unsigned char * s, int min, int max) { - int ch; - if (z->c <= z->lb) return 0; - ch = z->p[z->c - 1]; - unless (ch > max || (ch -= min) < 0 || (s[ch >> 3] & (0X1 << (ch & 0X7))) == 0) return 0; - z->c--; return 1; +extern int +out_grouping_b(struct SN_env * z, unsigned char *s, int min, int max) +{ + int ch; + + if (z->c <= z->lb) + return 0; + ch = z->p[z->c - 1]; + unless(ch > max || (ch -= min) < 0 || (s[ch >> 3] & (0X1 << (ch & 0X7))) == 0) return 0; + z->c--; + return 1; } -extern int eq_s(struct SN_env * z, int s_size, symbol * s) { - if (z->l - z->c < s_size || memcmp(z->p + z->c, s, s_size * sizeof(symbol)) != 0) return 0; - z->c += s_size; return 1; +extern int +eq_s(struct SN_env * z, int s_size, symbol * s) +{ + if (z->l - z->c < s_size || memcmp(z->p + z->c, s, s_size * sizeof(symbol)) != 0) + return 0; + z->c += s_size; + return 1; } -extern int eq_s_b(struct SN_env * z, int s_size, symbol * s) { - if (z->c - z->lb < s_size || memcmp(z->p + z->c - s_size, s, s_size * sizeof(symbol)) != 0) return 0; - z->c -= s_size; return 1; +extern int +eq_s_b(struct SN_env * z, int s_size, symbol * s) +{ + if (z->c - z->lb < s_size || memcmp(z->p + z->c - s_size, s, s_size * sizeof(symbol)) != 0) + return 0; + z->c -= s_size; + return 1; } -extern int eq_v(struct SN_env * z, symbol * p) { - return eq_s(z, SIZE(p), p); +extern int +eq_v(struct SN_env * z, symbol * p) +{ + return eq_s(z, SIZE(p), p); } -extern int eq_v_b(struct SN_env * z, symbol * p) { - return eq_s_b(z, SIZE(p), p); +extern int +eq_v_b(struct SN_env * z, symbol * p) +{ + return eq_s_b(z, SIZE(p), p); } -extern int find_among(struct SN_env * z, struct among * v, int v_size) { +extern int +find_among(struct SN_env * z, struct among * v, int v_size) +{ - int i = 0; - int j = v_size; + int i = 0; + int j = v_size; - int c = z->c; int l = z->l; - symbol * q = z->p + c; + int c = z->c; + int l = z->l; + symbol *q = z->p + c; - struct among * w; + struct among *w; - int common_i = 0; - int common_j = 0; + int common_i = 0; + int common_j = 0; - int first_key_inspected = 0; + int first_key_inspected = 0; - while(1) { - int k = i + ((j - i) >> 1); - int diff = 0; - int common = common_i < common_j ? common_i : common_j; /* smaller */ - w = v + k; - { - int i; for (i = common; i < w->s_size; i++) { - if (c + common == l) { diff = -1; break; } - diff = q[common] - w->s[i]; - if (diff != 0) break; - common++; - } - } - if (diff < 0) { j = k; common_j = common; } - else { i = k; common_i = common; } - if (j - i <= 1) { - if (i > 0) break; /* v->s has been inspected */ - if (j == i) break; /* only one item in v */ + while (1) + { + int k = i + ((j - i) >> 1); + int diff = 0; + int common = common_i < common_j ? common_i : common_j; /* smaller */ - /* - but now we need to go round once more to get - v->s inspected. This looks messy, but is actually - the optimal approach. */ + w = v + k; + { + int i; - if (first_key_inspected) break; - first_key_inspected = 1; - } - } - while(1) { - w = v + i; - if (common_i >= w->s_size) { - z->c = c + w->s_size; - if (w->function == 0) return w->result; - { - int res = w->function(z); - z->c = c + w->s_size; - if (res) return w->result; - } - } - i = w->substring_i; - if (i < 0) return 0; - } + for (i = common; i < w->s_size; i++) + { + if (c + common == l) + { + diff = -1; + break; + } + diff = q[common] - w->s[i]; + if (diff != 0) + break; + common++; + } + } + if (diff < 0) + { + j = k; + common_j = common; + } + else + { + i = k; + common_i = common; + } + if (j - i <= 1) + { + if (i > 0) + break; /* v->s has been inspected */ + if (j == i) + break; /* only one item in v */ + + /* + * - but now we need to go round once more to get v->s inspected. + * This looks messy, but is actually the optimal approach. + */ + + if (first_key_inspected) + break; + first_key_inspected = 1; + } + } + while (1) + { + w = v + i; + if (common_i >= w->s_size) + { + z->c = c + w->s_size; + if (w->function == 0) + return w->result; + { + int res = w->function(z); + + z->c = c + w->s_size; + if (res) + return w->result; + } + } + i = w->substring_i; + if (i < 0) + return 0; + } } /* find_among_b is for backwards processing. Same comments apply */ -extern int find_among_b(struct SN_env * z, struct among * v, int v_size) { +extern int +find_among_b(struct SN_env * z, struct among * v, int v_size) +{ - int i = 0; - int j = v_size; + int i = 0; + int j = v_size; - int c = z->c; int lb = z->lb; - symbol * q = z->p + c - 1; + int c = z->c; + int lb = z->lb; + symbol *q = z->p + c - 1; - struct among * w; + struct among *w; - int common_i = 0; - int common_j = 0; + int common_i = 0; + int common_j = 0; - int first_key_inspected = 0; + int first_key_inspected = 0; - while(1) { - int k = i + ((j - i) >> 1); - int diff = 0; - int common = common_i < common_j ? common_i : common_j; - w = v + k; - { - int i; for (i = w->s_size - 1 - common; i >= 0; i--) { - if (c - common == lb) { diff = -1; break; } - diff = q[- common] - w->s[i]; - if (diff != 0) break; - common++; - } - } - if (diff < 0) { j = k; common_j = common; } - else { i = k; common_i = common; } - if (j - i <= 1) { - if (i > 0) break; - if (j == i) break; - if (first_key_inspected) break; - first_key_inspected = 1; - } - } - while(1) { - w = v + i; - if (common_i >= w->s_size) { - z->c = c - w->s_size; - if (w->function == 0) return w->result; - { - int res = w->function(z); - z->c = c - w->s_size; - if (res) return w->result; - } - } - i = w->substring_i; - if (i < 0) return 0; - } + while (1) + { + int k = i + ((j - i) >> 1); + int diff = 0; + int common = common_i < common_j ? common_i : common_j; + + w = v + k; + { + int i; + + for (i = w->s_size - 1 - common; i >= 0; i--) + { + if (c - common == lb) + { + diff = -1; + break; + } + diff = q[-common] - w->s[i]; + if (diff != 0) + break; + common++; + } + } + if (diff < 0) + { + j = k; + common_j = common; + } + else + { + i = k; + common_i = common; + } + if (j - i <= 1) + { + if (i > 0) + break; + if (j == i) + break; + if (first_key_inspected) + break; + first_key_inspected = 1; + } + } + while (1) + { + w = v + i; + if (common_i >= w->s_size) + { + z->c = c - w->s_size; + if (w->function == 0) + return w->result; + { + int res = w->function(z); + + z->c = c - w->s_size; + if (res) + return w->result; + } + } + i = w->substring_i; + if (i < 0) + return 0; + } } /* Increase the size of the buffer pointed to by p to at least n symbols. * If insufficient memory, returns NULL and frees the old buffer. */ -static symbol * increase_size(symbol * p, int n) { - symbol * q; - int new_size = n + 20; - void * mem = realloc((char *) p - HEAD, - HEAD + (new_size + 1) * sizeof(symbol)); - if (mem == NULL) { - lose_s(p); - return NULL; - } - q = (symbol *) (HEAD + (char *)mem); - CAPACITY(q) = new_size; - return q; +static symbol * +increase_size(symbol * p, int n) +{ + symbol *q; + int new_size = n + 20; + void *mem = realloc((char *) p - HEAD, + HEAD + (new_size + 1) * sizeof(symbol)); + + if (mem == NULL) + { + lose_s(p); + return NULL; + } + q = (symbol *) (HEAD + (char *) mem); + CAPACITY(q) = new_size; + return q; } /* to replace symbols between c_bra and c_ket in z->p by the @@ -313,134 +475,182 @@ static symbol * increase_size(symbol * p, int n) { Returns 0 on success, -1 on error. Also, frees z->p (and sets it to NULL) on error. */ -extern int replace_s(struct SN_env * z, int c_bra, int c_ket, int s_size, const symbol * s, int * adjptr) +extern int +replace_s(struct SN_env * z, int c_bra, int c_ket, int s_size, const symbol * s, int *adjptr) { - int adjustment; - int len; - if (z->p == NULL) { - z->p = create_s(); - if (z->p == NULL) return -1; - } - adjustment = s_size - (c_ket - c_bra); - len = SIZE(z->p); - if (adjustment != 0) { - if (adjustment + len > CAPACITY(z->p)) { - z->p = increase_size(z->p, adjustment + len); - if (z->p == NULL) return -1; - } - memmove(z->p + c_ket + adjustment, - z->p + c_ket, - (len - c_ket) * sizeof(symbol)); - SET_SIZE(z->p, adjustment + len); - z->l += adjustment; - if (z->c >= c_ket) - z->c += adjustment; - else - if (z->c > c_bra) - z->c = c_bra; - } - unless (s_size == 0) memmove(z->p + c_bra, s, s_size * sizeof(symbol)); - if (adjptr != NULL) - *adjptr = adjustment; - return 0; + int adjustment; + int len; + + if (z->p == NULL) + { + z->p = create_s(); + if (z->p == NULL) + return -1; + } + adjustment = s_size - (c_ket - c_bra); + len = SIZE(z->p); + if (adjustment != 0) + { + if (adjustment + len > CAPACITY(z->p)) + { + z->p = increase_size(z->p, adjustment + len); + if (z->p == NULL) + return -1; + } + memmove(z->p + c_ket + adjustment, + z->p + c_ket, + (len - c_ket) * sizeof(symbol)); + SET_SIZE(z->p, adjustment + len); + z->l += adjustment; + if (z->c >= c_ket) + z->c += adjustment; + else if (z->c > c_bra) + z->c = c_bra; + } + unless(s_size == 0) memmove(z->p + c_bra, s, s_size * sizeof(symbol)); + if (adjptr != NULL) + *adjptr = adjustment; + return 0; } -static int slice_check(struct SN_env * z) { +static int +slice_check(struct SN_env * z) +{ - if (z->bra < 0 || - z->bra > z->ket || - z->ket > z->l || - z->p == NULL || - z->l > SIZE(z->p)) /* this line could be removed */ - { + if (z->bra < 0 || + z->bra > z->ket || + z->ket > z->l || + z->p == NULL || + z->l > SIZE(z->p)) /* this line could be removed */ + { #if 0 - fprintf(stderr, "faulty slice operation:\n"); - debug(z, -1, 0); + fprintf(stderr, "faulty slice operation:\n"); + debug(z, -1, 0); #endif - return -1; - } - return 0; + return -1; + } + return 0; } -extern int slice_from_s(struct SN_env * z, int s_size, symbol * s) { - if (slice_check(z)) return -1; - return replace_s(z, z->bra, z->ket, s_size, s, NULL); +extern int +slice_from_s(struct SN_env * z, int s_size, symbol * s) +{ + if (slice_check(z)) + return -1; + return replace_s(z, z->bra, z->ket, s_size, s, NULL); } -extern int slice_from_v(struct SN_env * z, symbol * p) { - return slice_from_s(z, SIZE(p), p); +extern int +slice_from_v(struct SN_env * z, symbol * p) +{ + return slice_from_s(z, SIZE(p), p); } -extern int slice_del(struct SN_env * z) { - return slice_from_s(z, 0, 0); +extern int +slice_del(struct SN_env * z) +{ + return slice_from_s(z, 0, 0); } -extern int insert_s(struct SN_env * z, int bra, int ket, int s_size, symbol * s) { - int adjustment; - if (replace_s(z, bra, ket, s_size, s, &adjustment)) - return -1; - if (bra <= z->bra) z->bra += adjustment; - if (bra <= z->ket) z->ket += adjustment; - return 0; +extern int +insert_s(struct SN_env * z, int bra, int ket, int s_size, symbol * s) +{ + int adjustment; + + if (replace_s(z, bra, ket, s_size, s, &adjustment)) + return -1; + if (bra <= z->bra) + z->bra += adjustment; + if (bra <= z->ket) + z->ket += adjustment; + return 0; } -extern int insert_v(struct SN_env * z, int bra, int ket, symbol * p) { - int adjustment; - if (replace_s(z, bra, ket, SIZE(p), p, &adjustment)) - return -1; - if (bra <= z->bra) z->bra += adjustment; - if (bra <= z->ket) z->ket += adjustment; - return 0; +extern int +insert_v(struct SN_env * z, int bra, int ket, symbol * p) +{ + int adjustment; + + if (replace_s(z, bra, ket, SIZE(p), p, &adjustment)) + return -1; + if (bra <= z->bra) + z->bra += adjustment; + if (bra <= z->ket) + z->ket += adjustment; + return 0; } -extern symbol * slice_to(struct SN_env * z, symbol * p) { - if (slice_check(z)) { - lose_s(p); - return NULL; - } - { - int len = z->ket - z->bra; - if (CAPACITY(p) < len) { - p = increase_size(p, len); - if (p == NULL) - return NULL; - } - memmove(p, z->p + z->bra, len * sizeof(symbol)); - SET_SIZE(p, len); - } - return p; +extern symbol * +slice_to(struct SN_env * z, symbol * p) +{ + if (slice_check(z)) + { + lose_s(p); + return NULL; + } + { + int len = z->ket - z->bra; + + if (CAPACITY(p) < len) + { + p = increase_size(p, len); + if (p == NULL) + return NULL; + } + memmove(p, z->p + z->bra, len * sizeof(symbol)); + SET_SIZE(p, len); + } + return p; } -extern symbol * assign_to(struct SN_env * z, symbol * p) { - int len = z->l; - if (CAPACITY(p) < len) { - p = increase_size(p, len); - if (p == NULL) - return NULL; - } - memmove(p, z->p, len * sizeof(symbol)); - SET_SIZE(p, len); - return p; +extern symbol * +assign_to(struct SN_env * z, symbol * p) +{ + int len = z->l; + + if (CAPACITY(p) < len) + { + p = increase_size(p, len); + if (p == NULL) + return NULL; + } + memmove(p, z->p, len * sizeof(symbol)); + SET_SIZE(p, len); + return p; } #if 0 -extern void debug(struct SN_env * z, int number, int line_count) { - int i; - int limit = SIZE(z->p); - /*if (number >= 0) printf("%3d (line %4d): '", number, line_count);*/ - if (number >= 0) printf("%3d (line %4d): [%d]'", number, line_count,limit); - for (i = 0; i <= limit; i++) { - if (z->lb == i) printf("{"); - if (z->bra == i) printf("["); - if (z->c == i) printf("|"); - if (z->ket == i) printf("]"); - if (z->l == i) printf("}"); - if (i < limit) - { int ch = z->p[i]; - if (ch == 0) ch = '#'; - printf("%c", ch); - } - } - printf("'\n"); +extern void +debug(struct SN_env * z, int number, int line_count) +{ + int i; + int limit = SIZE(z->p); + + /* if (number >= 0) printf("%3d (line %4d): '", number, line_count); */ + if (number >= 0) + printf("%3d (line %4d): [%d]'", number, line_count, limit); + for (i = 0; i <= limit; i++) + { + if (z->lb == i) + printf("{"); + if (z->bra == i) + printf("["); + if (z->c == i) + printf("|"); + if (z->ket == i) + printf("]"); + if (z->l == i) + printf("}"); + if (i < limit) + { + int ch = z->p[i]; + + if (ch == 0) + ch = '#'; + printf("%c", ch); + } + } + printf("'\n"); } + #endif diff --git a/contrib/tsearch2/stopword.c b/contrib/tsearch2/stopword.c index 185d085de1..b8789f9e64 100644 --- a/contrib/tsearch2/stopword.c +++ b/contrib/tsearch2/stopword.c @@ -58,8 +58,8 @@ readstoplist(text *in, StopList * s) /* if path is relative, take it as relative to share dir */ if (!is_absolute_path(filename)) { - char sharepath[MAXPGPATH]; - char *absfn; + char sharepath[MAXPGPATH]; + char *absfn; get_share_path(my_exec_path, sharepath); absfn = palloc(strlen(sharepath) + strlen(filename) + 2); diff --git a/contrib/tsearch2/ts_cfg.c b/contrib/tsearch2/ts_cfg.c index c5916b0f0d..a1fcf0b4f2 100644 --- a/contrib/tsearch2/ts_cfg.c +++ b/contrib/tsearch2/ts_cfg.c @@ -185,9 +185,9 @@ reset_cfg(void) static int comparecfg(const void *a, const void *b) { - if ( ((TSCfgInfo *) a)->id == ((TSCfgInfo *) b)->id ) + if (((TSCfgInfo *) a)->id == ((TSCfgInfo *) b)->id) return 0; - return ( ((TSCfgInfo *) a)->id < ((TSCfgInfo *) b)->id ) ? -1 : 1; + return (((TSCfgInfo *) a)->id < ((TSCfgInfo *) b)->id) ? -1 : 1; } TSCfgInfo * @@ -289,17 +289,17 @@ parsetext_v2(TSCfgInfo * cfg, PRSTEXT * prs, char *buf, int4 buflen) prsobj->prs = (void *) DatumGetPointer( FunctionCall2( - &(prsobj->start_info), - PointerGetDatum(buf), - Int32GetDatum(buflen) + &(prsobj->start_info), + PointerGetDatum(buf), + Int32GetDatum(buflen) ) ); while ((type = DatumGetInt32(FunctionCall3( &(prsobj->getlexeme_info), - PointerGetDatum(prsobj->prs), + PointerGetDatum(prsobj->prs), PointerGetDatum(&lemm), - PointerGetDatum(&lenlemm)))) != 0) + PointerGetDatum(&lenlemm)))) != 0) { if (lenlemm >= MAXSTRLEN) @@ -322,16 +322,16 @@ parsetext_v2(TSCfgInfo * cfg, PRSTEXT * prs, char *buf, int4 buflen) for (i = 0; i < cfg->map[type].len; i++) { DictInfo *dict = finddict(DatumGetObjectId(cfg->map[type].dict_id[i])); - TSLexeme *norms, - *ptr; + TSLexeme *norms, + *ptr; norms = ptr = (TSLexeme *) DatumGetPointer( - FunctionCall3( - &(dict->lexize_info), - PointerGetDatum(dict->dictionary), - PointerGetDatum(lemm), - PointerGetDatum(lenlemm) - ) + FunctionCall3( + &(dict->lexize_info), + PointerGetDatum(dict->dictionary), + PointerGetDatum(lemm), + PointerGetDatum(lenlemm) + ) ); if (!norms) /* dictionary doesn't know this lexem */ continue; @@ -355,8 +355,7 @@ parsetext_v2(TSCfgInfo * cfg, PRSTEXT * prs, char *buf, int4 buflen) prs->curwords++; } pfree(norms); - break; /* lexem already normalized or is stop - * word */ + break; /* lexem already normalized or is stop word */ } } @@ -425,17 +424,17 @@ hlparsetext(TSCfgInfo * cfg, HLPRSTEXT * prs, QUERYTYPE * query, char *buf, int4 prsobj->prs = (void *) DatumGetPointer( FunctionCall2( - &(prsobj->start_info), - PointerGetDatum(buf), - Int32GetDatum(buflen) + &(prsobj->start_info), + PointerGetDatum(buf), + Int32GetDatum(buflen) ) ); while ((type = DatumGetInt32(FunctionCall3( &(prsobj->getlexeme_info), - PointerGetDatum(prsobj->prs), + PointerGetDatum(prsobj->prs), PointerGetDatum(&lemm), - PointerGetDatum(&lenlemm)))) != 0) + PointerGetDatum(&lenlemm)))) != 0) { if (lenlemm >= MAXSTRLEN) @@ -460,16 +459,16 @@ hlparsetext(TSCfgInfo * cfg, HLPRSTEXT * prs, QUERYTYPE * query, char *buf, int4 for (i = 0; i < cfg->map[type].len; i++) { DictInfo *dict = finddict(DatumGetObjectId(cfg->map[type].dict_id[i])); - TSLexeme *norms, - *ptr; + TSLexeme *norms, + *ptr; norms = ptr = (TSLexeme *) DatumGetPointer( - FunctionCall3( - &(dict->lexize_info), - PointerGetDatum(dict->dictionary), - PointerGetDatum(lemm), - PointerGetDatum(lenlemm) - ) + FunctionCall3( + &(dict->lexize_info), + PointerGetDatum(dict->dictionary), + PointerGetDatum(lemm), + PointerGetDatum(lenlemm) + ) ); if (!norms) /* dictionary doesn't know this lexem */ continue; @@ -481,8 +480,7 @@ hlparsetext(TSCfgInfo * cfg, HLPRSTEXT * prs, QUERYTYPE * query, char *buf, int4 ptr++; } pfree(norms); - break; /* lexem already normalized or is stop - * word */ + break; /* lexem already normalized or is stop word */ } } diff --git a/contrib/tsearch2/ts_stat.c b/contrib/tsearch2/ts_stat.c index aaf43f8d74..2cde25df8e 100644 --- a/contrib/tsearch2/ts_stat.c +++ b/contrib/tsearch2/ts_stat.c @@ -505,10 +505,10 @@ ts_stat_sql(text *txt, text *ws) if (!isnull) { newstat = (tsstat *) DatumGetPointer(DirectFunctionCall2( - ts_accum, - PointerGetDatum(stat), - data - )); + ts_accum, + PointerGetDatum(stat), + data + )); if (stat != newstat && stat) pfree(stat); stat = newstat; diff --git a/contrib/tsearch2/tsvector.c b/contrib/tsearch2/tsvector.c index 2630694e4e..cfed6e428a 100644 --- a/contrib/tsearch2/tsvector.c +++ b/contrib/tsearch2/tsvector.c @@ -52,7 +52,7 @@ comparePos(const void *a, const void *b) { if (WEP_GETPOS(*(WordEntryPos *) a) == WEP_GETPOS(*(WordEntryPos *) b)) return 0; - return (WEP_GETPOS(*(WordEntryPos *) a)> WEP_GETPOS(*(WordEntryPos *) b)) ? 1 : -1; + return (WEP_GETPOS(*(WordEntryPos *) a) > WEP_GETPOS(*(WordEntryPos *) b)) ? 1 : -1; } static int @@ -328,7 +328,7 @@ gettoken_tsvector(TI_IN_STATE * state) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("wrong position info"))); - WEP_SETWEIGHT( state->pos[*(uint16 *) (state->pos)], 0 ); + WEP_SETWEIGHT(state->pos[*(uint16 *) (state->pos)], 0); state->state = WAITPOSDELIM; } else @@ -342,35 +342,35 @@ gettoken_tsvector(TI_IN_STATE * state) state->state = INPOSINFO; else if (tolower(*(state->prsbuf)) == 'a' || *(state->prsbuf) == '*') { - if ( WEP_GETWEIGHT(state->pos[*(uint16 *) (state->pos)]) ) + if (WEP_GETWEIGHT(state->pos[*(uint16 *) (state->pos)])) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("syntax error"))); - WEP_SETWEIGHT( state->pos[*(uint16 *) (state->pos)], 3 ); + WEP_SETWEIGHT(state->pos[*(uint16 *) (state->pos)], 3); } else if (tolower(*(state->prsbuf)) == 'b') { - if ( WEP_GETWEIGHT(state->pos[*(uint16 *) (state->pos)]) ) + if (WEP_GETWEIGHT(state->pos[*(uint16 *) (state->pos)])) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("syntax error"))); - WEP_SETWEIGHT( state->pos[*(uint16 *) (state->pos)], 2 ); + WEP_SETWEIGHT(state->pos[*(uint16 *) (state->pos)], 2); } else if (tolower(*(state->prsbuf)) == 'c') { - if ( WEP_GETWEIGHT(state->pos[*(uint16 *) (state->pos)]) ) + if (WEP_GETWEIGHT(state->pos[*(uint16 *) (state->pos)])) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("syntax error"))); - WEP_SETWEIGHT( state->pos[*(uint16 *) (state->pos)], 1 ); + WEP_SETWEIGHT(state->pos[*(uint16 *) (state->pos)], 1); } else if (tolower(*(state->prsbuf)) == 'd') { - if ( WEP_GETWEIGHT(state->pos[*(uint16 *) (state->pos)]) ) + if (WEP_GETWEIGHT(state->pos[*(uint16 *) (state->pos)])) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("syntax error"))); - WEP_SETWEIGHT( state->pos[*(uint16 *) (state->pos)], 0 ); + WEP_SETWEIGHT(state->pos[*(uint16 *) (state->pos)], 0); } else if (isspace((unsigned char) *(state->prsbuf)) || *(state->prsbuf) == '\0') @@ -906,9 +906,9 @@ tsearch2(PG_FUNCTION_ARGS) if (funcoid != InvalidOid) { text *txttmp = (text *) DatumGetPointer(OidFunctionCall1( - funcoid, - PointerGetDatum(txt_toasted) - )); + funcoid, + PointerGetDatum(txt_toasted) + )); txt = (text *) DatumGetPointer(PG_DETOAST_DATUM(PointerGetDatum(txttmp))); if (txt == txttmp) diff --git a/contrib/tsearch2/tsvector.h b/contrib/tsearch2/tsvector.h index e2fd0b6fae..b30d3239f3 100644 --- a/contrib/tsearch2/tsvector.h +++ b/contrib/tsearch2/tsvector.h @@ -24,13 +24,13 @@ typedef struct #define MAXSTRPOS ( 1<<20 ) /* -Equivalent to +Equivalent to typedef struct { - uint16 - weight:2, - pos:14; -} WordEntryPos; + uint16 + weight:2, + pos:14; +} WordEntryPos; */ @@ -39,8 +39,8 @@ typedef uint16 WordEntryPos; #define WEP_GETWEIGHT(x) ( (x) >> 14 ) #define WEP_GETPOS(x) ( (x) & 0x3fff ) -#define WEP_SETWEIGHT(x,v) (x) = ( (v) << 14 ) | ( (x) & 0x3fff ) -#define WEP_SETPOS(x,v) (x) = ( (x) & 0xc000 ) | ( (v) & 0x3fff ) +#define WEP_SETWEIGHT(x,v) (x) = ( (v) << 14 ) | ( (x) & 0x3fff ) +#define WEP_SETPOS(x,v) (x) = ( (x) & 0xc000 ) | ( (v) & 0x3fff ) #define MAXENTRYPOS (1<<14) diff --git a/contrib/tsearch2/tsvector_op.c b/contrib/tsearch2/tsvector_op.c index 7f1a33c943..b2562e8984 100644 --- a/contrib/tsearch2/tsvector_op.c +++ b/contrib/tsearch2/tsvector_op.c @@ -106,7 +106,7 @@ setweight(PG_FUNCTION_ARGS) p = POSDATAPTR(out, entry); while (j--) { - WEP_SETWEIGHT(*p,w); + WEP_SETWEIGHT(*p, w); p++; } } diff --git a/contrib/tsearch2/wparser.c b/contrib/tsearch2/wparser.c index 0f3ead832e..725020e23d 100644 --- a/contrib/tsearch2/wparser.c +++ b/contrib/tsearch2/wparser.c @@ -92,9 +92,9 @@ reset_prs(void) static int compareprs(const void *a, const void *b) { - if ( ((WParserInfo *) a)->prs_id == ((WParserInfo *) b)->prs_id ) + if (((WParserInfo *) a)->prs_id == ((WParserInfo *) b)->prs_id) return 0; - return ( ((WParserInfo *) a)->prs_id < ((WParserInfo *) b)->prs_id ) ? -1 : 1; + return (((WParserInfo *) a)->prs_id < ((WParserInfo *) b)->prs_id) ? -1 : 1; } WParserInfo * @@ -194,7 +194,7 @@ setup_firstcall(FunctionCallInfo fcinfo, FuncCallContext *funcctx, Oid prsid) st = (TypeStorage *) palloc(sizeof(TypeStorage)); st->cur = 0; st->list = (LexDescr *) DatumGetPointer( - OidFunctionCall1(prs->lextype, PointerGetDatum(prs->prs)) + OidFunctionCall1(prs->lextype, PointerGetDatum(prs->prs)) ); funcctx->user_fctx = (void *) st; if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE) @@ -375,8 +375,8 @@ prs_setup_firstcall(FunctionCallInfo fcinfo, FuncCallContext *funcctx, prs->prs = (void *) DatumGetPointer( FunctionCall2( &(prs->start_info), - PointerGetDatum(VARDATA(txt)), - Int32GetDatum(VARSIZE(txt) - VARHDRSZ) + PointerGetDatum(VARDATA(txt)), + Int32GetDatum(VARSIZE(txt) - VARHDRSZ) ) ); @@ -384,7 +384,7 @@ prs_setup_firstcall(FunctionCallInfo fcinfo, FuncCallContext *funcctx, &(prs->getlexeme_info), PointerGetDatum(prs->prs), PointerGetDatum(&lex), - PointerGetDatum(&llen)))) != 0) + PointerGetDatum(&llen)))) != 0) { if (st->cur >= st->len) @@ -588,7 +588,7 @@ headline_byname(PG_FUNCTION_ARGS) ObjectIdGetDatum(name2id_cfg(cfg)), PG_GETARG_DATUM(1), PG_GETARG_DATUM(2), - (PG_NARGS() > 3) ? PG_GETARG_DATUM(3) : PointerGetDatum(NULL) + (PG_NARGS() > 3) ? PG_GETARG_DATUM(3) : PointerGetDatum(NULL) ); PG_FREE_IF_COPY(cfg, 0); @@ -606,6 +606,6 @@ headline_current(PG_FUNCTION_ARGS) ObjectIdGetDatum(get_currcfg()), PG_GETARG_DATUM(0), PG_GETARG_DATUM(1), - (PG_NARGS() > 2) ? PG_GETARG_DATUM(2) : PointerGetDatum(NULL) + (PG_NARGS() > 2) ? PG_GETARG_DATUM(2) : PointerGetDatum(NULL) )); } diff --git a/contrib/tsearch2/wparser_def.c b/contrib/tsearch2/wparser_def.c index a33bacf31b..6686257887 100644 --- a/contrib/tsearch2/wparser_def.c +++ b/contrib/tsearch2/wparser_def.c @@ -242,7 +242,7 @@ prsd_headline(PG_FUNCTION_ARGS) if (min_words >= max_words) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("MinWords should be less than MaxWords"))); + errmsg("MinWords should be less than MaxWords"))); if (min_words <= 0) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), diff --git a/contrib/vacuumlo/vacuumlo.c b/contrib/vacuumlo/vacuumlo.c index 861244fea7..810f9cd36c 100644 --- a/contrib/vacuumlo/vacuumlo.c +++ b/contrib/vacuumlo/vacuumlo.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/contrib/vacuumlo/vacuumlo.c,v 1.29 2004/12/31 21:58:50 pgsql Exp $ + * $PostgreSQL: pgsql/contrib/vacuumlo/vacuumlo.c,v 1.30 2005/10/15 02:49:08 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -130,8 +130,8 @@ vacuumlo(char *database, struct _param * param) PQclear(res); /* - * Vacuum the temp table so that planner will generate decent plans - * for the DELETEs below. + * Vacuum the temp table so that planner will generate decent plans for + * the DELETEs below. */ buf[0] = '\0'; strcat(buf, "VACUUM ANALYZE vacuum_l"); @@ -193,8 +193,8 @@ vacuumlo(char *database, struct _param * param) /* * The "IN" construct used here was horribly inefficient before - * Postgres 7.4, but should be now competitive if not better than - * the bogus join we used before. + * Postgres 7.4, but should be now competitive if not better than the + * bogus join we used before. */ snprintf(buf, BUFSIZE, "DELETE FROM vacuum_l " @@ -216,10 +216,9 @@ vacuumlo(char *database, struct _param * param) PQclear(res); /* - * Run the actual deletes in a single transaction. Note that this - * would be a bad idea in pre-7.1 Postgres releases (since rolling - * back a table delete used to cause problems), but it should be safe - * now. + * Run the actual deletes in a single transaction. Note that this would + * be a bad idea in pre-7.1 Postgres releases (since rolling back a table + * delete used to cause problems), but it should be safe now. */ res = PQexec(conn, "begin"); PQclear(res); @@ -277,7 +276,7 @@ vacuumlo(char *database, struct _param * param) if (param->verbose) fprintf(stdout, "\r%s %d large objects from %s.\n", - (param->dry_run ? "Would remove" : "Removed"), deleted, database); + (param->dry_run ? "Would remove" : "Removed"), deleted, database); return 0; } diff --git a/contrib/xml2/xpath.c b/contrib/xml2/xpath.c index 98a5e3a0e2..b4b06a039d 100644 --- a/contrib/xml2/xpath.c +++ b/contrib/xml2/xpath.c @@ -194,10 +194,11 @@ PG_FUNCTION_INFO_V1(xml_encode_special_chars); Datum xml_encode_special_chars(PG_FUNCTION_ARGS) { - text *tin = PG_GETARG_TEXT_P(0); - text *tout; - int32 ressize; - xmlChar *ts, *tt; + text *tin = PG_GETARG_TEXT_P(0); + text *tout; + int32 ressize; + xmlChar *ts, + *tt; ts = pgxml_texttoxmlchar(tin); @@ -225,15 +226,15 @@ pgxmlNodeSetToText(xmlNodeSetPtr nodeset, /* Function translates a nodeset into a text representation */ /* - * iterates over each node in the set and calls xmlNodeDump to write - * it to an xmlBuffer -from which an xmlChar * string is returned. + * iterates over each node in the set and calls xmlNodeDump to write it to + * an xmlBuffer -from which an xmlChar * string is returned. */ /* each representation is surrounded by ... */ /* - * plainsep is an ordinary (not tag) seperator - if used, then nodes - * are cast to string as output method + * plainsep is an ordinary (not tag) seperator - if used, then nodes are + * cast to string as output method */ @@ -257,7 +258,7 @@ pgxmlNodeSetToText(xmlNodeSetPtr nodeset, if (plainsep != NULL) { xmlBufferWriteCHAR(buf, - xmlXPathCastNodeToString(nodeset->nodeTab[i])); + xmlXPathCastNodeToString(nodeset->nodeTab[i])); /* If this isn't the last entry, write the plain sep. */ if (i < (nodeset->nodeNr) - 1) @@ -412,8 +413,8 @@ xpath_string(PG_FUNCTION_ARGS) pathsize = VARSIZE(xpathsupp) - VARHDRSZ; /* - * We encapsulate the supplied path with "string()" = 8 chars + 1 for - * NUL at end + * We encapsulate the supplied path with "string()" = 8 chars + 1 for NUL + * at end */ /* We could try casting to string using the libxml function? */ @@ -663,8 +664,8 @@ xpath_table(PG_FUNCTION_ARGS) int proc; int i; int j; - int rownr; /* For issuing multiple rows from one - * original document */ + int rownr; /* For issuing multiple rows from one original + * document */ int had_values; /* To determine end of nodeset results */ StringInfo querysql; @@ -686,17 +687,19 @@ xpath_table(PG_FUNCTION_ARGS) if (!(rsinfo->allowedModes & SFRM_Materialize)) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("xpath_table requires Materialize mode, but it is not " - "allowed in this context"))); + errmsg("xpath_table requires Materialize mode, but it is not " + "allowed in this context"))); - /* The tuplestore must exist in a higher context than - * this function call (per_query_ctx is used) + /* + * The tuplestore must exist in a higher context than this function call + * (per_query_ctx is used) */ per_query_ctx = rsinfo->econtext->ecxt_per_query_memory; oldcontext = MemoryContextSwitchTo(per_query_ctx); - /* Create the tuplestore - work_mem is the max in-memory size before a + /* + * Create the tuplestore - work_mem is the max in-memory size before a * file is created on disk to hold it. */ tupstore = tuplestore_begin_heap(true, false, work_mem); @@ -707,11 +710,11 @@ xpath_table(PG_FUNCTION_ARGS) ret_tupdesc = CreateTupleDescCopy(rsinfo->expectedDesc); /* - * At the moment we assume that the returned attributes make sense for - * the XPath specififed (i.e. we trust the caller). It's not fatal if - * they get it wrong - the input function for the column type will - * raise an error if the path result can't be converted into the - * correct binary representation. + * At the moment we assume that the returned attributes make sense for the + * XPath specififed (i.e. we trust the caller). It's not fatal if they get + * it wrong - the input function for the column type will raise an error + * if the path result can't be converted into the correct binary + * representation. */ attinmeta = TupleDescGetAttInMetadata(ret_tupdesc); @@ -810,8 +813,8 @@ xpath_table(PG_FUNCTION_ARGS) /* - * Clear the values array, so that not-well-formed documents - * return NULL in all columns. + * Clear the values array, so that not-well-formed documents return + * NULL in all columns. */ /* Note that this also means that spare columns will be NULL. */ @@ -825,8 +828,7 @@ xpath_table(PG_FUNCTION_ARGS) doctree = xmlParseMemory(xmldoc, strlen(xmldoc)); if (doctree == NULL) - { /* not well-formed, so output all-NULL - * tuple */ + { /* not well-formed, so output all-NULL tuple */ ret_tuple = BuildTupleFromCStrings(attinmeta, values); oldcontext = MemoryContextSwitchTo(per_query_ctx); @@ -933,10 +935,10 @@ xpath_table(PG_FUNCTION_ARGS) /* * SFRM_Materialize mode expects us to return a NULL Datum. The actual - * tuples are in our tuplestore and passed back through - * rsinfo->setResult. rsinfo->setDesc is set to the tuple description - * that we actually used to build our tuples with, so the caller can - * verify we did what it was expecting. + * tuples are in our tuplestore and passed back through rsinfo->setResult. + * rsinfo->setDesc is set to the tuple description that we actually used + * to build our tuples with, so the caller can verify we did what it was + * expecting. */ return (Datum) 0; diff --git a/contrib/xml2/xslt_proc.c b/contrib/xml2/xslt_proc.c index 7b044a9e8a..ff2ab8d045 100644 --- a/contrib/xml2/xslt_proc.c +++ b/contrib/xml2/xslt_proc.c @@ -65,7 +65,7 @@ xslt_process(PG_FUNCTION_ARGS) parse_params(params, paramstr); } else - /* No parameters */ + /* No parameters */ params[0] = NULL; /* Setup parser */ diff --git a/src/backend/access/common/heaptuple.c b/src/backend/access/common/heaptuple.c index 8b9714184c..2ba59ab5e9 100644 --- a/src/backend/access/common/heaptuple.c +++ b/src/backend/access/common/heaptuple.c @@ -6,7 +6,7 @@ * * NOTE: there is massive duplication of code in this module to * support both the convention that a null is marked by a bool TRUE, - * and the convention that a null is marked by a char 'n'. The latter + * and the convention that a null is marked by a char 'n'. The latter * convention is deprecated but it'll probably be a long time before * we can get rid of it entirely. * @@ -16,7 +16,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/common/heaptuple.c,v 1.99 2005/03/21 01:23:55 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/common/heaptuple.c,v 1.100 2005/10/15 02:49:08 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -452,8 +452,8 @@ nocachegetattr(HeapTuple tuple, int j; /* - * In for(), we test <= and not < because we want to see if we - * can go past it in initializing offsets. + * In for(), we test <= and not < because we want to see if we can + * go past it in initializing offsets. */ for (j = 0; j <= attnum; j++) { @@ -467,10 +467,9 @@ nocachegetattr(HeapTuple tuple, } /* - * If slow is false, and we got here, we know that we have a tuple - * with no nulls or var-widths before the target attribute. If - * possible, we also want to initialize the remainder of the attribute - * cached offset values. + * If slow is false, and we got here, we know that we have a tuple with no + * nulls or var-widths before the target attribute. If possible, we also + * want to initialize the remainder of the attribute cached offset values. */ if (!slow) { @@ -513,11 +512,11 @@ nocachegetattr(HeapTuple tuple, /* * Now we know that we have to walk the tuple CAREFULLY. * - * Note - This loop is a little tricky. For each non-null attribute, - * we have to first account for alignment padding before the attr, - * then advance over the attr based on its length. Nulls have no - * storage and no alignment padding either. We can use/set attcacheoff - * until we pass either a null or a var-width attribute. + * Note - This loop is a little tricky. For each non-null attribute, we + * have to first account for alignment padding before the attr, then + * advance over the attr based on its length. Nulls have no storage + * and no alignment padding either. We can use/set attcacheoff until + * we pass either a null or a var-width attribute. */ for (i = 0; i < attnum; i++) @@ -597,15 +596,13 @@ heap_getsysattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull) break; /* - * If the attribute number is 0, then we are supposed to - * return the entire tuple as a row-type Datum. (Using zero - * for this purpose is unclean since it risks confusion with - * "invalid attr" result codes, but it's not worth changing - * now.) + * If the attribute number is 0, then we are supposed to return + * the entire tuple as a row-type Datum. (Using zero for this + * purpose is unclean since it risks confusion with "invalid attr" + * result codes, but it's not worth changing now.) * - * We have to make a copy of the tuple so we can safely insert - * the Datum overhead fields, which are not set in on-disk - * tuples. + * We have to make a copy of the tuple so we can safely insert the + * Datum overhead fields, which are not set in on-disk tuples. */ case InvalidAttrNumber: { @@ -708,15 +705,15 @@ heap_form_tuple(TupleDesc tupleDescriptor, numberOfAttributes, MaxTupleAttributeNumber))); /* - * Check for nulls and embedded tuples; expand any toasted attributes - * in embedded tuples. This preserves the invariant that toasting can - * only go one level deep. + * Check for nulls and embedded tuples; expand any toasted attributes in + * embedded tuples. This preserves the invariant that toasting can only + * go one level deep. * * We can skip calling toast_flatten_tuple_attribute() if the attribute * couldn't possibly be of composite type. All composite datums are - * varlena and have alignment 'd'; furthermore they aren't arrays. - * Also, if an attribute is already toasted, it must have been sent to - * disk already and so cannot contain toasted attributes. + * varlena and have alignment 'd'; furthermore they aren't arrays. Also, + * if an attribute is already toasted, it must have been sent to disk + * already and so cannot contain toasted attributes. */ for (i = 0; i < numberOfAttributes; i++) { @@ -757,8 +754,8 @@ heap_form_tuple(TupleDesc tupleDescriptor, tuple->t_data = td = (HeapTupleHeader) ((char *) tuple + HEAPTUPLESIZE); /* - * And fill in the information. Note we fill the Datum fields even - * though this tuple may never become a Datum. + * And fill in the information. Note we fill the Datum fields even though + * this tuple may never become a Datum. */ tuple->t_len = len; ItemPointerSetInvalid(&(tuple->t_self)); @@ -816,15 +813,15 @@ heap_formtuple(TupleDesc tupleDescriptor, numberOfAttributes, MaxTupleAttributeNumber))); /* - * Check for nulls and embedded tuples; expand any toasted attributes - * in embedded tuples. This preserves the invariant that toasting can - * only go one level deep. + * Check for nulls and embedded tuples; expand any toasted attributes in + * embedded tuples. This preserves the invariant that toasting can only + * go one level deep. * * We can skip calling toast_flatten_tuple_attribute() if the attribute * couldn't possibly be of composite type. All composite datums are - * varlena and have alignment 'd'; furthermore they aren't arrays. - * Also, if an attribute is already toasted, it must have been sent to - * disk already and so cannot contain toasted attributes. + * varlena and have alignment 'd'; furthermore they aren't arrays. Also, + * if an attribute is already toasted, it must have been sent to disk + * already and so cannot contain toasted attributes. */ for (i = 0; i < numberOfAttributes; i++) { @@ -865,8 +862,8 @@ heap_formtuple(TupleDesc tupleDescriptor, tuple->t_data = td = (HeapTupleHeader) ((char *) tuple + HEAPTUPLESIZE); /* - * And fill in the information. Note we fill the Datum fields even - * though this tuple may never become a Datum. + * And fill in the information. Note we fill the Datum fields even though + * this tuple may never become a Datum. */ tuple->t_len = len; ItemPointerSetInvalid(&(tuple->t_self)); @@ -917,15 +914,15 @@ heap_modify_tuple(HeapTuple tuple, HeapTuple newTuple; /* - * allocate and fill values and isnull arrays from either the tuple or - * the repl information, as appropriate. + * allocate and fill values and isnull arrays from either the tuple or the + * repl information, as appropriate. * * NOTE: it's debatable whether to use heap_deform_tuple() here or just - * heap_getattr() only the non-replaced colums. The latter could win - * if there are many replaced columns and few non-replaced ones. - * However, heap_deform_tuple costs only O(N) while the heap_getattr - * way would cost O(N^2) if there are many non-replaced columns, so it - * seems better to err on the side of linear cost. + * heap_getattr() only the non-replaced colums. The latter could win if + * there are many replaced columns and few non-replaced ones. However, + * heap_deform_tuple costs only O(N) while the heap_getattr way would cost + * O(N^2) if there are many non-replaced columns, so it seems better to + * err on the side of linear cost. */ values = (Datum *) palloc(numberOfAttributes * sizeof(Datum)); isnull = (bool *) palloc(numberOfAttributes * sizeof(bool)); @@ -950,8 +947,8 @@ heap_modify_tuple(HeapTuple tuple, pfree(isnull); /* - * copy the identification info of the old tuple: t_ctid, t_self, and - * OID (if any) + * copy the identification info of the old tuple: t_ctid, t_self, and OID + * (if any) */ newTuple->t_data->t_ctid = tuple->t_data->t_ctid; newTuple->t_self = tuple->t_self; @@ -986,15 +983,15 @@ heap_modifytuple(HeapTuple tuple, HeapTuple newTuple; /* - * allocate and fill values and nulls arrays from either the tuple or - * the repl information, as appropriate. + * allocate and fill values and nulls arrays from either the tuple or the + * repl information, as appropriate. * * NOTE: it's debatable whether to use heap_deformtuple() here or just - * heap_getattr() only the non-replaced colums. The latter could win - * if there are many replaced columns and few non-replaced ones. - * However, heap_deformtuple costs only O(N) while the heap_getattr - * way would cost O(N^2) if there are many non-replaced columns, so it - * seems better to err on the side of linear cost. + * heap_getattr() only the non-replaced colums. The latter could win if + * there are many replaced columns and few non-replaced ones. However, + * heap_deformtuple costs only O(N) while the heap_getattr way would cost + * O(N^2) if there are many non-replaced columns, so it seems better to + * err on the side of linear cost. */ values = (Datum *) palloc(numberOfAttributes * sizeof(Datum)); nulls = (char *) palloc(numberOfAttributes * sizeof(char)); @@ -1022,8 +1019,8 @@ heap_modifytuple(HeapTuple tuple, pfree(nulls); /* - * copy the identification info of the old tuple: t_ctid, t_self, and - * OID (if any) + * copy the identification info of the old tuple: t_ctid, t_self, and OID + * (if any) */ newTuple->t_data->t_ctid = tuple->t_data->t_ctid; newTuple->t_self = tuple->t_self; @@ -1068,9 +1065,9 @@ heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc, natts = tup->t_natts; /* - * In inheritance situations, it is possible that the given tuple - * actually has more fields than the caller is expecting. Don't run - * off the end of the caller's arrays. + * In inheritance situations, it is possible that the given tuple actually + * has more fields than the caller is expecting. Don't run off the end of + * the caller's arrays. */ natts = Min(natts, tdesc_natts); @@ -1161,9 +1158,9 @@ heap_deformtuple(HeapTuple tuple, natts = tup->t_natts; /* - * In inheritance situations, it is possible that the given tuple - * actually has more fields than the caller is expecting. Don't run - * off the end of the caller's arrays. + * In inheritance situations, it is possible that the given tuple actually + * has more fields than the caller is expecting. Don't run off the end of + * the caller's arrays. */ natts = Min(natts, tdesc_natts); @@ -1228,22 +1225,22 @@ heap_deformtuple(HeapTuple tuple, static void slot_deform_tuple(TupleTableSlot *slot, int natts) { - HeapTuple tuple = slot->tts_tuple; - TupleDesc tupleDesc = slot->tts_tupleDescriptor; + HeapTuple tuple = slot->tts_tuple; + TupleDesc tupleDesc = slot->tts_tupleDescriptor; Datum *values = slot->tts_values; bool *isnull = slot->tts_isnull; - HeapTupleHeader tup = tuple->t_data; + HeapTupleHeader tup = tuple->t_data; bool hasnulls = HeapTupleHasNulls(tuple); Form_pg_attribute *att = tupleDesc->attrs; int attnum; - char *tp; /* ptr to tuple data */ - long off; /* offset in tuple data */ - bits8 *bp = tup->t_bits; /* ptr to null bitmap in tuple */ - bool slow; /* can we use/set attcacheoff? */ + char *tp; /* ptr to tuple data */ + long off; /* offset in tuple data */ + bits8 *bp = tup->t_bits; /* ptr to null bitmap in tuple */ + bool slow; /* can we use/set attcacheoff? */ /* - * Check whether the first call for this tuple, and initialize or - * restore loop state. + * Check whether the first call for this tuple, and initialize or restore + * loop state. */ attnum = slot->tts_nvalid; if (attnum == 0) @@ -1269,7 +1266,7 @@ slot_deform_tuple(TupleTableSlot *slot, int natts) { values[attnum] = (Datum) 0; isnull[attnum] = true; - slow = true; /* can't use attcacheoff anymore */ + slow = true; /* can't use attcacheoff anymore */ continue; } @@ -1290,7 +1287,7 @@ slot_deform_tuple(TupleTableSlot *slot, int natts) off = att_addlength(off, thisatt->attlen, tp + off); if (thisatt->attlen <= 0) - slow = true; /* can't use attcacheoff anymore */ + slow = true; /* can't use attcacheoff anymore */ } /* @@ -1316,9 +1313,9 @@ slot_deform_tuple(TupleTableSlot *slot, int natts) Datum slot_getattr(TupleTableSlot *slot, int attnum, bool *isnull) { - HeapTuple tuple = slot->tts_tuple; - TupleDesc tupleDesc = slot->tts_tupleDescriptor; - HeapTupleHeader tup; + HeapTuple tuple = slot->tts_tuple; + TupleDesc tupleDesc = slot->tts_tupleDescriptor; + HeapTupleHeader tup; /* * system attributes are handled by heap_getsysattr @@ -1349,18 +1346,18 @@ slot_getattr(TupleTableSlot *slot, int attnum, bool *isnull) } /* - * otherwise we had better have a physical tuple (tts_nvalid should - * equal natts in all virtual-tuple cases) + * otherwise we had better have a physical tuple (tts_nvalid should equal + * natts in all virtual-tuple cases) */ - if (tuple == NULL) /* internal error */ + if (tuple == NULL) /* internal error */ elog(ERROR, "cannot extract attribute from empty tuple slot"); /* * return NULL if attnum is out of range according to the tuple * - * (We have to check this separately because of various inheritance - * and table-alteration scenarios: the tuple could be either longer - * or shorter than the tupdesc.) + * (We have to check this separately because of various inheritance and + * table-alteration scenarios: the tuple could be either longer or shorter + * than the tupdesc.) */ tup = tuple->t_data; if (attnum > tup->t_natts) @@ -1379,10 +1376,9 @@ slot_getattr(TupleTableSlot *slot, int attnum, bool *isnull) } /* - * If the attribute's column has been dropped, we force a NULL - * result. This case should not happen in normal use, but it could - * happen if we are executing a plan cached before the column was - * dropped. + * If the attribute's column has been dropped, we force a NULL result. + * This case should not happen in normal use, but it could happen if we + * are executing a plan cached before the column was dropped. */ if (tupleDesc->attrs[attnum - 1]->attisdropped) { @@ -1420,11 +1416,11 @@ slot_getallattrs(TupleTableSlot *slot) return; /* - * otherwise we had better have a physical tuple (tts_nvalid should - * equal natts in all virtual-tuple cases) + * otherwise we had better have a physical tuple (tts_nvalid should equal + * natts in all virtual-tuple cases) */ tuple = slot->tts_tuple; - if (tuple == NULL) /* internal error */ + if (tuple == NULL) /* internal error */ elog(ERROR, "cannot extract attribute from empty tuple slot"); /* @@ -1467,11 +1463,11 @@ slot_getsomeattrs(TupleTableSlot *slot, int attnum) elog(ERROR, "invalid attribute number %d", attnum); /* - * otherwise we had better have a physical tuple (tts_nvalid should - * equal natts in all virtual-tuple cases) + * otherwise we had better have a physical tuple (tts_nvalid should equal + * natts in all virtual-tuple cases) */ tuple = slot->tts_tuple; - if (tuple == NULL) /* internal error */ + if (tuple == NULL) /* internal error */ elog(ERROR, "cannot extract attribute from empty tuple slot"); /* @@ -1502,8 +1498,8 @@ slot_getsomeattrs(TupleTableSlot *slot, int attnum) bool slot_attisnull(TupleTableSlot *slot, int attnum) { - HeapTuple tuple = slot->tts_tuple; - TupleDesc tupleDesc = slot->tts_tupleDescriptor; + HeapTuple tuple = slot->tts_tuple; + TupleDesc tupleDesc = slot->tts_tupleDescriptor; /* * system attributes are handled by heap_attisnull @@ -1528,10 +1524,10 @@ slot_attisnull(TupleTableSlot *slot, int attnum) return true; /* - * otherwise we had better have a physical tuple (tts_nvalid should - * equal natts in all virtual-tuple cases) + * otherwise we had better have a physical tuple (tts_nvalid should equal + * natts in all virtual-tuple cases) */ - if (tuple == NULL) /* internal error */ + if (tuple == NULL) /* internal error */ elog(ERROR, "cannot extract attribute from empty tuple slot"); /* and let the tuple tell it */ diff --git a/src/backend/access/common/indextuple.c b/src/backend/access/common/indextuple.c index e5d19765e7..b3520baa2b 100644 --- a/src/backend/access/common/indextuple.c +++ b/src/backend/access/common/indextuple.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/common/indextuple.c,v 1.74 2005/03/27 18:38:26 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/common/indextuple.c,v 1.75 2005/10/15 02:49:08 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -70,20 +70,20 @@ index_form_tuple(TupleDesc tupleDescriptor, continue; /* - * If value is stored EXTERNAL, must fetch it so we are not - * depending on outside storage. This should be improved someday. + * If value is stored EXTERNAL, must fetch it so we are not depending + * on outside storage. This should be improved someday. */ if (VARATT_IS_EXTERNAL(values[i])) { untoasted_values[i] = PointerGetDatum( - heap_tuple_fetch_attr( - (varattrib *) DatumGetPointer(values[i]))); + heap_tuple_fetch_attr( + (varattrib *) DatumGetPointer(values[i]))); untoasted_free[i] = true; } /* - * If value is above size target, and is of a compressible - * datatype, try to compress it in-line. + * If value is above size target, and is of a compressible datatype, + * try to compress it in-line. */ if (VARATT_SIZE(untoasted_values[i]) > TOAST_INDEX_TARGET && !VARATT_IS_EXTENDED(untoasted_values[i]) && @@ -149,23 +149,23 @@ index_form_tuple(TupleDesc tupleDescriptor, /* * We do this because heap_fill_tuple wants to initialize a "tupmask" - * which is used for HeapTuples, but we want an indextuple infomask. - * The only relevant info is the "has variable attributes" field. - * We have already set the hasnull bit above. + * which is used for HeapTuples, but we want an indextuple infomask. The + * only relevant info is the "has variable attributes" field. We have + * already set the hasnull bit above. */ if (tupmask & HEAP_HASVARWIDTH) infomask |= INDEX_VAR_MASK; /* - * Here we make sure that the size will fit in the field reserved for - * it in t_info. + * Here we make sure that the size will fit in the field reserved for it + * in t_info. */ if ((size & INDEX_SIZE_MASK) != size) ereport(ERROR, (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), - errmsg("index row requires %lu bytes, maximum size is %lu", - (unsigned long) size, - (unsigned long) INDEX_SIZE_MASK))); + errmsg("index row requires %lu bytes, maximum size is %lu", + (unsigned long) size, + (unsigned long) INDEX_SIZE_MASK))); infomask |= size; @@ -322,10 +322,9 @@ nocache_index_getattr(IndexTuple tup, } /* - * If slow is false, and we got here, we know that we have a tuple - * with no nulls or var-widths before the target attribute. If - * possible, we also want to initialize the remainder of the attribute - * cached offset values. + * If slow is false, and we got here, we know that we have a tuple with no + * nulls or var-widths before the target attribute. If possible, we also + * want to initialize the remainder of the attribute cached offset values. */ if (!slow) { diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 9080d047fc..96dfafb7cb 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -9,7 +9,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/common/printtup.c,v 1.91 2005/06/22 17:45:45 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/common/printtup.c,v 1.92 2005/10/15 02:49:08 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -78,9 +78,9 @@ printtup_create_DR(CommandDest dest, Portal portal) else { /* - * In protocol 2.0 the Bind message does not exist, so there is no - * way for the columns to have different print formats; it's - * sufficient to look at the first one. + * In protocol 2.0 the Bind message does not exist, so there is no way + * for the columns to have different print formats; it's sufficient to + * look at the first one. */ if (portal->formats && portal->formats[0] != 0) self->pub.receiveSlot = printtup_internal_20; @@ -113,8 +113,7 @@ printtup_startup(DestReceiver *self, int operation, TupleDesc typeinfo) if (PG_PROTOCOL_MAJOR(FrontendProtocol) < 3) { /* - * Send portal name to frontend (obsolete cruft, gone in proto - * 3.0) + * Send portal name to frontend (obsolete cruft, gone in proto 3.0) * * If portal name not specified, use "blank" portal. */ @@ -127,8 +126,8 @@ printtup_startup(DestReceiver *self, int operation, TupleDesc typeinfo) } /* - * If this is a retrieve, and we are supposed to emit row - * descriptions, then we send back the tuple descriptor of the tuples. + * If this is a retrieve, and we are supposed to emit row descriptions, + * then we send back the tuple descriptor of the tuples. */ if (operation == CMD_SELECT && myState->sendDescrip) SendRowDescriptionMessage(typeinfo, @@ -280,7 +279,7 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) static void printtup(TupleTableSlot *slot, DestReceiver *self) { - TupleDesc typeinfo = slot->tts_tupleDescriptor; + TupleDesc typeinfo = slot->tts_tupleDescriptor; DR_printtup *myState = (DR_printtup *) self; StringInfoData buf; int natts = typeinfo->natts; @@ -363,7 +362,7 @@ printtup(TupleTableSlot *slot, DestReceiver *self) static void printtup_20(TupleTableSlot *slot, DestReceiver *self) { - TupleDesc typeinfo = slot->tts_tupleDescriptor; + TupleDesc typeinfo = slot->tts_tupleDescriptor; DR_printtup *myState = (DR_printtup *) self; StringInfoData buf; int natts = typeinfo->natts; @@ -566,7 +565,7 @@ debugtup(TupleTableSlot *slot, DestReceiver *self) static void printtup_internal_20(TupleTableSlot *slot, DestReceiver *self) { - TupleDesc typeinfo = slot->tts_tupleDescriptor; + TupleDesc typeinfo = slot->tts_tupleDescriptor; DR_printtup *myState = (DR_printtup *) self; StringInfoData buf; int natts = typeinfo->natts; diff --git a/src/backend/access/common/tupdesc.c b/src/backend/access/common/tupdesc.c index fedc7ec489..cfa455beec 100644 --- a/src/backend/access/common/tupdesc.c +++ b/src/backend/access/common/tupdesc.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/common/tupdesc.c,v 1.111 2005/04/14 22:34:48 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/common/tupdesc.c,v 1.112 2005/10/15 02:49:08 momjian Exp $ * * NOTES * some of the executor utility code such as "ExecTypeFromTL" should be @@ -49,10 +49,10 @@ CreateTemplateTupleDesc(int natts, bool hasoid) * Allocate enough memory for the tuple descriptor, including the * attribute rows, and set up the attribute row pointers. * - * Note: we assume that sizeof(struct tupleDesc) is a multiple of - * the struct pointer alignment requirement, and hence we don't need - * to insert alignment padding between the struct and the array of - * attribute row pointers. + * Note: we assume that sizeof(struct tupleDesc) is a multiple of the struct + * pointer alignment requirement, and hence we don't need to insert + * alignment padding between the struct and the array of attribute row + * pointers. */ attroffset = sizeof(struct tupleDesc) + natts * sizeof(Form_pg_attribute); attroffset = MAXALIGN(attroffset); @@ -273,16 +273,16 @@ equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2) Form_pg_attribute attr2 = tupdesc2->attrs[i]; /* - * We do not need to check every single field here: we can - * disregard attrelid and attnum (which were used to place the row - * in the attrs array in the first place). It might look like we - * could dispense with checking attlen/attbyval/attalign, since these - * are derived from atttypid; but in the case of dropped columns - * we must check them (since atttypid will be zero for all dropped - * columns) and in general it seems safer to check them always. + * We do not need to check every single field here: we can disregard + * attrelid and attnum (which were used to place the row in the attrs + * array in the first place). It might look like we could dispense + * with checking attlen/attbyval/attalign, since these are derived + * from atttypid; but in the case of dropped columns we must check + * them (since atttypid will be zero for all dropped columns) and in + * general it seems safer to check them always. * - * attcacheoff must NOT be checked since it's possibly not set - * in both copies. + * attcacheoff must NOT be checked since it's possibly not set in both + * copies. */ if (strcmp(NameStr(attr1->attname), NameStr(attr2->attname)) != 0) return false; @@ -332,9 +332,9 @@ equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2) AttrDefault *defval2 = constr2->defval; /* - * We can't assume that the items are always read from the - * system catalogs in the same order; so use the adnum field - * to identify the matching item to compare. + * We can't assume that the items are always read from the system + * catalogs in the same order; so use the adnum field to identify + * the matching item to compare. */ for (j = 0; j < n; defval2++, j++) { @@ -355,9 +355,9 @@ equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2) ConstrCheck *check2 = constr2->check; /* - * Similarly, don't assume that the checks are always read in - * the same order; match them up by name and contents. (The - * name *should* be unique, but...) + * Similarly, don't assume that the checks are always read in the + * same order; match them up by name and contents. (The name + * *should* be unique, but...) */ for (j = 0; j < n; check2++, j++) { @@ -407,8 +407,8 @@ TupleDescInitEntry(TupleDesc desc, /* * Note: attributeName can be NULL, because the planner doesn't always - * fill in valid resname values in targetlists, particularly for - * resjunk attributes. + * fill in valid resname values in targetlists, particularly for resjunk + * attributes. */ if (attributeName != NULL) namestrcpy(&(att->attname), attributeName); @@ -482,8 +482,8 @@ BuildDescForRelation(List *schema) ColumnDef *entry = lfirst(l); /* - * for each entry in the list, get the name and type information - * from the list and have TupleDescInitEntry fill in the attribute + * for each entry in the list, get the name and type information from + * the list and have TupleDescInitEntry fill in the attribute * information we need. */ attnum++; @@ -508,8 +508,8 @@ BuildDescForRelation(List *schema) desc->attrs[attnum - 1]->attnotnull = entry->is_not_null; /* - * Note we copy only pre-cooked default expressions. Digestion of - * raw ones is someone else's problem. + * Note we copy only pre-cooked default expressions. Digestion of raw + * ones is someone else's problem. */ if (entry->cooked_default != NULL) { diff --git a/src/backend/access/gist/gistproc.c b/src/backend/access/gist/gistproc.c index 5978c8af4c..b9e0469b05 100644 --- a/src/backend/access/gist/gistproc.c +++ b/src/backend/access/gist/gistproc.c @@ -10,7 +10,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/gist/gistproc.c,v 1.2 2005/09/22 20:44:36 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/gist/gistproc.c,v 1.3 2005/10/15 02:49:08 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -26,7 +26,7 @@ typedef struct { BOX *key; int pos; -} KBsort; +} KBsort; static int compare_KB(const void *a, const void *b); static bool gist_box_leaf_consistent(BOX *key, BOX *query, diff --git a/src/backend/access/hash/hash.c b/src/backend/access/hash/hash.c index f8611ce46a..2cff9509b6 100644 --- a/src/backend/access/hash/hash.c +++ b/src/backend/access/hash/hash.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/hash/hash.c,v 1.80 2005/06/06 17:01:21 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/hash/hash.c,v 1.81 2005/10/15 02:49:08 momjian Exp $ * * NOTES * This file contains only the public interface routines. @@ -55,8 +55,8 @@ hashbuild(PG_FUNCTION_ARGS) HashBuildState buildstate; /* - * We expect to be called exactly once for any index relation. If - * that's not the case, big trouble's what we have. + * We expect to be called exactly once for any index relation. If that's + * not the case, big trouble's what we have. */ if (RelationGetNumberOfBlocks(index) != 0) elog(ERROR, "index \"%s\" already contains data", @@ -70,7 +70,7 @@ hashbuild(PG_FUNCTION_ARGS) /* do the heap scan */ reltuples = IndexBuildHeapScan(heap, index, indexInfo, - hashbuildCallback, (void *) &buildstate); + hashbuildCallback, (void *) &buildstate); /* since we just counted the # of tuples, may as well update stats */ IndexCloseAndUpdateStats(heap, reltuples, index, buildstate.indtuples); @@ -141,12 +141,12 @@ hashinsert(PG_FUNCTION_ARGS) /* * If the single index key is null, we don't insert it into the index. - * Hash tables support scans on '='. Relational algebra says that A = - * B returns null if either A or B is null. This means that no - * qualification used in an index scan could ever return true on a - * null attribute. It also means that indices can't be used by ISNULL - * or NOTNULL scans, but that's an artifact of the strategy map - * architecture chosen in 1986, not of the way nulls are handled here. + * Hash tables support scans on '='. Relational algebra says that A = B + * returns null if either A or B is null. This means that no + * qualification used in an index scan could ever return true on a null + * attribute. It also means that indices can't be used by ISNULL or + * NOTNULL scans, but that's an artifact of the strategy map architecture + * chosen in 1986, not of the way nulls are handled here. */ if (IndexTupleHasNulls(itup)) { @@ -180,16 +180,16 @@ hashgettuple(PG_FUNCTION_ARGS) bool res; /* - * We hold pin but not lock on current buffer while outside the hash - * AM. Reacquire the read lock here. + * We hold pin but not lock on current buffer while outside the hash AM. + * Reacquire the read lock here. */ if (BufferIsValid(so->hashso_curbuf)) _hash_chgbufaccess(rel, so->hashso_curbuf, HASH_NOLOCK, HASH_READ); /* - * If we've already initialized this scan, we can just advance it in - * the appropriate direction. If we haven't done so yet, we call a - * routine to get the first item in the scan. + * If we've already initialized this scan, we can just advance it in the + * appropriate direction. If we haven't done so yet, we call a routine to + * get the first item in the scan. */ if (ItemPointerIsValid(&(scan->currentItemData))) { @@ -199,17 +199,16 @@ hashgettuple(PG_FUNCTION_ARGS) if (scan->kill_prior_tuple) { /* - * Yes, so mark it by setting the LP_DELETE bit in the item - * flags. + * Yes, so mark it by setting the LP_DELETE bit in the item flags. */ offnum = ItemPointerGetOffsetNumber(&(scan->currentItemData)); page = BufferGetPage(so->hashso_curbuf); PageGetItemId(page, offnum)->lp_flags |= LP_DELETE; /* - * Since this can be redone later if needed, it's treated the - * same as a commit-hint-bit status update for heap tuples: we - * mark the buffer dirty but don't make a WAL log entry. + * Since this can be redone later if needed, it's treated the same + * as a commit-hint-bit status update for heap tuples: we mark the + * buffer dirty but don't make a WAL log entry. */ SetBufferCommitInfoNeedsSave(so->hashso_curbuf); } @@ -256,7 +255,7 @@ Datum hashgetmulti(PG_FUNCTION_ARGS) { IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0); - ItemPointer tids = (ItemPointer) PG_GETARG_POINTER(1); + ItemPointer tids = (ItemPointer) PG_GETARG_POINTER(1); int32 max_tids = PG_GETARG_INT32(2); int32 *returned_tids = (int32 *) PG_GETARG_POINTER(3); HashScanOpaque so = (HashScanOpaque) scan->opaque; @@ -265,8 +264,8 @@ hashgetmulti(PG_FUNCTION_ARGS) int32 ntids = 0; /* - * We hold pin but not lock on current buffer while outside the hash - * AM. Reacquire the read lock here. + * We hold pin but not lock on current buffer while outside the hash AM. + * Reacquire the read lock here. */ if (BufferIsValid(so->hashso_curbuf)) _hash_chgbufaccess(rel, so->hashso_curbuf, HASH_NOLOCK, HASH_READ); @@ -280,6 +279,7 @@ hashgetmulti(PG_FUNCTION_ARGS) res = _hash_next(scan, ForwardScanDirection); else res = _hash_first(scan, ForwardScanDirection); + /* * Skip killed tuples if asked to. */ @@ -505,12 +505,12 @@ hashbulkdelete(PG_FUNCTION_ARGS) num_index_tuples = 0; /* - * Read the metapage to fetch original bucket and tuple counts. Also, - * we keep a copy of the last-seen metapage so that we can use its - * hashm_spares[] values to compute bucket page addresses. This is a - * bit hokey but perfectly safe, since the interesting entries in the - * spares array cannot change under us; and it beats rereading the - * metapage for each bucket. + * Read the metapage to fetch original bucket and tuple counts. Also, we + * keep a copy of the last-seen metapage so that we can use its + * hashm_spares[] values to compute bucket page addresses. This is a bit + * hokey but perfectly safe, since the interesting entries in the spares + * array cannot change under us; and it beats rereading the metapage for + * each bucket. */ metabuf = _hash_getbuf(rel, HASH_METAPAGE, HASH_READ); metap = (HashMetaPage) BufferGetPage(metabuf); @@ -569,7 +569,7 @@ loop_top: ItemPointer htup; hitem = (HashItem) PageGetItem(page, - PageGetItemId(page, offno)); + PageGetItemId(page, offno)); htup = &(hitem->hash_itup.t_tid); if (callback(htup, callback_state)) { @@ -641,8 +641,7 @@ loop_top: { /* * Otherwise, our count is untrustworthy since we may have - * double-scanned tuples in split buckets. Proceed by - * dead-reckoning. + * double-scanned tuples in split buckets. Proceed by dead-reckoning. */ if (metap->hashm_ntuples > tuples_removed) metap->hashm_ntuples -= tuples_removed; diff --git a/src/backend/access/hash/hashfunc.c b/src/backend/access/hash/hashfunc.c index 05ca3bcdb1..2ffca5efe6 100644 --- a/src/backend/access/hash/hashfunc.c +++ b/src/backend/access/hash/hashfunc.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/hash/hashfunc.c,v 1.44 2005/05/25 21:40:40 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/hash/hashfunc.c,v 1.45 2005/10/15 02:49:08 momjian Exp $ * * NOTES * These functions are stored in pg_amproc. For each operator class @@ -46,11 +46,11 @@ hashint8(PG_FUNCTION_ARGS) { /* * The idea here is to produce a hash value compatible with the values - * produced by hashint4 and hashint2 for logically equivalent inputs; - * this is necessary if we ever hope to support cross-type hash joins - * across these input types. Since all three types are signed, we can - * xor the high half of the int8 value if the sign is positive, or the - * complement of the high half when the sign is negative. + * produced by hashint4 and hashint2 for logically equivalent inputs; this + * is necessary if we ever hope to support cross-type hash joins across + * these input types. Since all three types are signed, we can xor the + * high half of the int8 value if the sign is positive, or the complement + * of the high half when the sign is negative. */ #ifndef INT64_IS_BUSTED int64 val = PG_GETARG_INT64(0); @@ -78,9 +78,9 @@ hashfloat4(PG_FUNCTION_ARGS) float4 key = PG_GETARG_FLOAT4(0); /* - * On IEEE-float machines, minus zero and zero have different bit - * patterns but should compare as equal. We must ensure that they - * have the same hash value, which is most easily done this way: + * On IEEE-float machines, minus zero and zero have different bit patterns + * but should compare as equal. We must ensure that they have the same + * hash value, which is most easily done this way: */ if (key == (float4) 0) PG_RETURN_UINT32(0); @@ -94,9 +94,9 @@ hashfloat8(PG_FUNCTION_ARGS) float8 key = PG_GETARG_FLOAT8(0); /* - * On IEEE-float machines, minus zero and zero have different bit - * patterns but should compare as equal. We must ensure that they - * have the same hash value, which is most easily done this way: + * On IEEE-float machines, minus zero and zero have different bit patterns + * but should compare as equal. We must ensure that they have the same + * hash value, which is most easily done this way: */ if (key == (float8) 0) PG_RETURN_UINT32(0); @@ -126,8 +126,7 @@ hashname(PG_FUNCTION_ARGS) char *key = NameStr(*PG_GETARG_NAME(0)); int keylen = strlen(key); - Assert(keylen < NAMEDATALEN); /* else it's not truncated - * correctly */ + Assert(keylen < NAMEDATALEN); /* else it's not truncated correctly */ return hash_any((unsigned char *) key, keylen); } @@ -139,8 +138,8 @@ hashtext(PG_FUNCTION_ARGS) Datum result; /* - * Note: this is currently identical in behavior to hashvarlena, but - * it seems likely that we may need to do something different in non-C + * Note: this is currently identical in behavior to hashvarlena, but it + * seems likely that we may need to do something different in non-C * locales. (See also hashbpchar, if so.) */ result = hash_any((unsigned char *) VARDATA(key), diff --git a/src/backend/access/hash/hashinsert.c b/src/backend/access/hash/hashinsert.c index 860376cd48..7637c3566c 100644 --- a/src/backend/access/hash/hashinsert.c +++ b/src/backend/access/hash/hashinsert.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/hash/hashinsert.c,v 1.37 2005/08/10 21:36:45 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/hash/hashinsert.c,v 1.38 2005/10/15 02:49:08 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -50,8 +50,8 @@ _hash_doinsert(Relation rel, HashItem hitem) bool isnull; /* - * Compute the hash key for the item. We do this first so as not to - * need to hold any locks while running the hash function. + * Compute the hash key for the item. We do this first so as not to need + * to hold any locks while running the hash function. */ itup = &(hitem->hash_itup); if (rel->rd_rel->relnatts != 1) @@ -64,12 +64,12 @@ _hash_doinsert(Relation rel, HashItem hitem) itemsz = IndexTupleDSize(hitem->hash_itup) + (sizeof(HashItemData) - sizeof(IndexTupleData)); - itemsz = MAXALIGN(itemsz); /* be safe, PageAddItem will do this but - * we need to be consistent */ + itemsz = MAXALIGN(itemsz); /* be safe, PageAddItem will do this but we + * need to be consistent */ /* - * Acquire shared split lock so we can compute the target bucket - * safely (see README). + * Acquire shared split lock so we can compute the target bucket safely + * (see README). */ _hash_getlock(rel, 0, HASH_SHARE); @@ -79,9 +79,9 @@ _hash_doinsert(Relation rel, HashItem hitem) _hash_checkpage(rel, (Page) metap, LH_META_PAGE); /* - * Check whether the item can fit on a hash page at all. (Eventually, - * we ought to try to apply TOAST methods if not.) Note that at this - * point, itemsz doesn't include the ItemId. + * Check whether the item can fit on a hash page at all. (Eventually, we + * ought to try to apply TOAST methods if not.) Note that at this point, + * itemsz doesn't include the ItemId. */ if (itemsz > HashMaxItemSize((Page) metap)) ereport(ERROR, @@ -89,7 +89,7 @@ _hash_doinsert(Relation rel, HashItem hitem) errmsg("index row size %lu exceeds hash maximum %lu", (unsigned long) itemsz, (unsigned long) HashMaxItemSize((Page) metap)), - errhint("Values larger than a buffer page cannot be indexed."))); + errhint("Values larger than a buffer page cannot be indexed."))); /* * Compute the target bucket number, and convert to block number. @@ -105,8 +105,7 @@ _hash_doinsert(Relation rel, HashItem hitem) _hash_chgbufaccess(rel, metabuf, HASH_READ, HASH_NOLOCK); /* - * Acquire share lock on target bucket; then we can release split - * lock. + * Acquire share lock on target bucket; then we can release split lock. */ _hash_getlock(rel, blkno, HASH_SHARE); @@ -130,8 +129,8 @@ _hash_doinsert(Relation rel, HashItem hitem) if (BlockNumberIsValid(nextblkno)) { /* - * ovfl page exists; go get it. if it doesn't have room, - * we'll find out next pass through the loop test above. + * ovfl page exists; go get it. if it doesn't have room, we'll + * find out next pass through the loop test above. */ _hash_relbuf(rel, buf); buf = _hash_getbuf(rel, nextblkno, HASH_WRITE); diff --git a/src/backend/access/hash/hashovfl.c b/src/backend/access/hash/hashovfl.c index 1b8b798b45..7289d9a0b3 100644 --- a/src/backend/access/hash/hashovfl.c +++ b/src/backend/access/hash/hashovfl.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/hash/hashovfl.c,v 1.46 2005/05/11 01:26:01 neilc Exp $ + * $PostgreSQL: pgsql/src/backend/access/hash/hashovfl.c,v 1.47 2005/10/15 02:49:08 momjian Exp $ * * NOTES * Overflow pages look like ordinary relation pages. @@ -44,8 +44,8 @@ bitno_to_blkno(HashMetaPage metap, uint32 ovflbitnum) /* loop */ ; /* - * Convert to absolute page number by adding the number of bucket - * pages that exist before this split point. + * Convert to absolute page number by adding the number of bucket pages + * that exist before this split point. */ return (BlockNumber) ((1 << i) + ovflbitnum); } @@ -252,10 +252,10 @@ _hash_getovflpage(Relation rel, Buffer metabuf) /* * We create the new bitmap page with all pages marked "in use". * Actually two pages in the new bitmap's range will exist - * immediately: the bitmap page itself, and the following page - * which is the one we return to the caller. Both of these are - * correctly marked "in use". Subsequent pages do not exist yet, - * but it is convenient to pre-mark them as "in use" too. + * immediately: the bitmap page itself, and the following page which + * is the one we return to the caller. Both of these are correctly + * marked "in use". Subsequent pages do not exist yet, but it is + * convenient to pre-mark them as "in use" too. */ _hash_initbitmap(rel, metap, bitno_to_blkno(metap, bit)); @@ -265,8 +265,8 @@ _hash_getovflpage(Relation rel, Buffer metabuf) else { /* - * Nothing to do here; since the page was past the last used page, - * we know its bitmap bit was preinitialized to "in use". + * Nothing to do here; since the page was past the last used page, we + * know its bitmap bit was preinitialized to "in use". */ } @@ -275,8 +275,7 @@ _hash_getovflpage(Relation rel, Buffer metabuf) /* * Adjust hashm_firstfree to avoid redundant searches. But don't risk - * changing it if someone moved it while we were searching bitmap - * pages. + * changing it if someone moved it while we were searching bitmap pages. */ if (metap->hashm_firstfree == orig_firstfree) metap->hashm_firstfree = bit + 1; @@ -305,8 +304,7 @@ found: /* * Adjust hashm_firstfree to avoid redundant searches. But don't risk - * changing it if someone moved it while we were searching bitmap - * pages. + * changing it if someone moved it while we were searching bitmap pages. */ if (metap->hashm_firstfree == orig_firstfree) { @@ -394,10 +392,10 @@ _hash_freeovflpage(Relation rel, Buffer ovflbuf) _hash_wrtbuf(rel, ovflbuf); /* - * Fix up the bucket chain. this is a doubly-linked list, so we must - * fix up the bucket chain members behind and ahead of the overflow - * page being deleted. No concurrency issues since we hold exclusive - * lock on the entire bucket. + * Fix up the bucket chain. this is a doubly-linked list, so we must fix + * up the bucket chain members behind and ahead of the overflow page being + * deleted. No concurrency issues since we hold exclusive lock on the + * entire bucket. */ if (BlockNumberIsValid(prevblkno)) { @@ -488,12 +486,11 @@ _hash_initbitmap(Relation rel, HashMetaPage metap, BlockNumber blkno) /* * It is okay to write-lock the new bitmap page while holding metapage - * write lock, because no one else could be contending for the new - * page. + * write lock, because no one else could be contending for the new page. * - * There is some loss of concurrency in possibly doing I/O for the new - * page while holding the metapage lock, but this path is taken so - * seldom that it's not worth worrying about. + * There is some loss of concurrency in possibly doing I/O for the new page + * while holding the metapage lock, but this path is taken so seldom that + * it's not worth worrying about. */ buf = _hash_getbuf(rel, blkno, HASH_WRITE); pg = BufferGetPage(buf); @@ -586,8 +583,8 @@ _hash_squeezebucket(Relation rel, } /* - * find the last page in the bucket chain by starting at the base - * bucket page and working forward. + * find the last page in the bucket chain by starting at the base bucket + * page and working forward. */ ropaque = wopaque; do @@ -655,22 +652,21 @@ _hash_squeezebucket(Relation rel, /* * delete the tuple from the "read" page. PageIndexTupleDelete - * repacks the ItemId array, so 'roffnum' will be "advanced" - * to the "next" ItemId. + * repacks the ItemId array, so 'roffnum' will be "advanced" to + * the "next" ItemId. */ PageIndexTupleDelete(rpage, roffnum); } /* - * if the "read" page is now empty because of the deletion (or - * because it was empty when we got to it), free it. + * if the "read" page is now empty because of the deletion (or because + * it was empty when we got to it), free it. * * Tricky point here: if our read and write pages are adjacent in the * bucket chain, our write lock on wbuf will conflict with * _hash_freeovflpage's attempt to update the sibling links of the - * removed page. However, in that case we are done anyway, so we - * can simply drop the write lock before calling - * _hash_freeovflpage. + * removed page. However, in that case we are done anyway, so we can + * simply drop the write lock before calling _hash_freeovflpage. */ if (PageIsEmpty(rpage)) { diff --git a/src/backend/access/hash/hashpage.c b/src/backend/access/hash/hashpage.c index 883f2a7312..b40c20b480 100644 --- a/src/backend/access/hash/hashpage.c +++ b/src/backend/access/hash/hashpage.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/hash/hashpage.c,v 1.51 2005/06/09 21:01:25 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/hash/hashpage.c,v 1.52 2005/10/15 02:49:08 momjian Exp $ * * NOTES * Postgres hash pages look like ordinary relation pages. The opaque @@ -240,13 +240,13 @@ _hash_metapinit(Relation rel) RelationGetRelationName(rel)); /* - * Determine the target fill factor (tuples per bucket) for this - * index. The idea is to make the fill factor correspond to pages - * about 3/4ths full. We can compute it exactly if the index datatype - * is fixed-width, but for var-width there's some guessing involved. + * Determine the target fill factor (tuples per bucket) for this index. + * The idea is to make the fill factor correspond to pages about 3/4ths + * full. We can compute it exactly if the index datatype is fixed-width, + * but for var-width there's some guessing involved. */ data_width = get_typavgwidth(RelationGetDescr(rel)->attrs[0]->atttypid, - RelationGetDescr(rel)->attrs[0]->atttypmod); + RelationGetDescr(rel)->attrs[0]->atttypmod); item_width = MAXALIGN(sizeof(HashItemData)) + MAXALIGN(data_width) + sizeof(ItemIdData); /* include the line pointer */ ffactor = (BLCKSZ * 3 / 4) / item_width; @@ -289,9 +289,8 @@ _hash_metapinit(Relation rel) metap->hashm_procid = index_getprocid(rel, 1, HASHPROC); /* - * We initialize the index with two buckets, 0 and 1, occupying - * physical blocks 1 and 2. The first freespace bitmap page is in - * block 3. + * We initialize the index with two buckets, 0 and 1, occupying physical + * blocks 1 and 2. The first freespace bitmap page is in block 3. */ metap->hashm_maxbucket = metap->hashm_lowmask = 1; /* nbuckets - 1 */ metap->hashm_highmask = 3; /* (nbuckets << 1) - 1 */ @@ -321,8 +320,8 @@ _hash_metapinit(Relation rel) } /* - * Initialize first bitmap page. Can't do this until we create the - * first two buckets, else smgr will complain. + * Initialize first bitmap page. Can't do this until we create the first + * two buckets, else smgr will complain. */ _hash_initbitmap(rel, metap, 3); @@ -367,15 +366,14 @@ _hash_expandtable(Relation rel, Buffer metabuf) * Obtain the page-zero lock to assert the right to begin a split (see * README). * - * Note: deadlock should be impossible here. Our own backend could only - * be holding bucket sharelocks due to stopped indexscans; those will - * not block other holders of the page-zero lock, who are only - * interested in acquiring bucket sharelocks themselves. Exclusive - * bucket locks are only taken here and in hashbulkdelete, and neither - * of these operations needs any additional locks to complete. (If, - * due to some flaw in this reasoning, we manage to deadlock anyway, - * it's okay to error out; the index will be left in a consistent - * state.) + * Note: deadlock should be impossible here. Our own backend could only be + * holding bucket sharelocks due to stopped indexscans; those will not + * block other holders of the page-zero lock, who are only interested in + * acquiring bucket sharelocks themselves. Exclusive bucket locks are + * only taken here and in hashbulkdelete, and neither of these operations + * needs any additional locks to complete. (If, due to some flaw in this + * reasoning, we manage to deadlock anyway, it's okay to error out; the + * index will be left in a consistent state.) */ _hash_getlock(rel, 0, HASH_EXCLUSIVE); @@ -386,8 +384,8 @@ _hash_expandtable(Relation rel, Buffer metabuf) _hash_checkpage(rel, (Page) metap, LH_META_PAGE); /* - * Check to see if split is still needed; someone else might have - * already done one while we waited for the lock. + * Check to see if split is still needed; someone else might have already + * done one while we waited for the lock. * * Make sure this stays in sync with _hash_doinsert() */ @@ -402,11 +400,11 @@ _hash_expandtable(Relation rel, Buffer metabuf) * The lock protects us against other backends, but not against our own * backend. Must check for active scans separately. * - * Ideally we would lock the new bucket too before proceeding, but if we - * are about to cross a splitpoint then the BUCKET_TO_BLKNO mapping - * isn't correct yet. For simplicity we update the metapage first and - * then lock. This should be okay because no one else should be - * trying to lock the new bucket yet... + * Ideally we would lock the new bucket too before proceeding, but if we are + * about to cross a splitpoint then the BUCKET_TO_BLKNO mapping isn't + * correct yet. For simplicity we update the metapage first and then + * lock. This should be okay because no one else should be trying to lock + * the new bucket yet... */ new_bucket = metap->hashm_maxbucket + 1; old_bucket = (new_bucket & metap->hashm_lowmask); @@ -420,14 +418,13 @@ _hash_expandtable(Relation rel, Buffer metabuf) goto fail; /* - * Okay to proceed with split. Update the metapage bucket mapping - * info. + * Okay to proceed with split. Update the metapage bucket mapping info. * - * Since we are scribbling on the metapage data right in the shared - * buffer, any failure in this next little bit leaves us with a big - * problem: the metapage is effectively corrupt but could get written - * back to disk. We don't really expect any failure, but just to be - * sure, establish a critical section. + * Since we are scribbling on the metapage data right in the shared buffer, + * any failure in this next little bit leaves us with a big problem: the + * metapage is effectively corrupt but could get written back to disk. We + * don't really expect any failure, but just to be sure, establish a + * critical section. */ START_CRIT_SECTION(); @@ -443,8 +440,8 @@ _hash_expandtable(Relation rel, Buffer metabuf) /* * If the split point is increasing (hashm_maxbucket's log base 2 * increases), we need to adjust the hashm_spares[] array and - * hashm_ovflpoint so that future overflow pages will be created - * beyond this new batch of bucket pages. + * hashm_ovflpoint so that future overflow pages will be created beyond + * this new batch of bucket pages. * * XXX should initialize new bucket pages to prevent out-of-order page * creation? Don't wanna do it right here though. @@ -471,10 +468,9 @@ _hash_expandtable(Relation rel, Buffer metabuf) /* * Copy bucket mapping info now; this saves re-accessing the meta page * inside _hash_splitbucket's inner loop. Note that once we drop the - * split lock, other splits could begin, so these values might be out - * of date before _hash_splitbucket finishes. That's okay, since all - * it needs is to tell which of these two buckets to map hashkeys - * into. + * split lock, other splits could begin, so these values might be out of + * date before _hash_splitbucket finishes. That's okay, since all it + * needs is to tell which of these two buckets to map hashkeys into. */ maxbucket = metap->hashm_maxbucket; highmask = metap->hashm_highmask; @@ -554,9 +550,9 @@ _hash_splitbucket(Relation rel, TupleDesc itupdesc = RelationGetDescr(rel); /* - * It should be okay to simultaneously write-lock pages from each - * bucket, since no one else can be trying to acquire buffer lock on - * pages of either bucket. + * It should be okay to simultaneously write-lock pages from each bucket, + * since no one else can be trying to acquire buffer lock on pages of + * either bucket. */ oblkno = start_oblkno; nblkno = start_nblkno; @@ -578,17 +574,17 @@ _hash_splitbucket(Relation rel, nopaque->hasho_filler = HASHO_FILL; /* - * Partition the tuples in the old bucket between the old bucket and - * the new bucket, advancing along the old bucket's overflow bucket - * chain and adding overflow pages to the new bucket as needed. + * Partition the tuples in the old bucket between the old bucket and the + * new bucket, advancing along the old bucket's overflow bucket chain and + * adding overflow pages to the new bucket as needed. */ ooffnum = FirstOffsetNumber; omaxoffnum = PageGetMaxOffsetNumber(opage); for (;;) { /* - * at each iteration through this loop, each of these variables - * should be up-to-date: obuf opage oopaque ooffnum omaxoffnum + * at each iteration through this loop, each of these variables should + * be up-to-date: obuf opage oopaque ooffnum omaxoffnum */ /* check if we're at the end of the page */ @@ -600,8 +596,8 @@ _hash_splitbucket(Relation rel, break; /* - * we ran out of tuples on this particular page, but we have - * more overflow pages; advance to next page. + * we ran out of tuples on this particular page, but we have more + * overflow pages; advance to next page. */ _hash_wrtbuf(rel, obuf); @@ -618,8 +614,7 @@ _hash_splitbucket(Relation rel, * Re-hash the tuple to determine which bucket it now belongs in. * * It is annoying to call the hash function while holding locks, but - * releasing and relocking the page for each tuple is unappealing - * too. + * releasing and relocking the page for each tuple is unappealing too. */ hitem = (HashItem) PageGetItem(opage, PageGetItemId(opage, ooffnum)); itup = &(hitem->hash_itup); @@ -632,9 +627,9 @@ _hash_splitbucket(Relation rel, if (bucket == nbucket) { /* - * insert the tuple into the new bucket. if it doesn't fit on - * the current page in the new bucket, we must allocate a new - * overflow page and place the tuple on that page instead. + * insert the tuple into the new bucket. if it doesn't fit on the + * current page in the new bucket, we must allocate a new overflow + * page and place the tuple on that page instead. */ itemsz = IndexTupleDSize(hitem->hash_itup) + (sizeof(HashItemData) - sizeof(IndexTupleData)); @@ -659,13 +654,13 @@ _hash_splitbucket(Relation rel, RelationGetRelationName(rel)); /* - * now delete the tuple from the old bucket. after this - * section of code, 'ooffnum' will actually point to the - * ItemId to which we would point if we had advanced it before - * the deletion (PageIndexTupleDelete repacks the ItemId - * array). this also means that 'omaxoffnum' is exactly one - * less than it used to be, so we really can just decrement it - * instead of calling PageGetMaxOffsetNumber. + * now delete the tuple from the old bucket. after this section + * of code, 'ooffnum' will actually point to the ItemId to which + * we would point if we had advanced it before the deletion + * (PageIndexTupleDelete repacks the ItemId array). this also + * means that 'omaxoffnum' is exactly one less than it used to be, + * so we really can just decrement it instead of calling + * PageGetMaxOffsetNumber. */ PageIndexTupleDelete(opage, ooffnum); omaxoffnum = OffsetNumberPrev(omaxoffnum); @@ -673,9 +668,9 @@ _hash_splitbucket(Relation rel, else { /* - * the tuple stays on this page. we didn't move anything, so - * we didn't delete anything and therefore we don't have to - * change 'omaxoffnum'. + * the tuple stays on this page. we didn't move anything, so we + * didn't delete anything and therefore we don't have to change + * 'omaxoffnum'. */ Assert(bucket == obucket); ooffnum = OffsetNumberNext(ooffnum); @@ -683,11 +678,10 @@ _hash_splitbucket(Relation rel, } /* - * We're at the end of the old bucket chain, so we're done - * partitioning the tuples. Before quitting, call _hash_squeezebucket - * to ensure the tuples remaining in the old bucket (including the - * overflow pages) are packed as tightly as possible. The new bucket - * is already tight. + * We're at the end of the old bucket chain, so we're done partitioning + * the tuples. Before quitting, call _hash_squeezebucket to ensure the + * tuples remaining in the old bucket (including the overflow pages) are + * packed as tightly as possible. The new bucket is already tight. */ _hash_wrtbuf(rel, obuf); _hash_wrtbuf(rel, nbuf); diff --git a/src/backend/access/hash/hashscan.c b/src/backend/access/hash/hashscan.c index 782c087e3b..213eaf89fc 100644 --- a/src/backend/access/hash/hashscan.c +++ b/src/backend/access/hash/hashscan.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/hash/hashscan.c,v 1.38 2004/12/31 21:59:13 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/access/hash/hashscan.c,v 1.39 2005/10/15 02:49:08 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -44,9 +44,9 @@ ReleaseResources_hash(void) HashScanList next; /* - * Note: this should be a no-op during normal query shutdown. However, - * in an abort situation ExecutorEnd is not called and so there may be - * open index scans to clean up. + * Note: this should be a no-op during normal query shutdown. However, in + * an abort situation ExecutorEnd is not called and so there may be open + * index scans to clean up. */ prev = NULL; diff --git a/src/backend/access/hash/hashsearch.c b/src/backend/access/hash/hashsearch.c index 9aaf70b0a9..fac46d7902 100644 --- a/src/backend/access/hash/hashsearch.c +++ b/src/backend/access/hash/hashsearch.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/hash/hashsearch.c,v 1.39 2005/10/06 02:29:08 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/hash/hashsearch.c,v 1.40 2005/10/15 02:49:08 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -137,33 +137,32 @@ _hash_first(IndexScanDesc scan, ScanDirection dir) ItemPointerSetInvalid(current); /* - * We do not support hash scans with no index qualification, because - * we would have to read the whole index rather than just one bucket. - * That creates a whole raft of problems, since we haven't got a - * practical way to lock all the buckets against splits or - * compactions. + * We do not support hash scans with no index qualification, because we + * would have to read the whole index rather than just one bucket. That + * creates a whole raft of problems, since we haven't got a practical way + * to lock all the buckets against splits or compactions. */ if (scan->numberOfKeys < 1) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("hash indexes do not support whole-index scans"))); + errmsg("hash indexes do not support whole-index scans"))); /* - * If the constant in the index qual is NULL, assume it cannot match - * any items in the index. + * If the constant in the index qual is NULL, assume it cannot match any + * items in the index. */ if (scan->keyData[0].sk_flags & SK_ISNULL) return false; /* - * Okay to compute the hash key. We want to do this before acquiring - * any locks, in case a user-defined hash function happens to be slow. + * Okay to compute the hash key. We want to do this before acquiring any + * locks, in case a user-defined hash function happens to be slow. */ hashkey = _hash_datum2hashkey(rel, scan->keyData[0].sk_argument); /* - * Acquire shared split lock so we can compute the target bucket - * safely (see README). + * Acquire shared split lock so we can compute the target bucket safely + * (see README). */ _hash_getlock(rel, 0, HASH_SHARE); @@ -186,8 +185,7 @@ _hash_first(IndexScanDesc scan, ScanDirection dir) _hash_relbuf(rel, metabuf); /* - * Acquire share lock on target bucket; then we can release split - * lock. + * Acquire share lock on target bucket; then we can release split lock. */ _hash_getlock(rel, blkno, HASH_SHARE); @@ -263,9 +261,9 @@ _hash_step(IndexScanDesc scan, Buffer *bufP, ScanDirection dir) bucket = opaque->hasho_bucket; /* - * If _hash_step is called from _hash_first, current will not be - * valid, so we can't dereference it. However, in that case, we - * presumably want to start at the beginning/end of the page... + * If _hash_step is called from _hash_first, current will not be valid, so + * we can't dereference it. However, in that case, we presumably want to + * start at the beginning/end of the page... */ maxoff = PageGetMaxOffsetNumber(page); if (ItemPointerIsValid(current)) @@ -276,8 +274,8 @@ _hash_step(IndexScanDesc scan, Buffer *bufP, ScanDirection dir) /* * 'offnum' now points to the last tuple we have seen (if any). * - * continue to step through tuples until: 1) we get to the end of the - * bucket chain or 2) we find a valid tuple. + * continue to step through tuples until: 1) we get to the end of the bucket + * chain or 2) we find a valid tuple. */ do { diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c index 185918d03a..6c669ed62b 100644 --- a/src/backend/access/heap/heapam.c +++ b/src/backend/access/heap/heapam.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.199 2005/10/06 02:29:10 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.200 2005/10/15 02:49:08 momjian Exp $ * * * INTERFACE ROUTINES @@ -54,7 +54,7 @@ static XLogRecPtr log_heap_update(Relation reln, Buffer oldbuf, - ItemPointerData from, Buffer newbuf, HeapTuple newtup, bool move); + ItemPointerData from, Buffer newbuf, HeapTuple newtup, bool move); /* ---------------------------------------------------------------- @@ -272,8 +272,8 @@ heapgettup(Relation relation, /* 'dir' is now non-zero */ /* - * calculate line pointer and number of remaining items to check on - * this page. + * calculate line pointer and number of remaining items to check on this + * page. */ lpp = PageGetItemId(dp, lineoff); if (dir < 0) @@ -282,8 +282,8 @@ heapgettup(Relation relation, linesleft = lines - lineoff; /* - * advance the scan until we find a qualifying tuple or run out of - * stuff to scan + * advance the scan until we find a qualifying tuple or run out of stuff + * to scan */ for (;;) { @@ -321,15 +321,14 @@ heapgettup(Relation relation, } else { - ++lpp; /* move forward in this page's ItemId - * array */ + ++lpp; /* move forward in this page's ItemId array */ ++lineoff; } } /* - * if we get here, it means we've exhausted the items on this page - * and it's time to move to the next. + * if we get here, it means we've exhausted the items on this page and + * it's time to move to the next. */ LockBuffer(*buffer, BUFFER_LOCK_UNLOCK); @@ -506,15 +505,15 @@ relation_openrv(const RangeVar *relation, LOCKMODE lockmode) /* * Check for shared-cache-inval messages before trying to open the - * relation. This is needed to cover the case where the name - * identifies a rel that has been dropped and recreated since the - * start of our transaction: if we don't flush the old syscache entry - * then we'll latch onto that entry and suffer an error when we do - * LockRelation. Note that relation_open does not need to do this, - * since a relation's OID never changes. + * relation. This is needed to cover the case where the name identifies a + * rel that has been dropped and recreated since the start of our + * transaction: if we don't flush the old syscache entry then we'll latch + * onto that entry and suffer an error when we do LockRelation. Note that + * relation_open does not need to do this, since a relation's OID never + * changes. * - * We skip this if asked for NoLock, on the assumption that the caller - * has already ensured some appropriate lock is held. + * We skip this if asked for NoLock, on the assumption that the caller has + * already ensured some appropriate lock is held. */ if (lockmode != NoLock) AcceptInvalidationMessages(); @@ -633,9 +632,9 @@ heap_beginscan(Relation relation, Snapshot snapshot, /* * increment relation ref count while scanning relation * - * This is just to make really sure the relcache entry won't go away - * while the scan has a pointer to it. Caller should be holding the - * rel open anyway, so this is redundant in all normal scenarios... + * This is just to make really sure the relcache entry won't go away while + * the scan has a pointer to it. Caller should be holding the rel open + * anyway, so this is redundant in all normal scenarios... */ RelationIncrementReferenceCount(relation); @@ -649,8 +648,8 @@ heap_beginscan(Relation relation, Snapshot snapshot, scan->rs_nkeys = nkeys; /* - * we do this here instead of in initscan() because heap_rescan also - * calls initscan() and we don't want to allocate memory again + * we do this here instead of in initscan() because heap_rescan also calls + * initscan() and we don't want to allocate memory again */ if (nkeys > 0) scan->rs_key = (ScanKey) palloc(sizeof(ScanKeyData) * nkeys); @@ -763,8 +762,8 @@ heap_getnext(HeapScanDesc scan, ScanDirection direction) } /* - * if we get here it means we have a new current scan tuple, so point - * to the proper return buffer and return the tuple. + * if we get here it means we have a new current scan tuple, so point to + * the proper return buffer and return the tuple. */ HEAPDEBUG_3; /* heap_getnext returning tuple */ @@ -859,8 +858,8 @@ heap_release_fetch(Relation relation, dp = (PageHeader) BufferGetPage(buffer); /* - * We'd better check for out-of-range offnum in case of VACUUM since - * the TID was obtained. + * We'd better check for out-of-range offnum in case of VACUUM since the + * TID was obtained. */ offnum = ItemPointerGetOffsetNumber(tid); if (offnum < FirstOffsetNumber || offnum > PageGetMaxOffsetNumber(dp)) @@ -952,7 +951,7 @@ heap_release_fetch(Relation relation, * possibly uncommitted version. * * *tid is both an input and an output parameter: it is updated to - * show the latest version of the row. Note that it will not be changed + * show the latest version of the row. Note that it will not be changed * if no version of the row passes the snapshot test. */ void @@ -960,7 +959,7 @@ heap_get_latest_tid(Relation relation, Snapshot snapshot, ItemPointer tid) { - BlockNumber blk; + BlockNumber blk; ItemPointerData ctid; TransactionId priorXmax; @@ -969,10 +968,10 @@ heap_get_latest_tid(Relation relation, return; /* - * Since this can be called with user-supplied TID, don't trust the - * input too much. (RelationGetNumberOfBlocks is an expensive check, - * so we don't check t_ctid links again this way. Note that it would - * not do to call it just once and save the result, either.) + * Since this can be called with user-supplied TID, don't trust the input + * too much. (RelationGetNumberOfBlocks is an expensive check, so we + * don't check t_ctid links again this way. Note that it would not do to + * call it just once and save the result, either.) */ blk = ItemPointerGetBlockNumber(tid); if (blk >= RelationGetNumberOfBlocks(relation)) @@ -980,9 +979,9 @@ heap_get_latest_tid(Relation relation, blk, RelationGetRelationName(relation)); /* - * Loop to chase down t_ctid links. At top of loop, ctid is the - * tuple we need to examine, and *tid is the TID we will return if - * ctid turns out to be bogus. + * Loop to chase down t_ctid links. At top of loop, ctid is the tuple we + * need to examine, and *tid is the TID we will return if ctid turns out + * to be bogus. * * Note that we will loop until we reach the end of the t_ctid chain. * Depending on the snapshot passed, there might be at most one visible @@ -1008,8 +1007,8 @@ heap_get_latest_tid(Relation relation, /* * Check for bogus item number. This is not treated as an error - * condition because it can happen while following a t_ctid link. - * We just assume that the prior tid is OK and return it unchanged. + * condition because it can happen while following a t_ctid link. We + * just assume that the prior tid is OK and return it unchanged. */ offnum = ItemPointerGetOffsetNumber(&ctid); if (offnum < FirstOffsetNumber || offnum > PageGetMaxOffsetNumber(dp)) @@ -1037,7 +1036,7 @@ heap_get_latest_tid(Relation relation, * tuple. Check for XMIN match. */ if (TransactionIdIsValid(priorXmax) && - !TransactionIdEquals(priorXmax, HeapTupleHeaderGetXmin(tp.t_data))) + !TransactionIdEquals(priorXmax, HeapTupleHeaderGetXmin(tp.t_data))) { LockBuffer(buffer, BUFFER_LOCK_UNLOCK); ReleaseBuffer(buffer); @@ -1068,7 +1067,7 @@ heap_get_latest_tid(Relation relation, priorXmax = HeapTupleHeaderGetXmax(tp.t_data); LockBuffer(buffer, BUFFER_LOCK_UNLOCK); ReleaseBuffer(buffer); - } /* end of loop */ + } /* end of loop */ } /* @@ -1102,13 +1101,12 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid, #endif /* - * If the object id of this tuple has already been assigned, trust - * the caller. There are a couple of ways this can happen. At - * initial db creation, the backend program sets oids for tuples. - * When we define an index, we set the oid. Finally, in the - * future, we may allow users to set their own object ids in order - * to support a persistent object store (objects need to contain - * pointers to one another). + * If the object id of this tuple has already been assigned, trust the + * caller. There are a couple of ways this can happen. At initial db + * creation, the backend program sets oids for tuples. When we define + * an index, we set the oid. Finally, in the future, we may allow + * users to set their own object ids in order to support a persistent + * object store (objects need to contain pointers to one another). */ if (!OidIsValid(HeapTupleGetOid(tup))) HeapTupleSetOid(tup, GetNewOid(relation)); @@ -1129,8 +1127,7 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid, /* * If the new tuple is too big for storage or contains already toasted - * out-of-line attributes from some other relation, invoke the - * toaster. + * out-of-line attributes from some other relation, invoke the toaster. */ if (HeapTupleHasExternal(tup) || (MAXALIGN(tup->t_len) > TOAST_TUPLE_THRESHOLD)) @@ -1172,9 +1169,9 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid, xlhdr.t_hoff = tup->t_data->t_hoff; /* - * note we mark rdata[1] as belonging to buffer; if XLogInsert - * decides to write the whole page to the xlog, we don't need to - * store xl_heap_header in the xlog. + * note we mark rdata[1] as belonging to buffer; if XLogInsert decides + * to write the whole page to the xlog, we don't need to store + * xl_heap_header in the xlog. */ rdata[1].data = (char *) &xlhdr; rdata[1].len = SizeOfHeapHeader; @@ -1190,9 +1187,9 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid, rdata[2].next = NULL; /* - * If this is the single and first tuple on page, we can reinit - * the page instead of restoring the whole thing. Set flag, and - * hide buffer references from XLogInsert. + * If this is the single and first tuple on page, we can reinit the + * page instead of restoring the whole thing. Set flag, and hide + * buffer references from XLogInsert. */ if (ItemPointerGetOffsetNumber(&(tup->t_self)) == FirstOffsetNumber && PageGetMaxOffsetNumber(page) == FirstOffsetNumber) @@ -1213,10 +1210,10 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid, WriteBuffer(buffer); /* - * If tuple is cachable, mark it for invalidation from the caches in - * case we abort. Note it is OK to do this after WriteBuffer releases - * the buffer, because the "tup" data structure is all in local - * memory, not in the shared buffer. + * If tuple is cachable, mark it for invalidation from the caches in case + * we abort. Note it is OK to do this after WriteBuffer releases the + * buffer, because the "tup" data structure is all in local memory, not in + * the shared buffer. */ CacheInvalidateHeapTuple(relation, tup); @@ -1268,7 +1265,7 @@ heap_delete(Relation relation, ItemPointer tid, ItemPointer ctid, TransactionId *update_xmax, CommandId cid, Snapshot crosscheck, bool wait) { - HTSU_Result result; + HTSU_Result result; TransactionId xid = GetCurrentTransactionId(); ItemId lp; HeapTupleData tp; @@ -1301,7 +1298,7 @@ l1: else if (result == HeapTupleBeingUpdated && wait) { TransactionId xwait; - uint16 infomask; + uint16 infomask; /* must copy state data before unlocking buffer */ xwait = HeapTupleHeaderGetXmax(tp.t_data); @@ -1310,13 +1307,13 @@ l1: LockBuffer(buffer, BUFFER_LOCK_UNLOCK); /* - * Acquire tuple lock to establish our priority for the tuple - * (see heap_lock_tuple). LockTuple will release us when we are + * Acquire tuple lock to establish our priority for the tuple (see + * heap_lock_tuple). LockTuple will release us when we are * next-in-line for the tuple. * - * If we are forced to "start over" below, we keep the tuple lock; - * this arranges that we stay at the head of the line while - * rechecking tuple state. + * If we are forced to "start over" below, we keep the tuple lock; this + * arranges that we stay at the head of the line while rechecking + * tuple state. */ if (!have_tuple_lock) { @@ -1347,12 +1344,12 @@ l1: goto l1; /* - * You might think the multixact is necessarily done here, but - * not so: it could have surviving members, namely our own xact - * or other subxacts of this backend. It is legal for us to - * delete the tuple in either case, however (the latter case is - * essentially a situation of upgrading our former shared lock - * to exclusive). We don't bother changing the on-disk hint bits + * You might think the multixact is necessarily done here, but not + * so: it could have surviving members, namely our own xact or + * other subxacts of this backend. It is legal for us to delete + * the tuple in either case, however (the latter case is + * essentially a situation of upgrading our former shared lock to + * exclusive). We don't bother changing the on-disk hint bits * since we are about to overwrite the xmax altogether. */ } @@ -1385,8 +1382,8 @@ l1: } /* - * We may overwrite if previous xmax aborted, or if it committed - * but only locked the tuple without updating it. + * We may overwrite if previous xmax aborted, or if it committed but + * only locked the tuple without updating it. */ if (tp.t_data->t_infomask & (HEAP_XMAX_INVALID | HEAP_IS_LOCKED)) @@ -1467,18 +1464,18 @@ l1: /* * If the tuple has toasted out-of-line attributes, we need to delete - * those items too. We have to do this before WriteBuffer because we - * need to look at the contents of the tuple, but it's OK to release - * the context lock on the buffer first. + * those items too. We have to do this before WriteBuffer because we need + * to look at the contents of the tuple, but it's OK to release the + * context lock on the buffer first. */ if (HeapTupleHasExternal(&tp)) heap_tuple_toast_attrs(relation, NULL, &tp); /* * Mark tuple for invalidation from system caches at next command - * boundary. We have to do this before WriteBuffer because we need to - * look at the contents of the tuple, so we need to hold our refcount - * on the buffer. + * boundary. We have to do this before WriteBuffer because we need to look + * at the contents of the tuple, so we need to hold our refcount on the + * buffer. */ CacheInvalidateHeapTuple(relation, &tp); @@ -1506,7 +1503,7 @@ l1: void simple_heap_delete(Relation relation, ItemPointer tid) { - HTSU_Result result; + HTSU_Result result; ItemPointerData update_ctid; TransactionId update_xmax; @@ -1569,7 +1566,7 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup, ItemPointer ctid, TransactionId *update_xmax, CommandId cid, Snapshot crosscheck, bool wait) { - HTSU_Result result; + HTSU_Result result; TransactionId xid = GetCurrentTransactionId(); ItemId lp; HeapTupleData oldtup; @@ -1598,8 +1595,8 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup, /* * Note: beyond this point, use oldtup not otid to refer to old tuple. * otid may very well point at newtup->t_self, which we will overwrite - * with the new tuple's location, so there's great risk of confusion - * if we use otid anymore. + * with the new tuple's location, so there's great risk of confusion if we + * use otid anymore. */ l2: @@ -1614,7 +1611,7 @@ l2: else if (result == HeapTupleBeingUpdated && wait) { TransactionId xwait; - uint16 infomask; + uint16 infomask; /* must copy state data before unlocking buffer */ xwait = HeapTupleHeaderGetXmax(oldtup.t_data); @@ -1623,13 +1620,13 @@ l2: LockBuffer(buffer, BUFFER_LOCK_UNLOCK); /* - * Acquire tuple lock to establish our priority for the tuple - * (see heap_lock_tuple). LockTuple will release us when we are + * Acquire tuple lock to establish our priority for the tuple (see + * heap_lock_tuple). LockTuple will release us when we are * next-in-line for the tuple. * - * If we are forced to "start over" below, we keep the tuple lock; - * this arranges that we stay at the head of the line while - * rechecking tuple state. + * If we are forced to "start over" below, we keep the tuple lock; this + * arranges that we stay at the head of the line while rechecking + * tuple state. */ if (!have_tuple_lock) { @@ -1660,12 +1657,12 @@ l2: goto l2; /* - * You might think the multixact is necessarily done here, but - * not so: it could have surviving members, namely our own xact - * or other subxacts of this backend. It is legal for us to - * update the tuple in either case, however (the latter case is - * essentially a situation of upgrading our former shared lock - * to exclusive). We don't bother changing the on-disk hint bits + * You might think the multixact is necessarily done here, but not + * so: it could have surviving members, namely our own xact or + * other subxacts of this backend. It is legal for us to update + * the tuple in either case, however (the latter case is + * essentially a situation of upgrading our former shared lock to + * exclusive). We don't bother changing the on-disk hint bits * since we are about to overwrite the xmax altogether. */ } @@ -1698,8 +1695,8 @@ l2: } /* - * We may overwrite if previous xmax aborted, or if it committed - * but only locked the tuple without updating it. + * We may overwrite if previous xmax aborted, or if it committed but + * only locked the tuple without updating it. */ if (oldtup.t_data->t_infomask & (HEAP_XMAX_INVALID | HEAP_IS_LOCKED)) @@ -1753,15 +1750,15 @@ l2: HeapTupleHeaderSetCmax(newtup->t_data, 0); /* for cleanliness */ /* - * If the toaster needs to be activated, OR if the new tuple will not - * fit on the same page as the old, then we need to release the - * context lock (but not the pin!) on the old tuple's buffer while we - * are off doing TOAST and/or table-file-extension work. We must mark - * the old tuple to show that it's already being updated, else other - * processes may try to update it themselves. + * If the toaster needs to be activated, OR if the new tuple will not fit + * on the same page as the old, then we need to release the context lock + * (but not the pin!) on the old tuple's buffer while we are off doing + * TOAST and/or table-file-extension work. We must mark the old tuple to + * show that it's already being updated, else other processes may try to + * update it themselves. * - * We need to invoke the toaster if there are already any out-of-line - * toasted values present, or if the new tuple is over-threshold. + * We need to invoke the toaster if there are already any out-of-line toasted + * values present, or if the new tuple is over-threshold. */ need_toast = (HeapTupleHasExternal(&oldtup) || HeapTupleHasExternal(newtup) || @@ -1790,22 +1787,21 @@ l2: } /* - * Now, do we need a new page for the tuple, or not? This is a - * bit tricky since someone else could have added tuples to the - * page while we weren't looking. We have to recheck the - * available space after reacquiring the buffer lock. But don't - * bother to do that if the former amount of free space is still - * not enough; it's unlikely there's more free now than before. + * Now, do we need a new page for the tuple, or not? This is a bit + * tricky since someone else could have added tuples to the page while + * we weren't looking. We have to recheck the available space after + * reacquiring the buffer lock. But don't bother to do that if the + * former amount of free space is still not enough; it's unlikely + * there's more free now than before. * * What's more, if we need to get a new page, we will need to acquire - * buffer locks on both old and new pages. To avoid deadlock - * against some other backend trying to get the same two locks in - * the other order, we must be consistent about the order we get - * the locks in. We use the rule "lock the lower-numbered page of - * the relation first". To implement this, we must do - * RelationGetBufferForTuple while not holding the lock on the old - * page, and we must rely on it to get the locks on both pages in - * the correct order. + * buffer locks on both old and new pages. To avoid deadlock against + * some other backend trying to get the same two locks in the other + * order, we must be consistent about the order we get the locks in. + * We use the rule "lock the lower-numbered page of the relation + * first". To implement this, we must do RelationGetBufferForTuple + * while not holding the lock on the old page, and we must rely on it + * to get the locks on both pages in the correct order. */ if (newtupsize > pagefree) { @@ -1823,8 +1819,8 @@ l2: { /* * Rats, it doesn't fit anymore. We must now unlock and - * relock to avoid deadlock. Fortunately, this path - * should seldom be taken. + * relock to avoid deadlock. Fortunately, this path should + * seldom be taken. */ LockBuffer(buffer, BUFFER_LOCK_UNLOCK); newbuf = RelationGetBufferForTuple(relation, newtup->t_len, @@ -1845,9 +1841,9 @@ l2: } /* - * At this point newbuf and buffer are both pinned and locked, and - * newbuf has enough space for the new tuple. If they are the same - * buffer, only one pin is held. + * At this point newbuf and buffer are both pinned and locked, and newbuf + * has enough space for the new tuple. If they are the same buffer, only + * one pin is held. */ /* NO EREPORT(ERROR) from here till changes are logged */ @@ -1897,8 +1893,8 @@ l2: /* * Mark old tuple for invalidation from system caches at next command - * boundary. We have to do this before WriteBuffer because we need to - * look at the contents of the tuple, so we need to hold our refcount. + * boundary. We have to do this before WriteBuffer because we need to look + * at the contents of the tuple, so we need to hold our refcount. */ CacheInvalidateHeapTuple(relation, &oldtup); @@ -1907,10 +1903,10 @@ l2: WriteBuffer(buffer); /* - * If new tuple is cachable, mark it for invalidation from the caches - * in case we abort. Note it is OK to do this after WriteBuffer - * releases the buffer, because the "newtup" data structure is all in - * local memory, not in the shared buffer. + * If new tuple is cachable, mark it for invalidation from the caches in + * case we abort. Note it is OK to do this after WriteBuffer releases the + * buffer, because the "newtup" data structure is all in local memory, not + * in the shared buffer. */ CacheInvalidateHeapTuple(relation, newtup); @@ -1936,7 +1932,7 @@ l2: void simple_heap_update(Relation relation, ItemPointer otid, HeapTuple tup) { - HTSU_Result result; + HTSU_Result result; ItemPointerData update_ctid; TransactionId update_xmax; @@ -2012,7 +2008,7 @@ simple_heap_update(Relation relation, ItemPointer otid, HeapTuple tup) * waiter gets the tuple, potentially leading to indefinite starvation of * some waiters. The possibility of share-locking makes the problem much * worse --- a steady stream of share-lockers can easily block an exclusive - * locker forever. To provide more reliable semantics about who gets a + * locker forever. To provide more reliable semantics about who gets a * tuple-level lock first, we use the standard lock manager. The protocol * for waiting for a tuple-level lock is really * LockTuple() @@ -2020,7 +2016,7 @@ simple_heap_update(Relation relation, ItemPointer otid, HeapTuple tup) * mark tuple as locked by me * UnlockTuple() * When there are multiple waiters, arbitration of who is to get the lock next - * is provided by LockTuple(). However, at most one tuple-level lock will + * is provided by LockTuple(). However, at most one tuple-level lock will * be held or awaited per backend at any time, so we don't risk overflow * of the lock table. Note that incoming share-lockers are required to * do LockTuple as well, if there is any conflict, to ensure that they don't @@ -2032,11 +2028,11 @@ heap_lock_tuple(Relation relation, HeapTuple tuple, Buffer *buffer, ItemPointer ctid, TransactionId *update_xmax, CommandId cid, LockTupleMode mode, bool nowait) { - HTSU_Result result; + HTSU_Result result; ItemPointer tid = &(tuple->t_self); ItemId lp; PageHeader dp; - TransactionId xid; + TransactionId xid; uint16 new_infomask; LOCKMODE tuple_lock_type; bool have_tuple_lock = false; @@ -2067,7 +2063,7 @@ l3: else if (result == HeapTupleBeingUpdated) { TransactionId xwait; - uint16 infomask; + uint16 infomask; /* must copy state data before unlocking buffer */ xwait = HeapTupleHeaderGetXmax(tuple->t_data); @@ -2077,12 +2073,12 @@ l3: /* * Acquire tuple lock to establish our priority for the tuple. - * LockTuple will release us when we are next-in-line for the - * tuple. We must do this even if we are share-locking. + * LockTuple will release us when we are next-in-line for the tuple. + * We must do this even if we are share-locking. * - * If we are forced to "start over" below, we keep the tuple lock; - * this arranges that we stay at the head of the line while - * rechecking tuple state. + * If we are forced to "start over" below, we keep the tuple lock; this + * arranges that we stay at the head of the line while rechecking + * tuple state. */ if (!have_tuple_lock) { @@ -2091,8 +2087,8 @@ l3: if (!ConditionalLockTuple(relation, tid, tuple_lock_type)) ereport(ERROR, (errcode(ERRCODE_LOCK_NOT_AVAILABLE), - errmsg("could not obtain lock on row in relation \"%s\"", - RelationGetRelationName(relation)))); + errmsg("could not obtain lock on row in relation \"%s\"", + RelationGetRelationName(relation)))); } else LockTuple(relation, tid, tuple_lock_type); @@ -2108,8 +2104,8 @@ l3: LockBuffer(*buffer, BUFFER_LOCK_EXCLUSIVE); /* - * Make sure it's still a shared lock, else start over. (It's - * OK if the ownership of the shared lock has changed, though.) + * Make sure it's still a shared lock, else start over. (It's OK + * if the ownership of the shared lock has changed, though.) */ if (!(tuple->t_data->t_infomask & HEAP_XMAX_SHARED_LOCK)) goto l3; @@ -2122,8 +2118,8 @@ l3: if (!ConditionalMultiXactIdWait((MultiXactId) xwait)) ereport(ERROR, (errcode(ERRCODE_LOCK_NOT_AVAILABLE), - errmsg("could not obtain lock on row in relation \"%s\"", - RelationGetRelationName(relation)))); + errmsg("could not obtain lock on row in relation \"%s\"", + RelationGetRelationName(relation)))); } else MultiXactIdWait((MultiXactId) xwait); @@ -2131,9 +2127,9 @@ l3: LockBuffer(*buffer, BUFFER_LOCK_EXCLUSIVE); /* - * If xwait had just locked the tuple then some other xact - * could update this tuple before we get to this point. - * Check for xmax change, and start over if so. + * If xwait had just locked the tuple then some other xact could + * update this tuple before we get to this point. Check for xmax + * change, and start over if so. */ if (!(tuple->t_data->t_infomask & HEAP_XMAX_IS_MULTI) || !TransactionIdEquals(HeapTupleHeaderGetXmax(tuple->t_data), @@ -2141,12 +2137,12 @@ l3: goto l3; /* - * You might think the multixact is necessarily done here, but - * not so: it could have surviving members, namely our own xact - * or other subxacts of this backend. It is legal for us to - * lock the tuple in either case, however. We don't bother - * changing the on-disk hint bits since we are about to - * overwrite the xmax altogether. + * You might think the multixact is necessarily done here, but not + * so: it could have surviving members, namely our own xact or + * other subxacts of this backend. It is legal for us to lock the + * tuple in either case, however. We don't bother changing the + * on-disk hint bits since we are about to overwrite the xmax + * altogether. */ } else @@ -2157,8 +2153,8 @@ l3: if (!ConditionalXactLockTableWait(xwait)) ereport(ERROR, (errcode(ERRCODE_LOCK_NOT_AVAILABLE), - errmsg("could not obtain lock on row in relation \"%s\"", - RelationGetRelationName(relation)))); + errmsg("could not obtain lock on row in relation \"%s\"", + RelationGetRelationName(relation)))); } else XactLockTableWait(xwait); @@ -2166,9 +2162,9 @@ l3: LockBuffer(*buffer, BUFFER_LOCK_EXCLUSIVE); /* - * xwait is done, but if xwait had just locked the tuple then - * some other xact could update this tuple before we get to - * this point. Check for xmax change, and start over if so. + * xwait is done, but if xwait had just locked the tuple then some + * other xact could update this tuple before we get to this point. + * Check for xmax change, and start over if so. */ if ((tuple->t_data->t_infomask & HEAP_XMAX_IS_MULTI) || !TransactionIdEquals(HeapTupleHeaderGetXmax(tuple->t_data), @@ -2188,10 +2184,10 @@ l3: } /* - * We may lock if previous xmax aborted, or if it committed - * but only locked the tuple without updating it. The case where - * we didn't wait because we are joining an existing shared lock - * is correctly handled, too. + * We may lock if previous xmax aborted, or if it committed but only + * locked the tuple without updating it. The case where we didn't + * wait because we are joining an existing shared lock is correctly + * handled, too. */ if (tuple->t_data->t_infomask & (HEAP_XMAX_INVALID | HEAP_IS_LOCKED)) @@ -2213,9 +2209,9 @@ l3: } /* - * Compute the new xmax and infomask to store into the tuple. Note we - * do not modify the tuple just yet, because that would leave it in the - * wrong state if multixact.c elogs. + * Compute the new xmax and infomask to store into the tuple. Note we do + * not modify the tuple just yet, because that would leave it in the wrong + * state if multixact.c elogs. */ xid = GetCurrentTransactionId(); @@ -2229,17 +2225,16 @@ l3: if (mode == LockTupleShared) { - TransactionId xmax = HeapTupleHeaderGetXmax(tuple->t_data); + TransactionId xmax = HeapTupleHeaderGetXmax(tuple->t_data); uint16 old_infomask = tuple->t_data->t_infomask; /* * If this is the first acquisition of a shared lock in the current - * transaction, set my per-backend OldestMemberMXactId setting. - * We can be certain that the transaction will never become a - * member of any older MultiXactIds than that. (We have to do this - * even if we end up just using our own TransactionId below, since - * some other backend could incorporate our XID into a MultiXact - * immediately afterwards.) + * transaction, set my per-backend OldestMemberMXactId setting. We can + * be certain that the transaction will never become a member of any + * older MultiXactIds than that. (We have to do this even if we end + * up just using our own TransactionId below, since some other backend + * could incorporate our XID into a MultiXact immediately afterwards.) */ MultiXactIdSetOldestMember(); @@ -2249,14 +2244,14 @@ l3: * Check to see if we need a MultiXactId because there are multiple * lockers. * - * HeapTupleSatisfiesUpdate will have set the HEAP_XMAX_INVALID - * bit if the xmax was a MultiXactId but it was not running anymore. - * There is a race condition, which is that the MultiXactId may have - * finished since then, but that uncommon case is handled within + * HeapTupleSatisfiesUpdate will have set the HEAP_XMAX_INVALID bit if + * the xmax was a MultiXactId but it was not running anymore. There is + * a race condition, which is that the MultiXactId may have finished + * since then, but that uncommon case is handled within * MultiXactIdExpand. * - * There is a similar race condition possible when the old xmax was - * a regular TransactionId. We test TransactionIdIsInProgress again + * There is a similar race condition possible when the old xmax was a + * regular TransactionId. We test TransactionIdIsInProgress again * just to narrow the window, but it's still possible to end up * creating an unnecessary MultiXactId. Fortunately this is harmless. */ @@ -2277,10 +2272,10 @@ l3: { /* * If the old locker is ourselves, we'll just mark the - * tuple again with our own TransactionId. However we - * have to consider the possibility that we had - * exclusive rather than shared lock before --- if so, - * be careful to preserve the exclusivity of the lock. + * tuple again with our own TransactionId. However we + * have to consider the possibility that we had exclusive + * rather than shared lock before --- if so, be careful to + * preserve the exclusivity of the lock. */ if (!(old_infomask & HEAP_XMAX_SHARED_LOCK)) { @@ -2303,9 +2298,9 @@ l3: else { /* - * Can get here iff HeapTupleSatisfiesUpdate saw the old - * xmax as running, but it finished before - * TransactionIdIsInProgress() got to run. Treat it like + * Can get here iff HeapTupleSatisfiesUpdate saw the old xmax + * as running, but it finished before + * TransactionIdIsInProgress() got to run. Treat it like * there's no locker in the tuple. */ } @@ -2329,8 +2324,8 @@ l3: /* * Store transaction information of xact locking the tuple. * - * Note: our CID is meaningless if storing a MultiXactId, but no harm - * in storing it anyway. + * Note: our CID is meaningless if storing a MultiXactId, but no harm in + * storing it anyway. */ tuple->t_data->t_infomask = new_infomask; HeapTupleHeaderSetXmax(tuple->t_data, xid); @@ -2339,8 +2334,8 @@ l3: tuple->t_data->t_ctid = *tid; /* - * XLOG stuff. You might think that we don't need an XLOG record because - * there is no state change worth restoring after a crash. You would be + * XLOG stuff. You might think that we don't need an XLOG record because + * there is no state change worth restoring after a crash. You would be * wrong however: we have just written either a TransactionId or a * MultiXactId that may never have been seen on disk before, and we need * to make sure that there are XLOG entries covering those ID numbers. @@ -2473,8 +2468,8 @@ log_heap_clean(Relation reln, Buffer buffer, OffsetNumber *unused, int uncnt) /* * The unused-offsets array is not actually in the buffer, but pretend - * that it is. When XLogInsert stores the whole buffer, the offsets - * array need not be stored too. + * that it is. When XLogInsert stores the whole buffer, the offsets array + * need not be stored too. */ if (uncnt > 0) { @@ -2500,11 +2495,10 @@ log_heap_update(Relation reln, Buffer oldbuf, ItemPointerData from, Buffer newbuf, HeapTuple newtup, bool move) { /* - * Note: xlhdr is declared to have adequate size and correct alignment - * for an xl_heap_header. However the two tids, if present at all, - * will be packed in with no wasted space after the xl_heap_header; - * they aren't necessarily aligned as implied by this struct - * declaration. + * Note: xlhdr is declared to have adequate size and correct alignment for + * an xl_heap_header. However the two tids, if present at all, will be + * packed in with no wasted space after the xl_heap_header; they aren't + * necessarily aligned as implied by this struct declaration. */ struct { @@ -2555,8 +2549,8 @@ log_heap_update(Relation reln, Buffer oldbuf, ItemPointerData from, } /* - * As with insert records, we need not store the rdata[2] segment if - * we decide to store the whole buffer instead. + * As with insert records, we need not store the rdata[2] segment if we + * decide to store the whole buffer instead. */ rdata[2].data = (char *) &xlhdr; rdata[2].len = hsize; @@ -2655,8 +2649,8 @@ heap_xlog_newpage(XLogRecPtr lsn, XLogRecord *record) Page page; /* - * Note: the NEWPAGE log record is used for both heaps and indexes, so - * do not do anything that assumes we are touching a heap. + * Note: the NEWPAGE log record is used for both heaps and indexes, so do + * not do anything that assumes we are touching a heap. */ if (record->xl_info & XLR_BKP_BLOCK_1) @@ -2699,7 +2693,7 @@ heap_xlog_delete(XLogRecPtr lsn, XLogRecord *record) return; buffer = XLogReadBuffer(false, reln, - ItemPointerGetBlockNumber(&(xlrec->target.tid))); + ItemPointerGetBlockNumber(&(xlrec->target.tid))); if (!BufferIsValid(buffer)) elog(PANIC, "heap_delete_redo: no block"); @@ -2707,7 +2701,7 @@ heap_xlog_delete(XLogRecPtr lsn, XLogRecord *record) if (PageIsNew((PageHeader) page)) elog(PANIC, "heap_delete_redo: uninitialized page"); - if (XLByteLE(lsn, PageGetLSN(page))) /* changes are applied */ + if (XLByteLE(lsn, PageGetLSN(page))) /* changes are applied */ { LockBuffer(buffer, BUFFER_LOCK_UNLOCK); ReleaseBuffer(buffer); @@ -2749,7 +2743,7 @@ heap_xlog_insert(XLogRecPtr lsn, XLogRecord *record) struct { HeapTupleHeaderData hdr; - char data[MaxTupleSize]; + char data[MaxTupleSize]; } tbuf; HeapTupleHeader htup; xl_heap_header xlhdr; @@ -2764,7 +2758,7 @@ heap_xlog_insert(XLogRecPtr lsn, XLogRecord *record) return; buffer = XLogReadBuffer(true, reln, - ItemPointerGetBlockNumber(&(xlrec->target.tid))); + ItemPointerGetBlockNumber(&(xlrec->target.tid))); if (!BufferIsValid(buffer)) return; @@ -2776,7 +2770,7 @@ heap_xlog_insert(XLogRecPtr lsn, XLogRecord *record) if (record->xl_info & XLOG_HEAP_INIT_PAGE) PageInit(page, BufferGetPageSize(buffer), 0); - if (XLByteLE(lsn, PageGetLSN(page))) /* changes are applied */ + if (XLByteLE(lsn, PageGetLSN(page))) /* changes are applied */ { LockBuffer(buffer, BUFFER_LOCK_UNLOCK); ReleaseBuffer(buffer); @@ -2835,7 +2829,7 @@ heap_xlog_update(XLogRecPtr lsn, XLogRecord *record, bool move) struct { HeapTupleHeaderData hdr; - char data[MaxTupleSize]; + char data[MaxTupleSize]; } tbuf; xl_heap_header xlhdr; int hsize; @@ -2850,7 +2844,7 @@ heap_xlog_update(XLogRecPtr lsn, XLogRecord *record, bool move) /* Deal with old tuple version */ buffer = XLogReadBuffer(false, reln, - ItemPointerGetBlockNumber(&(xlrec->target.tid))); + ItemPointerGetBlockNumber(&(xlrec->target.tid))); if (!BufferIsValid(buffer)) elog(PANIC, "heap_update_redo: no block"); @@ -2858,7 +2852,7 @@ heap_xlog_update(XLogRecPtr lsn, XLogRecord *record, bool move) if (PageIsNew((PageHeader) page)) elog(PANIC, "heap_update_redo: uninitialized old page"); - if (XLByteLE(lsn, PageGetLSN(page))) /* changes are applied */ + if (XLByteLE(lsn, PageGetLSN(page))) /* changes are applied */ { LockBuffer(buffer, BUFFER_LOCK_UNLOCK); ReleaseBuffer(buffer); @@ -2928,7 +2922,7 @@ newsame:; if (record->xl_info & XLOG_HEAP_INIT_PAGE) PageInit(page, BufferGetPageSize(buffer), 0); - if (XLByteLE(lsn, PageGetLSN(page))) /* changes are applied */ + if (XLByteLE(lsn, PageGetLSN(page))) /* changes are applied */ { LockBuffer(buffer, BUFFER_LOCK_UNLOCK); ReleaseBuffer(buffer); @@ -2961,7 +2955,7 @@ newsame:; if (move) { - TransactionId xid[2]; /* xmax, xmin */ + TransactionId xid[2]; /* xmax, xmin */ memcpy((char *) xid, (char *) xlrec + SizeOfHeapUpdate + SizeOfHeapHeader, @@ -3008,7 +3002,7 @@ heap_xlog_lock(XLogRecPtr lsn, XLogRecord *record) return; buffer = XLogReadBuffer(false, reln, - ItemPointerGetBlockNumber(&(xlrec->target.tid))); + ItemPointerGetBlockNumber(&(xlrec->target.tid))); if (!BufferIsValid(buffer)) elog(PANIC, "heap_lock_redo: no block"); @@ -3016,7 +3010,7 @@ heap_xlog_lock(XLogRecPtr lsn, XLogRecord *record) if (PageIsNew((PageHeader) page)) elog(PANIC, "heap_lock_redo: uninitialized page"); - if (XLByteLE(lsn, PageGetLSN(page))) /* changes are applied */ + if (XLByteLE(lsn, PageGetLSN(page))) /* changes are applied */ { LockBuffer(buffer, BUFFER_LOCK_UNLOCK); ReleaseBuffer(buffer); @@ -3081,7 +3075,7 @@ static void out_target(char *buf, xl_heaptid *target) { sprintf(buf + strlen(buf), "rel %u/%u/%u; tid %u/%u", - target->node.spcNode, target->node.dbNode, target->node.relNode, + target->node.spcNode, target->node.dbNode, target->node.relNode, ItemPointerGetBlockNumber(&(target->tid)), ItemPointerGetOffsetNumber(&(target->tid))); } diff --git a/src/backend/access/heap/hio.c b/src/backend/access/heap/hio.c index fc1b0afd21..800ee4a805 100644 --- a/src/backend/access/heap/hio.c +++ b/src/backend/access/heap/hio.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/heap/hio.c,v 1.57 2005/06/20 18:37:01 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/heap/hio.c,v 1.58 2005/10/15 02:49:08 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -80,7 +80,7 @@ RelationPutHeapTuple(Relation relation, * enough there). In that case, the page will be pinned and locked only once. * * If use_fsm is true (the normal case), we use FSM to help us find free - * space. If use_fsm is false, we always append a new empty page to the + * space. If use_fsm is false, we always append a new empty page to the * end of the relation if the tuple won't fit on the current target page. * This can save some cycles when we know the relation is new and doesn't * contain useful amounts of free space. @@ -122,22 +122,20 @@ RelationGetBufferForTuple(Relation relation, Size len, if (otherBuffer != InvalidBuffer) otherBlock = BufferGetBlockNumber(otherBuffer); else - otherBlock = InvalidBlockNumber; /* just to keep compiler - * quiet */ + otherBlock = InvalidBlockNumber; /* just to keep compiler quiet */ /* - * We first try to put the tuple on the same page we last inserted a - * tuple on, as cached in the relcache entry. If that doesn't work, - * we ask the shared Free Space Map to locate a suitable page. Since - * the FSM's info might be out of date, we have to be prepared to loop - * around and retry multiple times. (To insure this isn't an infinite - * loop, we must update the FSM with the correct amount of free space - * on each page that proves not to be suitable.) If the FSM has no - * record of a page with enough free space, we give up and extend the - * relation. + * We first try to put the tuple on the same page we last inserted a tuple + * on, as cached in the relcache entry. If that doesn't work, we ask the + * shared Free Space Map to locate a suitable page. Since the FSM's info + * might be out of date, we have to be prepared to loop around and retry + * multiple times. (To insure this isn't an infinite loop, we must update + * the FSM with the correct amount of free space on each page that proves + * not to be suitable.) If the FSM has no record of a page with enough + * free space, we give up and extend the relation. * - * When use_fsm is false, we either put the tuple onto the existing - * target page or extend the relation. + * When use_fsm is false, we either put the tuple onto the existing target + * page or extend the relation. */ targetBlock = relation->rd_targblock; @@ -151,9 +149,9 @@ RelationGetBufferForTuple(Relation relation, Size len, targetBlock = GetPageWithFreeSpace(&relation->rd_node, len); /* - * If the FSM knows nothing of the rel, try the last page before - * we give up and extend. This avoids one-tuple-per-page syndrome - * during bootstrapping or in a recently-started system. + * If the FSM knows nothing of the rel, try the last page before we + * give up and extend. This avoids one-tuple-per-page syndrome during + * bootstrapping or in a recently-started system. */ if (targetBlock == InvalidBlockNumber) { @@ -168,8 +166,8 @@ RelationGetBufferForTuple(Relation relation, Size len, { /* * Read and exclusive-lock the target block, as well as the other - * block if one was given, taking suitable care with lock ordering - * and the possibility they are the same block. + * block if one was given, taking suitable care with lock ordering and + * the possibility they are the same block. */ if (otherBuffer == InvalidBuffer) { @@ -199,8 +197,8 @@ RelationGetBufferForTuple(Relation relation, Size len, } /* - * Now we can check to see if there's enough free space here. If - * so, we're done. + * Now we can check to see if there's enough free space here. If so, + * we're done. */ pageHeader = (Page) BufferGetPage(buffer); pageFreeSpace = PageGetFreeSpace(pageHeader); @@ -213,9 +211,9 @@ RelationGetBufferForTuple(Relation relation, Size len, /* * Not enough space, so we must give up our page locks and pin (if - * any) and prepare to look elsewhere. We don't care which order - * we unlock the two buffers in, so this can be slightly simpler - * than the code above. + * any) and prepare to look elsewhere. We don't care which order we + * unlock the two buffers in, so this can be slightly simpler than the + * code above. */ LockBuffer(buffer, BUFFER_LOCK_UNLOCK); if (otherBuffer == InvalidBuffer) @@ -231,8 +229,8 @@ RelationGetBufferForTuple(Relation relation, Size len, break; /* - * Update FSM as to condition of this page, and ask for another - * page to try. + * Update FSM as to condition of this page, and ask for another page + * to try. */ targetBlock = RecordAndGetPageWithFreeSpace(&relation->rd_node, targetBlock, @@ -243,10 +241,10 @@ RelationGetBufferForTuple(Relation relation, Size len, /* * Have to extend the relation. * - * We have to use a lock to ensure no one else is extending the rel at - * the same time, else we will both try to initialize the same new - * page. We can skip locking for new or temp relations, however, - * since no one else could be accessing them. + * We have to use a lock to ensure no one else is extending the rel at the + * same time, else we will both try to initialize the same new page. We + * can skip locking for new or temp relations, however, since no one else + * could be accessing them. */ needLock = !RELATION_IS_LOCAL(relation); @@ -254,17 +252,16 @@ RelationGetBufferForTuple(Relation relation, Size len, LockRelationForExtension(relation, ExclusiveLock); /* - * XXX This does an lseek - rather expensive - but at the moment it is - * the only way to accurately determine how many blocks are in a - * relation. Is it worth keeping an accurate file length in shared - * memory someplace, rather than relying on the kernel to do it for - * us? + * XXX This does an lseek - rather expensive - but at the moment it is the + * only way to accurately determine how many blocks are in a relation. Is + * it worth keeping an accurate file length in shared memory someplace, + * rather than relying on the kernel to do it for us? */ buffer = ReadBuffer(relation, P_NEW); /* - * We can be certain that locking the otherBuffer first is OK, since - * it must have a lower page number. + * We can be certain that locking the otherBuffer first is OK, since it + * must have a lower page number. */ if (otherBuffer != InvalidBuffer) LockBuffer(otherBuffer, BUFFER_LOCK_EXCLUSIVE); @@ -275,10 +272,10 @@ RelationGetBufferForTuple(Relation relation, Size len, LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE); /* - * Release the file-extension lock; it's now OK for someone else to - * extend the relation some more. Note that we cannot release this - * lock before we have buffer lock on the new page, or we risk a - * race condition against vacuumlazy.c --- see comments therein. + * Release the file-extension lock; it's now OK for someone else to extend + * the relation some more. Note that we cannot release this lock before + * we have buffer lock on the new page, or we risk a race condition + * against vacuumlazy.c --- see comments therein. */ if (needLock) UnlockRelationForExtension(relation, ExclusiveLock); @@ -299,11 +296,11 @@ RelationGetBufferForTuple(Relation relation, Size len, /* * Remember the new page as our target for future insertions. * - * XXX should we enter the new page into the free space map immediately, - * or just keep it for this backend's exclusive use in the short run - * (until VACUUM sees it)? Seems to depend on whether you expect the - * current backend to make more insertions or not, which is probably a - * good bet most of the time. So for now, don't add it to FSM yet. + * XXX should we enter the new page into the free space map immediately, or + * just keep it for this backend's exclusive use in the short run (until + * VACUUM sees it)? Seems to depend on whether you expect the current + * backend to make more insertions or not, which is probably a good bet + * most of the time. So for now, don't add it to FSM yet. */ relation->rd_targblock = BufferGetBlockNumber(buffer); diff --git a/src/backend/access/heap/tuptoaster.c b/src/backend/access/heap/tuptoaster.c index 02da8446cd..fd20f111b8 100644 --- a/src/backend/access/heap/tuptoaster.c +++ b/src/backend/access/heap/tuptoaster.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/heap/tuptoaster.c,v 1.52 2005/08/12 01:35:54 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/heap/tuptoaster.c,v 1.53 2005/10/15 02:49:09 momjian Exp $ * * * INTERFACE ROUTINES @@ -90,8 +90,7 @@ heap_tuple_fetch_attr(varattrib *attr) else { /* - * This is a plain value inside of the main tuple - why am I - * called? + * This is a plain value inside of the main tuple - why am I called? */ result = attr; } @@ -154,8 +153,7 @@ heap_tuple_untoast_attr(varattrib *attr) else /* - * This is a plain value inside of the main tuple - why am I - * called? + * This is a plain value inside of the main tuple - why am I called? */ return attr; @@ -255,8 +253,8 @@ toast_raw_datum_size(Datum value) else if (VARATT_IS_EXTERNAL(attr)) { /* - * an uncompressed external attribute has rawsize including the - * header (not too consistent!) + * an uncompressed external attribute has rawsize including the header + * (not too consistent!) */ result = attr->va_content.va_external.va_rawsize; } @@ -274,26 +272,26 @@ toast_raw_datum_size(Datum value) * Return the physical storage size (possibly compressed) of a varlena datum * ---------- */ -Size +Size toast_datum_size(Datum value) { - varattrib *attr = (varattrib *) DatumGetPointer(value); + varattrib *attr = (varattrib *) DatumGetPointer(value); Size result; if (VARATT_IS_EXTERNAL(attr)) { /* * Attribute is stored externally - return the extsize whether - * compressed or not. We do not count the size of the toast - * pointer ... should we? + * compressed or not. We do not count the size of the toast pointer + * ... should we? */ result = attr->va_content.va_external.va_extsize; } else { /* - * Attribute is stored inline either compressed or not, just - * calculate the size of the datum in either case. + * Attribute is stored inline either compressed or not, just calculate + * the size of the datum in either case. */ result = VARSIZE(attr); } @@ -321,12 +319,12 @@ toast_delete(Relation rel, HeapTuple oldtup) * Get the tuple descriptor and break down the tuple into fields. * * NOTE: it's debatable whether to use heap_deformtuple() here or just - * heap_getattr() only the varlena columns. The latter could win if - * there are few varlena columns and many non-varlena ones. However, - * heap_deformtuple costs only O(N) while the heap_getattr way would - * cost O(N^2) if there are many varlena columns, so it seems better - * to err on the side of linear cost. (We won't even be here unless - * there's at least one varlena column, by the way.) + * heap_getattr() only the varlena columns. The latter could win if there + * are few varlena columns and many non-varlena ones. However, + * heap_deformtuple costs only O(N) while the heap_getattr way would cost + * O(N^2) if there are many varlena columns, so it seems better to err on + * the side of linear cost. (We won't even be here unless there's at + * least one varlena column, by the way.) */ tupleDesc = rel->rd_att; att = tupleDesc->attrs; @@ -336,8 +334,8 @@ toast_delete(Relation rel, HeapTuple oldtup) heap_deform_tuple(oldtup, tupleDesc, toast_values, toast_isnull); /* - * Check for external stored attributes and delete them from the - * secondary relation. + * Check for external stored attributes and delete them from the secondary + * relation. */ for (i = 0; i < numAttrs; i++) { @@ -447,9 +445,9 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup) else { /* - * This attribute isn't changed by this update so we - * reuse the original reference to the old value in - * the new tuple. + * This attribute isn't changed by this update so we reuse + * the original reference to the old value in the new + * tuple. */ toast_action[i] = 'p'; toast_sizes[i] = VARATT_SIZE(toast_values[i]); @@ -582,16 +580,15 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup) else { /* - * incompressible data, ignore on subsequent compression - * passes + * incompressible data, ignore on subsequent compression passes */ toast_action[i] = 'x'; } } /* - * Second we look for attributes of attstorage 'x' or 'e' that are - * still inline. + * Second we look for attributes of attstorage 'x' or 'e' that are still + * inline. */ while (MAXALIGN(heap_compute_data_size(tupleDesc, toast_values, toast_isnull)) > @@ -696,8 +693,7 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup) else { /* - * incompressible data, ignore on subsequent compression - * passes + * incompressible data, ignore on subsequent compression passes */ toast_action[i] = 'x'; } @@ -755,8 +751,8 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup) } /* - * In the case we toasted any values, we need to build a new heap - * tuple with the changed values. + * In the case we toasted any values, we need to build a new heap tuple + * with the changed values. */ if (need_change) { @@ -798,8 +794,8 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup) has_nulls ? newtup->t_data->t_bits : NULL); /* - * In the case we modified a previously modified tuple again, free - * the memory from the previous run + * In the case we modified a previously modified tuple again, free the + * memory from the previous run */ if ((char *) olddata != ((char *) newtup + HEAPTUPLESIZE)) pfree(olddata); @@ -906,8 +902,8 @@ toast_flatten_tuple_attribute(Datum value, return value; /* - * Calculate the new size of the tuple. Header size should not - * change, but data size might. + * Calculate the new size of the tuple. Header size should not change, + * but data size might. */ new_len = offsetof(HeapTupleHeaderData, t_bits); if (has_nulls) @@ -1007,9 +1003,9 @@ toast_save_datum(Relation rel, Datum value) int32 data_todo; /* - * Open the toast relation and its index. We can use the index to - * check uniqueness of the OID we assign to the toasted item, even - * though it has additional columns besides OID. + * Open the toast relation and its index. We can use the index to check + * uniqueness of the OID we assign to the toasted item, even though it has + * additional columns besides OID. */ toastrel = heap_open(rel->rd_rel->reltoastrelid, RowExclusiveLock); toasttupDesc = toastrel->rd_att; @@ -1082,11 +1078,11 @@ toast_save_datum(Relation rel, Datum value) /* * Create the index entry. We cheat a little here by not using - * FormIndexDatum: this relies on the knowledge that the index - * columns are the same as the initial columns of the table. + * FormIndexDatum: this relies on the knowledge that the index columns + * are the same as the initial columns of the table. * - * Note also that there had better not be any user-created index on - * the TOAST table, since we don't bother to update anything else. + * Note also that there had better not be any user-created index on the + * TOAST table, since we don't bother to update anything else. */ index_insert(toastidx, t_values, t_isnull, &(toasttup->t_self), @@ -1148,7 +1144,7 @@ toast_delete_datum(Relation rel, Datum value) ScanKeyInit(&toastkey, (AttrNumber) 1, BTEqualStrategyNumber, F_OIDEQ, - ObjectIdGetDatum(attr->va_content.va_external.va_valueid)); + ObjectIdGetDatum(attr->va_content.va_external.va_valueid)); /* * Find the chunks by index @@ -1219,14 +1215,14 @@ toast_fetch_datum(varattrib *attr) ScanKeyInit(&toastkey, (AttrNumber) 1, BTEqualStrategyNumber, F_OIDEQ, - ObjectIdGetDatum(attr->va_content.va_external.va_valueid)); + ObjectIdGetDatum(attr->va_content.va_external.va_valueid)); /* * Read the chunks by index * - * Note that because the index is actually on (valueid, chunkidx) we will - * see the chunks in chunkidx order, even though we didn't explicitly - * ask for it. + * Note that because the index is actually on (valueid, chunkidx) we will see + * the chunks in chunkidx order, even though we didn't explicitly ask for + * it. */ nextidx = 0; @@ -1367,13 +1363,13 @@ toast_fetch_datum_slice(varattrib *attr, int32 sliceoffset, int32 length) toastidx = index_open(toastrel->rd_rel->reltoastidxid); /* - * Setup a scan key to fetch from the index. This is either two keys - * or three depending on the number of chunks. + * Setup a scan key to fetch from the index. This is either two keys or + * three depending on the number of chunks. */ ScanKeyInit(&toastkey[0], (AttrNumber) 1, BTEqualStrategyNumber, F_OIDEQ, - ObjectIdGetDatum(attr->va_content.va_external.va_valueid)); + ObjectIdGetDatum(attr->va_content.va_external.va_valueid)); /* * Use equality condition for one chunk, a range condition otherwise: diff --git a/src/backend/access/index/genam.c b/src/backend/access/index/genam.c index 90e910f343..ed604f9c5d 100644 --- a/src/backend/access/index/genam.c +++ b/src/backend/access/index/genam.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/index/genam.c,v 1.48 2005/05/27 23:31:20 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/index/genam.c,v 1.49 2005/10/15 02:49:09 momjian Exp $ * * NOTES * many of the old access method routines have been turned into @@ -78,15 +78,15 @@ RelationGetIndexScan(Relation indexRelation, scan->numberOfKeys = nkeys; /* - * We allocate the key space here, but the AM is responsible for - * actually filling it from the passed key array. + * We allocate the key space here, but the AM is responsible for actually + * filling it from the passed key array. */ if (nkeys > 0) scan->keyData = (ScanKey) palloc(sizeof(ScanKeyData) * nkeys); else scan->keyData = NULL; - scan->is_multiscan = false; /* caller may change this */ + scan->is_multiscan = false; /* caller may change this */ scan->kill_prior_tuple = false; scan->ignore_killed_tuples = true; /* default setting */ scan->keys_are_unique = false; /* may be set by index AM */ @@ -203,8 +203,8 @@ systable_beginscan(Relation heapRelation, /* * Change attribute numbers to be index column numbers. * - * This code could be generalized to search for the index key numbers - * to substitute, but for now there's no need. + * This code could be generalized to search for the index key numbers to + * substitute, but for now there's no need. */ for (i = 0; i < nkeys; i++) { diff --git a/src/backend/access/index/indexam.c b/src/backend/access/index/indexam.c index 7bf7fcd22f..bd2e3bdd06 100644 --- a/src/backend/access/index/indexam.c +++ b/src/backend/access/index/indexam.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/index/indexam.c,v 1.85 2005/10/06 02:29:11 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/index/indexam.c,v 1.86 2005/10/15 02:49:09 momjian Exp $ * * INTERFACE ROUTINES * index_open - open an index relation by relation OID @@ -111,7 +111,7 @@ do { \ } while(0) static IndexScanDesc index_beginscan_internal(Relation indexRelation, - int nkeys, ScanKey key); + int nkeys, ScanKey key); /* ---------------------------------------------------------------- @@ -122,14 +122,14 @@ static IndexScanDesc index_beginscan_internal(Relation indexRelation, /* ---------------- * index_open - open an index relation by relation OID * - * Note: we acquire no lock on the index. A lock is not needed when + * Note: we acquire no lock on the index. A lock is not needed when * simply examining the index reldesc; the index's schema information * is considered to be protected by the lock that the caller had better - * be holding on the parent relation. Some type of lock should be + * be holding on the parent relation. Some type of lock should be * obtained on the index before physically accessing it, however. * This is handled automatically for most uses by index_beginscan * and index_endscan for scan cases, or by ExecOpenIndices and - * ExecCloseIndices for update cases. Other callers will need to + * ExecCloseIndices for update cases. Other callers will need to * obtain their own locks. * * This is a convenience routine adapted for indexscan use. @@ -241,8 +241,8 @@ index_beginscan(Relation heapRelation, scan = index_beginscan_internal(indexRelation, nkeys, key); /* - * Save additional parameters into the scandesc. Everything else was - * set up by RelationGetIndexScan. + * Save additional parameters into the scandesc. Everything else was set + * up by RelationGetIndexScan. */ scan->is_multiscan = false; scan->heapRelation = heapRelation; @@ -267,8 +267,8 @@ index_beginscan_multi(Relation indexRelation, scan = index_beginscan_internal(indexRelation, nkeys, key); /* - * Save additional parameters into the scandesc. Everything else was - * set up by RelationGetIndexScan. + * Save additional parameters into the scandesc. Everything else was set + * up by RelationGetIndexScan. */ scan->is_multiscan = true; scan->xs_snapshot = snapshot; @@ -294,14 +294,14 @@ index_beginscan_internal(Relation indexRelation, * Acquire AccessShareLock for the duration of the scan * * Note: we could get an SI inval message here and consequently have to - * rebuild the relcache entry. The refcount increment above ensures - * that we will rebuild it and not just flush it... + * rebuild the relcache entry. The refcount increment above ensures that + * we will rebuild it and not just flush it... */ LockRelation(indexRelation, AccessShareLock); /* - * LockRelation can clean rd_aminfo structure, so fill procedure - * after LockRelation + * LockRelation can clean rd_aminfo structure, so fill procedure after + * LockRelation */ GET_REL_PROCEDURE(ambeginscan); @@ -425,8 +425,8 @@ index_restrpos(IndexScanDesc scan) /* * We do not reset got_tuple; so if the scan is actually being - * short-circuited by index_getnext, the effective position - * restoration is done by restoring unique_tuple_pos. + * short-circuited by index_getnext, the effective position restoration is + * done by restoring unique_tuple_pos. */ scan->unique_tuple_pos = scan->unique_tuple_mark; @@ -454,19 +454,19 @@ index_getnext(IndexScanDesc scan, ScanDirection direction) /* * If we already got a tuple and it must be unique, there's no need to - * make the index AM look through any additional tuples. (This can - * save a useful amount of work in scenarios where there are many dead - * tuples due to heavy update activity.) + * make the index AM look through any additional tuples. (This can save a + * useful amount of work in scenarios where there are many dead tuples due + * to heavy update activity.) * * To do this we must keep track of the logical scan position * (before/on/after tuple). Also, we have to be sure to release scan - * resources before returning NULL; if we fail to do so then a - * multi-index scan can easily run the system out of free buffers. We - * can release index-level resources fairly cheaply by calling - * index_rescan. This means there are two persistent states as far as - * the index AM is concerned: on-tuple and rescanned. If we are - * actually asked to re-fetch the single tuple, we have to go through - * a fresh indexscan startup, which penalizes that (infrequent) case. + * resources before returning NULL; if we fail to do so then a multi-index + * scan can easily run the system out of free buffers. We can release + * index-level resources fairly cheaply by calling index_rescan. This + * means there are two persistent states as far as the index AM is + * concerned: on-tuple and rescanned. If we are actually asked to + * re-fetch the single tuple, we have to go through a fresh indexscan + * startup, which penalizes that (infrequent) case. */ if (scan->keys_are_unique && scan->got_tuple) { @@ -485,19 +485,18 @@ index_getnext(IndexScanDesc scan, ScanDirection direction) if (new_tuple_pos == 0) { /* - * We are moving onto the unique tuple from having been off - * it. We just fall through and let the index AM do the work. - * Note we should get the right answer regardless of scan - * direction. + * We are moving onto the unique tuple from having been off it. We + * just fall through and let the index AM do the work. Note we + * should get the right answer regardless of scan direction. */ scan->unique_tuple_pos = 0; /* need to update position */ } else { /* - * Moving off the tuple; must do amrescan to release - * index-level pins before we return NULL. Since index_rescan - * will reset my state, must save and restore... + * Moving off the tuple; must do amrescan to release index-level + * pins before we return NULL. Since index_rescan will reset my + * state, must save and restore... */ int unique_tuple_mark = scan->unique_tuple_mark; @@ -520,8 +519,7 @@ index_getnext(IndexScanDesc scan, ScanDirection direction) bool found; /* - * The AM's gettuple proc finds the next tuple matching the scan - * keys. + * The AM's gettuple proc finds the next tuple matching the scan keys. */ found = DatumGetBool(FunctionCall2(procedure, PointerGetDatum(scan), @@ -556,9 +554,9 @@ index_getnext(IndexScanDesc scan, ScanDirection direction) continue; /* - * If we can't see it, maybe no one else can either. Check to see - * if the tuple is dead to all transactions. If so, signal the - * index AM to not return it on future indexscans. + * If we can't see it, maybe no one else can either. Check to see if + * the tuple is dead to all transactions. If so, signal the index AM + * to not return it on future indexscans. * * We told heap_release_fetch to keep a pin on the buffer, so we can * re-access the tuple here. But we must re-lock the buffer first. @@ -576,8 +574,8 @@ index_getnext(IndexScanDesc scan, ScanDirection direction) scan->got_tuple = true; /* - * If we just fetched a known-unique tuple, then subsequent calls will - * go through the short-circuit code above. unique_tuple_pos has been + * If we just fetched a known-unique tuple, then subsequent calls will go + * through the short-circuit code above. unique_tuple_pos has been * initialized to 0, which is the correct state ("on row"). */ @@ -805,11 +803,10 @@ index_getprocinfo(Relation irel, procId = loc[procindex]; /* - * Complain if function was not found during - * IndexSupportInitialize. This should not happen unless the - * system tables contain bogus entries for the index opclass. (If - * an AM wants to allow a support function to be optional, it can - * use index_getprocid.) + * Complain if function was not found during IndexSupportInitialize. + * This should not happen unless the system tables contain bogus + * entries for the index opclass. (If an AM wants to allow a support + * function to be optional, it can use index_getprocid.) */ if (!RegProcedureIsValid(procId)) elog(ERROR, "missing support function %d for attribute %d of index \"%s\"", diff --git a/src/backend/access/nbtree/nbtinsert.c b/src/backend/access/nbtree/nbtinsert.c index c73ba358ec..33c7612aac 100644 --- a/src/backend/access/nbtree/nbtinsert.c +++ b/src/backend/access/nbtree/nbtinsert.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.126 2005/10/12 17:18:03 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.127 2005/10/15 02:49:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -93,30 +93,29 @@ top: /* * If the page was split between the time that we surrendered our read - * lock and acquired our write lock, then this page may no longer be - * the right place for the key we want to insert. In this case, we - * need to move right in the tree. See Lehman and Yao for an - * excruciatingly precise description. + * lock and acquired our write lock, then this page may no longer be the + * right place for the key we want to insert. In this case, we need to + * move right in the tree. See Lehman and Yao for an excruciatingly + * precise description. */ buf = _bt_moveright(rel, buf, natts, itup_scankey, false, BT_WRITE); /* - * If we're not allowing duplicates, make sure the key isn't already - * in the index. + * If we're not allowing duplicates, make sure the key isn't already in + * the index. * - * NOTE: obviously, _bt_check_unique can only detect keys that are - * already in the index; so it cannot defend against concurrent - * insertions of the same key. We protect against that by means of - * holding a write lock on the target page. Any other would-be - * inserter of the same key must acquire a write lock on the same - * target page, so only one would-be inserter can be making the check - * at one time. Furthermore, once we are past the check we hold write - * locks continuously until we have performed our insertion, so no - * later inserter can fail to see our insertion. (This requires some - * care in _bt_insertonpg.) + * NOTE: obviously, _bt_check_unique can only detect keys that are already in + * the index; so it cannot defend against concurrent insertions of the + * same key. We protect against that by means of holding a write lock on + * the target page. Any other would-be inserter of the same key must + * acquire a write lock on the same target page, so only one would-be + * inserter can be making the check at one time. Furthermore, once we are + * past the check we hold write locks continuously until we have performed + * our insertion, so no later inserter can fail to see our insertion. + * (This requires some care in _bt_insertonpg.) * - * If we must wait for another xact, we release the lock while waiting, - * and then must start over completely. + * If we must wait for another xact, we release the lock while waiting, and + * then must start over completely. */ if (index_is_unique) { @@ -167,8 +166,8 @@ _bt_check_unique(Relation rel, BTItem btitem, Relation heapRel, maxoff = PageGetMaxOffsetNumber(page); /* - * Find first item >= proposed new item. Note we could also get a - * pointer to end-of-page here. + * Find first item >= proposed new item. Note we could also get a pointer + * to end-of-page here. */ offset = _bt_binsrch(rel, buf, natts, itup_scankey, false); @@ -194,24 +193,24 @@ _bt_check_unique(Relation rel, BTItem btitem, Relation heapRel, /* * We can skip items that are marked killed. * - * Formerly, we applied _bt_isequal() before checking the kill - * flag, so as to fall out of the item loop as soon as - * possible. However, in the presence of heavy update activity - * an index may contain many killed items with the same key; - * running _bt_isequal() on each killed item gets expensive. - * Furthermore it is likely that the non-killed version of - * each key appears first, so that we didn't actually get to - * exit any sooner anyway. So now we just advance over killed - * items as quickly as we can. We only apply _bt_isequal() - * when we get to a non-killed item or the end of the page. + * Formerly, we applied _bt_isequal() before checking the kill flag, + * so as to fall out of the item loop as soon as possible. + * However, in the presence of heavy update activity an index may + * contain many killed items with the same key; running + * _bt_isequal() on each killed item gets expensive. Furthermore + * it is likely that the non-killed version of each key appears + * first, so that we didn't actually get to exit any sooner + * anyway. So now we just advance over killed items as quickly as + * we can. We only apply _bt_isequal() when we get to a non-killed + * item or the end of the page. */ if (!ItemIdDeleted(curitemid)) { /* - * _bt_compare returns 0 for (1,NULL) and (1,NULL) - - * this's how we handling NULLs - and so we must not use - * _bt_compare in real comparison, but only for - * ordering/finding items on pages. - vadim 03/24/97 + * _bt_compare returns 0 for (1,NULL) and (1,NULL) - this's + * how we handling NULLs - and so we must not use _bt_compare + * in real comparison, but only for ordering/finding items on + * pages. - vadim 03/24/97 */ if (!_bt_isequal(itupdesc, page, offset, natts, itup_scankey)) break; /* we're past all the equal tuples */ @@ -246,15 +245,15 @@ _bt_check_unique(Relation rel, BTItem btitem, Relation heapRel, */ ereport(ERROR, (errcode(ERRCODE_UNIQUE_VIOLATION), - errmsg("duplicate key violates unique constraint \"%s\"", - RelationGetRelationName(rel)))); + errmsg("duplicate key violates unique constraint \"%s\"", + RelationGetRelationName(rel)))); } else if (htup.t_data != NULL) { /* - * Hmm, if we can't see the tuple, maybe it can be - * marked killed. This logic should match - * index_getnext and btgettuple. + * Hmm, if we can't see the tuple, maybe it can be marked + * killed. This logic should match index_getnext and + * btgettuple. */ LockBuffer(hbuffer, BUFFER_LOCK_SHARE); if (HeapTupleSatisfiesVacuum(htup.t_data, RecentGlobalXmin, @@ -377,15 +376,15 @@ _bt_insertonpg(Relation rel, itemsz = IndexTupleDSize(btitem->bti_itup) + (sizeof(BTItemData) - sizeof(IndexTupleData)); - itemsz = MAXALIGN(itemsz); /* be safe, PageAddItem will do this but - * we need to be consistent */ + itemsz = MAXALIGN(itemsz); /* be safe, PageAddItem will do this but we + * need to be consistent */ /* - * Check whether the item can fit on a btree page at all. (Eventually, - * we ought to try to apply TOAST methods if not.) We actually need to - * be able to fit three items on every page, so restrict any one item - * to 1/3 the per-page available space. Note that at this point, - * itemsz doesn't include the ItemId. + * Check whether the item can fit on a btree page at all. (Eventually, we + * ought to try to apply TOAST methods if not.) We actually need to be + * able to fit three items on every page, so restrict any one item to 1/3 + * the per-page available space. Note that at this point, itemsz doesn't + * include the ItemId. */ if (itemsz > BTMaxItemSize(page)) ereport(ERROR, @@ -393,9 +392,9 @@ _bt_insertonpg(Relation rel, errmsg("index row size %lu exceeds btree maximum, %lu", (unsigned long) itemsz, (unsigned long) BTMaxItemSize(page)), - errhint("Values larger than 1/3 of a buffer page cannot be indexed.\n" - "Consider a function index of an MD5 hash of the value, " - "or use full text indexing."))); + errhint("Values larger than 1/3 of a buffer page cannot be indexed.\n" + "Consider a function index of an MD5 hash of the value, " + "or use full text indexing."))); /* * Determine exactly where new item will go. @@ -432,11 +431,11 @@ _bt_insertonpg(Relation rel, /* * step right to next non-dead page * - * must write-lock that page before releasing write lock on - * current page; else someone else's _bt_check_unique scan - * could fail to see our insertion. write locks on - * intermediate dead pages won't do because we don't know when - * they will get de-linked from the tree. + * must write-lock that page before releasing write lock on current + * page; else someone else's _bt_check_unique scan could fail to + * see our insertion. write locks on intermediate dead pages + * won't do because we don't know when they will get de-linked + * from the tree. */ Buffer rbuf = InvalidBuffer; @@ -459,9 +458,9 @@ _bt_insertonpg(Relation rel, } /* - * Now we are on the right page, so find the insert position. If - * we moved right at all, we know we should insert at the start of - * the page, else must find the position by searching. + * Now we are on the right page, so find the insert position. If we + * moved right at all, we know we should insert at the start of the + * page, else must find the position by searching. */ if (movedright) newitemoff = P_FIRSTDATAKEY(lpageop); @@ -472,9 +471,9 @@ _bt_insertonpg(Relation rel, /* * Do we need to split the page to fit the item on it? * - * Note: PageGetFreeSpace() subtracts sizeof(ItemIdData) from its result, - * so this comparison is correct even though we appear to be - * accounting only for the item and not for its line pointer. + * Note: PageGetFreeSpace() subtracts sizeof(ItemIdData) from its result, so + * this comparison is correct even though we appear to be accounting only + * for the item and not for its line pointer. */ if (PageGetFreeSpace(page) < itemsz) { @@ -522,12 +521,11 @@ _bt_insertonpg(Relation rel, itup_blkno = BufferGetBlockNumber(buf); /* - * If we are doing this insert because we split a page that was - * the only one on its tree level, but was not the root, it may - * have been the "fast root". We need to ensure that the fast - * root link points at or above the current page. We can safely - * acquire a lock on the metapage here --- see comments for - * _bt_newroot(). + * If we are doing this insert because we split a page that was the + * only one on its tree level, but was not the root, it may have been + * the "fast root". We need to ensure that the fast root link points + * at or above the current page. We can safely acquire a lock on the + * metapage here --- see comments for _bt_newroot(). */ if (split_only_page) { @@ -692,11 +690,11 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright, lopaque->btpo.level = ropaque->btpo.level = oopaque->btpo.level; /* - * If the page we're splitting is not the rightmost page at its level - * in the tree, then the first entry on the page is the high key for - * the page. We need to copy that to the right half. Otherwise - * (meaning the rightmost page case), all the items on the right half - * will be user data. + * If the page we're splitting is not the rightmost page at its level in + * the tree, then the first entry on the page is the high key for the + * page. We need to copy that to the right half. Otherwise (meaning the + * rightmost page case), all the items on the right half will be user + * data. */ rightoff = P_HIKEY; @@ -712,9 +710,9 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright, } /* - * The "high key" for the new left page will be the first key that's - * going to go into the new right page. This might be either the - * existing data item at position firstright, or the incoming tuple. + * The "high key" for the new left page will be the first key that's going + * to go into the new right page. This might be either the existing data + * item at position firstright, or the incoming tuple. */ leftoff = P_HIKEY; if (!newitemonleft && newitemoff == firstright) @@ -806,8 +804,8 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright, /* * We have to grab the right sibling (if any) and fix the prev pointer * there. We are guaranteed that this is deadlock-free since no other - * writer will be holding a lock on that page and trying to move left, - * and all readers release locks on a page before trying to fetch its + * writer will be holding a lock on that page and trying to move left, and + * all readers release locks on a page before trying to fetch its * neighbors. */ @@ -821,8 +819,8 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright, } /* - * Right sibling is locked, new siblings are prepared, but original - * page is not updated yet. Log changes before continuing. + * Right sibling is locked, new siblings are prepared, but original page + * is not updated yet. Log changes before continuing. * * NO EREPORT(ERROR) till right sibling is updated. */ @@ -850,10 +848,10 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright, xlrec.level = lopaque->btpo.level; /* - * Direct access to page is not good but faster - we should - * implement some new func in page API. Note we only store the - * tuples themselves, knowing that the item pointers are in the - * same order and can be reconstructed by scanning the tuples. + * Direct access to page is not good but faster - we should implement + * some new func in page API. Note we only store the tuples + * themselves, knowing that the item pointers are in the same order + * and can be reconstructed by scanning the tuples. */ xlrec.leftlen = ((PageHeader) leftpage)->pd_special - ((PageHeader) leftpage)->pd_upper; @@ -903,13 +901,13 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright, } /* - * By here, the original data page has been split into two new halves, - * and these are correct. The algorithm requires that the left page - * never move during a split, so we copy the new left page back on top - * of the original. Note that this is not a waste of time, since we - * also require (in the page management code) that the center of a - * page always be clean, and the most efficient way to guarantee this - * is just to compact the data by reinserting it into a new left page. + * By here, the original data page has been split into two new halves, and + * these are correct. The algorithm requires that the left page never + * move during a split, so we copy the new left page back on top of the + * original. Note that this is not a waste of time, since we also require + * (in the page management code) that the center of a page always be + * clean, and the most efficient way to guarantee this is just to compact + * the data by reinserting it into a new left page. */ PageRestoreTempPage(leftpage, origpage); @@ -984,13 +982,13 @@ _bt_findsplitloc(Relation rel, MAXALIGN(sizeof(BTPageOpaqueData)); /* - * Finding the best possible split would require checking all the - * possible split points, because of the high-key and left-key special - * cases. That's probably more work than it's worth; instead, stop as - * soon as we find a "good-enough" split, where good-enough is defined - * as an imbalance in free space of no more than pagesize/16 - * (arbitrary...) This should let us stop near the middle on most - * pages, instead of plowing to the end. + * Finding the best possible split would require checking all the possible + * split points, because of the high-key and left-key special cases. + * That's probably more work than it's worth; instead, stop as soon as we + * find a "good-enough" split, where good-enough is defined as an + * imbalance in free space of no more than pagesize/16 (arbitrary...) This + * should let us stop near the middle on most pages, instead of plowing to + * the end. */ goodenough = leftspace / 16; @@ -1006,8 +1004,8 @@ _bt_findsplitloc(Relation rel, dataitemtotal = rightspace - (int) PageGetFreeSpace(page); /* - * Scan through the data items and calculate space usage for a split - * at each possible position. + * Scan through the data items and calculate space usage for a split at + * each possible position. */ dataitemstoleft = 0; maxoff = PageGetMaxOffsetNumber(page); @@ -1024,9 +1022,9 @@ _bt_findsplitloc(Relation rel, itemsz = MAXALIGN(ItemIdGetLength(itemid)) + sizeof(ItemIdData); /* - * We have to allow for the current item becoming the high key of - * the left page; therefore it counts against left space as well - * as right space. + * We have to allow for the current item becoming the high key of the + * left page; therefore it counts against left space as well as right + * space. */ leftfree = leftspace - dataitemstoleft - (int) itemsz; rightfree = rightspace - (dataitemtotal - dataitemstoleft); @@ -1058,8 +1056,8 @@ _bt_findsplitloc(Relation rel, } /* - * I believe it is not possible to fail to find a feasible split, but - * just in case ... + * I believe it is not possible to fail to find a feasible split, but just + * in case ... */ if (!state.have_split) elog(ERROR, "could not find a feasible split point for \"%s\"", @@ -1105,8 +1103,7 @@ _bt_checksplitloc(FindSplitData *state, OffsetNumber firstright, { /* * On a rightmost page, try to equalize right free space with - * twice the left free space. See comments for - * _bt_findsplitloc. + * twice the left free space. See comments for _bt_findsplitloc. */ delta = (2 * leftfree) - rightfree; } @@ -1153,19 +1150,18 @@ _bt_insert_parent(Relation rel, bool is_only) { /* - * Here we have to do something Lehman and Yao don't talk about: deal - * with a root split and construction of a new root. If our stack is - * empty then we have just split a node on what had been the root - * level when we descended the tree. If it was still the root then we - * perform a new-root construction. If it *wasn't* the root anymore, - * search to find the next higher level that someone constructed - * meanwhile, and find the right place to insert as for the normal - * case. + * Here we have to do something Lehman and Yao don't talk about: deal with + * a root split and construction of a new root. If our stack is empty + * then we have just split a node on what had been the root level when we + * descended the tree. If it was still the root then we perform a + * new-root construction. If it *wasn't* the root anymore, search to find + * the next higher level that someone constructed meanwhile, and find the + * right place to insert as for the normal case. * - * If we have to search for the parent level, we do so by re-descending - * from the root. This is not super-efficient, but it's rare enough - * not to matter. (This path is also taken when called from WAL - * recovery --- we have no stack in that case.) + * If we have to search for the parent level, we do so by re-descending from + * the root. This is not super-efficient, but it's rare enough not to + * matter. (This path is also taken when called from WAL recovery --- we + * have no stack in that case.) */ if (is_root) { @@ -1219,9 +1215,9 @@ _bt_insert_parent(Relation rel, /* * Find the parent buffer and get the parent page. * - * Oops - if we were moved right then we need to change stack item! - * We want to find parent pointing to where we are, right ? - - * vadim 05/27/97 + * Oops - if we were moved right then we need to change stack item! We + * want to find parent pointing to where we are, right ? - vadim + * 05/27/97 */ ItemPointerSet(&(stack->bts_btitem.bti_itup.t_tid), bknum, P_HIKEY); @@ -1291,9 +1287,9 @@ _bt_getstackbuf(Relation rel, BTStack stack, int access) maxoff = PageGetMaxOffsetNumber(page); /* - * start = InvalidOffsetNumber means "search the whole page". - * We need this test anyway due to possibility that page has a - * high key now when it didn't before. + * start = InvalidOffsetNumber means "search the whole page". We + * need this test anyway due to possibility that page has a high + * key now when it didn't before. */ if (start < minoff) start = minoff; @@ -1307,8 +1303,8 @@ _bt_getstackbuf(Relation rel, BTStack stack, int access) /* * These loops will check every item on the page --- but in an - * order that's attuned to the probability of where it - * actually is. Scan to the right first, then to the left. + * order that's attuned to the probability of where it actually + * is. Scan to the right first, then to the left. */ for (offnum = start; offnum <= maxoff; @@ -1424,9 +1420,9 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf) metad->btm_fastlevel = rootopaque->btpo.level; /* - * Create downlink item for left page (old root). Since this will be - * the first item in a non-leaf page, it implicitly has minus-infinity - * key value, so we need not store any actual key in it. + * Create downlink item for left page (old root). Since this will be the + * first item in a non-leaf page, it implicitly has minus-infinity key + * value, so we need not store any actual key in it. */ itemsz = sizeof(BTItemData); new_item = (BTItem) palloc(itemsz); @@ -1434,17 +1430,17 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf) ItemPointerSet(&(new_item->bti_itup.t_tid), lbkno, P_HIKEY); /* - * Insert the left page pointer into the new root page. The root page - * is the rightmost page on its level so there is no "high key" in it; - * the two items will go into positions P_HIKEY and P_FIRSTKEY. + * Insert the left page pointer into the new root page. The root page is + * the rightmost page on its level so there is no "high key" in it; the + * two items will go into positions P_HIKEY and P_FIRSTKEY. */ if (PageAddItem(rootpage, (Item) new_item, itemsz, P_HIKEY, LP_USED) == InvalidOffsetNumber) elog(PANIC, "failed to add leftkey to new root page"); pfree(new_item); /* - * Create downlink item for right page. The key for it is obtained - * from the "high key" position in the left page. + * Create downlink item for right page. The key for it is obtained from + * the "high key" position in the left page. */ itemid = PageGetItemId(lpage, P_HIKEY); itemsz = ItemIdGetLength(itemid); @@ -1476,8 +1472,8 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf) rdata[0].next = &(rdata[1]); /* - * Direct access to page is not good but faster - we should - * implement some new func in page API. + * Direct access to page is not good but faster - we should implement + * some new func in page API. */ rdata[1].data = (char *) rootpage + ((PageHeader) rootpage)->pd_upper; rdata[1].len = ((PageHeader) rootpage)->pd_special - diff --git a/src/backend/access/nbtree/nbtpage.c b/src/backend/access/nbtree/nbtpage.c index 52d60abaec..927860030c 100644 --- a/src/backend/access/nbtree/nbtpage.c +++ b/src/backend/access/nbtree/nbtpage.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtpage.c,v 1.87 2005/08/12 14:34:14 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtpage.c,v 1.88 2005/10/15 02:49:09 momjian Exp $ * * NOTES * Postgres btree pages look like ordinary relation pages. The opaque @@ -115,8 +115,8 @@ _bt_initmetapage(Page page, BlockNumber rootbknum, uint32 level) metaopaque->btpo_flags = BTP_META; /* - * Set pd_lower just past the end of the metadata. This is not - * essential but it makes the page look compressible to xlog.c. + * Set pd_lower just past the end of the metadata. This is not essential + * but it makes the page look compressible to xlog.c. */ ((PageHeader) page)->pd_lower = ((char *) metad + sizeof(BTMetaPageData)) - (char *) page; @@ -198,26 +198,26 @@ _bt_getroot(Relation rel, int access) LockBuffer(metabuf, BT_WRITE); /* - * Race condition: if someone else initialized the metadata - * between the time we released the read lock and acquired the - * write lock, we must avoid doing it again. + * Race condition: if someone else initialized the metadata between + * the time we released the read lock and acquired the write lock, we + * must avoid doing it again. */ if (metad->btm_root != P_NONE) { /* - * Metadata initialized by someone else. In order to - * guarantee no deadlocks, we have to release the metadata - * page and start all over again. (Is that really true? But - * it's hardly worth trying to optimize this case.) + * Metadata initialized by someone else. In order to guarantee no + * deadlocks, we have to release the metadata page and start all + * over again. (Is that really true? But it's hardly worth trying + * to optimize this case.) */ _bt_relbuf(rel, metabuf); return _bt_getroot(rel, access); } /* - * Get, initialize, write, and leave a lock of the appropriate - * type on the new root page. Since this is the first page in the - * tree, it's a leaf as well as the root. + * Get, initialize, write, and leave a lock of the appropriate type on + * the new root page. Since this is the first page in the tree, it's + * a leaf as well as the root. */ rootbuf = _bt_getbuf(rel, P_NEW, BT_WRITE); rootblkno = BufferGetBlockNumber(rootbuf); @@ -266,9 +266,9 @@ _bt_getroot(Relation rel, int access) _bt_wrtnorelbuf(rel, rootbuf); /* - * swap root write lock for read lock. There is no danger of - * anyone else accessing the new root page while it's unlocked, - * since no one else knows where it is yet. + * swap root write lock for read lock. There is no danger of anyone + * else accessing the new root page while it's unlocked, since no one + * else knows where it is yet. */ LockBuffer(rootbuf, BUFFER_LOCK_UNLOCK); LockBuffer(rootbuf, BT_READ); @@ -312,8 +312,8 @@ _bt_getroot(Relation rel, int access) } /* - * By here, we have a pin and read lock on the root page, and no lock - * set on the metadata page. Return the root page's buffer. + * By here, we have a pin and read lock on the root page, and no lock set + * on the metadata page. Return the root page's buffer. */ return rootbuf; } @@ -435,27 +435,26 @@ _bt_getbuf(Relation rel, BlockNumber blkno, int access) /* * First see if the FSM knows of any free pages. * - * We can't trust the FSM's report unreservedly; we have to check - * that the page is still free. (For example, an already-free - * page could have been re-used between the time the last VACUUM - * scanned it and the time the VACUUM made its FSM updates.) + * We can't trust the FSM's report unreservedly; we have to check that + * the page is still free. (For example, an already-free page could + * have been re-used between the time the last VACUUM scanned it and + * the time the VACUUM made its FSM updates.) * - * In fact, it's worse than that: we can't even assume that it's safe - * to take a lock on the reported page. If somebody else has a - * lock on it, or even worse our own caller does, we could - * deadlock. (The own-caller scenario is actually not improbable. - * Consider an index on a serial or timestamp column. Nearly all - * splits will be at the rightmost page, so it's entirely likely - * that _bt_split will call us while holding a lock on the page - * most recently acquired from FSM. A VACUUM running concurrently - * with the previous split could well have placed that page back - * in FSM.) + * In fact, it's worse than that: we can't even assume that it's safe to + * take a lock on the reported page. If somebody else has a lock on + * it, or even worse our own caller does, we could deadlock. (The + * own-caller scenario is actually not improbable. Consider an index + * on a serial or timestamp column. Nearly all splits will be at the + * rightmost page, so it's entirely likely that _bt_split will call us + * while holding a lock on the page most recently acquired from FSM. + * A VACUUM running concurrently with the previous split could well + * have placed that page back in FSM.) * - * To get around that, we ask for only a conditional lock on the - * reported page. If we fail, then someone else is using the - * page, and we may reasonably assume it's not free. (If we - * happen to be wrong, the worst consequence is the page will be - * lost to use till the next VACUUM, which is no big problem.) + * To get around that, we ask for only a conditional lock on the reported + * page. If we fail, then someone else is using the page, and we may + * reasonably assume it's not free. (If we happen to be wrong, the + * worst consequence is the page will be lost to use till the next + * VACUUM, which is no big problem.) */ for (;;) { @@ -486,10 +485,10 @@ _bt_getbuf(Relation rel, BlockNumber blkno, int access) /* * Extend the relation by one page. * - * We have to use a lock to ensure no one else is extending the rel - * at the same time, else we will both try to initialize the same - * new page. We can skip locking for new or temp relations, - * however, since no one else could be accessing them. + * We have to use a lock to ensure no one else is extending the rel at + * the same time, else we will both try to initialize the same new + * page. We can skip locking for new or temp relations, however, + * since no one else could be accessing them. */ needLock = !RELATION_IS_LOCAL(rel); @@ -504,8 +503,8 @@ _bt_getbuf(Relation rel, BlockNumber blkno, int access) /* * Release the file-extension lock; it's now OK for someone else to * extend the relation some more. Note that we cannot release this - * lock before we have buffer lock on the new page, or we risk a - * race condition against btvacuumcleanup --- see comments therein. + * lock before we have buffer lock on the new page, or we risk a race + * condition against btvacuumcleanup --- see comments therein. */ if (needLock) UnlockRelationForExtension(rel, ExclusiveLock); @@ -614,10 +613,10 @@ _bt_page_recyclable(Page page) BTPageOpaque opaque; /* - * It's possible to find an all-zeroes page in an index --- for - * example, a backend might successfully extend the relation one page - * and then crash before it is able to make a WAL entry for adding the - * page. If we find a zeroed page then reclaim it. + * It's possible to find an all-zeroes page in an index --- for example, a + * backend might successfully extend the relation one page and then crash + * before it is able to make a WAL entry for adding the page. If we find a + * zeroed page then reclaim it. */ if (PageIsNew(page)) return true; @@ -672,9 +671,9 @@ _bt_delitems(Relation rel, Buffer buf, rdata[0].next = &(rdata[1]); /* - * The target-offsets array is not in the buffer, but pretend that - * it is. When XLogInsert stores the whole buffer, the offsets - * array need not be stored too. + * The target-offsets array is not in the buffer, but pretend that it + * is. When XLogInsert stores the whole buffer, the offsets array + * need not be stored too. */ if (nitems > 0) { @@ -747,8 +746,8 @@ _bt_pagedel(Relation rel, Buffer buf, bool vacuum_full) BTPageOpaque opaque; /* - * We can never delete rightmost pages nor root pages. While at it, - * check that page is not already deleted and is empty. + * We can never delete rightmost pages nor root pages. While at it, check + * that page is not already deleted and is empty. */ page = BufferGetPage(buf); opaque = (BTPageOpaque) PageGetSpecialPointer(page); @@ -760,8 +759,8 @@ _bt_pagedel(Relation rel, Buffer buf, bool vacuum_full) } /* - * Save info about page, including a copy of its high key (it must - * have one, being non-rightmost). + * Save info about page, including a copy of its high key (it must have + * one, being non-rightmost). */ target = BufferGetBlockNumber(buf); targetlevel = opaque->btpo.level; @@ -770,11 +769,11 @@ _bt_pagedel(Relation rel, Buffer buf, bool vacuum_full) targetkey = CopyBTItem((BTItem) PageGetItem(page, itemid)); /* - * We need to get an approximate pointer to the page's parent page. - * Use the standard search mechanism to search for the page's high - * key; this will give us a link to either the current parent or - * someplace to its left (if there are multiple equal high keys). To - * avoid deadlocks, we'd better drop the target page lock first. + * We need to get an approximate pointer to the page's parent page. Use + * the standard search mechanism to search for the page's high key; this + * will give us a link to either the current parent or someplace to its + * left (if there are multiple equal high keys). To avoid deadlocks, we'd + * better drop the target page lock first. */ _bt_relbuf(rel, buf); /* we need a scan key to do our search, so build one */ @@ -786,9 +785,8 @@ _bt_pagedel(Relation rel, Buffer buf, bool vacuum_full) _bt_relbuf(rel, lbuf); /* - * If we are trying to delete an interior page, _bt_search did more - * than we needed. Locate the stack item pointing to our parent - * level. + * If we are trying to delete an interior page, _bt_search did more than + * we needed. Locate the stack item pointing to our parent level. */ ilevel = 0; for (;;) @@ -803,16 +801,15 @@ _bt_pagedel(Relation rel, Buffer buf, bool vacuum_full) /* * We have to lock the pages we need to modify in the standard order: - * moving right, then up. Else we will deadlock against other - * writers. + * moving right, then up. Else we will deadlock against other writers. * - * So, we need to find and write-lock the current left sibling of the - * target page. The sibling that was current a moment ago could have - * split, so we may have to move right. This search could fail if - * either the sibling or the target page was deleted by someone else - * meanwhile; if so, give up. (Right now, that should never happen, - * since page deletion is only done in VACUUM and there shouldn't be - * multiple VACUUMs concurrently on the same table.) + * So, we need to find and write-lock the current left sibling of the target + * page. The sibling that was current a moment ago could have split, so + * we may have to move right. This search could fail if either the + * sibling or the target page was deleted by someone else meanwhile; if + * so, give up. (Right now, that should never happen, since page deletion + * is only done in VACUUM and there shouldn't be multiple VACUUMs + * concurrently on the same table.) */ if (leftsib != P_NONE) { @@ -839,19 +836,18 @@ _bt_pagedel(Relation rel, Buffer buf, bool vacuum_full) lbuf = InvalidBuffer; /* - * Next write-lock the target page itself. It should be okay to take - * just a write lock not a superexclusive lock, since no scans would - * stop on an empty page. + * Next write-lock the target page itself. It should be okay to take just + * a write lock not a superexclusive lock, since no scans would stop on an + * empty page. */ buf = _bt_getbuf(rel, target, BT_WRITE); page = BufferGetPage(buf); opaque = (BTPageOpaque) PageGetSpecialPointer(page); /* - * Check page is still empty etc, else abandon deletion. The empty - * check is necessary since someone else might have inserted into it - * while we didn't have it locked; the others are just for paranoia's - * sake. + * Check page is still empty etc, else abandon deletion. The empty check + * is necessary since someone else might have inserted into it while we + * didn't have it locked; the others are just for paranoia's sake. */ if (P_RIGHTMOST(opaque) || P_ISROOT(opaque) || P_ISDELETED(opaque) || P_FIRSTDATAKEY(opaque) <= PageGetMaxOffsetNumber(page)) @@ -872,9 +868,8 @@ _bt_pagedel(Relation rel, Buffer buf, bool vacuum_full) rbuf = _bt_getbuf(rel, rightsib, BT_WRITE); /* - * Next find and write-lock the current parent of the target page. - * This is essentially the same as the corresponding step of - * splitting. + * Next find and write-lock the current parent of the target page. This is + * essentially the same as the corresponding step of splitting. */ ItemPointerSet(&(stack->bts_btitem.bti_itup.t_tid), target, P_HIKEY); @@ -887,8 +882,8 @@ _bt_pagedel(Relation rel, Buffer buf, bool vacuum_full) /* * If the target is the rightmost child of its parent, then we can't - * delete, unless it's also the only child --- in which case the - * parent changes to half-dead status. + * delete, unless it's also the only child --- in which case the parent + * changes to half-dead status. */ page = BufferGetPage(pbuf); opaque = (BTPageOpaque) PageGetSpecialPointer(page); @@ -917,11 +912,10 @@ _bt_pagedel(Relation rel, Buffer buf, bool vacuum_full) } /* - * If we are deleting the next-to-last page on the target's level, - * then the rightsib is a candidate to become the new fast root. (In - * theory, it might be possible to push the fast root even further - * down, but the odds of doing so are slim, and the locking - * considerations daunting.) + * If we are deleting the next-to-last page on the target's level, then + * the rightsib is a candidate to become the new fast root. (In theory, it + * might be possible to push the fast root even further down, but the odds + * of doing so are slim, and the locking considerations daunting.) * * We can safely acquire a lock on the metapage here --- see comments for * _bt_newroot(). @@ -939,9 +933,9 @@ _bt_pagedel(Relation rel, Buffer buf, bool vacuum_full) metad = BTPageGetMeta(metapg); /* - * The expected case here is btm_fastlevel == targetlevel+1; - * if the fastlevel is <= targetlevel, something is wrong, and - * we choose to overwrite it to fix it. + * The expected case here is btm_fastlevel == targetlevel+1; if + * the fastlevel is <= targetlevel, something is wrong, and we + * choose to overwrite it to fix it. */ if (metad->btm_fastlevel > targetlevel + 1) { @@ -961,9 +955,9 @@ _bt_pagedel(Relation rel, Buffer buf, bool vacuum_full) /* * Update parent. The normal case is a tad tricky because we want to - * delete the target's downlink and the *following* key. Easiest way - * is to copy the right sibling's downlink over the target downlink, - * and then delete the following item. + * delete the target's downlink and the *following* key. Easiest way is + * to copy the right sibling's downlink over the target downlink, and then + * delete the following item. */ page = BufferGetPage(pbuf); opaque = (BTPageOpaque) PageGetSpecialPointer(page); @@ -992,8 +986,8 @@ _bt_pagedel(Relation rel, Buffer buf, bool vacuum_full) } /* - * Update siblings' side-links. Note the target page's side-links - * will continue to point to the siblings. + * Update siblings' side-links. Note the target page's side-links will + * continue to point to the siblings. */ if (BufferIsValid(lbuf)) { @@ -1123,10 +1117,10 @@ _bt_pagedel(Relation rel, Buffer buf, bool vacuum_full) _bt_wrtbuf(rel, lbuf); /* - * If parent became half dead, recurse to try to delete it. Otherwise, - * if right sibling is empty and is now the last child of the parent, - * recurse to try to delete it. (These cases cannot apply at the same - * time, though the second case might itself recurse to the first.) + * If parent became half dead, recurse to try to delete it. Otherwise, if + * right sibling is empty and is now the last child of the parent, recurse + * to try to delete it. (These cases cannot apply at the same time, + * though the second case might itself recurse to the first.) */ if (parent_half_dead) { diff --git a/src/backend/access/nbtree/nbtree.c b/src/backend/access/nbtree/nbtree.c index d4232c847f..10e2fe6190 100644 --- a/src/backend/access/nbtree/nbtree.c +++ b/src/backend/access/nbtree/nbtree.c @@ -12,7 +12,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtree.c,v 1.131 2005/09/02 19:02:19 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtree.c,v 1.132 2005/10/15 02:49:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -39,9 +39,9 @@ typedef struct BTSpool *spool; /* - * spool2 is needed only when the index is an unique index. Dead - * tuples are put into spool2 instead of spool in order to avoid - * uniqueness check. + * spool2 is needed only when the index is an unique index. Dead tuples + * are put into spool2 instead of spool in order to avoid uniqueness + * check. */ BTSpool *spool2; double indtuples; @@ -72,10 +72,10 @@ btbuild(PG_FUNCTION_ARGS) BTBuildState buildstate; /* - * bootstrap processing does something strange, so don't use - * sort/build for initial catalog indices. at some point i need to - * look harder at this. (there is some kind of incremental processing - * going on there.) -- pma 08/29/95 + * bootstrap processing does something strange, so don't use sort/build + * for initial catalog indices. at some point i need to look harder at + * this. (there is some kind of incremental processing going on there.) + * -- pma 08/29/95 */ buildstate.usefast = (FastBuild && IsNormalProcessingMode()); buildstate.isUnique = indexInfo->ii_Unique; @@ -91,8 +91,8 @@ btbuild(PG_FUNCTION_ARGS) #endif /* BTREE_BUILD_STATS */ /* - * We expect to be called exactly once for any index relation. If - * that's not the case, big trouble's what we have. + * We expect to be called exactly once for any index relation. If that's + * not the case, big trouble's what we have. */ if (RelationGetNumberOfBlocks(index) != 0) elog(ERROR, "index \"%s\" already contains data", @@ -103,8 +103,8 @@ btbuild(PG_FUNCTION_ARGS) buildstate.spool = _bt_spoolinit(index, indexInfo->ii_Unique, false); /* - * If building a unique index, put dead tuples in a second spool - * to keep them out of the uniqueness check. + * If building a unique index, put dead tuples in a second spool to + * keep them out of the uniqueness check. */ if (indexInfo->ii_Unique) buildstate.spool2 = _bt_spoolinit(index, false, true); @@ -129,8 +129,8 @@ btbuild(PG_FUNCTION_ARGS) /* * if we are doing bottom-up btree build, finish the build by (1) - * completing the sort of the spool file, (2) inserting the sorted - * tuples into btree pages and (3) building the upper levels. + * completing the sort of the spool file, (2) inserting the sorted tuples + * into btree pages and (3) building the upper levels. */ if (buildstate.usefast) { @@ -176,9 +176,8 @@ btbuildCallback(Relation index, btitem = _bt_formitem(itup); /* - * if we are doing bottom-up btree build, we insert the index into a - * spool file for subsequent processing. otherwise, we insert into - * the btree. + * if we are doing bottom-up btree build, we insert the index into a spool + * file for subsequent processing. otherwise, we insert into the btree. */ if (buildstate->usefast) { @@ -248,16 +247,16 @@ btgettuple(PG_FUNCTION_ARGS) bool res; /* - * If we've already initialized this scan, we can just advance it in - * the appropriate direction. If we haven't done so yet, we call a - * routine to get the first item in the scan. + * If we've already initialized this scan, we can just advance it in the + * appropriate direction. If we haven't done so yet, we call a routine to + * get the first item in the scan. */ if (ItemPointerIsValid(&(scan->currentItemData))) { /* - * Restore scan position using heap TID returned by previous call - * to btgettuple(). _bt_restscan() re-grabs the read lock on the - * buffer, too. + * Restore scan position using heap TID returned by previous call to + * btgettuple(). _bt_restscan() re-grabs the read lock on the buffer, + * too. */ _bt_restscan(scan); @@ -267,17 +266,16 @@ btgettuple(PG_FUNCTION_ARGS) if (scan->kill_prior_tuple) { /* - * Yes, so mark it by setting the LP_DELETE bit in the item - * flags. + * Yes, so mark it by setting the LP_DELETE bit in the item flags. */ offnum = ItemPointerGetOffsetNumber(&(scan->currentItemData)); page = BufferGetPage(so->btso_curbuf); PageGetItemId(page, offnum)->lp_flags |= LP_DELETE; /* - * Since this can be redone later if needed, it's treated the - * same as a commit-hint-bit status update for heap tuples: we - * mark the buffer dirty but don't make a WAL log entry. + * Since this can be redone later if needed, it's treated the same + * as a commit-hint-bit status update for heap tuples: we mark the + * buffer dirty but don't make a WAL log entry. */ SetBufferCommitInfoNeedsSave(so->btso_curbuf); } @@ -306,11 +304,11 @@ btgettuple(PG_FUNCTION_ARGS) } /* - * Save heap TID to use it in _bt_restscan. Then release the read - * lock on the buffer so that we aren't blocking other backends. + * Save heap TID to use it in _bt_restscan. Then release the read lock on + * the buffer so that we aren't blocking other backends. * - * NOTE: we do keep the pin on the buffer! This is essential to ensure - * that someone else doesn't delete the index entry we are stopped on. + * NOTE: we do keep the pin on the buffer! This is essential to ensure that + * someone else doesn't delete the index entry we are stopped on. */ if (res) { @@ -333,7 +331,7 @@ Datum btgetmulti(PG_FUNCTION_ARGS) { IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0); - ItemPointer tids = (ItemPointer) PG_GETARG_POINTER(1); + ItemPointer tids = (ItemPointer) PG_GETARG_POINTER(1); int32 max_tids = PG_GETARG_INT32(2); int32 *returned_tids = (int32 *) PG_GETARG_POINTER(3); BTScanOpaque so = (BTScanOpaque) scan->opaque; @@ -355,6 +353,7 @@ btgetmulti(PG_FUNCTION_ARGS) res = _bt_next(scan, ForwardScanDirection); else res = _bt_first(scan, ForwardScanDirection); + /* * Skip killed tuples if asked to. */ @@ -381,8 +380,8 @@ btgetmulti(PG_FUNCTION_ARGS) } /* - * Save heap TID to use it in _bt_restscan. Then release the read - * lock on the buffer so that we aren't blocking other backends. + * Save heap TID to use it in _bt_restscan. Then release the read lock on + * the buffer so that we aren't blocking other backends. */ if (res) { @@ -456,8 +455,8 @@ btrescan(PG_FUNCTION_ARGS) } /* - * Reset the scan keys. Note that keys ordering stuff moved to - * _bt_first. - vadim 05/05/97 + * Reset the scan keys. Note that keys ordering stuff moved to _bt_first. + * - vadim 05/05/97 */ if (scankey && scan->numberOfKeys > 0) memmove(scan->keyData, @@ -593,21 +592,20 @@ btbulkdelete(PG_FUNCTION_ARGS) num_index_tuples = 0; /* - * The outer loop iterates over index leaf pages, the inner over items - * on a leaf page. We issue just one _bt_delitems() call per page, so - * as to minimize WAL traffic. + * The outer loop iterates over index leaf pages, the inner over items on + * a leaf page. We issue just one _bt_delitems() call per page, so as to + * minimize WAL traffic. * * Note that we exclusive-lock every leaf page containing data items, in - * sequence left to right. It sounds attractive to only - * exclusive-lock those containing items we need to delete, but - * unfortunately that is not safe: we could then pass a stopped - * indexscan, which could in rare cases lead to deleting the item it - * needs to find when it resumes. (See _bt_restscan --- this could - * only happen if an indexscan stops on a deletable item and then a - * page split moves that item into a page further to its right, which - * the indexscan will have no pin on.) We can skip obtaining - * exclusive lock on empty pages though, since no indexscan could be - * stopped on those. + * sequence left to right. It sounds attractive to only exclusive-lock + * those containing items we need to delete, but unfortunately that is not + * safe: we could then pass a stopped indexscan, which could in rare cases + * lead to deleting the item it needs to find when it resumes. (See + * _bt_restscan --- this could only happen if an indexscan stops on a + * deletable item and then a page split moves that item into a page + * further to its right, which the indexscan will have no pin on.) We can + * skip obtaining exclusive lock on empty pages though, since no indexscan + * could be stopped on those. */ buf = _bt_get_endpoint(rel, 0, false); if (BufferIsValid(buf)) /* check for empty index */ @@ -632,15 +630,15 @@ btbulkdelete(PG_FUNCTION_ARGS) if (minoff <= maxoff && !P_ISDELETED(opaque)) { /* - * Trade in the initial read lock for a super-exclusive - * write lock on this page. + * Trade in the initial read lock for a super-exclusive write + * lock on this page. */ LockBuffer(buf, BUFFER_LOCK_UNLOCK); LockBufferForCleanup(buf); /* - * Recompute minoff/maxoff, both of which could have - * changed while we weren't holding the lock. + * Recompute minoff/maxoff, both of which could have changed + * while we weren't holding the lock. */ minoff = P_FIRSTDATAKEY(opaque); maxoff = PageGetMaxOffsetNumber(page); @@ -657,7 +655,7 @@ btbulkdelete(PG_FUNCTION_ARGS) ItemPointer htup; btitem = (BTItem) PageGetItem(page, - PageGetItemId(page, offnum)); + PageGetItemId(page, offnum)); htup = &(btitem->bti_itup.t_tid); if (callback(htup, callback_state)) { @@ -670,8 +668,8 @@ btbulkdelete(PG_FUNCTION_ARGS) } /* - * If we need to delete anything, do it and write the buffer; - * else just release the buffer. + * If we need to delete anything, do it and write the buffer; else + * just release the buffer. */ nextpage = opaque->btpo_next; if (ndeletable > 0) @@ -725,19 +723,19 @@ btvacuumcleanup(PG_FUNCTION_ARGS) Assert(stats != NULL); /* - * First find out the number of pages in the index. We must acquire - * the relation-extension lock while doing this to avoid a race - * condition: if someone else is extending the relation, there is - * a window where bufmgr/smgr have created a new all-zero page but - * it hasn't yet been write-locked by _bt_getbuf(). If we manage to - * scan such a page here, we'll improperly assume it can be recycled. - * Taking the lock synchronizes things enough to prevent a problem: - * either num_pages won't include the new page, or _bt_getbuf already - * has write lock on the buffer and it will be fully initialized before - * we can examine it. (See also vacuumlazy.c, which has the same issue.) + * First find out the number of pages in the index. We must acquire the + * relation-extension lock while doing this to avoid a race condition: if + * someone else is extending the relation, there is a window where + * bufmgr/smgr have created a new all-zero page but it hasn't yet been + * write-locked by _bt_getbuf(). If we manage to scan such a page here, + * we'll improperly assume it can be recycled. Taking the lock + * synchronizes things enough to prevent a problem: either num_pages won't + * include the new page, or _bt_getbuf already has write lock on the + * buffer and it will be fully initialized before we can examine it. (See + * also vacuumlazy.c, which has the same issue.) * - * We can skip locking for new or temp relations, - * however, since no one else could be accessing them. + * We can skip locking for new or temp relations, however, since no one else + * could be accessing them. */ needLock = !RELATION_IS_LOCAL(rel); @@ -807,12 +805,12 @@ btvacuumcleanup(PG_FUNCTION_ARGS) /* * During VACUUM FULL it's okay to recycle deleted pages - * immediately, since there can be no other transactions - * scanning the index. Note that we will only recycle the - * current page and not any parent pages that _bt_pagedel - * might have recursed to; this seems reasonable in the name - * of simplicity. (Trying to do otherwise would mean we'd - * have to sort the list of recyclable pages we're building.) + * immediately, since there can be no other transactions scanning + * the index. Note that we will only recycle the current page and + * not any parent pages that _bt_pagedel might have recursed to; + * this seems reasonable in the name of simplicity. (Trying to do + * otherwise would mean we'd have to sort the list of recyclable + * pages we're building.) */ if (ndel && info->vacuum_full) { @@ -827,10 +825,10 @@ btvacuumcleanup(PG_FUNCTION_ARGS) } /* - * During VACUUM FULL, we truncate off any recyclable pages at the end - * of the index. In a normal vacuum it'd be unsafe to do this except - * by acquiring exclusive lock on the index and then rechecking all - * the pages; doesn't seem worth it. + * During VACUUM FULL, we truncate off any recyclable pages at the end of + * the index. In a normal vacuum it'd be unsafe to do this except by + * acquiring exclusive lock on the index and then rechecking all the + * pages; doesn't seem worth it. */ if (info->vacuum_full && nFreePages > 0) { @@ -857,9 +855,9 @@ btvacuumcleanup(PG_FUNCTION_ARGS) } /* - * Update the shared Free Space Map with the info we now have about - * free pages in the index, discarding any old info the map may have. - * We do not need to sort the page numbers; they're in order already. + * Update the shared Free Space Map with the info we now have about free + * pages in the index, discarding any old info the map may have. We do not + * need to sort the page numbers; they're in order already. */ RecordIndexFreeSpace(&rel->rd_node, nFreePages, freePages); @@ -915,15 +913,15 @@ _bt_restscan(IndexScanDesc scan) opaque = (BTPageOpaque) PageGetSpecialPointer(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 + * 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)... XXX still needed? */ if (!ItemPointerIsValid(target)) { ItemPointerSetOffsetNumber(current, - OffsetNumberPrev(P_FIRSTDATAKEY(opaque))); + OffsetNumberPrev(P_FIRSTDATAKEY(opaque))); return; } @@ -948,12 +946,12 @@ _bt_restscan(IndexScanDesc scan) } /* - * The item we're looking for moved right at least one page, so - * move right. We are careful here to pin and read-lock the next - * non-dead page before releasing the current one. This ensures - * that a concurrent btbulkdelete scan cannot pass our position - * --- if it did, it might be able to reach and delete our target - * item before we can find it again. + * The item we're looking for moved right at least one page, so move + * right. We are careful here to pin and read-lock the next non-dead + * page before releasing the current one. This ensures that a + * concurrent btbulkdelete scan cannot pass our position --- if it + * did, it might be able to reach and delete our target item before we + * can find it again. */ if (P_RIGHTMOST(opaque)) elog(ERROR, "failed to re-find previous key in \"%s\"", diff --git a/src/backend/access/nbtree/nbtsearch.c b/src/backend/access/nbtree/nbtsearch.c index c029824fa6..06075dd3dd 100644 --- a/src/backend/access/nbtree/nbtsearch.c +++ b/src/backend/access/nbtree/nbtsearch.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.94 2005/10/06 02:29:12 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.95 2005/10/15 02:49:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -69,9 +69,9 @@ _bt_search(Relation rel, int keysz, ScanKey scankey, bool nextkey, BTStack new_stack; /* - * Race -- the page we just grabbed may have split since we read - * its pointer in the parent (or metapage). If it has, we may - * need to move right to its new sibling. Do that. + * Race -- the page we just grabbed may have split since we read its + * pointer in the parent (or metapage). If it has, we may need to + * move right to its new sibling. Do that. */ *bufP = _bt_moveright(rel, *bufP, keysz, scankey, nextkey, BT_READ); @@ -82,8 +82,8 @@ _bt_search(Relation rel, int keysz, ScanKey scankey, bool nextkey, break; /* - * Find the appropriate item on the internal page, and get the - * child page that it points to. + * Find the appropriate item on the internal page, and get the child + * page that it points to. */ offnum = _bt_binsrch(rel, *bufP, keysz, scankey, nextkey); itemid = PageGetItemId(page, offnum); @@ -94,13 +94,13 @@ _bt_search(Relation rel, int keysz, ScanKey scankey, bool nextkey, /* * We need to save the location of the index entry we chose in the - * parent page on a stack. In case we split the tree, we'll use - * the stack to work back up to the parent page. We also save the - * actual downlink (TID) to uniquely identify the index entry, in - * case it moves right while we're working lower in the tree. See - * the paper by Lehman and Yao for how this is detected and - * handled. (We use the child link to disambiguate duplicate keys - * in the index -- Lehman and Yao disallow duplicate keys.) + * parent page on a stack. In case we split the tree, we'll use the + * stack to work back up to the parent page. We also save the actual + * downlink (TID) to uniquely identify the index entry, in case it + * moves right while we're working lower in the tree. See the paper + * by Lehman and Yao for how this is detected and handled. (We use the + * child link to disambiguate duplicate keys in the index -- Lehman + * and Yao disallow duplicate keys.) */ new_stack = (BTStack) palloc(sizeof(BTStackData)); new_stack->bts_blkno = par_blkno; @@ -156,19 +156,18 @@ _bt_moveright(Relation rel, opaque = (BTPageOpaque) PageGetSpecialPointer(page); /* - * When nextkey = false (normal case): if the scan key that brought us - * to this page is > the high key stored on the page, then the page - * has split and we need to move right. (If the scan key is equal to - * the high key, we might or might not need to move right; have to - * scan the page first anyway.) + * When nextkey = false (normal case): if the scan key that brought us to + * this page is > the high key stored on the page, then the page has split + * and we need to move right. (If the scan key is equal to the high key, + * we might or might not need to move right; have to scan the page first + * anyway.) * * When nextkey = true: move right if the scan key is >= page's high key. * - * The page could even have split more than once, so scan as far as - * needed. + * The page could even have split more than once, so scan as far as needed. * - * We also have to move right if we followed a link that brought us to a - * dead page. + * We also have to move right if we followed a link that brought us to a dead + * page. */ cmpval = nextkey ? 0 : 1; @@ -242,24 +241,24 @@ _bt_binsrch(Relation rel, high = PageGetMaxOffsetNumber(page); /* - * If there are no keys on the page, return the first available slot. - * Note this covers two cases: the page is really empty (no keys), or - * it contains only a high key. The latter case is possible after - * vacuuming. This can never happen on an internal page, however, - * since they are never empty (an internal page must have children). + * If there are no keys on the page, return the first available slot. Note + * this covers two cases: the page is really empty (no keys), or it + * contains only a high key. The latter case is possible after vacuuming. + * This can never happen on an internal page, however, since they are + * never empty (an internal page must have children). */ if (high < low) return low; /* - * Binary search to find the first key on the page >= scan key, or - * first key > scankey when nextkey is true. + * Binary search to find the first key on the page >= scan key, or first + * key > scankey when nextkey is true. * * For nextkey=false (cmpval=1), the loop invariant is: all slots before * 'low' are < scan key, all slots at or after 'high' are >= scan key. * - * For nextkey=true (cmpval=0), the loop invariant is: all slots before - * 'low' are <= scan key, all slots at or after 'high' are > scan key. + * For nextkey=true (cmpval=0), the loop invariant is: all slots before 'low' + * are <= scan key, all slots at or after 'high' are > scan key. * * We can fall out when high == low. */ @@ -285,15 +284,15 @@ _bt_binsrch(Relation rel, * At this point we have high == low, but be careful: they could point * past the last slot on the page. * - * On a leaf page, we always return the first key >= scan key (resp. > - * scan key), which could be the last slot + 1. + * On a leaf page, we always return the first key >= scan key (resp. > scan + * key), which could be the last slot + 1. */ if (P_ISLEAF(opaque)) return low; /* - * On a non-leaf page, return the last key < scan key (resp. <= scan - * key). There must be one if _bt_compare() is playing by the rules. + * On a non-leaf page, return the last key < scan key (resp. <= scan key). + * There must be one if _bt_compare() is playing by the rules. */ Assert(low > P_FIRSTDATAKEY(opaque)); @@ -337,8 +336,8 @@ _bt_compare(Relation rel, int i; /* - * Force result ">" if target item is first data item on an internal - * page --- see NOTE above. + * Force result ">" if target item is first data item on an internal page + * --- see NOTE above. */ if (!P_ISLEAF(opaque) && offnum == P_FIRSTDATAKEY(opaque)) return 1; @@ -347,15 +346,15 @@ _bt_compare(Relation rel, itup = &(btitem->bti_itup); /* - * The scan key is set up with the attribute number associated with - * each term in the key. It is important that, if the index is - * multi-key, the scan contain the first k key attributes, and that - * they be in order. If you think about how multi-key ordering works, - * you'll understand why this is. + * The scan key is set up with the attribute number associated with each + * term in the key. It is important that, if the index is multi-key, the + * scan contain the first k key attributes, and that they be in order. If + * you think about how multi-key ordering works, you'll understand why + * this is. * - * We don't test for violation of this condition here, however. The - * initial setup for the index scan had better have gotten it right - * (see _bt_first). + * We don't test for violation of this condition here, however. The initial + * setup for the index scan had better have gotten it right (see + * _bt_first). */ for (i = 1; i <= keysz; i++) @@ -381,15 +380,15 @@ _bt_compare(Relation rel, else { /* - * The sk_func needs to be passed the index value as left arg - * and the sk_argument as right arg (they might be of - * different types). Since it is convenient for callers to - * think of _bt_compare as comparing the scankey to the index - * item, we have to flip the sign of the comparison result. + * The sk_func needs to be passed the index value as left arg and + * the sk_argument as right arg (they might be of different + * types). Since it is convenient for callers to think of + * _bt_compare as comparing the scankey to the index item, we have + * to flip the sign of the comparison result. * - * Note: curious-looking coding is to avoid overflow if - * comparison function returns INT_MIN. There is no risk of - * overflow for positive results. + * Note: curious-looking coding is to avoid overflow if comparison + * function returns INT_MIN. There is no risk of overflow for + * positive results. */ result = DatumGetInt32(FunctionCall2(&scankey->sk_func, datum, @@ -497,7 +496,7 @@ _bt_first(IndexScanDesc scan, ScanDirection dir) bool goback; bool continuescan; ScanKey startKeys[INDEX_MAX_KEYS]; - ScanKeyData scankeys[INDEX_MAX_KEYS]; + ScanKeyData scankeys[INDEX_MAX_KEYS]; int keysCount = 0; int i; StrategyNumber strat_total; @@ -505,8 +504,8 @@ _bt_first(IndexScanDesc scan, ScanDirection dir) pgstat_count_index_scan(&scan->xs_pgstat_info); /* - * Examine the scan keys and eliminate any redundant keys; also - * discover how many keys must be matched to continue the scan. + * Examine the scan keys and eliminate any redundant keys; also discover + * how many keys must be matched to continue the scan. */ _bt_preprocess_keys(scan); @@ -556,9 +555,9 @@ _bt_first(IndexScanDesc scan, ScanDirection dir) ScanKey cur; /* - * chosen is the so-far-chosen key for the current attribute, if - * any. We don't cast the decision in stone until we reach keys - * for the next attribute. + * chosen is the so-far-chosen key for the current attribute, if any. + * We don't cast the decision in stone until we reach keys for the + * next attribute. */ curattr = 1; chosen = NULL; @@ -595,9 +594,9 @@ _bt_first(IndexScanDesc scan, ScanDirection dir) } /* - * Done if that was the last attribute, or if next key - * is not in sequence (implying no boundary key is available - * for the next attribute). + * Done if that was the last attribute, or if next key is not + * in sequence (implying no boundary key is available for the + * next attribute). */ if (i >= so->numberOfKeys || cur->sk_attno != curattr + 1) @@ -632,17 +631,17 @@ _bt_first(IndexScanDesc scan, ScanDirection dir) } /* - * If we found no usable boundary keys, we have to start from one end - * of the tree. Walk down that edge to the first or last key, and - * scan from there. + * If we found no usable boundary keys, we have to start from one end of + * the tree. Walk down that edge to the first or last key, and scan from + * there. */ if (keysCount == 0) return _bt_endpoint(scan, dir); /* * We want to start the scan somewhere within the index. Set up a - * 3-way-comparison scankey we can use to search for the boundary - * point we identified above. + * 3-way-comparison scankey we can use to search for the boundary point we + * identified above. */ Assert(keysCount <= INDEX_MAX_KEYS); for (i = 0; i < keysCount; i++) @@ -650,16 +649,15 @@ _bt_first(IndexScanDesc scan, ScanDirection dir) ScanKey cur = startKeys[i]; /* - * _bt_preprocess_keys disallows it, but it's place to add some - * code later + * _bt_preprocess_keys disallows it, but it's place to add some code + * later */ if (cur->sk_flags & SK_ISNULL) elog(ERROR, "btree doesn't support is(not)null, yet"); /* - * If scankey operator is of default subtype, we can use the - * cached comparison procedure; otherwise gotta look it up in the - * catalogs. + * If scankey operator is of default subtype, we can use the cached + * comparison procedure; otherwise gotta look it up in the catalogs. */ if (cur->sk_subtype == InvalidOid) { @@ -692,13 +690,13 @@ _bt_first(IndexScanDesc scan, ScanDirection dir) } /* - * Examine the selected initial-positioning strategy to determine - * exactly where we need to start the scan, and set flag variables to - * control the code below. + * Examine the selected initial-positioning strategy to determine exactly + * where we need to start the scan, and set flag variables to control the + * code below. * - * If nextkey = false, _bt_search and _bt_binsrch will locate the first - * item >= scan key. If nextkey = true, they will locate the first - * item > scan key. + * If nextkey = false, _bt_search and _bt_binsrch will locate the first item + * >= scan key. If nextkey = true, they will locate the first item > scan + * key. * * If goback = true, we will then step back one item, while if goback = * false, we will start the scan on the located item. @@ -710,10 +708,10 @@ _bt_first(IndexScanDesc scan, ScanDirection dir) case BTLessStrategyNumber: /* - * Find first item >= scankey, then back up one to arrive at - * last item < scankey. (Note: this positioning strategy is - * only used for a backward scan, so that is always the - * correct starting position.) + * Find first item >= scankey, then back up one to arrive at last + * item < scankey. (Note: this positioning strategy is only used + * for a backward scan, so that is always the correct starting + * position.) */ nextkey = false; goback = true; @@ -722,10 +720,10 @@ _bt_first(IndexScanDesc scan, ScanDirection dir) case BTLessEqualStrategyNumber: /* - * Find first item > scankey, then back up one to arrive at - * last item <= scankey. (Note: this positioning strategy is - * only used for a backward scan, so that is always the - * correct starting position.) + * Find first item > scankey, then back up one to arrive at last + * item <= scankey. (Note: this positioning strategy is only used + * for a backward scan, so that is always the correct starting + * position.) */ nextkey = true; goback = true; @@ -734,14 +732,14 @@ _bt_first(IndexScanDesc scan, ScanDirection dir) case BTEqualStrategyNumber: /* - * If a backward scan was specified, need to start with last - * equal item not first one. + * If a backward scan was specified, need to start with last equal + * item not first one. */ if (ScanDirectionIsBackward(dir)) { /* - * This is the same as the <= strategy. We will check at - * the end whether the found item is actually =. + * This is the same as the <= strategy. We will check at the + * end whether the found item is actually =. */ nextkey = true; goback = true; @@ -749,8 +747,8 @@ _bt_first(IndexScanDesc scan, ScanDirection dir) else { /* - * This is the same as the >= strategy. We will check at - * the end whether the found item is actually =. + * This is the same as the >= strategy. We will check at the + * end whether the found item is actually =. */ nextkey = false; goback = false; @@ -813,24 +811,24 @@ _bt_first(IndexScanDesc scan, ScanDirection dir) ItemPointerSet(current, blkno, offnum); /* - * If nextkey = false, we are positioned at the first item >= scan - * key, or possibly at the end of a page on which all the existing - * items are less than the scan key and we know that everything on - * later pages is greater than or equal to scan key. + * If nextkey = false, we are positioned at the first item >= scan key, or + * possibly at the end of a page on which all the existing items are less + * than the scan key and we know that everything on later pages is greater + * than or equal to scan key. * * If nextkey = true, we are positioned at the first item > scan key, or - * possibly at the end of a page on which all the existing items are - * less than or equal to the scan key and we know that everything on - * later pages is greater than scan key. + * possibly at the end of a page on which all the existing items are less + * than or equal to the scan key and we know that everything on later + * pages is greater than scan key. * - * The actually desired starting point is either this item or the prior - * one, or in the end-of-page case it's the first item on the next - * page or the last item on this page. We apply _bt_step if needed to - * get to the right place. + * The actually desired starting point is either this item or the prior one, + * or in the end-of-page case it's the first item on the next page or the + * last item on this page. We apply _bt_step if needed to get to the + * right place. * * If _bt_step fails (meaning we fell off the end of the index in one - * direction or the other), then there are no matches so we just - * return false. + * direction or the other), then there are no matches so we just return + * false. */ if (goback) { @@ -902,8 +900,8 @@ _bt_step(IndexScanDesc scan, Buffer *bufP, ScanDirection dir) BlockNumber blkno; /* - * 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; @@ -954,9 +952,9 @@ _bt_step(IndexScanDesc scan, Buffer *bufP, ScanDirection dir) /* * Walk left to the next page with data. This is much more * complex than the walk-right case because of the possibility - * that the page to our left splits while we are in flight to - * it, plus the possibility that the page we were on gets - * deleted after we leave it. See nbtree/README for details. + * that the page to our left splits while we are in flight to it, + * plus the possibility that the page we were on gets deleted + * after we leave it. See nbtree/README for details. */ for (;;) { @@ -973,9 +971,9 @@ _bt_step(IndexScanDesc scan, Buffer *bufP, ScanDirection dir) opaque = (BTPageOpaque) PageGetSpecialPointer(page); /* - * Okay, we managed to move left to a non-deleted page. - * Done if it's not half-dead and not empty. Else loop - * back and do it all again. + * Okay, we managed to move left to a non-deleted page. Done + * if it's not half-dead and not empty. Else loop back and do + * it all again. */ if (!P_IGNORE(opaque)) { @@ -1043,15 +1041,14 @@ _bt_walk_left(Relation rel, Buffer buf) /* * If this isn't the page we want, walk right till we find what we - * want --- but go no more than four hops (an arbitrary limit). If - * we don't find the correct page by then, the most likely bet is - * that the original page got deleted and isn't in the sibling - * chain at all anymore, not that its left sibling got split more - * than four times. + * want --- but go no more than four hops (an arbitrary limit). If we + * don't find the correct page by then, the most likely bet is that + * the original page got deleted and isn't in the sibling chain at all + * anymore, not that its left sibling got split more than four times. * - * Note that it is correct to test P_ISDELETED not P_IGNORE here, - * because half-dead pages are still in the sibling chain. Caller - * must reject half-dead pages if wanted. + * Note that it is correct to test P_ISDELETED not P_IGNORE here, because + * half-dead pages are still in the sibling chain. Caller must reject + * half-dead pages if wanted. */ tries = 0; for (;;) @@ -1077,9 +1074,9 @@ _bt_walk_left(Relation rel, Buffer buf) { /* * It was deleted. Move right to first nondeleted page (there - * must be one); that is the page that has acquired the - * deleted one's keyspace, so stepping left from it will take - * us where we want to be. + * must be one); that is the page that has acquired the deleted + * one's keyspace, so stepping left from it will take us where we + * want to be. */ for (;;) { @@ -1095,16 +1092,16 @@ _bt_walk_left(Relation rel, Buffer buf) } /* - * Now return to top of loop, resetting obknum to point to - * this nondeleted page, and try again. + * Now return to top of loop, resetting obknum to point to this + * nondeleted page, and try again. */ } else { /* - * It wasn't deleted; the explanation had better be that the - * page to the left got split or deleted. Without this check, - * we'd go into an infinite loop if there's anything wrong. + * It wasn't deleted; the explanation had better be that the page + * to the left got split or deleted. Without this check, we'd go + * into an infinite loop if there's anything wrong. */ if (opaque->btpo_prev == lblkno) elog(ERROR, "could not find left sibling in \"%s\"", @@ -1137,8 +1134,8 @@ _bt_get_endpoint(Relation rel, uint32 level, bool rightmost) /* * If we are looking for a leaf page, okay to descend from fast root; - * otherwise better descend from true root. (There is no point in - * being smarter about intermediate levels.) + * otherwise better descend from true root. (There is no point in being + * smarter about intermediate levels.) */ if (level == 0) buf = _bt_getroot(rel, BT_READ); @@ -1159,8 +1156,8 @@ _bt_get_endpoint(Relation rel, uint32 level, bool rightmost) /* * If we landed on a deleted page, step right to find a live page * (there must be one). Also, if we want the rightmost page, step - * right if needed to get to it (this could happen if the page - * split since we obtained a pointer to it). + * right if needed to get to it (this could happen if the page split + * since we obtained a pointer to it). */ while (P_IGNORE(opaque) || (rightmost && !P_RIGHTMOST(opaque))) @@ -1228,9 +1225,9 @@ _bt_endpoint(IndexScanDesc scan, ScanDirection dir) so = (BTScanOpaque) scan->opaque; /* - * Scan down to the leftmost or rightmost leaf page. This is a - * simplified version of _bt_search(). We don't maintain a stack - * since we know we won't need it. + * Scan down to the leftmost or rightmost leaf page. This is a simplified + * version of _bt_search(). We don't maintain a stack since we know we + * won't need it. */ buf = _bt_get_endpoint(rel, 0, ScanDirectionIsBackward(dir)); @@ -1261,8 +1258,7 @@ _bt_endpoint(IndexScanDesc scan, ScanDirection dir) Assert(P_RIGHTMOST(opaque)); start = PageGetMaxOffsetNumber(page); - if (start < P_FIRSTDATAKEY(opaque)) /* watch out for empty - * page */ + if (start < P_FIRSTDATAKEY(opaque)) /* watch out for empty page */ start = P_FIRSTDATAKEY(opaque); } else @@ -1276,8 +1272,8 @@ _bt_endpoint(IndexScanDesc scan, ScanDirection dir) so->btso_curbuf = buf; /* - * Left/rightmost page could be empty due to deletions, if so step - * till we find a nonempty page. + * Left/rightmost page could be empty due to deletions, if so step till we + * find a nonempty page. */ if (start > maxoff) { @@ -1291,8 +1287,7 @@ _bt_endpoint(IndexScanDesc scan, ScanDirection dir) itup = &(btitem->bti_itup); /* - * Okay, we are on the first or last tuple. Does it pass all the - * quals? + * Okay, we are on the first or last tuple. Does it pass all the quals? */ if (_bt_checkkeys(scan, itup, dir, &continuescan)) { diff --git a/src/backend/access/nbtree/nbtsort.c b/src/backend/access/nbtree/nbtsort.c index ee5acee5c3..6ee5d42b63 100644 --- a/src/backend/access/nbtree/nbtsort.c +++ b/src/backend/access/nbtree/nbtsort.c @@ -56,7 +56,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtsort.c,v 1.94 2005/08/11 13:22:33 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtsort.c,v 1.95 2005/10/15 02:49:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -99,12 +99,10 @@ typedef struct BTPageState { Page btps_page; /* workspace for page building */ BlockNumber btps_blkno; /* block # to write this page at */ - BTItem btps_minkey; /* copy of minimum key (first item) on - * page */ + BTItem btps_minkey; /* copy of minimum key (first item) on page */ OffsetNumber btps_lastoff; /* last item offset loaded */ uint32 btps_level; /* tree level (0 = leaf) */ - Size btps_full; /* "full" if less than this much free - * space */ + Size btps_full; /* "full" if less than this much free space */ struct BTPageState *btps_next; /* link to parent level, if any */ } BTPageState; @@ -157,21 +155,21 @@ _bt_spoolinit(Relation index, bool isunique, bool isdead) btspool->isunique = isunique; /* - * We size the sort area as maintenance_work_mem rather than work_mem - * to speed index creation. This should be OK since a single backend - * can't run multiple index creations in parallel. Note that creation - * of a unique index actually requires two BTSpool objects. We expect - * that the second one (for dead tuples) won't get very full, so we - * give it only work_mem. + * We size the sort area as maintenance_work_mem rather than work_mem to + * speed index creation. This should be OK since a single backend can't + * run multiple index creations in parallel. Note that creation of a + * unique index actually requires two BTSpool objects. We expect that the + * second one (for dead tuples) won't get very full, so we give it only + * work_mem. */ btKbytes = isdead ? work_mem : maintenance_work_mem; btspool->sortstate = tuplesort_begin_index(index, isunique, btKbytes, false); /* - * Currently, tuplesort provides sort functions on IndexTuples. If we - * kept anything in a BTItem other than a regular IndexTuple, we'd - * need to modify tuplesort to understand BTItems as such. + * Currently, tuplesort provides sort functions on IndexTuples. If we kept + * anything in a BTItem other than a regular IndexTuple, we'd need to + * modify tuplesort to understand BTItems as such. */ Assert(sizeof(BTItemData) == sizeof(IndexTupleData)); @@ -222,8 +220,8 @@ _bt_leafbuild(BTSpool *btspool, BTSpool *btspool2) wstate.index = btspool->index; /* - * We need to log index creation in WAL iff WAL archiving is enabled - * AND it's not a temp index. + * We need to log index creation in WAL iff WAL archiving is enabled AND + * it's not a temp index. */ wstate.btws_use_wal = XLogArchivingActive() && !wstate.index->rd_istemp; @@ -313,9 +311,9 @@ _bt_blwritepage(BTWriteState *wstate, Page page, BlockNumber blkno) /* * If we have to write pages nonsequentially, fill in the space with * zeroes until we come back and overwrite. This is not logically - * necessary on standard Unix filesystems (unwritten space will read - * as zeroes anyway), but it should help to avoid fragmentation. The - * dummy pages aren't WAL-logged though. + * necessary on standard Unix filesystems (unwritten space will read as + * zeroes anyway), but it should help to avoid fragmentation. The dummy + * pages aren't WAL-logged though. */ while (blkno > wstate->btws_pages_written) { @@ -328,8 +326,8 @@ _bt_blwritepage(BTWriteState *wstate, Page page, BlockNumber blkno) /* * Now write the page. We say isTemp = true even if it's not a temp - * index, because there's no need for smgr to schedule an fsync for - * this write; we'll do it ourselves before ending the build. + * index, because there's no need for smgr to schedule an fsync for this + * write; we'll do it ourselves before ending the build. */ smgrwrite(wstate->index->rd_smgr, blkno, (char *) page, true); @@ -483,15 +481,15 @@ _bt_buildadd(BTWriteState *wstate, BTPageState *state, BTItem bti) btisz = MAXALIGN(btisz); /* - * Check whether the item can fit on a btree page at all. (Eventually, - * we ought to try to apply TOAST methods if not.) We actually need to - * be able to fit three items on every page, so restrict any one item - * to 1/3 the per-page available space. Note that at this point, btisz - * doesn't include the ItemId. + * Check whether the item can fit on a btree page at all. (Eventually, we + * ought to try to apply TOAST methods if not.) We actually need to be + * able to fit three items on every page, so restrict any one item to 1/3 + * the per-page available space. Note that at this point, btisz doesn't + * include the ItemId. * - * NOTE: similar code appears in _bt_insertonpg() to defend against - * oversize items being inserted into an already-existing index. But - * during creation of an index, we don't go through there. + * NOTE: similar code appears in _bt_insertonpg() to defend against oversize + * items being inserted into an already-existing index. But during + * creation of an index, we don't go through there. */ if (btisz > BTMaxItemSize(npage)) ereport(ERROR, @@ -499,9 +497,9 @@ _bt_buildadd(BTWriteState *wstate, BTPageState *state, BTItem bti) errmsg("index row size %lu exceeds btree maximum, %lu", (unsigned long) btisz, (unsigned long) BTMaxItemSize(npage)), - errhint("Values larger than 1/3 of a buffer page cannot be indexed.\n" - "Consider a function index of an MD5 hash of the value, " - "or use full text indexing."))); + errhint("Values larger than 1/3 of a buffer page cannot be indexed.\n" + "Consider a function index of an MD5 hash of the value, " + "or use full text indexing."))); if (pgspc < btisz || pgspc < state->btps_full) { @@ -523,11 +521,11 @@ _bt_buildadd(BTWriteState *wstate, BTPageState *state, BTItem bti) /* * We copy the last item on the page into the new page, and then - * rearrange the old page so that the 'last item' becomes its high - * key rather than a true data item. There had better be at least - * two items on the page already, else the page would be empty of - * useful data. (Hence, we must allow pages to be packed at least - * 2/3rds full; the 70% figure used above is close to minimum.) + * rearrange the old page so that the 'last item' becomes its high key + * rather than a true data item. There had better be at least two + * items on the page already, else the page would be empty of useful + * data. (Hence, we must allow pages to be packed at least 2/3rds + * full; the 70% figure used above is close to minimum.) */ Assert(last_off > P_FIRSTKEY); ii = PageGetItemId(opage, last_off); @@ -544,8 +542,8 @@ _bt_buildadd(BTWriteState *wstate, BTPageState *state, BTItem bti) /* * Link the old page into its parent, using its minimum key. If we - * don't have a parent, we have to create one; this adds a new - * btree level. + * don't have a parent, we have to create one; this adds a new btree + * level. */ if (state->btps_next == NULL) state->btps_next = _bt_pagestate(wstate, state->btps_level + 1); @@ -557,9 +555,9 @@ _bt_buildadd(BTWriteState *wstate, BTPageState *state, BTItem bti) pfree(state->btps_minkey); /* - * Save a copy of the minimum key for the new page. We have to - * copy it off the old page, not the new one, in case we are not - * at leaf level. + * Save a copy of the minimum key for the new page. We have to copy + * it off the old page, not the new one, in case we are not at leaf + * level. */ state->btps_minkey = _bt_formitem(&(obti->bti_itup)); @@ -576,8 +574,8 @@ _bt_buildadd(BTWriteState *wstate, BTPageState *state, BTItem bti) } /* - * Write out the old page. We never need to touch it again, so we - * can free the opage workspace too. + * Write out the old page. We never need to touch it again, so we can + * free the opage workspace too. */ _bt_blwritepage(wstate, opage, oblkno); @@ -588,10 +586,10 @@ _bt_buildadd(BTWriteState *wstate, BTPageState *state, BTItem bti) } /* - * If the new item is the first for its page, stash a copy for later. - * Note this will only happen for the first item on a level; on later - * pages, the first item for a page is copied from the prior page in - * the code above. + * If the new item is the first for its page, stash a copy for later. Note + * this will only happen for the first item on a level; on later pages, + * the first item for a page is copied from the prior page in the code + * above. */ if (last_off == P_HIKEY) { @@ -636,9 +634,9 @@ _bt_uppershutdown(BTWriteState *wstate, BTPageState *state) * We have to link the last page on this level to somewhere. * * If we're at the top, it's the root, so attach it to the metapage. - * Otherwise, add an entry for it to its parent using its minimum - * key. This may cause the last page of the parent level to - * split, but that's not a problem -- we haven't gotten to it yet. + * Otherwise, add an entry for it to its parent using its minimum key. + * This may cause the last page of the parent level to split, but + * that's not a problem -- we haven't gotten to it yet. */ if (s->btps_next == NULL) { @@ -657,8 +655,8 @@ _bt_uppershutdown(BTWriteState *wstate, BTPageState *state) } /* - * This is the rightmost page, so the ItemId array needs to be - * slid back one slot. Then we can dump out the page. + * This is the rightmost page, so the ItemId array needs to be slid + * back one slot. Then we can dump out the page. */ _bt_slideleft(s->btps_page); _bt_blwritepage(wstate, s->btps_page, s->btps_blkno); @@ -667,9 +665,9 @@ _bt_uppershutdown(BTWriteState *wstate, BTPageState *state) /* * As the last step in the process, construct the metapage and make it - * point to the new root (unless we had no data at all, in which case - * it's set to point to "P_NONE"). This changes the index to the - * "valid" state by filling in a valid magic number in the metapage. + * point to the new root (unless we had no data at all, in which case it's + * set to point to "P_NONE"). This changes the index to the "valid" state + * by filling in a valid magic number in the metapage. */ metapage = (Page) palloc(BLCKSZ); _bt_initmetapage(metapage, rootblkno, rootlevel); @@ -748,7 +746,7 @@ _bt_load(BTWriteState *wstate, BTSpool *btspool, BTSpool *btspool2) compare = DatumGetInt32(FunctionCall2(&entry->sk_func, attrDatum1, - attrDatum2)); + attrDatum2)); if (compare > 0) { load1 = false; @@ -772,7 +770,7 @@ _bt_load(BTWriteState *wstate, BTSpool *btspool, BTSpool *btspool2) if (should_free) pfree(bti); bti = (BTItem) tuplesort_getindextuple(btspool->sortstate, - true, &should_free); + true, &should_free); } else { @@ -780,7 +778,7 @@ _bt_load(BTWriteState *wstate, BTSpool *btspool, BTSpool *btspool2) if (should_free2) pfree(bti2); bti2 = (BTItem) tuplesort_getindextuple(btspool2->sortstate, - true, &should_free2); + true, &should_free2); } } _bt_freeskey(indexScanKey); @@ -789,7 +787,7 @@ _bt_load(BTWriteState *wstate, BTSpool *btspool, BTSpool *btspool2) { /* merge is unnecessary */ while ((bti = (BTItem) tuplesort_getindextuple(btspool->sortstate, - true, &should_free)) != NULL) + true, &should_free)) != NULL) { /* When we see first tuple, create first index page */ if (state == NULL) @@ -805,19 +803,19 @@ _bt_load(BTWriteState *wstate, BTSpool *btspool, BTSpool *btspool2) _bt_uppershutdown(wstate, state); /* - * If the index isn't temp, we must fsync it down to disk before it's - * safe to commit the transaction. (For a temp index we don't care - * since the index will be uninteresting after a crash anyway.) + * If the index isn't temp, we must fsync it down to disk before it's safe + * to commit the transaction. (For a temp index we don't care since the + * index will be uninteresting after a crash anyway.) * * It's obvious that we must do this when not WAL-logging the build. It's * less obvious that we have to do it even if we did WAL-log the index - * pages. The reason is that since we're building outside shared - * buffers, a CHECKPOINT occurring during the build has no way to - * flush the previously written data to disk (indeed it won't know the - * index even exists). A crash later on would replay WAL from the - * checkpoint, therefore it wouldn't replay our earlier WAL entries. - * If we do not fsync those pages here, they might still not be on - * disk when the crash occurs. + * pages. The reason is that since we're building outside shared buffers, + * a CHECKPOINT occurring during the build has no way to flush the + * previously written data to disk (indeed it won't know the index even + * exists). A crash later on would replay WAL from the checkpoint, + * therefore it wouldn't replay our earlier WAL entries. If we do not + * fsync those pages here, they might still not be on disk when the crash + * occurs. */ if (!wstate->index->rd_istemp) smgrimmedsync(wstate->index->rd_smgr); diff --git a/src/backend/access/nbtree/nbtutils.c b/src/backend/access/nbtree/nbtutils.c index 9a5f8d7ac9..269213d21f 100644 --- a/src/backend/access/nbtree/nbtutils.c +++ b/src/backend/access/nbtree/nbtutils.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtutils.c,v 1.63 2005/06/13 23:14:48 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtutils.c,v 1.64 2005/10/15 02:49:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -48,8 +48,8 @@ _bt_mkscankey(Relation rel, IndexTuple itup) bool null; /* - * We can use the cached (default) support procs since no - * cross-type comparison can be needed. + * We can use the cached (default) support procs since no cross-type + * comparison can be needed. */ procinfo = index_getprocinfo(rel, i + 1, BTORDER_PROC); arg = index_getattr(itup, i + 1, itupdesc, &null); @@ -93,8 +93,8 @@ _bt_mkscankey_nodata(Relation rel) FmgrInfo *procinfo; /* - * We can use the cached (default) support procs since no - * cross-type comparison can be needed. + * We can use the cached (default) support procs since no cross-type + * comparison can be needed. */ procinfo = index_getprocinfo(rel, i + 1, BTORDER_PROC); ScanKeyEntryInitializeWithInfo(&skey[i], @@ -257,9 +257,9 @@ _bt_preprocess_keys(IndexScanDesc scan) if (numberOfKeys == 1) { /* - * We don't use indices for 'A is null' and 'A is not null' - * currently and 'A < = > <> NULL' will always fail - so qual is - * not OK if comparison value is NULL. - vadim 03/21/97 + * We don't use indices for 'A is null' and 'A is not null' currently + * and 'A < = > <> NULL' will always fail - so qual is not OK if + * comparison value is NULL. - vadim 03/21/97 */ if (cur->sk_flags & SK_ISNULL) so->qual_ok = false; @@ -286,20 +286,20 @@ _bt_preprocess_keys(IndexScanDesc scan) /* * Initialize for processing of keys for attr 1. * - * xform[i] points to the currently best scan key of strategy type i+1, - * if any is found with a default operator subtype; it is NULL if we - * haven't yet found such a key for this attr. Scan keys of - * nondefault subtypes are transferred to the output with no - * processing except for noting if they are of "=" type. + * xform[i] points to the currently best scan key of strategy type i+1, if + * any is found with a default operator subtype; it is NULL if we haven't + * yet found such a key for this attr. Scan keys of nondefault subtypes + * are transferred to the output with no processing except for noting if + * they are of "=" type. */ attno = 1; memset(xform, 0, sizeof(xform)); hasOtherTypeEqual = false; /* - * Loop iterates from 0 to numberOfKeys inclusive; we use the last - * pass to handle after-last-key processing. Actual exit from the - * loop is at the "break" statement below. + * Loop iterates from 0 to numberOfKeys inclusive; we use the last pass to + * handle after-last-key processing. Actual exit from the loop is at the + * "break" statement below. */ for (i = 0;; cur++, i++) { @@ -319,8 +319,8 @@ _bt_preprocess_keys(IndexScanDesc scan) } /* - * If we are at the end of the keys for a particular attr, finish - * up processing and emit the cleaned-up keys. + * If we are at the end of the keys for a particular attr, finish up + * processing and emit the cleaned-up keys. */ if (i == numberOfKeys || cur->sk_attno != attno) { @@ -331,9 +331,9 @@ _bt_preprocess_keys(IndexScanDesc scan) elog(ERROR, "btree index keys must be ordered by attribute"); /* - * If = has been specified, no other key will be used. In case - * of key > 2 && key == 1 and so on we have to set qual_ok to - * false before discarding the other keys. + * If = has been specified, no other key will be used. In case of + * key > 2 && key == 1 and so on we have to set qual_ok to false + * before discarding the other keys. */ if (xform[BTEqualStrategyNumber - 1]) { @@ -411,8 +411,8 @@ _bt_preprocess_keys(IndexScanDesc scan) } /* - * If all attrs before this one had "=", include these keys - * into the required-keys count. + * If all attrs before this one had "=", include these keys into + * the required-keys count. */ if (priorNumberOfEqualCols == attno - 1) so->numberOfRequiredKeys = new_numberOfKeys; @@ -526,11 +526,11 @@ _bt_checkkeys(IndexScanDesc scan, IndexTuple tuple, if (isNull) { /* - * Since NULLs are sorted after non-NULLs, we know we have - * reached the upper limit of the range of values for this - * index attr. On a forward scan, we can stop if this qual is - * one of the "must match" subset. On a backward scan, - * however, we should keep going. + * Since NULLs are sorted after non-NULLs, we know we have reached + * the upper limit of the range of values for this index attr. On + * a forward scan, we can stop if this qual is one of the "must + * match" subset. On a backward scan, however, we should keep + * going. */ if (ikey < so->numberOfRequiredKeys && ScanDirectionIsForward(dir)) @@ -547,24 +547,22 @@ _bt_checkkeys(IndexScanDesc scan, IndexTuple tuple, if (!DatumGetBool(test)) { /* - * Tuple fails this qual. If it's a required qual, then we - * may be able to conclude no further tuples will pass, - * either. We have to look at the scan direction and the qual - * type. + * Tuple fails this qual. If it's a required qual, then we may be + * able to conclude no further tuples will pass, either. We have + * to look at the scan direction and the qual type. * - * Note: the only case in which we would keep going after failing - * a required qual is if there are partially-redundant quals - * that _bt_preprocess_keys() was unable to eliminate. For - * example, given "x > 4 AND x > 10" where both are cross-type - * comparisons and so not removable, we might start the scan - * at the x = 4 boundary point. The "x > 10" condition will - * fail until we pass x = 10, but we must not stop the scan on - * its account. + * Note: the only case in which we would keep going after failing a + * required qual is if there are partially-redundant quals that + * _bt_preprocess_keys() was unable to eliminate. For example, + * given "x > 4 AND x > 10" where both are cross-type comparisons + * and so not removable, we might start the scan at the x = 4 + * boundary point. The "x > 10" condition will fail until we pass + * x = 10, but we must not stop the scan on its account. * - * Note: because we stop the scan as soon as any required - * equality qual fails, it is critical that equality quals be - * used for the initial positioning in _bt_first() when they - * are available. See comments in _bt_first(). + * Note: because we stop the scan as soon as any required equality + * qual fails, it is critical that equality quals be used for the + * initial positioning in _bt_first() when they are available. See + * comments in _bt_first(). */ if (ikey < so->numberOfRequiredKeys) { diff --git a/src/backend/access/nbtree/nbtxlog.c b/src/backend/access/nbtree/nbtxlog.c index 078d852924..61bf93a904 100644 --- a/src/backend/access/nbtree/nbtxlog.c +++ b/src/backend/access/nbtree/nbtxlog.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtxlog.c,v 1.22 2005/06/06 17:01:22 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtxlog.c,v 1.23 2005/10/15 02:49:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -101,7 +101,7 @@ _bt_restore_page(Page page, char *from, int len) (sizeof(BTItemData) - sizeof(IndexTupleData)); itemsz = MAXALIGN(itemsz); if (PageAddItem(page, (Item) from, itemsz, - FirstOffsetNumber, LP_USED) == InvalidOffsetNumber) + FirstOffsetNumber, LP_USED) == InvalidOffsetNumber) elog(PANIC, "_bt_restore_page: can't add item to page"); from += itemsz; } @@ -136,8 +136,8 @@ _bt_restore_meta(Relation reln, XLogRecPtr lsn, pageop->btpo_flags = BTP_META; /* - * Set pd_lower just past the end of the metadata. This is not - * essential but it makes the page look compressible to xlog.c. + * Set pd_lower just past the end of the metadata. This is not essential + * but it makes the page look compressible to xlog.c. */ ((PageHeader) metapg)->pd_lower = ((char *) md + sizeof(BTMetaPageData)) - (char *) metapg; @@ -181,7 +181,7 @@ btree_xlog_insert(bool isleaf, bool ismeta, if (!(record->xl_info & XLR_BKP_BLOCK_1)) { buffer = XLogReadBuffer(false, reln, - ItemPointerGetBlockNumber(&(xlrec->target.tid))); + ItemPointerGetBlockNumber(&(xlrec->target.tid))); if (!BufferIsValid(buffer)) elog(PANIC, "btree_insert_redo: block unfound"); page = (Page) BufferGetPage(buffer); @@ -217,8 +217,8 @@ btree_xlog_insert(bool isleaf, bool ismeta, if (!isleaf && incomplete_splits != NIL) { forget_matching_split(reln, xlrec->target.node, - ItemPointerGetBlockNumber(&(xlrec->target.tid)), - ItemPointerGetOffsetNumber(&(xlrec->target.tid)), + ItemPointerGetBlockNumber(&(xlrec->target.tid)), + ItemPointerGetOffsetNumber(&(xlrec->target.tid)), false); } } @@ -325,8 +325,8 @@ btree_xlog_split(bool onleft, bool isroot, if (xlrec->level > 0 && incomplete_splits != NIL) { forget_matching_split(reln, xlrec->target.node, - ItemPointerGetBlockNumber(&(xlrec->target.tid)), - ItemPointerGetOffsetNumber(&(xlrec->target.tid)), + ItemPointerGetBlockNumber(&(xlrec->target.tid)), + ItemPointerGetOffsetNumber(&(xlrec->target.tid)), false); } @@ -655,7 +655,7 @@ static void out_target(char *buf, xl_btreetid *target) { sprintf(buf + strlen(buf), "rel %u/%u/%u; tid %u/%u", - target->node.spcNode, target->node.dbNode, target->node.relNode, + target->node.spcNode, target->node.dbNode, target->node.relNode, ItemPointerGetBlockNumber(&(target->tid)), ItemPointerGetOffsetNumber(&(target->tid))); } diff --git a/src/backend/access/rtree/rtget.c b/src/backend/access/rtree/rtget.c index 199a178c4f..010a493d20 100644 --- a/src/backend/access/rtree/rtget.c +++ b/src/backend/access/rtree/rtget.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/rtree/rtget.c,v 1.36 2005/10/06 02:29:14 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/rtree/rtget.c,v 1.37 2005/10/15 02:49:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -32,12 +32,12 @@ rtgettuple(PG_FUNCTION_ARGS) IndexScanDesc s = (IndexScanDesc) PG_GETARG_POINTER(0); ScanDirection dir = (ScanDirection) PG_GETARG_INT32(1); RTreeScanOpaque so = (RTreeScanOpaque) s->opaque; - Page page; + Page page; OffsetNumber offnum; /* - * If we've already produced a tuple and the executor has informed - * us that it should be marked "killed", do so now. + * If we've already produced a tuple and the executor has informed us that + * it should be marked "killed", do so now. */ if (s->kill_prior_tuple && ItemPointerIsValid(&(s->currentItemData))) { @@ -48,14 +48,13 @@ rtgettuple(PG_FUNCTION_ARGS) } /* - * Get the next tuple that matches the search key; if asked to - * skip killed tuples, find the first non-killed tuple that - * matches. Return as soon as we've run out of matches or we've - * found an acceptable match. + * Get the next tuple that matches the search key; if asked to skip killed + * tuples, find the first non-killed tuple that matches. Return as soon as + * we've run out of matches or we've found an acceptable match. */ for (;;) { - bool res = rtnext(s, dir); + bool res = rtnext(s, dir); if (res && s->ignore_killed_tuples) { @@ -73,7 +72,7 @@ Datum rtgetmulti(PG_FUNCTION_ARGS) { IndexScanDesc s = (IndexScanDesc) PG_GETARG_POINTER(0); - ItemPointer tids = (ItemPointer) PG_GETARG_POINTER(1); + ItemPointer tids = (ItemPointer) PG_GETARG_POINTER(1); int32 max_tids = PG_GETARG_INT32(2); int32 *returned_tids = (int32 *) PG_GETARG_POINTER(3); RTreeScanOpaque so = (RTreeScanOpaque) s->opaque; @@ -86,7 +85,7 @@ rtgetmulti(PG_FUNCTION_ARGS) res = rtnext(s, ForwardScanDirection); if (res && s->ignore_killed_tuples) { - Page page; + Page page; OffsetNumber offnum; offnum = ItemPointerGetOffsetNumber(&(s->currentItemData)); @@ -201,12 +200,11 @@ rtnext(IndexScanDesc s, ScanDirection dir) blk = ItemPointerGetBlockNumber(&(it->t_tid)); /* - * Note that we release the pin on the page as we descend - * down the tree, even though there's a good chance we'll - * eventually need to re-read the buffer later in this - * scan. This may or may not be optimal, but it doesn't - * seem likely to make a huge performance difference - * either way. + * Note that we release the pin on the page as we descend down the + * tree, even though there's a good chance we'll eventually need + * to re-read the buffer later in this scan. This may or may not + * be optimal, but it doesn't seem likely to make a huge + * performance difference either way. */ so->curbuf = ReleaseAndReadBuffer(so->curbuf, s->indexRelation, blk); p = BufferGetPage(so->curbuf); @@ -233,7 +231,7 @@ findnext(IndexScanDesc s, OffsetNumber n, ScanDirection dir) IndexTuple it; RTreePageOpaque po; RTreeScanOpaque so; - Page p; + Page p; so = (RTreeScanOpaque) s->opaque; p = BufferGetPage(so->curbuf); @@ -242,8 +240,8 @@ findnext(IndexScanDesc s, OffsetNumber n, ScanDirection dir) po = (RTreePageOpaque) PageGetSpecialPointer(p); /* - * If we modified the index during the scan, we may have a pointer to - * a ghost tuple, before the scan. If this is the case, back up one. + * If we modified the index during the scan, we may have a pointer to a + * ghost tuple, before the scan. If this is the case, back up one. */ if (so->s_flags & RTS_CURBEFORE) @@ -277,7 +275,7 @@ findnext(IndexScanDesc s, OffsetNumber n, ScanDirection dir) } if (n >= FirstOffsetNumber && n <= maxoff) - return n; /* found a match on this page */ + return n; /* found a match on this page */ else return InvalidOffsetNumber; /* no match, go to next page */ } diff --git a/src/backend/access/rtree/rtproc.c b/src/backend/access/rtree/rtproc.c index d8d766f47d..292dac6a13 100644 --- a/src/backend/access/rtree/rtproc.c +++ b/src/backend/access/rtree/rtproc.c @@ -15,7 +15,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/rtree/rtproc.c,v 1.42 2004/12/31 21:59:26 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/access/rtree/rtproc.c,v 1.43 2005/10/15 02:49:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -146,8 +146,8 @@ rt_poly_size(PG_FUNCTION_ARGS) ydim; /* - * Can't just use GETARG because of possibility that input is NULL; - * since POLYGON is toastable, GETARG will try to inspect its value + * Can't just use GETARG because of possibility that input is NULL; since + * POLYGON is toastable, GETARG will try to inspect its value */ if (aptr == NULL) { diff --git a/src/backend/access/rtree/rtree.c b/src/backend/access/rtree/rtree.c index 3b96b9ebe2..d684101d26 100644 --- a/src/backend/access/rtree/rtree.c +++ b/src/backend/access/rtree/rtree.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/rtree/rtree.c,v 1.91 2005/08/10 21:36:46 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/rtree/rtree.c,v 1.92 2005/10/15 02:49:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -121,8 +121,8 @@ rtbuild(PG_FUNCTION_ARGS) initRtstate(&buildstate.rtState, index); /* - * We expect to be called exactly once for any index relation. If - * that's not the case, big trouble's what we have. + * We expect to be called exactly once for any index relation. If that's + * not the case, big trouble's what we have. */ if (RelationGetNumberOfBlocks(index) != 0) elog(ERROR, "index \"%s\" already contains data", @@ -175,10 +175,10 @@ rtbuildCallback(Relation index, /* * Since we already have the index relation locked, we call rtdoinsert - * directly. Normal access method calls dispatch through rtinsert, - * which locks the relation for write. This is the right thing to do - * if you're inserting single tups, but not when you're initializing - * the whole index at once. + * directly. Normal access method calls dispatch through rtinsert, which + * locks the relation for write. This is the right thing to do if you're + * inserting single tups, but not when you're initializing the whole index + * at once. */ rtdoinsert(index, itup, &buildstate->rtState); @@ -226,9 +226,8 @@ rtinsert(PG_FUNCTION_ARGS) initRtstate(&rtState, r); /* - * Since rtree is not marked "amconcurrent" in pg_am, caller should - * have acquired exclusive lock on index relation. We need no locking - * here. + * Since rtree is not marked "amconcurrent" in pg_am, caller should have + * acquired exclusive lock on index relation. We need no locking here. */ rtdoinsert(r, itup, &rtState); @@ -331,7 +330,7 @@ rttighten(Relation r, p = BufferGetPage(b); oldud = IndexTupleGetDatum(PageGetItem(p, - PageGetItemId(p, stk->rts_child))); + PageGetItemId(p, stk->rts_child))); FunctionCall2(&rtstate->sizeFn, oldud, PointerGetDatum(&old_size)); @@ -342,8 +341,8 @@ rttighten(Relation r, PointerGetDatum(&newd_size)); /* - * If newd_size == 0 we have degenerate rectangles, so we don't know - * if there was any change, so we have to assume there was. + * If newd_size == 0 we have degenerate rectangles, so we don't know if + * there was any change, so we have to assume there was. */ if ((newd_size == 0) || (newd_size != old_size)) { @@ -370,8 +369,8 @@ rttighten(Relation r, /* * The user may be defining an index on variable-sized data (like * polygons). If so, we need to get a constant-sized datum for - * insertion on the internal page. We do this by calling the - * union proc, which is required to return a rectangle. + * insertion on the internal page. We do this by calling the union + * proc, which is required to return a rectangle. */ tdatum = FunctionCall2(&rtstate->unionFn, datum, datum); @@ -428,8 +427,8 @@ rtdosplit(Relation r, /* * The root of the tree is the first block in the relation. If we're - * about to split the root, we need to do some hocus-pocus to enforce - * this guarantee. + * about to split the root, we need to do some hocus-pocus to enforce this + * guarantee. */ if (BufferGetBlockNumber(buffer) == P_ROOT) @@ -459,10 +458,9 @@ rtdosplit(Relation r, newitemoff = OffsetNumberNext(maxoff); /* - * spl_left contains a list of the offset numbers of the tuples that - * will go to the left page. For each offset number, get the tuple - * item, then add the item to the left page. Similarly for the right - * side. + * spl_left contains a list of the offset numbers of the tuples that will + * go to the left page. For each offset number, get the tuple item, then + * add the item to the left page. Similarly for the right side. */ /* fill left node */ @@ -525,13 +523,13 @@ rtdosplit(Relation r, * introduced in its structure by splitting this page. * * 2) "Tighten" the bounding box of the pointer to the left page in the - * parent node in the tree, if any. Since we moved a bunch of stuff - * off the left page, we expect it to get smaller. This happens in - * the internal insertion routine. + * parent node in the tree, if any. Since we moved a bunch of stuff off + * the left page, we expect it to get smaller. This happens in the + * internal insertion routine. * - * 3) Insert a pointer to the right page in the parent. This may cause - * the parent to split. If it does, we need to repeat steps one and - * two for each split node in the tree. + * 3) Insert a pointer to the right page in the parent. This may cause the + * parent to split. If it does, we need to repeat steps one and two for + * each split node in the tree. */ /* adjust active scans */ @@ -583,10 +581,10 @@ rtintinsert(Relation r, old = (IndexTuple) PageGetItem(p, PageGetItemId(p, stk->rts_child)); /* - * This is a hack. Right now, we force rtree internal keys to be - * constant size. To fix this, need delete the old key and add both - * left and right for the two new pages. The insertion of left may - * force a split if the new left key is bigger than the old key. + * This is a hack. Right now, we force rtree internal keys to be constant + * size. To fix this, need delete the old key and add both left and right + * for the two new pages. The insertion of left may force a split if the + * new left key is bigger than the old key. */ if (IndexTupleSize(old) != IndexTupleSize(ltup)) @@ -603,8 +601,7 @@ rtintinsert(Relation r, rttighten(r, stk->rts_parent, newdatum, IndexTupleAttSize(ltup), rtstate); rtdosplit(r, b, stk->rts_parent, rtup, rtstate); - WriteBuffer(b); /* don't forget to release buffer! - - * 01/31/94 */ + WriteBuffer(b); /* don't forget to release buffer! - 01/31/94 */ } else { @@ -716,16 +713,15 @@ rtpicksplit(Relation r, int total_num_tuples, num_tuples_without_seeds, max_after_split; /* in Guttman's lingo, (M - m) */ - float diff; /* diff between cost of putting tuple left - * or right */ + float diff; /* diff between cost of putting tuple left or + * right */ SPLITCOST *cost_vector; int n; /* - * First, make sure the new item is not so large that we can't - * possibly fit it on a page, even by itself. (It's sufficient to - * make this test here, since any oversize tuple must lead to a page - * split attempt.) + * First, make sure the new item is not so large that we can't possibly + * fit it on a page, even by itself. (It's sufficient to make this test + * here, since any oversize tuple must lead to a page split attempt.) */ newitemsz = IndexTupleTotalSize(itup); if (newitemsz > RTPageAvailSpace) @@ -734,11 +730,10 @@ rtpicksplit(Relation r, errmsg("index row size %lu exceeds rtree maximum, %lu", (unsigned long) newitemsz, (unsigned long) RTPageAvailSpace), - errhint("Values larger than a buffer page cannot be indexed."))); + errhint("Values larger than a buffer page cannot be indexed."))); maxoff = PageGetMaxOffsetNumber(page); - newitemoff = OffsetNumberNext(maxoff); /* phony index for new - * item */ + newitemoff = OffsetNumberNext(maxoff); /* phony index for new item */ total_num_tuples = newitemoff; num_tuples_without_seeds = total_num_tuples - 2; max_after_split = total_num_tuples / 2; /* works for m = M/2 */ @@ -793,8 +788,7 @@ rtpicksplit(Relation r, pfree(DatumGetPointer(inter_d)); /* - * are these a more promising split that what we've already - * seen? + * are these a more promising split that what we've already seen? */ if (size_waste > waste || firsttime) { @@ -809,10 +803,10 @@ rtpicksplit(Relation r, if (firsttime) { /* - * There is no possible split except to put the new item on its - * own page. Since we still have to compute the union rectangles, - * we play dumb and run through the split algorithm anyway, - * setting seed_1 = first item on page and seed_2 = new item. + * There is no possible split except to put the new item on its own + * page. Since we still have to compute the union rectangles, we play + * dumb and run through the split algorithm anyway, setting seed_1 = + * first item on page and seed_2 = new item. */ seed_1 = FirstOffsetNumber; seed_2 = newitemoff; @@ -840,25 +834,23 @@ rtpicksplit(Relation r, /* * Now split up the regions between the two seeds. * - * The cost_vector array will contain hints for determining where each - * tuple should go. Each record in the array will contain a boolean, - * choose_left, that indicates which node the tuple prefers to be on, - * and the absolute difference in cost between putting the tuple in - * its favored node and in the other node. + * The cost_vector array will contain hints for determining where each tuple + * should go. Each record in the array will contain a boolean, + * choose_left, that indicates which node the tuple prefers to be on, and + * the absolute difference in cost between putting the tuple in its + * favored node and in the other node. * * Later, we will sort the cost_vector in descending order by cost - * difference, and consider the tuples in that order for placement. - * That way, the tuples that *really* want to be in one node or the - * other get to choose first, and the tuples that don't really care - * choose last. + * difference, and consider the tuples in that order for placement. That + * way, the tuples that *really* want to be in one node or the other get + * to choose first, and the tuples that don't really care choose last. * * First, build the cost_vector array. The new index tuple will also be - * handled in this loop, and represented in the array, with - * i==newitemoff. + * handled in this loop, and represented in the array, with i==newitemoff. * - * In the case of variable size tuples it is possible that we only have - * the two seeds and no other tuples, in which case we don't do any of - * this cost_vector stuff. + * In the case of variable size tuples it is possible that we only have the + * two seeds and no other tuples, in which case we don't do any of this + * cost_vector stuff. */ /* to keep compiler quiet */ @@ -908,13 +900,13 @@ rtpicksplit(Relation r, } /* - * Now make the final decisions about where each tuple will go, and - * build the vectors to return in the SPLITVEC record. + * Now make the final decisions about where each tuple will go, and build + * the vectors to return in the SPLITVEC record. * - * The cost_vector array contains (descriptions of) all the tuples, in - * the order that we want to consider them, so we we just iterate - * through it and place each tuple in left or right nodes, according - * to the criteria described below. + * The cost_vector array contains (descriptions of) all the tuples, in the + * order that we want to consider them, so we we just iterate through it + * and place each tuple in left or right nodes, according to the criteria + * described below. */ left = v->spl_left; @@ -923,8 +915,8 @@ rtpicksplit(Relation r, v->spl_nright = 0; /* - * Place the seeds first. left avail space, left union, right avail - * space, and right union have already been adjusted for the seeds. + * Place the seeds first. left avail space, left union, right avail space, + * and right union have already been adjusted for the seeds. */ *left++ = seed_1; @@ -966,32 +958,30 @@ rtpicksplit(Relation r, PointerGetDatum(&size_beta)); /* - * We prefer the page that shows smaller enlargement of its union - * area (Guttman's algorithm), but we must take care that at least - * one page will still have room for the new item after this one - * is added. + * We prefer the page that shows smaller enlargement of its union area + * (Guttman's algorithm), but we must take care that at least one page + * will still have room for the new item after this one is added. * - * (We know that all the old items together can fit on one page, so - * we need not worry about any other problem than failing to fit - * the new item.) + * (We know that all the old items together can fit on one page, so we + * need not worry about any other problem than failing to fit the new + * item.) * - * Guttman's algorithm actually has two factors to consider (in - * order): 1. if one node has so many tuples already assigned to - * it that the other needs all the rest in order to satisfy the - * condition that neither node has fewer than m tuples, then that - * is decisive; 2. otherwise, choose the page that shows the - * smaller enlargement of its union area. + * Guttman's algorithm actually has two factors to consider (in order): + * 1. if one node has so many tuples already assigned to it that the + * other needs all the rest in order to satisfy the condition that + * neither node has fewer than m tuples, then that is decisive; 2. + * otherwise, choose the page that shows the smaller enlargement of + * its union area. * - * I have chosen m = M/2, where M is the maximum number of tuples on - * a page. (Actually, this is only strictly true for fixed size - * tuples. For variable size tuples, there still might have to be - * only one tuple on a page, if it is really big. But even with - * variable size tuples we still try to get m as close as possible - * to M/2.) + * I have chosen m = M/2, where M is the maximum number of tuples on a + * page. (Actually, this is only strictly true for fixed size tuples. + * For variable size tuples, there still might have to be only one + * tuple on a page, if it is really big. But even with variable size + * tuples we still try to get m as close as possible to M/2.) * - * The question of which page shows the smaller enlargement of its - * union area has already been answered, and the answer stored in - * the choose_left field of the SPLITCOST record. + * The question of which page shows the smaller enlargement of its union + * area has already been answered, and the answer stored in the + * choose_left field of the SPLITCOST record. */ left_feasible = (left_avail_space >= item_1_sz && ((left_avail_space - item_1_sz) >= newitemsz || @@ -1003,9 +993,8 @@ rtpicksplit(Relation r, { /* * Both feasible, use Guttman's algorithm. First check the m - * condition described above, and if that doesn't apply, - * choose the page with the smaller enlargement of its union - * area. + * condition described above, and if that doesn't apply, choose + * the page with the smaller enlargement of its union area. */ if (v->spl_nleft > max_after_split) choose_left = false; @@ -1153,9 +1142,8 @@ rtbulkdelete(PG_FUNCTION_ARGS) num_index_tuples = 0; /* - * Since rtree is not marked "amconcurrent" in pg_am, caller should - * have acquired exclusive lock on index relation. We need no locking - * here. + * Since rtree is not marked "amconcurrent" in pg_am, caller should have + * acquired exclusive lock on index relation. We need no locking here. */ /* diff --git a/src/backend/access/rtree/rtscan.c b/src/backend/access/rtree/rtscan.c index 3f9f81befb..577c6a6436 100644 --- a/src/backend/access/rtree/rtscan.c +++ b/src/backend/access/rtree/rtscan.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/rtree/rtscan.c,v 1.59 2005/06/24 00:18:52 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/rtree/rtscan.c,v 1.60 2005/10/15 02:49:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -123,11 +123,11 @@ rtrescan(PG_FUNCTION_ARGS) /* * Scans on internal pages use different operators than they do on - * leaf pages. For example, if the user wants all boxes that - * exactly match (x1,y1,x2,y2), then on internal pages we need to - * find all boxes that contain (x1,y1,x2,y2). rtstrat.c knows - * how to pick the opclass member to use for internal pages. - * In some cases we need to negate the result of the opclass member. + * leaf pages. For example, if the user wants all boxes that exactly + * match (x1,y1,x2,y2), then on internal pages we need to find all + * boxes that contain (x1,y1,x2,y2). rtstrat.c knows how to pick the + * opclass member to use for internal pages. In some cases we need to + * negate the result of the opclass member. */ for (i = 0; i < s->numberOfKeys; i++) { @@ -333,9 +333,9 @@ ReleaseResources_rtree(void) RTScanList next; /* - * Note: this should be a no-op during normal query shutdown. However, - * in an abort situation ExecutorEnd is not called and so there may be - * open index scans to clean up. + * Note: this should be a no-op during normal query shutdown. However, in + * an abort situation ExecutorEnd is not called and so there may be open + * index scans to clean up. */ prev = NULL; @@ -440,8 +440,7 @@ adjustiptr(IndexScanDesc s, else { /* - * remember that we're before the current - * tuple + * remember that we're before the current tuple */ ItemPointerSet(iptr, blkno, FirstOffsetNumber); if (iptr == &(s->currentItemData)) diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c index 4a2e1f5592..f29f460ade 100644 --- a/src/backend/access/transam/clog.c +++ b/src/backend/access/transam/clog.c @@ -24,7 +24,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/access/transam/clog.c,v 1.32 2005/08/20 23:26:08 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/transam/clog.c,v 1.33 2005/10/15 02:49:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -222,14 +222,14 @@ StartupCLOG(void) /* * Zero out the remainder of the current clog page. Under normal * circumstances it should be zeroes already, but it seems at least - * theoretically possible that XLOG replay will have settled on a - * nextXID value that is less than the last XID actually used and - * marked by the previous database lifecycle (since subtransaction - * commit writes clog but makes no WAL entry). Let's just be safe. - * (We need not worry about pages beyond the current one, since those - * will be zeroed when first used. For the same reason, there is no - * need to do anything when nextXid is exactly at a page boundary; and - * it's likely that the "current" page doesn't exist yet in that case.) + * theoretically possible that XLOG replay will have settled on a nextXID + * value that is less than the last XID actually used and marked by the + * previous database lifecycle (since subtransaction commit writes clog + * but makes no WAL entry). Let's just be safe. (We need not worry about + * pages beyond the current one, since those will be zeroed when first + * used. For the same reason, there is no need to do anything when + * nextXid is exactly at a page boundary; and it's likely that the + * "current" page doesn't exist yet in that case.) */ if (TransactionIdToPgIndex(xid) != 0) { @@ -325,8 +325,8 @@ TruncateCLOG(TransactionId oldestXact) int cutoffPage; /* - * The cutoff point is the start of the segment containing oldestXact. - * We pass the *page* containing oldestXact to SimpleLruTruncate. + * The cutoff point is the start of the segment containing oldestXact. We + * pass the *page* containing oldestXact to SimpleLruTruncate. */ cutoffPage = TransactionIdToPage(oldestXact); diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c index 1adaebb6d8..ffe14ed6bf 100644 --- a/src/backend/access/transam/multixact.c +++ b/src/backend/access/transam/multixact.c @@ -4,15 +4,15 @@ * PostgreSQL multi-transaction-log manager * * The pg_multixact manager is a pg_clog-like manager that stores an array - * of TransactionIds for each MultiXactId. It is a fundamental part of the - * shared-row-lock implementation. A share-locked tuple stores a + * of TransactionIds for each MultiXactId. It is a fundamental part of the + * shared-row-lock implementation. A share-locked tuple stores a * MultiXactId in its Xmax, and a transaction that needs to wait for the * tuple to be unlocked can sleep on the potentially-several TransactionIds * that compose the MultiXactId. * * We use two SLRU areas, one for storing the offsets at which the data * starts for each MultiXactId in the other one. This trick allows us to - * store variable length arrays of TransactionIds. (We could alternatively + * store variable length arrays of TransactionIds. (We could alternatively * use one area containing counts and TransactionIds, with valid MultiXactId * values pointing at slots containing counts; but that way seems less robust * since it would get completely confused if someone inquired about a bogus @@ -32,7 +32,7 @@ * * Like clog.c, and unlike subtrans.c, we have to preserve state across * crashes and ensure that MXID and offset numbering increases monotonically - * across a crash. We do this in the same way as it's done for transaction + * across a crash. We do this in the same way as it's done for transaction * IDs: the WAL record is guaranteed to contain evidence of every MXID we * could need to worry about, and we just make sure that at the end of * replay, the next-MXID and next-offset counters are at least as large as @@ -42,7 +42,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/access/transam/multixact.c,v 1.8 2005/08/20 23:26:08 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/transam/multixact.c,v 1.9 2005/10/15 02:49:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -59,13 +59,13 @@ /* - * Defines for MultiXactOffset page sizes. A page is the same BLCKSZ as is + * Defines for MultiXactOffset page sizes. A page is the same BLCKSZ as is * used everywhere else in Postgres. * * Note: because both MultiXactOffsets and TransactionIds are 32 bits and * wrap around at 0xFFFFFFFF, MultiXact page numbering also wraps around at * 0xFFFFFFFF/MULTIXACT_*_PER_PAGE, and segment numbering at - * 0xFFFFFFFF/MULTIXACT_*_PER_PAGE/SLRU_SEGMENTS_PER_PAGE. We need take no + * 0xFFFFFFFF/MULTIXACT_*_PER_PAGE/SLRU_SEGMENTS_PER_PAGE. We need take no * explicit notice of that fact in this module, except when comparing segment * and page numbers in TruncateMultiXact * (see MultiXact{Offset,Member}PagePrecedes). @@ -92,11 +92,11 @@ static SlruCtlData MultiXactOffsetCtlData; static SlruCtlData MultiXactMemberCtlData; -#define MultiXactOffsetCtl (&MultiXactOffsetCtlData) -#define MultiXactMemberCtl (&MultiXactMemberCtlData) +#define MultiXactOffsetCtl (&MultiXactOffsetCtlData) +#define MultiXactMemberCtl (&MultiXactMemberCtlData) /* - * MultiXact state shared across all backends. All this state is protected + * MultiXact state shared across all backends. All this state is protected * by MultiXactGenLock. (We also use MultiXactOffsetControlLock and * MultiXactMemberControlLock to guard accesses to the two sets of SLRU * buffers. For concurrency's sake, we avoid holding more than one of these @@ -105,50 +105,48 @@ static SlruCtlData MultiXactMemberCtlData; typedef struct MultiXactStateData { /* next-to-be-assigned MultiXactId */ - MultiXactId nextMXact; + MultiXactId nextMXact; /* next-to-be-assigned offset */ - MultiXactOffset nextOffset; + MultiXactOffset nextOffset; /* the Offset SLRU area was last truncated at this MultiXactId */ - MultiXactId lastTruncationPoint; + MultiXactId lastTruncationPoint; /* - * Per-backend data starts here. We have two arrays stored in - * the area immediately following the MultiXactStateData struct. - * Each is indexed by BackendId. (Note: valid BackendIds run from 1 to - * MaxBackends; element zero of each array is never used.) + * Per-backend data starts here. We have two arrays stored in the area + * immediately following the MultiXactStateData struct. Each is indexed by + * BackendId. (Note: valid BackendIds run from 1 to MaxBackends; element + * zero of each array is never used.) * - * OldestMemberMXactId[k] is the oldest MultiXactId each backend's - * current transaction(s) could possibly be a member of, or - * InvalidMultiXactId when the backend has no live transaction that - * could possibly be a member of a MultiXact. Each backend sets its - * entry to the current nextMXact counter just before first acquiring a - * shared lock in a given transaction, and clears it at transaction end. - * (This works because only during or after acquiring a shared lock - * could an XID possibly become a member of a MultiXact, and that - * MultiXact would have to be created during or after the lock - * acquisition.) + * OldestMemberMXactId[k] is the oldest MultiXactId each backend's current + * transaction(s) could possibly be a member of, or InvalidMultiXactId + * when the backend has no live transaction that could possibly be a + * member of a MultiXact. Each backend sets its entry to the current + * nextMXact counter just before first acquiring a shared lock in a given + * transaction, and clears it at transaction end. (This works because only + * during or after acquiring a shared lock could an XID possibly become a + * member of a MultiXact, and that MultiXact would have to be created + * during or after the lock acquisition.) * - * OldestVisibleMXactId[k] is the oldest MultiXactId each backend's - * current transaction(s) think is potentially live, or InvalidMultiXactId - * when not in a transaction or not in a transaction that's paid any - * attention to MultiXacts yet. This is computed when first needed in - * a given transaction, and cleared at transaction end. We can compute - * it as the minimum of the valid OldestMemberMXactId[] entries at the - * time we compute it (using nextMXact if none are valid). Each backend - * is required not to attempt to access any SLRU data for MultiXactIds - * older than its own OldestVisibleMXactId[] setting; this is necessary - * because the checkpointer could truncate away such data at any instant. + * OldestVisibleMXactId[k] is the oldest MultiXactId each backend's current + * transaction(s) think is potentially live, or InvalidMultiXactId when + * not in a transaction or not in a transaction that's paid any attention + * to MultiXacts yet. This is computed when first needed in a given + * transaction, and cleared at transaction end. We can compute it as the + * minimum of the valid OldestMemberMXactId[] entries at the time we + * compute it (using nextMXact if none are valid). Each backend is + * required not to attempt to access any SLRU data for MultiXactIds older + * than its own OldestVisibleMXactId[] setting; this is necessary because + * the checkpointer could truncate away such data at any instant. * - * The checkpointer can compute the safe truncation point as the oldest - * valid value among all the OldestMemberMXactId[] and - * OldestVisibleMXactId[] entries, or nextMXact if none are valid. - * Clearly, it is not possible for any later-computed OldestVisibleMXactId - * value to be older than this, and so there is no risk of truncating - * data that is still needed. + * The checkpointer can compute the safe truncation point as the oldest valid + * value among all the OldestMemberMXactId[] and OldestVisibleMXactId[] + * entries, or nextMXact if none are valid. Clearly, it is not possible + * for any later-computed OldestVisibleMXactId value to be older than + * this, and so there is no risk of truncating data that is still needed. */ - MultiXactId perBackendXactIds[1]; /* VARIABLE LENGTH ARRAY */ + MultiXactId perBackendXactIds[1]; /* VARIABLE LENGTH ARRAY */ } MultiXactStateData; /* Pointers to the state data in shared memory */ @@ -176,13 +174,13 @@ static MultiXactId *OldestVisibleMXactId; typedef struct mXactCacheEnt { struct mXactCacheEnt *next; - MultiXactId multi; - int nxids; - TransactionId xids[1]; /* VARIABLE LENGTH ARRAY */ + MultiXactId multi; + int nxids; + TransactionId xids[1]; /* VARIABLE LENGTH ARRAY */ } mXactCacheEnt; -static mXactCacheEnt *MXactCache = NULL; -static MemoryContext MXactContext = NULL; +static mXactCacheEnt *MXactCache = NULL; +static MemoryContext MXactContext = NULL; #ifdef MULTIXACT_DEBUG @@ -201,14 +199,15 @@ static MemoryContext MXactContext = NULL; static void MultiXactIdSetOldestVisible(void); static MultiXactId CreateMultiXactId(int nxids, TransactionId *xids); static void RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset, - int nxids, TransactionId *xids); + int nxids, TransactionId *xids); static MultiXactId GetNewMultiXactId(int nxids, MultiXactOffset *offset); /* MultiXact cache management */ static MultiXactId mXactCacheGetBySet(int nxids, TransactionId *xids); -static int mXactCacheGetById(MultiXactId multi, TransactionId **xids); +static int mXactCacheGetById(MultiXactId multi, TransactionId **xids); static void mXactCachePut(MultiXactId multi, int nxids, TransactionId *xids); -static int xidComparator(const void *arg1, const void *arg2); +static int xidComparator(const void *arg1, const void *arg2); + #ifdef MULTIXACT_DEBUG static char *mxid_to_string(MultiXactId multi, int nxids, TransactionId *xids); #endif @@ -220,7 +219,7 @@ static bool MultiXactOffsetPagePrecedes(int page1, int page2); static bool MultiXactMemberPagePrecedes(int page1, int page2); static bool MultiXactIdPrecedes(MultiXactId multi1, MultiXactId multi2); static bool MultiXactOffsetPrecedes(MultiXactOffset offset1, - MultiXactOffset offset2); + MultiXactOffset offset2); static void ExtendMultiXactOffset(MultiXactId multi); static void ExtendMultiXactMember(MultiXactOffset offset, int nmembers); static void TruncateMultiXact(void); @@ -239,8 +238,8 @@ static void WriteMZeroPageXlogRec(int pageno, uint8 info); MultiXactId MultiXactIdCreate(TransactionId xid1, TransactionId xid2) { - MultiXactId newMulti; - TransactionId xids[2]; + MultiXactId newMulti; + TransactionId xids[2]; AssertArg(TransactionIdIsValid(xid1)); AssertArg(TransactionIdIsValid(xid2)); @@ -248,9 +247,9 @@ MultiXactIdCreate(TransactionId xid1, TransactionId xid2) Assert(!TransactionIdEquals(xid1, xid2)); /* - * Note: unlike MultiXactIdExpand, we don't bother to check that both - * XIDs are still running. In typical usage, xid2 will be our own XID - * and the caller just did a check on xid1, so it'd be wasted effort. + * Note: unlike MultiXactIdExpand, we don't bother to check that both XIDs + * are still running. In typical usage, xid2 will be our own XID and the + * caller just did a check on xid1, so it'd be wasted effort. */ xids[0] = xid1; @@ -281,12 +280,12 @@ MultiXactIdCreate(TransactionId xid1, TransactionId xid2) MultiXactId MultiXactIdExpand(MultiXactId multi, TransactionId xid) { - MultiXactId newMulti; - TransactionId *members; - TransactionId *newMembers; - int nmembers; - int i; - int j; + MultiXactId newMulti; + TransactionId *members; + TransactionId *newMembers; + int nmembers; + int i; + int j; AssertArg(MultiXactIdIsValid(multi)); AssertArg(TransactionIdIsValid(xid)); @@ -313,8 +312,8 @@ MultiXactIdExpand(MultiXactId multi, TransactionId xid) } /* - * If the TransactionId is already a member of the MultiXactId, - * just return the existing MultiXactId. + * If the TransactionId is already a member of the MultiXactId, just + * return the existing MultiXactId. */ for (i = 0; i < nmembers; i++) { @@ -329,9 +328,9 @@ MultiXactIdExpand(MultiXactId multi, TransactionId xid) /* * Determine which of the members of the MultiXactId are still running, - * and use them to create a new one. (Removing dead members is just - * an optimization, but a useful one. Note we have the same race - * condition here as above: j could be 0 at the end of the loop.) + * and use them to create a new one. (Removing dead members is just an + * optimization, but a useful one. Note we have the same race condition + * here as above: j could be 0 at the end of the loop.) */ newMembers = (TransactionId *) palloc(sizeof(TransactionId) * (nmembers + 1)); @@ -355,7 +354,7 @@ MultiXactIdExpand(MultiXactId multi, TransactionId xid) /* * MultiXactIdIsRunning - * Returns whether a MultiXactId is "running". + * Returns whether a MultiXactId is "running". * * We return true if at least one member of the given MultiXactId is still * running. Note that a "false" result is certain not to change, @@ -365,9 +364,9 @@ bool MultiXactIdIsRunning(MultiXactId multi) { TransactionId *members; - TransactionId myXid; - int nmembers; - int i; + TransactionId myXid; + int nmembers; + int i; debug_elog3(DEBUG2, "IsRunning %u?", multi); @@ -394,7 +393,7 @@ MultiXactIdIsRunning(MultiXactId multi) /* * This could be made faster by having another entry point in procarray.c, - * walking the PGPROC array only once for all the members. But in most + * walking the PGPROC array only once for all the members. But in most * cases nmembers should be small enough that it doesn't much matter. */ for (i = 0; i < nmembers; i++) @@ -436,19 +435,19 @@ MultiXactIdSetOldestMember(void) /* * You might think we don't need to acquire a lock here, since - * fetching and storing of TransactionIds is probably atomic, - * but in fact we do: suppose we pick up nextMXact and then - * lose the CPU for a long time. Someone else could advance - * nextMXact, and then another someone else could compute an - * OldestVisibleMXactId that would be after the value we are - * going to store when we get control back. Which would be wrong. + * fetching and storing of TransactionIds is probably atomic, but in + * fact we do: suppose we pick up nextMXact and then lose the CPU for + * a long time. Someone else could advance nextMXact, and then + * another someone else could compute an OldestVisibleMXactId that + * would be after the value we are going to store when we get control + * back. Which would be wrong. */ LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE); /* * We have to beware of the possibility that nextMXact is in the - * wrapped-around state. We don't fix the counter itself here, - * but we must be sure to store a valid value in our array entry. + * wrapped-around state. We don't fix the counter itself here, but we + * must be sure to store a valid value in our array entry. */ nextMXact = MultiXactState->nextMXact; if (nextMXact < FirstMultiXactId) @@ -475,7 +474,7 @@ MultiXactIdSetOldestMember(void) * The value to set is the oldest of nextMXact and all the valid per-backend * OldestMemberMXactId[] entries. Because of the locking we do, we can be * certain that no subsequent call to MultiXactIdSetOldestMember can set - * an OldestMemberMXactId[] entry older than what we compute here. Therefore + * an OldestMemberMXactId[] entry older than what we compute here. Therefore * there is no live transaction, now or later, that can be a member of any * MultiXactId older than the OldestVisibleMXactId we compute here. */ @@ -485,14 +484,14 @@ MultiXactIdSetOldestVisible(void) if (!MultiXactIdIsValid(OldestVisibleMXactId[MyBackendId])) { MultiXactId oldestMXact; - int i; + int i; LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE); /* * We have to beware of the possibility that nextMXact is in the - * wrapped-around state. We don't fix the counter itself here, - * but we must be sure to store a valid value in our array entry. + * wrapped-around state. We don't fix the counter itself here, but we + * must be sure to store a valid value in our array entry. */ oldestMXact = MultiXactState->nextMXact; if (oldestMXact < FirstMultiXactId) @@ -535,17 +534,17 @@ void MultiXactIdWait(MultiXactId multi) { TransactionId *members; - int nmembers; + int nmembers; nmembers = GetMultiXactIdMembers(multi, &members); if (nmembers >= 0) { - int i; + int i; for (i = 0; i < nmembers; i++) { - TransactionId member = members[i]; + TransactionId member = members[i]; debug_elog4(DEBUG2, "MultiXactIdWait: waiting for %d (%u)", i, member); @@ -564,19 +563,19 @@ MultiXactIdWait(MultiXactId multi) bool ConditionalMultiXactIdWait(MultiXactId multi) { - bool result = true; + bool result = true; TransactionId *members; - int nmembers; + int nmembers; nmembers = GetMultiXactIdMembers(multi, &members); if (nmembers >= 0) { - int i; + int i; for (i = 0; i < nmembers; i++) { - TransactionId member = members[i]; + TransactionId member = members[i]; debug_elog4(DEBUG2, "ConditionalMultiXactIdWait: trying %d (%u)", i, member); @@ -596,7 +595,7 @@ ConditionalMultiXactIdWait(MultiXactId multi) /* * CreateMultiXactId - * Make a new MultiXactId + * Make a new MultiXactId * * Make XLOG, SLRU and cache entries for a new MultiXactId, recording the * given TransactionIds as members. Returns the newly created MultiXactId. @@ -606,7 +605,7 @@ ConditionalMultiXactIdWait(MultiXactId multi) static MultiXactId CreateMultiXactId(int nxids, TransactionId *xids) { - MultiXactId multi; + MultiXactId multi; MultiXactOffset offset; XLogRecData rdata[2]; xl_multixact_create xlrec; @@ -641,15 +640,15 @@ CreateMultiXactId(int nxids, TransactionId *xids) /* * Make an XLOG entry describing the new MXID. * - * Note: we need not flush this XLOG entry to disk before proceeding. - * The only way for the MXID to be referenced from any data page is - * for heap_lock_tuple() to have put it there, and heap_lock_tuple() - * generates an XLOG record that must follow ours. The normal LSN - * interlock between the data page and that XLOG record will ensure - * that our XLOG record reaches disk first. If the SLRU members/offsets - * data reaches disk sooner than the XLOG record, we do not care because - * we'll overwrite it with zeroes unless the XLOG record is there too; - * see notes at top of this file. + * Note: we need not flush this XLOG entry to disk before proceeding. The + * only way for the MXID to be referenced from any data page is for + * heap_lock_tuple() to have put it there, and heap_lock_tuple() generates + * an XLOG record that must follow ours. The normal LSN interlock between + * the data page and that XLOG record will ensure that our XLOG record + * reaches disk first. If the SLRU members/offsets data reaches disk + * sooner than the XLOG record, we do not care because we'll overwrite it + * with zeroes unless the XLOG record is there too; see notes at top of + * this file. */ xlrec.mid = multi; xlrec.moff = offset; @@ -702,9 +701,9 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset, /* * Note: we pass the MultiXactId to SimpleLruReadPage as the "transaction" * to complain about if there's any I/O error. This is kinda bogus, but - * since the errors will always give the full pathname, it should be - * clear enough that a MultiXactId is really involved. Perhaps someday - * we'll take the trouble to generalize the slru.c error reporting code. + * since the errors will always give the full pathname, it should be clear + * enough that a MultiXactId is really involved. Perhaps someday we'll + * take the trouble to generalize the slru.c error reporting code. */ slotno = SimpleLruReadPage(MultiXactOffsetCtl, pageno, multi); offptr = (MultiXactOffset *) MultiXactOffsetCtl->shared->page_buffer[slotno]; @@ -750,7 +749,7 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset, * GetNewMultiXactId * Get the next MultiXactId. * - * Also, reserve the needed amount of space in the "members" area. The + * Also, reserve the needed amount of space in the "members" area. The * starting offset of the reserved space is returned in *offset. * * This may generate XLOG records for expansion of the offsets and/or members @@ -761,7 +760,7 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset, static MultiXactId GetNewMultiXactId(int nxids, MultiXactOffset *offset) { - MultiXactId result; + MultiXactId result; debug_elog3(DEBUG2, "GetNew: for %d xids", nxids); @@ -785,8 +784,8 @@ GetNewMultiXactId(int nxids, MultiXactOffset *offset) * Advance counter. As in GetNewTransactionId(), this must not happen * until after ExtendMultiXactOffset has succeeded! * - * We don't care about MultiXactId wraparound here; it will be handled by - * the next iteration. But note that nextMXact may be InvalidMultiXactId + * We don't care about MultiXactId wraparound here; it will be handled by the + * next iteration. But note that nextMXact may be InvalidMultiXactId * after this routine exits, so anyone else looking at the variable must * be prepared to deal with that. */ @@ -809,7 +808,7 @@ GetNewMultiXactId(int nxids, MultiXactOffset *offset) /* * GetMultiXactIdMembers - * Returns the set of TransactionIds that make up a MultiXactId + * Returns the set of TransactionIds that make up a MultiXactId * * We return -1 if the MultiXactId is too old to possibly have any members * still running; in that case we have not actually looked them up, and @@ -822,13 +821,13 @@ GetMultiXactIdMembers(MultiXactId multi, TransactionId **xids) int prev_pageno; int entryno; int slotno; - MultiXactOffset *offptr; - MultiXactOffset offset; + MultiXactOffset *offptr; + MultiXactOffset offset; int length; int i; - MultiXactId nextMXact; - MultiXactId tmpMXact; - MultiXactOffset nextOffset; + MultiXactId nextMXact; + MultiXactId tmpMXact; + MultiXactOffset nextOffset; TransactionId *ptr; debug_elog3(DEBUG2, "GetMembers: asked for %u", multi); @@ -850,13 +849,13 @@ GetMultiXactIdMembers(MultiXactId multi, TransactionId **xids) /* * We check known limits on MultiXact before resorting to the SLRU area. * - * An ID older than our OldestVisibleMXactId[] entry can't possibly still - * be running, and we'd run the risk of trying to read already-truncated - * SLRU data if we did try to examine it. + * An ID older than our OldestVisibleMXactId[] entry can't possibly still be + * running, and we'd run the risk of trying to read already-truncated SLRU + * data if we did try to examine it. * - * Conversely, an ID >= nextMXact shouldn't ever be seen here; if it is - * seen, it implies undetected ID wraparound has occurred. We just - * silently assume that such an ID is no longer running. + * Conversely, an ID >= nextMXact shouldn't ever be seen here; if it is seen, + * it implies undetected ID wraparound has occurred. We just silently + * assume that such an ID is no longer running. * * Shared lock is enough here since we aren't modifying any global state. * Also, we can examine our own OldestVisibleMXactId without the lock, @@ -880,9 +879,9 @@ GetMultiXactIdMembers(MultiXactId multi, TransactionId **xids) } /* - * Before releasing the lock, save the current counter values, because - * the target MultiXactId may be just one less than nextMXact. We will - * need to use nextOffset as the endpoint if so. + * Before releasing the lock, save the current counter values, because the + * target MultiXactId may be just one less than nextMXact. We will need + * to use nextOffset as the endpoint if so. */ nextMXact = MultiXactState->nextMXact; nextOffset = MultiXactState->nextOffset; @@ -902,11 +901,11 @@ GetMultiXactIdMembers(MultiXactId multi, TransactionId **xids) /* * How many members do we need to read? If we are at the end of the - * assigned MultiXactIds, use the offset just saved above. Else we - * need to check the MultiXactId following ours. + * assigned MultiXactIds, use the offset just saved above. Else we need + * to check the MultiXactId following ours. * - * Use the same increment rule as GetNewMultiXactId(), that is, don't - * handle wraparound explicitly until needed. + * Use the same increment rule as GetNewMultiXactId(), that is, don't handle + * wraparound explicitly until needed. */ tmpMXact = multi + 1; @@ -974,9 +973,9 @@ GetMultiXactIdMembers(MultiXactId multi, TransactionId **xids) /* * mXactCacheGetBySet - * returns a MultiXactId from the cache based on the set of - * TransactionIds that compose it, or InvalidMultiXactId if - * none matches. + * returns a MultiXactId from the cache based on the set of + * TransactionIds that compose it, or InvalidMultiXactId if + * none matches. * * This is helpful, for example, if two transactions want to lock a huge * table. By using the cache, the second will use the same MultiXactId @@ -988,7 +987,7 @@ GetMultiXactIdMembers(MultiXactId multi, TransactionId **xids) static MultiXactId mXactCacheGetBySet(int nxids, TransactionId *xids) { - mXactCacheEnt *entry; + mXactCacheEnt *entry; debug_elog3(DEBUG2, "CacheGet: looking for %s", mxid_to_string(InvalidMultiXactId, nxids, xids)); @@ -1015,8 +1014,8 @@ mXactCacheGetBySet(int nxids, TransactionId *xids) /* * mXactCacheGetById - * returns the composing TransactionId set from the cache for a - * given MultiXactId, if present. + * returns the composing TransactionId set from the cache for a + * given MultiXactId, if present. * * If successful, *xids is set to the address of a palloc'd copy of the * TransactionId set. Return value is number of members, or -1 on failure. @@ -1024,7 +1023,7 @@ mXactCacheGetBySet(int nxids, TransactionId *xids) static int mXactCacheGetById(MultiXactId multi, TransactionId **xids) { - mXactCacheEnt *entry; + mXactCacheEnt *entry; debug_elog3(DEBUG2, "CacheGet: looking for %u", multi); @@ -1032,7 +1031,7 @@ mXactCacheGetById(MultiXactId multi, TransactionId **xids) { if (entry->multi == multi) { - TransactionId *ptr; + TransactionId *ptr; Size size; size = sizeof(TransactionId) * entry->nxids; @@ -1042,7 +1041,7 @@ mXactCacheGetById(MultiXactId multi, TransactionId **xids) memcpy(ptr, entry->xids, size); debug_elog3(DEBUG2, "CacheGet: found %s", - mxid_to_string(multi, entry->nxids, entry->xids)); + mxid_to_string(multi, entry->nxids, entry->xids)); return entry->nxids; } } @@ -1053,12 +1052,12 @@ mXactCacheGetById(MultiXactId multi, TransactionId **xids) /* * mXactCachePut - * Add a new MultiXactId and its composing set into the local cache. + * Add a new MultiXactId and its composing set into the local cache. */ static void mXactCachePut(MultiXactId multi, int nxids, TransactionId *xids) { - mXactCacheEnt *entry; + mXactCacheEnt *entry; debug_elog3(DEBUG2, "CachePut: storing %s", mxid_to_string(multi, nxids, xids)); @@ -1092,7 +1091,7 @@ mXactCachePut(MultiXactId multi, int nxids, TransactionId *xids) /* * xidComparator - * qsort comparison function for XIDs + * qsort comparison function for XIDs * * We don't need to use wraparound comparison for XIDs, and indeed must * not do so since that does not respect the triangle inequality! Any @@ -1101,8 +1100,8 @@ mXactCachePut(MultiXactId multi, int nxids, TransactionId *xids) static int xidComparator(const void *arg1, const void *arg2) { - TransactionId xid1 = * (const TransactionId *) arg1; - TransactionId xid2 = * (const TransactionId *) arg2; + TransactionId xid1 = *(const TransactionId *) arg1; + TransactionId xid2 = *(const TransactionId *) arg2; if (xid1 > xid2) return 1; @@ -1115,8 +1114,9 @@ xidComparator(const void *arg1, const void *arg2) static char * mxid_to_string(MultiXactId multi, int nxids, TransactionId *xids) { - char *str = palloc(15 * (nxids + 1) + 4); - int i; + char *str = palloc(15 * (nxids + 1) + 4); + int i; + snprintf(str, 47, "%u %d[%u", multi, nxids, xids[0]); for (i = 1; i < nxids; i++) @@ -1137,18 +1137,18 @@ void AtEOXact_MultiXact(void) { /* - * Reset our OldestMemberMXactId and OldestVisibleMXactId values, - * both of which should only be valid while within a transaction. + * Reset our OldestMemberMXactId and OldestVisibleMXactId values, both of + * which should only be valid while within a transaction. * - * We assume that storing a MultiXactId is atomic and so we need - * not take MultiXactGenLock to do this. + * We assume that storing a MultiXactId is atomic and so we need not take + * MultiXactGenLock to do this. */ OldestMemberMXactId[MyBackendId] = InvalidMultiXactId; OldestVisibleMXactId[MyBackendId] = InvalidMultiXactId; /* - * Discard the local MultiXactId cache. Since MXactContext was created - * as a child of TopTransactionContext, we needn't delete it explicitly. + * Discard the local MultiXactId cache. Since MXactContext was created as + * a child of TopTransactionContext, we needn't delete it explicitly. */ MXactContext = NULL; MXactCache = NULL; @@ -1156,7 +1156,7 @@ AtEOXact_MultiXact(void) /* * Initialization of shared memory for MultiXact. We use two SLRU areas, - * thus double memory. Also, reserve space for the shared MultiXactState + * thus double memory. Also, reserve space for the shared MultiXactState * struct and the per-backend MultiXactId arrays (two of those, too). */ Size @@ -1178,7 +1178,7 @@ MultiXactShmemSize(void) void MultiXactShmemInit(void) { - bool found; + bool found; debug_elog2(DEBUG2, "Shared Memory Init for MultiXact"); @@ -1205,8 +1205,8 @@ MultiXactShmemInit(void) Assert(found); /* - * Set up array pointers. Note that perBackendXactIds[0] is wasted - * space since we only use indexes 1..MaxBackends in each array. + * Set up array pointers. Note that perBackendXactIds[0] is wasted space + * since we only use indexes 1..MaxBackends in each array. */ OldestMemberMXactId = MultiXactState->perBackendXactIds; OldestVisibleMXactId = OldestMemberMXactId + MaxBackends; @@ -1214,7 +1214,7 @@ MultiXactShmemInit(void) /* * This func must be called ONCE on system install. It creates the initial - * MultiXact segments. (The MultiXacts directories are assumed to have been + * MultiXact segments. (The MultiXacts directories are assumed to have been * created by initdb, and MultiXactShmemInit must have been called already.) */ void @@ -1287,7 +1287,7 @@ ZeroMultiXactMemberPage(int pageno, bool writeXlog) * This must be called ONCE during postmaster or standalone-backend startup. * * StartupXLOG has already established nextMXact/nextOffset by calling - * MultiXactSetNextMXact and/or MultiXactAdvanceNextMXact. Note that we + * MultiXactSetNextMXact and/or MultiXactAdvanceNextMXact. Note that we * may already have replayed WAL data into the SLRU files. * * We don't need any locks here, really; the SLRU locks are taken @@ -1311,14 +1311,14 @@ StartupMultiXact(void) MultiXactOffsetCtl->shared->latest_page_number = pageno; /* - * Zero out the remainder of the current offsets page. See notes - * in StartupCLOG() for motivation. + * Zero out the remainder of the current offsets page. See notes in + * StartupCLOG() for motivation. */ entryno = MultiXactIdToOffsetEntry(multi); if (entryno != 0) { int slotno; - MultiXactOffset *offptr; + MultiXactOffset *offptr; slotno = SimpleLruReadPage(MultiXactOffsetCtl, pageno, multi); offptr = (MultiXactOffset *) MultiXactOffsetCtl->shared->page_buffer[slotno]; @@ -1341,14 +1341,14 @@ StartupMultiXact(void) MultiXactMemberCtl->shared->latest_page_number = pageno; /* - * Zero out the remainder of the current members page. See notes - * in StartupCLOG() for motivation. + * Zero out the remainder of the current members page. See notes in + * StartupCLOG() for motivation. */ entryno = MXOffsetToMemberEntry(offset); if (entryno != 0) { int slotno; - TransactionId *xidptr; + TransactionId *xidptr; slotno = SimpleLruReadPage(MultiXactMemberCtl, pageno, offset); xidptr = (TransactionId *) MultiXactMemberCtl->shared->page_buffer[slotno]; @@ -1499,14 +1499,14 @@ static void ExtendMultiXactMember(MultiXactOffset offset, int nmembers) { /* - * It's possible that the members span more than one page of the - * members file, so we loop to ensure we consider each page. The - * coding is not optimal if the members span several pages, but - * that seems unusual enough to not worry much about. + * It's possible that the members span more than one page of the members + * file, so we loop to ensure we consider each page. The coding is not + * optimal if the members span several pages, but that seems unusual + * enough to not worry much about. */ while (nmembers > 0) { - int entryno; + int entryno; /* * Only zero when at first entry of a page. @@ -1514,7 +1514,7 @@ ExtendMultiXactMember(MultiXactOffset offset, int nmembers) entryno = MXOffsetToMemberEntry(offset); if (entryno == 0) { - int pageno; + int pageno; pageno = MXOffsetToMemberPage(offset); @@ -1536,7 +1536,7 @@ ExtendMultiXactMember(MultiXactOffset offset, int nmembers) * Remove all MultiXactOffset and MultiXactMember segments before the oldest * ones still of interest. * - * This is called only during checkpoints. We assume no more than one + * This is called only during checkpoints. We assume no more than one * backend does this at a time. * * XXX do we have any issues with needing to checkpoint here? @@ -1545,23 +1545,23 @@ static void TruncateMultiXact(void) { MultiXactId nextMXact; - MultiXactOffset nextOffset; + MultiXactOffset nextOffset; MultiXactId oldestMXact; - MultiXactOffset oldestOffset; + MultiXactOffset oldestOffset; int cutoffPage; int i; /* - * First, compute where we can safely truncate. Per notes above, - * this is the oldest valid value among all the OldestMemberMXactId[] and + * First, compute where we can safely truncate. Per notes above, this is + * the oldest valid value among all the OldestMemberMXactId[] and * OldestVisibleMXactId[] entries, or nextMXact if none are valid. */ LWLockAcquire(MultiXactGenLock, LW_SHARED); /* * We have to beware of the possibility that nextMXact is in the - * wrapped-around state. We don't fix the counter itself here, - * but we must be sure to use a valid value in our calculation. + * wrapped-around state. We don't fix the counter itself here, but we + * must be sure to use a valid value in our calculation. */ nextMXact = MultiXactState->nextMXact; if (nextMXact < FirstMultiXactId) @@ -1597,9 +1597,9 @@ TruncateMultiXact(void) return; /* - * We need to determine where to truncate MultiXactMember. If we - * found a valid oldest MultiXactId, read its starting offset; - * otherwise we use the nextOffset value we saved above. + * We need to determine where to truncate MultiXactMember. If we found a + * valid oldest MultiXactId, read its starting offset; otherwise we use + * the nextOffset value we saved above. */ if (oldestMXact == nextMXact) oldestOffset = nextOffset; @@ -1608,7 +1608,7 @@ TruncateMultiXact(void) int pageno; int slotno; int entryno; - MultiXactOffset *offptr; + MultiXactOffset *offptr; LWLockAcquire(MultiXactOffsetControlLock, LW_EXCLUSIVE); @@ -1624,8 +1624,8 @@ TruncateMultiXact(void) } /* - * The cutoff point is the start of the segment containing oldestMXact. - * We pass the *page* containing oldestMXact to SimpleLruTruncate. + * The cutoff point is the start of the segment containing oldestMXact. We + * pass the *page* containing oldestMXact to SimpleLruTruncate. */ cutoffPage = MultiXactIdToOffsetPage(oldestMXact); @@ -1677,8 +1677,8 @@ MultiXactOffsetPagePrecedes(int page1, int page2) static bool MultiXactMemberPagePrecedes(int page1, int page2) { - MultiXactOffset offset1; - MultiXactOffset offset2; + MultiXactOffset offset1; + MultiXactOffset offset2; offset1 = ((MultiXactOffset) page1) * MULTIXACT_MEMBERS_PER_PAGE; offset2 = ((MultiXactOffset) page2) * MULTIXACT_MEMBERS_PER_PAGE; @@ -1695,7 +1695,7 @@ MultiXactMemberPagePrecedes(int page1, int page2) static bool MultiXactIdPrecedes(MultiXactId multi1, MultiXactId multi2) { - int32 diff = (int32) (multi1 - multi2); + int32 diff = (int32) (multi1 - multi2); return (diff < 0); } @@ -1706,7 +1706,7 @@ MultiXactIdPrecedes(MultiXactId multi1, MultiXactId multi2) static bool MultiXactOffsetPrecedes(MultiXactOffset offset1, MultiXactOffset offset2) { - int32 diff = (int32) (offset1 - offset2); + int32 diff = (int32) (offset1 - offset2); return (diff < 0); } @@ -1783,9 +1783,9 @@ multixact_redo(XLogRecPtr lsn, XLogRecord *record) MultiXactAdvanceNextMXact(xlrec->mid + 1, xlrec->moff + xlrec->nxids); /* - * Make sure nextXid is beyond any XID mentioned in the record. - * This should be unnecessary, since any XID found here ought to - * have other evidence in the XLOG, but let's be safe. + * Make sure nextXid is beyond any XID mentioned in the record. This + * should be unnecessary, since any XID found here ought to have other + * evidence in the XLOG, but let's be safe. */ max_xid = record->xl_xid; for (i = 0; i < xlrec->nxids; i++) diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c index 67d9d3f54f..5891890b76 100644 --- a/src/backend/access/transam/slru.c +++ b/src/backend/access/transam/slru.c @@ -48,7 +48,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/access/transam/slru.c,v 1.27 2005/08/20 23:26:08 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/transam/slru.c,v 1.28 2005/10/15 02:49:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -186,8 +186,8 @@ SimpleLruInit(SlruCtl ctl, const char *name, Assert(found); /* - * Initialize the unshared control struct, including directory path. - * We assume caller set PagePrecedes. + * Initialize the unshared control struct, including directory path. We + * assume caller set PagePrecedes. */ ctl->shared = shared; ctl->do_fsync = true; /* default behavior */ @@ -351,11 +351,11 @@ SimpleLruWritePage(SlruCtl ctl, int slotno, SlruFlush fdata) LWLockAcquire(shared->buffer_locks[slotno], LW_EXCLUSIVE); /* - * Check to see if someone else already did the write, or took the - * buffer away from us. If so, do nothing. NOTE: we really should - * never see WRITE_IN_PROGRESS here, since that state should only - * occur while the writer is holding the buffer lock. But accept it - * so that we have a recovery path if a writer aborts. + * Check to see if someone else already did the write, or took the buffer + * away from us. If so, do nothing. NOTE: we really should never see + * WRITE_IN_PROGRESS here, since that state should only occur while the + * writer is holding the buffer lock. But accept it so that we have a + * recovery path if a writer aborts. */ if (shared->page_number[slotno] != pageno || (shared->page_status[slotno] != SLRU_PAGE_DIRTY && @@ -368,15 +368,14 @@ SimpleLruWritePage(SlruCtl ctl, int slotno, SlruFlush fdata) /* * Mark the slot write-busy. After this point, a transaction status - * update on this page will mark it dirty again. NB: we are assuming - * that read/write of the page status field is atomic, since we change - * the state while not holding control lock. However, we cannot set - * this state any sooner, or we'd possibly fool a previous writer into - * thinking he's successfully dumped the page when he hasn't. - * (Scenario: other writer starts, page is redirtied, we come along - * and set WRITE_IN_PROGRESS again, other writer completes and sets - * CLEAN because redirty info has been lost, then we think it's clean - * too.) + * update on this page will mark it dirty again. NB: we are assuming that + * read/write of the page status field is atomic, since we change the + * state while not holding control lock. However, we cannot set this + * state any sooner, or we'd possibly fool a previous writer into thinking + * he's successfully dumped the page when he hasn't. (Scenario: other + * writer starts, page is redirtied, we come along and set + * WRITE_IN_PROGRESS again, other writer completes and sets CLEAN because + * redirty info has been lost, then we think it's clean too.) */ shared->page_status[slotno] = SLRU_PAGE_WRITE_IN_PROGRESS; @@ -436,8 +435,8 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno) * In a crash-and-restart situation, it's possible for us to receive * commands to set the commit status of transactions whose bits are in * already-truncated segments of the commit log (see notes in - * SlruPhysicalWritePage). Hence, if we are InRecovery, allow the - * case where the file doesn't exist, and return zeroes instead. + * SlruPhysicalWritePage). Hence, if we are InRecovery, allow the case + * where the file doesn't exist, and return zeroes instead. */ fd = BasicOpenFile(path, O_RDWR | PG_BINARY, S_IRUSR | S_IWUSR); if (fd < 0) @@ -528,17 +527,16 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruFlush fdata) { /* * If the file doesn't already exist, we should create it. It is - * possible for this to need to happen when writing a page that's - * not first in its segment; we assume the OS can cope with that. - * (Note: it might seem that it'd be okay to create files only - * when SimpleLruZeroPage is called for the first page of a - * segment. However, if after a crash and restart the REDO logic - * elects to replay the log from a checkpoint before the latest - * one, then it's possible that we will get commands to set - * transaction status of transactions that have already been - * truncated from the commit log. Easiest way to deal with that is - * to accept references to nonexistent files here and in - * SlruPhysicalReadPage.) + * possible for this to need to happen when writing a page that's not + * first in its segment; we assume the OS can cope with that. (Note: + * it might seem that it'd be okay to create files only when + * SimpleLruZeroPage is called for the first page of a segment. + * However, if after a crash and restart the REDO logic elects to + * replay the log from a checkpoint before the latest one, then it's + * possible that we will get commands to set transaction status of + * transactions that have already been truncated from the commit log. + * Easiest way to deal with that is to accept references to + * nonexistent files here and in SlruPhysicalReadPage.) */ SlruFileName(ctl, path, segno); fd = BasicOpenFile(path, O_RDWR | PG_BINARY, S_IRUSR | S_IWUSR); @@ -635,49 +633,49 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid) case SLRU_OPEN_FAILED: ereport(ERROR, (errcode_for_file_access(), - errmsg("could not access status of transaction %u", xid), + errmsg("could not access status of transaction %u", xid), errdetail("could not open file \"%s\": %m", path))); break; case SLRU_CREATE_FAILED: ereport(ERROR, (errcode_for_file_access(), - errmsg("could not access status of transaction %u", xid), + errmsg("could not access status of transaction %u", xid), errdetail("could not create file \"%s\": %m", path))); break; case SLRU_SEEK_FAILED: ereport(ERROR, (errcode_for_file_access(), - errmsg("could not access status of transaction %u", xid), - errdetail("could not seek in file \"%s\" to offset %u: %m", - path, offset))); + errmsg("could not access status of transaction %u", xid), + errdetail("could not seek in file \"%s\" to offset %u: %m", + path, offset))); break; case SLRU_READ_FAILED: ereport(ERROR, (errcode_for_file_access(), - errmsg("could not access status of transaction %u", xid), - errdetail("could not read from file \"%s\" at offset %u: %m", - path, offset))); + errmsg("could not access status of transaction %u", xid), + errdetail("could not read from file \"%s\" at offset %u: %m", + path, offset))); break; case SLRU_WRITE_FAILED: ereport(ERROR, (errcode_for_file_access(), - errmsg("could not access status of transaction %u", xid), - errdetail("could not write to file \"%s\" at offset %u: %m", - path, offset))); + errmsg("could not access status of transaction %u", xid), + errdetail("could not write to file \"%s\" at offset %u: %m", + path, offset))); break; case SLRU_FSYNC_FAILED: ereport(ERROR, (errcode_for_file_access(), - errmsg("could not access status of transaction %u", xid), + errmsg("could not access status of transaction %u", xid), errdetail("could not fsync file \"%s\": %m", path))); break; case SLRU_CLOSE_FAILED: ereport(ERROR, (errcode_for_file_access(), - errmsg("could not access status of transaction %u", xid), + errmsg("could not access status of transaction %u", xid), errdetail("could not close file \"%s\": %m", path))); break; @@ -723,8 +721,8 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno) } /* - * If we find any EMPTY slot, just select that one. Else locate - * the least-recently-used slot that isn't the latest page. + * If we find any EMPTY slot, just select that one. Else locate the + * least-recently-used slot that isn't the latest page. */ for (slotno = 0; slotno < NUM_SLRU_BUFFERS; slotno++) { @@ -745,10 +743,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno) return bestslot; /* - * We need to do I/O. Normal case is that we have to write it - * out, but it's possible in the worst case to have selected a - * read-busy page. In that case we use SimpleLruReadPage to wait - * for the read to complete. + * We need to do I/O. Normal case is that we have to write it out, + * but it's possible in the worst case to have selected a read-busy + * page. In that case we use SimpleLruReadPage to wait for the read + * to complete. */ if (shared->page_status[bestslot] == SLRU_PAGE_READ_IN_PROGRESS) (void) SimpleLruReadPage(ctl, shared->page_number[bestslot], @@ -757,9 +755,9 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno) SimpleLruWritePage(ctl, bestslot, NULL); /* - * Now loop back and try again. This is the easiest way of - * dealing with corner cases such as the victim page being - * re-dirtied while we wrote it. + * Now loop back and try again. This is the easiest way of dealing + * with corner cases such as the victim page being re-dirtied while we + * wrote it. */ } } @@ -789,9 +787,9 @@ SimpleLruFlush(SlruCtl ctl, bool checkpoint) SimpleLruWritePage(ctl, slotno, &fdata); /* - * When called during a checkpoint, we cannot assert that the slot - * is clean now, since another process might have re-dirtied it - * already. That's okay. + * When called during a checkpoint, we cannot assert that the slot is + * clean now, since another process might have re-dirtied it already. + * That's okay. */ Assert(checkpoint || shared->page_status[slotno] == SLRU_PAGE_EMPTY || @@ -841,10 +839,10 @@ SimpleLruTruncate(SlruCtl ctl, int cutoffPage) cutoffPage -= cutoffPage % SLRU_PAGES_PER_SEGMENT; /* - * Scan shared memory and remove any pages preceding the cutoff page, - * to ensure we won't rewrite them later. (Since this is normally - * called in or just after a checkpoint, any dirty pages should have - * been flushed already ... we're just being extra careful here.) + * Scan shared memory and remove any pages preceding the cutoff page, to + * ensure we won't rewrite them later. (Since this is normally called in + * or just after a checkpoint, any dirty pages should have been flushed + * already ... we're just being extra careful here.) */ LWLockAcquire(shared->ControlLock, LW_EXCLUSIVE); @@ -852,16 +850,16 @@ restart:; /* * While we are holding the lock, make an important safety check: the - * planned cutoff point must be <= the current endpoint page. - * Otherwise we have already wrapped around, and proceeding with the - * truncation would risk removing the current segment. + * planned cutoff point must be <= the current endpoint page. Otherwise we + * have already wrapped around, and proceeding with the truncation would + * risk removing the current segment. */ if (ctl->PagePrecedes(shared->latest_page_number, cutoffPage)) { LWLockRelease(shared->ControlLock); ereport(LOG, - (errmsg("could not truncate directory \"%s\": apparent wraparound", - ctl->Dir))); + (errmsg("could not truncate directory \"%s\": apparent wraparound", + ctl->Dir))); return; } @@ -882,9 +880,9 @@ restart:; } /* - * Hmm, we have (or may have) I/O operations acting on the page, - * so we've got to wait for them to finish and then start again. - * This is the same logic as in SlruSelectLRUPage. + * Hmm, we have (or may have) I/O operations acting on the page, so + * we've got to wait for them to finish and then start again. This is + * the same logic as in SlruSelectLRUPage. */ if (shared->page_status[slotno] == SLRU_PAGE_READ_IN_PROGRESS) (void) SimpleLruReadPage(ctl, shared->page_number[slotno], diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c index 9b45035036..7671eb6a45 100644 --- a/src/backend/access/transam/subtrans.c +++ b/src/backend/access/transam/subtrans.c @@ -22,7 +22,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/access/transam/subtrans.c,v 1.10 2005/08/20 23:26:08 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/transam/subtrans.c,v 1.11 2005/10/15 02:49:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -234,9 +234,8 @@ StartupSUBTRANS(TransactionId oldestActiveXID) /* * Since we don't expect pg_subtrans to be valid across crashes, we * initialize the currently-active page(s) to zeroes during startup. - * Whenever we advance into a new page, ExtendSUBTRANS will likewise - * zero the new page without regard to whatever was previously on - * disk. + * Whenever we advance into a new page, ExtendSUBTRANS will likewise zero + * the new page without regard to whatever was previously on disk. */ LWLockAcquire(SubtransControlLock, LW_EXCLUSIVE); @@ -262,8 +261,8 @@ ShutdownSUBTRANS(void) /* * Flush dirty SUBTRANS pages to disk * - * This is not actually necessary from a correctness point of view. We do - * it merely as a debugging aid. + * This is not actually necessary from a correctness point of view. We do it + * merely as a debugging aid. */ SimpleLruFlush(SubTransCtl, false); } @@ -277,9 +276,9 @@ CheckPointSUBTRANS(void) /* * Flush dirty SUBTRANS pages to disk * - * This is not actually necessary from a correctness point of view. We do - * it merely to improve the odds that writing of dirty pages is done - * by the checkpoint process and not by backends. + * This is not actually necessary from a correctness point of view. We do it + * merely to improve the odds that writing of dirty pages is done by the + * checkpoint process and not by backends. */ SimpleLruFlush(SubTransCtl, true); } @@ -329,8 +328,8 @@ TruncateSUBTRANS(TransactionId oldestXact) int cutoffPage; /* - * The cutoff point is the start of the segment containing oldestXact. - * We pass the *page* containing oldestXact to SimpleLruTruncate. + * The cutoff point is the start of the segment containing oldestXact. We + * pass the *page* containing oldestXact to SimpleLruTruncate. */ cutoffPage = TransactionIdToPage(oldestXact); diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c index 5fa6f82daf..5985252052 100644 --- a/src/backend/access/transam/transam.c +++ b/src/backend/access/transam/transam.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/transam/transam.c,v 1.65 2005/06/17 22:32:42 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/transam/transam.c,v 1.66 2005/10/15 02:49:09 momjian Exp $ * * NOTES * This file contains the high level access-method interface to the @@ -54,8 +54,8 @@ TransactionLogFetch(TransactionId transactionId) XidStatus xidstatus; /* - * Before going to the commit log manager, check our single item cache - * to see if we didn't just check the transaction status a moment ago. + * Before going to the commit log manager, check our single item cache to + * see if we didn't just check the transaction status a moment ago. */ if (TransactionIdEquals(transactionId, cachedFetchXid)) return cachedFetchXidStatus; @@ -78,8 +78,8 @@ TransactionLogFetch(TransactionId transactionId) xidstatus = TransactionIdGetStatus(transactionId); /* - * DO NOT cache status for unfinished or sub-committed transactions! - * We only cache status that is guaranteed not to change. + * DO NOT cache status for unfinished or sub-committed transactions! We + * only cache status that is guaranteed not to change. */ if (xidstatus != TRANSACTION_STATUS_IN_PROGRESS && xidstatus != TRANSACTION_STATUS_SUB_COMMITTED) @@ -169,18 +169,18 @@ TransactionIdDidCommit(TransactionId transactionId) return true; /* - * If it's marked subcommitted, we have to check the parent - * recursively. However, if it's older than TransactionXmin, we can't - * look at pg_subtrans; instead assume that the parent crashed without - * cleaning up its children. + * If it's marked subcommitted, we have to check the parent recursively. + * However, if it's older than TransactionXmin, we can't look at + * pg_subtrans; instead assume that the parent crashed without cleaning up + * its children. * - * Originally we Assert'ed that the result of SubTransGetParent was - * not zero. However with the introduction of prepared transactions, - * there can be a window just after database startup where we do not - * have complete knowledge in pg_subtrans of the transactions after - * TransactionXmin. StartupSUBTRANS() has ensured that any missing - * information will be zeroed. Since this case should not happen under - * normal conditions, it seems reasonable to emit a WARNING for it. + * Originally we Assert'ed that the result of SubTransGetParent was not zero. + * However with the introduction of prepared transactions, there can be a + * window just after database startup where we do not have complete + * knowledge in pg_subtrans of the transactions after TransactionXmin. + * StartupSUBTRANS() has ensured that any missing information will be + * zeroed. Since this case should not happen under normal conditions, it + * seems reasonable to emit a WARNING for it. */ if (xidstatus == TRANSACTION_STATUS_SUB_COMMITTED) { @@ -225,10 +225,10 @@ TransactionIdDidAbort(TransactionId transactionId) return true; /* - * If it's marked subcommitted, we have to check the parent - * recursively. However, if it's older than TransactionXmin, we can't - * look at pg_subtrans; instead assume that the parent crashed without - * cleaning up its children. + * If it's marked subcommitted, we have to check the parent recursively. + * However, if it's older than TransactionXmin, we can't look at + * pg_subtrans; instead assume that the parent crashed without cleaning up + * its children. */ if (xidstatus == TRANSACTION_STATUS_SUB_COMMITTED) { diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c index 05590da14e..0ece348e18 100644 --- a/src/backend/access/transam/twophase.c +++ b/src/backend/access/transam/twophase.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/transam/twophase.c,v 1.14 2005/10/13 22:55:55 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/transam/twophase.c,v 1.15 2005/10/15 02:49:09 momjian Exp $ * * NOTES * Each global transaction is associated with a global transaction @@ -64,7 +64,7 @@ #define TWOPHASE_DIR "pg_twophase" /* GUC variable, can't be changed after startup */ -int max_prepared_xacts = 5; +int max_prepared_xacts = 5; /* * This struct describes one global transaction that is in prepared state @@ -97,7 +97,7 @@ int max_prepared_xacts = 5; * entry will remain in prepXacts until recycled. We can detect recyclable * entries by checking for valid = false and locking_xid no longer active. * - * typedef struct GlobalTransactionData *GlobalTransaction appears in + * typedef struct GlobalTransactionData *GlobalTransaction appears in * twophase.h */ #define GIDSIZE 200 @@ -105,12 +105,12 @@ int max_prepared_xacts = 5; typedef struct GlobalTransactionData { PGPROC proc; /* dummy proc */ - TimestampTz prepared_at; /* time of preparation */ + TimestampTz prepared_at; /* time of preparation */ XLogRecPtr prepare_lsn; /* XLOG offset of prepare record */ Oid owner; /* ID of user that executed the xact */ TransactionId locking_xid; /* top-level XID of backend working on xact */ bool valid; /* TRUE if fully prepared */ - char gid[GIDSIZE]; /* The GID assigned to the prepared xact */ + char gid[GIDSIZE]; /* The GID assigned to the prepared xact */ } GlobalTransactionData; /* @@ -123,30 +123,30 @@ typedef struct TwoPhaseStateData SHMEM_OFFSET freeGXacts; /* Number of valid prepXacts entries. */ - int numPrepXacts; + int numPrepXacts; /* * There are max_prepared_xacts items in this array, but C wants a * fixed-size array. */ - GlobalTransaction prepXacts[1]; /* VARIABLE LENGTH ARRAY */ + GlobalTransaction prepXacts[1]; /* VARIABLE LENGTH ARRAY */ } TwoPhaseStateData; /* VARIABLE LENGTH STRUCT */ static TwoPhaseStateData *TwoPhaseState; static void RecordTransactionCommitPrepared(TransactionId xid, - int nchildren, - TransactionId *children, - int nrels, - RelFileNode *rels); + int nchildren, + TransactionId *children, + int nrels, + RelFileNode *rels); static void RecordTransactionAbortPrepared(TransactionId xid, - int nchildren, - TransactionId *children, - int nrels, - RelFileNode *rels); + int nchildren, + TransactionId *children, + int nrels, + RelFileNode *rels); static void ProcessRecords(char *bufptr, TransactionId xid, - const TwoPhaseCallback callbacks[]); + const TwoPhaseCallback callbacks[]); /* @@ -171,7 +171,7 @@ TwoPhaseShmemSize(void) void TwoPhaseShmemInit(void) { - bool found; + bool found; TwoPhaseState = ShmemInitStruct("Prepared Transaction Table", TwoPhaseShmemSize(), @@ -190,7 +190,7 @@ TwoPhaseShmemInit(void) */ gxacts = (GlobalTransaction) ((char *) TwoPhaseState + - MAXALIGN(offsetof(TwoPhaseStateData, prepXacts) + + MAXALIGN(offsetof(TwoPhaseStateData, prepXacts) + sizeof(GlobalTransaction) * max_prepared_xacts)); for (i = 0; i < max_prepared_xacts; i++) { @@ -205,7 +205,7 @@ TwoPhaseShmemInit(void) /* * MarkAsPreparing - * Reserve the GID for the given transaction. + * Reserve the GID for the given transaction. * * Internally, this creates a gxact struct and puts it into the active array. * NOTE: this is also used when reloading a gxact after a crash; so avoid @@ -215,8 +215,8 @@ GlobalTransaction MarkAsPreparing(TransactionId xid, const char *gid, TimestampTz prepared_at, Oid owner, Oid databaseid) { - GlobalTransaction gxact; - int i; + GlobalTransaction gxact; + int i; if (strlen(gid) >= GIDSIZE) ereport(ERROR, @@ -227,10 +227,9 @@ MarkAsPreparing(TransactionId xid, const char *gid, LWLockAcquire(TwoPhaseStateLock, LW_EXCLUSIVE); /* - * First, find and recycle any gxacts that failed during prepare. - * We do this partly to ensure we don't mistakenly say their GIDs - * are still reserved, and partly so we don't fail on out-of-slots - * unnecessarily. + * First, find and recycle any gxacts that failed during prepare. We do + * this partly to ensure we don't mistakenly say their GIDs are still + * reserved, and partly so we don't fail on out-of-slots unnecessarily. */ for (i = 0; i < TwoPhaseState->numPrepXacts; i++) { @@ -360,13 +359,13 @@ MarkAsPrepared(GlobalTransaction gxact) static GlobalTransaction LockGXact(const char *gid, Oid user) { - int i; + int i; LWLockAcquire(TwoPhaseStateLock, LW_EXCLUSIVE); for (i = 0; i < TwoPhaseState->numPrepXacts; i++) { - GlobalTransaction gxact = TwoPhaseState->prepXacts[i]; + GlobalTransaction gxact = TwoPhaseState->prepXacts[i]; /* Ignore not-yet-valid GIDs */ if (!gxact->valid) @@ -380,15 +379,15 @@ LockGXact(const char *gid, Oid user) if (TransactionIdIsActive(gxact->locking_xid)) ereport(ERROR, (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), - errmsg("prepared transaction with identifier \"%s\" is busy", - gid))); + errmsg("prepared transaction with identifier \"%s\" is busy", + gid))); gxact->locking_xid = InvalidTransactionId; } if (user != gxact->owner && !superuser_arg(user)) ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), - errmsg("permission denied to finish prepared transaction"), + errmsg("permission denied to finish prepared transaction"), errhint("Must be superuser or the user that prepared the transaction."))); /* OK for me to lock it */ @@ -403,8 +402,8 @@ LockGXact(const char *gid, Oid user) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), - errmsg("prepared transaction with identifier \"%s\" does not exist", - gid))); + errmsg("prepared transaction with identifier \"%s\" does not exist", + gid))); /* NOTREACHED */ return NULL; @@ -419,7 +418,7 @@ LockGXact(const char *gid, Oid user) static void RemoveGXact(GlobalTransaction gxact) { - int i; + int i; LWLockAcquire(TwoPhaseStateLock, LW_EXCLUSIVE); @@ -449,7 +448,7 @@ RemoveGXact(GlobalTransaction gxact) /* * TransactionIdIsPrepared * True iff transaction associated with the identifier is prepared - * for two-phase commit + * for two-phase commit * * Note: only gxacts marked "valid" are considered; but notice we do not * check the locking status. @@ -459,14 +458,14 @@ RemoveGXact(GlobalTransaction gxact) static bool TransactionIdIsPrepared(TransactionId xid) { - bool result = false; - int i; + bool result = false; + int i; LWLockAcquire(TwoPhaseStateLock, LW_SHARED); for (i = 0; i < TwoPhaseState->numPrepXacts; i++) { - GlobalTransaction gxact = TwoPhaseState->prepXacts[i]; + GlobalTransaction gxact = TwoPhaseState->prepXacts[i]; if (gxact->valid && gxact->proc.xid == xid) { @@ -496,8 +495,8 @@ static int GetPreparedTransactionList(GlobalTransaction *gxacts) { GlobalTransaction array; - int num; - int i; + int num; + int i; LWLockAcquire(TwoPhaseStateLock, LW_SHARED); @@ -526,13 +525,13 @@ GetPreparedTransactionList(GlobalTransaction *gxacts) typedef struct { GlobalTransaction array; - int ngxacts; - int currIdx; + int ngxacts; + int currIdx; } Working_State; /* * pg_prepared_xact - * Produce a view with one row per prepared transaction. + * Produce a view with one row per prepared transaction. * * This function is here so we don't have to export the * GlobalTransactionData struct definition. @@ -552,8 +551,7 @@ pg_prepared_xact(PG_FUNCTION_ARGS) funcctx = SRF_FIRSTCALL_INIT(); /* - * Switch to memory context appropriate for multiple function - * calls + * Switch to memory context appropriate for multiple function calls */ oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); @@ -574,8 +572,8 @@ pg_prepared_xact(PG_FUNCTION_ARGS) funcctx->tuple_desc = BlessTupleDesc(tupdesc); /* - * Collect all the 2PC status information that we will format and - * send out as a result set. + * Collect all the 2PC status information that we will format and send + * out as a result set. */ status = (Working_State *) palloc(sizeof(Working_State)); funcctx->user_fctx = (void *) status; @@ -644,7 +642,7 @@ TwoPhaseGetDummyProc(TransactionId xid) for (i = 0; i < TwoPhaseState->numPrepXacts; i++) { - GlobalTransaction gxact = TwoPhaseState->prepXacts[i]; + GlobalTransaction gxact = TwoPhaseState->prepXacts[i]; if (gxact->proc.xid == xid) { @@ -665,7 +663,7 @@ TwoPhaseGetDummyProc(TransactionId xid) } /************************************************************************/ -/* State file support */ +/* State file support */ /************************************************************************/ #define TwoPhaseFilePath(path, xid) \ @@ -674,14 +672,14 @@ TwoPhaseGetDummyProc(TransactionId xid) /* * 2PC state file format: * - * 1. TwoPhaseFileHeader - * 2. TransactionId[] (subtransactions) + * 1. TwoPhaseFileHeader + * 2. TransactionId[] (subtransactions) * 3. RelFileNode[] (files to be deleted at commit) * 4. RelFileNode[] (files to be deleted at abort) - * 5. TwoPhaseRecordOnDisk - * 6. ... - * 7. TwoPhaseRecordOnDisk (end sentinel, rmid == TWOPHASE_RM_END_ID) - * 8. CRC32 + * 5. TwoPhaseRecordOnDisk + * 6. ... + * 7. TwoPhaseRecordOnDisk (end sentinel, rmid == TWOPHASE_RM_END_ID) + * 8. CRC32 * * Each segment except the final CRC32 is MAXALIGN'd. */ @@ -693,16 +691,16 @@ TwoPhaseGetDummyProc(TransactionId xid) typedef struct TwoPhaseFileHeader { - uint32 magic; /* format identifier */ - uint32 total_len; /* actual file length */ - TransactionId xid; /* original transaction XID */ - Oid database; /* OID of database it was in */ - TimestampTz prepared_at; /* time of preparation */ - Oid owner; /* user running the transaction */ - int32 nsubxacts; /* number of following subxact XIDs */ - int32 ncommitrels; /* number of delete-on-commit rels */ - int32 nabortrels; /* number of delete-on-abort rels */ - char gid[GIDSIZE]; /* GID for transaction */ + uint32 magic; /* format identifier */ + uint32 total_len; /* actual file length */ + TransactionId xid; /* original transaction XID */ + Oid database; /* OID of database it was in */ + TimestampTz prepared_at; /* time of preparation */ + Oid owner; /* user running the transaction */ + int32 nsubxacts; /* number of following subxact XIDs */ + int32 ncommitrels; /* number of delete-on-commit rels */ + int32 nabortrels; /* number of delete-on-abort rels */ + char gid[GIDSIZE]; /* GID for transaction */ } TwoPhaseFileHeader; /* @@ -713,9 +711,9 @@ typedef struct TwoPhaseFileHeader */ typedef struct TwoPhaseRecordOnDisk { - uint32 len; /* length of rmgr data */ - TwoPhaseRmgrId rmid; /* resource manager for this record */ - uint16 info; /* flag bits for use by rmgr */ + uint32 len; /* length of rmgr data */ + TwoPhaseRmgrId rmid; /* resource manager for this record */ + uint16 info; /* flag bits for use by rmgr */ } TwoPhaseRecordOnDisk; /* @@ -728,9 +726,9 @@ static struct xllist { XLogRecData *head; /* first data block in the chain */ XLogRecData *tail; /* last block in chain */ - uint32 bytes_free; /* free bytes left in tail block */ - uint32 total_len; /* total data bytes in chain */ -} records; + uint32 bytes_free; /* free bytes left in tail block */ + uint32 total_len; /* total data bytes in chain */ +} records; /* @@ -744,7 +742,7 @@ static struct xllist static void save_state_data(const void *data, uint32 len) { - uint32 padlen = MAXALIGN(len); + uint32 padlen = MAXALIGN(len); if (padlen > records.bytes_free) { @@ -772,7 +770,7 @@ save_state_data(const void *data, uint32 len) void StartPrepare(GlobalTransaction gxact) { - TransactionId xid = gxact->proc.xid; + TransactionId xid = gxact->proc.xid; TwoPhaseFileHeader hdr; TransactionId *children; RelFileNode *commitrels; @@ -833,13 +831,13 @@ StartPrepare(GlobalTransaction gxact) void EndPrepare(GlobalTransaction gxact) { - TransactionId xid = gxact->proc.xid; + TransactionId xid = gxact->proc.xid; TwoPhaseFileHeader *hdr; - char path[MAXPGPATH]; - XLogRecData *record; - pg_crc32 statefile_crc; - pg_crc32 bogus_crc; - int fd; + char path[MAXPGPATH]; + XLogRecData *record; + pg_crc32 statefile_crc; + pg_crc32 bogus_crc; + int fd; /* Add the end sentinel to the list of 2PC records */ RegisterTwoPhaseRecord(TWOPHASE_RM_END_ID, 0, @@ -853,10 +851,10 @@ EndPrepare(GlobalTransaction gxact) /* * Create the 2PC state file. * - * Note: because we use BasicOpenFile(), we are responsible for ensuring - * the FD gets closed in any error exit path. Once we get into the - * critical section, though, it doesn't matter since any failure causes - * PANIC anyway. + * Note: because we use BasicOpenFile(), we are responsible for ensuring the + * FD gets closed in any error exit path. Once we get into the critical + * section, though, it doesn't matter since any failure causes PANIC + * anyway. */ TwoPhaseFilePath(path, xid); @@ -887,11 +885,10 @@ EndPrepare(GlobalTransaction gxact) FIN_CRC32(statefile_crc); /* - * Write a deliberately bogus CRC to the state file; this is just - * paranoia to catch the case where four more bytes will run us out of - * disk space. + * Write a deliberately bogus CRC to the state file; this is just paranoia + * to catch the case where four more bytes will run us out of disk space. */ - bogus_crc = ~ statefile_crc; + bogus_crc = ~statefile_crc; if ((write(fd, &bogus_crc, sizeof(pg_crc32))) != sizeof(pg_crc32)) { @@ -914,11 +911,11 @@ EndPrepare(GlobalTransaction gxact) * The state file isn't valid yet, because we haven't written the correct * CRC yet. Before we do that, insert entry in WAL and flush it to disk. * - * Between the time we have written the WAL entry and the time we write - * out the correct state file CRC, we have an inconsistency: the xact is - * prepared according to WAL but not according to our on-disk state. - * We use a critical section to force a PANIC if we are unable to complete - * the write --- then, WAL replay should repair the inconsistency. The + * Between the time we have written the WAL entry and the time we write out + * the correct state file CRC, we have an inconsistency: the xact is + * prepared according to WAL but not according to our on-disk state. We + * use a critical section to force a PANIC if we are unable to complete + * the write --- then, WAL replay should repair the inconsistency. The * odds of a PANIC actually occurring should be very tiny given that we * were able to write the bogus CRC above. * @@ -956,16 +953,16 @@ EndPrepare(GlobalTransaction gxact) errmsg("could not close twophase state file: %m"))); /* - * Mark the prepared transaction as valid. As soon as xact.c marks - * MyProc as not running our XID (which it will do immediately after - * this function returns), others can commit/rollback the xact. + * Mark the prepared transaction as valid. As soon as xact.c marks MyProc + * as not running our XID (which it will do immediately after this + * function returns), others can commit/rollback the xact. * * NB: a side effect of this is to make a dummy ProcArray entry for the * prepared XID. This must happen before we clear the XID from MyProc, * else there is a window where the XID is not running according to - * TransactionIdInProgress, and onlookers would be entitled to assume - * the xact crashed. Instead we have a window where the same XID - * appears twice in ProcArray, which is OK. + * TransactionIdInProgress, and onlookers would be entitled to assume the + * xact crashed. Instead we have a window where the same XID appears + * twice in ProcArray, which is OK. */ MarkAsPrepared(gxact); @@ -1011,9 +1008,10 @@ ReadTwoPhaseFile(TransactionId xid) char *buf; TwoPhaseFileHeader *hdr; int fd; - struct stat stat; + struct stat stat; uint32 crc_offset; - pg_crc32 calc_crc, file_crc; + pg_crc32 calc_crc, + file_crc; TwoPhaseFilePath(path, xid); @@ -1028,9 +1026,8 @@ ReadTwoPhaseFile(TransactionId xid) } /* - * Check file length. We can determine a lower bound pretty easily. - * We set an upper bound mainly to avoid palloc() failure on a corrupt - * file. + * Check file length. We can determine a lower bound pretty easily. We + * set an upper bound mainly to avoid palloc() failure on a corrupt file. */ if (fstat(fd, &stat)) { @@ -1107,17 +1104,17 @@ FinishPreparedTransaction(const char *gid, bool isCommit) { GlobalTransaction gxact; TransactionId xid; - char *buf; - char *bufptr; + char *buf; + char *bufptr; TwoPhaseFileHeader *hdr; TransactionId *children; RelFileNode *commitrels; RelFileNode *abortrels; - int i; + int i; /* - * Validate the GID, and lock the GXACT to ensure that two backends - * do not try to commit the same GID at once. + * Validate the GID, and lock the GXACT to ensure that two backends do not + * try to commit the same GID at once. */ gxact = LockGXact(gid, GetUserId()); xid = gxact->proc.xid; @@ -1148,10 +1145,10 @@ FinishPreparedTransaction(const char *gid, bool isCommit) /* * The order of operations here is critical: make the XLOG entry for * commit or abort, then mark the transaction committed or aborted in - * pg_clog, then remove its PGPROC from the global ProcArray (which - * means TransactionIdIsInProgress will stop saying the prepared xact - * is in progress), then run the post-commit or post-abort callbacks. - * The callbacks will release the locks the transaction held. + * pg_clog, then remove its PGPROC from the global ProcArray (which means + * TransactionIdIsInProgress will stop saying the prepared xact is in + * progress), then run the post-commit or post-abort callbacks. The + * callbacks will release the locks the transaction held. */ if (isCommit) RecordTransactionCommitPrepared(xid, @@ -1165,18 +1162,18 @@ FinishPreparedTransaction(const char *gid, bool isCommit) ProcArrayRemove(&gxact->proc); /* - * In case we fail while running the callbacks, mark the gxact invalid - * so no one else will try to commit/rollback, and so it can be recycled - * properly later. It is still locked by our XID so it won't go away yet. + * In case we fail while running the callbacks, mark the gxact invalid so + * no one else will try to commit/rollback, and so it can be recycled + * properly later. It is still locked by our XID so it won't go away yet. * * (We assume it's safe to do this without taking TwoPhaseStateLock.) */ gxact->valid = false; /* - * We have to remove any files that were supposed to be dropped. - * For consistency with the regular xact.c code paths, must do this - * before releasing locks, so do it before running the callbacks. + * We have to remove any files that were supposed to be dropped. For + * consistency with the regular xact.c code paths, must do this before + * releasing locks, so do it before running the callbacks. * * NB: this code knows that we couldn't be dropping any temp rels ... */ @@ -1228,8 +1225,8 @@ ProcessRecords(char *bufptr, TransactionId xid, bufptr += MAXALIGN(sizeof(TwoPhaseRecordOnDisk)); if (callbacks[record->rmid] != NULL) - callbacks[record->rmid](xid, record->info, - (void *) bufptr, record->len); + callbacks[record->rmid] (xid, record->info, + (void *) bufptr, record->len); bufptr += MAXALIGN(record->len); } @@ -1244,15 +1241,15 @@ ProcessRecords(char *bufptr, TransactionId xid, void RemoveTwoPhaseFile(TransactionId xid, bool giveWarning) { - char path[MAXPGPATH]; + char path[MAXPGPATH]; TwoPhaseFilePath(path, xid); if (unlink(path)) if (errno != ENOENT || giveWarning) ereport(WARNING, (errcode_for_file_access(), - errmsg("could not remove two-phase state file \"%s\": %m", - path))); + errmsg("could not remove two-phase state file \"%s\": %m", + path))); } /* @@ -1300,8 +1297,8 @@ RecreateTwoPhaseFile(TransactionId xid, void *content, int len) } /* - * We must fsync the file because the end-of-replay checkpoint will - * not do so, there being no GXACT in shared memory yet to tell it to. + * We must fsync the file because the end-of-replay checkpoint will not do + * so, there being no GXACT in shared memory yet to tell it to. */ if (pg_fsync(fd) != 0) { @@ -1343,15 +1340,15 @@ CheckPointTwoPhase(XLogRecPtr redo_horizon) int i; /* - * We don't want to hold the TwoPhaseStateLock while doing I/O, - * so we grab it just long enough to make a list of the XIDs that - * require fsyncing, and then do the I/O afterwards. + * We don't want to hold the TwoPhaseStateLock while doing I/O, so we grab + * it just long enough to make a list of the XIDs that require fsyncing, + * and then do the I/O afterwards. * - * This approach creates a race condition: someone else could delete - * a GXACT between the time we release TwoPhaseStateLock and the time - * we try to open its state file. We handle this by special-casing - * ENOENT failures: if we see that, we verify that the GXACT is no - * longer valid, and if so ignore the failure. + * This approach creates a race condition: someone else could delete a GXACT + * between the time we release TwoPhaseStateLock and the time we try to + * open its state file. We handle this by special-casing ENOENT failures: + * if we see that, we verify that the GXACT is no longer valid, and if so + * ignore the failure. */ if (max_prepared_xacts <= 0) return; /* nothing to do */ @@ -1362,9 +1359,9 @@ CheckPointTwoPhase(XLogRecPtr redo_horizon) for (i = 0; i < TwoPhaseState->numPrepXacts; i++) { - GlobalTransaction gxact = TwoPhaseState->prepXacts[i]; + GlobalTransaction gxact = TwoPhaseState->prepXacts[i]; - if (gxact->valid && + if (gxact->valid && XLByteLE(gxact->prepare_lsn, redo_horizon)) xids[nxids++] = gxact->proc.xid; } @@ -1374,7 +1371,7 @@ CheckPointTwoPhase(XLogRecPtr redo_horizon) for (i = 0; i < nxids; i++) { TransactionId xid = xids[i]; - int fd; + int fd; TwoPhaseFilePath(path, xid); @@ -1424,7 +1421,7 @@ CheckPointTwoPhase(XLogRecPtr redo_horizon) * * We throw away any prepared xacts with main XID beyond nextXid --- if any * are present, it suggests that the DBA has done a PITR recovery to an - * earlier point in time without cleaning out pg_twophase. We dare not + * earlier point in time without cleaning out pg_twophase. We dare not * try to recover such prepared xacts since they likely depend on database * state that doesn't exist now. * @@ -1442,7 +1439,7 @@ PrescanPreparedTransactions(void) { TransactionId origNextXid = ShmemVariableCache->nextXid; TransactionId result = origNextXid; - DIR *cldir; + DIR *cldir; struct dirent *clde; cldir = AllocateDir(TWOPHASE_DIR); @@ -1452,10 +1449,10 @@ PrescanPreparedTransactions(void) strspn(clde->d_name, "0123456789ABCDEF") == 8) { TransactionId xid; - char *buf; - TwoPhaseFileHeader *hdr; + char *buf; + TwoPhaseFileHeader *hdr; TransactionId *subxids; - int i; + int i; xid = (TransactionId) strtoul(clde->d_name, NULL, 16); @@ -1541,8 +1538,8 @@ PrescanPreparedTransactions(void) void RecoverPreparedTransactions(void) { - char dir[MAXPGPATH]; - DIR *cldir; + char dir[MAXPGPATH]; + DIR *cldir; struct dirent *clde; snprintf(dir, MAXPGPATH, "%s", TWOPHASE_DIR); @@ -1554,12 +1551,12 @@ RecoverPreparedTransactions(void) strspn(clde->d_name, "0123456789ABCDEF") == 8) { TransactionId xid; - char *buf; - char *bufptr; - TwoPhaseFileHeader *hdr; + char *buf; + char *bufptr; + TwoPhaseFileHeader *hdr; TransactionId *subxids; - GlobalTransaction gxact; - int i; + GlobalTransaction gxact; + int i; xid = (TransactionId) strtoul(clde->d_name, NULL, 16); @@ -1598,8 +1595,8 @@ RecoverPreparedTransactions(void) /* * Reconstruct subtrans state for the transaction --- needed - * because pg_subtrans is not preserved over a restart. Note - * that we are linking all the subtransactions directly to the + * because pg_subtrans is not preserved over a restart. Note that + * we are linking all the subtransactions directly to the * top-level XID; there may originally have been a more complex * hierarchy, but there's no need to restore that exactly. */ @@ -1609,12 +1606,12 @@ RecoverPreparedTransactions(void) /* * Recreate its GXACT and dummy PGPROC * - * Note: since we don't have the PREPARE record's WAL location - * at hand, we leave prepare_lsn zeroes. This means the GXACT - * will be fsync'd on every future checkpoint. We assume this + * Note: since we don't have the PREPARE record's WAL location at + * hand, we leave prepare_lsn zeroes. This means the GXACT will + * be fsync'd on every future checkpoint. We assume this * situation is infrequent enough that the performance cost is - * negligible (especially since we know the state file has - * already been fsynced). + * negligible (especially since we know the state file has already + * been fsynced). */ gxact = MarkAsPreparing(xid, hdr->gid, hdr->prepared_at, @@ -1773,12 +1770,11 @@ RecordTransactionAbortPrepared(TransactionId xid, XLogFlush(recptr); /* - * Mark the transaction aborted in clog. This is not absolutely - * necessary but we may as well do it while we are here. + * Mark the transaction aborted in clog. This is not absolutely necessary + * but we may as well do it while we are here. */ TransactionIdAbort(xid); TransactionIdAbortTree(nchildren, children); END_CRIT_SECTION(); } - diff --git a/src/backend/access/transam/twophase_rmgr.c b/src/backend/access/transam/twophase_rmgr.c index e78f8b2fbb..eab442404f 100644 --- a/src/backend/access/transam/twophase_rmgr.c +++ b/src/backend/access/transam/twophase_rmgr.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/transam/twophase_rmgr.c,v 1.1 2005/06/17 22:32:42 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/transam/twophase_rmgr.c,v 1.2 2005/10/15 02:49:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -21,29 +21,29 @@ #include "utils/inval.h" -const TwoPhaseCallback twophase_recover_callbacks[TWOPHASE_RM_MAX_ID + 1] = +const TwoPhaseCallback twophase_recover_callbacks[TWOPHASE_RM_MAX_ID + 1] = { - NULL, /* END ID */ - lock_twophase_recover, /* Lock */ - NULL, /* Inval */ - NULL, /* flat file update */ - NULL /* notify/listen */ + NULL, /* END ID */ + lock_twophase_recover, /* Lock */ + NULL, /* Inval */ + NULL, /* flat file update */ + NULL /* notify/listen */ }; -const TwoPhaseCallback twophase_postcommit_callbacks[TWOPHASE_RM_MAX_ID + 1] = +const TwoPhaseCallback twophase_postcommit_callbacks[TWOPHASE_RM_MAX_ID + 1] = { - NULL, /* END ID */ - lock_twophase_postcommit, /* Lock */ - inval_twophase_postcommit, /* Inval */ - flatfile_twophase_postcommit, /* flat file update */ - notify_twophase_postcommit /* notify/listen */ + NULL, /* END ID */ + lock_twophase_postcommit, /* Lock */ + inval_twophase_postcommit, /* Inval */ + flatfile_twophase_postcommit, /* flat file update */ + notify_twophase_postcommit /* notify/listen */ }; -const TwoPhaseCallback twophase_postabort_callbacks[TWOPHASE_RM_MAX_ID + 1] = +const TwoPhaseCallback twophase_postabort_callbacks[TWOPHASE_RM_MAX_ID + 1] = { - NULL, /* END ID */ - lock_twophase_postabort, /* Lock */ - NULL, /* Inval */ - NULL, /* flat file update */ - NULL /* notify/listen */ + NULL, /* END ID */ + lock_twophase_postabort, /* Lock */ + NULL, /* Inval */ + NULL, /* flat file update */ + NULL /* notify/listen */ }; diff --git a/src/backend/access/transam/varsup.c b/src/backend/access/transam/varsup.c index 99d9213af0..bff646afb6 100644 --- a/src/backend/access/transam/varsup.c +++ b/src/backend/access/transam/varsup.c @@ -6,7 +6,7 @@ * Copyright (c) 2000-2005, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/transam/varsup.c,v 1.66 2005/08/22 16:59:47 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/transam/varsup.c,v 1.67 2005/10/15 02:49:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -49,21 +49,21 @@ GetNewTransactionId(bool isSubXact) xid = ShmemVariableCache->nextXid; /* - * Check to see if it's safe to assign another XID. This protects - * against catastrophic data loss due to XID wraparound. The basic - * rules are: warn if we're past xidWarnLimit, and refuse to execute - * transactions if we're past xidStopLimit, unless we are running in - * a standalone backend (which gives an escape hatch to the DBA who - * ignored all those warnings). + * Check to see if it's safe to assign another XID. This protects against + * catastrophic data loss due to XID wraparound. The basic rules are: + * warn if we're past xidWarnLimit, and refuse to execute transactions if + * we're past xidStopLimit, unless we are running in a standalone backend + * (which gives an escape hatch to the DBA who ignored all those + * warnings). * - * Test is coded to fall out as fast as possible during normal operation, - * ie, when the warn limit is set and we haven't violated it. + * Test is coded to fall out as fast as possible during normal operation, ie, + * when the warn limit is set and we haven't violated it. */ if (TransactionIdFollowsOrEquals(xid, ShmemVariableCache->xidWarnLimit) && TransactionIdIsValid(ShmemVariableCache->xidWarnLimit)) { if (IsUnderPostmaster && - TransactionIdFollowsOrEquals(xid, ShmemVariableCache->xidStopLimit)) + TransactionIdFollowsOrEquals(xid, ShmemVariableCache->xidStopLimit)) ereport(ERROR, (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), errmsg("database is not accepting queries to avoid wraparound data loss in database \"%s\"", @@ -72,20 +72,19 @@ GetNewTransactionId(bool isSubXact) NameStr(ShmemVariableCache->limit_datname)))); else ereport(WARNING, - (errmsg("database \"%s\" must be vacuumed within %u transactions", - NameStr(ShmemVariableCache->limit_datname), - ShmemVariableCache->xidWrapLimit - xid), - errhint("To avoid a database shutdown, execute a full-database VACUUM in \"%s\".", - NameStr(ShmemVariableCache->limit_datname)))); + (errmsg("database \"%s\" must be vacuumed within %u transactions", + NameStr(ShmemVariableCache->limit_datname), + ShmemVariableCache->xidWrapLimit - xid), + errhint("To avoid a database shutdown, execute a full-database VACUUM in \"%s\".", + NameStr(ShmemVariableCache->limit_datname)))); } /* * If we are allocating the first XID of a new page of the commit log, - * zero out that commit-log page before returning. We must do this - * while holding XidGenLock, else another xact could acquire and - * commit a later XID before we zero the page. Fortunately, a page of - * the commit log holds 32K or more transactions, so we don't have to - * do this very often. + * zero out that commit-log page before returning. We must do this while + * holding XidGenLock, else another xact could acquire and commit a later + * XID before we zero the page. Fortunately, a page of the commit log + * holds 32K or more transactions, so we don't have to do this very often. * * Extend pg_subtrans too. */ @@ -93,45 +92,43 @@ GetNewTransactionId(bool isSubXact) ExtendSUBTRANS(xid); /* - * Now advance the nextXid counter. This must not happen until after - * we have successfully completed ExtendCLOG() --- if that routine - * fails, we want the next incoming transaction to try it again. We - * cannot assign more XIDs until there is CLOG space for them. + * Now advance the nextXid counter. This must not happen until after we + * have successfully completed ExtendCLOG() --- if that routine fails, we + * want the next incoming transaction to try it again. We cannot assign + * more XIDs until there is CLOG space for them. */ TransactionIdAdvance(ShmemVariableCache->nextXid); /* - * We must store the new XID into the shared PGPROC array before - * releasing XidGenLock. This ensures that when GetSnapshotData calls + * We must store the new XID into the shared PGPROC array before releasing + * XidGenLock. This ensures that when GetSnapshotData calls * ReadNewTransactionId, all active XIDs before the returned value of - * nextXid are already present in PGPROC. Else we have a race - * condition. + * nextXid are already present in PGPROC. Else we have a race condition. * * XXX by storing xid into MyProc without acquiring ProcArrayLock, we are * relying on fetch/store of an xid to be atomic, else other backends * might see a partially-set xid here. But holding both locks at once - * would be a nasty concurrency hit (and in fact could cause a - * deadlock against GetSnapshotData). So for now, assume atomicity. - * Note that readers of PGPROC xid field should be careful to fetch - * the value only once, rather than assume they can read it multiple - * times and get the same answer each time. + * would be a nasty concurrency hit (and in fact could cause a deadlock + * against GetSnapshotData). So for now, assume atomicity. Note that + * readers of PGPROC xid field should be careful to fetch the value only + * once, rather than assume they can read it multiple times and get the + * same answer each time. * * The same comments apply to the subxact xid count and overflow fields. * - * A solution to the atomic-store problem would be to give each PGPROC - * its own spinlock used only for fetching/storing that PGPROC's xid - * and related fields. + * A solution to the atomic-store problem would be to give each PGPROC its + * own spinlock used only for fetching/storing that PGPROC's xid and + * related fields. * * If there's no room to fit a subtransaction XID into PGPROC, set the * cache-overflowed flag instead. This forces readers to look in - * pg_subtrans to map subtransaction XIDs up to top-level XIDs. There - * is a race-condition window, in that the new XID will not appear as - * running until its parent link has been placed into pg_subtrans. - * However, that will happen before anyone could possibly have a - * reason to inquire about the status of the XID, so it seems OK. - * (Snapshots taken during this window *will* include the parent XID, - * so they will deliver the correct answer later on when someone does - * have a reason to inquire.) + * pg_subtrans to map subtransaction XIDs up to top-level XIDs. There is a + * race-condition window, in that the new XID will not appear as running + * until its parent link has been placed into pg_subtrans. However, that + * will happen before anyone could possibly have a reason to inquire about + * the status of the XID, so it seems OK. (Snapshots taken during this + * window *will* include the parent XID, so they will deliver the correct + * answer later on when someone does have a reason to inquire.) */ if (MyProc != NULL) { @@ -197,27 +194,26 @@ SetTransactionIdLimit(TransactionId oldest_datfrozenxid, xidWrapLimit += FirstNormalTransactionId; /* - * We'll refuse to continue assigning XIDs in interactive mode once - * we get within 1M transactions of data loss. This leaves lots - * of room for the DBA to fool around fixing things in a standalone - * backend, while not being significant compared to total XID space. - * (Note that since vacuuming requires one transaction per table - * cleaned, we had better be sure there's lots of XIDs left...) + * We'll refuse to continue assigning XIDs in interactive mode once we get + * within 1M transactions of data loss. This leaves lots of room for the + * DBA to fool around fixing things in a standalone backend, while not + * being significant compared to total XID space. (Note that since + * vacuuming requires one transaction per table cleaned, we had better be + * sure there's lots of XIDs left...) */ xidStopLimit = xidWrapLimit - 1000000; if (xidStopLimit < FirstNormalTransactionId) xidStopLimit -= FirstNormalTransactionId; /* - * We'll start complaining loudly when we get within 10M transactions - * of the stop point. This is kind of arbitrary, but if you let your - * gas gauge get down to 1% of full, would you be looking for the - * next gas station? We need to be fairly liberal about this number - * because there are lots of scenarios where most transactions are - * done by automatic clients that won't pay attention to warnings. - * (No, we're not gonna make this configurable. If you know enough to - * configure it, you know enough to not get in this kind of trouble in - * the first place.) + * We'll start complaining loudly when we get within 10M transactions of + * the stop point. This is kind of arbitrary, but if you let your gas + * gauge get down to 1% of full, would you be looking for the next gas + * station? We need to be fairly liberal about this number because there + * are lots of scenarios where most transactions are done by automatic + * clients that won't pay attention to warnings. (No, we're not gonna make + * this configurable. If you know enough to configure it, you know enough + * to not get in this kind of trouble in the first place.) */ xidWarnLimit = xidStopLimit - 10000000; if (xidWarnLimit < FirstNormalTransactionId) @@ -234,16 +230,16 @@ SetTransactionIdLimit(TransactionId oldest_datfrozenxid, /* Log the info */ ereport(LOG, - (errmsg("transaction ID wrap limit is %u, limited by database \"%s\"", - xidWrapLimit, NameStr(*oldest_datname)))); + (errmsg("transaction ID wrap limit is %u, limited by database \"%s\"", + xidWrapLimit, NameStr(*oldest_datname)))); /* Give an immediate warning if past the wrap warn point */ if (TransactionIdFollowsOrEquals(curXid, xidWarnLimit)) ereport(WARNING, - (errmsg("database \"%s\" must be vacuumed within %u transactions", - NameStr(*oldest_datname), - xidWrapLimit - curXid), - errhint("To avoid a database shutdown, execute a full-database VACUUM in \"%s\".", - NameStr(*oldest_datname)))); + (errmsg("database \"%s\" must be vacuumed within %u transactions", + NameStr(*oldest_datname), + xidWrapLimit - curXid), + errhint("To avoid a database shutdown, execute a full-database VACUUM in \"%s\".", + NameStr(*oldest_datname)))); } @@ -272,11 +268,11 @@ GetNewObjectId(void) * right after a wrap occurs, so as to avoid a possibly large number of * iterations in GetNewOid.) Note we are relying on unsigned comparison. * - * During initdb, we start the OID generator at FirstBootstrapObjectId, - * so we only enforce wrapping to that point when in bootstrap or - * standalone mode. The first time through this routine after normal - * postmaster start, the counter will be forced up to FirstNormalObjectId. - * This mechanism leaves the OIDs between FirstBootstrapObjectId and + * During initdb, we start the OID generator at FirstBootstrapObjectId, so we + * only enforce wrapping to that point when in bootstrap or standalone + * mode. The first time through this routine after normal postmaster + * start, the counter will be forced up to FirstNormalObjectId. This + * mechanism leaves the OIDs between FirstBootstrapObjectId and * FirstNormalObjectId available for automatic assignment during initdb, * while ensuring they will never conflict with user-assigned OIDs. */ diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index eabcb117cc..ea19e07564 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.214 2005/08/20 23:45:08 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.215 2005/10/15 02:49:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -110,15 +110,14 @@ typedef enum TBlockState */ typedef struct TransactionStateData { - TransactionId transactionId; /* my XID, or Invalid if none */ + TransactionId transactionId; /* my XID, or Invalid if none */ SubTransactionId subTransactionId; /* my subxact ID */ char *name; /* savepoint name, if any */ int savepointLevel; /* savepoint level */ TransState state; /* low-level state */ TBlockState blockState; /* high-level state */ int nestingLevel; /* nest depth */ - MemoryContext curTransactionContext; /* my xact-lifetime - * context */ + MemoryContext curTransactionContext; /* my xact-lifetime context */ ResourceOwner curTransactionOwner; /* my query resources */ List *childXids; /* subcommitted child XIDs */ Oid currentUser; /* subxact start current_user */ @@ -219,8 +218,8 @@ static void AtStart_Memory(void); static void AtStart_ResourceOwner(void); static void CallXactCallbacks(XactEvent event); static void CallSubXactCallbacks(SubXactEvent event, - SubTransactionId mySubid, - SubTransactionId parentSubid); + SubTransactionId mySubid, + SubTransactionId parentSubid); static void CleanupTransaction(void); static void CommitTransaction(void); static void RecordTransactionAbort(void); @@ -349,18 +348,18 @@ AssignSubTransactionId(TransactionState s) /* * Generate a new Xid and record it in PG_PROC and pg_subtrans. * - * NB: we must make the subtrans entry BEFORE the Xid appears anywhere - * in shared storage other than PG_PROC; because if there's no room for - * it in PG_PROC, the subtrans entry is needed to ensure that other - * backends see the Xid as "running". See GetNewTransactionId. + * NB: we must make the subtrans entry BEFORE the Xid appears anywhere in + * shared storage other than PG_PROC; because if there's no room for it in + * PG_PROC, the subtrans entry is needed to ensure that other backends see + * the Xid as "running". See GetNewTransactionId. */ s->transactionId = GetNewTransactionId(true); SubTransSetParent(s->transactionId, s->parent->transactionId); /* - * Acquire lock on the transaction XID. (We assume this cannot block.) - * We have to be sure that the lock is assigned to the transaction's + * Acquire lock on the transaction XID. (We assume this cannot block.) We + * have to be sure that the lock is assigned to the transaction's * ResourceOwner. */ currentOwner = CurrentResourceOwner; @@ -453,22 +452,22 @@ TransactionIdIsCurrentTransactionId(TransactionId xid) /* * We always say that BootstrapTransactionId is "not my transaction ID" - * even when it is (ie, during bootstrap). Along with the fact that + * even when it is (ie, during bootstrap). Along with the fact that * transam.c always treats BootstrapTransactionId as already committed, - * this causes the tqual.c routines to see all tuples as committed, - * which is what we need during bootstrap. (Bootstrap mode only inserts - * tuples, it never updates or deletes them, so all tuples can be presumed - * good immediately.) + * this causes the tqual.c routines to see all tuples as committed, which + * is what we need during bootstrap. (Bootstrap mode only inserts tuples, + * it never updates or deletes them, so all tuples can be presumed good + * immediately.) */ if (xid == BootstrapTransactionId) return false; /* - * We will return true for the Xid of the current subtransaction, any - * of its subcommitted children, any of its parents, or any of their - * previously subcommitted children. However, a transaction being - * aborted is no longer "current", even though it may still have an - * entry on the state stack. + * We will return true for the Xid of the current subtransaction, any of + * its subcommitted children, any of its parents, or any of their + * previously subcommitted children. However, a transaction being aborted + * is no longer "current", even though it may still have an entry on the + * state stack. */ for (s = CurrentTransactionState; s != NULL; s = s->parent) { @@ -498,12 +497,12 @@ void CommandCounterIncrement(void) { currentCommandId += 1; - if (currentCommandId == FirstCommandId) /* check for overflow */ + if (currentCommandId == FirstCommandId) /* check for overflow */ { currentCommandId -= 1; ereport(ERROR, (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), - errmsg("cannot have more than 2^32-1 commands in a transaction"))); + errmsg("cannot have more than 2^32-1 commands in a transaction"))); } /* Propagate new command ID into static snapshots, if set */ @@ -607,16 +606,15 @@ AtSubStart_Memory(void) Assert(CurTransactionContext != NULL); /* - * Create a CurTransactionContext, which will be used to hold data - * that survives subtransaction commit but disappears on - * subtransaction abort. We make it a child of the immediate parent's - * CurTransactionContext. + * Create a CurTransactionContext, which will be used to hold data that + * survives subtransaction commit but disappears on subtransaction abort. + * We make it a child of the immediate parent's CurTransactionContext. */ CurTransactionContext = AllocSetContextCreate(CurTransactionContext, "CurTransactionContext", - ALLOCSET_DEFAULT_MINSIZE, - ALLOCSET_DEFAULT_INITSIZE, - ALLOCSET_DEFAULT_MAXSIZE); + ALLOCSET_DEFAULT_MINSIZE, + ALLOCSET_DEFAULT_INITSIZE, + ALLOCSET_DEFAULT_MAXSIZE); s->curTransactionContext = CurTransactionContext; /* Make the CurTransactionContext active. */ @@ -634,8 +632,8 @@ AtSubStart_ResourceOwner(void) Assert(s->parent != NULL); /* - * Create a resource owner for the subtransaction. We make it a child - * of the immediate parent's resource owner. + * Create a resource owner for the subtransaction. We make it a child of + * the immediate parent's resource owner. */ s->curTransactionOwner = ResourceOwnerCreate(s->parent->curTransactionOwner, @@ -666,11 +664,10 @@ RecordTransactionCommit(void) nchildren = xactGetCommittedChildren(&children); /* - * If we made neither any XLOG entries nor any temp-rel updates, and - * have no files to be deleted, we can omit recording the transaction - * commit at all. (This test includes the effects of subtransactions, - * so the presence of committed subxacts need not alone force a - * write.) + * If we made neither any XLOG entries nor any temp-rel updates, and have + * no files to be deleted, we can omit recording the transaction commit at + * all. (This test includes the effects of subtransactions, so the + * presence of committed subxacts need not alone force a write.) */ if (MyXactMadeXLogEntry || MyXactMadeTempRelUpdate || nrels > 0) { @@ -684,18 +681,17 @@ RecordTransactionCommit(void) START_CRIT_SECTION(); /* - * If our transaction made any transaction-controlled XLOG - * entries, we need to lock out checkpoint start between writing - * our XLOG record and updating pg_clog. Otherwise it is possible - * for the checkpoint to set REDO after the XLOG record but fail - * to flush the pg_clog update to disk, leading to loss of the - * transaction commit if we crash a little later. Slightly klugy - * fix for problem discovered 2004-08-10. + * If our transaction made any transaction-controlled XLOG entries, we + * need to lock out checkpoint start between writing our XLOG record + * and updating pg_clog. Otherwise it is possible for the checkpoint + * to set REDO after the XLOG record but fail to flush the pg_clog + * update to disk, leading to loss of the transaction commit if we + * crash a little later. Slightly klugy fix for problem discovered + * 2004-08-10. * - * (If it made no transaction-controlled XLOG entries, its XID - * appears nowhere in permanent storage, so no one else will ever - * care if it committed; so it doesn't matter if we lose the - * commit flag.) + * (If it made no transaction-controlled XLOG entries, its XID appears + * nowhere in permanent storage, so no one else will ever care if it + * committed; so it doesn't matter if we lose the commit flag.) * * Note we only need a shared lock. */ @@ -704,8 +700,8 @@ RecordTransactionCommit(void) LWLockAcquire(CheckpointStartLock, LW_SHARED); /* - * We only need to log the commit in XLOG if the transaction made - * any transaction-controlled XLOG entries or will delete files. + * We only need to log the commit in XLOG if the transaction made any + * transaction-controlled XLOG entries or will delete files. */ if (madeTCentries || nrels > 0) { @@ -748,26 +744,26 @@ RecordTransactionCommit(void) } /* - * We must flush our XLOG entries to disk if we made any XLOG - * entries, whether in or out of transaction control. For - * example, if we reported a nextval() result to the client, this - * ensures that any XLOG record generated by nextval will hit the - * disk before we report the transaction committed. + * We must flush our XLOG entries to disk if we made any XLOG entries, + * whether in or out of transaction control. For example, if we + * reported a nextval() result to the client, this ensures that any + * XLOG record generated by nextval will hit the disk before we report + * the transaction committed. * - * Note: if we generated a commit record above, MyXactMadeXLogEntry - * will certainly be set now. + * Note: if we generated a commit record above, MyXactMadeXLogEntry will + * certainly be set now. */ if (MyXactMadeXLogEntry) { /* * Sleep before flush! So we can flush more than one commit - * records per single fsync. (The idea is some other backend - * may do the XLogFlush while we're sleeping. This needs work - * still, because on most Unixen, the minimum select() delay - * is 10msec or more, which is way too long.) + * records per single fsync. (The idea is some other backend may + * do the XLogFlush while we're sleeping. This needs work still, + * because on most Unixen, the minimum select() delay is 10msec or + * more, which is way too long.) * - * We do not sleep if enableFsync is not turned on, nor if there - * are fewer than CommitSiblings other backends with active + * We do not sleep if enableFsync is not turned on, nor if there are + * fewer than CommitSiblings other backends with active * transactions. */ if (CommitDelay > 0 && enableFsync && @@ -778,14 +774,13 @@ RecordTransactionCommit(void) } /* - * We must mark the transaction committed in clog if its XID - * appears either in permanent rels or in local temporary rels. We - * test this by seeing if we made transaction-controlled entries - * *OR* local-rel tuple updates. Note that if we made only the - * latter, we have not emitted an XLOG record for our commit, and - * so in the event of a crash the clog update might be lost. This - * is okay because no one else will ever care whether we - * committed. + * We must mark the transaction committed in clog if its XID appears + * either in permanent rels or in local temporary rels. We test this + * by seeing if we made transaction-controlled entries *OR* local-rel + * tuple updates. Note that if we made only the latter, we have not + * emitted an XLOG record for our commit, and so in the event of a + * crash the clog update might be lost. This is okay because no one + * else will ever care whether we committed. */ if (madeTCentries || MyXactMadeTempRelUpdate) { @@ -833,9 +828,8 @@ static void AtCommit_Memory(void) { /* - * Now that we're "out" of a transaction, have the system allocate - * things in the top memory context instead of per-transaction - * contexts. + * Now that we're "out" of a transaction, have the system allocate things + * in the top memory context instead of per-transaction contexts. */ MemoryContextSwitchTo(TopMemoryContext); @@ -870,9 +864,9 @@ AtSubCommit_Memory(void) /* * Ordinarily we cannot throw away the child's CurTransactionContext, - * since the data it contains will be needed at upper commit. However, - * if there isn't actually anything in it, we can throw it away. This - * avoids a small memory leak in the common case of "trivial" subxacts. + * since the data it contains will be needed at upper commit. However, if + * there isn't actually anything in it, we can throw it away. This avoids + * a small memory leak in the common case of "trivial" subxacts. */ if (MemoryContextIsEmpty(s->curTransactionContext)) { @@ -908,9 +902,10 @@ AtSubCommit_childXids(void) { s->parent->childXids = list_concat(s->parent->childXids, s->childXids); + /* - * list_concat doesn't free the list header for the second list; - * do so here to avoid memory leakage (kluge) + * list_concat doesn't free the list header for the second list; do so + * here to avoid memory leakage (kluge) */ pfree(s->childXids); s->childXids = NIL; @@ -929,14 +924,14 @@ RecordSubTransactionCommit(void) * We do not log the subcommit in XLOG; it doesn't matter until the * top-level transaction commits. * - * We must mark the subtransaction subcommitted in clog if its XID - * appears either in permanent rels or in local temporary rels. We - * test this by seeing if we made transaction-controlled entries *OR* - * local-rel tuple updates. (The test here actually covers the entire - * transaction tree so far, so it may mark subtransactions that don't - * really need it, but it's probably not worth being tenser. Note that - * if a prior subtransaction dirtied these variables, then - * RecordTransactionCommit will have to do the full pushup anyway...) + * We must mark the subtransaction subcommitted in clog if its XID appears + * either in permanent rels or in local temporary rels. We test this by + * seeing if we made transaction-controlled entries *OR* local-rel tuple + * updates. (The test here actually covers the entire transaction tree so + * far, so it may mark subtransactions that don't really need it, but it's + * probably not worth being tenser. Note that if a prior subtransaction + * dirtied these variables, then RecordTransactionCommit will have to do + * the full pushup anyway...) */ if (MyLastRecPtr.xrecoff != 0 || MyXactMadeTempRelUpdate) { @@ -974,9 +969,9 @@ RecordTransactionAbort(void) /* * If we made neither any transaction-controlled XLOG entries nor any - * temp-rel updates, and are not going to delete any files, we can - * omit recording the transaction abort at all. No one will ever care - * that it aborted. (These tests cover our whole transaction tree.) + * temp-rel updates, and are not going to delete any files, we can omit + * recording the transaction abort at all. No one will ever care that it + * aborted. (These tests cover our whole transaction tree.) */ if (MyLastRecPtr.xrecoff != 0 || MyXactMadeTempRelUpdate || nrels > 0) { @@ -992,16 +987,16 @@ RecordTransactionAbort(void) START_CRIT_SECTION(); /* - * We only need to log the abort in XLOG if the transaction made - * any transaction-controlled XLOG entries or will delete files. - * (If it made no transaction-controlled XLOG entries, its XID - * appears nowhere in permanent storage, so no one else will ever - * care if it committed.) + * We only need to log the abort in XLOG if the transaction made any + * transaction-controlled XLOG entries or will delete files. (If it + * made no transaction-controlled XLOG entries, its XID appears + * nowhere in permanent storage, so no one else will ever care if it + * committed.) * - * We do not flush XLOG to disk unless deleting files, since the - * default assumption after a crash would be that we aborted, - * anyway. For the same reason, we don't need to worry about - * interlocking against checkpoint start. + * We do not flush XLOG to disk unless deleting files, since the default + * assumption after a crash would be that we aborted, anyway. For the + * same reason, we don't need to worry about interlocking against + * checkpoint start. */ if (MyLastRecPtr.xrecoff != 0 || nrels > 0) { @@ -1047,8 +1042,8 @@ RecordTransactionAbort(void) * Mark the transaction aborted in clog. This is not absolutely * necessary but we may as well do it while we are here. * - * The ordering here isn't critical but it seems best to mark the - * parent first. This assures an atomic transition of all the + * The ordering here isn't critical but it seems best to mark the parent + * first. This assures an atomic transition of all the * subtransactions to aborted state from the point of view of * concurrent TransactionIdDidAbort calls. */ @@ -1078,8 +1073,8 @@ AtAbort_Memory(void) { /* * Make sure we are in a valid context (not a child of - * TopTransactionContext...). Note that it is possible for this code - * to be called when we aren't in a transaction at all; go directly to + * TopTransactionContext...). Note that it is possible for this code to + * be called when we aren't in a transaction at all; go directly to * TopMemoryContext in that case. */ if (TopTransactionContext != NULL) @@ -1087,8 +1082,8 @@ AtAbort_Memory(void) MemoryContextSwitchTo(TopTransactionContext); /* - * We do not want to destroy the transaction's global state yet, - * so we can't free any memory here. + * We do not want to destroy the transaction's global state yet, so we + * can't free any memory here. */ } else @@ -1114,8 +1109,8 @@ static void AtAbort_ResourceOwner(void) { /* - * Make sure we have a valid ResourceOwner, if possible (else it - * will be NULL, which is OK) + * Make sure we have a valid ResourceOwner, if possible (else it will be + * NULL, which is OK) */ CurrentResourceOwner = TopTransactionResourceOwner; } @@ -1143,7 +1138,7 @@ AtSubAbort_childXids(void) /* * We keep the child-XID lists in TopTransactionContext (see - * AtSubCommit_childXids). This means we'd better free the list + * AtSubCommit_childXids). This means we'd better free the list * explicitly at abort to avoid leakage. */ list_free(s->childXids); @@ -1168,11 +1163,11 @@ RecordSubTransactionAbort(void) /* * If we made neither any transaction-controlled XLOG entries nor any - * temp-rel updates, and are not going to delete any files, we can - * omit recording the transaction abort at all. No one will ever care - * that it aborted. (These tests cover our whole transaction tree, - * and therefore may mark subxacts that don't really need it, but it's - * probably not worth being tenser.) + * temp-rel updates, and are not going to delete any files, we can omit + * recording the transaction abort at all. No one will ever care that it + * aborted. (These tests cover our whole transaction tree, and therefore + * may mark subxacts that don't really need it, but it's probably not + * worth being tenser.) * * In this case we needn't worry about marking subcommitted children as * aborted, because they didn't mark themselves as subcommitted in the @@ -1183,8 +1178,8 @@ RecordSubTransactionAbort(void) START_CRIT_SECTION(); /* - * We only need to log the abort in XLOG if the transaction made - * any transaction-controlled XLOG entries or will delete files. + * We only need to log the abort in XLOG if the transaction made any + * transaction-controlled XLOG entries or will delete files. */ if (MyLastRecPtr.xrecoff != 0 || nrels > 0) { @@ -1238,11 +1233,10 @@ RecordSubTransactionAbort(void) } /* - * We can immediately remove failed XIDs from PGPROC's cache of - * running child XIDs. It's easiest to do it here while we have the - * child XID array at hand, even though in the main-transaction case - * the equivalent work happens just after return from - * RecordTransactionAbort. + * We can immediately remove failed XIDs from PGPROC's cache of running + * child XIDs. It's easiest to do it here while we have the child XID + * array at hand, even though in the main-transaction case the equivalent + * work happens just after return from RecordTransactionAbort. */ XidCacheRemoveRunningXids(xid, nchildren, children); @@ -1265,9 +1259,8 @@ static void AtCleanup_Memory(void) { /* - * Now that we're "out" of a transaction, have the system allocate - * things in the top memory context instead of per-transaction - * contexts. + * Now that we're "out" of a transaction, have the system allocate things + * in the top memory context instead of per-transaction contexts. */ MemoryContextSwitchTo(TopMemoryContext); @@ -1304,9 +1297,9 @@ AtSubCleanup_Memory(void) CurTransactionContext = s->parent->curTransactionContext; /* - * Delete the subxact local memory contexts. Its CurTransactionContext - * can go too (note this also kills CurTransactionContexts from any - * children of the subxact). + * Delete the subxact local memory contexts. Its CurTransactionContext can + * go too (note this also kills CurTransactionContexts from any children + * of the subxact). */ if (s->curTransactionContext) MemoryContextDelete(s->curTransactionContext); @@ -1344,11 +1337,10 @@ StartTransaction(void) * start processing */ s->state = TRANS_START; - s->transactionId = InvalidTransactionId; /* until assigned */ + s->transactionId = InvalidTransactionId; /* until assigned */ /* - * Make sure we've freed any old snapshot, and reset xact state - * variables + * Make sure we've freed any old snapshot, and reset xact state variables */ FreeXactSnapshot(); XactIsoLevel = DefaultXactIsoLevel; @@ -1386,10 +1378,10 @@ StartTransaction(void) s->childXids = NIL; /* - * You might expect to see "s->currentUser = GetUserId();" here, but - * you won't because it doesn't work during startup; the userid isn't - * set yet during a backend's first transaction start. We only use - * the currentUser field in sub-transaction state structs. + * You might expect to see "s->currentUser = GetUserId();" here, but you + * won't because it doesn't work during startup; the userid isn't set yet + * during a backend's first transaction start. We only use the + * currentUser field in sub-transaction state structs. * * prevXactReadOnly is also valid only in sub-transactions. */ @@ -1432,13 +1424,12 @@ CommitTransaction(void) Assert(s->parent == NULL); /* - * Do pre-commit processing (most of this stuff requires database - * access, and in fact could still cause an error...) + * Do pre-commit processing (most of this stuff requires database access, + * and in fact could still cause an error...) * - * It is possible for CommitHoldablePortals to invoke functions that - * queue deferred triggers, and it's also possible that triggers create - * holdable cursors. So we have to loop until there's nothing left to - * do. + * It is possible for CommitHoldablePortals to invoke functions that queue + * deferred triggers, and it's also possible that triggers create holdable + * cursors. So we have to loop until there's nothing left to do. */ for (;;) { @@ -1525,19 +1516,19 @@ CommitTransaction(void) } /* - * This is all post-commit cleanup. Note that if an error is raised - * here, it's too late to abort the transaction. This should be just + * This is all post-commit cleanup. Note that if an error is raised here, + * it's too late to abort the transaction. This should be just * noncritical resource releasing. * - * The ordering of operations is not entirely random. The idea is: - * release resources visible to other backends (eg, files, buffer - * pins); then release locks; then release backend-local resources. We - * want to release locks at the point where any backend waiting for us - * will see our transaction as being fully cleaned up. + * The ordering of operations is not entirely random. The idea is: release + * resources visible to other backends (eg, files, buffer pins); then + * release locks; then release backend-local resources. We want to release + * locks at the point where any backend waiting for us will see our + * transaction as being fully cleaned up. * - * Resources that can be associated with individual queries are handled - * by the ResourceOwner mechanism. The other calls here are for - * backend-wide state. + * Resources that can be associated with individual queries are handled by + * the ResourceOwner mechanism. The other calls here are for backend-wide + * state. */ CallXactCallbacks(XACT_EVENT_COMMIT); @@ -1553,12 +1544,11 @@ CommitTransaction(void) AtEOXact_RelationCache(true); /* - * Make catalog changes visible to all backends. This has to happen - * after relcache references are dropped (see comments for - * AtEOXact_RelationCache), but before locks are released (if anyone - * is waiting for lock on a relation we've modified, we want them to - * know about the catalog change before they start using the - * relation). + * Make catalog changes visible to all backends. This has to happen after + * relcache references are dropped (see comments for + * AtEOXact_RelationCache), but before locks are released (if anyone is + * waiting for lock on a relation we've modified, we want them to know + * about the catalog change before they start using the relation). */ AtEOXact_Inval(true); @@ -1621,10 +1611,10 @@ CommitTransaction(void) static void PrepareTransaction(void) { - TransactionState s = CurrentTransactionState; - TransactionId xid = GetCurrentTransactionId(); - GlobalTransaction gxact; - TimestampTz prepared_at; + TransactionState s = CurrentTransactionState; + TransactionId xid = GetCurrentTransactionId(); + GlobalTransaction gxact; + TimestampTz prepared_at; ShowTransactionState("PrepareTransaction"); @@ -1637,13 +1627,12 @@ PrepareTransaction(void) Assert(s->parent == NULL); /* - * Do pre-commit processing (most of this stuff requires database - * access, and in fact could still cause an error...) + * Do pre-commit processing (most of this stuff requires database access, + * and in fact could still cause an error...) * - * It is possible for PrepareHoldablePortals to invoke functions that - * queue deferred triggers, and it's also possible that triggers create - * holdable cursors. So we have to loop until there's nothing left to - * do. + * It is possible for PrepareHoldablePortals to invoke functions that queue + * deferred triggers, and it's also possible that triggers create holdable + * cursors. So we have to loop until there's nothing left to do. */ for (;;) { @@ -1693,8 +1682,8 @@ PrepareTransaction(void) BufmgrCommit(); /* - * Reserve the GID for this transaction. This could fail if the - * requested GID is invalid or already in use. + * Reserve the GID for this transaction. This could fail if the requested + * GID is invalid or already in use. */ gxact = MarkAsPreparing(xid, prepareGID, prepared_at, GetUserId(), MyDatabaseId); @@ -1707,14 +1696,14 @@ PrepareTransaction(void) * want transaction abort to be able to clean up. (In particular, the * AtPrepare routines may error out if they find cases they cannot * handle.) State cleanup should happen in the PostPrepare routines - * below. However, some modules can go ahead and clear state here - * because they wouldn't do anything with it during abort anyway. + * below. However, some modules can go ahead and clear state here because + * they wouldn't do anything with it during abort anyway. * * Note: because the 2PC state file records will be replayed in the same - * order they are made, the order of these calls has to match the order - * in which we want things to happen during COMMIT PREPARED or - * ROLLBACK PREPARED; in particular, pay attention to whether things - * should happen before or after releasing the transaction's locks. + * order they are made, the order of these calls has to match the order in + * which we want things to happen during COMMIT PREPARED or ROLLBACK + * PREPARED; in particular, pay attention to whether things should happen + * before or after releasing the transaction's locks. */ StartPrepare(gxact); @@ -1726,15 +1715,14 @@ PrepareTransaction(void) /* * Here is where we really truly prepare. * - * We have to record transaction prepares even if we didn't - * make any updates, because the transaction manager might - * get confused if we lose a global transaction. + * We have to record transaction prepares even if we didn't make any updates, + * because the transaction manager might get confused if we lose a global + * transaction. */ EndPrepare(gxact); /* - * Now we clean up backend-internal state and release internal - * resources. + * Now we clean up backend-internal state and release internal resources. */ /* Break the chain of back-links in the XLOG records I output */ @@ -1743,9 +1731,9 @@ PrepareTransaction(void) MyXactMadeTempRelUpdate = false; /* - * Let others know about no transaction in progress by me. This has - * to be done *after* the prepared transaction has been marked valid, - * else someone may think it is unlocked and recyclable. + * Let others know about no transaction in progress by me. This has to be + * done *after* the prepared transaction has been marked valid, else + * someone may think it is unlocked and recyclable. */ /* Lock ProcArrayLock because that's what GetSnapshotData uses. */ @@ -1762,7 +1750,7 @@ PrepareTransaction(void) /* * This is all post-transaction cleanup. Note that if an error is raised * here, it's too late to abort the transaction. This should be just - * noncritical resource releasing. See notes in CommitTransaction. + * noncritical resource releasing. See notes in CommitTransaction. */ CallXactCallbacks(XACT_EVENT_PREPARE); @@ -1819,8 +1807,8 @@ PrepareTransaction(void) s->childXids = NIL; /* - * done with 1st phase commit processing, set current transaction - * state back to default + * done with 1st phase commit processing, set current transaction state + * back to default */ s->state = TRANS_DEFAULT; @@ -1842,8 +1830,8 @@ AbortTransaction(void) /* * Release any LW locks we might be holding as quickly as possible. * (Regular locks, however, must be held till we finish aborting.) - * Releasing LW locks is critical since we might try to grab them - * again while cleaning up! + * Releasing LW locks is critical since we might try to grab them again + * while cleaning up! */ LWLockReleaseAll(); @@ -1852,8 +1840,8 @@ AbortTransaction(void) UnlockBuffers(); /* - * Also clean up any open wait for lock, since the lock manager will - * choke if we try to wait for another lock before doing this. + * Also clean up any open wait for lock, since the lock manager will choke + * if we try to wait for another lock before doing this. */ LockWaitCancel(); @@ -1866,8 +1854,8 @@ AbortTransaction(void) Assert(s->parent == NULL); /* - * set the current transaction state information appropriately during - * the abort processing + * set the current transaction state information appropriately during the + * abort processing */ s->state = TRANS_ABORT; @@ -1876,15 +1864,14 @@ AbortTransaction(void) AtAbort_ResourceOwner(); /* - * Reset user id which might have been changed transiently. We cannot - * use s->currentUser, since it may not be set yet; instead rely on - * internal state of miscinit.c. + * Reset user id which might have been changed transiently. We cannot use + * s->currentUser, since it may not be set yet; instead rely on internal + * state of miscinit.c. * - * (Note: it is not necessary to restore session authorization here - * because that can only be changed via GUC, and GUC will take care of - * rolling it back if need be. However, an error within a SECURITY - * DEFINER function could send control here with the wrong current - * userid.) + * (Note: it is not necessary to restore session authorization here because + * that can only be changed via GUC, and GUC will take care of rolling it + * back if need be. However, an error within a SECURITY DEFINER function + * could send control here with the wrong current userid.) */ AtAbort_UserId(); @@ -1898,15 +1885,15 @@ AbortTransaction(void) AtEOXact_UpdateFlatFiles(false); /* - * Advertise the fact that we aborted in pg_clog (assuming that we - * got as far as assigning an XID to advertise). + * Advertise the fact that we aborted in pg_clog (assuming that we got as + * far as assigning an XID to advertise). */ if (TransactionIdIsValid(s->transactionId)) RecordTransactionAbort(); /* - * Let others know about no transaction in progress by me. Note that - * this must be done _before_ releasing locks we hold and _after_ + * Let others know about no transaction in progress by me. Note that this + * must be done _before_ releasing locks we hold and _after_ * RecordTransactionAbort. */ if (MyProc != NULL) @@ -2012,8 +1999,8 @@ StartTransactionCommand(void) switch (s->blockState) { /* - * if we aren't in a transaction block, we just do our usual - * start transaction. + * if we aren't in a transaction block, we just do our usual start + * transaction. */ case TBLOCK_DEFAULT: StartTransaction(); @@ -2021,23 +2008,23 @@ StartTransactionCommand(void) break; /* - * We are somewhere in a transaction block or subtransaction - * and about to start a new command. For now we do nothing, - * but someday we may do command-local resource initialization. - * (Note that any needed CommandCounterIncrement was done by - * the previous CommitTransactionCommand.) + * We are somewhere in a transaction block or subtransaction and + * about to start a new command. For now we do nothing, but + * someday we may do command-local resource initialization. (Note + * that any needed CommandCounterIncrement was done by the + * previous CommitTransactionCommand.) */ case TBLOCK_INPROGRESS: case TBLOCK_SUBINPROGRESS: break; /* - * Here we are in a failed transaction block (one of - * the commands caused an abort) so we do nothing but remain in - * the abort state. Eventually we will get a ROLLBACK command - * which will get us out of this state. (It is up to other - * code to ensure that no commands other than ROLLBACK will be - * processed in these states.) + * Here we are in a failed transaction block (one of the commands + * caused an abort) so we do nothing but remain in the abort + * state. Eventually we will get a ROLLBACK command which will + * get us out of this state. (It is up to other code to ensure + * that no commands other than ROLLBACK will be processed in these + * states.) */ case TBLOCK_ABORT: case TBLOCK_SUBABORT: @@ -2099,10 +2086,10 @@ CommitTransactionCommand(void) break; /* - * We are completing a "BEGIN TRANSACTION" command, so we - * change to the "transaction block in progress" state and - * return. (We assume the BEGIN did nothing to the database, - * so we need no CommandCounterIncrement.) + * We are completing a "BEGIN TRANSACTION" command, so we change + * to the "transaction block in progress" state and return. (We + * assume the BEGIN did nothing to the database, so we need no + * CommandCounterIncrement.) */ case TBLOCK_BEGIN: s->blockState = TBLOCK_INPROGRESS; @@ -2110,8 +2097,8 @@ CommitTransactionCommand(void) /* * This is the case when we have finished executing a command - * someplace within a transaction block. We increment the - * command counter and return. + * someplace within a transaction block. We increment the command + * counter and return. */ case TBLOCK_INPROGRESS: case TBLOCK_SUBINPROGRESS: @@ -2119,8 +2106,8 @@ CommitTransactionCommand(void) break; /* - * We are completing a "COMMIT" command. Do it and return to - * the idle state. + * We are completing a "COMMIT" command. Do it and return to the + * idle state. */ case TBLOCK_END: CommitTransaction(); @@ -2128,17 +2115,17 @@ CommitTransactionCommand(void) break; /* - * Here we are in the middle of a transaction block but one of - * the commands caused an abort so we do nothing but remain in - * the abort state. Eventually we will get a ROLLBACK comand. + * Here we are in the middle of a transaction block but one of the + * commands caused an abort so we do nothing but remain in the + * abort state. Eventually we will get a ROLLBACK comand. */ case TBLOCK_ABORT: case TBLOCK_SUBABORT: break; /* - * Here we were in an aborted transaction block and we just - * got the ROLLBACK command from the user, so clean up the + * Here we were in an aborted transaction block and we just got + * the ROLLBACK command from the user, so clean up the * already-aborted transaction and return to the idle state. */ case TBLOCK_ABORT_END: @@ -2147,9 +2134,9 @@ CommitTransactionCommand(void) break; /* - * Here we were in a perfectly good transaction block but the - * user told us to ROLLBACK anyway. We have to abort the - * transaction and then clean up. + * Here we were in a perfectly good transaction block but the user + * told us to ROLLBACK anyway. We have to abort the transaction + * and then clean up. */ case TBLOCK_ABORT_PENDING: AbortTransaction(); @@ -2169,8 +2156,8 @@ CommitTransactionCommand(void) /* * We were just issued a SAVEPOINT inside a transaction block. * Start a subtransaction. (DefineSavepoint already did - * PushTransaction, so as to have someplace to put the - * SUBBEGIN state.) + * PushTransaction, so as to have someplace to put the SUBBEGIN + * state.) */ case TBLOCK_SUBBEGIN: StartSubTransaction(); @@ -2259,8 +2246,8 @@ CommitTransactionCommand(void) break; /* - * Same as above, but the subtransaction had already failed, - * so we don't need AbortSubTransaction. + * Same as above, but the subtransaction had already failed, so we + * don't need AbortSubTransaction. */ case TBLOCK_SUBABORT_RESTART: { @@ -2320,8 +2307,8 @@ AbortCurrentTransaction(void) break; /* - * if we aren't in a transaction block, we just do the basic - * abort & cleanup transaction. + * if we aren't in a transaction block, we just do the basic abort + * & cleanup transaction. */ case TBLOCK_STARTED: AbortTransaction(); @@ -2330,11 +2317,11 @@ AbortCurrentTransaction(void) break; /* - * If we are in TBLOCK_BEGIN it means something screwed up - * right after reading "BEGIN TRANSACTION". We assume that - * the user will interpret the error as meaning the BEGIN - * failed to get him into a transaction block, so we should - * abort and return to idle state. + * If we are in TBLOCK_BEGIN it means something screwed up right + * after reading "BEGIN TRANSACTION". We assume that the user + * will interpret the error as meaning the BEGIN failed to get him + * into a transaction block, so we should abort and return to idle + * state. */ case TBLOCK_BEGIN: AbortTransaction(); @@ -2354,9 +2341,9 @@ AbortCurrentTransaction(void) break; /* - * Here, we failed while trying to COMMIT. Clean up the - * transaction and return to idle state (we do not want to - * stay in the transaction). + * Here, we failed while trying to COMMIT. Clean up the + * transaction and return to idle state (we do not want to stay in + * the transaction). */ case TBLOCK_END: AbortTransaction(); @@ -2365,9 +2352,9 @@ AbortCurrentTransaction(void) break; /* - * Here, we are already in an aborted transaction state and - * are waiting for a ROLLBACK, but for some reason we failed - * again! So we just remain in the abort state. + * Here, we are already in an aborted transaction state and are + * waiting for a ROLLBACK, but for some reason we failed again! + * So we just remain in the abort state. */ case TBLOCK_ABORT: case TBLOCK_SUBABORT: @@ -2375,8 +2362,8 @@ AbortCurrentTransaction(void) /* * We are in a failed transaction and we got the ROLLBACK command. - * We have already aborted, we just need to cleanup and go to - * idle state. + * We have already aborted, we just need to cleanup and go to idle + * state. */ case TBLOCK_ABORT_END: CleanupTransaction(); @@ -2395,8 +2382,8 @@ AbortCurrentTransaction(void) /* * Here, we failed while trying to PREPARE. Clean up the - * transaction and return to idle state (we do not want to - * stay in the transaction). + * transaction and return to idle state (we do not want to stay in + * the transaction). */ case TBLOCK_PREPARE: AbortTransaction(); @@ -2406,8 +2393,8 @@ AbortCurrentTransaction(void) /* * We got an error inside a subtransaction. Abort just the - * subtransaction, and go to the persistent SUBABORT state - * until we get ROLLBACK. + * subtransaction, and go to the persistent SUBABORT state until + * we get ROLLBACK. */ case TBLOCK_SUBINPROGRESS: AbortSubTransaction(); @@ -2416,7 +2403,7 @@ AbortCurrentTransaction(void) /* * If we failed while trying to create a subtransaction, clean up - * the broken subtransaction and abort the parent. The same + * the broken subtransaction and abort the parent. The same * applies if we get a failure while ending a subtransaction. */ case TBLOCK_SUBBEGIN: @@ -2479,15 +2466,15 @@ PreventTransactionChain(void *stmtNode, const char *stmtType) stmtType))); /* - * Are we inside a function call? If the statement's parameter block - * was allocated in QueryContext, assume it is an interactive command. + * Are we inside a function call? If the statement's parameter block was + * allocated in QueryContext, assume it is an interactive command. * Otherwise assume it is coming from a function. */ if (!MemoryContextContains(QueryContext, stmtNode)) ereport(ERROR, (errcode(ERRCODE_ACTIVE_SQL_TRANSACTION), /* translator: %s represents an SQL statement name */ - errmsg("%s cannot be executed from a function", stmtType))); + errmsg("%s cannot be executed from a function", stmtType))); /* If we got past IsTransactionBlock test, should be in default state */ if (CurrentTransactionState->blockState != TBLOCK_DEFAULT && @@ -2529,8 +2516,8 @@ RequireTransactionChain(void *stmtNode, const char *stmtType) return; /* - * Are we inside a function call? If the statement's parameter block - * was allocated in QueryContext, assume it is an interactive command. + * Are we inside a function call? If the statement's parameter block was + * allocated in QueryContext, assume it is an interactive command. * Otherwise assume it is coming from a function. */ if (!MemoryContextContains(QueryContext, stmtNode)) @@ -2556,8 +2543,8 @@ bool IsInTransactionChain(void *stmtNode) { /* - * Return true on same conditions that would make - * PreventTransactionChain error out + * Return true on same conditions that would make PreventTransactionChain + * error out */ if (IsTransactionBlock()) return true; @@ -2705,8 +2692,7 @@ BeginTransactionBlock(void) switch (s->blockState) { /* - * We are not inside a transaction block, so allow one to - * begin. + * We are not inside a transaction block, so allow one to begin. */ case TBLOCK_STARTED: s->blockState = TBLOCK_BEGIN; @@ -2721,7 +2707,7 @@ BeginTransactionBlock(void) case TBLOCK_SUBABORT: ereport(WARNING, (errcode(ERRCODE_ACTIVE_SQL_TRANSACTION), - errmsg("there is already a transaction in progress"))); + errmsg("there is already a transaction in progress"))); break; /* These cases are invalid. */ @@ -2759,7 +2745,7 @@ bool PrepareTransactionBlock(char *gid) { TransactionState s; - bool result; + bool result; /* Set up to commit the current transaction */ result = EndTransactionBlock(); @@ -2832,8 +2818,8 @@ EndTransactionBlock(void) break; /* - * We are in a live subtransaction block. Set up to subcommit - * all open subtransactions and then commit the main transaction. + * We are in a live subtransaction block. Set up to subcommit all + * open subtransactions and then commit the main transaction. */ case TBLOCK_SUBINPROGRESS: while (s->parent != NULL) @@ -2854,9 +2840,9 @@ EndTransactionBlock(void) break; /* - * Here we are inside an aborted subtransaction. Treat the - * COMMIT as ROLLBACK: set up to abort everything and exit - * the main transaction. + * Here we are inside an aborted subtransaction. Treat the COMMIT + * as ROLLBACK: set up to abort everything and exit the main + * transaction. */ case TBLOCK_SUBABORT: while (s->parent != NULL) @@ -2927,9 +2913,9 @@ UserAbortTransactionBlock(void) switch (s->blockState) { /* - * We are inside a transaction block and we got a ROLLBACK - * command from the user, so tell CommitTransactionCommand - * to abort and exit the transaction block. + * We are inside a transaction block and we got a ROLLBACK command + * from the user, so tell CommitTransactionCommand to abort and + * exit the transaction block. */ case TBLOCK_INPROGRESS: s->blockState = TBLOCK_ABORT_PENDING; @@ -2937,17 +2923,17 @@ UserAbortTransactionBlock(void) /* * We are inside a failed transaction block and we got a ROLLBACK - * command from the user. Abort processing is already done, - * so CommitTransactionCommand just has to cleanup and go back - * to idle state. + * command from the user. Abort processing is already done, so + * CommitTransactionCommand just has to cleanup and go back to + * idle state. */ case TBLOCK_ABORT: s->blockState = TBLOCK_ABORT_END; break; /* - * We are inside a subtransaction. Mark everything - * up to top level as exitable. + * We are inside a subtransaction. Mark everything up to top + * level as exitable. */ case TBLOCK_SUBINPROGRESS: case TBLOCK_SUBABORT: @@ -2972,8 +2958,8 @@ UserAbortTransactionBlock(void) break; /* - * The user issued ABORT when not inside a transaction. Issue - * a WARNING and go to abort state. The upcoming call to + * The user issued ABORT when not inside a transaction. Issue a + * WARNING and go to abort state. The upcoming call to * CommitTransactionCommand() will then put us back into the * default state. */ @@ -3021,8 +3007,8 @@ DefineSavepoint(char *name) s = CurrentTransactionState; /* changed by push */ /* - * Savepoint names, like the TransactionState block itself, - * live in TopTransactionContext. + * Savepoint names, like the TransactionState block itself, live + * in TopTransactionContext. */ if (name) s->name = MemoryContextStrdup(TopTransactionContext, name); @@ -3078,8 +3064,8 @@ ReleaseSavepoint(List *options) break; /* - * We are in a non-aborted subtransaction. This is the only - * valid case. + * We are in a non-aborted subtransaction. This is the only valid + * case. */ case TBLOCK_SUBINPROGRESS: break; @@ -3134,8 +3120,8 @@ ReleaseSavepoint(List *options) /* * Mark "commit pending" all subtransactions up to the target - * subtransaction. The actual commits will happen when control gets - * to CommitTransactionCommand. + * subtransaction. The actual commits will happen when control gets to + * CommitTransactionCommand. */ xact = CurrentTransactionState; for (;;) @@ -3232,8 +3218,8 @@ RollbackToSavepoint(List *options) /* * Mark "abort pending" all subtransactions up to the target - * subtransaction. The actual aborts will happen when control gets - * to CommitTransactionCommand. + * subtransaction. The actual aborts will happen when control gets to + * CommitTransactionCommand. */ xact = CurrentTransactionState; for (;;) @@ -3284,8 +3270,8 @@ BeginInternalSubTransaction(char *name) s = CurrentTransactionState; /* changed by push */ /* - * Savepoint names, like the TransactionState block itself, - * live in TopTransactionContext. + * Savepoint names, like the TransactionState block itself, live + * in TopTransactionContext. */ if (name) s->name = MemoryContextStrdup(TopTransactionContext, name); @@ -3333,7 +3319,7 @@ ReleaseCurrentSubTransaction(void) Assert(s->state == TRANS_INPROGRESS); MemoryContextSwitchTo(CurTransactionContext); CommitSubTransaction(); - s = CurrentTransactionState; /* changed by pop */ + s = CurrentTransactionState; /* changed by pop */ Assert(s->state == TRANS_INPROGRESS); } @@ -3433,8 +3419,7 @@ AbortOutOfAnyTransaction(void) break; /* - * In a subtransaction, so clean it up and abort parent - * too + * In a subtransaction, so clean it up and abort parent too */ case TBLOCK_SUBBEGIN: case TBLOCK_SUBINPROGRESS: @@ -3667,9 +3652,9 @@ CommitSubTransaction(void) s->parent->subTransactionId); /* - * We need to restore the upper transaction's read-only state, in case - * the upper is read-write while the child is read-only; GUC will - * incorrectly think it should leave the child state in place. + * We need to restore the upper transaction's read-only state, in case the + * upper is read-write while the child is read-only; GUC will incorrectly + * think it should leave the child state in place. */ XactReadOnly = s->prevXactReadOnly; @@ -3706,8 +3691,8 @@ AbortSubTransaction(void) /* * Release any LW locks we might be holding as quickly as possible. * (Regular locks, however, must be held till we finish aborting.) - * Releasing LW locks is critical since we might try to grab them - * again while cleaning up! + * Releasing LW locks is critical since we might try to grab them again + * while cleaning up! * * FIXME This may be incorrect --- Are there some locks we should keep? * Buffer locks, for example? I don't think so but I'm not sure. @@ -3726,8 +3711,8 @@ AbortSubTransaction(void) AtSubAbort_ResourceOwner(); /* - * We can skip all this stuff if the subxact failed before creating - * a ResourceOwner... + * We can skip all this stuff if the subxact failed before creating a + * ResourceOwner... */ if (s->curTransactionOwner) { @@ -3777,25 +3762,23 @@ AbortSubTransaction(void) } /* - * Reset user id which might have been changed transiently. Here we - * want to restore to the userid that was current at subxact entry. - * (As in AbortTransaction, we need not worry about the session - * userid.) + * Reset user id which might have been changed transiently. Here we want + * to restore to the userid that was current at subxact entry. (As in + * AbortTransaction, we need not worry about the session userid.) * - * Must do this after AtEOXact_GUC to handle the case where we entered - * the subxact inside a SECURITY DEFINER function (hence current and - * session userids were different) and then session auth was changed - * inside the subxact. GUC will reset both current and session - * userids to the entry-time session userid. This is right in every - * other scenario so it seems simplest to let GUC do that and fix it - * here. + * Must do this after AtEOXact_GUC to handle the case where we entered the + * subxact inside a SECURITY DEFINER function (hence current and session + * userids were different) and then session auth was changed inside the + * subxact. GUC will reset both current and session userids to the + * entry-time session userid. This is right in every other scenario so it + * seems simplest to let GUC do that and fix it here. */ SetUserId(s->currentUser); /* - * Restore the upper transaction's read-only state, too. This should - * be redundant with GUC's cleanup but we may as well do it for - * consistency with the commit case. + * Restore the upper transaction's read-only state, too. This should be + * redundant with GUC's cleanup but we may as well do it for consistency + * with the commit case. */ XactReadOnly = s->prevXactReadOnly; @@ -3846,11 +3829,11 @@ PushTransaction(void) { TransactionState p = CurrentTransactionState; TransactionState s; - Oid currentUser; + Oid currentUser; /* - * At present, GetUserId cannot fail, but let's not assume that. Get - * the ID before entering the critical code sequence. + * At present, GetUserId cannot fail, but let's not assume that. Get the + * ID before entering the critical code sequence. */ currentUser = GetUserId(); @@ -3860,6 +3843,7 @@ PushTransaction(void) s = (TransactionState) MemoryContextAllocZero(TopTransactionContext, sizeof(TransactionStateData)); + /* * Assign a subtransaction ID, watching out for counter wraparound. */ @@ -3872,11 +3856,12 @@ PushTransaction(void) (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), errmsg("cannot have more than 2^32-1 subtransactions in a transaction"))); } + /* * We can now stack a minimally valid subtransaction without fear of * failure. */ - s->transactionId = InvalidTransactionId; /* until assigned */ + s->transactionId = InvalidTransactionId; /* until assigned */ s->subTransactionId = currentSubTransactionId; s->parent = p; s->nestingLevel = p->nestingLevel + 1; @@ -3889,10 +3874,10 @@ PushTransaction(void) CurrentTransactionState = s; /* - * AbortSubTransaction and CleanupSubTransaction have to be able to - * cope with the subtransaction from here on out; in particular they - * should not assume that it necessarily has a transaction context, - * resource owner, or XID. + * AbortSubTransaction and CleanupSubTransaction have to be able to cope + * with the subtransaction from here on out; in particular they should not + * assume that it necessarily has a transaction context, resource owner, + * or XID. */ } @@ -3959,7 +3944,7 @@ ShowTransactionStateRec(TransactionState s) /* use ereport to suppress computation if msg will not be printed */ ereport(DEBUG3, (errmsg_internal("name: %s; blockState: %13s; state: %7s, xid/subid/cid: %u/%u/%u, nestlvl: %d, children: %s", - PointerIsValid(s->name) ? s->name : "unnamed", + PointerIsValid(s->name) ? s->name : "unnamed", BlockStateAsString(s->blockState), TransStateAsString(s->state), (unsigned int) s->transactionId, @@ -4215,7 +4200,7 @@ xact_desc_commit(char *buf, xl_xact_commit *xlrec) if (xlrec->nsubxacts > 0) { TransactionId *xacts = (TransactionId *) - &xlrec->xnodes[xlrec->nrels]; + &xlrec->xnodes[xlrec->nrels]; sprintf(buf + strlen(buf), "; subxacts:"); for (i = 0; i < xlrec->nsubxacts; i++) @@ -4246,7 +4231,7 @@ xact_desc_abort(char *buf, xl_xact_abort *xlrec) if (xlrec->nsubxacts > 0) { TransactionId *xacts = (TransactionId *) - &xlrec->xnodes[xlrec->nrels]; + &xlrec->xnodes[xlrec->nrels]; sprintf(buf + strlen(buf), "; subxacts:"); for (i = 0; i < xlrec->nsubxacts; i++) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 878d7e21ef..7a37c656dc 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.219 2005/10/03 00:28:41 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.220 2005/10/15 02:49:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -51,7 +51,7 @@ /* * Because O_DIRECT bypasses the kernel buffers, and because we never * read those buffers except during crash recovery, it is a win to use - * it in all cases where we sync on each write(). We could allow O_DIRECT + * it in all cases where we sync on each write(). We could allow O_DIRECT * with fsync(), but because skipping the kernel buffer forces writes out * quickly, it seems best just to use it for O_SYNC. It is hard to imagine * how fsync() could be a win for O_DIRECT compared to O_SYNC and O_DIRECT. @@ -85,14 +85,14 @@ #if O_DSYNC != BARE_OPEN_SYNC_FLAG #define OPEN_DATASYNC_FLAG (O_DSYNC | PG_O_DIRECT) #endif -#else /* !defined(OPEN_SYNC_FLAG) */ +#else /* !defined(OPEN_SYNC_FLAG) */ /* Win32 only has O_DSYNC */ #define OPEN_DATASYNC_FLAG (O_DSYNC | PG_O_DIRECT) #endif #endif #if defined(OPEN_DATASYNC_FLAG) -#define DEFAULT_SYNC_METHOD_STR "open_datasync" +#define DEFAULT_SYNC_METHOD_STR "open_datasync" #define DEFAULT_SYNC_METHOD SYNC_METHOD_OPEN #define DEFAULT_SYNC_FLAGBIT OPEN_DATASYNC_FLAG #elif defined(HAVE_FDATASYNC) @@ -154,7 +154,7 @@ bool XLOG_DEBUG = false; /* these are derived from XLOG_sync_method by assign_xlog_sync_method */ -int sync_method = DEFAULT_SYNC_METHOD; +int sync_method = DEFAULT_SYNC_METHOD; static int open_sync_bit = DEFAULT_SYNC_FLAGBIT; #define XLOG_SYNC_BIT (enableFsync ? open_sync_bit : 0) @@ -368,10 +368,9 @@ typedef struct XLogCtlData XLogCtlWrite Write; /* - * These values do not change after startup, although the pointed-to - * pages and xlblocks values certainly do. Permission to read/write - * the pages and xlblocks values depends on WALInsertLock and - * WALWriteLock. + * These values do not change after startup, although the pointed-to pages + * and xlblocks values certainly do. Permission to read/write the pages + * and xlblocks values depends on WALInsertLock and WALWriteLock. */ char *pages; /* buffers for unwritten XLOG pages */ XLogRecPtr *xlblocks; /* 1st byte ptr-s + BLCKSZ */ @@ -449,8 +448,8 @@ static char *readRecordBuf = NULL; static uint32 readRecordBufSize = 0; /* State information for XLOG reading */ -static XLogRecPtr ReadRecPtr; /* start of last record read */ -static XLogRecPtr EndRecPtr; /* end+1 of last record read */ +static XLogRecPtr ReadRecPtr; /* start of last record read */ +static XLogRecPtr EndRecPtr; /* end+1 of last record read */ static XLogRecord *nextRecord = NULL; static TimeLineID lastPageTLI = 0; @@ -467,7 +466,7 @@ static void exitArchiveRecovery(TimeLineID endTLI, static bool recoveryStopsHere(XLogRecord *record, bool *includeThis); static bool XLogCheckBuffer(XLogRecData *rdata, - XLogRecPtr *lsn, BkpBlock *bkpb); + XLogRecPtr *lsn, BkpBlock *bkpb); static bool AdvanceXLInsertBuffer(void); static void XLogWrite(XLogwrtRqst WriteRqst, bool flexible); static int XLogFileInit(uint32 log, uint32 seg, @@ -481,7 +480,7 @@ static bool RestoreArchivedFile(char *path, const char *xlogfname, const char *recovername, off_t expectedSize); static int PreallocXlogFiles(XLogRecPtr endptr); static void MoveOfflineLogs(uint32 log, uint32 seg, XLogRecPtr endptr, - int *nsegsremoved, int *nsegsrecycled); + int *nsegsremoved, int *nsegsrecycled); static void RemoveOldBackupHistory(void); static XLogRecord *ReadRecord(XLogRecPtr *RecPtr, int emode); static bool ValidXLOGHeader(XLogPageHeader hdr, int emode); @@ -554,36 +553,34 @@ XLogInsert(RmgrId rmid, uint8 info, XLogRecData *rdata) } /* - * In bootstrap mode, we don't actually log anything but XLOG - * resources; return a phony record pointer. + * In bootstrap mode, we don't actually log anything but XLOG resources; + * return a phony record pointer. */ if (IsBootstrapProcessingMode() && rmid != RM_XLOG_ID) { RecPtr.xlogid = 0; - RecPtr.xrecoff = SizeOfXLogLongPHD; /* start of 1st chkpt - * record */ + RecPtr.xrecoff = SizeOfXLogLongPHD; /* start of 1st chkpt record */ return (RecPtr); } /* * Here we scan the rdata chain, determine which buffers must be backed * up, and compute the CRC values for the data. Note that the record - * header isn't added into the CRC initially since we don't know the - * final length or info bits quite yet. Thus, the CRC will represent - * the CRC of the whole record in the order "rdata, then backup blocks, - * then record header". + * header isn't added into the CRC initially since we don't know the final + * length or info bits quite yet. Thus, the CRC will represent the CRC of + * the whole record in the order "rdata, then backup blocks, then record + * header". * - * We may have to loop back to here if a race condition is detected - * below. We could prevent the race by doing all this work while - * holding the insert lock, but it seems better to avoid doing CRC - * calculations while holding the lock. This means we have to be - * careful about modifying the rdata chain until we know we aren't - * going to loop back again. The only change we allow ourselves to - * make earlier is to set rdt->data = NULL in chain items we have - * decided we will have to back up the whole buffer for. This is OK - * because we will certainly decide the same thing again for those - * items if we do it over; doing it here saves an extra pass over the - * chain later. + * We may have to loop back to here if a race condition is detected below. We + * could prevent the race by doing all this work while holding the insert + * lock, but it seems better to avoid doing CRC calculations while holding + * the lock. This means we have to be careful about modifying the rdata + * chain until we know we aren't going to loop back again. The only + * change we allow ourselves to make earlier is to set rdt->data = NULL in + * chain items we have decided we will have to back up the whole buffer + * for. This is OK because we will certainly decide the same thing again + * for those items if we do it over; doing it here saves an extra pass + * over the chain later. */ begin:; for (i = 0; i < XLR_MAX_BKP_BLOCKS; i++) @@ -680,12 +677,12 @@ begin:; } /* - * NOTE: the test for len == 0 here is somewhat fishy, since in theory - * all of the rmgr data might have been suppressed in favor of backup - * blocks. Currently, all callers of XLogInsert provide at least some - * not-in-a-buffer data and so len == 0 should never happen, but that - * may not be true forever. If you need to remove the len == 0 check, - * also remove the check for xl_len == 0 in ReadRecord, below. + * NOTE: the test for len == 0 here is somewhat fishy, since in theory all + * of the rmgr data might have been suppressed in favor of backup blocks. + * Currently, all callers of XLogInsert provide at least some + * not-in-a-buffer data and so len == 0 should never happen, but that may + * not be true forever. If you need to remove the len == 0 check, also + * remove the check for xl_len == 0 in ReadRecord, below. */ if (len == 0) elog(PANIC, "invalid xlog record length %u", len); @@ -718,9 +715,9 @@ begin:; * Since the amount of data we write here is completely optional * anyway, tell XLogWrite it can be "flexible" and stop at a * convenient boundary. This allows writes triggered by this - * mechanism to synchronize with the cache boundaries, so that - * in a long transaction we'll basically dump alternating halves - * of the buffer array. + * mechanism to synchronize with the cache boundaries, so that in + * a long transaction we'll basically dump alternating halves of + * the buffer array. */ LogwrtResult = XLogCtl->Write.LogwrtResult; if (XLByteLT(LogwrtResult.Write, LogwrtRqst.Write)) @@ -733,10 +730,9 @@ begin:; LWLockAcquire(WALInsertLock, LW_EXCLUSIVE); /* - * Check to see if my RedoRecPtr is out of date. If so, may have to - * go back and recompute everything. This can only happen just after - * a checkpoint, so it's better to be slow in this case and fast - * otherwise. + * Check to see if my RedoRecPtr is out of date. If so, may have to go + * back and recompute everything. This can only happen just after a + * checkpoint, so it's better to be slow in this case and fast otherwise. */ if (!XLByteEQ(RedoRecPtr, Insert->RedoRecPtr)) { @@ -751,8 +747,8 @@ begin:; XLByteLE(dtbuf_lsn[i], RedoRecPtr)) { /* - * Oops, this buffer now needs to be backed up, but we - * didn't think so above. Start over. + * Oops, this buffer now needs to be backed up, but we didn't + * think so above. Start over. */ LWLockRelease(WALInsertLock); END_CRIT_SECTION(); @@ -762,15 +758,14 @@ begin:; } /* - * Make additional rdata chain entries for the backup blocks, so that - * we don't need to special-case them in the write loop. Note that we - * have now irrevocably changed the input rdata chain. At the exit of - * this loop, write_len includes the backup block data. + * Make additional rdata chain entries for the backup blocks, so that we + * don't need to special-case them in the write loop. Note that we have + * now irrevocably changed the input rdata chain. At the exit of this + * loop, write_len includes the backup block data. * - * Also set the appropriate info bits to show which buffers were backed - * up. The i'th XLR_SET_BKP_BLOCK bit corresponds to the i'th - * distinct buffer value (ignoring InvalidBuffer) appearing in the - * rdata chain. + * Also set the appropriate info bits to show which buffers were backed up. + * The i'th XLR_SET_BKP_BLOCK bit corresponds to the i'th distinct buffer + * value (ignoring InvalidBuffer) appearing in the rdata chain. */ write_len = len; for (i = 0; i < XLR_MAX_BKP_BLOCKS; i++) @@ -822,8 +817,7 @@ begin:; /* * If there isn't enough space on the current XLOG page for a record - * header, advance to the next page (leaving the unused space as - * zeroes). + * header, advance to the next page (leaving the unused space as zeroes). */ updrqst = false; freespace = INSERT_FREESPACE(Insert); @@ -925,15 +919,15 @@ begin:; freespace = INSERT_FREESPACE(Insert); /* - * The recptr I return is the beginning of the *next* record. This - * will be stored as LSN for changed data pages... + * The recptr I return is the beginning of the *next* record. This will be + * stored as LSN for changed data pages... */ INSERT_RECPTR(RecPtr, Insert, curridx); /* Need to update shared LogwrtRqst if some block was filled up */ if (freespace < SizeOfXLogRecord) - updrqst = true; /* curridx is filled and available for - * writing out */ + updrqst = true; /* curridx is filled and available for writing + * out */ else curridx = PrevBufIdx(curridx); WriteRqst = XLogCtl->xlblocks[curridx]; @@ -975,9 +969,9 @@ XLogCheckBuffer(XLogRecData *rdata, page = (PageHeader) BufferGetBlock(rdata->buffer); /* - * XXX We assume page LSN is first data on *every* page that can be - * passed to XLogInsert, whether it otherwise has the standard page - * layout or not. + * XXX We assume page LSN is first data on *every* page that can be passed + * to XLogInsert, whether it otherwise has the standard page layout or + * not. */ *lsn = page->pd_lsn; @@ -1163,9 +1157,9 @@ AdvanceXLInsertBuffer(void) LogwrtResult = Insert->LogwrtResult; /* - * Get ending-offset of the buffer page we need to replace (this may - * be zero if the buffer hasn't been used yet). Fall through if it's - * already written out. + * Get ending-offset of the buffer page we need to replace (this may be + * zero if the buffer hasn't been used yet). Fall through if it's already + * written out. */ OldPageRqstPtr = XLogCtl->xlblocks[nextidx]; if (!XLByteLE(OldPageRqstPtr, LogwrtResult.Write)) @@ -1208,9 +1202,8 @@ AdvanceXLInsertBuffer(void) else { /* - * Have to write buffers while holding insert lock. This - * is not good, so only write as much as we absolutely - * must. + * Have to write buffers while holding insert lock. This is + * not good, so only write as much as we absolutely must. */ WriteRqst.Write = OldPageRqstPtr; WriteRqst.Flush.xlogid = 0; @@ -1223,8 +1216,8 @@ AdvanceXLInsertBuffer(void) } /* - * Now the next buffer slot is free and we can set it up to be the - * next output page. + * Now the next buffer slot is free and we can set it up to be the next + * output page. */ NewPageEndPtr = XLogCtl->xlblocks[Insert->curridx]; if (NewPageEndPtr.xrecoff >= XLogFileSize) @@ -1237,24 +1230,27 @@ AdvanceXLInsertBuffer(void) NewPageEndPtr.xrecoff += BLCKSZ; XLogCtl->xlblocks[nextidx] = NewPageEndPtr; NewPage = (XLogPageHeader) (XLogCtl->pages + nextidx * (Size) BLCKSZ); + Insert->curridx = nextidx; Insert->currpage = NewPage; - Insert->currpos = ((char *) NewPage) + SizeOfXLogShortPHD; + + Insert->currpos = ((char *) NewPage) +SizeOfXLogShortPHD; /* - * Be sure to re-zero the buffer so that bytes beyond what we've - * written will look like zeroes and not valid XLOG records... + * Be sure to re-zero the buffer so that bytes beyond what we've written + * will look like zeroes and not valid XLOG records... */ MemSet((char *) NewPage, 0, BLCKSZ); /* * Fill the new page's header */ - NewPage->xlp_magic = XLOG_PAGE_MAGIC; + NewPage ->xlp_magic = XLOG_PAGE_MAGIC; + /* NewPage->xlp_info = 0; */ /* done by memset */ - NewPage->xlp_tli = ThisTimeLineID; - NewPage->xlp_pageaddr.xlogid = NewPageEndPtr.xlogid; - NewPage->xlp_pageaddr.xrecoff = NewPageEndPtr.xrecoff - BLCKSZ; + NewPage ->xlp_tli = ThisTimeLineID; + NewPage ->xlp_pageaddr.xlogid = NewPageEndPtr.xlogid; + NewPage ->xlp_pageaddr.xrecoff = NewPageEndPtr.xrecoff - BLCKSZ; /* * If first page of an XLOG segment file, make it a long header. @@ -1265,8 +1261,9 @@ AdvanceXLInsertBuffer(void) NewLongPage->xlp_sysid = ControlFile->system_identifier; NewLongPage->xlp_seg_size = XLogSegSize; - NewPage->xlp_info |= XLP_LONG_HEADER; - Insert->currpos = ((char *) NewPage) + SizeOfXLogLongPHD; + NewPage ->xlp_info |= XLP_LONG_HEADER; + + Insert->currpos = ((char *) NewPage) +SizeOfXLogLongPHD; } return update_needed; @@ -1298,19 +1295,18 @@ XLogWrite(XLogwrtRqst WriteRqst, bool flexible) Assert(CritSectionCount > 0); /* - * Update local LogwrtResult (caller probably did this already, - * but...) + * Update local LogwrtResult (caller probably did this already, but...) */ LogwrtResult = Write->LogwrtResult; /* * Since successive pages in the xlog cache are consecutively allocated, * we can usually gather multiple pages together and issue just one - * write() call. npages is the number of pages we have determined can - * be written together; startidx is the cache block index of the first - * one, and startoffset is the file offset at which it should go. - * The latter two variables are only valid when npages > 0, but we must - * initialize all of them to keep the compiler quiet. + * write() call. npages is the number of pages we have determined can be + * written together; startidx is the cache block index of the first one, + * and startoffset is the file offset at which it should go. The latter + * two variables are only valid when npages > 0, but we must initialize + * all of them to keep the compiler quiet. */ npages = 0; startidx = 0; @@ -1320,18 +1316,17 @@ XLogWrite(XLogwrtRqst WriteRqst, bool flexible) * Within the loop, curridx is the cache block index of the page to * consider writing. We advance Write->curridx only after successfully * writing pages. (Right now, this refinement is useless since we are - * going to PANIC if any error occurs anyway; but someday it may come - * in useful.) + * going to PANIC if any error occurs anyway; but someday it may come in + * useful.) */ curridx = Write->curridx; while (XLByteLT(LogwrtResult.Write, WriteRqst.Write)) { /* - * Make sure we're not ahead of the insert process. This could - * happen if we're passed a bogus WriteRqst.Write that is past the - * end of the last page that's been initialized by - * AdvanceXLInsertBuffer. + * Make sure we're not ahead of the insert process. This could happen + * if we're passed a bogus WriteRqst.Write that is past the end of the + * last page that's been initialized by AdvanceXLInsertBuffer. */ if (!XLByteLT(LogwrtResult.Write, XLogCtl->xlblocks[curridx])) elog(PANIC, "xlog write request %X/%X is past end of log %X/%X", @@ -1355,8 +1350,8 @@ XLogWrite(XLogwrtRqst WriteRqst, bool flexible) if (close(openLogFile)) ereport(PANIC, (errcode_for_file_access(), - errmsg("could not close log file %u, segment %u: %m", - openLogId, openLogSeg))); + errmsg("could not close log file %u, segment %u: %m", + openLogId, openLogSeg))); openLogFile = -1; } XLByteToPrevSeg(LogwrtResult.Write, openLogId, openLogSeg); @@ -1379,13 +1374,13 @@ XLogWrite(XLogwrtRqst WriteRqst, bool flexible) UpdateControlFile(); /* - * Signal bgwriter to start a checkpoint if it's been - * too long since the last one. (We look at local copy of - * RedoRecPtr which might be a little out of date, but - * should be close enough for this purpose.) + * Signal bgwriter to start a checkpoint if it's been too long + * since the last one. (We look at local copy of RedoRecPtr + * which might be a little out of date, but should be close + * enough for this purpose.) * - * A straight computation of segment number could overflow - * 32 bits. Rather than assuming we have working 64-bit + * A straight computation of segment number could overflow 32 + * bits. Rather than assuming we have working 64-bit * arithmetic, we compare the highest-order bits separately, * and force a checkpoint immediately when they change. */ @@ -1434,10 +1429,10 @@ XLogWrite(XLogwrtRqst WriteRqst, bool flexible) npages++; /* - * Dump the set if this will be the last loop iteration, or if - * we are at the last page of the cache area (since the next page - * won't be contiguous in memory), or if we are at the end of the - * logfile segment. + * Dump the set if this will be the last loop iteration, or if we are + * at the last page of the cache area (since the next page won't be + * contiguous in memory), or if we are at the end of the logfile + * segment. */ finishing_seg = !ispartialpage && (startoffset + npages * BLCKSZ) >= XLogSegSize; @@ -1496,7 +1491,7 @@ XLogWrite(XLogwrtRqst WriteRqst, bool flexible) if (finishing_seg) { issue_xlog_fsync(); - LogwrtResult.Flush = LogwrtResult.Write; /* end of page */ + LogwrtResult.Flush = LogwrtResult.Write; /* end of page */ if (XLogArchivingActive()) XLogArchiveNotifySeg(openLogId, openLogSeg); @@ -1526,20 +1521,20 @@ XLogWrite(XLogwrtRqst WriteRqst, bool flexible) XLByteLT(LogwrtResult.Flush, LogwrtResult.Write)) { /* - * Could get here without iterating above loop, in which case we - * might have no open file or the wrong one. However, we do not - * need to fsync more than one file. + * Could get here without iterating above loop, in which case we might + * have no open file or the wrong one. However, we do not need to + * fsync more than one file. */ if (sync_method != SYNC_METHOD_OPEN) { if (openLogFile >= 0 && - !XLByteInPrevSeg(LogwrtResult.Write, openLogId, openLogSeg)) + !XLByteInPrevSeg(LogwrtResult.Write, openLogId, openLogSeg)) { if (close(openLogFile)) ereport(PANIC, (errcode_for_file_access(), - errmsg("could not close log file %u, segment %u: %m", - openLogId, openLogSeg))); + errmsg("could not close log file %u, segment %u: %m", + openLogId, openLogSeg))); openLogFile = -1; } if (openLogFile < 0) @@ -1557,8 +1552,8 @@ XLogWrite(XLogwrtRqst WriteRqst, bool flexible) * Update shared-memory status * * We make sure that the shared 'request' values do not fall behind the - * 'result' values. This is not absolutely essential, but it saves - * some code in a couple of places. + * 'result' values. This is not absolutely essential, but it saves some + * code in a couple of places. */ { /* use volatile pointer to prevent code rearrangement */ @@ -1608,11 +1603,10 @@ XLogFlush(XLogRecPtr record) /* * Since fsync is usually a horribly expensive operation, we try to - * piggyback as much data as we can on each fsync: if we see any more - * data entered into the xlog buffer, we'll write and fsync that too, - * so that the final value of LogwrtResult.Flush is as large as - * possible. This gives us some chance of avoiding another fsync - * immediately after. + * piggyback as much data as we can on each fsync: if we see any more data + * entered into the xlog buffer, we'll write and fsync that too, so that + * the final value of LogwrtResult.Flush is as large as possible. This + * gives us some chance of avoiding another fsync immediately after. */ /* initialize to given target; may increase below */ @@ -1669,31 +1663,29 @@ XLogFlush(XLogRecPtr record) /* * If we still haven't flushed to the request point then we have a - * problem; most likely, the requested flush point is past end of - * XLOG. This has been seen to occur when a disk page has a corrupted - * LSN. + * problem; most likely, the requested flush point is past end of XLOG. + * This has been seen to occur when a disk page has a corrupted LSN. * - * Formerly we treated this as a PANIC condition, but that hurts the - * system's robustness rather than helping it: we do not want to take - * down the whole system due to corruption on one data page. In - * particular, if the bad page is encountered again during recovery - * then we would be unable to restart the database at all! (This - * scenario has actually happened in the field several times with 7.1 - * releases. Note that we cannot get here while InRedo is true, but if - * the bad page is brought in and marked dirty during recovery then - * CreateCheckPoint will try to flush it at the end of recovery.) + * Formerly we treated this as a PANIC condition, but that hurts the system's + * robustness rather than helping it: we do not want to take down the + * whole system due to corruption on one data page. In particular, if the + * bad page is encountered again during recovery then we would be unable + * to restart the database at all! (This scenario has actually happened + * in the field several times with 7.1 releases. Note that we cannot get + * here while InRedo is true, but if the bad page is brought in and marked + * dirty during recovery then CreateCheckPoint will try to flush it at the + * end of recovery.) * - * The current approach is to ERROR under normal conditions, but only - * WARNING during recovery, so that the system can be brought up even - * if there's a corrupt LSN. Note that for calls from xact.c, the - * ERROR will be promoted to PANIC since xact.c calls this routine - * inside a critical section. However, calls from bufmgr.c are not - * within critical sections and so we will not force a restart for a - * bad LSN on a data page. + * The current approach is to ERROR under normal conditions, but only WARNING + * during recovery, so that the system can be brought up even if there's a + * corrupt LSN. Note that for calls from xact.c, the ERROR will be + * promoted to PANIC since xact.c calls this routine inside a critical + * section. However, calls from bufmgr.c are not within critical sections + * and so we will not force a restart for a bad LSN on a data page. */ if (XLByteLT(LogwrtResult.Flush, record)) elog(InRecovery ? WARNING : ERROR, - "xlog flush request %X/%X is not satisfied --- flushed only to %X/%X", + "xlog flush request %X/%X is not satisfied --- flushed only to %X/%X", record.xlogid, record.xrecoff, LogwrtResult.Flush.xlogid, LogwrtResult.Flush.xrecoff); } @@ -1734,8 +1726,7 @@ XLogFileInit(uint32 log, uint32 seg, XLogFilePath(path, ThisTimeLineID, log, seg); /* - * Try to use existent file (checkpoint maker may have created it - * already) + * Try to use existent file (checkpoint maker may have created it already) */ if (*use_existent) { @@ -1754,10 +1745,10 @@ XLogFileInit(uint32 log, uint32 seg, } /* - * Initialize an empty (all zeroes) segment. NOTE: it is possible - * that another process is doing the same thing. If so, we will end - * up pre-creating an extra log segment. That seems OK, and better - * than holding the lock throughout this lengthy process. + * Initialize an empty (all zeroes) segment. NOTE: it is possible that + * another process is doing the same thing. If so, we will end up + * pre-creating an extra log segment. That seems OK, and better than + * holding the lock throughout this lengthy process. */ snprintf(tmppath, MAXPGPATH, XLOGDIR "/xlogtemp.%d", (int) getpid()); @@ -1772,13 +1763,13 @@ XLogFileInit(uint32 log, uint32 seg, errmsg("could not create file \"%s\": %m", tmppath))); /* - * Zero-fill the file. We have to do this the hard way to ensure that - * all the file space has really been allocated --- on platforms that - * allow "holes" in files, just seeking to the end doesn't allocate - * intermediate space. This way, we know that we have all the space - * and (after the fsync below) that all the indirect blocks are down - * on disk. Therefore, fdatasync(2) or O_DSYNC will be sufficient to - * sync future writes to the log file. + * Zero-fill the file. We have to do this the hard way to ensure that all + * the file space has really been allocated --- on platforms that allow + * "holes" in files, just seeking to the end doesn't allocate intermediate + * space. This way, we know that we have all the space and (after the + * fsync below) that all the indirect blocks are down on disk. Therefore, + * fdatasync(2) or O_DSYNC will be sufficient to sync future writes to the + * log file. */ MemSet(zbuffer, 0, sizeof(zbuffer)); for (nbytes = 0; nbytes < XLogSegSize; nbytes += sizeof(zbuffer)) @@ -1789,8 +1780,7 @@ XLogFileInit(uint32 log, uint32 seg, int save_errno = errno; /* - * If we fail to make the file, delete it to release disk - * space + * If we fail to make the file, delete it to release disk space */ unlink(tmppath); /* if write didn't set errno, assume problem is no disk space */ @@ -1798,7 +1788,7 @@ XLogFileInit(uint32 log, uint32 seg, ereport(ERROR, (errcode_for_file_access(), - errmsg("could not write to file \"%s\": %m", tmppath))); + errmsg("could not write to file \"%s\": %m", tmppath))); } } @@ -1816,9 +1806,9 @@ XLogFileInit(uint32 log, uint32 seg, * Now move the segment into place with its final name. * * If caller didn't want to use a pre-existing file, get rid of any - * pre-existing file. Otherwise, cope with possibility that someone - * else has created the file while we were filling ours: if so, use - * ours to pre-create a future log segment. + * pre-existing file. Otherwise, cope with possibility that someone else + * has created the file while we were filling ours: if so, use ours to + * pre-create a future log segment. */ installed_log = log; installed_seg = seg; @@ -1840,8 +1830,8 @@ XLogFileInit(uint32 log, uint32 seg, if (fd < 0) ereport(ERROR, (errcode_for_file_access(), - errmsg("could not open file \"%s\" (log file %u, segment %u): %m", - path, log, seg))); + errmsg("could not open file \"%s\" (log file %u, segment %u): %m", + path, log, seg))); return (fd); } @@ -1908,7 +1898,7 @@ XLogFileCopy(uint32 log, uint32 seg, errmsg("could not read file \"%s\": %m", path))); else ereport(ERROR, - (errmsg("not enough data in file \"%s\"", path))); + (errmsg("not enough data in file \"%s\"", path))); } errno = 0; if ((int) write(fd, buffer, sizeof(buffer)) != (int) sizeof(buffer)) @@ -1916,8 +1906,7 @@ XLogFileCopy(uint32 log, uint32 seg, int save_errno = errno; /* - * If we fail to make the file, delete it to release disk - * space + * If we fail to make the file, delete it to release disk space */ unlink(tmppath); /* if write didn't set errno, assume problem is no disk space */ @@ -1925,7 +1914,7 @@ XLogFileCopy(uint32 log, uint32 seg, ereport(ERROR, (errcode_for_file_access(), - errmsg("could not write to file \"%s\": %m", tmppath))); + errmsg("could not write to file \"%s\": %m", tmppath))); } } @@ -2057,8 +2046,8 @@ XLogFileOpen(uint32 log, uint32 seg) if (fd < 0) ereport(PANIC, (errcode_for_file_access(), - errmsg("could not open file \"%s\" (log file %u, segment %u): %m", - path, log, seg))); + errmsg("could not open file \"%s\" (log file %u, segment %u): %m", + path, log, seg))); return fd; } @@ -2075,14 +2064,14 @@ XLogFileRead(uint32 log, uint32 seg, int emode) int fd; /* - * Loop looking for a suitable timeline ID: we might need to read any - * of the timelines listed in expectedTLIs. + * Loop looking for a suitable timeline ID: we might need to read any of + * the timelines listed in expectedTLIs. * * We expect curFileTLI on entry to be the TLI of the preceding file in - * sequence, or 0 if there was no predecessor. We do not allow - * curFileTLI to go backwards; this prevents us from picking up the - * wrong file when a parent timeline extends to higher segment numbers - * than the child we want to read. + * sequence, or 0 if there was no predecessor. We do not allow curFileTLI + * to go backwards; this prevents us from picking up the wrong file when a + * parent timeline extends to higher segment numbers than the child we + * want to read. */ foreach(cell, expectedTLIs) { @@ -2111,8 +2100,8 @@ XLogFileRead(uint32 log, uint32 seg, int emode) if (errno != ENOENT) /* unexpected failure? */ ereport(PANIC, (errcode_for_file_access(), - errmsg("could not open file \"%s\" (log file %u, segment %u): %m", - path, log, seg))); + errmsg("could not open file \"%s\" (log file %u, segment %u): %m", + path, log, seg))); } /* Couldn't find it. For simplicity, complain about front timeline */ @@ -2120,8 +2109,8 @@ XLogFileRead(uint32 log, uint32 seg, int emode) errno = ENOENT; ereport(emode, (errcode_for_file_access(), - errmsg("could not open file \"%s\" (log file %u, segment %u): %m", - path, log, seg))); + errmsg("could not open file \"%s\" (log file %u, segment %u): %m", + path, log, seg))); return -1; } @@ -2152,29 +2141,27 @@ RestoreArchivedFile(char *path, const char *xlogfname, struct stat stat_buf; /* - * When doing archive recovery, we always prefer an archived log file - * even if a file of the same name exists in XLOGDIR. The reason is - * that the file in XLOGDIR could be an old, un-filled or - * partly-filled version that was copied and restored as part of - * backing up $PGDATA. + * When doing archive recovery, we always prefer an archived log file even + * if a file of the same name exists in XLOGDIR. The reason is that the + * file in XLOGDIR could be an old, un-filled or partly-filled version + * that was copied and restored as part of backing up $PGDATA. * * We could try to optimize this slightly by checking the local copy - * lastchange timestamp against the archived copy, but we have no API - * to do this, nor can we guarantee that the lastchange timestamp was - * preserved correctly when we copied to archive. Our aim is - * robustness, so we elect not to do this. + * lastchange timestamp against the archived copy, but we have no API to + * do this, nor can we guarantee that the lastchange timestamp was + * preserved correctly when we copied to archive. Our aim is robustness, + * so we elect not to do this. * - * If we cannot obtain the log file from the archive, however, we will - * try to use the XLOGDIR file if it exists. This is so that we can - * make use of log segments that weren't yet transferred to the - * archive. + * If we cannot obtain the log file from the archive, however, we will try to + * use the XLOGDIR file if it exists. This is so that we can make use of + * log segments that weren't yet transferred to the archive. * - * Notice that we don't actually overwrite any files when we copy back - * from archive because the recoveryRestoreCommand may inadvertently - * restore inappropriate xlogs, or they may be corrupt, so we may wish - * to fallback to the segments remaining in current XLOGDIR later. The - * copy-from-archive filename is always the same, ensuring that we - * don't run out of disk space on long recoveries. + * Notice that we don't actually overwrite any files when we copy back from + * archive because the recoveryRestoreCommand may inadvertently restore + * inappropriate xlogs, or they may be corrupt, so we may wish to fallback + * to the segments remaining in current XLOGDIR later. The + * copy-from-archive filename is always the same, ensuring that we don't + * run out of disk space on long recoveries. */ snprintf(xlogpath, MAXPGPATH, XLOGDIR "/%s", recovername); @@ -2259,11 +2246,11 @@ RestoreArchivedFile(char *path, const char *xlogfname, * command apparently succeeded, but let's make sure the file is * really there now and has the correct size. * - * XXX I made wrong-size a fatal error to ensure the DBA would notice - * it, but is that too strong? We could try to plow ahead with a - * local copy of the file ... but the problem is that there - * probably isn't one, and we'd incorrectly conclude we've reached - * the end of WAL and we're done recovering ... + * XXX I made wrong-size a fatal error to ensure the DBA would notice it, + * but is that too strong? We could try to plow ahead with a local + * copy of the file ... but the problem is that there probably isn't + * one, and we'd incorrectly conclude we've reached the end of WAL and + * we're done recovering ... */ if (stat(xlogpath, &stat_buf) == 0) { @@ -2296,18 +2283,17 @@ RestoreArchivedFile(char *path, const char *xlogfname, /* * remember, we rollforward UNTIL the restore fails so failure here is * just part of the process... that makes it difficult to determine - * whether the restore failed because there isn't an archive to - * restore, or because the administrator has specified the restore - * program incorrectly. We have to assume the former. + * whether the restore failed because there isn't an archive to restore, + * or because the administrator has specified the restore program + * incorrectly. We have to assume the former. */ ereport(DEBUG2, - (errmsg("could not restore file \"%s\" from archive: return code %d", - xlogfname, rc))); + (errmsg("could not restore file \"%s\" from archive: return code %d", + xlogfname, rc))); /* - * if an archived file is not available, there might still be a - * version of this file in XLOGDIR, so return that as the filename to - * open. + * if an archived file is not available, there might still be a version of + * this file in XLOGDIR, so return that as the filename to open. * * In many recovery scenarios we expect this to fail also, but if so that * just means we've reached the end of WAL. @@ -2375,8 +2361,8 @@ MoveOfflineLogs(uint32 log, uint32 seg, XLogRecPtr endptr, if (xldir == NULL) ereport(ERROR, (errcode_for_file_access(), - errmsg("could not open transaction log directory \"%s\": %m", - XLOGDIR))); + errmsg("could not open transaction log directory \"%s\": %m", + XLOGDIR))); XLogFileName(lastoff, ThisTimeLineID, log, seg); @@ -2384,14 +2370,14 @@ MoveOfflineLogs(uint32 log, uint32 seg, XLogRecPtr endptr, { /* * We ignore the timeline part of the XLOG segment identifiers in - * deciding whether a segment is still needed. This ensures that - * we won't prematurely remove a segment from a parent timeline. - * We could probably be a little more proactive about removing - * segments of non-parent timelines, but that would be a whole lot - * more complicated. + * deciding whether a segment is still needed. This ensures that we + * won't prematurely remove a segment from a parent timeline. We could + * probably be a little more proactive about removing segments of + * non-parent timelines, but that would be a whole lot more + * complicated. * - * We use the alphanumeric sorting property of the filenames to - * decide which ones are earlier than the lastoff segment. + * We use the alphanumeric sorting property of the filenames to decide + * which ones are earlier than the lastoff segment. */ if (strlen(xlde->d_name) == 24 && strspn(xlde->d_name, "0123456789ABCDEF") == 24 && @@ -2409,16 +2395,16 @@ MoveOfflineLogs(uint32 log, uint32 seg, XLogRecPtr endptr, snprintf(path, MAXPGPATH, XLOGDIR "/%s", xlde->d_name); /* - * Before deleting the file, see if it can be recycled as - * a future log segment. + * Before deleting the file, see if it can be recycled as a + * future log segment. */ if (InstallXLogFileSegment(&endlogId, &endlogSeg, path, true, &max_advance, true)) { ereport(DEBUG2, - (errmsg("recycled transaction log file \"%s\"", - xlde->d_name))); + (errmsg("recycled transaction log file \"%s\"", + xlde->d_name))); (*nsegsrecycled)++; /* Needn't recheck that slot on future iterations */ if (max_advance > 0) @@ -2431,8 +2417,8 @@ MoveOfflineLogs(uint32 log, uint32 seg, XLogRecPtr endptr, { /* No need for any more future segments... */ ereport(DEBUG2, - (errmsg("removing transaction log file \"%s\"", - xlde->d_name))); + (errmsg("removing transaction log file \"%s\"", + xlde->d_name))); unlink(path); (*nsegsremoved)++; } @@ -2459,8 +2445,8 @@ RemoveOldBackupHistory(void) if (xldir == NULL) ereport(ERROR, (errcode_for_file_access(), - errmsg("could not open transaction log directory \"%s\": %m", - XLOGDIR))); + errmsg("could not open transaction log directory \"%s\": %m", + XLOGDIR))); while ((xlde = ReadDir(xldir, XLOGDIR)) != NULL) { @@ -2473,8 +2459,8 @@ RemoveOldBackupHistory(void) if (!XLogArchivingActive() || XLogArchiveIsDone(xlde->d_name)) { ereport(DEBUG2, - (errmsg("removing transaction log backup history file \"%s\"", - xlde->d_name))); + (errmsg("removing transaction log backup history file \"%s\"", + xlde->d_name))); snprintf(path, MAXPGPATH, XLOGDIR "/%s", xlde->d_name); unlink(path); XLogArchiveCleanup(xlde->d_name); @@ -2576,7 +2562,7 @@ RecordIsValid(XLogRecord *record, XLogRecPtr recptr, int emode) blk = (char *) XLogRecGetData(record) + len; for (i = 0; i < XLR_MAX_BKP_BLOCKS; i++) { - uint32 blen; + uint32 blen; if (!(record->xl_info & XLR_SET_BKP_BLOCK(i))) continue; @@ -2611,8 +2597,8 @@ RecordIsValid(XLogRecord *record, XLogRecPtr recptr, int emode) if (!EQ_CRC32(record->xl_crc, crc)) { ereport(emode, - (errmsg("incorrect resource manager data checksum in record at %X/%X", - recptr.xlogid, recptr.xrecoff))); + (errmsg("incorrect resource manager data checksum in record at %X/%X", + recptr.xlogid, recptr.xrecoff))); return false; } @@ -2647,12 +2633,11 @@ ReadRecord(XLogRecPtr *RecPtr, int emode) if (readBuf == NULL) { /* - * First time through, permanently allocate readBuf. We do it - * this way, rather than just making a static array, for two - * reasons: (1) no need to waste the storage in most - * instantiations of the backend; (2) a static char array isn't - * guaranteed to have any particular alignment, whereas malloc() - * will provide MAXALIGN'd storage. + * First time through, permanently allocate readBuf. We do it this + * way, rather than just making a static array, for two reasons: (1) + * no need to waste the storage in most instantiations of the backend; + * (2) a static char array isn't guaranteed to have any particular + * alignment, whereas malloc() will provide MAXALIGN'd storage. */ readBuf = (char *) malloc(BLCKSZ); Assert(readBuf != NULL); @@ -2685,11 +2670,11 @@ ReadRecord(XLogRecPtr *RecPtr, int emode) RecPtr->xlogid, RecPtr->xrecoff))); /* - * Since we are going to a random position in WAL, forget any - * prior state about what timeline we were in, and allow it to be - * any timeline in expectedTLIs. We also set a flag to allow - * curFileTLI to go backwards (but we can't reset that variable - * right here, since we might not change files at all). + * Since we are going to a random position in WAL, forget any prior + * state about what timeline we were in, and allow it to be any + * timeline in expectedTLIs. We also set a flag to allow curFileTLI + * to go backwards (but we can't reset that variable right here, since + * we might not change files at all). */ lastPageTLI = 0; /* see comment in ValidXLOGHeader */ randAccess = true; /* allow curFileTLI to go backwards too */ @@ -2741,9 +2726,9 @@ ReadRecord(XLogRecPtr *RecPtr, int emode) if (targetRecOff == 0) { /* - * Can only get here in the continuing-from-prev-page case, - * because XRecOffIsValid eliminated the zero-page-offset case - * otherwise. Need to skip over the new page's header. + * Can only get here in the continuing-from-prev-page case, because + * XRecOffIsValid eliminated the zero-page-offset case otherwise. Need + * to skip over the new page's header. */ tmpRecPtr.xrecoff += pageHeaderSize; targetRecOff = pageHeaderSize; @@ -2791,14 +2776,14 @@ got_record:; { ereport(emode, (errmsg("invalid resource manager ID %u at %X/%X", - record->xl_rmid, RecPtr->xlogid, RecPtr->xrecoff))); + record->xl_rmid, RecPtr->xlogid, RecPtr->xrecoff))); goto next_record_is_invalid; } if (randAccess) { /* - * We can't exactly verify the prev-link, but surely it should be - * less than the record's own address. + * We can't exactly verify the prev-link, but surely it should be less + * than the record's own address. */ if (!XLByteLT(record->xl_prev, *RecPtr)) { @@ -2812,9 +2797,9 @@ got_record:; else { /* - * Record's prev-link should exactly match our previous location. - * This check guards against torn WAL pages where a stale but - * valid-looking WAL record starts on a sector boundary. + * Record's prev-link should exactly match our previous location. This + * check guards against torn WAL pages where a stale but valid-looking + * WAL record starts on a sector boundary. */ if (!XLByteEQ(record->xl_prev, ReadRecPtr)) { @@ -2827,11 +2812,10 @@ got_record:; } /* - * Allocate or enlarge readRecordBuf as needed. To avoid useless - * small increases, round its size to a multiple of BLCKSZ, and make - * sure it's at least 4*BLCKSZ to start with. (That is enough for all - * "normal" records, but very large commit or abort records might need - * more space.) + * Allocate or enlarge readRecordBuf as needed. To avoid useless small + * increases, round its size to a multiple of BLCKSZ, and make sure it's + * at least 4*BLCKSZ to start with. (That is enough for all "normal" + * records, but very large commit or abort records might need more space.) */ total_len = record->xl_tot_len; if (total_len > readRecordBufSize) @@ -2927,7 +2911,7 @@ got_record:; MAXALIGN(SizeOfXLogContRecord + contrecord->xl_rem_len)) { nextRecord = (XLogRecord *) ((char *) contrecord + - MAXALIGN(SizeOfXLogContRecord + contrecord->xl_rem_len)); + MAXALIGN(SizeOfXLogContRecord + contrecord->xl_rem_len)); } EndRecPtr.xlogid = readId; EndRecPtr.xrecoff = readSeg * XLogSegSize + readOff + @@ -2991,8 +2975,8 @@ ValidXLOGHeader(XLogPageHeader hdr, int emode) char sysident_str[32]; /* - * Format sysids separately to keep platform-dependent format - * code out of the translatable message string. + * Format sysids separately to keep platform-dependent format code + * out of the translatable message string. */ snprintf(fhdrident_str, sizeof(fhdrident_str), UINT64_FORMAT, longhdr->xlp_sysid); @@ -3000,15 +2984,15 @@ ValidXLOGHeader(XLogPageHeader hdr, int emode) ControlFile->system_identifier); ereport(emode, (errmsg("WAL file is from different system"), - errdetail("WAL file SYSID is %s, pg_control SYSID is %s", - fhdrident_str, sysident_str))); + errdetail("WAL file SYSID is %s, pg_control SYSID is %s", + fhdrident_str, sysident_str))); return false; } if (longhdr->xlp_seg_size != XLogSegSize) { ereport(emode, (errmsg("WAL file is from different system"), - errdetail("Incorrect XLOG_SEG_SIZE in page header."))); + errdetail("Incorrect XLOG_SEG_SIZE in page header."))); return false; } } @@ -3018,7 +3002,7 @@ ValidXLOGHeader(XLogPageHeader hdr, int emode) { ereport(emode, (errmsg("unexpected pageaddr %X/%X in log file %u, segment %u, offset %u", - hdr->xlp_pageaddr.xlogid, hdr->xlp_pageaddr.xrecoff, + hdr->xlp_pageaddr.xlogid, hdr->xlp_pageaddr.xrecoff, readId, readSeg, readOff))); return false; } @@ -3040,9 +3024,9 @@ ValidXLOGHeader(XLogPageHeader hdr, int emode) * immediate parent's TLI, we should never see TLI go backwards across * successive pages of a consistent WAL sequence. * - * Of course this check should only be applied when advancing - * sequentially across pages; therefore ReadRecord resets lastPageTLI - * to zero when going to a random page. + * Of course this check should only be applied when advancing sequentially + * across pages; therefore ReadRecord resets lastPageTLI to zero when + * going to a random page. */ if (hdr->xlp_tli < lastPageTLI) { @@ -3123,7 +3107,7 @@ readTimeLineHistory(TimeLineID targetTLI) tli <= (TimeLineID) linitial_int(result)) ereport(FATAL, (errmsg("invalid data in history file: %s", fline), - errhint("Timeline IDs must be in increasing sequence."))); + errhint("Timeline IDs must be in increasing sequence."))); /* Build list with newest item first */ result = lcons_int((int) tli, result); @@ -3137,7 +3121,7 @@ readTimeLineHistory(TimeLineID targetTLI) targetTLI <= (TimeLineID) linitial_int(result)) ereport(FATAL, (errmsg("invalid data in history file \"%s\"", path), - errhint("Timeline IDs must be less than child timeline's ID."))); + errhint("Timeline IDs must be less than child timeline's ID."))); result = lcons_int((int) targetTLI, result); @@ -3196,8 +3180,8 @@ findNewestTimeLine(TimeLineID startTLI) TimeLineID probeTLI; /* - * The algorithm is just to probe for the existence of timeline - * history files. XXX is it useful to allow gaps in the sequence? + * The algorithm is just to probe for the existence of timeline history + * files. XXX is it useful to allow gaps in the sequence? */ newestTLI = startTLI; @@ -3302,14 +3286,13 @@ writeTimeLineHistory(TimeLineID newTLI, TimeLineID parentTLI, unlink(tmppath); /* - * if write didn't set errno, assume problem is no disk - * space + * if write didn't set errno, assume problem is no disk space */ errno = save_errno ? save_errno : ENOSPC; ereport(ERROR, (errcode_for_file_access(), - errmsg("could not write to file \"%s\": %m", tmppath))); + errmsg("could not write to file \"%s\": %m", tmppath))); } } close(srcfd); @@ -3454,11 +3437,11 @@ WriteControlFile(void) FIN_CRC32(ControlFile->crc); /* - * We write out BLCKSZ bytes into pg_control, zero-padding the excess - * over sizeof(ControlFileData). This reduces the odds of - * premature-EOF errors when reading pg_control. We'll still fail - * when we check the contents of the file, but hopefully with a more - * specific error than "couldn't read pg_control". + * We write out BLCKSZ bytes into pg_control, zero-padding the excess over + * sizeof(ControlFileData). This reduces the odds of premature-EOF errors + * when reading pg_control. We'll still fail when we check the contents + * of the file, but hopefully with a more specific error than "couldn't + * read pg_control". */ if (sizeof(ControlFileData) > BLCKSZ) ereport(PANIC, @@ -3524,17 +3507,17 @@ ReadControlFile(void) close(fd); /* - * Check for expected pg_control format version. If this is wrong, - * the CRC check will likely fail because we'll be checking the wrong - * number of bytes. Complaining about wrong version will probably be - * more enlightening than complaining about wrong CRC. + * Check for expected pg_control format version. If this is wrong, the + * CRC check will likely fail because we'll be checking the wrong number + * of bytes. Complaining about wrong version will probably be more + * enlightening than complaining about wrong CRC. */ if (ControlFile->pg_control_version != PG_CONTROL_VERSION) ereport(FATAL, (errmsg("database files are incompatible with server"), errdetail("The database cluster was initialized with PG_CONTROL_VERSION %d," - " but the server was compiled with PG_CONTROL_VERSION %d.", - ControlFile->pg_control_version, PG_CONTROL_VERSION), + " but the server was compiled with PG_CONTROL_VERSION %d.", + ControlFile->pg_control_version, PG_CONTROL_VERSION), errhint("It looks like you need to initdb."))); /* Now check the CRC. */ INIT_CRC32(crc); @@ -3548,31 +3531,30 @@ ReadControlFile(void) (errmsg("incorrect checksum in control file"))); /* - * Do compatibility checking immediately. We do this here for 2 - * reasons: + * Do compatibility checking immediately. We do this here for 2 reasons: * - * (1) if the database isn't compatible with the backend executable, we - * want to abort before we can possibly do any damage; + * (1) if the database isn't compatible with the backend executable, we want + * to abort before we can possibly do any damage; * * (2) this code is executed in the postmaster, so the setlocale() will - * propagate to forked backends, which aren't going to read this file - * for themselves. (These locale settings are considered critical + * propagate to forked backends, which aren't going to read this file for + * themselves. (These locale settings are considered critical * compatibility items because they can affect sort order of indexes.) */ if (ControlFile->catalog_version_no != CATALOG_VERSION_NO) ereport(FATAL, (errmsg("database files are incompatible with server"), errdetail("The database cluster was initialized with CATALOG_VERSION_NO %d," - " but the server was compiled with CATALOG_VERSION_NO %d.", - ControlFile->catalog_version_no, CATALOG_VERSION_NO), + " but the server was compiled with CATALOG_VERSION_NO %d.", + ControlFile->catalog_version_no, CATALOG_VERSION_NO), errhint("It looks like you need to initdb."))); if (ControlFile->maxAlign != MAXIMUM_ALIGNOF) ereport(FATAL, (errmsg("database files are incompatible with server"), - errdetail("The database cluster was initialized with MAXALIGN %d," - " but the server was compiled with MAXALIGN %d.", - ControlFile->maxAlign, MAXIMUM_ALIGNOF), - errhint("It looks like you need to initdb."))); + errdetail("The database cluster was initialized with MAXALIGN %d," + " but the server was compiled with MAXALIGN %d.", + ControlFile->maxAlign, MAXIMUM_ALIGNOF), + errhint("It looks like you need to initdb."))); if (ControlFile->floatFormat != FLOATFORMAT_VALUE) ereport(FATAL, (errmsg("database files are incompatible with server"), @@ -3581,76 +3563,76 @@ ReadControlFile(void) if (ControlFile->blcksz != BLCKSZ) ereport(FATAL, (errmsg("database files are incompatible with server"), - errdetail("The database cluster was initialized with BLCKSZ %d," - " but the server was compiled with BLCKSZ %d.", - ControlFile->blcksz, BLCKSZ), - errhint("It looks like you need to recompile or initdb."))); + errdetail("The database cluster was initialized with BLCKSZ %d," + " but the server was compiled with BLCKSZ %d.", + ControlFile->blcksz, BLCKSZ), + errhint("It looks like you need to recompile or initdb."))); if (ControlFile->relseg_size != RELSEG_SIZE) ereport(FATAL, (errmsg("database files are incompatible with server"), - errdetail("The database cluster was initialized with RELSEG_SIZE %d," - " but the server was compiled with RELSEG_SIZE %d.", - ControlFile->relseg_size, RELSEG_SIZE), - errhint("It looks like you need to recompile or initdb."))); + errdetail("The database cluster was initialized with RELSEG_SIZE %d," + " but the server was compiled with RELSEG_SIZE %d.", + ControlFile->relseg_size, RELSEG_SIZE), + errhint("It looks like you need to recompile or initdb."))); if (ControlFile->xlog_seg_size != XLOG_SEG_SIZE) ereport(FATAL, (errmsg("database files are incompatible with server"), errdetail("The database cluster was initialized with XLOG_SEG_SIZE %d," - " but the server was compiled with XLOG_SEG_SIZE %d.", + " but the server was compiled with XLOG_SEG_SIZE %d.", ControlFile->xlog_seg_size, XLOG_SEG_SIZE), - errhint("It looks like you need to recompile or initdb."))); + errhint("It looks like you need to recompile or initdb."))); if (ControlFile->nameDataLen != NAMEDATALEN) ereport(FATAL, (errmsg("database files are incompatible with server"), - errdetail("The database cluster was initialized with NAMEDATALEN %d," - " but the server was compiled with NAMEDATALEN %d.", - ControlFile->nameDataLen, NAMEDATALEN), - errhint("It looks like you need to recompile or initdb."))); + errdetail("The database cluster was initialized with NAMEDATALEN %d," + " but the server was compiled with NAMEDATALEN %d.", + ControlFile->nameDataLen, NAMEDATALEN), + errhint("It looks like you need to recompile or initdb."))); if (ControlFile->indexMaxKeys != INDEX_MAX_KEYS) ereport(FATAL, (errmsg("database files are incompatible with server"), errdetail("The database cluster was initialized with INDEX_MAX_KEYS %d," - " but the server was compiled with INDEX_MAX_KEYS %d.", + " but the server was compiled with INDEX_MAX_KEYS %d.", ControlFile->indexMaxKeys, INDEX_MAX_KEYS), - errhint("It looks like you need to recompile or initdb."))); + errhint("It looks like you need to recompile or initdb."))); #ifdef HAVE_INT64_TIMESTAMP if (ControlFile->enableIntTimes != TRUE) ereport(FATAL, (errmsg("database files are incompatible with server"), errdetail("The database cluster was initialized without HAVE_INT64_TIMESTAMP" - " but the server was compiled with HAVE_INT64_TIMESTAMP."), - errhint("It looks like you need to recompile or initdb."))); + " but the server was compiled with HAVE_INT64_TIMESTAMP."), + errhint("It looks like you need to recompile or initdb."))); #else if (ControlFile->enableIntTimes != FALSE) ereport(FATAL, (errmsg("database files are incompatible with server"), errdetail("The database cluster was initialized with HAVE_INT64_TIMESTAMP" - " but the server was compiled without HAVE_INT64_TIMESTAMP."), - errhint("It looks like you need to recompile or initdb."))); + " but the server was compiled without HAVE_INT64_TIMESTAMP."), + errhint("It looks like you need to recompile or initdb."))); #endif if (ControlFile->localeBuflen != LOCALE_NAME_BUFLEN) ereport(FATAL, (errmsg("database files are incompatible with server"), errdetail("The database cluster was initialized with LOCALE_NAME_BUFLEN %d," - " but the server was compiled with LOCALE_NAME_BUFLEN %d.", + " but the server was compiled with LOCALE_NAME_BUFLEN %d.", ControlFile->localeBuflen, LOCALE_NAME_BUFLEN), - errhint("It looks like you need to recompile or initdb."))); + errhint("It looks like you need to recompile or initdb."))); if (setlocale(LC_COLLATE, ControlFile->lc_collate) == NULL) ereport(FATAL, - (errmsg("database files are incompatible with operating system"), - errdetail("The database cluster was initialized with LC_COLLATE \"%s\"," - " which is not recognized by setlocale().", - ControlFile->lc_collate), - errhint("It looks like you need to initdb or install locale support."))); + (errmsg("database files are incompatible with operating system"), + errdetail("The database cluster was initialized with LC_COLLATE \"%s\"," + " which is not recognized by setlocale().", + ControlFile->lc_collate), + errhint("It looks like you need to initdb or install locale support."))); if (setlocale(LC_CTYPE, ControlFile->lc_ctype) == NULL) ereport(FATAL, - (errmsg("database files are incompatible with operating system"), - errdetail("The database cluster was initialized with LC_CTYPE \"%s\"," - " which is not recognized by setlocale().", - ControlFile->lc_ctype), - errhint("It looks like you need to initdb or install locale support."))); + (errmsg("database files are incompatible with operating system"), + errdetail("The database cluster was initialized with LC_CTYPE \"%s\"," + " which is not recognized by setlocale().", + ControlFile->lc_ctype), + errhint("It looks like you need to initdb or install locale support."))); /* Make the fixed locale settings visible as GUC variables, too */ SetConfigOption("lc_collate", ControlFile->lc_collate, @@ -3719,9 +3701,9 @@ XLOGShmemSize(void) size = add_size(size, mul_size(BLCKSZ, XLOGbuffers)); /* - * Note: we don't count ControlFileData, it comes out of the "slop - * factor" added by CreateSharedMemoryAndSemaphores. This lets us - * use this routine again below to compute the actual allocation size. + * Note: we don't count ControlFileData, it comes out of the "slop factor" + * added by CreateSharedMemoryAndSemaphores. This lets us use this + * routine again below to compute the actual allocation size. */ return size; @@ -3749,9 +3731,9 @@ XLOGShmemInit(void) memset(XLogCtl, 0, sizeof(XLogCtlData)); /* - * Since XLogCtlData contains XLogRecPtr fields, its sizeof should be - * a multiple of the alignment for same, so no extra alignment padding - * is needed here. + * Since XLogCtlData contains XLogRecPtr fields, its sizeof should be a + * multiple of the alignment for same, so no extra alignment padding is + * needed here. */ allocptr = ((char *) XLogCtl) + sizeof(XLogCtlData); XLogCtl->xlblocks = (XLogRecPtr *) allocptr; @@ -3766,18 +3748,19 @@ XLOGShmemInit(void) memset(XLogCtl->pages, 0, (Size) BLCKSZ * XLOGbuffers); /* - * Do basic initialization of XLogCtl shared data. (StartupXLOG will - * fill in additional info.) + * Do basic initialization of XLogCtl shared data. (StartupXLOG will fill + * in additional info.) */ - XLogCtl->XLogCacheByte = (Size) BLCKSZ * XLOGbuffers; + XLogCtl->XLogCacheByte = (Size) BLCKSZ *XLOGbuffers; + XLogCtl->XLogCacheBlck = XLOGbuffers - 1; XLogCtl->Insert.currpage = (XLogPageHeader) (XLogCtl->pages); SpinLockInit(&XLogCtl->info_lck); /* - * If we are not in bootstrap mode, pg_control should already exist. - * Read and validate it immediately (see comments in ReadControlFile() - * for the reasons why). + * If we are not in bootstrap mode, pg_control should already exist. Read + * and validate it immediately (see comments in ReadControlFile() for the + * reasons why). */ if (!IsBootstrapProcessingMode()) ReadControlFile(); @@ -3801,17 +3784,16 @@ BootStrapXLOG(void) pg_crc32 crc; /* - * Select a hopefully-unique system identifier code for this - * installation. We use the result of gettimeofday(), including the - * fractional seconds field, as being about as unique as we can easily - * get. (Think not to use random(), since it hasn't been seeded and - * there's no portable way to seed it other than the system clock - * value...) The upper half of the uint64 value is just the tv_sec - * part, while the lower half is the XOR of tv_sec and tv_usec. This - * is to ensure that we don't lose uniqueness unnecessarily if - * "uint64" is really only 32 bits wide. A person knowing this - * encoding can determine the initialization time of the installation, - * which could perhaps be useful sometimes. + * Select a hopefully-unique system identifier code for this installation. + * We use the result of gettimeofday(), including the fractional seconds + * field, as being about as unique as we can easily get. (Think not to + * use random(), since it hasn't been seeded and there's no portable way + * to seed it other than the system clock value...) The upper half of the + * uint64 value is just the tv_sec part, while the lower half is the XOR + * of tv_sec and tv_usec. This is to ensure that we don't lose uniqueness + * unnecessarily if "uint64" is really only 32 bits wide. A person + * knowing this encoding can determine the initialization time of the + * installation, which could perhaps be useful sometimes. */ gettimeofday(&tv, NULL); sysidentifier = ((uint64) tv.tv_sec) << 32; @@ -3821,7 +3803,7 @@ BootStrapXLOG(void) ThisTimeLineID = 1; /* page buffer must be aligned suitably for O_DIRECT */ - buffer = (char *) palloc(BLCKSZ + ALIGNOF_XLOG_BUFFER); + buffer = (char *) palloc(BLCKSZ + ALIGNOF_XLOG_BUFFER); page = (XLogPageHeader) TYPEALIGN(ALIGNOF_XLOG_BUFFER, buffer); memset(page, 0, BLCKSZ); @@ -3882,18 +3864,18 @@ BootStrapXLOG(void) errno = ENOSPC; ereport(PANIC, (errcode_for_file_access(), - errmsg("could not write bootstrap transaction log file: %m"))); + errmsg("could not write bootstrap transaction log file: %m"))); } if (pg_fsync(openLogFile) != 0) ereport(PANIC, (errcode_for_file_access(), - errmsg("could not fsync bootstrap transaction log file: %m"))); + errmsg("could not fsync bootstrap transaction log file: %m"))); if (close(openLogFile)) ereport(PANIC, (errcode_for_file_access(), - errmsg("could not close bootstrap transaction log file: %m"))); + errmsg("could not close bootstrap transaction log file: %m"))); openLogFile = -1; @@ -4036,8 +4018,8 @@ readRecoveryCommandFile(void) recoveryTargetXid = (TransactionId) strtoul(tok2, NULL, 0); if (errno == EINVAL || errno == ERANGE) ereport(FATAL, - (errmsg("recovery_target_xid is not a valid number: \"%s\"", - tok2))); + (errmsg("recovery_target_xid is not a valid number: \"%s\"", + tok2))); ereport(LOG, (errmsg("recovery_target_xid = %u", recoveryTargetXid))); @@ -4056,17 +4038,17 @@ readRecoveryCommandFile(void) recoveryTargetExact = false; /* - * Convert the time string given by the user to the time_t - * format. We use type abstime's input converter because we - * know abstime has the same representation as time_t. + * Convert the time string given by the user to the time_t format. + * We use type abstime's input converter because we know abstime + * has the same representation as time_t. */ recoveryTargetTime = (time_t) DatumGetAbsoluteTime(DirectFunctionCall1(abstimein, - CStringGetDatum(tok2))); + CStringGetDatum(tok2))); ereport(LOG, (errmsg("recovery_target_time = %s", - DatumGetCString(DirectFunctionCall1(abstimeout, - AbsoluteTimeGetDatum((AbsoluteTime) recoveryTargetTime)))))); + DatumGetCString(DirectFunctionCall1(abstimeout, + AbsoluteTimeGetDatum((AbsoluteTime) recoveryTargetTime)))))); } else if (strcmp(tok1, "recovery_target_inclusive") == 0) { @@ -4095,7 +4077,7 @@ readRecoveryCommandFile(void) ereport(FATAL, (errmsg("syntax error in recovery command file: %s", cmdline), - errhint("Lines should have the format parameter = 'value'."))); + errhint("Lines should have the format parameter = 'value'."))); /* Check that required parameters were supplied */ if (recoveryRestoreCommand == NULL) @@ -4107,10 +4089,10 @@ readRecoveryCommandFile(void) InArchiveRecovery = true; /* - * If user specified recovery_target_timeline, validate it or compute - * the "latest" value. We can't do this until after we've gotten the - * restore command and set InArchiveRecovery, because we need to fetch - * timeline history files from the archive. + * If user specified recovery_target_timeline, validate it or compute the + * "latest" value. We can't do this until after we've gotten the restore + * command and set InArchiveRecovery, because we need to fetch timeline + * history files from the archive. */ if (rtliGiven) { @@ -4119,8 +4101,8 @@ readRecoveryCommandFile(void) /* Timeline 1 does not have a history file, all else should */ if (rtli != 1 && !existsTimeLineHistory(rtli)) ereport(FATAL, - (errmsg("recovery_target_timeline %u does not exist", - rtli))); + (errmsg("recovery_target_timeline %u does not exist", + rtli))); recoveryTargetTLI = rtli; } else @@ -4146,9 +4128,9 @@ exitArchiveRecovery(TimeLineID endTLI, uint32 endLogId, uint32 endLogSeg) InArchiveRecovery = false; /* - * We should have the ending log segment currently open. Verify, and - * then close it (to avoid problems on Windows with trying to rename - * or delete an open file). + * We should have the ending log segment currently open. Verify, and then + * close it (to avoid problems on Windows with trying to rename or delete + * an open file). */ Assert(readFile >= 0); Assert(readId == endLogId); @@ -4158,17 +4140,17 @@ exitArchiveRecovery(TimeLineID endTLI, uint32 endLogId, uint32 endLogSeg) readFile = -1; /* - * If the segment was fetched from archival storage, we want to - * replace the existing xlog segment (if any) with the archival - * version. This is because whatever is in XLOGDIR is very possibly - * older than what we have from the archives, since it could have come - * from restoring a PGDATA backup. In any case, the archival version - * certainly is more descriptive of what our current database state - * is, because that is what we replayed from. + * If the segment was fetched from archival storage, we want to replace + * the existing xlog segment (if any) with the archival version. This is + * because whatever is in XLOGDIR is very possibly older than what we have + * from the archives, since it could have come from restoring a PGDATA + * backup. In any case, the archival version certainly is more + * descriptive of what our current database state is, because that is what + * we replayed from. * - * Note that if we are establishing a new timeline, ThisTimeLineID is - * already set to the new value, and so we will create a new file - * instead of overwriting any existing file. + * Note that if we are establishing a new timeline, ThisTimeLineID is already + * set to the new value, and so we will create a new file instead of + * overwriting any existing file. */ snprintf(recoveryPath, MAXPGPATH, XLOGDIR "/RECOVERYXLOG"); XLogFilePath(xlogpath, ThisTimeLineID, endLogId, endLogSeg); @@ -4195,9 +4177,9 @@ exitArchiveRecovery(TimeLineID endTLI, uint32 endLogId, uint32 endLogSeg) unlink(recoveryPath); /* ignore any error */ /* - * If we are establishing a new timeline, we have to copy data - * from the last WAL segment of the old timeline to create a - * starting WAL segment for the new timeline. + * If we are establishing a new timeline, we have to copy data from + * the last WAL segment of the old timeline to create a starting WAL + * segment for the new timeline. */ if (endTLI != ThisTimeLineID) XLogFileCopy(endLogId, endLogSeg, @@ -4205,8 +4187,8 @@ exitArchiveRecovery(TimeLineID endTLI, uint32 endLogId, uint32 endLogSeg) } /* - * Let's just make real sure there are not .ready or .done flags - * posted for the new segment. + * Let's just make real sure there are not .ready or .done flags posted + * for the new segment. */ XLogFileName(xlogpath, ThisTimeLineID, endLogId, endLogSeg); XLogArchiveCleanup(xlogpath); @@ -4216,8 +4198,8 @@ exitArchiveRecovery(TimeLineID endTLI, uint32 endLogId, uint32 endLogSeg) unlink(recoveryPath); /* ignore any error */ /* - * Rename the config file out of the way, so that we don't - * accidentally re-enter archive recovery mode in a subsequent crash. + * Rename the config file out of the way, so that we don't accidentally + * re-enter archive recovery mode in a subsequent crash. */ unlink(RECOVERY_COMMAND_DONE); if (rename(RECOVERY_COMMAND_FILE, RECOVERY_COMMAND_DONE) != 0) @@ -4278,9 +4260,9 @@ recoveryStopsHere(XLogRecord *record, bool *includeThis) * transactionid * * when testing for an xid, we MUST test for equality only, since - * transactions are numbered in the order they start, not the - * order they complete. A higher numbered xid will complete before - * you about 50% of the time... + * transactions are numbered in the order they start, not the order + * they complete. A higher numbered xid will complete before you about + * 50% of the time... */ stopsHere = (record->xl_xid == recoveryTargetXid); if (stopsHere) @@ -4289,9 +4271,9 @@ recoveryStopsHere(XLogRecord *record, bool *includeThis) else { /* - * there can be many transactions that share the same commit time, - * so we stop after the last one, if we are inclusive, or stop at - * the first one if we are exclusive + * there can be many transactions that share the same commit time, so + * we stop after the last one, if we are inclusive, or stop at the + * first one if we are exclusive */ if (recoveryTargetInclusive) stopsHere = (recordXtime > recoveryTargetTime); @@ -4312,22 +4294,22 @@ recoveryStopsHere(XLogRecord *record, bool *includeThis) if (recoveryStopAfter) ereport(LOG, (errmsg("recovery stopping after commit of transaction %u, time %s", - recoveryStopXid, str_time(recoveryStopTime)))); + recoveryStopXid, str_time(recoveryStopTime)))); else ereport(LOG, (errmsg("recovery stopping before commit of transaction %u, time %s", - recoveryStopXid, str_time(recoveryStopTime)))); + recoveryStopXid, str_time(recoveryStopTime)))); } else { if (recoveryStopAfter) ereport(LOG, (errmsg("recovery stopping after abort of transaction %u, time %s", - recoveryStopXid, str_time(recoveryStopTime)))); + recoveryStopXid, str_time(recoveryStopTime)))); else ereport(LOG, (errmsg("recovery stopping before abort of transaction %u, time %s", - recoveryStopXid, str_time(recoveryStopTime)))); + recoveryStopXid, str_time(recoveryStopTime)))); } } @@ -4359,8 +4341,8 @@ StartupXLOG(void) /* * Read control file and check XLOG status looks valid. * - * Note: in most control paths, *ControlFile is already valid and we need - * not do ReadControlFile() here, but might as well do it to be sure. + * Note: in most control paths, *ControlFile is already valid and we need not + * do ReadControlFile() here, but might as well do it to be sure. */ ReadControlFile(); @@ -4381,10 +4363,10 @@ StartupXLOG(void) str_time(ControlFile->time)))); else if (ControlFile->state == DB_IN_RECOVERY) ereport(LOG, - (errmsg("database system was interrupted while in recovery at %s", - str_time(ControlFile->time)), - errhint("This probably means that some data is corrupted and" - " you will have to use the last backup for recovery."))); + (errmsg("database system was interrupted while in recovery at %s", + str_time(ControlFile->time)), + errhint("This probably means that some data is corrupted and" + " you will have to use the last backup for recovery."))); else if (ControlFile->state == DB_IN_PRODUCTION) ereport(LOG, (errmsg("database system was interrupted at %s", @@ -4397,8 +4379,8 @@ StartupXLOG(void) #endif /* - * Initialize on the assumption we want to recover to the same - * timeline that's active according to pg_control. + * Initialize on the assumption we want to recover to the same timeline + * that's active according to pg_control. */ recoveryTargetTLI = ControlFile->checkPointCopy.ThisTimeLineID; @@ -4417,7 +4399,7 @@ StartupXLOG(void) * timeline. */ if (!list_member_int(expectedTLIs, - (int) ControlFile->checkPointCopy.ThisTimeLineID)) + (int) ControlFile->checkPointCopy.ThisTimeLineID)) ereport(FATAL, (errmsg("requested timeline %u is not a child of database system timeline %u", recoveryTargetTLI, @@ -4426,30 +4408,29 @@ StartupXLOG(void) if (read_backup_label(&checkPointLoc)) { /* - * When a backup_label file is present, we want to roll forward - * from the checkpoint it identifies, rather than using - * pg_control. + * When a backup_label file is present, we want to roll forward from + * the checkpoint it identifies, rather than using pg_control. */ record = ReadCheckpointRecord(checkPointLoc, 0); if (record != NULL) { ereport(LOG, (errmsg("checkpoint record is at %X/%X", - checkPointLoc.xlogid, checkPointLoc.xrecoff))); + checkPointLoc.xlogid, checkPointLoc.xrecoff))); InRecovery = true; /* force recovery even if SHUTDOWNED */ } else { ereport(PANIC, - (errmsg("could not locate required checkpoint record"), - errhint("If you are not restoring from a backup, try removing the file \"%s/backup_label\".", DataDir))); + (errmsg("could not locate required checkpoint record"), + errhint("If you are not restoring from a backup, try removing the file \"%s/backup_label\".", DataDir))); } } else { /* - * Get the last valid checkpoint record. If the latest one - * according to pg_control is broken, try the next-to-last one. + * Get the last valid checkpoint record. If the latest one according + * to pg_control is broken, try the next-to-last one. */ checkPointLoc = ControlFile->checkPoint; record = ReadCheckpointRecord(checkPointLoc, 1); @@ -4457,7 +4438,7 @@ StartupXLOG(void) { ereport(LOG, (errmsg("checkpoint record is at %X/%X", - checkPointLoc.xlogid, checkPointLoc.xrecoff))); + checkPointLoc.xlogid, checkPointLoc.xrecoff))); } else { @@ -4466,14 +4447,13 @@ StartupXLOG(void) if (record != NULL) { ereport(LOG, - (errmsg("using previous checkpoint record at %X/%X", - checkPointLoc.xlogid, checkPointLoc.xrecoff))); - InRecovery = true; /* force recovery even if - * SHUTDOWNED */ + (errmsg("using previous checkpoint record at %X/%X", + checkPointLoc.xlogid, checkPointLoc.xrecoff))); + InRecovery = true; /* force recovery even if SHUTDOWNED */ } else ereport(PANIC, - (errmsg("could not locate a valid checkpoint record"))); + (errmsg("could not locate a valid checkpoint record"))); } } @@ -4482,10 +4462,10 @@ StartupXLOG(void) wasShutdown = (record->xl_info == XLOG_CHECKPOINT_SHUTDOWN); ereport(LOG, - (errmsg("redo record is at %X/%X; undo record is at %X/%X; shutdown %s", - checkPoint.redo.xlogid, checkPoint.redo.xrecoff, - checkPoint.undo.xlogid, checkPoint.undo.xrecoff, - wasShutdown ? "TRUE" : "FALSE"))); + (errmsg("redo record is at %X/%X; undo record is at %X/%X; shutdown %s", + checkPoint.redo.xlogid, checkPoint.redo.xrecoff, + checkPoint.undo.xlogid, checkPoint.undo.xrecoff, + wasShutdown ? "TRUE" : "FALSE"))); ereport(LOG, (errmsg("next transaction ID: %u; next OID: %u", checkPoint.nextXid, checkPoint.nextOid))); @@ -4502,9 +4482,9 @@ StartupXLOG(void) MultiXactSetNextMXact(checkPoint.nextMulti, checkPoint.nextMultiOffset); /* - * We must replay WAL entries using the same TimeLineID they were - * created under, so temporarily adopt the TLI indicated by the - * checkpoint (see also xlog_redo()). + * We must replay WAL entries using the same TimeLineID they were created + * under, so temporarily adopt the TLI indicated by the checkpoint (see + * also xlog_redo()). */ ThisTimeLineID = checkPoint.ThisTimeLineID; @@ -4518,15 +4498,15 @@ StartupXLOG(void) /* * Check whether we need to force recovery from WAL. If it appears to - * have been a clean shutdown and we did not have a recovery.conf - * file, then assume no recovery needed. + * have been a clean shutdown and we did not have a recovery.conf file, + * then assume no recovery needed. */ if (XLByteLT(checkPoint.undo, RecPtr) || XLByteLT(checkPoint.redo, RecPtr)) { if (wasShutdown) ereport(PANIC, - (errmsg("invalid redo/undo record in shutdown checkpoint"))); + (errmsg("invalid redo/undo record in shutdown checkpoint"))); InRecovery = true; } else if (ControlFile->state != DB_SHUTDOWNED) @@ -4563,8 +4543,8 @@ StartupXLOG(void) } /* - * Find the first record that logically follows the checkpoint --- - * it might physically precede it, though. + * Find the first record that logically follows the checkpoint --- it + * might physically precede it, though. */ if (XLByteLT(checkPoint.redo, RecPtr)) { @@ -4603,7 +4583,7 @@ StartupXLOG(void) xlog_outrec(buf, record); strcat(buf, " - "); RmgrTable[record->xl_rmid].rm_desc(buf, - record->xl_info, XLogRecGetData(record)); + record->xl_info, XLogRecGetData(record)); elog(LOG, "%s", buf); } #endif @@ -4621,7 +4601,7 @@ StartupXLOG(void) /* nextXid must be beyond record's xid */ if (TransactionIdFollowsOrEquals(record->xl_xid, - ShmemVariableCache->nextXid)) + ShmemVariableCache->nextXid)) { ShmemVariableCache->nextXid = record->xl_xid; TransactionIdAdvance(ShmemVariableCache->nextXid); @@ -4655,8 +4635,8 @@ StartupXLOG(void) } /* - * Re-fetch the last valid or last applied record, so we can identify - * the exact endpoint of what we consider the valid portion of WAL. + * Re-fetch the last valid or last applied record, so we can identify the + * exact endpoint of what we consider the valid portion of WAL. */ record = ReadRecord(&LastRec, PANIC); EndOfLog = EndRecPtr; @@ -4682,8 +4662,8 @@ StartupXLOG(void) * * If we stopped short of the end of WAL during recovery, then we are * generating a new timeline and must assign it a unique new ID. - * Otherwise, we can just extend the timeline we were in when we ran - * out of WAL. + * Otherwise, we can just extend the timeline we were in when we ran out + * of WAL. */ if (needNewTimeLine) { @@ -4698,10 +4678,10 @@ StartupXLOG(void) XLogCtl->ThisTimeLineID = ThisTimeLineID; /* - * We are now done reading the old WAL. Turn off archive fetching if - * it was active, and make a writable copy of the last WAL segment. - * (Note that we also have a copy of the last block of the old WAL in - * readBuf; we will use that below.) + * We are now done reading the old WAL. Turn off archive fetching if it + * was active, and make a writable copy of the last WAL segment. (Note + * that we also have a copy of the last block of the old WAL in readBuf; + * we will use that below.) */ if (InArchiveRecovery) exitArchiveRecovery(curFileTLI, endLogId, endLogSeg); @@ -4724,9 +4704,9 @@ StartupXLOG(void) ((EndOfLog.xrecoff - 1) / BLCKSZ + 1) * BLCKSZ; /* - * Tricky point here: readBuf contains the *last* block that the - * LastRec record spans, not the one it starts in. The last block is - * indeed the one we want to use. + * Tricky point here: readBuf contains the *last* block that the LastRec + * record spans, not the one it starts in. The last block is indeed the + * one we want to use. */ Assert(readOff == (XLogCtl->xlblocks[0].xrecoff - BLCKSZ) % XLogSegSize); memcpy((char *) Insert->currpage, readBuf, BLCKSZ); @@ -4752,9 +4732,8 @@ StartupXLOG(void) else { /* - * Whenever Write.LogwrtResult points to exactly the end of a - * page, Write.curridx must point to the *next* page (see - * XLogWrite()). + * Whenever Write.LogwrtResult points to exactly the end of a page, + * Write.curridx must point to the *next* page (see XLogWrite()). * * Note: it might seem we should do AdvanceXLInsertBuffer() here, but * this is sufficient. The first actual attempt to insert a log @@ -4785,17 +4764,16 @@ StartupXLOG(void) pgstat_reset_all(); /* - * Perform a new checkpoint to update our recovery activity to - * disk. + * Perform a new checkpoint to update our recovery activity to disk. * - * Note that we write a shutdown checkpoint rather than an on-line - * one. This is not particularly critical, but since we may be - * assigning a new TLI, using a shutdown checkpoint allows us to - * have the rule that TLI only changes in shutdown checkpoints, - * which allows some extra error checking in xlog_redo. + * Note that we write a shutdown checkpoint rather than an on-line one. + * This is not particularly critical, but since we may be assigning a + * new TLI, using a shutdown checkpoint allows us to have the rule + * that TLI only changes in shutdown checkpoints, which allows some + * extra error checking in xlog_redo. * - * In case we had to use the secondary checkpoint, make sure that it - * will still be shown as the secondary checkpoint after this + * In case we had to use the secondary checkpoint, make sure that it will + * still be shown as the secondary checkpoint after this * CreateCheckPoint operation; we don't want the broken primary * checkpoint to become prevCheckPoint... */ @@ -4810,8 +4788,8 @@ StartupXLOG(void) XLogCloseRelationCache(); /* - * Now that we've checkpointed the recovery, it's safe to flush - * old backup_label, if present. + * Now that we've checkpointed the recovery, it's safe to flush old + * backup_label, if present. */ remove_backup_label(); } @@ -4878,7 +4856,7 @@ ReadCheckpointRecord(XLogRecPtr RecPtr, int whichChkpt) { case 1: ereport(LOG, - (errmsg("invalid primary checkpoint link in control file"))); + (errmsg("invalid primary checkpoint link in control file"))); break; case 2: ereport(LOG, @@ -4886,7 +4864,7 @@ ReadCheckpointRecord(XLogRecPtr RecPtr, int whichChkpt) break; default: ereport(LOG, - (errmsg("invalid checkpoint link in backup_label file"))); + (errmsg("invalid checkpoint link in backup_label file"))); break; } return NULL; @@ -4927,7 +4905,7 @@ ReadCheckpointRecord(XLogRecPtr RecPtr, int whichChkpt) break; default: ereport(LOG, - (errmsg("invalid resource manager ID in checkpoint record"))); + (errmsg("invalid resource manager ID in checkpoint record"))); break; } return NULL; @@ -4939,11 +4917,11 @@ ReadCheckpointRecord(XLogRecPtr RecPtr, int whichChkpt) { case 1: ereport(LOG, - (errmsg("invalid xl_info in primary checkpoint record"))); + (errmsg("invalid xl_info in primary checkpoint record"))); break; case 2: ereport(LOG, - (errmsg("invalid xl_info in secondary checkpoint record"))); + (errmsg("invalid xl_info in secondary checkpoint record"))); break; default: ereport(LOG, @@ -4959,11 +4937,11 @@ ReadCheckpointRecord(XLogRecPtr RecPtr, int whichChkpt) { case 1: ereport(LOG, - (errmsg("invalid length of primary checkpoint record"))); + (errmsg("invalid length of primary checkpoint record"))); break; case 2: ereport(LOG, - (errmsg("invalid length of secondary checkpoint record"))); + (errmsg("invalid length of secondary checkpoint record"))); break; default: ereport(LOG, @@ -5084,10 +5062,10 @@ CreateCheckPoint(bool shutdown, bool force) int nsegsrecycled = 0; /* - * Acquire CheckpointLock to ensure only one checkpoint happens at a - * time. (This is just pro forma, since in the present system - * structure there is only one process that is allowed to issue - * checkpoints at any given time.) + * Acquire CheckpointLock to ensure only one checkpoint happens at a time. + * (This is just pro forma, since in the present system structure there is + * only one process that is allowed to issue checkpoints at any given + * time.) */ LWLockAcquire(CheckpointLock, LW_EXCLUSIVE); @@ -5108,10 +5086,10 @@ CreateCheckPoint(bool shutdown, bool force) checkPoint.time = time(NULL); /* - * We must hold CheckpointStartLock while determining the checkpoint - * REDO pointer. This ensures that any concurrent transaction commits - * will be either not yet logged, or logged and recorded in pg_clog. - * See notes in RecordTransactionCommit(). + * We must hold CheckpointStartLock while determining the checkpoint REDO + * pointer. This ensures that any concurrent transaction commits will be + * either not yet logged, or logged and recorded in pg_clog. See notes in + * RecordTransactionCommit(). */ LWLockAcquire(CheckpointStartLock, LW_EXCLUSIVE); @@ -5119,20 +5097,19 @@ CreateCheckPoint(bool shutdown, bool force) LWLockAcquire(WALInsertLock, LW_EXCLUSIVE); /* - * If this isn't a shutdown or forced checkpoint, and we have not - * inserted any XLOG records since the start of the last checkpoint, - * skip the checkpoint. The idea here is to avoid inserting duplicate - * checkpoints when the system is idle. That wastes log space, and - * more importantly it exposes us to possible loss of both current and - * previous checkpoint records if the machine crashes just as we're - * writing the update. (Perhaps it'd make even more sense to - * checkpoint only when the previous checkpoint record is in a - * different xlog page?) + * If this isn't a shutdown or forced checkpoint, and we have not inserted + * any XLOG records since the start of the last checkpoint, skip the + * checkpoint. The idea here is to avoid inserting duplicate checkpoints + * when the system is idle. That wastes log space, and more importantly it + * exposes us to possible loss of both current and previous checkpoint + * records if the machine crashes just as we're writing the update. + * (Perhaps it'd make even more sense to checkpoint only when the previous + * checkpoint record is in a different xlog page?) * - * We have to make two tests to determine that nothing has happened since - * the start of the last checkpoint: current insertion point must - * match the end of the last checkpoint record, and its redo pointer - * must point to itself. + * We have to make two tests to determine that nothing has happened since the + * start of the last checkpoint: current insertion point must match the + * end of the last checkpoint record, and its redo pointer must point to + * itself. */ if (!shutdown && !force) { @@ -5158,10 +5135,10 @@ CreateCheckPoint(bool shutdown, bool force) /* * Compute new REDO record ptr = location of next XLOG record. * - * NB: this is NOT necessarily where the checkpoint record itself will - * be, since other backends may insert more XLOG records while we're - * off doing the buffer flush work. Those XLOG records are logically - * after the checkpoint, even though physically before it. Got that? + * NB: this is NOT necessarily where the checkpoint record itself will be, + * since other backends may insert more XLOG records while we're off doing + * the buffer flush work. Those XLOG records are logically after the + * checkpoint, even though physically before it. Got that? */ freespace = INSERT_FREESPACE(Insert); if (freespace < SizeOfXLogRecord) @@ -5173,16 +5150,15 @@ CreateCheckPoint(bool shutdown, bool force) INSERT_RECPTR(checkPoint.redo, Insert, Insert->curridx); /* - * Here we update the shared RedoRecPtr for future XLogInsert calls; - * this must be done while holding the insert lock AND the info_lck. + * Here we update the shared RedoRecPtr for future XLogInsert calls; this + * must be done while holding the insert lock AND the info_lck. * * Note: if we fail to complete the checkpoint, RedoRecPtr will be left - * pointing past where it really needs to point. This is okay; the - * only consequence is that XLogInsert might back up whole buffers - * that it didn't really need to. We can't postpone advancing - * RedoRecPtr because XLogInserts that happen while we are dumping - * buffers must assume that their buffer changes are not included in - * the checkpoint. + * pointing past where it really needs to point. This is okay; the only + * consequence is that XLogInsert might back up whole buffers that it + * didn't really need to. We can't postpone advancing RedoRecPtr because + * XLogInserts that happen while we are dumping buffers must assume that + * their buffer changes are not included in the checkpoint. */ { /* use volatile pointer to prevent code rearrangement */ @@ -5219,15 +5195,15 @@ CreateCheckPoint(bool shutdown, bool force) &checkPoint.nextMultiOffset); /* - * Having constructed the checkpoint record, ensure all shmem disk - * buffers and commit-log buffers are flushed to disk. + * Having constructed the checkpoint record, ensure all shmem disk buffers + * and commit-log buffers are flushed to disk. * - * This I/O could fail for various reasons. If so, we will fail to - * complete the checkpoint, but there is no reason to force a system - * panic. Accordingly, exit critical section while doing it. (If - * we are doing a shutdown checkpoint, we probably *should* panic --- - * but that will happen anyway because we'll still be inside the - * critical section established by ShutdownXLOG.) + * This I/O could fail for various reasons. If so, we will fail to complete + * the checkpoint, but there is no reason to force a system panic. + * Accordingly, exit critical section while doing it. (If we are doing a + * shutdown checkpoint, we probably *should* panic --- but that will + * happen anyway because we'll still be inside the critical section + * established by ShutdownXLOG.) */ END_CRIT_SECTION(); @@ -5260,8 +5236,8 @@ CreateCheckPoint(bool shutdown, bool force) XLogFlush(recptr); /* - * We now have ProcLastRecPtr = start of actual checkpoint record, - * recptr = end of actual checkpoint record. + * We now have ProcLastRecPtr = start of actual checkpoint record, recptr + * = end of actual checkpoint record. */ if (shutdown && !XLByteEQ(checkPoint.redo, ProcLastRecPtr)) ereport(PANIC, @@ -5287,8 +5263,8 @@ CreateCheckPoint(bool shutdown, bool force) LWLockRelease(ControlFileLock); /* - * We are now done with critical updates; no need for system panic if - * we have trouble while fooling with offline log segments. + * We are now done with critical updates; no need for system panic if we + * have trouble while fooling with offline log segments. */ END_CRIT_SECTION(); @@ -5304,19 +5280,18 @@ CreateCheckPoint(bool shutdown, bool force) } /* - * Make more log segments if needed. (Do this after deleting offline - * log segments, to avoid having peak disk space usage higher than - * necessary.) + * Make more log segments if needed. (Do this after deleting offline log + * segments, to avoid having peak disk space usage higher than necessary.) */ if (!shutdown) nsegsadded = PreallocXlogFiles(recptr); /* - * Truncate pg_subtrans if possible. We can throw away all data - * before the oldest XMIN of any running transaction. No future - * transaction will attempt to reference any pg_subtrans entry older - * than that (see Asserts in subtrans.c). During recovery, though, we - * mustn't do this because StartupSUBTRANS hasn't been called yet. + * Truncate pg_subtrans if possible. We can throw away all data before + * the oldest XMIN of any running transaction. No future transaction will + * attempt to reference any pg_subtrans entry older than that (see Asserts + * in subtrans.c). During recovery, though, we mustn't do this because + * StartupSUBTRANS hasn't been called yet. */ if (!InRecovery) TruncateSUBTRANS(GetOldestXmin(true)); @@ -5342,13 +5317,14 @@ XLogPutNextOid(Oid nextOid) rdata.buffer = InvalidBuffer; rdata.next = NULL; (void) XLogInsert(RM_XLOG_ID, XLOG_NEXTOID, &rdata); + /* * We need not flush the NEXTOID record immediately, because any of the - * just-allocated OIDs could only reach disk as part of a tuple insert - * or update that would have its own XLOG record that must follow the - * NEXTOID record. Therefore, the standard buffer LSN interlock applied - * to those records will ensure no such OID reaches disk before the - * NEXTOID record does. + * just-allocated OIDs could only reach disk as part of a tuple insert or + * update that would have its own XLOG record that must follow the NEXTOID + * record. Therefore, the standard buffer LSN interlock applied to those + * records will ensure no such OID reaches disk before the NEXTOID record + * does. */ } @@ -5384,8 +5360,7 @@ xlog_redo(XLogRecPtr lsn, XLogRecord *record) checkPoint.nextMultiOffset); /* - * TLI may change in a shutdown checkpoint, but it shouldn't - * decrease + * TLI may change in a shutdown checkpoint, but it shouldn't decrease */ if (checkPoint.ThisTimeLineID != ThisTimeLineID) { @@ -5394,7 +5369,7 @@ xlog_redo(XLogRecPtr lsn, XLogRecord *record) (int) checkPoint.ThisTimeLineID)) ereport(PANIC, (errmsg("unexpected timeline ID %u (after %u) in checkpoint record", - checkPoint.ThisTimeLineID, ThisTimeLineID))); + checkPoint.ThisTimeLineID, ThisTimeLineID))); /* Following WAL records should be run with new TLI */ ThisTimeLineID = checkPoint.ThisTimeLineID; } @@ -5441,7 +5416,7 @@ xlog_desc(char *buf, uint8 xl_info, char *rec) checkpoint->nextOid, checkpoint->nextMulti, checkpoint->nextMultiOffset, - (info == XLOG_CHECKPOINT_SHUTDOWN) ? "shutdown" : "online"); + (info == XLOG_CHECKPOINT_SHUTDOWN) ? "shutdown" : "online"); } else if (info == XLOG_NEXTOID) { @@ -5535,23 +5510,23 @@ assign_xlog_sync_method(const char *method, bool doit, GucSource source) /* * To ensure that no blocks escape unsynced, force an fsync on the * currently open log segment (if any). Also, if the open flag is - * changing, close the log file so it will be reopened (with new - * flag bit) at next use. + * changing, close the log file so it will be reopened (with new flag + * bit) at next use. */ if (openLogFile >= 0) { if (pg_fsync(openLogFile) != 0) ereport(PANIC, (errcode_for_file_access(), - errmsg("could not fsync log file %u, segment %u: %m", - openLogId, openLogSeg))); + errmsg("could not fsync log file %u, segment %u: %m", + openLogId, openLogSeg))); if (open_sync_bit != new_sync_bit) { if (close(openLogFile)) ereport(PANIC, (errcode_for_file_access(), - errmsg("could not close log file %u, segment %u: %m", - openLogId, openLogSeg))); + errmsg("could not close log file %u, segment %u: %m", + openLogId, openLogSeg))); openLogFile = -1; } } @@ -5575,16 +5550,16 @@ issue_xlog_fsync(void) if (pg_fsync_no_writethrough(openLogFile) != 0) ereport(PANIC, (errcode_for_file_access(), - errmsg("could not fsync log file %u, segment %u: %m", - openLogId, openLogSeg))); + errmsg("could not fsync log file %u, segment %u: %m", + openLogId, openLogSeg))); break; #ifdef HAVE_FSYNC_WRITETHROUGH case SYNC_METHOD_FSYNC_WRITETHROUGH: if (pg_fsync_writethrough(openLogFile) != 0) ereport(PANIC, (errcode_for_file_access(), - errmsg("could not fsync write-through log file %u, segment %u: %m", - openLogId, openLogSeg))); + errmsg("could not fsync write-through log file %u, segment %u: %m", + openLogId, openLogSeg))); break; #endif #ifdef HAVE_FDATASYNC @@ -5592,8 +5567,8 @@ issue_xlog_fsync(void) if (pg_fdatasync(openLogFile) != 0) ereport(PANIC, (errcode_for_file_access(), - errmsg("could not fdatasync log file %u, segment %u: %m", - openLogId, openLogSeg))); + errmsg("could not fdatasync log file %u, segment %u: %m", + openLogId, openLogSeg))); break; #endif case SYNC_METHOD_OPEN: @@ -5640,25 +5615,25 @@ pg_start_backup(PG_FUNCTION_ARGS) ereport(ERROR, (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), (errmsg("WAL archiving is not active"), - (errhint("archive_command must be defined before " - "online backups can be made safely."))))); + (errhint("archive_command must be defined before " + "online backups can be made safely."))))); backupidstr = DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(backupid))); + PointerGetDatum(backupid))); /* - * Force a CHECKPOINT. This is not strictly necessary, but it seems - * like a good idea to minimize the amount of past WAL needed to use - * the backup. Also, this guarantees that two successive backup runs - * will have different checkpoint positions and hence different - * history file names, even if nothing happened in between. + * Force a CHECKPOINT. This is not strictly necessary, but it seems like + * a good idea to minimize the amount of past WAL needed to use the + * backup. Also, this guarantees that two successive backup runs will + * have different checkpoint positions and hence different history file + * names, even if nothing happened in between. */ RequestCheckpoint(true, false); /* - * Now we need to fetch the checkpoint record location, and also its - * REDO pointer. The oldest point in WAL that would be needed to - * restore starting from the checkpoint is precisely the REDO pointer. + * Now we need to fetch the checkpoint record location, and also its REDO + * pointer. The oldest point in WAL that would be needed to restore + * starting from the checkpoint is precisely the REDO pointer. */ LWLockAcquire(ControlFileLock, LW_EXCLUSIVE); checkpointloc = ControlFile->checkPoint; @@ -5669,10 +5644,10 @@ pg_start_backup(PG_FUNCTION_ARGS) XLogFileName(xlogfilename, ThisTimeLineID, _logId, _logSeg); /* - * We deliberately use strftime/localtime not the src/timezone - * functions, so that backup labels will consistently be recorded in - * the same timezone regardless of TimeZone setting. This matches - * elog.c's practice. + * We deliberately use strftime/localtime not the src/timezone functions, + * so that backup labels will consistently be recorded in the same + * timezone regardless of TimeZone setting. This matches elog.c's + * practice. */ stamp_time = time(NULL); strftime(strfbuf, sizeof(strfbuf), @@ -5680,8 +5655,7 @@ pg_start_backup(PG_FUNCTION_ARGS) localtime(&stamp_time)); /* - * Check for existing backup label --- implies a backup is already - * running + * Check for existing backup label --- implies a backup is already running */ if (stat(BACKUP_LABEL_FILE, &stat_buf) != 0) { @@ -5725,7 +5699,7 @@ pg_start_backup(PG_FUNCTION_ARGS) snprintf(xlogfilename, sizeof(xlogfilename), "%X/%X", startpoint.xlogid, startpoint.xrecoff); result = DatumGetTextP(DirectFunctionCall1(textin, - CStringGetDatum(xlogfilename))); + CStringGetDatum(xlogfilename))); PG_RETURN_TEXT_P(result); } @@ -5762,8 +5736,8 @@ pg_stop_backup(PG_FUNCTION_ARGS) (errmsg("must be superuser to run a backup")))); /* - * Get the current end-of-WAL position; it will be unsafe to use this - * dump to restore to a point in advance of this time. + * Get the current end-of-WAL position; it will be unsafe to use this dump + * to restore to a point in advance of this time. */ LWLockAcquire(WALInsertLock, LW_EXCLUSIVE); INSERT_RECPTR(stoppoint, Insert, Insert->curridx); @@ -5773,10 +5747,10 @@ pg_stop_backup(PG_FUNCTION_ARGS) XLogFileName(stopxlogfilename, ThisTimeLineID, _logId, _logSeg); /* - * We deliberately use strftime/localtime not the src/timezone - * functions, so that backup labels will consistently be recorded in - * the same timezone regardless of TimeZone setting. This matches - * elog.c's practice. + * We deliberately use strftime/localtime not the src/timezone functions, + * so that backup labels will consistently be recorded in the same + * timezone regardless of TimeZone setting. This matches elog.c's + * practice. */ stamp_time = time(NULL); strftime(strfbuf, sizeof(strfbuf), @@ -5800,9 +5774,8 @@ pg_stop_backup(PG_FUNCTION_ARGS) } /* - * Read and parse the START WAL LOCATION line (this code is pretty - * crude, but we are not expecting any variability in the file - * format). + * Read and parse the START WAL LOCATION line (this code is pretty crude, + * but we are not expecting any variability in the file format). */ if (fscanf(lfp, "START WAL LOCATION: %X/%X (file %24s)%c", &startpoint.xlogid, &startpoint.xrecoff, startxlogfilename, @@ -5869,7 +5842,7 @@ pg_stop_backup(PG_FUNCTION_ARGS) snprintf(stopxlogfilename, sizeof(stopxlogfilename), "%X/%X", stoppoint.xlogid, stoppoint.xrecoff); result = DatumGetTextP(DirectFunctionCall1(textin, - CStringGetDatum(stopxlogfilename))); + CStringGetDatum(stopxlogfilename))); PG_RETURN_TEXT_P(result); } @@ -5921,9 +5894,9 @@ read_backup_label(XLogRecPtr *checkPointLoc) } /* - * Read and parse the START WAL LOCATION and CHECKPOINT lines (this - * code is pretty crude, but we are not expecting any variability in - * the file format). + * Read and parse the START WAL LOCATION and CHECKPOINT lines (this code + * is pretty crude, but we are not expecting any variability in the file + * format). */ if (fscanf(lfp, "START WAL LOCATION: %X/%X (file %08X%16s)%c", &startpoint.xlogid, &startpoint.xrecoff, &tli, @@ -5963,17 +5936,17 @@ read_backup_label(XLogRecPtr *checkPointLoc) * Parse history file to identify stop point. */ if (fscanf(fp, "START WAL LOCATION: %X/%X (file %24s)%c", - &startpoint.xlogid, &startpoint.xrecoff, startxlogfilename, + &startpoint.xlogid, &startpoint.xrecoff, startxlogfilename, &ch) != 4 || ch != '\n') ereport(FATAL, (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), - errmsg("invalid data in file \"%s\"", histfilename))); + errmsg("invalid data in file \"%s\"", histfilename))); if (fscanf(fp, "STOP WAL LOCATION: %X/%X (file %24s)%c", - &stoppoint.xlogid, &stoppoint.xrecoff, stopxlogfilename, + &stoppoint.xlogid, &stoppoint.xrecoff, stopxlogfilename, &ch) != 4 || ch != '\n') ereport(FATAL, (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), - errmsg("invalid data in file \"%s\"", histfilename))); + errmsg("invalid data in file \"%s\"", histfilename))); recoveryMinXlogOffset = stoppoint; if (ferror(fp) || FreeFile(fp)) ereport(FATAL, diff --git a/src/backend/access/transam/xlogutils.c b/src/backend/access/transam/xlogutils.c index 55caf84a04..485aa52474 100644 --- a/src/backend/access/transam/xlogutils.c +++ b/src/backend/access/transam/xlogutils.c @@ -11,7 +11,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/access/transam/xlogutils.c,v 1.38 2005/06/06 17:01:23 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/transam/xlogutils.c,v 1.39 2005/10/15 02:49:11 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -121,7 +121,7 @@ _xl_remove_hash_entry(XLogRelDesc *rdesc) rdesc->moreRecently->lessRecently = rdesc->lessRecently; hentry = (XLogRelCacheEntry *) hash_search(_xlrelcache, - (void *) &(rdesc->reldata.rd_node), HASH_REMOVE, NULL); + (void *) &(rdesc->reldata.rd_node), HASH_REMOVE, NULL); if (hentry == NULL) elog(PANIC, "_xl_remove_hash_entry: file was not found in cache"); @@ -211,11 +211,11 @@ XLogOpenRelation(RelFileNode rnode) res->reldata.rd_node = rnode; /* - * We set up the lockRelId in case anything tries to lock the - * dummy relation. Note that this is fairly bogus since relNode - * may be different from the relation's OID. It shouldn't really - * matter though, since we are presumably running by ourselves and - * can't have any lock conflicts ... + * We set up the lockRelId in case anything tries to lock the dummy + * relation. Note that this is fairly bogus since relNode may be + * different from the relation's OID. It shouldn't really matter + * though, since we are presumably running by ourselves and can't have + * any lock conflicts ... */ res->reldata.rd_lockInfo.lockRelId.dbId = rnode.dbNode; res->reldata.rd_lockInfo.lockRelId.relId = rnode.relNode; @@ -233,13 +233,13 @@ XLogOpenRelation(RelFileNode rnode) RelationOpenSmgr(&(res->reldata)); /* - * Create the target file if it doesn't already exist. This lets - * us cope if the replay sequence contains writes to a relation - * that is later deleted. (The original coding of this routine - * would instead return NULL, causing the writes to be suppressed. - * But that seems like it risks losing valuable data if the - * filesystem loses an inode during a crash. Better to write the - * data until we are actually told to delete the file.) + * Create the target file if it doesn't already exist. This lets us + * cope if the replay sequence contains writes to a relation that is + * later deleted. (The original coding of this routine would instead + * return NULL, causing the writes to be suppressed. But that seems + * like it risks losing valuable data if the filesystem loses an inode + * during a crash. Better to write the data until we are actually + * told to delete the file.) */ smgrcreate(res->reldata.rd_smgr, res->reldata.rd_istemp, true); } diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c index 6f74ceaed7..9ea3d74111 100644 --- a/src/backend/bootstrap/bootstrap.c +++ b/src/backend/bootstrap/bootstrap.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.206 2005/08/08 03:11:30 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.207 2005/10/15 02:49:12 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -379,9 +379,8 @@ BootstrapMain(int argc, char *argv[]) BaseInit(); /* - * We aren't going to do the full InitPostgres pushups, but there - * are a couple of things that need to get lit up even in a dummy - * process. + * We aren't going to do the full InitPostgres pushups, but there are a + * couple of things that need to get lit up even in a dummy process. */ if (IsUnderPostmaster) { @@ -445,8 +444,8 @@ BootstrapMain(int argc, char *argv[]) /* * In NOP mode, all we really want to do is create shared memory and - * semaphores (just to prove we can do it with the current GUC - * settings). So, quit now. + * semaphores (just to prove we can do it with the current GUC settings). + * So, quit now. */ if (xlogop == BS_XLOG_NOP) proc_exit(0); @@ -465,8 +464,8 @@ BootstrapMain(int argc, char *argv[]) /* * Process bootstrap input. * - * the sed script boot.sed renamed yyparse to Int_yyparse for the - * bootstrap parser to avoid conflicts with the normal SQL parser + * the sed script boot.sed renamed yyparse to Int_yyparse for the bootstrap + * parser to avoid conflicts with the normal SQL parser */ Int_yyparse(); @@ -537,8 +536,7 @@ bootstrap_signals(void) pqsignal(SIGWINCH, SIG_DFL); /* - * Unblock signals (they were blocked when the postmaster forked - * us) + * Unblock signals (they were blocked when the postmaster forked us) */ PG_SETMASK(&UnBlockSig); } @@ -733,12 +731,12 @@ DefineAttr(char *name, char *type, int attnum) attrtypes[attnum]->attislocal = true; /* - * Mark as "not null" if type is fixed-width and prior columns are - * too. This corresponds to case where column can be accessed directly - * via C struct declaration. + * Mark as "not null" if type is fixed-width and prior columns are too. + * This corresponds to case where column can be accessed directly via C + * struct declaration. * - * oidvector and int2vector are also treated as not-nullable, even - * though they are no longer fixed-width. + * oidvector and int2vector are also treated as not-nullable, even though + * they are no longer fixed-width. */ #define MARKNOTNULL(att) \ ((att)->attlen > 0 || \ @@ -1005,8 +1003,7 @@ MapArrayTypeName(char *s) { int i, j; - static char newStr[NAMEDATALEN]; /* array type names < NAMEDATALEN - * long */ + static char newStr[NAMEDATALEN]; /* array type names < NAMEDATALEN long */ if (s == NULL || s[0] == '\0') return s; @@ -1095,8 +1092,8 @@ FindStr(char *str, int length, hashnode *mderef) while (node != NULL) { /* - * We must differentiate between string constants that might have - * the same value as a identifier and the identifier itself. + * We must differentiate between string constants that might have the + * same value as a identifier and the identifier itself. */ if (!strcmp(str, strtable[node->strnum])) { @@ -1131,11 +1128,11 @@ AddStr(char *str, int strlength, int mderef) elog(FATAL, "bootstrap string table overflow"); /* - * Some of the utilites (eg, define type, create relation) assume that - * the string they're passed is a NAMEDATALEN. We get array bound - * read violations from purify if we don't allocate at least - * NAMEDATALEN bytes for strings of this sort. Because we're lazy, we - * allocate at least NAMEDATALEN bytes all the time. + * Some of the utilites (eg, define type, create relation) assume that the + * string they're passed is a NAMEDATALEN. We get array bound read + * violations from purify if we don't allocate at least NAMEDATALEN bytes + * for strings of this sort. Because we're lazy, we allocate at least + * NAMEDATALEN bytes all the time. */ if ((len = strlength + 1) < NAMEDATALEN) @@ -1191,8 +1188,8 @@ index_register(Oid heap, /* * XXX mao 10/31/92 -- don't gc index reldescs, associated info at - * bootstrap time. we'll declare the indices now, but want to create - * them later. + * bootstrap time. we'll declare the indices now, but want to create them + * later. */ if (nogc == NULL) diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c index 689a2ff819..15a197af81 100644 --- a/src/backend/catalog/aclchk.c +++ b/src/backend/catalog/aclchk.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/catalog/aclchk.c,v 1.119 2005/10/10 18:49:01 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/catalog/aclchk.c,v 1.120 2005/10/15 02:49:12 momjian Exp $ * * NOTES * See acl.h. @@ -65,7 +65,7 @@ dumpacl(Acl *acl) for (i = 0; i < ACL_NUM(acl); ++i) elog(DEBUG2, " acl[%d]: %s", i, DatumGetCString(DirectFunctionCall1(aclitemout, - PointerGetDatum(aip + i)))); + PointerGetDatum(aip + i)))); } #endif /* ACLDEBUG */ @@ -101,9 +101,10 @@ merge_acl_with_grant(Acl *old_acl, bool is_grant, Acl *newer_acl; if (grantee->rolname) - aclitem.ai_grantee = get_roleid_checked(grantee->rolname); + aclitem. ai_grantee = get_roleid_checked(grantee->rolname); + else - aclitem.ai_grantee = ACL_ID_PUBLIC; + aclitem. ai_grantee = ACL_ID_PUBLIC; /* * Grant options can only be granted to individual roles, not PUBLIC. @@ -116,19 +117,18 @@ merge_acl_with_grant(Acl *old_acl, bool is_grant, (errcode(ERRCODE_INVALID_GRANT_OPERATION), errmsg("grant options can only be granted to roles"))); - aclitem.ai_grantor = grantorId; + aclitem. ai_grantor = grantorId; /* * The asymmetry in the conditions here comes from the spec. In - * GRANT, the grant_option flag signals WITH GRANT OPTION, which - * means to grant both the basic privilege and its grant option. - * But in REVOKE, plain revoke revokes both the basic privilege - * and its grant option, while REVOKE GRANT OPTION revokes only - * the option. + * GRANT, the grant_option flag signals WITH GRANT OPTION, which means + * to grant both the basic privilege and its grant option. But in + * REVOKE, plain revoke revokes both the basic privilege and its grant + * option, while REVOKE GRANT OPTION revokes only the option. */ ACLITEM_SET_PRIVS_GOPTIONS(aclitem, - (is_grant || !grant_option) ? privileges : ACL_NO_RIGHTS, - (!is_grant || grant_option) ? privileges : ACL_NO_RIGHTS); + (is_grant || !grant_option) ? privileges : ACL_NO_RIGHTS, + (!is_grant || grant_option) ? privileges : ACL_NO_RIGHTS); newer_acl = aclupdate(new_acl, &aclitem, modechg, ownerId, behavior); @@ -221,8 +221,8 @@ ExecuteGrantStmt_Relation(GrantStmt *stmt) AclMode this_privileges; Acl *old_acl; Acl *new_acl; - Oid grantorId; - Oid ownerId; + Oid grantorId; + Oid ownerId; HeapTuple newtuple; Datum values[Natts_pg_class]; char nulls[Natts_pg_class]; @@ -257,8 +257,8 @@ ExecuteGrantStmt_Relation(GrantStmt *stmt) relvar->relname))); /* - * Get owner ID and working copy of existing ACL. - * If there's no ACL, substitute the proper default. + * Get owner ID and working copy of existing ACL. If there's no ACL, + * substitute the proper default. */ ownerId = pg_class_tuple->relowner; aclDatum = SysCacheGetAttr(RELOID, tuple, Anum_pg_class_relacl, @@ -275,8 +275,8 @@ ExecuteGrantStmt_Relation(GrantStmt *stmt) /* * If we found no grant options, consider whether to issue a hard - * error. Per spec, having any privilege at all on the object - * will get you by here. + * error. Per spec, having any privilege at all on the object will + * get you by here. */ if (avail_goptions == ACL_NO_RIGHTS) { @@ -289,12 +289,12 @@ ExecuteGrantStmt_Relation(GrantStmt *stmt) } /* - * Restrict the operation to what we can actually grant or revoke, - * and issue a warning if appropriate. (For REVOKE this isn't - * quite what the spec says to do: the spec seems to want a - * warning only if no privilege bits actually change in the ACL. - * In practice that behavior seems much too noisy, as well as - * inconsistent with the GRANT case.) + * Restrict the operation to what we can actually grant or revoke, and + * issue a warning if appropriate. (For REVOKE this isn't quite what + * the spec says to do: the spec seems to want a warning only if no + * privilege bits actually change in the ACL. In practice that + * behavior seems much too noisy, as well as inconsistent with the + * GRANT case.) */ this_privileges = privileges & ACL_OPTION_TO_PRIVS(avail_goptions); if (stmt->is_grant) @@ -323,8 +323,8 @@ ExecuteGrantStmt_Relation(GrantStmt *stmt) /* * Generate new ACL. * - * We need the members of both old and new ACLs so we can correct - * the shared dependency information. + * We need the members of both old and new ACLs so we can correct the + * shared dependency information. */ noldmembers = aclmembers(old_acl, &oldmembers); @@ -411,8 +411,8 @@ ExecuteGrantStmt_Database(GrantStmt *stmt) AclMode this_privileges; Acl *old_acl; Acl *new_acl; - Oid grantorId; - Oid ownerId; + Oid grantorId; + Oid ownerId; HeapTuple newtuple; Datum values[Natts_pg_database]; char nulls[Natts_pg_database]; @@ -436,8 +436,8 @@ ExecuteGrantStmt_Database(GrantStmt *stmt) pg_database_tuple = (Form_pg_database) GETSTRUCT(tuple); /* - * Get owner ID and working copy of existing ACL. - * If there's no ACL, substitute the proper default. + * Get owner ID and working copy of existing ACL. If there's no ACL, + * substitute the proper default. */ ownerId = pg_database_tuple->datdba; aclDatum = heap_getattr(tuple, Anum_pg_database_datacl, @@ -454,8 +454,8 @@ ExecuteGrantStmt_Database(GrantStmt *stmt) /* * If we found no grant options, consider whether to issue a hard - * error. Per spec, having any privilege at all on the object - * will get you by here. + * error. Per spec, having any privilege at all on the object will + * get you by here. */ if (avail_goptions == ACL_NO_RIGHTS) { @@ -468,12 +468,12 @@ ExecuteGrantStmt_Database(GrantStmt *stmt) } /* - * Restrict the operation to what we can actually grant or revoke, - * and issue a warning if appropriate. (For REVOKE this isn't - * quite what the spec says to do: the spec seems to want a - * warning only if no privilege bits actually change in the ACL. - * In practice that behavior seems much too noisy, as well as - * inconsistent with the GRANT case.) + * Restrict the operation to what we can actually grant or revoke, and + * issue a warning if appropriate. (For REVOKE this isn't quite what + * the spec says to do: the spec seems to want a warning only if no + * privilege bits actually change in the ACL. In practice that + * behavior seems much too noisy, as well as inconsistent with the + * GRANT case.) */ this_privileges = privileges & ACL_OPTION_TO_PRIVS(avail_goptions); if (stmt->is_grant) @@ -502,8 +502,8 @@ ExecuteGrantStmt_Database(GrantStmt *stmt) /* * Generate new ACL. * - * We need the members of both old and new ACLs so we can correct - * the shared dependency information. + * We need the members of both old and new ACLs so we can correct the + * shared dependency information. */ noldmembers = aclmembers(old_acl, &oldmembers); @@ -589,8 +589,8 @@ ExecuteGrantStmt_Function(GrantStmt *stmt) AclMode this_privileges; Acl *old_acl; Acl *new_acl; - Oid grantorId; - Oid ownerId; + Oid grantorId; + Oid ownerId; HeapTuple newtuple; Datum values[Natts_pg_proc]; char nulls[Natts_pg_proc]; @@ -611,8 +611,8 @@ ExecuteGrantStmt_Function(GrantStmt *stmt) pg_proc_tuple = (Form_pg_proc) GETSTRUCT(tuple); /* - * Get owner ID and working copy of existing ACL. - * If there's no ACL, substitute the proper default. + * Get owner ID and working copy of existing ACL. If there's no ACL, + * substitute the proper default. */ ownerId = pg_proc_tuple->proowner; aclDatum = SysCacheGetAttr(PROCOID, tuple, Anum_pg_proc_proacl, @@ -629,8 +629,8 @@ ExecuteGrantStmt_Function(GrantStmt *stmt) /* * If we found no grant options, consider whether to issue a hard - * error. Per spec, having any privilege at all on the object - * will get you by here. + * error. Per spec, having any privilege at all on the object will + * get you by here. */ if (avail_goptions == ACL_NO_RIGHTS) { @@ -643,12 +643,12 @@ ExecuteGrantStmt_Function(GrantStmt *stmt) } /* - * Restrict the operation to what we can actually grant or revoke, - * and issue a warning if appropriate. (For REVOKE this isn't - * quite what the spec says to do: the spec seems to want a - * warning only if no privilege bits actually change in the ACL. - * In practice that behavior seems much too noisy, as well as - * inconsistent with the GRANT case.) + * Restrict the operation to what we can actually grant or revoke, and + * issue a warning if appropriate. (For REVOKE this isn't quite what + * the spec says to do: the spec seems to want a warning only if no + * privilege bits actually change in the ACL. In practice that + * behavior seems much too noisy, as well as inconsistent with the + * GRANT case.) */ this_privileges = privileges & ACL_OPTION_TO_PRIVS(avail_goptions); if (stmt->is_grant) @@ -677,8 +677,8 @@ ExecuteGrantStmt_Function(GrantStmt *stmt) /* * Generate new ACL. * - * We need the members of both old and new ACLs so we can correct - * the shared dependency information. + * We need the members of both old and new ACLs so we can correct the + * shared dependency information. */ noldmembers = aclmembers(old_acl, &oldmembers); @@ -763,8 +763,8 @@ ExecuteGrantStmt_Language(GrantStmt *stmt) AclMode this_privileges; Acl *old_acl; Acl *new_acl; - Oid grantorId; - Oid ownerId; + Oid grantorId; + Oid ownerId; HeapTuple newtuple; Datum values[Natts_pg_language]; char nulls[Natts_pg_language]; @@ -788,14 +788,14 @@ ExecuteGrantStmt_Language(GrantStmt *stmt) ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), errmsg("language \"%s\" is not trusted", langname), - errhint("Only superusers may use untrusted languages."))); + errhint("Only superusers may use untrusted languages."))); /* - * Get owner ID and working copy of existing ACL. - * If there's no ACL, substitute the proper default. + * Get owner ID and working copy of existing ACL. If there's no ACL, + * substitute the proper default. * - * Note: for now, languages are treated as owned by the bootstrap - * user. We should add an owner column to pg_language instead. + * Note: for now, languages are treated as owned by the bootstrap user. + * We should add an owner column to pg_language instead. */ ownerId = BOOTSTRAP_SUPERUSERID; aclDatum = SysCacheGetAttr(LANGNAME, tuple, Anum_pg_language_lanacl, @@ -812,8 +812,8 @@ ExecuteGrantStmt_Language(GrantStmt *stmt) /* * If we found no grant options, consider whether to issue a hard - * error. Per spec, having any privilege at all on the object - * will get you by here. + * error. Per spec, having any privilege at all on the object will + * get you by here. */ if (avail_goptions == ACL_NO_RIGHTS) { @@ -826,12 +826,12 @@ ExecuteGrantStmt_Language(GrantStmt *stmt) } /* - * Restrict the operation to what we can actually grant or revoke, - * and issue a warning if appropriate. (For REVOKE this isn't - * quite what the spec says to do: the spec seems to want a - * warning only if no privilege bits actually change in the ACL. - * In practice that behavior seems much too noisy, as well as - * inconsistent with the GRANT case.) + * Restrict the operation to what we can actually grant or revoke, and + * issue a warning if appropriate. (For REVOKE this isn't quite what + * the spec says to do: the spec seems to want a warning only if no + * privilege bits actually change in the ACL. In practice that + * behavior seems much too noisy, as well as inconsistent with the + * GRANT case.) */ this_privileges = privileges & ACL_OPTION_TO_PRIVS(avail_goptions); if (stmt->is_grant) @@ -860,8 +860,8 @@ ExecuteGrantStmt_Language(GrantStmt *stmt) /* * Generate new ACL. * - * We need the members of both old and new ACLs so we can correct - * the shared dependency information. + * We need the members of both old and new ACLs so we can correct the + * shared dependency information. */ noldmembers = aclmembers(old_acl, &oldmembers); @@ -946,8 +946,8 @@ ExecuteGrantStmt_Namespace(GrantStmt *stmt) AclMode this_privileges; Acl *old_acl; Acl *new_acl; - Oid grantorId; - Oid ownerId; + Oid grantorId; + Oid ownerId; HeapTuple newtuple; Datum values[Natts_pg_namespace]; char nulls[Natts_pg_namespace]; @@ -968,8 +968,8 @@ ExecuteGrantStmt_Namespace(GrantStmt *stmt) pg_namespace_tuple = (Form_pg_namespace) GETSTRUCT(tuple); /* - * Get owner ID and working copy of existing ACL. - * If there's no ACL, substitute the proper default. + * Get owner ID and working copy of existing ACL. If there's no ACL, + * substitute the proper default. */ ownerId = pg_namespace_tuple->nspowner; aclDatum = SysCacheGetAttr(NAMESPACENAME, tuple, @@ -987,8 +987,8 @@ ExecuteGrantStmt_Namespace(GrantStmt *stmt) /* * If we found no grant options, consider whether to issue a hard - * error. Per spec, having any privilege at all on the object - * will get you by here. + * error. Per spec, having any privilege at all on the object will + * get you by here. */ if (avail_goptions == ACL_NO_RIGHTS) { @@ -1001,12 +1001,12 @@ ExecuteGrantStmt_Namespace(GrantStmt *stmt) } /* - * Restrict the operation to what we can actually grant or revoke, - * and issue a warning if appropriate. (For REVOKE this isn't - * quite what the spec says to do: the spec seems to want a - * warning only if no privilege bits actually change in the ACL. - * In practice that behavior seems much too noisy, as well as - * inconsistent with the GRANT case.) + * Restrict the operation to what we can actually grant or revoke, and + * issue a warning if appropriate. (For REVOKE this isn't quite what + * the spec says to do: the spec seems to want a warning only if no + * privilege bits actually change in the ACL. In practice that + * behavior seems much too noisy, as well as inconsistent with the + * GRANT case.) */ this_privileges = privileges & ACL_OPTION_TO_PRIVS(avail_goptions); if (stmt->is_grant) @@ -1035,8 +1035,8 @@ ExecuteGrantStmt_Namespace(GrantStmt *stmt) /* * Generate new ACL. * - * We need the members of both old and new ACLs so we can correct - * the shared dependency information. + * We need the members of both old and new ACLs so we can correct the + * shared dependency information. */ noldmembers = aclmembers(old_acl, &oldmembers); @@ -1103,8 +1103,8 @@ ExecuteGrantStmt_Tablespace(GrantStmt *stmt) if (priv & ~((AclMode) ACL_ALL_RIGHTS_TABLESPACE)) ereport(ERROR, (errcode(ERRCODE_INVALID_GRANT_OPERATION), - errmsg("invalid privilege type %s for tablespace", - privilege_to_string(priv)))); + errmsg("invalid privilege type %s for tablespace", + privilege_to_string(priv)))); privileges |= priv; } } @@ -1123,8 +1123,8 @@ ExecuteGrantStmt_Tablespace(GrantStmt *stmt) AclMode this_privileges; Acl *old_acl; Acl *new_acl; - Oid grantorId; - Oid ownerId; + Oid grantorId; + Oid ownerId; HeapTuple newtuple; Datum values[Natts_pg_tablespace]; char nulls[Natts_pg_tablespace]; @@ -1144,12 +1144,12 @@ ExecuteGrantStmt_Tablespace(GrantStmt *stmt) if (!HeapTupleIsValid(tuple)) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), - errmsg("tablespace \"%s\" does not exist", spcname))); + errmsg("tablespace \"%s\" does not exist", spcname))); pg_tablespace_tuple = (Form_pg_tablespace) GETSTRUCT(tuple); /* - * Get owner ID and working copy of existing ACL. - * If there's no ACL, substitute the proper default. + * Get owner ID and working copy of existing ACL. If there's no ACL, + * substitute the proper default. */ ownerId = pg_tablespace_tuple->spcowner; aclDatum = heap_getattr(tuple, Anum_pg_tablespace_spcacl, @@ -1166,8 +1166,8 @@ ExecuteGrantStmt_Tablespace(GrantStmt *stmt) /* * If we found no grant options, consider whether to issue a hard - * error. Per spec, having any privilege at all on the object - * will get you by here. + * error. Per spec, having any privilege at all on the object will + * get you by here. */ if (avail_goptions == ACL_NO_RIGHTS) { @@ -1180,12 +1180,12 @@ ExecuteGrantStmt_Tablespace(GrantStmt *stmt) } /* - * Restrict the operation to what we can actually grant or revoke, - * and issue a warning if appropriate. (For REVOKE this isn't - * quite what the spec says to do: the spec seems to want a - * warning only if no privilege bits actually change in the ACL. - * In practice that behavior seems much too noisy, as well as - * inconsistent with the GRANT case.) + * Restrict the operation to what we can actually grant or revoke, and + * issue a warning if appropriate. (For REVOKE this isn't quite what + * the spec says to do: the spec seems to want a warning only if no + * privilege bits actually change in the ACL. In practice that + * behavior seems much too noisy, as well as inconsistent with the + * GRANT case.) */ this_privileges = privileges & ACL_OPTION_TO_PRIVS(avail_goptions); if (stmt->is_grant) @@ -1214,8 +1214,8 @@ ExecuteGrantStmt_Tablespace(GrantStmt *stmt) /* * Generate new ACL. * - * We need the members of both old and new ACLs so we can correct - * the shared dependency information. + * We need the members of both old and new ACLs so we can correct the + * shared dependency information. */ noldmembers = aclmembers(old_acl, &oldmembers); @@ -1449,7 +1449,7 @@ pg_class_aclmask(Oid table_oid, Oid roleid, Datum aclDatum; bool isNull; Acl *acl; - Oid ownerId; + Oid ownerId; /* * Must get the relation's tuple from pg_class @@ -1467,8 +1467,7 @@ pg_class_aclmask(Oid table_oid, Oid roleid, /* * Deny anyone permission to update a system catalog unless * pg_authid.rolcatupdate is set. (This is to let superusers protect - * themselves from themselves.) Also allow it if - * allowSystemTableMods. + * themselves from themselves.) Also allow it if allowSystemTableMods. * * As of 7.4 we have some updatable system views; those shouldn't be * protected in this way. Assume the view rules can take care of @@ -1543,7 +1542,7 @@ pg_database_aclmask(Oid db_oid, Oid roleid, Datum aclDatum; bool isNull; Acl *acl; - Oid ownerId; + Oid ownerId; /* Superusers bypass all permission checking. */ if (superuser_arg(roleid)) @@ -1607,7 +1606,7 @@ pg_proc_aclmask(Oid proc_oid, Oid roleid, Datum aclDatum; bool isNull; Acl *acl; - Oid ownerId; + Oid ownerId; /* Superusers bypass all permission checking. */ if (superuser_arg(roleid)) @@ -1622,7 +1621,7 @@ pg_proc_aclmask(Oid proc_oid, Oid roleid, if (!HeapTupleIsValid(tuple)) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_FUNCTION), - errmsg("function with OID %u does not exist", proc_oid))); + errmsg("function with OID %u does not exist", proc_oid))); ownerId = ((Form_pg_proc) GETSTRUCT(tuple))->proowner; @@ -1663,7 +1662,7 @@ pg_language_aclmask(Oid lang_oid, Oid roleid, Datum aclDatum; bool isNull; Acl *acl; - Oid ownerId; + Oid ownerId; /* Superusers bypass all permission checking. */ if (superuser_arg(roleid)) @@ -1678,7 +1677,7 @@ pg_language_aclmask(Oid lang_oid, Oid roleid, if (!HeapTupleIsValid(tuple)) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), - errmsg("language with OID %u does not exist", lang_oid))); + errmsg("language with OID %u does not exist", lang_oid))); /* XXX pg_language should have an owner column, but doesn't */ ownerId = BOOTSTRAP_SUPERUSERID; @@ -1720,30 +1719,30 @@ pg_namespace_aclmask(Oid nsp_oid, Oid roleid, Datum aclDatum; bool isNull; Acl *acl; - Oid ownerId; + Oid ownerId; /* Superusers bypass all permission checking. */ if (superuser_arg(roleid)) return mask; /* - * If we have been assigned this namespace as a temp namespace, check - * to make sure we have CREATE TEMP permission on the database, and if - * so act as though we have all standard (but not GRANT OPTION) - * permissions on the namespace. If we don't have CREATE TEMP, act as - * though we have only USAGE (and not CREATE) rights. + * If we have been assigned this namespace as a temp namespace, check to + * make sure we have CREATE TEMP permission on the database, and if so act + * as though we have all standard (but not GRANT OPTION) permissions on + * the namespace. If we don't have CREATE TEMP, act as though we have + * only USAGE (and not CREATE) rights. * - * This may seem redundant given the check in InitTempTableNamespace, but - * it really isn't since current user ID may have changed since then. - * The upshot of this behavior is that a SECURITY DEFINER function can - * create temp tables that can then be accessed (if permission is - * granted) by code in the same session that doesn't have permissions - * to create temp tables. + * This may seem redundant given the check in InitTempTableNamespace, but it + * really isn't since current user ID may have changed since then. The + * upshot of this behavior is that a SECURITY DEFINER function can create + * temp tables that can then be accessed (if permission is granted) by + * code in the same session that doesn't have permissions to create temp + * tables. * * XXX Would it be safe to ereport a special error message as * InitTempTableNamespace does? Returning zero here means we'll get a - * generic "permission denied for schema pg_temp_N" message, which is - * not remarkably user-friendly. + * generic "permission denied for schema pg_temp_N" message, which is not + * remarkably user-friendly. */ if (isTempNamespace(nsp_oid)) { @@ -1807,7 +1806,7 @@ pg_tablespace_aclmask(Oid spc_oid, Oid roleid, Datum aclDatum; bool isNull; Acl *acl; - Oid ownerId; + Oid ownerId; /* * Only shared relations can be stored in global space; don't let even @@ -1835,7 +1834,7 @@ pg_tablespace_aclmask(Oid spc_oid, Oid roleid, if (!HeapTupleIsValid(tuple)) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), - errmsg("tablespace with OID %u does not exist", spc_oid))); + errmsg("tablespace with OID %u does not exist", spc_oid))); ownerId = ((Form_pg_tablespace) GETSTRUCT(tuple))->spcowner; @@ -1951,7 +1950,7 @@ bool pg_class_ownercheck(Oid class_oid, Oid roleid) { HeapTuple tuple; - Oid ownerId; + Oid ownerId; /* Superusers bypass all permission checking. */ if (superuser_arg(roleid)) @@ -1963,7 +1962,7 @@ pg_class_ownercheck(Oid class_oid, Oid roleid) if (!HeapTupleIsValid(tuple)) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_TABLE), - errmsg("relation with OID %u does not exist", class_oid))); + errmsg("relation with OID %u does not exist", class_oid))); ownerId = ((Form_pg_class) GETSTRUCT(tuple))->relowner; @@ -1979,7 +1978,7 @@ bool pg_type_ownercheck(Oid type_oid, Oid roleid) { HeapTuple tuple; - Oid ownerId; + Oid ownerId; /* Superusers bypass all permission checking. */ if (superuser_arg(roleid)) @@ -2007,7 +2006,7 @@ bool pg_oper_ownercheck(Oid oper_oid, Oid roleid) { HeapTuple tuple; - Oid ownerId; + Oid ownerId; /* Superusers bypass all permission checking. */ if (superuser_arg(roleid)) @@ -2019,7 +2018,7 @@ pg_oper_ownercheck(Oid oper_oid, Oid roleid) if (!HeapTupleIsValid(tuple)) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_FUNCTION), - errmsg("operator with OID %u does not exist", oper_oid))); + errmsg("operator with OID %u does not exist", oper_oid))); ownerId = ((Form_pg_operator) GETSTRUCT(tuple))->oprowner; @@ -2035,7 +2034,7 @@ bool pg_proc_ownercheck(Oid proc_oid, Oid roleid) { HeapTuple tuple; - Oid ownerId; + Oid ownerId; /* Superusers bypass all permission checking. */ if (superuser_arg(roleid)) @@ -2047,7 +2046,7 @@ pg_proc_ownercheck(Oid proc_oid, Oid roleid) if (!HeapTupleIsValid(tuple)) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_FUNCTION), - errmsg("function with OID %u does not exist", proc_oid))); + errmsg("function with OID %u does not exist", proc_oid))); ownerId = ((Form_pg_proc) GETSTRUCT(tuple))->proowner; @@ -2063,7 +2062,7 @@ bool pg_namespace_ownercheck(Oid nsp_oid, Oid roleid) { HeapTuple tuple; - Oid ownerId; + Oid ownerId; /* Superusers bypass all permission checking. */ if (superuser_arg(roleid)) @@ -2094,7 +2093,7 @@ pg_tablespace_ownercheck(Oid spc_oid, Oid roleid) ScanKeyData entry[1]; HeapScanDesc scan; HeapTuple spctuple; - Oid spcowner; + Oid spcowner; /* Superusers bypass all permission checking. */ if (superuser_arg(roleid)) @@ -2113,7 +2112,7 @@ pg_tablespace_ownercheck(Oid spc_oid, Oid roleid) if (!HeapTupleIsValid(spctuple)) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), - errmsg("tablespace with OID %u does not exist", spc_oid))); + errmsg("tablespace with OID %u does not exist", spc_oid))); spcowner = ((Form_pg_tablespace) GETSTRUCT(spctuple))->spcowner; @@ -2130,7 +2129,7 @@ bool pg_opclass_ownercheck(Oid opc_oid, Oid roleid) { HeapTuple tuple; - Oid ownerId; + Oid ownerId; /* Superusers bypass all permission checking. */ if (superuser_arg(roleid)) @@ -2162,7 +2161,7 @@ pg_database_ownercheck(Oid db_oid, Oid roleid) ScanKeyData entry[1]; HeapScanDesc scan; HeapTuple dbtuple; - Oid dba; + Oid dba; /* Superusers bypass all permission checking. */ if (superuser_arg(roleid)) @@ -2198,7 +2197,7 @@ bool pg_conversion_ownercheck(Oid conv_oid, Oid roleid) { HeapTuple tuple; - Oid ownerId; + Oid ownerId; /* Superusers bypass all permission checking. */ if (superuser_arg(roleid)) @@ -2210,7 +2209,7 @@ pg_conversion_ownercheck(Oid conv_oid, Oid roleid) if (!HeapTupleIsValid(tuple)) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), - errmsg("conversion with OID %u does not exist", conv_oid))); + errmsg("conversion with OID %u does not exist", conv_oid))); ownerId = ((Form_pg_conversion) GETSTRUCT(tuple))->conowner; diff --git a/src/backend/catalog/catalog.c b/src/backend/catalog/catalog.c index 0648b578e9..69313ea86a 100644 --- a/src/backend/catalog/catalog.c +++ b/src/backend/catalog/catalog.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/catalog/catalog.c,v 1.63 2005/08/12 01:35:56 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/catalog/catalog.c,v 1.64 2005/10/15 02:49:12 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -233,7 +233,7 @@ IsReservedName(const char *name) * Since the OID is not immediately inserted into the table, there is a * race condition here; but a problem could occur only if someone else * managed to cycle through 2^32 OIDs and generate the same OID before we - * finish inserting our row. This seems unlikely to be a problem. Note + * finish inserting our row. This seems unlikely to be a problem. Note * that if we had to *commit* the row to end the race condition, the risk * would be rather higher; therefore we use SnapshotDirty in the test, * so that we will see uncommitted rows. @@ -259,9 +259,9 @@ GetNewOid(Relation relation) if (!OidIsValid(oidIndex)) { /* - * System catalogs that have OIDs should *always* have a unique - * OID index; we should only take this path for user tables. - * Give a warning if it looks like somebody forgot an index. + * System catalogs that have OIDs should *always* have a unique OID + * index; we should only take this path for user tables. Give a + * warning if it looks like somebody forgot an index. */ if (IsSystemRelation(relation)) elog(WARNING, "generating possibly-non-unique OID for \"%s\"", @@ -338,7 +338,7 @@ GetNewOidWithIndex(Relation relation, Relation indexrel) Oid GetNewRelFileNode(Oid reltablespace, bool relisshared, Relation pg_class) { - RelFileNode rnode; + RelFileNode rnode; char *rpath; int fd; bool collides; @@ -369,14 +369,14 @@ GetNewRelFileNode(Oid reltablespace, bool relisshared, Relation pg_class) { /* * Here we have a little bit of a dilemma: if errno is something - * other than ENOENT, should we declare a collision and loop? - * In particular one might think this advisable for, say, EPERM. + * other than ENOENT, should we declare a collision and loop? In + * particular one might think this advisable for, say, EPERM. * However there really shouldn't be any unreadable files in a * tablespace directory, and if the EPERM is actually complaining * that we can't read the directory itself, we'd be in an infinite * loop. In practice it seems best to go ahead regardless of the - * errno. If there is a colliding file we will get an smgr failure - * when we attempt to create the new relation file. + * errno. If there is a colliding file we will get an smgr + * failure when we attempt to create the new relation file. */ collides = false; } diff --git a/src/backend/catalog/dependency.c b/src/backend/catalog/dependency.c index 8060055ff7..92d72af0f9 100644 --- a/src/backend/catalog/dependency.c +++ b/src/backend/catalog/dependency.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/catalog/dependency.c,v 1.46 2005/10/02 23:50:07 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/catalog/dependency.c,v 1.47 2005/10/15 02:49:12 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -155,9 +155,9 @@ performDeletion(const ObjectAddress *object, /* * Construct a list of objects that are reachable by AUTO or INTERNAL - * dependencies from the target object. These should be deleted - * silently, even if the actual deletion pass first reaches one of - * them via a non-auto dependency. + * dependencies from the target object. These should be deleted silently, + * even if the actual deletion pass first reaches one of them via a + * non-auto dependency. */ init_object_addresses(&oktodelete); @@ -167,9 +167,9 @@ performDeletion(const ObjectAddress *object, NULL, &oktodelete, depRel)) ereport(ERROR, (errcode(ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST), - errmsg("cannot drop %s because other objects depend on it", - objDescription), - errhint("Use DROP ... CASCADE to drop the dependent objects too."))); + errmsg("cannot drop %s because other objects depend on it", + objDescription), + errhint("Use DROP ... CASCADE to drop the dependent objects too."))); term_object_addresses(&oktodelete); @@ -209,17 +209,17 @@ deleteWhatDependsOn(const ObjectAddress *object, /* * Construct a list of objects that are reachable by AUTO or INTERNAL - * dependencies from the target object. These should be deleted - * silently, even if the actual deletion pass first reaches one of - * them via a non-auto dependency. + * dependencies from the target object. These should be deleted silently, + * even if the actual deletion pass first reaches one of them via a + * non-auto dependency. */ init_object_addresses(&oktodelete); findAutoDeletableObjects(object, &oktodelete, depRel); /* - * Now invoke only step 2 of recursiveDeletion: just recurse to the - * stuff dependent on the given object. + * Now invoke only step 2 of recursiveDeletion: just recurse to the stuff + * dependent on the given object. */ if (!deleteDependentObjects(object, objDescription, DROP_CASCADE, @@ -263,9 +263,9 @@ findAutoDeletableObjects(const ObjectAddress *object, ObjectAddress otherObject; /* - * If this object is already in oktodelete, then we already visited - * it; don't do so again (this prevents infinite recursion if there's - * a loop in pg_depend). Otherwise, add it. + * If this object is already in oktodelete, then we already visited it; + * don't do so again (this prevents infinite recursion if there's a loop + * in pg_depend). Otherwise, add it. */ if (object_address_present(object, oktodelete)) return; @@ -273,11 +273,11 @@ findAutoDeletableObjects(const ObjectAddress *object, /* * Scan pg_depend records that link to this object, showing the things - * that depend on it. For each one that is AUTO or INTERNAL, visit - * the referencing object. + * that depend on it. For each one that is AUTO or INTERNAL, visit the + * referencing object. * - * When dropping a whole object (subId = 0), find pg_depend records for - * its sub-objects too. + * When dropping a whole object (subId = 0), find pg_depend records for its + * sub-objects too. */ ScanKeyInit(&key[0], Anum_pg_depend_refclassid, @@ -322,8 +322,8 @@ findAutoDeletableObjects(const ObjectAddress *object, /* * For a PIN dependency we just ereport immediately; there - * won't be any others to examine, and we aren't ever - * going to let the user delete it. + * won't be any others to examine, and we aren't ever going to + * let the user delete it. */ ereport(ERROR, (errcode(ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST), @@ -406,13 +406,13 @@ recursiveDeletion(const ObjectAddress *object, objDescription = getObjectDescription(object); /* - * Step 1: find and remove pg_depend records that link from this - * object to others. We have to do this anyway, and doing it first - * ensures that we avoid infinite recursion in the case of cycles. - * Also, some dependency types require extra processing here. + * Step 1: find and remove pg_depend records that link from this object to + * others. We have to do this anyway, and doing it first ensures that we + * avoid infinite recursion in the case of cycles. Also, some dependency + * types require extra processing here. * - * When dropping a whole object (subId = 0), remove all pg_depend records - * for its sub-objects too. + * When dropping a whole object (subId = 0), remove all pg_depend records for + * its sub-objects too. */ ScanKeyInit(&key[0], Anum_pg_depend_classid, @@ -456,41 +456,41 @@ recursiveDeletion(const ObjectAddress *object, * This object is part of the internal implementation of * another object. We have three cases: * - * 1. At the outermost recursion level, disallow the DROP. - * (We just ereport here, rather than proceeding, since no - * other dependencies are likely to be interesting.) + * 1. At the outermost recursion level, disallow the DROP. (We + * just ereport here, rather than proceeding, since no other + * dependencies are likely to be interesting.) */ if (callingObject == NULL) { char *otherObjDesc = getObjectDescription(&otherObject); ereport(ERROR, - (errcode(ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST), - errmsg("cannot drop %s because %s requires it", - objDescription, otherObjDesc), - errhint("You may drop %s instead.", - otherObjDesc))); + (errcode(ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST), + errmsg("cannot drop %s because %s requires it", + objDescription, otherObjDesc), + errhint("You may drop %s instead.", + otherObjDesc))); } /* - * 2. When recursing from the other end of this - * dependency, it's okay to continue with the deletion. - * This holds when recursing from a whole object that - * includes the nominal other end as a component, too. + * 2. When recursing from the other end of this dependency, + * it's okay to continue with the deletion. This holds when + * recursing from a whole object that includes the nominal + * other end as a component, too. */ if (callingObject->classId == otherObject.classId && callingObject->objectId == otherObject.objectId && - (callingObject->objectSubId == otherObject.objectSubId || - callingObject->objectSubId == 0)) + (callingObject->objectSubId == otherObject.objectSubId || + callingObject->objectSubId == 0)) break; /* * 3. When recursing from anyplace else, transform this - * deletion request into a delete of the other object. - * (This will be an error condition iff RESTRICT mode.) In - * this case we finish deleting my dependencies except for - * the INTERNAL link, which will be needed to cause the - * owning object to recurse back to me. + * deletion request into a delete of the other object. (This + * will be an error condition iff RESTRICT mode.) In this case + * we finish deleting my dependencies except for the INTERNAL + * link, which will be needed to cause the owning object to + * recurse back to me. */ if (amOwned) /* shouldn't happen */ elog(ERROR, "multiple INTERNAL dependencies for %s", @@ -502,8 +502,8 @@ recursiveDeletion(const ObjectAddress *object, case DEPENDENCY_PIN: /* - * Should not happen; PIN dependencies should have zeroes - * in the depender fields... + * Should not happen; PIN dependencies should have zeroes in + * the depender fields... */ elog(ERROR, "incorrect use of PIN dependency with %s", objDescription); @@ -521,10 +521,10 @@ recursiveDeletion(const ObjectAddress *object, systable_endscan(scan); /* - * CommandCounterIncrement here to ensure that preceding changes are - * all visible; in particular, that the above deletions of pg_depend - * entries are visible. That prevents infinite recursion in case of a - * dependency loop (which is perfectly legal). + * CommandCounterIncrement here to ensure that preceding changes are all + * visible; in particular, that the above deletions of pg_depend entries + * are visible. That prevents infinite recursion in case of a dependency + * loop (which is perfectly legal). */ CommandCounterIncrement(); @@ -562,11 +562,11 @@ recursiveDeletion(const ObjectAddress *object, } /* - * Step 2: scan pg_depend records that link to this object, showing - * the things that depend on it. Recursively delete those things. - * Note it's important to delete the dependent objects before the - * referenced one, since the deletion routines might do things like - * try to update the pg_class record when deleting a check constraint. + * Step 2: scan pg_depend records that link to this object, showing the + * things that depend on it. Recursively delete those things. Note it's + * important to delete the dependent objects before the referenced one, + * since the deletion routines might do things like try to update the + * pg_class record when deleting a check constraint. */ if (!deleteDependentObjects(object, objDescription, behavior, msglevel, @@ -584,23 +584,21 @@ recursiveDeletion(const ObjectAddress *object, doDeletion(object); /* - * Delete any comments associated with this object. (This is a - * convenient place to do it instead of having every object type know - * to do it.) + * Delete any comments associated with this object. (This is a convenient + * place to do it instead of having every object type know to do it.) */ DeleteComments(object->objectId, object->classId, object->objectSubId); /* - * Delete shared dependency references related to this object. - * Sub-objects (columns) don't have dependencies on global objects, - * so skip them. + * Delete shared dependency references related to this object. Sub-objects + * (columns) don't have dependencies on global objects, so skip them. */ if (object->objectSubId == 0) deleteSharedDependencyRecordsFor(object->classId, object->objectId); /* - * CommandCounterIncrement here to ensure that preceding changes are - * all visible. + * CommandCounterIncrement here to ensure that preceding changes are all + * visible. */ CommandCounterIncrement(); @@ -691,10 +689,10 @@ deleteDependentObjects(const ObjectAddress *object, case DEPENDENCY_NORMAL: /* - * Perhaps there was another dependency path that would - * have allowed silent deletion of the otherObject, had we - * only taken that path first. In that case, act like this - * link is AUTO, too. + * Perhaps there was another dependency path that would have + * allowed silent deletion of the otherObject, had we only + * taken that path first. In that case, act like this link is + * AUTO, too. */ if (object_address_present(&otherObject, oktodelete)) ereport(DEBUG2, @@ -1023,7 +1021,7 @@ find_expr_references_walker(Node *node, var->varattno > list_length(rte->joinaliasvars)) elog(ERROR, "invalid varattno %d", var->varattno); find_expr_references_walker((Node *) list_nth(rte->joinaliasvars, - var->varattno - 1), + var->varattno - 1), context); list_free(context->rtables); context->rtables = save_rtables; @@ -1037,9 +1035,9 @@ find_expr_references_walker(Node *node, /* * If it's a regclass or similar literal referring to an existing - * object, add a reference to that object. (Currently, only the - * regclass case has any likely use, but we may as well handle all - * the OID-alias datatypes consistently.) + * object, add a reference to that object. (Currently, only the + * regclass case has any likely use, but we may as well handle all the + * OID-alias datatypes consistently.) */ if (!con->constisnull) { @@ -1156,11 +1154,10 @@ find_expr_references_walker(Node *node, bool result; /* - * Add whole-relation refs for each plain relation mentioned in - * the subquery's rtable. (Note: query_tree_walker takes care of - * recursing into RTE_FUNCTION and RTE_SUBQUERY RTEs, so no need - * to do that here. But keep it from looking at join alias - * lists.) + * Add whole-relation refs for each plain relation mentioned in the + * subquery's rtable. (Note: query_tree_walker takes care of + * recursing into RTE_FUNCTION and RTE_SUBQUERY RTEs, so no need to do + * that here. But keep it from looking at join alias lists.) */ foreach(rtable, query->rtable) { @@ -1215,11 +1212,11 @@ eliminate_duplicate_dependencies(ObjectAddresses *addrs) continue; /* identical, so drop thisobj */ /* - * If we have a whole-object reference and a reference to a - * part of the same object, we don't need the whole-object - * reference (for example, we don't need to reference both - * table foo and column foo.bar). The whole-object reference - * will always appear first in the sorted list. + * If we have a whole-object reference and a reference to a part + * of the same object, we don't need the whole-object reference + * (for example, we don't need to reference both table foo and + * column foo.bar). The whole-object reference will always appear + * first in the sorted list. */ if (priorobj->objectSubId == 0) { @@ -1469,8 +1466,8 @@ getObjectDescription(const ObjectAddress *object) getRelationDescription(&buffer, object->objectId); if (object->objectSubId != 0) appendStringInfo(&buffer, _(" column %s"), - get_relid_attribute_name(object->objectId, - object->objectSubId)); + get_relid_attribute_name(object->objectId, + object->objectSubId)); break; case OCLASS_PROC: @@ -1566,13 +1563,13 @@ getObjectDescription(const ObjectAddress *object) HeapTuple conTup; conTup = SearchSysCache(CONOID, - ObjectIdGetDatum(object->objectId), + ObjectIdGetDatum(object->objectId), 0, 0, 0); if (!HeapTupleIsValid(conTup)) elog(ERROR, "cache lookup failed for conversion %u", object->objectId); appendStringInfo(&buffer, _("conversion %s"), - NameStr(((Form_pg_conversion) GETSTRUCT(conTup))->conname)); + NameStr(((Form_pg_conversion) GETSTRUCT(conTup))->conname)); ReleaseSysCache(conTup); break; } @@ -1621,13 +1618,13 @@ getObjectDescription(const ObjectAddress *object) HeapTuple langTup; langTup = SearchSysCache(LANGOID, - ObjectIdGetDatum(object->objectId), + ObjectIdGetDatum(object->objectId), 0, 0, 0); if (!HeapTupleIsValid(langTup)) elog(ERROR, "cache lookup failed for language %u", object->objectId); appendStringInfo(&buffer, _("language %s"), - NameStr(((Form_pg_language) GETSTRUCT(langTup))->lanname)); + NameStr(((Form_pg_language) GETSTRUCT(langTup))->lanname)); ReleaseSysCache(langTup); break; } @@ -1646,7 +1643,7 @@ getObjectDescription(const ObjectAddress *object) char *nspname; opcTup = SearchSysCache(CLAOID, - ObjectIdGetDatum(object->objectId), + ObjectIdGetDatum(object->objectId), 0, 0, 0); if (!HeapTupleIsValid(opcTup)) elog(ERROR, "cache lookup failed for opclass %u", @@ -1669,7 +1666,7 @@ getObjectDescription(const ObjectAddress *object) appendStringInfo(&buffer, _("operator class %s for access method %s"), quote_qualified_identifier(nspname, - NameStr(opcForm->opcname)), + NameStr(opcForm->opcname)), NameStr(amForm->amname)); ReleaseSysCache(amTup); diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c index f5f030695b..15c0129c61 100644 --- a/src/backend/catalog/heap.c +++ b/src/backend/catalog/heap.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/catalog/heap.c,v 1.290 2005/08/26 03:07:12 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/catalog/heap.c,v 1.291 2005/10/15 02:49:12 momjian Exp $ * * * INTERFACE ROUTINES @@ -67,7 +67,7 @@ static void AddNewRelationTuple(Relation pg_class_desc, Oid new_rel_oid, Oid new_type_oid, Oid relowner, char relkind); -static Oid AddNewRelationType(const char *typeName, +static Oid AddNewRelationType(const char *typeName, Oid typeNamespace, Oid new_rel_oid, char new_rel_kind); @@ -217,23 +217,24 @@ heap_create(const char *relname, * sanity checks */ if (!allow_system_table_mods && - (IsSystemNamespace(relnamespace) || IsToastNamespace(relnamespace)) && + (IsSystemNamespace(relnamespace) || IsToastNamespace(relnamespace)) && IsNormalProcessingMode()) ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), errmsg("permission denied to create \"%s.%s\"", get_namespace_name(relnamespace), relname), - errdetail("System catalog modifications are currently disallowed."))); + errdetail("System catalog modifications are currently disallowed."))); /* - * Decide if we need storage or not, and handle a couple other - * special cases for particular relkinds. + * Decide if we need storage or not, and handle a couple other special + * cases for particular relkinds. */ switch (relkind) { case RELKIND_VIEW: case RELKIND_COMPOSITE_TYPE: create_storage = false; + /* * Force reltablespace to zero if the relation has no physical * storage. This is mainly just for cleanliness' sake. @@ -242,6 +243,7 @@ heap_create(const char *relname, break; case RELKIND_SEQUENCE: create_storage = true; + /* * Force reltablespace to zero for sequences, since we don't * support moving them around into different tablespaces. @@ -257,8 +259,8 @@ heap_create(const char *relname, * Never allow a pg_class entry to explicitly specify the database's * default tablespace in reltablespace; force it to zero instead. This * ensures that if the database is cloned with a different default - * tablespace, the pg_class entry will still match where CREATE - * DATABASE will put the physically copied relation. + * tablespace, the pg_class entry will still match where CREATE DATABASE + * will put the physically copied relation. * * Yes, this is a bit of a hack. */ @@ -276,8 +278,7 @@ heap_create(const char *relname, shared_relation); /* - * have the storage manager create the relation's disk file, if - * needed. + * have the storage manager create the relation's disk file, if needed. */ if (create_storage) { @@ -453,8 +454,8 @@ AddNewAttributeTuples(Oid new_rel_oid, indstate = CatalogOpenIndexes(rel); /* - * First we add the user attributes. This is also a convenient place - * to add dependencies on their datatypes. + * First we add the user attributes. This is also a convenient place to + * add dependencies on their datatypes. */ dpp = tupdesc->attrs; for (i = 0; i < natts; i++) @@ -488,10 +489,9 @@ AddNewAttributeTuples(Oid new_rel_oid, } /* - * Next we add the system attributes. Skip OID if rel has no OIDs. - * Skip all for a view or type relation. We don't bother with making - * datatype dependencies here, since presumably all these types are - * pinned. + * Next we add the system attributes. Skip OID if rel has no OIDs. Skip + * all for a view or type relation. We don't bother with making datatype + * dependencies here, since presumably all these types are pinned. */ if (relkind != RELKIND_VIEW && relkind != RELKIND_COMPOSITE_TYPE) { @@ -563,8 +563,8 @@ AddNewRelationTuple(Relation pg_class_desc, HeapTuple tup; /* - * first we update some of the information in our uncataloged - * relation's relation descriptor. + * first we update some of the information in our uncataloged relation's + * relation descriptor. */ new_rel_reltup = new_rel_desc->rd_rel; @@ -632,28 +632,28 @@ AddNewRelationType(const char *typeName, char new_rel_kind) { return - TypeCreate(typeName, /* type name */ - typeNamespace, /* type namespace */ - new_rel_oid, /* relation oid */ + TypeCreate(typeName, /* type name */ + typeNamespace, /* type namespace */ + new_rel_oid, /* relation oid */ new_rel_kind, /* relation kind */ - -1, /* internal size (varlena) */ - 'c', /* type-type (complex) */ - ',', /* default array delimiter */ - F_RECORD_IN, /* input procedure */ + -1, /* internal size (varlena) */ + 'c', /* type-type (complex) */ + ',', /* default array delimiter */ + F_RECORD_IN, /* input procedure */ F_RECORD_OUT, /* output procedure */ - F_RECORD_RECV, /* receive procedure */ - F_RECORD_SEND, /* send procedure */ - InvalidOid, /* analyze procedure - default */ - InvalidOid, /* array element type - irrelevant */ - InvalidOid, /* domain base type - irrelevant */ - NULL, /* default value - none */ - NULL, /* default binary representation */ - false, /* passed by reference */ - 'd', /* alignment - must be the largest! */ - 'x', /* fully TOASTable */ - -1, /* typmod */ - 0, /* array dimensions for typBaseType */ - false); /* Type NOT NULL */ + F_RECORD_RECV, /* receive procedure */ + F_RECORD_SEND, /* send procedure */ + InvalidOid, /* analyze procedure - default */ + InvalidOid, /* array element type - irrelevant */ + InvalidOid, /* domain base type - irrelevant */ + NULL, /* default value - none */ + NULL, /* default binary representation */ + false, /* passed by reference */ + 'd', /* alignment - must be the largest! */ + 'x', /* fully TOASTable */ + -1, /* typmod */ + 0, /* array dimensions for typBaseType */ + false); /* Type NOT NULL */ } /* -------------------------------- @@ -697,17 +697,17 @@ heap_create_with_catalog(const char *relname, /* * Allocate an OID for the relation, unless we were told what to use. * - * The OID will be the relfilenode as well, so make sure it doesn't - * collide with either pg_class OIDs or existing physical files. + * The OID will be the relfilenode as well, so make sure it doesn't collide + * with either pg_class OIDs or existing physical files. */ if (!OidIsValid(relid)) relid = GetNewRelFileNode(reltablespace, shared_relation, pg_class_desc); /* - * Create the relcache entry (mostly dummy at this point) and the - * physical disk file. (If we fail further down, it's the smgr's - * responsibility to remove the disk file again.) + * Create the relcache entry (mostly dummy at this point) and the physical + * disk file. (If we fail further down, it's the smgr's responsibility to + * remove the disk file again.) */ new_rel_desc = heap_create(relname, relnamespace, @@ -724,8 +724,8 @@ heap_create_with_catalog(const char *relname, * since defining a relation also defines a complex type, we add a new * system type corresponding to the new relation. * - * NOTE: we could get a unique-index failure here, in case the same name - * has already been used for a type. + * NOTE: we could get a unique-index failure here, in case the same name has + * already been used for a type. */ new_type_oid = AddNewRelationType(relname, relnamespace, @@ -735,9 +735,9 @@ heap_create_with_catalog(const char *relname, /* * now create an entry in pg_class for the relation. * - * NOTE: we could get a unique-index failure here, in case someone else - * is creating the same relation name in parallel but hadn't committed - * yet when we checked for a duplicate name above. + * NOTE: we could get a unique-index failure here, in case someone else is + * creating the same relation name in parallel but hadn't committed yet + * when we checked for a duplicate name above. */ AddNewRelationTuple(pg_class_desc, new_rel_desc, @@ -747,8 +747,7 @@ heap_create_with_catalog(const char *relname, relkind); /* - * now add tuples to pg_attribute for the attributes in our new - * relation. + * now add tuples to pg_attribute for the attributes in our new relation. */ AddNewAttributeTuples(relid, new_rel_desc->rd_att, relkind, oidislocal, oidinhcount); @@ -779,10 +778,9 @@ heap_create_with_catalog(const char *relname, /* * store constraints and defaults passed in the tupdesc, if any. * - * NB: this may do a CommandCounterIncrement and rebuild the relcache - * entry, so the relation must be valid and self-consistent at this - * point. In particular, there are not yet constraints and defaults - * anywhere. + * NB: this may do a CommandCounterIncrement and rebuild the relcache entry, + * so the relation must be valid and self-consistent at this point. In + * particular, there are not yet constraints and defaults anywhere. */ StoreConstraints(new_rel_desc, tupdesc); @@ -793,8 +791,8 @@ heap_create_with_catalog(const char *relname, register_on_commit_action(relid, oncommit); /* - * ok, the relation has been cataloged, so close our relations and - * return the OID of the newly created relation. + * ok, the relation has been cataloged, so close our relations and return + * the OID of the newly created relation. */ heap_close(new_rel_desc, NoLock); /* do not unlock till end of xact */ heap_close(pg_class_desc, RowExclusiveLock); @@ -923,11 +921,11 @@ RemoveAttributeById(Oid relid, AttrNumber attnum) char newattname[NAMEDATALEN]; /* - * Grab an exclusive lock on the target table, which we will NOT - * release until end of transaction. (In the simple case where we are - * directly dropping this column, AlterTableDropColumn already did - * this ... but when cascading from a drop of some other object, we - * may not have any lock.) + * Grab an exclusive lock on the target table, which we will NOT release + * until end of transaction. (In the simple case where we are directly + * dropping this column, AlterTableDropColumn already did this ... but + * when cascading from a drop of some other object, we may not have any + * lock.) */ rel = relation_open(relid, AccessExclusiveLock); @@ -957,12 +955,12 @@ RemoveAttributeById(Oid relid, AttrNumber attnum) /* * Set the type OID to invalid. A dropped attribute's type link - * cannot be relied on (once the attribute is dropped, the type - * might be too). Fortunately we do not need the type row --- the - * only really essential information is the type's typlen and - * typalign, which are preserved in the attribute's attlen and - * attalign. We set atttypid to zero here as a means of catching - * code that incorrectly expects it to be valid. + * cannot be relied on (once the attribute is dropped, the type might + * be too). Fortunately we do not need the type row --- the only + * really essential information is the type's typlen and typalign, + * which are preserved in the attribute's attlen and attalign. We set + * atttypid to zero here as a means of catching code that incorrectly + * expects it to be valid. */ attStruct->atttypid = InvalidOid; @@ -973,8 +971,7 @@ RemoveAttributeById(Oid relid, AttrNumber attnum) attStruct->attstattarget = 0; /* - * Change the column name to something that isn't likely to - * conflict + * Change the column name to something that isn't likely to conflict */ snprintf(newattname, sizeof(newattname), "........pg.dropped.%d........", attnum); @@ -987,9 +984,9 @@ RemoveAttributeById(Oid relid, AttrNumber attnum) } /* - * Because updating the pg_attribute row will trigger a relcache flush - * for the target relation, we need not do anything else to notify - * other backends of the change. + * Because updating the pg_attribute row will trigger a relcache flush for + * the target relation, we need not do anything else to notify other + * backends of the change. */ heap_close(attr_rel, RowExclusiveLock); @@ -1118,8 +1115,8 @@ RemoveAttrDefaultById(Oid attrdefId) CatalogUpdateIndexes(attr_rel, tuple); /* - * Our update of the pg_attribute row will force a relcache rebuild, - * so there's nothing else to do here. + * Our update of the pg_attribute row will force a relcache rebuild, so + * there's nothing else to do here. */ heap_close(attr_rel, RowExclusiveLock); @@ -1157,9 +1154,9 @@ heap_drop_with_catalog(Oid relid) } /* - * Close relcache entry, but *keep* AccessExclusiveLock on the - * relation until transaction commit. This ensures no one else will - * try to do something with the doomed relation. + * Close relcache entry, but *keep* AccessExclusiveLock on the relation + * until transaction commit. This ensures no one else will try to do + * something with the doomed relation. */ relation_close(rel, NoLock); @@ -1170,10 +1167,10 @@ heap_drop_with_catalog(Oid relid) /* * Flush the relation from the relcache. We want to do this before - * starting to remove catalog entries, just to be certain that no - * relcache entry rebuild will happen partway through. (That should - * not really matter, since we don't do CommandCounterIncrement here, - * but let's be safe.) + * starting to remove catalog entries, just to be certain that no relcache + * entry rebuild will happen partway through. (That should not really + * matter, since we don't do CommandCounterIncrement here, but let's be + * safe.) */ RelationForgetRelation(relid); @@ -1228,8 +1225,8 @@ StoreAttrDefault(Relation rel, AttrNumber attnum, char *adbin) * deparse it */ adsrc = deparse_expression(expr, - deparse_context_for(RelationGetRelationName(rel), - RelationGetRelid(rel)), + deparse_context_for(RelationGetRelationName(rel), + RelationGetRelid(rel)), false, false); /* @@ -1238,9 +1235,9 @@ StoreAttrDefault(Relation rel, AttrNumber attnum, char *adbin) values[Anum_pg_attrdef_adrelid - 1] = RelationGetRelid(rel); values[Anum_pg_attrdef_adnum - 1] = attnum; values[Anum_pg_attrdef_adbin - 1] = DirectFunctionCall1(textin, - CStringGetDatum(adbin)); + CStringGetDatum(adbin)); values[Anum_pg_attrdef_adsrc - 1] = DirectFunctionCall1(textin, - CStringGetDatum(adsrc)); + CStringGetDatum(adsrc)); adrel = heap_open(AttrDefaultRelationId, RowExclusiveLock); @@ -1285,8 +1282,8 @@ StoreAttrDefault(Relation rel, AttrNumber attnum, char *adbin) heap_freetuple(atttup); /* - * Make a dependency so that the pg_attrdef entry goes away if the - * column (or whole table) is deleted. + * Make a dependency so that the pg_attrdef entry goes away if the column + * (or whole table) is deleted. */ colobject.classId = RelationRelationId; colobject.objectId = RelationGetRelid(rel); @@ -1325,16 +1322,15 @@ StoreRelCheck(Relation rel, char *ccname, char *ccbin) * deparse it */ ccsrc = deparse_expression(expr, - deparse_context_for(RelationGetRelationName(rel), - RelationGetRelid(rel)), + deparse_context_for(RelationGetRelationName(rel), + RelationGetRelid(rel)), false, false); /* * Find columns of rel that are used in ccbin * - * NB: pull_var_clause is okay here only because we don't allow - * subselects in check constraints; it would fail to examine the - * contents of subselects. + * NB: pull_var_clause is okay here only because we don't allow subselects in + * check constraints; it would fail to examine the contents of subselects. */ varList = pull_var_clause(expr, false); keycount = list_length(varList); @@ -1405,10 +1401,9 @@ StoreConstraints(Relation rel, TupleDesc tupdesc) return; /* nothing to do */ /* - * Deparsing of constraint expressions will fail unless the - * just-created pg_attribute tuples for this relation are made - * visible. So, bump the command counter. CAUTION: this will cause a - * relcache entry rebuild. + * Deparsing of constraint expressions will fail unless the just-created + * pg_attribute tuples for this relation are made visible. So, bump the + * command counter. CAUTION: this will cause a relcache entry rebuild. */ CommandCounterIncrement(); @@ -1483,8 +1478,8 @@ AddRelationRawConstraints(Relation rel, } /* - * Create a dummy ParseState and insert the target relation as its - * sole rangetable entry. We need a ParseState for transformExpr. + * Create a dummy ParseState and insert the target relation as its sole + * rangetable entry. We need a ParseState for transformExpr. */ pstate = make_parsestate(NULL); rte = addRangeTableEntryForRelation(pstate, @@ -1546,8 +1541,8 @@ AddRelationRawConstraints(Relation rel, if (list_length(pstate->p_rtable) != 1) ereport(ERROR, (errcode(ERRCODE_INVALID_COLUMN_REFERENCE), - errmsg("only table \"%s\" can be referenced in check constraint", - RelationGetRelationName(rel)))); + errmsg("only table \"%s\" can be referenced in check constraint", + RelationGetRelationName(rel)))); /* * No subplans or aggregates, either... @@ -1559,7 +1554,7 @@ AddRelationRawConstraints(Relation rel, if (pstate->p_hasAggs) ereport(ERROR, (errcode(ERRCODE_GROUPING_ERROR), - errmsg("cannot use aggregate function in check constraint"))); + errmsg("cannot use aggregate function in check constraint"))); /* * Check name uniqueness, or generate a name if none was given. @@ -1576,8 +1571,8 @@ AddRelationRawConstraints(Relation rel, ccname)) ereport(ERROR, (errcode(ERRCODE_DUPLICATE_OBJECT), - errmsg("constraint \"%s\" for relation \"%s\" already exists", - ccname, RelationGetRelationName(rel)))); + errmsg("constraint \"%s\" for relation \"%s\" already exists", + ccname, RelationGetRelationName(rel)))); /* Check against other new constraints */ /* Needed because we don't do CommandCounterIncrement in loop */ foreach(cell2, checknames) @@ -1585,20 +1580,19 @@ AddRelationRawConstraints(Relation rel, if (strcmp((char *) lfirst(cell2), ccname) == 0) ereport(ERROR, (errcode(ERRCODE_DUPLICATE_OBJECT), - errmsg("check constraint \"%s\" already exists", - ccname))); + errmsg("check constraint \"%s\" already exists", + ccname))); } } else { /* - * When generating a name, we want to create "tab_col_check" - * for a column constraint and "tab_check" for a table - * constraint. We no longer have any info about the syntactic - * positioning of the constraint phrase, so we approximate - * this by seeing whether the expression references more than - * one column. (If the user played by the rules, the result - * is the same...) + * When generating a name, we want to create "tab_col_check" for a + * column constraint and "tab_check" for a table constraint. We + * no longer have any info about the syntactic positioning of the + * constraint phrase, so we approximate this by seeing whether the + * expression references more than one column. (If the user + * played by the rules, the result is the same...) * * Note: pull_var_clause() doesn't descend into sublinks, but we * eliminated those above; and anyway this only needs to be an @@ -1644,11 +1638,11 @@ AddRelationRawConstraints(Relation rel, } /* - * Update the count of constraints in the relation's pg_class tuple. - * We do this even if there was no change, in order to ensure that an - * SI update message is sent out for the pg_class tuple, which will - * force other backends to rebuild their relcache entries for the rel. - * (This is critical if we added defaults but not constraints.) + * Update the count of constraints in the relation's pg_class tuple. We do + * this even if there was no change, in order to ensure that an SI update + * message is sent out for the pg_class tuple, which will force other + * backends to rebuild their relcache entries for the rel. (This is + * critical if we added defaults but not constraints.) */ SetRelationNumChecks(rel, numchecks); @@ -1734,7 +1728,7 @@ cookDefault(ParseState *pstate, if (contain_var_clause(expr)) ereport(ERROR, (errcode(ERRCODE_INVALID_COLUMN_REFERENCE), - errmsg("cannot use column references in default expression"))); + errmsg("cannot use column references in default expression"))); /* * It can't return a set either. @@ -1754,12 +1748,12 @@ cookDefault(ParseState *pstate, if (pstate->p_hasAggs) ereport(ERROR, (errcode(ERRCODE_GROUPING_ERROR), - errmsg("cannot use aggregate function in default expression"))); + errmsg("cannot use aggregate function in default expression"))); /* - * Coerce the expression to the correct type and typmod, if given. - * This should match the parser's processing of non-defaulted - * expressions --- see updateTargetListEntry(). + * Coerce the expression to the correct type and typmod, if given. This + * should match the parser's processing of non-defaulted expressions --- + * see updateTargetListEntry(). */ if (OidIsValid(atttypid)) { @@ -1777,7 +1771,7 @@ cookDefault(ParseState *pstate, attname, format_type_be(atttypid), format_type_be(type_id)), - errhint("You will need to rewrite or cast the expression."))); + errhint("You will need to rewrite or cast the expression."))); } return expr; @@ -1930,9 +1924,9 @@ RelationTruncateIndexes(Oid heapId) index_build(heapRelation, currentIndex, indexInfo); /* - * index_build will close both the heap and index relations (but - * not give up the locks we hold on them). We're done with this - * index, but we must re-open the heap rel. + * index_build will close both the heap and index relations (but not + * give up the locks we hold on them). We're done with this index, + * but we must re-open the heap rel. */ heapRelation = heap_open(heapId, NoLock); } @@ -1947,7 +1941,7 @@ RelationTruncateIndexes(Oid heapId) * This routine deletes all data within all the specified relations. * * This is not transaction-safe! There is another, transaction-safe - * implementation in commands/tablecmds.c. We now use this only for + * implementation in commands/tablecmds.c. We now use this only for * ON COMMIT truncation of temporary tables, where it doesn't matter. */ void @@ -2039,8 +2033,8 @@ heap_truncate_check_FKs(List *relations, bool tempTables) return; /* - * Otherwise, must scan pg_constraint. Right now, it is a seqscan - * because there is no available index on confrelid. + * Otherwise, must scan pg_constraint. Right now, it is a seqscan because + * there is no available index on confrelid. */ fkeyRel = heap_open(ConstraintRelationId, AccessShareLock); @@ -2056,16 +2050,16 @@ heap_truncate_check_FKs(List *relations, bool tempTables) continue; /* Not for one of our list of tables */ - if (! list_member_oid(oids, con->confrelid)) + if (!list_member_oid(oids, con->confrelid)) continue; /* The referencer should be in our list too */ - if (! list_member_oid(oids, con->conrelid)) + if (!list_member_oid(oids, con->conrelid)) { if (tempTables) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("unsupported ON COMMIT and foreign key combination"), + errmsg("unsupported ON COMMIT and foreign key combination"), errdetail("Table \"%s\" references \"%s\" via foreign key constraint \"%s\", but they do not have the same ON COMMIT setting.", get_rel_name(con->conrelid), get_rel_name(con->confrelid), diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c index 3d543fa06c..a25f34b85e 100644 --- a/src/backend/catalog/index.c +++ b/src/backend/catalog/index.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.260 2005/08/26 03:07:12 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.261 2005/10/15 02:49:12 momjian Exp $ * * * INTERFACE ROUTINES @@ -91,9 +91,9 @@ ConstructTupleDescriptor(Relation heapRelation, indexTupDesc = CreateTemplateTupleDesc(numatts, false); /* - * For simple index columns, we copy the pg_attribute row from the - * parent relation and modify it as necessary. For expressions we - * have to cons up a pg_attribute row the hard way. + * For simple index columns, we copy the pg_attribute row from the parent + * relation and modify it as necessary. For expressions we have to cons + * up a pg_attribute row the hard way. */ for (i = 0; i < numatts; i++) { @@ -114,7 +114,7 @@ ConstructTupleDescriptor(Relation heapRelation, * here we are indexing on a system attribute (-1...-n) */ from = SystemAttributeDefinition(atnum, - heapRelation->rd_rel->relhasoids); + heapRelation->rd_rel->relhasoids); } else { @@ -127,8 +127,8 @@ ConstructTupleDescriptor(Relation heapRelation, } /* - * now that we've determined the "from", let's copy the tuple - * desc data... + * now that we've determined the "from", let's copy the tuple desc + * data... */ memcpy(to, from, ATTRIBUTE_TUPLE_SIZE); @@ -158,14 +158,13 @@ ConstructTupleDescriptor(Relation heapRelation, indexpr_item = lnext(indexpr_item); /* - * Make the attribute's name "pg_expresssion_nnn" (maybe think - * of something better later) + * Make the attribute's name "pg_expresssion_nnn" (maybe think of + * something better later) */ sprintf(NameStr(to->attname), "pg_expression_%d", i + 1); /* - * Lookup the expression type in pg_type for the type length - * etc. + * Lookup the expression type in pg_type for the type length etc. */ keyType = exprType(indexkey); tuple = SearchSysCache(TYPEOID, @@ -193,15 +192,15 @@ ConstructTupleDescriptor(Relation heapRelation, } /* - * We do not yet have the correct relation OID for the index, so - * just set it invalid for now. InitializeAttributeOids() will - * fix it later. + * We do not yet have the correct relation OID for the index, so just + * set it invalid for now. InitializeAttributeOids() will fix it + * later. */ to->attrelid = InvalidOid; /* - * Check the opclass to see if it provides a keytype (overriding - * the attribute type). + * Check the opclass to see if it provides a keytype (overriding the + * attribute type). */ tuple = SearchSysCache(CLAOID, ObjectIdGetDatum(classObjectId[i]), @@ -311,8 +310,8 @@ AppendAttributeTuples(Relation indexRelation, int numatts) for (i = 0; i < numatts; i++) { /* - * There used to be very grotty code here to set these fields, but - * I think it's unnecessary. They should be set already. + * There used to be very grotty code here to set these fields, but I + * think it's unnecessary. They should be set already. */ Assert(indexTupDesc->attrs[i]->attnum == i + 1); Assert(indexTupDesc->attrs[i]->attcacheoff == -1); @@ -380,8 +379,8 @@ UpdateIndexRelation(Oid indexoid, exprsDatum = (Datum) 0; /* - * Convert the index predicate (if any) to a text datum. Note we - * convert implicit-AND format to normal explicit-AND for storage. + * Convert the index predicate (if any) to a text datum. Note we convert + * implicit-AND format to normal explicit-AND for storage. */ if (indexInfo->ii_Predicate != NIL) { @@ -442,7 +441,7 @@ UpdateIndexRelation(Oid indexoid, * index_create * * indexRelationId is normally InvalidOid to let this routine - * generate an OID for the index. During bootstrap it may be + * generate an OID for the index. During bootstrap it may be * nonzero to specify a preselected OID. * * Returns OID of the created index. @@ -500,15 +499,14 @@ index_create(Oid heapRelationId, * We cannot allow indexing a shared relation after initdb (because * there's no way to make the entry in other databases' pg_class). * Unfortunately we can't distinguish initdb from a manually started - * standalone backend (toasting of shared rels happens after the - * bootstrap phase, so checking IsBootstrapProcessingMode() won't - * work). However, we can at least prevent this mistake under normal - * multi-user operation. + * standalone backend (toasting of shared rels happens after the bootstrap + * phase, so checking IsBootstrapProcessingMode() won't work). However, + * we can at least prevent this mistake under normal multi-user operation. */ if (shared_relation && IsUnderPostmaster) ereport(ERROR, (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), - errmsg("shared indexes cannot be created after initdb"))); + errmsg("shared indexes cannot be created after initdb"))); if (get_relname_relid(indexRelationName, namespaceId)) ereport(ERROR, @@ -526,17 +524,17 @@ index_create(Oid heapRelationId, /* * Allocate an OID for the index, unless we were told what to use. * - * The OID will be the relfilenode as well, so make sure it doesn't - * collide with either pg_class OIDs or existing physical files. + * The OID will be the relfilenode as well, so make sure it doesn't collide + * with either pg_class OIDs or existing physical files. */ if (!OidIsValid(indexRelationId)) indexRelationId = GetNewRelFileNode(tableSpaceId, shared_relation, pg_class); /* - * create the index relation's relcache entry and physical disk file. - * (If we fail further down, it's the smgr's responsibility to remove - * the disk file again.) + * create the index relation's relcache entry and physical disk file. (If + * we fail further down, it's the smgr's responsibility to remove the disk + * file again.) */ indexRelation = heap_create(indexRelationName, namespaceId, @@ -557,8 +555,8 @@ index_create(Oid heapRelationId, LockRelation(indexRelation, AccessExclusiveLock); /* - * Fill in fields of the index's pg_class entry that are not set - * correctly by heap_create. + * Fill in fields of the index's pg_class entry that are not set correctly + * by heap_create. * * XXX should have a cleaner way to create cataloged indexes */ @@ -602,16 +600,16 @@ index_create(Oid heapRelationId, /* * Register constraint and dependencies for the index. * - * If the index is from a CONSTRAINT clause, construct a pg_constraint - * entry. The index is then linked to the constraint, which in turn - * is linked to the table. If it's not a CONSTRAINT, make the - * dependency directly on the table. + * If the index is from a CONSTRAINT clause, construct a pg_constraint entry. + * The index is then linked to the constraint, which in turn is linked to + * the table. If it's not a CONSTRAINT, make the dependency directly on + * the table. * * We don't need a dependency on the namespace, because there'll be an * indirect dependency via our parent table. * - * During bootstrap we can't register any dependencies, and we don't try - * to make a constraint either. + * During bootstrap we can't register any dependencies, and we don't try to + * make a constraint either. */ if (!IsBootstrapProcessingMode()) { @@ -697,7 +695,7 @@ index_create(Oid heapRelationId, if (indexInfo->ii_Expressions) { recordDependencyOnSingleRelExpr(&myself, - (Node *) indexInfo->ii_Expressions, + (Node *) indexInfo->ii_Expressions, heapRelationId, DEPENDENCY_NORMAL, DEPENDENCY_AUTO); @@ -707,7 +705,7 @@ index_create(Oid heapRelationId, if (indexInfo->ii_Predicate) { recordDependencyOnSingleRelExpr(&myself, - (Node *) indexInfo->ii_Predicate, + (Node *) indexInfo->ii_Predicate, heapRelationId, DEPENDENCY_NORMAL, DEPENDENCY_AUTO); @@ -721,10 +719,10 @@ index_create(Oid heapRelationId, CommandCounterIncrement(); /* - * In bootstrap mode, we have to fill in the index strategy structure - * with information from the catalogs. If we aren't bootstrapping, - * then the relcache entry has already been rebuilt thanks to sinval - * update during CommandCounterIncrement. + * In bootstrap mode, we have to fill in the index strategy structure with + * information from the catalogs. If we aren't bootstrapping, then the + * relcache entry has already been rebuilt thanks to sinval update during + * CommandCounterIncrement. */ if (IsBootstrapProcessingMode()) RelationInitIndexAccessInfo(indexRelation); @@ -732,17 +730,16 @@ index_create(Oid heapRelationId, Assert(indexRelation->rd_indexcxt != NULL); /* - * If this is bootstrap (initdb) time, then we don't actually fill in - * the index yet. We'll be creating more indexes and classes later, - * so we delay filling them in until just before we're done with - * bootstrapping. Similarly, if the caller specified skip_build then - * filling the index is delayed till later (ALTER TABLE can save work - * in some cases with this). Otherwise, we call the AM routine that - * constructs the index. + * If this is bootstrap (initdb) time, then we don't actually fill in the + * index yet. We'll be creating more indexes and classes later, so we + * delay filling them in until just before we're done with bootstrapping. + * Similarly, if the caller specified skip_build then filling the index is + * delayed till later (ALTER TABLE can save work in some cases with this). + * Otherwise, we call the AM routine that constructs the index. * - * In normal processing mode, the heap and index relations are closed, - * but we continue to hold the ShareLock on the heap and the exclusive - * lock on the index that we acquired above, until end of transaction. + * In normal processing mode, the heap and index relations are closed, but we + * continue to hold the ShareLock on the heap and the exclusive lock on + * the index that we acquired above, until end of transaction. */ if (IsBootstrapProcessingMode()) { @@ -784,13 +781,12 @@ index_drop(Oid indexId) * To drop an index safely, we must grab exclusive lock on its parent * table; otherwise there could be other backends using the index! * Exclusive lock on the index alone is insufficient because another - * backend might be in the midst of devising a query plan that will - * use the index. The parser and planner take care to hold an - * appropriate lock on the parent table while working, but having them - * hold locks on all the indexes too seems overly expensive. We do grab - * exclusive lock on the index too, just to be safe. Both locks must - * be held till end of transaction, else other backends will still see - * this index in pg_index. + * backend might be in the midst of devising a query plan that will use + * the index. The parser and planner take care to hold an appropriate + * lock on the parent table while working, but having them hold locks on + * all the indexes too seems overly expensive. We do grab exclusive lock + * on the index too, just to be safe. Both locks must be held till end of + * transaction, else other backends will still see this index in pg_index. */ heapId = IndexGetRelation(indexId); userHeapRelation = heap_open(heapId, AccessExclusiveLock); @@ -806,9 +802,9 @@ index_drop(Oid indexId) userIndexRelation->rd_istemp); /* - * Close and flush the index's relcache entry, to ensure relcache - * doesn't try to rebuild it while we're deleting catalog entries. We - * keep the lock though. + * Close and flush the index's relcache entry, to ensure relcache doesn't + * try to rebuild it while we're deleting catalog entries. We keep the + * lock though. */ index_close(userIndexRelation); @@ -833,8 +829,8 @@ index_drop(Oid indexId) heap_close(indexRelation, RowExclusiveLock); /* - * if it has any expression columns, we might have stored statistics - * about them. + * if it has any expression columns, we might have stored statistics about + * them. */ if (hasexprs) RemoveStatistics(indexId, 0); @@ -850,12 +846,11 @@ index_drop(Oid indexId) DeleteRelationTuple(indexId); /* - * We are presently too lazy to attempt to compute the new correct - * value of relhasindex (the next VACUUM will fix it if necessary). So - * there is no need to update the pg_class tuple for the owning - * relation. But we must send out a shared-cache-inval notice on the - * owning relation to ensure other backends update their relcache - * lists of indexes. + * We are presently too lazy to attempt to compute the new correct value + * of relhasindex (the next VACUUM will fix it if necessary). So there is + * no need to update the pg_class tuple for the owning relation. But we + * must send out a shared-cache-inval notice on the owning relation to + * ensure other backends update their relcache lists of indexes. */ CacheInvalidateRelcache(userHeapRelation); @@ -926,7 +921,7 @@ BuildIndexInfo(Relation index) * context must point to the heap tuple passed in. * * Notice we don't actually call index_form_tuple() here; we just prepare - * its input arrays values[] and isnull[]. This is because the index AM + * its input arrays values[] and isnull[]. This is because the index AM * may wish to alter the data before storage. * ---------------- */ @@ -974,7 +969,7 @@ FormIndexDatum(IndexInfo *indexInfo, if (indexpr_item == NULL) elog(ERROR, "wrong number of index expressions"); iDatum = ExecEvalExprSwitchContext((ExprState *) lfirst(indexpr_item), - GetPerTupleExprContext(estate), + GetPerTupleExprContext(estate), &isNull, NULL); indexpr_item = lnext(indexpr_item); @@ -1013,9 +1008,9 @@ setRelhasindex(Oid relid, bool hasindex, bool isprimary, Oid reltoastidxid) HeapScanDesc pg_class_scan = NULL; /* - * Find the tuple to update in pg_class. In bootstrap mode we can't - * use heap_update, so cheat and overwrite the tuple in-place. In - * normal processing, make a copy to scribble on. + * Find the tuple to update in pg_class. In bootstrap mode we can't use + * heap_update, so cheat and overwrite the tuple in-place. In normal + * processing, make a copy to scribble on. */ pg_class = heap_open(RelationRelationId, RowExclusiveLock); @@ -1135,7 +1130,7 @@ setNewRelfilenode(Relation relation) pg_class = heap_open(RelationRelationId, RowExclusiveLock); tuple = SearchSysCacheCopy(RELOID, - ObjectIdGetDatum(RelationGetRelid(relation)), + ObjectIdGetDatum(RelationGetRelid(relation)), 0, 0, 0); if (!HeapTupleIsValid(tuple)) elog(ERROR, "could not find tuple for relation %u", @@ -1178,7 +1173,7 @@ setNewRelfilenode(Relation relation) * advantage of the opportunity to update pg_class to ensure that the * planner takes advantage of the index we just created. But, only * update statistics during normal index definitions, not for indices - * on system catalogs created during bootstrap processing. We must + * on system catalogs created during bootstrap processing. We must * close the relations before updating statistics to guarantee that * the relcache entries are flushed when we increment the command * counter in UpdateStats(). But we do not release any locks on the @@ -1188,8 +1183,8 @@ void IndexCloseAndUpdateStats(Relation heap, double heapTuples, Relation index, double indexTuples) { - Oid hrelid = RelationGetRelid(heap); - Oid irelid = RelationGetRelid(index); + Oid hrelid = RelationGetRelid(heap); + Oid irelid = RelationGetRelid(index); if (!IsNormalProcessingMode()) return; @@ -1222,9 +1217,9 @@ UpdateStats(Oid relid, double reltuples) /* * This routine handles updates for both the heap and index relation - * statistics. In order to guarantee that we're able to *see* the - * index relation tuple, we bump the command counter id here. The - * index relation tuple was created in the current transaction. + * statistics. In order to guarantee that we're able to *see* the index + * relation tuple, we bump the command counter id here. The index + * relation tuple was created in the current transaction. */ CommandCounterIncrement(); @@ -1232,8 +1227,8 @@ UpdateStats(Oid relid, double reltuples) * CommandCounterIncrement() flushes invalid cache entries, including * those for the heap and index relations for which we're updating * statistics. Now that the cache is flushed, it's safe to open the - * relation again. We need the relation open in order to figure out - * how many blocks it contains. + * relation again. We need the relation open in order to figure out how + * many blocks it contains. */ /* @@ -1242,17 +1237,17 @@ UpdateStats(Oid relid, double reltuples) whichRel = relation_open(relid, ShareLock); /* - * Find the tuple to update in pg_class. Normally we make a copy of - * the tuple using the syscache, modify it, and apply heap_update. But - * in bootstrap mode we can't use heap_update, so we cheat and - * overwrite the tuple in-place. (Note: as of PG 8.0 this isn't called - * during bootstrap, but leave the code here for possible future use.) + * Find the tuple to update in pg_class. Normally we make a copy of the + * tuple using the syscache, modify it, and apply heap_update. But in + * bootstrap mode we can't use heap_update, so we cheat and overwrite the + * tuple in-place. (Note: as of PG 8.0 this isn't called during + * bootstrap, but leave the code here for possible future use.) * - * We also must cheat if reindexing pg_class itself, because the target - * index may presently not be part of the set of indexes that - * CatalogUpdateIndexes would update (see reindex_relation). In this - * case the stats updates will not be WAL-logged and so could be lost - * in a crash. This seems OK considering VACUUM does the same thing. + * We also must cheat if reindexing pg_class itself, because the target index + * may presently not be part of the set of indexes that + * CatalogUpdateIndexes would update (see reindex_relation). In this case + * the stats updates will not be WAL-logged and so could be lost in a + * crash. This seems OK considering VACUUM does the same thing. */ pg_class = heap_open(RelationRelationId, RowExclusiveLock); @@ -1284,9 +1279,9 @@ UpdateStats(Oid relid, double reltuples) /* * Update statistics in pg_class, if they changed. (Avoiding an - * unnecessary update is not just a tiny performance improvement; it - * also reduces the window wherein concurrent CREATE INDEX commands - * may conflict.) + * unnecessary update is not just a tiny performance improvement; it also + * reduces the window wherein concurrent CREATE INDEX commands may + * conflict.) */ relpages = RelationGetNumberOfBlocks(whichRel); @@ -1320,10 +1315,10 @@ UpdateStats(Oid relid, double reltuples) heap_freetuple(tuple); /* - * We shouldn't have to do this, but we do... Modify the reldesc in - * place with the new values so that the cache contains the latest - * copy. (XXX is this really still necessary? The relcache will get - * fixed at next CommandCounterIncrement, so why bother here?) + * We shouldn't have to do this, but we do... Modify the reldesc in place + * with the new values so that the cache contains the latest copy. (XXX + * is this really still necessary? The relcache will get fixed at next + * CommandCounterIncrement, so why bother here?) */ whichRel->rd_rel->relpages = (int32) relpages; whichRel->rd_rel->reltuples = (float4) reltuples; @@ -1405,8 +1400,8 @@ IndexBuildHeapScan(Relation heapRelation, Assert(OidIsValid(indexRelation->rd_rel->relam)); /* - * Need an EState for evaluation of index expressions and - * partial-index predicates. Also a slot to hold the current tuple. + * Need an EState for evaluation of index expressions and partial-index + * predicates. Also a slot to hold the current tuple. */ estate = CreateExecutorState(); econtext = GetPerTupleExprContext(estate); @@ -1421,9 +1416,8 @@ IndexBuildHeapScan(Relation heapRelation, estate); /* - * Ok, begin our scan of the base relation. We use SnapshotAny - * because we must retrieve all tuples and do our own time qual - * checks. + * Ok, begin our scan of the base relation. We use SnapshotAny because we + * must retrieve all tuples and do our own time qual checks. */ if (IsBootstrapProcessingMode()) { @@ -1487,16 +1481,16 @@ IndexBuildHeapScan(Relation heapRelation, case HEAPTUPLE_INSERT_IN_PROGRESS: /* - * Since caller should hold ShareLock or better, we - * should not see any tuples inserted by open - * transactions --- unless it's our own transaction. - * (Consider INSERT followed by CREATE INDEX within a - * transaction.) An exception occurs when reindexing - * a system catalog, because we often release lock on - * system catalogs before committing. + * Since caller should hold ShareLock or better, we should + * not see any tuples inserted by open transactions --- + * unless it's our own transaction. (Consider INSERT + * followed by CREATE INDEX within a transaction.) An + * exception occurs when reindexing a system catalog, + * because we often release lock on system catalogs before + * committing. */ if (!TransactionIdIsCurrentTransactionId( - HeapTupleHeaderGetXmin(heapTuple->t_data)) + HeapTupleHeaderGetXmin(heapTuple->t_data)) && !IsSystemRelation(heapRelation)) elog(ERROR, "concurrent insert in progress"); indexIt = true; @@ -1505,17 +1499,17 @@ IndexBuildHeapScan(Relation heapRelation, case HEAPTUPLE_DELETE_IN_PROGRESS: /* - * Since caller should hold ShareLock or better, we - * should not see any tuples deleted by open - * transactions --- unless it's our own transaction. - * (Consider DELETE followed by CREATE INDEX within a - * transaction.) An exception occurs when reindexing - * a system catalog, because we often release lock on - * system catalogs before committing. + * Since caller should hold ShareLock or better, we should + * not see any tuples deleted by open transactions --- + * unless it's our own transaction. (Consider DELETE + * followed by CREATE INDEX within a transaction.) An + * exception occurs when reindexing a system catalog, + * because we often release lock on system catalogs before + * committing. */ Assert(!(heapTuple->t_data->t_infomask & HEAP_XMAX_IS_MULTI)); if (!TransactionIdIsCurrentTransactionId( - HeapTupleHeaderGetXmax(heapTuple->t_data)) + HeapTupleHeaderGetXmax(heapTuple->t_data)) && !IsSystemRelation(heapRelation)) elog(ERROR, "concurrent delete in progress"); indexIt = true; @@ -1547,9 +1541,8 @@ IndexBuildHeapScan(Relation heapRelation, /* * In a partial index, discard tuples that don't satisfy the - * predicate. We can also discard recently-dead tuples, since - * VACUUM doesn't complain about tuple count mismatch for partial - * indexes. + * predicate. We can also discard recently-dead tuples, since VACUUM + * doesn't complain about tuple count mismatch for partial indexes. */ if (predicate != NIL) { @@ -1560,9 +1553,9 @@ IndexBuildHeapScan(Relation heapRelation, } /* - * For the current heap tuple, extract all the attributes we use - * in this index, and note which are null. This also performs - * evaluation of any expressions needed. + * For the current heap tuple, extract all the attributes we use in + * this index, and note which are null. This also performs evaluation + * of any expressions needed. */ FormIndexDatum(indexInfo, slot, @@ -1571,9 +1564,9 @@ IndexBuildHeapScan(Relation heapRelation, isnull); /* - * You'd think we should go ahead and build the index tuple here, - * but some index AMs want to do further processing on the data - * first. So pass the values[] and isnull[] arrays, instead. + * You'd think we should go ahead and build the index tuple here, but + * some index AMs want to do further processing on the data first. So + * pass the values[] and isnull[] arrays, instead. */ /* Call the AM's callback routine to process the tuple */ @@ -1631,27 +1624,27 @@ reindex_index(Oid indexId) bool inplace; /* - * Open and lock the parent heap relation. ShareLock is sufficient - * since we only need to be sure no schema or data changes are going on. + * Open and lock the parent heap relation. ShareLock is sufficient since + * we only need to be sure no schema or data changes are going on. */ heapId = IndexGetRelation(indexId); heapRelation = heap_open(heapId, ShareLock); /* - * Open the target index relation and get an exclusive lock on it, - * to ensure that no one else is touching this particular index. + * Open the target index relation and get an exclusive lock on it, to + * ensure that no one else is touching this particular index. */ iRel = index_open(indexId); LockRelation(iRel, AccessExclusiveLock); /* - * If it's a shared index, we must do inplace processing (because we - * have no way to update relfilenode in other databases). Otherwise - * we can do it the normal transaction-safe way. + * If it's a shared index, we must do inplace processing (because we have + * no way to update relfilenode in other databases). Otherwise we can do + * it the normal transaction-safe way. * * Since inplace processing isn't crash-safe, we only allow it in a - * standalone backend. (In the REINDEX TABLE and REINDEX DATABASE - * cases, the caller should have detected this.) + * standalone backend. (In the REINDEX TABLE and REINDEX DATABASE cases, + * the caller should have detected this.) */ inplace = iRel->rd_rel->relisshared; @@ -1688,8 +1681,8 @@ reindex_index(Oid indexId) index_build(heapRelation, iRel, indexInfo); /* - * index_build will close both the heap and index relations (but - * not give up the locks we hold on them). So we're done. + * index_build will close both the heap and index relations (but not + * give up the locks we hold on them). So we're done. */ } PG_CATCH(); @@ -1721,8 +1714,8 @@ reindex_relation(Oid relid, bool toast_too) ListCell *indexId; /* - * Open and lock the relation. ShareLock is sufficient since we only - * need to prevent schema and data changes in it. + * Open and lock the relation. ShareLock is sufficient since we only need + * to prevent schema and data changes in it. */ rel = heap_open(relid, ShareLock); @@ -1736,26 +1729,25 @@ reindex_relation(Oid relid, bool toast_too) indexIds = RelationGetIndexList(rel); /* - * reindex_index will attempt to update the pg_class rows for the - * relation and index. If we are processing pg_class itself, we want - * to make sure that the updates do not try to insert index entries - * into indexes we have not processed yet. (When we are trying to - * recover from corrupted indexes, that could easily cause a crash.) - * We can accomplish this because CatalogUpdateIndexes will use the - * relcache's index list to know which indexes to update. We just - * force the index list to be only the stuff we've processed. + * reindex_index will attempt to update the pg_class rows for the relation + * and index. If we are processing pg_class itself, we want to make sure + * that the updates do not try to insert index entries into indexes we + * have not processed yet. (When we are trying to recover from corrupted + * indexes, that could easily cause a crash.) We can accomplish this + * because CatalogUpdateIndexes will use the relcache's index list to know + * which indexes to update. We just force the index list to be only the + * stuff we've processed. * - * It is okay to not insert entries into the indexes we have not - * processed yet because all of this is transaction-safe. If we fail - * partway through, the updated rows are dead and it doesn't matter - * whether they have index entries. Also, a new pg_class index will - * be created with an entry for its own pg_class row because we do - * setNewRelfilenode() before we do index_build(). + * It is okay to not insert entries into the indexes we have not processed + * yet because all of this is transaction-safe. If we fail partway + * through, the updated rows are dead and it doesn't matter whether they + * have index entries. Also, a new pg_class index will be created with an + * entry for its own pg_class row because we do setNewRelfilenode() before + * we do index_build(). * - * Note that we also clear pg_class's rd_oidindex until the loop is done, - * so that that index can't be accessed either. This means we cannot - * safely generate new relation OIDs while in the loop; shouldn't be a - * problem. + * Note that we also clear pg_class's rd_oidindex until the loop is done, so + * that that index can't be accessed either. This means we cannot safely + * generate new relation OIDs while in the loop; shouldn't be a problem. */ is_pg_class = (RelationGetRelid(rel) == RelationRelationId); doneIndexes = NIL; @@ -1787,8 +1779,8 @@ reindex_relation(Oid relid, bool toast_too) result = (indexIds != NIL); /* - * If the relation has a secondary toast rel, reindex that too while - * we still hold the lock on the master table. + * If the relation has a secondary toast rel, reindex that too while we + * still hold the lock on the master table. */ if (toast_too && OidIsValid(toast_relid)) result |= reindex_relation(toast_relid, false); diff --git a/src/backend/catalog/indexing.c b/src/backend/catalog/indexing.c index 905d99d946..ad193dd7ff 100644 --- a/src/backend/catalog/indexing.c +++ b/src/backend/catalog/indexing.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/catalog/indexing.c,v 1.109 2005/03/21 01:24:01 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/catalog/indexing.c,v 1.110 2005/10/15 02:49:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -109,8 +109,8 @@ CatalogIndexInsert(CatalogIndexState indstate, HeapTuple heapTuple) Assert(indexInfo->ii_Predicate == NIL); /* - * FormIndexDatum fills in its values and isnull parameters with - * the appropriate values for the column(s) of the index. + * FormIndexDatum fills in its values and isnull parameters with the + * appropriate values for the column(s) of the index. */ FormIndexDatum(indexInfo, slot, @@ -122,8 +122,8 @@ CatalogIndexInsert(CatalogIndexState indstate, HeapTuple heapTuple) * The index AM does the rest. */ index_insert(relationDescs[i], /* index relation */ - values, /* array of index Datums */ - isnull, /* is-null flags */ + values, /* array of index Datums */ + isnull, /* is-null flags */ &(heapTuple->t_self), /* tid of heap tuple */ heapRelation, relationDescs[i]->rd_index->indisunique); diff --git a/src/backend/catalog/namespace.c b/src/backend/catalog/namespace.c index dc627e4288..0cafa9f9fa 100644 --- a/src/backend/catalog/namespace.c +++ b/src/backend/catalog/namespace.c @@ -13,7 +13,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/catalog/namespace.c,v 1.78 2005/10/06 22:43:16 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/catalog/namespace.c,v 1.79 2005/10/15 02:49:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -108,7 +108,7 @@ static bool namespaceSearchPathValid = true; * command is first executed). Thereafter it's the OID of the temp namespace. * * myTempNamespaceSubID shows whether we've created the TEMP namespace in the - * current subtransaction. The flag propagates up the subtransaction tree, + * current subtransaction. The flag propagates up the subtransaction tree, * so the main transaction will correctly recognize the flag if all * intermediate subtransactions commit. When it is InvalidSubTransactionId, * we either haven't made the TEMP namespace yet, or have successfully @@ -225,7 +225,7 @@ RangeVarGetCreationNamespace(const RangeVar *newRelation) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("cross-database references are not implemented: \"%s.%s.%s\"", - newRelation->catalogname, newRelation->schemaname, + newRelation->catalogname, newRelation->schemaname, newRelation->relname))); } @@ -235,7 +235,7 @@ RangeVarGetCreationNamespace(const RangeVar *newRelation) if (newRelation->schemaname) ereport(ERROR, (errcode(ERRCODE_INVALID_TABLE_DEFINITION), - errmsg("temporary tables may not specify a schema name"))); + errmsg("temporary tables may not specify a schema name"))); /* Initialize temp namespace if first time through */ if (!OidIsValid(myTempNamespace)) InitTempTableNamespace(); @@ -246,7 +246,7 @@ RangeVarGetCreationNamespace(const RangeVar *newRelation) { /* use exact schema given */ namespaceId = GetSysCacheOid(NAMESPACENAME, - CStringGetDatum(newRelation->schemaname), + CStringGetDatum(newRelation->schemaname), 0, 0, 0); if (!OidIsValid(namespaceId)) ereport(ERROR, @@ -322,9 +322,9 @@ RelationIsVisible(Oid relid) recomputeNamespacePath(); /* - * Quick check: if it ain't in the path at all, it ain't visible. - * Items in the system namespace are surely in the path and so we - * needn't even do list_member_oid() for them. + * Quick check: if it ain't in the path at all, it ain't visible. Items in + * the system namespace are surely in the path and so we needn't even do + * list_member_oid() for them. */ relnamespace = relform->relnamespace; if (relnamespace != PG_CATALOG_NAMESPACE && @@ -333,9 +333,9 @@ RelationIsVisible(Oid relid) else { /* - * If it is in the path, it might still not be visible; it could - * be hidden by another relation of the same name earlier in the - * path. So we must do a slow check for conflicting relations. + * If it is in the path, it might still not be visible; it could be + * hidden by another relation of the same name earlier in the path. So + * we must do a slow check for conflicting relations. */ char *relname = NameStr(relform->relname); ListCell *l; @@ -420,9 +420,9 @@ TypeIsVisible(Oid typid) recomputeNamespacePath(); /* - * Quick check: if it ain't in the path at all, it ain't visible. - * Items in the system namespace are surely in the path and so we - * needn't even do list_member_oid() for them. + * Quick check: if it ain't in the path at all, it ain't visible. Items in + * the system namespace are surely in the path and so we needn't even do + * list_member_oid() for them. */ typnamespace = typform->typnamespace; if (typnamespace != PG_CATALOG_NAMESPACE && @@ -431,9 +431,9 @@ TypeIsVisible(Oid typid) else { /* - * If it is in the path, it might still not be visible; it could - * be hidden by another type of the same name earlier in the path. - * So we must do a slow check for conflicting types. + * If it is in the path, it might still not be visible; it could be + * hidden by another type of the same name earlier in the path. So we + * must do a slow check for conflicting types. */ char *typname = NameStr(typform->typname); ListCell *l; @@ -545,14 +545,14 @@ FuncnameGetCandidates(List *names, int nargs) /* * Okay, it's in the search path, but does it have the same - * arguments as something we already accepted? If so, keep - * only the one that appears earlier in the search path. + * arguments as something we already accepted? If so, keep only + * the one that appears earlier in the search path. * * If we have an ordered list from SearchSysCacheList (the normal - * case), then any conflicting proc must immediately adjoin - * this one in the list, so we only need to look at the newest - * result item. If we have an unordered list, we have to scan - * the whole result list. + * case), then any conflicting proc must immediately adjoin this + * one in the list, so we only need to look at the newest result + * item. If we have an unordered list, we have to scan the whole + * result list. */ if (resultList) { @@ -575,9 +575,9 @@ FuncnameGetCandidates(List *names, int nargs) prevResult = prevResult->next) { if (pronargs == prevResult->nargs && - memcmp(procform->proargtypes.values, - prevResult->args, - pronargs * sizeof(Oid)) == 0) + memcmp(procform->proargtypes.values, + prevResult->args, + pronargs * sizeof(Oid)) == 0) break; } } @@ -640,9 +640,9 @@ FunctionIsVisible(Oid funcid) recomputeNamespacePath(); /* - * Quick check: if it ain't in the path at all, it ain't visible. - * Items in the system namespace are surely in the path and so we - * needn't even do list_member_oid() for them. + * Quick check: if it ain't in the path at all, it ain't visible. Items in + * the system namespace are surely in the path and so we needn't even do + * list_member_oid() for them. */ pronamespace = procform->pronamespace; if (pronamespace != PG_CATALOG_NAMESPACE && @@ -651,10 +651,10 @@ FunctionIsVisible(Oid funcid) else { /* - * If it is in the path, it might still not be visible; it could - * be hidden by another proc of the same name and arguments - * earlier in the path. So we must do a slow check to see if this - * is the same proc that would be found by FuncnameGetCandidates. + * If it is in the path, it might still not be visible; it could be + * hidden by another proc of the same name and arguments earlier in + * the path. So we must do a slow check to see if this is the same + * proc that would be found by FuncnameGetCandidates. */ char *proname = NameStr(procform->proname); int nargs = procform->pronargs; @@ -733,13 +733,12 @@ OpernameGetCandidates(List *names, char oprkind) /* * In typical scenarios, most if not all of the operators found by the - * catcache search will end up getting returned; and there can be - * quite a few, for common operator names such as '=' or '+'. To - * reduce the time spent in palloc, we allocate the result space as an - * array large enough to hold all the operators. The original coding - * of this routine did a separate palloc for each operator, but - * profiling revealed that the pallocs used an unreasonably large - * fraction of parsing time. + * catcache search will end up getting returned; and there can be quite a + * few, for common operator names such as '=' or '+'. To reduce the time + * spent in palloc, we allocate the result space as an array large enough + * to hold all the operators. The original coding of this routine did a + * separate palloc for each operator, but profiling revealed that the + * pallocs used an unreasonably large fraction of parsing time. */ #define SPACE_PER_OP MAXALIGN(sizeof(struct _FuncCandidateList) + sizeof(Oid)) @@ -780,14 +779,14 @@ OpernameGetCandidates(List *names, char oprkind) /* * Okay, it's in the search path, but does it have the same - * arguments as something we already accepted? If so, keep - * only the one that appears earlier in the search path. + * arguments as something we already accepted? If so, keep only + * the one that appears earlier in the search path. * * If we have an ordered list from SearchSysCacheList (the normal - * case), then any conflicting oper must immediately adjoin - * this one in the list, so we only need to look at the newest - * result item. If we have an unordered list, we have to scan - * the whole result list. + * case), then any conflicting oper must immediately adjoin this + * one in the list, so we only need to look at the newest result + * item. If we have an unordered list, we have to scan the whole + * result list. */ if (resultList) { @@ -870,9 +869,9 @@ OperatorIsVisible(Oid oprid) recomputeNamespacePath(); /* - * Quick check: if it ain't in the path at all, it ain't visible. - * Items in the system namespace are surely in the path and so we - * needn't even do list_member_oid() for them. + * Quick check: if it ain't in the path at all, it ain't visible. Items in + * the system namespace are surely in the path and so we needn't even do + * list_member_oid() for them. */ oprnamespace = oprform->oprnamespace; if (oprnamespace != PG_CATALOG_NAMESPACE && @@ -881,11 +880,10 @@ OperatorIsVisible(Oid oprid) else { /* - * If it is in the path, it might still not be visible; it could - * be hidden by another operator of the same name and arguments - * earlier in the path. So we must do a slow check to see if this - * is the same operator that would be found by - * OpernameGetCandidates. + * If it is in the path, it might still not be visible; it could be + * hidden by another operator of the same name and arguments earlier + * in the path. So we must do a slow check to see if this is the same + * operator that would be found by OpernameGetCandidates. */ char *oprname = NameStr(oprform->oprname); FuncCandidateList clist; @@ -956,15 +954,14 @@ OpclassGetCandidates(Oid amid) continue; /* opclass is not in search path */ /* - * Okay, it's in the search path, but does it have the same name - * as something we already accepted? If so, keep only the one - * that appears earlier in the search path. + * Okay, it's in the search path, but does it have the same name as + * something we already accepted? If so, keep only the one that + * appears earlier in the search path. * - * If we have an ordered list from SearchSysCacheList (the normal - * case), then any conflicting opclass must immediately adjoin - * this one in the list, so we only need to look at the newest - * result item. If we have an unordered list, we have to scan the - * whole result list. + * If we have an ordered list from SearchSysCacheList (the normal case), + * then any conflicting opclass must immediately adjoin this one in + * the list, so we only need to look at the newest result item. If we + * have an unordered list, we have to scan the whole result list. */ if (resultList) { @@ -1083,9 +1080,9 @@ OpclassIsVisible(Oid opcid) recomputeNamespacePath(); /* - * Quick check: if it ain't in the path at all, it ain't visible. - * Items in the system namespace are surely in the path and so we - * needn't even do list_member_oid() for them. + * Quick check: if it ain't in the path at all, it ain't visible. Items in + * the system namespace are surely in the path and so we needn't even do + * list_member_oid() for them. */ opcnamespace = opcform->opcnamespace; if (opcnamespace != PG_CATALOG_NAMESPACE && @@ -1094,10 +1091,10 @@ OpclassIsVisible(Oid opcid) else { /* - * If it is in the path, it might still not be visible; it could - * be hidden by another opclass of the same name earlier in the - * path. So we must do a slow check to see if this opclass would - * be found by OpclassnameGetOpcid. + * If it is in the path, it might still not be visible; it could be + * hidden by another opclass of the same name earlier in the path. So + * we must do a slow check to see if this opclass would be found by + * OpclassnameGetOpcid. */ char *opcname = NameStr(opcform->opcname); @@ -1164,9 +1161,9 @@ ConversionIsVisible(Oid conid) recomputeNamespacePath(); /* - * Quick check: if it ain't in the path at all, it ain't visible. - * Items in the system namespace are surely in the path and so we - * needn't even do list_member_oid() for them. + * Quick check: if it ain't in the path at all, it ain't visible. Items in + * the system namespace are surely in the path and so we needn't even do + * list_member_oid() for them. */ connamespace = conform->connamespace; if (connamespace != PG_CATALOG_NAMESPACE && @@ -1175,10 +1172,10 @@ ConversionIsVisible(Oid conid) else { /* - * If it is in the path, it might still not be visible; it could - * be hidden by another conversion of the same name earlier in the - * path. So we must do a slow check to see if this conversion - * would be found by ConversionGetConid. + * If it is in the path, it might still not be visible; it could be + * hidden by another conversion of the same name earlier in the path. + * So we must do a slow check to see if this conversion would be found + * by ConversionGetConid. */ char *conname = NameStr(conform->conname); @@ -1226,14 +1223,14 @@ DeconstructQualifiedName(List *names, if (strcmp(catalogname, get_database_name(MyDatabaseId)) != 0) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cross-database references are not implemented: %s", - NameListToString(names)))); + errmsg("cross-database references are not implemented: %s", + NameListToString(names)))); break; default: ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("improper qualified name (too many dotted names): %s", - NameListToString(names)))); + errmsg("improper qualified name (too many dotted names): %s", + NameListToString(names)))); break; } @@ -1373,8 +1370,8 @@ makeRangeVarFromNameList(List *names) default: ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("improper relation name (too many dotted names): %s", - NameListToString(names)))); + errmsg("improper relation name (too many dotted names): %s", + NameListToString(names)))); break; } @@ -1574,7 +1571,7 @@ FindDefaultConversionProc(int4 for_encoding, int4 to_encoding) static void recomputeNamespacePath(void) { - Oid roleid = GetUserId(); + Oid roleid = GetUserId(); char *rawname; List *namelist; List *oidlist; @@ -1602,9 +1599,9 @@ recomputeNamespacePath(void) /* * Convert the list of names to a list of OIDs. If any names are not - * recognizable or we don't have read access, just leave them out of - * the list. (We can't raise an error, since the search_path setting - * has already been accepted.) Don't make duplicate entries, either. + * recognizable or we don't have read access, just leave them out of the + * list. (We can't raise an error, since the search_path setting has + * already been accepted.) Don't make duplicate entries, either. */ oidlist = NIL; foreach(l, namelist) @@ -1659,8 +1656,8 @@ recomputeNamespacePath(void) firstNS = linitial_oid(oidlist); /* - * Add any implicitly-searched namespaces to the list. Note these go - * on the front, not the back; also notice that we do not check USAGE + * Add any implicitly-searched namespaces to the list. Note these go on + * the front, not the back; also notice that we do not check USAGE * permissions for these. */ if (!list_member_oid(oidlist, PG_CATALOG_NAMESPACE)) @@ -1675,8 +1672,8 @@ recomputeNamespacePath(void) oidlist = lcons_oid(mySpecialNamespace, oidlist); /* - * Now that we've successfully built the new list of namespace OIDs, - * save it in permanent storage. + * Now that we've successfully built the new list of namespace OIDs, save + * it in permanent storage. */ oldcxt = MemoryContextSwitchTo(TopMemoryContext); newpath = list_copy(oidlist); @@ -1717,14 +1714,13 @@ InitTempTableNamespace(void) /* * First, do permission check to see if we are authorized to make temp - * tables. We use a nonstandard error message here since - * "databasename: permission denied" might be a tad cryptic. + * tables. We use a nonstandard error message here since "databasename: + * permission denied" might be a tad cryptic. * - * Note that ACL_CREATE_TEMP rights are rechecked in - * pg_namespace_aclmask; that's necessary since current user ID could - * change during the session. But there's no need to make the - * namespace in the first place until a temp table creation request is - * made by someone with appropriate rights. + * Note that ACL_CREATE_TEMP rights are rechecked in pg_namespace_aclmask; + * that's necessary since current user ID could change during the session. + * But there's no need to make the namespace in the first place until a + * temp table creation request is made by someone with appropriate rights. */ if (pg_database_aclcheck(MyDatabaseId, GetUserId(), ACL_CREATE_TEMP) != ACLCHECK_OK) @@ -1741,13 +1737,12 @@ InitTempTableNamespace(void) if (!OidIsValid(namespaceId)) { /* - * First use of this temp namespace in this database; create it. - * The temp namespaces are always owned by the superuser. We - * leave their permissions at default --- i.e., no access except - * to superuser --- to ensure that unprivileged users can't peek - * at other backends' temp tables. This works because the places - * that access the temp namespace for my own backend skip - * permissions checks on it. + * First use of this temp namespace in this database; create it. The + * temp namespaces are always owned by the superuser. We leave their + * permissions at default --- i.e., no access except to superuser --- + * to ensure that unprivileged users can't peek at other backends' + * temp tables. This works because the places that access the temp + * namespace for my own backend skip permissions checks on it. */ namespaceId = NamespaceCreate(namespaceName, BOOTSTRAP_SUPERUSERID); /* Advance command counter to make namespace visible */ @@ -1756,16 +1751,16 @@ InitTempTableNamespace(void) else { /* - * If the namespace already exists, clean it out (in case the - * former owner crashed without doing so). + * If the namespace already exists, clean it out (in case the former + * owner crashed without doing so). */ RemoveTempRelations(namespaceId); } /* - * Okay, we've prepared the temp namespace ... but it's not committed - * yet, so all our work could be undone by transaction rollback. Set - * flag for AtEOXact_Namespace to know what to do. + * Okay, we've prepared the temp namespace ... but it's not committed yet, + * so all our work could be undone by transaction rollback. Set flag for + * AtEOXact_Namespace to know what to do. */ myTempNamespace = namespaceId; @@ -1784,11 +1779,11 @@ AtEOXact_Namespace(bool isCommit) { /* * If we abort the transaction in which a temp namespace was selected, - * we'll have to do any creation or cleanout work over again. So, - * just forget the namespace entirely until next time. On the other - * hand, if we commit then register an exit callback to clean out the - * temp tables at backend shutdown. (We only want to register the - * callback once per session, so this is a good place to do it.) + * we'll have to do any creation or cleanout work over again. So, just + * forget the namespace entirely until next time. On the other hand, if + * we commit then register an exit callback to clean out the temp tables + * at backend shutdown. (We only want to register the callback once per + * session, so this is a good place to do it.) */ if (myTempNamespaceSubID != InvalidSubTransactionId) { @@ -1852,9 +1847,9 @@ RemoveTempRelations(Oid tempNamespaceId) ObjectAddress object; /* - * We want to get rid of everything in the target namespace, but not - * the namespace itself (deleting it only to recreate it later would - * be a waste of cycles). We do this by finding everything that has a + * We want to get rid of everything in the target namespace, but not the + * namespace itself (deleting it only to recreate it later would be a + * waste of cycles). We do this by finding everything that has a * dependency on the namespace. */ object.classId = NamespaceRelationId; @@ -1916,15 +1911,13 @@ assign_search_path(const char *newval, bool doit, GucSource source) /* * Verify that all the names are either valid namespace names or * "$user". We do not require $user to correspond to a valid - * namespace. We do not check for USAGE rights, either; should - * we? + * namespace. We do not check for USAGE rights, either; should we? * - * When source == PGC_S_TEST, we are checking the argument of an - * ALTER DATABASE SET or ALTER USER SET command. It could be that - * the intended use of the search path is for some other database, - * so we should not error out if it mentions schemas not present - * in the current database. We reduce the message to NOTICE - * instead. + * When source == PGC_S_TEST, we are checking the argument of an ALTER + * DATABASE SET or ALTER USER SET command. It could be that the + * intended use of the search path is for some other database, so we + * should not error out if it mentions schemas not present in the + * current database. We reduce the message to NOTICE instead. */ foreach(l, namelist) { @@ -1937,7 +1930,7 @@ assign_search_path(const char *newval, bool doit, GucSource source) 0, 0, 0)) ereport((source == PGC_S_TEST) ? NOTICE : ERROR, (errcode(ERRCODE_UNDEFINED_SCHEMA), - errmsg("schema \"%s\" does not exist", curname))); + errmsg("schema \"%s\" does not exist", curname))); } } @@ -1945,9 +1938,9 @@ assign_search_path(const char *newval, bool doit, GucSource source) list_free(namelist); /* - * We mark the path as needing recomputation, but don't do anything - * until it's needed. This avoids trying to do database access during - * GUC initialization. + * We mark the path as needing recomputation, but don't do anything until + * it's needed. This avoids trying to do database access during GUC + * initialization. */ if (doit) namespaceSearchPathValid = false; @@ -1967,8 +1960,7 @@ InitializeSearchPath(void) { /* * In bootstrap mode, the search path must be 'pg_catalog' so that - * tables are created in the proper namespace; ignore the GUC - * setting. + * tables are created in the proper namespace; ignore the GUC setting. */ MemoryContext oldcxt; @@ -1983,8 +1975,8 @@ InitializeSearchPath(void) else { /* - * In normal mode, arrange for a callback on any syscache - * invalidation of pg_namespace rows. + * In normal mode, arrange for a callback on any syscache invalidation + * of pg_namespace rows. */ CacheRegisterSyscacheCallback(NAMESPACEOID, NamespaceCallback, diff --git a/src/backend/catalog/pg_aggregate.c b/src/backend/catalog/pg_aggregate.c index 26491e22a1..fb7562e306 100644 --- a/src/backend/catalog/pg_aggregate.c +++ b/src/backend/catalog/pg_aggregate.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/catalog/pg_aggregate.c,v 1.75 2005/04/14 20:03:23 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/catalog/pg_aggregate.c,v 1.76 2005/10/15 02:49:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -76,16 +76,16 @@ AggregateCreate(const char *aggName, elog(ERROR, "aggregate must have a transition function"); /* - * If transtype is polymorphic, basetype must be polymorphic also; - * else we will have no way to deduce the actual transtype. + * If transtype is polymorphic, basetype must be polymorphic also; else we + * will have no way to deduce the actual transtype. */ if ((aggTransType == ANYARRAYOID || aggTransType == ANYELEMENTOID) && !(aggBaseType == ANYARRAYOID || aggBaseType == ANYELEMENTOID)) ereport(ERROR, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), errmsg("cannot determine transition data type"), - errdetail("An aggregate using \"anyarray\" or \"anyelement\" as " - "transition type must have one of them as its base type."))); + errdetail("An aggregate using \"anyarray\" or \"anyelement\" as " + "transition type must have one of them as its base type."))); /* handle transfn */ fnArgs[0] = aggTransType; @@ -101,13 +101,13 @@ AggregateCreate(const char *aggName, /* * Return type of transfn (possibly after refinement by - * enforce_generic_type_consistency, if transtype isn't polymorphic) - * must exactly match declared transtype. + * enforce_generic_type_consistency, if transtype isn't polymorphic) must + * exactly match declared transtype. * - * In the non-polymorphic-transtype case, it might be okay to allow a - * rettype that's binary-coercible to transtype, but I'm not quite - * convinced that it's either safe or useful. When transtype is - * polymorphic we *must* demand exact equality. + * In the non-polymorphic-transtype case, it might be okay to allow a rettype + * that's binary-coercible to transtype, but I'm not quite convinced that + * it's either safe or useful. When transtype is polymorphic we *must* + * demand exact equality. */ if (rettype != aggTransType) ereport(ERROR, @@ -124,10 +124,9 @@ AggregateCreate(const char *aggName, proc = (Form_pg_proc) GETSTRUCT(tup); /* - * If the transfn is strict and the initval is NULL, make sure input - * type and transtype are the same (or at least binary-compatible), so - * that it's OK to use the first input value as the initial - * transValue. + * If the transfn is strict and the initval is NULL, make sure input type + * and transtype are the same (or at least binary-compatible), so that + * it's OK to use the first input value as the initial transValue. */ if (proc->proisstrict && agginitval == NULL) { @@ -155,20 +154,20 @@ AggregateCreate(const char *aggName, Assert(OidIsValid(finaltype)); /* - * If finaltype (i.e. aggregate return type) is polymorphic, basetype - * must be polymorphic also, else parser will fail to deduce result - * type. (Note: given the previous test on transtype and basetype, - * this cannot happen, unless someone has snuck a finalfn definition - * into the catalogs that itself violates the rule against polymorphic - * result with no polymorphic input.) + * If finaltype (i.e. aggregate return type) is polymorphic, basetype must + * be polymorphic also, else parser will fail to deduce result type. + * (Note: given the previous test on transtype and basetype, this cannot + * happen, unless someone has snuck a finalfn definition into the catalogs + * that itself violates the rule against polymorphic result with no + * polymorphic input.) */ if ((finaltype == ANYARRAYOID || finaltype == ANYELEMENTOID) && !(aggBaseType == ANYARRAYOID || aggBaseType == ANYELEMENTOID)) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), errmsg("cannot determine result data type"), - errdetail("An aggregate returning \"anyarray\" or \"anyelement\" " - "must have one of them as its base type."))); + errdetail("An aggregate returning \"anyarray\" or \"anyelement\" " + "must have one of them as its base type."))); /* handle sortop, if supplied */ if (aggsortopName) @@ -178,8 +177,7 @@ AggregateCreate(const char *aggName, /* * Everything looks okay. Try to create the pg_proc entry for the - * aggregate. (This could fail if there's already a conflicting - * entry.) + * aggregate. (This could fail if there's already a conflicting entry.) */ fnArgs[0] = aggBaseType; @@ -198,7 +196,7 @@ AggregateCreate(const char *aggName, false, /* isStrict (not needed for agg) */ PROVOLATILE_IMMUTABLE, /* volatility (not * needed for agg) */ - buildoidvector(fnArgs, 1), /* paramTypes */ + buildoidvector(fnArgs, 1), /* paramTypes */ PointerGetDatum(NULL), /* allParamTypes */ PointerGetDatum(NULL), /* parameterModes */ PointerGetDatum(NULL)); /* parameterNames */ @@ -235,10 +233,9 @@ AggregateCreate(const char *aggName, heap_close(aggdesc, RowExclusiveLock); /* - * Create dependencies for the aggregate (above and beyond those - * already made by ProcedureCreate). Note: we don't need an explicit - * dependency on aggTransType since we depend on it indirectly through - * transfn. + * Create dependencies for the aggregate (above and beyond those already + * made by ProcedureCreate). Note: we don't need an explicit dependency + * on aggTransType since we depend on it indirectly through transfn. */ myself.classId = ProcedureRelationId; myself.objectId = procOid; @@ -288,8 +285,8 @@ lookup_agg_function(List *fnName, * func_get_detail looks up the function in the catalogs, does * disambiguation for polymorphic functions, handles inheritance, and * returns the funcid and type and set or singleton status of the - * function's return value. it also returns the true argument types - * to the function. + * function's return value. it also returns the true argument types to + * the function. */ fdresult = func_get_detail(fnName, NIL, nargs, input_types, &fnOid, rettype, &retset, @@ -300,21 +297,20 @@ lookup_agg_function(List *fnName, ereport(ERROR, (errcode(ERRCODE_UNDEFINED_FUNCTION), errmsg("function %s does not exist", - func_signature_string(fnName, nargs, input_types)))); + func_signature_string(fnName, nargs, input_types)))); if (retset) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), errmsg("function %s returns a set", - func_signature_string(fnName, nargs, input_types)))); + func_signature_string(fnName, nargs, input_types)))); /* - * If the given type(s) are all polymorphic, there's nothing we can - * check. Otherwise, enforce consistency, and possibly refine the - * result type. + * If the given type(s) are all polymorphic, there's nothing we can check. + * Otherwise, enforce consistency, and possibly refine the result type. */ if ((input_types[0] == ANYARRAYOID || input_types[0] == ANYELEMENTOID) && (nargs == 1 || - (input_types[1] == ANYARRAYOID || input_types[1] == ANYELEMENTOID))) + (input_types[1] == ANYARRAYOID || input_types[1] == ANYELEMENTOID))) { /* nothing to check here */ } @@ -327,8 +323,8 @@ lookup_agg_function(List *fnName, } /* - * func_get_detail will find functions requiring run-time argument - * type coercion, but nodeAgg.c isn't prepared to deal with that + * func_get_detail will find functions requiring run-time argument type + * coercion, but nodeAgg.c isn't prepared to deal with that */ if (true_oid_array[0] != ANYARRAYOID && true_oid_array[0] != ANYELEMENTOID && @@ -336,7 +332,7 @@ lookup_agg_function(List *fnName, ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), errmsg("function %s requires run-time type coercion", - func_signature_string(fnName, nargs, true_oid_array)))); + func_signature_string(fnName, nargs, true_oid_array)))); if (nargs == 2 && true_oid_array[1] != ANYARRAYOID && @@ -345,7 +341,7 @@ lookup_agg_function(List *fnName, ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), errmsg("function %s requires run-time type coercion", - func_signature_string(fnName, nargs, true_oid_array)))); + func_signature_string(fnName, nargs, true_oid_array)))); /* Check aggregate creator has permission to call the function */ aclresult = pg_proc_aclcheck(fnOid, GetUserId(), ACL_EXECUTE); diff --git a/src/backend/catalog/pg_constraint.c b/src/backend/catalog/pg_constraint.c index b2cc3d5c47..cf18051f52 100644 --- a/src/backend/catalog/pg_constraint.c +++ b/src/backend/catalog/pg_constraint.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/catalog/pg_constraint.c,v 1.26 2005/08/01 04:03:54 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/catalog/pg_constraint.c,v 1.27 2005/10/15 02:49:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -140,7 +140,7 @@ CreateConstraintEntry(const char *constraintName, */ if (conBin) values[Anum_pg_constraint_conbin - 1] = DirectFunctionCall1(textin, - CStringGetDatum(conBin)); + CStringGetDatum(conBin)); else nulls[Anum_pg_constraint_conbin - 1] = 'n'; @@ -149,7 +149,7 @@ CreateConstraintEntry(const char *constraintName, */ if (conSrc) values[Anum_pg_constraint_consrc - 1] = DirectFunctionCall1(textin, - CStringGetDatum(conSrc)); + CStringGetDatum(conSrc)); else nulls[Anum_pg_constraint_consrc - 1] = 'n'; @@ -169,8 +169,8 @@ CreateConstraintEntry(const char *constraintName, if (OidIsValid(relId)) { /* - * Register auto dependency from constraint to owning relation, or - * to specific column(s) if any are mentioned. + * Register auto dependency from constraint to owning relation, or to + * specific column(s) if any are mentioned. */ ObjectAddress relobject; @@ -210,8 +210,8 @@ CreateConstraintEntry(const char *constraintName, if (OidIsValid(foreignRelId)) { /* - * Register normal dependency from constraint to foreign relation, - * or to specific column(s) if any are mentioned. + * Register normal dependency from constraint to foreign relation, or + * to specific column(s) if any are mentioned. */ ObjectAddress relobject; @@ -252,8 +252,8 @@ CreateConstraintEntry(const char *constraintName, if (conExpr != NULL) { /* - * Register dependencies from constraint to objects mentioned in - * CHECK expression. + * Register dependencies from constraint to objects mentioned in CHECK + * expression. */ recordDependencyOnSingleRelExpr(&conobject, conExpr, relId, DEPENDENCY_NORMAL, @@ -450,15 +450,15 @@ RemoveConstraintById(Oid conId) Relation rel; /* - * If the constraint is for a relation, open and exclusive-lock - * the relation it's for. + * If the constraint is for a relation, open and exclusive-lock the + * relation it's for. */ rel = heap_open(con->conrelid, AccessExclusiveLock); /* - * We need to update the relcheck count if it is a check - * constraint being dropped. This update will force backends to - * rebuild relcache entries when we commit. + * We need to update the relcheck count if it is a check constraint + * being dropped. This update will force backends to rebuild relcache + * entries when we commit. */ if (con->contype == CONSTRAINT_CHECK) { @@ -495,11 +495,10 @@ RemoveConstraintById(Oid conId) else if (OidIsValid(con->contypid)) { /* - * XXX for now, do nothing special when dropping a domain - * constraint + * XXX for now, do nothing special when dropping a domain constraint * - * Probably there should be some form of locking on the domain type, - * but we have no such concept at the moment. + * Probably there should be some form of locking on the domain type, but + * we have no such concept at the moment. */ } else @@ -531,9 +530,9 @@ GetConstraintNameForTrigger(Oid triggerId) HeapTuple tup; /* - * We must grovel through pg_depend to find the owning constraint. - * Perhaps pg_trigger should have a column for the owning constraint ... - * but right now this is not performance-critical code. + * We must grovel through pg_depend to find the owning constraint. Perhaps + * pg_trigger should have a column for the owning constraint ... but right + * now this is not performance-critical code. */ depRel = heap_open(DependRelationId, AccessShareLock); @@ -567,7 +566,7 @@ GetConstraintNameForTrigger(Oid triggerId) heap_close(depRel, AccessShareLock); if (!OidIsValid(constraintId)) - return NULL; /* no owning constraint found */ + return NULL; /* no owning constraint found */ conRel = heap_open(ConstraintRelationId, AccessShareLock); @@ -611,10 +610,10 @@ void AlterConstraintNamespaces(Oid ownerId, Oid oldNspId, Oid newNspId, bool isType) { - Relation conRel; - ScanKeyData key[1]; - SysScanDesc scan; - HeapTuple tup; + Relation conRel; + ScanKeyData key[1]; + SysScanDesc scan; + HeapTuple tup; conRel = heap_open(ConstraintRelationId, RowExclusiveLock); diff --git a/src/backend/catalog/pg_conversion.c b/src/backend/catalog/pg_conversion.c index 0cdca75f3a..21adfbcf94 100644 --- a/src/backend/catalog/pg_conversion.c +++ b/src/backend/catalog/pg_conversion.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/catalog/pg_conversion.c,v 1.26 2005/09/24 17:53:12 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/catalog/pg_conversion.c,v 1.27 2005/10/15 02:49:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -67,17 +67,17 @@ ConversionCreate(const char *conname, Oid connamespace, if (def) { /* - * make sure there is no existing default pair in this name space + * make sure there is no existing default + * pair in this name space */ if (FindDefaultConversion(connamespace, conforencoding, contoencoding)) ereport(ERROR, (errcode(ERRCODE_DUPLICATE_OBJECT), - errmsg("default conversion for %s to %s already exists", - pg_encoding_to_char(conforencoding), - pg_encoding_to_char(contoencoding)))); + errmsg("default conversion for %s to %s already exists", + pg_encoding_to_char(conforencoding), + pg_encoding_to_char(contoencoding)))); } /* open pg_conversion */ @@ -150,7 +150,7 @@ ConversionDrop(Oid conversionOid, DropBehavior behavior) if (!superuser() && ((Form_pg_conversion) GETSTRUCT(tuple))->conowner != GetUserId()) aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_CONVERSION, - NameStr(((Form_pg_conversion) GETSTRUCT(tuple))->conname)); + NameStr(((Form_pg_conversion) GETSTRUCT(tuple))->conname)); ReleaseSysCache(tuple); @@ -330,9 +330,8 @@ pg_convert_using(PG_FUNCTION_ARGS) ReleaseSysCache(tuple); /* - * build text result structure. we cannot use textin() here, since - * textin assumes that input string encoding is same as database - * encoding. + * build text result structure. we cannot use textin() here, since textin + * assumes that input string encoding is same as database encoding. */ len = strlen(result) + VARHDRSZ; retval = palloc(len); diff --git a/src/backend/catalog/pg_depend.c b/src/backend/catalog/pg_depend.c index bf910d09a5..c8f9e53212 100644 --- a/src/backend/catalog/pg_depend.c +++ b/src/backend/catalog/pg_depend.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/catalog/pg_depend.c,v 1.14 2005/08/01 04:03:54 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/catalog/pg_depend.c,v 1.15 2005/10/15 02:49:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -62,8 +62,8 @@ recordMultipleDependencies(const ObjectAddress *depender, return; /* nothing to do */ /* - * During bootstrap, do nothing since pg_depend may not exist yet. - * initdb will fill in appropriate pg_depend entries after bootstrap. + * During bootstrap, do nothing since pg_depend may not exist yet. initdb + * will fill in appropriate pg_depend entries after bootstrap. */ if (IsBootstrapProcessingMode()) return; @@ -78,9 +78,9 @@ recordMultipleDependencies(const ObjectAddress *depender, for (i = 0; i < nreferenced; i++, referenced++) { /* - * If the referenced object is pinned by the system, there's no - * real need to record dependencies on it. This saves lots of - * space in pg_depend, so it's worth the time taken to check. + * If the referenced object is pinned by the system, there's no real + * need to record dependencies on it. This saves lots of space in + * pg_depend, so it's worth the time taken to check. */ if (!isObjectPinned(referenced, dependDesc)) { @@ -190,11 +190,10 @@ changeDependencyFor(Oid classId, Oid objectId, depRel = heap_open(DependRelationId, RowExclusiveLock); /* - * If oldRefObjectId is pinned, there won't be any dependency entries - * on it --- we can't cope in that case. (This isn't really worth - * expending code to fix, in current usage; it just means you can't - * rename stuff out of pg_catalog, which would likely be a bad move - * anyway.) + * If oldRefObjectId is pinned, there won't be any dependency entries on + * it --- we can't cope in that case. (This isn't really worth expending + * code to fix, in current usage; it just means you can't rename stuff out + * of pg_catalog, which would likely be a bad move anyway.) */ objAddr.classId = refClassId; objAddr.objectId = oldRefObjectId; @@ -203,12 +202,12 @@ changeDependencyFor(Oid classId, Oid objectId, if (isObjectPinned(&objAddr, depRel)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot remove dependency on %s because it is a system object", - getObjectDescription(&objAddr)))); + errmsg("cannot remove dependency on %s because it is a system object", + getObjectDescription(&objAddr)))); /* - * We can handle adding a dependency on something pinned, though, - * since that just means deleting the dependency entry. + * We can handle adding a dependency on something pinned, though, since + * that just means deleting the dependency entry. */ objAddr.objectId = newRefObjectId; @@ -293,9 +292,9 @@ isObjectPinned(const ObjectAddress *object, Relation rel) /* * Since we won't generate additional pg_depend entries for pinned - * objects, there can be at most one entry referencing a pinned - * object. Hence, it's sufficient to look at the first returned - * tuple; we don't need to loop. + * objects, there can be at most one entry referencing a pinned object. + * Hence, it's sufficient to look at the first returned tuple; we don't + * need to loop. */ tup = systable_getnext(scan); if (HeapTupleIsValid(tup)) diff --git a/src/backend/catalog/pg_operator.c b/src/backend/catalog/pg_operator.c index 903a46ac0f..8dea69a234 100644 --- a/src/backend/catalog/pg_operator.c +++ b/src/backend/catalog/pg_operator.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/catalog/pg_operator.c,v 1.93 2005/07/07 20:39:57 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/catalog/pg_operator.c,v 1.94 2005/10/15 02:49:14 momjian Exp $ * * NOTES * these routines moved here from commands/define.c and somewhat cleaned up. @@ -90,10 +90,10 @@ validOperatorName(const char *name) /* * For SQL92 compatibility, '+' and '-' cannot be the last char of a - * multi-char operator unless the operator contains chars that are not - * in SQL92 operators. The idea is to lex '=-' as two operators, but - * not to forbid operator names like '?-' that could not be sequences - * of SQL92 operators. + * multi-char operator unless the operator contains chars that are not in + * SQL92 operators. The idea is to lex '=-' as two operators, but not to + * forbid operator names like '?-' that could not be sequences of SQL92 + * operators. */ if (len > 1 && (name[len - 1] == '+' || @@ -228,14 +228,14 @@ OperatorShellMake(const char *operatorName, } /* - * initialize values[] with the operator name and input data types. - * Note that oprcode is set to InvalidOid, indicating it's a shell. + * initialize values[] with the operator name and input data types. Note + * that oprcode is set to InvalidOid, indicating it's a shell. */ i = 0; namestrcpy(&oname, operatorName); values[i++] = NameGetDatum(&oname); /* oprname */ values[i++] = ObjectIdGetDatum(operatorNamespace); /* oprnamespace */ - values[i++] = ObjectIdGetDatum(GetUserId()); /* oprowner */ + values[i++] = ObjectIdGetDatum(GetUserId()); /* oprowner */ values[i++] = CharGetDatum(leftTypeId ? (rightTypeId ? 'b' : 'r') : 'l'); /* oprkind */ values[i++] = BoolGetDatum(false); /* oprcanhash */ values[i++] = ObjectIdGetDatum(leftTypeId); /* oprleft */ @@ -410,7 +410,7 @@ OperatorCreate(const char *operatorName, if (!OidIsValid(leftTypeId) && !OidIsValid(rightTypeId)) ereport(ERROR, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), - errmsg("at least one of leftarg or rightarg must be specified"))); + errmsg("at least one of leftarg or rightarg must be specified"))); if (!(OidIsValid(leftTypeId) && OidIsValid(rightTypeId))) { @@ -418,11 +418,11 @@ OperatorCreate(const char *operatorName, if (commutatorName) ereport(ERROR, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), - errmsg("only binary operators can have commutators"))); + errmsg("only binary operators can have commutators"))); if (joinName) ereport(ERROR, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), - errmsg("only binary operators can have join selectivity"))); + errmsg("only binary operators can have join selectivity"))); if (canHash) ereport(ERROR, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), @@ -451,9 +451,9 @@ OperatorCreate(const char *operatorName, */ /* - * Look up registered procedures -- find the return type of - * procedureName to place in "result" field. Do this before shells are - * created so we don't have to worry about deleting them later. + * Look up registered procedures -- find the return type of procedureName + * to place in "result" field. Do this before shells are created so we + * don't have to worry about deleting them later. */ if (!OidIsValid(leftTypeId)) { @@ -519,7 +519,7 @@ OperatorCreate(const char *operatorName, namestrcpy(&oname, operatorName); values[i++] = NameGetDatum(&oname); /* oprname */ values[i++] = ObjectIdGetDatum(operatorNamespace); /* oprnamespace */ - values[i++] = ObjectIdGetDatum(GetUserId()); /* oprowner */ + values[i++] = ObjectIdGetDatum(GetUserId()); /* oprowner */ values[i++] = CharGetDatum(leftTypeId ? (rightTypeId ? 'b' : 'r') : 'l'); /* oprkind */ values[i++] = BoolGetDatum(canHash); /* oprcanhash */ values[i++] = ObjectIdGetDatum(leftTypeId); /* oprleft */ @@ -660,14 +660,14 @@ OperatorCreate(const 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; @@ -721,7 +721,7 @@ get_other_operator(List *otherOp, Oid otherLeftTypeId, Oid otherRightTypeId, if (!isCommutator) ereport(ERROR, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), - errmsg("operator cannot be its own negator or sort operator"))); + errmsg("operator cannot be its own negator or sort operator"))); return InvalidOid; } @@ -780,9 +780,9 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId) 0, 0, 0); /* - * 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... + * 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... */ if (commId == negId) { @@ -931,10 +931,10 @@ makeOperatorDependencies(HeapTuple tuple) * NOTE: we do not consider the operator to depend on the associated * operators oprcom, oprnegate, oprlsortop, oprrsortop, oprltcmpop, * oprgtcmpop. We would not want to delete this operator if those go - * away, but only reset the link fields; which is not a function that - * the dependency code can presently handle. (Something could perhaps - * be done with objectSubId though.) For now, it's okay to let those - * links dangle if a referenced operator is removed. + * away, but only reset the link fields; which is not a function that the + * dependency code can presently handle. (Something could perhaps be done + * with objectSubId though.) For now, it's okay to let those links dangle + * if a referenced operator is removed. */ /* Dependency on implementation function */ diff --git a/src/backend/catalog/pg_proc.c b/src/backend/catalog/pg_proc.c index 691be63dc7..ab3de4ed4b 100644 --- a/src/backend/catalog/pg_proc.c +++ b/src/backend/catalog/pg_proc.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/catalog/pg_proc.c,v 1.133 2005/09/24 22:54:35 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/catalog/pg_proc.c,v 1.134 2005/10/15 02:49:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -115,9 +115,9 @@ ProcedureCreate(const char *procedureName, if (allParameterTypes != PointerGetDatum(NULL)) { /* - * We expect the array to be a 1-D OID array; verify that. We - * don't need to use deconstruct_array() since the array data is - * just going to look like a C array of OID values. + * We expect the array to be a 1-D OID array; verify that. We don't + * need to use deconstruct_array() since the array data is just going + * to look like a C array of OID values. */ allParamCount = ARR_DIMS(DatumGetPointer(allParameterTypes))[0]; if (ARR_NDIM(DatumGetPointer(allParameterTypes)) != 1 || @@ -136,8 +136,8 @@ ProcedureCreate(const char *procedureName, /* * Do not allow return type ANYARRAY or ANYELEMENT unless at least one - * input argument is ANYARRAY or ANYELEMENT. Also, do not allow - * return type INTERNAL unless at least one input argument is INTERNAL. + * input argument is ANYARRAY or ANYELEMENT. Also, do not allow return + * type INTERNAL unless at least one input argument is INTERNAL. */ for (i = 0; i < parameterCount; i++) { @@ -158,9 +158,9 @@ ProcedureCreate(const char *procedureName, for (i = 0; i < allParamCount; i++) { /* - * We don't bother to distinguish input and output params here, - * so if there is, say, just an input INTERNAL param then we will - * still set internalOutParam. This is OK since we don't really + * We don't bother to distinguish input and output params here, so + * if there is, say, just an input INTERNAL param then we will + * still set internalOutParam. This is OK since we don't really * care. */ switch (allParams[i]) @@ -240,9 +240,9 @@ ProcedureCreate(const char *procedureName, else nulls[Anum_pg_proc_proargnames - 1] = 'n'; values[Anum_pg_proc_prosrc - 1] = DirectFunctionCall1(textin, - CStringGetDatum(prosrc)); + CStringGetDatum(prosrc)); values[Anum_pg_proc_probin - 1] = DirectFunctionCall1(textin, - CStringGetDatum(probin)); + CStringGetDatum(probin)); /* start out with empty permissions */ nulls[Anum_pg_proc_proacl - 1] = 'n'; @@ -264,8 +264,8 @@ ProcedureCreate(const char *procedureName, if (!replace) ereport(ERROR, (errcode(ERRCODE_DUPLICATE_FUNCTION), - errmsg("function \"%s\" already exists with same argument types", - procedureName))); + errmsg("function \"%s\" already exists with same argument types", + procedureName))); if (!pg_proc_ownercheck(HeapTupleGetOid(oldtup), GetUserId())) aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_PROC, procedureName); @@ -295,14 +295,14 @@ ProcedureCreate(const char *procedureName, parameterModes, parameterNames); if (olddesc == NULL && newdesc == NULL) - /* ok, both are runtime-defined RECORDs */ ; + /* ok, both are runtime-defined RECORDs */ ; else if (olddesc == NULL || newdesc == NULL || !equalTupleDescs(olddesc, newdesc)) - ereport(ERROR, - (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), - errmsg("cannot change return type of existing function"), - errdetail("Row type defined by OUT parameters is different."), - errhint("Use DROP FUNCTION first."))); + ereport(ERROR, + (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), + errmsg("cannot change return type of existing function"), + errdetail("Row type defined by OUT parameters is different."), + errhint("Use DROP FUNCTION first."))); } /* Can't change aggregate status, either */ @@ -422,8 +422,8 @@ fmgr_internal_validator(PG_FUNCTION_ARGS) char *prosrc; /* - * We do not honor check_function_bodies since it's unlikely the - * function name will be found later if it isn't there now. + * We do not honor check_function_bodies since it's unlikely the function + * name will be found later if it isn't there now. */ tuple = SearchSysCache(PROCOID, @@ -471,10 +471,9 @@ fmgr_c_validator(PG_FUNCTION_ARGS) char *probin; /* - * It'd be most consistent to skip the check if - * !check_function_bodies, but the purpose of that switch is to be - * helpful for pg_dump loading, and for pg_dump loading it's much - * better if we *do* check. + * It'd be most consistent to skip the check if !check_function_bodies, + * but the purpose of that switch is to be helpful for pg_dump loading, + * and for pg_dump loading it's much better if we *do* check. */ tuple = SearchSysCache(PROCOID, @@ -554,8 +553,8 @@ fmgr_sql_validator(PG_FUNCTION_ARGS) else ereport(ERROR, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), - errmsg("SQL functions cannot have arguments of type %s", - format_type_be(proc->proargtypes.values[i])))); + errmsg("SQL functions cannot have arguments of type %s", + format_type_be(proc->proargtypes.values[i])))); } } @@ -577,13 +576,13 @@ fmgr_sql_validator(PG_FUNCTION_ARGS) error_context_stack = &sqlerrcontext; /* - * We can't do full prechecking of the function definition if - * there are any polymorphic input types, because actual datatypes - * of expression results will be unresolvable. The check will be - * done at runtime instead. + * We can't do full prechecking of the function definition if there + * are any polymorphic input types, because actual datatypes of + * expression results will be unresolvable. The check will be done at + * runtime instead. * - * We can run the text through the raw parser though; this will at - * least catch silly syntactic errors. + * We can run the text through the raw parser though; this will at least + * catch silly syntactic errors. */ if (!haspolyarg) { @@ -652,8 +651,8 @@ function_parse_error_transpose(const char *prosrc) * Nothing to do unless we are dealing with a syntax error that has a * cursor position. * - * Some PLs may prefer to report the error position as an internal error - * to begin with, so check that too. + * Some PLs may prefer to report the error position as an internal error to + * begin with, so check that too. */ origerrposition = geterrposition(); if (origerrposition <= 0) @@ -703,10 +702,10 @@ match_prosrc_to_query(const char *prosrc, const char *queryText, int cursorpos) { /* - * Rather than fully parsing the CREATE FUNCTION command, we just scan - * the command looking for $prosrc$ or 'prosrc'. This could be fooled - * (though not in any very probable scenarios), so fail if we find - * more than one match. + * Rather than fully parsing the CREATE FUNCTION command, we just scan the + * command looking for $prosrc$ or 'prosrc'. This could be fooled (though + * not in any very probable scenarios), so fail if we find more than one + * match. */ int prosrclen = strlen(prosrc); int querylen = strlen(queryText); @@ -722,8 +721,8 @@ match_prosrc_to_query(const char *prosrc, const char *queryText, { /* * Found a $foo$ match. Since there are no embedded quoting - * characters in a dollar-quoted literal, we don't have to do - * any fancy arithmetic; just offset by the starting position. + * characters in a dollar-quoted literal, we don't have to do any + * fancy arithmetic; just offset by the starting position. */ if (matchpos) return 0; /* multiple matches, fail */ @@ -735,9 +734,8 @@ match_prosrc_to_query(const char *prosrc, const char *queryText, cursorpos, &newcursorpos)) { /* - * Found a 'foo' match. match_prosrc_to_literal() has - * adjusted for any quotes or backslashes embedded in the - * literal. + * Found a 'foo' match. match_prosrc_to_literal() has adjusted + * for any quotes or backslashes embedded in the literal. */ if (matchpos) return 0; /* multiple matches, fail */ @@ -769,8 +767,8 @@ match_prosrc_to_literal(const char *prosrc, const char *literal, * string literal. It does not handle the SQL syntax for literals * continued across line boundaries. * - * We do the comparison a character at a time, not a byte at a time, so - * that we can do the correct cursorpos math. + * We do the comparison a character at a time, not a byte at a time, so that + * we can do the correct cursorpos math. */ while (*prosrc) { diff --git a/src/backend/catalog/pg_shdepend.c b/src/backend/catalog/pg_shdepend.c index bd326b876b..4cce7ba13c 100644 --- a/src/backend/catalog/pg_shdepend.c +++ b/src/backend/catalog/pg_shdepend.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/catalog/pg_shdepend.c,v 1.2 2005/08/30 01:07:54 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/catalog/pg_shdepend.c,v 1.3 2005/10/15 02:49:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -36,22 +36,22 @@ typedef enum } objectType; static int getOidListDiff(Oid *list1, int nlist1, Oid *list2, int nlist2, - Oid **diff); -static Oid classIdGetDbId(Oid classId); + Oid **diff); +static Oid classIdGetDbId(Oid classId); static void shdepLockAndCheckObject(Oid classId, Oid objectId); static void shdepChangeDep(Relation sdepRel, Oid classid, Oid objid, - Oid refclassid, Oid refobjid, - SharedDependencyType deptype); + Oid refclassid, Oid refobjid, + SharedDependencyType deptype); static void shdepAddDependency(Relation sdepRel, Oid classId, Oid objectId, - Oid refclassId, Oid refobjId, - SharedDependencyType deptype); + Oid refclassId, Oid refobjId, + SharedDependencyType deptype); static void shdepDropDependency(Relation sdepRel, Oid classId, Oid objectId, - Oid refclassId, Oid refobjId, - SharedDependencyType deptype); + Oid refclassId, Oid refobjId, + SharedDependencyType deptype); static void storeObjectDescription(StringInfo descs, objectType type, - ObjectAddress *object, - SharedDependencyType deptype, - int count); + ObjectAddress *object, + SharedDependencyType deptype, + int count); static bool isSharedObjectPinned(Oid classId, Oid objectId, Relation sdepRel); @@ -70,7 +70,7 @@ static bool isSharedObjectPinned(Oid classId, Oid objectId, Relation sdepRel); */ void recordSharedDependencyOn(ObjectAddress *depender, - ObjectAddress *referenced, + ObjectAddress *referenced, SharedDependencyType deptype) { Relation sdepRel; @@ -95,7 +95,7 @@ recordSharedDependencyOn(ObjectAddress *depender, sdepRel)) { shdepAddDependency(sdepRel, depender->classId, depender->objectId, - referenced->classId, referenced->objectId, + referenced->classId, referenced->objectId, deptype); } @@ -132,11 +132,11 @@ recordDependencyOnOwner(Oid classId, Oid objectId, Oid owner) * shdepChangeDep * * Update shared dependency records to account for an updated referenced - * object. This is an internal workhorse for operations such as changing + * object. This is an internal workhorse for operations such as changing * an object's owner. * * There must be no more than one existing entry for the given dependent - * object and dependency type! So in practice this can only be used for + * object and dependency type! So in practice this can only be used for * updating SHARED_DEPENDENCY_OWNER entries, which should have that property. * * If there is no previous entry, we assume it was referencing a PINned @@ -154,12 +154,12 @@ shdepChangeDep(Relation sdepRel, Oid classid, Oid objid, Oid dbid = classIdGetDbId(classid); HeapTuple oldtup = NULL; HeapTuple scantup; - ScanKeyData key[3]; - SysScanDesc scan; + ScanKeyData key[3]; + SysScanDesc scan; /* - * Make sure the new referenced object doesn't go away while we record - * the dependency. + * Make sure the new referenced object doesn't go away while we record the + * dependency. */ shdepLockAndCheckObject(refclassid, refobjid); @@ -167,11 +167,11 @@ shdepChangeDep(Relation sdepRel, Oid classid, Oid objid, * Look for a previous entry */ ScanKeyInit(&key[0], - Anum_pg_shdepend_dbid, + Anum_pg_shdepend_dbid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(dbid)); ScanKeyInit(&key[1], - Anum_pg_shdepend_classid, + Anum_pg_shdepend_classid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(classid)); ScanKeyInit(&key[2], @@ -181,7 +181,7 @@ shdepChangeDep(Relation sdepRel, Oid classid, Oid objid, scan = systable_beginscan(sdepRel, SharedDependDependerIndexId, true, SnapshotNow, 3, key); - + while ((scantup = systable_getnext(scan)) != NULL) { /* Ignore if not of the target dependency type */ @@ -220,8 +220,8 @@ shdepChangeDep(Relation sdepRel, Oid classid, Oid objid, else { /* Need to insert new entry */ - Datum values[Natts_pg_shdepend]; - bool nulls[Natts_pg_shdepend]; + Datum values[Natts_pg_shdepend]; + bool nulls[Natts_pg_shdepend]; memset(nulls, 0, sizeof(nulls)); @@ -234,8 +234,8 @@ shdepChangeDep(Relation sdepRel, Oid classid, Oid objid, values[Anum_pg_shdepend_deptype - 1] = CharGetDatum(deptype); /* - * we are reusing oldtup just to avoid declaring a new variable, - * but it's certainly a new tuple + * we are reusing oldtup just to avoid declaring a new variable, but + * it's certainly a new tuple */ oldtup = heap_form_tuple(RelationGetDescr(sdepRel), values, nulls); simple_heap_insert(sdepRel, oldtup); @@ -271,7 +271,7 @@ changeDependencyOnOwner(Oid classId, Oid objectId, Oid newOwnerId) * was previously granted some rights to the object. * * This step is analogous to aclnewowner's removal of duplicate entries - * in the ACL. We have to do it to handle this scenario: + * in the ACL. We have to do it to handle this scenario: * A grants some rights on an object to B * ALTER OWNER changes the object's owner to B * ALTER OWNER changes the object's owner to C @@ -296,7 +296,7 @@ changeDependencyOnOwner(Oid classId, Oid objectId, Oid newOwnerId) * Helper for updateAclDependencies. * * Takes two Oid arrays and returns elements from the first not found in the - * second. We assume both arrays are sorted and de-duped, and that the + * second. We assume both arrays are sorted and de-duped, and that the * second array does not contain any values not found in the first. * * NOTE: Both input arrays are pfreed. @@ -304,17 +304,17 @@ changeDependencyOnOwner(Oid classId, Oid objectId, Oid newOwnerId) static int getOidListDiff(Oid *list1, int nlist1, Oid *list2, int nlist2, Oid **diff) { - Oid *result; - int i, - j, - k = 0; + Oid *result; + int i, + j, + k = 0; AssertArg(nlist1 >= nlist2 && nlist2 >= 0); result = palloc(sizeof(Oid) * (nlist1 - nlist2)); *diff = result; - for (i = 0, j = 0; i < nlist1 && j < nlist2; ) + for (i = 0, j = 0; i < nlist1 && j < nlist2;) { if (list1[i] == list2[j]) { @@ -350,7 +350,7 @@ getOidListDiff(Oid *list1, int nlist1, Oid *list2, int nlist2, Oid **diff) /* * updateAclDependencies - * Update the pg_shdepend info for an object's ACL during GRANT/REVOKE. + * Update the pg_shdepend info for an object's ACL during GRANT/REVOKE. * * classId, objectId: identify the object whose ACL this is * ownerId: role owning the object @@ -398,12 +398,12 @@ updateAclDependencies(Oid classId, Oid objectId, Oid ownerId, bool isGrant, /* Add or drop the respective dependency */ for (i = 0; i < ndiff; i++) { - Oid roleid = diff[i]; + Oid roleid = diff[i]; /* - * Skip the owner: he has an OWNER shdep entry instead. - * (This is not just a space optimization; it makes ALTER OWNER - * easier. See notes in changeDependencyOnOwner.) + * Skip the owner: he has an OWNER shdep entry instead. (This is + * not just a space optimization; it makes ALTER OWNER easier. + * See notes in changeDependencyOnOwner.) */ if (roleid == ownerId) continue; @@ -416,7 +416,7 @@ updateAclDependencies(Oid classId, Oid objectId, Oid ownerId, bool isGrant, shdepAddDependency(sdepRel, classId, objectId, AuthIdRelationId, roleid, SHARED_DEPENDENCY_ACL); - else + else shdepDropDependency(sdepRel, classId, objectId, AuthIdRelationId, roleid, SHARED_DEPENDENCY_ACL); @@ -433,15 +433,15 @@ updateAclDependencies(Oid classId, Oid objectId, Oid ownerId, bool isGrant, */ typedef struct { - Oid dbOid; - int count; + Oid dbOid; + int count; } remoteDep; /* * checkSharedDependencies * * Check whether there are shared dependency entries for a given shared - * object. Returns a string containing a newline-separated list of object + * object. Returns a string containing a newline-separated list of object * descriptions that depend on the shared object, or NULL if none is found. * * We can find three different kinds of dependencies: dependencies on objects @@ -456,20 +456,20 @@ char * checkSharedDependencies(Oid classId, Oid objectId) { Relation sdepRel; - ScanKeyData key[2]; - SysScanDesc scan; + ScanKeyData key[2]; + SysScanDesc scan; HeapTuple tup; int totalDeps = 0; int numLocalDeps = 0; int numSharedDeps = 0; List *remDeps = NIL; ListCell *cell; - ObjectAddress object; + ObjectAddress object; StringInfoData descs; /* - * We try to limit the number of reported dependencies to something - * sane, both for the user's sake and to avoid blowing out memory. + * We try to limit the number of reported dependencies to something sane, + * both for the user's sake and to avoid blowing out memory. */ #define MAX_REPORTED_DEPS 100 @@ -478,20 +478,20 @@ checkSharedDependencies(Oid classId, Oid objectId) sdepRel = heap_open(SharedDependRelationId, AccessShareLock); ScanKeyInit(&key[0], - Anum_pg_shdepend_refclassid, + Anum_pg_shdepend_refclassid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(classId)); ScanKeyInit(&key[1], - Anum_pg_shdepend_refobjid, + Anum_pg_shdepend_refobjid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(objectId)); - + scan = systable_beginscan(sdepRel, SharedDependReferenceIndexId, true, SnapshotNow, 2, key); while (HeapTupleIsValid(tup = systable_getnext(scan))) { - Form_pg_shdepend sdepForm = (Form_pg_shdepend) GETSTRUCT(tup); + Form_pg_shdepend sdepForm = (Form_pg_shdepend) GETSTRUCT(tup); /* This case can be dispatched quickly */ if (sdepForm->deptype == SHARED_DEPENDENCY_PIN) @@ -502,7 +502,7 @@ checkSharedDependencies(Oid classId, Oid objectId) ereport(ERROR, (errcode(ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST), errmsg("cannot drop %s because it is required by the database system", - getObjectDescription(&object)))); + getObjectDescription(&object)))); } object.classId = sdepForm->classid; @@ -513,8 +513,8 @@ checkSharedDependencies(Oid classId, Oid objectId) * If it's a dependency local to this database or it's a shared * object, describe it. * - * If it's a remote dependency, keep track of it so we can report - * the number of them later. + * If it's a remote dependency, keep track of it so we can report the + * number of them later. */ if (sdepForm->dbid == MyDatabaseId) { @@ -537,10 +537,10 @@ checkSharedDependencies(Oid classId, Oid objectId) bool stored = false; /* - * XXX this info is kept on a simple List. Maybe it's not good + * XXX this info is kept on a simple List. Maybe it's not good * for performance, but using a hash table seems needlessly - * complex. The expected number of databases is not high - * anyway, I suppose. + * complex. The expected number of databases is not high anyway, + * I suppose. */ foreach(cell, remDeps) { @@ -572,8 +572,8 @@ checkSharedDependencies(Oid classId, Oid objectId) /* * Report seems unreasonably long, so reduce it to per-database info * - * Note: we don't ever suppress per-database totals, which should - * be OK as long as there aren't too many databases ... + * Note: we don't ever suppress per-database totals, which should be OK + * as long as there aren't too many databases ... */ descs.len = 0; /* reset to empty */ descs.data[0] = '\0'; @@ -592,7 +592,7 @@ checkSharedDependencies(Oid classId, Oid objectId) foreach(cell, remDeps) { - remoteDep *dep = lfirst(cell); + remoteDep *dep = lfirst(cell); object.classId = DatabaseRelationId; object.objectId = dep->dbOid; @@ -624,8 +624,8 @@ copyTemplateDependencies(Oid templateDbId, Oid newDbId) { Relation sdepRel; TupleDesc sdepDesc; - ScanKeyData key[1]; - SysScanDesc scan; + ScanKeyData key[1]; + SysScanDesc scan; HeapTuple tup; CatalogIndexState indstate; Datum values[Natts_pg_shdepend]; @@ -655,11 +655,11 @@ copyTemplateDependencies(Oid templateDbId, Oid newDbId) values[Anum_pg_shdepend_dbid - 1] = ObjectIdGetDatum(newDbId); /* - * Copy the entries of the original database, changing the database Id - * to that of the new database. Note that because we are not copying - * rows with dbId == 0 (ie, rows describing dependent shared objects) - * we won't copy the ownership dependency of the template database - * itself; this is what we want. + * Copy the entries of the original database, changing the database Id to + * that of the new database. Note that because we are not copying rows + * with dbId == 0 (ie, rows describing dependent shared objects) we won't + * copy the ownership dependency of the template database itself; this is + * what we want. */ while (HeapTupleIsValid(tup = systable_getnext(scan))) { @@ -690,15 +690,15 @@ void dropDatabaseDependencies(Oid databaseId) { Relation sdepRel; - ScanKeyData key[1]; - SysScanDesc scan; + ScanKeyData key[1]; + SysScanDesc scan; HeapTuple tup; sdepRel = heap_open(SharedDependRelationId, RowExclusiveLock); /* - * First, delete all the entries that have the database Oid in the - * dbid field. + * First, delete all the entries that have the database Oid in the dbid + * field. */ ScanKeyInit(&key[0], Anum_pg_shdepend_dbid, @@ -747,7 +747,7 @@ deleteSharedDependencyRecordsFor(Oid classId, Oid objectId) /* * shdepAddDependency - * Internal workhorse for inserting into pg_shdepend + * Internal workhorse for inserting into pg_shdepend * * sdepRel must be the pg_shdepend relation, already opened and suitably * locked. @@ -762,9 +762,9 @@ shdepAddDependency(Relation sdepRel, Oid classId, Oid objectId, bool nulls[Natts_pg_shdepend]; /* - * Make sure the object doesn't go away while we record the dependency - * on it. DROP routines should lock the object exclusively before they - * check shared dependencies. + * Make sure the object doesn't go away while we record the dependency on + * it. DROP routines should lock the object exclusively before they check + * shared dependencies. */ shdepLockAndCheckObject(refclassId, refobjId); @@ -794,7 +794,7 @@ shdepAddDependency(Relation sdepRel, Oid classId, Oid objectId, /* * shdepDropDependency - * Internal workhorse for deleting entries from pg_shdepend. + * Internal workhorse for deleting entries from pg_shdepend. * * We drop entries having the following properties: * dependent object is the one identified by classId/objectId @@ -810,17 +810,17 @@ shdepDropDependency(Relation sdepRel, Oid classId, Oid objectId, Oid refclassId, Oid refobjId, SharedDependencyType deptype) { - ScanKeyData key[3]; - SysScanDesc scan; + ScanKeyData key[3]; + SysScanDesc scan; HeapTuple tup; /* Scan for entries matching the dependent object */ ScanKeyInit(&key[0], - Anum_pg_shdepend_dbid, + Anum_pg_shdepend_dbid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(classIdGetDbId(classId))); ScanKeyInit(&key[1], - Anum_pg_shdepend_classid, + Anum_pg_shdepend_classid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(classId)); ScanKeyInit(&key[2], @@ -899,8 +899,8 @@ shdepLockAndCheckObject(Oid classId, Oid objectId) LockSharedObject(classId, objectId, 0, AccessShareLock); /* - * We have to recognize sinval updates here, else our local syscache - * may still contain the object even if it was just dropped. + * We have to recognize sinval updates here, else our local syscache may + * still contain the object even if it was just dropped. */ AcceptInvalidationMessages(); @@ -916,25 +916,26 @@ shdepLockAndCheckObject(Oid classId, Oid objectId) objectId))); break; - /* - * Currently, this routine need not support any other shared object - * types besides roles. If we wanted to record explicit dependencies - * on databases or tablespaces, we'd need code along these lines: - */ + /* + * Currently, this routine need not support any other shared + * object types besides roles. If we wanted to record explicit + * dependencies on databases or tablespaces, we'd need code along + * these lines: + */ #ifdef NOT_USED case TableSpaceRelationId: - { - /* For lack of a syscache on pg_tablespace, do this: */ - char *tablespace = get_tablespace_name(objectId); + { + /* For lack of a syscache on pg_tablespace, do this: */ + char *tablespace = get_tablespace_name(objectId); - if (tablespace == NULL) - ereport(ERROR, - (errcode(ERRCODE_UNDEFINED_OBJECT), - errmsg("tablespace %u was concurrently dropped", - objectId))); - pfree(tablespace); - break; - } + if (tablespace == NULL) + ereport(ERROR, + (errcode(ERRCODE_UNDEFINED_OBJECT), + errmsg("tablespace %u was concurrently dropped", + objectId))); + pfree(tablespace); + break; + } #endif default: @@ -963,13 +964,13 @@ storeObjectDescription(StringInfo descs, objectType type, SharedDependencyType deptype, int count) { - char *objdesc = getObjectDescription(object); + char *objdesc = getObjectDescription(object); /* separate entries with a newline */ if (descs->len != 0) appendStringInfoChar(descs, '\n'); - switch (type) + switch (type) { case LOCAL_OBJECT: case SHARED_OBJECT: @@ -1006,16 +1007,16 @@ static bool isSharedObjectPinned(Oid classId, Oid objectId, Relation sdepRel) { bool result = false; - ScanKeyData key[2]; - SysScanDesc scan; + ScanKeyData key[2]; + SysScanDesc scan; HeapTuple tup; ScanKeyInit(&key[0], - Anum_pg_shdepend_refclassid, + Anum_pg_shdepend_refclassid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(classId)); ScanKeyInit(&key[1], - Anum_pg_shdepend_refobjid, + Anum_pg_shdepend_refobjid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(objectId)); @@ -1024,9 +1025,9 @@ isSharedObjectPinned(Oid classId, Oid objectId, Relation sdepRel) /* * Since we won't generate additional pg_shdepend entries for pinned - * objects, there can be at most one entry referencing a pinned - * object. Hence, it's sufficient to look at the first returned - * tuple; we don't need to loop. + * objects, there can be at most one entry referencing a pinned object. + * Hence, it's sufficient to look at the first returned tuple; we don't + * need to loop. */ tup = systable_getnext(scan); if (HeapTupleIsValid(tup)) diff --git a/src/backend/catalog/pg_type.c b/src/backend/catalog/pg_type.c index d84bc2c1ac..ab250b02ea 100644 --- a/src/backend/catalog/pg_type.c +++ b/src/backend/catalog/pg_type.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/catalog/pg_type.c,v 1.103 2005/08/12 01:35:57 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/catalog/pg_type.c,v 1.104 2005/10/15 02:49:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -75,7 +75,7 @@ TypeShellMake(const char *typeName, Oid typeNamespace) namestrcpy(&name, typeName); values[i++] = NameGetDatum(&name); /* typname */ values[i++] = ObjectIdGetDatum(typeNamespace); /* typnamespace */ - values[i++] = ObjectIdGetDatum(GetUserId()); /* typowner */ + values[i++] = ObjectIdGetDatum(GetUserId()); /* typowner */ values[i++] = Int16GetDatum(0); /* typlen */ values[i++] = BoolGetDatum(false); /* typbyval */ values[i++] = CharGetDatum(0); /* typtype */ @@ -180,8 +180,8 @@ TypeCreate(const char *typeName, int i; /* - * We assume that the caller validated the arguments individually, but - * did not check for bad combinations. + * We assume that the caller validated the arguments individually, but did + * not check for bad combinations. * * Validate size specifications: either positive (fixed-length) or -1 * (varlena) or -2 (cstring). Pass-by-value types must have a fixed @@ -198,8 +198,8 @@ TypeCreate(const char *typeName, (internalSize <= 0 || internalSize > (int16) sizeof(Datum))) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("internal size %d is invalid for passed-by-value type", - internalSize))); + errmsg("internal size %d is invalid for passed-by-value type", + internalSize))); /* Only varlena types can be toasted */ if (storage != 'p' && internalSize != -1) @@ -224,7 +224,7 @@ TypeCreate(const char *typeName, namestrcpy(&name, typeName); values[i++] = NameGetDatum(&name); /* typname */ values[i++] = ObjectIdGetDatum(typeNamespace); /* typnamespace */ - values[i++] = ObjectIdGetDatum(GetUserId()); /* typowner */ + values[i++] = ObjectIdGetDatum(GetUserId()); /* typowner */ values[i++] = Int16GetDatum(internalSize); /* typlen */ values[i++] = BoolGetDatum(passedByValue); /* typbyval */ values[i++] = CharGetDatum(typeType); /* typtype */ @@ -245,8 +245,8 @@ TypeCreate(const char *typeName, values[i++] = Int32GetDatum(typNDims); /* typndims */ /* - * initialize the default binary value for this type. Check for nulls - * of course. + * initialize the default binary value for this type. Check for nulls of + * course. */ if (defaultTypeBin) values[i] = DirectFunctionCall1(textin, @@ -260,7 +260,7 @@ TypeCreate(const char *typeName, */ if (defaultTypeValue) values[i] = DirectFunctionCall1(textin, - CStringGetDatum(defaultTypeValue)); + CStringGetDatum(defaultTypeValue)); else nulls[i] = 'n'; i++; /* typdefault */ @@ -356,8 +356,7 @@ TypeCreate(const char *typeName, void GenerateTypeDependencies(Oid typeNamespace, Oid typeObjectId, - Oid relationOid, /* only for 'c'atalog - * types */ + Oid relationOid, /* only for 'c'atalog types */ char relationKind, /* ditto */ Oid owner, Oid inputProcedure, @@ -436,13 +435,12 @@ GenerateTypeDependencies(Oid typeNamespace, /* * If the type is a rowtype for a relation, mark it as internally - * dependent on the relation, *unless* it is a stand-alone composite - * type relation. For the latter case, we have to reverse the - * dependency. + * dependent on the relation, *unless* it is a stand-alone composite type + * relation. For the latter case, we have to reverse the dependency. * * In the former case, this allows the type to be auto-dropped when the - * relation is, and not otherwise. And in the latter, of course we get - * the opposite effect. + * relation is, and not otherwise. And in the latter, of course we get the + * opposite effect. */ if (OidIsValid(relationOid)) { @@ -457,11 +455,10 @@ GenerateTypeDependencies(Oid typeNamespace, } /* - * If the type is an array type, mark it auto-dependent on the base - * type. (This is a compromise between the typical case where the - * array type is automatically generated and the case where it is - * manually created: we'd prefer INTERNAL for the former case and - * NORMAL for the latter.) + * If the type is an array type, mark it auto-dependent on the base type. + * (This is a compromise between the typical case where the array type is + * automatically generated and the case where it is manually created: we'd + * prefer INTERNAL for the former case and NORMAL for the latter.) */ if (OidIsValid(elementType)) { diff --git a/src/backend/commands/aggregatecmds.c b/src/backend/commands/aggregatecmds.c index e3efde249d..160cd8e488 100644 --- a/src/backend/commands/aggregatecmds.c +++ b/src/backend/commands/aggregatecmds.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/aggregatecmds.c,v 1.29 2005/08/22 17:38:20 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/aggregatecmds.c,v 1.30 2005/10/15 02:49:14 momjian Exp $ * * DESCRIPTION * The "DefineFoo" routines take the parse tree and pick out the @@ -72,8 +72,8 @@ DefineAggregate(List *names, List *parameters) DefElem *defel = (DefElem *) lfirst(pl); /* - * sfunc1, stype1, and initcond1 are accepted as obsolete - * spellings for sfunc, stype, initcond. + * sfunc1, stype1, and initcond1 are accepted as obsolete spellings + * for sfunc, stype, initcond. */ if (pg_strcasecmp(defel->defname, "sfunc") == 0) transfuncName = defGetQualifiedName(defel); @@ -119,11 +119,11 @@ DefineAggregate(List *names, List *parameters) /* * look up the aggregate's base type (input datatype) and transtype. * - * We have historically allowed the command to look like basetype = 'ANY' - * so we must do a case-insensitive comparison for the name ANY. Ugh. + * We have historically allowed the command to look like basetype = 'ANY' so + * we must do a case-insensitive comparison for the name ANY. Ugh. * - * basetype can be a pseudo-type, but transtype can't, since we need to - * be able to store values of the transtype. However, we can allow + * basetype can be a pseudo-type, but transtype can't, since we need to be + * able to store values of the transtype. However, we can allow * polymorphic transtype in some cases (AggregateCreate will check). */ if (pg_strcasecmp(TypeNameToString(baseType), "ANY") == 0) @@ -169,11 +169,11 @@ RemoveAggregate(RemoveAggrStmt *stmt) ObjectAddress object; /* - * if a basetype is passed in, then attempt to find an aggregate for - * that specific type. + * if a basetype is passed in, then attempt to find an aggregate for that + * specific type. * - * else attempt to find an aggregate with a basetype of ANYOID. This - * means that the aggregate is to apply to all basetypes (eg, COUNT). + * else attempt to find an aggregate with a basetype of ANYOID. This means + * that the aggregate is to apply to all basetypes (eg, COUNT). */ if (aggType) basetypeID = typenameTypeId(aggType); @@ -193,8 +193,8 @@ RemoveAggregate(RemoveAggrStmt *stmt) /* Permission check: must own agg or its namespace */ if (!pg_proc_ownercheck(procOid, GetUserId()) && - !pg_namespace_ownercheck(((Form_pg_proc) GETSTRUCT(tup))->pronamespace, - GetUserId())) + !pg_namespace_ownercheck(((Form_pg_proc) GETSTRUCT(tup))->pronamespace, + GetUserId())) aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_PROC, NameListToString(aggName)); @@ -225,10 +225,10 @@ RenameAggregate(List *name, TypeName *basetype, const char *newname) AclResult aclresult; /* - * if a basetype is passed in, then attempt to find an aggregate for - * that specific type; else attempt to find an aggregate with a - * basetype of ANYOID. This means that the aggregate applies to all - * basetypes (eg, COUNT). + * if a basetype is passed in, then attempt to find an aggregate for that + * specific type; else attempt to find an aggregate with a basetype of + * ANYOID. This means that the aggregate applies to all basetypes (eg, + * COUNT). */ if (basetype) basetypeOid = typenameTypeId(basetype); @@ -258,16 +258,16 @@ RenameAggregate(List *name, TypeName *basetype, const char *newname) if (basetypeOid == ANYOID) ereport(ERROR, (errcode(ERRCODE_DUPLICATE_FUNCTION), - errmsg("function %s(*) already exists in schema \"%s\"", - newname, - get_namespace_name(namespaceOid)))); + errmsg("function %s(*) already exists in schema \"%s\"", + newname, + get_namespace_name(namespaceOid)))); else ereport(ERROR, (errcode(ERRCODE_DUPLICATE_FUNCTION), errmsg("function %s already exists in schema \"%s\"", funcname_signature_string(newname, procForm->pronargs, - procForm->proargtypes.values), + procForm->proargtypes.values), get_namespace_name(namespaceOid)))); } @@ -305,10 +305,10 @@ AlterAggregateOwner(List *name, TypeName *basetype, Oid newOwnerId) AclResult aclresult; /* - * if a basetype is passed in, then attempt to find an aggregate for - * that specific type; else attempt to find an aggregate with a - * basetype of ANYOID. This means that the aggregate applies to all - * basetypes (eg, COUNT). + * if a basetype is passed in, then attempt to find an aggregate for that + * specific type; else attempt to find an aggregate with a basetype of + * ANYOID. This means that the aggregate applies to all basetypes (eg, + * COUNT). */ if (basetype) basetypeOid = typenameTypeId(basetype); @@ -353,8 +353,7 @@ AlterAggregateOwner(List *name, TypeName *basetype, Oid newOwnerId) } /* - * Modify the owner --- okay to scribble on tup because it's a - * copy + * Modify the owner --- okay to scribble on tup because it's a copy */ procForm->proowner = newOwnerId; diff --git a/src/backend/commands/alter.c b/src/backend/commands/alter.c index 996d70e163..102dafb8a2 100644 --- a/src/backend/commands/alter.c +++ b/src/backend/commands/alter.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/alter.c,v 1.14 2005/08/01 04:03:55 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/alter.c,v 1.15 2005/10/15 02:49:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -102,8 +102,8 @@ ExecRenameStmt(RenameStmt *stmt) { /* * RENAME TABLE requires that we (still) hold - * CREATE rights on the containing namespace, - * as well as ownership of the table. + * CREATE rights on the containing namespace, as + * well as ownership of the table. */ Oid namespaceId = get_rel_namespace(relid); AclResult aclresult; @@ -113,7 +113,7 @@ ExecRenameStmt(RenameStmt *stmt) ACL_CREATE); if (aclresult != ACLCHECK_OK) aclcheck_error(aclresult, ACL_KIND_NAMESPACE, - get_namespace_name(namespaceId)); + get_namespace_name(namespaceId)); renamerel(relid, stmt->newname); break; @@ -122,7 +122,7 @@ ExecRenameStmt(RenameStmt *stmt) renameatt(relid, stmt->subname, /* old att name */ stmt->newname, /* new att name */ - interpretInhOption(stmt->relation->inhOpt), /* recursive? */ + interpretInhOption(stmt->relation->inhOpt), /* recursive? */ false); /* recursing already? */ break; case OBJECT_TRIGGER: @@ -156,18 +156,18 @@ ExecAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt) AlterFunctionNamespace(stmt->object, stmt->objarg, stmt->newschema); break; - + case OBJECT_SEQUENCE: case OBJECT_TABLE: CheckRelationOwnership(stmt->relation, true); AlterTableNamespace(stmt->relation, stmt->newschema); break; - + case OBJECT_TYPE: case OBJECT_DOMAIN: AlterTypeNamespace(stmt->object, stmt->newschema); break; - + default: elog(ERROR, "unrecognized AlterObjectSchemaStmt type: %d", (int) stmt->objectType); @@ -181,7 +181,7 @@ ExecAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt) void ExecAlterOwnerStmt(AlterOwnerStmt *stmt) { - Oid newowner = get_roleid_checked(stmt->newowner); + Oid newowner = get_roleid_checked(stmt->newowner); switch (stmt->objectType) { diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c index bd32c8c841..431e39f3b0 100644 --- a/src/backend/commands/analyze.c +++ b/src/backend/commands/analyze.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/analyze.c,v 1.88 2005/07/29 19:30:03 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/analyze.c,v 1.89 2005/10/15 02:49:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -119,9 +119,9 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt) elevel = DEBUG2; /* - * Use the current context for storing analysis info. vacuum.c - * ensures that this context will be cleared when I return, thus - * releasing the memory allocated here. + * Use the current context for storing analysis info. vacuum.c ensures + * that this context will be cleared when I return, thus releasing the + * memory allocated here. */ anl_context = CurrentMemoryContext; @@ -132,8 +132,8 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt) CHECK_FOR_INTERRUPTS(); /* - * Race condition -- if the pg_class tuple has gone away since the - * last time we saw it, we don't need to process it. + * Race condition -- if the pg_class tuple has gone away since the last + * time we saw it, we don't need to process it. */ if (!SearchSysCacheExists(RELOID, ObjectIdGetDatum(relid), @@ -141,8 +141,8 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt) return; /* - * Open the class, getting only a read lock on it, and check - * permissions. Permissions check should match vacuum's check! + * Open the class, getting only a read lock on it, and check permissions. + * Permissions check should match vacuum's check! */ onerel = relation_open(relid, AccessShareLock); @@ -159,8 +159,8 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt) } /* - * Check that it's a plain table; we used to do this in get_rel_oids() - * but seems safer to check after we've locked the relation. + * Check that it's a plain table; we used to do this in get_rel_oids() but + * seems safer to check after we've locked the relation. */ if (onerel->rd_rel->relkind != RELKIND_RELATION) { @@ -175,10 +175,9 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt) /* * Silently ignore tables that are temp tables of other backends --- - * trying to analyze these is rather pointless, since their contents - * are probably not up-to-date on disk. (We don't throw a warning - * here; it would just lead to chatter during a database-wide - * ANALYZE.) + * trying to analyze these is rather pointless, since their contents are + * probably not up-to-date on disk. (We don't throw a warning here; it + * would just lead to chatter during a database-wide ANALYZE.) */ if (isOtherTempNamespace(RelationGetNamespace(onerel))) { @@ -239,10 +238,9 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt) } /* - * Open all indexes of the relation, and see if there are any - * analyzable columns in the indexes. We do not analyze index columns - * if there was an explicit column list in the ANALYZE command, - * however. + * Open all indexes of the relation, and see if there are any analyzable + * columns in the indexes. We do not analyze index columns if there was + * an explicit column list in the ANALYZE command, however. */ vac_open_indexes(onerel, AccessShareLock, &nindexes, &Irel); hasindex = (nindexes > 0); @@ -280,13 +278,12 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt) indexpr_item = lnext(indexpr_item); /* - * Can't analyze if the opclass uses a storage - * type different from the expression result type. - * We'd get confused because the type shown in - * pg_attribute for the index column doesn't match - * what we are getting from the expression. - * Perhaps this can be fixed someday, but for now, - * punt. + * Can't analyze if the opclass uses a storage type + * different from the expression result type. We'd get + * confused because the type shown in pg_attribute for + * the index column doesn't match what we are getting + * from the expression. Perhaps this can be fixed + * someday, but for now, punt. */ if (exprType(indexkey) != Irel[ind]->rd_att->attrs[i]->atttypid) @@ -313,13 +310,13 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt) { /* * We report that the table is empty; this is just so that the - * autovacuum code doesn't go nuts trying to get stats about - * a zero-column table. + * autovacuum code doesn't go nuts trying to get stats about a + * zero-column table. */ if (!vacstmt->vacuum) pgstat_report_analyze(RelationGetRelid(onerel), onerel->rd_rel->relisshared, - 0, 0); + 0, 0); vac_close_indexes(nindexes, Irel, AccessShareLock); relation_close(onerel, AccessShareLock); @@ -327,9 +324,9 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt) } /* - * Determine how many rows we need to sample, using the worst case - * from all analyzable columns. We use a lower bound of 100 rows to - * avoid possible overflow in Vitter's algorithm. + * Determine how many rows we need to sample, using the worst case from + * all analyzable columns. We use a lower bound of 100 rows to avoid + * possible overflow in Vitter's algorithm. */ targrows = 100; for (i = 0; i < attr_cnt; i++) @@ -356,10 +353,10 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt) &totalrows, &totaldeadrows); /* - * Compute the statistics. Temporary results during the calculations - * for each column are stored in a child context. The calc routines - * are responsible to make sure that whatever they store into the - * VacAttrStats structure is allocated in anl_context. + * Compute the statistics. Temporary results during the calculations for + * each column are stored in a child context. The calc routines are + * responsible to make sure that whatever they store into the VacAttrStats + * structure is allocated in anl_context. */ if (numrows > 0) { @@ -397,9 +394,8 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt) /* * Emit the completed stats rows into pg_statistic, replacing any - * previous statistics for the target columns. (If there are - * stats in pg_statistic for columns we didn't process, we leave - * them alone.) + * previous statistics for the target columns. (If there are stats in + * pg_statistic for columns we didn't process, we leave them alone.) */ update_attstats(relid, attr_cnt, vacattrstats); @@ -413,11 +409,11 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt) } /* - * If we are running a standalone ANALYZE, update pages/tuples stats - * in pg_class. We know the accurate page count from the smgr, but - * only an approximate number of tuples; therefore, if we are part of - * VACUUM ANALYZE do *not* overwrite the accurate count already - * inserted by VACUUM. The same consideration applies to indexes. + * If we are running a standalone ANALYZE, update pages/tuples stats in + * pg_class. We know the accurate page count from the smgr, but only an + * approximate number of tuples; therefore, if we are part of VACUUM + * ANALYZE do *not* overwrite the accurate count already inserted by + * VACUUM. The same consideration applies to indexes. */ if (!vacstmt->vacuum) { @@ -440,7 +436,7 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt) /* report results to the stats collector, too */ pgstat_report_analyze(RelationGetRelid(onerel), onerel->rd_rel->relisshared, - totalrows, totaldeadrows); + totalrows, totaldeadrows); } /* Done with indexes */ @@ -448,8 +444,8 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt) /* * Close source relation now, but keep lock so that no one deletes it - * before we commit. (If someone did, they'd fail to clean up the - * entries we made in pg_statistic.) + * before we commit. (If someone did, they'd fail to clean up the entries + * we made in pg_statistic.) */ relation_close(onerel, NoLock); } @@ -499,8 +495,8 @@ compute_index_stats(Relation onerel, double totalrows, /* * Need an EState for evaluation of index expressions and - * partial-index predicates. Create it in the per-index context - * to be sure it gets cleaned up at the bottom of the loop. + * partial-index predicates. Create it in the per-index context to be + * sure it gets cleaned up at the bottom of the loop. */ estate = CreateExecutorState(); econtext = GetPerTupleExprContext(estate); @@ -539,8 +535,7 @@ compute_index_stats(Relation onerel, double totalrows, { /* * Evaluate the index row to compute expression values. We - * could do this by hand, but FormIndexDatum is - * convenient. + * could do this by hand, but FormIndexDatum is convenient. */ FormIndexDatum(indexInfo, slot, @@ -564,9 +559,8 @@ compute_index_stats(Relation onerel, double totalrows, } /* - * Having counted the number of rows that pass the predicate in - * the sample, we can estimate the total number of rows in the - * index. + * Having counted the number of rows that pass the predicate in the + * sample, we can estimate the total number of rows in the index. */ thisdata->tupleFract = (double) numindexrows / (double) numrows; totalindexrows = ceil(thisdata->tupleFract * totalrows); @@ -644,8 +638,8 @@ examine_attribute(Relation onerel, int attnum) stats->tupattnum = attnum; /* - * Call the type-specific typanalyze function. If none is specified, - * use std_typanalyze(). + * Call the type-specific typanalyze function. If none is specified, use + * std_typanalyze(). */ if (OidIsValid(stats->attrtype->typanalyze)) ok = DatumGetBool(OidFunctionCall1(stats->attrtype->typanalyze, @@ -683,8 +677,8 @@ BlockSampler_Init(BlockSampler bs, BlockNumber nblocks, int samplesize) bs->N = nblocks; /* measured table size */ /* - * If we decide to reduce samplesize for tables that have less or not - * much more than samplesize blocks, here is the place to do it. + * If we decide to reduce samplesize for tables that have less or not much + * more than samplesize blocks, here is the place to do it. */ bs->n = samplesize; bs->t = 0; /* blocks scanned so far */ @@ -815,12 +809,11 @@ acquire_sample_rows(Relation onerel, HeapTuple *rows, int targrows, vacuum_delay_point(); /* - * We must maintain a pin on the target page's buffer to ensure - * that the maxoffset value stays good (else concurrent VACUUM - * might delete tuples out from under us). Hence, pin the page - * until we are done looking at it. We don't maintain a lock on - * the page, so tuples could get added to it, but we ignore such - * tuples. + * We must maintain a pin on the target page's buffer to ensure that + * the maxoffset value stays good (else concurrent VACUUM might delete + * tuples out from under us). Hence, pin the page until we are done + * looking at it. We don't maintain a lock on the page, so tuples + * could get added to it, but we ignore such tuples. */ targbuffer = ReadBuffer(onerel, targblock); LockBuffer(targbuffer, BUFFER_LOCK_SHARE); @@ -842,24 +835,24 @@ acquire_sample_rows(Relation onerel, HeapTuple *rows, int targrows, /* * The first targrows live rows are simply copied into the * reservoir. Then we start replacing tuples in the sample - * until we reach the end of the relation. This algorithm - * is from Jeff Vitter's paper (see full citation below). - * It works by repeatedly computing the number of tuples - * to skip before selecting a tuple, which replaces a - * randomly chosen element of the reservoir (current set - * of tuples). At all times the reservoir is a true - * random sample of the tuples we've passed over so far, - * so when we fall off the end of the relation we're done. + * until we reach the end of the relation. This algorithm is + * from Jeff Vitter's paper (see full citation below). It + * works by repeatedly computing the number of tuples to skip + * before selecting a tuple, which replaces a randomly chosen + * element of the reservoir (current set of tuples). At all + * times the reservoir is a true random sample of the tuples + * we've passed over so far, so when we fall off the end of + * the relation we're done. */ if (numrows < targrows) rows[numrows++] = heap_copytuple(&targtuple); else { /* - * t in Vitter's paper is the number of records - * already processed. If we need to compute a new S - * value, we must use the not-yet-incremented value of - * liverows as t. + * t in Vitter's paper is the number of records already + * processed. If we need to compute a new S value, we + * must use the not-yet-incremented value of liverows as + * t. */ if (rowstoskip < 0) rowstoskip = get_next_S(liverows, targrows, &rstate); @@ -867,8 +860,8 @@ acquire_sample_rows(Relation onerel, HeapTuple *rows, int targrows, if (rowstoskip <= 0) { /* - * Found a suitable tuple, so save it, replacing - * one old tuple at random + * Found a suitable tuple, so save it, replacing one + * old tuple at random */ int k = (int) (targrows * random_fract()); @@ -895,12 +888,12 @@ acquire_sample_rows(Relation onerel, HeapTuple *rows, int targrows, } /* - * If we didn't find as many tuples as we wanted then we're done. No - * sort is needed, since they're already in order. + * If we didn't find as many tuples as we wanted then we're done. No sort + * is needed, since they're already in order. * - * Otherwise we need to sort the collected tuples by position - * (itempointer). It's not worth worrying about corner cases where - * the tuples are already sorted. + * Otherwise we need to sort the collected tuples by position (itempointer). + * It's not worth worrying about corner cases where the tuples are already + * sorted. */ if (numrows == targrows) qsort((void *) rows, numrows, sizeof(HeapTuple), compare_rows); @@ -1455,8 +1448,7 @@ compute_minimal_stats(VacAttrStatsP stats, StdAnalyzeData *mystats = (StdAnalyzeData *) stats->extra_data; /* - * We track up to 2*n values for an n-element MCV list; but at least - * 10 + * We track up to 2*n values for an n-element MCV list; but at least 10 */ track_max = 2 * num_mcv; if (track_max < 10) @@ -1488,9 +1480,9 @@ compute_minimal_stats(VacAttrStatsP stats, /* * If it's a variable-width field, add up widths for average width - * calculation. Note that if the value is toasted, we use the - * toasted width. We don't bother with this calculation if it's a - * fixed-width type. + * calculation. Note that if the value is toasted, we use the toasted + * width. We don't bother with this calculation if it's a fixed-width + * type. */ if (is_varlena) { @@ -1498,10 +1490,10 @@ compute_minimal_stats(VacAttrStatsP stats, /* * If the value is toasted, we want to detoast it just once to - * avoid repeated detoastings and resultant excess memory - * usage during the comparisons. Also, check to see if the - * value is excessively wide, and if so don't detoast at all - * --- just ignore the value. + * avoid repeated detoastings and resultant excess memory usage + * during the comparisons. Also, check to see if the value is + * excessively wide, and if so don't detoast at all --- just + * ignore the value. */ if (toast_raw_datum_size(value) > WIDTH_THRESHOLD) { @@ -1594,9 +1586,9 @@ compute_minimal_stats(VacAttrStatsP stats, nmultiple == track_cnt) { /* - * Our track list includes every value in the sample, and - * every value appeared more than once. Assume the column has - * just these values. + * Our track list includes every value in the sample, and every + * value appeared more than once. Assume the column has just + * these values. */ stats->stadistinct = track_cnt; } @@ -1641,22 +1633,22 @@ compute_minimal_stats(VacAttrStatsP stats, } /* - * If we estimated the number of distinct values at more than 10% - * of the total row count (a very arbitrary limit), then assume - * that stadistinct should scale with the row count rather than be - * a fixed value. + * If we estimated the number of distinct values at more than 10% of + * the total row count (a very arbitrary limit), then assume that + * stadistinct should scale with the row count rather than be a fixed + * value. */ if (stats->stadistinct > 0.1 * totalrows) stats->stadistinct = -(stats->stadistinct / totalrows); /* - * Decide how many values are worth storing as most-common values. - * If we are able to generate a complete MCV list (all the values - * in the sample will fit, and we think these are all the ones in - * the table), then do so. Otherwise, store only those values - * that are significantly more common than the (estimated) - * average. We set the threshold rather arbitrarily at 25% more - * than average, with at least 2 instances in the sample. + * Decide how many values are worth storing as most-common values. If + * we are able to generate a complete MCV list (all the values in the + * sample will fit, and we think these are all the ones in the table), + * then do so. Otherwise, store only those values that are + * significantly more common than the (estimated) average. We set the + * threshold rather arbitrarily at 25% more than average, with at + * least 2 instances in the sample. */ if (track_cnt < track_max && toowide_cnt == 0 && stats->stadistinct > 0 && @@ -1725,10 +1717,10 @@ compute_minimal_stats(VacAttrStatsP stats, stats->stats_valid = true; stats->stanullfrac = 1.0; if (is_varwidth) - stats->stawidth = 0; /* "unknown" */ + stats->stawidth = 0; /* "unknown" */ else stats->stawidth = stats->attrtype->typlen; - stats->stadistinct = 0.0; /* "unknown" */ + stats->stadistinct = 0.0; /* "unknown" */ } /* We don't need to bother cleaning up any of our temporary palloc's */ @@ -1802,9 +1794,9 @@ compute_scalar_stats(VacAttrStatsP stats, /* * If it's a variable-width field, add up widths for average width - * calculation. Note that if the value is toasted, we use the - * toasted width. We don't bother with this calculation if it's a - * fixed-width type. + * calculation. Note that if the value is toasted, we use the toasted + * width. We don't bother with this calculation if it's a fixed-width + * type. */ if (is_varlena) { @@ -1812,10 +1804,10 @@ compute_scalar_stats(VacAttrStatsP stats, /* * If the value is toasted, we want to detoast it just once to - * avoid repeated detoastings and resultant excess memory - * usage during the comparisons. Also, check to see if the - * value is excessively wide, and if so don't detoast at all - * --- just ignore the value. + * avoid repeated detoastings and resultant excess memory usage + * during the comparisons. Also, check to see if the value is + * excessively wide, and if so don't detoast at all --- just + * ignore the value. */ if (toast_raw_datum_size(value) > WIDTH_THRESHOLD) { @@ -1854,24 +1846,23 @@ compute_scalar_stats(VacAttrStatsP stats, sizeof(ScalarItem), compare_scalars); /* - * Now scan the values in order, find the most common ones, and - * also accumulate ordering-correlation statistics. + * Now scan the values in order, find the most common ones, and also + * accumulate ordering-correlation statistics. * - * To determine which are most common, we first have to count the - * number of duplicates of each value. The duplicates are - * adjacent in the sorted list, so a brute-force approach is to - * compare successive datum values until we find two that are not - * equal. However, that requires N-1 invocations of the datum - * comparison routine, which are completely redundant with work - * that was done during the sort. (The sort algorithm must at - * some point have compared each pair of items that are adjacent - * in the sorted order; otherwise it could not know that it's - * ordered the pair correctly.) We exploit this by having + * To determine which are most common, we first have to count the number + * of duplicates of each value. The duplicates are adjacent in the + * sorted list, so a brute-force approach is to compare successive + * datum values until we find two that are not equal. However, that + * requires N-1 invocations of the datum comparison routine, which are + * completely redundant with work that was done during the sort. (The + * sort algorithm must at some point have compared each pair of items + * that are adjacent in the sorted order; otherwise it could not know + * that it's ordered the pair correctly.) We exploit this by having * compare_scalars remember the highest tupno index that each * ScalarItem has been found equal to. At the end of the sort, a - * ScalarItem's tupnoLink will still point to itself if and only - * if it is the last item of its group of duplicates (since the - * group will be ordered by tupno). + * ScalarItem's tupnoLink will still point to itself if and only if it + * is the last item of its group of duplicates (since the group will + * be ordered by tupno). */ corr_xysum = 0; ndistinct = 0; @@ -1895,9 +1886,9 @@ compute_scalar_stats(VacAttrStatsP stats, { /* * Found a new item for the mcv list; find its - * position, bubbling down old items if needed. - * Loop invariant is that j points at an empty/ - * replaceable slot. + * position, bubbling down old items if needed. Loop + * invariant is that j points at an empty/ replaceable + * slot. */ int j; @@ -1934,8 +1925,8 @@ compute_scalar_stats(VacAttrStatsP stats, else if (toowide_cnt == 0 && nmultiple == ndistinct) { /* - * Every value in the sample appeared more than once. Assume - * the column has just these values. + * Every value in the sample appeared more than once. Assume the + * column has just these values. */ stats->stadistinct = ndistinct; } @@ -1976,26 +1967,25 @@ compute_scalar_stats(VacAttrStatsP stats, } /* - * If we estimated the number of distinct values at more than 10% - * of the total row count (a very arbitrary limit), then assume - * that stadistinct should scale with the row count rather than be - * a fixed value. + * If we estimated the number of distinct values at more than 10% of + * the total row count (a very arbitrary limit), then assume that + * stadistinct should scale with the row count rather than be a fixed + * value. */ if (stats->stadistinct > 0.1 * totalrows) stats->stadistinct = -(stats->stadistinct / totalrows); /* - * Decide how many values are worth storing as most-common values. - * If we are able to generate a complete MCV list (all the values - * in the sample will fit, and we think these are all the ones in - * the table), then do so. Otherwise, store only those values - * that are significantly more common than the (estimated) - * average. We set the threshold rather arbitrarily at 25% more - * than average, with at least 2 instances in the sample. Also, - * we won't suppress values that have a frequency of at least 1/K - * where K is the intended number of histogram bins; such values - * might otherwise cause us to emit duplicate histogram bin - * boundaries. + * Decide how many values are worth storing as most-common values. If + * we are able to generate a complete MCV list (all the values in the + * sample will fit, and we think these are all the ones in the table), + * then do so. Otherwise, store only those values that are + * significantly more common than the (estimated) average. We set the + * threshold rather arbitrarily at 25% more than average, with at + * least 2 instances in the sample. Also, we won't suppress values + * that have a frequency of at least 1/K where K is the intended + * number of histogram bins; such values might otherwise cause us to + * emit duplicate histogram bin boundaries. */ if (track_cnt == ndistinct && toowide_cnt == 0 && stats->stadistinct > 0 && @@ -2065,9 +2055,9 @@ compute_scalar_stats(VacAttrStatsP stats, } /* - * Generate a histogram slot entry if there are at least two - * distinct values not accounted for in the MCV list. (This - * ensures the histogram won't collapse to empty or a singleton.) + * Generate a histogram slot entry if there are at least two distinct + * values not accounted for in the MCV list. (This ensures the + * histogram won't collapse to empty or a singleton.) */ num_hist = ndistinct - num_mcv; if (num_hist > num_bins) @@ -2085,10 +2075,9 @@ compute_scalar_stats(VacAttrStatsP stats, /* * Collapse out the MCV items from the values[] array. * - * Note we destroy the values[] array here... but we don't need - * it for anything more. We do, however, still need - * values_cnt. nvals will be the number of remaining entries - * in values[]. + * Note we destroy the values[] array here... but we don't need it + * for anything more. We do, however, still need values_cnt. + * nvals will be the number of remaining entries in values[]. */ if (num_mcv > 0) { @@ -2193,10 +2182,10 @@ compute_scalar_stats(VacAttrStatsP stats, stats->stats_valid = true; stats->stanullfrac = 1.0; if (is_varwidth) - stats->stawidth = 0; /* "unknown" */ + stats->stawidth = 0; /* "unknown" */ else stats->stawidth = stats->attrtype->typlen; - stats->stadistinct = 0.0; /* "unknown" */ + stats->stadistinct = 0.0; /* "unknown" */ } /* We don't need to bother cleaning up any of our temporary palloc's */ diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c index da13378896..69d97d0923 100644 --- a/src/backend/commands/async.c +++ b/src/backend/commands/async.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/async.c,v 1.125 2005/10/06 21:30:32 neilc Exp $ + * $PostgreSQL: pgsql/src/backend/commands/async.c,v 1.126 2005/10/15 02:49:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -106,8 +106,7 @@ */ static List *pendingNotifies = NIL; -static List *upperPendingNotifies = NIL; /* list of upper-xact - * lists */ +static List *upperPendingNotifies = NIL; /* list of upper-xact lists */ /* * State for inbound notifies consists of two flags: one saying whether @@ -158,8 +157,8 @@ Async_Notify(const char *relname) if (!AsyncExistsPendingNotify(relname)) { /* - * The name list needs to live until end of transaction, so store - * it in the transaction context. + * The name list needs to live until end of transaction, so store it + * in the transaction context. */ MemoryContext oldcontext; @@ -208,7 +207,7 @@ Async_Listen(const char *relname) Form_pg_listener listener = (Form_pg_listener) GETSTRUCT(tuple); if (listener->listenerpid == MyProcPid && - strncmp(NameStr(listener->relname), relname, NAMEDATALEN) == 0) + strncmp(NameStr(listener->relname), relname, NAMEDATALEN) == 0) { alreadyListener = true; /* No need to scan the rest of the table */ @@ -298,14 +297,14 @@ Async_Unlisten(const char *relname) Form_pg_listener listener = (Form_pg_listener) GETSTRUCT(tuple); if (listener->listenerpid == MyProcPid && - strncmp(NameStr(listener->relname), relname, NAMEDATALEN) == 0) + strncmp(NameStr(listener->relname), relname, NAMEDATALEN) == 0) { /* Found the matching tuple, delete it */ simple_heap_delete(lRel, &tuple->t_self); /* - * We assume there can be only one match, so no need to scan - * the rest of the table + * We assume there can be only one match, so no need to scan the + * rest of the table */ break; } @@ -387,10 +386,10 @@ static void Async_UnlistenOnExit(int code, Datum arg) { /* - * 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 */ @@ -404,14 +403,14 @@ Async_UnlistenOnExit(int code, Datum arg) *-------------------------------------------------------------- * AtPrepare_Notify * - * This is called at the prepare phase of a two-phase + * This is called at the prepare phase of a two-phase * transaction. Save the state for possible commit later. *-------------------------------------------------------------- */ void AtPrepare_Notify(void) { - ListCell *p; + ListCell *p; foreach(p, pendingNotifies) { @@ -423,8 +422,8 @@ AtPrepare_Notify(void) /* * We can clear the state immediately, rather than needing a separate - * PostPrepare call, because if the transaction fails we'd just - * discard the state anyway. + * PostPrepare call, because if the transaction fails we'd just discard + * the state anyway. */ ClearPendingNotifies(); } @@ -464,12 +463,11 @@ AtCommit_Notify(void) nulls[Natts_pg_listener]; if (pendingNotifies == NIL) - 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()) { @@ -503,10 +501,10 @@ AtCommit_Notify(void) if (listenerPID == MyProcPid) { /* - * 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. + * 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. */ if (Trace_notify) @@ -521,27 +519,27 @@ AtCommit_Notify(void) 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. */ if (kill(listenerPID, SIGUSR2) < 0) { /* - * 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...) + * 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...) */ simple_heap_delete(lRel, &lTuple->t_self); } else if (listener->notification == 0) { - HTSU_Result result; + HTSU_Result result; ItemPointerData update_ctid; TransactionId update_xmax; @@ -551,17 +549,16 @@ AtCommit_Notify(void) /* * We cannot use simple_heap_update here because the tuple * could have been modified by an uncommitted transaction; - * specifically, since UNLISTEN releases exclusive lock on - * the table before commit, the other guy could already - * have tried to unlisten. There are no other cases where - * we should be able to see an uncommitted update or - * delete. Therefore, our response to a - * HeapTupleBeingUpdated result is just to ignore it. We - * do *not* wait for the other guy to commit --- that - * would risk deadlock, and we don't want to block while - * holding the table lock anyway for performance reasons. - * We also ignore HeapTupleUpdated, which could occur if - * the other guy commits between our heap_getnext and + * specifically, since UNLISTEN releases exclusive lock on the + * table before commit, the other guy could already have tried + * to unlisten. There are no other cases where we should be + * able to see an uncommitted update or delete. Therefore, our + * response to a HeapTupleBeingUpdated result is just to + * ignore it. We do *not* wait for the other guy to commit + * --- that would risk deadlock, and we don't want to block + * while holding the table lock anyway for performance + * reasons. We also ignore HeapTupleUpdated, which could occur + * if the other guy commits between our heap_getnext and * heap_update calls. */ result = heap_update(lRel, &lTuple->t_self, rTuple, @@ -603,10 +600,10 @@ AtCommit_Notify(void) /* * We do NOT release the lock on pg_listener here; we need to hold it - * until end of transaction (which is about to happen, anyway) to - * ensure that notified backends see our tuple updates when they look. - * Else they might disregard the signal, which would make the - * application programmer very unhappy. + * until end of transaction (which is about to happen, anyway) to ensure + * that notified backends see our tuple updates when they look. Else they + * might disregard the signal, which would make the application programmer + * very unhappy. */ heap_close(lRel, NoLock); @@ -676,8 +673,7 @@ AtSubCommit_Notify(void) GetCurrentTransactionNestLevel() - 2); /* - * We could try to eliminate duplicates here, but it seems not - * worthwhile. + * We could try to eliminate duplicates here, but it seems not worthwhile. */ pendingNotifies = list_concat(parentPendingNotifies, pendingNotifies); } @@ -695,10 +691,10 @@ AtSubAbort_Notify(void) * subxact are no longer interesting, and the space will be freed when * CurTransactionContext is recycled. * - * This routine could be called more than once at a given nesting level - * if there is trouble during subxact abort. Avoid dumping core by - * using GetCurrentTransactionNestLevel as the indicator of how far - * we need to prune the list. + * This routine could be called more than once at a given nesting level if + * there is trouble during subxact abort. Avoid dumping core by using + * GetCurrentTransactionNestLevel as the indicator of how far we need to + * prune the list. */ while (list_length(upperPendingNotifies) > my_level - 2) { @@ -731,9 +727,9 @@ NotifyInterruptHandler(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. + * 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. */ /* Don't joggle the elbow of proc_exit */ @@ -745,19 +741,18 @@ NotifyInterruptHandler(SIGNAL_ARGS) bool save_ImmediateInterruptOK = ImmediateInterruptOK; /* - * We may be called while ImmediateInterruptOK is true; turn it - * off while messing with the NOTIFY state. (We would have to - * save and restore it anyway, because PGSemaphore operations - * inside ProcessIncomingNotify() might reset it.) + * We may be called while ImmediateInterruptOK is true; turn it off + * while messing with the NOTIFY state. (We would have to save and + * restore it anyway, because PGSemaphore operations inside + * ProcessIncomingNotify() might reset it.) */ ImmediateInterruptOK = false; /* * 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. + * 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 */ @@ -781,8 +776,7 @@ NotifyInterruptHandler(SIGNAL_ARGS) } /* - * Restore ImmediateInterruptOK, and check for interrupts if - * needed. + * Restore ImmediateInterruptOK, and check for interrupts if needed. */ ImmediateInterruptOK = save_ImmediateInterruptOK; if (save_ImmediateInterruptOK) @@ -791,8 +785,7 @@ NotifyInterruptHandler(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; } @@ -820,27 +813,25 @@ EnableNotifyInterrupt(void) return; /* not really idle */ /* - * This code is tricky because we are communicating with a signal - * handler that could interrupt us at any point. If we just checked - * 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 - * unserviced interrupt. + * This code is tricky because we are communicating with a signal handler + * that could interrupt us at any point. If we just checked + * 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 unserviced + * interrupt. * - * NB: an overenthusiastic optimizing compiler could easily break this - * code. Hopefully, they all understand what "volatile" means these - * days. + * NB: an overenthusiastic optimizing compiler could easily break this code. + * Hopefully, they all understand what "volatile" means these days. */ for (;;) { @@ -960,8 +951,7 @@ ProcessIncomingNotify(void) * Rewrite the tuple with 0 in notification column. * * simple_heap_update is safe here because no one else would have - * tried to UNLISTEN us, so there can be no uncommitted - * changes. + * tried to UNLISTEN us, so there can be no uncommitted changes. */ rTuple = heap_modifytuple(lTuple, tdesc, value, nulls, repl); simple_heap_update(lRel, &lTuple->t_self, rTuple); @@ -975,18 +965,17 @@ ProcessIncomingNotify(void) /* * We do NOT release the lock on pg_listener here; we need to hold it - * until end of transaction (which is about to happen, anyway) to - * ensure that other backends see our tuple updates when they look. - * Otherwise, a transaction started after this one might mistakenly - * think it doesn't need to send this backend a new NOTIFY. + * until end of transaction (which is about to happen, anyway) to ensure + * that other backends see our tuple updates when they look. Otherwise, a + * transaction started after this one might mistakenly think it doesn't + * need to send this backend a new NOTIFY. */ heap_close(lRel, NoLock); 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(); @@ -1022,8 +1011,7 @@ NotifyMyFrontEnd(char *relname, int32 listenerPID) /* * 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 @@ -1052,11 +1040,11 @@ static void ClearPendingNotifies(void) { /* - * We used to have to explicitly deallocate the list members and - * nodes, because they were malloc'd. Now, since we know they are - * palloc'd in CurTransactionContext, we need not do that --- they'll - * go away automatically at transaction exit. We need only reset the - * list head pointer. + * We used to have to explicitly deallocate the list members and nodes, + * because they were malloc'd. Now, since we know they are palloc'd in + * CurTransactionContext, we need not do that --- they'll go away + * automatically at transaction exit. We need only reset the list head + * pointer. */ pendingNotifies = NIL; } @@ -1071,11 +1059,10 @@ notify_twophase_postcommit(TransactionId xid, uint16 info, void *recdata, uint32 len) { /* - * Set up to issue the NOTIFY at the end of my own - * current transaction. (XXX this has some issues if my own - * transaction later rolls back, or if there is any significant - * delay before I commit. OK for now because we disallow - * COMMIT PREPARED inside a transaction block.) + * Set up to issue the NOTIFY at the end of my own current transaction. + * (XXX this has some issues if my own transaction later rolls back, or if + * there is any significant delay before I commit. OK for now because we + * disallow COMMIT PREPARED inside a transaction block.) */ Async_Notify((char *) recdata); } diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c index 1d5a916c54..35420a87c0 100644 --- a/src/backend/commands/cluster.c +++ b/src/backend/commands/cluster.c @@ -11,7 +11,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.139 2005/08/26 03:07:16 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.140 2005/10/15 02:49:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -144,8 +144,8 @@ cluster(ClusterStmt *stmt) if (!OidIsValid(indexOid)) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), - errmsg("index \"%s\" for table \"%s\" does not exist", - stmt->indexname, stmt->relation->relname))); + errmsg("index \"%s\" for table \"%s\" does not exist", + stmt->indexname, stmt->relation->relname))); } /* All other checks are done in cluster_rel() */ @@ -161,24 +161,24 @@ cluster(ClusterStmt *stmt) else { /* - * This is the "multi relation" case. We need to cluster all - * tables that have some index with indisclustered set. + * This is the "multi relation" case. We need to cluster all tables + * that have some index with indisclustered set. */ MemoryContext cluster_context; List *rvs; ListCell *rv; /* - * We cannot run this form of CLUSTER inside a user transaction - * block; we'd be holding locks way too long. + * We cannot run this form of CLUSTER inside a user transaction block; + * we'd be holding locks way too long. */ PreventTransactionChain((void *) stmt, "CLUSTER"); /* * Create special memory context for cross-transaction storage. * - * Since it is a child of PortalContext, it will go away even in case - * of error. + * Since it is a child of PortalContext, it will go away even in case of + * error. */ cluster_context = AllocSetContextCreate(PortalContext, "Cluster", @@ -187,8 +187,8 @@ cluster(ClusterStmt *stmt) ALLOCSET_DEFAULT_MAXSIZE); /* - * Build the list of relations to cluster. Note that this lives - * in cluster_context. + * Build the list of relations to cluster. Note that this lives in + * cluster_context. */ rvs = get_tables_to_cluster(cluster_context); @@ -239,12 +239,12 @@ cluster_rel(RelToCluster *rvtc, bool recheck) CHECK_FOR_INTERRUPTS(); /* - * Since we may open a new transaction for each relation, we have to - * check that the relation still is what we think it is. + * Since we may open a new transaction for each relation, we have to check + * that the relation still is what we think it is. * - * If this is a single-transaction CLUSTER, we can skip these tests. We - * *must* skip the one on indisclustered since it would reject an - * attempt to cluster a not-previously-clustered index. + * If this is a single-transaction CLUSTER, we can skip these tests. We *must* + * skip the one on indisclustered since it would reject an attempt to + * cluster a not-previously-clustered index. */ if (recheck) { @@ -284,10 +284,10 @@ cluster_rel(RelToCluster *rvtc, bool recheck) } /* - * We grab exclusive access to the target rel and index for the - * duration of the transaction. (This is redundant for the single- - * transaction case, since cluster() already did it.) The index lock - * is taken inside check_index_is_clusterable. + * We grab exclusive access to the target rel and index for the duration + * of the transaction. (This is redundant for the single- transaction + * case, since cluster() already did it.) The index lock is taken inside + * check_index_is_clusterable. */ OldHeap = heap_open(rvtc->tableOid, AccessExclusiveLock); @@ -328,26 +328,26 @@ check_index_is_clusterable(Relation OldHeap, Oid indexOid, bool recheck) RelationGetRelationName(OldHeap)))); /* - * Disallow clustering on incomplete indexes (those that might not - * index every row of the relation). We could relax this by making a - * separate seqscan pass over the table to copy the missing rows, but - * that seems expensive and tedious. + * Disallow clustering on incomplete indexes (those that might not index + * every row of the relation). We could relax this by making a separate + * seqscan pass over the table to copy the missing rows, but that seems + * expensive and tedious. */ if (!heap_attisnull(OldIndex->rd_indextuple, Anum_pg_index_indpred)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("cannot cluster on partial index \"%s\"", RelationGetRelationName(OldIndex)))); - + if (!OldIndex->rd_am->amindexnulls) { AttrNumber colno; /* - * If the AM doesn't index nulls, then it's a partial index unless - * we can prove all the rows are non-null. Note we only need look - * at the first column; multicolumn-capable AMs are *required* to - * index nulls in columns after the first. + * If the AM doesn't index nulls, then it's a partial index unless we + * can prove all the rows are non-null. Note we only need look at the + * first column; multicolumn-capable AMs are *required* to index nulls + * in columns after the first. */ colno = OldIndex->rd_index->indkey.values[0]; if (colno > 0) @@ -358,11 +358,11 @@ check_index_is_clusterable(Relation OldHeap, Oid indexOid, bool recheck) (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("cannot cluster on index \"%s\" because access method\n" "does not handle null values", - RelationGetRelationName(OldIndex)), + RelationGetRelationName(OldIndex)), errhint("You may be able to work around this by marking column \"%s\" NOT NULL%s", - NameStr(OldHeap->rd_att->attrs[colno - 1]->attname), - recheck ? ",\nor use ALTER TABLE ... SET WITHOUT CLUSTER to remove the cluster\n" - "specification from the table." : "."))); + NameStr(OldHeap->rd_att->attrs[colno - 1]->attname), + recheck ? ",\nor use ALTER TABLE ... SET WITHOUT CLUSTER to remove the cluster\n" + "specification from the table." : "."))); } else if (colno < 0) { @@ -374,15 +374,15 @@ check_index_is_clusterable(Relation OldHeap, Oid indexOid, bool recheck) (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("cannot cluster on expressional index \"%s\" because its index access\n" "method does not handle null values", - RelationGetRelationName(OldIndex)))); + RelationGetRelationName(OldIndex)))); } /* - * Disallow clustering system relations. This will definitely NOT - * work for shared relations (we have no way to update pg_class rows - * in other databases), nor for nailed-in-cache relations (the - * relfilenode values for those are hardwired, see relcache.c). It - * might work for other system relations, but I ain't gonna risk it. + * Disallow clustering system relations. This will definitely NOT work + * for shared relations (we have no way to update pg_class rows in other + * databases), nor for nailed-in-cache relations (the relfilenode values + * for those are hardwired, see relcache.c). It might work for other + * system relations, but I ain't gonna risk it. */ if (IsSystemRelation(OldHeap)) ereport(ERROR, @@ -391,13 +391,13 @@ check_index_is_clusterable(Relation OldHeap, Oid indexOid, bool recheck) RelationGetRelationName(OldHeap)))); /* - * Don't allow cluster on temp tables of other backends ... their - * local buffer manager is not going to cope. + * Don't allow cluster on temp tables of other backends ... their local + * buffer manager is not going to cope. */ if (isOtherTempNamespace(RelationGetNamespace(OldHeap))) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot cluster temporary tables of other sessions"))); + errmsg("cannot cluster temporary tables of other sessions"))); /* Drop relcache refcnt on OldIndex, but keep lock */ index_close(OldIndex); @@ -454,8 +454,8 @@ mark_index_clustered(Relation rel, Oid indexOid) indexForm = (Form_pg_index) GETSTRUCT(indexTuple); /* - * Unset the bit if set. We know it's wrong because we checked - * this earlier. + * Unset the bit if set. We know it's wrong because we checked this + * earlier. */ if (indexForm->indisclustered) { @@ -503,20 +503,18 @@ rebuild_relation(Relation OldHeap, Oid indexOid) heap_close(OldHeap, NoLock); /* - * Create the new heap, using a temporary name in the same namespace - * as the existing table. NOTE: there is some risk of collision with - * user relnames. Working around this seems more trouble than it's - * worth; in particular, we can't create the new heap in a different - * namespace from the old, or we will have problems with the TEMP - * status of temp tables. + * Create the new heap, using a temporary name in the same namespace as + * the existing table. NOTE: there is some risk of collision with user + * relnames. Working around this seems more trouble than it's worth; in + * particular, we can't create the new heap in a different namespace from + * the old, or we will have problems with the TEMP status of temp tables. */ snprintf(NewHeapName, sizeof(NewHeapName), "pg_temp_%u", tableOid); OIDNewHeap = make_new_heap(tableOid, NewHeapName, tableSpace); /* - * We don't need CommandCounterIncrement() because make_new_heap did - * it. + * We don't need CommandCounterIncrement() because make_new_heap did it. */ /* @@ -546,9 +544,9 @@ rebuild_relation(Relation OldHeap, Oid indexOid) /* performDeletion does CommandCounterIncrement at end */ /* - * Rebuild each index on the relation (but not the toast table, which - * is all-new at this point). We do not need - * CommandCounterIncrement() because reindex_relation does it. + * Rebuild each index on the relation (but not the toast table, which is + * all-new at this point). We do not need CommandCounterIncrement() + * because reindex_relation does it. */ reindex_relation(tableOid, false); } @@ -587,15 +585,15 @@ make_new_heap(Oid OIDOldHeap, const char *NewName, Oid NewTableSpace) allowSystemTableMods); /* - * Advance command counter so that the newly-created relation's - * catalog tuples will be visible to heap_open. + * Advance command counter so that the newly-created relation's catalog + * tuples will be visible to heap_open. */ CommandCounterIncrement(); /* * If necessary, create a TOAST table for the new relation. Note that - * AlterTableCreateToastTable ends with CommandCounterIncrement(), so - * that the TOAST table will be visible for insertion. + * AlterTableCreateToastTable ends with CommandCounterIncrement(), so that + * the TOAST table will be visible for insertion. */ AlterTableCreateToastTable(OIDNewHeap, true); @@ -629,8 +627,8 @@ copy_heap_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex) OldIndex = index_open(OIDOldIndex); /* - * Their tuple descriptors should be exactly alike, but here we only - * need assume that they have the same number of columns. + * Their tuple descriptors should be exactly alike, but here we only need + * assume that they have the same number of columns. */ oldTupDesc = RelationGetDescr(OldHeap); newTupDesc = RelationGetDescr(NewHeap); @@ -654,15 +652,14 @@ copy_heap_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex) * We cannot simply pass the tuple to heap_insert(), for several * reasons: * - * 1. heap_insert() will overwrite the commit-status fields of the - * tuple it's handed. This would trash the source relation, which is - * bad news if we abort later on. (This was a bug in releases thru - * 7.0) + * 1. heap_insert() will overwrite the commit-status fields of the tuple + * it's handed. This would trash the source relation, which is bad + * news if we abort later on. (This was a bug in releases thru 7.0) * - * 2. We'd like to squeeze out the values of any dropped columns, - * both to save space and to ensure we have no corner-case failures. - * (It's possible for example that the new table hasn't got a TOAST - * table and so is unable to store any large values of dropped cols.) + * 2. We'd like to squeeze out the values of any dropped columns, both to + * save space and to ensure we have no corner-case failures. (It's + * possible for example that the new table hasn't got a TOAST table + * and so is unable to store any large values of dropped cols.) * * 3. The tuple might not even be legal for the new table; this is * currently only known to happen as an after-effect of ALTER TABLE @@ -784,19 +781,18 @@ swap_relation_files(Oid r1, Oid r2) CatalogCloseIndexes(indstate); /* - * If we have toast tables associated with the relations being - * swapped, change their dependency links to re-associate them with - * their new owning relations. Otherwise the wrong one will get - * dropped ... + * If we have toast tables associated with the relations being swapped, + * change their dependency links to re-associate them with their new + * owning relations. Otherwise the wrong one will get dropped ... * * NOTE: it is possible that only one table has a toast table; this can - * happen in CLUSTER if there were dropped columns in the old table, - * and in ALTER TABLE when adding or changing type of columns. + * happen in CLUSTER if there were dropped columns in the old table, and + * in ALTER TABLE when adding or changing type of columns. * - * NOTE: at present, a TOAST table's only dependency is the one on its - * owning table. If more are ever created, we'd need to use something - * more selective than deleteDependencyRecordsFor() to get rid of only - * the link we want. + * NOTE: at present, a TOAST table's only dependency is the one on its owning + * table. If more are ever created, we'd need to use something more + * selective than deleteDependencyRecordsFor() to get rid of only the link + * we want. */ if (relform1->reltoastrelid || relform2->reltoastrelid) { @@ -845,16 +841,16 @@ swap_relation_files(Oid r1, Oid r2) /* * Blow away the old relcache entries now. We need this kluge because - * relcache.c keeps a link to the smgr relation for the physical file, - * and that will be out of date as soon as we do - * CommandCounterIncrement. Whichever of the rels is the second to be - * cleared during cache invalidation will have a dangling reference to - * an already-deleted smgr relation. Rather than trying to avoid this - * by ordering operations just so, it's easiest to not have the - * relcache entries there at all. (Fortunately, since one of the - * entries is local in our transaction, it's sufficient to clear out - * our own relcache this way; the problem cannot arise for other - * backends when they see our update on the non-local relation.) + * relcache.c keeps a link to the smgr relation for the physical file, and + * that will be out of date as soon as we do CommandCounterIncrement. + * Whichever of the rels is the second to be cleared during cache + * invalidation will have a dangling reference to an already-deleted smgr + * relation. Rather than trying to avoid this by ordering operations just + * so, it's easiest to not have the relcache entries there at all. + * (Fortunately, since one of the entries is local in our transaction, + * it's sufficient to clear out our own relcache this way; the problem + * cannot arise for other backends when they see our update on the + * non-local relation.) */ RelationForgetRelation(r1); RelationForgetRelation(r2); @@ -886,9 +882,9 @@ get_tables_to_cluster(MemoryContext cluster_context) /* * Get all indexes that have indisclustered set and are owned by - * appropriate user. System relations or nailed-in relations cannot - * ever have indisclustered set, because CLUSTER will refuse to set it - * when called with one of them as argument. + * appropriate user. System relations or nailed-in relations cannot ever + * have indisclustered set, because CLUSTER will refuse to set it when + * called with one of them as argument. */ indRelation = heap_open(IndexRelationId, AccessShareLock); ScanKeyInit(&entry, @@ -904,8 +900,8 @@ get_tables_to_cluster(MemoryContext cluster_context) continue; /* - * We have to build the list in a different memory context so it - * will survive the cross-transaction processing + * We have to build the list in a different memory context so it will + * survive the cross-transaction processing */ old_context = MemoryContextSwitchTo(cluster_context); diff --git a/src/backend/commands/comment.c b/src/backend/commands/comment.c index 8177e39c71..cf7dc06fa7 100644 --- a/src/backend/commands/comment.c +++ b/src/backend/commands/comment.c @@ -7,7 +7,7 @@ * Copyright (c) 1996-2005, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/comment.c,v 1.83 2005/04/14 20:03:23 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/comment.c,v 1.84 2005/10/15 02:49:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -310,10 +310,9 @@ CommentRelation(int objtype, List *relname, char *comment) tgtrel = makeRangeVarFromNameList(relname); /* - * Open the relation. We do this mainly to acquire a lock that - * ensures no one else drops the relation before we commit. (If they - * did, they'd fail to remove the entry we are about to make in - * pg_description.) + * Open the relation. We do this mainly to acquire a lock that ensures no + * one else drops the relation before we commit. (If they did, they'd + * fail to remove the entry we are about to make in pg_description.) */ relation = relation_openrv(tgtrel, AccessShareLock); @@ -441,17 +440,16 @@ CommentDatabase(List *qualname, char *comment) database = strVal(linitial(qualname)); /* - * We cannot currently support cross-database comments (since other - * DBs cannot see pg_description of this database). So, we reject - * attempts to comment on a database other than the current one. - * Someday this might be improved, but it would take a redesigned - * infrastructure. + * We cannot currently support cross-database comments (since other DBs + * cannot see pg_description of this database). So, we reject attempts to + * comment on a database other than the current one. Someday this might be + * improved, but it would take a redesigned infrastructure. * - * When loading a dump, we may see a COMMENT ON DATABASE for the old name - * of the database. Erroring out would prevent pg_restore from - * completing (which is really pg_restore's fault, but for now we will - * work around the problem here). Consensus is that the best fix is - * to treat wrong database name as a WARNING not an ERROR. + * When loading a dump, we may see a COMMENT ON DATABASE for the old name of + * the database. Erroring out would prevent pg_restore from completing + * (which is really pg_restore's fault, but for now we will work around + * the problem here). Consensus is that the best fix is to treat wrong + * database name as a WARNING not an ERROR. */ /* First get the database OID */ @@ -467,8 +465,8 @@ CommentDatabase(List *qualname, char *comment) /* Only allow comments on the current database */ if (oid != MyDatabaseId) { - ereport(WARNING, /* throw just a warning so pg_restore - * doesn't fail */ + ereport(WARNING, /* throw just a warning so pg_restore doesn't + * fail */ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("database comments may only be applied to the current database"))); return; @@ -587,8 +585,8 @@ CommentRule(List *qualname, char *comment) ForwardScanDirection))) ereport(ERROR, (errcode(ERRCODE_DUPLICATE_OBJECT), - errmsg("there are multiple rules named \"%s\"", rulename), - errhint("Specify a relation name as well as a rule name."))); + errmsg("there are multiple rules named \"%s\"", rulename), + errhint("Specify a relation name as well as a rule name."))); heap_endscan(scanDesc); heap_close(RewriteRelation, AccessShareLock); @@ -616,8 +614,8 @@ CommentRule(List *qualname, char *comment) if (!HeapTupleIsValid(tuple)) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), - errmsg("rule \"%s\" for relation \"%s\" does not exist", - rulename, RelationGetRelationName(relation)))); + errmsg("rule \"%s\" for relation \"%s\" does not exist", + rulename, RelationGetRelationName(relation)))); Assert(reloid == ((Form_pg_rewrite) GETSTRUCT(tuple))->ev_class); ruleoid = HeapTupleGetOid(tuple); ReleaseSysCache(tuple); @@ -802,8 +800,8 @@ CommentTrigger(List *qualname, char *comment) RelationGetRelationName(relation)); /* - * Fetch the trigger tuple from pg_trigger. There can be only one - * because of the unique index. + * Fetch the trigger tuple from pg_trigger. There can be only one because + * of the unique index. */ pg_trigger = heap_open(TriggerRelationId, AccessShareLock); ScanKeyInit(&entry[0], @@ -879,9 +877,9 @@ CommentConstraint(List *qualname, char *comment) RelationGetRelationName(relation)); /* - * Fetch the constraint tuple from pg_constraint. There may be more - * than one match, because constraints are not required to have unique - * names; if so, error out. + * Fetch the constraint tuple from pg_constraint. There may be more than + * one match, because constraints are not required to have unique names; + * if so, error out. */ pg_constraint = heap_open(ConstraintRelationId, AccessShareLock); @@ -902,8 +900,8 @@ CommentConstraint(List *qualname, char *comment) if (OidIsValid(conOid)) ereport(ERROR, (errcode(ERRCODE_DUPLICATE_OBJECT), - errmsg("table \"%s\" has multiple constraints named \"%s\"", - RelationGetRelationName(relation), conName))); + errmsg("table \"%s\" has multiple constraints named \"%s\"", + RelationGetRelationName(relation), conName))); conOid = HeapTupleGetOid(tuple); } } @@ -914,8 +912,8 @@ CommentConstraint(List *qualname, char *comment) if (!OidIsValid(conOid)) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), - errmsg("constraint \"%s\" for table \"%s\" does not exist", - conName, RelationGetRelationName(relation)))); + errmsg("constraint \"%s\" for table \"%s\" does not exist", + conName, RelationGetRelationName(relation)))); /* Call CreateComments() to create/drop the comments */ CreateComments(conOid, ConstraintRelationId, 0, comment); @@ -988,7 +986,7 @@ CommentLanguage(List *qualname, char *comment) if (!superuser()) ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), - errmsg("must be superuser to comment on procedural language"))); + errmsg("must be superuser to comment on procedural language"))); /* Call CreateComments() to create/drop the comments */ CreateComments(oid, LanguageRelationId, 0, comment); @@ -1111,7 +1109,7 @@ CommentLargeObject(List *qualname, char *comment) * strings. */ loid = DatumGetObjectId(DirectFunctionCall1(oidin, - CStringGetDatum(strVal(node)))); + CStringGetDatum(strVal(node)))); break; default: elog(ERROR, "unrecognized node type: %d", diff --git a/src/backend/commands/conversioncmds.c b/src/backend/commands/conversioncmds.c index 912f35ea20..53b3f854ce 100644 --- a/src/backend/commands/conversioncmds.c +++ b/src/backend/commands/conversioncmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/conversioncmds.c,v 1.22 2005/08/22 17:38:20 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/conversioncmds.c,v 1.23 2005/10/15 02:49:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -74,8 +74,8 @@ CreateConversionCommand(CreateConversionStmt *stmt) to_encoding_name))); /* - * Check the existence of the conversion function. Function name could - * be a qualified name. + * Check the existence of the conversion function. Function name could be + * a qualified name. */ funcoid = LookupFuncName(func_name, sizeof(funcargs) / sizeof(Oid), funcargs, false); @@ -87,8 +87,8 @@ CreateConversionCommand(CreateConversionStmt *stmt) NameListToString(func_name)); /* - * All seem ok, go ahead (possible failure would be a duplicate - * conversion name) + * All seem ok, go ahead (possible failure would be a duplicate conversion + * name) */ ConversionCreate(conversion_name, namespaceId, GetUserId(), from_encoding, to_encoding, funcoid, stmt->def); @@ -148,11 +148,11 @@ RenameConversion(List *name, const char *newname) 0, 0)) ereport(ERROR, (errcode(ERRCODE_DUPLICATE_OBJECT), - errmsg("conversion \"%s\" already exists in schema \"%s\"", - newname, get_namespace_name(namespaceOid)))); + errmsg("conversion \"%s\" already exists in schema \"%s\"", + newname, get_namespace_name(namespaceOid)))); /* must be owner */ - if (!pg_conversion_ownercheck(conversionOid,GetUserId())) + if (!pg_conversion_ownercheck(conversionOid, GetUserId())) aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_CONVERSION, NameListToString(name)); @@ -210,7 +210,7 @@ AlterConversionOwner(List *name, Oid newOwnerId) if (!superuser()) { /* Otherwise, must be owner of the existing object */ - if (!pg_conversion_ownercheck(HeapTupleGetOid(tup),GetUserId())) + if (!pg_conversion_ownercheck(HeapTupleGetOid(tup), GetUserId())) aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_CONVERSION, NameListToString(name)); @@ -227,8 +227,7 @@ AlterConversionOwner(List *name, Oid newOwnerId) } /* - * Modify the owner --- okay to scribble on tup because it's a - * copy + * Modify the owner --- okay to scribble on tup because it's a copy */ convForm->conowner = newOwnerId; diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c index cd215cb415..8ab402e6b7 100644 --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.252 2005/10/03 23:43:09 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.253 2005/10/15 02:49:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -100,7 +100,7 @@ typedef struct CopyStateData bool fe_eof; /* true if detected end of copy data */ EolType eol_type; /* EOL type of input */ int client_encoding; /* remote side's character encoding */ - bool need_transcoding; /* client encoding diff from server? */ + bool need_transcoding; /* client encoding diff from server? */ bool client_only_encoding; /* encoding not valid on server? */ /* parameters from the COPY command */ @@ -111,12 +111,12 @@ typedef struct CopyStateData bool csv_mode; /* Comma Separated Value format? */ bool header_line; /* CSV header line? */ char *null_print; /* NULL marker string (server encoding!) */ - int null_print_len; /* length of same */ + int null_print_len; /* length of same */ char *delim; /* column delimiter (must be 1 byte) */ char *quote; /* CSV quote char (must be 1 byte) */ char *escape; /* CSV escape char (must be 1 byte) */ - List *force_quote_atts; /* integer list of attnums to FQ */ - List *force_notnull_atts; /* integer list of attnums to FNN */ + List *force_quote_atts; /* integer list of attnums to FQ */ + List *force_notnull_atts; /* integer list of attnums to FNN */ /* these are just for error messages, see copy_in_error_callback */ const char *cur_relname; /* table name for error messages */ @@ -127,26 +127,26 @@ typedef struct CopyStateData /* * These variables are used to reduce overhead in textual COPY FROM. * - * attribute_buf holds the separated, de-escaped text for each field of - * the current line. The CopyReadAttributes functions return arrays of + * attribute_buf holds the separated, de-escaped text for each field of the + * current line. The CopyReadAttributes functions return arrays of * pointers into this buffer. We avoid palloc/pfree overhead by re-using * the buffer on each cycle. */ StringInfoData attribute_buf; /* - * Similarly, line_buf holds the whole input line being processed. - * The input cycle is first to read the whole line into line_buf, - * convert it to server encoding there, and then extract the individual - * attribute fields into attribute_buf. line_buf is preserved unmodified - * so that we can display it in error messages if appropriate. + * Similarly, line_buf holds the whole input line being processed. The + * input cycle is first to read the whole line into line_buf, convert it + * to server encoding there, and then extract the individual attribute + * fields into attribute_buf. line_buf is preserved unmodified so that we + * can display it in error messages if appropriate. */ StringInfoData line_buf; - bool line_buf_converted; /* converted to server encoding? */ + bool line_buf_converted; /* converted to server encoding? */ /* * Finally, raw_buf holds raw data read from the data source (file or - * client connection). CopyReadLine parses this data sufficiently to + * client connection). CopyReadLine parses this data sufficiently to * locate line boundaries, then transfers the data to line_buf and * converts it. Note: we guarantee that there is a \0 at * raw_buf[raw_buf_len]. @@ -170,17 +170,17 @@ static void CopyFrom(CopyState cstate); static bool CopyReadLine(CopyState cstate); static bool CopyReadLineText(CopyState cstate); static bool CopyReadLineCSV(CopyState cstate); -static int CopyReadAttributesText(CopyState cstate, int maxfields, - char **fieldvals); -static int CopyReadAttributesCSV(CopyState cstate, int maxfields, - char **fieldvals); +static int CopyReadAttributesText(CopyState cstate, int maxfields, + char **fieldvals); +static int CopyReadAttributesCSV(CopyState cstate, int maxfields, + char **fieldvals); static Datum CopyReadBinaryAttribute(CopyState cstate, - int column_no, FmgrInfo *flinfo, - Oid typioparam, int32 typmod, - bool *isnull); + int column_no, FmgrInfo *flinfo, + Oid typioparam, int32 typmod, + bool *isnull); static void CopyAttributeOutText(CopyState cstate, char *server_string); static void CopyAttributeOutCSV(CopyState cstate, char *server_string, - bool use_quote); + bool use_quote); static List *CopyGetAttnums(Relation rel, List *attnamelist); static char *limit_printout_length(const char *str); @@ -192,8 +192,8 @@ static void CopySendData(CopyState cstate, void *databuf, int datasize); static void CopySendString(CopyState cstate, const char *str); static void CopySendChar(CopyState cstate, char c); static void CopySendEndOfRow(CopyState cstate); -static int CopyGetData(CopyState cstate, void *databuf, - int minread, int maxread); +static int CopyGetData(CopyState cstate, void *databuf, + int minread, int maxread); static void CopySendInt32(CopyState cstate, int32 val); static bool CopyGetInt32(CopyState cstate, int32 *val); static void CopySendInt16(CopyState cstate, int16 val); @@ -230,7 +230,7 @@ SendCopyBegin(CopyState cstate) if (cstate->binary) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("COPY BINARY is not supported to stdout or from stdin"))); + errmsg("COPY BINARY is not supported to stdout or from stdin"))); pq_putemptymessage('H'); /* grottiness needed for old COPY OUT protocol */ pq_startcopyout(); @@ -242,7 +242,7 @@ SendCopyBegin(CopyState cstate) if (cstate->binary) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("COPY BINARY is not supported to stdout or from stdin"))); + errmsg("COPY BINARY is not supported to stdout or from stdin"))); pq_putemptymessage('B'); /* grottiness needed for old COPY OUT protocol */ pq_startcopyout(); @@ -276,7 +276,7 @@ ReceiveCopyBegin(CopyState cstate) if (cstate->binary) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("COPY BINARY is not supported to stdout or from stdin"))); + errmsg("COPY BINARY is not supported to stdout or from stdin"))); pq_putemptymessage('G'); cstate->copy_dest = COPY_OLD_FE; } @@ -286,7 +286,7 @@ ReceiveCopyBegin(CopyState cstate) if (cstate->binary) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("COPY BINARY is not supported to stdout or from stdin"))); + errmsg("COPY BINARY is not supported to stdout or from stdin"))); pq_putemptymessage('D'); cstate->copy_dest = COPY_OLD_FE; } @@ -408,7 +408,7 @@ CopySendEndOfRow(CopyState cstate) * CopyGetData reads data from the source (file or frontend) * * We attempt to read at least minread, and at most maxread, bytes from - * the source. The actual number of bytes read is returned; if this is + * the source. The actual number of bytes read is returned; if this is * less than minread, EOF was detected. * * Note: when copying from the frontend, we expect a proper EOF mark per @@ -420,7 +420,7 @@ CopySendEndOfRow(CopyState cstate) static int CopyGetData(CopyState cstate, void *databuf, int minread, int maxread) { - int bytesread = 0; + int bytesread = 0; switch (cstate->copy_dest) { @@ -432,12 +432,13 @@ CopyGetData(CopyState cstate, void *databuf, int minread, int maxread) errmsg("could not read from COPY file: %m"))); break; case COPY_OLD_FE: + /* * We cannot read more than minread bytes (which in practice is 1) * because old protocol doesn't have any clear way of separating - * the COPY stream from following data. This is slow, but not - * any slower than the code path was originally, and we don't - * care much anymore about the performance of old protocol. + * the COPY stream from following data. This is slow, but not any + * slower than the code path was originally, and we don't care + * much anymore about the performance of old protocol. */ if (pq_getbytes((char *) databuf, minread)) { @@ -463,11 +464,11 @@ CopyGetData(CopyState cstate, void *databuf, int minread, int maxread) if (mtype == EOF) ereport(ERROR, (errcode(ERRCODE_CONNECTION_FAILURE), - errmsg("unexpected EOF on client connection"))); + errmsg("unexpected EOF on client connection"))); if (pq_getmessage(cstate->fe_msgbuf, 0)) ereport(ERROR, (errcode(ERRCODE_CONNECTION_FAILURE), - errmsg("unexpected EOF on client connection"))); + errmsg("unexpected EOF on client connection"))); switch (mtype) { case 'd': /* CopyData */ @@ -480,16 +481,16 @@ CopyGetData(CopyState cstate, void *databuf, int minread, int maxread) ereport(ERROR, (errcode(ERRCODE_QUERY_CANCELED), errmsg("COPY from stdin failed: %s", - pq_getmsgstring(cstate->fe_msgbuf)))); + pq_getmsgstring(cstate->fe_msgbuf)))); break; case 'H': /* Flush */ case 'S': /* Sync */ /* - * Ignore Flush/Sync for the convenience of - * client libraries (such as libpq) that may - * send those without noticing that the - * command they just sent was COPY. + * Ignore Flush/Sync for the convenience of client + * libraries (such as libpq) that may send those + * without noticing that the command they just + * sent was COPY. */ goto readmessage; default: @@ -593,8 +594,8 @@ CopyGetInt16(CopyState cstate, int16 *val) static bool CopyLoadRawBuf(CopyState cstate) { - int nbytes; - int inbytes; + int nbytes; + int inbytes; if (cstate->raw_buf_index < cstate->raw_buf_len) { @@ -791,7 +792,7 @@ DoCopy(const CopyStmt *stmt) (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("COPY delimiter must be a single character"))); - /* Check header */ + /* Check header */ if (!cstate->csv_mode && cstate->header_line) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), @@ -827,23 +828,23 @@ DoCopy(const CopyStmt *stmt) if (force_quote != NIL && is_from) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("COPY force quote only available using COPY TO"))); + errmsg("COPY force quote only available using COPY TO"))); /* Check force_notnull */ if (!cstate->csv_mode && force_notnull != NIL) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("COPY force not null available only in CSV mode"))); + errmsg("COPY force not null available only in CSV mode"))); if (force_notnull != NIL && !is_from) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("COPY force not null only available using COPY FROM"))); + errmsg("COPY force not null only available using COPY FROM"))); /* Don't allow the delimiter to appear in the null string. */ if (strchr(cstate->null_print, cstate->delim[0]) != NULL) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("COPY delimiter must not appear in the NULL specification"))); + errmsg("COPY delimiter must not appear in the NULL specification"))); /* Don't allow the CSV quote char to appear in the null string. */ if (cstate->csv_mode && @@ -874,7 +875,7 @@ DoCopy(const CopyStmt *stmt) (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), errmsg("must be superuser to COPY to or from a file"), errhint("Anyone can COPY to stdout or from stdin. " - "psql's \\copy command also works for anyone."))); + "psql's \\copy command also works for anyone."))); /* Don't allow COPY w/ OIDs to or from a table without them */ if (cstate->oids && !cstate->rel->rd_rel->relhasoids) @@ -902,8 +903,8 @@ DoCopy(const CopyStmt *stmt) if (!list_member_int(cstate->attnumlist, attnum)) ereport(ERROR, (errcode(ERRCODE_INVALID_COLUMN_REFERENCE), - errmsg("FORCE QUOTE column \"%s\" not referenced by COPY", - NameStr(attr[attnum - 1]->attname)))); + errmsg("FORCE QUOTE column \"%s\" not referenced by COPY", + NameStr(attr[attnum - 1]->attname)))); } } @@ -924,8 +925,8 @@ DoCopy(const CopyStmt *stmt) if (!list_member_int(cstate->attnumlist, attnum)) ereport(ERROR, (errcode(ERRCODE_INVALID_COLUMN_REFERENCE), - errmsg("FORCE NOT NULL column \"%s\" not referenced by COPY", - NameStr(attr[attnum - 1]->attname)))); + errmsg("FORCE NOT NULL column \"%s\" not referenced by COPY", + NameStr(attr[attnum - 1]->attname)))); } } @@ -960,8 +961,8 @@ DoCopy(const CopyStmt *stmt) else ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), - errmsg("cannot copy to non-table relation \"%s\"", - RelationGetRelationName(cstate->rel)))); + errmsg("cannot copy to non-table relation \"%s\"", + RelationGetRelationName(cstate->rel)))); } if (pipe) { @@ -979,8 +980,8 @@ DoCopy(const CopyStmt *stmt) if (cstate->copy_file == NULL) ereport(ERROR, (errcode_for_file_access(), - errmsg("could not open file \"%s\" for reading: %m", - filename))); + errmsg("could not open file \"%s\" for reading: %m", + filename))); fstat(fileno(cstate->copy_file), &st); if (S_ISDIR(st.st_mode)) @@ -1011,8 +1012,8 @@ DoCopy(const CopyStmt *stmt) else ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), - errmsg("cannot copy from non-table relation \"%s\"", - RelationGetRelationName(cstate->rel)))); + errmsg("cannot copy from non-table relation \"%s\"", + RelationGetRelationName(cstate->rel)))); } if (pipe) { @@ -1027,13 +1028,13 @@ DoCopy(const CopyStmt *stmt) struct stat st; /* - * Prevent write to relative path ... too easy to shoot - * oneself in the foot by overwriting a database file ... + * Prevent write to relative path ... too easy to shoot oneself in + * the foot by overwriting a database file ... */ if (!is_absolute_path(filename)) ereport(ERROR, (errcode(ERRCODE_INVALID_NAME), - errmsg("relative path not allowed for COPY to file"))); + errmsg("relative path not allowed for COPY to file"))); oumask = umask((mode_t) 022); cstate->copy_file = AllocateFile(filename, PG_BINARY_W); @@ -1042,8 +1043,8 @@ DoCopy(const CopyStmt *stmt) if (cstate->copy_file == NULL) ereport(ERROR, (errcode_for_file_access(), - errmsg("could not open file \"%s\" for writing: %m", - filename))); + errmsg("could not open file \"%s\" for writing: %m", + filename))); fstat(fileno(cstate->copy_file), &st); if (S_ISDIR(st.st_mode)) @@ -1069,10 +1070,9 @@ DoCopy(const CopyStmt *stmt) } /* - * Close the relation. If reading, we can release the AccessShareLock - * we got; if writing, we should hold the lock until end of - * transaction to ensure that updates will be committed before lock is - * released. + * Close the relation. If reading, we can release the AccessShareLock we + * got; if writing, we should hold the lock until end of transaction to + * ensure that updates will be committed before lock is released. */ heap_close(cstate->rel, (is_from ? NoLock : AccessShareLock)); @@ -1105,8 +1105,8 @@ DoCopyTo(CopyState cstate) { /* * Make sure we turn off old-style COPY OUT mode upon error. It is - * okay to do this in all cases, since it does nothing if the mode - * is not on. + * okay to do this in all cases, since it does nothing if the mode is + * not on. */ pq_endcopyout(true); PG_RE_THROW(); @@ -1138,7 +1138,7 @@ CopyTo(CopyState cstate) attr = tupDesc->attrs; num_phys_attrs = tupDesc->natts; attr_count = list_length(cstate->attnumlist); - null_print_client = cstate->null_print; /* default */ + null_print_client = cstate->null_print; /* default */ /* Get info about the columns we need to process. */ out_functions = (FmgrInfo *) palloc(num_phys_attrs * sizeof(FmgrInfo)); @@ -1167,9 +1167,9 @@ CopyTo(CopyState cstate) /* * Create a temporary memory context that we can reset once per row to - * recover palloc'd memory. This avoids any problems with leaks - * inside datatype output routines, and should be faster than retail - * pfree's anyway. (We don't need a whole econtext as CopyFrom does.) + * recover palloc'd memory. This avoids any problems with leaks inside + * datatype output routines, and should be faster than retail pfree's + * anyway. (We don't need a whole econtext as CopyFrom does.) */ mycontext = AllocSetContextCreate(CurrentMemoryContext, "COPY TO", @@ -1206,12 +1206,12 @@ CopyTo(CopyState cstate) /* if a header has been requested send the line */ if (cstate->header_line) { - bool hdr_delim = false; - + bool hdr_delim = false; + foreach(cur, cstate->attnumlist) { int attnum = lfirst_int(cur); - char *colname; + char *colname; if (hdr_delim) CopySendChar(cstate, cstate->delim[0]); @@ -1258,7 +1258,7 @@ CopyTo(CopyState cstate) if (cstate->oids) { string = DatumGetCString(DirectFunctionCall1(oidout, - ObjectIdGetDatum(HeapTupleGetOid(tuple)))); + ObjectIdGetDatum(HeapTupleGetOid(tuple)))); CopySendString(cstate, string); need_delim = true; } @@ -1356,7 +1356,7 @@ copy_in_error_callback(void *arg) if (cstate->cur_attname && cstate->cur_attval) { /* error is relevant to a particular column */ - char *attval; + char *attval; attval = limit_printout_length(cstate->cur_attval); errcontext("COPY %s, line %d, column %s: \"%s\"", @@ -1369,7 +1369,7 @@ copy_in_error_callback(void *arg) /* error is relevant to a particular line */ if (cstate->line_buf_converted || !cstate->need_transcoding) { - char *lineval; + char *lineval; lineval = limit_printout_length(cstate->line_buf.data); errcontext("COPY %s, line %d: \"%s\"", @@ -1379,12 +1379,12 @@ copy_in_error_callback(void *arg) else { /* - * Here, the line buffer is still in a foreign encoding, - * and indeed it's quite likely that the error is precisely - * a failure to do encoding conversion (ie, bad data). We - * dare not try to convert it, and at present there's no way - * to regurgitate it without conversion. So we have to punt - * and just report the line number. + * Here, the line buffer is still in a foreign encoding, and + * indeed it's quite likely that the error is precisely a + * failure to do encoding conversion (ie, bad data). We dare + * not try to convert it, and at present there's no way to + * regurgitate it without conversion. So we have to punt and + * just report the line number. */ errcontext("COPY %s, line %d", cstate->cur_relname, cstate->cur_lineno); @@ -1474,8 +1474,8 @@ CopyFrom(CopyState cstate) /* * We need a ResultRelInfo so we can use the regular executor's - * index-entry-making machinery. (There used to be a huge amount of - * code here that basically duplicated execUtils.c ...) + * index-entry-making machinery. (There used to be a huge amount of code + * here that basically duplicated execUtils.c ...) */ resultRelInfo = makeNode(ResultRelInfo); resultRelInfo->ri_RangeTableIndex = 1; /* dummy */ @@ -1499,9 +1499,9 @@ CopyFrom(CopyState cstate) /* * Pick up the required catalog information for each attribute in the - * relation, including the input function, the element type (to pass - * to the input function), and info about defaults and constraints. - * (Which input function we use depends on text/binary format choice.) + * relation, including the input function, the element type (to pass to + * the input function), and info about defaults and constraints. (Which + * input function we use depends on text/binary format choice.) */ in_functions = (FmgrInfo *) palloc(num_phys_attrs * sizeof(FmgrInfo)); typioparams = (Oid *) palloc(num_phys_attrs * sizeof(Oid)); @@ -1519,7 +1519,7 @@ CopyFrom(CopyState cstate) /* Fetch the input function and typioparam info */ if (cstate->binary) getTypeBinaryInputInfo(attr[attnum - 1]->atttypid, - &in_func_oid, &typioparams[attnum - 1]); + &in_func_oid, &typioparams[attnum - 1]); else getTypeInputInfo(attr[attnum - 1]->atttypid, &in_func_oid, &typioparams[attnum - 1]); @@ -1553,12 +1553,12 @@ CopyFrom(CopyState cstate) Node *node; /* - * Easiest way to do this is to use parse_coerce.c to set up - * an expression that checks the constraints. (At present, - * the expression might contain a length-coercion-function - * call and/or CoerceToDomain nodes.) The bottom of the - * expression is a Param node so that we can fill in the - * actual datum during the data input loop. + * Easiest way to do this is to use parse_coerce.c to set up an + * expression that checks the constraints. (At present, the + * expression might contain a length-coercion-function call and/or + * CoerceToDomain nodes.) The bottom of the expression is a Param + * node so that we can fill in the actual datum during the data + * input loop. */ prm = makeNode(Param); prm->paramkind = PARAM_EXEC; @@ -1580,11 +1580,10 @@ CopyFrom(CopyState cstate) AfterTriggerBeginQuery(); /* - * Check BEFORE STATEMENT insertion triggers. It's debateable whether - * we should do this for COPY, since it's not really an "INSERT" - * statement as such. However, executing these triggers maintains - * consistency with the EACH ROW triggers that we already fire on - * COPY. + * Check BEFORE STATEMENT insertion triggers. It's debateable whether we + * should do this for COPY, since it's not really an "INSERT" statement as + * such. However, executing these triggers maintains consistency with the + * EACH ROW triggers that we already fire on COPY. */ ExecBSInsertTriggers(estate, resultRelInfo); @@ -1612,20 +1611,20 @@ CopyFrom(CopyState cstate) if ((tmp >> 16) != 0) ereport(ERROR, (errcode(ERRCODE_BAD_COPY_FILE_FORMAT), - errmsg("unrecognized critical flags in COPY file header"))); + errmsg("unrecognized critical flags in COPY file header"))); /* Header extension length */ if (!CopyGetInt32(cstate, &tmp) || tmp < 0) ereport(ERROR, (errcode(ERRCODE_BAD_COPY_FILE_FORMAT), - errmsg("invalid COPY file header (missing length)"))); + errmsg("invalid COPY file header (missing length)"))); /* Skip extension header, if present */ while (tmp-- > 0) { if (CopyGetData(cstate, readSig, 1, 1) != 1) ereport(ERROR, (errcode(ERRCODE_BAD_COPY_FILE_FORMAT), - errmsg("invalid COPY file header (wrong length)"))); + errmsg("invalid COPY file header (wrong length)"))); } } @@ -1700,9 +1699,8 @@ CopyFrom(CopyState cstate) /* * EOF at start of line means we're done. If we see EOF after - * some characters, we act as though it was newline followed - * by EOF, ie, process the line and then exit loop on next - * iteration. + * some characters, we act as though it was newline followed by + * EOF, ie, process the line and then exit loop on next iteration. */ if (done && cstate->line_buf.len == 0) break; @@ -1732,7 +1730,7 @@ CopyFrom(CopyState cstate) cstate->cur_attname = "oid"; cstate->cur_attval = string; loaded_oid = DatumGetObjectId(DirectFunctionCall1(oidin, - CStringGetDatum(string))); + CStringGetDatum(string))); if (loaded_oid == InvalidOid) ereport(ERROR, (errcode(ERRCODE_BAD_COPY_FILE_FORMAT), @@ -1768,8 +1766,8 @@ CopyFrom(CopyState cstate) cstate->cur_attval = string; values[m] = FunctionCall3(&in_functions[m], CStringGetDatum(string), - ObjectIdGetDatum(typioparams[m]), - Int32GetDatum(attr[m]->atttypmod)); + ObjectIdGetDatum(typioparams[m]), + Int32GetDatum(attr[m]->atttypmod)); nulls[m] = ' '; cstate->cur_attname = NULL; cstate->cur_attval = NULL; @@ -1834,9 +1832,9 @@ CopyFrom(CopyState cstate) } /* - * Now compute and insert any defaults available for the columns - * not provided by the input data. Anything not processed here or - * above will remain NULL. + * Now compute and insert any defaults available for the columns not + * provided by the input data. Anything not processed here or above + * will remain NULL. */ for (i = 0; i < num_defaults; i++) { @@ -1863,9 +1861,9 @@ CopyFrom(CopyState cstate) prmdata->isnull = (nulls[i] == 'n'); /* - * Execute the constraint expression. Allow the - * expression to replace the value (consider e.g. a - * timestamp precision restriction). + * Execute the constraint expression. Allow the expression to + * replace the value (consider e.g. a timestamp precision + * restriction). */ values[i] = ExecEvalExpr(exprstate, econtext, &isnull, NULL); @@ -1886,7 +1884,7 @@ CopyFrom(CopyState cstate) /* BEFORE ROW INSERT Triggers */ if (resultRelInfo->ri_TrigDesc && - resultRelInfo->ri_TrigDesc->n_before_row[TRIGGER_EVENT_INSERT] > 0) + resultRelInfo->ri_TrigDesc->n_before_row[TRIGGER_EVENT_INSERT] > 0) { HeapTuple newtuple; @@ -1956,7 +1954,7 @@ CopyFrom(CopyState cstate) * server encoding. * * Result is true if read was terminated by EOF, false if terminated - * by newline. The terminating newline or EOF marker is not included + * by newline. The terminating newline or EOF marker is not included * in the final value of line_buf. */ static bool @@ -1981,12 +1979,13 @@ CopyReadLine(CopyState cstate) { /* * Reached EOF. In protocol version 3, we should ignore anything - * after \. up to the protocol end of copy data. (XXX maybe - * better not to treat \. as special?) + * after \. up to the protocol end of copy data. (XXX maybe better + * not to treat \. as special?) */ if (cstate->copy_dest == COPY_NEW_FE) { - do { + do + { cstate->raw_buf_index = cstate->raw_buf_len; } while (CopyLoadRawBuf(cstate)); } @@ -2070,25 +2069,24 @@ CopyReadLineText(CopyState cstate) result = false; /* - * The objective of this loop is to transfer the entire next input - * line into line_buf. Hence, we only care for detecting newlines - * (\r and/or \n) and the end-of-copy marker (\.). + * The objective of this loop is to transfer the entire next input line + * into line_buf. Hence, we only care for detecting newlines (\r and/or + * \n) and the end-of-copy marker (\.). * * For backwards compatibility we allow backslashes to escape newline - * characters. Backslashes other than the end marker get put into the + * characters. Backslashes other than the end marker get put into the * line_buf, since CopyReadAttributesText does its own escape processing. * * These four characters, and only these four, are assumed the same in * frontend and backend encodings. * - * For speed, we try to move data to line_buf in chunks rather than - * one character at a time. raw_buf_ptr points to the next character - * to examine; any characters from raw_buf_index to raw_buf_ptr have - * been determined to be part of the line, but not yet transferred - * to line_buf. + * For speed, we try to move data to line_buf in chunks rather than one + * character at a time. raw_buf_ptr points to the next character to + * examine; any characters from raw_buf_index to raw_buf_ptr have been + * determined to be part of the line, but not yet transferred to line_buf. * - * For a little extra speed within the loop, we copy raw_buf and - * raw_buf_len into local variables. + * For a little extra speed within the loop, we copy raw_buf and raw_buf_len + * into local variables. */ copy_raw_buf = cstate->raw_buf; raw_buf_ptr = cstate->raw_buf_index; @@ -2098,31 +2096,33 @@ CopyReadLineText(CopyState cstate) for (;;) { - int prev_raw_ptr; - char c; + int prev_raw_ptr; + char c; /* Load more data if needed */ if (raw_buf_ptr >= copy_buf_len || need_data) { /* - * Transfer any approved data to line_buf; must do this to - * be sure there is some room in raw_buf. + * Transfer any approved data to line_buf; must do this to be sure + * there is some room in raw_buf. */ if (raw_buf_ptr > cstate->raw_buf_index) { appendBinaryStringInfo(&cstate->line_buf, - cstate->raw_buf + cstate->raw_buf_index, + cstate->raw_buf + cstate->raw_buf_index, raw_buf_ptr - cstate->raw_buf_index); cstate->raw_buf_index = raw_buf_ptr; } + /* - * Try to read some more data. This will certainly reset + * Try to read some more data. This will certainly reset * raw_buf_index to zero, and raw_buf_ptr must go with it. */ if (!CopyLoadRawBuf(cstate)) hit_eof = true; raw_buf_ptr = 0; copy_buf_len = cstate->raw_buf_len; + /* * If we are completely out of data, break out of the loop, * reporting EOF. @@ -2148,12 +2148,12 @@ CopyReadLineText(CopyState cstate) /* * If need more data, go back to loop top to load it. * - * Note that if we are at EOF, c will wind up as '\0' - * because of the guaranteed pad of raw_buf. + * Note that if we are at EOF, c will wind up as '\0' because of + * the guaranteed pad of raw_buf. */ if (raw_buf_ptr >= copy_buf_len && !hit_eof) { - raw_buf_ptr = prev_raw_ptr; /* undo fetch */ + raw_buf_ptr = prev_raw_ptr; /* undo fetch */ need_data = true; continue; } @@ -2161,8 +2161,8 @@ CopyReadLineText(CopyState cstate) if (c == '\n') { - raw_buf_ptr++; /* eat newline */ - cstate->eol_type = EOL_CRNL; /* in case not set yet */ + raw_buf_ptr++; /* eat newline */ + cstate->eol_type = EOL_CRNL; /* in case not set yet */ } else { @@ -2170,11 +2170,12 @@ CopyReadLineText(CopyState cstate) if (cstate->eol_type == EOL_CRNL) ereport(ERROR, (errcode(ERRCODE_BAD_COPY_FILE_FORMAT), - errmsg("literal carriage return found in data"), + errmsg("literal carriage return found in data"), errhint("Use \"\\r\" to represent carriage return."))); + /* - * if we got here, it is the first line and we didn't - * find \n, so don't consume the peeked character + * if we got here, it is the first line and we didn't find + * \n, so don't consume the peeked character */ cstate->eol_type = EOL_CR; } @@ -2183,7 +2184,7 @@ CopyReadLineText(CopyState cstate) ereport(ERROR, (errcode(ERRCODE_BAD_COPY_FILE_FORMAT), errmsg("literal carriage return found in data"), - errhint("Use \"\\r\" to represent carriage return."))); + errhint("Use \"\\r\" to represent carriage return."))); /* If reach here, we have found the line terminator */ break; } @@ -2195,7 +2196,7 @@ CopyReadLineText(CopyState cstate) (errcode(ERRCODE_BAD_COPY_FILE_FORMAT), errmsg("literal newline found in data"), errhint("Use \"\\n\" to represent newline."))); - cstate->eol_type = EOL_NL; /* in case not set yet */ + cstate->eol_type = EOL_NL; /* in case not set yet */ /* If reach here, we have found the line terminator */ break; } @@ -2219,8 +2220,8 @@ CopyReadLineText(CopyState cstate) } /* - * In non-CSV mode, backslash quotes the following character - * even if it's a newline, so we always advance to next character + * In non-CSV mode, backslash quotes the following character even + * if it's a newline, so we always advance to next character */ c = copy_raw_buf[raw_buf_ptr++]; @@ -2230,7 +2231,7 @@ CopyReadLineText(CopyState cstate) { if (raw_buf_ptr >= copy_buf_len && !hit_eof) { - raw_buf_ptr = prev_raw_ptr; /* undo fetch */ + raw_buf_ptr = prev_raw_ptr; /* undo fetch */ need_data = true; continue; } @@ -2247,7 +2248,7 @@ CopyReadLineText(CopyState cstate) } if (raw_buf_ptr >= copy_buf_len && !hit_eof) { - raw_buf_ptr = prev_raw_ptr; /* undo fetch */ + raw_buf_ptr = prev_raw_ptr; /* undo fetch */ need_data = true; continue; } @@ -2265,13 +2266,13 @@ CopyReadLineText(CopyState cstate) errmsg("end-of-copy marker does not match previous newline style"))); /* - * Transfer only the data before the \. into line_buf, - * then discard the data and the \. sequence. + * Transfer only the data before the \. into line_buf, then + * discard the data and the \. sequence. */ if (prev_raw_ptr > cstate->raw_buf_index) appendBinaryStringInfo(&cstate->line_buf, - cstate->raw_buf + cstate->raw_buf_index, - prev_raw_ptr - cstate->raw_buf_index); + cstate->raw_buf + cstate->raw_buf_index, + prev_raw_ptr - cstate->raw_buf_index); cstate->raw_buf_index = raw_buf_ptr; result = true; /* report EOF */ break; @@ -2280,10 +2281,10 @@ CopyReadLineText(CopyState cstate) /* * Do we need to be careful about trailing bytes of multibyte - * characters? (See note above about client_only_encoding) + * characters? (See note above about client_only_encoding) * - * We assume here that pg_encoding_mblen only looks at the first - * byte of the character! + * We assume here that pg_encoding_mblen only looks at the first byte of + * the character! */ if (cstate->client_only_encoding) { @@ -2291,7 +2292,7 @@ CopyReadLineText(CopyState cstate) s[0] = c; mblen = pg_encoding_mblen(cstate->client_encoding, s); - if (raw_buf_ptr + (mblen-1) > copy_buf_len) + if (raw_buf_ptr + (mblen - 1) > copy_buf_len) { if (hit_eof) { @@ -2300,11 +2301,11 @@ CopyReadLineText(CopyState cstate) result = true; break; } - raw_buf_ptr = prev_raw_ptr; /* undo fetch */ + raw_buf_ptr = prev_raw_ptr; /* undo fetch */ need_data = true; continue; } - raw_buf_ptr += mblen-1; + raw_buf_ptr += mblen - 1; } } /* end of outer loop */ @@ -2337,7 +2338,8 @@ CopyReadLineCSV(CopyState cstate) bool need_data; bool hit_eof; char s[2]; - bool in_quote = false, last_was_esc = false; + bool in_quote = false, + last_was_esc = false; char quotec = cstate->quote[0]; char escapec = cstate->escape[0]; @@ -2351,25 +2353,24 @@ CopyReadLineCSV(CopyState cstate) result = false; /* - * The objective of this loop is to transfer the entire next input - * line into line_buf. Hence, we only care for detecting newlines - * (\r and/or \n) and the end-of-copy marker (\.). + * The objective of this loop is to transfer the entire next input line + * into line_buf. Hence, we only care for detecting newlines (\r and/or + * \n) and the end-of-copy marker (\.). * - * In CSV mode, \r and \n inside a quoted field are just part of the - * data value and are put in line_buf. We keep just enough state - * to know if we are currently in a quoted field or not. + * In CSV mode, \r and \n inside a quoted field are just part of the data + * value and are put in line_buf. We keep just enough state to know if we + * are currently in a quoted field or not. * - * These four characters, and the CSV escape and quote characters, - * are assumed the same in frontend and backend encodings. + * These four characters, and the CSV escape and quote characters, are + * assumed the same in frontend and backend encodings. * - * For speed, we try to move data to line_buf in chunks rather than - * one character at a time. raw_buf_ptr points to the next character - * to examine; any characters from raw_buf_index to raw_buf_ptr have - * been determined to be part of the line, but not yet transferred - * to line_buf. + * For speed, we try to move data to line_buf in chunks rather than one + * character at a time. raw_buf_ptr points to the next character to + * examine; any characters from raw_buf_index to raw_buf_ptr have been + * determined to be part of the line, but not yet transferred to line_buf. * - * For a little extra speed within the loop, we copy raw_buf and - * raw_buf_len into local variables. + * For a little extra speed within the loop, we copy raw_buf and raw_buf_len + * into local variables. */ copy_raw_buf = cstate->raw_buf; raw_buf_ptr = cstate->raw_buf_index; @@ -2379,31 +2380,33 @@ CopyReadLineCSV(CopyState cstate) for (;;) { - int prev_raw_ptr; - char c; + int prev_raw_ptr; + char c; /* Load more data if needed */ if (raw_buf_ptr >= copy_buf_len || need_data) { /* - * Transfer any approved data to line_buf; must do this to - * be sure there is some room in raw_buf. + * Transfer any approved data to line_buf; must do this to be sure + * there is some room in raw_buf. */ if (raw_buf_ptr > cstate->raw_buf_index) { appendBinaryStringInfo(&cstate->line_buf, - cstate->raw_buf + cstate->raw_buf_index, + cstate->raw_buf + cstate->raw_buf_index, raw_buf_ptr - cstate->raw_buf_index); cstate->raw_buf_index = raw_buf_ptr; } + /* - * Try to read some more data. This will certainly reset + * Try to read some more data. This will certainly reset * raw_buf_index to zero, and raw_buf_ptr must go with it. */ if (!CopyLoadRawBuf(cstate)) hit_eof = true; raw_buf_ptr = 0; copy_buf_len = cstate->raw_buf_len; + /* * If we are completely out of data, break out of the loop, * reporting EOF. @@ -2422,44 +2425,44 @@ CopyReadLineCSV(CopyState cstate) /* * If character is '\\' or '\r', we may need to look ahead below. - * Force fetch of the next character if we don't already have it. - * We need to do this before changing CSV state, in case one of - * these characters is also the quote or escape character. + * Force fetch of the next character if we don't already have it. We + * need to do this before changing CSV state, in case one of these + * characters is also the quote or escape character. * - * Note: old-protocol does not like forced prefetch, but it's OK - * here since we cannot validly be at EOF. + * Note: old-protocol does not like forced prefetch, but it's OK here + * since we cannot validly be at EOF. */ if (c == '\\' || c == '\r') { if (raw_buf_ptr >= copy_buf_len && !hit_eof) { - raw_buf_ptr = prev_raw_ptr; /* undo fetch */ + raw_buf_ptr = prev_raw_ptr; /* undo fetch */ need_data = true; continue; } } - /* - * Dealing with quotes and escapes here is mildly tricky. If the - * quote char is also the escape char, there's no problem - we - * just use the char as a toggle. If they are different, we need - * to ensure that we only take account of an escape inside a quoted - * field and immediately preceding a quote char, and not the - * second in a escape-escape sequence. - */ + /* + * Dealing with quotes and escapes here is mildly tricky. If the quote + * char is also the escape char, there's no problem - we just use the + * char as a toggle. If they are different, we need to ensure that we + * only take account of an escape inside a quoted field and + * immediately preceding a quote char, and not the second in a + * escape-escape sequence. + */ if (in_quote && c == escapec) - last_was_esc = ! last_was_esc; - if (c == quotec && ! last_was_esc) - in_quote = ! in_quote; + last_was_esc = !last_was_esc; + if (c == quotec && !last_was_esc) + in_quote = !in_quote; if (c != escapec) last_was_esc = false; /* - * Updating the line count for embedded CR and/or LF chars is - * necessarily a little fragile - this test is probably about - * the best we can do. (XXX it's arguable whether we should - * do this at all --- is cur_lineno a physical or logical count?) - */ + * Updating the line count for embedded CR and/or LF chars is + * necessarily a little fragile - this test is probably about the best + * we can do. (XXX it's arguable whether we should do this at all --- + * is cur_lineno a physical or logical count?) + */ if (in_quote && c == (cstate->eol_type == EOL_NL ? '\n' : '\r')) cstate->cur_lineno++; @@ -2472,12 +2475,12 @@ CopyReadLineCSV(CopyState cstate) /* * If need more data, go back to loop top to load it. * - * Note that if we are at EOF, c will wind up as '\0' - * because of the guaranteed pad of raw_buf. + * Note that if we are at EOF, c will wind up as '\0' because of + * the guaranteed pad of raw_buf. */ if (raw_buf_ptr >= copy_buf_len && !hit_eof) { - raw_buf_ptr = prev_raw_ptr; /* undo fetch */ + raw_buf_ptr = prev_raw_ptr; /* undo fetch */ need_data = true; continue; } @@ -2485,8 +2488,8 @@ CopyReadLineCSV(CopyState cstate) if (c == '\n') { - raw_buf_ptr++; /* eat newline */ - cstate->eol_type = EOL_CRNL; /* in case not set yet */ + raw_buf_ptr++; /* eat newline */ + cstate->eol_type = EOL_CRNL; /* in case not set yet */ } else { @@ -2494,11 +2497,12 @@ CopyReadLineCSV(CopyState cstate) if (cstate->eol_type == EOL_CRNL) ereport(ERROR, (errcode(ERRCODE_BAD_COPY_FILE_FORMAT), - errmsg("unquoted carriage return found in data"), + errmsg("unquoted carriage return found in data"), errhint("Use quoted CSV field to represent carriage return."))); + /* - * if we got here, it is the first line and we didn't - * find \n, so don't consume the peeked character + * if we got here, it is the first line and we didn't find + * \n, so don't consume the peeked character */ cstate->eol_type = EOL_CR; } @@ -2518,8 +2522,8 @@ CopyReadLineCSV(CopyState cstate) ereport(ERROR, (errcode(ERRCODE_BAD_COPY_FILE_FORMAT), errmsg("unquoted newline found in data"), - errhint("Use quoted CSV field to represent newline."))); - cstate->eol_type = EOL_NL; /* in case not set yet */ + errhint("Use quoted CSV field to represent newline."))); + cstate->eol_type = EOL_NL; /* in case not set yet */ /* If reach here, we have found the line terminator */ break; } @@ -2529,7 +2533,7 @@ CopyReadLineCSV(CopyState cstate) */ if (c == '\\' && cstate->line_buf.len == 0) { - char c2; + char c2; /* * If need more data, go back to loop top to load it. @@ -2548,25 +2552,25 @@ CopyReadLineCSV(CopyState cstate) } /* - * Note: we do not change c here since we aren't treating \ - * as escaping the next character. + * Note: we do not change c here since we aren't treating \ as + * escaping the next character. */ c2 = copy_raw_buf[raw_buf_ptr]; if (c2 == '.') { - raw_buf_ptr++; /* consume the '.' */ + raw_buf_ptr++; /* consume the '.' */ /* * Note: if we loop back for more data here, it does not - * matter that the CSV state change checks are re-executed; - * we will come back here with no important state changed. + * matter that the CSV state change checks are re-executed; we + * will come back here with no important state changed. */ if (cstate->eol_type == EOL_CRNL) { if (raw_buf_ptr >= copy_buf_len && !hit_eof) { - raw_buf_ptr = prev_raw_ptr; /* undo fetch */ + raw_buf_ptr = prev_raw_ptr; /* undo fetch */ need_data = true; continue; } @@ -2583,7 +2587,7 @@ CopyReadLineCSV(CopyState cstate) } if (raw_buf_ptr >= copy_buf_len && !hit_eof) { - raw_buf_ptr = prev_raw_ptr; /* undo fetch */ + raw_buf_ptr = prev_raw_ptr; /* undo fetch */ need_data = true; continue; } @@ -2601,12 +2605,12 @@ CopyReadLineCSV(CopyState cstate) errmsg("end-of-copy marker does not match previous newline style"))); /* - * Transfer only the data before the \. into line_buf, - * then discard the data and the \. sequence. + * Transfer only the data before the \. into line_buf, then + * discard the data and the \. sequence. */ if (prev_raw_ptr > cstate->raw_buf_index) appendBinaryStringInfo(&cstate->line_buf, cstate->raw_buf + cstate->raw_buf_index, - prev_raw_ptr - cstate->raw_buf_index); + prev_raw_ptr - cstate->raw_buf_index); cstate->raw_buf_index = raw_buf_ptr; result = true; /* report EOF */ break; @@ -2615,10 +2619,10 @@ CopyReadLineCSV(CopyState cstate) /* * Do we need to be careful about trailing bytes of multibyte - * characters? (See note above about client_only_encoding) + * characters? (See note above about client_only_encoding) * - * We assume here that pg_encoding_mblen only looks at the first - * byte of the character! + * We assume here that pg_encoding_mblen only looks at the first byte of + * the character! */ if (cstate->client_only_encoding) { @@ -2626,7 +2630,7 @@ CopyReadLineCSV(CopyState cstate) s[0] = c; mblen = pg_encoding_mblen(cstate->client_encoding, s); - if (raw_buf_ptr + (mblen-1) > copy_buf_len) + if (raw_buf_ptr + (mblen - 1) > copy_buf_len) { if (hit_eof) { @@ -2635,11 +2639,11 @@ CopyReadLineCSV(CopyState cstate) result = true; break; } - raw_buf_ptr = prev_raw_ptr; /* undo fetch */ + raw_buf_ptr = prev_raw_ptr; /* undo fetch */ need_data = true; continue; } - raw_buf_ptr += mblen-1; + raw_buf_ptr += mblen - 1; } } /* end of outer loop */ @@ -2684,7 +2688,7 @@ GetDecimalFromHex(char hex) * null_print is the null marker string. Note that this is compared to * the pre-de-escaped input string. * - * The return value is the number of fields actually read. (We error out + * The return value is the number of fields actually read. (We error out * if this would exceed maxfields, which is the length of fieldvals[].) */ static int @@ -2716,9 +2720,9 @@ CopyReadAttributesText(CopyState cstate, int maxfields, char **fieldvals) /* * The de-escaped attributes will certainly not be longer than the input * data line, so we can just force attribute_buf to be large enough and - * then transfer data without any checks for enough space. We need to - * do it this way because enlarging attribute_buf mid-stream would - * invalidate pointers already stored into fieldvals[]. + * then transfer data without any checks for enough space. We need to do + * it this way because enlarging attribute_buf mid-stream would invalidate + * pointers already stored into fieldvals[]. */ if (cstate->attribute_buf.maxlen <= cstate->line_buf.len) enlargeStringInfo(&cstate->attribute_buf, cstate->line_buf.len); @@ -2750,7 +2754,7 @@ CopyReadAttributesText(CopyState cstate, int maxfields, char **fieldvals) /* Scan data for field */ for (;;) { - char c; + char c; end_ptr = cur_ptr; if (cur_ptr >= line_end_ptr) @@ -2776,41 +2780,41 @@ CopyReadAttributesText(CopyState cstate, int maxfields, char **fieldvals) case '5': case '6': case '7': - { - /* handle \013 */ - int val; - - val = OCTVALUE(c); - if (cur_ptr < line_end_ptr) { - c = *cur_ptr; - if (ISOCTAL(c)) + /* handle \013 */ + int val; + + val = OCTVALUE(c); + if (cur_ptr < line_end_ptr) { - cur_ptr++; - val = (val << 3) + OCTVALUE(c); - if (cur_ptr < line_end_ptr) + c = *cur_ptr; + if (ISOCTAL(c)) { - c = *cur_ptr; - if (ISOCTAL(c)) + cur_ptr++; + val = (val << 3) + OCTVALUE(c); + if (cur_ptr < line_end_ptr) { - cur_ptr++; - val = (val << 3) + OCTVALUE(c); + c = *cur_ptr; + if (ISOCTAL(c)) + { + cur_ptr++; + val = (val << 3) + OCTVALUE(c); + } } } } + c = val & 0377; } - c = val & 0377; - } - break; + break; case 'x': /* Handle \x3F */ if (cur_ptr < line_end_ptr) { - char hexchar = *cur_ptr; + char hexchar = *cur_ptr; if (isxdigit((unsigned char) hexchar)) { - int val = GetDecimalFromHex(hexchar); + int val = GetDecimalFromHex(hexchar); cur_ptr++; if (cur_ptr < line_end_ptr) @@ -2916,9 +2920,9 @@ CopyReadAttributesCSV(CopyState cstate, int maxfields, char **fieldvals) /* * The de-escaped attributes will certainly not be longer than the input * data line, so we can just force attribute_buf to be large enough and - * then transfer data without any checks for enough space. We need to - * do it this way because enlarging attribute_buf mid-stream would - * invalidate pointers already stored into fieldvals[]. + * then transfer data without any checks for enough space. We need to do + * it this way because enlarging attribute_buf mid-stream would invalidate + * pointers already stored into fieldvals[]. */ if (cstate->attribute_buf.maxlen <= cstate->line_buf.len) enlargeStringInfo(&cstate->attribute_buf, cstate->line_buf.len); @@ -2952,7 +2956,7 @@ CopyReadAttributesCSV(CopyState cstate, int maxfields, char **fieldvals) /* Scan data for field */ for (;;) { - char c; + char c; end_ptr = cur_ptr; if (cur_ptr >= line_end_ptr) @@ -2980,7 +2984,7 @@ CopyReadAttributesCSV(CopyState cstate, int maxfields, char **fieldvals) */ if (cur_ptr < line_end_ptr) { - char nextc = *cur_ptr; + char nextc = *cur_ptr; if (nextc == escapec || nextc == quotec) { @@ -2990,6 +2994,7 @@ CopyReadAttributesCSV(CopyState cstate, int maxfields, char **fieldvals) } } } + /* * end of quoted field. Must do this test after testing for escape * in case quote char and escape char are the same (which is the @@ -3141,9 +3146,9 @@ CopyAttributeOutText(CopyState cstate, char *server_string) CopySendChar(cstate, '\\'); /* - * We can skip pg_encoding_mblen() overhead when encoding - * is safe, because in valid backend encodings, extra - * bytes of a multibyte character never look like ASCII. + * We can skip pg_encoding_mblen() overhead when encoding is + * safe, because in valid backend encodings, extra bytes of a + * multibyte character never look like ASCII. */ if (cstate->client_only_encoding) mblen = pg_encoding_mblen(cstate->client_encoding, string); diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c index 548648066b..accbafc848 100644 --- a/src/backend/commands/dbcommands.c +++ b/src/backend/commands/dbcommands.c @@ -15,7 +15,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.172 2005/10/10 20:02:20 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.173 2005/10/15 02:49:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -202,11 +202,11 @@ createdb(const CreatedbStmt *stmt) datdba = GetUserId(); /* - * To create a database, must have createdb privilege and must be able - * to become the target role (this does not imply that the target role - * itself must have createdb privilege). The latter provision guards - * against "giveaway" attacks. Note that a superuser will always have - * both of these privileges a fortiori. + * To create a database, must have createdb privilege and must be able to + * become the target role (this does not imply that the target role itself + * must have createdb privilege). The latter provision guards against + * "giveaway" attacks. Note that a superuser will always have both of + * these privileges a fortiori. */ if (!have_createdb_privilege()) ereport(ERROR, @@ -218,10 +218,10 @@ createdb(const CreatedbStmt *stmt) /* * Check for db name conflict. There is a race condition here, since * another backend could create the same DB name before we commit. - * However, holding an exclusive lock on pg_database for the whole - * time we are copying the source database doesn't seem like a good - * idea, so accept possibility of race to create. We will check again - * after we grab the exclusive lock. + * However, holding an exclusive lock on pg_database for the whole time we + * are copying the source database doesn't seem like a good idea, so + * accept possibility of race to create. We will check again after we + * grab the exclusive lock. */ if (get_db_info(dbname, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)) @@ -240,7 +240,7 @@ createdb(const CreatedbStmt *stmt) &src_vacuumxid, &src_frozenxid, &src_deftablespace)) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_DATABASE), - errmsg("template database \"%s\" does not exist", dbtemplate))); + errmsg("template database \"%s\" does not exist", dbtemplate))); /* * Permission check: to copy a DB that's not marked datistemplate, you @@ -264,8 +264,8 @@ createdb(const CreatedbStmt *stmt) if (DatabaseHasActiveBackends(src_dboid, true)) ereport(ERROR, (errcode(ERRCODE_OBJECT_IN_USE), - errmsg("source database \"%s\" is being accessed by other users", - dbtemplate))); + errmsg("source database \"%s\" is being accessed by other users", + dbtemplate))); /* If encoding is defaulted, use source's encoding */ if (encoding < 0) @@ -300,7 +300,7 @@ createdb(const CreatedbStmt *stmt) /* * If we are trying to change the default tablespace of the template, * we require that the template not have any files in the new default - * tablespace. This is necessary because otherwise the copied + * tablespace. This is necessary because otherwise the copied * database would contain pg_class rows that refer to its default * tablespace both explicitly (by OID) and implicitly (as zero), which * would cause problems. For example another CREATE DATABASE using @@ -337,7 +337,7 @@ createdb(const CreatedbStmt *stmt) /* * Normally we mark the new database with the same datvacuumxid and - * datfrozenxid as the source. However, if the source is not allowing + * datfrozenxid as the source. However, if the source is not allowing * connections then we assume it is fully frozen, and we can set the * current transaction ID as the xid limits. This avoids immediately * starting to generate warnings after cloning template0. @@ -346,9 +346,9 @@ createdb(const CreatedbStmt *stmt) src_vacuumxid = src_frozenxid = GetCurrentTransactionId(); /* - * Preassign OID for pg_database tuple, so that we can compute db - * path. We have to open pg_database to do this, but we don't want - * to take ExclusiveLock yet, so just do it and close again. + * Preassign OID for pg_database tuple, so that we can compute db path. + * We have to open pg_database to do this, but we don't want to take + * ExclusiveLock yet, so just do it and close again. */ pg_database_rel = heap_open(DatabaseRelationId, AccessShareLock); dboid = GetNewOid(pg_database_rel); @@ -357,23 +357,23 @@ createdb(const CreatedbStmt *stmt) /* * Force dirty buffers out to disk, to ensure source database is - * up-to-date for the copy. (We really only need to flush buffers for - * the source database, but bufmgr.c provides no API for that.) + * up-to-date for the copy. (We really only need to flush buffers for the + * source database, but bufmgr.c provides no API for that.) */ BufferSync(); /* - * Once we start copying subdirectories, we need to be able to clean - * 'em up if we fail. Establish a TRY block to make sure this happens. - * (This is not a 100% solution, because of the possibility of failure - * during transaction commit after we leave this routine, but it should - * handle most scenarios.) + * Once we start copying subdirectories, we need to be able to clean 'em + * up if we fail. Establish a TRY block to make sure this happens. (This + * is not a 100% solution, because of the possibility of failure during + * transaction commit after we leave this routine, but it should handle + * most scenarios.) */ PG_TRY(); { /* - * Iterate through all tablespaces of the template database, - * and copy each one to the new database. + * Iterate through all tablespaces of the template database, and copy + * each one to the new database. */ rel = heap_open(TableSpaceRelationId, AccessShareLock); scan = heap_beginscan(rel, SnapshotNow, 0, NULL); @@ -478,8 +478,8 @@ createdb(const CreatedbStmt *stmt) tuple = heap_formtuple(pg_database_dsc, new_record, new_record_nulls); - HeapTupleSetOid(tuple, dboid); /* override heap_insert's OID - * selection */ + HeapTupleSetOid(tuple, dboid); /* override heap_insert's OID + * selection */ simple_heap_insert(pg_database_rel, tuple); @@ -495,30 +495,31 @@ createdb(const CreatedbStmt *stmt) /* * We force a checkpoint before committing. This effectively means * that committed XLOG_DBASE_CREATE operations will never need to be - * replayed (at least not in ordinary crash recovery; we still have - * to make the XLOG entry for the benefit of PITR operations). - * This avoids two nasty scenarios: + * replayed (at least not in ordinary crash recovery; we still have to + * make the XLOG entry for the benefit of PITR operations). This + * avoids two nasty scenarios: * * #1: When PITR is off, we don't XLOG the contents of newly created * indexes; therefore the drop-and-recreate-whole-directory behavior * of DBASE_CREATE replay would lose such indexes. * * #2: Since we have to recopy the source database during DBASE_CREATE - * replay, we run the risk of copying changes in it that were committed - * after the original CREATE DATABASE command but before the system - * crash that led to the replay. This is at least unexpected and at - * worst could lead to inconsistencies, eg duplicate table names. + * replay, we run the risk of copying changes in it that were + * committed after the original CREATE DATABASE command but before the + * system crash that led to the replay. This is at least unexpected + * and at worst could lead to inconsistencies, eg duplicate table + * names. * * (Both of these were real bugs in releases 8.0 through 8.0.3.) * - * In PITR replay, the first of these isn't an issue, and the second - * is only a risk if the CREATE DATABASE and subsequent template - * database change both occur while a base backup is being taken. - * There doesn't seem to be much we can do about that except document - * it as a limitation. + * In PITR replay, the first of these isn't an issue, and the second is + * only a risk if the CREATE DATABASE and subsequent template database + * change both occur while a base backup is being taken. There doesn't + * seem to be much we can do about that except document it as a + * limitation. * - * Perhaps if we ever implement CREATE DATABASE in a less cheesy - * way, we can avoid this. + * Perhaps if we ever implement CREATE DATABASE in a less cheesy way, we + * can avoid this. */ RequestCheckpoint(true, false); @@ -569,16 +570,16 @@ dropdb(const char *dbname) errmsg("cannot drop the currently open database"))); /* - * Obtain exclusive lock on pg_database. We need this to ensure that - * no new backend starts up in the target database while we are - * deleting it. (Actually, a new backend might still manage to start - * up, because it isn't able to lock pg_database while starting. But - * it will detect its error in ReverifyMyDatabase and shut down before - * any serious damage is done. See postinit.c.) + * Obtain exclusive lock on pg_database. We need this to ensure that no + * new backend starts up in the target database while we are deleting it. + * (Actually, a new backend might still manage to start up, because it + * isn't able to lock pg_database while starting. But it will detect its + * error in ReverifyMyDatabase and shut down before any serious damage is + * done. See postinit.c.) * - * An ExclusiveLock, rather than AccessExclusiveLock, is sufficient - * since ReverifyMyDatabase takes RowShareLock. This allows ordinary - * readers of pg_database to proceed in parallel. + * An ExclusiveLock, rather than AccessExclusiveLock, is sufficient since + * ReverifyMyDatabase takes RowShareLock. This allows ordinary readers of + * pg_database to proceed in parallel. */ pgdbrel = heap_open(DatabaseRelationId, ExclusiveLock); @@ -594,8 +595,8 @@ dropdb(const char *dbname) /* * Disallow dropping a DB that is marked istemplate. This is just to - * prevent people from accidentally dropping template0 or template1; - * they can do so if they're really determined ... + * prevent people from accidentally dropping template0 or template1; they + * can do so if they're really determined ... */ if (db_istemplate) ereport(ERROR, @@ -608,8 +609,8 @@ dropdb(const char *dbname) if (DatabaseHasActiveBackends(db_id, false)) ereport(ERROR, (errcode(ERRCODE_OBJECT_IN_USE), - errmsg("database \"%s\" is being accessed by other users", - dbname))); + errmsg("database \"%s\" is being accessed by other users", + dbname))); /* * Find the database's tuple by OID (should be unique). @@ -626,8 +627,8 @@ dropdb(const char *dbname) if (!HeapTupleIsValid(tup)) { /* - * This error should never come up since the existence of the - * database is checked earlier + * This error should never come up since the existence of the database + * is checked earlier */ elog(ERROR, "database \"%s\" doesn't exist despite earlier reports to the contrary", dbname); @@ -641,8 +642,8 @@ dropdb(const char *dbname) /* * Delete any comments associated with the database * - * NOTE: this is probably dead code since any such comments should have - * been in that database, not mine. + * NOTE: this is probably dead code since any such comments should have been + * in that database, not mine. */ DeleteComments(db_id, DatabaseRelationId, 0); @@ -652,9 +653,9 @@ dropdb(const char *dbname) dropDatabaseDependencies(db_id); /* - * Drop pages for this database that are in the shared buffer cache. - * This is important to ensure that no remaining backend tries to - * write out a dirty buffer to the dead database later... + * Drop pages for this database that are in the shared buffer cache. This + * is important to ensure that no remaining backend tries to write out a + * dirty buffer to the dead database later... */ DropBuffers(db_id); @@ -701,8 +702,8 @@ RenameDatabase(const char *oldname, const char *newname) key2; /* - * Obtain ExclusiveLock so that no new session gets started - * while the rename is in progress. + * Obtain ExclusiveLock so that no new session gets started while the + * rename is in progress. */ rel = heap_open(DatabaseRelationId, ExclusiveLock); @@ -720,10 +721,10 @@ RenameDatabase(const char *oldname, const char *newname) errmsg("database \"%s\" does not exist", oldname))); /* - * XXX Client applications probably store the current database - * somewhere, so renaming it could cause confusion. On the other - * hand, there may not be an actual problem besides a little - * confusion, so think about this and decide. + * XXX Client applications probably store the current database somewhere, + * so renaming it could cause confusion. On the other hand, there may not + * be an actual problem besides a little confusion, so think about this + * and decide. */ if (HeapTupleGetOid(tup) == MyDatabaseId) ereport(ERROR, @@ -737,8 +738,8 @@ RenameDatabase(const char *oldname, const char *newname) if (DatabaseHasActiveBackends(HeapTupleGetOid(tup), false)) ereport(ERROR, (errcode(ERRCODE_OBJECT_IN_USE), - errmsg("database \"%s\" is being accessed by other users", - oldname))); + errmsg("database \"%s\" is being accessed by other users", + oldname))); /* make sure the new name doesn't exist */ ScanKeyInit(&key2, @@ -822,8 +823,7 @@ AlterDatabase(AlterDatabaseStmt *stmt) connlimit = intVal(dconnlimit->arg); /* - * We don't need ExclusiveLock since we aren't updating the - * flat file. + * We don't need ExclusiveLock since we aren't updating the flat file. */ rel = heap_open(DatabaseRelationId, RowExclusiveLock); ScanKeyInit(&scankey, @@ -868,8 +868,8 @@ AlterDatabase(AlterDatabaseStmt *stmt) heap_close(rel, NoLock); /* - * We don't bother updating the flat file since the existing options - * for ALTER DATABASE don't affect it. + * We don't bother updating the flat file since the existing options for + * ALTER DATABASE don't affect it. */ } @@ -893,8 +893,7 @@ AlterDatabaseSet(AlterDatabaseSetStmt *stmt) valuestr = flatten_set_variable_args(stmt->variable, stmt->value); /* - * We don't need ExclusiveLock since we aren't updating the - * flat file. + * We don't need ExclusiveLock since we aren't updating the flat file. */ rel = heap_open(DatabaseRelationId, RowExclusiveLock); ScanKeyInit(&scankey, @@ -958,8 +957,8 @@ AlterDatabaseSet(AlterDatabaseSetStmt *stmt) heap_close(rel, NoLock); /* - * We don't bother updating the flat file since ALTER DATABASE SET - * doesn't affect it. + * We don't bother updating the flat file since ALTER DATABASE SET doesn't + * affect it. */ } @@ -977,8 +976,7 @@ AlterDatabaseOwner(const char *dbname, Oid newOwnerId) Form_pg_database datForm; /* - * We don't need ExclusiveLock since we aren't updating the - * flat file. + * We don't need ExclusiveLock since we aren't updating the flat file. */ rel = heap_open(DatabaseRelationId, RowExclusiveLock); ScanKeyInit(&scankey, @@ -1011,7 +1009,7 @@ AlterDatabaseOwner(const char *dbname, Oid newOwnerId) HeapTuple newtuple; /* Otherwise, must be owner of the existing object */ - if (!pg_database_ownercheck(HeapTupleGetOid(tuple),GetUserId())) + if (!pg_database_ownercheck(HeapTupleGetOid(tuple), GetUserId())) aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_DATABASE, dbname); @@ -1019,18 +1017,18 @@ AlterDatabaseOwner(const char *dbname, Oid newOwnerId) check_is_member_of_role(GetUserId(), newOwnerId); /* - * must have createdb rights + * must have createdb rights * - * NOTE: This is different from other alter-owner checks in - * that the current user is checked for createdb privileges - * instead of the destination owner. This is consistent - * with the CREATE case for databases. Because superusers - * will always have this right, we need no special case for them. + * NOTE: This is different from other alter-owner checks in that the + * current user is checked for createdb privileges instead of the + * destination owner. This is consistent with the CREATE case for + * databases. Because superusers will always have this right, we need + * no special case for them. */ if (!have_createdb_privilege()) ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), - errmsg("permission denied to change owner of database"))); + errmsg("permission denied to change owner of database"))); memset(repl_null, ' ', sizeof(repl_null)); memset(repl_repl, ' ', sizeof(repl_repl)); @@ -1332,10 +1330,9 @@ dbase_redo(XLogRecPtr lsn, XLogRecord *record) dst_path = GetDatabasePath(xlrec->db_id, xlrec->tablespace_id); /* - * Our theory for replaying a CREATE is to forcibly drop the - * target subdirectory if present, then re-copy the source data. - * This may be more work than needed, but it is simple to - * implement. + * Our theory for replaying a CREATE is to forcibly drop the target + * subdirectory if present, then re-copy the source data. This may be + * more work than needed, but it is simple to implement. */ if (stat(dst_path, &st) == 0 && S_ISDIR(st.st_mode)) { @@ -1367,8 +1364,7 @@ dbase_redo(XLogRecPtr lsn, XLogRecord *record) dst_path = GetDatabasePath(xlrec->db_id, xlrec->tablespace_id); /* - * Drop pages for this database that are in the shared buffer - * cache + * Drop pages for this database that are in the shared buffer cache */ DropBuffers(xlrec->db_id); diff --git a/src/backend/commands/define.c b/src/backend/commands/define.c index 68b1360bca..da5a112bf1 100644 --- a/src/backend/commands/define.c +++ b/src/backend/commands/define.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/define.c,v 1.92 2004/12/31 21:59:41 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/commands/define.c,v 1.93 2005/10/15 02:49:15 momjian Exp $ * * DESCRIPTION * The "DefineFoo" routines take the parse tree and pick out the @@ -157,11 +157,11 @@ defGetInt64(DefElem *def) /* * Values too large for int4 will be represented as Float - * constants by the lexer. Accept these if they are valid - * int8 strings. + * constants by the lexer. Accept these if they are valid int8 + * strings. */ return DatumGetInt64(DirectFunctionCall1(int8in, - CStringGetDatum(strVal(def->arg)))); + CStringGetDatum(strVal(def->arg)))); default: ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index 0a330a2137..d470990e94 100644 --- a/src/backend/commands/explain.c +++ b/src/backend/commands/explain.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994-5, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.137 2005/06/04 02:07:09 neilc Exp $ + * $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.138 2005/10/15 02:49:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -75,12 +75,12 @@ ExplainQuery(ExplainStmt *stmt, DestReceiver *dest) ListCell *l; /* - * Because the planner is not cool about not scribbling on its input, - * we make a preliminary copy of the source querytree. This prevents + * Because the planner is not cool about not scribbling on its input, we + * make a preliminary copy of the source querytree. This prevents * problems in the case that the EXPLAIN is in a portal or plpgsql * function and is executed repeatedly. (See also the same hack in - * DECLARE CURSOR and PREPARE.) XXX the planner really shouldn't - * modify its input ... FIXME someday. + * DECLARE CURSOR and PREPARE.) XXX the planner really shouldn't modify + * its input ... FIXME someday. */ query = copyObject(query); @@ -219,7 +219,7 @@ void ExplainOnePlan(QueryDesc *queryDesc, ExplainStmt *stmt, TupOutputState *tstate) { - instr_time starttime; + instr_time starttime; double totaltime = 0; ExplainState *es; StringInfo str; @@ -264,7 +264,7 @@ ExplainOnePlan(QueryDesc *queryDesc, ExplainStmt *stmt, pfree(s); do_text_output_multiline(tstate, f); pfree(f); - do_text_output_oneline(tstate, ""); /* separator line */ + do_text_output_oneline(tstate, ""); /* separator line */ } } @@ -289,21 +289,21 @@ ExplainOnePlan(QueryDesc *queryDesc, ExplainStmt *stmt, if (es->printAnalyze) { ResultRelInfo *rInfo; - int numrels = queryDesc->estate->es_num_result_relations; - int nr; + int numrels = queryDesc->estate->es_num_result_relations; + int nr; rInfo = queryDesc->estate->es_result_relations; for (nr = 0; nr < numrels; rInfo++, nr++) { - int nt; + int nt; if (!rInfo->ri_TrigDesc || !rInfo->ri_TrigInstrument) continue; for (nt = 0; nt < rInfo->ri_TrigDesc->numtriggers; nt++) { - Trigger *trig = rInfo->ri_TrigDesc->triggers + nt; + Trigger *trig = rInfo->ri_TrigDesc->triggers + nt; Instrumentation *instr = rInfo->ri_TrigInstrument + nt; - char *conname; + char *conname; /* Must clean up instrumentation state */ InstrEndLoop(instr); @@ -316,7 +316,7 @@ ExplainOnePlan(QueryDesc *queryDesc, ExplainStmt *stmt, continue; if (trig->tgisconstraint && - (conname = GetConstraintNameForTrigger(trig->tgoid)) != NULL) + (conname = GetConstraintNameForTrigger(trig->tgoid)) != NULL) { appendStringInfo(str, "Trigger for constraint %s", conname); @@ -327,7 +327,7 @@ ExplainOnePlan(QueryDesc *queryDesc, ExplainStmt *stmt, if (numrels > 1) appendStringInfo(str, " on %s", - RelationGetRelationName(rInfo->ri_RelationDesc)); + RelationGetRelationName(rInfo->ri_RelationDesc)); appendStringInfo(str, ": time=%.3f calls=%.0f\n", 1000.0 * instr->total, @@ -337,8 +337,8 @@ ExplainOnePlan(QueryDesc *queryDesc, ExplainStmt *stmt, } /* - * Close down the query and free resources. Include time for this - * in the total runtime (although it should be pretty minimal). + * Close down the query and free resources. Include time for this in the + * total runtime (although it should be pretty minimal). */ INSTR_TIME_SET_CURRENT(starttime); @@ -366,7 +366,7 @@ ExplainOnePlan(QueryDesc *queryDesc, ExplainStmt *stmt, static double elapsed_time(instr_time *starttime) { - instr_time endtime; + instr_time endtime; INSTR_TIME_SET_CURRENT(endtime); @@ -378,7 +378,7 @@ elapsed_time(instr_time *starttime) endtime.tv_usec += 1000000; endtime.tv_sec--; } -#else /* WIN32 */ +#else /* WIN32 */ endtime.QuadPart -= starttime->QuadPart; #endif @@ -583,7 +583,7 @@ explain_outNode(StringInfo str, if (ScanDirectionIsBackward(((IndexScan *) plan)->indexorderdir)) appendStringInfoString(str, " Backward"); appendStringInfo(str, " using %s", - quote_identifier(get_rel_name(((IndexScan *) plan)->indexid))); + quote_identifier(get_rel_name(((IndexScan *) plan)->indexid))); /* FALL THRU */ case T_SeqScan: case T_BitmapHeapScan: @@ -604,7 +604,7 @@ explain_outNode(StringInfo str, quote_identifier(relname)); if (strcmp(rte->eref->aliasname, relname) != 0) appendStringInfo(str, " %s", - quote_identifier(rte->eref->aliasname)); + quote_identifier(rte->eref->aliasname)); } break; case T_BitmapIndexScan: @@ -632,10 +632,10 @@ explain_outNode(StringInfo str, Assert(rte->rtekind == RTE_FUNCTION); /* - * If the expression is still a function call, we can get - * the real name of the function. Otherwise, punt (this - * can happen if the optimizer simplified away the - * function call, for example). + * If the expression is still a function call, we can get the + * real name of the function. Otherwise, punt (this can + * happen if the optimizer simplified away the function call, + * for example). */ if (rte->funcexpr && IsA(rte->funcexpr, FuncExpr)) { @@ -652,20 +652,20 @@ explain_outNode(StringInfo str, quote_identifier(proname)); if (strcmp(rte->eref->aliasname, proname) != 0) appendStringInfo(str, " %s", - quote_identifier(rte->eref->aliasname)); + quote_identifier(rte->eref->aliasname)); } break; default: break; } - + appendStringInfo(str, " (cost=%.2f..%.2f rows=%.0f width=%d)", plan->startup_cost, plan->total_cost, plan->plan_rows, plan->plan_width); /* - * We have to forcibly clean up the instrumentation state because - * we haven't done ExecutorEnd yet. This is pretty grotty ... + * We have to forcibly clean up the instrumentation state because we + * haven't done ExecutorEnd yet. This is pretty grotty ... */ if (planstate->instrument) InstrEndLoop(planstate->instrument); @@ -675,8 +675,8 @@ explain_outNode(StringInfo str, double nloops = planstate->instrument->nloops; appendStringInfo(str, " (actual time=%.3f..%.3f rows=%.0f loops=%.0f)", - 1000.0 * planstate->instrument->startup / nloops, - 1000.0 * planstate->instrument->total / nloops, + 1000.0 * planstate->instrument->startup / nloops, + 1000.0 * planstate->instrument->total / nloops, planstate->instrument->ntuples / nloops, planstate->instrument->nloops); } @@ -833,9 +833,10 @@ explain_outNode(StringInfo str, for (i = 0; i < indent; i++) appendStringInfo(str, " "); appendStringInfo(str, " -> "); + /* - * Ordinarily we don't pass down our own outer_plan value to our - * child nodes, but in bitmap scan trees we must, since the bottom + * Ordinarily we don't pass down our own outer_plan value to our child + * nodes, but in bitmap scan trees we must, since the bottom * BitmapIndexScan nodes may have outer references. */ explain_outNode(str, outerPlan(plan), @@ -882,7 +883,7 @@ explain_outNode(StringInfo str, if (IsA(plan, BitmapAnd)) { - BitmapAnd *bitmapandplan = (BitmapAnd *) plan; + BitmapAnd *bitmapandplan = (BitmapAnd *) plan; BitmapAndState *bitmapandstate = (BitmapAndState *) planstate; ListCell *lst; int j; @@ -898,7 +899,7 @@ explain_outNode(StringInfo str, explain_outNode(str, subnode, bitmapandstate->bitmapplans[j], - outer_plan, /* pass down same outer plan */ + outer_plan, /* pass down same outer plan */ indent + 3, es); j++; } @@ -906,7 +907,7 @@ explain_outNode(StringInfo str, if (IsA(plan, BitmapOr)) { - BitmapOr *bitmaporplan = (BitmapOr *) plan; + BitmapOr *bitmaporplan = (BitmapOr *) plan; BitmapOrState *bitmaporstate = (BitmapOrState *) planstate; ListCell *lst; int j; @@ -922,7 +923,7 @@ explain_outNode(StringInfo str, explain_outNode(str, subnode, bitmaporstate->bitmapplans[j], - outer_plan, /* pass down same outer plan */ + outer_plan, /* pass down same outer plan */ indent + 3, es); j++; } @@ -1008,9 +1009,9 @@ show_scan_qual(List *qual, const char *qlabel, scancontext = deparse_context_for_rte(rte); /* - * If we have an outer plan that is referenced by the qual, add it to - * the deparse context. If not, don't (so that we don't force - * prefixes unnecessarily). + * If we have an outer plan that is referenced by the qual, add it to the + * deparse context. If not, don't (so that we don't force prefixes + * unnecessarily). */ if (outer_plan) { @@ -1018,7 +1019,7 @@ show_scan_qual(List *qual, const char *qlabel, if (bms_is_member(OUTER, varnos)) outercontext = deparse_context_for_subplan("outer", - outer_plan->targetlist, + outer_plan->targetlist, es->rtable); else outercontext = NULL; @@ -1111,11 +1112,10 @@ show_sort_keys(List *tlist, int nkeys, AttrNumber *keycols, /* * In this routine we expect that the plan node's tlist has not been - * processed by set_plan_references(). Normally, any Vars will - * contain valid varnos referencing the actual rtable. But we might - * instead be looking at a dummy tlist generated by prepunion.c; if - * there are Vars with zero varno, use the tlist itself to determine - * their names. + * processed by set_plan_references(). Normally, any Vars will contain + * valid varnos referencing the actual rtable. But we might instead be + * looking at a dummy tlist generated by prepunion.c; if there are Vars + * with zero varno, use the tlist itself to determine their names. */ varnos = pull_varnos((Node *) tlist); if (bms_is_member(0, varnos)) diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c index a2a8f56e23..f4d6164775 100644 --- a/src/backend/commands/functioncmds.c +++ b/src/backend/commands/functioncmds.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.68 2005/09/24 22:54:36 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.69 2005/10/15 02:49:15 momjian Exp $ * * DESCRIPTION * These routines take the parse tree and pick out the @@ -83,8 +83,8 @@ compute_return_type(TypeName *returnType, Oid languageOid, if (languageOid == SQLlanguageId) ereport(ERROR, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), - errmsg("SQL function cannot return shell type %s", - TypeNameToString(returnType)))); + errmsg("SQL function cannot return shell type %s", + TypeNameToString(returnType)))); else ereport(NOTICE, (errcode(ERRCODE_WRONG_OBJECT_TYPE), @@ -158,7 +158,7 @@ examine_parameter_list(List *parameters, Oid languageOid, ListCell *x; int i; - *requiredResultType = InvalidOid; /* default result */ + *requiredResultType = InvalidOid; /* default result */ inTypes = (Oid *) palloc(parameterCount * sizeof(Oid)); allTypes = (Datum *) palloc(parameterCount * sizeof(Datum)); @@ -182,8 +182,8 @@ examine_parameter_list(List *parameters, Oid languageOid, if (languageOid == SQLlanguageId) ereport(ERROR, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), - errmsg("SQL function cannot accept shell type %s", - TypeNameToString(t)))); + errmsg("SQL function cannot accept shell type %s", + TypeNameToString(t)))); else ereport(NOTICE, (errcode(ERRCODE_WRONG_OBJECT_TYPE), @@ -307,13 +307,13 @@ duplicate_error: ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("conflicting or redundant options"))); - return false; /* keep compiler quiet */ + return false; /* keep compiler quiet */ } static char interpret_func_volatility(DefElem *defel) { - char *str = strVal(defel->arg); + char *str = strVal(defel->arg); if (strcmp(str, "immutable") == 0) return PROVOLATILE_IMMUTABLE; @@ -324,7 +324,7 @@ interpret_func_volatility(DefElem *defel) else { elog(ERROR, "invalid volatility \"%s\"", str); - return 0; /* keep compiler quiet */ + return 0; /* keep compiler quiet */ } } @@ -445,8 +445,8 @@ compute_attributes_with_style(List *parameters, bool *isStrict_p, char *volatili else ereport(WARNING, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("unrecognized function attribute \"%s\" ignored", - param->defname))); + errmsg("unrecognized function attribute \"%s\" ignored", + param->defname))); } } @@ -469,8 +469,8 @@ interpret_AS_clause(Oid languageOid, const char *languageName, List *as, if (languageOid == ClanguageId) { /* - * For "C" language, store the file name in probin and, when - * given, the link symbol name in prosrc. + * For "C" language, store the file name in probin and, when given, + * the link symbol name in prosrc. */ *probin_str_p = strVal(linitial(as)); if (list_length(as) == 1) @@ -541,7 +541,7 @@ CreateFunction(CreateFunctionStmt *stmt) /* override attributes from explicit list */ compute_attributes_sql_style(stmt->options, - &as_clause, &language, &volatility, &isStrict, &security); + &as_clause, &language, &volatility, &isStrict, &security); /* Convert language name to canonical case */ languageName = case_translate_language_name(language); @@ -630,10 +630,10 @@ CreateFunction(CreateFunctionStmt *stmt) /* * In PostgreSQL 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. + * "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 (strlen(prosrc_str) == 0) prosrc_str = funcname; @@ -647,8 +647,8 @@ CreateFunction(CreateFunctionStmt *stmt) } /* - * And now that we have all the parameters, and know we're permitted - * to do so, go ahead and create the function. + * And now that we have all the parameters, and know we're permitted to do + * so, go ahead and create the function. */ ProcedureCreate(funcname, namespaceId, @@ -696,8 +696,8 @@ RemoveFunction(RemoveFuncStmt *stmt) /* Permission check: must own func or its namespace */ if (!pg_proc_ownercheck(funcOid, GetUserId()) && - !pg_namespace_ownercheck(((Form_pg_proc) GETSTRUCT(tup))->pronamespace, - GetUserId())) + !pg_namespace_ownercheck(((Form_pg_proc) GETSTRUCT(tup))->pronamespace, + GetUserId())) aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_PROC, NameListToString(functionName)); @@ -706,7 +706,7 @@ RemoveFunction(RemoveFuncStmt *stmt) (errcode(ERRCODE_WRONG_OBJECT_TYPE), errmsg("\"%s\" is an aggregate function", NameListToString(functionName)), - errhint("Use DROP AGGREGATE to drop aggregate functions."))); + errhint("Use DROP AGGREGATE to drop aggregate functions."))); if (((Form_pg_proc) GETSTRUCT(tup))->prolang == INTERNALlanguageId) { @@ -812,7 +812,7 @@ RenameFunction(List *name, List *argtypes, const char *newname) (errcode(ERRCODE_WRONG_OBJECT_TYPE), errmsg("\"%s\" is an aggregate function", NameListToString(name)), - errhint("Use ALTER AGGREGATE to rename aggregate functions."))); + errhint("Use ALTER AGGREGATE to rename aggregate functions."))); namespaceOid = procForm->pronamespace; @@ -828,7 +828,7 @@ RenameFunction(List *name, List *argtypes, const char *newname) errmsg("function %s already exists in schema \"%s\"", funcname_signature_string(newname, procForm->pronargs, - procForm->proargtypes.values), + procForm->proargtypes.values), get_namespace_name(namespaceOid)))); } @@ -900,7 +900,7 @@ AlterFunctionOwner(List *name, List *argtypes, Oid newOwnerId) if (!superuser()) { /* Otherwise, must be owner of the existing object */ - if (!pg_proc_ownercheck(procOid,GetUserId())) + if (!pg_proc_ownercheck(procOid, GetUserId())) aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_PROC, NameListToString(name)); @@ -960,14 +960,14 @@ AlterFunctionOwner(List *name, List *argtypes, Oid newOwnerId) void AlterFunction(AlterFunctionStmt *stmt) { - HeapTuple tup; - Oid funcOid; + HeapTuple tup; + Oid funcOid; Form_pg_proc procForm; - Relation rel; - ListCell *l; - DefElem *volatility_item = NULL; - DefElem *strict_item = NULL; - DefElem *security_def_item = NULL; + Relation rel; + ListCell *l; + DefElem *volatility_item = NULL; + DefElem *strict_item = NULL; + DefElem *security_def_item = NULL; rel = heap_open(ProcedureRelationId, RowExclusiveLock); @@ -995,9 +995,9 @@ AlterFunction(AlterFunctionStmt *stmt) NameListToString(stmt->func->funcname)))); /* Examine requested actions. */ - foreach (l, stmt->actions) + foreach(l, stmt->actions) { - DefElem *defel = (DefElem *) lfirst(l); + DefElem *defel = (DefElem *) lfirst(l); if (compute_common_attribute(defel, &volatility_item, @@ -1182,27 +1182,27 @@ CreateCast(CreateCastStmt *stmt) if (nargs < 1 || nargs > 3) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("cast function must take one to three arguments"))); + errmsg("cast function must take one to three arguments"))); if (procstruct->proargtypes.values[0] != sourcetypeid) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("argument of cast function must match source data type"))); + errmsg("argument of cast function must match source data type"))); if (nargs > 1 && procstruct->proargtypes.values[1] != INT4OID) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("second argument of cast function must be type integer"))); + errmsg("second argument of cast function must be type integer"))); if (nargs > 2 && procstruct->proargtypes.values[2] != BOOLOID) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("third argument of cast function must be type boolean"))); + errmsg("third argument of cast function must be type boolean"))); if (procstruct->prorettype != targettypeid) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), errmsg("return data type of cast function must match target data type"))); /* - * Restricting the volatility of a cast function may or may not be - * a good idea in the abstract, but it definitely breaks many old + * Restricting the volatility of a cast function may or may not be a + * good idea in the abstract, but it definitely breaks many old * user-defined types. Disable this check --- tgl 2/1/03 */ #ifdef NOT_USED @@ -1214,7 +1214,7 @@ CreateCast(CreateCastStmt *stmt) if (procstruct->proisagg) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("cast function must not be an aggregate function"))); + errmsg("cast function must not be an aggregate function"))); if (procstruct->proretset) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), @@ -1242,13 +1242,13 @@ CreateCast(CreateCastStmt *stmt) if (!superuser()) ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), - errmsg("must be superuser to create a cast WITHOUT FUNCTION"))); + errmsg("must be superuser to create a cast WITHOUT FUNCTION"))); /* * Also, insist that the types match as to size, alignment, and - * pass-by-value attributes; this provides at least a crude check - * that they have similar representations. A pair of types that - * fail this test should certainly not be equated. + * pass-by-value attributes; this provides at least a crude check that + * they have similar representations. A pair of types that fail this + * test should certainly not be equated. */ get_typlenbyvalalign(sourcetypeid, &typ1len, &typ1byval, &typ1align); get_typlenbyvalalign(targettypeid, &typ2len, &typ2byval, &typ2align); @@ -1267,7 +1267,7 @@ CreateCast(CreateCastStmt *stmt) if (sourcetypeid == targettypeid && nargs < 2) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("source data type and target data type are the same"))); + errmsg("source data type and target data type are the same"))); /* convert CoercionContext enum to char value for castcontext */ switch (stmt->context) @@ -1290,9 +1290,9 @@ CreateCast(CreateCastStmt *stmt) relation = heap_open(CastRelationId, RowExclusiveLock); /* - * Check for duplicate. This is just to give a friendly error - * message, the unique index would catch it anyway (so no need to - * sweat about race conditions). + * Check for duplicate. This is just to give a friendly error message, + * the unique index would catch it anyway (so no need to sweat about race + * conditions). */ tuple = SearchSysCache(CASTSOURCETARGET, ObjectIdGetDatum(sourcetypeid), @@ -1442,12 +1442,12 @@ DropCastById(Oid castOid) void AlterFunctionNamespace(List *name, List *argtypes, const char *newschema) { - Oid procOid; - Oid oldNspOid; - Oid nspOid; - HeapTuple tup; - Relation procRel; - Form_pg_proc proc; + Oid procOid; + Oid oldNspOid; + Oid nspOid; + HeapTuple tup; + Relation procRel; + Form_pg_proc proc; procRel = heap_open(ProcedureRelationId, RowExclusiveLock); @@ -1482,7 +1482,7 @@ AlterFunctionNamespace(List *name, List *argtypes, const char *newschema) if (isAnyTempNamespace(nspOid) || isAnyTempNamespace(oldNspOid)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot move objects into or out of temporary schemas"))); + errmsg("cannot move objects into or out of temporary schemas"))); /* same for TOAST schema */ if (nspOid == PG_TOAST_NAMESPACE || oldNspOid == PG_TOAST_NAMESPACE) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 6bfa8a04e2..07654e455a 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/indexcmds.c,v 1.133 2005/06/22 21:14:29 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/indexcmds.c,v 1.134 2005/10/15 02:49:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -145,10 +145,9 @@ DefineIndex(RangeVar *heapRelation, /* * Verify we (still) have CREATE rights in the rel's namespace. - * (Presumably we did when the rel was created, but maybe not - * anymore.) Skip check if caller doesn't want it. Also skip check - * if bootstrapping, since permissions machinery may not be working - * yet. + * (Presumably we did when the rel was created, but maybe not anymore.) + * Skip check if caller doesn't want it. Also skip check if + * bootstrapping, since permissions machinery may not be working yet. */ if (check_rights && !IsBootstrapProcessingMode()) { @@ -193,8 +192,8 @@ DefineIndex(RangeVar *heapRelation, } /* - * Force shared indexes into the pg_global tablespace. This is a bit of - * a hack but seems simpler than marking them in the BKI commands. + * Force shared indexes into the pg_global tablespace. This is a bit of a + * hack but seems simpler than marking them in the BKI commands. */ if (rel->rd_rel->relisshared) tablespaceId = GLOBALTABLESPACE_OID; @@ -221,8 +220,7 @@ DefineIndex(RangeVar *heapRelation, } /* - * look up the access method, verify it can handle the requested - * features + * look up the access method, verify it can handle the requested features */ tuple = SearchSysCache(AMNAME, PointerGetDatum(accessMethodName), @@ -238,13 +236,13 @@ DefineIndex(RangeVar *heapRelation, if (unique && !accessMethodForm->amcanunique) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("access method \"%s\" does not support unique indexes", - accessMethodName))); + errmsg("access method \"%s\" does not support unique indexes", + accessMethodName))); if (numberOfAttributes > 1 && !accessMethodForm->amcanmulticol) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("access method \"%s\" does not support multicolumn indexes", - accessMethodName))); + errmsg("access method \"%s\" does not support multicolumn indexes", + accessMethodName))); ReleaseSysCache(tuple); @@ -275,23 +273,23 @@ DefineIndex(RangeVar *heapRelation, ListCell *keys; /* - * If ALTER TABLE, check that there isn't already a PRIMARY KEY. - * In CREATE TABLE, we have faith that the parser rejected - * multiple pkey clauses; and CREATE INDEX doesn't have a way to - * say PRIMARY KEY, so it's no problem either. + * If ALTER TABLE, check that there isn't already a PRIMARY KEY. In + * CREATE TABLE, we have faith that the parser rejected multiple pkey + * clauses; and CREATE INDEX doesn't have a way to say PRIMARY KEY, so + * it's no problem either. */ if (is_alter_table && relationHasPrimaryKey(rel)) { ereport(ERROR, (errcode(ERRCODE_INVALID_TABLE_DEFINITION), - errmsg("multiple primary keys for table \"%s\" are not allowed", - RelationGetRelationName(rel)))); + errmsg("multiple primary keys for table \"%s\" are not allowed", + RelationGetRelationName(rel)))); } /* - * Check that all of the attributes in a primary key are marked as - * not null, otherwise attempt to ALTER TABLE .. SET NOT NULL + * Check that all of the attributes in a primary key are marked as not + * null, otherwise attempt to ALTER TABLE .. SET NOT NULL */ cmds = NIL; foreach(keys, attributeList) @@ -326,35 +324,35 @@ DefineIndex(RangeVar *heapRelation, else { /* - * This shouldn't happen during CREATE TABLE, but can - * happen during ALTER TABLE. Keep message in sync with + * This shouldn't happen during CREATE TABLE, but can happen + * during ALTER TABLE. Keep message in sync with * transformIndexConstraints() in parser/analyze.c. */ ereport(ERROR, (errcode(ERRCODE_UNDEFINED_COLUMN), - errmsg("column \"%s\" named in key does not exist", - key->name))); + errmsg("column \"%s\" named in key does not exist", + key->name))); } } /* * XXX: Shouldn't the ALTER TABLE .. SET NOT NULL cascade to child - * tables? Currently, since the PRIMARY KEY itself doesn't - * cascade, we don't cascade the notnull constraint(s) either; but - * this is pretty debatable. + * tables? Currently, since the PRIMARY KEY itself doesn't cascade, + * we don't cascade the notnull constraint(s) either; but this is + * pretty debatable. * - * XXX: possible future improvement: when being called from ALTER - * TABLE, it would be more efficient to merge this with the outer - * ALTER TABLE, so as to avoid two scans. But that seems to - * complicate DefineIndex's API unduly. + * XXX: possible future improvement: when being called from ALTER TABLE, + * it would be more efficient to merge this with the outer ALTER + * TABLE, so as to avoid two scans. But that seems to complicate + * DefineIndex's API unduly. */ if (cmds) AlterTableInternal(relationId, cmds, false); } /* - * Prepare arguments for index_create, primarily an IndexInfo - * structure. Note that ii_Predicate must be in implicit-AND format. + * Prepare arguments for index_create, primarily an IndexInfo structure. + * Note that ii_Predicate must be in implicit-AND format. */ indexInfo = makeNode(IndexInfo); indexInfo->ii_NumIndexAttrs = numberOfAttributes; @@ -372,15 +370,15 @@ DefineIndex(RangeVar *heapRelation, heap_close(rel, NoLock); /* - * Report index creation if appropriate (delay this till after most of - * the error checks) + * Report index creation if appropriate (delay this till after most of the + * error checks) */ if (isconstraint && !quiet) ereport(NOTICE, - (errmsg("%s %s will create implicit index \"%s\" for table \"%s\"", - is_alter_table ? "ALTER TABLE / ADD" : "CREATE TABLE /", - primary ? "PRIMARY KEY" : "UNIQUE", - indexRelationName, RelationGetRelationName(rel)))); + (errmsg("%s %s will create implicit index \"%s\" for table \"%s\"", + is_alter_table ? "ALTER TABLE / ADD" : "CREATE TABLE /", + primary ? "PRIMARY KEY" : "UNIQUE", + indexRelationName, RelationGetRelationName(rel)))); index_create(relationId, indexRelationName, indexRelationId, indexInfo, accessMethodId, tablespaceId, classObjectId, @@ -391,8 +389,8 @@ DefineIndex(RangeVar *heapRelation, * We update the relation's pg_class tuple even if it already has * relhasindex = true. This is needed to cause a shared-cache-inval * message to be sent for the pg_class tuple, which will cause other - * backends to flush their relcache entries and in particular their - * cached lists of the indexes for this relation. + * backends to flush their relcache entries and in particular their cached + * lists of the indexes for this relation. */ setRelhasindex(relationId, true, primary, InvalidOid); } @@ -414,8 +412,7 @@ CheckPredicate(Expr *predicate) { /* * We don't currently support generation of an actual query plan for a - * predicate, only simple scalar expressions; hence these - * restrictions. + * predicate, only simple scalar expressions; hence these restrictions. */ if (contain_subplans((Node *) predicate)) ereport(ERROR, @@ -433,7 +430,7 @@ CheckPredicate(Expr *predicate) if (contain_mutable_functions((Node *) predicate)) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("functions in index predicate must be marked IMMUTABLE"))); + errmsg("functions in index predicate must be marked IMMUTABLE"))); } static void @@ -470,8 +467,8 @@ ComputeIndexAttrs(IndexInfo *indexInfo, if (isconstraint) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_COLUMN), - errmsg("column \"%s\" named in key does not exist", - attribute->name))); + errmsg("column \"%s\" named in key does not exist", + attribute->name))); else ereport(ERROR, (errcode(ERRCODE_UNDEFINED_COLUMN), @@ -501,24 +498,23 @@ ComputeIndexAttrs(IndexInfo *indexInfo, atttype = exprType(attribute->expr); /* - * We don't currently support generation of an actual query - * plan for an index expression, only simple scalar - * expressions; hence these restrictions. + * We don't currently support generation of an actual query plan + * for an index expression, only simple scalar expressions; hence + * these restrictions. */ if (contain_subplans(attribute->expr)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot use subquery in index expression"))); + errmsg("cannot use subquery in index expression"))); if (contain_agg_clause(attribute->expr)) ereport(ERROR, (errcode(ERRCODE_GROUPING_ERROR), - errmsg("cannot use aggregate function in index expression"))); + errmsg("cannot use aggregate function in index expression"))); /* - * A expression using mutable functions is probably wrong, - * since if you aren't going to get the same result for the - * same data every time, it's not clear what the index entries - * mean at all. + * A expression using mutable functions is probably wrong, since + * if you aren't going to get the same result for the same data + * every time, it's not clear what the index entries mean at all. */ if (contain_mutable_functions(attribute->expr)) ereport(ERROR, @@ -548,16 +544,16 @@ GetIndexOpClass(List *opclass, Oid attrType, opInputType; /* - * Release 7.0 removed network_ops, timespan_ops, and datetime_ops, so - * we ignore those opclass names so the default *_ops is used. This - * can be removed in some later release. bjm 2000/02/07 + * Release 7.0 removed network_ops, timespan_ops, and datetime_ops, so we + * ignore those opclass names so the default *_ops is used. This can be + * removed in some later release. bjm 2000/02/07 * * Release 7.1 removes lztext_ops, so suppress that too for a while. tgl * 2000/07/30 * - * Release 7.2 renames timestamp_ops to timestamptz_ops, so suppress that - * too for awhile. I'm starting to think we need a better approach. - * tgl 2000/10/01 + * Release 7.2 renames timestamp_ops to timestamptz_ops, so suppress that too + * for awhile. I'm starting to think we need a better approach. tgl + * 2000/10/01 * * Release 8.0 removes bigbox_ops (which was dead code for a long while * anyway). tgl 2003/11/11 @@ -628,8 +624,8 @@ GetIndexOpClass(List *opclass, Oid attrType, NameListToString(opclass), accessMethodName))); /* - * Verify that the index operator class accepts this datatype. Note - * we will accept binary compatibility. + * Verify that the index operator class accepts this datatype. Note we + * will accept binary compatibility. */ opClassId = HeapTupleGetOid(tuple); opInputType = ((Form_pg_opclass) GETSTRUCT(tuple))->opcintype; @@ -637,8 +633,8 @@ GetIndexOpClass(List *opclass, Oid attrType, if (!IsBinaryCoercible(attrType, opInputType)) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("operator class \"%s\" does not accept data type %s", - NameListToString(opclass), format_type_be(attrType)))); + errmsg("operator class \"%s\" does not accept data type %s", + NameListToString(opclass), format_type_be(attrType)))); ReleaseSysCache(tuple); @@ -663,8 +659,8 @@ GetDefaultOpClass(Oid attrType, Oid accessMethodId) * (either exactly or binary-compatibly, but prefer an exact match). * * We could find more than one binary-compatible match, in which case we - * require the user to specify which one he wants. If we find more - * than one exact match, then someone put bogus entries in pg_opclass. + * require the user to specify which one he wants. If we find more than + * one exact match, then someone put bogus entries in pg_opclass. * * The initial search is done by namespace.c so that we only consider * opclasses visible in the current namespace search path. (See also @@ -694,8 +690,8 @@ GetDefaultOpClass(Oid attrType, Oid accessMethodId) if (nexact != 0) ereport(ERROR, (errcode(ERRCODE_DUPLICATE_OBJECT), - errmsg("there are multiple default operator classes for data type %s", - format_type_be(attrType)))); + errmsg("there are multiple default operator classes for data type %s", + format_type_be(attrType)))); if (ncompatible == 1) return compatibleOid; @@ -749,8 +745,8 @@ makeObjectName(const char *name1, const char *name2, const char *label) /* * If we must truncate, preferentially truncate the longer name. This - * logic could be expressed without a loop, but it's simple and - * obvious as a loop. + * logic could be expressed without a loop, but it's simple and obvious as + * a loop. */ while (name1chars + name2chars > availchars) { @@ -842,9 +838,9 @@ relationHasPrimaryKey(Relation rel) ListCell *indexoidscan; /* - * Get the list of index OIDs for the table from the relcache, and - * look up each one in the pg_index syscache until we find one marked - * primary key (hopefully there isn't more than one such). + * Get the list of index OIDs for the table from the relcache, and look up + * each one in the pg_index syscache until we find one marked primary key + * (hopefully there isn't more than one such). */ indexoidlist = RelationGetIndexList(rel); @@ -1004,16 +1000,16 @@ ReindexDatabase(const char *databaseName, bool do_system, bool do_user) /* * We cannot run inside a user transaction block; if we were inside a - * transaction, then our commit- and start-transaction-command calls - * would not have the intended effect! + * transaction, then our commit- and start-transaction-command calls would + * not have the intended effect! */ PreventTransactionChain((void *) databaseName, "REINDEX DATABASE"); /* - * Create a memory context that will survive forced transaction - * commits we do below. Since it is a child of PortalContext, it will - * go away eventually even if we suffer an error; there's no need for - * special abort cleanup logic. + * Create a memory context that will survive forced transaction commits we + * do below. Since it is a child of PortalContext, it will go away + * eventually even if we suffer an error; there's no need for special + * abort cleanup logic. */ private_context = AllocSetContextCreate(PortalContext, "ReindexDatabase", @@ -1022,10 +1018,10 @@ ReindexDatabase(const char *databaseName, bool do_system, bool do_user) ALLOCSET_DEFAULT_MAXSIZE); /* - * We always want to reindex pg_class first. This ensures that if - * there is any corruption in pg_class' indexes, they will be fixed - * before we process any other tables. This is critical because - * reindexing itself will try to update pg_class. + * We always want to reindex pg_class first. This ensures that if there + * is any corruption in pg_class' indexes, they will be fixed before we + * process any other tables. This is critical because reindexing itself + * will try to update pg_class. */ if (do_system) { diff --git a/src/backend/commands/lockcmds.c b/src/backend/commands/lockcmds.c index b4a87a4d39..72a61ad9c2 100644 --- a/src/backend/commands/lockcmds.c +++ b/src/backend/commands/lockcmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/lockcmds.c,v 1.12 2004/12/31 21:59:41 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/commands/lockcmds.c,v 1.13 2005/10/15 02:49:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -31,8 +31,8 @@ LockTableCommand(LockStmt *lockstmt) ListCell *p; /* - * Iterate over the list and open, lock, and close the relations one - * at a time + * Iterate over the list and open, lock, and close the relations one at a + * time */ foreach(p, lockstmt->relations) @@ -43,8 +43,8 @@ LockTableCommand(LockStmt *lockstmt) Relation rel; /* - * We don't want to open the relation until we've checked - * privilege. So, manually get the relation OID. + * We don't want to open the relation until we've checked privilege. + * So, manually get the relation OID. */ reloid = RangeVarGetRelid(relation, false); diff --git a/src/backend/commands/opclasscmds.c b/src/backend/commands/opclasscmds.c index 186fac96ed..ea8afcfccb 100644 --- a/src/backend/commands/opclasscmds.c +++ b/src/backend/commands/opclasscmds.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/opclasscmds.c,v 1.37 2005/08/23 01:41:30 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/opclasscmds.c,v 1.38 2005/10/15 02:49:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -117,16 +117,16 @@ DefineOpClass(CreateOpClassStmt *stmt) ReleaseSysCache(tup); /* - * Currently, we require superuser privileges to create an opclass. - * This seems necessary because we have no way to validate that the - * offered set of operators and functions are consistent with the AM's - * expectations. It would be nice to provide such a check someday, if - * it can be done without solving the halting problem :-( + * Currently, we require superuser privileges to create an opclass. This + * seems necessary because we have no way to validate that the offered set + * of operators and functions are consistent with the AM's expectations. + * It would be nice to provide such a check someday, if it can be done + * without solving the halting problem :-( */ if (!superuser()) ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), - errmsg("must be superuser to create an operator class"))); + errmsg("must be superuser to create an operator class"))); /* Look up the datatype */ typeoid = typenameTypeId(stmt->datatype); @@ -223,7 +223,7 @@ DefineOpClass(CreateOpClassStmt *stmt) if (OidIsValid(storageoid)) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("storage type specified more than once"))); + errmsg("storage type specified more than once"))); storageoid = typenameTypeId(item->storedtype); break; default: @@ -244,8 +244,8 @@ DefineOpClass(CreateOpClassStmt *stmt) { /* * Currently, only GiST allows storagetype different from - * datatype. This hardcoded test should be eliminated in - * favor of adding another boolean column to pg_am ... + * datatype. This hardcoded test should be eliminated in favor of + * adding another boolean column to pg_am ... */ if (amoid != GIST_AM_OID) ereport(ERROR, @@ -258,8 +258,8 @@ DefineOpClass(CreateOpClassStmt *stmt) rel = heap_open(OperatorClassRelationId, RowExclusiveLock); /* - * Make sure there is no existing opclass of this name (this is just - * to give a more friendly error message than "duplicate key"). + * Make sure there is no existing opclass of this name (this is just to + * give a more friendly error message than "duplicate key"). */ if (SearchSysCacheExists(CLAAMNAMENSP, ObjectIdGetDatum(amoid), @@ -272,10 +272,9 @@ DefineOpClass(CreateOpClassStmt *stmt) opcname, stmt->amname))); /* - * If we are creating a default opclass, check there isn't one - * already. (Note we do not restrict this test to visible opclasses; - * this ensures that typcache.c can find unique solutions to its - * questions.) + * If we are creating a default opclass, check there isn't one already. + * (Note we do not restrict this test to visible opclasses; this ensures + * that typcache.c can find unique solutions to its questions.) */ if (stmt->isDefault) { @@ -300,8 +299,8 @@ DefineOpClass(CreateOpClassStmt *stmt) errmsg("could not make operator class \"%s\" be default for type %s", opcname, TypeNameToString(stmt->datatype)), - errdetail("Operator class \"%s\" already is the default.", - NameStr(opclass->opcname)))); + errdetail("Operator class \"%s\" already is the default.", + NameStr(opclass->opcname)))); } systable_endscan(scan); @@ -321,7 +320,7 @@ DefineOpClass(CreateOpClassStmt *stmt) namestrcpy(&opcName, opcname); values[i++] = NameGetDatum(&opcName); /* opcname */ values[i++] = ObjectIdGetDatum(namespaceoid); /* opcnamespace */ - values[i++] = ObjectIdGetDatum(GetUserId()); /* opcowner */ + values[i++] = ObjectIdGetDatum(GetUserId()); /* opcowner */ values[i++] = ObjectIdGetDatum(typeoid); /* opcintype */ values[i++] = BoolGetDatum(stmt->isDefault); /* opcdefault */ values[i++] = ObjectIdGetDatum(storageoid); /* opckeytype */ @@ -342,8 +341,8 @@ DefineOpClass(CreateOpClassStmt *stmt) storeProcedures(opclassoid, procedures); /* - * Create dependencies. Note: we do not create a dependency link to - * the AM, because we don't currently support DROP ACCESS METHOD. + * Create dependencies. Note: we do not create a dependency link to the + * AM, because we don't currently support DROP ACCESS METHOD. */ myself.classId = OperatorClassRelationId; myself.objectId = opclassoid; @@ -424,8 +423,8 @@ assignOperSubtype(Oid amoid, Oid typeoid, Oid operOid) opform = (Form_pg_operator) GETSTRUCT(optup); /* - * btree operators must be binary ops returning boolean, and the - * left-side input type must match the operator class' input type. + * btree operators must be binary ops returning boolean, and the left-side + * input type must match the operator class' input type. */ if (opform->oprkind != 'b') ereport(ERROR, @@ -438,11 +437,11 @@ assignOperSubtype(Oid amoid, Oid typeoid, Oid operOid) if (opform->oprleft != typeoid) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("btree operators must have index type as left input"))); + errmsg("btree operators must have index type as left input"))); /* - * The subtype is "default" (0) if oprright matches the operator - * class, otherwise it is oprright. + * The subtype is "default" (0) if oprright matches the operator class, + * otherwise it is oprright. */ if (opform->oprright == typeoid) subtype = InvalidOid; @@ -478,8 +477,8 @@ assignProcSubtype(Oid amoid, Oid typeoid, Oid procOid) procform = (Form_pg_proc) GETSTRUCT(proctup); /* - * btree support procs must be 2-arg procs returning int4, and the - * first input type must match the operator class' input type. + * btree support procs must be 2-arg procs returning int4, and the first + * input type must match the operator class' input type. */ if (procform->pronargs != 2) ereport(ERROR, @@ -492,11 +491,11 @@ assignProcSubtype(Oid amoid, Oid typeoid, Oid procOid) if (procform->proargtypes.values[0] != typeoid) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("btree procedures must have index type as first input"))); + errmsg("btree procedures must have index type as first input"))); /* - * The subtype is "default" (0) if second input type matches the - * operator class, otherwise it is the second input type. + * The subtype is "default" (0) if second input type matches the operator + * class, otherwise it is the second input type. */ if (procform->proargtypes.values[1] == typeoid) subtype = InvalidOid; @@ -525,13 +524,13 @@ addClassMember(List **list, OpClassMember *member, bool isProc) if (isProc) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("procedure number %d appears more than once", - member->number))); + errmsg("procedure number %d appears more than once", + member->number))); else ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("operator number %d appears more than once", - member->number))); + errmsg("operator number %d appears more than once", + member->number))); } } *list = lappend(*list, member); @@ -688,7 +687,7 @@ RemoveOpClass(RemoveOpClassStmt *stmt) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("operator class \"%s\" does not exist for access method \"%s\"", - NameListToString(stmt->opclassname), stmt->amname))); + NameListToString(stmt->opclassname), stmt->amname))); opcID = HeapTupleGetOid(tuple); @@ -956,7 +955,7 @@ AlterOpClassOwner(List *name, const char *access_method, Oid newOwnerId) if (!superuser()) { /* Otherwise, must be owner of the existing object */ - if (!pg_opclass_ownercheck(HeapTupleGetOid(tup),GetUserId())) + if (!pg_opclass_ownercheck(HeapTupleGetOid(tup), GetUserId())) aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_OPCLASS, NameListToString(name)); @@ -972,8 +971,7 @@ AlterOpClassOwner(List *name, const char *access_method, Oid newOwnerId) } /* - * Modify the owner --- okay to scribble on tup because it's a - * copy + * Modify the owner --- okay to scribble on tup because it's a copy */ opcForm->opcowner = newOwnerId; diff --git a/src/backend/commands/operatorcmds.c b/src/backend/commands/operatorcmds.c index f9db742e84..07877962e3 100644 --- a/src/backend/commands/operatorcmds.c +++ b/src/backend/commands/operatorcmds.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/operatorcmds.c,v 1.25 2005/08/22 17:38:20 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/operatorcmds.c,v 1.26 2005/10/15 02:49:15 momjian Exp $ * * DESCRIPTION * The "DefineFoo" routines take the parse tree and pick out the @@ -69,11 +69,9 @@ DefineOperator(List *names, List *parameters) TypeName *typeName2 = NULL; /* second type name */ Oid typeId1 = InvalidOid; /* types converted to OID */ Oid typeId2 = InvalidOid; - List *commutatorName = NIL; /* optional commutator operator - * name */ + List *commutatorName = NIL; /* optional commutator operator name */ List *negatorName = NIL; /* optional negator operator name */ - List *restrictionName = NIL; /* optional restrict. sel. - * procedure */ + List *restrictionName = NIL; /* optional restrict. sel. procedure */ List *joinName = NIL; /* optional join sel. procedure */ List *leftSortName = NIL; /* optional left sort operator */ List *rightSortName = NIL; /* optional right sort operator */ @@ -103,7 +101,7 @@ DefineOperator(List *names, List *parameters) if (typeName1->setof) ereport(ERROR, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), - errmsg("setof type not allowed for operator argument"))); + errmsg("setof type not allowed for operator argument"))); } else if (pg_strcasecmp(defel->defname, "rightarg") == 0) { @@ -111,7 +109,7 @@ DefineOperator(List *names, List *parameters) if (typeName2->setof) ereport(ERROR, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), - errmsg("setof type not allowed for operator argument"))); + errmsg("setof type not allowed for operator argument"))); } else if (pg_strcasecmp(defel->defname, "procedure") == 0) functionName = defGetQualifiedName(defel); @@ -157,8 +155,8 @@ DefineOperator(List *names, List *parameters) typeId2 = typenameTypeId(typeName2); /* - * If any of the mergejoin support operators were given, then canMerge - * is implicit. If canMerge is specified or implicit, fill in default + * If any of the mergejoin support operators were given, then canMerge is + * implicit. If canMerge is specified or implicit, fill in default * operator names for any missing mergejoin support operators. */ if (leftSortName || rightSortName || ltCompareName || gtCompareName) @@ -184,11 +182,9 @@ DefineOperator(List *names, List *parameters) typeId1, /* left type id */ typeId2, /* right type id */ functionName, /* function for operator */ - commutatorName, /* optional commutator operator - * name */ + commutatorName, /* optional commutator operator name */ negatorName, /* optional negator operator name */ - restrictionName, /* optional restrict. sel. - * procedure */ + restrictionName, /* optional restrict. sel. procedure */ joinName, /* optional join sel. procedure name */ canHash, /* operator hashes */ leftSortName, /* optional left sort operator */ @@ -300,7 +296,7 @@ AlterOperatorOwner(List *name, TypeName *typeName1, TypeName *typeName2, if (!superuser()) { /* Otherwise, must be owner of the existing object */ - if (!pg_oper_ownercheck(operOid,GetUserId())) + if (!pg_oper_ownercheck(operOid, GetUserId())) aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_OPER, NameListToString(name)); @@ -317,8 +313,7 @@ AlterOperatorOwner(List *name, TypeName *typeName1, TypeName *typeName2, } /* - * Modify the owner --- okay to scribble on tup because it's a - * copy + * Modify the owner --- okay to scribble on tup because it's a copy */ oprForm->oprowner = newOwnerId; diff --git a/src/backend/commands/portalcmds.c b/src/backend/commands/portalcmds.c index 0ff5366613..e68d221f01 100644 --- a/src/backend/commands/portalcmds.c +++ b/src/backend/commands/portalcmds.c @@ -14,7 +14,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/portalcmds.c,v 1.42 2005/06/03 23:05:28 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/portalcmds.c,v 1.43 2005/10/15 02:49:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -54,27 +54,26 @@ PerformCursorOpen(DeclareCursorStmt *stmt, ParamListInfo params) errmsg("invalid cursor name: must not be empty"))); /* - * If this is a non-holdable cursor, we require that this statement - * has been executed inside a transaction block (or else, it would - * have no user-visible effect). + * If this is a non-holdable cursor, we require that this statement has + * been executed inside a transaction block (or else, it would have no + * user-visible effect). */ if (!(stmt->options & CURSOR_OPT_HOLD)) RequireTransactionChain((void *) stmt, "DECLARE CURSOR"); /* - * Because the planner is not cool about not scribbling on its input, - * we make a preliminary copy of the source querytree. This prevents + * Because the planner is not cool about not scribbling on its input, we + * make a preliminary copy of the source querytree. This prevents * problems in the case that the DECLARE CURSOR is in a portal and is - * executed repeatedly. XXX the planner really shouldn't modify its - * input ... FIXME someday. + * executed repeatedly. XXX the planner really shouldn't modify its input + * ... FIXME someday. */ query = copyObject(stmt->query); /* * The query has been through parse analysis, but not rewriting or - * planning as yet. Note that the grammar ensured we have a SELECT - * query, so we are not expecting rule rewriting to do anything - * strange. + * planning as yet. Note that the grammar ensured we have a SELECT query, + * so we are not expecting rule rewriting to do anything strange. */ AcquireRewriteLocks(query); rewritten = QueryRewrite(query); @@ -91,14 +90,13 @@ PerformCursorOpen(DeclareCursorStmt *stmt, ParamListInfo params) if (query->rowMarks != NIL) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("DECLARE CURSOR ... FOR UPDATE/SHARE is not supported"), + errmsg("DECLARE CURSOR ... FOR UPDATE/SHARE is not supported"), errdetail("Cursors must be READ ONLY."))); plan = planner(query, true, stmt->options, NULL); /* - * Create a portal and copy the query and plan into its memory - * context. + * Create a portal and copy the query and plan into its memory context. */ portal = CreatePortal(stmt->portalname, false, false); @@ -116,11 +114,10 @@ PerformCursorOpen(DeclareCursorStmt *stmt, ParamListInfo params) /* * Also copy the outer portal's parameter list into the inner portal's - * memory context. We want to pass down the parameter values in case - * we had a command like DECLARE c CURSOR FOR SELECT ... WHERE foo = - * $1 This will have been parsed using the outer parameter set and the - * parameter value needs to be preserved for use when the cursor is - * executed. + * memory context. We want to pass down the parameter values in case we + * had a command like DECLARE c CURSOR FOR SELECT ... WHERE foo = $1 This + * will have been parsed using the outer parameter set and the parameter + * value needs to be preserved for use when the cursor is executed. */ params = copyParamList(params); @@ -130,8 +127,8 @@ PerformCursorOpen(DeclareCursorStmt *stmt, ParamListInfo params) * Set up options for portal. * * If the user didn't specify a SCROLL type, allow or disallow scrolling - * based on whether it would require any additional runtime overhead - * to do so. + * based on whether it would require any additional runtime overhead to do + * so. */ portal->cursorOptions = stmt->options; if (!(portal->cursorOptions & (CURSOR_OPT_SCROLL | CURSOR_OPT_NO_SCROLL))) @@ -150,8 +147,8 @@ PerformCursorOpen(DeclareCursorStmt *stmt, ParamListInfo params) Assert(portal->strategy == PORTAL_ONE_SELECT); /* - * We're done; the query won't actually be run until - * PerformPortalFetch is called. + * We're done; the query won't actually be run until PerformPortalFetch is + * called. */ } @@ -189,7 +186,7 @@ PerformPortalFetch(FetchStmt *stmt, { ereport(ERROR, (errcode(ERRCODE_UNDEFINED_CURSOR), - errmsg("cursor \"%s\" does not exist", stmt->portalname))); + errmsg("cursor \"%s\" does not exist", stmt->portalname))); return; /* keep compiler happy */ } @@ -264,10 +261,9 @@ PortalCleanup(Portal portal) AssertArg(portal->cleanup == PortalCleanup); /* - * Shut down executor, if still running. We skip this during error - * abort, since other mechanisms will take care of releasing executor - * resources, and we can't be sure that ExecutorEnd itself wouldn't - * fail. + * Shut down executor, if still running. We skip this during error abort, + * since other mechanisms will take care of releasing executor resources, + * and we can't be sure that ExecutorEnd itself wouldn't fail. */ queryDesc = PortalGetQueryDesc(portal); if (queryDesc) @@ -367,9 +363,8 @@ PersistHoldablePortal(Portal portal) MemoryContextSwitchTo(PortalContext); /* - * Rewind the executor: we need to store the entire result set in - * the tuplestore, so that subsequent backward FETCHs can be - * processed. + * Rewind the executor: we need to store the entire result set in the + * tuplestore, so that subsequent backward FETCHs can be processed. */ ExecutorRewind(queryDesc); @@ -391,10 +386,10 @@ PersistHoldablePortal(Portal portal) /* * Reset the position in the result set: ideally, this could be - * implemented by just skipping straight to the tuple # that we - * need to be at, but the tuplestore API doesn't support that. So - * we start at the beginning of the tuplestore and iterate through - * it until we reach where we need to be. FIXME someday? + * implemented by just skipping straight to the tuple # that we need + * to be at, but the tuplestore API doesn't support that. So we start + * at the beginning of the tuplestore and iterate through it until we + * reach where we need to be. FIXME someday? */ MemoryContextSwitchTo(portal->holdContext); @@ -404,8 +399,8 @@ PersistHoldablePortal(Portal portal) if (portal->posOverflow) /* oops, cannot trust portalPos */ ereport(ERROR, - (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), - errmsg("could not reposition held cursor"))); + (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), + errmsg("could not reposition held cursor"))); tuplestore_rescan(portal->holdStore); @@ -453,10 +448,10 @@ PersistHoldablePortal(Portal portal) QueryContext = saveQueryContext; /* - * We can now release any subsidiary memory of the portal's heap - * context; we'll never use it again. The executor already dropped - * its context, but this will clean up anything that glommed onto the - * portal's heap via PortalContext. + * We can now release any subsidiary memory of the portal's heap context; + * we'll never use it again. The executor already dropped its context, + * but this will clean up anything that glommed onto the portal's heap via + * PortalContext. */ MemoryContextDeleteChildren(PortalGetHeapMemory(portal)); } diff --git a/src/backend/commands/prepare.c b/src/backend/commands/prepare.c index dec3d249df..5420da4a62 100644 --- a/src/backend/commands/prepare.c +++ b/src/backend/commands/prepare.c @@ -10,7 +10,7 @@ * Copyright (c) 2002-2005, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.40 2005/06/22 17:45:45 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.41 2005/10/15 02:49:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -84,17 +84,17 @@ PrepareQuery(PrepareStmt *stmt) } /* - * Parse analysis is already done, but we must still rewrite and plan - * the query. + * Parse analysis is already done, but we must still rewrite and plan the + * query. */ /* - * Because the planner is not cool about not scribbling on its input, - * we make a preliminary copy of the source querytree. This prevents + * Because the planner is not cool about not scribbling on its input, we + * make a preliminary copy of the source querytree. This prevents * problems in the case that the PREPARE is in a portal or plpgsql * function and is executed repeatedly. (See also the same hack in - * DECLARE CURSOR and EXPLAIN.) XXX the planner really shouldn't - * modify its input ... FIXME someday. + * DECLARE CURSOR and EXPLAIN.) XXX the planner really shouldn't modify + * its input ... FIXME someday. */ query = copyObject(stmt->query); @@ -106,8 +106,8 @@ PrepareQuery(PrepareStmt *stmt) plan_list = pg_plan_queries(query_list, NULL, false); /* - * Save the results. We don't have the query string for this PREPARE, - * but we do have the string we got from the client, so use that. + * Save the results. We don't have the query string for this PREPARE, but + * we do have the string we got from the client, so use that. */ StorePreparedStatement(stmt->name, debug_query_string, @@ -146,8 +146,8 @@ ExecuteQuery(ExecuteStmt *stmt, DestReceiver *dest, char *completionTag) if (entry->argtype_list != NIL) { /* - * Need an EState to evaluate parameters; must not delete it till - * end of query, in case parameters are pass-by-reference. + * Need an EState to evaluate parameters; must not delete it till end + * of query, in case parameters are pass-by-reference. */ estate = CreateExecutorState(); paramLI = EvaluateParams(estate, stmt->params, entry->argtype_list); @@ -159,10 +159,10 @@ ExecuteQuery(ExecuteStmt *stmt, DestReceiver *dest, char *completionTag) portal = CreateNewPortal(); /* - * For CREATE TABLE / AS EXECUTE, make a copy of the stored query so - * that we can modify its destination (yech, but this has always been - * ugly). For regular EXECUTE we can just use the stored query where - * it sits, since the executor is read-only. + * For CREATE TABLE / AS EXECUTE, make a copy of the stored query so that + * we can modify its destination (yech, but this has always been ugly). + * For regular EXECUTE we can just use the stored query where it sits, + * since the executor is read-only. */ if (stmt->into) { @@ -245,7 +245,7 @@ EvaluateParams(EState *estate, List *params, List *argtypes) bool isNull; paramLI[i].value = ExecEvalExprSwitchContext(n, - GetPerTupleExprContext(estate), + GetPerTupleExprContext(estate), &isNull, NULL); paramLI[i].kind = PARAM_NUM; @@ -333,8 +333,8 @@ StorePreparedStatement(const char *stmt_name, /* * We need to copy the data so that it is stored in the correct memory * context. Do this before making hashtable entry, so that an - * out-of-memory failure only wastes memory and doesn't leave us with - * an incomplete (ie corrupt) hashtable entry. + * out-of-memory failure only wastes memory and doesn't leave us with an + * incomplete (ie corrupt) hashtable entry. */ qstring = query_string ? pstrdup(query_string) : NULL; query_list = (List *) copyObject(query_list); @@ -380,9 +380,9 @@ FetchPreparedStatement(const char *stmt_name, bool throwError) if (prepared_queries) { /* - * We can't just use the statement name as supplied by the user: - * the hash package is picky enough that it needs to be - * NULL-padded out to the appropriate length to work correctly. + * We can't just use the statement name as supplied by the user: the + * hash package is picky enough that it needs to be NULL-padded out to + * the appropriate length to work correctly. */ StrNCpy(key, stmt_name, sizeof(key)); @@ -447,7 +447,7 @@ FetchPreparedStatementResultDesc(PreparedStatement *stmt) /* * Given a prepared statement that returns tuples, extract the query - * targetlist. Returns NIL if the statement doesn't have a determinable + * targetlist. Returns NIL if the statement doesn't have a determinable * targetlist. * * Note: do not modify the result. @@ -464,31 +464,31 @@ FetchPreparedStatementTargetList(PreparedStatement *stmt) return ((Query *) linitial(stmt->query_list))->targetList; if (strategy == PORTAL_UTIL_SELECT) { - Node *utilityStmt; + Node *utilityStmt; utilityStmt = ((Query *) linitial(stmt->query_list))->utilityStmt; switch (nodeTag(utilityStmt)) { case T_FetchStmt: - { - FetchStmt *substmt = (FetchStmt *) utilityStmt; - Portal subportal; + { + FetchStmt *substmt = (FetchStmt *) utilityStmt; + Portal subportal; - Assert(!substmt->ismove); - subportal = GetPortalByName(substmt->portalname); - Assert(PortalIsValid(subportal)); - return FetchPortalTargetList(subportal); - } + Assert(!substmt->ismove); + subportal = GetPortalByName(substmt->portalname); + Assert(PortalIsValid(subportal)); + return FetchPortalTargetList(subportal); + } case T_ExecuteStmt: - { - ExecuteStmt *substmt = (ExecuteStmt *) utilityStmt; - PreparedStatement *entry; + { + ExecuteStmt *substmt = (ExecuteStmt *) utilityStmt; + PreparedStatement *entry; - Assert(!substmt->into); - entry = FetchPreparedStatement(substmt->name, true); - return FetchPreparedStatementTargetList(entry); - } + Assert(!substmt->into); + entry = FetchPreparedStatement(substmt->name, true); + return FetchPreparedStatementTargetList(entry); + } default: break; @@ -564,8 +564,8 @@ ExplainExecuteQuery(ExplainStmt *stmt, TupOutputState *tstate) if (entry->argtype_list != NIL) { /* - * Need an EState to evaluate parameters; must not delete it till - * end of query, in case parameters are pass-by-reference. + * Need an EState to evaluate parameters; must not delete it till end + * of query, in case parameters are pass-by-reference. */ estate = CreateExecutorState(); paramLI = EvaluateParams(estate, execstmt->params, @@ -597,7 +597,7 @@ ExplainExecuteQuery(ExplainStmt *stmt, TupOutputState *tstate) if (query->commandType != CMD_SELECT) ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), - errmsg("prepared statement is not a SELECT"))); + errmsg("prepared statement is not a SELECT"))); /* Copy the query so we can modify it */ query = copyObject(query); diff --git a/src/backend/commands/proclang.c b/src/backend/commands/proclang.c index 4155dc179a..b13f7234db 100644 --- a/src/backend/commands/proclang.c +++ b/src/backend/commands/proclang.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/proclang.c,v 1.62 2005/09/08 20:07:42 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/proclang.c,v 1.63 2005/10/15 02:49:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -44,7 +44,7 @@ typedef struct } PLTemplate; static void create_proc_lang(const char *languageName, - Oid handlerOid, Oid valOid, bool trusted); + Oid handlerOid, Oid valOid, bool trusted); static PLTemplate *find_language_template(const char *languageName); @@ -68,7 +68,7 @@ CreateProceduralLanguage(CreatePLangStmt *stmt) if (!superuser()) ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), - errmsg("must be superuser to create procedural language"))); + errmsg("must be superuser to create procedural language"))); /* * Translate the language name and check that this language doesn't @@ -89,7 +89,7 @@ CreateProceduralLanguage(CreatePLangStmt *stmt) */ if ((pltemplate = find_language_template(languageName)) != NULL) { - List *funcname; + List *funcname; /* * Give a notice if we are ignoring supplied parameters. @@ -99,9 +99,9 @@ CreateProceduralLanguage(CreatePLangStmt *stmt) (errmsg("using pg_pltemplate information instead of CREATE LANGUAGE parameters"))); /* - * Find or create the handler function, which we force to be in - * the pg_catalog schema. If already present, it must have the - * correct return type. + * Find or create the handler function, which we force to be in the + * pg_catalog schema. If already present, it must have the correct + * return type. */ funcname = SystemFuncName(pltemplate->tmplhandler); handlerOid = LookupFuncName(funcname, 0, funcargtypes, true); @@ -111,23 +111,23 @@ CreateProceduralLanguage(CreatePLangStmt *stmt) if (funcrettype != LANGUAGE_HANDLEROID) ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), - errmsg("function %s must return type \"language_handler\"", - NameListToString(funcname)))); + errmsg("function %s must return type \"language_handler\"", + NameListToString(funcname)))); } else { handlerOid = ProcedureCreate(pltemplate->tmplhandler, PG_CATALOG_NAMESPACE, - false, /* replace */ - false, /* returnsSet */ + false, /* replace */ + false, /* returnsSet */ LANGUAGE_HANDLEROID, ClanguageId, F_FMGR_C_VALIDATOR, pltemplate->tmplhandler, pltemplate->tmpllibrary, - false, /* isAgg */ - false, /* security_definer */ - false, /* isStrict */ + false, /* isAgg */ + false, /* security_definer */ + false, /* isStrict */ PROVOLATILE_VOLATILE, buildoidvector(funcargtypes, 0), PointerGetDatum(NULL), @@ -148,16 +148,16 @@ CreateProceduralLanguage(CreatePLangStmt *stmt) { valOid = ProcedureCreate(pltemplate->tmplvalidator, PG_CATALOG_NAMESPACE, - false, /* replace */ - false, /* returnsSet */ + false, /* replace */ + false, /* returnsSet */ VOIDOID, ClanguageId, F_FMGR_C_VALIDATOR, pltemplate->tmplvalidator, pltemplate->tmpllibrary, - false, /* isAgg */ - false, /* security_definer */ - false, /* isStrict */ + false, /* isAgg */ + false, /* security_definer */ + false, /* isStrict */ PROVOLATILE_VOLATILE, buildoidvector(funcargtypes, 1), PointerGetDatum(NULL), @@ -175,9 +175,9 @@ CreateProceduralLanguage(CreatePLangStmt *stmt) else { /* - * No template, so use the provided information. If there's - * no handler clause, the user is trying to rely on a template - * that we don't have, so complain accordingly. + * No template, so use the provided information. If there's no + * handler clause, the user is trying to rely on a template that we + * don't have, so complain accordingly. */ if (!stmt->plhandler) ereport(ERROR, @@ -210,8 +210,8 @@ CreateProceduralLanguage(CreatePLangStmt *stmt) else ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), - errmsg("function %s must return type \"language_handler\"", - NameListToString(stmt->plhandler)))); + errmsg("function %s must return type \"language_handler\"", + NameListToString(stmt->plhandler)))); } /* validate the validator function */ @@ -385,7 +385,7 @@ DropProceduralLanguage(DropPLangStmt *stmt) if (!superuser()) ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), - errmsg("must be superuser to drop procedural language"))); + errmsg("must be superuser to drop procedural language"))); /* * Translate the language name, check that the language exists @@ -471,7 +471,7 @@ RenameLanguage(const char *oldname, const char *newname) if (!superuser()) ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), - errmsg("must be superuser to rename procedural language"))); + errmsg("must be superuser to rename procedural language"))); /* rename */ namestrcpy(&(((Form_pg_language) GETSTRUCT(tup))->lanname), newname); diff --git a/src/backend/commands/schemacmds.c b/src/backend/commands/schemacmds.c index f0ae06f15c..56a3359a53 100644 --- a/src/backend/commands/schemacmds.c +++ b/src/backend/commands/schemacmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/schemacmds.c,v 1.34 2005/08/22 17:38:20 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/schemacmds.c,v 1.35 2005/10/15 02:49:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -42,8 +42,8 @@ CreateSchemaCommand(CreateSchemaStmt *stmt) Oid namespaceId; List *parsetree_list; ListCell *parsetree_item; - Oid owner_uid; - Oid saved_uid; + Oid owner_uid; + Oid saved_uid; AclResult aclresult; saved_uid = GetUserId(); @@ -60,8 +60,8 @@ CreateSchemaCommand(CreateSchemaStmt *stmt) * To create a schema, must have schema-create privilege on the current * database and must be able to become the target role (this does not * imply that the target role itself must have create-schema privilege). - * The latter provision guards against "giveaway" attacks. Note that - * a superuser will always have both of these privileges a fortiori. + * The latter provision guards against "giveaway" attacks. Note that a + * superuser will always have both of these privileges a fortiori. */ aclresult = pg_database_aclcheck(MyDatabaseId, saved_uid, ACL_CREATE); if (aclresult != ACLCHECK_OK) @@ -75,15 +75,15 @@ CreateSchemaCommand(CreateSchemaStmt *stmt) ereport(ERROR, (errcode(ERRCODE_RESERVED_NAME), errmsg("unacceptable schema name \"%s\"", schemaName), - errdetail("The prefix \"pg_\" is reserved for system schemas."))); + errdetail("The prefix \"pg_\" is reserved for system schemas."))); /* * If the requested authorization is different from the current user, - * temporarily set the current user so that the object(s) will be - * created with the correct ownership. + * temporarily set the current user so that the object(s) will be created + * with the correct ownership. * - * (The setting will revert to session user on error or at the end of - * this routine.) + * (The setting will revert to session user on error or at the end of this + * routine.) */ if (saved_uid != owner_uid) SetUserId(owner_uid); @@ -95,19 +95,18 @@ CreateSchemaCommand(CreateSchemaStmt *stmt) CommandCounterIncrement(); /* - * Temporarily make the new namespace be the front of the search path, - * as well as the default creation target namespace. This will be - * undone at the end of this routine, or upon error. + * Temporarily make the new namespace be the front of the search path, as + * well as the default creation target namespace. This will be undone at + * the end of this routine, or upon error. */ PushSpecialNamespace(namespaceId); /* - * Examine the list of commands embedded in the CREATE SCHEMA command, - * and reorganize them into a sequentially executable order with no - * forward references. Note that the result is still a list of raw - * parsetrees in need of parse analysis --- we cannot, in general, run - * analyze.c on one statement until we have actually executed the - * prior ones. + * Examine the list of commands embedded in the CREATE SCHEMA command, and + * reorganize them into a sequentially executable order with no forward + * references. Note that the result is still a list of raw parsetrees in + * need of parse analysis --- we cannot, in general, run analyze.c on one + * statement until we have actually executed the prior ones. */ parsetree_list = analyzeCreateSchemaStmt(stmt); @@ -174,8 +173,8 @@ RemoveSchema(List *names, DropBehavior behavior) namespaceName); /* - * Do the deletion. Objects contained in the schema are removed by - * means of their dependency links to the schema. + * Do the deletion. Objects contained in the schema are removed by means + * of their dependency links to the schema. */ object.classId = NamespaceRelationId; object.objectId = namespaceId; @@ -254,7 +253,7 @@ RenameSchema(const char *oldname, const char *newname) ereport(ERROR, (errcode(ERRCODE_RESERVED_NAME), errmsg("unacceptable schema name \"%s\"", newname), - errdetail("The prefix \"pg_\" is reserved for system schemas."))); + errdetail("The prefix \"pg_\" is reserved for system schemas."))); /* rename */ namestrcpy(&(((Form_pg_namespace) GETSTRUCT(tup))->nspname), newname); @@ -302,21 +301,21 @@ AlterSchemaOwner(const char *name, Oid newOwnerId) AclResult aclresult; /* Otherwise, must be owner of the existing object */ - if (!pg_namespace_ownercheck(HeapTupleGetOid(tup),GetUserId())) + if (!pg_namespace_ownercheck(HeapTupleGetOid(tup), GetUserId())) aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_NAMESPACE, name); /* Must be able to become new owner */ - check_is_member_of_role(GetUserId(),newOwnerId); + check_is_member_of_role(GetUserId(), newOwnerId); /* * must have create-schema rights * - * NOTE: This is different from other alter-owner checks in - * that the current user is checked for create privileges - * instead of the destination owner. This is consistent - * with the CREATE case for schemas. Because superusers - * will always have this right, we need no special case for them. + * NOTE: This is different from other alter-owner checks in that the + * current user is checked for create privileges instead of the + * destination owner. This is consistent with the CREATE case for + * schemas. Because superusers will always have this right, we need + * no special case for them. */ aclresult = pg_database_aclcheck(MyDatabaseId, GetUserId(), ACL_CREATE); diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c index 9bf801f230..201fcbf0c6 100644 --- a/src/backend/commands/sequence.c +++ b/src/backend/commands/sequence.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/sequence.c,v 1.124 2005/10/02 23:50:08 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/sequence.c,v 1.125 2005/10/15 02:49:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -219,17 +219,17 @@ DefineSequence(CreateSeqStmt *seq) /* * Two special hacks here: * - * 1. Since VACUUM does not process sequences, we have to force the tuple - * to have xmin = FrozenTransactionId now. Otherwise it would become + * 1. Since VACUUM does not process sequences, we have to force the tuple to + * have xmin = FrozenTransactionId now. Otherwise it would become * invisible to SELECTs after 2G transactions. It is okay to do this * because if the current transaction aborts, no other xact will ever * examine the sequence tuple anyway. * - * 2. Even though heap_insert emitted a WAL log record, we have to emit - * an XLOG_SEQ_LOG record too, since (a) the heap_insert record will - * not have the right xmin, and (b) REDO of the heap_insert record - * would re-init page and sequence magic number would be lost. This - * means two log records instead of one :-( + * 2. Even though heap_insert emitted a WAL log record, we have to emit an + * XLOG_SEQ_LOG record too, since (a) the heap_insert record will not have + * the right xmin, and (b) REDO of the heap_insert record would re-init + * page and sequence magic number would be lost. This means two log + * records instead of one :-( */ LockBuffer(buf, BUFFER_LOCK_EXCLUSIVE); @@ -237,12 +237,11 @@ DefineSequence(CreateSeqStmt *seq) { /* - * Note that the "tuple" structure is still just a local tuple - * record created by heap_formtuple; its t_data pointer doesn't - * point at the disk buffer. To scribble on the disk buffer we - * need to fetch the item pointer. But do the same to the local - * tuple, since that will be the source for the WAL log record, - * below. + * Note that the "tuple" structure is still just a local tuple record + * created by heap_formtuple; its t_data pointer doesn't point at the + * disk buffer. To scribble on the disk buffer we need to fetch the + * item pointer. But do the same to the local tuple, since that will + * be the source for the WAL log record, below. */ ItemId itemId; Item item; @@ -334,8 +333,8 @@ AlterSequence(AlterSeqStmt *stmt) /* Clear local cache so that we don't think we have cached numbers */ elm->last = new.last_value; /* last returned number */ - elm->cached = new.last_value; /* last cached number (forget - * cached values) */ + elm->cached = new.last_value; /* last cached number (forget cached + * values) */ START_CRIT_SECTION(); @@ -456,14 +455,14 @@ nextval_internal(Oid relid) } /* - * Decide whether we should emit a WAL log record. If so, force up - * the fetch count to grab SEQ_LOG_VALS more values than we actually - * need to cache. (These will then be usable without logging.) + * Decide whether we should emit a WAL log record. If so, force up the + * fetch count to grab SEQ_LOG_VALS more values than we actually need to + * cache. (These will then be usable without logging.) * - * If this is the first nextval after a checkpoint, we must force a new - * WAL record to be written anyway, else replay starting from the - * checkpoint would fail to advance the sequence past the logged - * values. In this case we may as well fetch extra values. + * If this is the first nextval after a checkpoint, we must force a new WAL + * record to be written anyway, else replay starting from the checkpoint + * would fail to advance the sequence past the logged values. In this + * case we may as well fetch extra values. */ if (log < fetch) { @@ -486,8 +485,8 @@ nextval_internal(Oid relid) while (fetch) /* try to fetch cache [+ log ] numbers */ { /* - * Check MAXVALUE for ascending sequences and MINVALUE for - * descending sequences + * Check MAXVALUE for ascending sequences and MINVALUE for descending + * sequences */ if (incby > 0) { @@ -503,9 +502,9 @@ nextval_internal(Oid relid) snprintf(buf, sizeof(buf), INT64_FORMAT, maxv); ereport(ERROR, - (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), - errmsg("nextval: reached maximum value of sequence \"%s\" (%s)", - RelationGetRelationName(seqrel), buf))); + (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), + errmsg("nextval: reached maximum value of sequence \"%s\" (%s)", + RelationGetRelationName(seqrel), buf))); } next = minv; } @@ -526,9 +525,9 @@ nextval_internal(Oid relid) snprintf(buf, sizeof(buf), INT64_FORMAT, minv); ereport(ERROR, - (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), - errmsg("nextval: reached minimum value of sequence \"%s\" (%s)", - RelationGetRelationName(seqrel), buf))); + (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), + errmsg("nextval: reached minimum value of sequence \"%s\" (%s)", + RelationGetRelationName(seqrel), buf))); } next = maxv; } @@ -721,8 +720,7 @@ do_setval(Oid relid, int64 next, bool iscalled) /* save info in local cache */ elm->last = next; /* last returned number */ - elm->cached = next; /* last cached number (forget cached - * values) */ + elm->cached = next; /* last cached number (forget cached values) */ START_CRIT_SECTION(); @@ -805,7 +803,7 @@ setval3_oid(PG_FUNCTION_ARGS) /* * If we haven't touched the sequence already in this transaction, - * we need to acquire AccessShareLock. We arrange for the lock to + * we need to acquire AccessShareLock. We arrange for the lock to * be owned by the top transaction, so that we don't need to do it * more than once per xact. */ @@ -869,15 +867,15 @@ init_sequence(Oid relid, SeqTable *p_elm, Relation *p_rel) /* * Allocate new seqtable entry if we didn't find one. * - * NOTE: seqtable entries remain in the list for the life of a backend. - * If the sequence itself is deleted then the entry becomes wasted - * memory, but it's small enough that this should not matter. + * NOTE: seqtable entries remain in the list for the life of a backend. If + * the sequence itself is deleted then the entry becomes wasted memory, + * but it's small enough that this should not matter. */ if (elm == NULL) { /* - * Time to make a new seqtable entry. These entries live as long - * as the backend does, so we use plain malloc for them. + * Time to make a new seqtable entry. These entries live as long as + * the backend does, so we use plain malloc for them. */ elm = (SeqTable) malloc(sizeof(SeqTableData)); if (elm == NULL) @@ -1094,8 +1092,8 @@ init_params(List *options, Form_pg_sequence new, bool isInit) snprintf(bufm, sizeof(bufm), INT64_FORMAT, new->min_value); ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("START value (%s) can't be less than MINVALUE (%s)", - bufs, bufm))); + errmsg("START value (%s) can't be less than MINVALUE (%s)", + bufs, bufm))); } if (new->last_value > new->max_value) { @@ -1106,8 +1104,8 @@ init_params(List *options, Form_pg_sequence new, bool isInit) snprintf(bufm, sizeof(bufm), INT64_FORMAT, new->max_value); ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("START value (%s) can't be greater than MAXVALUE (%s)", - bufs, bufm))); + errmsg("START value (%s) can't be greater than MAXVALUE (%s)", + bufs, bufm))); } /* CACHE */ @@ -1152,7 +1150,7 @@ seq_redo(XLogRecPtr lsn, XLogRecord *record) buffer = XLogReadBuffer(true, reln, 0); if (!BufferIsValid(buffer)) elog(PANIC, "seq_redo: can't read block 0 of rel %u/%u/%u", - xlrec->node.spcNode, xlrec->node.dbNode, xlrec->node.relNode); + xlrec->node.spcNode, xlrec->node.dbNode, xlrec->node.relNode); page = (Page) BufferGetPage(buffer); diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 7df645af9d..abec1a835d 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.173 2005/10/03 02:45:12 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.174 2005/10/15 02:49:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -164,10 +164,10 @@ static int findAttrByName(const char *attributeName, List *schema); static void setRelhassubclassInRelation(Oid relationId, bool relhassubclass); static bool needs_toast_table(Relation rel); static void AlterIndexNamespaces(Relation classRel, Relation rel, - Oid oldNspOid, Oid newNspOid); + Oid oldNspOid, Oid newNspOid); static void AlterSeqNamespaces(Relation classRel, Relation rel, - Oid oldNspOid, Oid newNspOid, - const char *newNspName); + Oid oldNspOid, Oid newNspOid, + const char *newNspName); static int transformColumnNameList(Oid relId, List *colList, int16 *attnums, Oid *atttypids); static int transformFkeyGetPrimaryKey(Relation pkrel, Oid *indexOid, @@ -238,14 +238,14 @@ static void ATPostAlterTypeCleanup(List **wqueue, AlteredTableInfo *tab); static void ATPostAlterTypeParse(char *cmd, List **wqueue); static void ATExecChangeOwner(Oid relationOid, Oid newOwnerId, bool recursing); static void change_owner_recurse_to_sequences(Oid relationOid, - Oid newOwnerId); + Oid newOwnerId); static void ATExecClusterOn(Relation rel, const char *indexName); static void ATExecDropCluster(Relation rel); static void ATPrepSetTableSpace(AlteredTableInfo *tab, Relation rel, char *tablespacename); static void ATExecSetTableSpace(Oid tableOid, Oid newTableSpace); static void ATExecEnableDisableTrigger(Relation rel, char *trigname, - bool enable, bool skip_system); + bool enable, bool skip_system); static void copy_relation_data(Relation rel, SMgrRelation dst); static void update_ri_trigger_args(Oid relid, const char *oldname, @@ -281,8 +281,8 @@ DefineRelation(CreateStmt *stmt, char relkind) AttrNumber attnum; /* - * Truncate relname to appropriate length (probably a waste of time, - * as parser should have done this already). + * Truncate relname to appropriate length (probably a waste of time, as + * parser should have done this already). */ StrNCpy(relname, stmt->relation->relname, NAMEDATALEN); @@ -292,12 +292,12 @@ DefineRelation(CreateStmt *stmt, char relkind) if (stmt->oncommit != ONCOMMIT_NOOP && !stmt->relation->istemp) ereport(ERROR, (errcode(ERRCODE_INVALID_TABLE_DEFINITION), - errmsg("ON COMMIT can only be used on temporary tables"))); + errmsg("ON COMMIT can only be used on temporary tables"))); /* - * Look up the namespace in which we are supposed to create the - * relation. Check we have permission to create there. Skip check if - * bootstrapping, since permissions machinery may not be working yet. + * Look up the namespace in which we are supposed to create the relation. + * Check we have permission to create there. Skip check if bootstrapping, + * since permissions machinery may not be working yet. */ namespaceId = RangeVarGetCreationNamespace(stmt->relation); @@ -344,19 +344,19 @@ DefineRelation(CreateStmt *stmt, char relkind) } /* - * Look up inheritance ancestors and generate relation schema, - * including inherited attributes. + * Look up inheritance ancestors and generate relation schema, including + * inherited attributes. */ schema = MergeAttributes(schema, stmt->inhRelations, stmt->relation->istemp, - &inheritOids, &old_constraints, &parentOidCount); + &inheritOids, &old_constraints, &parentOidCount); /* - * Create a relation descriptor from the relation schema and create - * the relation. Note that in this stage only inherited (pre-cooked) - * defaults and constraints will be included into the new relation. - * (BuildDescForRelation takes care of the inherited defaults, but we - * have to copy inherited constraints here.) + * Create a relation descriptor from the relation schema and create the + * relation. Note that in this stage only inherited (pre-cooked) defaults + * and constraints will be included into the new relation. + * (BuildDescForRelation takes care of the inherited defaults, but we have + * to copy inherited constraints here.) */ descriptor = BuildDescForRelation(schema); @@ -380,11 +380,10 @@ DefineRelation(CreateStmt *stmt, char relkind) Assert(cdef->raw_expr == NULL && cdef->cooked_expr != NULL); /* - * In multiple-inheritance situations, it's possible to - * inherit the same grandparent constraint through multiple - * parents. Hence, discard inherited constraints that match as - * to both name and expression. Otherwise, gripe if the names - * conflict. + * In multiple-inheritance situations, it's possible to inherit + * the same grandparent constraint through multiple parents. + * Hence, discard inherited constraints that match as to both name + * and expression. Otherwise, gripe if the names conflict. */ for (i = 0; i < ncheck; i++) { @@ -444,25 +443,24 @@ DefineRelation(CreateStmt *stmt, char relkind) /* * Open the new relation and acquire exclusive lock on it. This isn't - * really necessary for locking out other backends (since they can't - * see the new rel anyway until we commit), but it keeps the lock - * manager from complaining about deadlock risks. + * really necessary for locking out other backends (since they can't see + * the new rel anyway until we commit), but it keeps the lock manager from + * complaining about deadlock risks. */ rel = relation_open(relationId, AccessExclusiveLock); /* - * Now add any newly specified column default values and CHECK - * constraints to the new relation. These are passed to us in the - * form of raw parsetrees; we need to transform them to executable - * expression trees before they can be added. The most convenient way - * to do that is to apply the parser's transformExpr routine, but - * transformExpr doesn't work unless we have a pre-existing relation. - * So, the transformation has to be postponed to this final step of - * CREATE TABLE. + * Now add any newly specified column default values and CHECK constraints + * to the new relation. These are passed to us in the form of raw + * parsetrees; we need to transform them to executable expression trees + * before they can be added. The most convenient way to do that is to + * apply the parser's transformExpr routine, but transformExpr doesn't + * work unless we have a pre-existing relation. So, the transformation has + * to be postponed to this final step of CREATE TABLE. * - * Another task that's conveniently done at this step is to add - * dependency links between columns and supporting relations (such as - * SERIAL sequences). + * Another task that's conveniently done at this step is to add dependency + * links between columns and supporting relations (such as SERIAL + * sequences). * * First, scan schema to find new column defaults. */ @@ -528,7 +526,7 @@ RemoveRelation(const RangeVar *relation, DropBehavior behavior) /* * ExecuteTruncate - * Executes a TRUNCATE command. + * Executes a TRUNCATE command. * * This is a multi-relation truncate. It first opens and grabs exclusive * locks on all relations involved, checking permissions and otherwise @@ -540,8 +538,8 @@ RemoveRelation(const RangeVar *relation, DropBehavior behavior) void ExecuteTruncate(List *relations) { - List *rels = NIL; - ListCell *cell; + List *rels = NIL; + ListCell *cell; foreach(cell, relations) { @@ -556,18 +554,18 @@ ExecuteTruncate(List *relations) ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), errmsg("\"%s\" is not a table", - RelationGetRelationName(rel)))); + RelationGetRelationName(rel)))); /* Permissions checks */ if (!pg_class_ownercheck(RelationGetRelid(rel), GetUserId())) aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_CLASS, - RelationGetRelationName(rel)); + RelationGetRelationName(rel)); if (!allowSystemTableMods && IsSystemRelation(rel)) ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), errmsg("permission denied: \"%s\" is a system catalog", - RelationGetRelationName(rel)))); + RelationGetRelationName(rel)))); /* * We can never allow truncation of shared or nailed-in-cache @@ -578,7 +576,7 @@ ExecuteTruncate(List *relations) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("cannot truncate system relation \"%s\"", - RelationGetRelationName(rel)))); + RelationGetRelationName(rel)))); /* * Don't allow truncate on temp tables of other backends ... their @@ -587,7 +585,7 @@ ExecuteTruncate(List *relations) if (isOtherTempNamespace(RelationGetNamespace(rel))) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot truncate temporary tables of other sessions"))); + errmsg("cannot truncate temporary tables of other sessions"))); /* Save it into the list of rels to truncate */ rels = lappend(rels, rel); @@ -704,20 +702,19 @@ MergeAttributes(List *schema, List *supers, bool istemp, List *constraints = NIL; int parentsWithOids = 0; bool have_bogus_defaults = false; - char *bogus_marker = "Bogus!"; /* marks conflicting - * defaults */ + char *bogus_marker = "Bogus!"; /* marks conflicting defaults */ int child_attno; /* - * Check for and reject tables with too many columns. We perform - * this check relatively early for two reasons: (a) we don't run - * the risk of overflowing an AttrNumber in subsequent code (b) an - * O(n^2) algorithm is okay if we're processing <= 1600 columns, - * but could take minutes to execute if the user attempts to - * create a table with hundreds of thousands of columns. + * Check for and reject tables with too many columns. We perform this + * check relatively early for two reasons: (a) we don't run the risk of + * overflowing an AttrNumber in subsequent code (b) an O(n^2) algorithm is + * okay if we're processing <= 1600 columns, but could take minutes to + * execute if the user attempts to create a table with hundreds of + * thousands of columns. * - * Note that we also need to check that any we do not exceed this - * figure after including columns from inherited relations. + * Note that we also need to check that any we do not exceed this figure + * after including columns from inherited relations. */ if (list_length(schema) > MaxHeapAttributeNumber) ereport(ERROR, @@ -728,9 +725,9 @@ MergeAttributes(List *schema, List *supers, bool istemp, /* * Check for duplicate names in the explicit list of attributes. * - * Although we might consider merging such entries in the same way that - * we handle name conflicts for inherited attributes, it seems to make - * more sense to assume such conflicts are errors. + * Although we might consider merging such entries in the same way that we + * handle name conflicts for inherited attributes, it seems to make more + * sense to assume such conflicts are errors. */ foreach(entry, schema) { @@ -750,9 +747,9 @@ MergeAttributes(List *schema, List *supers, bool istemp, } /* - * Scan the parents left-to-right, and merge their attributes to form - * a list of inherited attributes (inhSchema). Also check to see if - * we need to inherit an OID column. + * Scan the parents left-to-right, and merge their attributes to form a + * list of inherited attributes (inhSchema). Also check to see if we need + * to inherit an OID column. */ child_attno = 0; foreach(entry, supers) @@ -775,8 +772,8 @@ MergeAttributes(List *schema, List *supers, bool istemp, if (!istemp && isTempNamespace(RelationGetNamespace(relation))) ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), - errmsg("cannot inherit from temporary relation \"%s\"", - parent->relname))); + errmsg("cannot inherit from temporary relation \"%s\"", + parent->relname))); /* * We should have an UNDER permission flag for this, but for now, @@ -804,10 +801,9 @@ MergeAttributes(List *schema, List *supers, bool istemp, constr = tupleDesc->constr; /* - * newattno[] will contain the child-table attribute numbers for - * the attributes of this parent table. (They are not the same - * for parents after the first one, nor if we have dropped - * columns.) + * newattno[] will contain the child-table attribute numbers for the + * attributes of this parent table. (They are not the same for + * parents after the first one, nor if we have dropped columns.) */ newattno = (AttrNumber *) palloc(tupleDesc->natts * sizeof(AttrNumber)); @@ -828,8 +824,8 @@ MergeAttributes(List *schema, List *supers, bool istemp, { /* * change_varattnos_of_a_node asserts that this is greater - * than zero, so if anything tries to use it, we should - * find out. + * than zero, so if anything tries to use it, we should find + * out. */ newattno[parent_attno - 1] = 0; continue; @@ -853,11 +849,11 @@ MergeAttributes(List *schema, List *supers, bool istemp, def->typename->typmod != attribute->atttypmod) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("inherited column \"%s\" has a type conflict", - attributeName), + errmsg("inherited column \"%s\" has a type conflict", + attributeName), errdetail("%s versus %s", TypeNameToString(def->typename), - format_type_be(attribute->atttypid)))); + format_type_be(attribute->atttypid)))); def->inhcount++; /* Merge of NOT NULL constraints = OR 'em together */ def->is_not_null |= attribute->attnotnull; @@ -909,15 +905,14 @@ MergeAttributes(List *schema, List *supers, bool istemp, Assert(this_default != NULL); /* - * If default expr could contain any vars, we'd need to - * fix 'em, but it can't; so default is ready to apply to - * child. + * If default expr could contain any vars, we'd need to fix + * 'em, but it can't; so default is ready to apply to child. * - * If we already had a default from some prior parent, check - * to see if they are the same. If so, no problem; if - * not, mark the column as having a bogus default. Below, - * we will complain if the bogus default isn't overridden - * by the child schema. + * If we already had a default from some prior parent, check to + * see if they are the same. If so, no problem; if not, mark + * the column as having a bogus default. Below, we will + * complain if the bogus default isn't overridden by the child + * schema. */ Assert(def->raw_default == NULL); if (def->cooked_default == NULL) @@ -931,8 +926,8 @@ MergeAttributes(List *schema, List *supers, bool istemp, } /* - * Now copy the constraints of this parent, adjusting attnos using - * the completed newattno[] map + * Now copy the constraints of this parent, adjusting attnos using the + * completed newattno[] map */ if (constr && constr->num_check > 0) { @@ -958,17 +953,17 @@ MergeAttributes(List *schema, List *supers, bool istemp, pfree(newattno); /* - * Close the parent rel, but keep our AccessShareLock on it until - * xact commit. That will prevent someone else from deleting or - * ALTERing the parent before the child is committed. + * Close the parent rel, but keep our AccessShareLock on it until xact + * commit. That will prevent someone else from deleting or ALTERing + * the parent before the child is committed. */ heap_close(relation, NoLock); } /* * If we had no inherited attributes, the result schema is just the - * explicitly declared columns. Otherwise, we need to merge the - * declared columns into the inherited schema list. + * explicitly declared columns. Otherwise, we need to merge the declared + * columns into the inherited schema list. */ if (inhSchema != NIL) { @@ -991,8 +986,8 @@ MergeAttributes(List *schema, List *supers, bool istemp, * have the same type and typmod. */ ereport(NOTICE, - (errmsg("merging column \"%s\" with inherited definition", - attributeName))); + (errmsg("merging column \"%s\" with inherited definition", + attributeName))); def = (ColumnDef *) list_nth(inhSchema, exist_attno - 1); if (typenameTypeId(def->typename) != typenameTypeId(newdef->typename) || def->typename->typmod != newdef->typename->typmod) @@ -1002,7 +997,7 @@ MergeAttributes(List *schema, List *supers, bool istemp, attributeName), errdetail("%s versus %s", TypeNameToString(def->typename), - TypeNameToString(newdef->typename)))); + TypeNameToString(newdef->typename)))); /* Mark the column as locally defined */ def->is_local = true; /* Merge of NOT NULL constraints = OR 'em together */ @@ -1026,8 +1021,8 @@ MergeAttributes(List *schema, List *supers, bool istemp, schema = inhSchema; /* - * Check that we haven't exceeded the legal # of columns after - * merging in inherited columns. + * Check that we haven't exceeded the legal # of columns after merging + * in inherited columns. */ if (list_length(schema) > MaxHeapAttributeNumber) ereport(ERROR, @@ -1037,8 +1032,8 @@ MergeAttributes(List *schema, List *supers, bool istemp, } /* - * If we found any conflicting parent default values, check to make - * sure they were overridden by the child. + * If we found any conflicting parent default values, check to make sure + * they were overridden by the child. */ if (have_bogus_defaults) { @@ -1049,8 +1044,8 @@ MergeAttributes(List *schema, List *supers, bool istemp, if (def->cooked_default == bogus_marker) ereport(ERROR, (errcode(ERRCODE_INVALID_COLUMN_DEFINITION), - errmsg("column \"%s\" inherits conflicting default values", - def->colname), + errmsg("column \"%s\" inherits conflicting default values", + def->colname), errhint("To resolve the conflict, specify a default explicitly."))); } } @@ -1083,9 +1078,9 @@ change_varattnos_walker(Node *node, const AttrNumber *newattno) var->varattno > 0) { /* - * ??? the following may be a problem when the node is - * multiply referenced though stringToNode() doesn't create - * such a node currently. + * ??? the following may be a problem when the node is multiply + * referenced though stringToNode() doesn't create such a node + * currently. */ Assert(newattno[var->varattno - 1] > 0); var->varattno = newattno[var->varattno - 1]; @@ -1126,13 +1121,13 @@ StoreCatalogInheritance(Oid relationId, List *supers) return; /* - * Store INHERITS information in pg_inherits using direct ancestors - * only. Also enter dependencies on the direct ancestors, and make - * sure they are marked with relhassubclass = true. + * Store INHERITS information in pg_inherits using direct ancestors only. + * Also enter dependencies on the direct ancestors, and make sure they are + * marked with relhassubclass = true. * - * (Once upon a time, both direct and indirect ancestors were found here - * and then entered into pg_ipl. Since that catalog doesn't exist - * anymore, there's no need to look for indirect ancestors.) + * (Once upon a time, both direct and indirect ancestors were found here and + * then entered into pg_ipl. Since that catalog doesn't exist anymore, + * there's no need to look for indirect ancestors.) */ relation = heap_open(InheritsRelationId, RowExclusiveLock); desc = RelationGetDescr(relation); @@ -1222,8 +1217,8 @@ setRelhassubclassInRelation(Oid relationId, bool relhassubclass) /* * Fetch a modifiable copy of the tuple, modify it, update pg_class. * - * If the tuple already has the right relhassubclass setting, we don't - * need to update it, but we still need to issue an SI inval message. + * If the tuple already has the right relhassubclass setting, we don't need + * to update it, but we still need to issue an SI inval message. */ relationRelation = heap_open(RelationRelationId, RowExclusiveLock); tuple = SearchSysCacheCopy(RELOID, @@ -1282,14 +1277,14 @@ renameatt(Oid myrelid, ListCell *indexoidscan; /* - * Grab an exclusive lock on the target table, which we will NOT - * release until end of transaction. + * Grab an exclusive lock on the target table, which we will NOT release + * until end of transaction. */ targetrelation = relation_open(myrelid, AccessExclusiveLock); /* - * permissions checking. this would normally be done in utility.c, - * but this particular routine is recursive. + * permissions checking. this would normally be done in utility.c, but + * this particular routine is recursive. * * normally, only the owner of a class can change its schema. */ @@ -1307,9 +1302,8 @@ renameatt(Oid myrelid, * attribute in all classes that inherit from 'relname' (as well as in * 'relname'). * - * any permissions or problems with duplicate attributes will cause the - * whole transaction to abort, which is what we want -- all or - * nothing. + * any permissions or problems with duplicate attributes will cause the whole + * transaction to abort, which is what we want -- all or nothing. */ if (recurse) { @@ -1320,9 +1314,9 @@ renameatt(Oid myrelid, children = find_all_inheritors(myrelid); /* - * find_all_inheritors does the recursive search of the - * inheritance hierarchy, so all we have to do is process all of - * the relids in the list that it returns. + * find_all_inheritors does the recursive search of the inheritance + * hierarchy, so all we have to do is process all of the relids in the + * list that it returns. */ foreach(child, children) { @@ -1337,8 +1331,8 @@ renameatt(Oid myrelid, else { /* - * If we are told not to recurse, there had better not be any - * child tables; else the rename would put them out of step. + * If we are told not to recurse, there had better not be any child + * tables; else the rename would put them out of step. */ if (!recursing && find_inheritance_children(myrelid) != NIL) @@ -1384,7 +1378,7 @@ renameatt(Oid myrelid, ereport(ERROR, (errcode(ERRCODE_DUPLICATE_COLUMN), errmsg("column \"%s\" of relation \"%s\" already exists", - newattname, RelationGetRelationName(targetrelation)))); + newattname, RelationGetRelationName(targetrelation)))); namestrcpy(&(attform->attname), newattname); @@ -1396,8 +1390,7 @@ renameatt(Oid myrelid, heap_freetuple(atttup); /* - * Update column names of indexes that refer to the column being - * renamed. + * Update column names of indexes that refer to the column being renamed. */ indexoidlist = RelationGetIndexList(targetrelation); @@ -1494,8 +1487,8 @@ renamerel(Oid myrelid, const char *newrelname) bool relhastriggers; /* - * Grab an exclusive lock on the target table or index, which we will - * NOT release until end of transaction. + * Grab an exclusive lock on the target table or index, which we will NOT + * release until end of transaction. */ targetrelation = relation_open(myrelid, AccessExclusiveLock); @@ -1512,8 +1505,7 @@ renamerel(Oid myrelid, const char *newrelname) relhastriggers = (targetrelation->rd_rel->reltriggers > 0); /* - * Find relation's pg_class tuple, and make sure newrelname isn't in - * use. + * Find relation's pg_class tuple, and make sure newrelname isn't in use. */ relrelation = heap_open(RelationRelationId, RowExclusiveLock); @@ -1530,8 +1522,8 @@ renamerel(Oid myrelid, const char *newrelname) newrelname))); /* - * Update pg_class tuple with new relname. (Scribbling on reltup is - * OK because it's a copy...) + * Update pg_class tuple with new relname. (Scribbling on reltup is OK + * because it's a copy...) */ namestrcpy(&(((Form_pg_class) GETSTRUCT(reltup))->relname), newrelname); @@ -1641,8 +1633,8 @@ update_ri_trigger_args(Oid relid, /* * It is an RI trigger, so parse the tgargs bytea. * - * NB: we assume the field will never be compressed or moved out of - * line; so does trigger.c ... + * NB: we assume the field will never be compressed or moved out of line; + * so does trigger.c ... */ tgnargs = pg_trigger->tgnargs; val = (bytea *) @@ -1663,11 +1655,11 @@ update_ri_trigger_args(Oid relid, } /* - * Figure out which item(s) to look at. If the trigger is - * primary-key type and attached to my rel, I should look at the - * PK fields; if it is foreign-key type and attached to my rel, I - * should look at the FK fields. But the opposite rule holds when - * examining triggers found by tgconstrrel search. + * Figure out which item(s) to look at. If the trigger is primary-key + * type and attached to my rel, I should look at the PK fields; if it + * is foreign-key type and attached to my rel, I should look at the FK + * fields. But the opposite rule holds when examining triggers found + * by tgconstrrel search. */ examine_pk = (tg_type == RI_TRIGGER_PK) == (!fk_scan); @@ -1763,9 +1755,9 @@ update_ri_trigger_args(Oid relid, heap_close(tgrel, RowExclusiveLock); /* - * Increment cmd counter to make updates visible; this is needed in - * case the same tuple has to be updated again by next pass (can - * happen in case of a self-referential FK relationship). + * Increment cmd counter to make updates visible; this is needed in case + * the same tuple has to be updated again by next pass (can happen in case + * of a self-referential FK relationship). */ CommandCounterIncrement(); } @@ -1870,14 +1862,14 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd, /* * Copy the original subcommand for each table. This avoids conflicts * when different child tables need to make different parse - * transformations (for example, the same column may have different - * column numbers in different children). + * transformations (for example, the same column may have different column + * numbers in different children). */ cmd = copyObject(cmd); /* - * Do permissions checking, recursion to child tables if needed, and - * any additional phase-1 processing needed. + * Do permissions checking, recursion to child tables if needed, and any + * additional phase-1 processing needed. */ switch (cmd->subtype) { @@ -1890,8 +1882,8 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd, case AT_ColumnDefault: /* ALTER COLUMN DEFAULT */ /* - * We allow defaults on views so that INSERT into a view can - * have default-ish behavior. This works because the rewriter + * We allow defaults on views so that INSERT into a view can have + * default-ish behavior. This works because the rewriter * substitutes default values into INSERTs before it expands * rules. */ @@ -1943,8 +1935,8 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd, /* * Currently we recurse only for CHECK constraints, never for - * foreign-key constraints. UNIQUE/PKEY constraints won't be - * seen here. + * foreign-key constraints. UNIQUE/PKEY constraints won't be seen + * here. */ if (IsA(cmd->def, Constraint)) ATSimpleRecursion(wqueue, rel, cmd, recurse); @@ -2042,11 +2034,11 @@ ATRewriteCatalogs(List **wqueue) ListCell *ltab; /* - * We process all the tables "in parallel", one pass at a time. This - * is needed because we may have to propagate work from one table to - * another (specifically, ALTER TYPE on a foreign key's PK has to - * dispatch the re-adding of the foreign key constraint to the other - * table). Work can only be propagated into later passes, however. + * We process all the tables "in parallel", one pass at a time. This is + * needed because we may have to propagate work from one table to another + * (specifically, ALTER TYPE on a foreign key's PK has to dispatch the + * re-adding of the foreign key constraint to the other table). Work can + * only be propagated into later passes, however. */ for (pass = 0; pass < AT_NUM_PASSES; pass++) { @@ -2062,8 +2054,7 @@ ATRewriteCatalogs(List **wqueue) continue; /* - * Exclusive lock was obtained by phase 1, needn't get it - * again + * Exclusive lock was obtained by phase 1, needn't get it again */ rel = relation_open(tab->relid, NoLock); @@ -2071,9 +2062,9 @@ ATRewriteCatalogs(List **wqueue) ATExecCmd(tab, rel, (AlterTableCmd *) lfirst(lcmd)); /* - * After the ALTER TYPE pass, do cleanup work (this is not - * done in ATExecAlterColumnType since it should be done only - * once if multiple columns of a table are altered). + * After the ALTER TYPE pass, do cleanup work (this is not done in + * ATExecAlterColumnType since it should be done only once if + * multiple columns of a table are altered). */ if (pass == AT_PASS_ALTER_TYPE) ATPostAlterTypeCleanup(wqueue, tab); @@ -2083,8 +2074,8 @@ ATRewriteCatalogs(List **wqueue) } /* - * Do an implicit CREATE TOAST TABLE if we executed any subcommands - * that might have added a column or changed column storage. + * Do an implicit CREATE TOAST TABLE if we executed any subcommands that + * might have added a column or changed column storage. */ foreach(ltab, *wqueue) { @@ -2190,7 +2181,7 @@ ATExecCmd(AlteredTableInfo *tab, Relation rel, AlterTableCmd *cmd) case AT_EnableTrigUser: /* ENABLE TRIGGER USER */ ATExecEnableDisableTrigger(rel, NULL, true, true); break; - case AT_DisableTrigUser: /* DISABLE TRIGGER USER */ + case AT_DisableTrigUser: /* DISABLE TRIGGER USER */ ATExecEnableDisableTrigger(rel, NULL, false, true); break; default: /* oops */ @@ -2200,8 +2191,8 @@ ATExecCmd(AlteredTableInfo *tab, Relation rel, AlterTableCmd *cmd) } /* - * Bump the command counter to ensure the next subcommand in the - * sequence can see the changes so far + * Bump the command counter to ensure the next subcommand in the sequence + * can see the changes so far */ CommandCounterIncrement(); } @@ -2220,8 +2211,8 @@ ATRewriteTables(List **wqueue) AlteredTableInfo *tab = (AlteredTableInfo *) lfirst(ltab); /* - * We only need to rewrite the table if at least one column needs - * to be recomputed. + * We only need to rewrite the table if at least one column needs to + * be recomputed. */ if (tab->newvals != NIL) { @@ -2236,8 +2227,8 @@ ATRewriteTables(List **wqueue) /* * We can never allow rewriting of shared or nailed-in-cache - * relations, because we can't support changing their - * relfilenode values. + * relations, because we can't support changing their relfilenode + * values. */ if (OldHeap->rd_rel->relisshared || OldHeap->rd_isnailed) ereport(ERROR, @@ -2246,13 +2237,13 @@ ATRewriteTables(List **wqueue) RelationGetRelationName(OldHeap)))); /* - * Don't allow rewrite on temp tables of other backends ... - * their local buffer manager is not going to cope. + * Don't allow rewrite on temp tables of other backends ... their + * local buffer manager is not going to cope. */ if (isOtherTempNamespace(RelationGetNamespace(OldHeap))) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot rewrite temporary tables of other sessions"))); + errmsg("cannot rewrite temporary tables of other sessions"))); /* * Select destination tablespace (same as original unless user @@ -2267,12 +2258,11 @@ ATRewriteTables(List **wqueue) /* * Create the new heap, using a temporary name in the same - * namespace as the existing table. NOTE: there is some risk - * of collision with user relnames. Working around this seems - * more trouble than it's worth; in particular, we can't - * create the new heap in a different namespace from the old, - * or we will have problems with the TEMP status of temp - * tables. + * namespace as the existing table. NOTE: there is some risk of + * collision with user relnames. Working around this seems more + * trouble than it's worth; in particular, we can't create the new + * heap in a different namespace from the old, or we will have + * problems with the TEMP status of temp tables. */ snprintf(NewHeapName, sizeof(NewHeapName), "pg_temp_%u", tab->relid); @@ -2304,8 +2294,8 @@ ATRewriteTables(List **wqueue) /* performDeletion does CommandCounterIncrement at end */ /* - * Rebuild each index on the relation (but not the toast - * table, which is all-new anyway). We do not need + * Rebuild each index on the relation (but not the toast table, + * which is all-new anyway). We do not need * CommandCounterIncrement() because reindex_relation does it. */ reindex_relation(tab->relid, false); @@ -2313,16 +2303,15 @@ ATRewriteTables(List **wqueue) else { /* - * Test the current data within the table against new - * constraints generated by ALTER TABLE commands, but don't - * rebuild data. + * Test the current data within the table against new constraints + * generated by ALTER TABLE commands, but don't rebuild data. */ if (tab->constraints != NIL) ATRewriteTable(tab, InvalidOid); /* - * If we had SET TABLESPACE but no reason to reconstruct - * tuples, just do a block-by-block copy. + * If we had SET TABLESPACE but no reason to reconstruct tuples, + * just do a block-by-block copy. */ if (tab->newTableSpace) ATExecSetTableSpace(tab->relid, tab->newTableSpace); @@ -2331,10 +2320,10 @@ ATRewriteTables(List **wqueue) /* * Foreign key constraints are checked in a final pass, since (a) it's - * generally best to examine each one separately, and (b) it's at - * least theoretically possible that we have changed both relations of - * the foreign key, and we'd better have finished both rewrites before - * we try to read the tables. + * generally best to examine each one separately, and (b) it's at least + * theoretically possible that we have changed both relations of the + * foreign key, and we'd better have finished both rewrites before we try + * to read the tables. */ foreach(ltab, *wqueue) { @@ -2401,12 +2390,12 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap) newrel = NULL; /* - * If we need to rewrite the table, the operation has to be propagated - * to tables that use this table's rowtype as a column type. + * If we need to rewrite the table, the operation has to be propagated to + * tables that use this table's rowtype as a column type. * - * (Eventually this will probably become true for scans as well, but at - * the moment a composite type does not enforce any constraints, so - * it's not necessary/appropriate to enforce them just during ALTER.) + * (Eventually this will probably become true for scans as well, but at the + * moment a composite type does not enforce any constraints, so it's not + * necessary/appropriate to enforce them just during ALTER.) */ if (newrel) find_composite_type_dependencies(oldrel->rd_rel->reltype, @@ -2461,15 +2450,15 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap) HeapScanDesc scan; HeapTuple tuple; MemoryContext oldCxt; - List *dropped_attrs = NIL; - ListCell *lc; + List *dropped_attrs = NIL; + ListCell *lc; econtext = GetPerTupleExprContext(estate); /* - * Make tuple slots for old and new tuples. Note that even when - * the tuples are the same, the tupDescs might not be (consider - * ADD COLUMN without a default). + * Make tuple slots for old and new tuples. Note that even when the + * tuples are the same, the tupDescs might not be (consider ADD COLUMN + * without a default). */ oldslot = MakeSingleTupleTableSlot(oldTupDesc); newslot = MakeSingleTupleTableSlot(newTupDesc); @@ -2483,9 +2472,8 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap) /* * Any attributes that are dropped according to the new tuple - * descriptor can be set to NULL. We precompute the list of - * dropped attributes to avoid needing to do so in the - * per-tuple loop. + * descriptor can be set to NULL. We precompute the list of dropped + * attributes to avoid needing to do so in the per-tuple loop. */ for (i = 0; i < newTupDesc->natts; i++) { @@ -2500,8 +2488,8 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap) scan = heap_beginscan(oldrel, SnapshotNow, 0, NULL); /* - * Switch to per-tuple memory context and reset it for each - * tuple produced, so we don't leak memory. + * Switch to per-tuple memory context and reset it for each tuple + * produced, so we don't leak memory. */ oldCxt = MemoryContextSwitchTo(GetPerTupleMemoryContext(estate)); @@ -2509,7 +2497,7 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap) { if (newrel) { - Oid tupOid = InvalidOid; + Oid tupOid = InvalidOid; /* Extract data from old tuple */ heap_deform_tuple(tuple, oldTupDesc, values, isnull); @@ -2517,12 +2505,12 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap) tupOid = HeapTupleGetOid(tuple); /* Set dropped attributes to null in new tuple */ - foreach (lc, dropped_attrs) + foreach(lc, dropped_attrs) isnull[lfirst_int(lc)] = true; /* - * Process supplied expressions to replace selected - * columns. Expression inputs come from the old tuple. + * Process supplied expressions to replace selected columns. + * Expression inputs come from the old tuple. */ ExecStoreTuple(tuple, oldslot, InvalidBuffer, false); econtext->ecxt_scantuple = oldslot; @@ -2533,14 +2521,13 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap) values[ex->attnum - 1] = ExecEvalExpr(ex->exprstate, econtext, - &isnull[ex->attnum - 1], + &isnull[ex->attnum - 1], NULL); } /* - * Form the new tuple. Note that we don't explicitly - * pfree it, since the per-tuple memory context will - * be reset shortly. + * Form the new tuple. Note that we don't explicitly pfree it, + * since the per-tuple memory context will be reset shortly. */ tuple = heap_form_tuple(newTupDesc, values, isnull); @@ -2575,10 +2562,10 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap) &isnull); if (isnull) ereport(ERROR, - (errcode(ERRCODE_NOT_NULL_VIOLATION), - errmsg("column \"%s\" contains null values", - get_attname(tab->relid, - con->attnum)))); + (errcode(ERRCODE_NOT_NULL_VIOLATION), + errmsg("column \"%s\" contains null values", + get_attname(tab->relid, + con->attnum)))); } break; case CONSTR_FOREIGN: @@ -2706,9 +2693,9 @@ ATSimpleRecursion(List **wqueue, Relation rel, children = find_all_inheritors(relid); /* - * find_all_inheritors does the recursive search of the - * inheritance hierarchy, so all we have to do is process all of - * the relids in the list that it returns. + * find_all_inheritors does the recursive search of the inheritance + * hierarchy, so all we have to do is process all of the relids in the + * list that it returns. */ foreach(child, children) { @@ -2775,8 +2762,8 @@ find_composite_type_dependencies(Oid typeOid, const char *origTblName) HeapTuple depTup; /* - * We scan pg_depend to find those things that depend on the rowtype. - * (We assume we can ignore refobjsubid for a rowtype.) + * We scan pg_depend to find those things that depend on the rowtype. (We + * assume we can ignore refobjsubid for a rowtype.) */ depRel = heap_open(DependRelationId, AccessShareLock); @@ -2819,9 +2806,8 @@ find_composite_type_dependencies(Oid typeOid, const char *origTblName) else if (OidIsValid(rel->rd_rel->reltype)) { /* - * A view or composite type itself isn't a problem, but we - * must recursively check for indirect dependencies via its - * rowtype. + * A view or composite type itself isn't a problem, but we must + * recursively check for indirect dependencies via its rowtype. */ find_composite_type_dependencies(rel->rd_rel->reltype, origTblName); @@ -2851,9 +2837,9 @@ ATPrepAddColumn(List **wqueue, Relation rel, bool recurse, /* * Recurse to add the column to child classes, if requested. * - * We must recurse one level at a time, so that multiply-inheriting - * children are visited the right number of times and end up with the - * right attinhcount. + * We must recurse one level at a time, so that multiply-inheriting children + * are visited the right number of times and end up with the right + * attinhcount. */ if (recurse) { @@ -2871,8 +2857,8 @@ ATPrepAddColumn(List **wqueue, Relation rel, bool recurse, else { /* - * If we are told not to recurse, there had better not be any - * child tables; else the addition would put them out of step. + * If we are told not to recurse, there had better not be any child + * tables; else the addition would put them out of step. */ if (find_inheritance_children(RelationGetRelid(rel)) != NIL) ereport(ERROR, @@ -2903,8 +2889,8 @@ ATExecAddColumn(AlteredTableInfo *tab, Relation rel, attrdesc = heap_open(AttributeRelationId, RowExclusiveLock); /* - * Are we adding the column to a recursion child? If so, check - * whether to merge with an existing definition for the column. + * Are we adding the column to a recursion child? If so, check whether to + * merge with an existing definition for the column. */ if (colDef->inhcount > 0) { @@ -2922,7 +2908,7 @@ ATExecAddColumn(AlteredTableInfo *tab, Relation rel, ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), errmsg("child table \"%s\" has different type for column \"%s\"", - RelationGetRelationName(rel), colDef->colname))); + RelationGetRelationName(rel), colDef->colname))); /* Bump the existing child att's inhcount */ childatt->attinhcount++; @@ -2933,8 +2919,8 @@ ATExecAddColumn(AlteredTableInfo *tab, Relation rel, /* Inform the user about the merge */ ereport(NOTICE, - (errmsg("merging definition of column \"%s\" for child \"%s\"", - colDef->colname, RelationGetRelationName(rel)))); + (errmsg("merging definition of column \"%s\" for child \"%s\"", + colDef->colname, RelationGetRelationName(rel)))); heap_close(attrdesc, RowExclusiveLock); return; @@ -2950,9 +2936,8 @@ ATExecAddColumn(AlteredTableInfo *tab, Relation rel, elog(ERROR, "cache lookup failed for relation %u", myrelid); /* - * this test is deliberately not attisdropped-aware, since if one - * tries to add a column matching a dropped column name, it's gonna - * fail anyway. + * this test is deliberately not attisdropped-aware, since if one tries to + * add a column matching a dropped column name, it's gonna fail anyway. */ if (SearchSysCacheExists(ATTNAME, ObjectIdGetDatum(myrelid), @@ -3054,30 +3039,30 @@ ATExecAddColumn(AlteredTableInfo *tab, Relation rel, /* * Tell Phase 3 to fill in the default expression, if there is one. * - * If there is no default, Phase 3 doesn't have to do anything, because - * that effectively means that the default is NULL. The heap tuple - * access routines always check for attnum > # of attributes in tuple, - * and return NULL if so, so without any modification of the tuple - * data we will get the effect of NULL values in the new column. + * If there is no default, Phase 3 doesn't have to do anything, because that + * effectively means that the default is NULL. The heap tuple access + * routines always check for attnum > # of attributes in tuple, and return + * NULL if so, so without any modification of the tuple data we will get + * the effect of NULL values in the new column. * - * An exception occurs when the new column is of a domain type: the - * domain might have a NOT NULL constraint, or a check constraint that - * indirectly rejects nulls. If there are any domain constraints then - * we construct an explicit NULL default value that will be passed through - * CoerceToDomain processing. (This is a tad inefficient, since it - * causes rewriting the table which we really don't have to do, but - * the present design of domain processing doesn't offer any simple way - * of checking the constraints more directly.) + * An exception occurs when the new column is of a domain type: the domain + * might have a NOT NULL constraint, or a check constraint that indirectly + * rejects nulls. If there are any domain constraints then we construct + * an explicit NULL default value that will be passed through + * CoerceToDomain processing. (This is a tad inefficient, since it causes + * rewriting the table which we really don't have to do, but the present + * design of domain processing doesn't offer any simple way of checking + * the constraints more directly.) * * Note: we use build_column_default, and not just the cooked default - * returned by AddRelationRawConstraints, so that the right thing - * happens when a datatype's default applies. + * returned by AddRelationRawConstraints, so that the right thing happens + * when a datatype's default applies. */ defval = (Expr *) build_column_default(rel, attribute->attnum); if (!defval && GetDomainConstraints(typeOid) != NIL) { - Oid basetype = getBaseType(typeOid); + Oid basetype = getBaseType(typeOid); defval = (Expr *) makeNullConst(basetype); defval = (Expr *) coerce_to_target_type(NULL, @@ -3355,8 +3340,8 @@ ATPrepSetStatistics(Relation rel, const char *colName, Node *flagValue) { /* * We do our own permission checking because (a) we want to allow SET - * STATISTICS on indexes (for expressional index columns), and (b) we - * want to allow SET STATISTICS on system catalogs without requiring + * STATISTICS on indexes (for expressional index columns), and (b) we want + * to allow SET STATISTICS on system catalogs without requiring * allowSystemTableMods to be turned on. */ if (rel->rd_rel->relkind != RELKIND_RELATION && @@ -3481,8 +3466,8 @@ ATExecSetStorage(Relation rel, const char *colName, Node *newValue) colName))); /* - * safety check: do not allow toasted storage modes unless column - * datatype is TOAST-aware. + * safety check: do not allow toasted storage modes unless column datatype + * is TOAST-aware. */ if (newstorage == 'p' || TypeIsToastable(attrtuple->atttypid)) attrtuple->attstorage = newstorage; @@ -3560,8 +3545,8 @@ ATExecDropColumn(Relation rel, const char *colName, /* * Propagate to children as appropriate. Unlike most other ALTER - * routines, we have to do this one level of recursion at a time; we - * can't use find_all_inheritors to do it in one pass. + * routines, we have to do this one level of recursion at a time; we can't + * use find_all_inheritors to do it in one pass. */ children = find_inheritance_children(RelationGetRelid(rel)); @@ -3593,8 +3578,8 @@ ATExecDropColumn(Relation rel, const char *colName, { /* * If the child column has other definition sources, just - * decrement its inheritance count; if not, recurse to - * delete it. + * decrement its inheritance count; if not, recurse to delete + * it. */ if (childatt->attinhcount == 1 && !childatt->attislocal) { @@ -3618,9 +3603,9 @@ ATExecDropColumn(Relation rel, const char *colName, else { /* - * If we were told to drop ONLY in this table (no - * recursion), we need to mark the inheritors' attribute - * as locally defined rather than inherited. + * If we were told to drop ONLY in this table (no recursion), + * we need to mark the inheritors' attribute as locally + * defined rather than inherited. */ childatt->attinhcount--; childatt->attislocal = true; @@ -3661,7 +3646,7 @@ ATExecDropColumn(Relation rel, const char *colName, class_rel = heap_open(RelationRelationId, RowExclusiveLock); tuple = SearchSysCacheCopy(RELOID, - ObjectIdGetDatum(RelationGetRelid(rel)), + ObjectIdGetDatum(RelationGetRelid(rel)), 0, 0, 0); if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for relation %u", @@ -3734,8 +3719,8 @@ ATExecAddConstraint(AlteredTableInfo *tab, Relation rel, Node *newConstraint) /* * Currently, we only expect to see CONSTR_CHECK nodes * arriving here (see the preprocessing done in - * parser/analyze.c). Use a switch anyway to make it - * easier to add more code later. + * parser/analyze.c). Use a switch anyway to make it easier + * to add more code later. */ switch (constr->contype) { @@ -3745,12 +3730,11 @@ ATExecAddConstraint(AlteredTableInfo *tab, Relation rel, Node *newConstraint) ListCell *lcon; /* - * Call AddRelationRawConstraints to do the - * work. It returns a list of cooked - * constraints. + * Call AddRelationRawConstraints to do the work. + * It returns a list of cooked constraints. */ newcons = AddRelationRawConstraints(rel, NIL, - list_make1(constr)); + list_make1(constr)); /* Add each constraint to Phase 3's queue */ foreach(lcon, newcons) { @@ -3798,7 +3782,7 @@ ATExecAddConstraint(AlteredTableInfo *tab, Relation rel, Node *newConstraint) else fkconstraint->constr_name = ChooseConstraintName(RelationGetRelationName(rel), - strVal(linitial(fkconstraint->fk_attrs)), + strVal(linitial(fkconstraint->fk_attrs)), "fkey", RelationGetNamespace(rel), NIL); @@ -3838,19 +3822,19 @@ ATAddForeignKeyConstraint(AlteredTableInfo *tab, Relation rel, Oid constrOid; /* - * Grab an exclusive lock on the pk table, so that someone doesn't - * delete rows out from under us. (Although a lesser lock would do for - * that purpose, we'll need exclusive lock anyway to add triggers to - * the pk table; trying to start with a lesser lock will just create a - * risk of deadlock.) + * Grab an exclusive lock on the pk table, so that someone doesn't delete + * rows out from under us. (Although a lesser lock would do for that + * purpose, we'll need exclusive lock anyway to add triggers to the pk + * table; trying to start with a lesser lock will just create a risk of + * deadlock.) */ pkrel = heap_openrv(fkconstraint->pktable, AccessExclusiveLock); /* * Validity and permissions checks * - * Note: REFERENCES permissions checks are redundant with CREATE TRIGGER, - * but we may as well error out sooner instead of later. + * Note: REFERENCES permissions checks are redundant with CREATE TRIGGER, but + * we may as well error out sooner instead of later. */ if (pkrel->rd_rel->relkind != RELKIND_RELATION) ereport(ERROR, @@ -3877,12 +3861,12 @@ ATAddForeignKeyConstraint(AlteredTableInfo *tab, Relation rel, RelationGetRelationName(rel)); /* - * Disallow reference from permanent table to temp table or vice - * versa. (The ban on perm->temp is for fairly obvious reasons. The - * ban on temp->perm is because other backends might need to run the - * RI triggers on the perm table, but they can't reliably see tuples - * the owning backend has created in the temp table, because - * non-shared buffers are used for temp tables.) + * Disallow reference from permanent table to temp table or vice versa. + * (The ban on perm->temp is for fairly obvious reasons. The ban on + * temp->perm is because other backends might need to run the RI triggers + * on the perm table, but they can't reliably see tuples the owning + * backend has created in the temp table, because non-shared buffers are + * used for temp tables.) */ if (isTempNamespace(RelationGetNamespace(pkrel))) { @@ -3900,8 +3884,8 @@ ATAddForeignKeyConstraint(AlteredTableInfo *tab, Relation rel, } /* - * Look up the referencing attributes to make sure they exist, and - * record their attnums and type OIDs. + * Look up the referencing attributes to make sure they exist, and record + * their attnums and type OIDs. */ MemSet(pkattnum, 0, sizeof(pkattnum)); MemSet(fkattnum, 0, sizeof(fkattnum)); @@ -3914,11 +3898,10 @@ ATAddForeignKeyConstraint(AlteredTableInfo *tab, Relation rel, fkattnum, fktypoid); /* - * If the attribute list for the referenced table was omitted, lookup - * the definition of the primary key and use it. Otherwise, validate - * the supplied attribute list. In either case, discover the index - * OID and index opclasses, and the attnums and type OIDs of the - * attributes. + * If the attribute list for the referenced table was omitted, lookup the + * definition of the primary key and use it. Otherwise, validate the + * supplied attribute list. In either case, discover the index OID and + * index opclasses, and the attnums and type OIDs of the attributes. */ if (fkconstraint->pk_attrs == NIL) { @@ -3946,15 +3929,15 @@ ATAddForeignKeyConstraint(AlteredTableInfo *tab, Relation rel, for (i = 0; i < numpks; i++) { /* - * pktypoid[i] is the primary key table's i'th key's type - * fktypoid[i] is the foreign key table's i'th key's type + * pktypoid[i] is the primary key table's i'th key's type fktypoid[i] + * is the foreign key table's i'th key's type * - * Note that we look for an operator with the PK type on the left; - * when the types are different this is critical because the PK - * index will need operators with the indexkey on the left. - * (Ordinarily both commutator operators will exist if either - * does, but we won't get the right answer from the test below on - * opclass membership unless we select the proper operator.) + * Note that we look for an operator with the PK type on the left; when + * the types are different this is critical because the PK index will + * need operators with the indexkey on the left. (Ordinarily both + * commutator operators will exist if either does, but we won't get + * the right answer from the test below on opclass membership unless + * we select the proper operator.) */ Operator o = oper(list_make1(makeString("=")), pktypoid[i], fktypoid[i], true); @@ -3967,15 +3950,15 @@ ATAddForeignKeyConstraint(AlteredTableInfo *tab, Relation rel, fkconstraint->constr_name), errdetail("Key columns \"%s\" and \"%s\" " "are of incompatible types: %s and %s.", - strVal(list_nth(fkconstraint->fk_attrs, i)), - strVal(list_nth(fkconstraint->pk_attrs, i)), + strVal(list_nth(fkconstraint->fk_attrs, i)), + strVal(list_nth(fkconstraint->pk_attrs, i)), format_type_be(fktypoid[i]), format_type_be(pktypoid[i])))); /* - * Check that the found operator is compatible with the PK index, - * and generate a warning if not, since otherwise costly seqscans - * will be incurred to check FK validity. + * Check that the found operator is compatible with the PK index, and + * generate a warning if not, since otherwise costly seqscans will be + * incurred to check FK validity. */ if (!op_in_opclass(oprid(o), opclasses[i])) ereport(WARNING, @@ -3984,8 +3967,8 @@ ATAddForeignKeyConstraint(AlteredTableInfo *tab, Relation rel, fkconstraint->constr_name), errdetail("Key columns \"%s\" and \"%s\" " "are of different types: %s and %s.", - strVal(list_nth(fkconstraint->fk_attrs, i)), - strVal(list_nth(fkconstraint->pk_attrs, i)), + strVal(list_nth(fkconstraint->fk_attrs, i)), + strVal(list_nth(fkconstraint->pk_attrs, i)), format_type_be(fktypoid[i]), format_type_be(pktypoid[i])))); @@ -3993,8 +3976,8 @@ ATAddForeignKeyConstraint(AlteredTableInfo *tab, Relation rel, } /* - * Tell Phase 3 to check that the constraint is satisfied by existing - * rows (we can skip this during table creation). + * Tell Phase 3 to check that the constraint is satisfied by existing rows + * (we can skip this during table creation). */ if (!fkconstraint->skip_validation) { @@ -4072,8 +4055,8 @@ transformColumnNameList(Oid relId, List *colList, if (attnum >= INDEX_MAX_KEYS) ereport(ERROR, (errcode(ERRCODE_TOO_MANY_COLUMNS), - errmsg("cannot have more than %d keys in a foreign key", - INDEX_MAX_KEYS))); + errmsg("cannot have more than %d keys in a foreign key", + INDEX_MAX_KEYS))); attnums[attnum] = ((Form_pg_attribute) GETSTRUCT(atttuple))->attnum; atttypids[attnum] = ((Form_pg_attribute) GETSTRUCT(atttuple))->atttypid; ReleaseSysCache(atttuple); @@ -4111,9 +4094,9 @@ transformFkeyGetPrimaryKey(Relation pkrel, Oid *indexOid, int i; /* - * Get the list of index OIDs for the table from the relcache, and - * look up each one in the pg_index syscache until we find one marked - * primary key (hopefully there isn't more than one such). + * Get the list of index OIDs for the table from the relcache, and look up + * each one in the pg_index syscache until we find one marked primary key + * (hopefully there isn't more than one such). */ *indexOid = InvalidOid; @@ -4145,8 +4128,8 @@ transformFkeyGetPrimaryKey(Relation pkrel, Oid *indexOid, if (!OidIsValid(*indexOid)) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), - errmsg("there is no primary key for referenced table \"%s\"", - RelationGetRelationName(pkrel)))); + errmsg("there is no primary key for referenced table \"%s\"", + RelationGetRelationName(pkrel)))); /* Must get indclass the hard way */ indclassDatum = SysCacheGetAttr(INDEXRELID, indexTuple, @@ -4167,7 +4150,7 @@ transformFkeyGetPrimaryKey(Relation pkrel, Oid *indexOid, atttypids[i] = attnumTypeId(pkrel, pkattno); opclasses[i] = indclass->values[i]; *attnamelist = lappend(*attnamelist, - makeString(pstrdup(NameStr(*attnumAttName(pkrel, pkattno))))); + makeString(pstrdup(NameStr(*attnumAttName(pkrel, pkattno))))); } ReleaseSysCache(indexTuple); @@ -4194,9 +4177,9 @@ transformFkeyCheckAttrs(Relation pkrel, ListCell *indexoidscan; /* - * Get the list of index OIDs for the table from the relcache, and - * look up each one in the pg_index syscache, and match unique indexes - * to the list of attnums we are given. + * Get the list of index OIDs for the table from the relcache, and look up + * each one in the pg_index syscache, and match unique indexes to the list + * of attnums we are given. */ indexoidlist = RelationGetIndexList(pkrel); @@ -4235,8 +4218,8 @@ transformFkeyCheckAttrs(Relation pkrel, indclass = (oidvector *) DatumGetPointer(indclassDatum); /* - * The given attnum list may match the index columns in any - * order. Check that each list is a subset of the other. + * The given attnum list may match the index columns in any order. + * Check that each list is a subset of the other. */ for (i = 0; i < numattrs; i++) { @@ -4312,9 +4295,9 @@ validateForeignKeyConstraint(FkConstraint *fkconstraint, return; /* - * Scan through each tuple, calling RI_FKey_check_ins (insert trigger) - * as if that tuple had just been inserted. If any of those fail, it - * should ereport(ERROR) and that's that. + * Scan through each tuple, calling RI_FKey_check_ins (insert trigger) as + * if that tuple had just been inserted. If any of those fail, it should + * ereport(ERROR) and that's that. */ MemSet(&trig, 0, sizeof(trig)); trig.tgoid = InvalidOid; @@ -4326,8 +4309,8 @@ validateForeignKeyConstraint(FkConstraint *fkconstraint, trig.tginitdeferred = FALSE; trig.tgargs = (char **) palloc(sizeof(char *) * - (4 + list_length(fkconstraint->fk_attrs) - + list_length(fkconstraint->pk_attrs))); + (4 + list_length(fkconstraint->fk_attrs) + + list_length(fkconstraint->pk_attrs))); trig.tgargs[0] = trig.tgname; trig.tgargs[1] = RelationGetRelationName(rel); @@ -4426,9 +4409,9 @@ CreateFKCheckTrigger(RangeVar *myRel, FkConstraint *fkconstraint, fk_trigger->args = lappend(fk_trigger->args, makeString(myRel->relname)); fk_trigger->args = lappend(fk_trigger->args, - makeString(fkconstraint->pktable->relname)); + makeString(fkconstraint->pktable->relname)); fk_trigger->args = lappend(fk_trigger->args, - makeString(fkMatchTypeToString(fkconstraint->fk_matchtype))); + makeString(fkMatchTypeToString(fkconstraint->fk_matchtype))); if (list_length(fkconstraint->fk_attrs) != list_length(fkconstraint->pk_attrs)) ereport(ERROR, (errcode(ERRCODE_INVALID_FOREIGN_KEY), @@ -4465,8 +4448,7 @@ createForeignKeyTriggers(Relation rel, FkConstraint *fkconstraint, constrobj; /* - * Reconstruct a RangeVar for my relation (not passed in, - * unfortunately). + * Reconstruct a RangeVar for my relation (not passed in, unfortunately). */ myRel = makeRangeVar(get_namespace_name(RelationGetNamespace(rel)), pstrdup(RelationGetRelationName(rel))); @@ -4484,8 +4466,8 @@ createForeignKeyTriggers(Relation rel, FkConstraint *fkconstraint, CommandCounterIncrement(); /* - * Build and execute a CREATE CONSTRAINT TRIGGER statement for the - * CHECK action for both INSERTs and UPDATEs on the referencing table. + * Build and execute a CREATE CONSTRAINT TRIGGER statement for the CHECK + * action for both INSERTs and UPDATEs on the referencing table. */ CreateFKCheckTrigger(myRel, fkconstraint, &constrobj, &trigobj, true); CreateFKCheckTrigger(myRel, fkconstraint, &constrobj, &trigobj, false); @@ -4543,9 +4525,9 @@ createForeignKeyTriggers(Relation rel, FkConstraint *fkconstraint, fk_trigger->args = lappend(fk_trigger->args, makeString(myRel->relname)); fk_trigger->args = lappend(fk_trigger->args, - makeString(fkconstraint->pktable->relname)); + makeString(fkconstraint->pktable->relname)); fk_trigger->args = lappend(fk_trigger->args, - makeString(fkMatchTypeToString(fkconstraint->fk_matchtype))); + makeString(fkMatchTypeToString(fkconstraint->fk_matchtype))); forboth(fk_attr, fkconstraint->fk_attrs, pk_attr, fkconstraint->pk_attrs) { @@ -4613,9 +4595,9 @@ createForeignKeyTriggers(Relation rel, FkConstraint *fkconstraint, fk_trigger->args = lappend(fk_trigger->args, makeString(myRel->relname)); fk_trigger->args = lappend(fk_trigger->args, - makeString(fkconstraint->pktable->relname)); + makeString(fkconstraint->pktable->relname)); fk_trigger->args = lappend(fk_trigger->args, - makeString(fkMatchTypeToString(fkconstraint->fk_matchtype))); + makeString(fkMatchTypeToString(fkconstraint->fk_matchtype))); forboth(fk_attr, fkconstraint->fk_attrs, pk_attr, fkconstraint->pk_attrs) { @@ -4690,8 +4672,8 @@ ATExecDropConstraint(Relation rel, const char *constrName, /* Otherwise if more than one constraint deleted, notify */ else if (deleted > 1) ereport(NOTICE, - (errmsg("multiple constraints named \"%s\" were dropped", - constrName))); + (errmsg("multiple constraints named \"%s\" were dropped", + constrName))); } } @@ -4750,12 +4732,12 @@ ATPrepAlterColumnType(List **wqueue, CheckAttributeType(colName, targettype); /* - * Set up an expression to transform the old data value to the new - * type. If a USING option was given, transform and use that - * expression, else just take the old value and try to coerce it. We - * do this first so that type incompatibility can be detected before - * we waste effort, and because we need the expression to be parsed - * against the original table rowtype. + * Set up an expression to transform the old data value to the new type. + * If a USING option was given, transform and use that expression, else + * just take the old value and try to coerce it. We do this first so that + * type incompatibility can be detected before we waste effort, and + * because we need the expression to be parsed against the original table + * rowtype. */ if (cmd->transform) { @@ -4775,17 +4757,17 @@ ATPrepAlterColumnType(List **wqueue, if (expression_returns_set(transform)) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("transform expression must not return a set"))); + errmsg("transform expression must not return a set"))); /* No subplans or aggregates, either... */ if (pstate->p_hasSubLinks) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot use subquery in transform expression"))); + errmsg("cannot use subquery in transform expression"))); if (pstate->p_hasAggs) ereport(ERROR, (errcode(ERRCODE_GROUPING_ERROR), - errmsg("cannot use aggregate function in transform expression"))); + errmsg("cannot use aggregate function in transform expression"))); } else { @@ -4818,9 +4800,9 @@ ATPrepAlterColumnType(List **wqueue, ReleaseSysCache(tuple); /* - * The recursion case is handled by ATSimpleRecursion. However, if we - * are told not to recurse, there had better not be any child tables; - * else the alter would put them out of step. + * The recursion case is handled by ATSimpleRecursion. However, if we are + * told not to recurse, there had better not be any child tables; else the + * alter would put them out of step. */ if (recurse) ATSimpleRecursion(wqueue, rel, cmd, recurse); @@ -4875,17 +4857,16 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel, targettype = HeapTupleGetOid(typeTuple); /* - * If there is a default expression for the column, get it and ensure - * we can coerce it to the new datatype. (We must do this before - * changing the column type, because build_column_default itself will - * try to coerce, and will not issue the error message we want if it - * fails.) + * If there is a default expression for the column, get it and ensure we + * can coerce it to the new datatype. (We must do this before changing + * the column type, because build_column_default itself will try to + * coerce, and will not issue the error message we want if it fails.) * - * We remove any implicit coercion steps at the top level of the old - * default expression; this has been agreed to satisfy the principle - * of least surprise. (The conversion to the new column type should - * act like it started from what the user sees as the stored expression, - * and the implicit coercions aren't going to be shown.) + * We remove any implicit coercion steps at the top level of the old default + * expression; this has been agreed to satisfy the principle of least + * surprise. (The conversion to the new column type should act like it + * started from what the user sees as the stored expression, and the + * implicit coercions aren't going to be shown.) */ if (attTup->atthasdef) { @@ -4893,32 +4874,32 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel, Assert(defaultexpr); defaultexpr = strip_implicit_coercions(defaultexpr); defaultexpr = coerce_to_target_type(NULL, /* no UNKNOWN params */ - defaultexpr, exprType(defaultexpr), + defaultexpr, exprType(defaultexpr), targettype, typename->typmod, COERCION_ASSIGNMENT, COERCE_IMPLICIT_CAST); if (defaultexpr == NULL) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("default for column \"%s\" cannot be cast to type \"%s\"", - colName, TypeNameToString(typename)))); + errmsg("default for column \"%s\" cannot be cast to type \"%s\"", + colName, TypeNameToString(typename)))); } else defaultexpr = NULL; /* - * Find everything that depends on the column (constraints, indexes, - * etc), and record enough information to let us recreate the objects. + * Find everything that depends on the column (constraints, indexes, etc), + * and record enough information to let us recreate the objects. * * The actual recreation does not happen here, but only after we have - * performed all the individual ALTER TYPE operations. We have to - * save the info before executing ALTER TYPE, though, else the - * deparser will get confused. + * performed all the individual ALTER TYPE operations. We have to save + * the info before executing ALTER TYPE, though, else the deparser will + * get confused. * - * There could be multiple entries for the same object, so we must check - * to ensure we process each one only once. Note: we assume that an - * index that implements a constraint will not show a direct - * dependency on the column. + * There could be multiple entries for the same object, so we must check to + * ensure we process each one only once. Note: we assume that an index + * that implements a constraint will not show a direct dependency on the + * column. */ depRel = heap_open(DependRelationId, RowExclusiveLock); @@ -4963,16 +4944,16 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel, if (!list_member_oid(tab->changedIndexOids, foundObject.objectId)) { tab->changedIndexOids = lappend_oid(tab->changedIndexOids, - foundObject.objectId); + foundObject.objectId); tab->changedIndexDefs = lappend(tab->changedIndexDefs, - pg_get_indexdef_string(foundObject.objectId)); + pg_get_indexdef_string(foundObject.objectId)); } } else if (relKind == RELKIND_SEQUENCE) { /* - * This must be a SERIAL column's sequence. We - * need not do anything to it. + * This must be a SERIAL column's sequence. We need + * not do anything to it. */ Assert(foundObject.objectSubId == 0); } @@ -4990,9 +4971,9 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel, if (!list_member_oid(tab->changedConstraintOids, foundObject.objectId)) { tab->changedConstraintOids = lappend_oid(tab->changedConstraintOids, - foundObject.objectId); + foundObject.objectId); tab->changedConstraintDefs = lappend(tab->changedConstraintDefs, - pg_get_constraintdef_string(foundObject.objectId)); + pg_get_constraintdef_string(foundObject.objectId)); } break; @@ -5009,8 +4990,8 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel, case OCLASS_DEFAULT: /* - * Ignore the column's default expression, since we will - * fix it below. + * Ignore the column's default expression, since we will fix + * it below. */ Assert(defaultexpr); break; @@ -5026,8 +5007,8 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel, case OCLASS_SCHEMA: /* - * We don't expect any of these sorts of objects to depend - * on a column. + * We don't expect any of these sorts of objects to depend on + * a column. */ elog(ERROR, "unexpected object depending on column: %s", getObjectDescription(&foundObject)); @@ -5043,8 +5024,8 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel, /* * Now scan for dependencies of this column on other things. The only - * thing we should find is the dependency on the column datatype, - * which we want to remove. + * thing we should find is the dependency on the column datatype, which we + * want to remove. */ ScanKeyInit(&key[0], Anum_pg_depend_classid, @@ -5105,17 +5086,16 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel, add_column_datatype_dependency(RelationGetRelid(rel), attnum, targettype); /* - * Drop any pg_statistic entry for the column, since it's now wrong - * type + * Drop any pg_statistic entry for the column, since it's now wrong type */ RemoveStatistics(RelationGetRelid(rel), attnum); /* - * Update the default, if present, by brute force --- remove and - * re-add the default. Probably unsafe to take shortcuts, since the - * new version may well have additional dependencies. (It's okay to - * do this now, rather than after other ALTER TYPE commands, since the - * default won't depend on other column types.) + * Update the default, if present, by brute force --- remove and re-add + * the default. Probably unsafe to take shortcuts, since the new version + * may well have additional dependencies. (It's okay to do this now, + * rather than after other ALTER TYPE commands, since the default won't + * depend on other column types.) */ if (defaultexpr) { @@ -5123,8 +5103,8 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel, CommandCounterIncrement(); /* - * We use RESTRICT here for safety, but at present we do not - * expect anything to depend on the default. + * We use RESTRICT here for safety, but at present we do not expect + * anything to depend on the default. */ RemoveAttrDefault(RelationGetRelid(rel), attnum, DROP_RESTRICT, true); @@ -5147,12 +5127,12 @@ ATPostAlterTypeCleanup(List **wqueue, AlteredTableInfo *tab) ListCell *l; /* - * Re-parse the index and constraint definitions, and attach them to - * the appropriate work queue entries. We do this before dropping - * because in the case of a FOREIGN KEY constraint, we might not yet - * have exclusive lock on the table the constraint is attached to, and - * we need to get that before dropping. It's safe because the parser - * won't actually look at the catalogs to detect the existing entry. + * Re-parse the index and constraint definitions, and attach them to the + * appropriate work queue entries. We do this before dropping because in + * the case of a FOREIGN KEY constraint, we might not yet have exclusive + * lock on the table the constraint is attached to, and we need to get + * that before dropping. It's safe because the parser won't actually look + * at the catalogs to detect the existing entry. */ foreach(l, tab->changedIndexDefs) ATPostAlterTypeParse((char *) lfirst(l), wqueue); @@ -5160,10 +5140,10 @@ ATPostAlterTypeCleanup(List **wqueue, AlteredTableInfo *tab) ATPostAlterTypeParse((char *) lfirst(l), wqueue); /* - * Now we can drop the existing constraints and indexes --- - * constraints first, since some of them might depend on the indexes. - * It should be okay to use DROP_RESTRICT here, since nothing else - * should be depending on these objects. + * Now we can drop the existing constraints and indexes --- constraints + * first, since some of them might depend on the indexes. It should be + * okay to use DROP_RESTRICT here, since nothing else should be depending + * on these objects. */ foreach(l, tab->changedConstraintOids) { @@ -5182,8 +5162,8 @@ ATPostAlterTypeCleanup(List **wqueue, AlteredTableInfo *tab) } /* - * The objects will get recreated during subsequent passes over the - * work queue. + * The objects will get recreated during subsequent passes over the work + * queue. */ } @@ -5195,8 +5175,8 @@ ATPostAlterTypeParse(char *cmd, List **wqueue) ListCell *list_item; /* - * We expect that we only have to do raw parsing and parse analysis, - * not any rule rewriting, since these will all be utility statements. + * We expect that we only have to do raw parsing and parse analysis, not + * any rule rewriting, since these will all be utility statements. */ raw_parsetree_list = raw_parser(cmd); querytree_list = NIL; @@ -5209,9 +5189,8 @@ ATPostAlterTypeParse(char *cmd, List **wqueue) } /* - * Attach each generated command to the proper place in the work - * queue. Note this could result in creation of entirely new - * work-queue entries. + * Attach each generated command to the proper place in the work queue. + * Note this could result in creation of entirely new work-queue entries. */ foreach(list_item, querytree_list) { @@ -5294,8 +5273,8 @@ ATExecChangeOwner(Oid relationOid, Oid newOwnerId, bool recursing) Form_pg_class tuple_class; /* - * Get exclusive lock till end of transaction on the target table. - * Use relation_open so that we can work on indexes and sequences. + * Get exclusive lock till end of transaction on the target table. Use + * relation_open so that we can work on indexes and sequences. */ target_rel = relation_open(relationOid, AccessExclusiveLock); @@ -5368,11 +5347,11 @@ ATExecChangeOwner(Oid relationOid, Oid newOwnerId, bool recursing) /* Superusers can always do it */ if (!superuser()) { - Oid namespaceOid = tuple_class->relnamespace; + Oid namespaceOid = tuple_class->relnamespace; AclResult aclresult; /* Otherwise, must be owner of the existing object */ - if (!pg_class_ownercheck(relationOid,GetUserId())) + if (!pg_class_ownercheck(relationOid, GetUserId())) aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_CLASS, RelationGetRelationName(target_rel)); @@ -5426,9 +5405,9 @@ ATExecChangeOwner(Oid relationOid, Oid newOwnerId, bool recursing) AlterTypeOwnerInternal(tuple_class->reltype, newOwnerId); /* - * If we are operating on a table, also change the ownership of - * any indexes and sequences that belong to the table, as well as - * the table's toast table (if it has one) + * If we are operating on a table, also change the ownership of any + * indexes and sequences that belong to the table, as well as the + * table's toast table (if it has one) */ if (tuple_class->relkind == RELKIND_RELATION || tuple_class->relkind == RELKIND_TOASTVALUE) @@ -5475,23 +5454,23 @@ change_owner_recurse_to_sequences(Oid relationOid, Oid newOwnerId) { Relation depRel; SysScanDesc scan; - ScanKeyData key[2]; + ScanKeyData key[2]; HeapTuple tup; /* - * SERIAL sequences are those having an internal dependency on one - * of the table's columns (we don't care *which* column, exactly). + * SERIAL sequences are those having an internal dependency on one of the + * table's columns (we don't care *which* column, exactly). */ depRel = heap_open(DependRelationId, AccessShareLock); ScanKeyInit(&key[0], - Anum_pg_depend_refclassid, - BTEqualStrategyNumber, F_OIDEQ, - ObjectIdGetDatum(RelationRelationId)); + Anum_pg_depend_refclassid, + BTEqualStrategyNumber, F_OIDEQ, + ObjectIdGetDatum(RelationRelationId)); ScanKeyInit(&key[1], - Anum_pg_depend_refobjid, - BTEqualStrategyNumber, F_OIDEQ, - ObjectIdGetDatum(relationOid)); + Anum_pg_depend_refobjid, + BTEqualStrategyNumber, F_OIDEQ, + ObjectIdGetDatum(relationOid)); /* we leave refobjsubid unspecified */ scan = systable_beginscan(depRel, DependReferenceIndexId, true, @@ -5605,7 +5584,7 @@ ATPrepSetTableSpace(AlteredTableInfo *tab, Relation rel, char *tablespacename) if (!OidIsValid(tablespaceId)) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), - errmsg("tablespace \"%s\" does not exist", tablespacename))); + errmsg("tablespace \"%s\" does not exist", tablespacename))); /* Check its permissions */ aclresult = pg_tablespace_aclcheck(tablespaceId, GetUserId(), ACL_CREATE); @@ -5616,7 +5595,7 @@ ATPrepSetTableSpace(AlteredTableInfo *tab, Relation rel, char *tablespacename) if (OidIsValid(tab->newTableSpace)) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("cannot have multiple SET TABLESPACE subcommands"))); + errmsg("cannot have multiple SET TABLESPACE subcommands"))); tab->newTableSpace = tablespaceId; } @@ -5650,13 +5629,13 @@ ATExecSetTableSpace(Oid tableOid, Oid newTableSpace) RelationGetRelationName(rel)))); /* - * Don't allow moving temp tables of other backends ... their local - * buffer manager is not going to cope. + * Don't allow moving temp tables of other backends ... their local buffer + * manager is not going to cope. */ if (isOtherTempNamespace(RelationGetNamespace(rel))) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot move temporary tables of other sessions"))); + errmsg("cannot move temporary tables of other sessions"))); /* * No work if no change in tablespace. @@ -5738,16 +5717,16 @@ copy_relation_data(Relation rel, SMgrRelation dst) Page page = (Page) buf; /* - * Since we copy the file directly without looking at the shared - * buffers, we'd better first flush out any pages of the source - * relation that are in shared buffers. We assume no new changes - * will be made while we are holding exclusive lock on the rel. + * Since we copy the file directly without looking at the shared buffers, + * we'd better first flush out any pages of the source relation that are + * in shared buffers. We assume no new changes will be made while we are + * holding exclusive lock on the rel. */ FlushRelationBuffers(rel); /* - * We need to log the copied data in WAL iff WAL archiving is enabled - * AND it's not a temp rel. + * We need to log the copied data in WAL iff WAL archiving is enabled AND + * it's not a temp rel. */ use_wal = XLogArchivingActive() && !rel->rd_istemp; @@ -5791,27 +5770,26 @@ copy_relation_data(Relation rel, SMgrRelation dst) } /* - * Now write the page. We say isTemp = true even if it's not a - * temp rel, because there's no need for smgr to schedule an fsync - * for this write; we'll do it ourselves below. + * Now write the page. We say isTemp = true even if it's not a temp + * rel, because there's no need for smgr to schedule an fsync for this + * write; we'll do it ourselves below. */ smgrwrite(dst, blkno, buf, true); } /* - * If the rel isn't temp, we must fsync it down to disk before it's - * safe to commit the transaction. (For a temp rel we don't care - * since the rel will be uninteresting after a crash anyway.) + * If the rel isn't temp, we must fsync it down to disk before it's safe + * to commit the transaction. (For a temp rel we don't care since the rel + * will be uninteresting after a crash anyway.) * - * It's obvious that we must do this when not WAL-logging the copy. It's - * less obvious that we have to do it even if we did WAL-log the - * copied pages. The reason is that since we're copying outside - * shared buffers, a CHECKPOINT occurring during the copy has no way - * to flush the previously written data to disk (indeed it won't know - * the new rel even exists). A crash later on would replay WAL from - * the checkpoint, therefore it wouldn't replay our earlier WAL - * entries. If we do not fsync those pages here, they might still not - * be on disk when the crash occurs. + * It's obvious that we must do this when not WAL-logging the copy. It's less + * obvious that we have to do it even if we did WAL-log the copied pages. + * The reason is that since we're copying outside shared buffers, a + * CHECKPOINT occurring during the copy has no way to flush the previously + * written data to disk (indeed it won't know the new rel even exists). A + * crash later on would replay WAL from the checkpoint, therefore it + * wouldn't replay our earlier WAL entries. If we do not fsync those pages + * here, they might still not be on disk when the crash occurs. */ if (!rel->rd_istemp) smgrimmedsync(dst); @@ -5855,21 +5833,21 @@ AlterTableCreateToastTable(Oid relOid, bool silent) toastobject; /* - * Grab an exclusive lock on the target table, which we will NOT - * release until end of transaction. (This is probably redundant in - * all present uses...) + * Grab an exclusive lock on the target table, which we will NOT release + * until end of transaction. (This is probably redundant in all present + * uses...) */ rel = heap_open(relOid, AccessExclusiveLock); /* * Toast table is shared if and only if its parent is. * - * We cannot allow toasting a shared relation after initdb (because - * there's no way to mark it toasted in other databases' pg_class). - * Unfortunately we can't distinguish initdb from a manually started - * standalone backend (toasting happens after the bootstrap phase, so - * checking IsBootstrapProcessingMode() won't work). However, we can - * at least prevent this mistake under normal multi-user operation. + * We cannot allow toasting a shared relation after initdb (because there's + * no way to mark it toasted in other databases' pg_class). Unfortunately + * we can't distinguish initdb from a manually started standalone backend + * (toasting happens after the bootstrap phase, so checking + * IsBootstrapProcessingMode() won't work). However, we can at least + * prevent this mistake under normal multi-user operation. */ shared_relation = rel->rd_rel->relisshared; if (shared_relation && IsUnderPostmaster) @@ -5944,11 +5922,10 @@ AlterTableCreateToastTable(Oid relOid, bool silent) tupdesc->attrs[2]->attstorage = 'p'; /* - * Note: the toast relation is placed in the regular pg_toast - * namespace even if its master relation is a temp table. There - * cannot be any naming collision, and the toast rel will be destroyed - * when its master is, so there's no need to handle the toast rel as - * temp. + * Note: the toast relation is placed in the regular pg_toast namespace + * even if its master relation is a temp table. There cannot be any + * naming collision, and the toast rel will be destroyed when its master + * is, so there's no need to handle the toast rel as temp. */ toast_relid = heap_create_with_catalog(toast_relname, PG_TOAST_NAMESPACE, @@ -5971,11 +5948,11 @@ AlterTableCreateToastTable(Oid relOid, bool silent) * * NOTE: the normal TOAST access routines could actually function with a * single-column index on chunk_id only. However, the slice access - * routines use both columns for faster access to an individual chunk. - * In addition, we want it to be unique as a check against the - * possibility of duplicate TOAST chunk OIDs. The index might also be - * a little more efficient this way, since btree isn't all that happy - * with large numbers of equal keys. + * routines use both columns for faster access to an individual chunk. In + * addition, we want it to be unique as a check against the possibility of + * duplicate TOAST chunk OIDs. The index might also be a little more + * efficient this way, since btree isn't all that happy with large numbers + * of equal keys. */ indexInfo = makeNode(IndexInfo); @@ -6000,8 +5977,8 @@ AlterTableCreateToastTable(Oid relOid, bool silent) /* * Update toast rel's pg_class entry to show that it has an index. The - * index OID is stored into the reltoastidxid field for easy access by - * the tuple toaster. + * index OID is stored into the reltoastidxid field for easy access by the + * tuple toaster. */ setRelhasindex(toast_relid, true, true, toast_idxid); @@ -6142,7 +6119,7 @@ AlterTableNamespace(RangeVar *relation, const char *newschema) if (isAnyTempNamespace(nspOid) || isAnyTempNamespace(oldNspOid)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot move objects into or out of temporary schemas"))); + errmsg("cannot move objects into or out of temporary schemas"))); /* same for TOAST schema */ if (nspOid == PG_TOAST_NAMESPACE || oldNspOid == PG_TOAST_NAMESPACE) @@ -6182,7 +6159,7 @@ AlterRelationNamespaceInternal(Relation classRel, Oid relOid, Oid oldNspOid, Oid newNspOid, bool hasDependEntry) { - HeapTuple classTup; + HeapTuple classTup; Form_pg_class classForm; classTup = SearchSysCacheCopy(RELOID, @@ -6236,12 +6213,12 @@ AlterIndexNamespaces(Relation classRel, Relation rel, foreach(l, indexList) { - Oid indexOid = lfirst_oid(l); + Oid indexOid = lfirst_oid(l); /* - * Note: currently, the index will not have its own dependency - * on the namespace, so we don't need to do changeDependencyFor(). - * There's no rowtype in pg_type, either. + * Note: currently, the index will not have its own dependency on the + * namespace, so we don't need to do changeDependencyFor(). There's no + * rowtype in pg_type, either. */ AlterRelationNamespaceInternal(classRel, indexOid, oldNspOid, newNspOid, @@ -6264,12 +6241,12 @@ AlterSeqNamespaces(Relation classRel, Relation rel, { Relation depRel; SysScanDesc scan; - ScanKeyData key[2]; + ScanKeyData key[2]; HeapTuple tup; /* - * SERIAL sequences are those having an internal dependency on one - * of the table's columns (we don't care *which* column, exactly). + * SERIAL sequences are those having an internal dependency on one of the + * table's columns (we don't care *which* column, exactly). */ depRel = heap_open(DependRelationId, AccessShareLock); @@ -6313,9 +6290,10 @@ AlterSeqNamespaces(Relation classRel, Relation rel, AlterRelationNamespaceInternal(classRel, depForm->objid, oldNspOid, newNspOid, true); + /* - * Sequences have entries in pg_type. We need to be careful - * to move them to the new namespace, too. + * Sequences have entries in pg_type. We need to be careful to move + * them to the new namespace, too. */ AlterTypeNamespaceInternal(RelationGetForm(seqRel)->reltype, newNspOid, false); @@ -6348,8 +6326,8 @@ register_on_commit_action(Oid relid, OnCommitAction action) MemoryContext oldcxt; /* - * We needn't bother registering the relation unless there is an ON - * COMMIT action we need to take. + * We needn't bother registering the relation unless there is an ON COMMIT + * action we need to take. */ if (action == ONCOMMIT_NOOP || action == ONCOMMIT_PRESERVE_ROWS) return; @@ -6429,8 +6407,8 @@ PreCommit_on_commit_actions(void) /* * Note that table deletion will call - * remove_on_commit_action, so the entry should get - * marked as deleted. + * remove_on_commit_action, so the entry should get marked + * as deleted. */ Assert(oc->deleting_subid != InvalidSubTransactionId); break; @@ -6440,7 +6418,7 @@ PreCommit_on_commit_actions(void) if (oids_to_truncate != NIL) { heap_truncate(oids_to_truncate); - CommandCounterIncrement(); /* XXX needed? */ + CommandCounterIncrement(); /* XXX needed? */ } } diff --git a/src/backend/commands/tablespace.c b/src/backend/commands/tablespace.c index 4bf2a4777f..f83d1ab884 100644 --- a/src/backend/commands/tablespace.c +++ b/src/backend/commands/tablespace.c @@ -37,7 +37,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/tablespace.c,v 1.27 2005/08/30 01:08:47 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/tablespace.c,v 1.28 2005/10/15 02:49:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -67,7 +67,7 @@ /* GUC variable */ -char *default_tablespace = NULL; +char *default_tablespace = NULL; static bool remove_tablespace_directories(Oid tablespaceoid, bool redo); @@ -118,9 +118,9 @@ TablespaceCreateDbspace(Oid spcNode, Oid dbNode, bool isRedo) if (errno == ENOENT) { /* - * Acquire ExclusiveLock on pg_tablespace to ensure that no - * DROP TABLESPACE or TablespaceCreateDbspace is running - * concurrently. Simple reads from pg_tablespace are OK. + * Acquire ExclusiveLock on pg_tablespace to ensure that no DROP + * TABLESPACE or TablespaceCreateDbspace is running concurrently. + * Simple reads from pg_tablespace are OK. */ Relation rel; @@ -130,8 +130,8 @@ TablespaceCreateDbspace(Oid spcNode, Oid dbNode, bool isRedo) rel = NULL; /* - * Recheck to see if someone created the directory while we - * were waiting for lock. + * Recheck to see if someone created the directory while we were + * waiting for lock. */ if (stat(dir, &st) == 0 && S_ISDIR(st.st_mode)) { @@ -147,22 +147,22 @@ TablespaceCreateDbspace(Oid spcNode, Oid dbNode, bool isRedo) if (errno != ENOENT || !isRedo) ereport(ERROR, (errcode_for_file_access(), - errmsg("could not create directory \"%s\": %m", - dir))); + errmsg("could not create directory \"%s\": %m", + dir))); /* Try to make parent directory too */ parentdir = pstrdup(dir); get_parent_directory(parentdir); if (mkdir(parentdir, S_IRWXU) < 0) ereport(ERROR, (errcode_for_file_access(), - errmsg("could not create directory \"%s\": %m", - parentdir))); + errmsg("could not create directory \"%s\": %m", + parentdir))); pfree(parentdir); if (mkdir(dir, S_IRWXU) < 0) ereport(ERROR, (errcode_for_file_access(), - errmsg("could not create directory \"%s\": %m", - dir))); + errmsg("could not create directory \"%s\": %m", + dir))); } } @@ -209,7 +209,7 @@ CreateTableSpace(CreateTableSpaceStmt *stmt) Oid tablespaceoid; char *location; char *linkloc; - Oid ownerId; + Oid ownerId; /* validate */ @@ -238,7 +238,7 @@ CreateTableSpace(CreateTableSpaceStmt *stmt) if (strchr(location, '\'')) ereport(ERROR, (errcode(ERRCODE_INVALID_NAME), - errmsg("tablespace location may not contain single quotes"))); + errmsg("tablespace location may not contain single quotes"))); /* * Allowing relative paths seems risky @@ -251,9 +251,9 @@ CreateTableSpace(CreateTableSpaceStmt *stmt) errmsg("tablespace location must be an absolute path"))); /* - * Check that location isn't too long. Remember that we're going to - * append '//.' (XXX but do we ever form the whole - * path explicitly? This may be overly conservative.) + * Check that location isn't too long. Remember that we're going to append + * '//.' (XXX but do we ever form the whole path + * explicitly? This may be overly conservative.) */ if (strlen(location) >= (MAXPGPATH - 1 - 10 - 1 - 10 - 1 - 10)) ereport(ERROR, @@ -270,7 +270,7 @@ CreateTableSpace(CreateTableSpaceStmt *stmt) (errcode(ERRCODE_RESERVED_NAME), errmsg("unacceptable tablespace name \"%s\"", stmt->tablespacename), - errdetail("The prefix \"pg_\" is reserved for system tablespaces."))); + errdetail("The prefix \"pg_\" is reserved for system tablespaces."))); /* * Check that there is no other tablespace by this name. (The unique @@ -284,9 +284,9 @@ CreateTableSpace(CreateTableSpaceStmt *stmt) stmt->tablespacename))); /* - * Insert tuple into pg_tablespace. The purpose of doing this first - * is to lock the proposed tablename against other would-be creators. - * The insertion will roll back if we find problems below. + * Insert tuple into pg_tablespace. The purpose of doing this first is to + * lock the proposed tablename against other would-be creators. The + * insertion will roll back if we find problems below. */ rel = heap_open(TableSpaceRelationId, RowExclusiveLock); @@ -312,14 +312,14 @@ CreateTableSpace(CreateTableSpaceStmt *stmt) recordDependencyOnOwner(TableSpaceRelationId, tablespaceoid, ownerId); /* - * Attempt to coerce target directory to safe permissions. If this - * fails, it doesn't exist or has the wrong owner. + * Attempt to coerce target directory to safe permissions. If this fails, + * it doesn't exist or has the wrong owner. */ if (chmod(location, 0700) != 0) ereport(ERROR, (errcode_for_file_access(), - errmsg("could not set permissions on directory \"%s\": %m", - location))); + errmsg("could not set permissions on directory \"%s\": %m", + location))); /* * Check the target directory is empty. @@ -331,11 +331,11 @@ CreateTableSpace(CreateTableSpaceStmt *stmt) location))); /* - * Create the PG_VERSION file in the target directory. This has - * several purposes: to make sure we can write in the directory, to - * prevent someone from creating another tablespace pointing at the - * same directory (the emptiness check above will fail), and to label - * tablespace directories by PG version. + * Create the PG_VERSION file in the target directory. This has several + * purposes: to make sure we can write in the directory, to prevent + * someone from creating another tablespace pointing at the same directory + * (the emptiness check above will fail), and to label tablespace + * directories by PG version. */ set_short_version(location); @@ -375,7 +375,6 @@ CreateTableSpace(CreateTableSpaceStmt *stmt) /* We keep the lock on pg_tablespace until commit */ heap_close(rel, NoLock); - #else /* !HAVE_SYMLINK */ ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), @@ -403,9 +402,8 @@ DropTableSpace(DropTableSpaceStmt *stmt) PreventTransactionChain((void *) stmt, "DROP TABLESPACE"); /* - * Acquire ExclusiveLock on pg_tablespace to ensure that no one else - * is trying to do DROP TABLESPACE or TablespaceCreateDbspace - * concurrently. + * Acquire ExclusiveLock on pg_tablespace to ensure that no one else is + * trying to do DROP TABLESPACE or TablespaceCreateDbspace concurrently. */ rel = heap_open(TableSpaceRelationId, ExclusiveLock); @@ -439,8 +437,7 @@ DropTableSpace(DropTableSpaceStmt *stmt) tablespacename); /* - * Remove the pg_tablespace tuple (this will roll back if we fail - * below) + * Remove the pg_tablespace tuple (this will roll back if we fail below) */ simple_heap_delete(rel, &tuple->t_self); @@ -476,7 +473,6 @@ DropTableSpace(DropTableSpaceStmt *stmt) /* We keep the lock on pg_tablespace until commit */ heap_close(rel, NoLock); - #else /* !HAVE_SYMLINK */ ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), @@ -504,17 +500,17 @@ remove_tablespace_directories(Oid tablespaceoid, bool redo) sprintf(location, "pg_tblspc/%u", tablespaceoid); /* - * Check if the tablespace still contains any files. We try to rmdir - * each per-database directory we find in it. rmdir failure implies - * there are still files in that subdirectory, so give up. (We do not - * have to worry about undoing any already completed rmdirs, since the - * next attempt to use the tablespace from that database will simply - * recreate the subdirectory via TablespaceCreateDbspace.) + * Check if the tablespace still contains any files. We try to rmdir each + * per-database directory we find in it. rmdir failure implies there are + * still files in that subdirectory, so give up. (We do not have to worry + * about undoing any already completed rmdirs, since the next attempt to + * use the tablespace from that database will simply recreate the + * subdirectory via TablespaceCreateDbspace.) * * Since we hold exclusive lock, no one else should be creating any fresh - * subdirectories in parallel. It is possible that new files are - * being created within subdirectories, though, so the rmdir call - * could fail. Worst consequence is a less friendly error message. + * subdirectories in parallel. It is possible that new files are being + * created within subdirectories, though, so the rmdir call could fail. + * Worst consequence is a less friendly error message. */ dirdesc = AllocateDir(location); if (dirdesc == NULL) @@ -558,8 +554,8 @@ remove_tablespace_directories(Oid tablespaceoid, bool redo) FreeDir(dirdesc); /* - * Okay, try to unlink PG_VERSION (we allow it to not be there, even - * in non-REDO case, for robustness). + * Okay, try to unlink PG_VERSION (we allow it to not be there, even in + * non-REDO case, for robustness). */ subfile = palloc(strlen(location) + 11 + 1); sprintf(subfile, "%s/PG_VERSION", location); @@ -577,9 +573,9 @@ remove_tablespace_directories(Oid tablespaceoid, bool redo) /* * Okay, try to remove the symlink. We must however deal with the - * possibility that it's a directory instead of a symlink --- this - * could happen during WAL replay (see TablespaceCreateDbspace), and - * it is also the normal case on Windows. + * possibility that it's a directory instead of a symlink --- this could + * happen during WAL replay (see TablespaceCreateDbspace), and it is also + * the normal case on Windows. */ if (lstat(location, &st) == 0 && S_ISDIR(st.st_mode)) { @@ -725,7 +721,7 @@ RenameTableSpace(const char *oldname, const char *newname) ereport(ERROR, (errcode(ERRCODE_RESERVED_NAME), errmsg("unacceptable tablespace name \"%s\"", newname), - errdetail("The prefix \"pg_\" is reserved for system tablespaces."))); + errdetail("The prefix \"pg_\" is reserved for system tablespaces."))); /* Make sure the new name doesn't exist */ ScanKeyInit(&entry[0], @@ -802,13 +798,13 @@ AlterTableSpaceOwner(const char *name, Oid newOwnerId) check_is_member_of_role(GetUserId(), newOwnerId); /* - * Normally we would also check for create permissions here, - * but there are none for tablespaces so we follow what rename - * tablespace does and omit the create permissions check. + * Normally we would also check for create permissions here, but there + * are none for tablespaces so we follow what rename tablespace does + * and omit the create permissions check. * - * NOTE: Only superusers may create tablespaces to begin with and - * so initially only a superuser would be able to change its - * ownership anyway. + * NOTE: Only superusers may create tablespaces to begin with and so + * initially only a superuser would be able to change its ownership + * anyway. */ memset(repl_null, ' ', sizeof(repl_null)); @@ -860,7 +856,7 @@ assign_default_tablespace(const char *newval, bool doit, GucSource source) { /* * If we aren't inside a transaction, we cannot do database access so - * cannot verify the name. Must accept the value on faith. + * cannot verify the name. Must accept the value on faith. */ if (IsTransactionState()) { @@ -895,15 +891,16 @@ GetDefaultTablespace(void) /* Fast path for default_tablespace == "" */ if (default_tablespace == NULL || default_tablespace[0] == '\0') return InvalidOid; + /* * It is tempting to cache this lookup for more speed, but then we would - * fail to detect the case where the tablespace was dropped since the - * GUC variable was set. Note also that we don't complain if the value - * fails to refer to an existing tablespace; we just silently return - * InvalidOid, causing the new object to be created in the database's - * tablespace. + * fail to detect the case where the tablespace was dropped since the GUC + * variable was set. Note also that we don't complain if the value fails + * to refer to an existing tablespace; we just silently return InvalidOid, + * causing the new object to be created in the database's tablespace. */ result = get_tablespace_oid(default_tablespace); + /* * Allow explicit specification of database's default tablespace in * default_tablespace without triggering permissions checks. @@ -1001,14 +998,14 @@ tblspc_redo(XLogRecPtr lsn, XLogRecord *record) char *linkloc; /* - * Attempt to coerce target directory to safe permissions. If - * this fails, it doesn't exist or has the wrong owner. + * Attempt to coerce target directory to safe permissions. If this + * fails, it doesn't exist or has the wrong owner. */ if (chmod(location, 0700) != 0) ereport(ERROR, (errcode_for_file_access(), - errmsg("could not set permissions on directory \"%s\": %m", - location))); + errmsg("could not set permissions on directory \"%s\": %m", + location))); /* Create or re-create the PG_VERSION file in the target directory */ set_short_version(location); @@ -1022,8 +1019,8 @@ tblspc_redo(XLogRecPtr lsn, XLogRecord *record) if (errno != EEXIST) ereport(ERROR, (errcode_for_file_access(), - errmsg("could not create symbolic link \"%s\": %m", - linkloc))); + errmsg("could not create symbolic link \"%s\": %m", + linkloc))); } pfree(linkloc); diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c index b3caaa4ce3..a3f7c37dc2 100644 --- a/src/backend/commands/trigger.c +++ b/src/backend/commands/trigger.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.194 2005/08/24 17:38:35 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.195 2005/10/15 02:49:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -52,7 +52,7 @@ static HeapTuple ExecCallTriggerFunc(TriggerData *trigdata, Instrumentation *instr, MemoryContext per_tuple_context); static void AfterTriggerSaveEvent(ResultRelInfo *relinfo, int event, - bool row_trigger, HeapTuple oldtup, HeapTuple newtup); + bool row_trigger, HeapTuple oldtup, HeapTuple newtup); /* @@ -98,15 +98,14 @@ CreateTrigger(CreateTrigStmt *stmt, bool forConstraint) { /* * If this trigger is a constraint (and a foreign key one) then we - * really need a constrrelid. Since we don't have one, we'll try - * to generate one from the argument information. + * really need a constrrelid. Since we don't have one, we'll try to + * generate one from the argument information. * * This is really just a workaround for a long-ago pg_dump bug that * omitted the FROM clause in dumped CREATE CONSTRAINT TRIGGER - * commands. We don't want to bomb out completely here if we - * can't determine the correct relation, because that would - * prevent loading the dump file. Instead, NOTICE here and ERROR - * in the trigger. + * commands. We don't want to bomb out completely here if we can't + * determine the correct relation, because that would prevent loading + * the dump file. Instead, NOTICE here and ERROR in the trigger. */ bool needconstrrelid = false; void *elem = NULL; @@ -181,8 +180,8 @@ CreateTrigger(CreateTrigStmt *stmt, bool forConstraint) } /* - * Generate the trigger's OID now, so that we can use it in the name - * if needed. + * Generate the trigger's OID now, so that we can use it in the name if + * needed. */ tgrel = heap_open(TriggerRelationId, RowExclusiveLock); @@ -190,9 +189,8 @@ CreateTrigger(CreateTrigStmt *stmt, bool forConstraint) /* * If trigger is an RI constraint, use specified trigger name as - * constraint name and build a unique trigger name instead. This is - * mainly for backwards compatibility with CREATE CONSTRAINT TRIGGER - * commands. + * constraint name and build a unique trigger name instead. This is mainly + * for backwards compatibility with CREATE CONSTRAINT TRIGGER commands. */ if (stmt->isconstraint) { @@ -246,10 +244,10 @@ CreateTrigger(CreateTrigStmt *stmt, bool forConstraint) } /* - * Scan pg_trigger for existing triggers on relation. We do this - * mainly because we must count them; a secondary benefit is to give a - * nice error message if there's already a trigger of the same name. - * (The unique index on tgrelid/tgname would complain anyway.) + * Scan pg_trigger for existing triggers on relation. We do this mainly + * because we must count them; a secondary benefit is to give a nice error + * message if there's already a trigger of the same name. (The unique + * index on tgrelid/tgname would complain anyway.) * * NOTE that this is cool only because we have AccessExclusiveLock on the * relation, so the trigger set won't be changing underneath us. @@ -267,8 +265,8 @@ CreateTrigger(CreateTrigStmt *stmt, bool forConstraint) if (namestrcmp(&(pg_trigger->tgname), trigname) == 0) ereport(ERROR, (errcode(ERRCODE_DUPLICATE_OBJECT), - errmsg("trigger \"%s\" for relation \"%s\" already exists", - trigname, stmt->relation->relname))); + errmsg("trigger \"%s\" for relation \"%s\" already exists", + trigname, stmt->relation->relname))); found++; } systable_endscan(tgscan); @@ -281,8 +279,8 @@ CreateTrigger(CreateTrigStmt *stmt, bool forConstraint) if (funcrettype != TRIGGEROID) { /* - * We allow OPAQUE just so we can load old dump files. When we - * see a trigger function declared OPAQUE, change it to TRIGGER. + * We allow OPAQUE just so we can load old dump files. When we see a + * trigger function declared OPAQUE, change it to TRIGGER. */ if (funcrettype == OPAQUEOID) { @@ -305,13 +303,13 @@ CreateTrigger(CreateTrigStmt *stmt, bool forConstraint) values[Anum_pg_trigger_tgrelid - 1] = ObjectIdGetDatum(RelationGetRelid(rel)); values[Anum_pg_trigger_tgname - 1] = DirectFunctionCall1(namein, - CStringGetDatum(trigname)); + CStringGetDatum(trigname)); values[Anum_pg_trigger_tgfoid - 1] = ObjectIdGetDatum(funcoid); values[Anum_pg_trigger_tgtype - 1] = Int16GetDatum(tgtype); values[Anum_pg_trigger_tgenabled - 1] = BoolGetDatum(true); values[Anum_pg_trigger_tgisconstraint - 1] = BoolGetDatum(stmt->isconstraint); values[Anum_pg_trigger_tgconstrname - 1] = DirectFunctionCall1(namein, - CStringGetDatum(constrname)); + CStringGetDatum(constrname)); values[Anum_pg_trigger_tgconstrrelid - 1] = ObjectIdGetDatum(constrrelid); values[Anum_pg_trigger_tgdeferrable - 1] = BoolGetDatum(stmt->deferrable); values[Anum_pg_trigger_tginitdeferred - 1] = BoolGetDatum(stmt->initdeferred); @@ -351,13 +349,13 @@ CreateTrigger(CreateTrigStmt *stmt, bool forConstraint) } values[Anum_pg_trigger_tgnargs - 1] = Int16GetDatum(nargs); values[Anum_pg_trigger_tgargs - 1] = DirectFunctionCall1(byteain, - CStringGetDatum(args)); + CStringGetDatum(args)); } else { values[Anum_pg_trigger_tgnargs - 1] = Int16GetDatum(0); values[Anum_pg_trigger_tgargs - 1] = DirectFunctionCall1(byteain, - CStringGetDatum("")); + CStringGetDatum("")); } /* tgattr is currently always a zero-length array */ tgattr = buildint2vector(NULL, 0); @@ -386,9 +384,9 @@ CreateTrigger(CreateTrigStmt *stmt, bool forConstraint) pfree(DatumGetPointer(values[Anum_pg_trigger_tgargs - 1])); /* - * Update relation's pg_class entry. Crucial side-effect: other - * backends (and this one too!) are sent SI message to make them - * rebuild relcache entries. + * Update relation's pg_class entry. Crucial side-effect: other backends + * (and this one too!) are sent SI message to make them rebuild relcache + * entries. */ pgrel = heap_open(RelationRelationId, RowExclusiveLock); tuple = SearchSysCacheCopy(RELOID, @@ -409,19 +407,18 @@ CreateTrigger(CreateTrigStmt *stmt, bool forConstraint) /* * We used to try to update the rel's relcache entry here, but that's - * fairly pointless since it will happen as a byproduct of the - * upcoming CommandCounterIncrement... + * fairly pointless since it will happen as a byproduct of the upcoming + * CommandCounterIncrement... */ /* - * Record dependencies for trigger. Always place a normal dependency - * on the function. If we are doing this in response to an explicit - * CREATE TRIGGER command, also make trigger be auto-dropped if its - * relation is dropped or if the FK relation is dropped. (Auto drop - * is compatible with our pre-7.3 behavior.) If the trigger is being - * made for a constraint, we can skip the relation links; the - * dependency on the constraint will indirectly depend on the - * relations. + * Record dependencies for trigger. Always place a normal dependency on + * the function. If we are doing this in response to an explicit CREATE + * TRIGGER command, also make trigger be auto-dropped if its relation is + * dropped or if the FK relation is dropped. (Auto drop is compatible + * with our pre-7.3 behavior.) If the trigger is being made for a + * constraint, we can skip the relation links; the dependency on the + * constraint will indirectly depend on the relations. */ referenced.classId = ProcedureRelationId; referenced.objectId = funcoid; @@ -565,13 +562,12 @@ RemoveTriggerById(Oid trigOid) heap_close(tgrel, RowExclusiveLock); /* - * Update relation's pg_class entry. Crucial side-effect: other - * backends (and this one too!) are sent SI message to make them - * rebuild relcache entries. + * Update relation's pg_class entry. Crucial side-effect: other backends + * (and this one too!) are sent SI message to make them rebuild relcache + * entries. * - * Note this is OK only because we have AccessExclusiveLock on the rel, - * so no one else is creating/deleting triggers on this rel at the - * same time. + * Note this is OK only because we have AccessExclusiveLock on the rel, so no + * one else is creating/deleting triggers on this rel at the same time. */ pgrel = heap_open(RelationRelationId, RowExclusiveLock); tuple = SearchSysCacheCopy(RELOID, @@ -623,16 +619,16 @@ renametrig(Oid relid, ScanKeyData key[2]; /* - * Grab an exclusive lock on the target table, which we will NOT - * release until end of transaction. + * Grab an exclusive lock on the target table, which we will NOT release + * until end of transaction. */ targetrel = heap_open(relid, AccessExclusiveLock); /* - * Scan pg_trigger twice for existing triggers on relation. We do - * this in order to ensure a trigger does not exist with newname (The - * unique index on tgrelid/tgname would complain anyway) and to ensure - * a trigger does exist with oldname. + * Scan pg_trigger twice for existing triggers on relation. We do this in + * order to ensure a trigger does not exist with newname (The unique index + * on tgrelid/tgname would complain anyway) and to ensure a trigger does + * exist with oldname. * * NOTE that this is cool only because we have AccessExclusiveLock on the * relation, so the trigger set won't be changing underneath us. @@ -655,8 +651,8 @@ renametrig(Oid relid, if (HeapTupleIsValid(tuple = systable_getnext(tgscan))) ereport(ERROR, (errcode(ERRCODE_DUPLICATE_OBJECT), - errmsg("trigger \"%s\" for relation \"%s\" already exists", - newname, RelationGetRelationName(targetrel)))); + errmsg("trigger \"%s\" for relation \"%s\" already exists", + newname, RelationGetRelationName(targetrel)))); systable_endscan(tgscan); /* @@ -687,10 +683,9 @@ renametrig(Oid relid, CatalogUpdateIndexes(tgrel, tuple); /* - * Invalidate relation's relcache entry so that other backends - * (and this one too!) are sent SI message to make them rebuild - * relcache entries. (Ideally this should happen - * automatically...) + * Invalidate relation's relcache entry so that other backends (and + * this one too!) are sent SI message to make them rebuild relcache + * entries. (Ideally this should happen automatically...) */ CacheInvalidateRelcache(targetrel); } @@ -732,13 +727,13 @@ void EnableDisableTrigger(Relation rel, const char *tgname, bool enable, bool skip_system) { - Relation tgrel; - int nkeys; + Relation tgrel; + int nkeys; ScanKeyData keys[2]; SysScanDesc tgscan; - HeapTuple tuple; - bool found; - bool changed; + HeapTuple tuple; + bool found; + bool changed; /* Scan the relevant entries in pg_triggers */ tgrel = heap_open(TriggerRelationId, RowExclusiveLock); @@ -775,8 +770,8 @@ EnableDisableTrigger(Relation rel, const char *tgname, if (!superuser()) ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), - errmsg("permission denied: \"%s\" is a system trigger", - NameStr(oldtrig->tgname)))); + errmsg("permission denied: \"%s\" is a system trigger", + NameStr(oldtrig->tgname)))); } found = true; @@ -784,7 +779,7 @@ EnableDisableTrigger(Relation rel, const char *tgname, if (oldtrig->tgenabled != enable) { /* need to change this one ... make a copy to scribble on */ - HeapTuple newtup = heap_copytuple(tuple); + HeapTuple newtup = heap_copytuple(tuple); Form_pg_trigger newtrig = (Form_pg_trigger) GETSTRUCT(newtup); newtrig->tgenabled = enable; @@ -848,10 +843,10 @@ RelationBuildTriggers(Relation relation) triggers = (Trigger *) palloc(ntrigs * sizeof(Trigger)); /* - * Note: since we scan the triggers using TriggerRelidNameIndexId, we - * will be reading the triggers in name order, except possibly during - * emergency-recovery operations (ie, IsIgnoringSystemIndexes). This - * in turn ensures that triggers will be fired in name order. + * Note: since we scan the triggers using TriggerRelidNameIndexId, we will + * be reading the triggers in name order, except possibly during + * emergency-recovery operations (ie, IsIgnoringSystemIndexes). This in + * turn ensures that triggers will be fired in name order. */ ScanKeyInit(&skey, Anum_pg_trigger_tgrelid, @@ -874,7 +869,7 @@ RelationBuildTriggers(Relation relation) build->tgoid = HeapTupleGetOid(htup); build->tgname = DatumGetCString(DirectFunctionCall1(nameout, - NameGetDatum(&pg_trigger->tgname))); + NameGetDatum(&pg_trigger->tgname))); build->tgfoid = pg_trigger->tgfoid; build->tgtype = pg_trigger->tgtype; build->tgenabled = pg_trigger->tgenabled; @@ -1183,12 +1178,12 @@ equalTriggerDescs(TriggerDesc *trigdesc1, TriggerDesc *trigdesc2) j; /* - * We need not examine the "index" data, just the trigger array - * itself; if we have the same triggers with the same types, the - * derived index data should match. + * We need not examine the "index" data, just the trigger array itself; if + * we have the same triggers with the same types, the derived index data + * should match. * - * As of 7.3 we assume trigger set ordering is significant in the - * comparison; so we just compare corresponding slots of the two sets. + * As of 7.3 we assume trigger set ordering is significant in the comparison; + * so we just compare corresponding slots of the two sets. */ if (trigdesc1 != NULL) { @@ -1279,9 +1274,9 @@ ExecCallTriggerFunc(TriggerData *trigdata, /* * Do the function evaluation in the per-tuple memory context, so that - * leaked memory will be reclaimed once per tuple. Note in particular - * that any new tuple created by the trigger function will live till - * the end of the tuple cycle. + * leaked memory will be reclaimed once per tuple. Note in particular that + * any new tuple created by the trigger function will live till the end of + * the tuple cycle. */ oldContext = MemoryContextSwitchTo(per_tuple_context); @@ -1295,8 +1290,8 @@ ExecCallTriggerFunc(TriggerData *trigdata, MemoryContextSwitchTo(oldContext); /* - * Trigger protocol allows function to return a null pointer, but NOT - * to set the isnull result flag. + * Trigger protocol allows function to return a null pointer, but NOT to + * set the isnull result flag. */ if (fcinfo.isnull) ereport(ERROR, @@ -1305,8 +1300,8 @@ ExecCallTriggerFunc(TriggerData *trigdata, fcinfo.flinfo->fn_oid))); /* - * If doing EXPLAIN ANALYZE, stop charging time to this trigger, - * and count one "tuple returned" (really the number of firings). + * If doing EXPLAIN ANALYZE, stop charging time to this trigger, and count + * one "tuple returned" (really the number of firings). */ if (instr) InstrStopNode(instr + tgindx, true); @@ -1359,7 +1354,7 @@ ExecBSInsertTriggers(EState *estate, ResultRelInfo *relinfo) if (newtuple) ereport(ERROR, (errcode(ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED), - errmsg("BEFORE STATEMENT trigger cannot return a value"))); + errmsg("BEFORE STATEMENT trigger cannot return a value"))); } } @@ -1470,7 +1465,7 @@ ExecBSDeleteTriggers(EState *estate, ResultRelInfo *relinfo) if (newtuple) ereport(ERROR, (errcode(ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED), - errmsg("BEFORE STATEMENT trigger cannot return a value"))); + errmsg("BEFORE STATEMENT trigger cannot return a value"))); } } @@ -1601,7 +1596,7 @@ ExecBSUpdateTriggers(EState *estate, ResultRelInfo *relinfo) if (newtuple) ereport(ERROR, (errcode(ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED), - errmsg("BEFORE STATEMENT trigger cannot return a value"))); + errmsg("BEFORE STATEMENT trigger cannot return a value"))); } } @@ -1703,7 +1698,7 @@ GetTupleForTrigger(EState *estate, ResultRelInfo *relinfo, if (newSlot != NULL) { - HTSU_Result test; + HTSU_Result test; ItemPointerData update_ctid; TransactionId update_xmax; @@ -1751,8 +1746,8 @@ 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; @@ -1799,7 +1794,7 @@ ltrmark:; * they will easily go away during subtransaction abort. * * Because the list of pending events can grow large, we go to some effort - * to minimize memory consumption. We do not use the generic List mechanism + * to minimize memory consumption. We do not use the generic List mechanism * but thread the events manually. * * XXX We need to be able to save the per-event data in a file if it grows too @@ -1832,7 +1827,7 @@ typedef struct SetConstraintStateData bool all_isdeferred; int numstates; /* number of trigstates[] entries in use */ int numalloc; /* allocated size of trigstates[] */ - SetConstraintTriggerData trigstates[1]; /* VARIABLE LENGTH ARRAY */ + SetConstraintTriggerData trigstates[1]; /* VARIABLE LENGTH ARRAY */ } SetConstraintStateData; typedef SetConstraintStateData *SetConstraintState; @@ -1849,12 +1844,12 @@ typedef struct AfterTriggerEventData *AfterTriggerEvent; typedef struct AfterTriggerEventData { - AfterTriggerEvent ate_next; /* list link */ - TriggerEvent ate_event; /* event type and status bits */ - CommandId ate_firing_id; /* ID for firing cycle */ - Oid ate_tgoid; /* the trigger's ID */ - Oid ate_relid; /* the relation it's on */ - ItemPointerData ate_oldctid; /* specific tuple(s) involved */ + AfterTriggerEvent ate_next; /* list link */ + TriggerEvent ate_event; /* event type and status bits */ + CommandId ate_firing_id; /* ID for firing cycle */ + Oid ate_tgoid; /* the trigger's ID */ + Oid ate_relid; /* the relation it's on */ + ItemPointerData ate_oldctid; /* specific tuple(s) involved */ ItemPointerData ate_newctid; } AfterTriggerEventData; @@ -1873,7 +1868,7 @@ typedef struct AfterTriggerEventList * * firing_counter is incremented for each call of afterTriggerInvokeEvents. * We mark firable events with the current firing cycle's ID so that we can - * tell which ones to work on. This ensures sane behavior if a trigger + * tell which ones to work on. This ensures sane behavior if a trigger * function chooses to do SET CONSTRAINTS: the inner SET CONSTRAINTS will * only fire those events that weren't already scheduled for firing. * @@ -1881,7 +1876,7 @@ typedef struct AfterTriggerEventList * This is saved and restored across failed subtransactions. * * events is the current list of deferred events. This is global across - * all subtransactions of the current transaction. In a subtransaction + * all subtransactions of the current transaction. In a subtransaction * abort, we know that the events added by the subtransaction are at the * end of the list, so it is relatively easy to discard them. * @@ -1908,31 +1903,31 @@ typedef struct AfterTriggerEventList * which we similarly use to clean up at subtransaction abort. * * firing_stack is a stack of copies of subtransaction-start-time - * firing_counter. We use this to recognize which deferred triggers were + * firing_counter. We use this to recognize which deferred triggers were * fired (or marked for firing) within an aborted subtransaction. * * We use GetCurrentTransactionNestLevel() to determine the correct array * index in these stacks. maxtransdepth is the number of allocated entries in - * each stack. (By not keeping our own stack pointer, we can avoid trouble + * each stack. (By not keeping our own stack pointer, we can avoid trouble * in cases where errors during subxact abort cause multiple invocations * of AfterTriggerEndSubXact() at the same nesting depth.) */ typedef struct AfterTriggersData { - CommandId firing_counter; /* next firing ID to assign */ - SetConstraintState state; /* the active S C state */ + CommandId firing_counter; /* next firing ID to assign */ + SetConstraintState state; /* the active S C state */ AfterTriggerEventList events; /* deferred-event list */ - int query_depth; /* current query list index */ - AfterTriggerEventList *query_stack; /* events pending from each query */ - int maxquerydepth; /* allocated len of above array */ + int query_depth; /* current query list index */ + AfterTriggerEventList *query_stack; /* events pending from each query */ + int maxquerydepth; /* allocated len of above array */ /* these fields are just for resetting at subtrans abort: */ SetConstraintState *state_stack; /* stacked S C states */ - AfterTriggerEventList *events_stack; /* stacked list pointers */ - int *depth_stack; /* stacked query_depths */ - CommandId *firing_stack; /* stacked firing_counters */ - int maxtransdepth; /* allocated len of above arrays */ + AfterTriggerEventList *events_stack; /* stacked list pointers */ + int *depth_stack; /* stacked query_depths */ + CommandId *firing_stack; /* stacked firing_counters */ + int maxtransdepth; /* allocated len of above arrays */ } AfterTriggersData; typedef AfterTriggersData *AfterTriggers; @@ -1941,14 +1936,14 @@ static AfterTriggers afterTriggers; static void AfterTriggerExecute(AfterTriggerEvent event, - Relation rel, TriggerDesc *trigdesc, - FmgrInfo *finfo, - Instrumentation *instr, - MemoryContext per_tuple_context); + Relation rel, TriggerDesc *trigdesc, + FmgrInfo *finfo, + Instrumentation *instr, + MemoryContext per_tuple_context); static SetConstraintState SetConstraintStateCreate(int numalloc); static SetConstraintState SetConstraintStateCopy(SetConstraintState state); static SetConstraintState SetConstraintStateAddItem(SetConstraintState state, - Oid tgoid, bool tgisdeferred); + Oid tgoid, bool tgisdeferred); /* ---------- @@ -2075,8 +2070,8 @@ AfterTriggerExecute(AfterTriggerEvent event, elog(ERROR, "could not find trigger %u", tgoid); /* - * If doing EXPLAIN ANALYZE, start charging time to this trigger. - * We want to include time spent re-fetching tuples in the trigger cost. + * If doing EXPLAIN ANALYZE, start charging time to this trigger. We want + * to include time spent re-fetching tuples in the trigger cost. */ if (instr) InstrStartNode(instr + tgindx); @@ -2133,8 +2128,8 @@ AfterTriggerExecute(AfterTriggerEvent event, MemoryContextReset(per_tuple_context); /* - * Call the trigger and throw away any possibly returned updated - * tuple. (Don't let ExecCallTriggerFunc measure EXPLAIN time.) + * Call the trigger and throw away any possibly returned updated tuple. + * (Don't let ExecCallTriggerFunc measure EXPLAIN time.) */ rettuple = ExecCallTriggerFunc(&LocTriggerData, tgindx, @@ -2153,8 +2148,8 @@ AfterTriggerExecute(AfterTriggerEvent event, ReleaseBuffer(newbuffer); /* - * If doing EXPLAIN ANALYZE, stop charging time to this trigger, - * and count one "tuple returned" (really the number of firings). + * If doing EXPLAIN ANALYZE, stop charging time to this trigger, and count + * one "tuple returned" (really the number of firings). */ if (instr) InstrStopNode(instr + tgindx, true); @@ -2264,7 +2259,7 @@ afterTriggerMarkEvents(AfterTriggerEventList *events, * * If estate isn't NULL, then we expect that all the firable events are * for triggers of the relations included in the estate's result relation - * array. This allows us to re-use the estate's open relations and + * array. This allows us to re-use the estate's open relations and * trigger cache info. When estate is NULL, we have to find the relations * the hard way. * @@ -2308,8 +2303,8 @@ afterTriggerInvokeEvents(AfterTriggerEventList *events, event->ate_firing_id == firing_id) { /* - * So let's fire it... but first, open the correct - * relation if this is not the same relation as before. + * So let's fire it... but first, open the correct relation if + * this is not the same relation as before. */ if (rel == NULL || rel->rd_id != event->ate_relid) { @@ -2317,7 +2312,7 @@ afterTriggerInvokeEvents(AfterTriggerEventList *events, { /* Find target relation among estate's result rels */ ResultRelInfo *rInfo; - int nr; + int nr; rInfo = estate->es_result_relations; nr = estate->es_num_result_relations; @@ -2328,7 +2323,7 @@ afterTriggerInvokeEvents(AfterTriggerEventList *events, rInfo++; nr--; } - if (nr <= 0) /* should not happen */ + if (nr <= 0) /* should not happen */ elog(ERROR, "could not find relation %u among query result relations", event->ate_relid); rel = rInfo->ri_RelationDesc; @@ -2345,17 +2340,17 @@ afterTriggerInvokeEvents(AfterTriggerEventList *events, FreeTriggerDesc(trigdesc); if (finfo) pfree(finfo); - Assert(instr == NULL); /* never used in this case */ + Assert(instr == NULL); /* never used in this case */ /* - * We assume that an appropriate lock is still held by - * the executor, so grab no new lock here. + * We assume that an appropriate lock is still held by the + * executor, so grab no new lock here. */ rel = heap_open(event->ate_relid, NoLock); /* - * Copy relation's trigger info so that we have a - * stable copy no matter what the called triggers do. + * Copy relation's trigger info so that we have a stable + * copy no matter what the called triggers do. */ trigdesc = CopyTriggerDesc(rel->trigdesc); @@ -2364,8 +2359,7 @@ afterTriggerInvokeEvents(AfterTriggerEventList *events, event->ate_relid); /* - * Allocate space to cache fmgr lookup info for - * triggers. + * Allocate space to cache fmgr lookup info for triggers. */ finfo = (FmgrInfo *) palloc0(trigdesc->numtriggers * sizeof(FmgrInfo)); @@ -2376,8 +2370,8 @@ afterTriggerInvokeEvents(AfterTriggerEventList *events, /* * Fire it. Note that the AFTER_TRIGGER_IN_PROGRESS flag is still - * set, so recursive examinations of the event list won't try - * to re-fire it. + * set, so recursive examinations of the event list won't try to + * re-fire it. */ AfterTriggerExecute(event, rel, trigdesc, finfo, instr, per_tuple_context); @@ -2393,9 +2387,9 @@ afterTriggerInvokeEvents(AfterTriggerEventList *events, * If it's now done, throw it away, if allowed. * * NB: it's possible the trigger call above added more events to the - * queue, or that calls we will do later will want to add more, so - * we have to be careful about maintaining list validity at all - * points here. + * queue, or that calls we will do later will want to add more, so we + * have to be careful about maintaining list validity at all points + * here. */ next_event = event->ate_next; @@ -2499,7 +2493,7 @@ AfterTriggerBeginQuery(void) if (afterTriggers->query_depth >= afterTriggers->maxquerydepth) { /* repalloc will keep the stack in the same context */ - int new_alloc = afterTriggers->maxquerydepth * 2; + int new_alloc = afterTriggers->maxquerydepth * 2; afterTriggers->query_stack = (AfterTriggerEventList *) repalloc(afterTriggers->query_stack, @@ -2537,21 +2531,21 @@ AfterTriggerEndQuery(EState *estate) Assert(afterTriggers->query_depth >= 0); /* - * Process all immediate-mode triggers queued by the query, and move - * the deferred ones to the main list of deferred events. + * Process all immediate-mode triggers queued by the query, and move the + * deferred ones to the main list of deferred events. * - * Notice that we decide which ones will be fired, and put the deferred - * ones on the main list, before anything is actually fired. This - * ensures reasonably sane behavior if a trigger function does - * SET CONSTRAINTS ... IMMEDIATE: all events we have decided to defer - * will be available for it to fire. + * Notice that we decide which ones will be fired, and put the deferred ones + * on the main list, before anything is actually fired. This ensures + * reasonably sane behavior if a trigger function does SET CONSTRAINTS ... + * IMMEDIATE: all events we have decided to defer will be available for it + * to fire. * * If we find no firable events, we don't have to increment firing_counter. */ events = &afterTriggers->query_stack[afterTriggers->query_depth]; if (afterTriggerMarkEvents(events, &afterTriggers->events, true)) { - CommandId firing_id = afterTriggers->firing_counter++; + CommandId firing_id = afterTriggers->firing_counter++; /* OK to delete the immediate events after processing them */ afterTriggerInvokeEvents(events, firing_id, estate, true); @@ -2584,21 +2578,21 @@ AfterTriggerFireDeferred(void) Assert(afterTriggers->query_depth == -1); /* - * If there are any triggers to fire, make sure we have set a snapshot - * for them to use. (Since PortalRunUtility doesn't set a snap for - * COMMIT, we can't assume ActiveSnapshot is valid on entry.) + * If there are any triggers to fire, make sure we have set a snapshot for + * them to use. (Since PortalRunUtility doesn't set a snap for COMMIT, we + * can't assume ActiveSnapshot is valid on entry.) */ events = &afterTriggers->events; if (events->head != NULL) ActiveSnapshot = CopySnapshot(GetTransactionSnapshot()); /* - * Run all the remaining triggers. Loop until they are all gone, - * just in case some trigger queues more for us to do. + * Run all the remaining triggers. Loop until they are all gone, just in + * case some trigger queues more for us to do. */ while (afterTriggerMarkEvents(events, NULL, false)) { - CommandId firing_id = afterTriggers->firing_counter++; + CommandId firing_id = afterTriggers->firing_counter++; afterTriggerInvokeEvents(events, firing_id, NULL, true); } @@ -2643,7 +2637,7 @@ AfterTriggerBeginSubXact(void) int my_level = GetCurrentTransactionNestLevel(); /* - * Ignore call if the transaction is in aborted state. (Probably + * Ignore call if the transaction is in aborted state. (Probably * shouldn't happen?) */ if (afterTriggers == NULL) @@ -2676,7 +2670,7 @@ AfterTriggerBeginSubXact(void) else { /* repalloc will keep the stacks in the same context */ - int new_alloc = afterTriggers->maxtransdepth * 2; + int new_alloc = afterTriggers->maxtransdepth * 2; afterTriggers->state_stack = (SetConstraintState *) repalloc(afterTriggers->state_stack, @@ -2695,8 +2689,8 @@ AfterTriggerBeginSubXact(void) } /* - * Push the current information into the stack. The SET CONSTRAINTS - * state is not saved until/unless changed. + * Push the current information into the stack. The SET CONSTRAINTS state + * is not saved until/unless changed. */ afterTriggers->state_stack[my_level] = NULL; afterTriggers->events_stack[my_level] = afterTriggers->events; @@ -2718,7 +2712,8 @@ AfterTriggerEndSubXact(bool isCommit) CommandId subxact_firing_id; /* - * Ignore call if the transaction is in aborted state. (Probably unneeded) + * Ignore call if the transaction is in aborted state. (Probably + * unneeded) */ if (afterTriggers == NULL) return; @@ -2759,8 +2754,8 @@ AfterTriggerEndSubXact(bool isCommit) */ /* - * Restore the trigger state. If the saved state is NULL, then - * this subxact didn't save it, so it doesn't need restoring. + * Restore the trigger state. If the saved state is NULL, then this + * subxact didn't save it, so it doesn't need restoring. */ state = afterTriggers->state_stack[my_level]; if (state != NULL) @@ -2772,12 +2767,12 @@ AfterTriggerEndSubXact(bool isCommit) afterTriggers->state_stack[my_level] = NULL; /* - * Scan for any remaining deferred events that were marked DONE - * or IN PROGRESS by this subxact or a child, and un-mark them. - * We can recognize such events because they have a firing ID - * greater than or equal to the firing_counter value we saved at - * subtransaction start. (This essentially assumes that the - * current subxact includes all subxacts started after it.) + * Scan for any remaining deferred events that were marked DONE or IN + * PROGRESS by this subxact or a child, and un-mark them. We can + * recognize such events because they have a firing ID greater than or + * equal to the firing_counter value we saved at subtransaction start. + * (This essentially assumes that the current subxact includes all + * subxacts started after it.) */ subxact_firing_id = afterTriggers->firing_stack[my_level]; for (event = afterTriggers->events.head; @@ -2813,7 +2808,7 @@ SetConstraintStateCreate(int numalloc) state = (SetConstraintState) MemoryContextAllocZero(TopTransactionContext, sizeof(SetConstraintStateData) + - (numalloc - 1) *sizeof(SetConstraintTriggerData)); + (numalloc - 1) *sizeof(SetConstraintTriggerData)); state->numalloc = numalloc; @@ -2840,7 +2835,7 @@ SetConstraintStateCopy(SetConstraintState origstate) } /* - * Add a per-trigger item to a SetConstraintState. Returns possibly-changed + * Add a per-trigger item to a SetConstraintState. Returns possibly-changed * pointer to the state object (it will change if we have to repalloc). */ static SetConstraintState @@ -2885,9 +2880,8 @@ AfterTriggerSetState(ConstraintsSetStmt *stmt) return; /* - * If in a subtransaction, and we didn't save the current state - * already, save it so it can be restored if the subtransaction - * aborts. + * If in a subtransaction, and we didn't save the current state already, + * save it so it can be restored if the subtransaction aborts. */ if (my_level > 1 && afterTriggers->state_stack[my_level] == NULL) @@ -2939,7 +2933,7 @@ AfterTriggerSetState(ConstraintsSetStmt *stmt) if (strlen(cname) == 0) ereport(ERROR, (errcode(ERRCODE_INVALID_NAME), - errmsg("unnamed constraints cannot be set explicitly"))); + errmsg("unnamed constraints cannot be set explicitly"))); /* * Setup to scan pg_trigger by tgconstrname ... @@ -2962,9 +2956,9 @@ AfterTriggerSetState(ConstraintsSetStmt *stmt) Form_pg_trigger pg_trigger = (Form_pg_trigger) GETSTRUCT(htup); /* - * If we found some, check that they fit the deferrability - * but skip referential action ones, since they are - * silently never deferrable. + * If we found some, check that they fit the deferrability but + * skip referential action ones, since they are silently never + * deferrable. */ if (pg_trigger->tgfoid != F_RI_FKEY_RESTRICT_UPD && pg_trigger->tgfoid != F_RI_FKEY_RESTRICT_DEL && @@ -3026,15 +3020,15 @@ AfterTriggerSetState(ConstraintsSetStmt *stmt) } /* - * SQL99 requires that when a constraint is set to IMMEDIATE, any - * deferred checks against that constraint must be made when the SET - * CONSTRAINTS command is executed -- i.e. the effects of the SET - * CONSTRAINTS command apply retroactively. We've updated the - * constraints state, so scan the list of previously deferred events - * to fire any that have now become immediate. + * SQL99 requires that when a constraint is set to IMMEDIATE, any deferred + * checks against that constraint must be made when the SET CONSTRAINTS + * command is executed -- i.e. the effects of the SET CONSTRAINTS command + * apply retroactively. We've updated the constraints state, so scan the + * list of previously deferred events to fire any that have now become + * immediate. * - * Obviously, if this was SET ... DEFERRED then it can't have converted - * any unfired events to immediate, so we need do nothing in that case. + * Obviously, if this was SET ... DEFERRED then it can't have converted any + * unfired events to immediate, so we need do nothing in that case. */ if (!stmt->deferred) { @@ -3042,12 +3036,12 @@ AfterTriggerSetState(ConstraintsSetStmt *stmt) if (afterTriggerMarkEvents(events, NULL, true)) { - CommandId firing_id = afterTriggers->firing_counter++; + CommandId firing_id = afterTriggers->firing_counter++; /* - * We can delete fired events if we are at top transaction - * level, but we'd better not if inside a subtransaction, since - * the subtransaction could later get rolled back. + * We can delete fired events if we are at top transaction level, + * but we'd better not if inside a subtransaction, since the + * subtransaction could later get rolled back. */ afterTriggerInvokeEvents(events, firing_id, NULL, !IsSubTransaction()); @@ -3116,9 +3110,9 @@ AfterTriggerSaveEvent(ResultRelInfo *relinfo, int event, bool row_trigger, continue; /* - * If this is an UPDATE of a PK table or FK table that does - * not change the PK or FK respectively, we can skip queuing - * the event: there is no need to fire the trigger. + * If this is an UPDATE of a PK table or FK table that does not change + * the PK or FK respectively, we can skip queuing the event: there is + * no need to fire the trigger. */ if ((event & TRIGGER_EVENT_OPMASK) == TRIGGER_EVENT_UPDATE) { @@ -3134,17 +3128,17 @@ AfterTriggerSaveEvent(ResultRelInfo *relinfo, int event, bool row_trigger, break; case RI_TRIGGER_FK: + /* * Update on FK table * - * There is one exception when updating FK tables: - * if the updated row was inserted by our own - * transaction and the FK is deferred, we still - * need to fire the trigger. This is because our - * UPDATE will invalidate the INSERT so the - * end-of-transaction INSERT RI trigger will not - * do anything, so we have to do the check for the - * UPDATE anyway. + * There is one exception when updating FK tables: if the + * updated row was inserted by our own transaction and the + * FK is deferred, we still need to fire the trigger. This + * is because our UPDATE will invalidate the INSERT so the + * end-of-transaction INSERT RI trigger will not do + * anything, so we have to do the check for the UPDATE + * anyway. */ if (HeapTupleHeaderGetXmin(oldtup->t_data) != GetCurrentTransactionId() && diff --git a/src/backend/commands/typecmds.c b/src/backend/commands/typecmds.c index ee69821bcf..7caacdacd2 100644 --- a/src/backend/commands/typecmds.c +++ b/src/backend/commands/typecmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/typecmds.c,v 1.80 2005/08/22 17:38:20 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/typecmds.c,v 1.81 2005/10/15 02:49:16 momjian Exp $ * * DESCRIPTION * The "DefineFoo" routines take the parse tree and pick out the @@ -130,8 +130,7 @@ DefineType(List *names, List *parameters) /* * Type names must be one character shorter than other names, allowing - * room to create the corresponding array type name with prepended - * "_". + * room to create the corresponding array type name with prepended "_". */ if (strlen(typeName) > (NAMEDATALEN - 2)) ereport(ERROR, @@ -183,10 +182,9 @@ DefineType(List *names, List *parameters) char *a = defGetString(defel); /* - * Note: if argument was an unquoted identifier, parser will - * have applied translations to it, so be prepared to - * recognize translated type names as well as the nominal - * form. + * Note: if argument was an unquoted identifier, parser will have + * applied translations to it, so be prepared to recognize + * translated type names as well as the nominal form. */ if (pg_strcasecmp(a, "double") == 0 || pg_strcasecmp(a, "float8") == 0 || @@ -303,8 +301,8 @@ DefineType(List *names, List *parameters) else ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("type output function %s must return type \"cstring\"", - NameListToString(outputName)))); + errmsg("type output function %s must return type \"cstring\"", + NameListToString(outputName)))); } if (receiveOid) { @@ -312,8 +310,8 @@ DefineType(List *names, List *parameters) if (resulttype != typoid) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("type receive function %s must return type %s", - NameListToString(receiveName), typeName))); + errmsg("type receive function %s must return type %s", + NameListToString(receiveName), typeName))); } if (sendOid) { @@ -321,14 +319,13 @@ DefineType(List *names, List *parameters) if (resulttype != BYTEAOID) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("type send function %s must return type \"bytea\"", - NameListToString(sendName)))); + errmsg("type send function %s must return type \"bytea\"", + NameListToString(sendName)))); } /* - * Convert analysis function proc name to an OID. If no analysis - * function is specified, we'll use zero to select the built-in - * default algorithm. + * Convert analysis function proc name to an OID. If no analysis function + * is specified, we'll use zero to select the built-in default algorithm. */ if (analyzeName) analyzeOid = findTypeAnalyzeFunction(analyzeName, typoid); @@ -361,8 +358,8 @@ DefineType(List *names, List *parameters) false); /* Type NOT NULL */ /* - * When we create a base type (as opposed to a complex type) we need - * to have an array entry for it in pg_type as well. + * When we create a base type (as opposed to a complex type) we need to + * have an array entry for it in pg_type as well. */ shadow_type = makeArrayTypeName(typeName); @@ -430,8 +427,8 @@ RemoveType(List *names, DropBehavior behavior) /* Permission check: must own type or its namespace */ if (!pg_type_ownercheck(typeoid, GetUserId()) && - !pg_namespace_ownercheck(((Form_pg_type) GETSTRUCT(tup))->typnamespace, - GetUserId())) + !pg_namespace_ownercheck(((Form_pg_type) GETSTRUCT(tup))->typnamespace, + GetUserId())) aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_TYPE, TypeNameToString(typename)); @@ -522,12 +519,11 @@ DefineDomain(CreateDomainStmt *stmt) get_namespace_name(domainNamespace)); /* - * Domainnames, unlike typenames don't need to account for the '_' - * prefix. So they can be one character longer. (This test is - * presently useless since the parser will have truncated the name to - * fit. But leave it here since we may someday support arrays of - * domains, in which case we'll be back to needing to enforce - * NAMEDATALEN-2.) + * Domainnames, unlike typenames don't need to account for the '_' prefix. + * So they can be one character longer. (This test is presently useless + * since the parser will have truncated the name to fit. But leave it + * here since we may someday support arrays of domains, in which case + * we'll be back to needing to enforce NAMEDATALEN-2.) */ if (strlen(domainName) > (NAMEDATALEN - 1)) ereport(ERROR, @@ -544,10 +540,9 @@ DefineDomain(CreateDomainStmt *stmt) basetypeoid = HeapTupleGetOid(typeTup); /* - * Base type must be a plain base type. Domains over pseudo types - * would create a security hole. Domains of domains might be made to - * work in the future, but not today. Ditto for domains over complex - * types. + * Base type must be a plain base type. Domains over pseudo types would + * create a security hole. Domains of domains might be made to work in + * the future, but not today. Ditto for domains over complex types. */ typtype = baseType->typtype; if (typtype != 'b') @@ -613,7 +608,7 @@ DefineDomain(CreateDomainStmt *stmt) if (IsA(newConstraint, FkConstraint)) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("foreign key constraints not possible for domains"))); + errmsg("foreign key constraints not possible for domains"))); /* otherwise it should be a plain Constraint */ if (!IsA(newConstraint, Constraint)) @@ -627,8 +622,8 @@ DefineDomain(CreateDomainStmt *stmt) case CONSTR_DEFAULT: /* - * The inherited default value may be overridden by the - * user with the DEFAULT statement. + * The inherited default value may be overridden by the user + * with the DEFAULT statement. */ if (defaultExpr) ereport(ERROR, @@ -639,8 +634,8 @@ DefineDomain(CreateDomainStmt *stmt) pstate = make_parsestate(NULL); /* - * Cook the constr->raw_expr into an expression. Note: - * Name is strictly for error message + * Cook the constr->raw_expr into an expression. Note: Name is + * strictly for error message */ defaultExpr = cookDefault(pstate, constr->raw_expr, basetypeoid, @@ -648,13 +643,13 @@ DefineDomain(CreateDomainStmt *stmt) domainName); /* - * Expression must be stored as a nodeToString result, but - * we also require a valid textual representation (mainly - * to make life easier for pg_dump). + * Expression must be stored as a nodeToString result, but we + * also require a valid textual representation (mainly to make + * life easier for pg_dump). */ defaultValue = deparse_expression(defaultExpr, - deparse_context_for(domainName, - InvalidOid), + deparse_context_for(domainName, + InvalidOid), false, false); defaultValueBin = nodeToString(defaultExpr); break; @@ -663,7 +658,7 @@ DefineDomain(CreateDomainStmt *stmt) if (nullDefined && !typNotNull) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("conflicting NULL/NOT NULL constraints"))); + errmsg("conflicting NULL/NOT NULL constraints"))); typNotNull = true; nullDefined = true; break; @@ -672,7 +667,7 @@ DefineDomain(CreateDomainStmt *stmt) if (nullDefined && typNotNull) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("conflicting NULL/NOT NULL constraints"))); + errmsg("conflicting NULL/NOT NULL constraints"))); typNotNull = false; nullDefined = true; break; @@ -691,13 +686,13 @@ DefineDomain(CreateDomainStmt *stmt) case CONSTR_UNIQUE: ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("unique constraints not possible for domains"))); + errmsg("unique constraints not possible for domains"))); break; case CONSTR_PRIMARY: ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("primary key constraints not possible for domains"))); + errmsg("primary key constraints not possible for domains"))); break; case CONSTR_ATTR_DEFERRABLE: @@ -744,8 +739,7 @@ DefineDomain(CreateDomainStmt *stmt) typNotNull); /* Type NOT NULL */ /* - * Process constraints which refer to the domain ID returned by - * TypeCreate + * Process constraints which refer to the domain ID returned by TypeCreate */ foreach(listptr, schema) { @@ -815,8 +809,8 @@ RemoveDomain(List *names, DropBehavior behavior) /* Permission check: must own type or its namespace */ if (!pg_type_ownercheck(typeoid, GetUserId()) && - !pg_namespace_ownercheck(((Form_pg_type) GETSTRUCT(tup))->typnamespace, - GetUserId())) + !pg_namespace_ownercheck(((Form_pg_type) GETSTRUCT(tup))->typnamespace, + GetUserId())) aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_TYPE, TypeNameToString(typename)); @@ -856,11 +850,11 @@ findTypeInputFunction(List *procname, Oid typeOid) Oid procOid; /* - * Input functions can take a single argument of type CSTRING, or - * three arguments (string, typioparam OID, typmod). + * Input functions can take a single argument of type CSTRING, or three + * arguments (string, typioparam OID, typmod). * - * For backwards compatibility we allow OPAQUE in place of CSTRING; if we - * see this, we issue a warning and fix up the pg_proc entry. + * For backwards compatibility we allow OPAQUE in place of CSTRING; if we see + * this, we issue a warning and fix up the pg_proc entry. */ argList[0] = CSTRINGOID; @@ -897,8 +891,8 @@ findTypeInputFunction(List *procname, Oid typeOid) SetFunctionArgType(procOid, 0, CSTRINGOID); /* - * Need CommandCounterIncrement since DefineType will likely try - * to alter the pg_proc tuple again. + * Need CommandCounterIncrement since DefineType will likely try to + * alter the pg_proc tuple again. */ CommandCounterIncrement(); @@ -925,9 +919,8 @@ findTypeOutputFunction(List *procname, Oid typeOid) /* * Output functions can take a single argument of the type. * - * For backwards compatibility we allow OPAQUE in place of the actual - * type name; if we see this, we issue a warning and fix up the - * pg_proc entry. + * For backwards compatibility we allow OPAQUE in place of the actual type + * name; if we see this, we issue a warning and fix up the pg_proc entry. */ argList[0] = typeOid; @@ -944,13 +937,13 @@ findTypeOutputFunction(List *procname, Oid typeOid) { /* Found, but must complain and fix the pg_proc entry */ ereport(WARNING, - (errmsg("changing argument type of function %s from \"opaque\" to %s", - NameListToString(procname), format_type_be(typeOid)))); + (errmsg("changing argument type of function %s from \"opaque\" to %s", + NameListToString(procname), format_type_be(typeOid)))); SetFunctionArgType(procOid, 0, typeOid); /* - * Need CommandCounterIncrement since DefineType will likely try - * to alter the pg_proc tuple again. + * Need CommandCounterIncrement since DefineType will likely try to + * alter the pg_proc tuple again. */ CommandCounterIncrement(); @@ -975,8 +968,8 @@ findTypeReceiveFunction(List *procname, Oid typeOid) Oid procOid; /* - * Receive functions can take a single argument of type INTERNAL, or - * three arguments (internal, typioparam OID, typmod). + * Receive functions can take a single argument of type INTERNAL, or three + * arguments (internal, typioparam OID, typmod). */ argList[0] = INTERNALOID; @@ -1029,8 +1022,7 @@ findTypeAnalyzeFunction(List *procname, Oid typeOid) Oid procOid; /* - * Analyze functions always take one INTERNAL argument and return - * bool. + * Analyze functions always take one INTERNAL argument and return bool. */ argList[0] = INTERNALOID; @@ -1044,8 +1036,8 @@ findTypeAnalyzeFunction(List *procname, Oid typeOid) if (get_func_rettype(procOid) != BOOLOID) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("type analyze function %s must return type \"boolean\"", - NameListToString(procname)))); + errmsg("type analyze function %s must return type \"boolean\"", + NameListToString(procname)))); return procOid; } @@ -1073,7 +1065,7 @@ DefineCompositeType(const RangeVar *typevar, List *coldeflist) if (coldeflist == NIL) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("composite type must have at least one attribute"))); + errmsg("composite type must have at least one attribute"))); /* * now set the parameters for keys/inheritance etc. All of these are @@ -1165,28 +1157,28 @@ AlterDomainDefault(List *names, Node *defaultRaw) /* * Expression must be stored as a nodeToString result, but we also - * require a valid textual representation (mainly to make life - * easier for pg_dump). + * require a valid textual representation (mainly to make life easier + * for pg_dump). */ defaultValue = deparse_expression(defaultExpr, - deparse_context_for(NameStr(typTup->typname), - InvalidOid), + deparse_context_for(NameStr(typTup->typname), + InvalidOid), false, false); /* * Form an updated tuple with the new default and write it back. */ new_record[Anum_pg_type_typdefaultbin - 1] = DirectFunctionCall1(textin, - CStringGetDatum( - nodeToString(defaultExpr))); + CStringGetDatum( + nodeToString(defaultExpr))); new_record_repl[Anum_pg_type_typdefaultbin - 1] = 'r'; new_record[Anum_pg_type_typdefault - 1] = DirectFunctionCall1(textin, - CStringGetDatum(defaultValue)); + CStringGetDatum(defaultValue)); new_record_repl[Anum_pg_type_typdefault - 1] = 'r'; } else - /* Default is NULL, drop it */ + /* Default is NULL, drop it */ { new_record_nulls[Anum_pg_type_typdefaultbin - 1] = 'n'; new_record_repl[Anum_pg_type_typdefaultbin - 1] = 'r'; @@ -1305,8 +1297,8 @@ AlterDomainNotNull(List *names, bool notNull) ereport(ERROR, (errcode(ERRCODE_NOT_NULL_VIOLATION), errmsg("column \"%s\" of table \"%s\" contains null values", - NameStr(tupdesc->attrs[attnum - 1]->attname), - RelationGetRelationName(testrel)))); + NameStr(tupdesc->attrs[attnum - 1]->attname), + RelationGetRelationName(testrel)))); } } heap_endscan(scan); @@ -1317,8 +1309,8 @@ AlterDomainNotNull(List *names, bool notNull) } /* - * Okay to update pg_type row. We can scribble on typTup because it's - * a copy. + * Okay to update pg_type row. We can scribble on typTup because it's a + * copy. */ typTup->typnotnull = notNull; @@ -1467,7 +1459,7 @@ AlterDomainAddConstraint(List *names, Node *newConstraint) if (IsA(newConstraint, FkConstraint)) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("foreign key constraints not possible for domains"))); + errmsg("foreign key constraints not possible for domains"))); /* otherwise it should be a plain Constraint */ if (!IsA(newConstraint, Constraint)) @@ -1485,13 +1477,13 @@ AlterDomainAddConstraint(List *names, Node *newConstraint) case CONSTR_UNIQUE: ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("unique constraints not possible for domains"))); + errmsg("unique constraints not possible for domains"))); break; case CONSTR_PRIMARY: ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("primary key constraints not possible for domains"))); + errmsg("primary key constraints not possible for domains"))); break; case CONSTR_ATTR_DEFERRABLE: @@ -1511,8 +1503,8 @@ AlterDomainAddConstraint(List *names, Node *newConstraint) /* * Since all other constraint types throw errors, this must be a check - * constraint. First, process the constraint expression and add an - * entry to pg_constraint. + * constraint. First, process the constraint expression and add an entry + * to pg_constraint. */ ccbin = domainAddConstraint(HeapTupleGetOid(tup), typTup->typnamespace, @@ -1572,7 +1564,7 @@ AlterDomainAddConstraint(List *names, Node *newConstraint) ereport(ERROR, (errcode(ERRCODE_CHECK_VIOLATION), errmsg("column \"%s\" of table \"%s\" contains values that violate the new constraint", - NameStr(tupdesc->attrs[attnum - 1]->attname), + NameStr(tupdesc->attrs[attnum - 1]->attname), RelationGetRelationName(testrel)))); } @@ -1626,8 +1618,8 @@ get_rels_with_domain(Oid domainOid, LOCKMODE lockmode) HeapTuple depTup; /* - * We scan pg_depend to find those things that depend on the domain. - * (We assume we can ignore refobjsubid for a domain.) + * We scan pg_depend to find those things that depend on the domain. (We + * assume we can ignore refobjsubid for a domain.) */ depRel = heap_open(DependRelationId, AccessShareLock); @@ -1693,10 +1685,10 @@ get_rels_with_domain(Oid domainOid, LOCKMODE lockmode) } /* - * Confirm column has not been dropped, and is of the expected - * type. This defends against an ALTER DROP COLUMN occuring just - * before we acquired lock ... but if the whole table were - * dropped, we'd still have a problem. + * Confirm column has not been dropped, and is of the expected type. + * This defends against an ALTER DROP COLUMN occuring just before we + * acquired lock ... but if the whole table were dropped, we'd still + * have a problem. */ if (pg_depend->objsubid > RelationGetNumberOfAttributes(rtc->rel)) continue; @@ -1705,9 +1697,9 @@ get_rels_with_domain(Oid domainOid, LOCKMODE lockmode) continue; /* - * Okay, add column to result. We store the columns in - * column-number order; this is just a hack to improve - * predictability of regression test output ... + * Okay, add column to result. We store the columns in column-number + * order; this is just a hack to improve predictability of regression + * test output ... */ Assert(rtc->natts < RelationGetNumberOfAttributes(rtc->rel)); @@ -1777,8 +1769,8 @@ domainAddConstraint(Oid domainOid, Oid domainNamespace, Oid baseTypeOid, constr->name)) ereport(ERROR, (errcode(ERRCODE_DUPLICATE_OBJECT), - errmsg("constraint \"%s\" for domain \"%s\" already exists", - constr->name, domainName))); + errmsg("constraint \"%s\" for domain \"%s\" already exists", + constr->name, domainName))); } else constr->name = ChooseConstraintName(domainName, @@ -1793,11 +1785,11 @@ domainAddConstraint(Oid domainOid, Oid domainNamespace, Oid baseTypeOid, pstate = make_parsestate(NULL); /* - * Set up a CoerceToDomainValue to represent the occurrence of VALUE - * in the expression. Note that it will appear to have the type of - * the base type, not the domain. This seems correct since within the - * check expression, we should not assume the input value can be - * considered a member of the domain. + * Set up a CoerceToDomainValue to represent the occurrence of VALUE in + * the expression. Note that it will appear to have the type of the base + * type, not the domain. This seems correct since within the check + * expression, we should not assume the input value can be considered a + * member of the domain. */ domVal = makeNode(CoerceToDomainValue); domVal->typeId = baseTypeOid; @@ -1818,7 +1810,7 @@ domainAddConstraint(Oid domainOid, Oid domainNamespace, Oid baseTypeOid, if (list_length(pstate->p_rtable) != 0) ereport(ERROR, (errcode(ERRCODE_INVALID_COLUMN_REFERENCE), - errmsg("cannot use table references in domain check constraint"))); + errmsg("cannot use table references in domain check constraint"))); /* * Domains don't allow var clauses (this should be redundant with the @@ -1827,7 +1819,7 @@ domainAddConstraint(Oid domainOid, Oid domainNamespace, Oid baseTypeOid, if (contain_var_clause(expr)) ereport(ERROR, (errcode(ERRCODE_INVALID_COLUMN_REFERENCE), - errmsg("cannot use table references in domain check constraint"))); + errmsg("cannot use table references in domain check constraint"))); /* * No subplans or aggregates, either... @@ -1849,8 +1841,8 @@ domainAddConstraint(Oid domainOid, Oid domainNamespace, Oid baseTypeOid, /* * Deparse it to produce text for consrc. * - * Since VARNOs aren't allowed in domain constraints, relation context - * isn't required as anything other than a shell. + * Since VARNOs aren't allowed in domain constraints, relation context isn't + * required as anything other than a shell. */ ccsrc = deparse_expression(expr, deparse_context_for(domainName, @@ -1881,8 +1873,8 @@ domainAddConstraint(Oid domainOid, Oid domainNamespace, Oid baseTypeOid, ccsrc); /* Source form check constraint */ /* - * Return the compiled constraint expression so the calling routine - * can perform any additional required tests. + * Return the compiled constraint expression so the calling routine can + * perform any additional required tests. */ return ccbin; } @@ -1956,8 +1948,7 @@ GetDomainConstraints(Oid typeOid) continue; /* - * Not expecting conbin to be NULL, but we'll test for it - * anyway + * Not expecting conbin to be NULL, but we'll test for it anyway */ val = fastgetattr(conTup, Anum_pg_constraint_conbin, conRel->rd_att, &isNull); @@ -1978,8 +1969,8 @@ GetDomainConstraints(Oid typeOid) r->check_expr = ExecInitExpr(check_expr, NULL); /* - * use lcons() here because constraints of lower domains - * should be applied earlier. + * use lcons() here because constraints of lower domains should be + * applied earlier. */ result = lcons(r, result); } @@ -1994,8 +1985,8 @@ GetDomainConstraints(Oid typeOid) heap_close(conRel, AccessShareLock); /* - * Only need to add one NOT NULL check regardless of how many domains - * in the stack request it. + * Only need to add one NOT NULL check regardless of how many domains in + * the stack request it. */ if (notNull) { @@ -2071,7 +2062,7 @@ AlterTypeOwner(List *names, Oid newOwnerId) if (!superuser()) { /* Otherwise, must be owner of the existing object */ - if (!pg_type_ownercheck(HeapTupleGetOid(tup),GetUserId())) + if (!pg_type_ownercheck(HeapTupleGetOid(tup), GetUserId())) aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_TYPE, TypeNameToString(typename)); @@ -2088,8 +2079,7 @@ AlterTypeOwner(List *names, Oid newOwnerId) } /* - * Modify the owner --- okay to scribble on typTup because it's a - * copy + * Modify the owner --- okay to scribble on typTup because it's a copy */ typTup->typowner = newOwnerId; @@ -2128,8 +2118,7 @@ AlterTypeOwnerInternal(Oid typeOid, Oid newOwnerId) typTup = (Form_pg_type) GETSTRUCT(tup); /* - * Modify the owner --- okay to scribble on typTup because it's a - * copy + * Modify the owner --- okay to scribble on typTup because it's a copy */ typTup->typowner = newOwnerId; @@ -2150,9 +2139,9 @@ AlterTypeOwnerInternal(Oid typeOid, Oid newOwnerId) void AlterTypeNamespace(List *names, const char *newschema) { - TypeName *typename; - Oid typeOid; - Oid nspOid; + TypeName *typename; + Oid typeOid; + Oid nspOid; /* get type OID */ typename = makeNode(TypeName); @@ -2221,7 +2210,7 @@ AlterTypeNamespaceInternal(Oid typeOid, Oid nspOid, if (isAnyTempNamespace(nspOid) || isAnyTempNamespace(oldNspOid)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot move objects into or out of temporary schemas"))); + errmsg("cannot move objects into or out of temporary schemas"))); /* same for TOAST schema */ if (nspOid == PG_TOAST_NAMESPACE || oldNspOid == PG_TOAST_NAMESPACE) @@ -2264,18 +2253,18 @@ AlterTypeNamespaceInternal(Oid typeOid, Oid nspOid, /* * Composite types have pg_class entries. * - * We need to modify the pg_class tuple as well to - * reflect the change of schema. + * We need to modify the pg_class tuple as well to reflect the change of + * schema. */ if (isCompositeType) { - Relation classRel; + Relation classRel; classRel = heap_open(RelationRelationId, RowExclusiveLock); /* - * The dependency on the schema is listed under the pg_class entry, - * so tell AlterRelationNamespaceInternal to fix it. + * The dependency on the schema is listed under the pg_class entry, so + * tell AlterRelationNamespaceInternal to fix it. */ AlterRelationNamespaceInternal(classRel, typform->typrelid, oldNspOid, nspOid, @@ -2284,8 +2273,8 @@ AlterTypeNamespaceInternal(Oid typeOid, Oid nspOid, heap_close(classRel, RowExclusiveLock); /* - * Check for constraints associated with the composite type - * (we don't currently support this, but probably will someday). + * Check for constraints associated with the composite type (we don't + * currently support this, but probably will someday). */ AlterConstraintNamespaces(typform->typrelid, oldNspOid, nspOid, false); @@ -2297,12 +2286,12 @@ AlterTypeNamespaceInternal(Oid typeOid, Oid nspOid, AlterConstraintNamespaces(typeOid, oldNspOid, nspOid, true); /* - * Update dependency on schema, if any --- a table rowtype has not - * got one. + * Update dependency on schema, if any --- a table rowtype has not got + * one. */ if (typform->typtype != 'c') if (changeDependencyFor(TypeRelationId, typeOid, - NamespaceRelationId, oldNspOid, nspOid) != 1) + NamespaceRelationId, oldNspOid, nspOid) != 1) elog(ERROR, "failed to change schema dependency for type %s", format_type_be(typeOid)); } diff --git a/src/backend/commands/user.c b/src/backend/commands/user.c index 082ea0cf7a..706e85dea5 100644 --- a/src/backend/commands/user.c +++ b/src/backend/commands/user.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/commands/user.c,v 1.160 2005/07/31 17:19:17 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/user.c,v 1.161 2005/10/15 02:49:16 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -34,11 +34,11 @@ extern bool Password_encryption; static List *roleNamesToIds(List *memberNames); static void AddRoleMems(const char *rolename, Oid roleid, - List *memberNames, List *memberIds, - Oid grantorId, bool admin_opt); + List *memberNames, List *memberIds, + Oid grantorId, bool admin_opt); static void DelRoleMems(const char *rolename, Oid roleid, - List *memberNames, List *memberIds, - bool admin_opt); + List *memberNames, List *memberIds, + bool admin_opt); /* Check if current user has createrole privileges */ @@ -78,16 +78,16 @@ CreateRole(CreateRoleStmt *stmt) Oid roleid; ListCell *item; ListCell *option; - char *password = NULL; /* user password */ + char *password = NULL; /* user password */ bool encrypt_password = Password_encryption; /* encrypt password? */ char encrypted_password[MD5_PASSWD_LEN + 1]; - bool issuper = false; /* Make the user a superuser? */ - bool inherit = true; /* Auto inherit privileges? */ + bool issuper = false; /* Make the user a superuser? */ + bool inherit = true; /* Auto inherit privileges? */ bool createrole = false; /* Can this user create roles? */ bool createdb = false; /* Can the user create databases? */ bool canlogin = false; /* Can this user login? */ - int connlimit = -1; /* maximum connections allowed */ - List *addroleto = NIL; /* roles to make this a member of */ + int connlimit = -1; /* maximum connections allowed */ + List *addroleto = NIL; /* roles to make this a member of */ List *rolemembers = NIL; /* roles to be members of this role */ List *adminmembers = NIL; /* roles to be admins of this role */ char *validUntil = NULL; /* time the login is valid until */ @@ -272,9 +272,9 @@ CreateRole(CreateRoleStmt *stmt) stmt->role))); /* - * Check the pg_authid relation to be certain the role doesn't - * already exist. Note we secure exclusive lock because - * we need to protect our eventual update of the flat auth file. + * Check the pg_authid relation to be certain the role doesn't already + * exist. Note we secure exclusive lock because we need to protect our + * eventual update of the flat auth file. */ pg_authid_rel = heap_open(AuthIdRelationId, ExclusiveLock); pg_authid_dsc = RelationGetDescr(pg_authid_rel); @@ -344,8 +344,8 @@ CreateRole(CreateRoleStmt *stmt) CatalogUpdateIndexes(pg_authid_rel, tuple); /* - * Advance command counter so we can see new record; else tests - * in AddRoleMems may fail. + * Advance command counter so we can see new record; else tests in + * AddRoleMems may fail. */ if (addroleto || adminmembers || rolemembers) CommandCounterIncrement(); @@ -355,8 +355,8 @@ CreateRole(CreateRoleStmt *stmt) */ foreach(item, addroleto) { - char *oldrolename = strVal(lfirst(item)); - Oid oldroleid = get_roleid_checked(oldrolename); + char *oldrolename = strVal(lfirst(item)); + Oid oldroleid = get_roleid_checked(oldrolename); AddRoleMems(oldrolename, oldroleid, list_make1(makeString(stmt->role)), @@ -365,8 +365,8 @@ CreateRole(CreateRoleStmt *stmt) } /* - * Add the specified members to this new role. adminmembers get the - * admin option, rolemembers don't. + * Add the specified members to this new role. adminmembers get the admin + * option, rolemembers don't. */ AddRoleMems(stmt->role, roleid, adminmembers, roleNamesToIds(adminmembers), @@ -406,15 +406,15 @@ AlterRole(AlterRoleStmt *stmt) HeapTuple tuple, new_tuple; ListCell *option; - char *password = NULL; /* user password */ + char *password = NULL; /* user password */ bool encrypt_password = Password_encryption; /* encrypt password? */ char encrypted_password[MD5_PASSWD_LEN + 1]; - int issuper = -1; /* Make the user a superuser? */ - int inherit = -1; /* Auto inherit privileges? */ - int createrole = -1; /* Can this user create roles? */ - int createdb = -1; /* Can the user create databases? */ - int canlogin = -1; /* Can this user login? */ - int connlimit = -1; /* maximum connections allowed */ + int issuper = -1; /* Make the user a superuser? */ + int inherit = -1; /* Auto inherit privileges? */ + int createrole = -1; /* Can this user create roles? */ + int createdb = -1; /* Can the user create databases? */ + int canlogin = -1; /* Can this user login? */ + int connlimit = -1; /* maximum connections allowed */ List *rolemembers = NIL; /* roles to be added/removed */ char *validUntil = NULL; /* time the login is valid until */ DefElem *dpassword = NULL; @@ -591,9 +591,9 @@ AlterRole(AlterRoleStmt *stmt) * issuper/createrole/catupdate/etc * * XXX It's rather unclear how to handle catupdate. It's probably best to - * keep it equal to the superuser status, otherwise you could end up - * with a situation where no existing superuser can alter the - * catalogs, including pg_authid! + * keep it equal to the superuser status, otherwise you could end up with + * a situation where no existing superuser can alter the catalogs, + * including pg_authid! */ if (issuper >= 0) { @@ -673,8 +673,8 @@ AlterRole(AlterRoleStmt *stmt) heap_freetuple(new_tuple); /* - * Advance command counter so we can see new record; else tests - * in AddRoleMems may fail. + * Advance command counter so we can see new record; else tests in + * AddRoleMems may fail. */ if (rolemembers) CommandCounterIncrement(); @@ -801,7 +801,8 @@ AlterRoleSet(AlterRoleSetStmt *stmt) void DropRole(DropRoleStmt *stmt) { - Relation pg_authid_rel, pg_auth_members_rel; + Relation pg_authid_rel, + pg_auth_members_rel; ListCell *item; if (!have_createrole_privilege()) @@ -811,9 +812,9 @@ DropRole(DropRoleStmt *stmt) /* * Scan the pg_authid relation to find the Oid of the role(s) to be - * deleted. Note we secure exclusive lock on pg_authid, because we - * need to protect our update of the flat auth file. A regular - * writer's lock on pg_auth_members is sufficient though. + * deleted. Note we secure exclusive lock on pg_authid, because we need + * to protect our update of the flat auth file. A regular writer's lock + * on pg_auth_members is sufficient though. */ pg_authid_rel = heap_open(AuthIdRelationId, ExclusiveLock); pg_auth_members_rel = heap_open(AuthMemRelationId, RowExclusiveLock); @@ -823,7 +824,7 @@ DropRole(DropRoleStmt *stmt) const char *role = strVal(lfirst(item)); HeapTuple tuple, tmp_tuple; - ScanKeyData scankey; + ScanKeyData scankey; char *detail; SysScanDesc sscan; Oid roleid; @@ -865,7 +866,7 @@ DropRole(DropRoleStmt *stmt) /* * Lock the role, so nobody can add dependencies to her while we drop * her. We keep the lock until the end of transaction. - */ + */ LockSharedObject(AuthIdRelationId, roleid, 0, AccessExclusiveLock); /* Check for pg_shdepend entries depending on this role */ @@ -873,7 +874,7 @@ DropRole(DropRoleStmt *stmt) ereport(ERROR, (errcode(ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST), errmsg("role \"%s\" cannot be dropped because some objects depend on it", - role), + role), errdetail("%s", detail))); /* @@ -884,10 +885,10 @@ DropRole(DropRoleStmt *stmt) ReleaseSysCache(tuple); /* - * Remove role from the pg_auth_members table. We have to remove - * all tuples that show it as either a role or a member. + * Remove role from the pg_auth_members table. We have to remove all + * tuples that show it as either a role or a member. * - * XXX what about grantor entries? Maybe we should do one heap scan. + * XXX what about grantor entries? Maybe we should do one heap scan. */ ScanKeyInit(&scankey, Anum_pg_auth_members_roleid, @@ -920,13 +921,13 @@ DropRole(DropRoleStmt *stmt) systable_endscan(sscan); /* - * Advance command counter so that later iterations of this loop - * will see the changes already made. This is essential if, for - * example, we are trying to drop both a role and one of its - * direct members --- we'll get an error if we try to delete the - * linking pg_auth_members tuple twice. (We do not need a CCI - * between the two delete loops above, because it's not allowed - * for a role to directly contain itself.) + * Advance command counter so that later iterations of this loop will + * see the changes already made. This is essential if, for example, + * we are trying to drop both a role and one of its direct members --- + * we'll get an error if we try to delete the linking pg_auth_members + * tuple twice. (We do not need a CCI between the two delete loops + * above, because it's not allowed for a role to directly contain + * itself.) */ CommandCounterIncrement(); } @@ -975,11 +976,11 @@ RenameRole(const char *oldname, const char *newname) errmsg("role \"%s\" does not exist", oldname))); /* - * XXX Client applications probably store the session user somewhere, - * so renaming it could cause confusion. On the other hand, there may - * not be an actual problem besides a little confusion, so think about - * this and decide. Same for SET ROLE ... we don't restrict renaming - * the current effective userid, though. + * XXX Client applications probably store the session user somewhere, so + * renaming it could cause confusion. On the other hand, there may not be + * an actual problem besides a little confusion, so think about this and + * decide. Same for SET ROLE ... we don't restrict renaming the current + * effective userid, though. */ roleid = HeapTupleGetOid(oldtuple); @@ -1032,7 +1033,7 @@ RenameRole(const char *oldname, const char *newname) repl_repl[Anum_pg_authid_rolname - 1] = 'r'; repl_val[Anum_pg_authid_rolname - 1] = DirectFunctionCall1(namein, - CStringGetDatum(newname)); + CStringGetDatum(newname)); repl_null[Anum_pg_authid_rolname - 1] = ' '; datum = heap_getattr(oldtuple, Anum_pg_authid_rolpassword, dsc, &isnull); @@ -1082,23 +1083,22 @@ GrantRole(GrantRoleStmt *stmt) grantee_ids = roleNamesToIds(stmt->grantee_roles); /* - * Even though this operation doesn't change pg_authid, we must - * secure exclusive lock on it to protect our update of the flat - * auth file. + * Even though this operation doesn't change pg_authid, we must secure + * exclusive lock on it to protect our update of the flat auth file. */ pg_authid_rel = heap_open(AuthIdRelationId, ExclusiveLock); /* - * Step through all of the granted roles and add/remove - * entries for the grantees, or, if admin_opt is set, then - * just add/remove the admin option. + * Step through all of the granted roles and add/remove entries for the + * grantees, or, if admin_opt is set, then just add/remove the admin + * option. * * Note: Permissions checking is done by AddRoleMems/DelRoleMems */ foreach(item, stmt->granted_roles) { - char *rolename = strVal(lfirst(item)); - Oid roleid = get_roleid_checked(rolename); + char *rolename = strVal(lfirst(item)); + Oid roleid = get_roleid_checked(rolename); if (stmt->is_grant) AddRoleMems(rolename, roleid, @@ -1132,8 +1132,8 @@ roleNamesToIds(List *memberNames) foreach(l, memberNames) { - char *rolename = strVal(lfirst(l)); - Oid roleid = get_roleid_checked(rolename); + char *rolename = strVal(lfirst(l)); + Oid roleid = get_roleid_checked(rolename); result = lappend_oid(result, roleid); } @@ -1160,8 +1160,8 @@ AddRoleMems(const char *rolename, Oid roleid, { Relation pg_authmem_rel; TupleDesc pg_authmem_dsc; - ListCell *nameitem; - ListCell *iditem; + ListCell *nameitem; + ListCell *iditem; Assert(list_length(memberNames) == list_length(memberIds)); @@ -1170,9 +1170,8 @@ AddRoleMems(const char *rolename, Oid roleid, return; /* - * Check permissions: must have createrole or admin option on the - * role to be changed. To mess with a superuser role, you gotta - * be superuser. + * Check permissions: must have createrole or admin option on the role to + * be changed. To mess with a superuser role, you gotta be superuser. */ if (superuser_arg(roleid)) { @@ -1207,32 +1206,32 @@ AddRoleMems(const char *rolename, Oid roleid, Oid memberid = lfirst_oid(iditem); HeapTuple authmem_tuple; HeapTuple tuple; - Datum new_record[Natts_pg_auth_members]; - char new_record_nulls[Natts_pg_auth_members]; - char new_record_repl[Natts_pg_auth_members]; + Datum new_record[Natts_pg_auth_members]; + char new_record_nulls[Natts_pg_auth_members]; + char new_record_repl[Natts_pg_auth_members]; /* * Refuse creation of membership loops, including the trivial case - * where a role is made a member of itself. We do this by checking - * to see if the target role is already a member of the proposed - * member role. + * where a role is made a member of itself. We do this by checking to + * see if the target role is already a member of the proposed member + * role. */ if (is_member_of_role(roleid, memberid)) ereport(ERROR, (errcode(ERRCODE_INVALID_GRANT_OPERATION), - (errmsg("role \"%s\" is a member of role \"%s\"", - rolename, membername)))); + (errmsg("role \"%s\" is a member of role \"%s\"", + rolename, membername)))); /* - * Check if entry for this role/member already exists; - * if so, give warning unless we are adding admin option. + * Check if entry for this role/member already exists; if so, give + * warning unless we are adding admin option. */ authmem_tuple = SearchSysCache(AUTHMEMROLEMEM, ObjectIdGetDatum(roleid), ObjectIdGetDatum(memberid), 0, 0); if (HeapTupleIsValid(authmem_tuple) && - (!admin_opt || + (!admin_opt || ((Form_pg_auth_members) GETSTRUCT(authmem_tuple))->admin_option)) { ereport(NOTICE, @@ -1301,8 +1300,8 @@ DelRoleMems(const char *rolename, Oid roleid, { Relation pg_authmem_rel; TupleDesc pg_authmem_dsc; - ListCell *nameitem; - ListCell *iditem; + ListCell *nameitem; + ListCell *iditem; Assert(list_length(memberNames) == list_length(memberIds)); @@ -1311,9 +1310,8 @@ DelRoleMems(const char *rolename, Oid roleid, return; /* - * Check permissions: must have createrole or admin option on the - * role to be changed. To mess with a superuser role, you gotta - * be superuser. + * Check permissions: must have createrole or admin option on the role to + * be changed. To mess with a superuser role, you gotta be superuser. */ if (superuser_arg(roleid)) { @@ -1366,9 +1364,9 @@ DelRoleMems(const char *rolename, Oid roleid, { /* Just turn off the admin option */ HeapTuple tuple; - Datum new_record[Natts_pg_auth_members]; - char new_record_nulls[Natts_pg_auth_members]; - char new_record_repl[Natts_pg_auth_members]; + Datum new_record[Natts_pg_auth_members]; + char new_record_nulls[Natts_pg_auth_members]; + char new_record_repl[Natts_pg_auth_members]; /* Build a tuple to update with */ MemSet(new_record, 0, sizeof(new_record)); diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c index 4f9eb19212..506eb23e70 100644 --- a/src/backend/commands/vacuum.c +++ b/src/backend/commands/vacuum.c @@ -13,7 +13,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/vacuum.c,v 1.316 2005/10/03 22:52:21 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/vacuum.c,v 1.317 2005/10/15 02:49:16 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -198,7 +198,7 @@ static TransactionId FreezeLimit; /* non-export function prototypes */ static List *get_rel_oids(List *relids, const RangeVar *vacrel, - const char *stmttype); + const char *stmttype); static void vac_update_dbstats(Oid dbid, TransactionId vacuumXID, TransactionId frozenXID); @@ -281,17 +281,16 @@ vacuum(VacuumStmt *vacstmt, List *relids) elevel = DEBUG2; /* - * We cannot run VACUUM inside a user transaction block; if we were - * inside a transaction, then our commit- and - * start-transaction-command calls would not have the intended effect! - * Furthermore, the forced commit that occurs before truncating the - * relation's file would have the effect of committing the rest of the - * user's transaction too, which would certainly not be the desired - * behavior. (This only applies to VACUUM FULL, though. We could in - * theory run lazy VACUUM inside a transaction block, but we choose to - * disallow that case because we'd rather commit as soon as possible - * after finishing the vacuum. This is mainly so that we can let go - * the AccessExclusiveLock that we may be holding.) + * We cannot run VACUUM inside a user transaction block; if we were inside + * a transaction, then our commit- and start-transaction-command calls + * would not have the intended effect! Furthermore, the forced commit that + * occurs before truncating the relation's file would have the effect of + * committing the rest of the user's transaction too, which would + * certainly not be the desired behavior. (This only applies to VACUUM + * FULL, though. We could in theory run lazy VACUUM inside a transaction + * block, but we choose to disallow that case because we'd rather commit + * as soon as possible after finishing the vacuum. This is mainly so that + * we can let go the AccessExclusiveLock that we may be holding.) * * ANALYZE (without VACUUM) can run either way. */ @@ -306,16 +305,16 @@ vacuum(VacuumStmt *vacstmt, List *relids) /* * Disallow the combination VACUUM FULL FREEZE; although it would mostly * work, VACUUM FULL's ability to move tuples around means that it is - * injecting its own XID into tuple visibility checks. We'd have to + * injecting its own XID into tuple visibility checks. We'd have to * guarantee that every moved tuple is properly marked XMIN_COMMITTED or * XMIN_INVALID before the end of the operation. There are corner cases - * where this does not happen, and getting rid of them all seems hard - * (not to mention fragile to maintain). On the whole it's not worth it + * where this does not happen, and getting rid of them all seems hard (not + * to mention fragile to maintain). On the whole it's not worth it * compared to telling people to use two operations. See pgsql-hackers * discussion of 27-Nov-2004, and comments below for update_hint_bits(). * - * Note: this is enforced here, and not in the grammar, since (a) we can - * give a better error message, and (b) we might want to allow it again + * Note: this is enforced here, and not in the grammar, since (a) we can give + * a better error message, and (b) we might want to allow it again * someday. */ if (vacstmt->vacuum && vacstmt->full && vacstmt->freeze) @@ -333,9 +332,8 @@ vacuum(VacuumStmt *vacstmt, List *relids) /* * Create special memory context for cross-transaction storage. * - * Since it is a child of PortalContext, it will go away eventually even - * if we suffer an error; there's no need for special abort cleanup - * logic. + * Since it is a child of PortalContext, it will go away eventually even if + * we suffer an error; there's no need for special abort cleanup logic. */ vac_context = AllocSetContextCreate(PortalContext, "Vacuum", @@ -347,8 +345,8 @@ vacuum(VacuumStmt *vacstmt, List *relids) all_rels = (relids == NIL && vacstmt->relation == NULL); /* - * Build list of relations to process, unless caller gave us one. - * (If we build one, we put it in vac_context for safekeeping.) + * Build list of relations to process, unless caller gave us one. (If we + * build one, we put it in vac_context for safekeeping.) */ relations = get_rel_oids(relids, vacstmt->relation, stmttype); @@ -357,21 +355,21 @@ vacuum(VacuumStmt *vacstmt, List *relids) /* * It's a database-wide VACUUM. * - * Compute the initially applicable OldestXmin and FreezeLimit XIDs, - * so that we can record these values at the end of the VACUUM. - * Note that individual tables may well be processed with newer - * values, but we can guarantee that no (non-shared) relations are - * processed with older ones. + * Compute the initially applicable OldestXmin and FreezeLimit XIDs, so + * that we can record these values at the end of the VACUUM. Note that + * individual tables may well be processed with newer values, but we + * can guarantee that no (non-shared) relations are processed with + * older ones. * - * It is okay to record non-shared values in pg_database, even though - * we may vacuum shared relations with older cutoffs, because only - * the minimum of the values present in pg_database matters. We - * can be sure that shared relations have at some time been - * vacuumed with cutoffs no worse than the global minimum; for, if - * there is a backend in some other DB with xmin = OLDXMIN that's - * determining the cutoff with which we vacuum shared relations, - * it is not possible for that database to have a cutoff newer - * than OLDXMIN recorded in pg_database. + * It is okay to record non-shared values in pg_database, even though we + * may vacuum shared relations with older cutoffs, because only the + * minimum of the values present in pg_database matters. We can be + * sure that shared relations have at some time been vacuumed with + * cutoffs no worse than the global minimum; for, if there is a + * backend in some other DB with xmin = OLDXMIN that's determining the + * cutoff with which we vacuum shared relations, it is not possible + * for that database to have a cutoff newer than OLDXMIN recorded in + * pg_database. */ vacuum_set_xid_limits(vacstmt, false, &initialOldestXmin, @@ -381,16 +379,15 @@ vacuum(VacuumStmt *vacstmt, List *relids) /* * Decide whether we need to start/commit our own transactions. * - * For VACUUM (with or without ANALYZE): always do so, so that we can - * release locks as soon as possible. (We could possibly use the - * outer transaction for a one-table VACUUM, but handling TOAST tables - * would be problematic.) + * For VACUUM (with or without ANALYZE): always do so, so that we can release + * locks as soon as possible. (We could possibly use the outer + * transaction for a one-table VACUUM, but handling TOAST tables would be + * problematic.) * * For ANALYZE (no VACUUM): if inside a transaction block, we cannot - * start/commit our own transactions. Also, there's no need to do so - * if only processing one relation. For multiple relations when not - * within a transaction block, use own transactions so we can release - * locks sooner. + * start/commit our own transactions. Also, there's no need to do so if + * only processing one relation. For multiple relations when not within a + * transaction block, use own transactions so we can release locks sooner. */ if (vacstmt->vacuum) use_own_xacts = true; @@ -406,8 +403,8 @@ vacuum(VacuumStmt *vacstmt, List *relids) } /* - * If we are running ANALYZE without per-table transactions, we'll - * need a memory context with table lifetime. + * If we are running ANALYZE without per-table transactions, we'll need a + * memory context with table lifetime. */ if (!use_own_xacts) anl_context = AllocSetContextCreate(PortalContext, @@ -417,12 +414,12 @@ vacuum(VacuumStmt *vacstmt, List *relids) ALLOCSET_DEFAULT_MAXSIZE); /* - * vacuum_rel expects to be entered with no transaction active; it - * will start and commit its own transaction. But we are called by an - * SQL command, and so we are executing inside a transaction already. - * We commit the transaction started in PostgresMain() here, and start - * another one before exiting to match the commit waiting for us back - * in PostgresMain(). + * vacuum_rel expects to be entered with no transaction active; it will + * start and commit its own transaction. But we are called by an SQL + * command, and so we are executing inside a transaction already. We + * commit the transaction started in PostgresMain() here, and start + * another one before exiting to match the commit waiting for us back in + * PostgresMain(). */ if (use_own_xacts) { @@ -455,11 +452,11 @@ vacuum(VacuumStmt *vacstmt, List *relids) MemoryContext old_context = NULL; /* - * If using separate xacts, start one for analyze. - * Otherwise, we can use the outer transaction, but we - * still need to call analyze_rel in a memory context that - * will be cleaned up on return (else we leak memory while - * processing multiple tables). + * If using separate xacts, start one for analyze. Otherwise, + * we can use the outer transaction, but we still need to call + * analyze_rel in a memory context that will be cleaned up on + * return (else we leak memory while processing multiple + * tables). */ if (use_own_xacts) { @@ -471,8 +468,8 @@ vacuum(VacuumStmt *vacstmt, List *relids) old_context = MemoryContextSwitchTo(anl_context); /* - * Tell the buffer replacement strategy that vacuum is - * causing the IO + * Tell the buffer replacement strategy that vacuum is causing + * the IO */ StrategyHintVacuum(true); @@ -518,16 +515,16 @@ vacuum(VacuumStmt *vacstmt, List *relids) if (vacstmt->vacuum) { /* - * If it was a database-wide VACUUM, print FSM usage statistics - * (we don't make you be superuser to see these). + * If it was a database-wide VACUUM, print FSM usage statistics (we + * don't make you be superuser to see these). */ if (all_rels) PrintFreeSpaceMapStatistics(elevel); /* * If we completed a database-wide VACUUM without skipping any - * relations, update the database's pg_database row with info - * about the transaction IDs used, and try to truncate pg_clog. + * relations, update the database's pg_database row with info about + * the transaction IDs used, and try to truncate pg_clog. */ if (all_rels) { @@ -539,8 +536,8 @@ vacuum(VacuumStmt *vacstmt, List *relids) /* * Clean up working storage --- note we must do this after - * StartTransactionCommand, else we might be trying to delete the - * active context! + * StartTransactionCommand, else we might be trying to delete the active + * context! */ MemoryContextDelete(vac_context); vac_context = NULL; @@ -725,10 +722,10 @@ vac_update_relstats(Oid relid, BlockNumber num_pages, double num_tuples, LockBuffer(buffer, BUFFER_LOCK_UNLOCK); /* - * Invalidate the tuple in the catcaches; this also arranges to flush - * the relation's relcache entry. (If we fail to commit for some - * reason, no flush will occur, but no great harm is done since there - * are no noncritical state updates here.) + * Invalidate the tuple in the catcaches; this also arranges to flush the + * relation's relcache entry. (If we fail to commit for some reason, no + * flush will occur, but no great harm is done since there are no + * noncritical state updates here.) */ CacheInvalidateHeapTuple(rd, &rtup); @@ -878,8 +875,8 @@ vac_truncate_clog(TransactionId vacuumXID, TransactionId frozenXID) heap_close(relation, AccessShareLock); /* - * Do not truncate CLOG if we seem to have suffered wraparound - * already; the computed minimum XID might be bogus. + * Do not truncate CLOG if we seem to have suffered wraparound already; + * the computed minimum XID might be bogus. */ if (vacuumAlreadyWrapped) { @@ -893,8 +890,8 @@ vac_truncate_clog(TransactionId vacuumXID, TransactionId frozenXID) TruncateCLOG(vacuumXID); /* - * Do not update varsup.c if we seem to have suffered wraparound - * already; the computed XID might be bogus. + * Do not update varsup.c if we seem to have suffered wraparound already; + * the computed XID might be bogus. */ if (frozenAlreadyWrapped) { @@ -911,11 +908,11 @@ vac_truncate_clog(TransactionId vacuumXID, TransactionId frozenXID) age = (int32) (myXID - frozenXID); if (age > (int32) ((MaxTransactionId >> 3) * 3)) ereport(WARNING, - (errmsg("database \"%s\" must be vacuumed within %u transactions", - NameStr(oldest_datname), - (MaxTransactionId >> 1) - age), - errhint("To avoid a database shutdown, execute a full-database VACUUM in \"%s\".", - NameStr(oldest_datname)))); + (errmsg("database \"%s\" must be vacuumed within %u transactions", + NameStr(oldest_datname), + (MaxTransactionId >> 1) - age), + errhint("To avoid a database shutdown, execute a full-database VACUUM in \"%s\".", + NameStr(oldest_datname)))); } @@ -970,8 +967,8 @@ vacuum_rel(Oid relid, VacuumStmt *vacstmt, char expected_relkind) CHECK_FOR_INTERRUPTS(); /* - * Race condition -- if the pg_class tuple has gone away since the - * last time we saw it, we don't need to vacuum it. + * Race condition -- if the pg_class tuple has gone away since the last + * time we saw it, we don't need to vacuum it. */ if (!SearchSysCacheExists(RELOID, ObjectIdGetDatum(relid), @@ -983,24 +980,22 @@ vacuum_rel(Oid relid, VacuumStmt *vacstmt, char expected_relkind) } /* - * Determine the type of lock we want --- hard exclusive lock for a - * FULL vacuum, but just ShareUpdateExclusiveLock for concurrent - * vacuum. Either way, we can be sure that no other backend is - * vacuuming the same table. + * Determine the type of lock we want --- hard exclusive lock for a FULL + * vacuum, but just ShareUpdateExclusiveLock for concurrent vacuum. + * Either way, we can be sure that no other backend is vacuuming the same + * table. */ lmode = vacstmt->full ? AccessExclusiveLock : ShareUpdateExclusiveLock; /* - * Open the class, get an appropriate lock on it, and check - * permissions. + * Open the class, get an appropriate lock on it, and check permissions. * - * We allow the user to vacuum a table if he is superuser, the table - * owner, or the database owner (but in the latter case, only if it's - * not a shared relation). pg_class_ownercheck includes the superuser - * case. + * We allow the user to vacuum a table if he is superuser, the table owner, + * or the database owner (but in the latter case, only if it's not a + * shared relation). pg_class_ownercheck includes the superuser case. * - * Note we choose to treat permissions failure as a WARNING and keep - * trying to vacuum the rest of the DB --- is this appropriate? + * Note we choose to treat permissions failure as a WARNING and keep trying + * to vacuum the rest of the DB --- is this appropriate? */ onerel = relation_open(relid, lmode); @@ -1017,8 +1012,8 @@ vacuum_rel(Oid relid, VacuumStmt *vacstmt, char expected_relkind) } /* - * Check that it's a plain table; we used to do this in get_rel_oids() - * but seems safer to check after we've locked the relation. + * Check that it's a plain table; we used to do this in get_rel_oids() but + * seems safer to check after we've locked the relation. */ if (onerel->rd_rel->relkind != expected_relkind) { @@ -1043,15 +1038,14 @@ vacuum_rel(Oid relid, VacuumStmt *vacstmt, char expected_relkind) relation_close(onerel, lmode); StrategyHintVacuum(false); CommitTransactionCommand(); - return true; /* assume no long-lived data in temp - * tables */ + return true; /* assume no long-lived data in temp tables */ } /* * Get a session-level lock too. This will protect our access to the * relation across multiple transactions, so that we can vacuum the - * relation's TOAST table (if any) secure in the knowledge that no one - * is deleting the parent relation. + * relation's TOAST table (if any) secure in the knowledge that no one is + * deleting the parent relation. * * NOTE: this cannot block, even if someone else is waiting for access, * because the lock manager knows that both lock requests are from the @@ -1087,9 +1081,9 @@ vacuum_rel(Oid relid, VacuumStmt *vacstmt, char expected_relkind) /* * If the relation has a secondary toast rel, vacuum that too while we * still hold the session lock on the master table. Note however that - * "analyze" will not get done on the toast table. This is good, - * because the toaster always uses hardcoded index access and - * statistics are totally unimportant for toast relations. + * "analyze" will not get done on the toast table. This is good, because + * the toaster always uses hardcoded index access and statistics are + * totally unimportant for toast relations. */ if (toast_relid != InvalidOid) { @@ -1128,8 +1122,8 @@ full_vacuum_rel(Relation onerel, VacuumStmt *vacstmt) { VacPageListData vacuum_pages; /* List of pages to vacuum and/or * clean indexes */ - VacPageListData fraged_pages; /* List of pages with space enough - * for re-using */ + VacPageListData fraged_pages; /* List of pages with space enough for + * re-using */ Relation *Irel; int nindexes, i; @@ -1198,7 +1192,7 @@ full_vacuum_rel(Relation onerel, VacuumStmt *vacstmt) /* report results to the stats collector, too */ pgstat_report_vacuum(RelationGetRelid(onerel), onerel->rd_rel->relisshared, - vacstmt->analyze, vacrelstats->rel_tuples); + vacstmt->analyze, vacrelstats->rel_tuples); } @@ -1275,11 +1269,11 @@ scan_heap(VRelStats *vacrelstats, Relation onerel, /* * Since we are holding exclusive lock on the relation, no other - * backend can be accessing the page; however it is possible that - * the background writer will try to write the page if it's already - * marked dirty. To ensure that invalid data doesn't get written to - * disk, we must take exclusive buffer lock wherever we potentially - * modify pages. + * backend can be accessing the page; however it is possible that the + * background writer will try to write the page if it's already marked + * dirty. To ensure that invalid data doesn't get written to disk, we + * must take exclusive buffer lock wherever we potentially modify + * pages. */ LockBuffer(buf, BUFFER_LOCK_EXCLUSIVE); @@ -1292,8 +1286,8 @@ scan_heap(VRelStats *vacrelstats, Relation onerel, VacPage vacpagecopy; ereport(WARNING, - (errmsg("relation \"%s\" page %u is uninitialized --- fixing", - relname, blkno))); + (errmsg("relation \"%s\" page %u is uninitialized --- fixing", + relname, blkno))); PageInit(page, BufferGetPageSize(buf), 0); vacpage->free = ((PageHeader) page)->pd_upper - ((PageHeader) page)->pd_lower; free_space += vacpage->free; @@ -1357,8 +1351,8 @@ scan_heap(VRelStats *vacrelstats, Relation onerel, case HEAPTUPLE_LIVE: /* - * Tuple is good. Consider whether to replace its - * xmin value with FrozenTransactionId. + * Tuple is good. Consider whether to replace its xmin + * value with FrozenTransactionId. */ if (TransactionIdIsNormal(HeapTupleHeaderGetXmin(tuple.t_data)) && TransactionIdPrecedes(HeapTupleHeaderGetXmin(tuple.t_data), @@ -1381,15 +1375,14 @@ scan_heap(VRelStats *vacrelstats, Relation onerel, case HEAPTUPLE_RECENTLY_DEAD: /* - * 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. */ nkeep += 1; /* - * If we do shrinking and this tuple is updated one - * then remember it to construct updated tuple - * dependencies. + * 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), @@ -1399,8 +1392,8 @@ scan_heap(VRelStats *vacrelstats, Relation onerel, { free_vtlinks = 1000; vtlinks = (VTupleLink) repalloc(vtlinks, - (free_vtlinks + num_vtlinks) * - sizeof(VTupleLinkData)); + (free_vtlinks + num_vtlinks) * + sizeof(VTupleLinkData)); } vtlinks[num_vtlinks].new_tid = tuple.t_data->t_ctid; vtlinks[num_vtlinks].this_tid = tuple.t_self; @@ -1411,10 +1404,10 @@ scan_heap(VRelStats *vacrelstats, Relation onerel, case HEAPTUPLE_INSERT_IN_PROGRESS: /* - * This should not happen, since we hold exclusive - * lock on the relation; shouldn't we raise an error? - * (Actually, it can happen in system catalogs, since - * we tend to release write lock before commit there.) + * This should not happen, since we hold exclusive lock on + * the relation; shouldn't we raise an error? (Actually, + * it can happen in system catalogs, since we tend to + * release write lock before commit there.) */ ereport(NOTICE, (errmsg("relation \"%s\" TID %u/%u: InsertTransactionInProgress %u --- can't shrink relation", @@ -1424,10 +1417,10 @@ scan_heap(VRelStats *vacrelstats, Relation onerel, case HEAPTUPLE_DELETE_IN_PROGRESS: /* - * This should not happen, since we hold exclusive - * lock on the relation; shouldn't we raise an error? - * (Actually, it can happen in system catalogs, since - * we tend to release write lock before commit there.) + * This should not happen, since we hold exclusive lock on + * the relation; shouldn't we raise an error? (Actually, + * it can happen in system catalogs, since we tend to + * release write lock before commit there.) */ ereport(NOTICE, (errmsg("relation \"%s\" TID %u/%u: DeleteTransactionInProgress %u --- can't shrink relation", @@ -1444,12 +1437,12 @@ scan_heap(VRelStats *vacrelstats, Relation onerel, ItemId lpp; /* - * Here we are building a temporary copy of the page with - * dead tuples removed. Below we will apply + * Here we are building a temporary copy of the page with dead + * tuples removed. Below we will apply * PageRepairFragmentation to the copy, so that we can - * determine how much space will be available after - * removal of dead tuples. But note we are NOT changing - * the real page yet... + * determine how much space will be available after removal of + * dead tuples. But note we are NOT changing the real page + * yet... */ if (tempPage == NULL) { @@ -1499,8 +1492,8 @@ scan_heap(VRelStats *vacrelstats, Relation onerel, /* * Add the page to fraged_pages if it has a useful amount of free * space. "Useful" means enough for a minimal-sized tuple. But we - * don't know that accurately near the start of the relation, so - * add pages unconditionally if they have >= BLCKSZ/10 free space. + * don't know that accurately near the start of the relation, so add + * pages unconditionally if they have >= BLCKSZ/10 free space. */ do_frag = (vacpage->free >= min_tlen || vacpage->free >= BLCKSZ / 10); @@ -1516,8 +1509,7 @@ scan_heap(VRelStats *vacrelstats, Relation onerel, /* * Include the page in empty_end_pages if it will be empty after - * vacuuming; this is to keep us from using it as a move - * destination. + * vacuuming; this is to keep us from using it as a move destination. */ if (notup) { @@ -1588,11 +1580,11 @@ scan_heap(VRelStats *vacrelstats, Relation onerel, RelationGetRelationName(onerel), tups_vacuumed, num_tuples, nblocks), errdetail("%.0f dead row versions cannot be removed yet.\n" - "Nonremovable row versions range from %lu to %lu bytes long.\n" + "Nonremovable row versions range from %lu to %lu bytes long.\n" "There were %.0f unused item pointers.\n" - "Total free space (including removable row versions) is %.0f bytes.\n" + "Total free space (including removable row versions) is %.0f bytes.\n" "%u pages are or will become empty, including %u at the end of the table.\n" - "%u pages containing %.0f free bytes are potential move destinations.\n" + "%u pages containing %.0f free bytes are potential move destinations.\n" "%s.", nkeep, (unsigned long) min_tlen, (unsigned long) max_tlen, @@ -1663,14 +1655,14 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, vacpage->offsets_used = vacpage->offsets_free = 0; /* - * Scan pages backwards from the last nonempty page, trying to move - * tuples down to lower pages. Quit when we reach a page that we have - * moved any tuples onto, or the first page if we haven't moved - * anything, or when we find a page we cannot completely empty (this - * last condition is handled by "break" statements within the loop). + * Scan pages backwards from the last nonempty page, trying to move tuples + * down to lower pages. Quit when we reach a page that we have moved any + * tuples onto, or the first page if we haven't moved anything, or when we + * find a page we cannot completely empty (this last condition is handled + * by "break" statements within the loop). * - * NB: this code depends on the vacuum_pages and fraged_pages lists being - * in order by blkno. + * NB: this code depends on the vacuum_pages and fraged_pages lists being in + * order by blkno. */ nblocks = vacrelstats->rel_pages; for (blkno = nblocks - vacuum_pages->empty_end_pages - 1; @@ -1688,18 +1680,17 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, vacuum_delay_point(); /* - * Forget fraged_pages pages at or after this one; they're no - * longer useful as move targets, since we only want to move down. - * Note that since we stop the outer loop at last_move_dest_block, - * pages removed here cannot have had anything moved onto them - * already. + * Forget fraged_pages pages at or after this one; they're no longer + * useful as move targets, since we only want to move down. Note that + * since we stop the outer loop at last_move_dest_block, pages removed + * here cannot have had anything moved onto them already. * - * Also note that we don't change the stored fraged_pages list, only - * our local variable num_fraged_pages; so the forgotten pages are - * still available to be loaded into the free space map later. + * Also note that we don't change the stored fraged_pages list, only our + * local variable num_fraged_pages; so the forgotten pages are still + * available to be loaded into the free space map later. */ while (num_fraged_pages > 0 && - fraged_pages->pagedesc[num_fraged_pages - 1]->blkno >= blkno) + fraged_pages->pagedesc[num_fraged_pages - 1]->blkno >= blkno) { Assert(fraged_pages->pagedesc[num_fraged_pages - 1]->offsets_used == 0); --num_fraged_pages; @@ -1752,8 +1743,8 @@ repair_frag(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 */ vacpage->blkno = blkno; maxoff = PageGetMaxOffsetNumber(page); for (offnum = FirstOffsetNumber; @@ -1807,9 +1798,9 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, elog(ERROR, "invalid XVAC in tuple header"); /* - * If this (chain) tuple is moved by me already then I - * have to check is it in vacpage 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 vacpage or not - i.e. is it moved while + * cleaning this page or some previous one. */ /* Can't we Assert(keep_tuples > 0) here? */ @@ -1839,34 +1830,33 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, } /* - * If this tuple is in a chain of tuples created in updates - * by "recent" transactions then we have to move the whole chain - * of tuples to other places, so that we can write new t_ctid - * links that preserve the chain relationship. + * If this tuple is in a chain of tuples created in updates by + * "recent" transactions then we have to move the whole chain of + * tuples to other places, so that we can write new t_ctid links + * that preserve the chain relationship. * * This test is complicated. Read it as "if tuple is a recently - * created updated version, OR if it is an obsoleted version". - * (In the second half of the test, we needn't make any check - * on XMAX --- it must be recently obsoleted, else scan_heap - * would have deemed it removable.) + * created updated version, OR if it is an obsoleted version". (In + * the second half of the test, we needn't make any check on XMAX + * --- it must be recently obsoleted, else scan_heap would have + * deemed it removable.) * - * NOTE: this test is not 100% accurate: it is possible for a - * tuple to be an updated one with recent xmin, and yet not - * match any new_tid entry in the vtlinks list. Presumably - * there was once a parent tuple with xmax matching the xmin, - * but it's possible that that tuple has been removed --- for - * example, if it had xmin = xmax and wasn't itself an updated - * version, then HeapTupleSatisfiesVacuum would deem it removable - * as soon as the xmin xact completes. + * NOTE: this test is not 100% accurate: it is possible for a tuple + * to be an updated one with recent xmin, and yet not match any + * new_tid entry in the vtlinks list. Presumably there was once a + * parent tuple with xmax matching the xmin, but it's possible + * that that tuple has been removed --- for example, if it had + * xmin = xmax and wasn't itself an updated version, then + * HeapTupleSatisfiesVacuum would deem it removable as soon as the + * xmin xact completes. * - * To be on the safe side, we abandon the repair_frag process if - * we cannot find the parent tuple in vtlinks. This may be - * overly conservative; AFAICS it would be safe to move the - * chain. + * To be on the safe side, we abandon the repair_frag process if we + * cannot find the parent tuple in vtlinks. This may be overly + * conservative; AFAICS it would be safe to move the chain. */ if (((tuple.t_data->t_infomask & HEAP_UPDATED) && - !TransactionIdPrecedes(HeapTupleHeaderGetXmin(tuple.t_data), - OldestXmin)) || + !TransactionIdPrecedes(HeapTupleHeaderGetXmin(tuple.t_data), + OldestXmin)) || (!(tuple.t_data->t_infomask & (HEAP_XMAX_INVALID | HEAP_IS_LOCKED)) && !(ItemPointerEquals(&(tuple.t_self), @@ -1899,10 +1889,10 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, } /* - * If this tuple is in the begin/middle of the chain then - * we have to move to the end of chain. As with any - * t_ctid chase, we have to verify that each new tuple - * is really the descendant of the tuple we came from. + * If this tuple is in the begin/middle of the chain then we + * have to move to the end of chain. As with any t_ctid + * chase, we have to verify that each new tuple is really the + * descendant of the tuple we came from. */ while (!(tp.t_data->t_infomask & (HEAP_XMAX_INVALID | HEAP_IS_LOCKED)) && @@ -1963,9 +1953,9 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, free_vtmove = 100; /* - * Now, walk backwards up the chain (towards older tuples) - * and check if all items in chain can be moved. We record - * all the moves that need to be made in the vtmove array. + * Now, walk backwards up the chain (towards older tuples) and + * check if all items in chain can be moved. We record all + * the moves that need to be made in the vtmove array. */ for (;;) { @@ -2020,9 +2010,9 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, /* Done if at beginning of chain */ if (!(tp.t_data->t_infomask & HEAP_UPDATED) || - TransactionIdPrecedes(HeapTupleHeaderGetXmin(tp.t_data), - OldestXmin)) - break; /* out of check-all-items loop */ + TransactionIdPrecedes(HeapTupleHeaderGetXmin(tp.t_data), + OldestXmin)) + break; /* out of check-all-items loop */ /* Move to tuple with prior row version */ vtld.new_tid = tp.t_self; @@ -2041,10 +2031,10 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, } tp.t_self = vtlp->this_tid; Pbuf = ReadBuffer(onerel, - ItemPointerGetBlockNumber(&(tp.t_self))); + ItemPointerGetBlockNumber(&(tp.t_self))); Ppage = BufferGetPage(Pbuf); Pitemid = PageGetItemId(Ppage, - ItemPointerGetOffsetNumber(&(tp.t_self))); + ItemPointerGetOffsetNumber(&(tp.t_self))); /* this can't happen since we saw tuple earlier: */ if (!ItemIdIsUsed(Pitemid)) elog(ERROR, "parent itemid marked as unused"); @@ -2056,19 +2046,18 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, /* * Read above about cases when !ItemIdIsUsed(nextItemid) - * (child item is removed)... Due to the fact that at - * the moment we don't remove unuseful part of - * update-chain, it's possible to get non-matching parent - * row here. Like as in the case which caused this - * problem, we stop shrinking here. I could try to - * find real parent row but want not to do it because - * of real solution will be implemented anyway, later, - * and we are too close to 6.5 release. - vadim - * 06/11/99 + * (child item is removed)... Due to the fact that at the + * moment we don't remove unuseful part of update-chain, + * it's possible to get non-matching parent row here. Like + * as in the case which caused this problem, we stop + * shrinking here. I could try to find real parent row but + * want not to do it because of real solution will be + * implemented anyway, later, and we are too close to 6.5 + * release. - vadim 06/11/99 */ if ((PTdata->t_infomask & HEAP_XMAX_IS_MULTI) || !(TransactionIdEquals(HeapTupleHeaderGetXmax(PTdata), - HeapTupleHeaderGetXmin(tp.t_data)))) + HeapTupleHeaderGetXmin(tp.t_data)))) { ReleaseBuffer(Pbuf); elog(DEBUG2, "too old parent tuple found --- can't continue repair_frag"); @@ -2091,9 +2080,9 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, if (chain_move_failed) { /* - * Undo changes to offsets_used state. We don't - * bother cleaning up the amount-free state, since - * we're not going to do any further tuple motion. + * Undo changes to offsets_used state. We don't bother + * cleaning up the amount-free state, since we're not + * going to do any further tuple motion. */ for (i = 0; i < num_vtmove; i++) { @@ -2119,7 +2108,7 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, /* Get page to move from */ tuple.t_self = vtmove[ti].tid; Cbuf = ReadBuffer(onerel, - ItemPointerGetBlockNumber(&(tuple.t_self))); + ItemPointerGetBlockNumber(&(tuple.t_self))); /* Get page to move to */ dst_buffer = ReadBuffer(onerel, destvacpage->blkno); @@ -2132,7 +2121,7 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, Cpage = BufferGetPage(Cbuf); Citemid = PageGetItemId(Cpage, - ItemPointerGetOffsetNumber(&(tuple.t_self))); + ItemPointerGetOffsetNumber(&(tuple.t_self))); tuple.t_datamcxt = NULL; tuple.t_data = (HeapTupleHeader) PageGetItem(Cpage, Citemid); tuple_len = tuple.t_len = ItemIdGetLength(Citemid); @@ -2211,18 +2200,17 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, } /* walk along page */ /* - * If we broke out of the walk-along-page loop early (ie, still - * have offnum <= maxoff), then we failed to move some tuple off - * this page. No point in shrinking any more, so clean up and - * exit the per-page loop. + * If we broke out of the walk-along-page loop early (ie, still have + * offnum <= maxoff), then we failed to move some tuple off this page. + * No point in shrinking any more, so clean up and exit the per-page + * loop. */ if (offnum < maxoff && keep_tuples > 0) { OffsetNumber off; /* - * Fix vacpage state for any unvisited tuples remaining on - * page + * Fix vacpage state for any unvisited tuples remaining on page */ for (off = OffsetNumberNext(offnum); off <= maxoff; @@ -2238,8 +2226,8 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, continue; /* - * See comments in the walk-along-page loop above about - * why only MOVED_OFF tuples should be found here. + * See comments in the walk-along-page loop above about why + * only MOVED_OFF tuples should be found here. */ if (htup->t_infomask & HEAP_MOVED_IN) elog(ERROR, "HEAP_MOVED_IN was not expected"); @@ -2307,20 +2295,20 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, * We have to commit our tuple movings before we truncate the * relation. Ideally we should do Commit/StartTransactionCommand * here, relying on the session-level table lock to protect our - * exclusive access to the relation. However, that would require - * a lot of extra code to close and re-open the relation, indexes, - * etc. For now, a quick hack: record status of current - * transaction as committed, and continue. + * exclusive access to the relation. However, that would require a + * lot of extra code to close and re-open the relation, indexes, etc. + * For now, a quick hack: record status of current transaction as + * committed, and continue. */ RecordTransactionCommit(); } /* * We are not going to move any more tuples across pages, but we still - * need to apply vacuum_page to compact free space in the remaining - * pages in vacuum_pages list. Note that some of these pages may also - * be in the fraged_pages list, and may have had tuples moved onto - * them; if so, we already did vacuum_page and needn't do it again. + * need to apply vacuum_page to compact free space in the remaining pages + * in vacuum_pages list. Note that some of these pages may also be in the + * fraged_pages list, and may have had tuples moved onto them; if so, we + * already did vacuum_page and needn't do it again. */ for (i = 0, curpage = vacuum_pages->pagedesc; i < vacuumed_pages; @@ -2354,17 +2342,17 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, last_move_dest_block, num_moved); /* - * It'd be cleaner to make this report at the bottom of this routine, - * but then the rusage would double-count the second pass of index - * vacuuming. So do it here and ignore the relatively small amount of - * processing that occurs below. + * It'd be cleaner to make this report at the bottom of this routine, but + * then the rusage would double-count the second pass of index vacuuming. + * So do it here and ignore the relatively small amount of processing that + * occurs below. */ ereport(elevel, - (errmsg("\"%s\": moved %u row versions, truncated %u to %u pages", - RelationGetRelationName(onerel), - num_moved, nblocks, blkno), - errdetail("%s.", - pg_rusage_show(&ru0)))); + (errmsg("\"%s\": moved %u row versions, truncated %u to %u pages", + RelationGetRelationName(onerel), + num_moved, nblocks, blkno), + errdetail("%s.", + pg_rusage_show(&ru0)))); /* * Reflect the motion of system tuples to catalog cache here. @@ -2382,7 +2370,7 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, /* re-sort Nvacpagelist.pagedesc */ for (vpleft = Nvacpagelist.pagedesc, - vpright = Nvacpagelist.pagedesc + Nvacpagelist.num_pages - 1; + vpright = Nvacpagelist.pagedesc + Nvacpagelist.num_pages - 1; vpleft < vpright; vpleft++, vpright--) { vpsave = *vpleft; @@ -2391,11 +2379,10 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, } /* - * keep_tuples is the number of tuples that have been moved - * off a page during chain moves but not been scanned over - * subsequently. The tuple ids of these tuples are not - * recorded as free offsets for any VacPage, so they will not - * be cleared from the indexes. + * keep_tuples is the number of tuples that have been moved off a + * page during chain moves but not been scanned over subsequently. + * The tuple ids of these tuples are not recorded as free offsets + * for any VacPage, so they will not be cleared from the indexes. */ Assert(keep_tuples >= 0); for (i = 0; i < nindexes; i++) @@ -2406,9 +2393,9 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, /* * Clean moved-off tuples from last page in Nvacpagelist list. * - * We need only do this in this one page, because higher-numbered - * pages are going to be truncated from the relation entirely. - * But see comments for update_hint_bits(). + * We need only do this in this one page, because higher-numbered pages + * are going to be truncated from the relation entirely. But see + * comments for update_hint_bits(). */ if (vacpage->blkno == (blkno - 1) && vacpage->offsets_free > 0) @@ -2439,8 +2426,8 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, continue; /* - * See comments in the walk-along-page loop above about - * why only MOVED_OFF tuples should be found here. + * See comments in the walk-along-page loop above about why + * only MOVED_OFF tuples should be found here. */ if (htup->t_infomask & HEAP_MOVED_IN) elog(ERROR, "HEAP_MOVED_IN was not expected"); @@ -2470,8 +2457,8 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, else { /* - * No XLOG record, but still need to flag that XID exists - * on disk + * No XLOG record, but still need to flag that XID exists on + * disk */ MyXactMadeTempRelUpdate = true; } @@ -2554,20 +2541,20 @@ move_chain_tuple(Relation rel, /* * If this page was not used before - clean it. * - * NOTE: a nasty bug used to lurk here. It is possible for the source - * and destination pages to be the same (since this tuple-chain member - * can be on a page lower than the one we're currently processing in - * the outer loop). If that's true, then after vacuum_page() the - * source tuple will have been moved, and tuple.t_data will be - * pointing at garbage. Therefore we must do everything that uses - * old_tup->t_data BEFORE this step!! + * NOTE: a nasty bug used to lurk here. It is possible for the source and + * destination pages to be the same (since this tuple-chain member can be + * on a page lower than the one we're currently processing in the outer + * loop). If that's true, then after vacuum_page() the source tuple will + * have been moved, and tuple.t_data will be pointing at garbage. + * Therefore we must do everything that uses old_tup->t_data BEFORE this + * step!! * - * This path is different from the other callers of vacuum_page, because - * we have already incremented the vacpage's offsets_used field to - * account for the tuple(s) we expect to move onto the page. Therefore - * vacuum_page's check for offsets_used == 0 is wrong. But since - * that's a good debugging check for all other callers, we work around - * it here rather than remove it. + * This path is different from the other callers of vacuum_page, because we + * have already incremented the vacpage's offsets_used field to account + * for the tuple(s) we expect to move onto the page. Therefore + * vacuum_page's check for offsets_used == 0 is wrong. But since that's a + * good debugging check for all other callers, we work around it here + * rather than remove it. */ if (!PageIsEmpty(dst_page) && cleanVpd) { @@ -2579,8 +2566,8 @@ move_chain_tuple(Relation rel, } /* - * Update the state of the copied tuple, and store it on the - * destination page. + * Update the state of the copied tuple, and store it on the destination + * page. */ newtup.t_data->t_infomask &= ~(HEAP_XMIN_COMMITTED | HEAP_XMIN_INVALID | @@ -2601,9 +2588,9 @@ move_chain_tuple(Relation rel, ItemPointerSet(&(newtup.t_self), dst_vacpage->blkno, newoff); /* - * Set new tuple's t_ctid pointing to itself if last tuple in chain, - * and to next tuple in chain otherwise. (Since we move the chain - * in reverse order, this is actually the previously processed tuple.) + * Set new tuple's t_ctid pointing to itself if last tuple in chain, and + * to next tuple in chain otherwise. (Since we move the chain in reverse + * order, this is actually the previously processed tuple.) */ if (!ItemPointerIsValid(ctid)) newtup.t_data->t_ctid = newtup.t_self; @@ -2678,8 +2665,8 @@ move_plain_tuple(Relation rel, * register invalidation of source tuple in catcaches. * * (Note: we do not need to register the copied tuple, because we are not - * changing the tuple contents and so there cannot be any need to - * flush negative catcache entries.) + * changing the tuple contents and so there cannot be any need to flush + * negative catcache entries.) */ CacheInvalidateHeapTuple(rel, old_tup); @@ -2957,9 +2944,9 @@ scan_index(Relation indrel, double num_tuples) /* * Even though we're not planning to delete anything, we use the - * ambulkdelete call, because (a) the scan happens within the index AM - * for more speed, and (b) it may want to pass private statistics to - * the amvacuumcleanup call. + * ambulkdelete call, because (a) the scan happens within the index AM for + * more speed, and (b) it may want to pass private statistics to the + * amvacuumcleanup call. */ stats = index_bulk_delete(indrel, dummy_tid_reaped, NULL); @@ -2978,18 +2965,18 @@ scan_index(Relation indrel, double num_tuples) false); ereport(elevel, - (errmsg("index \"%s\" now contains %.0f row versions in %u pages", - RelationGetRelationName(indrel), - stats->num_index_tuples, - stats->num_pages), - errdetail("%u index pages have been deleted, %u are currently reusable.\n" - "%s.", - stats->pages_deleted, stats->pages_free, - pg_rusage_show(&ru0)))); + (errmsg("index \"%s\" now contains %.0f row versions in %u pages", + RelationGetRelationName(indrel), + stats->num_index_tuples, + stats->num_pages), + errdetail("%u index pages have been deleted, %u are currently reusable.\n" + "%s.", + stats->pages_deleted, stats->pages_free, + pg_rusage_show(&ru0)))); /* - * Check for tuple count mismatch. If the index is partial, then it's - * OK for it to have fewer tuples than the heap; else we got trouble. + * Check for tuple count mismatch. If the index is partial, then it's OK + * for it to have fewer tuples than the heap; else we got trouble. */ if (stats->num_index_tuples != num_tuples) { @@ -3045,20 +3032,20 @@ vacuum_index(VacPageList vacpagelist, Relation indrel, false); ereport(elevel, - (errmsg("index \"%s\" now contains %.0f row versions in %u pages", - RelationGetRelationName(indrel), - stats->num_index_tuples, - stats->num_pages), - errdetail("%.0f index row versions were removed.\n" - "%u index pages have been deleted, %u are currently reusable.\n" - "%s.", - stats->tuples_removed, - stats->pages_deleted, stats->pages_free, - pg_rusage_show(&ru0)))); + (errmsg("index \"%s\" now contains %.0f row versions in %u pages", + RelationGetRelationName(indrel), + stats->num_index_tuples, + stats->num_pages), + errdetail("%.0f index row versions were removed.\n" + "%u index pages have been deleted, %u are currently reusable.\n" + "%s.", + stats->tuples_removed, + stats->pages_deleted, stats->pages_free, + pg_rusage_show(&ru0)))); /* - * Check for tuple count mismatch. If the index is partial, then it's - * OK for it to have fewer tuples than the heap; else we got trouble. + * Check for tuple count mismatch. If the index is partial, then it's OK + * for it to have fewer tuples than the heap; else we got trouble. */ if (stats->num_index_tuples != num_tuples + keep_tuples) { @@ -3067,7 +3054,7 @@ vacuum_index(VacPageList vacpagelist, Relation indrel, ereport(WARNING, (errmsg("index \"%s\" contains %.0f row versions, but table contains %.0f row versions", RelationGetRelationName(indrel), - stats->num_index_tuples, num_tuples + keep_tuples), + stats->num_index_tuples, num_tuples + keep_tuples), errhint("Rebuild the index with REINDEX."))); } @@ -3152,14 +3139,13 @@ vac_update_fsm(Relation onerel, VacPageList fraged_pages, /* * We only report pages with free space at least equal to the average - * request size --- this avoids cluttering FSM with uselessly-small - * bits of space. Although FSM would discard pages with little free - * space anyway, it's important to do this prefiltering because (a) it - * reduces the time spent holding the FSM lock in - * RecordRelationFreeSpace, and (b) FSM uses the number of pages - * reported as a statistic for guiding space management. If we didn't - * threshold our reports the same way vacuumlazy.c does, we'd be - * skewing that statistic. + * request size --- this avoids cluttering FSM with uselessly-small bits + * of space. Although FSM would discard pages with little free space + * anyway, it's important to do this prefiltering because (a) it reduces + * the time spent holding the FSM lock in RecordRelationFreeSpace, and (b) + * FSM uses the number of pages reported as a statistic for guiding space + * management. If we didn't threshold our reports the same way + * vacuumlazy.c does, we'd be skewing that statistic. */ threshold = GetAvgFSMRequestSize(&onerel->rd_node); @@ -3170,9 +3156,9 @@ vac_update_fsm(Relation onerel, VacPageList fraged_pages, for (i = 0; i < nPages; i++) { /* - * fraged_pages may contain entries for pages that we later - * decided to truncate from the relation; don't enter them into - * the free space map! + * fraged_pages may contain entries for pages that we later decided to + * truncate from the relation; don't enter them into the free space + * map! */ if (pagedesc[i]->blkno >= rel_pages) break; @@ -3198,7 +3184,7 @@ copy_vac_page(VacPage vacpage) /* allocate a VacPageData entry */ newvacpage = (VacPage) palloc(sizeof(VacPageData) + - vacpage->offsets_free * sizeof(OffsetNumber)); + vacpage->offsets_free * sizeof(OffsetNumber)); /* fill it in */ if (vacpage->offsets_free > 0) @@ -3368,7 +3354,7 @@ vac_open_indexes(Relation relation, LOCKMODE lockmode, } /* - * Release the resources acquired by vac_open_indexes. Optionally release + * Release the resources acquired by vac_open_indexes. Optionally release * the locks (say NoLock to keep 'em). */ void @@ -3396,8 +3382,7 @@ bool vac_is_partial_index(Relation indrel) { /* - * If the index's AM doesn't support nulls, it's partial for our - * purposes + * If the index's AM doesn't support nulls, it's partial for our purposes */ if (!indrel->rd_am->amindexnulls) return true; diff --git a/src/backend/commands/vacuumlazy.c b/src/backend/commands/vacuumlazy.c index 8a109237ef..7f27619901 100644 --- a/src/backend/commands/vacuumlazy.c +++ b/src/backend/commands/vacuumlazy.c @@ -31,7 +31,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.60 2005/10/03 22:52:22 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.61 2005/10/15 02:49:16 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -67,7 +67,7 @@ typedef struct LVRelStats /* Overall statistics about rel */ BlockNumber rel_pages; double rel_tuples; - BlockNumber pages_removed; + BlockNumber pages_removed; double tuples_deleted; BlockNumber nonempty_pages; /* actually, last nonempty page + 1 */ Size threshold; /* minimum interesting free space */ @@ -97,9 +97,9 @@ static void lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats, static void lazy_vacuum_heap(Relation onerel, LVRelStats *vacrelstats); static void lazy_scan_index(Relation indrel, LVRelStats *vacrelstats); static void lazy_vacuum_index(Relation indrel, - double *index_tups_vacuumed, - BlockNumber *index_pages_removed, - LVRelStats *vacrelstats); + double *index_tups_vacuumed, + BlockNumber *index_pages_removed, + LVRelStats *vacrelstats); static int lazy_vacuum_page(Relation onerel, BlockNumber blkno, Buffer buffer, int tupindex, LVRelStats *vacrelstats); static void lazy_truncate_heap(Relation onerel, LVRelStats *vacrelstats); @@ -167,7 +167,7 @@ lazy_vacuum_rel(Relation onerel, VacuumStmt *vacstmt) */ possibly_freeable = vacrelstats->rel_pages - vacrelstats->nonempty_pages; if (possibly_freeable >= REL_TRUNCATE_MINIMUM || - possibly_freeable >= vacrelstats->rel_pages / REL_TRUNCATE_FRACTION) + possibly_freeable >= vacrelstats->rel_pages / REL_TRUNCATE_FRACTION) lazy_truncate_heap(onerel, vacrelstats); /* Update shared free space map with final free space info */ @@ -181,7 +181,7 @@ lazy_vacuum_rel(Relation onerel, VacuumStmt *vacstmt) /* report results to the stats collector, too */ pgstat_report_vacuum(RelationGetRelid(onerel), onerel->rd_rel->relisshared, - vacstmt->analyze, vacrelstats->rel_tuples); + vacstmt->analyze, vacrelstats->rel_tuples); } @@ -228,7 +228,7 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats, * track of the total number of rows and pages removed from each index. * index_tups_vacuumed[i] is the number removed so far from the i'th * index. (For partial indexes this could well be different from - * tups_vacuumed.) Likewise for index_pages_removed[i]. + * tups_vacuumed.) Likewise for index_pages_removed[i]. */ index_tups_vacuumed = (double *) palloc0(nindexes * sizeof(double)); index_pages_removed = (BlockNumber *) palloc0(nindexes * sizeof(BlockNumber)); @@ -253,9 +253,8 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats, vacuum_delay_point(); /* - * If we are close to overrunning the available space for - * dead-tuple TIDs, pause and do a cycle of vacuuming before we - * tackle this page. + * If we are close to overrunning the available space for dead-tuple + * TIDs, pause and do a cycle of vacuuming before we tackle this page. */ if ((vacrelstats->max_dead_tuples - vacrelstats->num_dead_tuples) < MaxHeapTuplesPerPage && vacrelstats->num_dead_tuples > 0) @@ -283,25 +282,25 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats, if (PageIsNew(page)) { /* - * An all-zeroes page could be left over if a backend extends - * the relation but crashes before initializing the page. - * Reclaim such pages for use. + * An all-zeroes page could be left over if a backend extends the + * relation but crashes before initializing the page. Reclaim such + * pages for use. * - * We have to be careful here because we could be looking at - * a page that someone has just added to the relation and not - * yet been able to initialize (see RelationGetBufferForTuple). - * To interlock against that, release the buffer read lock - * (which we must do anyway) and grab the relation extension - * lock before re-locking in exclusive mode. If the page is - * still uninitialized by then, it must be left over from a - * crashed backend, and we can initialize it. + * We have to be careful here because we could be looking at a page + * that someone has just added to the relation and not yet been + * able to initialize (see RelationGetBufferForTuple). To + * interlock against that, release the buffer read lock (which we + * must do anyway) and grab the relation extension lock before + * re-locking in exclusive mode. If the page is still + * uninitialized by then, it must be left over from a crashed + * backend, and we can initialize it. * - * We don't really need the relation lock when this is a new - * or temp relation, but it's probably not worth the code space - * to check that, since this surely isn't a critical path. + * We don't really need the relation lock when this is a new or temp + * relation, but it's probably not worth the code space to check + * that, since this surely isn't a critical path. * - * Note: the comparable code in vacuum.c need not worry - * because it's got exclusive lock on the whole relation. + * Note: the comparable code in vacuum.c need not worry because it's + * got exclusive lock on the whole relation. */ LockBuffer(buf, BUFFER_LOCK_UNLOCK); LockRelationForExtension(onerel, ExclusiveLock); @@ -310,8 +309,8 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats, if (PageIsNew(page)) { ereport(WARNING, - (errmsg("relation \"%s\" page %u is uninitialized --- fixing", - relname, blkno))); + (errmsg("relation \"%s\" page %u is uninitialized --- fixing", + relname, blkno))); PageInit(page, BufferGetPageSize(buf), 0); empty_pages++; lazy_record_free_space(vacrelstats, blkno, @@ -365,15 +364,15 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats, case HEAPTUPLE_LIVE: /* - * Tuple is good. Consider whether to replace its - * xmin value with FrozenTransactionId. + * Tuple is good. Consider whether to replace its xmin + * value with FrozenTransactionId. * - * NB: Since we hold only a shared buffer lock here, we - * are assuming that TransactionId read/write is - * atomic. This is not the only place that makes such - * an assumption. It'd be possible to avoid the - * assumption by momentarily acquiring exclusive lock, - * but for the moment I see no need to. + * NB: Since we hold only a shared buffer lock here, we are + * assuming that TransactionId read/write is atomic. This + * is not the only place that makes such an assumption. + * It'd be possible to avoid the assumption by momentarily + * acquiring exclusive lock, but for the moment I see no + * need to. */ if (TransactionIdIsNormal(HeapTupleHeaderGetXmin(tuple.t_data)) && TransactionIdPrecedes(HeapTupleHeaderGetXmin(tuple.t_data), @@ -396,8 +395,8 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats, case HEAPTUPLE_RECENTLY_DEAD: /* - * 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. */ nkeep += 1; break; @@ -426,9 +425,9 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats, /* * If we remembered any tuples for deletion, then the page will be - * visited again by lazy_vacuum_heap, which will compute and - * record its post-compaction free space. If not, then we're done - * with this page, so remember its free space as-is. + * visited again by lazy_vacuum_heap, which will compute and record + * its post-compaction free space. If not, then we're done with this + * page, so remember its free space as-is. */ if (vacrelstats->num_dead_tuples == prev_dead_count) { @@ -608,8 +607,8 @@ lazy_scan_index(Relation indrel, LVRelStats *vacrelstats) pg_rusage_init(&ru0); /* - * Acquire appropriate type of lock on index: must be exclusive if - * index AM isn't concurrent-safe. + * Acquire appropriate type of lock on index: must be exclusive if index + * AM isn't concurrent-safe. */ if (indrel->rd_am->amconcurrent) LockRelation(indrel, RowExclusiveLock); @@ -618,9 +617,9 @@ lazy_scan_index(Relation indrel, LVRelStats *vacrelstats) /* * Even though we're not planning to delete anything, we use the - * ambulkdelete call, because (a) the scan happens within the index AM - * for more speed, and (b) it may want to pass private statistics to - * the amvacuumcleanup call. + * ambulkdelete call, because (a) the scan happens within the index AM for + * more speed, and (b) it may want to pass private statistics to the + * amvacuumcleanup call. */ stats = index_bulk_delete(indrel, dummy_tid_reaped, NULL); @@ -648,14 +647,14 @@ lazy_scan_index(Relation indrel, LVRelStats *vacrelstats) false); ereport(elevel, - (errmsg("index \"%s\" now contains %.0f row versions in %u pages", - RelationGetRelationName(indrel), - stats->num_index_tuples, - stats->num_pages), - errdetail("%u index pages have been deleted, %u are currently reusable.\n" - "%s.", - stats->pages_deleted, stats->pages_free, - pg_rusage_show(&ru0)))); + (errmsg("index \"%s\" now contains %.0f row versions in %u pages", + RelationGetRelationName(indrel), + stats->num_index_tuples, + stats->num_pages), + errdetail("%u index pages have been deleted, %u are currently reusable.\n" + "%s.", + stats->pages_deleted, stats->pages_free, + pg_rusage_show(&ru0)))); pfree(stats); } @@ -685,8 +684,8 @@ lazy_vacuum_index(Relation indrel, pg_rusage_init(&ru0); /* - * Acquire appropriate type of lock on index: must be exclusive if - * index AM isn't concurrent-safe. + * Acquire appropriate type of lock on index: must be exclusive if index + * AM isn't concurrent-safe. */ if (indrel->rd_am->amconcurrent) LockRelation(indrel, RowExclusiveLock); @@ -724,16 +723,16 @@ lazy_vacuum_index(Relation indrel, false); ereport(elevel, - (errmsg("index \"%s\" now contains %.0f row versions in %u pages", - RelationGetRelationName(indrel), - stats->num_index_tuples, - stats->num_pages), - errdetail("%.0f index row versions were removed.\n" - "%u index pages have been deleted, %u are currently reusable.\n" - "%s.", - stats->tuples_removed, - stats->pages_deleted, stats->pages_free, - pg_rusage_show(&ru0)))); + (errmsg("index \"%s\" now contains %.0f row versions in %u pages", + RelationGetRelationName(indrel), + stats->num_index_tuples, + stats->num_pages), + errdetail("%.0f index row versions were removed.\n" + "%u index pages have been deleted, %u are currently reusable.\n" + "%s.", + stats->tuples_removed, + stats->pages_deleted, stats->pages_free, + pg_rusage_show(&ru0)))); pfree(stats); } @@ -755,19 +754,18 @@ lazy_truncate_heap(Relation onerel, LVRelStats *vacrelstats) pg_rusage_init(&ru0); /* - * We need full exclusive lock on the relation in order to do - * truncation. If we can't get it, give up rather than waiting --- we - * don't want to block other backends, and we don't want to deadlock - * (which is quite possible considering we already hold a lower-grade - * lock). + * We need full exclusive lock on the relation in order to do truncation. + * If we can't get it, give up rather than waiting --- we don't want to + * block other backends, and we don't want to deadlock (which is quite + * possible considering we already hold a lower-grade lock). */ if (!ConditionalLockRelation(onerel, AccessExclusiveLock)) return; /* * Now that we have exclusive lock, look to see if the rel has grown - * whilst we were vacuuming with non-exclusive lock. If so, give up; - * the newly added pages presumably contain non-deletable tuples. + * whilst we were vacuuming with non-exclusive lock. If so, give up; the + * newly added pages presumably contain non-deletable tuples. */ new_rel_pages = RelationGetNumberOfBlocks(onerel); if (new_rel_pages != old_rel_pages) @@ -780,9 +778,9 @@ lazy_truncate_heap(Relation onerel, LVRelStats *vacrelstats) /* * Scan backwards from the end to verify that the end pages actually - * contain nothing we need to keep. This is *necessary*, not - * optional, because other backends could have added tuples to these - * pages whilst we were vacuuming. + * contain nothing we need to keep. This is *necessary*, not optional, + * because other backends could have added tuples to these pages whilst we + * were vacuuming. */ new_rel_pages = count_nondeletable_pages(onerel, vacrelstats); @@ -905,8 +903,8 @@ count_nondeletable_pages(Relation onerel, LVRelStats *vacrelstats) case HEAPTUPLE_RECENTLY_DEAD: /* - * 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. */ break; case HEAPTUPLE_INSERT_IN_PROGRESS: @@ -938,8 +936,8 @@ count_nondeletable_pages(Relation onerel, LVRelStats *vacrelstats) /* * If we fall out of the loop, all the previously-thought-to-be-empty - * pages really are; we need not bother to look at the last - * known-nonempty page. + * pages really are; we need not bother to look at the last known-nonempty + * page. */ return vacrelstats->nonempty_pages; } @@ -1010,18 +1008,16 @@ lazy_record_free_space(LVRelStats *vacrelstats, /* * A page with less than stats->threshold free space will be forgotten * immediately, and never passed to the free space map. Removing the - * uselessly small entries early saves cycles, and in particular - * reduces the amount of time we spend holding the FSM lock when we - * finally call RecordRelationFreeSpace. Since the FSM will probably - * drop pages with little free space anyway, there's no point in - * making this really small. + * uselessly small entries early saves cycles, and in particular reduces + * the amount of time we spend holding the FSM lock when we finally call + * RecordRelationFreeSpace. Since the FSM will probably drop pages with + * little free space anyway, there's no point in making this really small. * - * XXX Is it worth trying to measure average tuple size, and using that - * to adjust the threshold? Would be worthwhile if FSM has no stats - * yet for this relation. But changing the threshold as we scan the - * rel might lead to bizarre behavior, too. Also, it's probably - * better if vacuum.c has the same thresholding behavior as we do - * here. + * XXX Is it worth trying to measure average tuple size, and using that to + * adjust the threshold? Would be worthwhile if FSM has no stats yet for + * this relation. But changing the threshold as we scan the rel might + * lead to bizarre behavior, too. Also, it's probably better if vacuum.c + * has the same thresholding behavior as we do here. */ if (avail < vacrelstats->threshold) return; @@ -1055,8 +1051,8 @@ lazy_record_free_space(LVRelStats *vacrelstats, { /* * Scan backwards through the array, "sift-up" each value into its - * correct position. We can start the scan at n/2-1 since each - * entry above that position has no children to worry about. + * correct position. We can start the scan at n/2-1 since each entry + * above that position has no children to worry about. */ int l = n / 2; @@ -1092,9 +1088,9 @@ lazy_record_free_space(LVRelStats *vacrelstats, { /* * Notionally, we replace the zero'th entry with the new data, and - * then sift-up to maintain the heap property. Physically, the - * new data doesn't get stored into the arrays until we find the - * right location for it. + * then sift-up to maintain the heap property. Physically, the new + * data doesn't get stored into the arrays until we find the right + * location for it. */ int i = 0; /* i is where the "hole" is */ diff --git a/src/backend/commands/variable.c b/src/backend/commands/variable.c index 845c59625d..31113fffe2 100644 --- a/src/backend/commands/variable.c +++ b/src/backend/commands/variable.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/variable.c,v 1.113 2005/08/08 23:39:01 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/variable.c,v 1.114 2005/10/15 02:49:16 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -63,7 +63,7 @@ assign_datestyle(const char *value, bool doit, GucSource source) if (source >= PGC_S_INTERACTIVE) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("invalid list syntax for parameter \"datestyle\""))); + errmsg("invalid list syntax for parameter \"datestyle\""))); return NULL; } @@ -131,11 +131,11 @@ assign_datestyle(const char *value, bool doit, GucSource source) else if (pg_strcasecmp(tok, "DEFAULT") == 0) { /* - * Easiest way to get the current DEFAULT state is to fetch - * the DEFAULT string from guc.c and recursively parse it. + * Easiest way to get the current DEFAULT state is to fetch the + * DEFAULT string from guc.c and recursively parse it. * - * We can't simply "return assign_datestyle(...)" because we need - * to handle constructs like "DEFAULT, ISO". + * We can't simply "return assign_datestyle(...)" because we need to + * handle constructs like "DEFAULT, ISO". */ int saveDateStyle = DateStyle; int saveDateOrder = DateOrder; @@ -163,8 +163,8 @@ assign_datestyle(const char *value, bool doit, GucSource source) if (source >= PGC_S_INTERACTIVE) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("unrecognized \"datestyle\" key word: \"%s\"", - tok))); + errmsg("unrecognized \"datestyle\" key word: \"%s\"", + tok))); ok = false; break; } @@ -224,8 +224,8 @@ assign_datestyle(const char *value, bool doit, GucSource source) } /* - * Finally, it's safe to assign to the global variables; the - * assignment cannot fail now. + * Finally, it's safe to assign to the global variables; the assignment + * cannot fail now. */ DateStyle = newDateStyle; DateOrder = newDateOrder; @@ -274,14 +274,14 @@ assign_timezone(const char *value, bool doit, GucSource source) /* * Try to parse it. XXX an invalid interval format will result in - * ereport, which is not desirable for GUC. We did what we could - * to guard against this in flatten_set_variable_args, but a - * string coming in from postgresql.conf might contain anything. + * ereport, which is not desirable for GUC. We did what we could to + * guard against this in flatten_set_variable_args, but a string + * coming in from postgresql.conf might contain anything. */ interval = DatumGetIntervalP(DirectFunctionCall3(interval_in, - CStringGetDatum(val), - ObjectIdGetDatum(InvalidOid), - Int32GetDatum(-1))); + CStringGetDatum(val), + ObjectIdGetDatum(InvalidOid), + Int32GetDatum(-1))); pfree(val); if (interval->month != 0) @@ -336,15 +336,14 @@ assign_timezone(const char *value, bool doit, GucSource source) * UNKNOWN is the value shown as the "default" for TimeZone in * guc.c. We interpret it as being a complete no-op; we don't * change the timezone setting. Note that if there is a known - * timezone setting, we will return that name rather than - * UNKNOWN as the canonical spelling. + * timezone setting, we will return that name rather than UNKNOWN + * as the canonical spelling. * - * During GUC initialization, since the timezone library isn't - * set up yet, pg_get_timezone_name will return NULL and we - * will leave the setting as UNKNOWN. If this isn't - * overridden from the config file then - * pg_timezone_initialize() will eventually select a default - * value from the environment. + * During GUC initialization, since the timezone library isn't set up + * yet, pg_get_timezone_name will return NULL and we will leave + * the setting as UNKNOWN. If this isn't overridden from the + * config file then pg_timezone_initialize() will eventually + * select a default value from the environment. */ if (doit) { @@ -359,7 +358,7 @@ assign_timezone(const char *value, bool doit, GucSource source) /* * Otherwise assume it is a timezone name, and try to load it. */ - pg_tz *new_tz; + pg_tz *new_tz; new_tz = pg_tzset(value); @@ -376,9 +375,9 @@ assign_timezone(const char *value, bool doit, GucSource source) { ereport((source >= PGC_S_INTERACTIVE) ? ERROR : LOG, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("time zone \"%s\" appears to use leap seconds", - value), - errdetail("PostgreSQL does not support leap seconds."))); + errmsg("time zone \"%s\" appears to use leap seconds", + value), + errdetail("PostgreSQL does not support leap seconds."))); return NULL; } @@ -406,7 +405,7 @@ assign_timezone(const char *value, bool doit, GucSource source) if (!result) return NULL; snprintf(result, 64, "%.5f", - (double) (-CTimeZone) / (double)SECS_PER_HOUR); + (double) (-CTimeZone) / (double) SECS_PER_HOUR); } else result = strdup(value); @@ -424,7 +423,7 @@ show_timezone(void) if (HasCTZSet) { - Interval interval; + Interval interval; interval.month = 0; interval.day = 0; @@ -435,7 +434,7 @@ show_timezone(void) #endif tzn = DatumGetCString(DirectFunctionCall1(interval_out, - IntervalPGetDatum(&interval))); + IntervalPGetDatum(&interval))); } else tzn = pg_get_timezone_name(global_timezone); @@ -559,18 +558,18 @@ assign_client_encoding(const char *value, bool doit, GucSource source) return NULL; /* - * Note: if we are in startup phase then SetClientEncoding may not be - * able to really set the encoding. In this case we will assume that - * the encoding is okay, and InitializeClientEncoding() will fix - * things once initialization is complete. + * Note: if we are in startup phase then SetClientEncoding may not be able + * to really set the encoding. In this case we will assume that the + * encoding is okay, and InitializeClientEncoding() will fix things once + * initialization is complete. */ if (SetClientEncoding(encoding, doit) < 0) { if (source >= PGC_S_INTERACTIVE) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("conversion between %s and %s is not supported", - value, GetDatabaseEncodingName()))); + errmsg("conversion between %s and %s is not supported", + value, GetDatabaseEncodingName()))); return NULL; } return value; @@ -594,7 +593,7 @@ extern char *session_authorization_string; /* in guc.c */ const char * assign_session_authorization(const char *value, bool doit, GucSource source) { - Oid roleid = InvalidOid; + Oid roleid = InvalidOid; bool is_superuser = false; const char *actual_rolename = NULL; char *result; @@ -603,7 +602,7 @@ assign_session_authorization(const char *value, bool doit, GucSource source) (value[NAMEDATALEN] == 'T' || value[NAMEDATALEN] == 'F')) { /* might be a saved userid string */ - Oid savedoid; + Oid savedoid; char *endptr; savedoid = (Oid) strtoul(value + NAMEDATALEN + 1, &endptr, 10); @@ -625,9 +624,9 @@ assign_session_authorization(const char *value, bool doit, GucSource source) if (!IsTransactionState()) { /* - * Can't do catalog lookups, so fail. The upshot of this is - * that session_authorization cannot be set in - * postgresql.conf, which seems like a good thing anyway. + * Can't do catalog lookups, so fail. The upshot of this is that + * session_authorization cannot be set in postgresql.conf, which + * seems like a good thing anyway. */ return NULL; } @@ -676,7 +675,7 @@ show_session_authorization(void) * assign_session_authorization */ const char *value = session_authorization_string; - Oid savedoid; + Oid savedoid; char *endptr; Assert(strspn(value, "x") == NAMEDATALEN && @@ -706,7 +705,7 @@ extern char *role_string; /* in guc.c */ const char * assign_role(const char *value, bool doit, GucSource source) { - Oid roleid = InvalidOid; + Oid roleid = InvalidOid; bool is_superuser = false; const char *actual_rolename = value; char *result; @@ -715,7 +714,7 @@ assign_role(const char *value, bool doit, GucSource source) (value[NAMEDATALEN] == 'T' || value[NAMEDATALEN] == 'F')) { /* might be a saved userid string */ - Oid savedoid; + Oid savedoid; char *endptr; savedoid = (Oid) strtoul(value + NAMEDATALEN + 1, &endptr, 10); @@ -738,9 +737,9 @@ assign_role(const char *value, bool doit, GucSource source) if (!IsTransactionState()) { /* - * Can't do catalog lookups, so fail. The upshot of this is - * that role cannot be set in postgresql.conf, which seems - * like a good thing anyway. + * Can't do catalog lookups, so fail. The upshot of this is that + * role cannot be set in postgresql.conf, which seems like a good + * thing anyway. */ return NULL; } @@ -797,11 +796,10 @@ const char * show_role(void) { /* - * Extract the role name from the stored string; see - * assign_role + * Extract the role name from the stored string; see assign_role */ const char *value = role_string; - Oid savedoid; + Oid savedoid; char *endptr; /* This special case only applies if no SET ROLE has been done */ @@ -816,11 +814,11 @@ show_role(void) Assert(endptr != value + NAMEDATALEN + 1 && *endptr == ','); /* - * Check that the stored string still matches the effective setting, - * else return "none". This is a kluge to deal with the fact that - * SET SESSION AUTHORIZATION logically resets SET ROLE to NONE, but - * we cannot set the GUC role variable from assign_session_authorization - * (because we haven't got enough info to call set_config_option). + * Check that the stored string still matches the effective setting, else + * return "none". This is a kluge to deal with the fact that SET SESSION + * AUTHORIZATION logically resets SET ROLE to NONE, but we cannot set the + * GUC role variable from assign_session_authorization (because we haven't + * got enough info to call set_config_option). */ if (savedoid != GetCurrentRoleId()) return "none"; diff --git a/src/backend/commands/view.c b/src/backend/commands/view.c index 6158b16654..54030452f8 100644 --- a/src/backend/commands/view.c +++ b/src/backend/commands/view.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/view.c,v 1.90 2005/04/14 01:38:17 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/view.c,v 1.91 2005/10/15 02:49:16 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -55,16 +55,18 @@ isViewOnTempTable_walker(Node *node, void *context) if (IsA(node, Query)) { - Query *query = (Query *) node; - ListCell *rtable; + Query *query = (Query *) node; + ListCell *rtable; - foreach (rtable, query->rtable) + foreach(rtable, query->rtable) { RangeTblEntry *rte = lfirst(rtable); + if (rte->rtekind == RTE_RELATION) { - Relation rel = heap_open(rte->relid, AccessShareLock); - bool istemp = rel->rd_istemp; + Relation rel = heap_open(rte->relid, AccessShareLock); + bool istemp = rel->rd_istemp; + heap_close(rel, AccessShareLock); if (istemp) return true; @@ -101,8 +103,8 @@ DefineVirtualRelation(const RangeVar *relation, List *tlist, bool replace) ListCell *t; /* - * create a list of ColumnDef nodes based on the names and types of - * the (non-junk) targetlist items from the view's SELECT list. + * create a list of ColumnDef nodes based on the names and types of the + * (non-junk) targetlist items from the view's SELECT list. */ attrList = NIL; foreach(t, tlist) @@ -167,15 +169,15 @@ DefineVirtualRelation(const RangeVar *relation, List *tlist, bool replace) RelationGetRelationName(rel)); /* - * Due to the namespace visibility rules for temporary - * objects, we should only end up replacing a temporary view - * with another temporary view, and vice versa. + * Due to the namespace visibility rules for temporary objects, we + * should only end up replacing a temporary view with another + * temporary view, and vice versa. */ Assert(relation->istemp == rel->rd_istemp); /* - * Create a tuple descriptor to compare against the existing view, - * and verify it matches. + * Create a tuple descriptor to compare against the existing view, and + * verify it matches. */ descriptor = BuildDescForRelation(attrList); checkViewTupleDesc(descriptor, rel->rd_att); @@ -190,8 +192,8 @@ DefineVirtualRelation(const RangeVar *relation, List *tlist, bool replace) else { /* - * now set the parameters for keys/inheritance etc. All of these - * are uninteresting for views... + * now set the parameters for keys/inheritance etc. All of these are + * uninteresting for views... */ createStmt->relation = (RangeVar *) relation; createStmt->tableElts = attrList; @@ -203,8 +205,8 @@ DefineVirtualRelation(const RangeVar *relation, List *tlist, bool replace) /* * finally create the relation (this will error out if there's an - * existing view, so we don't need more code to complain if - * "replace" is false). + * existing view, so we don't need more code to complain if "replace" + * is false). */ return DefineRelation(createStmt, RELKIND_VIEW); } @@ -247,8 +249,8 @@ checkViewTupleDesc(TupleDesc newdesc, TupleDesc olddesc) newattr->atttypmod != oldattr->atttypmod) ereport(ERROR, (errcode(ERRCODE_INVALID_TABLE_DEFINITION), - errmsg("cannot change data type of view column \"%s\"", - NameStr(oldattr->attname)))); + errmsg("cannot change data type of view column \"%s\"", + NameStr(oldattr->attname)))); /* We can ignore the remaining attributes of an attribute... */ } @@ -265,8 +267,8 @@ FormViewRetrieveRule(const RangeVar *view, Query *viewParse, bool replace) RuleStmt *rule; /* - * Create a RuleStmt that corresponds to the suitable rewrite rule - * args for DefineQueryRewrite(); + * Create a RuleStmt that corresponds to the suitable rewrite rule args + * for DefineQueryRewrite(); */ rule = makeNode(RuleStmt); rule->relation = copyObject((RangeVar *) view); @@ -336,11 +338,11 @@ UpdateRangeTableOfViewParse(Oid viewOid, Query *viewParse) /* * Make a copy of the given parsetree. It's not so much that we don't - * want to scribble on our input, it's that the parser has a bad habit - * of outputting multiple links to the same subtree for constructs - * like BETWEEN, and we mustn't have OffsetVarNodes increment the - * varno of a Var node twice. copyObject will expand any - * multiply-referenced subtree into multiple copies. + * want to scribble on our input, it's that the parser has a bad habit of + * outputting multiple links to the same subtree for constructs like + * BETWEEN, and we mustn't have OffsetVarNodes increment the varno of a + * Var node twice. copyObject will expand any multiply-referenced subtree + * into multiple copies. */ viewParse = (Query *) copyObject(viewParse); @@ -348,8 +350,8 @@ UpdateRangeTableOfViewParse(Oid viewOid, Query *viewParse) viewRel = relation_open(viewOid, AccessShareLock); /* - * Create the 2 new range table entries and form the new range - * table... OLD first, then NEW.... + * Create the 2 new range table entries and form the new range table... + * OLD first, then NEW.... */ rt_entry1 = addRangeTableEntryForRelation(NULL, viewRel, makeAlias("*OLD*", NIL), @@ -393,8 +395,8 @@ DefineView(RangeVar *view, Query *viewParse, bool replace) Oid viewOid; /* - * If the user didn't explicitly ask for a temporary view, check - * whether we need one implicitly. + * If the user didn't explicitly ask for a temporary view, check whether + * we need one implicitly. */ if (!view->istemp) { @@ -404,25 +406,24 @@ DefineView(RangeVar *view, Query *viewParse, bool replace) (errmsg("view \"%s\" will be a temporary view", view->relname))); } - + /* * Create the view relation * - * NOTE: if it already exists and replace is false, the xact will be - * aborted. + * NOTE: if it already exists and replace is false, the xact will be aborted. */ viewOid = DefineVirtualRelation(view, viewParse->targetList, replace); /* - * The relation we have just created is not visible to any other - * commands running with the same transaction & command id. So, - * increment the command id counter (but do NOT pfree any memory!!!!) + * The relation we have just created is not visible to any other commands + * running with the same transaction & command id. So, increment the + * command id counter (but do NOT pfree any memory!!!!) */ CommandCounterIncrement(); /* - * The range table of 'viewParse' does not contain entries for the - * "OLD" and "NEW" relations. So... add them! + * The range table of 'viewParse' does not contain entries for the "OLD" + * and "NEW" relations. So... add them! */ viewParse = UpdateRangeTableOfViewParse(viewOid, viewParse); diff --git a/src/backend/executor/execAmi.c b/src/backend/executor/execAmi.c index c2cb4b6883..06e4ab7b23 100644 --- a/src/backend/executor/execAmi.c +++ b/src/backend/executor/execAmi.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/executor/execAmi.c,v 1.84 2005/05/15 21:19:54 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/execAmi.c,v 1.85 2005/10/15 02:49:16 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -251,10 +251,10 @@ ExecMarkPos(PlanState *node) * * NOTE: the semantics of this are that the first ExecProcNode following * the restore operation will yield the same tuple as the first one following - * the mark operation. It is unspecified what happens to the plan node's + * the mark operation. It is unspecified what happens to the plan node's * result TupleTableSlot. (In most cases the result slot is unchanged by * a restore, but the node may choose to clear it or to load it with the - * restored-to tuple.) Hence the caller should discard any previously + * restored-to tuple.) Hence the caller should discard any previously * returned TupleTableSlot after doing a restore. */ void @@ -398,15 +398,14 @@ ExecMayReturnRawTuples(PlanState *node) { /* * At a table scan node, we check whether ExecAssignScanProjectionInfo - * decided to do projection or not. Most non-scan nodes always - * project and so we can return "false" immediately. For nodes that - * don't project but just pass up input tuples, we have to recursively - * examine the input plan node. + * decided to do projection or not. Most non-scan nodes always project + * and so we can return "false" immediately. For nodes that don't project + * but just pass up input tuples, we have to recursively examine the input + * plan node. * - * Note: Hash and Material are listed here because they sometimes return - * an original input tuple, not a copy. But Sort and SetOp never - * return an original tuple, so they can be treated like projecting - * nodes. + * Note: Hash and Material are listed here because they sometimes return an + * original input tuple, not a copy. But Sort and SetOp never return an + * original tuple, so they can be treated like projecting nodes. */ switch (nodeTag(node)) { diff --git a/src/backend/executor/execGrouping.c b/src/backend/executor/execGrouping.c index 1bf46d815c..688e2157e8 100644 --- a/src/backend/executor/execGrouping.c +++ b/src/backend/executor/execGrouping.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/execGrouping.c,v 1.15 2005/05/29 04:23:03 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/execGrouping.c,v 1.16 2005/10/15 02:49:16 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -66,11 +66,10 @@ execTuplesMatch(TupleTableSlot *slot1, oldContext = MemoryContextSwitchTo(evalContext); /* - * We cannot report a match without checking all the fields, but we - * can report a non-match as soon as we find unequal fields. So, - * start comparing at the last field (least significant sort key). - * That's the most likely to be different if we are dealing with - * sorted input. + * We cannot report a match without checking all the fields, but we can + * report a non-match as soon as we find unequal fields. So, start + * comparing at the last field (least significant sort key). That's the + * most likely to be different if we are dealing with sorted input. */ result = true; @@ -137,11 +136,10 @@ execTuplesUnequal(TupleTableSlot *slot1, oldContext = MemoryContextSwitchTo(evalContext); /* - * We cannot report a match without checking all the fields, but we - * can report a non-match as soon as we find unequal fields. So, - * start comparing at the last field (least significant sort key). - * That's the most likely to be different if we are dealing with - * sorted input. + * We cannot report a match without checking all the fields, but we can + * report a non-match as soon as we find unequal fields. So, start + * comparing at the last field (least significant sort key). That's the + * most likely to be different if we are dealing with sorted input. */ result = false; @@ -288,7 +286,7 @@ BuildTupleHashTable(int numCols, AttrNumber *keyColIdx, Assert(entrysize >= sizeof(TupleHashEntryData)); hashtable = (TupleHashTable) MemoryContextAlloc(tablecxt, - sizeof(TupleHashTableData)); + sizeof(TupleHashTableData)); hashtable->numCols = numCols; hashtable->keyColIdx = keyColIdx; @@ -297,7 +295,7 @@ BuildTupleHashTable(int numCols, AttrNumber *keyColIdx, hashtable->tablecxt = tablecxt; hashtable->tempcxt = tempcxt; hashtable->entrysize = entrysize; - hashtable->tableslot = NULL; /* will be made on first lookup */ + hashtable->tableslot = NULL; /* will be made on first lookup */ hashtable->inputslot = NULL; MemSet(&hash_ctl, 0, sizeof(hash_ctl)); @@ -308,7 +306,7 @@ BuildTupleHashTable(int numCols, AttrNumber *keyColIdx, hash_ctl.hcxt = tablecxt; hashtable->hashtab = hash_create("TupleHashTable", (long) nbuckets, &hash_ctl, - HASH_ELEM | HASH_FUNCTION | HASH_COMPARE | HASH_CONTEXT); + HASH_ELEM | HASH_FUNCTION | HASH_COMPARE | HASH_CONTEXT); return hashtable; } @@ -341,6 +339,7 @@ LookupTupleHashEntry(TupleHashTable hashtable, TupleTableSlot *slot, TupleDesc tupdesc; oldContext = MemoryContextSwitchTo(hashtable->tablecxt); + /* * We copy the input tuple descriptor just for safety --- we assume * all input tuples will have equivalent descriptors. @@ -382,9 +381,9 @@ LookupTupleHashEntry(TupleHashTable hashtable, TupleTableSlot *slot, /* * created new entry * - * Zero any caller-requested space in the entry. (This zaps - * the "key data" dynahash.c copied into the new entry, but we - * don't care since we're about to overwrite it anyway.) + * Zero any caller-requested space in the entry. (This zaps the "key + * data" dynahash.c copied into the new entry, but we don't care + * since we're about to overwrite it anyway.) */ MemSet(entry, 0, hashtable->entrysize); @@ -482,6 +481,7 @@ static int TupleHashTableMatch(const void *key1, const void *key2, Size keysize) { HeapTuple tuple1 = ((const TupleHashEntryData *) key1)->firstTuple; + #ifdef USE_ASSERT_CHECKING HeapTuple tuple2 = ((const TupleHashEntryData *) key2)->firstTuple; #endif diff --git a/src/backend/executor/execJunk.c b/src/backend/executor/execJunk.c index 1cf403f88d..2245c61e7f 100644 --- a/src/backend/executor/execJunk.c +++ b/src/backend/executor/execJunk.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/execJunk.c,v 1.49 2005/04/06 16:34:04 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/execJunk.c,v 1.50 2005/10/15 02:49:16 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -55,7 +55,7 @@ * * Initialize the Junk filter. * - * The source targetlist is passed in. The output tuple descriptor is + * The source targetlist is passed in. The output tuple descriptor is * built from the non-junk tlist entries, plus the passed specification * of whether to include room for an OID or not. * An optional resultSlot can be passed as well. @@ -87,11 +87,11 @@ ExecInitJunkFilter(List *targetList, bool hasoid, TupleTableSlot *slot) * Now calculate the mapping between the original tuple's attributes and * the "clean" tuple's attributes. * - * The "map" is an array of "cleanLength" attribute numbers, i.e. one - * entry for every attribute of the "clean" tuple. The value of this - * entry is the attribute number of the corresponding attribute of the - * "original" tuple. (Zero indicates a NULL output attribute, but we - * do not use that feature in this routine.) + * The "map" is an array of "cleanLength" attribute numbers, i.e. one entry + * for every attribute of the "clean" tuple. The value of this entry is + * the attribute number of the corresponding attribute of the "original" + * tuple. (Zero indicates a NULL output attribute, but we do not use that + * feature in this routine.) */ cleanLength = cleanTupType->natts; if (cleanLength > 0) @@ -155,14 +155,14 @@ ExecInitJunkFilterConversion(List *targetList, slot = MakeSingleTupleTableSlot(cleanTupType); /* - * Calculate the mapping between the original tuple's attributes and - * the "clean" tuple's attributes. + * Calculate the mapping between the original tuple's attributes and the + * "clean" tuple's attributes. * - * The "map" is an array of "cleanLength" attribute numbers, i.e. one - * entry for every attribute of the "clean" tuple. The value of this - * entry is the attribute number of the corresponding attribute of the - * "original" tuple. We store zero for any deleted attributes, marking - * that a NULL is needed in the output tuple. + * The "map" is an array of "cleanLength" attribute numbers, i.e. one entry + * for every attribute of the "clean" tuple. The value of this entry is + * the attribute number of the corresponding attribute of the "original" + * tuple. We store zero for any deleted attributes, marking that a NULL + * is needed in the output tuple. */ cleanLength = cleanTupType->natts; if (cleanLength > 0) @@ -220,8 +220,8 @@ ExecGetJunkAttribute(JunkFilter *junkfilter, ListCell *t; /* - * Look in the junkfilter's target list for an attribute with - * the given name + * Look in the junkfilter's target list for an attribute with the given + * name */ foreach(t, junkfilter->jf_targetList) { diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c index 05b4a48be2..2a96a161c8 100644 --- a/src/backend/executor/execMain.c +++ b/src/backend/executor/execMain.c @@ -26,7 +26,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.255 2005/08/26 03:07:25 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.256 2005/10/15 02:49:16 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -208,8 +208,7 @@ ExecutorRun(QueryDesc *queryDesc, oldcontext = MemoryContextSwitchTo(estate->es_query_cxt); /* - * extract information from the query descriptor and the query - * feature. + * extract information from the query descriptor and the query feature. */ operation = queryDesc->operation; dest = queryDesc->dest; @@ -352,15 +351,15 @@ ExecCheckRTEPerms(RangeTblEntry *rte) { AclMode requiredPerms; Oid relOid; - Oid userid; + Oid userid; /* - * Only plain-relation RTEs need to be checked here. Subquery RTEs - * are checked by ExecInitSubqueryScan if the subquery is still a - * separate subquery --- if it's been pulled up into our query level - * then the RTEs are in our rangetable and will be checked here. - * Function RTEs are checked by init_fcache when the function is - * prepared for execution. Join and special RTEs need no checks. + * Only plain-relation RTEs need to be checked here. Subquery RTEs are + * checked by ExecInitSubqueryScan if the subquery is still a separate + * subquery --- if it's been pulled up into our query level then the RTEs + * are in our rangetable and will be checked here. Function RTEs are + * checked by init_fcache when the function is prepared for execution. + * Join and special RTEs need no checks. */ if (rte->rtekind != RTE_RELATION) return; @@ -375,19 +374,17 @@ ExecCheckRTEPerms(RangeTblEntry *rte) relOid = rte->relid; /* - * userid to check as: current user unless we have a setuid - * indication. + * userid to check as: current user unless we have a setuid indication. * - * Note: GetUserId() is presently fast enough that there's no harm in - * calling it separately for each RTE. If that stops being true, we - * could call it once in ExecCheckRTPerms and pass the userid down - * from there. But for now, no need for the extra clutter. + * Note: GetUserId() is presently fast enough that there's no harm in calling + * it separately for each RTE. If that stops being true, we could call it + * once in ExecCheckRTPerms and pass the userid down from there. But for + * now, no need for the extra clutter. */ userid = rte->checkAsUser ? rte->checkAsUser : GetUserId(); /* - * We must have *all* the requiredPerms bits, so use aclmask not - * aclcheck. + * We must have *all* the requiredPerms bits, so use aclmask not aclcheck. */ if (pg_class_aclmask(relOid, userid, requiredPerms, ACLMASK_ALL) != requiredPerms) @@ -515,8 +512,7 @@ InitPlan(QueryDesc *queryDesc, bool explainOnly) else { /* - * Single result relation identified by - * parseTree->resultRelation + * Single result relation identified by parseTree->resultRelation */ numResultRelations = 1; resultRelInfos = (ResultRelInfo *) palloc(sizeof(ResultRelInfo)); @@ -544,8 +540,8 @@ InitPlan(QueryDesc *queryDesc, bool explainOnly) /* * Detect whether we're doing SELECT INTO. If so, set the es_into_oids - * flag appropriately so that the plan tree will be initialized with - * the correct tuple descriptors. + * flag appropriately so that the plan tree will be initialized with the + * correct tuple descriptors. */ do_select_into = false; @@ -583,10 +579,10 @@ InitPlan(QueryDesc *queryDesc, bool explainOnly) } /* - * initialize the executor "tuple" table. We need slots for all the - * plan nodes, plus possibly output slots for the junkfilter(s). At - * this point we aren't sure if we need junkfilters, so just add slots - * for them unconditionally. + * initialize the executor "tuple" table. We need slots for all the plan + * nodes, plus possibly output slots for the junkfilter(s). At this point + * we aren't sure if we need junkfilters, so just add slots for them + * unconditionally. */ { int nSlots = ExecCountSlotsNode(plan); @@ -606,26 +602,26 @@ InitPlan(QueryDesc *queryDesc, bool explainOnly) estate->es_useEvalPlan = false; /* - * 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. */ planstate = ExecInitNode(plan, estate); /* - * Get the tuple descriptor describing the type of tuples to return. - * (this is especially important if we are creating a relation with - * "SELECT INTO") + * Get the tuple descriptor describing the type of tuples to return. (this + * is especially important if we are creating a relation with "SELECT + * INTO") */ tupType = ExecGetResultType(planstate); /* - * Initialize the junk filter if needed. SELECT and INSERT queries - * need a filter if there are any junk attrs in the tlist. INSERT and - * SELECT INTO also need a filter if the plan may return raw disk - * tuples (else heap_insert will be scribbling on the source - * relation!). UPDATE and DELETE always need a filter, since there's - * always a junk 'ctid' attribute present --- no need to look first. + * Initialize the junk filter if needed. SELECT and INSERT queries need a + * filter if there are any junk attrs in the tlist. INSERT and SELECT + * INTO also need a filter if the plan may return raw disk tuples (else + * heap_insert will be scribbling on the source relation!). UPDATE and + * DELETE always need a filter, since there's always a junk 'ctid' + * attribute present --- no need to look first. */ { bool junk_filter_needed = false; @@ -661,10 +657,9 @@ InitPlan(QueryDesc *queryDesc, bool explainOnly) if (junk_filter_needed) { /* - * If there are multiple result relations, each one needs its - * own junk filter. Note this is only possible for - * UPDATE/DELETE, so we can't be fooled by some needing a - * filter and some not. + * If there are multiple result relations, each one needs its own + * junk filter. Note this is only possible for UPDATE/DELETE, so + * we can't be fooled by some needing a filter and some not. */ if (parseTree->resultRelations != NIL) { @@ -687,15 +682,15 @@ InitPlan(QueryDesc *queryDesc, bool explainOnly) JunkFilter *j; j = ExecInitJunkFilter(subplan->plan->targetlist, - resultRelInfo->ri_RelationDesc->rd_att->tdhasoid, - ExecAllocTableSlot(estate->es_tupleTable)); + resultRelInfo->ri_RelationDesc->rd_att->tdhasoid, + ExecAllocTableSlot(estate->es_tupleTable)); resultRelInfo->ri_junkFilter = j; resultRelInfo++; } /* - * Set active junkfilter too; at this point ExecInitAppend - * has already selected an active result relation... + * Set active junkfilter too; at this point ExecInitAppend has + * already selected an active result relation... */ estate->es_junkFilter = estate->es_result_relation_info->ri_junkFilter; @@ -707,7 +702,7 @@ InitPlan(QueryDesc *queryDesc, bool explainOnly) j = ExecInitJunkFilter(planstate->plan->targetlist, tupType->tdhasoid, - ExecAllocTableSlot(estate->es_tupleTable)); + ExecAllocTableSlot(estate->es_tupleTable)); estate->es_junkFilter = j; if (estate->es_result_relation_info) estate->es_result_relation_info->ri_junkFilter = j; @@ -777,10 +772,9 @@ InitPlan(QueryDesc *queryDesc, bool explainOnly) CommandCounterIncrement(); /* - * If necessary, create a TOAST table for the into relation. Note - * that AlterTableCreateToastTable ends with - * CommandCounterIncrement(), so that the TOAST table will be - * visible for insertion. + * If necessary, create a TOAST table for the into relation. Note that + * AlterTableCreateToastTable ends with CommandCounterIncrement(), so + * that the TOAST table will be visible for insertion. */ AlterTableCreateToastTable(intoRelationId, true); @@ -795,11 +789,11 @@ InitPlan(QueryDesc *queryDesc, bool explainOnly) /* * We can skip WAL-logging the insertions, unless PITR is in use. * - * Note that for a non-temp INTO table, this is safe only because - * we know that the catalog changes above will have been WAL-logged, - * and so RecordTransactionCommit will think it needs to WAL-log the - * eventual transaction commit. Else the commit might be lost, even - * though all the data is safely fsync'd ... + * Note that for a non-temp INTO table, this is safe only because we know + * that the catalog changes above will have been WAL-logged, and so + * RecordTransactionCommit will think it needs to WAL-log the eventual + * transaction commit. Else the commit might be lost, even though all + * the data is safely fsync'd ... */ estate->es_into_relation_use_wal = XLogArchivingActive(); } @@ -832,19 +826,19 @@ initResultRelInfo(ResultRelInfo *resultRelInfo, ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), errmsg("cannot change sequence \"%s\"", - RelationGetRelationName(resultRelationDesc)))); + RelationGetRelationName(resultRelationDesc)))); break; case RELKIND_TOASTVALUE: ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), errmsg("cannot change TOAST relation \"%s\"", - RelationGetRelationName(resultRelationDesc)))); + RelationGetRelationName(resultRelationDesc)))); break; case RELKIND_VIEW: ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), errmsg("cannot change view \"%s\"", - RelationGetRelationName(resultRelationDesc)))); + RelationGetRelationName(resultRelationDesc)))); break; } @@ -859,7 +853,7 @@ initResultRelInfo(ResultRelInfo *resultRelInfo, resultRelInfo->ri_TrigDesc = CopyTriggerDesc(resultRelationDesc->trigdesc); if (resultRelInfo->ri_TrigDesc) { - int n = resultRelInfo->ri_TrigDesc->numtriggers; + int n = resultRelInfo->ri_TrigDesc->numtriggers; resultRelInfo->ri_TrigFunctions = (FmgrInfo *) palloc0(n * sizeof(FmgrInfo)); @@ -878,9 +872,9 @@ initResultRelInfo(ResultRelInfo *resultRelInfo, /* * If there are indices on the result relation, open them and save - * descriptors in the result relation info, so that we can add new - * index entries for the tuples we add/update. We need not do this - * for a DELETE, however, since deletion doesn't affect indexes. + * descriptors in the result relation info, so that we can add new index + * entries for the tuples we add/update. We need not do this for a + * DELETE, however, since deletion doesn't affect indexes. */ if (resultRelationDesc->rd_rel->relhasindex && operation != CMD_DELETE) @@ -981,8 +975,7 @@ ExecEndPlan(PlanState *planstate, EState *estate) estate->es_tupleTable = NULL; /* - * close the result relation(s) if any, but hold locks until xact - * commit. + * close the result relation(s) if any, but hold locks until xact commit. */ resultRelInfo = estate->es_result_relations; for (i = estate->es_num_result_relations; i > 0; i--) @@ -999,10 +992,10 @@ ExecEndPlan(PlanState *planstate, EState *estate) if (estate->es_into_relation_descriptor != NULL) { /* - * If we skipped using WAL, and it's not a temp relation, - * we must force the relation down to disk before it's - * safe to commit the transaction. This requires forcing - * out any dirty buffers and then doing a forced fsync. + * If we skipped using WAL, and it's not a temp relation, we must + * force the relation down to disk before it's safe to commit the + * transaction. This requires forcing out any dirty buffers and then + * doing a forced fsync. */ if (!estate->es_into_relation_use_wal && !estate->es_into_relation_descriptor->rd_istemp) @@ -1087,8 +1080,7 @@ ExecutePlan(EState *estate, } /* - * 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 (;;) @@ -1120,12 +1112,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 junkfilter's resultSlot. - * (Formerly, we stored it back over the "dirty" tuple, which is - * WRONG because that tuple slot has the wrong descriptor.) + * (Formerly, we stored it back over the "dirty" tuple, which is WRONG + * because that tuple slot has the wrong descriptor.) * * Also, extract all the junk information we need. */ @@ -1151,10 +1143,10 @@ lnext: ; elog(ERROR, "ctid is NULL"); tupleid = (ItemPointer) DatumGetPointer(datum); - tuple_ctid = *tupleid; /* make sure we don't free the - * ctid!! */ + tuple_ctid = *tupleid; /* make sure we don't free the ctid!! */ tupleid = &tuple_ctid; } + /* * Process any FOR UPDATE or FOR SHARE locking requested. */ @@ -1171,8 +1163,8 @@ lnext: ; ItemPointerData update_ctid; TransactionId update_xmax; TupleTableSlot *newSlot; - LockTupleMode lockmode; - HTSU_Result test; + LockTupleMode lockmode; + HTSU_Result test; if (!ExecGetJunkAttribute(junkfilter, slot, @@ -1210,8 +1202,8 @@ lnext: ; case HeapTupleUpdated: if (IsXactIsoLevelSerializable) ereport(ERROR, - (errcode(ERRCODE_T_R_SERIALIZATION_FAILURE), - errmsg("could not serialize access due to concurrent update"))); + (errcode(ERRCODE_T_R_SERIALIZATION_FAILURE), + errmsg("could not serialize access due to concurrent update"))); if (!ItemPointerEquals(&update_ctid, &tuple.t_self)) { @@ -1230,8 +1222,7 @@ lnext: ; /* * if tuple was deleted or PlanQual failed for - * updated tuple - we must not return this - * tuple! + * updated tuple - we must not return this tuple! */ goto lnext; @@ -1251,9 +1242,9 @@ lnext: ; } /* - * 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 its 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 its attributes. */ switch (operation) { @@ -1287,9 +1278,9 @@ lnext: ; } /* - * check our tuple count.. if we've processed the proper number - * then quit, else loop again and process more tuples. Zero - * numberTuples means no limit. + * check our tuple count.. if we've processed the proper number then + * quit, else loop again and process more tuples. Zero numberTuples + * means no limit. */ current_tuple_count++; if (numberTuples && numberTuples == current_tuple_count) @@ -1383,8 +1374,8 @@ ExecInsert(TupleTableSlot *slot, Oid newId; /* - * get the heap tuple out of the tuple table slot, making sure - * we have a writable copy + * get the heap tuple out of the tuple table slot, making sure we have a + * writable copy */ tuple = ExecMaterializeSlot(slot); @@ -1396,7 +1387,7 @@ ExecInsert(TupleTableSlot *slot, /* BEFORE ROW INSERT Triggers */ if (resultRelInfo->ri_TrigDesc && - resultRelInfo->ri_TrigDesc->n_before_row[TRIGGER_EVENT_INSERT] > 0) + resultRelInfo->ri_TrigDesc->n_before_row[TRIGGER_EVENT_INSERT] > 0) { HeapTuple newtuple; @@ -1409,9 +1400,9 @@ ExecInsert(TupleTableSlot *slot, { /* * Insert modified tuple into tuple table slot, replacing the - * original. We assume that it was allocated in per-tuple - * memory context, and therefore will go away by itself. The - * tuple table slot should not try to clear it. + * original. We assume that it was allocated in per-tuple memory + * context, and therefore will go away by itself. The tuple table + * slot should not try to clear it. */ ExecStoreTuple(newtuple, slot, InvalidBuffer, false); tuple = newtuple; @@ -1427,8 +1418,8 @@ ExecInsert(TupleTableSlot *slot, /* * insert the tuple * - * Note: heap_insert returns the tid (location) of the new tuple - * in the t_self field. + * Note: heap_insert returns the tid (location) of the new tuple in the + * t_self field. */ newId = heap_insert(resultRelationDesc, tuple, estate->es_snapshot->curcid, @@ -1463,7 +1454,7 @@ ExecDelete(TupleTableSlot *slot, { ResultRelInfo *resultRelInfo; Relation resultRelationDesc; - HTSU_Result result; + HTSU_Result result; ItemPointerData update_ctid; TransactionId update_xmax; @@ -1475,7 +1466,7 @@ ExecDelete(TupleTableSlot *slot, /* BEFORE ROW DELETE Triggers */ if (resultRelInfo->ri_TrigDesc && - resultRelInfo->ri_TrigDesc->n_before_row[TRIGGER_EVENT_DELETE] > 0) + resultRelInfo->ri_TrigDesc->n_before_row[TRIGGER_EVENT_DELETE] > 0) { bool dodelete; @@ -1489,9 +1480,9 @@ ExecDelete(TupleTableSlot *slot, /* * delete the tuple * - * Note: if es_crosscheck_snapshot isn't InvalidSnapshot, we check that - * the row to be deleted is visible to that snapshot, and throw a can't- - * serialize error if not. This is a special-case behavior needed for + * Note: if es_crosscheck_snapshot isn't InvalidSnapshot, we check that the + * row to be deleted is visible to that snapshot, and throw a can't- + * serialize error if not. This is a special-case behavior needed for * referential integrity updates in serializable transactions. */ ldelete:; @@ -1543,9 +1534,9 @@ ldelete:; * 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 */ @@ -1571,7 +1562,7 @@ ExecUpdate(TupleTableSlot *slot, HeapTuple tuple; ResultRelInfo *resultRelInfo; Relation resultRelationDesc; - HTSU_Result result; + HTSU_Result result; ItemPointerData update_ctid; TransactionId update_xmax; @@ -1582,8 +1573,8 @@ ExecUpdate(TupleTableSlot *slot, elog(ERROR, "cannot UPDATE during bootstrap"); /* - * get the heap tuple out of the tuple table slot, making sure - * we have a writable copy + * get the heap tuple out of the tuple table slot, making sure we have a + * writable copy */ tuple = ExecMaterializeSlot(slot); @@ -1595,7 +1586,7 @@ ExecUpdate(TupleTableSlot *slot, /* BEFORE ROW UPDATE Triggers */ if (resultRelInfo->ri_TrigDesc && - resultRelInfo->ri_TrigDesc->n_before_row[TRIGGER_EVENT_UPDATE] > 0) + resultRelInfo->ri_TrigDesc->n_before_row[TRIGGER_EVENT_UPDATE] > 0) { HeapTuple newtuple; @@ -1610,9 +1601,9 @@ ExecUpdate(TupleTableSlot *slot, { /* * Insert modified tuple into tuple table slot, replacing the - * original. We assume that it was allocated in per-tuple - * memory context, and therefore will go away by itself. The - * tuple table slot should not try to clear it. + * original. We assume that it was allocated in per-tuple memory + * context, and therefore will go away by itself. The tuple table + * slot should not try to clear it. */ ExecStoreTuple(newtuple, slot, InvalidBuffer, false); tuple = newtuple; @@ -1622,11 +1613,11 @@ ExecUpdate(TupleTableSlot *slot, /* * Check the constraints of the tuple * - * If we generate a new candidate tuple after EvalPlanQual testing, we - * must loop back here and recheck constraints. (We don't need to - * redo triggers, however. If there are any BEFORE triggers then - * trigger.c will have done heap_lock_tuple to lock the correct tuple, - * so there's no need to do them again.) + * If we generate a new candidate tuple after EvalPlanQual testing, we must + * loop back here and recheck constraints. (We don't need to redo + * triggers, however. If there are any BEFORE triggers then trigger.c + * will have done heap_lock_tuple to lock the correct tuple, so there's no + * need to do them again.) */ lreplace:; if (resultRelationDesc->rd_att->constr) @@ -1635,9 +1626,9 @@ lreplace:; /* * replace the heap tuple * - * Note: if es_crosscheck_snapshot isn't InvalidSnapshot, we check that - * the row to be updated is visible to that snapshot, and throw a can't- - * serialize error if not. This is a special-case behavior needed for + * Note: if es_crosscheck_snapshot isn't InvalidSnapshot, we check that the + * row to be updated is visible to that snapshot, and throw a can't- + * serialize error if not. This is a special-case behavior needed for * referential integrity updates in serializable transactions. */ result = heap_update(resultRelationDesc, tupleid, tuple, @@ -1687,18 +1678,18 @@ 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 UPDATEs are actually DELETEs and INSERTs, and index - * tuple deletion is done automagically by the vacuum daemon. 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 UPDATEs are actually DELETEs and INSERTs, and index tuple + * deletion is done automagically by the vacuum daemon. All we do is + * insert new index tuples. -cim 9/27/89 */ /* * insert index entries for tuple * - * Note: heap_update returns the tid (location) of the new tuple - * in the t_self field. + * Note: heap_update returns the tid (location) of the new tuple in the + * t_self field. */ if (resultRelInfo->ri_NumIndices > 0) ExecInsertIndexTuples(slot, &(tuple->t_self), estate, false); @@ -1721,8 +1712,8 @@ ExecRelCheck(ResultRelInfo *resultRelInfo, /* * If first time through for this result relation, build expression - * nodetrees for rel's constraint expressions. Keep them in the - * per-query memory context so they'll survive throughout the query. + * nodetrees for rel's constraint expressions. Keep them in the per-query + * memory context so they'll survive throughout the query. */ if (resultRelInfo->ri_ConstraintExprs == NULL) { @@ -1740,8 +1731,8 @@ ExecRelCheck(ResultRelInfo *resultRelInfo, } /* - * We will use the EState's per-tuple context for evaluating - * constraint expressions (creating it if it's not already there). + * We will use the EState's per-tuple context for evaluating constraint + * expressions (creating it if it's not already there). */ econtext = GetPerTupleExprContext(estate); @@ -1787,7 +1778,7 @@ ExecConstraints(ResultRelInfo *resultRelInfo, ereport(ERROR, (errcode(ERRCODE_NOT_NULL_VIOLATION), errmsg("null value in column \"%s\" violates not-null constraint", - NameStr(rel->rd_att->attrs[attrChk - 1]->attname)))); + NameStr(rel->rd_att->attrs[attrChk - 1]->attname)))); } } @@ -1870,9 +1861,9 @@ EvalPlanQual(EState *estate, Index rti, { /* * If xmin isn't what we're expecting, the slot must have been - * recycled and reused for an unrelated tuple. This implies - * that the latest version of the row was deleted, so we need - * do nothing. (Should be safe to examine xmin without getting + * recycled and reused for an unrelated tuple. This implies that + * the latest version of the row was deleted, so we need do + * nothing. (Should be safe to examine xmin without getting * buffer's content lock, since xmin never changes in an existing * tuple.) */ @@ -1888,8 +1879,8 @@ EvalPlanQual(EState *estate, Index rti, elog(ERROR, "t_xmin is uncommitted in tuple to be updated"); /* - * 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(SnapshotDirty->xmax)) { @@ -1907,8 +1898,8 @@ EvalPlanQual(EState *estate, Index rti, } /* - * If the referenced slot was actually empty, the latest version - * of the row must have been deleted, so we need do nothing. + * If the referenced slot was actually empty, the latest version of + * the row must have been deleted, so we need do nothing. */ if (tuple.t_data == NULL) { @@ -1928,15 +1919,15 @@ EvalPlanQual(EState *estate, Index rti, /* * If we get here, the tuple was found but failed SnapshotDirty. - * Assuming the xmin is either a committed xact or our own xact - * (as it certainly should be if we're trying to modify the tuple), - * this must mean that the row was updated or deleted by either - * a committed xact or our own xact. If it was deleted, we can - * ignore it; if it was updated then chain up to the next version - * and repeat the whole test. + * Assuming the xmin is either a committed xact or our own xact (as it + * certainly should be if we're trying to modify the tuple), this must + * mean that the row was updated or deleted by either a committed xact + * or our own xact. If it was deleted, we can ignore it; if it was + * updated then chain up to the next version and repeat the whole + * test. * - * As above, it should be safe to examine xmax and t_ctid without - * the buffer content lock, because they can't be changing. + * As above, it should be safe to examine xmax and t_ctid without the + * buffer content lock, because they can't be changing. */ if (ItemPointerEquals(&tuple.t_self, &tuple.t_data->t_ctid)) { @@ -1954,8 +1945,8 @@ EvalPlanQual(EState *estate, Index rti, } /* - * 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; @@ -1974,10 +1965,10 @@ EvalPlanQual(EState *estate, Index rti, } /* - * 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? -:)) + * 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? -:)) */ if (epq != NULL && epq->rti != rti && epq->estate->es_evTuple[rti - 1] != NULL) @@ -1999,8 +1990,8 @@ EvalPlanQual(EState *estate, Index rti, } /* - * If we are requested for another RTE then we have to suspend - * execution of current PlanQual and start execution for new one. + * 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) { @@ -2031,18 +2022,17 @@ EvalPlanQual(EState *estate, Index rti, Assert(epq->rti == rti); /* - * Ok - we're requested for the same RTE. Unfortunately we still have - * to end and restart execution of the plan, because ExecReScan - * wouldn't ensure that upper plan nodes would reset themselves. We - * could make that work if insertion of the target tuple were - * integrated with the Param mechanism somehow, so that the upper plan - * nodes know that their children's outputs have changed. + * Ok - we're requested for the same RTE. Unfortunately we still have to + * end and restart execution of the plan, because ExecReScan wouldn't + * ensure that upper plan nodes would reset themselves. We could make + * that work if insertion of the target tuple were integrated with the + * Param mechanism somehow, so that the upper plan nodes know that their + * children's outputs have changed. * * Note that the stack of free evalPlanQual nodes is quite useless at the * moment, since it only saves us from pallocing/releasing the - * evalPlanQual nodes themselves. But it will be useful once we - * implement ReScan instead of end/restart for re-using PlanQual - * nodes. + * evalPlanQual nodes themselves. But it will be useful once we implement + * ReScan instead of end/restart for re-using PlanQual nodes. */ if (endNode) { @@ -2055,15 +2045,14 @@ EvalPlanQual(EState *estate, Index rti, * * Note: if we were re-using PlanQual plans via ExecReScan, we'd need to * instead copy down changeable state from the top plan (including - * es_result_relation_info, es_junkFilter) and reset locally - * changeable state in the epq (including es_param_exec_vals, - * es_evTupleNull). + * es_result_relation_info, es_junkFilter) and reset locally changeable + * state in the epq (including es_param_exec_vals, es_evTupleNull). */ EvalPlanQualStart(epq, estate, epq->next); /* - * free old RTE' tuple, if any, and store target tuple where - * relation's scan node will see it + * free old RTE' tuple, if any, and store target tuple where relation's + * scan node will see it */ epqstate = epq->estate; if (epqstate->es_evTuple[rti - 1] != NULL) @@ -2171,10 +2160,10 @@ EvalPlanQualStart(evalPlanQual *epq, EState *estate, evalPlanQual *priorepq) oldcontext = MemoryContextSwitchTo(epqstate->es_query_cxt); /* - * The epqstates share the top query's copy of unchanging state such - * as the snapshot, rangetable, result-rel info, and external Param - * info. They need their own copies of local state, including a tuple - * table, es_param_exec_vals, etc. + * The epqstates share the top query's copy of unchanging state such as + * the snapshot, rangetable, result-rel info, and external Param info. + * They need their own copies of local state, including a tuple table, + * es_param_exec_vals, etc. */ epqstate->es_direction = ForwardScanDirection; epqstate->es_snapshot = estate->es_snapshot; @@ -2199,9 +2188,9 @@ EvalPlanQualStart(evalPlanQual *epq, EState *estate, evalPlanQual *priorepq) epqstate->es_topPlan = estate->es_topPlan; /* - * Each epqstate must have its own es_evTupleNull state, but all the - * stack entries share es_evTuple state. This allows sub-rechecks to - * inherit the value being examined by an outer recheck. + * Each epqstate must have its own es_evTupleNull state, but all the stack + * entries share es_evTuple state. This allows sub-rechecks to inherit + * the value being examined by an outer recheck. */ epqstate->es_evTupleNull = (bool *) palloc0(rtsize * sizeof(bool)); if (priorepq == NULL) diff --git a/src/backend/executor/execProcnode.c b/src/backend/executor/execProcnode.c index 28f67a2562..fe067086d3 100644 --- a/src/backend/executor/execProcnode.c +++ b/src/backend/executor/execProcnode.c @@ -12,7 +12,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/execProcnode.c,v 1.50 2005/04/19 22:35:11 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/execProcnode.c,v 1.51 2005/10/15 02:49:16 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -240,8 +240,8 @@ ExecInitNode(Plan *node, EState *estate) } /* - * Initialize any initPlans present in this node. The planner put - * them in a separate list for us. + * Initialize any initPlans present in this node. The planner put them in + * a separate list for us. */ subps = NIL; foreach(l, node->initPlan) @@ -258,9 +258,9 @@ ExecInitNode(Plan *node, EState *estate) /* * Initialize any subPlans present in this node. These were found by - * ExecInitExpr during initialization of the PlanState. Note we must - * do this after initializing initPlans, in case their arguments - * contain subPlans (is that actually possible? perhaps not). + * ExecInitExpr during initialization of the PlanState. Note we must do + * this after initializing initPlans, in case their arguments contain + * subPlans (is that actually possible? perhaps not). */ foreach(l, result->subPlan) { @@ -422,7 +422,7 @@ ExecProcNode(PlanState *node) Node * MultiExecProcNode(PlanState *node) { - Node *result; + Node *result; CHECK_FOR_INTERRUPTS(); @@ -431,9 +431,9 @@ MultiExecProcNode(PlanState *node) switch (nodeTag(node)) { - /* - * Only node types that actually support multiexec will be listed - */ + /* + * Only node types that actually support multiexec will be listed + */ case T_HashState: result = MultiExecHash((HashState *) node); diff --git a/src/backend/executor/execQual.c b/src/backend/executor/execQual.c index 87fcf53bf0..d535e6453d 100644 --- a/src/backend/executor/execQual.c +++ b/src/backend/executor/execQual.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.180 2005/06/26 22:05:36 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.181 2005/10/15 02:49:16 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -89,8 +89,8 @@ static Datum ExecEvalOr(BoolExprState *orExpr, ExprContext *econtext, static Datum ExecEvalAnd(BoolExprState *andExpr, ExprContext *econtext, bool *isNull, ExprDoneCond *isDone); static Datum ExecEvalConvertRowtype(ConvertRowtypeExprState *cstate, - ExprContext *econtext, - bool *isNull, ExprDoneCond *isDone); + ExprContext *econtext, + bool *isNull, ExprDoneCond *isDone); static Datum ExecEvalCase(CaseExprState *caseExpr, ExprContext *econtext, bool *isNull, ExprDoneCond *isDone); static Datum ExecEvalCaseTestExpr(ExprState *exprstate, @@ -106,8 +106,8 @@ static Datum ExecEvalCoalesce(CoalesceExprState *coalesceExpr, ExprContext *econtext, bool *isNull, ExprDoneCond *isDone); static Datum ExecEvalMinMax(MinMaxExprState *minmaxExpr, - ExprContext *econtext, - bool *isNull, ExprDoneCond *isDone); + ExprContext *econtext, + bool *isNull, ExprDoneCond *isDone); static Datum ExecEvalNullIf(FuncExprState *nullIfExpr, ExprContext *econtext, bool *isNull, ExprDoneCond *isDone); @@ -243,8 +243,8 @@ ExecEvalArrayRef(ArrayRefExprState *astate, isDone)); /* - * If refexpr yields NULL, and it's a fetch, then result is NULL. In - * the assignment case, we'll cons up something below. + * If refexpr yields NULL, and it's a fetch, then result is NULL. In the + * assignment case, we'll cons up something below. */ if (*isNull) { @@ -298,8 +298,7 @@ ExecEvalArrayRef(ArrayRefExprState *astate, NULL)); /* - * If any index expr yields NULL, result is NULL or source - * array + * If any index expr yields NULL, result is NULL or source array */ if (eisnull) { @@ -326,13 +325,12 @@ ExecEvalArrayRef(ArrayRefExprState *astate, /* * Evaluate the value to be assigned into the array. * - * XXX At some point we'll need to look into making the old value of - * the array element available via CaseTestExpr, as is done by - * ExecEvalFieldStore. This is not needed now but will be needed - * to support arrays of composite types; in an assignment to a - * field of an array member, the parser would generate a - * FieldStore that expects to fetch its input tuple via - * CaseTestExpr. + * XXX At some point we'll need to look into making the old value of the + * array element available via CaseTestExpr, as is done by + * ExecEvalFieldStore. This is not needed now but will be needed to + * support arrays of composite types; in an assignment to a field of + * an array member, the parser would generate a FieldStore that + * expects to fetch its input tuple via CaseTestExpr. */ sourceData = ExecEvalExpr(astate->refassgnexpr, econtext, @@ -340,19 +338,18 @@ ExecEvalArrayRef(ArrayRefExprState *astate, NULL); /* - * For now, can't cope with inserting NULL into an array, so make - * it a no-op per discussion above... + * For now, can't cope with inserting NULL into an array, so make it a + * no-op per discussion above... */ if (eisnull) return PointerGetDatum(array_source); /* - * For an assignment, if all the subscripts and the input - * expression are non-null but the original array is null, then - * substitute an empty (zero-dimensional) array and proceed with - * the assignment. This only works for varlena arrays, though; for - * fixed-length array types we punt and return the null input - * array. + * For an assignment, if all the subscripts and the input expression + * are non-null but the original array is null, then substitute an + * empty (zero-dimensional) array and proceed with the assignment. + * This only works for varlena arrays, though; for fixed-length array + * types we punt and return the null input array. */ if (*isNull) { @@ -379,7 +376,7 @@ ExecEvalArrayRef(ArrayRefExprState *astate, else resultArray = array_set_slice(array_source, i, upper.indx, lower.indx, - (ArrayType *) DatumGetPointer(sourceData), + (ArrayType *) DatumGetPointer(sourceData), astate->refattrlength, astate->refelemlength, astate->refelembyval, @@ -451,10 +448,10 @@ ExecEvalVar(ExprState *exprstate, ExprContext *econtext, /* * Get the slot and attribute number we want * - * The asserts check that references to system attributes only appear at - * the level of a relation scan; at higher levels, system attributes - * must be treated as ordinary variables (since we no longer have - * access to the original tuple). + * The asserts check that references to system attributes only appear at the + * level of a relation scan; at higher levels, system attributes must be + * treated as ordinary variables (since we no longer have access to the + * original tuple). */ attnum = variable->varattno; @@ -477,6 +474,7 @@ ExecEvalVar(ExprState *exprstate, ExprContext *econtext, } #ifdef USE_ASSERT_CHECKING + /* * Some checks that are only applied for user attribute numbers (bogus * system attnums will be caught inside slot_getattr). @@ -491,11 +489,10 @@ ExecEvalVar(ExprState *exprstate, ExprContext *econtext, Assert(attnum <= tuple_type->natts); /* - * This assert checks that the datatype the plan expects to get - * (as told by our "variable" argument) is in fact the datatype of - * the attribute being fetched (as seen in the current context, - * identified by our "econtext" argument). Otherwise crashes are - * likely. + * This assert checks that the datatype the plan expects to get (as + * told by our "variable" argument) is in fact the datatype of the + * attribute being fetched (as seen in the current context, identified + * by our "econtext" argument). Otherwise crashes are likely. * * Note that we can't check dropped columns, since their atttypid has * been zeroed. @@ -503,7 +500,7 @@ ExecEvalVar(ExprState *exprstate, ExprContext *econtext, Assert(variable->vartype == tuple_type->attrs[attnum - 1]->atttypid || tuple_type->attrs[attnum - 1]->attisdropped); } -#endif /* USE_ASSERT_CHECKING */ +#endif /* USE_ASSERT_CHECKING */ return slot_getattr(slot, attnum, isNull); } @@ -559,9 +556,8 @@ ExecEvalParam(ExprState *exprstate, ExprContext *econtext, if (thisParamKind == PARAM_EXEC) { /* - * PARAM_EXEC params (internal executor parameters) are stored in - * the ecxt_param_exec_vals array, and can be accessed by array - * index. + * PARAM_EXEC params (internal executor parameters) are stored in the + * ecxt_param_exec_vals array, and can be accessed by array index. */ ParamExecData *prm; @@ -579,8 +575,7 @@ ExecEvalParam(ExprState *exprstate, ExprContext *econtext, else { /* - * All other parameter types must be sought in - * ecxt_param_list_info. + * All other parameter types must be sought in ecxt_param_list_info. */ ParamListInfo paramInfo; @@ -641,9 +636,9 @@ GetAttributeByNum(HeapTupleHeader tuple, tupDesc = lookup_rowtype_tupdesc(tupType, tupTypmod); /* - * heap_getattr needs a HeapTuple not a bare HeapTupleHeader. We set - * all the fields in the struct just in case user tries to inspect - * system columns. + * heap_getattr needs a HeapTuple not a bare HeapTupleHeader. We set all + * the fields in the struct just in case user tries to inspect system + * columns. */ tmptup.t_len = HeapTupleHeaderGetDatumLength(tuple); ItemPointerSetInvalid(&(tmptup.t_self)); @@ -699,9 +694,9 @@ GetAttributeByName(HeapTupleHeader tuple, const char *attname, bool *isNull) elog(ERROR, "attribute \"%s\" does not exist", attname); /* - * heap_getattr needs a HeapTuple not a bare HeapTupleHeader. We set - * all the fields in the struct just in case user tries to inspect - * system columns. + * heap_getattr needs a HeapTuple not a bare HeapTupleHeader. We set all + * the fields in the struct just in case user tries to inspect system + * columns. */ tmptup.t_len = HeapTupleHeaderGetDatumLength(tuple); ItemPointerSetInvalid(&(tmptup.t_self)); @@ -730,9 +725,9 @@ init_fcache(Oid foid, FuncExprState *fcache, MemoryContext fcacheCxt) /* * Safety check on nargs. Under normal circumstances this should never - * fail, as parser should check sooner. But possibly it might fail - * if server has been compiled with FUNC_MAX_ARGS smaller than some - * functions declared in pg_proc? + * fail, as parser should check sooner. But possibly it might fail if + * server has been compiled with FUNC_MAX_ARGS smaller than some functions + * declared in pg_proc? */ if (list_length(fcache->args) > FUNC_MAX_ARGS) ereport(ERROR, @@ -793,10 +788,9 @@ ExecEvalFuncArgs(FunctionCallInfo fcinfo, if (thisArgIsDone != ExprSingleResult) { /* - * We allow only one argument to have a set value; we'd need - * much more complexity to keep track of multiple set - * arguments (cf. ExecTargetList) and it doesn't seem worth - * it. + * We allow only one argument to have a set value; we'd need much + * more complexity to keep track of multiple set arguments (cf. + * ExecTargetList) and it doesn't seem worth it. */ if (argIsDone != ExprSingleResult) ereport(ERROR, @@ -835,11 +829,10 @@ ExecMakeFunctionResult(FuncExprState *fcache, check_stack_depth(); /* - * arguments is a list of expressions to evaluate before passing to - * the function manager. We skip the evaluation if it was already - * done in the previous call (ie, we are continuing the evaluation of - * a set-valued function). Otherwise, collect the current argument - * values into fcinfo. + * arguments is a list of expressions to evaluate before passing to the + * function manager. We skip the evaluation if it was already done in the + * previous call (ie, we are continuing the evaluation of a set-valued + * function). Otherwise, collect the current argument values into fcinfo. */ if (!fcache->setArgsValid) { @@ -870,8 +863,7 @@ ExecMakeFunctionResult(FuncExprState *fcache, } /* - * If function returns set, prepare a resultinfo node for - * communication + * If function returns set, prepare a resultinfo node for communication */ if (fcache->func.fn_retset) { @@ -887,14 +879,14 @@ ExecMakeFunctionResult(FuncExprState *fcache, } /* - * 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->func.fn_retset || hasSetArg) { /* - * We need to return a set result. Complain if caller not ready - * to accept one. + * We need to return a set result. Complain if caller not ready to + * accept one. */ if (isDone == NULL) ereport(ERROR, @@ -902,18 +894,18 @@ ExecMakeFunctionResult(FuncExprState *fcache, errmsg("set-valued function called in context that cannot accept a set"))); /* - * This loop handles the situation where we have both a set - * argument and a set-valued function. Once we have exhausted the - * function's value(s) for a particular argument value, we have to - * get the next argument value and start the function over again. - * We might have to do it more than once, if the function produces - * an empty result set for a particular input value. + * This loop handles the situation where we have both a set argument + * and a set-valued function. Once we have exhausted the function's + * value(s) for a particular argument value, we have to get the next + * argument value and start the function over again. We might have to + * do it more than once, if the function produces an empty result set + * for a particular input value. */ for (;;) { /* - * If function is strict, and there are any NULL arguments, - * skip calling the function (at least for this set of args). + * If function is strict, and there are any NULL arguments, skip + * calling the function (at least for this set of args). */ bool callit = true; @@ -948,8 +940,8 @@ ExecMakeFunctionResult(FuncExprState *fcache, { /* * Got a result from current argument. If function itself - * returns set, save the current argument values to re-use - * on the next call. + * returns set, save the current argument values to re-use on + * the next call. */ if (fcache->func.fn_retset && *isDone == ExprMultipleResult) { @@ -961,7 +953,7 @@ ExecMakeFunctionResult(FuncExprState *fcache, { RegisterExprContextCallback(econtext, ShutdownFuncExpr, - PointerGetDatum(fcache)); + PointerGetDatum(fcache)); fcache->shutdown_reg = true; } } @@ -992,8 +984,8 @@ ExecMakeFunctionResult(FuncExprState *fcache, } /* - * If we reach here, loop around to run the function on the - * new argument. + * If we reach here, loop around to run the function on the new + * argument. */ } } @@ -1003,9 +995,9 @@ ExecMakeFunctionResult(FuncExprState *fcache, * Non-set case: much easier. * * We change the ExprState function pointer to use the simpler - * ExecMakeFunctionResultNoSets on subsequent calls. This amounts - * to assuming that no argument can return a set if it didn't do - * so the first time. + * ExecMakeFunctionResultNoSets on subsequent calls. This amounts to + * assuming that no argument can return a set if it didn't do so the + * first time. */ fcache->xprstate.evalfunc = (ExprStateEvalFunc) ExecMakeFunctionResultNoSets; @@ -1074,8 +1066,8 @@ ExecMakeFunctionResultNoSets(FuncExprState *fcache, InitFunctionCallInfoData(fcinfo, &(fcache->func), i, NULL, NULL); /* - * If function is strict, and there are any NULL arguments, skip - * calling the function and return NULL. + * If function is strict, and there are any NULL arguments, skip calling + * the function and return NULL. */ if (fcache->func.fn_strict) { @@ -1100,7 +1092,7 @@ ExecMakeFunctionResultNoSets(FuncExprState *fcache, * ExecMakeTableFunctionResult * * Evaluate a table function, producing a materialized result in a Tuplestore - * object. *returnDesc is set to the tupledesc actually returned by the + * object. *returnDesc is set to the tupledesc actually returned by the * function, or NULL if it didn't provide one. */ Tuplestorestate * @@ -1130,11 +1122,11 @@ ExecMakeTableFunctionResult(ExprState *funcexpr, get_typtype(funcrettype) == 'c'); /* - * Prepare a resultinfo node for communication. We always do this - * even if not expecting a set result, so that we can pass - * expectedDesc. In the generic-expression case, the expression - * doesn't actually get to see the resultinfo, but set it up anyway - * because we use some of the fields as our own state variables. + * Prepare a resultinfo node for communication. We always do this even if + * not expecting a set result, so that we can pass expectedDesc. In the + * generic-expression case, the expression doesn't actually get to see the + * resultinfo, but set it up anyway because we use some of the fields as + * our own state variables. */ InitFunctionCallInfoData(fcinfo, NULL, 0, NULL, (Node *) &rsinfo); rsinfo.type = T_ReturnSetInfo; @@ -1147,14 +1139,14 @@ ExecMakeTableFunctionResult(ExprState *funcexpr, rsinfo.setDesc = NULL; /* - * Normally the passed expression tree will be a FuncExprState, since - * the grammar only allows a function call at the top level of a table - * function reference. However, if the function doesn't return set - * then the planner might have replaced the function call via - * constant-folding or inlining. So if we see any other kind of - * expression node, execute it via the general ExecEvalExpr() code; - * the only difference is that we don't get a chance to pass a special - * ReturnSetInfo to any functions buried in the expression. + * Normally the passed expression tree will be a FuncExprState, since the + * grammar only allows a function call at the top level of a table + * function reference. However, if the function doesn't return set then + * the planner might have replaced the function call via constant-folding + * or inlining. So if we see any other kind of expression node, execute + * it via the general ExecEvalExpr() code; the only difference is that we + * don't get a chance to pass a special ReturnSetInfo to any functions + * buried in the expression. */ if (funcexpr && IsA(funcexpr, FuncExprState) && IsA(funcexpr->expr, FuncExpr)) @@ -1182,9 +1174,9 @@ ExecMakeTableFunctionResult(ExprState *funcexpr, * Evaluate the function's argument list. * * Note: ideally, we'd do this in the per-tuple context, but then the - * argument values would disappear when we reset the context in - * the inner loop. So do it in caller context. Perhaps we should - * make a separate context just to hold the evaluated arguments? + * argument values would disappear when we reset the context in the + * inner loop. So do it in caller context. Perhaps we should make a + * separate context just to hold the evaluated arguments? */ fcinfo.flinfo = &(fcache->func); argDone = ExecEvalFuncArgs(&fcinfo, fcache->args, econtext); @@ -1217,8 +1209,7 @@ ExecMakeTableFunctionResult(ExprState *funcexpr, } /* - * Switch to short-lived context for calling the function or - * expression. + * Switch to short-lived context for calling the function or expression. */ MemoryContextSwitchTo(econtext->ecxt_per_tuple_memory); @@ -1232,9 +1223,9 @@ ExecMakeTableFunctionResult(ExprState *funcexpr, HeapTuple tuple; /* - * reset per-tuple memory context before each call of the function - * or expression. This cleans up any local memory the function may - * leak when called. + * reset per-tuple memory context before each call of the function or + * expression. This cleans up any local memory the function may leak + * when called. */ ResetExprContext(econtext); @@ -1261,12 +1252,12 @@ ExecMakeTableFunctionResult(ExprState *funcexpr, break; /* - * Can't do anything very useful with NULL rowtype values. - * For a function returning set, we consider this a protocol - * violation (but another alternative would be to just ignore - * the result and "continue" to get another row). For a function - * not returning set, we fall out of the loop; we'll cons up - * an all-nulls result row below. + * Can't do anything very useful with NULL rowtype values. For a + * function returning set, we consider this a protocol violation + * (but another alternative would be to just ignore the result and + * "continue" to get another row). For a function not returning + * set, we fall out of the loop; we'll cons up an all-nulls result + * row below. */ if (returnsTuple && fcinfo.isnull) { @@ -1278,8 +1269,7 @@ ExecMakeTableFunctionResult(ExprState *funcexpr, } /* - * If first time through, build tupdesc and tuplestore for - * result + * If first time through, build tupdesc and tuplestore for result */ if (first_time) { @@ -1287,15 +1277,14 @@ ExecMakeTableFunctionResult(ExprState *funcexpr, if (returnsTuple) { /* - * Use the type info embedded in the rowtype Datum to - * look up the needed tupdesc. Make a copy for the - * query. + * Use the type info embedded in the rowtype Datum to look + * up the needed tupdesc. Make a copy for the query. */ HeapTupleHeader td; td = DatumGetHeapTupleHeader(result); tupdesc = lookup_rowtype_tupdesc(HeapTupleHeaderGetTypeId(td), - HeapTupleHeaderGetTypMod(td)); + HeapTupleHeaderGetTypMod(td)); tupdesc = CreateTupleDescCopy(tupdesc); } else @@ -1507,7 +1496,7 @@ ExecEvalDistinct(FuncExprState *fcache, if (argDone != ExprSingleResult) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("IS DISTINCT FROM does not support set arguments"))); + errmsg("IS DISTINCT FROM does not support set arguments"))); Assert(fcinfo.nargs == 2); if (fcinfo.argnull[0] && fcinfo.argnull[1]) @@ -1580,12 +1569,12 @@ ExecEvalScalarArrayOp(ScalarArrayOpExprState *sstate, if (argDone != ExprSingleResult) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("op ANY/ALL (array) does not support set arguments"))); + errmsg("op ANY/ALL (array) does not support set arguments"))); Assert(fcinfo.nargs == 2); /* - * If the array is NULL then we return NULL --- it's not very - * meaningful to do anything else, even if the operator isn't strict. + * If the array is NULL then we return NULL --- it's not very meaningful + * to do anything else, even if the operator isn't strict. */ if (fcinfo.argnull[1]) { @@ -1598,18 +1587,17 @@ ExecEvalScalarArrayOp(ScalarArrayOpExprState *sstate, /* * If the array is empty, we return either FALSE or TRUE per the useOr * flag. This is correct even if the scalar is NULL; since we would - * evaluate the operator zero times, it matters not whether it would - * want to return NULL. + * evaluate the operator zero times, it matters not whether it would want + * to return NULL. */ nitems = ArrayGetNItems(ARR_NDIM(arr), ARR_DIMS(arr)); if (nitems <= 0) return BoolGetDatum(!useOr); /* - * If the scalar is NULL, and the function is strict, return NULL. - * This is just to avoid having to test for strictness inside the - * loop. (XXX but if arrays could have null elements, we'd need a - * test anyway.) + * If the scalar is NULL, and the function is strict, return NULL. This is + * just to avoid having to test for strictness inside the loop. (XXX but + * if arrays could have null elements, we'd need a test anyway.) */ if (fcinfo.argnull[0] && sstate->fxprstate.func.fn_strict) { @@ -1618,9 +1606,8 @@ ExecEvalScalarArrayOp(ScalarArrayOpExprState *sstate, } /* - * We arrange to look up info about the element type only once per - * series of calls, assuming the element type doesn't change - * underneath us. + * We arrange to look up info about the element type only once per series + * of calls, assuming the element type doesn't change underneath us. */ if (sstate->element_type != ARR_ELEMTYPE(arr)) { @@ -1711,15 +1698,15 @@ ExecEvalNot(BoolExprState *notclause, ExprContext *econtext, expr_value = ExecEvalExpr(clause, econtext, isNull, NULL); /* - * 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. */ return BoolGetDatum(!DatumGetBool(expr_value)); } @@ -1742,18 +1729,17 @@ ExecEvalOr(BoolExprState *orExpr, ExprContext *econtext, AnyNull = false; /* - * If any of the clauses is TRUE, the OR result is TRUE regardless of - * the states of the rest of the clauses, so we can stop evaluating - * and return TRUE immediately. If none are TRUE and one or more is - * NULL, we return NULL; otherwise we return FALSE. This makes sense - * when you interpret NULL as "don't know": if we have a TRUE then the - * OR is TRUE even if we aren't sure about some of the other inputs. - * If all the known inputs are FALSE, but we have one or more "don't - * knows", then we have to report that we "don't know" what the OR's - * result should be --- perhaps one of the "don't knows" would have - * been TRUE if we'd known its value. Only when all the inputs are - * known to be FALSE can we state confidently that the OR's result is - * FALSE. + * If any of the clauses is TRUE, the OR result is TRUE regardless of the + * states of the rest of the clauses, so we can stop evaluating and return + * TRUE immediately. If none are TRUE and one or more is NULL, we return + * NULL; otherwise we return FALSE. This makes sense when you interpret + * NULL as "don't know": if we have a TRUE then the OR is TRUE even if we + * aren't sure about some of the other inputs. If all the known inputs are + * FALSE, but we have one or more "don't knows", then we have to report + * that we "don't know" what the OR's result should be --- perhaps one of + * the "don't knows" would have been TRUE if we'd known its value. Only + * when all the inputs are known to be FALSE can we state confidently that + * the OR's result is FALSE. */ foreach(clause, clauses) { @@ -1794,12 +1780,12 @@ ExecEvalAnd(BoolExprState *andExpr, ExprContext *econtext, AnyNull = false; /* - * If any of the clauses is FALSE, the AND result is FALSE regardless - * of the states of the rest of the clauses, so we can stop evaluating - * and return FALSE immediately. If none are FALSE and one or more is - * NULL, we return NULL; otherwise we return TRUE. This makes sense - * when you interpret NULL as "don't know", using the same sort of - * reasoning as for OR, above. + * If any of the clauses is FALSE, the AND result is FALSE regardless of + * the states of the rest of the clauses, so we can stop evaluating and + * return FALSE immediately. If none are FALSE and one or more is NULL, + * we return NULL; otherwise we return TRUE. This makes sense when you + * interpret NULL as "don't know", using the same sort of reasoning as for + * OR, above. */ foreach(clause, clauses) @@ -1826,7 +1812,7 @@ ExecEvalAnd(BoolExprState *andExpr, ExprContext *econtext, /* ---------------------------------------------------------------- * ExecEvalConvertRowtype * - * Evaluate a rowtype coercion operation. This may require + * Evaluate a rowtype coercion operation. This may require * rearranging field positions. * ---------------------------------------------------------------- */ @@ -1865,10 +1851,9 @@ ExecEvalConvertRowtype(ConvertRowtypeExprState *cstate, tmptup.t_data = tuple; /* - * Extract all the values of the old tuple, offsetting the arrays - * so that invalues[0] is NULL and invalues[1] is the first - * source attribute; this exactly matches the numbering convention - * in attrMap. + * Extract all the values of the old tuple, offsetting the arrays so that + * invalues[0] is NULL and invalues[1] is the first source attribute; this + * exactly matches the numbering convention in attrMap. */ heap_deform_tuple(&tmptup, cstate->indesc, invalues + 1, inisnull + 1); invalues[0] = (Datum) 0; @@ -1915,10 +1900,10 @@ ExecEvalCase(CaseExprState *caseExpr, ExprContext *econtext, *isDone = ExprSingleResult; /* - * If there's a test expression, we have to evaluate it and save the - * value where the CaseTestExpr placeholders can find it. We must save - * and restore prior setting of econtext's caseValue fields, in case - * this node is itself within a larger CASE. + * If there's a test expression, we have to evaluate it and save the value + * where the CaseTestExpr placeholders can find it. We must save and + * restore prior setting of econtext's caseValue fields, in case this node + * is itself within a larger CASE. */ save_datum = econtext->caseValue_datum; save_isNull = econtext->caseValue_isNull; @@ -1927,14 +1912,14 @@ ExecEvalCase(CaseExprState *caseExpr, ExprContext *econtext, { econtext->caseValue_datum = ExecEvalExpr(caseExpr->arg, econtext, - &econtext->caseValue_isNull, + &econtext->caseValue_isNull, 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 if there is none. + * 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 if there is none. */ foreach(clause, clauses) { @@ -1947,9 +1932,9 @@ ExecEvalCase(CaseExprState *caseExpr, ExprContext *econtext, NULL); /* - * if we have a true test, then we return the result, since the - * case statement is satisfied. A NULL result from the test is - * not considered true. + * if we have a true test, then we return the result, since the case + * statement is satisfied. A NULL result from the test is not + * considered true. */ if (DatumGetBool(clause_value) && !*isNull) { @@ -2098,7 +2083,7 @@ ExecEvalArray(ArrayExprState *astate, ExprContext *econtext, (errcode(ERRCODE_DATATYPE_MISMATCH), errmsg("cannot merge incompatible arrays"), errdetail("Array with element type %s cannot be " - "included in ARRAY construct with element type %s.", + "included in ARRAY construct with element type %s.", format_type_be(ARR_ELEMTYPE(array)), format_type_be(element_type)))); @@ -2110,8 +2095,8 @@ ExecEvalArray(ArrayExprState *astate, ExprContext *econtext, if (ndims <= 0 || ndims > MAXDIM) ereport(ERROR, (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), - errmsg("number of array dimensions (%d) exceeds " \ - "the maximum allowed (%d)", ndims, MAXDIM))); + errmsg("number of array dimensions (%d) exceeds " \ + "the maximum allowed (%d)", ndims, MAXDIM))); elem_dims = (int *) palloc(elem_ndims * sizeof(int)); memcpy(elem_dims, ARR_DIMS(array), elem_ndims * sizeof(int)); @@ -2130,8 +2115,8 @@ ExecEvalArray(ArrayExprState *astate, ExprContext *econtext, elem_ndims * sizeof(int)) != 0) ereport(ERROR, (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR), - errmsg("multidimensional arrays must have array " - "expressions with matching dimensions"))); + errmsg("multidimensional arrays must have array " + "expressions with matching dimensions"))); } elem_ndatabytes = ARR_SIZE(array) - ARR_OVERHEAD(elem_ndims); @@ -2258,10 +2243,10 @@ static Datum ExecEvalMinMax(MinMaxExprState *minmaxExpr, ExprContext *econtext, bool *isNull, ExprDoneCond *isDone) { - Datum result = (Datum) 0; + Datum result = (Datum) 0; MinMaxOp op = ((MinMaxExpr *) minmaxExpr->xprstate.expr)->op; FunctionCallInfoData locfcinfo; - ListCell *arg; + ListCell *arg; if (isDone) *isDone = ExprSingleResult; @@ -2295,7 +2280,7 @@ ExecEvalMinMax(MinMaxExprState *minmaxExpr, ExprContext *econtext, locfcinfo.arg[1] = value; locfcinfo.isnull = false; cmpresult = DatumGetInt32(FunctionCallInvoke(&locfcinfo)); - if (locfcinfo.isnull) /* probably should not happen */ + if (locfcinfo.isnull) /* probably should not happen */ continue; if (cmpresult > 0 && op == IS_LEAST) result = value; @@ -2531,8 +2516,8 @@ ExecEvalCoerceToDomain(CoerceToDomainState *cstate, ExprContext *econtext, if (*isNull) ereport(ERROR, (errcode(ERRCODE_NOT_NULL_VIOLATION), - errmsg("domain %s does not allow null values", - format_type_be(ctest->resulttype)))); + errmsg("domain %s does not allow null values", + format_type_be(ctest->resulttype)))); break; case DOM_CONSTRAINT_CHECK: { @@ -2545,8 +2530,7 @@ ExecEvalCoerceToDomain(CoerceToDomainState *cstate, ExprContext *econtext, * Set up value to be returned by CoerceToDomainValue * nodes. We must save and restore prior setting of * econtext's domainValue fields, in case this node is - * itself within a check expression for another - * domain. + * itself within a check expression for another domain. */ save_datum = econtext->domainValue_datum; save_isNull = econtext->domainValue_isNull; @@ -2647,9 +2631,9 @@ ExecEvalFieldSelect(FieldSelectState *fstate, } /* - * heap_getattr needs a HeapTuple not a bare HeapTupleHeader. We set - * all the fields in the struct just in case user tries to inspect - * system columns. + * heap_getattr needs a HeapTuple not a bare HeapTupleHeader. We set all + * the fields in the struct just in case user tries to inspect system + * columns. */ tmptup.t_len = HeapTupleHeaderGetDatumLength(tuple); ItemPointerSetInvalid(&(tmptup.t_self)); @@ -2715,8 +2699,8 @@ ExecEvalFieldStore(FieldStoreState *fstate, if (!*isNull) { /* - * heap_deform_tuple needs a HeapTuple not a bare HeapTupleHeader. - * We set all the fields in the struct just in case. + * heap_deform_tuple needs a HeapTuple not a bare HeapTupleHeader. We + * set all the fields in the struct just in case. */ HeapTupleHeader tuphdr; HeapTupleData tmptup; @@ -2749,11 +2733,11 @@ ExecEvalFieldStore(FieldStoreState *fstate, Assert(fieldnum > 0 && fieldnum <= tupDesc->natts); /* - * Use the CaseTestExpr mechanism to pass down the old value of - * the field being replaced; this is useful in case we have a - * nested field update situation. It's safe to reuse the CASE - * mechanism because there cannot be a CASE between here and where - * the value would be needed. + * Use the CaseTestExpr mechanism to pass down the old value of the + * field being replaced; this is useful in case we have a nested field + * update situation. It's safe to reuse the CASE mechanism because + * there cannot be a CASE between here and where the value would be + * needed. */ econtext->caseValue_datum = values[fieldnum - 1]; econtext->caseValue_isNull = isnull[fieldnum - 1]; @@ -2895,8 +2879,8 @@ ExecInitExpr(Expr *node, PlanState *parent) /* * Complain if the aggregate's argument contains any * aggregates; nested agg functions are semantically - * nonsensical. (This should have been caught - * earlier, but we defend against it here anyway.) + * nonsensical. (This should have been caught earlier, + * but we defend against it here anyway.) */ if (naggs != aggstate->numaggs) ereport(ERROR, @@ -3020,9 +3004,8 @@ ExecInitExpr(Expr *node, PlanState *parent) elog(ERROR, "SubPlan found with no parent plan"); /* - * Here we just add the SubPlanState nodes to - * parent->subPlan. The subplans will be initialized - * later. + * Here we just add the SubPlanState nodes to parent->subPlan. + * The subplans will be initialized later. */ parent->subPlan = lcons(sstate, parent->subPlan); sstate->sub_estate = NULL; @@ -3073,8 +3056,8 @@ ExecInitExpr(Expr *node, PlanState *parent) { ConvertRowtypeExpr *convert = (ConvertRowtypeExpr *) node; ConvertRowtypeExprState *cstate = makeNode(ConvertRowtypeExprState); - int i; - int n; + int i; + int n; cstate->xprstate.evalfunc = (ExprStateEvalFunc) ExecEvalConvertRowtype; cstate->arg = ExecInitExpr(convert->arg, parent); @@ -3095,7 +3078,7 @@ ExecInitExpr(Expr *node, PlanState *parent) int j; if (att->attisdropped) - continue; /* attrMap[i] is already 0 */ + continue; /* attrMap[i] is already 0 */ attname = NameStr(att->attname); atttypid = att->atttypid; atttypmod = att->atttypmod; @@ -3111,7 +3094,7 @@ ExecInitExpr(Expr *node, PlanState *parent) elog(ERROR, "attribute \"%s\" of type %s does not match corresponding attribute of type %s", attname, format_type_be(cstate->indesc->tdtypeid), - format_type_be(cstate->outdesc->tdtypeid)); + format_type_be(cstate->outdesc->tdtypeid)); cstate->attrMap[i] = (AttrNumber) (j + 1); break; } @@ -3217,24 +3200,24 @@ ExecInitExpr(Expr *node, PlanState *parent) if (!attrs[i]->attisdropped) { /* - * Guard against ALTER COLUMN TYPE on rowtype - * since the RowExpr was created. XXX should we - * check typmod too? Not sure we can be sure - * it'll be the same. + * Guard against ALTER COLUMN TYPE on rowtype since + * the RowExpr was created. XXX should we check + * typmod too? Not sure we can be sure it'll be the + * same. */ if (exprType((Node *) e) != attrs[i]->atttypid) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), errmsg("ROW() column has type %s instead of type %s", - format_type_be(exprType((Node *) e)), - format_type_be(attrs[i]->atttypid)))); + format_type_be(exprType((Node *) e)), + format_type_be(attrs[i]->atttypid)))); } else { /* - * Ignore original expression and insert a NULL. - * We don't really care what type of NULL it is, - * so always make an int4 NULL. + * Ignore original expression and insert a NULL. We + * don't really care what type of NULL it is, so + * always make an int4 NULL. */ e = (Expr *) makeNullConst(INT4OID); } @@ -3485,16 +3468,16 @@ ExecQual(List *qual, ExprContext *econtext, bool resultForNull) oldContext = MemoryContextSwitchTo(econtext->ecxt_per_tuple_memory); /* - * Evaluate the qual conditions one at a time. If we find a FALSE - * result, we can stop evaluating and return FALSE --- the AND result - * must be FALSE. Also, if we find a NULL result when resultForNull - * is FALSE, we can stop and return FALSE --- the AND result must be - * FALSE or NULL in that case, and the caller doesn't care which. + * Evaluate the qual conditions one at a time. If we find a FALSE result, + * we can stop evaluating and return FALSE --- the AND result must be + * FALSE. Also, if we find a NULL result when resultForNull is FALSE, we + * can stop and return FALSE --- the AND result must be FALSE or NULL in + * that case, and the caller doesn't care which. * - * If we get to the end of the list, we can return TRUE. This will - * happen when the AND result is indeed TRUE, or when the AND result - * is NULL (one or more NULL subresult, with all the rest TRUE) and - * the caller has specified resultForNull = TRUE. + * If we get to the end of the list, we can return TRUE. This will happen + * when the AND result is indeed TRUE, or when the AND result is NULL (one + * or more NULL subresult, with all the rest TRUE) and the caller has + * specified resultForNull = TRUE. */ result = true; @@ -3637,8 +3620,7 @@ ExecTargetList(List *targetlist, if (*isDone == ExprSingleResult) { /* - * all sets are done, so report that tlist expansion is - * complete. + * all sets are done, so report that tlist expansion is complete. */ *isDone = ExprEndResult; MemoryContextSwitchTo(oldContext); @@ -3647,8 +3629,8 @@ ExecTargetList(List *targetlist, else { /* - * We have some done and some undone sets. Restart the done - * ones so that we can deliver a tuple (if possible). + * We have some done and some undone sets. Restart the done ones + * so that we can deliver a tuple (if possible). */ foreach(tl, targetlist) { @@ -3666,8 +3648,8 @@ ExecTargetList(List *targetlist, if (itemIsDone[resind] == ExprEndResult) { /* - * Oh dear, this item is returning an empty set. - * Guess we can't make a tuple after all. + * Oh dear, this item is returning an empty set. Guess + * we can't make a tuple after all. */ *isDone = ExprEndResult; break; @@ -3676,9 +3658,9 @@ ExecTargetList(List *targetlist, } /* - * If we cannot make a tuple because some sets are empty, we - * still have to cycle the nonempty sets to completion, else - * resources will not be released from subplans etc. + * If we cannot make a tuple because some sets are empty, we still + * have to cycle the nonempty sets to completion, else resources + * will not be released from subplans etc. * * XXX is that still necessary? */ @@ -3741,8 +3723,8 @@ ExecVariableList(ProjectionInfo *projInfo, projInfo->pi_lastScanVar); /* - * Assign to result by direct extraction of fields from source - * slots ... a mite ugly, but fast ... + * Assign to result by direct extraction of fields from source slots ... a + * mite ugly, but fast ... */ for (i = list_length(projInfo->pi_targetlist) - 1; i >= 0; i--) { @@ -3784,10 +3766,9 @@ ExecProject(ProjectionInfo *projInfo, ExprDoneCond *isDone) slot = projInfo->pi_slot; /* - * Clear any former contents of the result slot. This makes it - * safe for us to use the slot's Datum/isnull arrays as workspace. - * (Also, we can return the slot as-is if we decide no rows can - * be projected.) + * Clear any former contents of the result slot. This makes it safe for + * us to use the slot's Datum/isnull arrays as workspace. (Also, we can + * return the slot as-is if we decide no rows can be projected.) */ ExecClearTuple(slot); diff --git a/src/backend/executor/execScan.c b/src/backend/executor/execScan.c index 843aa15101..90ffda092a 100644 --- a/src/backend/executor/execScan.c +++ b/src/backend/executor/execScan.c @@ -12,7 +12,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/execScan.c,v 1.36 2005/05/22 22:30:19 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/execScan.c,v 1.37 2005/10/15 02:49:16 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -61,16 +61,16 @@ ExecScan(ScanState *node, projInfo = node->ps.ps_ProjInfo; /* - * If we have neither a qual to check nor a projection to do, - * just skip all the overhead and return the raw scan tuple. + * If we have neither a qual to check nor a projection to do, just skip + * all the overhead and return the raw scan tuple. */ if (!qual && !projInfo) return (*accessMtd) (node); /* - * Check to see if we're still projecting out tuples from a previous - * scan tuple (because there is a function-returning-set in the - * projection expressions). If so, try to project another one. + * Check to see if we're still projecting out tuples from a previous scan + * tuple (because there is a function-returning-set in the projection + * expressions). If so, try to project another one. */ if (node->ps.ps_TupFromTlist) { @@ -84,15 +84,15 @@ ExecScan(ScanState *node, /* * Reset per-tuple memory context to free any expression evaluation - * storage allocated in the previous tuple cycle. Note this can't - * happen until we're done projecting out tuples from a scan tuple. + * storage allocated in the previous tuple cycle. Note this can't happen + * until we're done projecting out tuples from a scan tuple. */ econtext = node->ps.ps_ExprContext; ResetExprContext(econtext); /* - * get a tuple from the access method loop until we obtain a tuple - * which passes the qualification. + * get a tuple from the access method loop until we obtain a tuple which + * passes the qualification. */ for (;;) { @@ -103,10 +103,10 @@ ExecScan(ScanState *node, slot = (*accessMtd) (node); /* - * if the slot returned by the accessMtd contains NULL, then it - * means there is nothing more to scan so we just return an empty - * slot, being careful to use the projection result slot so it has - * correct tupleDesc. + * if the slot returned by the accessMtd contains NULL, then it means + * there is nothing more to scan so we just return an empty slot, + * being careful to use the projection result slot so it has correct + * tupleDesc. */ if (TupIsNull(slot)) { @@ -125,8 +125,8 @@ ExecScan(ScanState *node, * check that the current tuple satisfies the qual-clause * * check for non-nil qual here to avoid a function call to ExecQual() - * when the qual is nil ... saves only a few cycles, but they add - * up ... + * when the qual is nil ... saves only a few cycles, but they add up + * ... */ if (!qual || ExecQual(qual, econtext, false)) { @@ -136,10 +136,9 @@ ExecScan(ScanState *node, if (projInfo) { /* - * Form a projection tuple, store it in the result tuple - * slot and return it --- unless we find we can project no - * tuples from this scan tuple, in which case continue - * scan. + * Form a projection tuple, store it in the result tuple slot + * and return it --- unless we find we can project no tuples + * from this scan tuple, in which case continue scan. */ resultSlot = ExecProject(projInfo, &isDone); if (isDone != ExprEndResult) @@ -226,8 +225,8 @@ tlist_matches_tupdesc(PlanState *ps, List *tlist, Index varno, TupleDesc tupdesc return false; /* tlist too long */ /* - * If the plan context requires a particular hasoid setting, then that - * has to match, too. + * If the plan context requires a particular hasoid setting, then that has + * to match, too. */ if (ExecContextForcesOids(ps, &hasoid) && hasoid != tupdesc->tdhasoid) diff --git a/src/backend/executor/execTuples.c b/src/backend/executor/execTuples.c index 1c82a3b64b..b38bcc44cb 100644 --- a/src/backend/executor/execTuples.c +++ b/src/backend/executor/execTuples.c @@ -15,7 +15,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/execTuples.c,v 1.87 2005/04/06 16:34:04 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/execTuples.c,v 1.88 2005/10/15 02:49:16 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -129,7 +129,7 @@ ExecCreateTupleTable(int tableSize) * allocate the table itself */ newtable = (TupleTable) palloc(sizeof(TupleTableData) + - (tableSize - 1) * sizeof(TupleTableSlot)); + (tableSize - 1) *sizeof(TupleTableSlot)); newtable->size = tableSize; newtable->next = 0; @@ -175,10 +175,9 @@ ExecDropTupleTable(TupleTable table, /* tuple table */ Assert(table != NULL); /* - * first free all the valid pointers in the tuple array and drop - * refcounts of any referenced buffers, if that's what the caller - * wants. (There is probably no good reason for the caller ever not - * to want it!) + * first free all the valid pointers in the tuple array and drop refcounts + * of any referenced buffers, if that's what the caller wants. (There is + * probably no good reason for the caller ever not to want it!) */ if (shouldFree) { @@ -288,9 +287,9 @@ ExecAllocTableSlot(TupleTable table) Assert(table != NULL); /* - * We expect that the table was made big enough to begin with. - * We cannot reallocate it on the fly since previous plan nodes - * have already got pointers to individual entries. + * We expect that the table was made big enough to begin with. We cannot + * reallocate it on the fly since previous plan nodes have already got + * pointers to individual entries. */ if (table->next >= table->size) elog(ERROR, "plan requires more slots than are available"); @@ -322,8 +321,8 @@ ExecSetSlotDescriptor(TupleTableSlot *slot, /* slot to change */ ExecClearTuple(slot); /* - * Release any old descriptor. Also release old Datum/isnull arrays - * if present (we don't bother to check if they could be re-used). + * Release any old descriptor. Also release old Datum/isnull arrays if + * present (we don't bother to check if they could be re-used). */ if (slot->tts_shouldFreeDesc) FreeTupleDesc(slot->tts_tupleDescriptor); @@ -340,9 +339,8 @@ ExecSetSlotDescriptor(TupleTableSlot *slot, /* slot to change */ slot->tts_shouldFreeDesc = shouldFree; /* - * Allocate Datum/isnull arrays of the appropriate size. These must - * have the same lifetime as the slot, so allocate in the slot's own - * context. + * Allocate Datum/isnull arrays of the appropriate size. These must have + * the same lifetime as the slot, so allocate in the slot's own context. */ slot->tts_values = (Datum *) MemoryContextAlloc(slot->tts_mcxt, tupdesc->natts * sizeof(Datum)); @@ -417,8 +415,8 @@ ExecStoreTuple(HeapTuple tuple, slot->tts_tuple = tuple; /* - * If tuple is on a disk page, keep the page pinned as long as we hold - * a pointer into it. We assume the caller already has such a pin. + * If tuple is on a disk page, keep the page pinned as long as we hold a + * pointer into it. We assume the caller already has such a pin. */ slot->tts_buffer = buffer; if (BufferIsValid(buffer)) @@ -621,21 +619,20 @@ ExecMaterializeSlot(TupleTableSlot *slot) Assert(!slot->tts_isempty); /* - * If we have a physical tuple, and it's locally palloc'd, we have - * nothing to do. + * If we have a physical tuple, and it's locally palloc'd, we have nothing + * to do. */ if (slot->tts_tuple && slot->tts_shouldFree) return slot->tts_tuple; /* * Otherwise, copy or build a tuple, and then store it as the new slot - * value. (Note: tts_nvalid will be reset to zero here. There are - * cases in which this could be optimized but it's probably not worth - * worrying about.) + * value. (Note: tts_nvalid will be reset to zero here. There are cases + * in which this could be optimized but it's probably not worth worrying + * about.) * - * We may be called in a context that is shorter-lived than the - * tuple slot, but we have to ensure that the materialized tuple - * will survive anyway. + * We may be called in a context that is shorter-lived than the tuple slot, + * but we have to ensure that the materialized tuple will survive anyway. */ oldContext = MemoryContextSwitchTo(slot->tts_mcxt); newTuple = ExecCopySlotTuple(slot); @@ -663,9 +660,9 @@ ExecCopySlot(TupleTableSlot *dstslot, TupleTableSlot *srcslot) MemoryContext oldContext; /* - * There might be ways to optimize this when the source is virtual, - * but for now just always build a physical copy. Make sure it is - * in the right context. + * There might be ways to optimize this when the source is virtual, but + * for now just always build a physical copy. Make sure it is in the + * right context. */ oldContext = MemoryContextSwitchTo(dstslot->tts_mcxt); newTuple = ExecCopySlotTuple(srcslot); @@ -893,8 +890,7 @@ TupleDescGetAttInMetadata(TupleDesc tupdesc) attinmeta->tupdesc = BlessTupleDesc(tupdesc); /* - * Gather info needed later to call the "in" function for each - * attribute + * Gather info needed later to call the "in" function for each attribute */ attinfuncinfo = (FmgrInfo *) palloc0(natts * sizeof(FmgrInfo)); attioparams = (Oid *) palloc0(natts * sizeof(Oid)); @@ -974,8 +970,8 @@ BuildTupleFromCStrings(AttInMetadata *attinmeta, char **values) tuple = heap_formtuple(tupdesc, dvalues, nulls); /* - * Release locally palloc'd space. XXX would probably be good to - * pfree values of pass-by-reference datums, as well. + * Release locally palloc'd space. XXX would probably be good to pfree + * values of pass-by-reference datums, as well. */ pfree(dvalues); pfree(nulls); diff --git a/src/backend/executor/execUtils.c b/src/backend/executor/execUtils.c index feeffe7052..05bfc08dc7 100644 --- a/src/backend/executor/execUtils.c +++ b/src/backend/executor/execUtils.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/execUtils.c,v 1.125 2005/08/01 20:31:07 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/execUtils.c,v 1.126 2005/10/15 02:49:16 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -63,8 +63,8 @@ int NTupleReplaced; int NTupleAppended; int NTupleDeleted; int NIndexTupleInserted; -extern int NIndexTupleProcessed; /* have to be defined in the - * access method level so that the +extern int NIndexTupleProcessed; /* have to be defined in the access + * method level so that the * cinterface.a will link ok. */ @@ -166,8 +166,8 @@ CreateExecutorState(void) ALLOCSET_DEFAULT_MAXSIZE); /* - * Make the EState node within the per-query context. This way, we - * don't need a separate pfree() operation for it at shutdown. + * Make the EState node within the per-query context. This way, we don't + * need a separate pfree() operation for it at shutdown. */ oldcontext = MemoryContextSwitchTo(qcontext); @@ -244,16 +244,16 @@ void FreeExecutorState(EState *estate) { /* - * Shut down and free any remaining ExprContexts. We do this - * explicitly to ensure that any remaining shutdown callbacks get - * called (since they might need to release resources that aren't - * simply memory within the per-query memory context). + * Shut down and free any remaining ExprContexts. We do this explicitly + * to ensure that any remaining shutdown callbacks get called (since they + * might need to release resources that aren't simply memory within the + * per-query memory context). */ while (estate->es_exprcontexts) { /* - * XXX: seems there ought to be a faster way to implement this - * than repeated list_delete(), no? + * XXX: seems there ought to be a faster way to implement this than + * repeated list_delete(), no? */ FreeExprContext((ExprContext *) linitial(estate->es_exprcontexts)); /* FreeExprContext removed the list link for us */ @@ -324,10 +324,9 @@ CreateExprContext(EState *estate) econtext->ecxt_callbacks = NULL; /* - * Link the ExprContext into the EState to ensure it is shut down when - * the EState is freed. Because we use lcons(), shutdowns will occur - * in reverse order of creation, which may not be essential but can't - * hurt. + * Link the ExprContext into the EState to ensure it is shut down when the + * EState is freed. Because we use lcons(), shutdowns will occur in + * reverse order of creation, which may not be essential but can't hurt. */ estate->es_exprcontexts = lcons(econtext, estate->es_exprcontexts); @@ -471,9 +470,9 @@ ExecAssignResultTypeFromTL(PlanState *planstate) } /* - * ExecTypeFromTL needs the parse-time representation of the tlist, - * not a list of ExprStates. This is good because some plan nodes - * don't bother to set up planstate->targetlist ... + * ExecTypeFromTL needs the parse-time representation of the tlist, not a + * list of ExprStates. This is good because some plan nodes don't bother + * to set up planstate->targetlist ... */ tupDesc = ExecTypeFromTL(planstate->plan->targetlist, hasoid); ExecAssignResultType(planstate, tupDesc, true); @@ -518,8 +517,8 @@ ExecBuildProjectionInfo(List *targetList, /* * Determine whether the target list consists entirely of simple Var - * references (ie, references to non-system attributes). If so, - * we can use the simpler ExecVariableList instead of ExecTargetList. + * references (ie, references to non-system attributes). If so, we can + * use the simpler ExecVariableList instead of ExecTargetList. */ isVarList = true; foreach(tl, targetList) @@ -545,18 +544,18 @@ ExecBuildProjectionInfo(List *targetList, AttrNumber lastOuterVar = 0; AttrNumber lastScanVar = 0; - projInfo->pi_itemIsDone = NULL; /* not needed */ + projInfo->pi_itemIsDone = NULL; /* not needed */ projInfo->pi_varSlotOffsets = varSlotOffsets = (int *) palloc0(len * sizeof(int)); projInfo->pi_varNumbers = varNumbers = (int *) palloc0(len * sizeof(int)); /* - * Set up the data needed by ExecVariableList. The slots in which - * the variables can be found at runtime are denoted by the offsets - * of their slot pointers within the econtext. This rather grotty - * representation is needed because the caller may not have given - * us the real econtext yet (see hacks in nodeSubplan.c). + * Set up the data needed by ExecVariableList. The slots in which the + * variables can be found at runtime are denoted by the offsets of + * their slot pointers within the econtext. This rather grotty + * representation is needed because the caller may not have given us + * the real econtext yet (see hacks in nodeSubplan.c). */ foreach(tl, targetList) { @@ -631,7 +630,7 @@ ExecAssignProjectionInfo(PlanState *planstate) * * However ... there is no particular need to do it during ExecEndNode, * because FreeExecutorState will free any remaining ExprContexts within - * the EState. Letting FreeExecutorState do it allows the ExprContexts to + * the EState. Letting FreeExecutorState do it allows the ExprContexts to * be freed in reverse order of creation, rather than order of creation as * will happen if we delete them here, which saves O(N^2) work in the list * cleanup inside FreeExprContext. @@ -641,8 +640,8 @@ void ExecFreeExprContext(PlanState *planstate) { /* - * Per above discussion, don't actually delete the ExprContext. - * We do unlink it from the plan node, though. + * Per above discussion, don't actually delete the ExprContext. We do + * unlink it from the plan node, though. */ planstate->ps_ExprContext = NULL; } @@ -774,13 +773,13 @@ ExecOpenIndices(ResultRelInfo *resultRelInfo) * to a new tablespace. * * If the index AM is not safe for concurrent updates, obtain an - * exclusive lock on the index to lock out other updaters as well - * as readers (index_beginscan places AccessShareLock). + * exclusive lock on the index to lock out other updaters as well as + * readers (index_beginscan places AccessShareLock). * - * If there are multiple not-concurrent-safe indexes, all backends - * must lock the indexes in the same order or we will get deadlocks - * here. This is guaranteed by RelationGetIndexList(), which promises - * to return the index list in OID order. + * If there are multiple not-concurrent-safe indexes, all backends must + * lock the indexes in the same order or we will get deadlocks here. + * This is guaranteed by RelationGetIndexList(), which promises to + * return the index list in OID order. * * The locks will be released in ExecCloseIndices. */ @@ -876,9 +875,8 @@ ExecInsertIndexTuples(TupleTableSlot *slot, heapRelation = resultRelInfo->ri_RelationDesc; /* - * We will use the EState's per-tuple context for evaluating - * predicates and index expressions (creating it if it's not already - * there). + * We will use the EState's per-tuple context for evaluating predicates + * and index expressions (creating it if it's not already there). */ econtext = GetPerTupleExprContext(estate); @@ -903,8 +901,8 @@ ExecInsertIndexTuples(TupleTableSlot *slot, List *predicate; /* - * If predicate state not set up yet, create it (in the - * estate's per-query context) + * If predicate state not set up yet, create it (in the estate's + * per-query context) */ predicate = indexInfo->ii_PredicateState; if (predicate == NIL) @@ -921,8 +919,8 @@ ExecInsertIndexTuples(TupleTableSlot *slot, } /* - * FormIndexDatum fills in its values and isnull parameters with - * the appropriate values for the column(s) of the index. + * FormIndexDatum fills in its values and isnull parameters with the + * appropriate values for the column(s) of the index. */ FormIndexDatum(indexInfo, slot, @@ -931,14 +929,14 @@ ExecInsertIndexTuples(TupleTableSlot *slot, isnull); /* - * The index AM does the rest. Note we suppress unique-index - * checks if we are being called from VACUUM, since VACUUM may - * need to move dead tuples that have the same keys as live ones. + * The index AM does the rest. Note we suppress unique-index checks + * if we are being called from VACUUM, since VACUUM may need to move + * dead tuples that have the same keys as live ones. */ index_insert(relationDescs[i], /* index relation */ - values, /* array of index Datums */ - isnull, /* null flags */ - tupleid, /* tid of heap tuple */ + values, /* array of index Datums */ + isnull, /* null flags */ + tupleid, /* tid of heap tuple */ heapRelation, relationDescs[i]->rd_index->indisunique && !is_vacuum); @@ -959,14 +957,14 @@ UpdateChangedParamSet(PlanState *node, Bitmapset *newchg) Bitmapset *parmset; /* - * The plan node only depends on params listed in its allParam set. - * Don't include anything else into its chgParam set. + * The plan node only depends on params listed in its allParam set. Don't + * include anything else into its chgParam set. */ parmset = bms_intersect(node->plan->allParam, newchg); /* - * Keep node->chgParam == NULL if there's not actually any members; - * this allows the simplest possible tests in executor node files. + * Keep node->chgParam == NULL if there's not actually any members; this + * allows the simplest possible tests in executor node files. */ if (!bms_is_empty(parmset)) node->chgParam = bms_join(node->chgParam, parmset); @@ -1049,8 +1047,8 @@ ShutdownExprContext(ExprContext *econtext) return; /* - * Call the callbacks in econtext's per-tuple context. This ensures - * that any memory they might leak will get cleaned up. + * Call the callbacks in econtext's per-tuple context. This ensures that + * any memory they might leak will get cleaned up. */ oldcontext = MemoryContextSwitchTo(econtext->ecxt_per_tuple_memory); diff --git a/src/backend/executor/functions.c b/src/backend/executor/functions.c index 893ef64f03..24a8b9a493 100644 --- a/src/backend/executor/functions.c +++ b/src/backend/executor/functions.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/functions.c,v 1.97 2005/04/10 18:04:20 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/functions.c,v 1.98 2005/10/15 02:49:16 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -82,7 +82,7 @@ typedef SQLFunctionCache *SQLFunctionCachePtr; /* non-export function prototypes */ static execution_state *init_execution_state(List *queryTree_list, - bool readonly_func); + bool readonly_func); static void init_sql_fcache(FmgrInfo *finfo); static void postquel_start(execution_state *es, SQLFunctionCachePtr fcache); static TupleTableSlot *postquel_getnext(execution_state *es); @@ -115,14 +115,14 @@ init_execution_state(List *queryTree_list, bool readonly_func) IsA(queryTree->utilityStmt, TransactionStmt)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - /* translator: %s is a SQL statement name */ + /* translator: %s is a SQL statement name */ errmsg("%s is not allowed in a SQL function", CreateQueryTag(queryTree)))); if (readonly_func && !QueryIsReadOnly(queryTree)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - /* translator: %s is a SQL statement name */ + /* translator: %s is a SQL statement name */ errmsg("%s is not allowed in a non-volatile function", CreateQueryTag(queryTree)))); @@ -178,8 +178,8 @@ init_sql_fcache(FmgrInfo *finfo) procedureStruct = (Form_pg_proc) GETSTRUCT(procedureTuple); /* - * get the result type from the procedure tuple, and check for - * polymorphic result type; if so, find out the actual result type. + * get the result type from the procedure tuple, and check for polymorphic + * result type; if so, find out the actual result type. */ rettype = procedureStruct->prorettype; @@ -190,7 +190,7 @@ init_sql_fcache(FmgrInfo *finfo) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), errmsg("could not determine actual result type for function declared to return type %s", - format_type_be(procedureStruct->prorettype)))); + format_type_be(procedureStruct->prorettype)))); } fcache->rettype = rettype; @@ -208,9 +208,9 @@ init_sql_fcache(FmgrInfo *finfo) typeStruct = (Form_pg_type) GETSTRUCT(typeTuple); /* - * get the type length and by-value flag from the type tuple; also do - * a preliminary check for returnsTuple (this may prove inaccurate, - * see below). + * get the type length and by-value flag from the type tuple; also do a + * preliminary check for returnsTuple (this may prove inaccurate, see + * below). */ fcache->typlen = typeStruct->typlen; fcache->typbyval = typeStruct->typbyval; @@ -218,8 +218,8 @@ init_sql_fcache(FmgrInfo *finfo) rettype == RECORDOID); /* - * Parse and rewrite the queries. We need the argument type info to - * pass to the parser. + * Parse and rewrite the queries. We need the argument type info to pass + * to the parser. */ nargs = procedureStruct->pronargs; haspolyarg = false; @@ -265,17 +265,17 @@ init_sql_fcache(FmgrInfo *finfo) queryTree_list = pg_parse_and_rewrite(src, argOidVect, nargs); /* - * If the function has any arguments declared as polymorphic types, - * then it wasn't type-checked at definition time; must do so now. + * If the function has any arguments declared as polymorphic types, then + * it wasn't type-checked at definition time; must do so now. * - * Also, force a type-check if the declared return type is a rowtype; we - * need to find out whether we are actually returning the whole tuple - * result, or just regurgitating a rowtype expression result. In the - * latter case we clear returnsTuple because we need not act different - * from the scalar result case. + * Also, force a type-check if the declared return type is a rowtype; we need + * to find out whether we are actually returning the whole tuple result, + * or just regurgitating a rowtype expression result. In the latter case + * we clear returnsTuple because we need not act different from the scalar + * result case. * - * In the returnsTuple case, check_sql_fn_retval will also construct - * a JunkFilter we can use to coerce the returned rowtype to the desired + * In the returnsTuple case, check_sql_fn_retval will also construct a + * JunkFilter we can use to coerce the returned rowtype to the desired * form. */ if (haspolyarg || fcache->returnsTuple) @@ -307,9 +307,9 @@ postquel_start(execution_state *es, SQLFunctionCachePtr fcache) /* * In a read-only function, use the surrounding query's snapshot; * otherwise take a new snapshot for each query. The snapshot should - * include a fresh command ID so that all work to date in this - * transaction is visible. We copy in both cases so that postquel_end - * can unconditionally do FreeSnapshot. + * include a fresh command ID so that all work to date in this transaction + * is visible. We copy in both cases so that postquel_end can + * unconditionally do FreeSnapshot. */ if (fcache->readonly_func) snapshot = CopySnapshot(ActiveSnapshot); @@ -470,8 +470,8 @@ postquel_execute(execution_state *es, if (TupIsNull(slot)) { /* - * We fall out here for all cases except where we have obtained - * a row from a function's final SELECT. + * We fall out here for all cases except where we have obtained a row + * from a function's final SELECT. */ postquel_end(es); fcinfo->isnull = true; @@ -479,34 +479,34 @@ postquel_execute(execution_state *es, } /* - * If we got a row from a command within the function it has to be - * the final command. All others shouldn't be returning anything. + * If we got a row from a command within the function it has to be the + * final command. All others shouldn't be returning anything. */ Assert(LAST_POSTQUEL_COMMAND(es)); /* - * Set up to return the function value. For pass-by-reference - * datatypes, be sure to allocate the result in resultcontext, - * not the current memory context (which has query lifespan). + * Set up to return the function value. For pass-by-reference datatypes, + * be sure to allocate the result in resultcontext, not the current memory + * context (which has query lifespan). */ oldcontext = MemoryContextSwitchTo(resultcontext); if (fcache->returnsTuple) { /* - * We are returning the whole tuple, so filter it and apply the - * proper labeling to make it a valid Datum. There are several - * reasons why we do this: + * We are returning the whole tuple, so filter it and apply the proper + * labeling to make it a valid Datum. There are several reasons why + * we do this: * - * 1. To copy the tuple out of the child execution context and - * into the desired result context. + * 1. To copy the tuple out of the child execution context and into the + * desired result context. * - * 2. To remove any junk attributes present in the raw subselect - * result. (This is probably not absolutely necessary, but it - * seems like good policy.) + * 2. To remove any junk attributes present in the raw subselect result. + * (This is probably not absolutely necessary, but it seems like good + * policy.) * - * 3. To insert dummy null columns if the declared result type - * has any attisdropped columns. + * 3. To insert dummy null columns if the declared result type has any + * attisdropped columns. */ HeapTuple newtup; HeapTupleHeader dtup; @@ -517,19 +517,18 @@ postquel_execute(execution_state *es, newtup = ExecRemoveJunk(fcache->junkFilter, slot); /* - * Compress out the HeapTuple header data. We assume that - * heap_form_tuple made the tuple with header and body in one - * palloc'd chunk. We want to return a pointer to the chunk - * start so that it will work if someone tries to free it. + * Compress out the HeapTuple header data. We assume that + * heap_form_tuple made the tuple with header and body in one palloc'd + * chunk. We want to return a pointer to the chunk start so that it + * will work if someone tries to free it. */ t_len = newtup->t_len; dtup = (HeapTupleHeader) newtup; memmove((char *) dtup, (char *) newtup->t_data, t_len); /* - * Use the declared return type if it's not RECORD; else take - * the type from the computed result, making sure a typmod has - * been assigned. + * Use the declared return type if it's not RECORD; else take the type + * from the computed result, making sure a typmod has been assigned. */ if (fcache->rettype != RECORDOID) { @@ -559,9 +558,8 @@ postquel_execute(execution_state *es, else { /* - * Returning a scalar, which we have to extract from the first - * column of the SELECT result, and then copy into result - * context if needed. + * Returning a scalar, which we have to extract from the first column + * of the SELECT result, and then copy into result context if needed. */ value = slot_getattr(slot, 1, &(fcinfo->isnull)); @@ -617,8 +615,8 @@ fmgr_sql(PG_FUNCTION_ARGS) es = fcache->func_state; /* - * Convert params to appropriate format if starting a fresh execution. - * (If continuing execution, we can re-use prior params.) + * Convert params to appropriate format if starting a fresh execution. (If + * continuing execution, we can re-use prior params.) */ if (es && es->status == F_EXEC_START) postquel_sub_params(fcache, fcinfo); @@ -631,8 +629,7 @@ fmgr_sql(PG_FUNCTION_ARGS) /* * Execute each command in the function one after another until we're - * executing the final command and get a result or we run out of - * commands. + * executing the final command and get a result or we run out of commands. */ while (es) { @@ -691,8 +688,8 @@ fmgr_sql(PG_FUNCTION_ARGS) } /* - * If we got a result from a command within the function it has to be - * the final command. All others shouldn't be returning anything. + * If we got a result from a command within the function it has to be the + * final command. All others shouldn't be returning anything. */ Assert(LAST_POSTQUEL_COMMAND(es)); @@ -711,8 +708,8 @@ fmgr_sql(PG_FUNCTION_ARGS) errmsg("set-valued function called in context that cannot accept a set"))); /* - * Ensure we will get shut down cleanly if the exprcontext is not - * run to completion. + * Ensure we will get shut down cleanly if the exprcontext is not run + * to completion. */ if (!fcache->shutdown_reg) { @@ -754,8 +751,7 @@ sql_exec_error_callback(void *arg) fn_name = NameStr(functup->proname); /* - * If there is a syntax error position, convert to internal syntax - * error + * If there is a syntax error position, convert to internal syntax error */ syntaxerrposition = geterrposition(); if (syntaxerrposition > 0) @@ -776,11 +772,11 @@ sql_exec_error_callback(void *arg) } /* - * Try to determine where in the function we failed. If there is a - * query with non-null QueryDesc, finger it. (We check this rather - * than looking for F_EXEC_RUN state, so that errors during - * ExecutorStart or ExecutorEnd are blamed on the appropriate query; - * see postquel_start and postquel_end.) + * Try to determine where in the function we failed. If there is a query + * with non-null QueryDesc, finger it. (We check this rather than looking + * for F_EXEC_RUN state, so that errors during ExecutorStart or + * ExecutorEnd are blamed on the appropriate query; see postquel_start and + * postquel_end.) */ if (fcache) { @@ -888,9 +884,9 @@ check_sql_fn_retval(Oid func_id, Oid rettype, List *queryTreeList, if (rettype != VOIDOID) ereport(ERROR, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), - errmsg("return type mismatch in function declared to return %s", - format_type_be(rettype)), - errdetail("Function's final statement must be a SELECT."))); + errmsg("return type mismatch in function declared to return %s", + format_type_be(rettype)), + errdetail("Function's final statement must be a SELECT."))); return false; } @@ -901,17 +897,16 @@ check_sql_fn_retval(Oid func_id, Oid rettype, List *queryTreeList, tlist = parse->targetList; /* - * The last query must be a SELECT if and only if return type isn't - * VOID. + * The last query must be a SELECT if and only if return type isn't VOID. */ if (rettype == VOIDOID) { if (cmd == CMD_SELECT) ereport(ERROR, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), - errmsg("return type mismatch in function declared to return %s", - format_type_be(rettype)), - errdetail("Function's final statement must not be a SELECT."))); + errmsg("return type mismatch in function declared to return %s", + format_type_be(rettype)), + errdetail("Function's final statement must not be a SELECT."))); return false; } @@ -919,9 +914,9 @@ check_sql_fn_retval(Oid func_id, Oid rettype, List *queryTreeList, if (cmd != CMD_SELECT) ereport(ERROR, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), - errmsg("return type mismatch in function declared to return %s", - format_type_be(rettype)), - errdetail("Function's final statement must be a SELECT."))); + errmsg("return type mismatch in function declared to return %s", + format_type_be(rettype)), + errdetail("Function's final statement must be a SELECT."))); /* * Count the non-junk entries in the result targetlist. @@ -934,22 +929,22 @@ check_sql_fn_retval(Oid func_id, Oid rettype, List *queryTreeList, { /* * For base-type returns, the target list should have exactly one - * entry, and its type should agree with what the user declared. - * (As of Postgres 7.2, we accept binary-compatible types too.) + * entry, and its type should agree with what the user declared. (As + * of Postgres 7.2, we accept binary-compatible types too.) */ if (tlistlen != 1) ereport(ERROR, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), - errmsg("return type mismatch in function declared to return %s", - format_type_be(rettype)), - errdetail("Final SELECT must return exactly one column."))); + errmsg("return type mismatch in function declared to return %s", + format_type_be(rettype)), + errdetail("Final SELECT must return exactly one column."))); restype = exprType((Node *) ((TargetEntry *) linitial(tlist))->expr); if (!IsBinaryCoercible(restype, rettype)) ereport(ERROR, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), - errmsg("return type mismatch in function declared to return %s", - format_type_be(rettype)), + errmsg("return type mismatch in function declared to return %s", + format_type_be(rettype)), errdetail("Actual return type is %s.", format_type_be(restype)))); } @@ -957,16 +952,16 @@ check_sql_fn_retval(Oid func_id, Oid rettype, List *queryTreeList, { /* Returns a rowtype */ TupleDesc tupdesc; - int tupnatts; /* physical number of columns in tuple */ - int tuplogcols; /* # of nondeleted columns in tuple */ - int colindex; /* physical column index */ + int tupnatts; /* physical number of columns in tuple */ + int tuplogcols; /* # of nondeleted columns in tuple */ + int colindex; /* physical column index */ /* - * If the target list is of length 1, and the type of the varnode - * in the target list matches the declared return type, this is - * okay. This can happen, for example, where the body of the - * function is 'SELECT func2()', where func2 has the same return - * type as the function that's calling it. + * If the target list is of length 1, and the type of the varnode in + * the target list matches the declared return type, this is okay. + * This can happen, for example, where the body of the function is + * 'SELECT func2()', where func2 has the same return type as the + * function that's calling it. */ if (tlistlen == 1) { @@ -979,9 +974,8 @@ check_sql_fn_retval(Oid func_id, Oid rettype, List *queryTreeList, if (get_func_result_type(func_id, NULL, &tupdesc) != TYPEFUNC_COMPOSITE) { /* - * Assume we are returning the whole tuple. - * Crosschecking against what the caller expects will happen at - * runtime. + * Assume we are returning the whole tuple. Crosschecking against + * what the caller expects will happen at runtime. */ if (junkFilter) *junkFilter = ExecInitJunkFilter(tlist, false, NULL); @@ -990,9 +984,9 @@ check_sql_fn_retval(Oid func_id, Oid rettype, List *queryTreeList, Assert(tupdesc); /* - * Verify that the targetlist matches the return tuple type. - * We scan the non-deleted attributes to ensure that they match the - * datatypes of the non-resjunk columns. + * Verify that the targetlist matches the return tuple type. We scan + * the non-deleted attributes to ensure that they match the datatypes + * of the non-resjunk columns. */ tupnatts = tupdesc->natts; tuplogcols = 0; /* we'll count nondeleted cols as we go */ @@ -1016,7 +1010,7 @@ check_sql_fn_retval(Oid func_id, Oid rettype, List *queryTreeList, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), errmsg("return type mismatch in function declared to return %s", format_type_be(rettype)), - errdetail("Final SELECT returns too many columns."))); + errdetail("Final SELECT returns too many columns."))); attr = tupdesc->attrs[colindex - 1]; } while (attr->attisdropped); tuplogcols++; @@ -1046,15 +1040,15 @@ check_sql_fn_retval(Oid func_id, Oid rettype, List *queryTreeList, if (tlistlen != tuplogcols) ereport(ERROR, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), - errmsg("return type mismatch in function declared to return %s", - format_type_be(rettype)), + errmsg("return type mismatch in function declared to return %s", + format_type_be(rettype)), errdetail("Final SELECT returns too few columns."))); /* Set up junk filter if needed */ if (junkFilter) *junkFilter = ExecInitJunkFilterConversion(tlist, - CreateTupleDescCopy(tupdesc), - NULL); + CreateTupleDescCopy(tupdesc), + NULL); /* Report that we are returning entire tuple result */ return true; @@ -1070,8 +1064,8 @@ check_sql_fn_retval(Oid func_id, Oid rettype, List *queryTreeList, else ereport(ERROR, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), - errmsg("return type %s is not supported for SQL functions", - format_type_be(rettype)))); + errmsg("return type %s is not supported for SQL functions", + format_type_be(rettype)))); return false; } diff --git a/src/backend/executor/instrument.c b/src/backend/executor/instrument.c index c5b4a252d6..08d35c1616 100644 --- a/src/backend/executor/instrument.c +++ b/src/backend/executor/instrument.c @@ -7,7 +7,7 @@ * Copyright (c) 2001-2005, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/instrument.c,v 1.12 2005/04/16 20:07:35 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/instrument.c,v 1.13 2005/10/15 02:49:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -43,7 +43,7 @@ InstrStartNode(Instrumentation *instr) void InstrStopNode(Instrumentation *instr, bool returnedTuple) { - instr_time endtime; + instr_time endtime; /* count the returned tuples */ if (returnedTuple) @@ -72,7 +72,7 @@ InstrStopNode(Instrumentation *instr, bool returnedTuple) instr->counter.tv_usec -= 1000000; instr->counter.tv_sec++; } -#else /* WIN32 */ +#else /* WIN32 */ instr->counter.QuadPart += (endtime.QuadPart - instr->starttime.QuadPart); #endif diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c index b7a0bc344f..0403c9aca1 100644 --- a/src/backend/executor/nodeAgg.c +++ b/src/backend/executor/nodeAgg.c @@ -53,7 +53,7 @@ * pass-by-ref inputs, but in the aggregate case we know the left input is * either the initial transition value or a previous function result, and * in either case its value need not be preserved. See int8inc() for an - * example. Notice that advance_transition_function() is coded to avoid a + * example. Notice that advance_transition_function() is coded to avoid a * data copy step when the previous transition value pointer is returned. * * @@ -61,7 +61,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/nodeAgg.c,v 1.134 2005/06/28 05:08:55 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/nodeAgg.c,v 1.135 2005/10/15 02:49:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -109,8 +109,8 @@ typedef struct AggStatePerAggData /* * fmgr lookup data for transfer functions --- only valid when - * corresponding oid is not InvalidOid. Note in particular that - * fn_strict flags are kept here. + * corresponding oid is not InvalidOid. Note in particular that fn_strict + * flags are kept here. */ FmgrInfo transfn; FmgrInfo finalfn; @@ -124,8 +124,8 @@ typedef struct AggStatePerAggData Oid sortOperator; /* - * fmgr lookup data for input type's equality operator --- only - * set/used when aggregate has DISTINCT flag. + * fmgr lookup data for input type's equality operator --- only set/used + * when aggregate has DISTINCT flag. */ FmgrInfo equalfn; @@ -147,14 +147,14 @@ typedef struct AggStatePerAggData transtypeByVal; /* - * These values are working state that is initialized at the start of - * an input tuple group and updated for each input tuple. + * These values are working state that is initialized at the start of an + * input tuple group and updated for each input tuple. * * For a simple (non DISTINCT) aggregate, we just feed the input values * straight to the transition function. If it's DISTINCT, we pass the - * input values into a Tuplesort object; then at completion of the - * input tuple group, we scan the sorted values, eliminate duplicates, - * and run the transition function on the rest. + * input values into a Tuplesort object; then at completion of the input + * tuple group, we scan the sorted values, eliminate duplicates, and run + * the transition function on the rest. */ Tuplesortstate *sortstate; /* sort object, if a DISTINCT agg */ @@ -184,12 +184,11 @@ typedef struct AggStatePerGroupData bool noTransValue; /* true if transValue not set yet */ /* - * Note: noTransValue initially has the same value as - * transValueIsNull, and if true both are cleared to false at the same - * time. They are not the same though: if transfn later returns a - * NULL, we want to keep that NULL and not auto-replace it with a - * later input value. Only the first non-NULL input will be - * auto-substituted. + * Note: noTransValue initially has the same value as transValueIsNull, + * and if true both are cleared to false at the same time. They are not + * the same though: if transfn later returns a NULL, we want to keep that + * NULL and not auto-replace it with a later input value. Only the first + * non-NULL input will be auto-substituted. */ } AggStatePerGroupData; @@ -270,11 +269,11 @@ initialize_aggregates(AggState *aggstate, } /* - * If we are reinitializing after a group boundary, we have to - * free any prior transValue to avoid memory leakage. We must - * check not only the isnull flag but whether the pointer is NULL; - * since pergroupstate is initialized with palloc0, the initial - * condition has isnull = 0 and null pointer. + * If we are reinitializing after a group boundary, we have to free + * any prior transValue to avoid memory leakage. We must check not + * only the isnull flag but whether the pointer is NULL; since + * pergroupstate is initialized with palloc0, the initial condition + * has isnull = 0 and null pointer. */ if (!peraggstate->transtypeByVal && !pergroupstate->transValueIsNull && @@ -284,8 +283,8 @@ initialize_aggregates(AggState *aggstate, /* * (Re)set transValue to the initial value. * - * Note that when the initial value is pass-by-ref, we must copy it - * (into the aggcontext) since we will pfree the transValue later. + * Note that when the initial value is pass-by-ref, we must copy it (into + * the aggcontext) since we will pfree the transValue later. */ if (peraggstate->initValueIsNull) pergroupstate->transValue = peraggstate->initValue; @@ -295,18 +294,18 @@ initialize_aggregates(AggState *aggstate, oldContext = MemoryContextSwitchTo(aggstate->aggcontext); pergroupstate->transValue = datumCopy(peraggstate->initValue, - peraggstate->transtypeByVal, - peraggstate->transtypeLen); + peraggstate->transtypeByVal, + peraggstate->transtypeLen); MemoryContextSwitchTo(oldContext); } pergroupstate->transValueIsNull = peraggstate->initValueIsNull; /* - * If the initial value for the transition state doesn't exist in - * the pg_aggregate table then we will let the first non-NULL - * value returned from the outer procNode become the initial - * value. (This is useful for aggregates like max() and min().) - * The noTransValue flag signals that we still need to do this. + * If the initial value for the transition state doesn't exist in the + * pg_aggregate table then we will let the first non-NULL value + * returned from the outer procNode become the initial value. (This is + * useful for aggregates like max() and min().) The noTransValue flag + * signals that we still need to do this. */ pergroupstate->noTransValue = peraggstate->initValueIsNull; } @@ -337,20 +336,18 @@ advance_transition_function(AggState *aggstate, if (pergroupstate->noTransValue) { /* - * transValue has not been initialized. This is the first - * non-NULL input value. We use it as the initial value for - * transValue. (We already checked that the agg's input type - * is binary-compatible with its transtype, so straight copy - * here is OK.) + * transValue has not been initialized. This is the first non-NULL + * input value. We use it as the initial value for transValue. (We + * already checked that the agg's input type is binary-compatible + * with its transtype, so straight copy here is OK.) * - * We must copy the datum into aggcontext if it is pass-by-ref. - * We do not need to pfree the old transValue, since it's - * NULL. + * We must copy the datum into aggcontext if it is pass-by-ref. We do + * not need to pfree the old transValue, since it's NULL. */ oldContext = MemoryContextSwitchTo(aggstate->aggcontext); pergroupstate->transValue = datumCopy(newVal, - peraggstate->transtypeByVal, - peraggstate->transtypeLen); + peraggstate->transtypeByVal, + peraggstate->transtypeLen); pergroupstate->transValueIsNull = false; pergroupstate->noTransValue = false; MemoryContextSwitchTo(oldContext); @@ -360,10 +357,9 @@ advance_transition_function(AggState *aggstate, { /* * Don't call a strict function with NULL inputs. Note it is - * possible to get here despite the above tests, if the - * transfn is strict *and* returned a NULL on a prior cycle. - * If that happens we will propagate the NULL all the way to - * the end. + * possible to get here despite the above tests, if the transfn is + * strict *and* returned a NULL on a prior cycle. If that happens + * we will propagate the NULL all the way to the end. */ return; } @@ -385,12 +381,12 @@ advance_transition_function(AggState *aggstate, newVal = FunctionCallInvoke(&fcinfo); /* - * If pass-by-ref datatype, must copy the new value into aggcontext - * and pfree the prior transValue. But if transfn returned a pointer - * to its first input, we don't need to do anything. + * If pass-by-ref datatype, must copy the new value into aggcontext and + * pfree the prior transValue. But if transfn returned a pointer to its + * first input, we don't need to do anything. */ if (!peraggstate->transtypeByVal && - DatumGetPointer(newVal) != DatumGetPointer(pergroupstate->transValue)) + DatumGetPointer(newVal) != DatumGetPointer(pergroupstate->transValue)) { if (!fcinfo.isnull) { @@ -473,24 +469,24 @@ process_sorted_aggregate(AggState *aggstate, tuplesort_performsort(peraggstate->sortstate); /* - * Note: if input type is pass-by-ref, the datums returned by the sort - * are freshly palloc'd in the per-query context, so we must be - * careful to pfree them when they are no longer needed. + * Note: if input type is pass-by-ref, the datums returned by the sort are + * freshly palloc'd in the per-query context, so we must be careful to + * pfree them when they are no longer needed. */ while (tuplesort_getdatum(peraggstate->sortstate, true, &newVal, &isNull)) { /* - * DISTINCT always suppresses nulls, per SQL spec, regardless of - * the transition function's strictness. + * DISTINCT always suppresses nulls, per SQL spec, regardless of the + * transition function's strictness. */ if (isNull) continue; /* - * Clear and select the working context for evaluation of the - * equality function and transition function. + * Clear and select the working context for evaluation of the equality + * function and transition function. */ MemoryContextReset(workcontext); oldContext = MemoryContextSwitchTo(workcontext); @@ -726,8 +722,8 @@ agg_retrieve_direct(AggState *aggstate) while (!aggstate->agg_done) { /* - * If we don't already have the first tuple of the new group, - * fetch it from the outer plan. + * If we don't already have the first tuple of the new group, fetch it + * from the outer plan. */ if (aggstate->grp_firstTuple == NULL) { @@ -735,8 +731,8 @@ agg_retrieve_direct(AggState *aggstate) if (!TupIsNull(outerslot)) { /* - * Make a copy of the first input tuple; we will use this - * for comparisons (in group mode) and for projection. + * Make a copy of the first input tuple; we will use this for + * comparisons (in group mode) and for projection. */ aggstate->grp_firstTuple = ExecCopySlotTuple(outerslot); } @@ -764,8 +760,8 @@ agg_retrieve_direct(AggState *aggstate) { /* * Store the copied first input tuple in the tuple table slot - * reserved for it. The tuple will be deleted when it is - * cleared from the slot. + * reserved for it. The tuple will be deleted when it is cleared + * from the slot. */ ExecStoreTuple(aggstate->grp_firstTuple, firstSlot, @@ -807,7 +803,7 @@ agg_retrieve_direct(AggState *aggstate) outerslot, node->numCols, node->grpColIdx, aggstate->eqfunctions, - tmpcontext->ecxt_per_tuple_memory)) + tmpcontext->ecxt_per_tuple_memory)) { /* * Save the first input tuple of the next group. @@ -838,17 +834,16 @@ agg_retrieve_direct(AggState *aggstate) /* * If we have no first tuple (ie, the outerPlan didn't return * anything), create a dummy all-nulls input tuple for use by - * ExecQual/ExecProject. 99.44% of the time this is a waste of - * cycles, because ordinarily the projected output tuple's - * targetlist cannot contain any direct (non-aggregated) - * references to input columns, so the dummy tuple will not be - * referenced. However there are special cases where this isn't so - * --- in particular an UPDATE involving an aggregate will have a - * targetlist reference to ctid. We need to return a null for - * ctid in that situation, not coredump. + * ExecQual/ExecProject. 99.44% of the time this is a waste of cycles, + * because ordinarily the projected output tuple's targetlist cannot + * contain any direct (non-aggregated) references to input columns, so + * the dummy tuple will not be referenced. However there are special + * cases where this isn't so --- in particular an UPDATE involving an + * aggregate will have a targetlist reference to ctid. We need to + * return a null for ctid in that situation, not coredump. * - * The values returned for the aggregates will be the initial values - * of the transition functions. + * The values returned for the aggregates will be the initial values of + * the transition functions. */ if (TupIsNull(firstSlot)) { @@ -866,15 +861,15 @@ agg_retrieve_direct(AggState *aggstate) econtext->ecxt_scantuple = firstSlot; /* - * Check the qual (HAVING clause); if the group does not match, - * ignore it and loop back to try to process another group. + * Check the qual (HAVING clause); if the group does not match, ignore + * it and loop back to try to process another group. */ if (ExecQual(aggstate->ss.ps.qual, econtext, false)) { /* - * Form and return a projection tuple using the aggregate - * results and the representative input tuple. Note we do not - * support aggregates returning sets ... + * Form and return a projection tuple using the aggregate results + * and the representative input tuple. Note we do not support + * aggregates returning sets ... */ return ExecProject(projInfo, NULL); } @@ -903,8 +898,8 @@ agg_fill_hash_table(AggState *aggstate) tmpcontext = aggstate->tmpcontext; /* - * Process each outer-plan tuple, and then fetch the next one, until - * we exhaust the outer plan. + * Process each outer-plan tuple, and then fetch the next one, until we + * exhaust the outer plan. */ for (;;) { @@ -979,8 +974,8 @@ agg_retrieve_hash_table(AggState *aggstate) ResetExprContext(econtext); /* - * Store the copied first input tuple in the tuple table slot - * reserved for it, so that it can be used in ExecProject. + * Store the copied first input tuple in the tuple table slot reserved + * for it, so that it can be used in ExecProject. */ ExecStoreTuple(entry->shared.firstTuple, firstSlot, @@ -1010,15 +1005,15 @@ agg_retrieve_hash_table(AggState *aggstate) econtext->ecxt_scantuple = firstSlot; /* - * Check the qual (HAVING clause); if the group does not match, - * ignore it and loop back to try to process another group. + * Check the qual (HAVING clause); if the group does not match, ignore + * it and loop back to try to process another group. */ if (ExecQual(aggstate->ss.ps.qual, econtext, false)) { /* - * Form and return a projection tuple using the aggregate - * results and the representative input tuple. Note we do not - * support aggregates returning sets ... + * Form and return a projection tuple using the aggregate results + * and the representative input tuple. Note we do not support + * aggregates returning sets ... */ return ExecProject(projInfo, NULL); } @@ -1065,8 +1060,8 @@ ExecInitAgg(Agg *node, EState *estate) /* * Create expression contexts. We need two, one for per-input-tuple - * processing and one for per-output-tuple processing. We cheat a - * little by using ExecAssignExprContext() to build both. + * processing and one for per-output-tuple processing. We cheat a little + * by using ExecAssignExprContext() to build both. */ ExecAssignExprContext(estate, &aggstate->ss.ps); aggstate->tmpcontext = aggstate->ss.ps.ps_ExprContext; @@ -1074,10 +1069,10 @@ ExecInitAgg(Agg *node, EState *estate) /* * We also need a long-lived memory context for holding hashtable data - * structures and transition values. NOTE: the details of what is - * stored in aggcontext and what is stored in the regular per-query - * memory context are driven by a simple decision: we want to reset - * the aggcontext in ExecReScanAgg to recover no-longer-wanted space. + * structures and transition values. NOTE: the details of what is stored + * in aggcontext and what is stored in the regular per-query memory + * context are driven by a simple decision: we want to reset the + * aggcontext in ExecReScanAgg to recover no-longer-wanted space. */ aggstate->aggcontext = AllocSetContextCreate(CurrentMemoryContext, @@ -1098,10 +1093,10 @@ ExecInitAgg(Agg *node, EState *estate) * initialize child expressions * * Note: ExecInitExpr finds Aggrefs for us, and also checks that no aggs - * contain other agg calls in their arguments. This would make no - * sense under SQL semantics anyway (and it's forbidden by the spec). - * Because that is true, we don't need to worry about evaluating the - * aggs in any particular order. + * contain other agg calls in their arguments. This would make no sense + * under SQL semantics anyway (and it's forbidden by the spec). Because + * that is true, we don't need to worry about evaluating the aggs in any + * particular order. */ aggstate->ss.ps.targetlist = (List *) ExecInitExpr((Expr *) node->plan.targetlist, @@ -1135,20 +1130,19 @@ ExecInitAgg(Agg *node, EState *estate) if (numaggs <= 0) { /* - * This is not an error condition: we might be using the Agg node - * just to do hash-based grouping. Even in the regular case, - * constant-expression simplification could optimize away all of - * the Aggrefs in the targetlist and qual. So keep going, but - * force local copy of numaggs positive so that palloc()s below - * don't choke. + * This is not an error condition: we might be using the Agg node just + * to do hash-based grouping. Even in the regular case, + * constant-expression simplification could optimize away all of the + * Aggrefs in the targetlist and qual. So keep going, but force local + * copy of numaggs positive so that palloc()s below don't choke. */ numaggs = 1; } /* - * If we are grouping, precompute fmgr lookup data for inner loop. We - * need both equality and hashing functions to do it by hashing, but - * only equality if not hashing. + * If we are grouping, precompute fmgr lookup data for inner loop. We need + * both equality and hashing functions to do it by hashing, but only + * equality if not hashing. */ if (node->numCols > 0) { @@ -1166,8 +1160,8 @@ ExecInitAgg(Agg *node, EState *estate) } /* - * Set up aggregate-result storage in the output expr context, and - * also allocate my private per-agg working storage + * Set up aggregate-result storage in the output expr context, and also + * allocate my private per-agg working storage */ econtext = aggstate->ss.ps.ps_ExprContext; econtext->ecxt_aggvalues = (Datum *) palloc0(sizeof(Datum) * numaggs); @@ -1192,10 +1186,10 @@ ExecInitAgg(Agg *node, EState *estate) /* * Perform lookups of aggregate function info, and initialize the * unchanging fields of the per-agg data. We also detect duplicate - * aggregates (for example, "SELECT sum(x) ... HAVING sum(x) > 0"). - * When duplicates are detected, we only make an AggStatePerAgg struct - * for the first one. The clones are simply pointed at the same - * result entry by giving them duplicate aggno values. + * aggregates (for example, "SELECT sum(x) ... HAVING sum(x) > 0"). When + * duplicates are detected, we only make an AggStatePerAgg struct for the + * first one. The clones are simply pointed at the same result entry by + * giving them duplicate aggno values. */ aggno = -1; foreach(l, aggstate->aggs) @@ -1243,9 +1237,9 @@ ExecInitAgg(Agg *node, EState *estate) peraggstate->aggref = aggref; /* - * Get actual datatype of the input. We need this because it may - * be different from the agg's declared input type, when the agg - * accepts ANY (eg, COUNT(*)) or ANYARRAY or ANYELEMENT. + * Get actual datatype of the input. We need this because it may be + * different from the agg's declared input type, when the agg accepts + * ANY (eg, COUNT(*)) or ANYARRAY or ANYELEMENT. */ inputType = exprType((Node *) aggref->target); @@ -1270,7 +1264,7 @@ ExecInitAgg(Agg *node, EState *estate) /* Check that aggregate owner has permission to call component fns */ { HeapTuple procTuple; - Oid aggOwner; + Oid aggOwner; procTuple = SearchSysCache(PROCOID, ObjectIdGetDatum(aggref->aggfnoid), @@ -1339,8 +1333,8 @@ ExecInitAgg(Agg *node, EState *estate) &peraggstate->transtypeByVal); /* - * initval is potentially null, so don't try to access it as a - * struct field. Must do it the hard way with SysCacheGetAttr. + * initval is potentially null, so don't try to access it as a struct + * field. Must do it the hard way with SysCacheGetAttr. */ textInitVal = SysCacheGetAttr(AGGFNOID, aggTuple, Anum_pg_aggregate_agginitval, @@ -1353,11 +1347,11 @@ ExecInitAgg(Agg *node, EState *estate) aggtranstype); /* - * If the transfn is strict and the initval is NULL, make sure - * input type and transtype are the same (or at least binary- - * compatible), so that it's OK to use the first input value as - * the initial transValue. This should have been checked at agg - * definition time, but just in case... + * If the transfn is strict and the initval is NULL, make sure input + * type and transtype are the same (or at least binary- compatible), + * so that it's OK to use the first input value as the initial + * transValue. This should have been checked at agg definition time, + * but just in case... */ if (peraggstate->transfn.fn_strict && peraggstate->initValueIsNull) { @@ -1463,18 +1457,18 @@ ExecReScanAgg(AggState *node, ExprContext *exprCtxt) if (((Agg *) node->ss.ps.plan)->aggstrategy == AGG_HASHED) { /* - * In the hashed case, if we haven't yet built the hash table then - * we can just return; nothing done yet, so nothing to undo. If - * subnode's chgParam is not NULL then it will be re-scanned by - * ExecProcNode, else no reason to re-scan it at all. + * In the hashed case, if we haven't yet built the hash table then we + * can just return; nothing done yet, so nothing to undo. If subnode's + * chgParam is not NULL then it will be re-scanned by ExecProcNode, + * else no reason to re-scan it at all. */ if (!node->table_filled) return; /* * If we do have the hash table and the subplan does not have any - * parameter changes, then we can just rescan the existing hash - * table; no need to build it again. + * parameter changes, then we can just rescan the existing hash table; + * no need to build it again. */ if (((PlanState *) node)->lefttree->chgParam == NULL) { @@ -1516,8 +1510,7 @@ ExecReScanAgg(AggState *node, ExprContext *exprCtxt) else { /* - * Reset the per-group state (in particular, mark transvalues - * null) + * Reset the per-group state (in particular, mark transvalues null) */ MemSet(node->pergroup, 0, sizeof(AggStatePerGroupData) * node->numaggs); diff --git a/src/backend/executor/nodeAppend.c b/src/backend/executor/nodeAppend.c index b88eec46a4..fc5c445db0 100644 --- a/src/backend/executor/nodeAppend.c +++ b/src/backend/executor/nodeAppend.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/nodeAppend.c,v 1.64 2005/05/22 22:30:19 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/nodeAppend.c,v 1.65 2005/10/15 02:49:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -88,10 +88,9 @@ exec_append_initialize_next(AppendState *appendstate) if (whichplan < appendstate->as_firstplan) { /* - * if scanning in reverse, we start at the last scan in the list - * and then proceed back to the first.. in any case we inform - * ExecAppend that we are at the end of the line by returning - * FALSE + * if scanning in reverse, we start at the last scan in the list and + * then proceed back to the first.. in any case we inform ExecAppend + * that we are at the end of the line by returning FALSE */ appendstate->as_whichplan = appendstate->as_firstplan; return FALSE; @@ -99,8 +98,7 @@ exec_append_initialize_next(AppendState *appendstate) else if (whichplan > appendstate->as_lastplan) { /* - * as above, end the scan if we go beyond the last scan in our - * list.. + * as above, end the scan if we go beyond the last scan in our list.. */ appendstate->as_whichplan = appendstate->as_lastplan; return FALSE; @@ -110,8 +108,8 @@ exec_append_initialize_next(AppendState *appendstate) /* * initialize the scan * - * If we are controlling the target relation, select the proper - * active ResultRelInfo and junk filter for this target. + * If we are controlling the target relation, select the proper active + * ResultRelInfo and junk filter for this target. */ if (((Append *) appendstate->ps.plan)->isTarget) { @@ -168,9 +166,8 @@ ExecInitAppend(Append *node, EState *estate) appendstate->as_nplans = nplans; /* - * Do we want to scan just one subplan? (Special case for - * EvalPlanQual) XXX pretty dirty way of determining that this case - * applies ... + * Do we want to scan just one subplan? (Special case for EvalPlanQual) + * XXX pretty dirty way of determining that this case applies ... */ if (node->isTarget && estate->es_evTuple != NULL) { @@ -199,8 +196,8 @@ ExecInitAppend(Append *node, EState *estate) #define APPEND_NSLOTS 1 /* - * append nodes still have Result slots, which hold pointers to - * tuples, so we have to initialize them. + * append nodes still have Result slots, which hold pointers to tuples, so + * we have to initialize them. */ ExecInitResultTupleSlot(estate, &appendstate->ps); @@ -220,10 +217,10 @@ ExecInitAppend(Append *node, EState *estate) } /* - * Initialize tuple type. (Note: in an inherited UPDATE situation, - * the tuple type computed here corresponds to the parent table, which - * is really a lie since tuples returned from child subplans will not - * all look the same.) + * Initialize tuple type. (Note: in an inherited UPDATE situation, the + * tuple type computed here corresponds to the parent table, which is + * really a lie since tuples returned from child subplans will not all + * look the same.) */ ExecAssignResultTypeFromTL(&appendstate->ps); appendstate->ps.ps_ProjInfo = NULL; @@ -275,19 +272,19 @@ ExecAppend(AppendState *node) if (!TupIsNull(result)) { /* - * If the subplan gave us something then return it as-is. - * We do NOT make use of the result slot that was set up in - * ExecInitAppend, first because there's no reason to and - * second because it may have the wrong tuple descriptor in + * If the subplan gave us something then return it as-is. We do + * NOT make use of the result slot that was set up in + * ExecInitAppend, first because there's no reason to and second + * because it may have the wrong tuple descriptor in * inherited-UPDATE cases. */ return result; } /* - * Go on to the "next" subplan in the appropriate direction. - * If no more subplans, return the empty slot set up for us - * by ExecInitAppend. + * Go on to the "next" subplan in the appropriate direction. If no + * more subplans, return the empty slot set up for us by + * ExecInitAppend. */ if (ScanDirectionIsForward(node->ps.state->es_direction)) node->as_whichplan++; @@ -348,8 +345,8 @@ ExecReScanAppend(AppendState *node, ExprContext *exprCtxt) UpdateChangedParamSet(subnode, node->ps.chgParam); /* - * if chgParam of subnode is not null then plan will be re-scanned - * by first ExecProcNode. + * if chgParam of subnode is not null then plan will be re-scanned by + * first ExecProcNode. */ if (subnode->chgParam == NULL) { diff --git a/src/backend/executor/nodeBitmapAnd.c b/src/backend/executor/nodeBitmapAnd.c index 939062d4d6..a9e63cbfcc 100644 --- a/src/backend/executor/nodeBitmapAnd.c +++ b/src/backend/executor/nodeBitmapAnd.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/nodeBitmapAnd.c,v 1.3 2005/08/28 22:47:20 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/nodeBitmapAnd.c,v 1.4 2005/10/15 02:49:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -16,7 +16,7 @@ * ExecInitBitmapAnd - initialize the BitmapAnd node * MultiExecBitmapAnd - retrieve the result bitmap from the node * ExecEndBitmapAnd - shut down the BitmapAnd node - * ExecReScanBitmapAnd - rescan the BitmapAnd node + * ExecReScanBitmapAnd - rescan the BitmapAnd node * * NOTES * BitmapAnd nodes don't make use of their left and right @@ -137,7 +137,7 @@ MultiExecBitmapAnd(BitmapAndState *node) elog(ERROR, "unrecognized result from subplan"); if (result == NULL) - result = subresult; /* first subplan */ + result = subresult; /* first subplan */ else { tbm_intersect(result, subresult); @@ -145,11 +145,11 @@ MultiExecBitmapAnd(BitmapAndState *node) } /* - * If at any stage we have a completely empty bitmap, we can fall - * out without evaluating the remaining subplans, since ANDing them - * can no longer change the result. (Note: the fact that indxpath.c - * orders the subplans by selectivity should make this case more - * likely to occur.) + * If at any stage we have a completely empty bitmap, we can fall out + * without evaluating the remaining subplans, since ANDing them can no + * longer change the result. (Note: the fact that indxpath.c orders + * the subplans by selectivity should make this case more likely to + * occur.) */ if (tbm_is_empty(result)) break; @@ -160,7 +160,7 @@ MultiExecBitmapAnd(BitmapAndState *node) /* must provide our own instrumentation support */ if (node->ps.instrument) - InstrStopNodeMulti(node->ps.instrument, 0 /* XXX */); + InstrStopNodeMulti(node->ps.instrument, 0 /* XXX */ ); return (Node *) result; } diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c index 3c3c1fd96f..5d92c19ea5 100644 --- a/src/backend/executor/nodeBitmapHeapscan.c +++ b/src/backend/executor/nodeBitmapHeapscan.c @@ -5,7 +5,7 @@ * * NOTE: it is critical that this plan type only be used with MVCC-compliant * snapshots (ie, regular snapshots, not SnapshotNow or one of the other - * special snapshots). The reason is that since index and heap scans are + * special snapshots). The reason is that since index and heap scans are * decoupled, there can be no assurance that the index tuple prompting a * visit to a particular heap TID still exists when the visit is made. * Therefore the tuple might not exist anymore either (which is OK because @@ -21,7 +21,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/nodeBitmapHeapscan.c,v 1.3 2005/10/06 02:29:16 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/nodeBitmapHeapscan.c,v 1.4 2005/10/15 02:49:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -76,11 +76,11 @@ BitmapHeapNext(BitmapHeapScanState *node) tbmres = node->tbmres; /* - * Clear any reference to the previously returned tuple. The idea - * here is to not have the tuple slot be the last holder of a pin on - * that tuple's buffer; if it is, we'll need a separate visit to the - * bufmgr to release the buffer. By clearing here, we get to have the - * release done by ReleaseAndReadBuffer, below. + * Clear any reference to the previously returned tuple. The idea here is + * to not have the tuple slot be the last holder of a pin on that tuple's + * buffer; if it is, we'll need a separate visit to the bufmgr to release + * the buffer. By clearing here, we get to have the release done by + * ReleaseAndReadBuffer, below. */ ExecClearTuple(slot); @@ -105,7 +105,7 @@ BitmapHeapNext(BitmapHeapScanState *node) ResetExprContext(econtext); if (!ExecQual(node->bitmapqualorig, econtext, false)) - ExecClearTuple(slot); /* would not be returned by scan */ + ExecClearTuple(slot); /* would not be returned by scan */ /* Flag for the next call that no more tuples */ estate->es_evTupleNull[scanrelid - 1] = true; @@ -114,8 +114,8 @@ BitmapHeapNext(BitmapHeapScanState *node) } /* - * If we haven't yet performed the underlying index scan, do it, - * and prepare the bitmap to be iterated over. + * If we haven't yet performed the underlying index scan, do it, and + * prepare the bitmap to be iterated over. */ if (tbm == NULL) { @@ -145,10 +145,10 @@ BitmapHeapNext(BitmapHeapScanState *node) } /* - * Ignore any claimed entries past what we think is the end of - * the relation. (This is probably not necessary given that we - * got AccessShareLock before performing any of the indexscans, - * but let's be safe.) + * Ignore any claimed entries past what we think is the end of the + * relation. (This is probably not necessary given that we got + * AccessShareLock before performing any of the indexscans, but + * let's be safe.) */ if (tbmres->blockno >= scandesc->rs_nblocks) { @@ -157,19 +157,18 @@ BitmapHeapNext(BitmapHeapScanState *node) } /* - * Acquire pin on the current heap page. We'll hold the pin - * until done looking at the page. We trade in any pin we - * held before. + * Acquire pin on the current heap page. We'll hold the pin until + * done looking at the page. We trade in any pin we held before. */ scandesc->rs_cbuf = ReleaseAndReadBuffer(scandesc->rs_cbuf, scandesc->rs_rd, tbmres->blockno); /* - * Determine how many entries we need to look at on this page. - * If the bitmap is lossy then we need to look at each physical - * item pointer; otherwise we just look through the offsets - * listed in tbmres. + * Determine how many entries we need to look at on this page. If + * the bitmap is lossy then we need to look at each physical item + * pointer; otherwise we just look through the offsets listed in + * tbmres. */ if (tbmres->ntuples >= 0) { @@ -180,7 +179,7 @@ BitmapHeapNext(BitmapHeapScanState *node) else { /* lossy case */ - Page dp; + Page dp; LockBuffer(scandesc->rs_cbuf, BUFFER_LOCK_SHARE); dp = (Page) BufferGetPage(scandesc->rs_cbuf); @@ -230,8 +229,8 @@ BitmapHeapNext(BitmapHeapScanState *node) ItemPointerSet(&scandesc->rs_ctup.t_self, tbmres->blockno, targoffset); /* - * Fetch the heap tuple and see if it matches the snapshot. - * We use heap_release_fetch to avoid useless bufmgr traffic. + * Fetch the heap tuple and see if it matches the snapshot. We use + * heap_release_fetch to avoid useless bufmgr traffic. */ if (heap_release_fetch(scandesc->rs_rd, scandesc->rs_snapshot, @@ -241,8 +240,8 @@ BitmapHeapNext(BitmapHeapScanState *node) &scandesc->rs_pgstat_info)) { /* - * Set up the result slot to point to this tuple. - * Note that the slot acquires a pin on the buffer. + * Set up the result slot to point to this tuple. Note that the + * slot acquires a pin on the buffer. */ ExecStoreTuple(&scandesc->rs_ctup, slot, @@ -338,8 +337,8 @@ ExecBitmapHeapReScan(BitmapHeapScanState *node, ExprContext *exprCtxt) node->tbmres = NULL; /* - * Always rescan the input immediately, to ensure we can pass down - * any outer tuple that might be used in index quals. + * Always rescan the input immediately, to ensure we can pass down any + * outer tuple that might be used in index quals. */ ExecReScan(outerPlanState(node), exprCtxt); } @@ -391,9 +390,9 @@ ExecEndBitmapHeapScan(BitmapHeapScanState *node) * close the heap relation. * * Currently, we do not release the AccessShareLock acquired by - * ExecInitBitmapHeapScan. This lock should be held till end of - * transaction. (There is a faction that considers this too much - * locking, however.) + * ExecInitBitmapHeapScan. This lock should be held till end of + * transaction. (There is a faction that considers this too much locking, + * however.) */ heap_close(relation, NoLock); } @@ -470,9 +469,9 @@ ExecInitBitmapHeapScan(BitmapHeapScan *node, EState *estate) scanstate->ss.ss_currentRelation = currentRelation; /* - * Even though we aren't going to do a conventional seqscan, it is - * useful to create a HeapScanDesc --- this checks the relation size - * and sets up statistical infrastructure for us. + * Even though we aren't going to do a conventional seqscan, it is useful + * to create a HeapScanDesc --- this checks the relation size and sets up + * statistical infrastructure for us. */ scanstate->ss.ss_currentScanDesc = heap_beginscan(currentRelation, estate->es_snapshot, @@ -482,7 +481,7 @@ ExecInitBitmapHeapScan(BitmapHeapScan *node, EState *estate) /* * One problem is that heap_beginscan counts a "sequential scan" start, * when we actually aren't doing any such thing. Reverse out the added - * scan count. (Eventually we may want to count bitmap scans separately.) + * scan count. (Eventually we may want to count bitmap scans separately.) */ pgstat_discount_heap_scan(&scanstate->ss.ss_currentScanDesc->rs_pgstat_info); diff --git a/src/backend/executor/nodeBitmapIndexscan.c b/src/backend/executor/nodeBitmapIndexscan.c index 231c35b956..49b63170d4 100644 --- a/src/backend/executor/nodeBitmapIndexscan.c +++ b/src/backend/executor/nodeBitmapIndexscan.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/nodeBitmapIndexscan.c,v 1.9 2005/05/06 17:24:54 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/nodeBitmapIndexscan.c,v 1.10 2005/10/15 02:49:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -54,17 +54,16 @@ MultiExecBitmapIndexScan(BitmapIndexScanState *node) scandesc = node->biss_ScanDesc; /* - * If we have runtime keys and they've not already been set up, do it - * now. + * If we have runtime keys and they've not already been set up, do it now. */ if (node->biss_RuntimeKeyInfo && !node->biss_RuntimeKeysReady) ExecReScan((PlanState *) node, NULL); /* * Prepare the result bitmap. Normally we just create a new one to pass - * back; however, our parent node is allowed to store a pre-made one - * into node->biss_result, in which case we just OR our tuple IDs into - * the existing bitmap. (This saves needing explicit UNION steps.) + * back; however, our parent node is allowed to store a pre-made one into + * node->biss_result, in which case we just OR our tuple IDs into the + * existing bitmap. (This saves needing explicit UNION steps.) */ if (node->biss_result) { @@ -82,7 +81,7 @@ MultiExecBitmapIndexScan(BitmapIndexScanState *node) */ for (;;) { - bool more = index_getmulti(scandesc, tids, MAX_TIDS, &ntids); + bool more = index_getmulti(scandesc, tids, MAX_TIDS, &ntids); if (ntids > 0) { @@ -116,8 +115,7 @@ ExecBitmapIndexReScan(BitmapIndexScanState *node, ExprContext *exprCtxt) ExprContext *econtext; ExprState **runtimeKeyInfo; - econtext = node->biss_RuntimeContext; /* context for runtime - * keys */ + econtext = node->biss_RuntimeContext; /* context for runtime keys */ runtimeKeyInfo = node->biss_RuntimeKeyInfo; if (econtext) @@ -130,16 +128,16 @@ ExecBitmapIndexReScan(BitmapIndexScanState *node, ExprContext *exprCtxt) econtext->ecxt_outertuple = exprCtxt->ecxt_outertuple; /* - * Reset the runtime-key context so we don't leak memory as each - * outer tuple is scanned. Note this assumes that we will - * recalculate *all* runtime keys on each call. + * Reset the runtime-key context so we don't leak memory as each outer + * tuple is scanned. Note this assumes that we will recalculate *all* + * runtime keys on each call. */ ResetExprContext(econtext); } /* - * If we are doing runtime key calculations (ie, the index keys depend - * on data from an outer scan), compute the new key values + * If we are doing runtime key calculations (ie, the index keys depend on + * data from an outer scan), compute the new key values */ if (runtimeKeyInfo) { @@ -213,8 +211,8 @@ ExecInitBitmapIndexScan(BitmapIndexScan *node, EState *estate) /* * Miscellaneous initialization * - * We do not need a standard exprcontext for this node, though we may - * decide below to create a runtime-key exprcontext + * We do not need a standard exprcontext for this node, though we may decide + * below to create a runtime-key exprcontext */ /* @@ -252,10 +250,10 @@ ExecInitBitmapIndexScan(BitmapIndexScan *node, EState *estate) indexstate->biss_NumScanKeys = numScanKeys; /* - * If we have runtime keys, we need an ExprContext to evaluate them. - * We could just create a "standard" plan node exprcontext, but to - * keep the code looking similar to nodeIndexscan.c, it seems better - * to stick with the approach of using a separate ExprContext. + * If we have runtime keys, we need an ExprContext to evaluate them. We + * could just create a "standard" plan node exprcontext, but to keep the + * code looking similar to nodeIndexscan.c, it seems better to stick with + * the approach of using a separate ExprContext. */ if (have_runtime_keys) { @@ -272,17 +270,17 @@ ExecInitBitmapIndexScan(BitmapIndexScan *node, EState *estate) /* * We do not open or lock the base relation here. We assume that an - * ancestor BitmapHeapScan node is holding AccessShareLock on the - * heap relation throughout the execution of the plan tree. + * ancestor BitmapHeapScan node is holding AccessShareLock on the heap + * relation throughout the execution of the plan tree. */ indexstate->ss.ss_currentRelation = NULL; indexstate->ss.ss_currentScanDesc = NULL; /* - * open the index relation and initialize relation and scan - * descriptors. Note we acquire no locks here; the index machinery - * does its own locks and unlocks. + * open the index relation and initialize relation and scan descriptors. + * Note we acquire no locks here; the index machinery does its own locks + * and unlocks. */ indexstate->biss_RelationDesc = index_open(node->indexid); indexstate->biss_ScanDesc = diff --git a/src/backend/executor/nodeBitmapOr.c b/src/backend/executor/nodeBitmapOr.c index 9078855ec3..772b948cc5 100644 --- a/src/backend/executor/nodeBitmapOr.c +++ b/src/backend/executor/nodeBitmapOr.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/nodeBitmapOr.c,v 1.2 2005/04/20 15:48:36 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/nodeBitmapOr.c,v 1.3 2005/10/15 02:49:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -133,13 +133,13 @@ MultiExecBitmapOr(BitmapOrState *node) TIDBitmap *subresult; /* - * We can special-case BitmapIndexScan children to avoid an - * explicit tbm_union step for each child: just pass down the - * current result bitmap and let the child OR directly into it. + * We can special-case BitmapIndexScan children to avoid an explicit + * tbm_union step for each child: just pass down the current result + * bitmap and let the child OR directly into it. */ if (IsA(subnode, BitmapIndexScanState)) { - if (result == NULL) /* first subplan */ + if (result == NULL) /* first subplan */ { /* XXX should we use less than work_mem for this? */ result = tbm_create(work_mem * 1024L); @@ -161,7 +161,7 @@ MultiExecBitmapOr(BitmapOrState *node) elog(ERROR, "unrecognized result from subplan"); if (result == NULL) - result = subresult; /* first subplan */ + result = subresult; /* first subplan */ else { tbm_union(result, subresult); @@ -176,7 +176,7 @@ MultiExecBitmapOr(BitmapOrState *node) /* must provide our own instrumentation support */ if (node->ps.instrument) - InstrStopNodeMulti(node->ps.instrument, 0 /* XXX */); + InstrStopNodeMulti(node->ps.instrument, 0 /* XXX */ ); return (Node *) result; } diff --git a/src/backend/executor/nodeFunctionscan.c b/src/backend/executor/nodeFunctionscan.c index 5cd6de45fd..a0178e8fa1 100644 --- a/src/backend/executor/nodeFunctionscan.c +++ b/src/backend/executor/nodeFunctionscan.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/nodeFunctionscan.c,v 1.34 2005/05/22 22:30:19 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/nodeFunctionscan.c,v 1.35 2005/10/15 02:49:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -60,9 +60,8 @@ FunctionNext(FunctionScanState *node) tuplestorestate = node->tuplestorestate; /* - * If first time through, read all tuples from function and put them - * in a tuplestore. Subsequent calls just fetch tuples from - * tuplestore. + * If first time through, read all tuples from function and put them in a + * tuplestore. Subsequent calls just fetch tuples from tuplestore. */ if (tuplestorestate == NULL) { @@ -77,10 +76,10 @@ FunctionNext(FunctionScanState *node) /* * If function provided a tupdesc, cross-check it. We only really - * need to do this for functions returning RECORD, but might as - * well do it always. + * need to do this for functions returning RECORD, but might as well + * do it always. */ - if (funcTupdesc) + if (funcTupdesc) tupledesc_match(node->tupdesc, funcTupdesc); } @@ -174,8 +173,8 @@ ExecInitFunctionScan(FunctionScan *node, EState *estate) Assert(rte->rtekind == RTE_FUNCTION); /* - * Now determine if the function returns a simple or composite type, - * and build an appropriate tupdesc. + * Now determine if the function returns a simple or composite type, and + * build an appropriate tupdesc. */ functypclass = get_expr_result_type(rte->funcexpr, &funcrettype, @@ -213,8 +212,8 @@ ExecInitFunctionScan(FunctionScan *node, EState *estate) /* * For RECORD results, make sure a typmod has been assigned. (The - * function should do this for itself, but let's cover things in case - * it doesn't.) + * function should do this for itself, but let's cover things in case it + * doesn't.) */ BlessTupleDesc(tupdesc); @@ -329,10 +328,10 @@ ExecFunctionReScan(FunctionScanState *node, ExprContext *exprCtxt) return; /* - * Here we have a choice whether to drop the tuplestore (and recompute - * the function outputs) or just rescan it. This should depend on - * whether the function expression contains parameters and/or is - * marked volatile. FIXME soon. + * Here we have a choice whether to drop the tuplestore (and recompute the + * function outputs) or just rescan it. This should depend on whether the + * function expression contains parameters and/or is marked volatile. + * FIXME soon. */ if (node->ss.ps.chgParam != NULL) { @@ -376,7 +375,7 @@ tupledesc_match(TupleDesc dst_tupdesc, TupleDesc src_tupdesc) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), errmsg("function return row and query-specified return row do not match"), - errdetail("Returned type %s at ordinal position %d, but query expects %s.", + errdetail("Returned type %s at ordinal position %d, but query expects %s.", format_type_be(sattr->atttypid), i + 1, format_type_be(dattr->atttypid)))); diff --git a/src/backend/executor/nodeGroup.c b/src/backend/executor/nodeGroup.c index e16a228fa1..91a08add4d 100644 --- a/src/backend/executor/nodeGroup.c +++ b/src/backend/executor/nodeGroup.c @@ -15,7 +15,7 @@ * locate group boundaries. * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/nodeGroup.c,v 1.61 2005/03/16 21:38:07 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/nodeGroup.c,v 1.62 2005/10/15 02:49:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -61,8 +61,8 @@ ExecGroup(GroupState *node) */ /* - * If first time through, acquire first input tuple and determine - * whether to return it or not. + * If first time through, acquire first input tuple and determine whether + * to return it or not. */ if (TupIsNull(firsttupleslot)) { @@ -76,15 +76,15 @@ ExecGroup(GroupState *node) /* Copy tuple, set up as input for qual test and projection */ ExecCopySlot(firsttupleslot, outerslot); econtext->ecxt_scantuple = firsttupleslot; + /* - * Check the qual (HAVING clause); if the group does not match, - * ignore it and fall into scan loop. + * Check the qual (HAVING clause); if the group does not match, ignore + * it and fall into scan loop. */ if (ExecQual(node->ss.ps.qual, econtext, false)) { /* - * Form and return a projection tuple using the first input - * tuple. + * Form and return a projection tuple using the first input tuple. */ return ExecProject(node->ss.ps.ps_ProjInfo, NULL); } @@ -92,8 +92,8 @@ ExecGroup(GroupState *node) /* * This loop iterates once per input tuple group. At the head of the - * loop, we have finished processing the first tuple of the group and - * now need to scan over all the other group members. + * loop, we have finished processing the first tuple of the group and now + * need to scan over all the other group members. */ for (;;) { @@ -120,22 +120,23 @@ ExecGroup(GroupState *node) econtext->ecxt_per_tuple_memory)) break; } + /* - * We have the first tuple of the next input group. See if we - * want to return it. + * We have the first tuple of the next input group. See if we want to + * return it. */ /* Copy tuple, set up as input for qual test and projection */ ExecCopySlot(firsttupleslot, outerslot); econtext->ecxt_scantuple = firsttupleslot; + /* - * Check the qual (HAVING clause); if the group does not match, - * ignore it and loop back to scan the rest of the group. + * Check the qual (HAVING clause); if the group does not match, ignore + * it and loop back to scan the rest of the group. */ if (ExecQual(node->ss.ps.qual, econtext, false)) { /* - * Form and return a projection tuple using the first input - * tuple. + * Form and return a projection tuple using the first input tuple. */ return ExecProject(node->ss.ps.ps_ProjInfo, NULL); } diff --git a/src/backend/executor/nodeHash.c b/src/backend/executor/nodeHash.c index 5e2be394d8..8c51e785b2 100644 --- a/src/backend/executor/nodeHash.c +++ b/src/backend/executor/nodeHash.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/nodeHash.c,v 1.95 2005/09/25 19:37:34 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/nodeHash.c,v 1.96 2005/10/15 02:49:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -100,11 +100,11 @@ MultiExecHash(HashState *node) InstrStopNodeMulti(node->ps.instrument, hashtable->totalTuples); /* - * We do not return the hash table directly because it's not a subtype - * of Node, and so would violate the MultiExecProcNode API. Instead, - * our parent Hashjoin node is expected to know how to fish it out - * of our node state. Ugly but not really worth cleaning up, since - * Hashjoin knows quite a bit more about Hash besides that. + * We do not return the hash table directly because it's not a subtype of + * Node, and so would violate the MultiExecProcNode API. Instead, our + * parent Hashjoin node is expected to know how to fish it out of our node + * state. Ugly but not really worth cleaning up, since Hashjoin knows + * quite a bit more about Hash besides that. */ return NULL; } @@ -161,8 +161,8 @@ ExecInitHash(Hash *node, EState *estate) outerPlanState(hashstate) = ExecInitNode(outerPlan(node), estate); /* - * initialize tuple type. no need to initialize projection info - * because this node doesn't do projections + * initialize tuple type. no need to initialize projection info because + * this node doesn't do projections */ ExecAssignResultTypeFromOuterPlan(&hashstate->ps); hashstate->ps.ps_ProjInfo = NULL; @@ -221,9 +221,9 @@ ExecHashTableCreate(Hash *node, List *hashOperators) 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). Compute the appropriate size of the hash table. + * 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). + * Compute the appropriate size of the hash table. */ outerNode = outerPlan(node); @@ -237,8 +237,8 @@ ExecHashTableCreate(Hash *node, List *hashOperators) /* * Initialize the hash table control block. * - * The hashtable control block is just palloc'd from the executor's - * per-query memory context. + * The hashtable control block is just palloc'd from the executor's per-query + * memory context. */ hashtable = (HashJoinTable) palloc(sizeof(HashJoinTableData)); hashtable->nbuckets = nbuckets; @@ -273,8 +273,8 @@ ExecHashTableCreate(Hash *node, List *hashOperators) } /* - * Create temporary memory contexts in which to keep the hashtable - * working storage. See notes in executor/hashjoin.h. + * Create temporary memory contexts in which to keep the hashtable working + * storage. See notes in executor/hashjoin.h. */ hashtable->hashCxt = AllocSetContextCreate(CurrentMemoryContext, "HashTableContext", @@ -353,9 +353,9 @@ ExecChooseHashTableSize(double ntuples, int tupwidth, ntuples = 1000.0; /* - * Estimate tupsize based on footprint of tuple in hashtable... note - * this does not allow for any palloc overhead. The manipulations of - * spaceUsed don't count palloc overhead either. + * Estimate tupsize based on footprint of tuple in hashtable... note this + * does not allow for any palloc overhead. The manipulations of spaceUsed + * don't count palloc overhead either. */ tupsize = MAXALIGN(sizeof(HashJoinTupleData)) + MAXALIGN(sizeof(HeapTupleHeaderData)) + @@ -375,16 +375,16 @@ ExecChooseHashTableSize(double ntuples, int tupwidth, if (inner_rel_bytes > hash_table_bytes) { /* We'll need multiple batches */ - long lbuckets; - double dbatch; - int minbatch; + long lbuckets; + double dbatch; + int minbatch; lbuckets = (hash_table_bytes / tupsize) / NTUP_PER_BUCKET; lbuckets = Min(lbuckets, INT_MAX); nbuckets = (int) lbuckets; dbatch = ceil(inner_rel_bytes / hash_table_bytes); - dbatch = Min(dbatch, INT_MAX/2); + dbatch = Min(dbatch, INT_MAX / 2); minbatch = (int) dbatch; nbatch = 2; while (nbatch < minbatch) @@ -393,7 +393,7 @@ ExecChooseHashTableSize(double ntuples, int tupwidth, else { /* We expect the hashtable to fit in memory */ - double dbuckets; + double dbuckets; dbuckets = ceil(ntuples / NTUP_PER_BUCKET); dbuckets = Min(dbuckets, INT_MAX); @@ -406,8 +406,8 @@ ExecChooseHashTableSize(double ntuples, int tupwidth, * We want nbuckets to be prime so as to avoid having bucket and batch * numbers depend on only some bits of the hash code. Choose the next * larger prime from the list in hprimes[]. (This also enforces that - * nbuckets is not very small, by the simple expedient of not putting - * any very small entries in hprimes[].) + * nbuckets is not very small, by the simple expedient of not putting any + * very small entries in hprimes[].) */ for (i = 0; i < (int) lengthof(hprimes); i++) { @@ -475,7 +475,7 @@ ExecHashIncreaseNumBatches(HashJoinTable hashtable) return; /* safety check to avoid overflow */ - if (oldnbatch > INT_MAX/2) + if (oldnbatch > INT_MAX / 2) return; nbatch = oldnbatch * 2; @@ -514,8 +514,8 @@ ExecHashIncreaseNumBatches(HashJoinTable hashtable) hashtable->nbatch = nbatch; /* - * Scan through the existing hash table entries and dump out any - * that are no longer of the current batch. + * Scan through the existing hash table entries and dump out any that are + * no longer of the current batch. */ ninmemory = nfreed = 0; @@ -571,12 +571,12 @@ ExecHashIncreaseNumBatches(HashJoinTable hashtable) #endif /* - * If we dumped out either all or none of the tuples in the table, - * disable further expansion of nbatch. This situation implies that - * we have enough tuples of identical hashvalues to overflow spaceAllowed. - * Increasing nbatch will not fix it since there's no way to subdivide - * the group any more finely. - * We have to just gut it out and hope the server has enough RAM. + * If we dumped out either all or none of the tuples in the table, disable + * further expansion of nbatch. This situation implies that we have + * enough tuples of identical hashvalues to overflow spaceAllowed. + * Increasing nbatch will not fix it since there's no way to subdivide the + * group any more finely. We have to just gut it out and hope the server + * has enough RAM. */ if (nfreed == 0 || nfreed == ninmemory) { @@ -663,8 +663,8 @@ ExecHashGetHashValue(HashJoinTable hashtable, MemoryContext oldContext; /* - * We reset the eval context each time to reclaim any memory leaked in - * the hashkey expressions. + * We reset the eval context each time to reclaim any memory leaked in the + * hashkey expressions. */ ResetExprContext(econtext); @@ -727,8 +727,8 @@ ExecHashGetBucketAndBatch(HashJoinTable hashtable, int *bucketno, int *batchno) { - uint32 nbuckets = (uint32) hashtable->nbuckets; - uint32 nbatch = (uint32) hashtable->nbatch; + uint32 nbuckets = (uint32) hashtable->nbuckets; + uint32 nbatch = (uint32) hashtable->nbatch; if (nbatch > 1) { @@ -759,8 +759,8 @@ ExecScanHashBucket(HashJoinState *hjstate, uint32 hashvalue = hjstate->hj_CurHashValue; /* - * hj_CurTuple is NULL to start scanning a new bucket, or the address - * of the last tuple returned from the current bucket. + * 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]; @@ -812,8 +812,8 @@ ExecHashTableReset(HashJoinTable hashtable) int nbuckets = hashtable->nbuckets; /* - * Release all the hash buckets and tuples acquired in the prior pass, - * and reinitialize the context for a new pass. + * Release all the hash buckets and tuples acquired in the prior pass, and + * reinitialize the context for a new pass. */ MemoryContextReset(hashtable->batchCxt); oldcxt = MemoryContextSwitchTo(hashtable->batchCxt); diff --git a/src/backend/executor/nodeHashjoin.c b/src/backend/executor/nodeHashjoin.c index 4b0f9377ba..9f002dde9c 100644 --- a/src/backend/executor/nodeHashjoin.c +++ b/src/backend/executor/nodeHashjoin.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/nodeHashjoin.c,v 1.73 2005/09/25 19:37:34 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/nodeHashjoin.c,v 1.74 2005/10/15 02:49:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -24,8 +24,8 @@ static TupleTableSlot *ExecHashJoinOuterGetTuple(PlanState *outerNode, - HashJoinState *hjstate, - uint32 *hashvalue); + HashJoinState *hjstate, + uint32 *hashvalue); static TupleTableSlot *ExecHashJoinGetSavedTuple(HashJoinState *hjstate, BufFile *file, uint32 *hashvalue, @@ -77,9 +77,9 @@ ExecHashJoin(HashJoinState *node) econtext = node->js.ps.ps_ExprContext; /* - * Check to see if we're still projecting out tuples from a previous - * join tuple (because there is a function-returning-set in the - * projection expressions). If so, try to project another one. + * Check to see if we're still projecting out tuples from a previous join + * tuple (because there is a function-returning-set in the projection + * expressions). If so, try to project another one. */ if (node->js.ps.ps_TupFromTlist) { @@ -93,17 +93,17 @@ ExecHashJoin(HashJoinState *node) } /* - * If we're doing an IN join, we want to return at most one row per - * outer tuple; so we can stop scanning the inner scan if we matched - * on the previous try. + * If we're doing an IN join, we want to return at most one row per outer + * tuple; so we can stop scanning the inner scan if we matched on the + * previous try. */ if (node->js.jointype == JOIN_IN && node->hj_MatchedOuter) node->hj_NeedNewOuter = true; /* * Reset per-tuple memory context to free any expression evaluation - * storage allocated in the previous tuple cycle. Note this can't - * happen until we're done projecting out tuples from a join tuple. + * storage allocated in the previous tuple cycle. Note this can't happen + * until we're done projecting out tuples from a join tuple. */ ResetExprContext(econtext); @@ -114,17 +114,17 @@ ExecHashJoin(HashJoinState *node) { /* * If the outer relation is completely empty, we can quit without - * building the hash table. However, for an inner join it is only - * a win to check this when the outer relation's startup cost is less - * than the projected cost of building the hash table. Otherwise - * it's best to build the hash table first and see if the inner - * relation is empty. (When it's an outer join, we should always - * make this check, since we aren't going to be able to skip the - * join on the strength of an empty inner relation anyway.) + * building the hash table. However, for an inner join it is only a + * win to check this when the outer relation's startup cost is less + * than the projected cost of building the hash table. Otherwise it's + * best to build the hash table first and see if the inner relation is + * empty. (When it's an outer join, we should always make this check, + * since we aren't going to be able to skip the join on the strength + * of an empty inner relation anyway.) * - * The only way to make the check is to try to fetch a tuple from - * the outer plan node. If we succeed, we have to stash it away - * for later consumption by ExecHashJoinOuterGetTuple. + * The only way to make the check is to try to fetch a tuple from the + * outer plan node. If we succeed, we have to stash it away for later + * consumption by ExecHashJoinOuterGetTuple. */ if (outerNode->plan->startup_cost < hashNode->ps.plan->total_cost || node->js.jointype == JOIN_LEFT) @@ -150,8 +150,8 @@ ExecHashJoin(HashJoinState *node) (void) MultiExecProcNode((PlanState *) hashNode); /* - * If the inner relation is completely empty, and we're not doing - * an outer join, we can quit without scanning the outer relation. + * If the inner relation is completely empty, and we're not doing an + * outer join, we can quit without scanning the outer relation. */ if (hashtable->totalTuples == 0 && node->js.jointype != JOIN_LEFT) { @@ -193,8 +193,8 @@ ExecHashJoin(HashJoinState *node) node->hj_MatchedOuter = false; /* - * 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 */ node->hj_CurHashValue = hashvalue; ExecHashGetBucketAndBatch(hashtable, hashvalue, @@ -202,21 +202,21 @@ ExecHashJoin(HashJoinState *node) node->hj_CurTuple = NULL; /* - * Now we've got an outer tuple and the corresponding hash - * bucket, but this tuple may not belong to the current batch. + * Now we've got an outer tuple and the corresponding hash bucket, + * but this tuple may not belong to the current batch. */ if (batchno != hashtable->curbatch) { /* - * Need to postpone this outer tuple to a later batch. - * Save it in the corresponding outer-batch file. + * Need to postpone this outer tuple to a later batch. Save it + * in the corresponding outer-batch file. */ Assert(batchno > hashtable->curbatch); ExecHashJoinSaveTuple(ExecFetchSlotTuple(outerTupleSlot), hashvalue, &hashtable->outerBatchFile[batchno]); node->hj_NeedNewOuter = true; - continue; /* loop around for a new outer tuple */ + continue; /* loop around for a new outer tuple */ } } @@ -243,11 +243,11 @@ ExecHashJoin(HashJoinState *node) /* * if we pass the qual, then save state for next call and have - * ExecProject form the projection, store it in the tuple - * table, and return the slot. + * ExecProject form the projection, store it in the tuple table, + * and return the slot. * - * Only the joinquals determine MatchedOuter status, but all - * quals must pass to actually return the tuple. + * Only the joinquals determine MatchedOuter status, but all quals + * must pass to actually return the tuple. */ if (joinqual == NIL || ExecQual(joinqual, econtext, false)) { @@ -268,8 +268,7 @@ ExecHashJoin(HashJoinState *node) } /* - * If we didn't return a tuple, may need to set - * NeedNewOuter + * If we didn't return a tuple, may need to set NeedNewOuter */ if (node->js.jointype == JOIN_IN) { @@ -281,8 +280,8 @@ ExecHashJoin(HashJoinState *node) /* * Now the current outer tuple has run out of matches, so check - * whether to emit a dummy outer-join tuple. If not, loop around - * to get a new outer tuple. + * whether to emit a dummy outer-join tuple. If not, loop around to + * get a new outer tuple. */ node->hj_NeedNewOuter = true; @@ -290,19 +289,17 @@ ExecHashJoin(HashJoinState *node) node->js.jointype == JOIN_LEFT) { /* - * We are doing an outer join and there were no join matches - * for this outer tuple. Generate a fake join tuple with - * nulls for the inner tuple, and return it if it passes the - * non-join quals. + * We are doing an outer join and there were no join matches for + * this outer tuple. Generate a fake join tuple with nulls for + * the inner tuple, and return it if it passes the non-join quals. */ econtext->ecxt_innertuple = node->hj_NullInnerTupleSlot; if (ExecQual(otherqual, econtext, false)) { /* - * qualification was satisfied so we project and return - * the slot containing the result tuple using - * ExecProject(). + * qualification was satisfied so we project and return the + * slot containing the result tuple using ExecProject(). */ TupleTableSlot *result; @@ -392,7 +389,7 @@ ExecInitHashJoin(HashJoin *node, EState *estate) case JOIN_LEFT: hjstate->hj_NullInnerTupleSlot = ExecInitNullTupleSlot(estate, - ExecGetResultType(innerPlanState(hjstate))); + ExecGetResultType(innerPlanState(hjstate))); break; default: elog(ERROR, "unrecognized join type: %d", @@ -400,11 +397,11 @@ ExecInitHashJoin(HashJoin *node, EState *estate) } /* - * now for some voodoo. our temporary tuple slot is actually the - * result tuple slot of the Hash node (which is our inner plan). we - * do this because Hash nodes don't return tuples via ExecProcNode() - * -- instead the hash join node uses ExecScanHashBucket() to get at - * the contents of the hash table. -cim 6/9/91 + * now for some voodoo. our temporary tuple slot is actually the result + * tuple slot of the Hash node (which is our inner plan). we do this + * because Hash nodes don't return tuples via ExecProcNode() -- instead + * the hash join node uses ExecScanHashBucket() to get at the contents of + * the hash table. -cim 6/9/91 */ { HashState *hashstate = (HashState *) innerPlanState(hjstate); @@ -434,10 +431,10 @@ ExecInitHashJoin(HashJoin *node, EState *estate) hjstate->hj_CurTuple = NULL; /* - * Deconstruct the hash clauses into outer and inner argument values, - * so that we can evaluate those subexpressions separately. Also make - * a list of the hash operator OIDs, in preparation for looking up the - * hash functions to use. + * Deconstruct the hash clauses into outer and inner argument values, so + * that we can evaluate those subexpressions separately. Also make a list + * of the hash operator OIDs, in preparation for looking up the hash + * functions to use. */ lclauses = NIL; rclauses = NIL; @@ -536,6 +533,7 @@ ExecHashJoinOuterGetTuple(PlanState *outerNode, if (curbatch == 0) { /* if it is the first pass */ + /* * Check to see if first outer tuple was already fetched by * ExecHashJoin() and not used yet. @@ -560,16 +558,16 @@ ExecHashJoinOuterGetTuple(PlanState *outerNode, } /* - * 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 - * batches as needed. NOTE: nbatch could increase inside - * ExecHashJoinNewBatch, so don't try to optimize this loop. + * Try to read from a temp file. Loop allows us to advance to new batches + * as needed. NOTE: nbatch could increase inside ExecHashJoinNewBatch, so + * don't try to optimize this loop. */ while (curbatch < hashtable->nbatch) { @@ -623,16 +621,16 @@ start_over: * sides. We can sometimes skip over batches that are empty on only one * side, but there are exceptions: * - * 1. In a LEFT JOIN, we have to process outer batches even if the - * inner batch is empty. + * 1. In a LEFT JOIN, we have to process outer batches even if the inner + * batch is empty. * - * 2. If we have increased nbatch since the initial estimate, we have - * to scan inner batches since they might contain tuples that need to - * be reassigned to later inner batches. + * 2. If we have increased nbatch since the initial estimate, we have to scan + * inner batches since they might contain tuples that need to be + * reassigned to later inner batches. * - * 3. Similarly, if we have increased nbatch since starting the outer - * scan, we have to rescan outer batches in case they contain tuples - * that need to be reassigned. + * 3. Similarly, if we have increased nbatch since starting the outer scan, + * we have to rescan outer batches in case they contain tuples that need + * to be reassigned. */ curbatch++; while (curbatch < nbatch && @@ -676,7 +674,7 @@ start_over: if (BufFileSeek(innerFile, 0, 0L, SEEK_SET)) ereport(ERROR, (errcode_for_file_access(), - errmsg("could not rewind hash-join temporary file: %m"))); + errmsg("could not rewind hash-join temporary file: %m"))); while ((slot = ExecHashJoinGetSavedTuple(hjstate, innerFile, @@ -684,8 +682,8 @@ start_over: hjstate->hj_HashTupleSlot))) { /* - * NOTE: some tuples may be sent to future batches. Also, - * it is possible for hashtable->nbatch to be increased here! + * NOTE: some tuples may be sent to future batches. Also, it is + * possible for hashtable->nbatch to be increased here! */ ExecHashTableInsert(hashtable, ExecFetchSlotTuple(slot), @@ -733,7 +731,7 @@ void ExecHashJoinSaveTuple(HeapTuple heapTuple, uint32 hashvalue, BufFile **fileptr) { - BufFile *file = *fileptr; + BufFile *file = *fileptr; size_t written; if (file == NULL) @@ -764,7 +762,7 @@ ExecHashJoinSaveTuple(HeapTuple heapTuple, uint32 hashvalue, /* * ExecHashJoinGetSavedTuple - * read the next tuple from a batch file. Return NULL if no more. + * read the next tuple from a batch file. Return NULL if no more. * * On success, *hashvalue is set to the tuple's hash value, and the tuple * itself is stored in the given slot. @@ -809,18 +807,18 @@ void ExecReScanHashJoin(HashJoinState *node, ExprContext *exprCtxt) { /* - * If we haven't yet built the hash table then we can just return; - * nothing done yet, so nothing to undo. + * If we haven't yet built the hash table then we can just return; nothing + * done yet, so nothing to undo. */ if (node->hj_HashTable == NULL) return; /* - * In a multi-batch join, we currently have to do rescans the hard - * way, primarily because batch temp files may have already been - * released. But if it's a single-batch join, and there is no - * parameter change for the inner subnode, then we can just re-use the - * existing hash table without rebuilding it. + * In a multi-batch join, we currently have to do rescans the hard way, + * primarily because batch temp files may have already been released. But + * if it's a single-batch join, and there is no parameter change for the + * inner subnode, then we can just re-use the existing hash table without + * rebuilding it. */ if (node->hj_HashTable->nbatch == 1 && ((PlanState *) node)->righttree->chgParam == NULL) @@ -835,8 +833,8 @@ ExecReScanHashJoin(HashJoinState *node, ExprContext *exprCtxt) node->hj_FirstOuterTupleSlot = NULL; /* - * if chgParam of subnode is not null then plan will be re-scanned - * by first ExecProcNode. + * if chgParam of subnode is not null then plan will be re-scanned by + * first ExecProcNode. */ if (((PlanState *) node)->righttree->chgParam == NULL) ExecReScan(((PlanState *) node)->righttree, exprCtxt); diff --git a/src/backend/executor/nodeIndexscan.c b/src/backend/executor/nodeIndexscan.c index 2a10ef39c0..94ab2223c7 100644 --- a/src/backend/executor/nodeIndexscan.c +++ b/src/backend/executor/nodeIndexscan.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/nodeIndexscan.c,v 1.103 2005/05/06 17:24:54 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/nodeIndexscan.c,v 1.104 2005/10/15 02:49:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -75,11 +75,11 @@ IndexNext(IndexScanState *node) scanrelid = ((IndexScan *) node->ss.ps.plan)->scan.scanrelid; /* - * Clear any reference to the previously returned tuple. The idea - * here is to not have the tuple slot be the last holder of a pin on - * that tuple's buffer; if it is, we'll need a separate visit to the - * bufmgr to release the buffer. By clearing here, we get to have the - * release done by ReleaseAndReadBuffer inside index_getnext. + * Clear any reference to the previously returned tuple. The idea here is + * to not have the tuple slot be the last holder of a pin on that tuple's + * buffer; if it is, we'll need a separate visit to the bufmgr to release + * the buffer. By clearing here, we get to have the release done by + * ReleaseAndReadBuffer inside index_getnext. */ ExecClearTuple(slot); @@ -104,7 +104,7 @@ IndexNext(IndexScanState *node) ResetExprContext(econtext); if (!ExecQual(node->indexqualorig, econtext, false)) - ExecClearTuple(slot); /* would not be returned by scan */ + ExecClearTuple(slot); /* would not be returned by scan */ /* Flag for the next call that no more tuples */ estate->es_evTupleNull[scanrelid - 1] = true; @@ -118,22 +118,21 @@ IndexNext(IndexScanState *node) if ((tuple = index_getnext(scandesc, direction)) != NULL) { /* - * Store the scanned tuple in the scan tuple slot of the scan - * state. Note: we pass 'false' because tuples returned by - * amgetnext are pointers onto disk pages and must not be - * pfree()'d. + * Store the scanned tuple in the scan tuple slot of the scan state. + * Note: we pass 'false' because tuples returned by amgetnext are + * pointers onto disk pages and must not be pfree()'d. */ - ExecStoreTuple(tuple, /* tuple to store */ - slot, /* slot to store in */ - scandesc->xs_cbuf, /* buffer containing tuple */ - false); /* don't pfree */ + ExecStoreTuple(tuple, /* tuple to store */ + slot, /* slot to store in */ + scandesc->xs_cbuf, /* buffer containing tuple */ + false); /* don't pfree */ return slot; } /* - * if we get here it means the index scan failed so we are at the end - * of the scan.. + * if we get here it means the index scan failed so we are at the end of + * the scan.. */ return ExecClearTuple(slot); } @@ -146,8 +145,7 @@ TupleTableSlot * ExecIndexScan(IndexScanState *node) { /* - * If we have runtime keys and they've not already been set up, do it - * now. + * If we have runtime keys and they've not already been set up, do it now. */ if (node->iss_RuntimeKeyInfo && !node->iss_RuntimeKeysReady) ExecReScan((PlanState *) node, NULL); @@ -179,8 +177,7 @@ ExecIndexReScan(IndexScanState *node, ExprContext *exprCtxt) Index scanrelid; estate = node->ss.ps.state; - econtext = node->iss_RuntimeContext; /* context for runtime - * keys */ + econtext = node->iss_RuntimeContext; /* context for runtime keys */ scanKeys = node->iss_ScanKeys; runtimeKeyInfo = node->iss_RuntimeKeyInfo; numScanKeys = node->iss_NumScanKeys; @@ -203,16 +200,16 @@ ExecIndexReScan(IndexScanState *node, ExprContext *exprCtxt) } /* - * Reset the runtime-key context so we don't leak memory as each - * outer tuple is scanned. Note this assumes that we will - * recalculate *all* runtime keys on each call. + * Reset the runtime-key context so we don't leak memory as each outer + * tuple is scanned. Note this assumes that we will recalculate *all* + * runtime keys on each call. */ ResetExprContext(econtext); } /* - * If we are doing runtime key calculations (ie, the index keys depend - * on data from an outer scan), compute the new key values + * If we are doing runtime key calculations (ie, the index keys depend on + * data from an outer scan), compute the new key values */ if (runtimeKeyInfo) { @@ -251,16 +248,16 @@ ExecIndexEvalRuntimeKeys(ExprContext *econtext, for (j = 0; j < n_keys; j++) { /* - * If we have a run-time key, then extract the run-time - * expression and evaluate it with respect to the current - * outer tuple. We then stick the result into the scan key. + * If we have a run-time key, then extract the run-time expression and + * evaluate it with respect to the current outer tuple. We then stick + * the result into the scan key. * - * Note: the result of the eval could be a pass-by-ref value - * that's stored in the outer scan's tuple, not in - * econtext->ecxt_per_tuple_memory. We assume that the - * outer tuple will stay put throughout our scan. If this - * is wrong, we could copy the result into our context - * explicitly, but I think that's not necessary... + * Note: the result of the eval could be a pass-by-ref value that's + * stored in the outer scan's tuple, not in + * econtext->ecxt_per_tuple_memory. We assume that the outer tuple + * will stay put throughout our scan. If this is wrong, we could copy + * the result into our context explicitly, but I think that's not + * necessary... */ if (run_keys[j] != NULL) { @@ -323,9 +320,8 @@ ExecEndIndexScan(IndexScanState *node) * close the heap relation. * * Currently, we do not release the AccessShareLock acquired by - * ExecInitIndexScan. This lock should be held till end of - * transaction. (There is a faction that considers this too much - * locking, however.) + * ExecInitIndexScan. This lock should be held till end of transaction. + * (There is a faction that considers this too much locking, however.) */ heap_close(relation, NoLock); } @@ -392,11 +388,10 @@ ExecInitIndexScan(IndexScan *node, EState *estate) * initialize child expressions * * Note: we don't initialize all of the indexqual expression, only the - * sub-parts corresponding to runtime keys (see below). The - * indexqualorig expression is always initialized even though it will - * only be used in some uncommon cases --- would be nice to improve - * that. (Problem is that any SubPlans present in the expression must - * be found now...) + * sub-parts corresponding to runtime keys (see below). The indexqualorig + * expression is always initialized even though it will only be used in + * some uncommon cases --- would be nice to improve that. (Problem is + * that any SubPlans present in the expression must be found now...) */ indexstate->ss.ps.targetlist = (List *) ExecInitExpr((Expr *) node->scan.plan.targetlist, @@ -440,10 +435,10 @@ ExecInitIndexScan(IndexScan *node, EState *estate) indexstate->iss_NumScanKeys = numScanKeys; /* - * If we have runtime keys, we need an ExprContext to evaluate them. - * The node's standard context won't do because we want to reset that - * context for every tuple. So, build another context just like the - * other one... -tgl 7/11/00 + * If we have runtime keys, we need an ExprContext to evaluate them. The + * node's standard context won't do because we want to reset that context + * for every tuple. So, build another context just like the other one... + * -tgl 7/11/00 */ if (have_runtime_keys) { @@ -476,10 +471,10 @@ ExecInitIndexScan(IndexScan *node, EState *estate) ExecAssignScanType(&indexstate->ss, RelationGetDescr(currentRelation), false); /* - * open the index relation and initialize relation and scan - * descriptors. Note we acquire no locks here; the index machinery - * does its own locks and unlocks. (We rely on having AccessShareLock - * on the parent table to ensure the index won't go away!) + * open the index relation and initialize relation and scan descriptors. + * Note we acquire no locks here; the index machinery does its own locks + * and unlocks. (We rely on having AccessShareLock on the parent table to + * ensure the index won't go away!) */ indexstate->iss_RelationDesc = index_open(node->indexid); indexstate->iss_ScanDesc = index_beginscan(currentRelation, @@ -543,8 +538,8 @@ ExecIndexBuildScanKeys(PlanState *planstate, List *quals, (ExprState **) palloc(n_keys * sizeof(ExprState *)); /* - * for each opclause in the given qual, convert each qual's - * opclause into a single scan key + * for each opclause in the given qual, convert each qual's opclause into + * a single scan key */ qual_cell = list_head(quals); strategy_cell = list_head(strategies); @@ -552,15 +547,15 @@ ExecIndexBuildScanKeys(PlanState *planstate, List *quals, for (j = 0; j < n_keys; j++) { - OpExpr *clause; /* one clause of index qual */ - Expr *leftop; /* expr on lhs of operator */ - Expr *rightop; /* expr on rhs ... */ + OpExpr *clause; /* one clause of index qual */ + Expr *leftop; /* expr on lhs of operator */ + Expr *rightop; /* expr on rhs ... */ int flags = 0; - AttrNumber varattno; /* att number used in scan */ + AttrNumber varattno; /* att number used in scan */ StrategyNumber strategy; /* op's strategy number */ - Oid subtype; /* op's strategy subtype */ - RegProcedure opfuncid; /* operator proc id used in scan */ - Datum scanvalue; /* value used in scan (if const) */ + Oid subtype; /* op's strategy subtype */ + RegProcedure opfuncid; /* operator proc id used in scan */ + Datum scanvalue; /* value used in scan (if const) */ /* * extract clause information from the qualification @@ -578,18 +573,17 @@ ExecIndexBuildScanKeys(PlanState *planstate, List *quals, opfuncid = clause->opfuncid; /* - * Here we figure out the contents of the index qual. The - * usual case is (var op const) which means we form a scan key - * for the attribute listed in the var node and use the value - * of the const as comparison data. + * Here we figure out the contents of the index qual. The usual case + * is (var op const) which means we form a scan key for the attribute + * listed in the var node and use the value of the const as comparison + * data. * - * If we don't have a const node, it means our scan key is a - * function of information obtained during the execution of - * the plan, in which case we need to recalculate the index - * scan key at run time. Hence, we set have_runtime_keys to - * true and place the appropriate subexpression in run_keys. - * The corresponding scan key values are recomputed at run - * time. + * If we don't have a const node, it means our scan key is a function of + * information obtained during the execution of the plan, in which + * case we need to recalculate the index scan key at run time. Hence, + * we set have_runtime_keys to true and place the appropriate + * subexpression in run_keys. The corresponding scan key values are + * recomputed at run time. */ run_keys[j] = NULL; @@ -622,8 +616,8 @@ ExecIndexBuildScanKeys(PlanState *planstate, List *quals, if (IsA(rightop, Const)) { /* - * if the rightop is a const node then it means it - * identifies the value to place in our scan key. + * if the rightop is a const node then it means it identifies the + * value to place in our scan key. */ scanvalue = ((Const *) rightop)->constvalue; if (((Const *) rightop)->constisnull) @@ -632,9 +626,8 @@ ExecIndexBuildScanKeys(PlanState *planstate, List *quals, else { /* - * otherwise, the rightop contains an expression evaluable - * at runtime to figure out the value to place in our scan - * key. + * otherwise, the rightop contains an expression evaluable at + * runtime to figure out the value to place in our scan key. */ have_runtime_keys = true; run_keys[j] = ExecInitExpr(rightop, planstate); @@ -646,11 +639,11 @@ ExecIndexBuildScanKeys(PlanState *planstate, List *quals, */ ScanKeyEntryInitialize(&scan_keys[j], flags, - varattno, /* attribute number to scan */ - strategy, /* op's strategy */ - subtype, /* strategy subtype */ - opfuncid, /* reg proc to use */ - scanvalue); /* constant */ + varattno, /* attribute number to scan */ + strategy, /* op's strategy */ + subtype, /* strategy subtype */ + opfuncid, /* reg proc to use */ + scanvalue); /* constant */ } /* If no runtime keys, get rid of speculatively-allocated array */ diff --git a/src/backend/executor/nodeLimit.c b/src/backend/executor/nodeLimit.c index 40e0283e86..462db0aee9 100644 --- a/src/backend/executor/nodeLimit.c +++ b/src/backend/executor/nodeLimit.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/nodeLimit.c,v 1.21 2005/03/16 21:38:07 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/nodeLimit.c,v 1.22 2005/10/15 02:49:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -61,10 +61,9 @@ ExecLimit(LimitState *node) return NULL; /* - * First call for this scan, so compute limit/offset. (We - * can't do this any earlier, because parameters from upper - * nodes may not be set until now.) This also sets position = - * 0. + * First call for this scan, so compute limit/offset. (We can't do + * this any earlier, because parameters from upper nodes may not + * be set until now.) This also sets position = 0. */ recompute_limits(node); @@ -86,8 +85,8 @@ ExecLimit(LimitState *node) if (TupIsNull(slot)) { /* - * The subplan returns too few tuples for us to - * produce any output at all. + * The subplan returns too few tuples for us to produce + * any output at all. */ node->lstate = LIMIT_EMPTY; return NULL; @@ -115,11 +114,10 @@ ExecLimit(LimitState *node) if (ScanDirectionIsForward(direction)) { /* - * Forwards scan, so check for stepping off end of window. - * If we are at the end of the window, return NULL without - * advancing the subplan or the position variable; but - * change the state machine state to record having done - * so. + * Forwards scan, so check for stepping off end of window. If + * we are at the end of the window, return NULL without + * advancing the subplan or the position variable; but change + * the state machine state to record having done so. */ if (!node->noCount && node->position >= node->offset + node->count) @@ -143,9 +141,8 @@ ExecLimit(LimitState *node) else { /* - * Backwards scan, so check for stepping off start of - * window. As above, change only state-machine status if - * so. + * Backwards scan, so check for stepping off start of window. + * As above, change only state-machine status if so. */ if (node->position <= node->offset + 1) { @@ -169,9 +166,8 @@ ExecLimit(LimitState *node) return NULL; /* - * Backing up from subplan EOF, so re-fetch previous tuple; - * there should be one! Note previous tuple must be in - * window. + * Backing up from subplan EOF, so re-fetch previous tuple; there + * should be one! Note previous tuple must be in window. */ slot = ExecProcNode(outerPlan); if (TupIsNull(slot)) @@ -328,8 +324,8 @@ ExecInitLimit(Limit *node, EState *estate) outerPlanState(limitstate) = ExecInitNode(outerPlan, estate); /* - * limit nodes do no projections, so initialize projection info for - * this node appropriately + * limit nodes do no projections, so initialize projection info for this + * node appropriately */ ExecAssignResultTypeFromOuterPlan(&limitstate->ps); limitstate->ps.ps_ProjInfo = NULL; diff --git a/src/backend/executor/nodeMaterial.c b/src/backend/executor/nodeMaterial.c index fe12859557..750f355b0e 100644 --- a/src/backend/executor/nodeMaterial.c +++ b/src/backend/executor/nodeMaterial.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/nodeMaterial.c,v 1.49 2005/03/16 21:38:07 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/nodeMaterial.c,v 1.50 2005/10/15 02:49:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -68,8 +68,8 @@ ExecMaterial(MaterialState *node) } /* - * If we are not at the end of the tuplestore, or are going backwards, - * try to fetch a tuple from tuplestore. + * If we are not at the end of the tuplestore, or are going backwards, try + * to fetch a tuple from tuplestore. */ eof_tuplestore = tuplestore_ateof(tuplestorestate); @@ -79,9 +79,9 @@ ExecMaterial(MaterialState *node) { /* * When reversing direction at tuplestore EOF, the first - * getheaptuple call will fetch the last-added tuple; but we - * want to return the one before that, if possible. So do an - * extra fetch. + * getheaptuple call will fetch the last-added tuple; but we want + * to return the one before that, if possible. So do an extra + * fetch. */ heapTuple = tuplestore_getheaptuple(tuplestorestate, forward, @@ -106,10 +106,10 @@ ExecMaterial(MaterialState *node) /* * If necessary, try to fetch another row from the subplan. * - * Note: the eof_underlying state variable exists to short-circuit - * further subplan calls. It's not optional, unfortunately, because - * some plan node types are not robust about being called again when - * they've already returned NULL. + * Note: the eof_underlying state variable exists to short-circuit further + * subplan calls. It's not optional, unfortunately, because some plan + * node types are not robust about being called again when they've already + * returned NULL. */ if (eof_tuplestore && !node->eof_underlying) { @@ -117,8 +117,8 @@ ExecMaterial(MaterialState *node) TupleTableSlot *outerslot; /* - * We can only get here with forward==true, so no need to worry - * about which direction the subplan will go. + * We can only get here with forward==true, so no need to worry about + * which direction the subplan will go. */ outerNode = outerPlanState(node); outerslot = ExecProcNode(outerNode); @@ -132,8 +132,8 @@ ExecMaterial(MaterialState *node) /* * Append returned tuple to tuplestore, too. NOTE: because the - * tuplestore is certainly in EOF state, its read position will - * move forward over the added tuple. This is what we want. + * tuplestore is certainly in EOF state, its read position will move + * forward over the added tuple. This is what we want. */ tuplestore_puttuple(tuplestorestate, (void *) heapTuple); } @@ -192,8 +192,8 @@ ExecInitMaterial(Material *node, EState *estate) outerPlanState(matstate) = ExecInitNode(outerPlan, estate); /* - * initialize tuple type. no need to initialize projection info - * because this node doesn't do projections. + * initialize tuple type. no need to initialize projection info because + * this node doesn't do projections. */ ExecAssignResultTypeFromOuterPlan(&matstate->ss.ps); ExecAssignScanTypeFromOuterPlan(&matstate->ss); @@ -284,9 +284,9 @@ void ExecMaterialReScan(MaterialState *node, ExprContext *exprCtxt) { /* - * If we haven't materialized yet, just return. If outerplan' chgParam - * is not NULL then it will be re-scanned by ExecProcNode, else - no - * reason to re-scan it at all. + * If we haven't materialized yet, just return. If outerplan' chgParam is + * not NULL then it will be re-scanned by ExecProcNode, else - no reason + * to re-scan it at all. */ if (!node->tuplestorestate) return; @@ -294,11 +294,11 @@ ExecMaterialReScan(MaterialState *node, ExprContext *exprCtxt) ExecClearTuple(node->ss.ps.ps_ResultTupleSlot); /* - * If subnode is to be rescanned then we forget previous stored - * results; we have to re-read the subplan and re-store. + * If subnode is to be rescanned then we forget previous stored results; + * we have to re-read the subplan and re-store. * - * Otherwise we can just rewind and rescan the stored output. The state - * of the subnode does not change. + * Otherwise we can just rewind and rescan the stored output. The state of + * the subnode does not change. */ if (((PlanState *) node)->lefttree->chgParam != NULL) { diff --git a/src/backend/executor/nodeMergejoin.c b/src/backend/executor/nodeMergejoin.c index fb279e8b68..0d4eed4c9b 100644 --- a/src/backend/executor/nodeMergejoin.c +++ b/src/backend/executor/nodeMergejoin.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/nodeMergejoin.c,v 1.74 2005/05/15 21:19:55 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/nodeMergejoin.c,v 1.75 2005/10/15 02:49:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -40,7 +40,7 @@ * matching tuple and so on. * * Therefore, when initializing the merge-join node, we look up the - * associated sort operators. We assume the planner has seen to it + * associated sort operators. We assume the planner has seen to it * that the inputs are correctly sorted by these operators. Rather * than directly executing the merge join clauses, we evaluate the * left and right key expressions separately and then compare the @@ -124,30 +124,33 @@ typedef enum typedef struct MergeJoinClauseData { /* Executable expression trees */ - ExprState *lexpr; /* left-hand (outer) input expression */ - ExprState *rexpr; /* right-hand (inner) input expression */ + ExprState *lexpr; /* left-hand (outer) input expression */ + ExprState *rexpr; /* right-hand (inner) input expression */ + /* * If we have a current left or right input tuple, the values of the * expressions are loaded into these fields: */ - Datum ldatum; /* current left-hand value */ - Datum rdatum; /* current right-hand value */ - bool lisnull; /* and their isnull flags */ - bool risnull; + Datum ldatum; /* current left-hand value */ + Datum rdatum; /* current right-hand value */ + bool lisnull; /* and their isnull flags */ + bool risnull; + /* * Remember whether mergejoin operator is strict (usually it will be). - * NOTE: if it's not strict, we still assume it cannot return true for - * one null and one non-null input. + * NOTE: if it's not strict, we still assume it cannot return true for one + * null and one non-null input. */ - bool mergestrict; + bool mergestrict; + /* - * The comparison strategy in use, and the lookup info to let us call - * the needed comparison routines. eqfinfo is the "=" operator itself. + * The comparison strategy in use, and the lookup info to let us call the + * needed comparison routines. eqfinfo is the "=" operator itself. * cmpfinfo is either the btree comparator or the "<" operator. */ MergeFunctionKind cmpstrategy; - FmgrInfo eqfinfo; - FmgrInfo cmpfinfo; + FmgrInfo eqfinfo; + FmgrInfo cmpfinfo; } MergeJoinClauseData; @@ -167,8 +170,8 @@ typedef struct MergeJoinClauseData * * The best, most efficient way to compare two expressions is to use a btree * comparison support routine, since that requires only one function call - * per comparison. Hence we try to find a btree opclass that matches the - * mergejoinable operator. If we cannot find one, we'll have to call both + * per comparison. Hence we try to find a btree opclass that matches the + * mergejoinable operator. If we cannot find one, we'll have to call both * the "=" and (often) the "<" operator for each comparison. */ static MergeJoinClause @@ -204,8 +207,8 @@ MJExamineQuals(List *qualList, PlanState *parent) clause->rexpr = ExecInitExpr((Expr *) lsecond(qual->args), parent); /* - * Check permission to call the mergejoinable operator. - * For predictability, we check this even if we end up not using it. + * Check permission to call the mergejoinable operator. For + * predictability, we check this even if we end up not using it. */ aclresult = pg_proc_aclcheck(qual->opfuncid, GetUserId(), ACL_EXECUTE); if (aclresult != ACLCHECK_OK) @@ -220,7 +223,7 @@ MJExamineQuals(List *qualList, PlanState *parent) /* * Lookup the comparison operators that go with the mergejoinable - * top-level operator. (This will elog if the operator isn't + * top-level operator. (This will elog if the operator isn't * mergejoinable, which would be the planner's mistake.) */ op_mergejoin_crossops(qual->opno, @@ -232,13 +235,12 @@ MJExamineQuals(List *qualList, PlanState *parent) clause->cmpstrategy = MERGEFUNC_LT; /* - * Look for a btree opclass including all three operators. - * This is much like SelectSortFunction except we insist on - * matching all the operators provided, and it can be a cross-type - * opclass. + * Look for a btree opclass including all three operators. This is + * much like SelectSortFunction except we insist on matching all the + * operators provided, and it can be a cross-type opclass. * - * XXX for now, insist on forward sort so that NULLs can be counted - * on to be high. + * XXX for now, insist on forward sort so that NULLs can be counted on to + * be high. */ catlist = SearchSysCacheList(AMOPOPID, 1, ObjectIdGetDatum(qual->opno), @@ -255,13 +257,13 @@ MJExamineQuals(List *qualList, PlanState *parent) if (!opclass_is_btree(opcid)) continue; if (get_op_opclass_strategy(ltop, opcid) == BTLessStrategyNumber && - get_op_opclass_strategy(gtop, opcid) == BTGreaterStrategyNumber) + get_op_opclass_strategy(gtop, opcid) == BTGreaterStrategyNumber) { clause->cmpstrategy = MERGEFUNC_CMP; ltproc = get_opclass_proc(opcid, aform->amopsubtype, BTORDER_PROC); Assert(RegProcedureIsValid(ltproc)); - break; /* done looking */ + break; /* done looking */ } } @@ -325,7 +327,7 @@ MJEvalOuterValues(MergeJoinState *mergestate) /* * MJEvalInnerValues * - * Same as above, but for the inner tuple. Here, we have to be prepared + * Same as above, but for the inner tuple. Here, we have to be prepared * to load data from either the true current inner, or the marked inner, * so caller must tell us which slot to load from. */ @@ -379,8 +381,8 @@ MJCompare(MergeJoinState *mergestate) FunctionCallInfoData fcinfo; /* - * Call the comparison functions in short-lived context, in case they - * leak memory. + * Call the comparison functions in short-lived context, in case they leak + * memory. */ ResetExprContext(econtext); @@ -394,11 +396,11 @@ MJCompare(MergeJoinState *mergestate) /* * Deal with null inputs. We treat NULL as sorting after non-NULL. * - * If both inputs are NULL, and the comparison function isn't - * strict, then we call it and check for a true result (this allows - * operators that behave like IS NOT DISTINCT to be mergejoinable). - * If the function is strict or returns false, we temporarily - * pretend NULL == NULL and contine checking remaining columns. + * If both inputs are NULL, and the comparison function isn't strict, + * then we call it and check for a true result (this allows operators + * that behave like IS NOT DISTINCT to be mergejoinable). If the + * function is strict or returns false, we temporarily pretend NULL == + * NULL and contine checking remaining columns. */ if (clause->lisnull) { @@ -477,7 +479,8 @@ MJCompare(MergeJoinState *mergestate) break; } } - else /* must be MERGEFUNC_CMP */ + else + /* must be MERGEFUNC_CMP */ { InitFunctionCallInfoData(fcinfo, &(clause->cmpfinfo), 2, NULL, NULL); @@ -512,10 +515,10 @@ MJCompare(MergeJoinState *mergestate) } /* - * If we had any null comparison results or NULL-vs-NULL inputs, - * we do not want to report that the tuples are equal. Instead, - * if result is still 0, change it to +1. This will result in - * advancing the inner side of the join. + * If we had any null comparison results or NULL-vs-NULL inputs, we do not + * want to report that the tuples are equal. Instead, if result is still + * 0, change it to +1. This will result in advancing the inner side of + * the join. */ if (nulleqnull && result == 0) result = 1; @@ -544,8 +547,8 @@ MJFillOuter(MergeJoinState *node) if (ExecQual(otherqual, econtext, false)) { /* - * qualification succeeded. now form the desired projection tuple - * and return the slot containing it. + * qualification succeeded. now form the desired projection tuple and + * return the slot containing it. */ TupleTableSlot *result; ExprDoneCond isDone; @@ -583,8 +586,8 @@ MJFillInner(MergeJoinState *node) if (ExecQual(otherqual, econtext, false)) { /* - * qualification succeeded. now form the desired projection tuple - * and return the slot containing it. + * qualification succeeded. now form the desired projection tuple and + * return the slot containing it. */ TupleTableSlot *result; ExprDoneCond isDone; @@ -696,9 +699,9 @@ ExecMergeJoin(MergeJoinState *node) doFillInner = node->mj_FillInner; /* - * Check to see if we're still projecting out tuples from a previous - * join tuple (because there is a function-returning-set in the - * projection expressions). If so, try to project another one. + * Check to see if we're still projecting out tuples from a previous join + * tuple (because there is a function-returning-set in the projection + * expressions). If so, try to project another one. */ if (node->js.ps.ps_TupFromTlist) { @@ -714,8 +717,8 @@ ExecMergeJoin(MergeJoinState *node) /* * Reset per-tuple memory context to free any expression evaluation - * storage allocated in the previous tuple cycle. Note this can't - * happen until we're done projecting out tuples from a join tuple. + * storage allocated in the previous tuple cycle. Note this can't happen + * until we're done projecting out tuples from a join tuple. */ ResetExprContext(econtext); @@ -733,10 +736,10 @@ ExecMergeJoin(MergeJoinState *node) { /* * EXEC_MJ_INITIALIZE_OUTER means that this is the first time - * ExecMergeJoin() has been called and so we have to fetch - * the first matchable tuple for both outer and inner subplans. - * We do the outer side in INITIALIZE_OUTER state, then - * advance to INITIALIZE_INNER state for the inner subplan. + * ExecMergeJoin() has been called and so we have to fetch the + * first matchable tuple for both outer and inner subplans. We + * do the outer side in INITIALIZE_OUTER state, then advance + * to INITIALIZE_INNER state for the inner subplan. */ case EXEC_MJ_INITIALIZE_OUTER: MJ_printf("ExecMergeJoin: EXEC_MJ_INITIALIZE_OUTER\n"); @@ -749,9 +752,9 @@ ExecMergeJoin(MergeJoinState *node) if (doFillInner) { /* - * Need to emit right-join tuples for remaining - * inner tuples. We set MatchedInner = true to - * force the ENDOUTER state to advance inner. + * Need to emit right-join tuples for remaining inner + * tuples. We set MatchedInner = true to force the + * ENDOUTER state to advance inner. */ node->mj_JoinState = EXEC_MJ_ENDOUTER; node->mj_MatchedInner = true; @@ -797,11 +800,10 @@ ExecMergeJoin(MergeJoinState *node) if (doFillOuter) { /* - * Need to emit left-join tuples for all outer - * tuples, including the one we just fetched. We - * set MatchedOuter = false to force the ENDINNER - * state to emit first tuple before advancing - * outer. + * Need to emit left-join tuples for all outer tuples, + * including the one we just fetched. We set + * MatchedOuter = false to force the ENDINNER state to + * emit first tuple before advancing outer. */ node->mj_JoinState = EXEC_MJ_ENDINNER; node->mj_MatchedOuter = false; @@ -840,9 +842,9 @@ ExecMergeJoin(MergeJoinState *node) break; /* - * EXEC_MJ_JOINTUPLES means we have two tuples which - * satisfied the merge clause so we join them and then - * proceed to get the next inner tuple (EXEC_MJ_NEXTINNER). + * EXEC_MJ_JOINTUPLES means we have two tuples which satisfied + * the merge clause so we join them and then proceed to get + * the next inner tuple (EXEC_MJ_NEXTINNER). */ case EXEC_MJ_JOINTUPLES: MJ_printf("ExecMergeJoin: EXEC_MJ_JOINTUPLES\n"); @@ -855,18 +857,18 @@ ExecMergeJoin(MergeJoinState *node) node->mj_JoinState = EXEC_MJ_NEXTINNER; /* - * Check the extra qual conditions to see if we actually - * want to return this join tuple. If not, can proceed - * with merge. We must distinguish the additional - * joinquals (which must pass to consider the tuples - * "matched" for outer-join logic) from the otherquals - * (which must pass before we actually return the tuple). + * Check the extra qual conditions to see if we actually want + * to return this join tuple. If not, can proceed with merge. + * We must distinguish the additional joinquals (which must + * pass to consider the tuples "matched" for outer-join logic) + * from the otherquals (which must pass before we actually + * return the tuple). * * We don't bother with a ResetExprContext here, on the - * assumption that we just did one while checking the - * merge qual. One per tuple should be sufficient. We - * do have to set up the econtext links to the tuples - * for ExecQual to use. + * assumption that we just did one while checking the merge + * qual. One per tuple should be sufficient. We do have to + * set up the econtext links to the tuples for ExecQual to + * use. */ outerTupleSlot = node->mj_OuterTupleSlot; econtext->ecxt_outertuple = outerTupleSlot; @@ -896,8 +898,7 @@ ExecMergeJoin(MergeJoinState *node) { /* * qualification succeeded. now form the desired - * projection tuple and return the slot containing - * it. + * projection tuple and return the slot containing it. */ TupleTableSlot *result; ExprDoneCond isDone; @@ -918,9 +919,9 @@ ExecMergeJoin(MergeJoinState *node) break; /* - * EXEC_MJ_NEXTINNER means advance the inner scan to the - * next tuple. If the tuple is not nil, we then proceed to - * test it against the join qualification. + * EXEC_MJ_NEXTINNER means advance the inner scan to the next + * tuple. If the tuple is not nil, we then proceed to test it + * against the join qualification. * * Before advancing, we check to see if we must emit an * outer-join fill tuple for this inner tuple. @@ -932,8 +933,7 @@ ExecMergeJoin(MergeJoinState *node) { /* * Generate a fake join tuple with nulls for the outer - * tuple, and return it if it passes the non-join - * quals. + * tuple, and return it if it passes the non-join quals. */ TupleTableSlot *result; @@ -945,12 +945,12 @@ ExecMergeJoin(MergeJoinState *node) } /* - * now we get the next inner tuple, if any. If there's - * none, advance to next outer tuple (which may be able - * to join to previously marked tuples). + * now we get the next inner tuple, if any. If there's none, + * advance to next outer tuple (which may be able to join to + * previously marked tuples). * - * If we find one but it cannot join to anything, stay - * in NEXTINNER state to fetch the next one. + * If we find one but it cannot join to anything, stay in + * NEXTINNER state to fetch the next one. */ innerTupleSlot = ExecProcNode(innerPlan); node->mj_InnerTupleSlot = innerTupleSlot; @@ -969,8 +969,8 @@ ExecMergeJoin(MergeJoinState *node) /* * Test the new inner tuple to see if it matches outer. * - * If they do match, then we join them and move on to the - * next inner tuple (EXEC_MJ_JOINTUPLES). + * If they do match, then we join them and move on to the next + * inner tuple (EXEC_MJ_JOINTUPLES). * * If they do not match then advance to next outer tuple. */ @@ -1013,8 +1013,7 @@ ExecMergeJoin(MergeJoinState *node) { /* * Generate a fake join tuple with nulls for the inner - * tuple, and return it if it passes the non-join - * quals. + * tuple, and return it if it passes the non-join quals. */ TupleTableSlot *result; @@ -1034,8 +1033,8 @@ ExecMergeJoin(MergeJoinState *node) node->mj_MatchedOuter = false; /* - * if the outer tuple is null then we are done with the - * join, unless we have inner tuples we need to null-fill. + * if the outer tuple is null then we are done with the join, + * unless we have inner tuples we need to null-fill. */ if (TupIsNull(outerTupleSlot)) { @@ -1044,8 +1043,8 @@ ExecMergeJoin(MergeJoinState *node) if (doFillInner && !TupIsNull(innerTupleSlot)) { /* - * Need to emit right-join tuples for remaining - * inner tuples. + * Need to emit right-join tuples for remaining inner + * tuples. */ node->mj_JoinState = EXEC_MJ_ENDOUTER; break; @@ -1118,26 +1117,25 @@ ExecMergeJoin(MergeJoinState *node) if (compareResult == 0) { /* - * the merge clause matched so now we restore the - * inner scan position to the first mark, and go join - * that tuple (and any following ones) to the new outer. + * the merge clause matched so now we restore the inner + * scan position to the first mark, and go join that tuple + * (and any following ones) to the new outer. * - * NOTE: we do not need to worry about the MatchedInner - * state for the rescanned inner tuples. We know all - * of them will match this new outer tuple and - * therefore won't be emitted as fill tuples. This - * works *only* because we require the extra joinquals - * to be nil when doing a right or full join --- - * otherwise some of the rescanned tuples might fail - * the extra joinquals. + * NOTE: we do not need to worry about the MatchedInner state + * for the rescanned inner tuples. We know all of them + * will match this new outer tuple and therefore won't be + * emitted as fill tuples. This works *only* because we + * require the extra joinquals to be nil when doing a + * right or full join --- otherwise some of the rescanned + * tuples might fail the extra joinquals. */ ExecRestrPos(innerPlan); /* * ExecRestrPos probably should give us back a new Slot, * but since it doesn't, use the marked slot. (The - * previously returned mj_InnerTupleSlot cannot be - * assumed to hold the required tuple.) + * previously returned mj_InnerTupleSlot cannot be assumed + * to hold the required tuple.) */ node->mj_InnerTupleSlot = innerTupleSlot; /* we need not do MJEvalInnerValues again */ @@ -1159,7 +1157,7 @@ ExecMergeJoin(MergeJoinState *node) * which means that all subsequent outer tuples will be * larger than our marked inner tuples. So we need not * revisit any of the marked tuples but can proceed to - * look for a match to the current inner. If there's + * look for a match to the current inner. If there's * no more inners, we are done. * ---------------- */ @@ -1222,8 +1220,8 @@ ExecMergeJoin(MergeJoinState *node) /* * before we advance, make sure the current tuples do not - * satisfy the mergeclauses. If they do, then we update - * the marked tuple position and go join them. + * satisfy the mergeclauses. If they do, then we update the + * marked tuple position and go join them. */ compareResult = MJCompare(node); MJ_DEBUG_COMPARE(compareResult); @@ -1238,7 +1236,8 @@ ExecMergeJoin(MergeJoinState *node) } else if (compareResult < 0) node->mj_JoinState = EXEC_MJ_SKIPOUTER_ADVANCE; - else /* compareResult > 0 */ + else + /* compareResult > 0 */ node->mj_JoinState = EXEC_MJ_SKIPINNER_ADVANCE; break; @@ -1253,8 +1252,7 @@ ExecMergeJoin(MergeJoinState *node) { /* * Generate a fake join tuple with nulls for the inner - * tuple, and return it if it passes the non-join - * quals. + * tuple, and return it if it passes the non-join quals. */ TupleTableSlot *result; @@ -1274,8 +1272,8 @@ ExecMergeJoin(MergeJoinState *node) node->mj_MatchedOuter = false; /* - * if the outer tuple is null then we are done with the - * join, unless we have inner tuples we need to null-fill. + * if the outer tuple is null then we are done with the join, + * unless we have inner tuples we need to null-fill. */ if (TupIsNull(outerTupleSlot)) { @@ -1284,8 +1282,8 @@ ExecMergeJoin(MergeJoinState *node) if (doFillInner && !TupIsNull(innerTupleSlot)) { /* - * Need to emit right-join tuples for remaining - * inner tuples. + * Need to emit right-join tuples for remaining inner + * tuples. */ node->mj_JoinState = EXEC_MJ_ENDOUTER; break; @@ -1317,8 +1315,7 @@ ExecMergeJoin(MergeJoinState *node) { /* * Generate a fake join tuple with nulls for the outer - * tuple, and return it if it passes the non-join - * quals. + * tuple, and return it if it passes the non-join quals. */ TupleTableSlot *result; @@ -1338,8 +1335,8 @@ ExecMergeJoin(MergeJoinState *node) node->mj_MatchedInner = false; /* - * if the inner tuple is null then we are done with the - * join, unless we have outer tuples we need to null-fill. + * if the inner tuple is null then we are done with the join, + * unless we have outer tuples we need to null-fill. */ if (TupIsNull(innerTupleSlot)) { @@ -1348,8 +1345,8 @@ ExecMergeJoin(MergeJoinState *node) if (doFillOuter && !TupIsNull(outerTupleSlot)) { /* - * Need to emit left-join tuples for remaining - * outer tuples. + * Need to emit left-join tuples for remaining outer + * tuples. */ node->mj_JoinState = EXEC_MJ_ENDINNER; break; @@ -1371,9 +1368,9 @@ ExecMergeJoin(MergeJoinState *node) break; /* - * EXEC_MJ_ENDOUTER means we have run out of outer tuples, - * but are doing a right/full join and therefore must - * null-fill any remaing unmatched inner tuples. + * EXEC_MJ_ENDOUTER means we have run out of outer tuples, but + * are doing a right/full join and therefore must null-fill + * any remaing unmatched inner tuples. */ case EXEC_MJ_ENDOUTER: MJ_printf("ExecMergeJoin: EXEC_MJ_ENDOUTER\n"); @@ -1384,8 +1381,7 @@ ExecMergeJoin(MergeJoinState *node) { /* * Generate a fake join tuple with nulls for the outer - * tuple, and return it if it passes the non-join - * quals. + * tuple, and return it if it passes the non-join quals. */ TupleTableSlot *result; @@ -1414,9 +1410,9 @@ ExecMergeJoin(MergeJoinState *node) break; /* - * EXEC_MJ_ENDINNER means we have run out of inner tuples, - * but are doing a left/full join and therefore must null- - * fill any remaing unmatched outer tuples. + * EXEC_MJ_ENDINNER means we have run out of inner tuples, but + * are doing a left/full join and therefore must null- fill + * any remaing unmatched outer tuples. */ case EXEC_MJ_ENDINNER: MJ_printf("ExecMergeJoin: EXEC_MJ_ENDINNER\n"); @@ -1427,8 +1423,7 @@ ExecMergeJoin(MergeJoinState *node) { /* * Generate a fake join tuple with nulls for the inner - * tuple, and return it if it passes the non-join - * quals. + * tuple, and return it if it passes the non-join quals. */ TupleTableSlot *result; @@ -1493,10 +1488,9 @@ ExecInitMergeJoin(MergeJoin *node, EState *estate) ExecAssignExprContext(estate, &mergestate->js.ps); /* - * we need two additional econtexts in which we can compute the - * join expressions from the left and right input tuples. The - * node's regular econtext won't do because it gets reset too - * often. + * we need two additional econtexts in which we can compute the join + * expressions from the left and right input tuples. The node's regular + * econtext won't do because it gets reset too often. */ mergestate->mj_OuterEContext = CreateExprContext(estate); mergestate->mj_InnerEContext = CreateExprContext(estate); @@ -1546,18 +1540,18 @@ ExecInitMergeJoin(MergeJoin *node, EState *estate) mergestate->mj_FillInner = false; mergestate->mj_NullInnerTupleSlot = ExecInitNullTupleSlot(estate, - ExecGetResultType(innerPlanState(mergestate))); + ExecGetResultType(innerPlanState(mergestate))); break; case JOIN_RIGHT: mergestate->mj_FillOuter = false; mergestate->mj_FillInner = true; mergestate->mj_NullOuterTupleSlot = ExecInitNullTupleSlot(estate, - ExecGetResultType(outerPlanState(mergestate))); + ExecGetResultType(outerPlanState(mergestate))); /* - * Can't handle right or full join with non-nil extra - * joinclauses. This should have been caught by planner. + * Can't handle right or full join with non-nil extra joinclauses. + * This should have been caught by planner. */ if (node->join.joinqual != NIL) ereport(ERROR, @@ -1569,14 +1563,13 @@ ExecInitMergeJoin(MergeJoin *node, EState *estate) mergestate->mj_FillInner = true; mergestate->mj_NullOuterTupleSlot = ExecInitNullTupleSlot(estate, - ExecGetResultType(outerPlanState(mergestate))); + ExecGetResultType(outerPlanState(mergestate))); mergestate->mj_NullInnerTupleSlot = ExecInitNullTupleSlot(estate, - ExecGetResultType(innerPlanState(mergestate))); + ExecGetResultType(innerPlanState(mergestate))); /* - * Can't handle right or full join with non-nil extra - * joinclauses. + * Can't handle right or full join with non-nil extra joinclauses. */ if (node->join.joinqual != NIL) ereport(ERROR, @@ -1675,8 +1668,8 @@ ExecReScanMergeJoin(MergeJoinState *node, ExprContext *exprCtxt) node->mj_InnerTupleSlot = NULL; /* - * if chgParam of subnodes is not null then plans will be re-scanned - * by first ExecProcNode. + * if chgParam of subnodes is not null then plans will be re-scanned by + * first ExecProcNode. */ if (((PlanState *) node)->lefttree->chgParam == NULL) ExecReScan(((PlanState *) node)->lefttree, exprCtxt); diff --git a/src/backend/executor/nodeNestloop.c b/src/backend/executor/nodeNestloop.c index 8b48ceefd1..a497e9ac33 100644 --- a/src/backend/executor/nodeNestloop.c +++ b/src/backend/executor/nodeNestloop.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/nodeNestloop.c,v 1.38 2004/12/31 21:59:45 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/executor/nodeNestloop.c,v 1.39 2005/10/15 02:49:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -85,9 +85,9 @@ ExecNestLoop(NestLoopState *node) econtext->ecxt_outertuple = outerTupleSlot; /* - * Check to see if we're still projecting out tuples from a previous - * join tuple (because there is a function-returning-set in the - * projection expressions). If so, try to project another one. + * Check to see if we're still projecting out tuples from a previous join + * tuple (because there is a function-returning-set in the projection + * expressions). If so, try to project another one. */ if (node->js.ps.ps_TupFromTlist) { @@ -102,9 +102,9 @@ ExecNestLoop(NestLoopState *node) } /* - * If we're doing an IN join, we want to return at most one row per - * outer tuple; so we can stop scanning the inner scan if we matched - * on the previous try. + * If we're doing an IN join, we want to return at most one row per outer + * tuple; so we can stop scanning the inner scan if we matched on the + * previous try. */ if (node->js.jointype == JOIN_IN && node->nl_MatchedOuter) @@ -112,8 +112,8 @@ ExecNestLoop(NestLoopState *node) /* * Reset per-tuple memory context to free any expression evaluation - * storage allocated in the previous tuple cycle. Note this can't - * happen until we're done projecting out tuples from a join tuple. + * storage allocated in the previous tuple cycle. Note this can't happen + * until we're done projecting out tuples from a join tuple. */ ResetExprContext(econtext); @@ -135,8 +135,7 @@ ExecNestLoop(NestLoopState *node) outerTupleSlot = ExecProcNode(outerPlan); /* - * if there are no more outer tuples, then the join is - * complete.. + * if there are no more outer tuples, then the join is complete.. */ if (TupIsNull(outerTupleSlot)) { @@ -157,8 +156,8 @@ ExecNestLoop(NestLoopState *node) /* * The scan key of the inner plan might depend on the current - * outer tuple (e.g. in index scans), that's why we pass our - * expr context. + * outer tuple (e.g. in index scans), that's why we pass our expr + * context. */ ExecReScan(innerPlan, econtext); } @@ -181,10 +180,10 @@ ExecNestLoop(NestLoopState *node) node->js.jointype == JOIN_LEFT) { /* - * We are doing an outer join and there were no join - * matches for this outer tuple. Generate a fake join - * tuple with nulls for the inner tuple, and return it if - * it passes the non-join quals. + * We are doing an outer join and there were no join matches + * for this outer tuple. Generate a fake join tuple with + * nulls for the inner tuple, and return it if it passes the + * non-join quals. */ econtext->ecxt_innertuple = node->nl_NullInnerTupleSlot; @@ -193,8 +192,8 @@ ExecNestLoop(NestLoopState *node) if (ExecQual(otherqual, econtext, false)) { /* - * qualification was satisfied so we project and - * return the slot containing the result tuple using + * qualification was satisfied so we project and return + * the slot containing the result tuple using * ExecProject(). */ TupleTableSlot *result; @@ -220,12 +219,12 @@ ExecNestLoop(NestLoopState *node) } /* - * at this point we have a new pair of inner and outer tuples so - * we test the inner and outer tuples to see if they satisfy the - * node's qualification. + * at this point we have a new pair of inner and outer tuples so we + * test the inner and outer tuples to see if they satisfy the node's + * qualification. * - * Only the joinquals determine MatchedOuter status, but all quals - * must pass to actually return the tuple. + * Only the joinquals determine MatchedOuter status, but all quals must + * pass to actually return the tuple. */ ENL1_printf("testing qualification"); @@ -236,9 +235,8 @@ ExecNestLoop(NestLoopState *node) if (otherqual == NIL || ExecQual(otherqual, econtext, false)) { /* - * qualification was satisfied so we project and return - * the slot containing the result tuple using - * ExecProject(). + * qualification was satisfied so we project and return the + * slot containing the result tuple using ExecProject(). */ TupleTableSlot *result; ExprDoneCond isDone; @@ -330,7 +328,7 @@ ExecInitNestLoop(NestLoop *node, EState *estate) case JOIN_LEFT: nlstate->nl_NullInnerTupleSlot = ExecInitNullTupleSlot(estate, - ExecGetResultType(innerPlanState(nlstate))); + ExecGetResultType(innerPlanState(nlstate))); break; default: elog(ERROR, "unrecognized join type: %d", @@ -408,10 +406,9 @@ ExecReScanNestLoop(NestLoopState *node, ExprContext *exprCtxt) /* * If outerPlan->chgParam is not null then plan will be automatically - * re-scanned by first ExecProcNode. innerPlan is re-scanned for each - * new outer tuple and MUST NOT be re-scanned from here or you'll get - * troubles from inner index scans when outer Vars are used as - * run-time keys... + * re-scanned by first ExecProcNode. innerPlan is re-scanned for each new + * outer tuple and MUST NOT be re-scanned from here or you'll get troubles + * from inner index scans when outer Vars are used as run-time keys... */ if (outerPlan->chgParam == NULL) ExecReScan(outerPlan, exprCtxt); diff --git a/src/backend/executor/nodeResult.c b/src/backend/executor/nodeResult.c index 7c77dc0712..013c4e9979 100644 --- a/src/backend/executor/nodeResult.c +++ b/src/backend/executor/nodeResult.c @@ -38,7 +38,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/nodeResult.c,v 1.31 2005/04/24 15:32:07 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/nodeResult.c,v 1.32 2005/10/15 02:49:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -92,9 +92,9 @@ ExecResult(ResultState *node) } /* - * Check to see if we're still projecting out tuples from a previous - * scan tuple (because there is a function-returning-set in the - * projection expressions). If so, try to project another one. + * Check to see if we're still projecting out tuples from a previous scan + * tuple (because there is a function-returning-set in the projection + * expressions). If so, try to project another one. */ if (node->ps.ps_TupFromTlist) { @@ -107,16 +107,16 @@ ExecResult(ResultState *node) /* * Reset per-tuple memory context to free any expression evaluation - * storage allocated in the previous tuple cycle. Note this can't - * happen until we're done projecting out tuples from a scan tuple. + * storage allocated in the previous tuple cycle. Note this can't happen + * until we're done projecting out tuples from a scan tuple. */ ResetExprContext(econtext); /* * if rs_done is true then it means that we were asked to return a * constant tuple and we already did the last time ExecResult() was - * called, OR that we failed the constant qual check. Either way, now - * we are through. + * called, OR that we failed the constant qual check. Either way, now we + * are through. */ while (!node->rs_done) { @@ -125,8 +125,7 @@ ExecResult(ResultState *node) if (outerPlan != NULL) { /* - * retrieve tuples from the outer plan until there are no - * more. + * retrieve tuples from the outer plan until there are no more. */ outerTupleSlot = ExecProcNode(outerPlan); @@ -136,8 +135,7 @@ ExecResult(ResultState *node) node->ps.ps_OuterTupleSlot = outerTupleSlot; /* - * XXX gross hack. use outer tuple as scan tuple for - * projection + * XXX gross hack. use outer tuple as scan tuple for projection */ econtext->ecxt_outertuple = outerTupleSlot; econtext->ecxt_scantuple = outerTupleSlot; @@ -145,16 +143,16 @@ ExecResult(ResultState *node) else { /* - * if we don't have an outer plan, then we are just generating - * the results from a constant target list. Do it only once. + * if we don't have an outer plan, then we are just generating the + * results from a constant target list. Do it only once. */ node->rs_done = true; } /* - * form the result tuple using ExecProject(), and return it --- - * unless the projection produces an empty set, in which case we - * must loop back to see if there are more outerPlan tuples. + * form the result tuple using ExecProject(), and return it --- unless + * the projection produces an empty set, in which case we must loop + * back to see if there are more outerPlan tuples. */ resultSlot = ExecProject(node->ps.ps_ProjInfo, &isDone); diff --git a/src/backend/executor/nodeSeqscan.c b/src/backend/executor/nodeSeqscan.c index fab526f399..91e0c81e03 100644 --- a/src/backend/executor/nodeSeqscan.c +++ b/src/backend/executor/nodeSeqscan.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/nodeSeqscan.c,v 1.53 2005/05/15 21:19:55 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/nodeSeqscan.c,v 1.54 2005/10/15 02:49:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -62,11 +62,11 @@ SeqNext(SeqScanState *node) slot = node->ss_ScanTupleSlot; /* - * Clear any reference to the previously returned tuple. The idea - * here is to not have the tuple slot be the last holder of a pin on - * that tuple's buffer; if it is, we'll need a separate visit to the - * bufmgr to release the buffer. By clearing here, we get to have the - * release done by ReleaseAndReadBuffer inside heap_getnext. + * Clear any reference to the previously returned tuple. The idea here is + * to not have the tuple slot be the last holder of a pin on that tuple's + * buffer; if it is, we'll need a separate visit to the bufmgr to release + * the buffer. By clearing here, we get to have the release done by + * ReleaseAndReadBuffer inside heap_getnext. */ ExecClearTuple(slot); @@ -87,8 +87,8 @@ SeqNext(SeqScanState *node) /* * Note that unlike IndexScan, SeqScan never use keys in - * heap_beginscan (and this is very bad) - so, here we do not - * check are keys ok or not. + * heap_beginscan (and this is very bad) - so, here we do not check + * are keys ok or not. */ /* Flag for the next call that no more tuples */ @@ -102,20 +102,19 @@ SeqNext(SeqScanState *node) tuple = heap_getnext(scandesc, direction); /* - * save the tuple and the buffer returned to us by the access methods - * in our scan tuple slot and return the slot. Note: we pass 'false' - * because tuples returned by heap_getnext() are pointers onto disk - * pages and were not created with palloc() and so should not be - * pfree()'d. Note also that ExecStoreTuple will increment the - * refcount of the buffer; the refcount will not be dropped until the - * tuple table slot is cleared. + * save the tuple and the buffer returned to us by the access methods in + * our scan tuple slot and return the slot. Note: we pass 'false' because + * tuples returned by heap_getnext() are pointers onto disk pages and were + * not created with palloc() and so should not be pfree()'d. Note also + * that ExecStoreTuple will increment the refcount of the buffer; the + * refcount will not be dropped until the tuple table slot is cleared. */ if (tuple) - ExecStoreTuple(tuple, /* tuple to store */ - slot, /* slot to store in */ - scandesc->rs_cbuf, /* buffer associated with - * this tuple */ - false); /* don't pfree this pointer */ + ExecStoreTuple(tuple, /* tuple to store */ + slot, /* slot to store in */ + scandesc->rs_cbuf, /* buffer associated with this + * tuple */ + false); /* don't pfree this pointer */ return slot; } @@ -157,8 +156,8 @@ InitScanRelation(SeqScanState *node, EState *estate) HeapScanDesc currentScanDesc; /* - * get the relation object id from the relid'th entry in the range - * table, open that relation and initialize the scan state. + * get the relation object id from the relid'th entry in the range table, + * open that relation and initialize the scan state. * * We acquire AccessShareLock for the duration of the scan. */ @@ -191,8 +190,8 @@ ExecInitSeqScan(SeqScan *node, EState *estate) SeqScanState *scanstate; /* - * Once upon a time it was possible to have an outerPlan of a SeqScan, - * but not any more. + * Once upon a time it was possible to have an outerPlan of a SeqScan, but + * not any more. */ Assert(outerPlan(node) == NULL); Assert(innerPlan(node) == NULL); @@ -291,9 +290,8 @@ ExecEndSeqScan(SeqScanState *node) * close the heap relation. * * Currently, we do not release the AccessShareLock acquired by - * InitScanRelation. This lock should be held till end of - * transaction. (There is a faction that considers this too much - * locking, however.) + * InitScanRelation. This lock should be held till end of transaction. + * (There is a faction that considers this too much locking, however.) */ heap_close(relation, NoLock); } @@ -359,10 +357,10 @@ ExecSeqRestrPos(SeqScanState *node) HeapScanDesc scan = node->ss_currentScanDesc; /* - * Clear any reference to the previously returned tuple. This is - * needed because the slot is simply pointing at scan->rs_cbuf, which - * heap_restrpos will change; we'd have an internally inconsistent - * slot if we didn't do this. + * Clear any reference to the previously returned tuple. This is needed + * because the slot is simply pointing at scan->rs_cbuf, which + * heap_restrpos will change; we'd have an internally inconsistent slot if + * we didn't do this. */ ExecClearTuple(node->ss_ScanTupleSlot); diff --git a/src/backend/executor/nodeSetOp.c b/src/backend/executor/nodeSetOp.c index 6daadfd0b8..a5ca58354c 100644 --- a/src/backend/executor/nodeSetOp.c +++ b/src/backend/executor/nodeSetOp.c @@ -21,7 +21,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/nodeSetOp.c,v 1.17 2005/05/06 17:24:54 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/nodeSetOp.c,v 1.18 2005/10/15 02:49:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -58,8 +58,8 @@ ExecSetOp(SetOpState *node) resultTupleSlot = node->ps.ps_ResultTupleSlot; /* - * If the previously-returned tuple needs to be returned more than - * once, keep returning it. + * If the previously-returned tuple needs to be returned more than once, + * keep returning it. */ if (node->numOutput > 0) { @@ -71,9 +71,9 @@ ExecSetOp(SetOpState *node) ExecClearTuple(resultTupleSlot); /* - * Absorb groups of duplicate tuples, counting them, and saving the - * first of each group as a possible return value. At the end of each - * group, decide whether to return anything. + * Absorb groups of duplicate tuples, counting them, and saving the first + * of each group as a possible return value. At the end of each group, + * decide whether to return anything. * * We assume that the tuples arrive in sorted order so we can detect * duplicates easily. @@ -177,8 +177,8 @@ ExecSetOp(SetOpState *node) else { /* - * Current tuple is member of same group as resultTuple. Count - * it in the appropriate counter. + * Current tuple is member of same group as resultTuple. Count it + * in the appropriate counter. */ int flag; bool isNull; @@ -232,8 +232,8 @@ ExecInitSetOp(SetOp *node, EState *estate) * Miscellaneous initialization * * SetOp nodes have no ExprContext initialization because they never call - * ExecQual or ExecProject. But they do need a per-tuple memory - * context anyway for calling execTuplesMatch. + * ExecQual or ExecProject. But they do need a per-tuple memory context + * anyway for calling execTuplesMatch. */ setopstate->tempContext = AllocSetContextCreate(CurrentMemoryContext, @@ -255,8 +255,8 @@ ExecInitSetOp(SetOp *node, EState *estate) outerPlanState(setopstate) = ExecInitNode(outerPlan(node), estate); /* - * setop nodes do no projections, so initialize projection info for - * this node appropriately + * setop nodes do no projections, so initialize projection info for this + * node appropriately */ ExecAssignResultTypeFromOuterPlan(&setopstate->ps); setopstate->ps.ps_ProjInfo = NULL; diff --git a/src/backend/executor/nodeSort.c b/src/backend/executor/nodeSort.c index ef02537414..d3e4fb5e0b 100644 --- a/src/backend/executor/nodeSort.c +++ b/src/backend/executor/nodeSort.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/nodeSort.c,v 1.50 2005/03/16 21:38:08 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/nodeSort.c,v 1.51 2005/10/15 02:49:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -56,9 +56,8 @@ ExecSort(SortState *node) tuplesortstate = (Tuplesortstate *) node->tuplesortstate; /* - * If first time through, read all tuples from outer plan and pass - * them to tuplesort.c. Subsequent calls just fetch tuples from - * tuplesort. + * If first time through, read all tuples from outer plan and pass them to + * tuplesort.c. Subsequent calls just fetch tuples from tuplesort. */ if (!node->sort_Done) @@ -71,8 +70,8 @@ ExecSort(SortState *node) "sorting subplan"); /* - * Want to scan subplan in the forward direction while creating - * the sorted data. + * Want to scan subplan in the forward direction while creating the + * sorted data. */ estate->es_direction = ForwardScanDirection; @@ -191,8 +190,8 @@ ExecInitSort(Sort *node, EState *estate) outerPlanState(sortstate) = ExecInitNode(outerPlan(node), estate); /* - * initialize tuple type. no need to initialize projection info - * because this node doesn't do projections. + * initialize tuple type. no need to initialize projection info because + * this node doesn't do projections. */ ExecAssignResultTypeFromOuterPlan(&sortstate->ss.ps); ExecAssignScanTypeFromOuterPlan(&sortstate->ss); @@ -286,9 +285,9 @@ void ExecReScanSort(SortState *node, ExprContext *exprCtxt) { /* - * If we haven't sorted yet, just return. If outerplan' chgParam is - * not NULL then it will be re-scanned by ExecProcNode, else - no - * reason to re-scan it at all. + * If we haven't sorted yet, just return. If outerplan' chgParam is not + * NULL then it will be re-scanned by ExecProcNode, else - no reason to + * re-scan it at all. */ if (!node->sort_Done) return; @@ -296,8 +295,8 @@ ExecReScanSort(SortState *node, ExprContext *exprCtxt) ExecClearTuple(node->ss.ps.ps_ResultTupleSlot); /* - * If subnode is to be rescanned then we forget previous sort results; - * we have to re-read the subplan and re-sort. + * If subnode is to be rescanned then we forget previous sort results; we + * have to re-read the subplan and re-sort. * * Otherwise we can just rewind and rescan the sorted output. */ diff --git a/src/backend/executor/nodeSubplan.c b/src/backend/executor/nodeSubplan.c index 5bed87aea9..0e7b6df722 100644 --- a/src/backend/executor/nodeSubplan.c +++ b/src/backend/executor/nodeSubplan.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/nodeSubplan.c,v 1.69 2005/05/06 17:24:54 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/nodeSubplan.c,v 1.70 2005/10/15 02:49:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -86,15 +86,15 @@ ExecHashSubPlan(SubPlanState *node, elog(ERROR, "hashed subplan with direct correlation not supported"); /* - * If first time through or we need to rescan the subplan, build the - * hash table. + * If first time through or we need to rescan the subplan, build the hash + * table. */ if (node->hashtable == NULL || planstate->chgParam != NULL) buildSubPlanHash(node); /* - * The result for an empty subplan is always FALSE; no need to - * evaluate lefthand side. + * The result for an empty subplan is always FALSE; no need to evaluate + * lefthand side. */ *isNull = false; if (!node->havehashrows && !node->havenullrows) @@ -108,34 +108,32 @@ ExecHashSubPlan(SubPlanState *node, slot = ExecProject(node->projLeft, NULL); /* - * Note: because we are typically called in a per-tuple context, we - * have to explicitly clear the projected tuple before returning. - * Otherwise, we'll have a double-free situation: the per-tuple - * context will probably be reset before we're called again, and then - * the tuple slot will think it still needs to free the tuple. + * Note: because we are typically called in a per-tuple context, we have + * to explicitly clear the projected tuple before returning. Otherwise, + * we'll have a double-free situation: the per-tuple context will probably + * be reset before we're called again, and then the tuple slot will think + * it still needs to free the tuple. */ /* - * Since the hashtable routines will use innerecontext's per-tuple - * memory as working memory, be sure to reset it for each tuple. + * Since the hashtable routines will use innerecontext's per-tuple memory + * as working memory, be sure to reset it for each tuple. */ ResetExprContext(innerecontext); /* - * If the LHS is all non-null, probe for an exact match in the main - * hash table. If we find one, the result is TRUE. Otherwise, scan - * the partly-null table to see if there are any rows that aren't - * provably unequal to the LHS; if so, the result is UNKNOWN. (We - * skip that part if we don't care about UNKNOWN.) Otherwise, the - * result is FALSE. + * If the LHS is all non-null, probe for an exact match in the main hash + * table. If we find one, the result is TRUE. Otherwise, scan the + * partly-null table to see if there are any rows that aren't provably + * unequal to the LHS; if so, the result is UNKNOWN. (We skip that part + * if we don't care about UNKNOWN.) Otherwise, the result is FALSE. * - * Note: the reason we can avoid a full scan of the main hash table is - * that the combining operators are assumed never to yield NULL when - * both inputs are non-null. If they were to do so, we might need to - * produce UNKNOWN instead of FALSE because of an UNKNOWN result in - * comparing the LHS to some main-table entry --- which is a - * comparison we will not even make, unless there's a chance match of - * hash keys. + * Note: the reason we can avoid a full scan of the main hash table is that + * the combining operators are assumed never to yield NULL when both + * inputs are non-null. If they were to do so, we might need to produce + * UNKNOWN instead of FALSE because of an UNKNOWN result in comparing the + * LHS to some main-table entry --- which is a comparison we will not even + * make, unless there's a chance match of hash keys. */ if (slotNoNulls(slot)) { @@ -157,14 +155,14 @@ ExecHashSubPlan(SubPlanState *node, } /* - * When the LHS is partly or wholly NULL, we can never return TRUE. If - * we don't care about UNKNOWN, just return FALSE. Otherwise, if the - * LHS is wholly NULL, immediately return UNKNOWN. (Since the - * combining operators are strict, the result could only be FALSE if - * the sub-select were empty, but we already handled that case.) - * Otherwise, we must scan both the main and partly-null tables to see - * if there are any rows that aren't provably unequal to the LHS; if - * so, the result is UNKNOWN. Otherwise, the result is FALSE. + * When the LHS is partly or wholly NULL, we can never return TRUE. If we + * don't care about UNKNOWN, just return FALSE. Otherwise, if the LHS is + * wholly NULL, immediately return UNKNOWN. (Since the combining + * operators are strict, the result could only be FALSE if the sub-select + * were empty, but we already handled that case.) Otherwise, we must scan + * both the main and partly-null tables to see if there are any rows that + * aren't provably unequal to the LHS; if so, the result is UNKNOWN. + * Otherwise, the result is FALSE. */ if (node->hashnulls == NULL) { @@ -217,9 +215,9 @@ ExecScanSubPlan(SubPlanState *node, ArrayBuildState *astate = NULL; /* - * We are probably in a short-lived expression-evaluation context. - * Switch to the child plan's per-query context for manipulating its - * chgParam, calling ExecProcNode on it, etc. + * We are probably in a short-lived expression-evaluation context. Switch + * to the child plan's per-query context for manipulating its chgParam, + * calling ExecProcNode on it, etc. */ oldcontext = MemoryContextSwitchTo(node->sub_estate->es_query_cxt); @@ -245,24 +243,23 @@ ExecScanSubPlan(SubPlanState *node, ExecReScan(planstate, NULL); /* - * For all sublink types except EXPR_SUBLINK and ARRAY_SUBLINK, the - * result is boolean as are the results of the combining operators. We - * combine results within a tuple (if there are multiple columns) - * using OR semantics if "useOr" is true, AND semantics if not. We - * then combine results across tuples (if the subplan produces more - * than one) using OR semantics for ANY_SUBLINK or AND semantics for - * ALL_SUBLINK. (MULTIEXPR_SUBLINK doesn't allow multiple tuples from - * the subplan.) NULL results from the combining operators are handled - * according to the usual SQL semantics for OR and AND. The result - * for no input tuples is FALSE for ANY_SUBLINK, TRUE for ALL_SUBLINK, - * NULL for MULTIEXPR_SUBLINK. + * For all sublink types except EXPR_SUBLINK and ARRAY_SUBLINK, the result + * is boolean as are the results of the combining operators. We combine + * results within a tuple (if there are multiple columns) using OR + * semantics if "useOr" is true, AND semantics if not. We then combine + * results across tuples (if the subplan produces more than one) using OR + * semantics for ANY_SUBLINK or AND semantics for ALL_SUBLINK. + * (MULTIEXPR_SUBLINK doesn't allow multiple tuples from the subplan.) + * NULL results from the combining operators are handled according to the + * usual SQL semantics for OR and AND. The result for no input tuples is + * FALSE for ANY_SUBLINK, TRUE for ALL_SUBLINK, NULL for + * MULTIEXPR_SUBLINK. * - * For EXPR_SUBLINK we require the subplan to produce no more than one - * tuple, else an error is raised. For ARRAY_SUBLINK we allow the - * subplan to produce more than one tuple. In either case, if zero - * tuples are produced, we return NULL. Assuming we get a tuple, we - * just use its first column (there can be only one non-junk column in - * this case). + * For EXPR_SUBLINK we require the subplan to produce no more than one tuple, + * else an error is raised. For ARRAY_SUBLINK we allow the subplan to + * produce more than one tuple. In either case, if zero tuples are + * produced, we return NULL. Assuming we get a tuple, we just use its + * first column (there can be only one non-junk column in this case). */ result = BoolGetDatum(subLinkType == ALL_SUBLINK); *isNull = false; @@ -294,12 +291,12 @@ ExecScanSubPlan(SubPlanState *node, found = true; /* - * We need to copy the subplan's tuple in case the result is - * of pass-by-ref type --- our return value will point into - * this copied tuple! Can't use the subplan's instance of the - * tuple since it won't still be valid after next - * ExecProcNode() call. node->curTuple keeps track of the - * copied tuple for eventual freeing. + * We need to copy the subplan's tuple in case the result is of + * pass-by-ref type --- our return value will point into this + * copied tuple! Can't use the subplan's instance of the tuple + * since it won't still be valid after next ExecProcNode() call. + * node->curTuple keeps track of the copied tuple for eventual + * freeing. */ MemoryContextSwitchTo(econtext->ecxt_per_query_memory); if (node->curTuple) @@ -350,8 +347,7 @@ ExecScanSubPlan(SubPlanState *node, bool expnull; /* - * Load up the Param representing this column of the - * sub-select. + * Load up the Param representing this column of the sub-select. */ prmdata = &(econtext->ecxt_param_exec_vals[paramid]); Assert(prmdata->execPlan == NULL); @@ -436,8 +432,8 @@ ExecScanSubPlan(SubPlanState *node, { /* * deal with empty subplan result. result/isNull were previously - * initialized correctly for all sublink types except EXPR, ARRAY, - * and MULTIEXPR; for those, return NULL. + * initialized correctly for all sublink types except EXPR, ARRAY, and + * MULTIEXPR; for those, return NULL. */ if (subLinkType == EXPR_SUBLINK || subLinkType == ARRAY_SUBLINK || @@ -478,19 +474,19 @@ buildSubPlanHash(SubPlanState *node) Assert(!subplan->useOr); /* - * If we already had any hash tables, destroy 'em; then create empty - * hash table(s). + * If we already had any hash tables, destroy 'em; then create empty hash + * table(s). * * If we need to distinguish accurately between FALSE and UNKNOWN (i.e., - * NULL) results of the IN operation, then we have to store subplan - * output rows that are partly or wholly NULL. We store such rows in - * a separate hash table that we expect will be much smaller than the - * main table. (We can use hashing to eliminate partly-null rows that - * are not distinct. We keep them separate to minimize the cost of - * the inevitable full-table searches; see findPartialMatch.) + * NULL) results of the IN operation, then we have to store subplan output + * rows that are partly or wholly NULL. We store such rows in a separate + * hash table that we expect will be much smaller than the main table. + * (We can use hashing to eliminate partly-null rows that are not + * distinct. We keep them separate to minimize the cost of the inevitable + * full-table searches; see findPartialMatch.) * - * If it's not necessary to distinguish FALSE and UNKNOWN, then we don't - * need to store subplan output rows that contain NULL. + * If it's not necessary to distinguish FALSE and UNKNOWN, then we don't need + * to store subplan output rows that contain NULL. */ MemoryContextReset(node->tablecxt); node->hashtable = NULL; @@ -532,9 +528,8 @@ buildSubPlanHash(SubPlanState *node) } /* - * We are probably in a short-lived expression-evaluation context. - * Switch to the child plan's per-query context for calling - * ExecProcNode. + * We are probably in a short-lived expression-evaluation context. Switch + * to the child plan's per-query context for calling ExecProcNode. */ oldcontext = MemoryContextSwitchTo(node->sub_estate->es_query_cxt); @@ -544,9 +539,8 @@ buildSubPlanHash(SubPlanState *node) ExecReScan(planstate, NULL); /* - * Scan the subplan and load the hash table(s). Note that when there - * are duplicate rows coming out of the sub-select, only one copy is - * stored. + * Scan the subplan and load the hash table(s). Note that when there are + * duplicate rows coming out of the sub-select, only one copy is stored. */ for (slot = ExecProcNode(planstate); !TupIsNull(slot); @@ -557,8 +551,8 @@ buildSubPlanHash(SubPlanState *node) bool isnew; /* - * Load up the Params representing the raw sub-select outputs, - * then form the projection tuple to store in the hashtable. + * Load up the Params representing the raw sub-select outputs, then + * form the projection tuple to store in the hashtable. */ foreach(plst, subplan->paramIds) { @@ -588,18 +582,18 @@ buildSubPlanHash(SubPlanState *node) } /* - * Reset innerecontext after each inner tuple to free any memory - * used in hash computation or comparison routines. + * Reset innerecontext after each inner tuple to free any memory used + * in hash computation or comparison routines. */ ResetExprContext(innerecontext); } /* - * Since the projected tuples are in the sub-query's context and not - * the main context, we'd better clear the tuple slot before there's - * any chance of a reset of the sub-query's context. Else we will - * have the potential for a double free attempt. (XXX possibly - * no longer needed, but can't hurt.) + * Since the projected tuples are in the sub-query's context and not the + * main context, we'd better clear the tuple slot before there's any + * chance of a reset of the sub-query's context. Else we will have the + * potential for a double free attempt. (XXX possibly no longer needed, + * but can't hurt.) */ ExecClearTuple(node->projRight->pi_slot); @@ -710,10 +704,10 @@ ExecInitSubPlan(SubPlanState *node, EState *estate) /* * create an EState for the subplan * - * The subquery needs its own EState because it has its own rangetable. - * It shares our Param ID space, however. XXX if rangetable access - * were done differently, the subquery could share our EState, which - * would eliminate some thrashing about in this module... + * The subquery needs its own EState because it has its own rangetable. It + * shares our Param ID space, however. XXX if rangetable access were done + * differently, the subquery could share our EState, which would eliminate + * some thrashing about in this module... */ sp_estate = CreateExecutorState(); node->sub_estate = sp_estate; @@ -739,13 +733,12 @@ ExecInitSubPlan(SubPlanState *node, EState *estate) MemoryContextSwitchTo(oldcontext); /* - * If this plan is un-correlated or undirect correlated one and want - * to set params for parent plan then mark parameters as needing - * evaluation. + * If this plan is un-correlated or undirect correlated one and want to + * set params for parent plan then mark parameters as needing evaluation. * * Note that in the case of un-correlated subqueries we don't care about - * setting parent->chgParam here: indices take care about it, for - * others - it doesn't matter... + * setting parent->chgParam here: indices take care about it, for others - + * it doesn't matter... */ if (subplan->setParam != NIL) { @@ -761,8 +754,8 @@ ExecInitSubPlan(SubPlanState *node, EState *estate) } /* - * If we are going to hash the subquery output, initialize relevant - * stuff. (We don't create the hashtable until needed, though.) + * If we are going to hash the subquery output, initialize relevant stuff. + * (We don't create the hashtable until needed, though.) */ if (subplan->useHashTable) { @@ -794,18 +787,17 @@ ExecInitSubPlan(SubPlanState *node, EState *estate) /* * We use ExecProject to evaluate the lefthand and righthand - * expression lists and form tuples. (You might think that we - * could use the sub-select's output tuples directly, but that is - * not the case if we had to insert any run-time coercions of the - * sub-select's output datatypes; anyway this avoids storing any - * resjunk columns that might be in the sub-select's output.) Run - * through the combining expressions to build tlists for the - * lefthand and righthand sides. We need both the ExprState list - * (for ExecProject) and the underlying parse Exprs (for - * ExecTypeFromTL). + * expression lists and form tuples. (You might think that we could + * use the sub-select's output tuples directly, but that is not the + * case if we had to insert any run-time coercions of the sub-select's + * output datatypes; anyway this avoids storing any resjunk columns + * that might be in the sub-select's output.) Run through the + * combining expressions to build tlists for the lefthand and + * righthand sides. We need both the ExprState list (for ExecProject) + * and the underlying parse Exprs (for ExecTypeFromTL). * - * We also extract the combining operators themselves to initialize - * the equality and hashing functions for the hash tables. + * We also extract the combining operators themselves to initialize the + * equality and hashing functions for the hash tables. */ lefttlist = righttlist = NIL; leftptlist = rightptlist = NIL; @@ -869,21 +861,21 @@ ExecInitSubPlan(SubPlanState *node, EState *estate) } /* - * Create a tupletable to hold these tuples. (Note: we never - * bother to free the tupletable explicitly; that's okay because - * it will never store raw disk tuples that might have associated - * buffer pins. The only resource involved is memory, which will - * be cleaned up by freeing the query context.) + * Create a tupletable to hold these tuples. (Note: we never bother + * to free the tupletable explicitly; that's okay because it will + * never store raw disk tuples that might have associated buffer pins. + * The only resource involved is memory, which will be cleaned up by + * freeing the query context.) */ tupTable = ExecCreateTupleTable(2); /* - * Construct tupdescs, slots and projection nodes for left and - * right sides. The lefthand expressions will be evaluated in the - * parent plan node's exprcontext, which we don't have access to - * here. Fortunately we can just pass NULL for now and fill it in - * later (hack alert!). The righthand expressions will be - * evaluated in our own innerecontext. + * Construct tupdescs, slots and projection nodes for left and right + * sides. The lefthand expressions will be evaluated in the parent + * plan node's exprcontext, which we don't have access to here. + * Fortunately we can just pass NULL for now and fill it in later + * (hack alert!). The righthand expressions will be evaluated in our + * own innerecontext. */ tupDesc = ExecTypeFromTL(leftptlist, false); slot = ExecAllocTableSlot(tupTable); @@ -983,11 +975,10 @@ ExecSetParamPlan(SubPlanState *node, ExprContext *econtext) found = true; /* - * We need to copy the subplan's tuple into our own context, in - * case any of the params are pass-by-ref type --- the pointers - * stored in the param structs will point at this copied tuple! - * node->curTuple keeps track of the copied tuple for eventual - * freeing. + * We need to copy the subplan's tuple into our own context, in case + * any of the params are pass-by-ref type --- the pointers stored in + * the param structs will point at this copied tuple! node->curTuple + * keeps track of the copied tuple for eventual freeing. */ MemoryContextSwitchTo(econtext->ecxt_per_query_memory); if (node->curTuple) diff --git a/src/backend/executor/nodeSubqueryscan.c b/src/backend/executor/nodeSubqueryscan.c index 90e59f90f4..9b1bd25143 100644 --- a/src/backend/executor/nodeSubqueryscan.c +++ b/src/backend/executor/nodeSubqueryscan.c @@ -12,7 +12,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/nodeSubqueryscan.c,v 1.26 2005/05/22 22:30:19 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/nodeSubqueryscan.c,v 1.27 2005/10/15 02:49:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -62,13 +62,13 @@ SubqueryNext(SubqueryScanState *node) direction = estate->es_direction; /* - * We need not support EvalPlanQual here, since we are not scanning a - * real relation. + * We need not support EvalPlanQual here, since we are not scanning a real + * relation. */ /* - * Get the next tuple from the sub-query. We have to be careful to - * run it in its appropriate memory context. + * Get the next tuple from the sub-query. We have to be careful to run it + * in its appropriate memory context. */ node->sss_SubEState->es_direction = direction; @@ -170,11 +170,10 @@ ExecInitSubqueryScan(SubqueryScan *node, EState *estate) ExecCheckRTPerms(rte->subquery->rtable); /* - * The subquery needs its own EState because it has its own - * rangetable. It shares our Param ID space, however. XXX if - * rangetable access were done differently, the subquery could share - * our EState, which would eliminate some thrashing about in this - * module... + * The subquery needs its own EState because it has its own rangetable. It + * shares our Param ID space, however. XXX if rangetable access were done + * differently, the subquery could share our EState, which would eliminate + * some thrashing about in this module... */ sp_estate = CreateExecutorState(); subquerystate->sss_SubEState = sp_estate; @@ -246,7 +245,7 @@ ExecEndSubqueryScan(SubqueryScanState *node) * clean out the upper tuple table */ ExecClearTuple(node->ss.ps.ps_ResultTupleSlot); - node->ss.ss_ScanTupleSlot = NULL; /* not ours to clear */ + node->ss.ss_ScanTupleSlot = NULL; /* not ours to clear */ /* * close down subquery @@ -278,9 +277,8 @@ ExecSubqueryReScan(SubqueryScanState *node, ExprContext *exprCtxt) /* * ExecReScan doesn't know about my subplan, so I have to do - * changed-parameter signaling myself. This is just as well, because - * the subplan has its own memory context in which its chgParam state - * lives. + * changed-parameter signaling myself. This is just as well, because the + * subplan has its own memory context in which its chgParam state lives. */ if (node->ss.ps.chgParam != NULL) UpdateChangedParamSet(node->subplan, node->ss.ps.chgParam); diff --git a/src/backend/executor/nodeTidscan.c b/src/backend/executor/nodeTidscan.c index 4cc1e4df14..c8708f5831 100644 --- a/src/backend/executor/nodeTidscan.c +++ b/src/backend/executor/nodeTidscan.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/nodeTidscan.c,v 1.42 2005/09/22 15:09:51 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/nodeTidscan.c,v 1.43 2005/10/15 02:49:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -126,8 +126,8 @@ TidNext(TidScanState *node) return slot; /* return empty slot */ /* - * XXX shouldn't we check here to make sure tuple matches TID - * list? In runtime-key case this is not certain, is it? + * XXX shouldn't we check here to make sure tuple matches TID list? In + * runtime-key case this is not certain, is it? */ ExecStoreTuple(estate->es_evTuple[scanrelid - 1], @@ -150,9 +150,9 @@ TidNext(TidScanState *node) tuple = &(node->tss_htup); /* - * ok, now that we have what we need, fetch an tid tuple. if scanning - * this tid succeeded then return the appropriate heap tuple.. else - * return NULL. + * ok, now that we have what we need, fetch an tid tuple. if scanning this + * tid succeeded then return the appropriate heap tuple.. else return + * NULL. */ bBackward = ScanDirectionIsBackward(direction); if (bBackward) @@ -184,10 +184,10 @@ TidNext(TidScanState *node) /* * store the scanned tuple in the scan tuple slot of the scan - * state. Eventually we will only do this and not return a - * tuple. Note: we pass 'false' because tuples returned by - * amgetnext are pointers onto disk pages and were not created - * with palloc() and so should not be pfree()'d. + * state. Eventually we will only do this and not return a tuple. + * Note: we pass 'false' because tuples returned by amgetnext are + * pointers onto disk pages and were not created with palloc() and + * so should not be pfree()'d. */ ExecStoreTuple(tuple, /* tuple to store */ slot, /* slot to store in */ @@ -196,8 +196,7 @@ TidNext(TidScanState *node) /* * At this point we have an extra pin on the buffer, because - * ExecStoreTuple incremented the pin count. Drop our local - * pin. + * ExecStoreTuple incremented the pin count. Drop our local pin. */ ReleaseBuffer(buffer); @@ -229,8 +228,8 @@ TidNext(TidScanState *node) } /* - * if we get here it means the tid scan failed so we are at the end of - * the scan.. + * if we get here it means the tid scan failed so we are at the end of the + * scan.. */ return ExecClearTuple(slot); } @@ -420,8 +419,8 @@ ExecInitTidScan(TidScan *node, EState *estate) tidstate->tss_TidPtr = -1; /* - * get the range table and direction information from the execution - * state (these are needed to open the relations). + * get the range table and direction information from the execution state + * (these are needed to open the relations). */ rangeTable = estate->es_range_table; diff --git a/src/backend/executor/nodeUnique.c b/src/backend/executor/nodeUnique.c index b00a572e14..ab3879d7cc 100644 --- a/src/backend/executor/nodeUnique.c +++ b/src/backend/executor/nodeUnique.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/nodeUnique.c,v 1.47 2005/05/06 17:24:54 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/nodeUnique.c,v 1.48 2005/10/15 02:49:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -56,10 +56,10 @@ ExecUnique(UniqueState *node) * now loop, returning only non-duplicate tuples. We assume that the * tuples arrive in sorted order so we can detect duplicates easily. * - * We return the first tuple from each group of duplicates (or the last - * tuple of each group, when moving backwards). At either end of the - * subplan, clear the result slot so that we correctly return the - * first/last tuple when reversing direction. + * We return the first tuple from each group of duplicates (or the last tuple + * of each group, when moving backwards). At either end of the subplan, + * clear the result slot so that we correctly return the first/last tuple + * when reversing direction. */ for (;;) { @@ -81,9 +81,9 @@ ExecUnique(UniqueState *node) break; /* - * Else test if the new tuple and the previously returned tuple - * match. If so then we loop back and fetch another new tuple - * from the subplan. + * Else test if the new tuple and the previously returned tuple match. + * If so then we loop back and fetch another new tuple from the + * subplan. */ if (!execTuplesMatch(slot, resultTupleSlot, plannode->numCols, plannode->uniqColIdx, @@ -93,10 +93,10 @@ ExecUnique(UniqueState *node) } /* - * We have a new tuple different from the previous saved tuple (if - * any). Save it and return it. We must copy it because the source - * subplan won't guarantee that this source tuple is still accessible - * after fetching the next source tuple. + * We have a new tuple different from the previous saved tuple (if any). + * Save it and return it. We must copy it because the source subplan + * won't guarantee that this source tuple is still accessible after + * fetching the next source tuple. */ return ExecCopySlot(resultTupleSlot, slot); } @@ -123,9 +123,9 @@ ExecInitUnique(Unique *node, EState *estate) /* * Miscellaneous initialization * - * Unique nodes have no ExprContext initialization because they never - * call ExecQual or ExecProject. But they do need a per-tuple memory - * context anyway for calling execTuplesMatch. + * Unique nodes have no ExprContext initialization because they never call + * ExecQual or ExecProject. But they do need a per-tuple memory context + * anyway for calling execTuplesMatch. */ uniquestate->tempContext = AllocSetContextCreate(CurrentMemoryContext, @@ -147,8 +147,8 @@ ExecInitUnique(Unique *node, EState *estate) outerPlanState(uniquestate) = ExecInitNode(outerPlan(node), estate); /* - * unique nodes do no projections, so initialize projection info for - * this node appropriately + * unique nodes do no projections, so initialize projection info for this + * node appropriately */ ExecAssignResultTypeFromOuterPlan(&uniquestate->ps); uniquestate->ps.ps_ProjInfo = NULL; diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c index ff1b8932ea..c4aef41a8d 100644 --- a/src/backend/executor/spi.c +++ b/src/backend/executor/spi.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.142 2005/10/01 18:43:19 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.143 2005/10/15 02:49:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -38,11 +38,11 @@ static int _SPI_curid = -1; static void _SPI_prepare_plan(const char *src, _SPI_plan *plan); static int _SPI_execute_plan(_SPI_plan *plan, - Datum *Values, const char *Nulls, - Snapshot snapshot, Snapshot crosscheck_snapshot, - bool read_only, long tcount); + Datum *Values, const char *Nulls, + Snapshot snapshot, Snapshot crosscheck_snapshot, + bool read_only, long tcount); -static int _SPI_pquery(QueryDesc *queryDesc, long tcount); +static int _SPI_pquery(QueryDesc *queryDesc, long tcount); static void _SPI_error_callback(void *arg); @@ -66,8 +66,8 @@ SPI_connect(void) int newdepth; /* - * When procedure called by Executor _SPI_curid expected to be equal - * to _SPI_connected + * When procedure called by Executor _SPI_curid expected to be equal to + * _SPI_connected */ if (_SPI_curid != _SPI_connected) return SPI_ERROR_CONNECT; @@ -106,28 +106,28 @@ SPI_connect(void) _SPI_current->processed = 0; _SPI_current->lastoid = InvalidOid; _SPI_current->tuptable = NULL; - _SPI_current->procCxt = NULL; /* in case we fail to create 'em */ + _SPI_current->procCxt = NULL; /* in case we fail to create 'em */ _SPI_current->execCxt = NULL; _SPI_current->connectSubid = GetCurrentSubTransactionId(); /* * Create memory contexts for this procedure * - * XXX it would be better to use PortalContext as the parent context, but - * we may not be inside a portal (consider deferred-trigger - * execution). Perhaps CurTransactionContext would do? For now it - * doesn't matter because we clean up explicitly in AtEOSubXact_SPI(). + * XXX it would be better to use PortalContext as the parent context, but we + * may not be inside a portal (consider deferred-trigger execution). + * Perhaps CurTransactionContext would do? For now it doesn't matter + * because we clean up explicitly in AtEOSubXact_SPI(). */ _SPI_current->procCxt = AllocSetContextCreate(TopTransactionContext, "SPI Proc", - ALLOCSET_DEFAULT_MINSIZE, - ALLOCSET_DEFAULT_INITSIZE, - ALLOCSET_DEFAULT_MAXSIZE); + ALLOCSET_DEFAULT_MINSIZE, + ALLOCSET_DEFAULT_INITSIZE, + ALLOCSET_DEFAULT_MAXSIZE); _SPI_current->execCxt = AllocSetContextCreate(TopTransactionContext, "SPI Exec", - ALLOCSET_DEFAULT_MINSIZE, - ALLOCSET_DEFAULT_INITSIZE, - ALLOCSET_DEFAULT_MAXSIZE); + ALLOCSET_DEFAULT_MINSIZE, + ALLOCSET_DEFAULT_INITSIZE, + ALLOCSET_DEFAULT_MAXSIZE); /* ... and switch to procedure's context */ _SPI_current->savedcxt = MemoryContextSwitchTo(_SPI_current->procCxt); @@ -161,9 +161,9 @@ SPI_finish(void) SPI_tuptable = NULL; /* - * After _SPI_begin_call _SPI_connected == _SPI_curid. Now we are - * closing connection to SPI and returning to upper Executor and so - * _SPI_connected must be equal to _SPI_curid. + * After _SPI_begin_call _SPI_connected == _SPI_curid. Now we are closing + * connection to SPI and returning to upper Executor and so _SPI_connected + * must be equal to _SPI_curid. */ _SPI_connected--; _SPI_curid--; @@ -182,9 +182,9 @@ void AtEOXact_SPI(bool isCommit) { /* - * Note that memory contexts belonging to SPI stack entries will be - * freed automatically, so we can ignore them here. We just need to - * restore our static variables to initial state. + * Note that memory contexts belonging to SPI stack entries will be freed + * automatically, so we can ignore them here. We just need to restore our + * static variables to initial state. */ if (isCommit && _SPI_connected != -1) ereport(WARNING, @@ -236,8 +236,8 @@ AtEOSubXact_SPI(bool isCommit, SubTransactionId mySubid) /* * Pop the stack entry and reset global variables. Unlike - * SPI_finish(), we don't risk switching to memory contexts that - * might be already gone. + * SPI_finish(), we don't risk switching to memory contexts that might + * be already gone. */ _SPI_connected--; _SPI_curid = _SPI_connected; @@ -560,8 +560,8 @@ SPI_modifytuple(Relation rel, HeapTuple tuple, int natts, int *attnum, mtuple = heap_formtuple(rel->rd_att, v, n); /* - * copy the identification info of the old tuple: t_ctid, t_self, - * and OID (if any) + * copy the identification info of the old tuple: t_ctid, t_self, and + * OID (if any) */ mtuple->t_data->t_ctid = tuple->t_data->t_ctid; mtuple->t_self = tuple->t_self; @@ -658,8 +658,8 @@ SPI_getvalue(HeapTuple tuple, TupleDesc tupdesc, int fnumber) getTypeOutputInfo(typoid, &foutoid, &typisvarlena); /* - * If we have a toasted datum, forcibly detoast it here to avoid - * memory leakage inside the type's output routine. + * If we have a toasted datum, forcibly detoast it here to avoid memory + * leakage inside the type's output routine. */ if (typisvarlena) val = PointerGetDatum(PG_DETOAST_DATUM(origval)); @@ -755,7 +755,7 @@ SPI_getrelname(Relation rel) char * SPI_getnspname(Relation rel) { - return get_namespace_name(RelationGetNamespace(rel)); + return get_namespace_name(RelationGetNamespace(rel)); } void * @@ -939,8 +939,8 @@ SPI_cursor_open(const char *name, void *plan, portal->cursorOptions |= CURSOR_OPT_NO_SCROLL; /* - * Set up the snapshot to use. (PortalStart will do CopySnapshot, - * so we skip that here.) + * Set up the snapshot to use. (PortalStart will do CopySnapshot, so we + * skip that here.) */ if (read_only) snapshot = ActiveSnapshot; @@ -1214,7 +1214,7 @@ spi_printtup(TupleTableSlot *slot, DestReceiver *self) tuptable->free = 256; tuptable->alloced += tuptable->free; tuptable->vals = (HeapTuple *) repalloc(tuptable->vals, - tuptable->alloced * sizeof(HeapTuple)); + tuptable->alloced * sizeof(HeapTuple)); } tuptable->vals[tuptable->alloced - tuptable->free] = @@ -1247,9 +1247,9 @@ _SPI_prepare_plan(const char *src, _SPI_plan *plan) int nargs = plan->nargs; /* - * Increment CommandCounter to see changes made by now. We must do - * this to be sure of seeing any schema changes made by a just-preceding - * SPI command. (But we don't bother advancing the snapshot, since the + * Increment CommandCounter to see changes made by now. We must do this + * to be sure of seeing any schema changes made by a just-preceding SPI + * command. (But we don't bother advancing the snapshot, since the * planner generally operates under SnapshotNow rules anyway.) */ CommandCounterIncrement(); @@ -1270,9 +1270,9 @@ _SPI_prepare_plan(const char *src, _SPI_plan *plan) /* * Do parse analysis and rule rewrite for each raw parsetree. * - * We save the querytrees from each raw parsetree as a separate - * sublist. This allows _SPI_execute_plan() to know where the - * boundaries between original queries fall. + * We save the querytrees from each raw parsetree as a separate sublist. + * This allows _SPI_execute_plan() to know where the boundaries between + * original queries fall. */ query_list_list = NIL; plan_list = NIL; @@ -1316,7 +1316,7 @@ _SPI_execute_plan(_SPI_plan *plan, Datum *Values, const char *Nulls, volatile int res = 0; volatile uint32 my_processed = 0; volatile Oid my_lastoid = InvalidOid; - SPITupleTable * volatile my_tuptable = NULL; + SPITupleTable *volatile my_tuptable = NULL; Snapshot saveActiveSnapshot; /* Be sure to restore ActiveSnapshot on error exit */ @@ -1407,9 +1407,10 @@ _SPI_execute_plan(_SPI_plan *plan, Datum *Values, const char *Nulls, if (read_only && !QueryIsReadOnly(queryTree)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - /* translator: %s is a SQL statement name */ - errmsg("%s is not allowed in a non-volatile function", - CreateQueryTag(queryTree)))); + /* translator: %s is a SQL statement name */ + errmsg("%s is not allowed in a non-volatile function", + CreateQueryTag(queryTree)))); + /* * If not read-only mode, advance the command counter before * each command. @@ -1462,6 +1463,7 @@ _SPI_execute_plan(_SPI_plan *plan, Datum *Values, const char *Nulls, } FreeSnapshot(ActiveSnapshot); ActiveSnapshot = NULL; + /* * The last canSetTag query sets the auxiliary values returned * to the caller. Be careful to free any tuptables not @@ -1520,10 +1522,10 @@ _SPI_pquery(QueryDesc *queryDesc, long tcount) { case CMD_SELECT: res = SPI_OK_SELECT; - if (queryDesc->parsetree->into) /* select into table? */ + if (queryDesc->parsetree->into) /* select into table? */ { res = SPI_OK_SELINTO; - queryDesc->dest = None_Receiver; /* don't output results */ + queryDesc->dest = None_Receiver; /* don't output results */ } else if (queryDesc->dest->mydest != SPI) { @@ -1589,8 +1591,8 @@ _SPI_error_callback(void *arg) int syntaxerrposition; /* - * If there is a syntax error position, convert to internal syntax - * error; otherwise treat the query as an item of context stack + * If there is a syntax error position, convert to internal syntax error; + * otherwise treat the query as an item of context stack */ syntaxerrposition = geterrposition(); if (syntaxerrposition > 0) @@ -1635,13 +1637,12 @@ _SPI_cursor_operation(Portal portal, bool forward, long count, dest); /* - * Think not to combine this store with the preceding function call. - * If the portal contains calls to functions that use SPI, then - * SPI_stack is likely to move around while the portal runs. When - * control returns, _SPI_current will point to the correct stack - * entry... but the pointer may be different than it was beforehand. - * So we must be sure to re-fetch the pointer after the function call - * completes. + * Think not to combine this store with the preceding function call. If + * the portal contains calls to functions that use SPI, then SPI_stack is + * likely to move around while the portal runs. When control returns, + * _SPI_current will point to the correct stack entry... but the pointer + * may be different than it was beforehand. So we must be sure to re-fetch + * the pointer after the function call completes. */ _SPI_current->processed = nfetched; @@ -1738,12 +1739,13 @@ _SPI_copy_plan(_SPI_plan *plan, int location) parentcxt = _SPI_current->procCxt; else if (location == _SPI_CPLAN_TOPCXT) parentcxt = TopMemoryContext; - else /* (this case not currently used) */ + else + /* (this case not currently used) */ parentcxt = CurrentMemoryContext; /* - * Create a memory context for the plan. We don't expect the plan to - * be very large, so use smaller-than-default alloc parameters. + * Create a memory context for the plan. We don't expect the plan to be + * very large, so use smaller-than-default alloc parameters. */ plancxt = AllocSetContextCreate(parentcxt, "SPI Plan", diff --git a/src/backend/lib/dllist.c b/src/backend/lib/dllist.c index 59708bee78..95802a31ee 100644 --- a/src/backend/lib/dllist.c +++ b/src/backend/lib/dllist.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/lib/dllist.c,v 1.31 2005/01/18 22:59:32 neilc Exp $ + * $PostgreSQL: pgsql/src/backend/lib/dllist.c,v 1.32 2005/10/15 02:49:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -148,7 +148,7 @@ DLAddHead(Dllist *l, Dlelem *e) e->dle_prev = NULL; l->dll_head = e; - if (l->dll_tail == NULL) /* if this is first element added */ + if (l->dll_tail == NULL) /* if this is first element added */ l->dll_tail = e; } @@ -163,7 +163,7 @@ DLAddTail(Dllist *l, Dlelem *e) e->dle_next = NULL; l->dll_tail = e; - if (l->dll_head == NULL) /* if this is first element added */ + if (l->dll_head == NULL) /* if this is first element added */ l->dll_head = e; } diff --git a/src/backend/lib/stringinfo.c b/src/backend/lib/stringinfo.c index 49d509e57b..53e4913b4a 100644 --- a/src/backend/lib/stringinfo.c +++ b/src/backend/lib/stringinfo.c @@ -9,7 +9,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/lib/stringinfo.c,v 1.41 2004/12/31 21:59:48 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/lib/stringinfo.c,v 1.42 2005/10/15 02:49:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -106,8 +106,8 @@ appendStringInfoVA(StringInfo str, const char *fmt, va_list args) Assert(str != NULL); /* - * If there's hardly any space, don't bother trying, just fail to make - * the caller enlarge the buffer first. + * If there's hardly any space, don't bother trying, just fail to make the + * caller enlarge the buffer first. */ avail = str->maxlen - str->len - 1; if (avail < 16) @@ -115,8 +115,8 @@ appendStringInfoVA(StringInfo str, const char *fmt, va_list args) /* * Assert check here is to catch buggy vsnprintf that overruns the - * specified buffer length. Solaris 7 in 64-bit mode is an example of - * a platform with such a bug. + * specified buffer length. Solaris 7 in 64-bit mode is an example of a + * platform with such a bug. */ #ifdef USE_ASSERT_CHECKING str->data[str->maxlen - 1] = '\0'; @@ -127,9 +127,9 @@ appendStringInfoVA(StringInfo str, const char *fmt, va_list args) Assert(str->data[str->maxlen - 1] == '\0'); /* - * Note: some versions of vsnprintf return the number of chars - * actually stored, but at least one returns -1 on failure. Be - * conservative about believing whether the print worked. + * Note: some versions of vsnprintf return the number of chars actually + * stored, but at least one returns -1 on failure. Be conservative about + * believing whether the print worked. */ if (nprinted >= 0 && nprinted < avail - 1) { @@ -193,8 +193,8 @@ appendBinaryStringInfo(StringInfo str, const char *data, int datalen) str->len += datalen; /* - * Keep a trailing null in place, even though it's probably useless - * for binary data... + * Keep a trailing null in place, even though it's probably useless for + * binary data... */ str->data[str->len] = '\0'; } @@ -222,9 +222,9 @@ enlargeStringInfo(StringInfo str, int needed) int newlen; /* - * Guard against ridiculous "needed" values, which can occur if we're - * fed bogus data. Without this, we can get an overflow or infinite - * loop in the following. + * Guard against ridiculous "needed" values, which can occur if we're fed + * bogus data. Without this, we can get an overflow or infinite loop in + * the following. */ if (needed < 0 || ((Size) needed) >= (MaxAllocSize - (Size) str->len)) @@ -239,19 +239,18 @@ enlargeStringInfo(StringInfo str, int needed) 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) newlen = 2 * newlen; /* - * Clamp to MaxAllocSize in case we went past it. Note we are - * assuming here that MaxAllocSize <= INT_MAX/2, else the above loop - * could overflow. We will still have newlen >= needed. + * Clamp to MaxAllocSize in case we went past it. Note we are assuming + * here that MaxAllocSize <= INT_MAX/2, else the above loop could + * overflow. We will still have newlen >= needed. */ if (newlen > (int) MaxAllocSize) newlen = (int) MaxAllocSize; diff --git a/src/backend/libpq/auth.c b/src/backend/libpq/auth.c index 3bdddf86da..240a02f0e9 100644 --- a/src/backend/libpq/auth.c +++ b/src/backend/libpq/auth.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/libpq/auth.c,v 1.129 2005/10/13 22:55:19 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/libpq/auth.c,v 1.130 2005/10/15 02:49:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -41,7 +41,7 @@ static char *recv_password_packet(Port *port); static int recv_and_check_password_packet(Port *port); char *pg_krb_server_keyfile; -char *pg_krb_srvnam; +char *pg_krb_srvnam; bool pg_krb_caseins_users; char *pg_krb_server_hostname = NULL; @@ -65,8 +65,8 @@ static struct pam_conv pam_passw_conv = { }; static char *pam_passwd = NULL; /* Workaround for Solaris 2.6 brokenness */ -static Port *pam_port_cludge; /* Workaround for passing "Port *port" - * into pam_passwd_conv_proc */ +static Port *pam_port_cludge; /* Workaround for passing "Port *port" into + * pam_passwd_conv_proc */ #endif /* USE_PAM */ #ifdef KRB5 @@ -119,7 +119,7 @@ static int pg_krb5_init(void) { krb5_error_code retval; - char *khostname; + char *khostname; if (pg_krb5_initialised) return STATUS_OK; @@ -147,8 +147,8 @@ pg_krb5_init(void) } /* - * If no hostname was specified, pg_krb_server_hostname is already - * NULL. If it's set to blank, force it to NULL. + * If no hostname was specified, pg_krb_server_hostname is already NULL. + * If it's set to blank, force it to NULL. */ khostname = pg_krb_server_hostname; if (khostname && khostname[0] == '\0') @@ -163,9 +163,9 @@ pg_krb5_init(void) { ereport(LOG, (errmsg("Kerberos sname_to_principal(\"%s\", \"%s\") returned error %d", - khostname ? khostname : "localhost", pg_krb_srvnam, retval))); + khostname ? khostname : "localhost", pg_krb_srvnam, retval))); com_err("postgres", retval, - "while getting server principal for server \"%s\" for service \"%s\"", + "while getting server principal for server \"%s\" for service \"%s\"", khostname ? khostname : "localhost", pg_krb_srvnam); krb5_kt_close(pg_krb5_context, pg_krb5_keytab); krb5_free_context(pg_krb5_context); @@ -260,7 +260,6 @@ pg_krb5_recvauth(Port *port) return ret; } - #else static int @@ -293,13 +292,13 @@ auth_failed(Port *port, int status) /* * If we failed due to EOF from client, just quit; there's no point in - * trying to send a message to the client, and not much point in - * logging the failure in the postmaster log. (Logging the failure - * might be desirable, were it not for the fact that libpq closes the - * connection unceremoniously if challenged for a password when it - * hasn't got one to send. We'll get a useless log entry for every - * psql connection under password auth, even if it's perfectly - * successful, if we log STATUS_EOF events.) + * trying to send a message to the client, and not much point in logging + * the failure in the postmaster log. (Logging the failure might be + * desirable, were it not for the fact that libpq closes the connection + * unceremoniously if challenged for a password when it hasn't got one to + * send. We'll get a useless log entry for every psql connection under + * password auth, even if it's perfectly successful, if we log STATUS_EOF + * events.) */ if (status == STATUS_EOF) proc_exit(0); @@ -351,9 +350,9 @@ ClientAuthentication(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) != STATUS_OK) ereport(FATAL, @@ -368,11 +367,11 @@ ClientAuthentication(Port *port) /* * 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. + * 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. */ { char hostinfo[NI_MAXHOST]; @@ -384,14 +383,14 @@ ClientAuthentication(Port *port) #ifdef USE_SSL ereport(FATAL, - (errcode(ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION), - errmsg("no pg_hba.conf entry for host \"%s\", user \"%s\", database \"%s\", %s", - hostinfo, port->user_name, port->database_name, - port->ssl ? _("SSL on") : _("SSL off")))); + (errcode(ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION), + errmsg("no pg_hba.conf entry for host \"%s\", user \"%s\", database \"%s\", %s", + hostinfo, port->user_name, port->database_name, + port->ssl ? _("SSL on") : _("SSL off")))); #else ereport(FATAL, - (errcode(ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION), - errmsg("no pg_hba.conf entry for host \"%s\", user \"%s\", database \"%s\"", + (errcode(ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION), + errmsg("no pg_hba.conf entry for host \"%s\", user \"%s\", database \"%s\"", hostinfo, port->user_name, port->database_name))); #endif break; @@ -425,7 +424,7 @@ ClientAuthentication(Port *port) if (setsockopt(port->sock, 0, LOCAL_CREDS, &on, sizeof(on)) < 0) ereport(FATAL, (errcode_for_socket_access(), - errmsg("could not enable credential reception: %m"))); + errmsg("could not enable credential reception: %m"))); #endif sendAuthRequest(port, AUTH_REQ_SCM_CREDS); @@ -488,8 +487,8 @@ sendAuthRequest(Port *port, AuthRequest areq) pq_endmessage(&buf); /* - * Flush message so client will see it, except for AUTH_REQ_OK, which - * need not be sent until we are ready for queries. + * Flush message so client will see it, except for AUTH_REQ_OK, which need + * not be sent until we are ready for queries. */ if (areq != AUTH_REQ_OK) pq_flush(); @@ -526,15 +525,15 @@ pam_passwd_conv_proc(int num_msg, const struct pam_message ** msg, if (!appdata_ptr) { /* - * Workaround for Solaris 2.6 where the PAM library is broken and - * does not pass appdata_ptr to the conversation routine + * Workaround for Solaris 2.6 where the PAM library is broken and does + * not pass appdata_ptr to the conversation routine */ appdata_ptr = pam_passwd; } /* - * Password wasn't passed to PAM the first time around - let's go ask - * the client to send a password, which we then stuff into PAM. + * Password wasn't passed to PAM the first time around - let's go ask the + * client to send a password, which we then stuff into PAM. */ if (strlen(appdata_ptr) == 0) { @@ -695,15 +694,15 @@ recv_password_packet(Port *port) { /* * If the client just disconnects without offering a password, - * don't make a log entry. This is legal per protocol spec - * and in fact commonly done by psql, so complaining just - * clutters the log. + * don't make a log entry. This is legal per protocol spec and in + * fact commonly done by psql, so complaining just clutters the + * log. */ if (mtype != EOF) ereport(COMMERROR, (errcode(ERRCODE_PROTOCOL_VIOLATION), - errmsg("expected password response, got message type %d", - mtype))); + errmsg("expected password response, got message type %d", + mtype))); return NULL; /* EOF or bad message type */ } } @@ -723,8 +722,8 @@ recv_password_packet(Port *port) } /* - * Apply sanity check: password packet length should agree with length - * of contained string. Note it is safe to use strlen here because + * Apply sanity check: password packet length should agree with length of + * contained string. Note it is safe to use strlen here because * StringInfo is guaranteed to have an appended '\0'. */ if (strlen(buf.data) + 1 != buf.len) @@ -738,8 +737,8 @@ recv_password_packet(Port *port) /* * Return the received string. Note we do not attempt to do any - * character-set conversion on it; since we don't yet know the - * client's encoding, there wouldn't be much point. + * character-set conversion on it; since we don't yet know the client's + * encoding, there wouldn't be much point. */ return buf.data; } diff --git a/src/backend/libpq/be-fsstubs.c b/src/backend/libpq/be-fsstubs.c index 016884e425..139f8946dd 100644 --- a/src/backend/libpq/be-fsstubs.c +++ b/src/backend/libpq/be-fsstubs.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/libpq/be-fsstubs.c,v 1.78 2005/06/13 02:26:48 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/libpq/be-fsstubs.c,v 1.79 2005/10/15 02:49:17 momjian Exp $ * * NOTES * This should be moved to a more appropriate place. It is here @@ -74,7 +74,7 @@ static MemoryContext fscxt = NULL; ALLOCSET_DEFAULT_INITSIZE, \ ALLOCSET_DEFAULT_MAXSIZE); \ } while (0) - + static int newLOfd(LargeObjectDesc *lobjCookie); static void deleteLOfd(int fd); @@ -198,8 +198,8 @@ lo_write(int fd, char *buf, int len) if ((cookies[fd]->flags & IFS_WRLOCK) == 0) ereport(ERROR, (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), - errmsg("large object descriptor %d was not opened for writing", - fd))); + errmsg("large object descriptor %d was not opened for writing", + fd))); Assert(fscxt != NULL); currentContext = MemoryContextSwitchTo(fscxt); @@ -289,9 +289,8 @@ lo_tell(PG_FUNCTION_ARGS) } /* - * We assume we do not need to switch contexts for inv_tell. That is - * true for now, but is probably more than this module ought to - * assume... + * We assume we do not need to switch contexts for inv_tell. That is true + * for now, but is probably more than this module ought to assume... */ PG_RETURN_INT32(inv_tell(cookies[fd])); } @@ -322,9 +321,9 @@ lo_unlink(PG_FUNCTION_ARGS) } /* - * inv_drop does not need a context switch, indeed it doesn't touch - * any LO-specific data structures at all. (Again, that's probably - * more than this module ought to be assuming.) + * inv_drop does not need a context switch, indeed it doesn't touch any + * LO-specific data structures at all. (Again, that's probably more than + * this module ought to be assuming.) */ PG_RETURN_INT32(inv_drop(lobjId)); } @@ -388,13 +387,13 @@ lo_import(PG_FUNCTION_ARGS) if (!superuser()) ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), - errmsg("must be superuser to use server-side lo_import()"), + errmsg("must be superuser to use server-side lo_import()"), errhint("Anyone can use the client-side lo_import() provided by libpq."))); #endif /* - * We don't actually need to switch into fscxt, but create it anyway - * to ensure that AtEOXact_LargeObject knows there is state to clean up + * We don't actually need to switch into fscxt, but create it anyway to + * ensure that AtEOXact_LargeObject knows there is state to clean up */ CreateFSContext(); @@ -462,13 +461,13 @@ lo_export(PG_FUNCTION_ARGS) if (!superuser()) ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), - errmsg("must be superuser to use server-side lo_export()"), + errmsg("must be superuser to use server-side lo_export()"), errhint("Anyone can use the client-side lo_export() provided by libpq."))); #endif /* - * We don't actually need to switch into fscxt, but create it anyway - * to ensure that AtEOXact_LargeObject knows there is state to clean up + * We don't actually need to switch into fscxt, but create it anyway to + * ensure that AtEOXact_LargeObject knows there is state to clean up */ CreateFSContext(); @@ -480,9 +479,9 @@ lo_export(PG_FUNCTION_ARGS) /* * open the file to be written to * - * Note: we reduce backend's normal 077 umask to the slightly friendlier - * 022. This code used to drop it all the way to 0, but creating - * world-writable export files doesn't seem wise. + * Note: we reduce backend's normal 077 umask to the slightly friendlier 022. + * This code used to drop it all the way to 0, but creating world-writable + * export files doesn't seem wise. */ nbytes = VARSIZE(filename) - VARHDRSZ; if (nbytes >= MAXPGPATH) @@ -533,8 +532,8 @@ AtEOXact_LargeObject(bool isCommit) currentContext = MemoryContextSwitchTo(fscxt); /* - * Close LO fds and clear cookies array so that LO fds are no longer - * good. On abort we skip the close step. + * Close LO fds and clear cookies array so that LO fds are no longer good. + * On abort we skip the close step. */ for (i = 0; i < cookies_size; i++) { @@ -587,8 +586,8 @@ AtEOSubXact_LargeObject(bool isCommit, SubTransactionId mySubid, else { /* - * Make sure we do not call inv_close twice if it errors - * out for some reason. Better a leak than a crash. + * Make sure we do not call inv_close twice if it errors out + * for some reason. Better a leak than a crash. */ deleteLOfd(i); inv_close(lo); diff --git a/src/backend/libpq/be-secure.c b/src/backend/libpq/be-secure.c index 01dc4f1af0..a2404ebd38 100644 --- a/src/backend/libpq/be-secure.c +++ b/src/backend/libpq/be-secure.c @@ -11,7 +11,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/libpq/be-secure.c,v 1.58 2005/07/04 04:51:46 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/libpq/be-secure.c,v 1.59 2005/10/15 02:49:17 momjian Exp $ * * Since the server static private key ($DataDir/server.key) * will normally be stored unencrypted so that the database @@ -103,7 +103,7 @@ #define ROOT_CERT_FILE "root.crt" #define SERVER_CERT_FILE "server.crt" -#define SERVER_PRIVATE_KEY_FILE "server.key" +#define SERVER_PRIVATE_KEY_FILE "server.key" static DH *load_dh_file(int keylength); static DH *load_dh_buffer(const char *, size_t); @@ -276,8 +276,8 @@ rloop: case SSL_ERROR_WANT_WRITE: #ifdef WIN32 pgwin32_waitforsinglesocket(SSL_get_fd(port->ssl), - (err==SSL_ERROR_WANT_READ) ? - FD_READ|FD_CLOSE : FD_WRITE|FD_CLOSE); + (err == SSL_ERROR_WANT_READ) ? + FD_READ | FD_CLOSE : FD_WRITE | FD_CLOSE); #endif goto rloop; case SSL_ERROR_SYSCALL: @@ -353,7 +353,7 @@ secure_write(Port *port, void *ptr, size_t len) if (port->ssl->state != SSL_ST_OK) ereport(COMMERROR, (errcode(ERRCODE_PROTOCOL_VIOLATION), - errmsg("SSL failed to send renegotiation request"))); + errmsg("SSL failed to send renegotiation request"))); port->ssl->state |= SSL_ST_ACCEPT; SSL_do_handshake(port->ssl); if (port->ssl->state != SSL_ST_OK) @@ -375,8 +375,8 @@ wloop: case SSL_ERROR_WANT_WRITE: #ifdef WIN32 pgwin32_waitforsinglesocket(SSL_get_fd(port->ssl), - (err==SSL_ERROR_WANT_READ) ? - FD_READ|FD_CLOSE : FD_WRITE|FD_CLOSE); + (err == SSL_ERROR_WANT_READ) ? + FD_READ | FD_CLOSE : FD_WRITE | FD_CLOSE); #endif goto wloop; case SSL_ERROR_SYSCALL: @@ -439,12 +439,12 @@ wloop: static bool my_bio_initialized = false; static BIO_METHOD my_bio_methods; -static int (*std_sock_read) (BIO *h, char *buf, int size); +static int (*std_sock_read) (BIO *h, char *buf, int size); static int my_sock_read(BIO *h, char *buf, int size) { - int res; + int res; prepare_for_client_read(); @@ -472,21 +472,21 @@ my_BIO_s_socket(void) static int my_SSL_set_fd(SSL *s, int fd) { - int ret=0; - BIO *bio=NULL; + int ret = 0; + BIO *bio = NULL; - bio=BIO_new(my_BIO_s_socket()); + bio = BIO_new(my_BIO_s_socket()); if (bio == NULL) { - SSLerr(SSL_F_SSL_SET_FD,ERR_R_BUF_LIB); + SSLerr(SSL_F_SSL_SET_FD, ERR_R_BUF_LIB); goto err; } - BIO_set_fd(bio,fd,BIO_NOCLOSE); - SSL_set_bio(s,bio,bio); - ret=1; + BIO_set_fd(bio, fd, BIO_NOCLOSE); + SSL_set_bio(s, bio, bio); + ret = 1; err: - return(ret); + return (ret); } /* @@ -539,7 +539,7 @@ load_dh_file(int keylength) (codes & DH_CHECK_P_NOT_SAFE_PRIME)) { elog(LOG, - "DH error (%s): neither suitable generator or safe prime", + "DH error (%s): neither suitable generator or safe prime", fnbuf); return NULL; } @@ -640,8 +640,8 @@ tmp_dh_cb(SSL *s, int is_export, int keylength) if (r == NULL || 8 * DH_size(r) < keylength) { ereport(DEBUG2, - (errmsg_internal("DH: generating parameters (%d bits)....", - keylength))); + (errmsg_internal("DH: generating parameters (%d bits)....", + keylength))); r = DH_generate_parameters(keylength, DH_GENERATOR_2, NULL, NULL); } @@ -735,30 +735,30 @@ initialize_SSL(void) SSL_FILETYPE_PEM)) ereport(FATAL, (errcode(ERRCODE_CONFIG_FILE_ERROR), - errmsg("could not load server certificate file \"%s\": %s", - SERVER_CERT_FILE, SSLerrmessage()))); + errmsg("could not load server certificate file \"%s\": %s", + SERVER_CERT_FILE, SSLerrmessage()))); if (stat(SERVER_PRIVATE_KEY_FILE, &buf) == -1) ereport(FATAL, (errcode_for_file_access(), - errmsg("could not access private key file \"%s\": %m", - SERVER_PRIVATE_KEY_FILE))); + errmsg("could not access private key file \"%s\": %m", + SERVER_PRIVATE_KEY_FILE))); /* * Require no public access to key file. * - * XXX temporarily suppress check when on Windows, because there may - * not be proper support for Unix-y file permissions. Need to - * think of a reasonable check to apply on Windows. (See also the - * data directory permission check in postmaster.c) + * XXX temporarily suppress check when on Windows, because there may not + * be proper support for Unix-y file permissions. Need to think of a + * reasonable check to apply on Windows. (See also the data directory + * permission check in postmaster.c) */ #if !defined(WIN32) && !defined(__CYGWIN__) if (!S_ISREG(buf.st_mode) || (buf.st_mode & (S_IRWXG | S_IRWXO)) || buf.st_uid != geteuid()) ereport(FATAL, (errcode(ERRCODE_CONFIG_FILE_ERROR), - errmsg("unsafe permissions on private key file \"%s\"", - SERVER_PRIVATE_KEY_FILE), + errmsg("unsafe permissions on private key file \"%s\"", + SERVER_PRIVATE_KEY_FILE), errdetail("File must be owned by the database user and must have no permissions for \"group\" or \"other\"."))); #endif @@ -861,8 +861,8 @@ aloop: case SSL_ERROR_WANT_WRITE: #ifdef WIN32 pgwin32_waitforsinglesocket(SSL_get_fd(port->ssl), - (err==SSL_ERROR_WANT_READ) ? - FD_READ|FD_CLOSE|FD_ACCEPT : FD_WRITE|FD_CLOSE); + (err == SSL_ERROR_WANT_READ) ? + FD_READ | FD_CLOSE | FD_ACCEPT : FD_WRITE | FD_CLOSE); #endif goto aloop; case SSL_ERROR_SYSCALL: @@ -873,7 +873,7 @@ aloop: else ereport(COMMERROR, (errcode(ERRCODE_PROTOCOL_VIOLATION), - errmsg("could not accept SSL connection: EOF detected"))); + errmsg("could not accept SSL connection: EOF detected"))); break; case SSL_ERROR_SSL: ereport(COMMERROR, @@ -884,7 +884,7 @@ aloop: case SSL_ERROR_ZERO_RETURN: ereport(COMMERROR, (errcode(ERRCODE_PROTOCOL_VIOLATION), - errmsg("could not accept SSL connection: EOF detected"))); + errmsg("could not accept SSL connection: EOF detected"))); break; default: ereport(COMMERROR, @@ -912,7 +912,7 @@ aloop: port->peer_dn, sizeof(port->peer_dn)); port->peer_dn[sizeof(port->peer_dn) - 1] = '\0'; X509_NAME_get_text_by_NID(X509_get_subject_name(port->peer), - NID_commonName, port->peer_cn, sizeof(port->peer_cn)); + NID_commonName, port->peer_cn, sizeof(port->peer_cn)); port->peer_cn[sizeof(port->peer_cn) - 1] = '\0'; } ereport(DEBUG2, diff --git a/src/backend/libpq/crypt.c b/src/backend/libpq/crypt.c index 4e91b1a36f..b0a17aea53 100644 --- a/src/backend/libpq/crypt.c +++ b/src/backend/libpq/crypt.c @@ -9,7 +9,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/libpq/crypt.c,v 1.65 2005/08/15 02:40:25 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/libpq/crypt.c,v 1.66 2005/10/15 02:49:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -148,9 +148,9 @@ md5_crypt_verify(const Port *port, const char *role, char *client_pass) TimestampTz vuntil; vuntil = DatumGetTimestampTz(DirectFunctionCall3(timestamptz_in, - CStringGetDatum(valuntil), - ObjectIdGetDatum(InvalidOid), - Int32GetDatum(-1))); + CStringGetDatum(valuntil), + ObjectIdGetDatum(InvalidOid), + Int32GetDatum(-1))); if (vuntil < GetCurrentTimestamp()) retval = STATUS_ERROR; diff --git a/src/backend/libpq/hba.c b/src/backend/libpq/hba.c index f565442ac6..734a4568d2 100644 --- a/src/backend/libpq/hba.c +++ b/src/backend/libpq/hba.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.147 2005/08/11 21:11:44 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.148 2005/10/15 02:49:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -80,9 +80,9 @@ static List **role_sorted = NULL; /* sorted role list, for bsearch() */ static int role_length; static void tokenize_file(const char *filename, FILE *file, - List **lines, List **line_nums); + List **lines, List **line_nums); static char *tokenize_inc_file(const char *outer_filename, - const char *inc_filename); + const char *inc_filename); /* * isblank() exists in the ISO C99 spec, but it's not very portable yet, @@ -136,8 +136,8 @@ next_token(FILE *fp, char *buf, int bufsz) } /* - * Build a token in buf of next characters up to EOF, EOL, unquoted - * comma, or unquoted whitespace. + * Build a token in buf of next characters up to EOF, EOL, unquoted comma, + * or unquoted whitespace. */ while (c != EOF && c != '\n' && (!pg_isblank(c) || in_quote == true)) @@ -158,8 +158,8 @@ next_token(FILE *fp, char *buf, int bufsz) *buf = '\0'; ereport(LOG, (errcode(ERRCODE_CONFIG_FILE_ERROR), - errmsg("authentication file token too long, skipping: \"%s\"", - start_buf))); + errmsg("authentication file token too long, skipping: \"%s\"", + start_buf))); /* Discard remainder of line */ while ((c = getc(fp)) != EOF && c != '\n') ; @@ -189,8 +189,8 @@ next_token(FILE *fp, char *buf, int bufsz) } /* - * Put back the char right after the token (critical in case it is - * EOL, since we need to detect end-of-line at next call). + * Put back the char right after the token (critical in case it is EOL, + * since we need to detect end-of-line at next call). */ if (c != EOF) ungetc(c, fp); @@ -370,8 +370,8 @@ tokenize_inc_file(const char *outer_filename, foreach(token, token_list) { - int oldlen = strlen(comma_str); - int needed; + int oldlen = strlen(comma_str); + int needed; needed = oldlen + strlen(lfirst(token)) + 1; if (oldlen > 0) @@ -460,7 +460,7 @@ role_bsearch_cmp(const void *role, const void *list) /* * Lookup a role name in the pg_auth file */ -List ** +List ** get_role_line(const char *role) { /* On some versions of Solaris, bsearch of zero items dumps core */ @@ -495,8 +495,8 @@ is_member(const char *user, const char *role) return true; /* - * skip over the role name, password, valuntil, examine all the - * membership entries + * skip over the role name, password, valuntil, examine all the membership + * entries */ if (list_length(*line) < 4) return false; @@ -761,9 +761,9 @@ parse_hba(List *line, int line_num, hbaPort *port, { ereport(LOG, (errcode(ERRCODE_CONFIG_FILE_ERROR), - errmsg("invalid IP address \"%s\" in file \"%s\" line %d: %s", - token, HbaFileName, line_num, - gai_strerror(ret)))); + errmsg("invalid IP address \"%s\" in file \"%s\" line %d: %s", + token, HbaFileName, line_num, + gai_strerror(ret)))); if (cidr_slash) *cidr_slash = '/'; if (gai_result) @@ -796,9 +796,9 @@ parse_hba(List *line, int line_num, hbaPort *port, { ereport(LOG, (errcode(ERRCODE_CONFIG_FILE_ERROR), - errmsg("invalid IP mask \"%s\" in file \"%s\" line %d: %s", - token, HbaFileName, line_num, - gai_strerror(ret)))); + errmsg("invalid IP mask \"%s\" in file \"%s\" line %d: %s", + token, HbaFileName, line_num, + gai_strerror(ret)))); if (gai_result) freeaddrinfo_all(hints.ai_family, gai_result); goto hba_other_error; @@ -820,9 +820,9 @@ parse_hba(List *line, int line_num, hbaPort *port, if (addr.ss_family != port->raddr.addr.ss_family) { /* - * Wrong address family. We allow only one case: if the file - * has IPv4 and the port is IPv6, promote the file address to - * IPv6 and try to match that way. + * Wrong address family. We allow only one case: if the file has + * IPv4 and the port is IPv6, promote the file address to IPv6 and + * try to match that way. */ #ifdef HAVE_IPV6 if (addr.ss_family == AF_INET && @@ -869,14 +869,14 @@ hba_syntax: if (line_item) ereport(LOG, (errcode(ERRCODE_CONFIG_FILE_ERROR), - errmsg("invalid entry in file \"%s\" at line %d, token \"%s\"", - HbaFileName, line_num, - (char *) lfirst(line_item)))); + errmsg("invalid entry in file \"%s\" at line %d, token \"%s\"", + HbaFileName, line_num, + (char *) lfirst(line_item)))); else ereport(LOG, (errcode(ERRCODE_CONFIG_FILE_ERROR), - errmsg("missing field in file \"%s\" at end of line %d", - HbaFileName, line_num))); + errmsg("missing field in file \"%s\" at end of line %d", + HbaFileName, line_num))); /* Come here if suitable message already logged */ hba_other_error: @@ -928,7 +928,7 @@ load_role(void) /* Discard any old data */ if (role_lines || role_line_nums) free_lines(&role_lines, &role_line_nums); - if (role_sorted) + if (role_sorted) pfree(role_sorted); role_sorted = NULL; role_length = 0; @@ -957,8 +957,8 @@ load_role(void) role_length = list_length(role_lines); if (role_length) { - int i = 0; - ListCell *line; + int i = 0; + ListCell *line; /* We assume the flat file was written already-sorted */ role_sorted = palloc(role_length * sizeof(List *)); @@ -1124,7 +1124,7 @@ check_ident_usermap(const char *usermap_name, { ereport(LOG, (errcode(ERRCODE_CONFIG_FILE_ERROR), - errmsg("cannot use Ident authentication without usermap field"))); + errmsg("cannot use Ident authentication without usermap field"))); found_entry = false; } else if (strcmp(usermap_name, "sameuser\n") == 0 || @@ -1191,12 +1191,10 @@ static bool interpret_ident_response(const char *ident_response, char *ident_user) { - const char *cursor = ident_response; /* Cursor into - * *ident_response */ + const char *cursor = ident_response; /* Cursor into *ident_response */ /* - * Ident's response, in the telnet tradition, should end in crlf - * (\r\n). + * Ident's response, in the telnet tradition, should end in crlf (\r\n). */ if (strlen(ident_response) < 2) return false; @@ -1230,9 +1228,8 @@ interpret_ident_response(const char *ident_response, else { /* - * It's a USERID response. Good. "cursor" should be - * pointing to the colon that precedes the operating - * system type. + * It's a USERID response. Good. "cursor" should be pointing + * to the colon that precedes the operating system type. */ if (*cursor != ':') return false; @@ -1280,10 +1277,9 @@ ident_inet(const SockAddr remote_addr, const SockAddr local_addr, char *ident_user) { - 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 */ bool ident_return; char remote_addr_s[NI_MAXHOST]; char remote_port[NI_MAXSERV]; @@ -1297,8 +1293,8 @@ ident_inet(const SockAddr remote_addr, hints; /* - * Might look a little weird to first convert it to text and then back - * to sockaddr, but it's protocol independent. + * Might look a little weird to first convert it to text and then back to + * sockaddr, but it's protocol independent. */ getnameinfo_all(&remote_addr.addr, remote_addr.salen, remote_addr_s, sizeof(remote_addr_s), @@ -1348,16 +1344,15 @@ ident_inet(const SockAddr remote_addr, { ereport(LOG, (errcode_for_socket_access(), - errmsg("could not create socket for Ident connection: %m"))); + errmsg("could not create socket for Ident connection: %m"))); ident_return = false; goto ident_inet_done; } /* - * 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. + * 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. */ rc = bind(sock_fd, la->ai_addr, la->ai_addrlen); if (rc != 0) @@ -1421,8 +1416,8 @@ ident_inet(const SockAddr remote_addr, ident_return = interpret_ident_response(ident_response, ident_user); if (!ident_return) ereport(LOG, - (errmsg("invalidly formatted response from Ident server: \"%s\"", - ident_response))); + (errmsg("invalidly formatted response from Ident server: \"%s\"", + ident_response))); ident_inet_done: if (sock_fd >= 0) @@ -1473,7 +1468,6 @@ ident_unix(int sock, char *ident_user) StrNCpy(ident_user, pass->pw_name, IDENT_USERNAME_MAX + 1); return true; - #elif defined(SO_PEERCRED) /* Linux style: use getsockopt(SO_PEERCRED) */ struct ucred peercred; @@ -1504,7 +1498,6 @@ ident_unix(int sock, char *ident_user) StrNCpy(ident_user, pass->pw_name, IDENT_USERNAME_MAX + 1); return true; - #elif defined(HAVE_STRUCT_CMSGCRED) || defined(HAVE_STRUCT_FCRED) || (defined(HAVE_STRUCT_SOCKCRED) && defined(LOCAL_CREDS)) struct msghdr msg; @@ -1543,8 +1536,8 @@ ident_unix(int sock, char *ident_user) /* * The one character which is received here is not meaningful; its - * purposes is only to make sure that recvmsg() blocks long enough for - * the other side to send its credentials. + * purposes is only to make sure that recvmsg() blocks long enough for the + * other side to send its credentials. */ iov.iov_base = &buf; iov.iov_len = 1; @@ -1574,7 +1567,6 @@ ident_unix(int sock, char *ident_user) StrNCpy(ident_user, pw->pw_name, IDENT_USERNAME_MAX + 1); return true; - #else ereport(LOG, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), diff --git a/src/backend/libpq/md5.c b/src/backend/libpq/md5.c index 3c7fcd6912..f73d38795a 100644 --- a/src/backend/libpq/md5.c +++ b/src/backend/libpq/md5.c @@ -14,7 +14,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/libpq/md5.c,v 1.28 2005/02/23 22:46:17 neilc Exp $ + * $PostgreSQL: pgsql/src/backend/libpq/md5.c,v 1.29 2005/10/15 02:49:18 momjian Exp $ */ @@ -329,8 +329,8 @@ EncryptMD5(const char *passwd, const char *salt, size_t salt_len, bool ret; /* - * Place salt at the end because it may be known by users trying to - * crack the MD5 output. + * Place salt at the end because it may be known by users trying to crack + * the MD5 output. */ strcpy(crypt_buf, passwd); memcpy(crypt_buf + passwd_len, salt, salt_len); diff --git a/src/backend/libpq/pqcomm.c b/src/backend/libpq/pqcomm.c index d0904bfc7d..ccb4bcf2b5 100644 --- a/src/backend/libpq/pqcomm.c +++ b/src/backend/libpq/pqcomm.c @@ -30,7 +30,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/libpq/pqcomm.c,v 1.180 2005/09/24 17:53:14 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/libpq/pqcomm.c,v 1.181 2005/10/15 02:49:18 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -107,12 +107,10 @@ static char sock_path[MAXPGPATH]; #define PQ_BUFFER_SIZE 8192 static 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 char PqRecvBuffer[PQ_BUFFER_SIZE]; -static int PqRecvPointer; /* Next index to read a byte from - * PqRecvBuffer */ +static int PqRecvPointer; /* Next index to read a byte from PqRecvBuffer */ static int PqRecvLength; /* End of data available in PqRecvBuffer */ /* @@ -126,6 +124,7 @@ static bool DoingCopyOut; static void pq_close(int code, Datum arg); static int internal_putbytes(const char *s, size_t len); static int internal_flush(void); + #ifdef HAVE_UNIX_SOCKETS static int Lock_AF_UNIX(unsigned short portNumber, char *unixSocketName); static int Setup_AF_UNIX(void); @@ -178,11 +177,11 @@ pq_close(int code, Datum arg) secure_close(MyProcPort); /* - * Formerly we did an explicit close() here, but it seems better - * to leave the socket open until the process dies. This allows - * clients to perform a "synchronous close" if they care --- wait - * till the transport layer reports connection closure, and you - * can be sure the backend has exited. + * Formerly we did an explicit close() here, but it seems better to + * leave the socket open until the process dies. This allows clients + * to perform a "synchronous close" if they care --- wait till the + * transport layer reports connection closure, and you can be sure the + * backend has exited. * * We do set sock to -1 to prevent any further I/O, though. */ @@ -272,8 +271,8 @@ StreamServerPort(int family, char *hostName, unsigned short portNumber, hostName, service, gai_strerror(ret)))); else ereport(LOG, - (errmsg("could not translate service \"%s\" to address: %s", - service, gai_strerror(ret)))); + (errmsg("could not translate service \"%s\" to address: %s", + service, gai_strerror(ret)))); if (addrs) freeaddrinfo_all(hint.ai_family, addrs); return STATUS_ERROR; @@ -284,8 +283,8 @@ StreamServerPort(int family, char *hostName, unsigned short portNumber, if (!IS_AF_UNIX(family) && IS_AF_UNIX(addr->ai_family)) { /* - * Only set up a unix domain socket when they really asked for - * it. The service/port is different in that case. + * Only set up a unix domain socket when they really asked for it. + * The service/port is different in that case. */ continue; } @@ -368,9 +367,9 @@ StreamServerPort(int family, char *hostName, unsigned short portNumber, /* * Note: This might fail on some OS's, like Linux older than - * 2.4.21-pre3, that don't have the IPV6_V6ONLY socket option, and - * map ipv4 addresses to ipv6. It will show ::ffff:ipv4 for all - * ipv4 connections. + * 2.4.21-pre3, that don't have the IPV6_V6ONLY socket option, and map + * ipv4 addresses to ipv6. It will show ::ffff:ipv4 for all ipv4 + * connections. */ err = bind(fd, addr->ai_addr, addr->ai_addrlen); if (err < 0) @@ -381,12 +380,12 @@ StreamServerPort(int family, char *hostName, unsigned short portNumber, errmsg("could not bind %s socket: %m", familyDesc), (IS_AF_UNIX(addr->ai_family)) ? - errhint("Is another postmaster already running on port %d?" - " If not, remove socket file \"%s\" and retry.", - (int) portNumber, sock_path) : - errhint("Is another postmaster already running on port %d?" - " If not, wait a few seconds and retry.", - (int) portNumber))); + errhint("Is another postmaster already running on port %d?" + " If not, remove socket file \"%s\" and retry.", + (int) portNumber, sock_path) : + errhint("Is another postmaster already running on port %d?" + " If not, wait a few seconds and retry.", + (int) portNumber))); closesocket(fd); continue; } @@ -403,10 +402,9 @@ StreamServerPort(int family, char *hostName, unsigned short portNumber, #endif /* - * Select appropriate accept-queue length limit. PG_SOMAXCONN is - * only intended to provide a clamp on the request on platforms - * where an overly large request provokes a kernel error (are - * there any?). + * Select appropriate accept-queue length limit. PG_SOMAXCONN is only + * intended to provide a clamp on the request on platforms where an + * overly large request provokes a kernel error (are there any?). */ maxconn = MaxBackends * 2; if (maxconn > PG_SOMAXCONN) @@ -472,8 +470,8 @@ Setup_AF_UNIX(void) /* * Fix socket ownership/permission if requested. Note we must do this - * before we listen() to avoid a window where unwanted connections - * could get accepted. + * before we listen() to avoid a window where unwanted connections could + * get accepted. */ Assert(Unix_socket_group); if (Unix_socket_group[0] != '\0') @@ -596,11 +594,11 @@ StreamConnection(int server_fd, Port *port) } /* - * Also apply the current keepalive parameters. If we fail to set - * a parameter, don't error out, because these aren't universally + * Also apply the current keepalive parameters. If we fail to set a + * parameter, don't error out, because these aren't universally * supported. (Note: you might think we need to reset the GUC - * variables to 0 in such a case, but it's not necessary because - * the show hooks for these variables report the truth anyway.) + * variables to 0 in such a case, but it's not necessary because the + * show hooks for these variables report the truth anyway.) */ (void) pq_setkeepalivesidle(tcp_keepalives_idle, port); (void) pq_setkeepalivesinterval(tcp_keepalives_interval, port); @@ -642,9 +640,9 @@ TouchSocketFile(void) if (sock_path[0] != '\0') { /* - * utime() is POSIX standard, utimes() is a common alternative. If - * we have neither, there's no way to affect the mod or access - * time of the socket :-( + * utime() is POSIX standard, utimes() is a common alternative. If we + * have neither, there's no way to affect the mod or access time of + * the socket :-( * * In either path, we ignore errors; there's no point in complaining. */ @@ -705,10 +703,9 @@ pq_recvbuf(void) continue; /* Ok if interrupted */ /* - * Careful: an ereport() that tries to write to the client - * would cause recursion to here, leading to stack overflow - * and core dump! This message must go *only* to the - * postmaster log. + * Careful: an ereport() that tries to write to the client would + * cause recursion to here, leading to stack overflow and core + * dump! This message must go *only* to the postmaster log. */ ereport(COMMERROR, (errcode_for_socket_access(), @@ -718,8 +715,8 @@ pq_recvbuf(void) if (r == 0) { /* - * EOF detected. We used to write a log message here, but - * it's better to expect the ultimate caller to do that. + * EOF detected. We used to write a log message here, but it's + * better to expect the ultimate caller to do that. */ return EOF; } @@ -925,7 +922,7 @@ pq_getmessage(StringInfo s, int maxlen) if (len > 0) { /* - * Allocate space for message. If we run out of room (ridiculously + * Allocate space for message. If we run out of room (ridiculously * large message), we will elog(ERROR), but we want to discard the * message body so as not to lose communication sync. */ @@ -1044,14 +1041,13 @@ internal_flush(void) continue; /* Ok if we were interrupted */ /* - * Careful: an ereport() that tries to write to the client - * would cause recursion to here, leading to stack overflow - * and core dump! This message must go *only* to the - * postmaster log. + * Careful: an ereport() that tries to write to the client would + * cause recursion to here, leading to stack overflow and core + * dump! This message must go *only* to the postmaster log. * * If a client disconnects while we're in the midst of output, we - * might write quite a bit of data before we get to a safe - * query abort point. So, suppress duplicate log messages. + * might write quite a bit of data before we get to a safe query + * abort point. So, suppress duplicate log messages. */ if (errno != last_reported_send_errno) { @@ -1187,14 +1183,14 @@ pq_getkeepalivesidle(Port *port) if (port->default_keepalives_idle == 0) { - socklen_t size = sizeof(port->default_keepalives_idle); + socklen_t size = sizeof(port->default_keepalives_idle); if (getsockopt(port->sock, IPPROTO_TCP, TCP_KEEPIDLE, (char *) &port->default_keepalives_idle, &size) < 0) { elog(LOG, "getsockopt(TCP_KEEPIDLE) failed: %m"); - port->default_keepalives_idle = -1; /* don't know */ + port->default_keepalives_idle = -1; /* don't know */ } } @@ -1219,7 +1215,7 @@ pq_setkeepalivesidle(int idle, Port *port) if (pq_getkeepalivesidle(port) < 0) { if (idle == 0) - return STATUS_OK; /* default is set but unknown */ + return STATUS_OK; /* default is set but unknown */ else return STATUS_ERROR; } @@ -1259,14 +1255,14 @@ pq_getkeepalivesinterval(Port *port) if (port->default_keepalives_interval == 0) { - socklen_t size = sizeof(port->default_keepalives_interval); + socklen_t size = sizeof(port->default_keepalives_interval); if (getsockopt(port->sock, IPPROTO_TCP, TCP_KEEPINTVL, (char *) &port->default_keepalives_interval, &size) < 0) { elog(LOG, "getsockopt(TCP_KEEPINTVL) failed: %m"); - port->default_keepalives_interval = -1; /* don't know */ + port->default_keepalives_interval = -1; /* don't know */ } } @@ -1291,7 +1287,7 @@ pq_setkeepalivesinterval(int interval, Port *port) if (pq_getkeepalivesinterval(port) < 0) { if (interval == 0) - return STATUS_OK; /* default is set but unknown */ + return STATUS_OK; /* default is set but unknown */ else return STATUS_ERROR; } @@ -1331,14 +1327,14 @@ pq_getkeepalivescount(Port *port) if (port->default_keepalives_count == 0) { - socklen_t size = sizeof(port->default_keepalives_count); + socklen_t size = sizeof(port->default_keepalives_count); if (getsockopt(port->sock, IPPROTO_TCP, TCP_KEEPCNT, (char *) &port->default_keepalives_count, &size) < 0) { elog(LOG, "getsockopt(TCP_KEEPCNT) failed: %m"); - port->default_keepalives_count = -1; /* don't know */ + port->default_keepalives_count = -1; /* don't know */ } } @@ -1363,7 +1359,7 @@ pq_setkeepalivescount(int count, Port *port) if (pq_getkeepalivescount(port) < 0) { if (count == 0) - return STATUS_OK; /* default is set but unknown */ + return STATUS_OK; /* default is set but unknown */ else return STATUS_ERROR; } diff --git a/src/backend/libpq/pqformat.c b/src/backend/libpq/pqformat.c index 284427b832..46e75c5e04 100644 --- a/src/backend/libpq/pqformat.c +++ b/src/backend/libpq/pqformat.c @@ -24,7 +24,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/libpq/pqformat.c,v 1.39 2005/09/24 17:53:14 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/libpq/pqformat.c,v 1.40 2005/10/15 02:49:18 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -93,9 +93,8 @@ pq_beginmessage(StringInfo buf, char msgtype) /* * We stash the message type into the buffer's cursor field, expecting - * that the pq_sendXXX routines won't touch it. We could - * alternatively make it the first byte of the buffer contents, but - * this seems easier. + * that the pq_sendXXX routines won't touch it. We could alternatively + * make it the first byte of the buffer contents, but this seems easier. */ buf->cursor = msgtype; } @@ -664,8 +663,8 @@ pq_getmsgstring(StringInfo msg) str = &msg->data[msg->cursor]; /* - * It's safe to use strlen() here because a StringInfo is guaranteed - * to have a trailing null byte. But check we found a null inside the + * It's safe to use strlen() here because a StringInfo is guaranteed to + * have a trailing null byte. But check we found a null inside the * message. */ slen = strlen(str); diff --git a/src/backend/libpq/pqsignal.c b/src/backend/libpq/pqsignal.c index 6bc3535e83..abf13e33fc 100644 --- a/src/backend/libpq/pqsignal.c +++ b/src/backend/libpq/pqsignal.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/libpq/pqsignal.c,v 1.40 2005/02/14 23:02:35 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/libpq/pqsignal.c,v 1.41 2005/10/15 02:49:18 momjian Exp $ * * NOTES * This shouldn't be in libpq, but the monitor and some other @@ -50,7 +50,6 @@ sigset_t UnBlockSig, BlockSig, AuthBlockSig; - #else int UnBlockSig, BlockSig, @@ -83,9 +82,9 @@ pqinitmask(void) sigfillset(&AuthBlockSig); /* - * Unmark those signals that should never be blocked. Some of these - * signal names don't exist on all platforms. Most do, but might as - * well ifdef them all for consistency... + * Unmark those signals that should never be blocked. Some of these signal + * names don't exist on all platforms. Most do, but might as well ifdef + * them all for consistency... */ #ifdef SIGTRAP sigdelset(&BlockSig, SIGTRAP); @@ -135,7 +134,7 @@ pqinitmask(void) UnBlockSig = 0; BlockSig = sigmask(SIGQUIT) | sigmask(SIGTERM) | sigmask(SIGALRM) | - /* common signals between two */ + /* common signals between two */ sigmask(SIGHUP) | sigmask(SIGINT) | sigmask(SIGUSR1) | sigmask(SIGUSR2) | sigmask(SIGCHLD) | diff --git a/src/backend/main/main.c b/src/backend/main/main.c index ed1895d839..ea1a3bef25 100644 --- a/src/backend/main/main.c +++ b/src/backend/main/main.c @@ -13,7 +13,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/main/main.c,v 1.95 2005/10/13 15:37:14 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/main/main.c,v 1.96 2005/10/15 02:49:18 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -56,15 +56,15 @@ main(int argc, char *argv[]) char *pw_name_persist; /* - * Place platform-specific startup hacks here. This is the right - * place to put code that must be executed early in launch of either a - * postmaster, a standalone backend, or a standalone bootstrap run. - * Note that this code will NOT be executed when a backend or - * sub-bootstrap run is forked by the postmaster. + * Place platform-specific startup hacks here. This is the right place to + * put code that must be executed early in launch of either a postmaster, + * a standalone backend, or a standalone bootstrap run. Note that this + * code will NOT be executed when a backend or sub-bootstrap run is forked + * by the postmaster. * - * XXX The need for code here is proof that the platform in question is - * too brain-dead to provide a standard C execution environment - * without help. Avoid adding more here, if you can. + * XXX The need for code here is proof that the platform in question is too + * brain-dead to provide a standard C execution environment without help. + * Avoid adding more here, if you can. */ #if defined(__alpha) /* no __alpha__ ? */ @@ -78,12 +78,11 @@ main(int argc, char *argv[]) #endif /* - * On some platforms, unaligned memory accesses result in a kernel - * trap; the default kernel behavior is to emulate the memory - * access, but this results in a significant performance - * penalty. We ought to fix PG not to make such unaligned memory - * accesses, so this code disables the kernel emulation: unaligned - * accesses will result in SIGBUS instead. + * On some platforms, unaligned memory accesses result in a kernel trap; + * the default kernel behavior is to emulate the memory access, but this + * results in a significant performance penalty. We ought to fix PG not to + * make such unaligned memory accesses, so this code disables the kernel + * emulation: unaligned accesses will result in SIGBUS instead. */ #ifdef NOFIXADE @@ -125,31 +124,30 @@ main(int argc, char *argv[]) #endif /* - * Not-quite-so-platform-specific startup environment checks. Still - * best to minimize these. + * Not-quite-so-platform-specific startup environment checks. Still best + * to minimize these. */ /* - * Remember the physical location of the initially given argv[] array - * for possible use by ps display. On some platforms, the argv[] - * storage must be overwritten in order to set the process title for - * ps. In such cases save_ps_display_args makes and returns a new copy - * of the argv[] array. + * Remember the physical location of the initially given argv[] array for + * possible use by ps display. On some platforms, the argv[] storage must + * be overwritten in order to set the process title for ps. In such cases + * save_ps_display_args makes and returns a new copy of the argv[] array. * - * save_ps_display_args may also move the environment strings to make - * extra room. Therefore this should be done as early as possible - * during startup, to avoid entanglements with code that might save a - * getenv() result pointer. + * save_ps_display_args may also move the environment strings to make extra + * room. Therefore this should be done as early as possible during + * startup, to avoid entanglements with code that might save a getenv() + * result pointer. */ argv = save_ps_display_args(argc, argv); /* * Set up locale information from environment. Note that LC_CTYPE and * LC_COLLATE will be overridden later from pg_control if we are in an - * already-initialized database. We set them here so that they will - * be available to fill pg_control during initdb. LC_MESSAGES will - * get set later during GUC option processing, but we set it here to - * allow startup error messages to be localized. + * already-initialized database. We set them here so that they will be + * available to fill pg_control during initdb. LC_MESSAGES will get set + * later during GUC option processing, but we set it here to allow startup + * error messages to be localized. */ set_pglocale_pgservice(argv[0], "postgres"); @@ -157,11 +155,10 @@ main(int argc, char *argv[]) #ifdef WIN32 /* - * Windows uses codepages rather than the environment, so we work - * around that by querying the environment explicitly first for - * LC_COLLATE and LC_CTYPE. We have to do this because initdb passes - * those values in the environment. If there is nothing there we fall - * back on the codepage. + * Windows uses codepages rather than the environment, so we work around + * that by querying the environment explicitly first for LC_COLLATE and + * LC_CTYPE. We have to do this because initdb passes those values in the + * environment. If there is nothing there we fall back on the codepage. */ if ((env_locale = getenv("LC_COLLATE")) != NULL) @@ -183,17 +180,16 @@ main(int argc, char *argv[]) #endif /* - * We keep these set to "C" always, except transiently in pg_locale.c; - * see that file for explanations. + * We keep these set to "C" always, except transiently in pg_locale.c; see + * that file for explanations. */ setlocale(LC_MONETARY, "C"); setlocale(LC_NUMERIC, "C"); setlocale(LC_TIME, "C"); /* - * Skip permission checks if we're just trying to do --help or - * --version; otherwise root will get unhelpful failure messages from - * initdb. + * Skip permission checks if we're just trying to do --help or --version; + * otherwise root will get unhelpful failure messages from initdb. */ if (!(argc > 1 && (strcmp(argv[1], "--help") == 0 || @@ -215,19 +211,19 @@ main(int argc, char *argv[]) write_stderr("\"root\" execution of the PostgreSQL server is not permitted.\n" "The server must be started under an unprivileged user ID to prevent\n" "possible system security compromise. See the documentation for\n" - "more information on how to properly start the server.\n"); + "more information on how to properly start the server.\n"); exit(1); } #endif /* !__BEOS__ */ /* - * Also make sure that real and effective uids are the same. - * Executing Postgres as a setuid program from a root shell is a - * security hole, since on many platforms a nefarious subroutine - * could setuid back to root if real uid is root. (Since nobody - * actually uses Postgres as a setuid program, trying to actively - * fix this situation seems more trouble than it's worth; we'll - * just expend the effort to check for it.) + * Also make sure that real and effective uids are the same. Executing + * Postgres as a setuid program from a root shell is a security hole, + * since on many platforms a nefarious subroutine could setuid back to + * root if real uid is root. (Since nobody actually uses Postgres as + * a setuid program, trying to actively fix this situation seems more + * trouble than it's worth; we'll just expend the effort to check for + * it.) */ if (getuid() != geteuid()) { @@ -242,7 +238,7 @@ main(int argc, char *argv[]) "permitted.\n" "The server must be started under an unprivileged user ID to prevent\n" "possible system security compromises. See the documentation for\n" - "more information on how to properly start the server.\n"); + "more information on how to properly start the server.\n"); exit(1); } #endif /* !WIN32 */ @@ -250,9 +246,9 @@ main(int argc, char *argv[]) /* * Now dispatch to one of PostmasterMain, PostgresMain, GucInfoMain, - * SubPostmasterMain, or BootstrapMain depending on the program name - * (and possibly first argument) we were called with. The lack of - * consistency here is historical. + * SubPostmasterMain, or BootstrapMain depending on the program name (and + * possibly first argument) we were called with. The lack of consistency + * here is historical. */ if (strcmp(get_progname(argv[0]), "postmaster") == 0) { @@ -262,8 +258,8 @@ main(int argc, char *argv[]) /* * If the first argument begins with "-fork", then invoke - * SubPostmasterMain. This is used for forking postmaster child - * processes on systems where we can't simply fork. + * SubPostmasterMain. This is used for forking postmaster child processes + * on systems where we can't simply fork. */ #ifdef EXEC_BACKEND if (argc > 1 && strncmp(argv[1], "-fork", 5) == 0) @@ -271,11 +267,12 @@ main(int argc, char *argv[]) #endif #ifdef WIN32 + /* * Start our win32 signal implementation * - * SubPostmasterMain() will do this for itself, but the remaining - * modes need it here + * SubPostmasterMain() will do this for itself, but the remaining modes need + * it here */ pgwin32_signal_initialize(); #endif @@ -295,9 +292,8 @@ main(int argc, char *argv[]) exit(GucInfoMain()); /* - * Otherwise we're a standalone backend. Invoke PostgresMain, - * specifying current userid as the "authenticated" Postgres user - * name. + * Otherwise we're a standalone backend. Invoke PostgresMain, specifying + * current userid as the "authenticated" Postgres user name. */ #ifndef WIN32 pw = getpwuid(geteuid()); diff --git a/src/backend/nodes/bitmapset.c b/src/backend/nodes/bitmapset.c index d74ba6189e..916833df0d 100644 --- a/src/backend/nodes/bitmapset.c +++ b/src/backend/nodes/bitmapset.c @@ -14,7 +14,7 @@ * Copyright (c) 2003-2005, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/nodes/bitmapset.c,v 1.9 2005/06/15 16:24:07 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/nodes/bitmapset.c,v 1.10 2005/10/15 02:49:18 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -769,7 +769,7 @@ bms_first_member(Bitmapset *a) * * Note: we must ensure that any two bitmapsets that are bms_equal() will * hash to the same value; in practice this means that trailing all-zero - * words cannot affect the result. The circular-shift-and-XOR hash method + * words cannot affect the result. The circular-shift-and-XOR hash method * used here has this property, so long as we work from back to front. * * Note: you might wonder why we bother with the circular shift; at first @@ -779,7 +779,7 @@ bms_first_member(Bitmapset *a) * multiword bitmapsets is "a JOIN b JOIN c JOIN d ...", which gives rise * to rangetables in which base tables and JOIN nodes alternate; so * bitmapsets of base table RT indexes tend to use only odd-numbered or only - * even-numbered bits. A straight longitudinal XOR would preserve this + * even-numbered bits. A straight longitudinal XOR would preserve this * property, leading to a much smaller set of possible outputs than if * we include a shift. */ @@ -791,7 +791,7 @@ bms_hash_value(const Bitmapset *a) if (a == NULL || a->nwords <= 0) return 0; /* All empty sets hash to 0 */ - for (wordnum = a->nwords; --wordnum > 0; ) + for (wordnum = a->nwords; --wordnum > 0;) { result ^= a->words[wordnum]; if (result & ((bitmapword) 1 << (BITS_PER_BITMAPWORD - 1))) diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c index 9c21c2f977..4a90b10b27 100644 --- a/src/backend/nodes/copyfuncs.c +++ b/src/backend/nodes/copyfuncs.c @@ -15,7 +15,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.315 2005/08/01 20:31:08 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.316 2005/10/15 02:49:18 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -154,7 +154,7 @@ _copyAppend(Append *from) static BitmapAnd * _copyBitmapAnd(BitmapAnd *from) { - BitmapAnd *newnode = makeNode(BitmapAnd); + BitmapAnd *newnode = makeNode(BitmapAnd); /* * copy node superclass fields @@ -175,7 +175,7 @@ _copyBitmapAnd(BitmapAnd *from) static BitmapOr * _copyBitmapOr(BitmapOr *from) { - BitmapOr *newnode = makeNode(BitmapOr); + BitmapOr *newnode = makeNode(BitmapOr); /* * copy node superclass fields @@ -269,7 +269,7 @@ _copyIndexScan(IndexScan *from) static BitmapIndexScan * _copyBitmapIndexScan(BitmapIndexScan *from) { - BitmapIndexScan *newnode = makeNode(BitmapIndexScan); + BitmapIndexScan *newnode = makeNode(BitmapIndexScan); /* * copy node superclass fields @@ -294,7 +294,7 @@ _copyBitmapIndexScan(BitmapIndexScan *from) static BitmapHeapScan * _copyBitmapHeapScan(BitmapHeapScan *from) { - BitmapHeapScan *newnode = makeNode(BitmapHeapScan); + BitmapHeapScan *newnode = makeNode(BitmapHeapScan); /* * copy node superclass fields @@ -1262,8 +1262,7 @@ _copyRestrictInfo(RestrictInfo *from) COPY_SCALAR_FIELD(right_sortop); /* - * Do not copy pathkeys, since they'd not be canonical in a copied - * query + * Do not copy pathkeys, since they'd not be canonical in a copied query */ newnode->left_pathkey = NIL; newnode->right_pathkey = NIL; @@ -1791,7 +1790,7 @@ _copyFuncWithArgs(FuncWithArgs *from) static GrantRoleStmt * _copyGrantRoleStmt(GrantRoleStmt *from) { - GrantRoleStmt *newnode = makeNode(GrantRoleStmt); + GrantRoleStmt *newnode = makeNode(GrantRoleStmt); COPY_NODE_FIELD(granted_roles); COPY_NODE_FIELD(grantee_roles); @@ -2906,8 +2905,8 @@ copyObject(void *from) break; /* - * Lists of integers and OIDs don't need to be deep-copied, so - * we perform a shallow copy via list_copy() + * Lists of integers and OIDs don't need to be deep-copied, so we + * perform a shallow copy via list_copy() */ case T_IntList: case T_OidList: diff --git a/src/backend/nodes/equalfuncs.c b/src/backend/nodes/equalfuncs.c index 326eb9c62a..9baa79dd93 100644 --- a/src/backend/nodes/equalfuncs.c +++ b/src/backend/nodes/equalfuncs.c @@ -18,7 +18,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.252 2005/08/01 20:31:08 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.253 2005/10/15 02:49:18 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -135,8 +135,7 @@ _equalConst(Const *a, Const *b) /* * We treat all NULL constants of the same type as equal. Someday this - * might need to change? But datumIsEqual doesn't work on nulls, - * so... + * might need to change? But datumIsEqual doesn't work on nulls, so... */ if (a->constisnull) return true; @@ -202,8 +201,8 @@ _equalFuncExpr(FuncExpr *a, FuncExpr *b) COMPARE_SCALAR_FIELD(funcretset); /* - * Special-case COERCE_DONTCARE, so that planner can build coercion - * nodes that are equal() to both explicit and implicit coercions. + * Special-case COERCE_DONTCARE, so that planner can build coercion nodes + * that are equal() to both explicit and implicit coercions. */ if (a->funcformat != b->funcformat && a->funcformat != COERCE_DONTCARE && @@ -222,9 +221,9 @@ _equalOpExpr(OpExpr *a, OpExpr *b) /* * Special-case opfuncid: it is allowable for it to differ if one node - * contains zero and the other doesn't. This just means that the one - * node isn't as far along in the parse/plan pipeline and hasn't had - * the opfuncid cache filled yet. + * contains zero and the other doesn't. This just means that the one node + * isn't as far along in the parse/plan pipeline and hasn't had the + * opfuncid cache filled yet. */ if (a->opfuncid != b->opfuncid && a->opfuncid != 0 && @@ -245,9 +244,9 @@ _equalDistinctExpr(DistinctExpr *a, DistinctExpr *b) /* * Special-case opfuncid: it is allowable for it to differ if one node - * contains zero and the other doesn't. This just means that the one - * node isn't as far along in the parse/plan pipeline and hasn't had - * the opfuncid cache filled yet. + * contains zero and the other doesn't. This just means that the one node + * isn't as far along in the parse/plan pipeline and hasn't had the + * opfuncid cache filled yet. */ if (a->opfuncid != b->opfuncid && a->opfuncid != 0 && @@ -268,9 +267,9 @@ _equalScalarArrayOpExpr(ScalarArrayOpExpr *a, ScalarArrayOpExpr *b) /* * Special-case opfuncid: it is allowable for it to differ if one node - * contains zero and the other doesn't. This just means that the one - * node isn't as far along in the parse/plan pipeline and hasn't had - * the opfuncid cache filled yet. + * contains zero and the other doesn't. This just means that the one node + * isn't as far along in the parse/plan pipeline and hasn't had the + * opfuncid cache filled yet. */ if (a->opfuncid != b->opfuncid && a->opfuncid != 0 && @@ -354,8 +353,8 @@ _equalRelabelType(RelabelType *a, RelabelType *b) COMPARE_SCALAR_FIELD(resulttypmod); /* - * Special-case COERCE_DONTCARE, so that planner can build coercion - * nodes that are equal() to both explicit and implicit coercions. + * Special-case COERCE_DONTCARE, so that planner can build coercion nodes + * that are equal() to both explicit and implicit coercions. */ if (a->relabelformat != b->relabelformat && a->relabelformat != COERCE_DONTCARE && @@ -372,8 +371,8 @@ _equalConvertRowtypeExpr(ConvertRowtypeExpr *a, ConvertRowtypeExpr *b) COMPARE_SCALAR_FIELD(resulttype); /* - * Special-case COERCE_DONTCARE, so that planner can build coercion - * nodes that are equal() to both explicit and implicit coercions. + * Special-case COERCE_DONTCARE, so that planner can build coercion nodes + * that are equal() to both explicit and implicit coercions. */ if (a->convertformat != b->convertformat && a->convertformat != COERCE_DONTCARE && @@ -430,8 +429,8 @@ _equalRowExpr(RowExpr *a, RowExpr *b) COMPARE_SCALAR_FIELD(row_typeid); /* - * Special-case COERCE_DONTCARE, so that planner can build coercion - * nodes that are equal() to both explicit and implicit coercions. + * Special-case COERCE_DONTCARE, so that planner can build coercion nodes + * that are equal() to both explicit and implicit coercions. */ if (a->row_format != b->row_format && a->row_format != COERCE_DONTCARE && @@ -467,9 +466,9 @@ _equalNullIfExpr(NullIfExpr *a, NullIfExpr *b) /* * Special-case opfuncid: it is allowable for it to differ if one node - * contains zero and the other doesn't. This just means that the one - * node isn't as far along in the parse/plan pipeline and hasn't had - * the opfuncid cache filled yet. + * contains zero and the other doesn't. This just means that the one node + * isn't as far along in the parse/plan pipeline and hasn't had the + * opfuncid cache filled yet. */ if (a->opfuncid != b->opfuncid && a->opfuncid != 0 && @@ -509,8 +508,8 @@ _equalCoerceToDomain(CoerceToDomain *a, CoerceToDomain *b) COMPARE_SCALAR_FIELD(resulttypmod); /* - * Special-case COERCE_DONTCARE, so that planner can build coercion - * nodes that are equal() to both explicit and implicit coercions. + * Special-case COERCE_DONTCARE, so that planner can build coercion nodes + * that are equal() to both explicit and implicit coercions. */ if (a->coercionformat != b->coercionformat && a->coercionformat != COERCE_DONTCARE && @@ -606,8 +605,8 @@ _equalRestrictInfo(RestrictInfo *a, RestrictInfo *b) COMPARE_BITMAPSET_FIELD(required_relids); /* - * We ignore all the remaining fields, since they may not be set yet, - * and should be derivable from the clause anyway. + * We ignore all the remaining fields, since they may not be set yet, and + * should be derivable from the clause anyway. */ return true; @@ -1717,15 +1716,15 @@ _equalList(List *a, List *b) ListCell *item_b; /* - * Try to reject by simple scalar checks before grovelling through all - * the list elements... + * Try to reject by simple scalar checks before grovelling through all the + * list elements... */ COMPARE_SCALAR_FIELD(type); COMPARE_SCALAR_FIELD(length); /* - * We place the switch outside the loop for the sake of efficiency; - * this may not be worth doing... + * We place the switch outside the loop for the sake of efficiency; this + * may not be worth doing... */ switch (a->type) { diff --git a/src/backend/nodes/list.c b/src/backend/nodes/list.c index 80043834b6..c775770f70 100644 --- a/src/backend/nodes/list.c +++ b/src/backend/nodes/list.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/nodes/list.c,v 1.65 2005/07/28 20:26:19 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/nodes/list.c,v 1.66 2005/10/15 02:49:18 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -50,7 +50,6 @@ check_list_invariants(List *list) Assert(list->head->next == list->tail); Assert(list->tail->next == NULL); } - #else #define check_list_invariants(l) #endif /* USE_ASSERT_CHECKING */ @@ -532,9 +531,9 @@ list_delete_cell(List *list, ListCell *cell, ListCell *prev) Assert(prev != NULL ? lnext(prev) == cell : list_head(list) == cell); /* - * If we're about to delete the last node from the list, free the - * whole list instead and return NIL, which is the only valid - * representation of a zero-length list. + * If we're about to delete the last node from the list, free the whole + * list instead and return NIL, which is the only valid representation of + * a zero-length list. */ if (list->length == 1) { @@ -543,9 +542,8 @@ list_delete_cell(List *list, ListCell *cell, ListCell *prev) } /* - * Otherwise, adjust the necessary list links, deallocate the - * particular node we have just removed, and return the list we were - * given. + * Otherwise, adjust the necessary list links, deallocate the particular + * node we have just removed, and return the list we were given. */ list->length--; @@ -951,7 +949,7 @@ list_append_unique_oid(List *list, Oid datum) * via equal(). * * This is almost the same functionality as list_union(), but list1 is - * modified in-place rather than being copied. Note also that list2's cells + * modified in-place rather than being copied. Note also that list2's cells * are not inserted in list1, so the analogy to list_concat() isn't perfect. */ List * @@ -1110,8 +1108,8 @@ list_copy(List *oldlist) newlist->length = oldlist->length; /* - * Copy over the data in the first cell; new_list() has already - * allocated the head cell itself + * Copy over the data in the first cell; new_list() has already allocated + * the head cell itself */ newlist->head->data = oldlist->head->data; @@ -1163,8 +1161,8 @@ list_copy_tail(List *oldlist, int nskip) oldlist_cur = oldlist_cur->next; /* - * Copy over the data in the first remaining cell; new_list() has - * already allocated the head cell itself + * Copy over the data in the first remaining cell; new_list() has already + * allocated the head cell itself */ newlist->head->data = oldlist_cur->data; diff --git a/src/backend/nodes/makefuncs.c b/src/backend/nodes/makefuncs.c index e1e6c3da83..28202af9ee 100644 --- a/src/backend/nodes/makefuncs.c +++ b/src/backend/nodes/makefuncs.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/nodes/makefuncs.c,v 1.47 2005/04/06 16:34:05 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/nodes/makefuncs.c,v 1.48 2005/10/15 02:49:18 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -73,11 +73,10 @@ makeVar(Index varno, var->varlevelsup = varlevelsup; /* - * Since few if any routines ever create Var nodes with - * varnoold/varoattno different from varno/varattno, we don't provide - * separate arguments for them, but just initialize them to the given - * varno/varattno. This reduces code clutter and chance of error for - * most callers. + * Since few if any routines ever create Var nodes with varnoold/varoattno + * different from varno/varattno, we don't provide separate arguments for + * them, but just initialize them to the given varno/varattno. This + * reduces code clutter and chance of error for most callers. */ var->varnoold = varno; var->varoattno = varattno; @@ -102,8 +101,8 @@ makeTargetEntry(Expr *expr, tle->resname = resname; /* - * We always set these fields to 0. If the caller wants to change them - * he must do so explicitly. Few callers do that, so omitting these + * We always set these fields to 0. If the caller wants to change them he + * must do so explicitly. Few callers do that, so omitting these * arguments reduces the chance of error. */ tle->ressortgroupref = 0; diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c index d6d1236388..19306b3e53 100644 --- a/src/backend/nodes/outfuncs.c +++ b/src/backend/nodes/outfuncs.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.260 2005/08/27 22:13:43 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.261 2005/10/15 02:49:18 momjian Exp $ * * NOTES * Every node type that can appear in stored rules' parsetrees *must* @@ -113,9 +113,9 @@ _outToken(StringInfo str, char *s) } /* - * Look for characters or patterns that are treated specially by - * read.c (either in pg_strtok() or in nodeRead()), and therefore need - * a protective backslash. + * Look for characters or patterns that are treated specially by read.c + * (either in pg_strtok() or in nodeRead()), and therefore need a + * protective backslash. */ /* These characters only need to be quoted at the start of the string */ if (*s == '<' || @@ -151,8 +151,8 @@ _outList(StringInfo str, List *node) { /* * For the sake of backward compatibility, we emit a slightly - * different whitespace format for lists of nodes vs. other types - * of lists. XXX: is this necessary? + * different whitespace format for lists of nodes vs. other types of + * lists. XXX: is this necessary? */ if (IsA(node, List)) { @@ -1444,9 +1444,9 @@ _outQuery(StringInfo str, Query *node) /* * Hack to work around missing outfuncs routines for a lot of the * utility-statement node types. (The only one we actually *need* for - * rules support is NotifyStmt.) Someday we ought to support 'em all, - * but for the meantime do this to avoid getting lots of warnings when - * running with debug_print_parse on. + * rules support is NotifyStmt.) Someday we ought to support 'em all, but + * for the meantime do this to avoid getting lots of warnings when running + * with debug_print_parse on. */ if (node->utilityStmt) { @@ -1616,8 +1616,8 @@ _outValue(StringInfo str, Value *value) case T_Float: /* - * We assume the value is a valid numeric literal and so does - * not need quoting. + * We assume the value is a valid numeric literal and so does not + * need quoting. */ appendStringInfoString(str, value->val.str); break; @@ -2099,9 +2099,8 @@ _outNode(StringInfo str, void *obj) default: /* - * This should be an ERROR, but it's too useful to be able - * to dump structures that _outNode only understands part - * of. + * This should be an ERROR, but it's too useful to be able to + * dump structures that _outNode only understands part of. */ elog(WARNING, "could not dump unrecognized node type: %d", (int) nodeTag(obj)); diff --git a/src/backend/nodes/print.c b/src/backend/nodes/print.c index 9d6511cf50..2f70355b32 100644 --- a/src/backend/nodes/print.c +++ b/src/backend/nodes/print.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/nodes/print.c,v 1.76 2005/05/01 18:56:18 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/nodes/print.c,v 1.77 2005/10/15 02:49:19 momjian Exp $ * * HISTORY * AUTHOR DATE MAJOR EVENT @@ -603,7 +603,7 @@ print_plan_recursive(Plan *p, Query *parsetree, int indentLevel, char *label) if (IsA(p, BitmapAnd)) { ListCell *l; - BitmapAnd *bitmapandplan = (BitmapAnd *) p; + BitmapAnd *bitmapandplan = (BitmapAnd *) p; foreach(l, bitmapandplan->bitmapplans) { @@ -616,7 +616,7 @@ print_plan_recursive(Plan *p, Query *parsetree, int indentLevel, char *label) if (IsA(p, BitmapOr)) { ListCell *l; - BitmapOr *bitmaporplan = (BitmapOr *) p; + BitmapOr *bitmaporplan = (BitmapOr *) p; foreach(l, bitmaporplan->bitmapplans) { diff --git a/src/backend/nodes/read.c b/src/backend/nodes/read.c index df2165863d..09175074d5 100644 --- a/src/backend/nodes/read.c +++ b/src/backend/nodes/read.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/nodes/read.c,v 1.46 2004/12/31 21:59:55 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/nodes/read.c,v 1.47 2005/10/15 02:49:19 momjian Exp $ * * HISTORY * AUTHOR DATE MAJOR EVENT @@ -41,10 +41,10 @@ stringToNode(char *str) void *retval; /* - * We save and restore the pre-existing state of pg_strtok. This makes - * the world safe for re-entrant invocation of stringToNode, without - * incurring a lot of notational overhead by having to pass the - * next-character pointer around through all the readfuncs.c code. + * We save and restore the pre-existing state of pg_strtok. This makes the + * world safe for re-entrant invocation of stringToNode, without incurring + * a lot of notational overhead by having to pass the next-character + * pointer around through all the readfuncs.c code. */ save_strtok = pg_strtok_ptr; @@ -211,13 +211,13 @@ nodeTokenType(char *token, int length) if (*numptr == '+' || *numptr == '-') numptr++, numlen--; if ((numlen > 0 && isdigit((unsigned char) *numptr)) || - (numlen > 1 && *numptr == '.' && isdigit((unsigned char) numptr[1]))) + (numlen > 1 && *numptr == '.' && isdigit((unsigned char) numptr[1]))) { /* * Yes. Figure out whether it is integral or float; this requires - * both a syntax check and a range check. strtol() can do both for - * us. We know the token will end at a character that strtol will - * stop at, so we do not need to modify the string. + * both a syntax check and a range check. strtol() can do both for us. + * We know the token will end at a character that strtol will stop at, + * so we do not need to modify the string. */ long val; char *endptr; @@ -386,8 +386,7 @@ nodeRead(char *token, int tok_len) case T_Integer: /* - * we know that the token terminates on a char atol will stop - * at + * we know that the token terminates on a char atol will stop at */ result = (Node *) makeInteger(atol(token)); break; diff --git a/src/backend/nodes/readfuncs.c b/src/backend/nodes/readfuncs.c index ff49ee21f2..46c9983446 100644 --- a/src/backend/nodes/readfuncs.c +++ b/src/backend/nodes/readfuncs.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/nodes/readfuncs.c,v 1.181 2005/08/01 20:31:08 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/nodes/readfuncs.c,v 1.182 2005/10/15 02:49:19 momjian Exp $ * * NOTES * Path and Plan nodes do not have any readfuncs support, because we @@ -389,12 +389,12 @@ _readOpExpr(void) READ_OID_FIELD(opfuncid); /* - * The opfuncid is stored in the textual format primarily for - * debugging and documentation reasons. We want to always read it as - * zero to force it to be re-looked-up in the pg_operator entry. This - * ensures that stored rules don't have hidden dependencies on - * operators' functions. (We don't currently support an ALTER OPERATOR - * command, but might someday.) + * The opfuncid is stored in the textual format primarily for debugging + * and documentation reasons. We want to always read it as zero to force + * it to be re-looked-up in the pg_operator entry. This ensures that + * stored rules don't have hidden dependencies on operators' functions. + * (We don't currently support an ALTER OPERATOR command, but might + * someday.) */ local_node->opfuncid = InvalidOid; @@ -417,12 +417,12 @@ _readDistinctExpr(void) READ_OID_FIELD(opfuncid); /* - * The opfuncid is stored in the textual format primarily for - * debugging and documentation reasons. We want to always read it as - * zero to force it to be re-looked-up in the pg_operator entry. This - * ensures that stored rules don't have hidden dependencies on - * operators' functions. (We don't currently support an ALTER OPERATOR - * command, but might someday.) + * The opfuncid is stored in the textual format primarily for debugging + * and documentation reasons. We want to always read it as zero to force + * it to be re-looked-up in the pg_operator entry. This ensures that + * stored rules don't have hidden dependencies on operators' functions. + * (We don't currently support an ALTER OPERATOR command, but might + * someday.) */ local_node->opfuncid = InvalidOid; @@ -445,12 +445,12 @@ _readScalarArrayOpExpr(void) READ_OID_FIELD(opfuncid); /* - * The opfuncid is stored in the textual format primarily for - * debugging and documentation reasons. We want to always read it as - * zero to force it to be re-looked-up in the pg_operator entry. This - * ensures that stored rules don't have hidden dependencies on - * operators' functions. (We don't currently support an ALTER OPERATOR - * command, but might someday.) + * The opfuncid is stored in the textual format primarily for debugging + * and documentation reasons. We want to always read it as zero to force + * it to be re-looked-up in the pg_operator entry. This ensures that + * stored rules don't have hidden dependencies on operators' functions. + * (We don't currently support an ALTER OPERATOR command, but might + * someday.) */ local_node->opfuncid = InvalidOid; @@ -686,12 +686,12 @@ _readNullIfExpr(void) READ_OID_FIELD(opfuncid); /* - * The opfuncid is stored in the textual format primarily for - * debugging and documentation reasons. We want to always read it as - * zero to force it to be re-looked-up in the pg_operator entry. This - * ensures that stored rules don't have hidden dependencies on - * operators' functions. (We don't currently support an ALTER OPERATOR - * command, but might someday.) + * The opfuncid is stored in the textual format primarily for debugging + * and documentation reasons. We want to always read it as zero to force + * it to be re-looked-up in the pg_operator entry. This ensures that + * stored rules don't have hidden dependencies on operators' functions. + * (We don't currently support an ALTER OPERATOR command, but might + * someday.) */ local_node->opfuncid = InvalidOid; diff --git a/src/backend/nodes/tidbitmap.c b/src/backend/nodes/tidbitmap.c index a3b5c7d6d0..bcfc7d0920 100644 --- a/src/backend/nodes/tidbitmap.c +++ b/src/backend/nodes/tidbitmap.c @@ -23,7 +23,7 @@ * Copyright (c) 2003-2005, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/nodes/tidbitmap.c,v 1.7 2005/09/02 19:02:20 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/nodes/tidbitmap.c,v 1.8 2005/10/15 02:49:19 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -39,7 +39,7 @@ /* * The maximum number of tuples per page is not large (typically 256 with * 8K pages, or 1024 with 32K pages). So there's not much point in making - * the per-page bitmaps variable size. We just legislate that the size + * the per-page bitmaps variable size. We just legislate that the size * is this: */ #define MAX_TUPLES_PER_PAGE MaxHeapTuplesPerPage @@ -52,10 +52,10 @@ * for that page in the page table. * * We actually store both exact pages and lossy chunks in the same hash - * table, using identical data structures. (This is because dynahash.c's + * table, using identical data structures. (This is because dynahash.c's * memory management doesn't allow space to be transferred easily from one * hashtable to another.) Therefore it's best if PAGES_PER_CHUNK is the - * same as MAX_TUPLES_PER_PAGE, or at least not too different. But we + * same as MAX_TUPLES_PER_PAGE, or at least not too different. But we * also want PAGES_PER_CHUNK to be a power of 2 to avoid expensive integer * remainder operations. So, define it like this: */ @@ -69,7 +69,7 @@ typedef uint32 bitmapword; /* must be an unsigned type */ #define BITNUM(x) ((x) % BITS_PER_BITMAPWORD) /* number of active words for an exact page: */ -#define WORDS_PER_PAGE ((MAX_TUPLES_PER_PAGE - 1) / BITS_PER_BITMAPWORD + 1) +#define WORDS_PER_PAGE ((MAX_TUPLES_PER_PAGE - 1) / BITS_PER_BITMAPWORD + 1) /* number of active words for a lossy chunk: */ #define WORDS_PER_CHUNK ((PAGES_PER_CHUNK - 1) / BITS_PER_BITMAPWORD + 1) @@ -85,7 +85,7 @@ typedef uint32 bitmapword; /* must be an unsigned type */ */ typedef struct PagetableEntry { - BlockNumber blockno; /* page number (hashtable key) */ + BlockNumber blockno; /* page number (hashtable key) */ bool ischunk; /* T = lossy storage, F = exact */ bitmapword words[Max(WORDS_PER_PAGE, WORDS_PER_CHUNK)]; } PagetableEntry; @@ -136,9 +136,9 @@ struct TIDBitmap /* Local function prototypes */ static void tbm_union_page(TIDBitmap *a, const PagetableEntry *bpage); static bool tbm_intersect_page(TIDBitmap *a, PagetableEntry *apage, - const TIDBitmap *b); + const TIDBitmap *b); static const PagetableEntry *tbm_find_pageentry(const TIDBitmap *tbm, - BlockNumber pageno); + BlockNumber pageno); static PagetableEntry *tbm_get_pageentry(TIDBitmap *tbm, BlockNumber pageno); static bool tbm_page_is_lossy(const TIDBitmap *tbm, BlockNumber pageno); static void tbm_mark_page_lossy(TIDBitmap *tbm, BlockNumber pageno); @@ -160,8 +160,8 @@ tbm_create(long maxbytes) long nbuckets; /* - * Create the TIDBitmap struct, with enough trailing space to serve - * the needs of the TBMIterateResult sub-struct. + * Create the TIDBitmap struct, with enough trailing space to serve the + * needs of the TBMIterateResult sub-struct. */ tbm = (TIDBitmap *) palloc(sizeof(TIDBitmap) + MAX_TUPLES_PER_PAGE * sizeof(OffsetNumber)); @@ -173,17 +173,17 @@ tbm_create(long maxbytes) tbm->status = TBM_EMPTY; /* - * Estimate number of hashtable entries we can have within maxbytes. - * This estimates the hash overhead at MAXALIGN(sizeof(HASHELEMENT)) - * plus a pointer per hash entry, which is crude but good enough for - * our purpose. Also count an extra Pointer per entry for the arrays - * created during iteration readout. + * Estimate number of hashtable entries we can have within maxbytes. This + * estimates the hash overhead at MAXALIGN(sizeof(HASHELEMENT)) plus a + * pointer per hash entry, which is crude but good enough for our purpose. + * Also count an extra Pointer per entry for the arrays created during + * iteration readout. */ nbuckets = maxbytes / (MAXALIGN(sizeof(HASHELEMENT)) + MAXALIGN(sizeof(PagetableEntry)) + sizeof(Pointer) + sizeof(Pointer)); - nbuckets = Min(nbuckets, INT_MAX-1); /* safety limit */ - nbuckets = Max(nbuckets, 16); /* sanity limit */ + nbuckets = Min(nbuckets, INT_MAX - 1); /* safety limit */ + nbuckets = Max(nbuckets, 16); /* sanity limit */ tbm->maxentries = (int) nbuckets; return tbm; @@ -319,7 +319,7 @@ static void tbm_union_page(TIDBitmap *a, const PagetableEntry *bpage) { PagetableEntry *apage; - int wordnum; + int wordnum; if (bpage->ischunk) { @@ -330,7 +330,7 @@ tbm_union_page(TIDBitmap *a, const PagetableEntry *bpage) if (w != 0) { - BlockNumber pg; + BlockNumber pg; pg = bpage->blockno + (wordnum * BITS_PER_BITMAPWORD); while (w != 0) @@ -428,12 +428,12 @@ static bool tbm_intersect_page(TIDBitmap *a, PagetableEntry *apage, const TIDBitmap *b) { const PagetableEntry *bpage; - int wordnum; + int wordnum; if (apage->ischunk) { /* Scan each bit in chunk, try to clear */ - bool candelete = true; + bool candelete = true; for (wordnum = 0; wordnum < WORDS_PER_PAGE; wordnum++) { @@ -442,8 +442,8 @@ tbm_intersect_page(TIDBitmap *a, PagetableEntry *apage, const TIDBitmap *b) if (w != 0) { bitmapword neww = w; - BlockNumber pg; - int bitnum; + BlockNumber pg; + int bitnum; pg = apage->blockno + (wordnum * BITS_PER_BITMAPWORD); bitnum = 0; @@ -472,19 +472,19 @@ tbm_intersect_page(TIDBitmap *a, PagetableEntry *apage, const TIDBitmap *b) else if (tbm_page_is_lossy(b, apage->blockno)) { /* - * When the page is lossy in b, we have to mark it lossy in a too. - * We know that no bits need be set in bitmap a, but we do not know - * which ones should be cleared, and we have no API for "at most - * these tuples need be checked". (Perhaps it's worth adding that?) + * When the page is lossy in b, we have to mark it lossy in a too. We + * know that no bits need be set in bitmap a, but we do not know which + * ones should be cleared, and we have no API for "at most these + * tuples need be checked". (Perhaps it's worth adding that?) */ tbm_mark_page_lossy(a, apage->blockno); /* - * Note: tbm_mark_page_lossy will have removed apage from a, and - * may have inserted a new lossy chunk instead. We can continue the - * same seq_search scan at the caller level, because it does not - * matter whether we visit such a new chunk or not: it will have - * only the bit for apage->blockno set, which is correct. + * Note: tbm_mark_page_lossy will have removed apage from a, and may + * have inserted a new lossy chunk instead. We can continue the same + * seq_search scan at the caller level, because it does not matter + * whether we visit such a new chunk or not: it will have only the bit + * for apage->blockno set, which is correct. * * We must return false here since apage was already deleted. */ @@ -492,7 +492,7 @@ tbm_intersect_page(TIDBitmap *a, PagetableEntry *apage, const TIDBitmap *b) } else { - bool candelete = true; + bool candelete = true; bpage = tbm_find_pageentry(b, apage->blockno); if (bpage != NULL) @@ -535,17 +535,20 @@ tbm_begin_iterate(TIDBitmap *tbm) int nchunks; tbm->iterating = true; + /* * Reset iteration pointers. */ tbm->spageptr = 0; tbm->schunkptr = 0; tbm->schunkbit = 0; + /* * Nothing else to do if no entries, nor if we don't have a hashtable. */ if (tbm->nentries == 0 || tbm->status != TBM_HASH) return; + /* * Create and fill the sorted page lists if we didn't already. */ @@ -591,6 +594,7 @@ tbm_iterate(TIDBitmap *tbm) TBMIterateResult *output = &(tbm->output); Assert(tbm->iterating); + /* * If lossy chunk pages remain, make sure we've advanced schunkptr/ * schunkbit to the next set bit. @@ -598,12 +602,12 @@ tbm_iterate(TIDBitmap *tbm) while (tbm->schunkptr < tbm->nchunks) { PagetableEntry *chunk = tbm->schunks[tbm->schunkptr]; - int schunkbit = tbm->schunkbit; + int schunkbit = tbm->schunkbit; while (schunkbit < PAGES_PER_CHUNK) { - int wordnum = WORDNUM(schunkbit); - int bitnum = BITNUM(schunkbit); + int wordnum = WORDNUM(schunkbit); + int bitnum = BITNUM(schunkbit); if ((chunk->words[wordnum] & ((bitmapword) 1 << bitnum)) != 0) break; @@ -618,6 +622,7 @@ tbm_iterate(TIDBitmap *tbm) tbm->schunkptr++; tbm->schunkbit = 0; } + /* * If both chunk and per-page data remain, must output the numerically * earlier page. @@ -717,7 +722,7 @@ tbm_find_pageentry(const TIDBitmap *tbm, BlockNumber pageno) * * If new, the entry is marked as an exact (non-chunk) entry. * - * This may cause the table to exceed the desired memory size. It is + * This may cause the table to exceed the desired memory size. It is * up to the caller to call tbm_lossify() at the next safe point if so. */ static PagetableEntry * @@ -785,8 +790,8 @@ tbm_page_is_lossy(const TIDBitmap *tbm, BlockNumber pageno) HASH_FIND, NULL); if (page != NULL && page->ischunk) { - int wordnum = WORDNUM(bitno); - int bitnum = BITNUM(bitno); + int wordnum = WORDNUM(bitno); + int bitnum = BITNUM(bitno); if ((page->words[wordnum] & ((bitmapword) 1 << bitnum)) != 0) return true; @@ -797,7 +802,7 @@ tbm_page_is_lossy(const TIDBitmap *tbm, BlockNumber pageno) /* * tbm_mark_page_lossy - mark the page number as lossily stored * - * This may cause the table to exceed the desired memory size. It is + * This may cause the table to exceed the desired memory size. It is * up to the caller to call tbm_lossify() at the next safe point if so. */ static void @@ -818,9 +823,8 @@ tbm_mark_page_lossy(TIDBitmap *tbm, BlockNumber pageno) chunk_pageno = pageno - bitno; /* - * Remove any extant non-lossy entry for the page. If the page is - * its own chunk header, however, we skip this and handle the case - * below. + * Remove any extant non-lossy entry for the page. If the page is its own + * chunk header, however, we skip this and handle the case below. */ if (bitno != 0) { @@ -879,10 +883,9 @@ tbm_lossify(TIDBitmap *tbm) /* * XXX Really stupid implementation: this just lossifies pages in - * essentially random order. We should be paying some attention - * to the number of bits set in each page, instead. Also it might - * be a good idea to lossify more than the minimum number of pages - * during each call. + * essentially random order. We should be paying some attention to the + * number of bits set in each page, instead. Also it might be a good idea + * to lossify more than the minimum number of pages during each call. */ Assert(!tbm->iterating); Assert(tbm->status == TBM_HASH); @@ -892,9 +895,10 @@ tbm_lossify(TIDBitmap *tbm) { if (page->ischunk) continue; /* already a chunk header */ + /* - * If the page would become a chunk header, we won't save anything - * by converting it to lossy, so skip it. + * If the page would become a chunk header, we won't save anything by + * converting it to lossy, so skip it. */ if ((page->blockno % PAGES_PER_CHUNK) == 0) continue; @@ -906,9 +910,9 @@ tbm_lossify(TIDBitmap *tbm) return; /* we have done enough */ /* - * Note: tbm_mark_page_lossy may have inserted a lossy chunk into - * the hashtable. We can continue the same seq_search scan since - * we do not care whether we visit lossy chunks or not. + * Note: tbm_mark_page_lossy may have inserted a lossy chunk into the + * hashtable. We can continue the same seq_search scan since we do + * not care whether we visit lossy chunks or not. */ } } diff --git a/src/backend/optimizer/geqo/geqo_erx.c b/src/backend/optimizer/geqo/geqo_erx.c index 05d7602fef..9c7a342585 100644 --- a/src/backend/optimizer/geqo/geqo_erx.c +++ b/src/backend/optimizer/geqo/geqo_erx.c @@ -3,7 +3,7 @@ * geqo_erx.c * edge recombination crossover [ER] * -* $PostgreSQL: pgsql/src/backend/optimizer/geqo/geqo_erx.c,v 1.19 2003/11/29 22:39:49 pgsql Exp $ +* $PostgreSQL: pgsql/src/backend/optimizer/geqo/geqo_erx.c,v 1.20 2005/10/15 02:49:19 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -55,8 +55,8 @@ alloc_edge_table(int num_gene) Edge *edge_table; /* - * palloc one extra location so that nodes numbered 1..n can be - * indexed directly; 0 will not be used + * palloc one extra location so that nodes numbered 1..n can be indexed + * directly; 0 will not be used */ edge_table = (Edge *) palloc((num_gene + 1) * sizeof(Edge)); @@ -94,8 +94,7 @@ gimme_edge_table(Gene *tour1, Gene *tour2, int num_gene, Edge *edge_table) int i, index1, index2; - int edge_total; /* total number of unique edges in two - * genes */ + int edge_total; /* total number of unique edges in two genes */ /* at first clear the edge table's old data */ for (i = 1; i <= num_gene; i++) @@ -111,15 +110,15 @@ gimme_edge_table(Gene *tour1, Gene *tour2, int num_gene, Edge *edge_table) for (index1 = 0; index1 < num_gene; index1++) { /* - * presume the tour is circular, i.e. 1->2, 2->3, 3->1 this - * operaton maps n back to 1 + * presume the tour is circular, i.e. 1->2, 2->3, 3->1 this operaton + * maps n back to 1 */ index2 = (index1 + 1) % num_gene; /* - * edges are bidirectional, i.e. 1->2 is same as 2->1 call - * gimme_edge twice per edge + * edges are bidirectional, i.e. 1->2 is same as 2->1 call gimme_edge + * twice per edge */ edge_total += gimme_edge(tour1[index1], tour1[index2], edge_table); @@ -320,10 +319,10 @@ gimme_gene(Edge edge, Edge *edge_table) */ /* - * The test for minimum_count can probably be removed at some - * point but comments should probably indicate exactly why it is - * guaranteed that the test will always succeed the first time - * around. If it can fail then the code is in error + * The test for minimum_count can probably be removed at some point + * but comments should probably indicate exactly why it is guaranteed + * that the test will always succeed the first time around. If it can + * fail then the code is in error */ @@ -379,8 +378,8 @@ edge_failure(Gene *gene, int index, Edge *edge_table, int num_gene) /* - * how many edges remain? how many gene with four total (initial) - * edges remain? + * how many edges remain? how many gene with four total (initial) edges + * remain? */ for (i = 1; i <= num_gene; i++) @@ -395,8 +394,8 @@ edge_failure(Gene *gene, int index, Edge *edge_table, int num_gene) } /* - * random decision of the gene with remaining edges and whose - * total_edges == 4 + * random decision of the gene with remaining edges and whose total_edges + * == 4 */ if (four_count != 0) @@ -444,15 +443,15 @@ edge_failure(Gene *gene, int index, Edge *edge_table, int num_gene) } /* - * edge table seems to be empty; this happens sometimes on the last - * point due to the fact that the first point is removed from the - * table even though only one of its edges has been determined + * edge table seems to be empty; this happens sometimes on the last point + * due to the fact that the first point is removed from the table even + * though only one of its edges has been determined */ else - { /* occurs only at the last point in the - * tour; simply look for the point which - * is not yet used */ + { /* occurs only at the last point in the tour; + * simply look for the point which is not yet + * used */ for (i = 1; i <= num_gene; i++) if (edge_table[i].unused_edges >= 0) diff --git a/src/backend/optimizer/geqo/geqo_eval.c b/src/backend/optimizer/geqo/geqo_eval.c index d1bb3059fc..0a2dee08dc 100644 --- a/src/backend/optimizer/geqo/geqo_eval.c +++ b/src/backend/optimizer/geqo/geqo_eval.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/optimizer/geqo/geqo_eval.c,v 1.76 2005/06/09 04:18:59 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/geqo/geqo_eval.c,v 1.77 2005/10/15 02:49:19 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -52,15 +52,15 @@ geqo_eval(Gene *tour, int num_gene, GeqoEvalData *evaldata) struct HTAB *savehash; /* - * Because gimme_tree considers both left- and right-sided trees, - * there is no difference between a tour (a,b,c,d,...) and a tour - * (b,a,c,d,...) --- the same join orders will be considered. To avoid - * redundant cost calculations, we simply reject tours where tour[0] > - * tour[1], assigning them an artificially bad fitness. + * Because gimme_tree considers both left- and right-sided trees, there is + * no difference between a tour (a,b,c,d,...) and a tour (b,a,c,d,...) --- + * the same join orders will be considered. To avoid redundant cost + * calculations, we simply reject tours where tour[0] > tour[1], assigning + * them an artificially bad fitness. * * init_tour() is aware of this rule and so we should never reject a tour - * during the initial filling of the pool. It seems difficult to - * persuade the recombination logic never to break the rule, however. + * during the initial filling of the pool. It seems difficult to persuade + * the recombination logic never to break the rule, however. */ if (num_gene >= 2 && tour[0] > tour[1]) return DBL_MAX; @@ -69,10 +69,10 @@ geqo_eval(Gene *tour, int num_gene, GeqoEvalData *evaldata) * Create a private memory context that will hold all temp storage * allocated inside gimme_tree(). * - * Since geqo_eval() will be called many times, we can't afford to let - * all that memory go unreclaimed until end of statement. Note we - * make the temp context a child of the planner's normal context, so - * that it will be freed even if we abort via ereport(ERROR). + * Since geqo_eval() will be called many times, we can't afford to let all + * that memory go unreclaimed until end of statement. Note we make the + * temp context a child of the planner's normal context, so that it will + * be freed even if we abort via ereport(ERROR). */ mycontext = AllocSetContextCreate(CurrentMemoryContext, "GEQO", @@ -84,15 +84,15 @@ geqo_eval(Gene *tour, int num_gene, GeqoEvalData *evaldata) /* * gimme_tree will add entries to root->join_rel_list, which may or may * not already contain some entries. The newly added entries will be - * recycled by the MemoryContextDelete below, so we must ensure that - * the list is restored to its former state before exiting. We can - * do this by truncating the list to its original length. NOTE this - * assumes that any added entries are appended at the end! + * recycled by the MemoryContextDelete below, so we must ensure that the + * list is restored to its former state before exiting. We can do this by + * truncating the list to its original length. NOTE this assumes that any + * added entries are appended at the end! * - * We also must take care not to mess up the outer join_rel_hash, - * if there is one. We can do this by just temporarily setting the - * link to NULL. (If we are dealing with enough join rels, which we - * very likely are, a new hash table will get built and used locally.) + * We also must take care not to mess up the outer join_rel_hash, if there is + * one. We can do this by just temporarily setting the link to NULL. (If + * we are dealing with enough join rels, which we very likely are, a new + * hash table will get built and used locally.) */ savelength = list_length(evaldata->root->join_rel_list); savehash = evaldata->root->join_rel_hash; @@ -170,23 +170,22 @@ gimme_tree(Gene *tour, int num_gene, GeqoEvalData *evaldata) * Push each relation onto the stack in the specified order. After * pushing each relation, see whether the top two stack entries are * joinable according to the desirable_join() heuristics. If so, join - * them into one stack entry, and try again to combine with the next - * stack entry down (if any). When the stack top is no longer - * joinable, continue to the next input relation. After we have - * pushed the last input relation, the heuristics are disabled and we - * force joining all the remaining stack entries. + * them into one stack entry, and try again to combine with the next stack + * entry down (if any). When the stack top is no longer joinable, + * continue to the next input relation. After we have pushed the last + * input relation, the heuristics are disabled and we force joining all + * the remaining stack entries. * * If desirable_join() always returns true, this produces a straight - * left-to-right join just like the old code. Otherwise we may - * produce a bushy plan or a left/right-sided plan that really - * corresponds to some tour other than the one given. To the extent - * that the heuristics are helpful, however, this will be a better - * plan than the raw tour. + * left-to-right join just like the old code. Otherwise we may produce a + * bushy plan or a left/right-sided plan that really corresponds to some + * tour other than the one given. To the extent that the heuristics are + * helpful, however, this will be a better plan than the raw tour. * - * Also, when a join attempt fails (because of IN-clause constraints), we - * may be able to recover and produce a workable plan, where the old - * code just had to give up. This case acts the same as a false - * result from desirable_join(). + * Also, when a join attempt fails (because of IN-clause constraints), we may + * be able to recover and produce a workable plan, where the old code just + * had to give up. This case acts the same as a false result from + * desirable_join(). */ for (rel_count = 0; rel_count < num_gene; rel_count++) { @@ -199,8 +198,8 @@ gimme_tree(Gene *tour, int num_gene, GeqoEvalData *evaldata) stack_depth++; /* - * While it's feasible, pop the top two stack entries and replace - * with their join. + * While it's feasible, pop the top two stack entries and replace with + * their join. */ while (stack_depth >= 2) { @@ -208,20 +207,18 @@ gimme_tree(Gene *tour, int num_gene, GeqoEvalData *evaldata) RelOptInfo *inner_rel = stack[stack_depth - 1]; /* - * Don't pop if heuristics say not to join now. However, once - * we have exhausted the input, the heuristics can't prevent - * popping. + * Don't pop if heuristics say not to join now. However, once we + * have exhausted the input, the heuristics can't prevent popping. */ if (rel_count < num_gene - 1 && !desirable_join(evaldata->root, outer_rel, inner_rel)) break; /* - * Construct a RelOptInfo representing the join of these two - * input relations. These are always inner joins. Note that - * we expect the joinrel not to exist in root->join_rel_list - * yet, and so the paths constructed for it will only include - * the ones we want. + * Construct a RelOptInfo representing the join of these two input + * relations. These are always inner joins. Note that we expect + * the joinrel not to exist in root->join_rel_list yet, and so the + * paths constructed for it will only include the ones we want. */ joinrel = make_join_rel(evaldata->root, outer_rel, inner_rel, JOIN_INNER); @@ -266,9 +263,9 @@ desirable_join(PlannerInfo *root, return true; /* - * Join if the rels are members of the same IN sub-select. This is - * needed to improve the odds that we will find a valid solution in a - * case where an IN sub-select has a clauseless join. + * Join if the rels are members of the same IN sub-select. This is needed + * to improve the odds that we will find a valid solution in a case where + * an IN sub-select has a clauseless join. */ foreach(l, root->in_info_list) { diff --git a/src/backend/optimizer/geqo/geqo_main.c b/src/backend/optimizer/geqo/geqo_main.c index c027f4370c..d7618c5d67 100644 --- a/src/backend/optimizer/geqo/geqo_main.c +++ b/src/backend/optimizer/geqo/geqo_main.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/optimizer/geqo/geqo_main.c,v 1.50 2005/06/08 23:02:04 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/geqo/geqo_main.c,v 1.51 2005/10/15 02:49:19 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -106,10 +106,9 @@ geqo(PlannerInfo *root, int number_of_rels, List *initial_rels) random_init_pool(pool, &evaldata); /* sort the pool according to cheapest path as fitness */ - sort_pool(pool); /* we have to do it only one time, since - * all kids replace the worst individuals - * in future (-> geqo_pool.c:spread_chromo - * ) */ + sort_pool(pool); /* we have to do it only one time, since all + * kids replace the worst individuals in + * future (-> geqo_pool.c:spread_chromo ) */ #ifdef GEQO_DEBUG elog(DEBUG1, "GEQO selected %d pool entries, best %.2f, worst %.2f", diff --git a/src/backend/optimizer/geqo/geqo_misc.c b/src/backend/optimizer/geqo/geqo_misc.c index 5afdcd7b8f..ff5bd07e6a 100644 --- a/src/backend/optimizer/geqo/geqo_misc.c +++ b/src/backend/optimizer/geqo/geqo_misc.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/optimizer/geqo/geqo_misc.c,v 1.42 2004/12/31 21:59:58 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/geqo/geqo_misc.c,v 1.43 2005/10/15 02:49:19 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -41,10 +41,10 @@ avg_pool(Pool *pool) elog(ERROR, "pool_size is zero"); /* - * Since the pool may contain multiple occurrences of DBL_MAX, divide - * by pool->size before summing, not after, to avoid overflow. This - * loses a little in speed and accuracy, but this routine is only used - * for debug printouts, so we don't care that much. + * Since the pool may contain multiple occurrences of DBL_MAX, divide by + * pool->size before summing, not after, to avoid overflow. This loses a + * little in speed and accuracy, but this routine is only used for debug + * printouts, so we don't care that much. */ for (i = 0; i < pool->size; i++) cumulative += pool->data[i].worth / pool->size; diff --git a/src/backend/optimizer/geqo/geqo_pool.c b/src/backend/optimizer/geqo/geqo_pool.c index f6881c0f5f..83927facae 100644 --- a/src/backend/optimizer/geqo/geqo_pool.c +++ b/src/backend/optimizer/geqo/geqo_pool.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/optimizer/geqo/geqo_pool.c,v 1.26 2004/12/31 21:59:58 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/geqo/geqo_pool.c,v 1.27 2005/10/15 02:49:19 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -96,13 +96,12 @@ random_init_pool(Pool *pool, GeqoEvalData *evaldata) int bad = 0; /* - * We immediately discard any invalid individuals (those that - * geqo_eval returns DBL_MAX for), thereby not wasting pool space on - * them. + * We immediately discard any invalid individuals (those that geqo_eval + * returns DBL_MAX for), thereby not wasting pool space on them. * - * If we fail to make any valid individuals after 10000 tries, give up; - * this probably means something is broken, and we shouldn't just let - * ourselves get stuck in an infinite loop. + * If we fail to make any valid individuals after 10000 tries, give up; this + * probably means something is broken, and we shouldn't just let ourselves + * get stuck in an infinite loop. */ i = 0; while (i < pool->size) @@ -223,8 +222,8 @@ spread_chromo(Chromosome *chromo, Pool *pool) /* - * these 2 cases move the search indices since a new location has - * not yet been found. + * these 2 cases move the search indices since a new location has not + * yet been found. */ else if (chromo->worth < pool->data[mid].worth) @@ -242,8 +241,7 @@ spread_chromo(Chromosome *chromo, Pool *pool) /* now we have index for chromo */ /* - * move every gene from index on down one position to make room for - * chromo + * move every gene from index on down one position to make room for chromo */ /* diff --git a/src/backend/optimizer/geqo/geqo_recombination.c b/src/backend/optimizer/geqo/geqo_recombination.c index d2ebee1765..c73e5b2a79 100644 --- a/src/backend/optimizer/geqo/geqo_recombination.c +++ b/src/backend/optimizer/geqo/geqo_recombination.c @@ -3,7 +3,7 @@ * geqo_recombination.c * misc recombination procedures * -* $PostgreSQL: pgsql/src/backend/optimizer/geqo/geqo_recombination.c,v 1.14 2004/08/29 05:06:43 momjian Exp $ +* $PostgreSQL: pgsql/src/backend/optimizer/geqo/geqo_recombination.c,v 1.15 2005/10/15 02:49:19 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -62,8 +62,8 @@ init_tour(Gene *tour, int num_gene) } /* - * Since geqo_eval() will reject tours where tour[0] > tour[1], we may - * as well switch the two to make it a valid tour. + * Since geqo_eval() will reject tours where tour[0] > tour[1], we may as + * well switch the two to make it a valid tour. */ if (num_gene >= 2 && tour[0] > tour[1]) { @@ -86,8 +86,8 @@ alloc_city_table(int num_gene) City *city_table; /* - * palloc one extra location so that nodes numbered 1..n can be - * indexed directly; 0 will not be used + * palloc one extra location so that nodes numbered 1..n can be indexed + * directly; 0 will not be used */ city_table = (City *) palloc((num_gene + 1) * sizeof(City)); diff --git a/src/backend/optimizer/geqo/geqo_selection.c b/src/backend/optimizer/geqo/geqo_selection.c index 92b735cb28..32a3e83ae0 100644 --- a/src/backend/optimizer/geqo/geqo_selection.c +++ b/src/backend/optimizer/geqo/geqo_selection.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/optimizer/geqo/geqo_selection.c,v 1.19 2005/06/14 14:21:16 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/geqo/geqo_selection.c,v 1.20 2005/10/15 02:49:19 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -86,13 +86,14 @@ linear(int pool_size, double bias) /* bias is y-intercept of linear /* * If geqo_rand() returns exactly 1.0 then we will get exactly max from - * this equation, whereas we need 0 <= index < max. Also it seems possible - * that roundoff error might deliver values slightly outside the range; - * in particular avoid passing a value slightly less than 0 to sqrt(). - * If we get a bad value just try again. + * this equation, whereas we need 0 <= index < max. Also it seems + * possible that roundoff error might deliver values slightly outside the + * range; in particular avoid passing a value slightly less than 0 to + * sqrt(). If we get a bad value just try again. */ - do { - double sqrtval; + do + { + double sqrtval; sqrtval = (bias * bias) - 4.0 * (bias - 1.0) * geqo_rand(); if (sqrtval > 0.0) diff --git a/src/backend/optimizer/path/allpaths.c b/src/backend/optimizer/path/allpaths.c index aa14deacd0..d8a42b8254 100644 --- a/src/backend/optimizer/path/allpaths.c +++ b/src/backend/optimizer/path/allpaths.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/path/allpaths.c,v 1.136 2005/08/22 17:34:58 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/path/allpaths.c,v 1.137 2005/10/15 02:49:19 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -62,7 +62,7 @@ static void compare_tlist_datatypes(List *tlist, List *colTypes, static bool qual_is_pushdown_safe(Query *subquery, Index rti, Node *qual, bool *differentTypes); static void subquery_push_qual(Query *subquery, - RangeTblEntry *rte, Index rti, Node *qual); + RangeTblEntry *rte, Index rti, Node *qual); static void recurse_push_qual(Node *setOp, Query *topquery, RangeTblEntry *rte, Index rti, Node *qual); @@ -105,7 +105,7 @@ make_one_rel(PlannerInfo *root) if (brel == NULL) continue; - Assert(brel->relid == rti); /* sanity check on array */ + Assert(brel->relid == rti); /* sanity check on array */ /* ignore RTEs that are "other rels" */ if (brel->reloptkind != RELOPT_BASEREL) @@ -134,9 +134,9 @@ set_base_rel_pathlists(PlannerInfo *root) Index rti; /* - * Note: because we call expand_inherited_rtentry inside the loop, - * it's quite possible for the base_rel_array to be enlarged while - * the loop runs. Hence don't try to optimize the loop. + * Note: because we call expand_inherited_rtentry inside the loop, it's + * quite possible for the base_rel_array to be enlarged while the loop + * runs. Hence don't try to optimize the loop. */ for (rti = 1; rti < root->base_rel_array_size; rti++) { @@ -255,8 +255,8 @@ set_inherited_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, ListCell *il; /* - * XXX for now, can't handle inherited expansion of FOR UPDATE/SHARE; - * can we do better? + * XXX for now, can't handle inherited expansion of FOR UPDATE/SHARE; can + * we do better? */ if (list_member_int(root->parse->rowMarks, parentRTindex)) ereport(ERROR, @@ -270,8 +270,8 @@ set_inherited_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, rel->width = 0; /* - * Generate access paths for each table in the tree (parent AND - * children), and pick the cheapest path for each table. + * Generate access paths for each table in the tree (parent AND children), + * and pick the cheapest path for each table. */ foreach(il, inheritlist) { @@ -286,18 +286,17 @@ set_inherited_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, childOID = childrte->relid; /* - * Make a RelOptInfo for the child so we can do planning. - * Mark it as an "other rel" since it will not be part of the - * main join tree. + * Make a RelOptInfo for the child so we can do planning. Mark it as + * an "other rel" since it will not be part of the main join tree. */ childrel = build_other_rel(root, childRTindex); /* - * Copy the parent's targetlist and restriction quals to the - * child, with attribute-number adjustment as needed. We don't - * bother to copy the join quals, since we can't do any joining of - * the individual tables. Also, we just zap attr_needed rather - * than trying to adjust it; it won't be looked at in the child. + * Copy the parent's targetlist and restriction quals to the child, + * with attribute-number adjustment as needed. We don't bother to + * copy the join quals, since we can't do any joining of the + * individual tables. Also, we just zap attr_needed rather than + * trying to adjust it; it won't be looked at in the child. */ childrel->reltargetlist = (List *) adjust_inherited_attrs((Node *) rel->reltargetlist, @@ -320,13 +319,14 @@ set_inherited_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, */ if (constraint_exclusion) { - List *constraint_pred; + List *constraint_pred; constraint_pred = get_relation_constraints(childOID, childrel); + /* - * We do not currently enforce that CHECK constraints contain - * only immutable functions, so it's necessary to check here. - * We daren't draw conclusions from plan-time evaluation of + * We do not currently enforce that CHECK constraints contain only + * immutable functions, so it's necessary to check here. We + * daren't draw conclusions from plan-time evaluation of * non-immutable functions. */ if (!contain_mutable_functions((Node *) constraint_pred)) @@ -351,9 +351,9 @@ set_inherited_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, subpaths = lappend(subpaths, childrel->cheapest_total_path); /* - * Propagate size information from the child back to the parent. - * For simplicity, we use the largest widths from any child as the - * parent estimates. + * Propagate size information from the child back to the parent. For + * simplicity, we use the largest widths from any child as the parent + * estimates. */ rel->rows += childrel->rows; if (childrel->width > rel->width) @@ -377,9 +377,9 @@ set_inherited_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, } /* - * Finally, build Append path and install it as the only access path - * for the parent rel. (Note: this is correct even if we have zero - * or one live subpath due to constraint exclusion.) + * Finally, build Append path and install it as the only access path for + * the parent rel. (Note: this is correct even if we have zero or one + * live subpath due to constraint exclusion.) */ add_path(rel, (Path *) create_append_path(rel, subpaths)); @@ -430,18 +430,18 @@ set_subquery_pathlist(PlannerInfo *root, RelOptInfo *rel, /* * If there are any restriction clauses that have been attached to the - * subquery relation, consider pushing them down to become WHERE or - * HAVING quals of the subquery itself. This transformation is useful - * because it may allow us to generate a better plan for the subquery - * than evaluating all the subquery output rows and then filtering them. + * subquery relation, consider pushing them down to become WHERE or HAVING + * quals of the subquery itself. This transformation is useful because it + * may allow us to generate a better plan for the subquery than evaluating + * all the subquery output rows and then filtering them. * - * There are several cases where we cannot push down clauses. - * Restrictions involving the subquery are checked by - * subquery_is_pushdown_safe(). Restrictions on individual clauses - * are checked by qual_is_pushdown_safe(). + * There are several cases where we cannot push down clauses. Restrictions + * involving the subquery are checked by subquery_is_pushdown_safe(). + * Restrictions on individual clauses are checked by + * qual_is_pushdown_safe(). * - * Non-pushed-down clauses will get evaluated as qpquals of the - * SubqueryScan node. + * Non-pushed-down clauses will get evaluated as qpquals of the SubqueryScan + * node. * * XXX Are there any cases where we want to make a policy decision not to * push down a pushable qual, because it'd result in a worse plan? @@ -475,10 +475,10 @@ set_subquery_pathlist(PlannerInfo *root, RelOptInfo *rel, pfree(differentTypes); /* - * We can safely pass the outer tuple_fraction down to the subquery - * if the outer level has no joining, aggregation, or sorting to do. - * Otherwise we'd better tell the subquery to plan for full retrieval. - * (XXX This could probably be made more intelligent ...) + * We can safely pass the outer tuple_fraction down to the subquery if the + * outer level has no joining, aggregation, or sorting to do. Otherwise + * we'd better tell the subquery to plan for full retrieval. (XXX This + * could probably be made more intelligent ...) */ if (parse->hasAggs || parse->groupClause || @@ -540,8 +540,8 @@ make_fromexpr_rel(PlannerInfo *root, FromExpr *from) /* * Count the number of child jointree nodes. This is the depth of the - * dynamic-programming algorithm we must employ to consider all ways - * of joining the child nodes. + * dynamic-programming algorithm we must employ to consider all ways of + * joining the child nodes. */ levels_needed = list_length(from->fromlist); @@ -603,11 +603,11 @@ make_one_rel_by_joins(PlannerInfo *root, int levels_needed, List *initial_rels) RelOptInfo *rel; /* - * We employ a simple "dynamic programming" algorithm: we first find - * all ways to build joins of two jointree items, then all ways to - * build joins of three items (from two-item joins and single items), - * then four-item joins, and so on until we have considered all ways - * to join all the items into one rel. + * We employ a simple "dynamic programming" algorithm: we first find all + * ways to build joins of two jointree items, then all ways to build joins + * of three items (from two-item joins and single items), then four-item + * joins, and so on until we have considered all ways to join all the + * items into one rel. * * joinitems[j] is a list of all the j-item rels. Initially we set * joinitems[1] to represent all the single-jointree-item relations. @@ -823,8 +823,8 @@ qual_is_pushdown_safe(Query *subquery, Index rti, Node *qual, return false; /* - * Examine all Vars used in clause; since it's a restriction clause, - * all such Vars must refer to subselect output columns. + * Examine all Vars used in clause; since it's a restriction clause, all + * such Vars must refer to subselect output columns. */ vars = pull_var_clause(qual, false); foreach(vl, vars) @@ -835,9 +835,9 @@ qual_is_pushdown_safe(Query *subquery, Index rti, Node *qual, Assert(var->varno == rti); /* - * We use a bitmapset to avoid testing the same attno more than - * once. (NB: this only works because subquery outputs can't have - * negative attnos.) + * We use a bitmapset to avoid testing the same attno more than once. + * (NB: this only works because subquery outputs can't have negative + * attnos.) */ if (bms_is_member(var->varattno, tested)) continue; @@ -893,11 +893,10 @@ subquery_push_qual(Query *subquery, RangeTblEntry *rte, Index rti, Node *qual) else { /* - * We need to replace Vars in the qual (which must refer to - * outputs of the subquery) with copies of the subquery's - * targetlist expressions. Note that at this point, any uplevel - * Vars in the qual should have been replaced with Params, so they - * need no work. + * We need to replace Vars in the qual (which must refer to outputs of + * the subquery) with copies of the subquery's targetlist expressions. + * Note that at this point, any uplevel Vars in the qual should have + * been replaced with Params, so they need no work. * * This step also ensures that when we are pushing into a setop tree, * each component query gets its own copy of the qual. @@ -907,9 +906,9 @@ subquery_push_qual(Query *subquery, RangeTblEntry *rte, Index rti, Node *qual) CMD_SELECT, 0); /* - * Now attach the qual to the proper place: normally WHERE, but - * if the subquery uses grouping or aggregation, put it in HAVING - * (since the qual really refers to the group-result rows). + * Now attach the qual to the proper place: normally WHERE, but if the + * subquery uses grouping or aggregation, put it in HAVING (since the + * qual really refers to the group-result rows). */ if (subquery->hasAggs || subquery->groupClause || subquery->havingQual) subquery->havingQual = make_and_qual(subquery->havingQual, qual); @@ -919,8 +918,8 @@ subquery_push_qual(Query *subquery, RangeTblEntry *rte, Index rti, Node *qual) /* * We need not change the subquery's hasAggs or hasSublinks flags, - * since we can't be pushing down any aggregates that weren't - * there before, and we don't push down subselects at all. + * since we can't be pushing down any aggregates that weren't there + * before, and we don't push down subselects at all. */ } } diff --git a/src/backend/optimizer/path/clausesel.c b/src/backend/optimizer/path/clausesel.c index aad977164a..9a4990898e 100644 --- a/src/backend/optimizer/path/clausesel.c +++ b/src/backend/optimizer/path/clausesel.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/path/clausesel.c,v 1.74 2005/10/11 16:44:40 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/path/clausesel.c,v 1.75 2005/10/15 02:49:19 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -82,7 +82,7 @@ static void addRangeClause(RangeQueryClause **rqlist, Node *clause, * hisel + losel + null_frac - 1.) * * If either selectivity is exactly DEFAULT_INEQ_SEL, we forget this equation - * and instead use DEFAULT_RANGE_INEQ_SEL. The same applies if the equation + * and instead use DEFAULT_RANGE_INEQ_SEL. The same applies if the equation * yields an impossible (negative) result. * * A free side-effect is that we can recognize redundant inequalities such @@ -102,9 +102,9 @@ clauselist_selectivity(PlannerInfo *root, ListCell *l; /* - * Initial scan over clauses. Anything that doesn't look like a - * potential rangequery clause gets multiplied into s1 and forgotten. - * Anything that does gets inserted into an rqlist entry. + * Initial scan over clauses. Anything that doesn't look like a potential + * rangequery clause gets multiplied into s1 and forgotten. Anything that + * does gets inserted into an rqlist entry. */ foreach(l, clauses) { @@ -127,10 +127,10 @@ clauselist_selectivity(PlannerInfo *root, rinfo = NULL; /* - * See if it looks like a restriction clause with a pseudoconstant - * on one side. (Anything more complicated than that might not - * behave in the simple way we are expecting.) Most of the tests - * here can be done more efficiently with rinfo than without. + * See if it looks like a restriction clause with a pseudoconstant on + * one side. (Anything more complicated than that might not behave in + * the simple way we are expecting.) Most of the tests here can be + * done more efficiently with rinfo than without. */ if (is_opclause(clause) && list_length(((OpExpr *) clause)->args) == 2) { @@ -142,10 +142,10 @@ clauselist_selectivity(PlannerInfo *root, { ok = (bms_membership(rinfo->clause_relids) == BMS_SINGLETON) && (is_pseudo_constant_clause_relids(lsecond(expr->args), - rinfo->right_relids) || + rinfo->right_relids) || (varonleft = false, - is_pseudo_constant_clause_relids(linitial(expr->args), - rinfo->left_relids))); + is_pseudo_constant_clause_relids(linitial(expr->args), + rinfo->left_relids))); } else { @@ -159,8 +159,8 @@ clauselist_selectivity(PlannerInfo *root, { /* * If it's not a "<" or ">" operator, just merge the - * selectivity in generically. But if it's the right - * oprrest, add the clause to rqlist for later processing. + * selectivity in generically. But if it's the right oprrest, + * add the clause to rqlist for later processing. */ switch (get_oprrest(expr->opno)) { @@ -199,8 +199,8 @@ clauselist_selectivity(PlannerInfo *root, /* * Exact equality to the default value probably means the - * selectivity function punted. This is not airtight but - * should be good enough. + * selectivity function punted. This is not airtight but should + * be good enough. */ if (rqlist->hibound == DEFAULT_INEQ_SEL || rqlist->lobound == DEFAULT_INEQ_SEL) @@ -289,8 +289,8 @@ addRangeClause(RangeQueryClause **rqlist, Node *clause, for (rqelem = *rqlist; rqelem; rqelem = rqelem->next) { /* - * We use full equal() here because the "var" might be a function - * of one or more attributes of the same relation... + * We use full equal() here because the "var" might be a function of + * one or more attributes of the same relation... */ if (!equal(var, rqelem->var)) continue; @@ -423,17 +423,16 @@ clause_selectivity(PlannerInfo *root, rinfo = (RestrictInfo *) clause; /* - * If possible, cache the result of the selectivity calculation - * for the clause. We can cache if varRelid is zero or the clause - * contains only vars of that relid --- otherwise varRelid will - * affect the result, so mustn't cache. We also have to be - * careful about the jointype. It's OK to cache when jointype is - * JOIN_INNER or one of the outer join types (any given outer-join - * clause should always be examined with the same jointype, so - * result won't change). It's not OK to cache when jointype is one - * of the special types associated with IN processing, because the - * same clause may be examined with different jointypes and the - * result should vary. + * If possible, cache the result of the selectivity calculation for + * the clause. We can cache if varRelid is zero or the clause + * contains only vars of that relid --- otherwise varRelid will affect + * the result, so mustn't cache. We also have to be careful about the + * jointype. It's OK to cache when jointype is JOIN_INNER or one of + * the outer join types (any given outer-join clause should always be + * examined with the same jointype, so result won't change). It's not + * OK to cache when jointype is one of the special types associated + * with IN processing, because the same clause may be examined with + * different jointypes and the result should vary. */ if (varRelid == 0 || bms_is_subset_singleton(rinfo->clause_relids, varRelid)) @@ -477,8 +476,8 @@ clause_selectivity(PlannerInfo *root, Var *var = (Var *) clause; /* - * We probably shouldn't ever see an uplevel Var here, but if we - * do, return the default selectivity... + * We probably shouldn't ever see an uplevel Var here, but if we do, + * return the default selectivity... */ if (var->varlevelsup == 0 && (varRelid == 0 || varRelid == (int) var->varno)) @@ -488,23 +487,23 @@ clause_selectivity(PlannerInfo *root, if (rte->rtekind == RTE_SUBQUERY) { /* - * XXX not smart about subquery references... any way to - * do better? + * XXX not smart about subquery references... any way to do + * better? */ s1 = 0.5; } else { /* - * A Var at the top of a clause must be a bool Var. This - * is equivalent to the clause reln.attribute = 't', so we + * A Var at the top of a clause must be a bool Var. This is + * equivalent to the clause reln.attribute = 't', so we * compute the selectivity as if that is what we have. */ s1 = restriction_selectivity(root, BooleanEqualOperator, list_make2(var, - makeBoolConst(true, - false)), + makeBoolConst(true, + false)), varRelid); } } @@ -534,7 +533,7 @@ clause_selectivity(PlannerInfo *root, { /* inverse of the selectivity of the underlying clause */ s1 = 1.0 - clause_selectivity(root, - (Node *) get_notclausearg((Expr *) clause), + (Node *) get_notclausearg((Expr *) clause), varRelid, jointype); } @@ -576,17 +575,16 @@ clause_selectivity(PlannerInfo *root, { /* * If we are considering a nestloop join then all clauses are - * restriction clauses, since we are only interested in the - * one relation. + * restriction clauses, since we are only interested in the one + * relation. */ is_join_clause = false; } else { /* - * Otherwise, it's a join if there's more than one relation - * used. We can optimize this calculation if an rinfo was - * passed. + * Otherwise, it's a join if there's more than one relation used. + * We can optimize this calculation if an rinfo was passed. */ if (rinfo) is_join_clause = (bms_membership(rinfo->clause_relids) == @@ -613,8 +611,8 @@ clause_selectivity(PlannerInfo *root, else if (is_funcclause(clause)) { /* - * This is not an operator, so we guess at the selectivity. THIS - * IS A HACK TO GET V4 OUT THE DOOR. FUNCS SHOULD BE ABLE TO HAVE + * This is not an operator, so we guess at the selectivity. THIS IS A + * HACK TO GET V4 OUT THE DOOR. FUNCS SHOULD BE ABLE TO HAVE * SELECTIVITIES THEMSELVES. -- JMH 7/9/92 */ s1 = (Selectivity) 0.3333333; diff --git a/src/backend/optimizer/path/costsize.c b/src/backend/optimizer/path/costsize.c index bb506678ce..8a1df9e0a2 100644 --- a/src/backend/optimizer/path/costsize.c +++ b/src/backend/optimizer/path/costsize.c @@ -49,7 +49,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/path/costsize.c,v 1.148 2005/10/05 17:19:19 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/path/costsize.c,v 1.149 2005/10/15 02:49:19 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -121,8 +121,8 @@ clamp_row_est(double nrows) { /* * Force estimate to be at least one row, to make explain output look - * better and to avoid possible divide-by-zero when interpolating - * costs. Make it an integer, too. + * better and to avoid possible divide-by-zero when interpolating costs. + * Make it an integer, too. */ if (nrows < 1.0) nrows = 1.0; @@ -155,12 +155,11 @@ cost_seqscan(Path *path, PlannerInfo *root, /* * disk costs * - * The cost of reading a page sequentially is 1.0, by definition. Note - * that the Unix kernel will typically do some amount of read-ahead - * optimization, so that this cost is less than the true cost of - * reading a page from disk. We ignore that issue here, but must take - * it into account when estimating the cost of non-sequential - * accesses! + * The cost of reading a page sequentially is 1.0, by definition. Note that + * the Unix kernel will typically do some amount of read-ahead + * optimization, so that this cost is less than the true cost of reading a + * page from disk. We ignore that issue here, but must take it into + * account when estimating the cost of non-sequential accesses! */ run_cost += baserel->pages; /* sequential fetches with cost 1.0 */ @@ -276,10 +275,10 @@ cost_index(IndexPath *path, PlannerInfo *root, startup_cost += disable_cost; /* - * Call index-access-method-specific code to estimate the processing - * cost for scanning the index, as well as the selectivity of the - * index (ie, the fraction of main-table tuples we will have to - * retrieve) and its correlation to the main-table tuple order. + * Call index-access-method-specific code to estimate the processing cost + * for scanning the index, as well as the selectivity of the index (ie, + * the fraction of main-table tuples we will have to retrieve) and its + * correlation to the main-table tuple order. */ OidFunctionCall7(index->amcostestimate, PointerGetDatum(root), @@ -292,8 +291,8 @@ cost_index(IndexPath *path, PlannerInfo *root, /* * Save amcostestimate's results for possible use in bitmap scan planning. - * We don't bother to save indexStartupCost or indexCorrelation, because - * a bitmap scan doesn't care about either. + * We don't bother to save indexStartupCost or indexCorrelation, because a + * bitmap scan doesn't care about either. */ path->indextotalcost = indexTotalCost; path->indexselectivity = indexSelectivity; @@ -366,19 +365,18 @@ cost_index(IndexPath *path, PlannerInfo *root, } /* - * min_IO_cost corresponds to the perfectly correlated case - * (csquared=1), max_IO_cost to the perfectly uncorrelated case - * (csquared=0). Note that we just charge random_page_cost per page - * in the uncorrelated case, rather than using - * cost_nonsequential_access, since we've already accounted for - * caching effects by using the Mackert model. + * min_IO_cost corresponds to the perfectly correlated case (csquared=1), + * max_IO_cost to the perfectly uncorrelated case (csquared=0). Note that + * we just charge random_page_cost per page in the uncorrelated case, + * rather than using cost_nonsequential_access, since we've already + * accounted for caching effects by using the Mackert model. */ min_IO_cost = ceil(indexSelectivity * T); max_IO_cost = pages_fetched * random_page_cost; /* - * Now interpolate based on estimated index order correlation to get - * total disk I/O cost for main table accesses. + * Now interpolate based on estimated index order correlation to get total + * disk I/O cost for main table accesses. */ csquared = indexCorrelation * indexCorrelation; @@ -390,9 +388,9 @@ cost_index(IndexPath *path, PlannerInfo *root, * Normally the indexquals will be removed from the list of restriction * clauses that we have to evaluate as qpquals, so we should subtract * their costs from baserestrictcost. But if we are doing a join then - * some of the indexquals are join clauses and shouldn't be - * subtracted. Rather than work out exactly how much to subtract, we - * don't subtract anything. + * some of the indexquals are join clauses and shouldn't be subtracted. + * Rather than work out exactly how much to subtract, we don't subtract + * anything. */ startup_cost += baserel->baserestrictcost.startup; cpu_per_tuple = cpu_tuple_cost + baserel->baserestrictcost.per_tuple; @@ -467,9 +465,9 @@ cost_bitmap_heap_scan(Path *path, PlannerInfo *root, RelOptInfo *baserel, /* * For small numbers of pages we should charge random_page_cost apiece, * while if nearly all the table's pages are being read, it's more - * appropriate to charge 1.0 apiece. The effect is nonlinear, too. - * For lack of a better idea, interpolate like this to determine the - * cost per page. + * appropriate to charge 1.0 apiece. The effect is nonlinear, too. For + * lack of a better idea, interpolate like this to determine the cost per + * page. */ if (pages_fetched >= 2.0) cost_per_page = random_page_cost - @@ -482,10 +480,10 @@ cost_bitmap_heap_scan(Path *path, PlannerInfo *root, RelOptInfo *baserel, /* * Estimate CPU costs per tuple. * - * Often the indexquals don't need to be rechecked at each tuple ... - * but not always, especially not if there are enough tuples involved - * that the bitmaps become lossy. For the moment, just assume they - * will be rechecked always. + * Often the indexquals don't need to be rechecked at each tuple ... but not + * always, especially not if there are enough tuples involved that the + * bitmaps become lossy. For the moment, just assume they will be + * rechecked always. */ startup_cost += baserel->baserestrictcost.startup; cpu_per_tuple = cpu_tuple_cost + baserel->baserestrictcost.per_tuple; @@ -527,7 +525,7 @@ cost_bitmap_tree_node(Path *path, Cost *cost, Selectivity *selec) * Estimate the cost of a BitmapAnd node * * Note that this considers only the costs of index scanning and bitmap - * creation, not the eventual heap access. In that sense the object isn't + * creation, not the eventual heap access. In that sense the object isn't * truly a Path, but it has enough path-like properties (costs in particular) * to warrant treating it as one. */ @@ -535,24 +533,24 @@ void cost_bitmap_and_node(BitmapAndPath *path, PlannerInfo *root) { Cost totalCost; - Selectivity selec; + Selectivity selec; ListCell *l; /* - * We estimate AND selectivity on the assumption that the inputs - * are independent. This is probably often wrong, but we don't - * have the info to do better. + * We estimate AND selectivity on the assumption that the inputs are + * independent. This is probably often wrong, but we don't have the info + * to do better. * * The runtime cost of the BitmapAnd itself is estimated at 100x - * cpu_operator_cost for each tbm_intersect needed. Probably too - * small, definitely too simplistic? + * cpu_operator_cost for each tbm_intersect needed. Probably too small, + * definitely too simplistic? */ totalCost = 0.0; selec = 1.0; foreach(l, path->bitmapquals) { - Path *subpath = (Path *) lfirst(l); - Cost subCost; + Path *subpath = (Path *) lfirst(l); + Cost subCost; Selectivity subselec; cost_bitmap_tree_node(subpath, &subCost, &subselec); @@ -578,25 +576,25 @@ void cost_bitmap_or_node(BitmapOrPath *path, PlannerInfo *root) { Cost totalCost; - Selectivity selec; + Selectivity selec; ListCell *l; /* - * We estimate OR selectivity on the assumption that the inputs - * are non-overlapping, since that's often the case in "x IN (list)" - * type situations. Of course, we clamp to 1.0 at the end. + * We estimate OR selectivity on the assumption that the inputs are + * non-overlapping, since that's often the case in "x IN (list)" type + * situations. Of course, we clamp to 1.0 at the end. * * The runtime cost of the BitmapOr itself is estimated at 100x - * cpu_operator_cost for each tbm_union needed. Probably too - * small, definitely too simplistic? We are aware that the tbm_unions - * are optimized out when the inputs are BitmapIndexScans. + * cpu_operator_cost for each tbm_union needed. Probably too small, + * definitely too simplistic? We are aware that the tbm_unions are + * optimized out when the inputs are BitmapIndexScans. */ totalCost = 0.0; selec = 0.0; foreach(l, path->bitmapquals) { - Path *subpath = (Path *) lfirst(l); - Cost subCost; + Path *subpath = (Path *) lfirst(l); + Cost subCost; Selectivity subselec; cost_bitmap_tree_node(subpath, &subCost, &subselec); @@ -661,10 +659,9 @@ cost_subqueryscan(Path *path, RelOptInfo *baserel) Assert(baserel->rtekind == RTE_SUBQUERY); /* - * Cost of path is cost of evaluating the subplan, plus cost of - * evaluating any restriction clauses that will be attached to the - * SubqueryScan node, plus cpu_tuple_cost to account for selection and - * projection overhead. + * Cost of path is cost of evaluating the subplan, plus cost of evaluating + * any restriction clauses that will be attached to the SubqueryScan node, + * plus cpu_tuple_cost to account for selection and projection overhead. */ path->startup_cost = baserel->subplan->startup_cost; path->total_cost = baserel->subplan->total_cost; @@ -694,8 +691,8 @@ cost_functionscan(Path *path, PlannerInfo *root, RelOptInfo *baserel) /* * For now, estimate function's cost at one operator eval per function - * call. Someday we should revive the function cost estimate columns - * in pg_proc... + * call. Someday we should revive the function cost estimate columns in + * pg_proc... */ cpu_per_tuple = cpu_operator_cost; @@ -758,9 +755,8 @@ cost_sort(Path *path, PlannerInfo *root, startup_cost += 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 < 2.0) tuples = 2.0; @@ -790,8 +786,8 @@ cost_sort(Path *path, PlannerInfo *root, } /* - * Also charge a small amount (arbitrarily set equal to operator cost) - * per extracted tuple. + * Also charge a small amount (arbitrarily set equal to operator cost) per + * extracted tuple. */ run_cost += cpu_operator_cost * tuples; @@ -828,17 +824,16 @@ cost_material(Path *path, /* * Charge a very small amount per inserted tuple, to reflect bookkeeping - * costs. We use cpu_tuple_cost/10 for this. This is needed to break - * the tie that would otherwise exist between nestloop with A outer, + * costs. We use cpu_tuple_cost/10 for this. This is needed to break the + * tie that would otherwise exist between nestloop with A outer, * materialized B inner and nestloop with B outer, materialized A inner. * The extra cost ensures we'll prefer materializing the smaller rel. */ startup_cost += cpu_tuple_cost * 0.1 * tuples; /* - * Also charge a small amount per extracted tuple. We use - * cpu_tuple_cost so that it doesn't appear worthwhile to materialize - * a bare seqscan. + * Also charge a small amount per extracted tuple. We use cpu_tuple_cost + * so that it doesn't appear worthwhile to materialize a bare seqscan. */ run_cost += cpu_tuple_cost * tuples; @@ -865,23 +860,22 @@ cost_agg(Path *path, PlannerInfo *root, Cost total_cost; /* - * We charge one cpu_operator_cost per aggregate function per input - * tuple, and another one per output tuple (corresponding to transfn - * and finalfn calls respectively). If we are grouping, we charge an - * additional cpu_operator_cost per grouping column per input tuple - * for grouping comparisons. + * We charge one cpu_operator_cost per aggregate function per input tuple, + * and another one per output tuple (corresponding to transfn and finalfn + * calls respectively). If we are grouping, we charge an additional + * cpu_operator_cost per grouping column per input tuple for grouping + * comparisons. * * We will produce a single output tuple if not grouping, and a tuple per * group otherwise. We charge cpu_tuple_cost for each output tuple. * - * Note: in this cost model, AGG_SORTED and AGG_HASHED have exactly the - * same total CPU cost, but AGG_SORTED has lower startup cost. If the - * input path is already sorted appropriately, AGG_SORTED should be - * preferred (since it has no risk of memory overflow). This will - * happen as long as the computed total costs are indeed exactly equal - * --- but if there's roundoff error we might do the wrong thing. So - * be sure that the computations below form the same intermediate - * values in the same order. + * Note: in this cost model, AGG_SORTED and AGG_HASHED have exactly the same + * total CPU cost, but AGG_SORTED has lower startup cost. If the input + * path is already sorted appropriately, AGG_SORTED should be preferred + * (since it has no risk of memory overflow). This will happen as long as + * the computed total costs are indeed exactly equal --- but if there's + * roundoff error we might do the wrong thing. So be sure that the + * computations below form the same intermediate values in the same order. */ if (aggstrategy == AGG_PLAIN) { @@ -937,8 +931,8 @@ cost_group(Path *path, PlannerInfo *root, total_cost = input_total_cost; /* - * Charge one cpu_operator_cost per comparison per input tuple. We - * assume all columns get compared at most of the tuples. + * Charge one cpu_operator_cost per comparison per input tuple. We assume + * all columns get compared at most of the tuples. */ total_cost += cpu_operator_cost * input_tuples * numGroupCols; @@ -968,10 +962,10 @@ cost_nestloop(NestPath *path, PlannerInfo *root) Selectivity joininfactor; /* - * If inner path is an indexscan, be sure to use its estimated output - * row count, which may be lower than the restriction-clause-only row - * count of its parent. (We don't include this case in the PATH_ROWS - * macro because it applies *only* to a nestloop's inner relation.) + * If inner path is an indexscan, be sure to use its estimated output row + * count, which may be lower than the restriction-clause-only row count of + * its parent. (We don't include this case in the PATH_ROWS macro because + * it applies *only* to a nestloop's inner relation.) */ if (IsA(inner_path, IndexPath)) inner_path_rows = ((IndexPath *) inner_path)->rows; @@ -982,11 +976,11 @@ cost_nestloop(NestPath *path, PlannerInfo *root) startup_cost += disable_cost; /* - * If we're doing JOIN_IN then we will stop scanning inner tuples for - * an outer tuple as soon as we have one match. Account for the - * effects of this by scaling down the cost estimates in proportion to - * the JOIN_IN selectivity. (This assumes that all the quals attached - * to the join are IN quals, which should be true.) + * If we're doing JOIN_IN then we will stop scanning inner tuples for an + * outer tuple as soon as we have one match. Account for the effects of + * this by scaling down the cost estimates in proportion to the JOIN_IN + * selectivity. (This assumes that all the quals attached to the join are + * IN quals, which should be true.) */ joininfactor = join_in_selectivity(path, root); @@ -996,9 +990,9 @@ cost_nestloop(NestPath *path, PlannerInfo *root) * NOTE: clearly, we must pay both outer and inner paths' startup_cost * before we can start returning tuples, so the join's startup cost is * their sum. What's not so clear is whether the inner path's - * startup_cost must be paid again on each rescan of the inner path. - * This is not true if the inner path is materialized or is a - * hashjoin, but probably is true otherwise. + * startup_cost must be paid again on each rescan of the inner path. This + * is not true if the inner path is materialized or is a hashjoin, but + * probably is true otherwise. */ startup_cost += outer_path->startup_cost + inner_path->startup_cost; run_cost += outer_path->total_cost - outer_path->startup_cost; @@ -1077,12 +1071,11 @@ cost_mergejoin(MergePath *path, PlannerInfo *root) /* * Compute cost and selectivity of the mergequals and qpquals (other - * restriction clauses) separately. We use approx_selectivity here - * for speed --- in most cases, any errors won't affect the result - * much. + * restriction clauses) separately. We use approx_selectivity here for + * speed --- in most cases, any errors won't affect the result much. * - * Note: it's probably bogus to use the normal selectivity calculation - * here when either the outer or inner path is a UniquePath. + * Note: it's probably bogus to use the normal selectivity calculation here + * when either the outer or inner path is a UniquePath. */ merge_selec = approx_selectivity(root, mergeclauses, path->jpath.jointype); @@ -1095,31 +1088,30 @@ cost_mergejoin(MergePath *path, PlannerInfo *root) mergejointuples = clamp_row_est(merge_selec * outer_path_rows * inner_path_rows); /* - * When there are equal merge keys in the outer relation, the - * mergejoin must rescan any matching tuples in the inner relation. - * This means re-fetching inner tuples. Our cost model for this is - * that a re-fetch costs the same as an original fetch, which is - * probably an overestimate; but on the other hand we ignore the - * bookkeeping costs of mark/restore. Not clear if it's worth - * developing a more refined model. + * When there are equal merge keys in the outer relation, the mergejoin + * must rescan any matching tuples in the inner relation. This means + * re-fetching inner tuples. Our cost model for this is that a re-fetch + * costs the same as an original fetch, which is probably an overestimate; + * but on the other hand we ignore the bookkeeping costs of mark/restore. + * Not clear if it's worth developing a more refined model. * - * The number of re-fetches can be estimated approximately as size of - * merge join output minus size of inner relation. Assume that the - * distinct key values are 1, 2, ..., and denote the number of values - * of each key in the outer relation as m1, m2, ...; in the inner - * relation, n1, n2, ... Then we have + * The number of re-fetches can be estimated approximately as size of merge + * join output minus size of inner relation. Assume that the distinct key + * values are 1, 2, ..., and denote the number of values of each key in + * the outer relation as m1, m2, ...; in the inner relation, n1, n2, ... + * Then we have * * size of join = m1 * n1 + m2 * n2 + ... * - * number of rescanned tuples = (m1 - 1) * n1 + (m2 - 1) * n2 + ... = m1 * - * n1 + m2 * n2 + ... - (n1 + n2 + ...) = size of join - size of inner + * number of rescanned tuples = (m1 - 1) * n1 + (m2 - 1) * n2 + ... = m1 * n1 + * + m2 * n2 + ... - (n1 + n2 + ...) = size of join - size of inner * relation * - * This equation works correctly for outer tuples having no inner match - * (nk = 0), but not for inner tuples having no outer match (mk = 0); - * we are effectively subtracting those from the number of rescanned - * tuples, when we should not. Can we do better without expensive - * selectivity computations? + * This equation works correctly for outer tuples having no inner match (nk = + * 0), but not for inner tuples having no outer match (mk = 0); we are + * effectively subtracting those from the number of rescanned tuples, when + * we should not. Can we do better without expensive selectivity + * computations? */ if (IsA(outer_path, UniquePath)) rescannedtuples = 0; @@ -1140,9 +1132,9 @@ cost_mergejoin(MergePath *path, PlannerInfo *root) * inputs that will actually need to be scanned. We use only the first * (most significant) merge clause for this purpose. * - * Since this calculation is somewhat expensive, and will be the same for - * all mergejoin paths associated with the merge clause, we cache the - * results in the RestrictInfo node. + * Since this calculation is somewhat expensive, and will be the same for all + * mergejoin paths associated with the merge clause, we cache the results + * in the RestrictInfo node. */ if (mergeclauses && path->jpath.jointype != JOIN_FULL) { @@ -1181,9 +1173,8 @@ cost_mergejoin(MergePath *path, PlannerInfo *root) /* * Readjust scan selectivities to account for above rounding. This is - * normally an insignificant effect, but when there are only a few - * rows in the inputs, failing to do this makes for a large percentage - * error. + * normally an insignificant effect, but when there are only a few rows in + * the inputs, failing to do this makes for a large percentage error. */ outerscansel = outer_rows / outer_path_rows; innerscansel = inner_rows / inner_path_rows; @@ -1231,20 +1222,20 @@ cost_mergejoin(MergePath *path, PlannerInfo *root) /* CPU costs */ /* - * If we're doing JOIN_IN then we will stop outputting inner tuples - * for an outer tuple as soon as we have one match. Account for the - * effects of this by scaling down the cost estimates in proportion to - * the expected output size. (This assumes that all the quals - * attached to the join are IN quals, which should be true.) + * If we're doing JOIN_IN then we will stop outputting inner tuples for an + * outer tuple as soon as we have one match. Account for the effects of + * this by scaling down the cost estimates in proportion to the expected + * output size. (This assumes that all the quals attached to the join are + * IN quals, which should be true.) */ joininfactor = join_in_selectivity(&path->jpath, root); /* - * The number of tuple comparisons needed is approximately number of - * outer rows plus number of inner rows plus number of rescanned - * tuples (can we refine this?). At each one, we need to evaluate the - * mergejoin quals. NOTE: JOIN_IN mode does not save any work here, - * so do NOT include joininfactor. + * The number of tuple comparisons needed is approximately number of outer + * rows plus number of inner rows plus number of rescanned tuples (can we + * refine this?). At each one, we need to evaluate the mergejoin quals. + * NOTE: JOIN_IN mode does not save any work here, so do NOT include + * joininfactor. */ startup_cost += merge_qual_cost.startup; run_cost += merge_qual_cost.per_tuple * @@ -1253,9 +1244,9 @@ cost_mergejoin(MergePath *path, PlannerInfo *root) /* * For each tuple that gets through the mergejoin proper, we charge * cpu_tuple_cost plus the cost of evaluating additional restriction - * clauses that are to be applied at the join. (This is pessimistic - * since not all of the quals may get evaluated at each tuple.) This - * work is skipped in JOIN_IN mode, so apply the factor. + * clauses that are to be applied at the join. (This is pessimistic since + * not all of the quals may get evaluated at each tuple.) This work is + * skipped in JOIN_IN mode, so apply the factor. */ startup_cost += qp_qual_cost.startup; cpu_per_tuple = cpu_tuple_cost + qp_qual_cost.per_tuple; @@ -1290,9 +1281,9 @@ cost_hashjoin(HashPath *path, PlannerInfo *root) double outer_path_rows = PATH_ROWS(outer_path); double inner_path_rows = PATH_ROWS(inner_path); double outerbytes = relation_byte_size(outer_path_rows, - outer_path->parent->width); + outer_path->parent->width); double innerbytes = relation_byte_size(inner_path_rows, - inner_path->parent->width); + inner_path->parent->width); int num_hashclauses = list_length(hashclauses); int numbuckets; int numbatches; @@ -1306,12 +1297,11 @@ cost_hashjoin(HashPath *path, PlannerInfo *root) /* * Compute cost and selectivity of the hashquals and qpquals (other - * restriction clauses) separately. We use approx_selectivity here - * for speed --- in most cases, any errors won't affect the result - * much. + * restriction clauses) separately. We use approx_selectivity here for + * speed --- in most cases, any errors won't affect the result much. * - * Note: it's probably bogus to use the normal selectivity calculation - * here when either the outer or inner path is a UniquePath. + * Note: it's probably bogus to use the normal selectivity calculation here + * when either the outer or inner path is a UniquePath. */ hash_selec = approx_selectivity(root, hashclauses, path->jpath.jointype); @@ -1329,13 +1319,12 @@ cost_hashjoin(HashPath *path, PlannerInfo *root) startup_cost += inner_path->total_cost; /* - * Cost of computing hash function: must do it once per input tuple. - * We charge one cpu_operator_cost for each column's hash function. + * Cost of computing hash function: must do it once per input tuple. We + * charge one cpu_operator_cost for each column's hash function. * - * XXX when a hashclause is more complex than a single operator, we - * really should charge the extra eval costs of the left or right - * side, as appropriate, here. This seems more work than it's worth - * at the moment. + * XXX when a hashclause is more complex than a single operator, we really + * should charge the extra eval costs of the left or right side, as + * appropriate, here. This seems more work than it's worth at the moment. */ startup_cost += cpu_operator_cost * num_hashclauses * inner_path_rows; run_cost += cpu_operator_cost * num_hashclauses * outer_path_rows; @@ -1345,17 +1334,17 @@ cost_hashjoin(HashPath *path, PlannerInfo *root) inner_path->parent->width, &numbuckets, &numbatches); - virtualbuckets = (double) numbuckets * (double) numbatches; + virtualbuckets = (double) numbuckets *(double) numbatches; /* - * Determine bucketsize fraction for inner relation. We use the - * smallest bucketsize estimated for any individual hashclause; this - * is undoubtedly conservative. + * Determine bucketsize fraction for inner relation. We use the smallest + * bucketsize estimated for any individual hashclause; this is undoubtedly + * conservative. * - * BUT: if inner relation has been unique-ified, we can assume it's good - * for hashing. This is important both because it's the right answer, - * and because we avoid contaminating the cache with a value that's - * wrong for non-unique-ified paths. + * BUT: if inner relation has been unique-ified, we can assume it's good for + * hashing. This is important both because it's the right answer, and + * because we avoid contaminating the cache with a value that's wrong for + * non-unique-ified paths. */ if (IsA(inner_path, UniquePath)) innerbucketsize = 1.0 / virtualbuckets; @@ -1370,13 +1359,12 @@ cost_hashjoin(HashPath *path, PlannerInfo *root) Assert(IsA(restrictinfo, RestrictInfo)); /* - * First we have to figure out which side of the hashjoin - * clause is the inner side. + * First we have to figure out which side of the hashjoin clause + * is the inner side. * * Since we tend to visit the same clauses over and over when - * planning a large query, we cache the bucketsize estimate in - * the RestrictInfo node to avoid repeated lookups of - * statistics. + * planning a large query, we cache the bucketsize estimate in the + * RestrictInfo node to avoid repeated lookups of statistics. */ if (bms_is_subset(restrictinfo->right_relids, inner_path->parent->relids)) @@ -1388,7 +1376,7 @@ cost_hashjoin(HashPath *path, PlannerInfo *root) /* not cached yet */ thisbucketsize = estimate_hash_bucketsize(root, - get_rightop(restrictinfo->clause), + get_rightop(restrictinfo->clause), virtualbuckets); restrictinfo->right_bucketsize = thisbucketsize; } @@ -1404,7 +1392,7 @@ cost_hashjoin(HashPath *path, PlannerInfo *root) /* not cached yet */ thisbucketsize = estimate_hash_bucketsize(root, - get_leftop(restrictinfo->clause), + get_leftop(restrictinfo->clause), virtualbuckets); restrictinfo->left_bucketsize = thisbucketsize; } @@ -1417,10 +1405,10 @@ cost_hashjoin(HashPath *path, PlannerInfo *root) /* * 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. Charge one cost unit per page of I/O (correct since it - * should be nice and sequential...). Writing the inner rel counts as - * startup cost, all the rest as run cost. + * which implies writing and reading most of the tuples to disk an extra + * time. Charge one cost unit per page of I/O (correct since it should be + * nice and sequential...). Writing the inner rel counts as startup cost, + * all the rest as run cost. */ if (numbatches > 1) { @@ -1436,21 +1424,21 @@ cost_hashjoin(HashPath *path, PlannerInfo *root) /* CPU costs */ /* - * If we're doing JOIN_IN then we will stop comparing inner tuples to - * an outer tuple as soon as we have one match. Account for the - * effects of this by scaling down the cost estimates in proportion to - * the expected output size. (This assumes that all the quals - * attached to the join are IN quals, which should be true.) + * If we're doing JOIN_IN then we will stop comparing inner tuples to an + * outer tuple as soon as we have one match. Account for the effects of + * this by scaling down the cost estimates in proportion to the expected + * output size. (This assumes that all the quals attached to the join are + * IN quals, which should be true.) */ joininfactor = join_in_selectivity(&path->jpath, root); /* - * The number of tuple comparisons needed is the number of outer - * tuples times the typical number of tuples in a hash bucket, which - * is the inner relation size times its bucketsize fraction. At each - * one, we need to evaluate the hashjoin quals. (Note: charging the - * full qual eval cost at each tuple is pessimistic, since we don't - * evaluate the quals unless the hash values match exactly.) + * The number of tuple comparisons needed is the number of outer tuples + * times the typical number of tuples in a hash bucket, which is the inner + * relation size times its bucketsize fraction. At each one, we need to + * evaluate the hashjoin quals. (Note: charging the full qual eval cost + * at each tuple is pessimistic, since we don't evaluate the quals unless + * the hash values match exactly.) */ startup_cost += hash_qual_cost.startup; run_cost += hash_qual_cost.per_tuple * @@ -1460,8 +1448,8 @@ cost_hashjoin(HashPath *path, PlannerInfo *root) /* * For each tuple that gets through the hashjoin proper, we charge * cpu_tuple_cost plus the cost of evaluating additional restriction - * clauses that are to be applied at the join. (This is pessimistic - * since not all of the quals may get evaluated at each tuple.) + * clauses that are to be applied at the join. (This is pessimistic since + * not all of the quals may get evaluated at each tuple.) */ startup_cost += qp_qual_cost.startup; cpu_per_tuple = cpu_tuple_cost + qp_qual_cost.per_tuple; @@ -1469,16 +1457,16 @@ cost_hashjoin(HashPath *path, PlannerInfo *root) /* * Bias against putting larger relation on inside. We don't want an - * absolute prohibition, though, since larger relation might have - * better bucketsize --- and we can't trust the size estimates - * unreservedly, anyway. Instead, inflate the run cost by the square - * root of the size ratio. (Why square root? No real good reason, - * but it seems reasonable...) + * absolute prohibition, though, since larger relation might have better + * bucketsize --- and we can't trust the size estimates unreservedly, + * anyway. Instead, inflate the run cost by the square root of the size + * ratio. (Why square root? No real good reason, but it seems + * reasonable...) * * Note: before 7.4 we implemented this by inflating startup cost; but if - * there's a disable_cost component in the input paths' startup cost, - * that unfairly penalizes the hash. Probably it'd be better to keep - * track of disable penalty separately from cost. + * there's a disable_cost component in the input paths' startup cost, that + * unfairly penalizes the hash. Probably it'd be better to keep track of + * disable penalty separately from cost. */ if (innerbytes > outerbytes && outerbytes > 0) run_cost *= sqrt(innerbytes / outerbytes); @@ -1545,13 +1533,13 @@ cost_qual_eval_walker(Node *node, QualCost *total) return false; /* - * Our basic strategy is to charge one cpu_operator_cost for each - * operator or function node in the given tree. Vars and Consts are - * charged zero, and so are boolean operators (AND, OR, NOT). - * Simplistic, but a lot better than no model at all. + * Our basic strategy is to charge one cpu_operator_cost for each operator + * or function node in the given tree. Vars and Consts are charged zero, + * and so are boolean operators (AND, OR, NOT). Simplistic, but a lot + * better than no model at all. * - * Should we try to account for the possibility of short-circuit - * evaluation of AND/OR? + * Should we try to account for the possibility of short-circuit evaluation + * of AND/OR? */ if (IsA(node, FuncExpr) || IsA(node, OpExpr) || @@ -1572,12 +1560,12 @@ cost_qual_eval_walker(Node *node, QualCost *total) { /* * A subplan node in an expression typically indicates that the - * subplan will be executed on each evaluation, so charge - * accordingly. (Sub-selects that can be executed as InitPlans - * have already been removed from the expression.) + * subplan will be executed on each evaluation, so charge accordingly. + * (Sub-selects that can be executed as InitPlans have already been + * removed from the expression.) * - * An exception occurs when we have decided we can implement the - * subplan by hashing. + * An exception occurs when we have decided we can implement the subplan + * by hashing. * */ SubPlan *subplan = (SubPlan *) node; @@ -1586,32 +1574,31 @@ cost_qual_eval_walker(Node *node, QualCost *total) if (subplan->useHashTable) { /* - * If we are using a hash table for the subquery outputs, then - * the cost of evaluating the query is a one-time cost. We - * charge one cpu_operator_cost per tuple for the work of - * loading the hashtable, too. + * If we are using a hash table for the subquery outputs, then the + * cost of evaluating the query is a one-time cost. We charge one + * cpu_operator_cost per tuple for the work of loading the + * hashtable, too. */ total->startup += plan->total_cost + cpu_operator_cost * plan->plan_rows; /* - * The per-tuple costs include the cost of evaluating the - * lefthand expressions, plus the cost of probing the - * hashtable. Recursion into the exprs list will handle the - * lefthand expressions properly, and will count one - * cpu_operator_cost for each comparison operator. That is - * probably too low for the probing cost, but it's hard to - * make a better estimate, so live with it for now. + * The per-tuple costs include the cost of evaluating the lefthand + * expressions, plus the cost of probing the hashtable. Recursion + * into the exprs list will handle the lefthand expressions + * properly, and will count one cpu_operator_cost for each + * comparison operator. That is probably too low for the probing + * cost, but it's hard to make a better estimate, so live with it + * for now. */ } else { /* * Otherwise we will be rescanning the subplan output on each - * evaluation. We need to estimate how much of the output we - * will actually need to scan. NOTE: this logic should agree - * with the estimates used by make_subplan() in - * plan/subselect.c. + * evaluation. We need to estimate how much of the output we will + * actually need to scan. NOTE: this logic should agree with the + * estimates used by make_subplan() in plan/subselect.c. */ Cost plan_run_cost = plan->total_cost - plan->startup_cost; @@ -1636,10 +1623,10 @@ cost_qual_eval_walker(Node *node, QualCost *total) /* * Also account for subplan's startup cost. If the subplan is - * uncorrelated or undirect correlated, AND its topmost node - * is a Sort or Material node, assume that we'll only need to - * pay its startup cost once; otherwise assume we pay the - * startup cost every time. + * uncorrelated or undirect correlated, AND its topmost node is a + * Sort or Material node, assume that we'll only need to pay its + * startup cost once; otherwise assume we pay the startup cost + * every time. */ if (subplan->parParam == NIL && (IsA(plan, Sort) || @@ -1761,9 +1748,9 @@ set_joinrel_size_estimates(PlannerInfo *root, RelOptInfo *rel, /* * Compute joinclause selectivity. Note that we are only considering - * clauses that become restriction clauses at this join level; we are - * not double-counting them because they were not considered in - * estimating the sizes of the component rels. + * clauses that become restriction clauses at this join level; we are not + * double-counting them because they were not considered in estimating the + * sizes of the component rels. */ selec = clauselist_selectivity(root, restrictlist, @@ -1773,13 +1760,13 @@ set_joinrel_size_estimates(PlannerInfo *root, RelOptInfo *rel, /* * Basically, we multiply size of Cartesian product by selectivity. * - * If we are doing an outer join, take that into account: the output must - * be at least as large as the non-nullable input. (Is there any - * chance of being even smarter?) + * If we are doing an outer join, take that into account: the output must be + * at least as large as the non-nullable input. (Is there any chance of + * being even smarter?) * - * For JOIN_IN and variants, the Cartesian product is figured with - * respect to a unique-ified input, and then we can clamp to the size - * of the other input. + * For JOIN_IN and variants, the Cartesian product is figured with respect to + * a unique-ified input, and then we can clamp to the size of the other + * input. */ switch (jointype) { @@ -1848,12 +1835,11 @@ join_in_selectivity(JoinPath *path, PlannerInfo *root) return 1.0; /* - * Return 1.0 if the inner side is already known unique. The case - * where the inner path is already a UniquePath probably cannot happen - * in current usage, but check it anyway for completeness. The - * interesting case is where we've determined the inner relation - * itself is unique, which we can check by looking at the rows - * estimate for its UniquePath. + * Return 1.0 if the inner side is already known unique. The case where + * the inner path is already a UniquePath probably cannot happen in + * current usage, but check it anyway for completeness. The interesting + * case is where we've determined the inner relation itself is unique, + * which we can check by looking at the rows estimate for its UniquePath. */ if (IsA(path->innerjoinpath, UniquePath)) return 1.0; @@ -1866,10 +1852,9 @@ join_in_selectivity(JoinPath *path, PlannerInfo *root) /* * Compute same result set_joinrel_size_estimates would compute for - * JOIN_INNER. Note that we use the input rels' absolute size - * estimates, not PATH_ROWS() which might be less; if we used - * PATH_ROWS() we'd be double-counting the effects of any join clauses - * used in input scans. + * JOIN_INNER. Note that we use the input rels' absolute size estimates, + * not PATH_ROWS() which might be less; if we used PATH_ROWS() we'd be + * double-counting the effects of any join clauses used in input scans. */ selec = clauselist_selectivity(root, path->joinrestrictinfo, @@ -1908,8 +1893,8 @@ set_function_size_estimates(PlannerInfo *root, RelOptInfo *rel) /* * Estimate number of rows the function itself will return. * - * XXX no idea how to do this yet; but we can at least check whether - * function returns set or not... + * XXX no idea how to do this yet; but we can at least check whether function + * returns set or not... */ if (expression_returns_set(rte->funcexpr)) rel->tuples = 1000; @@ -1957,8 +1942,7 @@ set_rel_width(PlannerInfo *root, RelOptInfo *rel) ndx = var->varattno - rel->min_attr; /* - * The width probably hasn't been cached yet, but may as well - * check + * The width probably hasn't been cached yet, but may as well check */ if (rel->attr_widths[ndx] > 0) { diff --git a/src/backend/optimizer/path/indxpath.c b/src/backend/optimizer/path/indxpath.c index f186b89db4..1790cc5266 100644 --- a/src/backend/optimizer/path/indxpath.c +++ b/src/backend/optimizer/path/indxpath.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.190 2005/09/24 22:54:36 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.191 2005/10/15 02:49:19 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -48,9 +48,9 @@ static List *find_usable_indexes(PlannerInfo *root, RelOptInfo *rel, - List *clauses, List *outer_clauses, - bool istoplevel, bool isjoininner, - Relids outer_relids); + List *clauses, List *outer_clauses, + bool istoplevel, bool isjoininner, + Relids outer_relids); static Path *choose_bitmap_and(PlannerInfo *root, RelOptInfo *rel, List *paths); static int bitmap_path_comparator(const void *a, const void *b); static Cost bitmap_and_cost_est(PlannerInfo *root, RelOptInfo *rel, List *paths); @@ -62,25 +62,25 @@ static Oid indexable_operator(Expr *clause, Oid opclass, bool indexkey_on_left); static Relids indexable_outerrelids(RelOptInfo *rel); static bool matches_any_index(RestrictInfo *rinfo, RelOptInfo *rel, - Relids outer_relids); + Relids outer_relids); static List *find_clauses_for_join(PlannerInfo *root, RelOptInfo *rel, - Relids outer_relids, bool isouterjoin); + Relids outer_relids, bool isouterjoin); static ScanDirection match_variant_ordering(PlannerInfo *root, - IndexOptInfo *index, - List *restrictclauses); + IndexOptInfo *index, + List *restrictclauses); static List *identify_ignorable_ordering_cols(PlannerInfo *root, - IndexOptInfo *index, - List *restrictclauses); + IndexOptInfo *index, + List *restrictclauses); static bool match_index_to_query_keys(PlannerInfo *root, - IndexOptInfo *index, - ScanDirection indexscandir, - List *ignorables); + IndexOptInfo *index, + ScanDirection indexscandir, + List *ignorables); static bool match_boolean_index_clause(Node *clause, int indexcol, - IndexOptInfo *index); + IndexOptInfo *index); static bool match_special_index_operator(Expr *clause, Oid opclass, bool indexkey_on_left); static Expr *expand_boolean_index_clause(Node *clause, int indexcol, - IndexOptInfo *index); + IndexOptInfo *index); static List *expand_indexqual_condition(RestrictInfo *rinfo, Oid opclass); static List *prefix_quals(Node *leftop, Oid opclass, Const *prefix, Pattern_Prefix_Status pstatus); @@ -153,8 +153,8 @@ create_index_paths(PlannerInfo *root, RelOptInfo *rel) true, false, NULL); /* - * We can submit them all to add_path. (This generates access paths for - * plain IndexScan plans.) However, for the next step we will only want + * We can submit them all to add_path. (This generates access paths for + * plain IndexScan plans.) However, for the next step we will only want * the ones that have some selectivity; we must discard anything that was * generated solely for ordering purposes. */ @@ -180,8 +180,8 @@ create_index_paths(PlannerInfo *root, RelOptInfo *rel) bitindexpaths = list_concat(bitindexpaths, indexpaths); /* - * If we found anything usable, generate a BitmapHeapPath for the - * most promising combination of bitmap index paths. + * If we found anything usable, generate a BitmapHeapPath for the most + * promising combination of bitmap index paths. */ if (bitindexpaths != NIL) { @@ -254,19 +254,19 @@ find_usable_indexes(PlannerInfo *root, RelOptInfo *rel, bool index_is_ordered; /* - * Ignore partial indexes that do not match the query. If a partial - * index is marked predOK then we know it's OK; otherwise, if we - * are at top level we know it's not OK (since predOK is exactly - * whether its predicate could be proven from the toplevel clauses). - * Otherwise, we have to test whether the added clauses are - * sufficient to imply the predicate. If so, we could use - * the index in the current context. + * Ignore partial indexes that do not match the query. If a partial + * index is marked predOK then we know it's OK; otherwise, if we are + * at top level we know it's not OK (since predOK is exactly whether + * its predicate could be proven from the toplevel clauses). + * Otherwise, we have to test whether the added clauses are sufficient + * to imply the predicate. If so, we could use the index in the + * current context. * - * We set useful_predicate to true iff the predicate was proven - * using the current set of clauses. This is needed to prevent - * matching a predOK index to an arm of an OR, which would be - * a legal but pointlessly inefficient plan. (A better plan will - * be generated by just scanning the predOK index alone, no OR.) + * We set useful_predicate to true iff the predicate was proven using the + * current set of clauses. This is needed to prevent matching a + * predOK index to an arm of an OR, which would be a legal but + * pointlessly inefficient plan. (A better plan will be generated by + * just scanning the predOK index alone, no OR.) */ useful_predicate = false; if (index->indpred != NIL) @@ -282,7 +282,7 @@ find_usable_indexes(PlannerInfo *root, RelOptInfo *rel, else { if (istoplevel) - continue; /* no point in trying to prove it */ + continue; /* no point in trying to prove it */ /* Form all_clauses if not done already */ if (all_clauses == NIL) @@ -290,7 +290,7 @@ find_usable_indexes(PlannerInfo *root, RelOptInfo *rel, outer_clauses); if (!predicate_implied_by(index->indpred, all_clauses)) - continue; /* can't use it at all */ + continue; /* can't use it at all */ if (!predicate_implied_by(index->indpred, outer_clauses)) useful_predicate = true; @@ -309,17 +309,17 @@ find_usable_indexes(PlannerInfo *root, RelOptInfo *rel, &found_clause); /* - * Not all index AMs support scans with no restriction clauses. - * We can't generate a scan over an index with amoptionalkey = false + * Not all index AMs support scans with no restriction clauses. We + * can't generate a scan over an index with amoptionalkey = false * unless there's at least one restriction clause. */ if (restrictclauses == NIL && !index->amoptionalkey) continue; /* - * 2. Compute pathkeys describing index's ordering, if any, then - * see how many of them are actually useful for this query. This - * is not relevant unless we are at top level. + * 2. Compute pathkeys describing index's ordering, if any, then see + * how many of them are actually useful for this query. This is not + * relevant unless we are at top level. */ index_is_ordered = OidIsValid(index->ordering[0]); if (istoplevel && index_is_ordered && !isjoininner) @@ -335,9 +335,8 @@ find_usable_indexes(PlannerInfo *root, RelOptInfo *rel, /* * 3. Generate an indexscan path if there are relevant restriction * clauses in the current clauses, OR the index ordering is - * potentially useful for later merging or final output ordering, - * OR the index has a predicate that was proven by the current - * clauses. + * potentially useful for later merging or final output ordering, OR + * the index has a predicate that was proven by the current clauses. */ if (found_clause || useful_pathkeys != NIL || useful_predicate) { @@ -352,16 +351,15 @@ find_usable_indexes(PlannerInfo *root, RelOptInfo *rel, } /* - * 4. If the index is ordered, and there is a requested query - * ordering that we failed to match, consider variant ways of - * achieving the ordering. Again, this is only interesting - * at top level. + * 4. If the index is ordered, and there is a requested query ordering + * that we failed to match, consider variant ways of achieving the + * ordering. Again, this is only interesting at top level. */ if (istoplevel && index_is_ordered && !isjoininner && root->query_pathkeys != NIL && pathkeys_useful_for_ordering(root, useful_pathkeys) == 0) { - ScanDirection scandir; + ScanDirection scandir; scandir = match_variant_ordering(root, index, restrictclauses); if (!ScanDirectionIsNoMovement(scandir)) @@ -409,9 +407,9 @@ generate_bitmap_or_paths(PlannerInfo *root, RelOptInfo *rel, foreach(l, clauses) { RestrictInfo *rinfo = (RestrictInfo *) lfirst(l); - List *pathlist; - Path *bitmapqual; - ListCell *j; + List *pathlist; + Path *bitmapqual; + ListCell *j; Assert(IsA(rinfo, RestrictInfo)); /* Ignore RestrictInfos that aren't ORs */ @@ -419,19 +417,19 @@ generate_bitmap_or_paths(PlannerInfo *root, RelOptInfo *rel, continue; /* - * We must be able to match at least one index to each of the arms - * of the OR, else we can't use it. + * We must be able to match at least one index to each of the arms of + * the OR, else we can't use it. */ pathlist = NIL; foreach(j, ((BoolExpr *) rinfo->orclause)->args) { - Node *orarg = (Node *) lfirst(j); - List *indlist; + Node *orarg = (Node *) lfirst(j); + List *indlist; /* OR arguments should be ANDs or sub-RestrictInfos */ if (and_clause(orarg)) { - List *andargs = ((BoolExpr *) orarg)->args; + List *andargs = ((BoolExpr *) orarg)->args; indlist = find_usable_indexes(root, rel, andargs, @@ -458,25 +456,28 @@ generate_bitmap_or_paths(PlannerInfo *root, RelOptInfo *rel, isjoininner, outer_relids); } + /* - * If nothing matched this arm, we can't do anything - * with this OR clause. + * If nothing matched this arm, we can't do anything with this OR + * clause. */ if (indlist == NIL) { pathlist = NIL; break; } + /* - * OK, pick the most promising AND combination, - * and add it to pathlist. + * OK, pick the most promising AND combination, and add it to + * pathlist. */ bitmapqual = choose_bitmap_and(root, rel, indlist); pathlist = lappend(pathlist, bitmapqual); } + /* - * If we have a match for every arm, then turn them - * into a BitmapOrPath, and add to result list. + * If we have a match for every arm, then turn them into a + * BitmapOrPath, and add to result list. */ if (pathlist != NIL) { @@ -494,7 +495,7 @@ generate_bitmap_or_paths(PlannerInfo *root, RelOptInfo *rel, * Given a nonempty list of bitmap paths, AND them into one path. * * This is a nontrivial decision since we can legally use any subset of the - * given path set. We want to choose a good tradeoff between selectivity + * given path set. We want to choose a good tradeoff between selectivity * and cost of computing the bitmap. * * The result is either a single one of the inputs, or a BitmapAndPath @@ -511,7 +512,7 @@ choose_bitmap_and(PlannerInfo *root, RelOptInfo *rel, List *paths) int i; ListCell *l; - Assert(npaths > 0); /* else caller error */ + Assert(npaths > 0); /* else caller error */ if (npaths == 1) return (Path *) linitial(paths); /* easy case */ @@ -519,24 +520,23 @@ choose_bitmap_and(PlannerInfo *root, RelOptInfo *rel, List *paths) * In theory we should consider every nonempty subset of the given paths. * In practice that seems like overkill, given the crude nature of the * estimates, not to mention the possible effects of higher-level AND and - * OR clauses. As a compromise, we sort the paths by selectivity. - * We always take the first, and sequentially add on paths that result - * in a lower estimated cost. + * OR clauses. As a compromise, we sort the paths by selectivity. We + * always take the first, and sequentially add on paths that result in a + * lower estimated cost. * - * We also make some effort to detect directly redundant input paths, - * as can happen if there are multiple possibly usable indexes. For - * this we look only at plain IndexPath inputs, not at sub-OR clauses. - * And we consider an index redundant if all its index conditions were - * already used by earlier indexes. (We could use predicate_implied_by - * to have a more intelligent, but much more expensive, check --- but in - * most cases simple pointer equality should suffice, since after all the - * index conditions are all coming from the same RestrictInfo lists.) + * We also make some effort to detect directly redundant input paths, as can + * happen if there are multiple possibly usable indexes. For this we look + * only at plain IndexPath inputs, not at sub-OR clauses. And we consider + * an index redundant if all its index conditions were already used by + * earlier indexes. (We could use predicate_implied_by to have a more + * intelligent, but much more expensive, check --- but in most cases + * simple pointer equality should suffice, since after all the index + * conditions are all coming from the same RestrictInfo lists.) * - * XXX is there any risk of throwing away a useful partial index here - * because we don't explicitly look at indpred? At least in simple - * cases, the partial index will sort before competing non-partial - * indexes and so it makes the right choice, but perhaps we need to - * work harder. + * XXX is there any risk of throwing away a useful partial index here because + * we don't explicitly look at indpred? At least in simple cases, the + * partial index will sort before competing non-partial indexes and so it + * makes the right choice, but perhaps we need to work harder. * * Note: outputting the selected sub-paths in selectivity order is a good * thing even if we weren't using that as part of the selection method, @@ -559,13 +559,13 @@ choose_bitmap_and(PlannerInfo *root, RelOptInfo *rel, List *paths) qualsofar = list_copy(((IndexPath *) patharray[0])->indexclauses); else qualsofar = NIL; - lastcell = list_head(paths); /* for quick deletions */ + lastcell = list_head(paths); /* for quick deletions */ for (i = 1; i < npaths; i++) { - Path *newpath = patharray[i]; - List *newqual = NIL; - Cost newcost; + Path *newpath = patharray[i]; + List *newqual = NIL; + Cost newcost; if (IsA(newpath, IndexPath)) { @@ -599,12 +599,12 @@ choose_bitmap_and(PlannerInfo *root, RelOptInfo *rel, List *paths) static int bitmap_path_comparator(const void *a, const void *b) { - Path *pa = *(Path * const *) a; - Path *pb = *(Path * const *) b; + Path *pa = *(Path *const *) a; + Path *pb = *(Path *const *) b; Cost acost; Cost bcost; - Selectivity aselec; - Selectivity bselec; + Selectivity aselec; + Selectivity bselec; cost_bitmap_tree_node(pa, &acost, &aselec); cost_bitmap_tree_node(pb, &bcost, &bselec); @@ -660,7 +660,7 @@ bitmap_and_cost_est(PlannerInfo *root, RelOptInfo *rel, List *paths) * * We can use clauses from either the current clauses or outer_clauses lists, * but *found_clause is set TRUE only if we used at least one clause from - * the "current clauses" list. See find_usable_indexes() for motivation. + * the "current clauses" list. See find_usable_indexes() for motivation. * * outer_relids determines what Vars will be allowed on the other side * of a possible index qual; see match_clause_to_indexcol(). @@ -770,7 +770,7 @@ group_clauses_by_indexkey(IndexOptInfo *index, * to the caller-specified outer_relids relations (which had better not * include the relation whose index is being tested). outer_relids should * be NULL when checking simple restriction clauses, and the outer side - * of the join when building a join inner scan. Other than that, the + * of the join when building a join inner scan. Other than that, the * only thing we don't like is volatile functions. * * Note: in most cases we already know that the clause as a whole uses @@ -836,8 +836,8 @@ match_clause_to_indexcol(IndexOptInfo *index, return true; /* - * If we didn't find a member of the index's opclass, see whether - * it is a "special" indexable operator. + * If we didn't find a member of the index's opclass, see whether it + * is a "special" indexable operator. */ if (match_special_index_operator(clause, opclass, true)) return true; @@ -852,8 +852,8 @@ match_clause_to_indexcol(IndexOptInfo *index, return true; /* - * If we didn't find a member of the index's opclass, see whether - * it is a "special" indexable operator. + * If we didn't find a member of the index's opclass, see whether it + * is a "special" indexable operator. */ if (match_special_index_operator(clause, opclass, false)) return true; @@ -914,14 +914,14 @@ check_partial_indexes(PlannerInfo *root, RelOptInfo *rel) /* * Note: if Postgres tried to optimize queries by forming equivalence * classes over equi-joined attributes (i.e., if it recognized that a - * qualification such as "where a.b=c.d and a.b=5" could make use of - * an index on c.d), then we could use that equivalence class info - * here with joininfo lists to do more complete tests for the usability - * of a partial index. For now, the test only uses restriction - * clauses (those in baserestrictinfo). --Nels, Dec '92 + * qualification such as "where a.b=c.d and a.b=5" could make use of an + * index on c.d), then we could use that equivalence class info here with + * joininfo lists to do more complete tests for the usability of a partial + * index. For now, the test only uses restriction clauses (those in + * baserestrictinfo). --Nels, Dec '92 * - * XXX as of 7.1, equivalence class info *is* available. Consider - * improving this code as foreseen by Nels. + * XXX as of 7.1, equivalence class info *is* available. Consider improving + * this code as foreseen by Nels. */ foreach(ilist, rel->indexlist) @@ -943,7 +943,7 @@ check_partial_indexes(PlannerInfo *root, RelOptInfo *rel) /* * indexable_outerrelids * Finds all other relids that participate in any indexable join clause - * for the specified table. Returns a set of relids. + * for the specified table. Returns a set of relids. */ static Relids indexable_outerrelids(RelOptInfo *rel) @@ -958,7 +958,7 @@ indexable_outerrelids(RelOptInfo *rel) foreach(l, rel->joininfo) { RestrictInfo *joininfo = (RestrictInfo *) lfirst(l); - Relids other_rels; + Relids other_rels; other_rels = bms_difference(joininfo->required_relids, rel->relids); if (matches_any_index(joininfo, rel, other_rels)) @@ -986,7 +986,7 @@ matches_any_index(RestrictInfo *rinfo, RelOptInfo *rel, Relids outer_relids) { foreach(l, ((BoolExpr *) rinfo->orclause)->args) { - Node *orarg = (Node *) lfirst(l); + Node *orarg = (Node *) lfirst(l); /* OR arguments should be ANDs or sub-RestrictInfos */ if (and_clause(orarg)) @@ -1092,17 +1092,17 @@ best_inner_indexscan(PlannerInfo *root, RelOptInfo *rel, return NULL; /* - * Otherwise, we have to do path selection in the memory context of - * the given rel, so that any created path can be safely attached to - * the rel's cache of best inner paths. (This is not currently an - * issue for normal planning, but it is an issue for GEQO planning.) + * Otherwise, we have to do path selection in the memory context of the + * given rel, so that any created path can be safely attached to the rel's + * cache of best inner paths. (This is not currently an issue for normal + * planning, but it is an issue for GEQO planning.) */ oldcontext = MemoryContextSwitchTo(GetMemoryChunkContext(rel)); /* - * Intersect the given outer_relids with index_outer_relids to find - * the set of outer relids actually relevant for this rel. If there - * are none, again we can fail immediately. + * Intersect the given outer_relids with index_outer_relids to find the + * set of outer relids actually relevant for this rel. If there are none, + * again we can fail immediately. */ outer_relids = bms_intersect(rel->index_outer_relids, outer_relids); if (bms_is_empty(outer_relids)) @@ -1113,11 +1113,10 @@ best_inner_indexscan(PlannerInfo *root, RelOptInfo *rel, } /* - * Look to see if we already computed the result for this set of - * relevant outerrels. (We include the isouterjoin status in the - * cache lookup key for safety. In practice I suspect this is not - * necessary because it should always be the same for a given - * innerrel.) + * Look to see if we already computed the result for this set of relevant + * outerrels. (We include the isouterjoin status in the cache lookup key + * for safety. In practice I suspect this is not necessary because it + * should always be the same for a given innerrel.) */ foreach(l, rel->index_inner_paths) { @@ -1160,8 +1159,8 @@ best_inner_indexscan(PlannerInfo *root, RelOptInfo *rel, bitindexpaths = list_concat(bitindexpaths, list_copy(indexpaths)); /* - * If we found anything usable, generate a BitmapHeapPath for the - * most promising combination of bitmap index paths. + * If we found anything usable, generate a BitmapHeapPath for the most + * promising combination of bitmap index paths. */ if (bitindexpaths != NIL) { @@ -1218,12 +1217,11 @@ find_clauses_for_join(PlannerInfo *root, RelOptInfo *rel, ListCell *l; /* - * We can always use plain restriction clauses for the rel. We - * scan these first because we want them first in the clause - * list for the convenience of remove_redundant_join_clauses, - * which can never remove non-join clauses and hence won't be able - * to get rid of a non-join clause if it appears after a join - * clause it is redundant with. + * We can always use plain restriction clauses for the rel. We scan these + * first because we want them first in the clause list for the convenience + * of remove_redundant_join_clauses, which can never remove non-join + * clauses and hence won't be able to get rid of a non-join clause if it + * appears after a join clause it is redundant with. */ foreach(l, rel->baserestrictinfo) { @@ -1305,7 +1303,7 @@ find_clauses_for_join(PlannerInfo *root, RelOptInfo *rel, * * If able to match the requested query pathkeys, returns either * ForwardScanDirection or BackwardScanDirection to indicate the proper index - * scan direction. If no match, returns NoMovementScanDirection. + * scan direction. If no match, returns NoMovementScanDirection. */ static ScanDirection match_variant_ordering(PlannerInfo *root, @@ -1318,8 +1316,8 @@ match_variant_ordering(PlannerInfo *root, * Forget the whole thing if not a btree index; our check for ignorable * columns assumes we are dealing with btree opclasses. (It'd be possible * to factor out just the try for backwards indexscan, but considering - * that we presently have no orderable indexes except btrees anyway, - * it's hardly worth contorting this code for that case.) + * that we presently have no orderable indexes except btrees anyway, it's + * hardly worth contorting this code for that case.) * * Note: if you remove this, you probably need to put in a check on * amoptionalkey to prevent possible clauseless scan on an index that @@ -1327,17 +1325,19 @@ match_variant_ordering(PlannerInfo *root, */ if (index->relam != BTREE_AM_OID) return NoMovementScanDirection; + /* - * Figure out which index columns can be optionally ignored because - * they have an equality constraint. This is the same set for either - * forward or backward scan, so we do it just once. + * Figure out which index columns can be optionally ignored because they + * have an equality constraint. This is the same set for either forward + * or backward scan, so we do it just once. */ ignorables = identify_ignorable_ordering_cols(root, index, restrictclauses); + /* - * Try to match to forward scan, then backward scan. However, we can - * skip the forward-scan case if there are no ignorable columns, - * because find_usable_indexes() would have found the match already. + * Try to match to forward scan, then backward scan. However, we can skip + * the forward-scan case if there are no ignorable columns, because + * find_usable_indexes() would have found the match already. */ if (ignorables && match_index_to_query_keys(root, index, ForwardScanDirection, @@ -1365,24 +1365,24 @@ identify_ignorable_ordering_cols(PlannerInfo *root, List *restrictclauses) { List *result = NIL; - int indexcol = 0; /* note this is 0-based */ + int indexcol = 0; /* note this is 0-based */ ListCell *l; /* restrictclauses is either NIL or has a sublist per column */ foreach(l, restrictclauses) { - List *sublist = (List *) lfirst(l); - Oid opclass = index->classlist[indexcol]; - ListCell *l2; + List *sublist = (List *) lfirst(l); + Oid opclass = index->classlist[indexcol]; + ListCell *l2; foreach(l2, sublist) { RestrictInfo *rinfo = (RestrictInfo *) lfirst(l2); OpExpr *clause = (OpExpr *) rinfo->clause; - Oid clause_op; - int op_strategy; - bool varonleft; - bool ispc; + Oid clause_op; + int op_strategy; + bool varonleft; + bool ispc; /* We know this clause passed match_clause_to_indexcol */ @@ -1393,11 +1393,11 @@ identify_ignorable_ordering_cols(PlannerInfo *root, index)) { /* - * The clause means either col = TRUE or col = FALSE; - * we do not care which, it's an equality constraint - * either way. + * The clause means either col = TRUE or col = FALSE; we + * do not care which, it's an equality constraint either + * way. */ - result = lappend_int(result, indexcol+1); + result = lappend_int(result, indexcol + 1); break; } } @@ -1426,12 +1426,11 @@ identify_ignorable_ordering_cols(PlannerInfo *root, op_strategy = get_op_opclass_strategy(clause_op, opclass); /* - * You might expect to see Assert(op_strategy != 0) here, - * but you won't: the clause might contain a special indexable - * operator rather than an ordinary opclass member. Currently - * none of the special operators are very likely to expand to - * an equality operator; we do not bother to check, but just - * assume no match. + * You might expect to see Assert(op_strategy != 0) here, but you + * won't: the clause might contain a special indexable operator + * rather than an ordinary opclass member. Currently none of the + * special operators are very likely to expand to an equality + * operator; we do not bother to check, but just assume no match. */ if (op_strategy != BTEqualStrategyNumber) continue; @@ -1445,7 +1444,7 @@ identify_ignorable_ordering_cols(PlannerInfo *root, rinfo->left_relids); if (ispc) { - result = lappend_int(result, indexcol+1); + result = lappend_int(result, indexcol + 1); break; } } @@ -1480,8 +1479,8 @@ match_index_to_query_keys(PlannerInfo *root, index_pathkeys = build_index_pathkeys(root, index, indexscandir); /* - * Can we match to the query's requested pathkeys? The inner loop - * skips over ignorable index columns while trying to match. + * Can we match to the query's requested pathkeys? The inner loop skips + * over ignorable index columns while trying to match. */ index_cell = list_head(index_pathkeys); index_col = 0; @@ -1492,13 +1491,14 @@ match_index_to_query_keys(PlannerInfo *root, for (;;) { - List *isubkey; + List *isubkey; if (index_cell == NULL) return false; isubkey = (List *) lfirst(index_cell); index_cell = lnext(index_cell); index_col++; /* index_col is now 1-based */ + /* * Since we are dealing with canonicalized pathkeys, pointer * comparison is sufficient to determine a match. @@ -1561,9 +1561,9 @@ match_index_to_operand(Node *operand, int indkey; /* - * Ignore any RelabelType node above the operand. This is needed to - * be able to apply indexscanning in binary-compatible-operator cases. - * Note: we can assume there is at most one RelabelType node; + * Ignore any RelabelType node above the operand. This is needed to be + * able to apply indexscanning in binary-compatible-operator cases. Note: + * we can assume there is at most one RelabelType node; * eval_const_expressions() will have simplified if more than one. */ if (operand && IsA(operand, RelabelType)) @@ -1583,9 +1583,9 @@ match_index_to_operand(Node *operand, else { /* - * Index expression; find the correct expression. (This search - * could be avoided, at the cost of complicating all the callers - * of this routine; doesn't seem worth it.) + * Index expression; find the correct expression. (This search could + * be avoided, at the cost of complicating all the callers of this + * routine; doesn't seem worth it.) */ ListCell *indexpr_item; int i; @@ -1645,7 +1645,7 @@ match_index_to_operand(Node *operand, * * Another thing that we do with this machinery is to provide special * smarts for "boolean" indexes (that is, indexes on boolean columns - * that support boolean equality). We can transform a plain reference + * that support boolean equality). We can transform a plain reference * to the indexkey into "indexkey = true", or "NOT indexkey" into * "indexkey = false", so as to make the expression indexable using the * regular index operators. (As of Postgres 8.1, we must do this here @@ -1696,14 +1696,15 @@ match_boolean_index_clause(Node *clause, indexcol, index)) return true; } + /* * Since we only consider clauses at top level of WHERE, we can convert - * indexkey IS TRUE and indexkey IS FALSE to index searches as well. - * The different meaning for NULL isn't important. + * indexkey IS TRUE and indexkey IS FALSE to index searches as well. The + * different meaning for NULL isn't important. */ else if (clause && IsA(clause, BooleanTest)) { - BooleanTest *btest = (BooleanTest *) clause; + BooleanTest *btest = (BooleanTest *) clause; if (btest->booltesttype == IS_TRUE || btest->booltesttype == IS_FALSE) @@ -1737,8 +1738,8 @@ match_special_index_operator(Expr *clause, Oid opclass, /* * Currently, all known special operators require the indexkey on the - * left, but this test could be pushed into the switch statement if - * some are added that do not... + * left, but this test could be pushed into the switch statement if some + * are added that do not... */ if (!indexkey_on_left) return false; @@ -1760,12 +1761,12 @@ match_special_index_operator(Expr *clause, Oid opclass, case OID_NAME_LIKE_OP: /* the right-hand const is type text for all of these */ isIndexable = pattern_fixed_prefix(patt, Pattern_Type_Like, - &prefix, &rest) != Pattern_Prefix_None; + &prefix, &rest) != Pattern_Prefix_None; break; case OID_BYTEA_LIKE_OP: isIndexable = pattern_fixed_prefix(patt, Pattern_Type_Like, - &prefix, &rest) != Pattern_Prefix_None; + &prefix, &rest) != Pattern_Prefix_None; break; case OID_TEXT_ICLIKE_OP: @@ -1773,7 +1774,7 @@ match_special_index_operator(Expr *clause, Oid opclass, case OID_NAME_ICLIKE_OP: /* the right-hand const is type text for all of these */ isIndexable = pattern_fixed_prefix(patt, Pattern_Type_Like_IC, - &prefix, &rest) != Pattern_Prefix_None; + &prefix, &rest) != Pattern_Prefix_None; break; case OID_TEXT_REGEXEQ_OP: @@ -1781,7 +1782,7 @@ match_special_index_operator(Expr *clause, Oid opclass, case OID_NAME_REGEXEQ_OP: /* the right-hand const is type text for all of these */ isIndexable = pattern_fixed_prefix(patt, Pattern_Type_Regex, - &prefix, &rest) != Pattern_Prefix_None; + &prefix, &rest) != Pattern_Prefix_None; break; case OID_TEXT_ICREGEXEQ_OP: @@ -1789,7 +1790,7 @@ match_special_index_operator(Expr *clause, Oid opclass, case OID_NAME_ICREGEXEQ_OP: /* the right-hand const is type text for all of these */ isIndexable = pattern_fixed_prefix(patt, Pattern_Type_Regex_IC, - &prefix, &rest) != Pattern_Prefix_None; + &prefix, &rest) != Pattern_Prefix_None; break; case OID_INET_SUB_OP: @@ -1815,9 +1816,9 @@ match_special_index_operator(Expr *clause, Oid opclass, * want to apply. (A hash index, for example, will not support ">=".) * Currently, only btree supports the operators we need. * - * We insist on the opclass being the specific one we expect, else we'd - * do the wrong thing if someone were to make a reverse-sort opclass - * with the same operators. + * We insist on the opclass being the specific one we expect, else we'd do + * the wrong thing if someone were to make a reverse-sort opclass with the + * same operators. */ switch (expr_op) { @@ -1906,7 +1907,7 @@ expand_indexqual_conditions(IndexOptInfo *index, List *clausegroups) /* First check for boolean cases */ if (IsBooleanOpclass(curClass)) { - Expr *boolqual; + Expr *boolqual; boolqual = expand_boolean_index_clause((Node *) rinfo->clause, indexcol, @@ -1960,7 +1961,7 @@ expand_boolean_index_clause(Node *clause, /* NOT clause? */ if (not_clause(clause)) { - Node *arg = (Node *) get_notclausearg((Expr *) clause); + Node *arg = (Node *) get_notclausearg((Expr *) clause); /* It must have matched the indexkey */ Assert(match_index_to_operand(arg, indexcol, index)); @@ -1971,8 +1972,8 @@ expand_boolean_index_clause(Node *clause, } if (clause && IsA(clause, BooleanTest)) { - BooleanTest *btest = (BooleanTest *) clause; - Node *arg = (Node *) btest->arg; + BooleanTest *btest = (BooleanTest *) clause; + Node *arg = (Node *) btest->arg; /* It must have matched the indexkey */ Assert(match_index_to_operand(arg, indexcol, index)); @@ -2007,6 +2008,7 @@ static List * expand_indexqual_condition(RestrictInfo *rinfo, Oid opclass) { Expr *clause = rinfo->clause; + /* we know these will succeed */ Node *leftop = get_leftop(clause); Node *rightop = get_rightop(clause); @@ -2020,10 +2022,9 @@ expand_indexqual_condition(RestrictInfo *rinfo, Oid opclass) switch (expr_op) { /* - * LIKE and regex operators are not members of any index - * opclass, so if we find one in an indexqual list we can - * assume that it was accepted by - * match_special_index_operator(). + * LIKE and regex operators are not members of any index opclass, + * so if we find one in an indexqual list we can assume that it + * was accepted by match_special_index_operator(). */ case OID_TEXT_LIKE_OP: case OID_BPCHAR_LIKE_OP: @@ -2128,8 +2129,8 @@ prefix_quals(Node *leftop, Oid opclass, } /* - * If necessary, coerce the prefix constant to the right type. The - * given prefix constant is either text or bytea type. + * If necessary, coerce the prefix constant to the right type. The given + * prefix constant is either text or bytea type. */ if (prefix_const->consttype != datatype) { @@ -2139,11 +2140,11 @@ prefix_quals(Node *leftop, Oid opclass, { case TEXTOID: prefix = DatumGetCString(DirectFunctionCall1(textout, - prefix_const->constvalue)); + prefix_const->constvalue)); break; case BYTEAOID: prefix = DatumGetCString(DirectFunctionCall1(byteaout, - prefix_const->constvalue)); + prefix_const->constvalue)); break; default: elog(ERROR, "unexpected const type: %u", diff --git a/src/backend/optimizer/path/joinpath.c b/src/backend/optimizer/path/joinpath.c index b02f67ba1f..ab3f902f02 100644 --- a/src/backend/optimizer/path/joinpath.c +++ b/src/backend/optimizer/path/joinpath.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/path/joinpath.c,v 1.95 2005/06/05 22:32:55 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/path/joinpath.c,v 1.96 2005/10/15 02:49:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -65,9 +65,9 @@ add_paths_to_joinrel(PlannerInfo *root, /* * Find potential mergejoin clauses. We can skip this if we are not - * interested in doing a mergejoin. However, mergejoin is currently - * our only way of implementing full outer joins, so override - * mergejoin disable if it's a full join. + * interested in doing a mergejoin. However, mergejoin is currently our + * only way of implementing full outer joins, so override mergejoin + * disable if it's a full join. */ if (enable_mergejoin || jointype == JOIN_FULL) mergeclause_list = select_mergejoin_clauses(joinrel, @@ -95,23 +95,22 @@ add_paths_to_joinrel(PlannerInfo *root, /* * 3. Consider paths where the inner relation need not be explicitly - * sorted. This includes mergejoins only (nestloops were already - * built in match_unsorted_outer). + * sorted. This includes mergejoins only (nestloops were already built in + * match_unsorted_outer). * * Diked out as redundant 2/13/2000 -- tgl. There isn't any really - * significant difference between the inner and outer side of a - * mergejoin, so match_unsorted_inner creates no paths that aren't - * equivalent to those made by match_unsorted_outer when - * add_paths_to_joinrel() is invoked with the two rels given in the - * other order. + * significant difference between the inner and outer side of a mergejoin, + * so match_unsorted_inner creates no paths that aren't equivalent to + * those made by match_unsorted_outer when add_paths_to_joinrel() is + * invoked with the two rels given in the other order. */ match_unsorted_inner(root, joinrel, outerrel, innerrel, restrictlist, mergeclause_list, jointype); #endif /* - * 4. Consider paths where both outer and inner relations must be - * hashed before being joined. + * 4. Consider paths where both outer and inner relations must be hashed + * before being joined. */ if (enable_hashjoin) hash_inner_and_outer(root, joinrel, outerrel, innerrel, @@ -174,11 +173,11 @@ sort_inner_and_outer(PlannerInfo *root, /* * We only consider the cheapest-total-cost input paths, since we are * assuming here that a sort is required. We will consider - * cheapest-startup-cost input paths later, and only if they don't - * need a sort. + * cheapest-startup-cost input paths later, and only if they don't need a + * sort. * - * If unique-ification is requested, do it and then handle as a plain - * inner join. + * If unique-ification is requested, do it and then handle as a plain inner + * join. */ outer_path = outerrel->cheapest_total_path; inner_path = innerrel->cheapest_total_path; @@ -194,31 +193,29 @@ sort_inner_and_outer(PlannerInfo *root, } /* - * Each possible ordering of the available mergejoin clauses will - * generate a differently-sorted result path at essentially the same - * cost. We have no basis for choosing one over another at this level - * of joining, but some sort orders may be more useful than others for - * higher-level mergejoins, so it's worth considering multiple - * orderings. + * Each possible ordering of the available mergejoin clauses will generate + * a differently-sorted result path at essentially the same cost. We have + * no basis for choosing one over another at this level of joining, but + * some sort orders may be more useful than others for higher-level + * mergejoins, so it's worth considering multiple orderings. * * Actually, it's not quite true that every mergeclause ordering will * generate a different path order, because some of the clauses may be - * redundant. Therefore, what we do is convert the mergeclause list - * to a list of canonical pathkeys, and then consider different - * orderings of the pathkeys. + * redundant. Therefore, what we do is convert the mergeclause list to a + * list of canonical pathkeys, and then consider different orderings of + * the pathkeys. * * Generating a path for *every* permutation of the pathkeys doesn't seem * like a winning strategy; the cost in planning time is too high. For - * now, we generate one path for each pathkey, listing that pathkey - * first and the rest in random order. This should allow at least a - * one-clause mergejoin without re-sorting against any other possible - * mergejoin partner path. But if we've not guessed the right - * ordering of secondary keys, we may end up evaluating clauses as - * qpquals when they could have been done as mergeclauses. We need to - * figure out a better way. (Two possible approaches: look at all the - * relevant index relations to suggest plausible sort orders, or make - * just one output path and somehow mark it as having a sort-order - * that can be rearranged freely.) + * now, we generate one path for each pathkey, listing that pathkey first + * and the rest in random order. This should allow at least a one-clause + * mergejoin without re-sorting against any other possible mergejoin + * partner path. But if we've not guessed the right ordering of secondary + * keys, we may end up evaluating clauses as qpquals when they could have + * been done as mergeclauses. We need to figure out a better way. (Two + * possible approaches: look at all the relevant index relations to + * suggest plausible sort orders, or make just one output path and somehow + * mark it as having a sort-order that can be rearranged freely.) */ all_pathkeys = make_pathkeys_for_mergeclauses(root, mergeclause_list, @@ -243,26 +240,25 @@ sort_inner_and_outer(PlannerInfo *root, /* * Select mergeclause(s) that match this sort ordering. If we had - * redundant merge clauses then we will get a subset of the - * original clause list. There had better be some match, - * however... + * redundant merge clauses then we will get a subset of the original + * clause list. There had better be some match, however... */ cur_mergeclauses = find_mergeclauses_for_pathkeys(root, cur_pathkeys, - mergeclause_list); + mergeclause_list); Assert(cur_mergeclauses != NIL); /* Forget it if can't use all the clauses in right/full join */ if (useallclauses && - list_length(cur_mergeclauses) != list_length(mergeclause_list)) + list_length(cur_mergeclauses) != list_length(mergeclause_list)) continue; /* * Build sort pathkeys for both sides. * * Note: it's possible that the cheapest paths will already be sorted - * properly. create_mergejoin_path will detect that case and - * suppress an explicit sort step, so we needn't do so here. + * properly. create_mergejoin_path will detect that case and suppress + * an explicit sort step, so we needn't do so here. */ outerkeys = make_pathkeys_for_mergeclauses(root, cur_mergeclauses, @@ -343,10 +339,10 @@ match_unsorted_outer(PlannerInfo *root, /* * Nestloop only supports inner, left, and IN joins. Also, if we are - * doing a right or full join, we must use *all* the mergeclauses as - * join clauses, else we will not have a valid plan. (Although these - * two flags are currently inverses, keep them separate for clarity - * and possible future changes.) + * doing a right or full join, we must use *all* the mergeclauses as join + * clauses, else we will not have a valid plan. (Although these two flags + * are currently inverses, keep them separate for clarity and possible + * future changes.) */ switch (jointype) { @@ -385,10 +381,9 @@ match_unsorted_outer(PlannerInfo *root, else if (nestjoinOK) { /* - * If the cheapest inner path is a join or seqscan, we should - * consider materializing it. (This is a heuristic: we could - * consider it always, but for inner indexscans it's probably a - * waste of time.) + * If the cheapest inner path is a join or seqscan, we should consider + * materializing it. (This is a heuristic: we could consider it + * always, but for inner indexscans it's probably a waste of time.) */ if (!(IsA(inner_cheapest_total, IndexPath) || IsA(inner_cheapest_total, BitmapHeapPath) || @@ -397,8 +392,8 @@ match_unsorted_outer(PlannerInfo *root, create_material_path(innerrel, inner_cheapest_total); /* - * Get the best innerjoin indexpath (if any) for this outer rel. - * It's the same for all outer paths. + * Get the best innerjoin indexpath (if any) for this outer rel. It's + * the same for all outer paths. */ bestinnerjoin = best_inner_indexscan(root, innerrel, outerrel->relids, jointype); @@ -417,8 +412,8 @@ match_unsorted_outer(PlannerInfo *root, int sortkeycnt; /* - * If we need to unique-ify the outer path, it's pointless to - * consider any but the cheapest outer. + * If we need to unique-ify the outer path, it's pointless to consider + * any but the cheapest outer. */ if (save_jointype == JOIN_UNIQUE_OUTER) { @@ -429,9 +424,9 @@ match_unsorted_outer(PlannerInfo *root, } /* - * The result will have this sort order (even if it is implemented - * as a nestloop, and even if some of the mergeclauses are - * implemented by qpquals rather than as true mergeclauses): + * The result will have this sort order (even if it is implemented as + * a nestloop, and even if some of the mergeclauses are implemented by + * qpquals rather than as true mergeclauses): */ merge_pathkeys = build_join_pathkeys(root, joinrel, jointype, outerpath->pathkeys); @@ -516,9 +511,9 @@ match_unsorted_outer(PlannerInfo *root, innerrel); /* - * Generate a mergejoin on the basis of sorting the cheapest - * inner. Since a sort will be needed, only cheapest total cost - * matters. (But create_mergejoin_path will do the right thing if + * Generate a mergejoin on the basis of sorting the cheapest inner. + * Since a sort will be needed, only cheapest total cost matters. + * (But create_mergejoin_path will do the right thing if * inner_cheapest_total is already correctly sorted.) */ add_path(joinrel, (Path *) @@ -538,10 +533,10 @@ match_unsorted_outer(PlannerInfo *root, continue; /* - * Look for presorted inner paths that satisfy the innersortkey - * list --- or any truncation thereof, if we are allowed to build - * a mergejoin using a subset of the merge clauses. Here, we - * consider both cheap startup cost and cheap total cost. Ignore + * Look for presorted inner paths that satisfy the innersortkey list + * --- or any truncation thereof, if we are allowed to build a + * mergejoin using a subset of the merge clauses. Here, we consider + * both cheap startup cost and cheap total cost. Ignore * inner_cheapest_total, since we already made a path with it. */ num_sortkeys = list_length(innersortkeys); @@ -559,8 +554,8 @@ match_unsorted_outer(PlannerInfo *root, /* * Look for an inner path ordered well enough for the first - * 'sortkeycnt' innersortkeys. NB: trialsortkeys list is - * modified destructively, which is why we made a copy... + * 'sortkeycnt' innersortkeys. NB: trialsortkeys list is modified + * destructively, which is why we made a copy... */ trialsortkeys = list_truncate(trialsortkeys, sortkeycnt); innerpath = get_cheapest_path_for_pathkeys(innerrel->pathlist, @@ -611,8 +606,8 @@ match_unsorted_outer(PlannerInfo *root, if (innerpath != cheapest_total_inner) { /* - * Avoid rebuilding clause list if we already made - * one; saves memory in big join trees... + * Avoid rebuilding clause list if we already made one; + * saves memory in big join trees... */ if (newclauses == NIL) { @@ -620,8 +615,8 @@ match_unsorted_outer(PlannerInfo *root, { newclauses = find_mergeclauses_for_pathkeys(root, - trialsortkeys, - mergeclauses); + trialsortkeys, + mergeclauses); Assert(newclauses != NIL); } else @@ -697,8 +692,8 @@ hash_inner_and_outer(PlannerInfo *root, * We need to build only one hashpath for any given pair of outer and * inner relations; all of the hashable clauses will be used as keys. * - * Scan the join's restrictinfo list to find hashjoinable clauses that - * are usable with this pair of sub-relations. + * Scan the join's restrictinfo list to find hashjoinable clauses that are + * usable with this pair of sub-relations. */ hashclauses = NIL; foreach(l, restrictlist) @@ -725,7 +720,7 @@ hash_inner_and_outer(PlannerInfo *root, /* righthand side is inner */ } else if (bms_is_subset(restrictinfo->left_relids, innerrel->relids) && - bms_is_subset(restrictinfo->right_relids, outerrel->relids)) + bms_is_subset(restrictinfo->right_relids, outerrel->relids)) { /* lefthand side is inner */ } @@ -739,9 +734,9 @@ hash_inner_and_outer(PlannerInfo *root, if (hashclauses) { /* - * We consider both the cheapest-total-cost and - * cheapest-startup-cost outer paths. There's no need to consider - * any but the cheapest-total-cost inner path, however. + * We consider both the cheapest-total-cost and cheapest-startup-cost + * outer paths. There's no need to consider any but the + * cheapest-total-cost inner path, however. */ Path *cheapest_startup_outer = outerrel->cheapest_startup_path; Path *cheapest_total_outer = outerrel->cheapest_total_path; @@ -807,15 +802,15 @@ select_mergejoin_clauses(RelOptInfo *joinrel, RestrictInfo *restrictinfo = (RestrictInfo *) lfirst(l); /* - * If processing an outer join, only use its own join clauses in - * the merge. For inner joins we need not be so picky. + * If processing an outer join, only use its own join clauses in the + * merge. For inner joins we need not be so picky. * - * Furthermore, if it is a right/full join then *all* the explicit - * join clauses must be mergejoinable, else the executor will - * fail. If we are asked for a right join then just return NIL to - * indicate no mergejoin is possible (we can handle it as a left - * join instead). If we are asked for a full join then emit an - * error, because there is no fallback. + * Furthermore, if it is a right/full join then *all* the explicit join + * clauses must be mergejoinable, else the executor will fail. If we + * are asked for a right join then just return NIL to indicate no + * mergejoin is possible (we can handle it as a left join instead). If + * we are asked for a full join then emit an error, because there is + * no fallback. */ if (isouterjoin) { @@ -847,8 +842,8 @@ select_mergejoin_clauses(RelOptInfo *joinrel, /* * Check if clause is usable with these input rels. All the vars - * needed on each side of the clause must be available from one or - * the other of the input rels. + * needed on each side of the clause must be available from one or the + * other of the input rels. */ if (bms_is_subset(restrictinfo->left_relids, outerrel->relids) && bms_is_subset(restrictinfo->right_relids, innerrel->relids)) @@ -856,7 +851,7 @@ select_mergejoin_clauses(RelOptInfo *joinrel, /* righthand side is inner */ } else if (bms_is_subset(restrictinfo->left_relids, innerrel->relids) && - bms_is_subset(restrictinfo->right_relids, outerrel->relids)) + bms_is_subset(restrictinfo->right_relids, outerrel->relids)) { /* lefthand side is inner */ } diff --git a/src/backend/optimizer/path/joinrels.c b/src/backend/optimizer/path/joinrels.c index f4f2d779b0..ecb6315686 100644 --- a/src/backend/optimizer/path/joinrels.c +++ b/src/backend/optimizer/path/joinrels.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/path/joinrels.c,v 1.75 2005/07/28 22:27:00 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/path/joinrels.c,v 1.76 2005/10/15 02:49:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -49,17 +49,16 @@ make_rels_by_joins(PlannerInfo *root, int level, List **joinrels) /* * First, consider left-sided and right-sided plans, in which rels of - * exactly level-1 member relations are joined against initial - * relations. We prefer to join using join clauses, but if we find a - * rel of level-1 members that has no join clauses, we will generate - * Cartesian-product joins against all initial rels not already - * contained in it. + * exactly level-1 member relations are joined against initial relations. + * We prefer to join using join clauses, but if we find a rel of level-1 + * members that has no join clauses, we will generate Cartesian-product + * joins against all initial rels not already contained in it. * - * In the first pass (level == 2), we try to join each initial rel to - * each initial rel that appears later in joinrels[1]. (The - * mirror-image joins are handled automatically by make_join_rel.) In - * later passes, we try to join rels of size level-1 from - * joinrels[level-1] to each initial rel in joinrels[1]. + * In the first pass (level == 2), we try to join each initial rel to each + * initial rel that appears later in joinrels[1]. (The mirror-image joins + * are handled automatically by make_join_rel.) In later passes, we try + * to join rels of size level-1 from joinrels[level-1] to each initial rel + * in joinrels[1]. */ foreach(r, joinrels[level - 1]) { @@ -76,23 +75,22 @@ make_rels_by_joins(PlannerInfo *root, int level, List **joinrels) if (old_rel->joininfo != NIL) { /* - * Note that if all available join clauses for this rel - * require more than one other rel, we will fail to make any - * joins against it here. In most cases that's OK; it'll be - * considered by "bushy plan" join code in a higher-level pass - * where we have those other rels collected into a join rel. + * Note that if all available join clauses for this rel require + * more than one other rel, we will fail to make any joins against + * it here. In most cases that's OK; it'll be considered by + * "bushy plan" join code in a higher-level pass where we have + * those other rels collected into a join rel. */ new_rels = make_rels_by_clause_joins(root, old_rel, other_rels); /* - * An exception occurs when there is a clauseless join inside - * an IN (sub-SELECT) construct. Here, the members of the - * subselect all have join clauses (against the stuff outside - * the IN), but they *must* be joined to each other before we - * can make use of those join clauses. So do the clauseless - * join bit. + * An exception occurs when there is a clauseless join inside an + * IN (sub-SELECT) construct. Here, the members of the subselect + * all have join clauses (against the stuff outside the IN), but + * they *must* be joined to each other before we can make use of + * those join clauses. So do the clauseless join bit. * * See also the last-ditch case below. */ @@ -115,30 +113,29 @@ make_rels_by_joins(PlannerInfo *root, int level, List **joinrels) /* * At levels above 2 we will generate the same joined relation in * multiple ways --- for example (a join b) join c is the same - * RelOptInfo as (b join c) join a, though the second case will - * add a different set of Paths to it. To avoid making extra work - * for subsequent passes, do not enter the same RelOptInfo into - * our output list multiple times. + * RelOptInfo as (b join c) join a, though the second case will add a + * different set of Paths to it. To avoid making extra work for + * subsequent passes, do not enter the same RelOptInfo into our output + * list multiple times. */ result_rels = list_concat_unique_ptr(result_rels, new_rels); } /* - * Now, consider "bushy plans" in which relations of k initial rels - * are joined to relations of level-k initial rels, for 2 <= k <= - * level-2. + * Now, consider "bushy plans" in which relations of k initial rels are + * joined to relations of level-k initial rels, for 2 <= k <= level-2. * * We only consider bushy-plan joins for pairs of rels where there is a - * suitable join clause, in order to avoid unreasonable growth of - * planning time. + * suitable join clause, in order to avoid unreasonable growth of planning + * time. */ for (k = 2;; k++) { int other_level = level - k; /* - * Since make_join_rel(x, y) handles both x,y and y,x cases, we - * only need to go as far as the halfway point. + * Since make_join_rel(x, y) handles both x,y and y,x cases, we only + * need to go as far as the halfway point. */ if (k > other_level) break; @@ -165,8 +162,8 @@ make_rels_by_joins(PlannerInfo *root, int level, List **joinrels) { /* * OK, we can build a rel of the right level from this - * pair of rels. Do so if there is at least one - * usable join clause. + * pair of rels. Do so if there is at least one usable + * join clause. */ if (have_relevant_joinclause(old_rel, new_rel)) { @@ -185,16 +182,16 @@ make_rels_by_joins(PlannerInfo *root, int level, List **joinrels) } /* - * Last-ditch effort: if we failed to find any usable joins so far, - * force a set of cartesian-product joins to be generated. This - * handles the special case where all the available rels have join - * clauses but we cannot use any of the joins yet. An example is + * Last-ditch effort: if we failed to find any usable joins so far, force + * a set of cartesian-product joins to be generated. This handles the + * special case where all the available rels have join clauses but we + * cannot use any of the joins yet. An example is * * SELECT * FROM a,b,c WHERE (a.f1 + b.f2 + c.f3) = 0; * * The join clause will be usable at level 3, but at level 2 we have no - * choice but to make cartesian joins. We consider only left-sided - * and right-sided cartesian joins in this case (no bushy). + * choice but to make cartesian joins. We consider only left-sided and + * right-sided cartesian joins in this case (no bushy). */ if (result_rels == NIL) { @@ -318,8 +315,8 @@ make_rels_by_clauseless_joins(PlannerInfo *root, jrel = make_join_rel(root, old_rel, other_rel, JOIN_INNER); /* - * As long as given other_rels are distinct, don't need to - * test to see if jrel is already part of output list. + * As long as given other_rels are distinct, don't need to test to + * see if jrel is already part of output list. */ if (jrel) result = lcons(jrel, result); @@ -393,10 +390,10 @@ make_jointree_rel(PlannerInfo *root, Node *jtnode) elog(ERROR, "invalid join order"); /* - * Since we are only going to consider this one way to do it, - * we're done generating Paths for this joinrel and can now select - * the cheapest. In fact we *must* do so now, since next level up - * will need it! + * Since we are only going to consider this one way to do it, we're + * done generating Paths for this joinrel and can now select the + * cheapest. In fact we *must* do so now, since next level up will + * need it! */ set_cheapest(rel); @@ -439,10 +436,10 @@ make_join_rel(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2, joinrelids = bms_union(rel1->relids, rel2->relids); /* - * If we are implementing IN clauses as joins, there are some joins - * that are illegal. Check to see if the proposed join is trouble. We - * can skip the work if looking at an outer join, however, because - * only top-level joins might be affected. + * If we are implementing IN clauses as joins, there are some joins that + * are illegal. Check to see if the proposed join is trouble. We can skip + * the work if looking at an outer join, however, because only top-level + * joins might be affected. */ if (jointype == JOIN_INNER) { @@ -454,8 +451,8 @@ make_join_rel(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2, /* * This IN clause is not relevant unless its RHS overlaps the - * proposed join. (Check this first as a fast path for - * dismissing most irrelevant INs quickly.) + * proposed join. (Check this first as a fast path for dismissing + * most irrelevant INs quickly.) */ if (!bms_overlap(ininfo->righthand, joinrelids)) continue; @@ -468,10 +465,10 @@ make_join_rel(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2, continue; /* - * Cannot join if proposed join contains rels not in the RHS - * *and* contains only part of the RHS. We must build the - * complete RHS (subselect's join) before it can be joined to - * rels outside the subselect. + * Cannot join if proposed join contains rels not in the RHS *and* + * contains only part of the RHS. We must build the complete RHS + * (subselect's join) before it can be joined to rels outside the + * subselect. */ if (!bms_is_subset(ininfo->righthand, joinrelids)) { @@ -480,13 +477,12 @@ make_join_rel(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2, } /* - * At this point we are considering a join of the IN's RHS to - * some other rel(s). + * At this point we are considering a join of the IN's RHS to some + * other rel(s). * - * If we already joined IN's RHS to any other rels in either - * input path, then this join is not constrained (the - * necessary work was done at the lower level where that join - * occurred). + * If we already joined IN's RHS to any other rels in either input + * path, then this join is not constrained (the necessary work was + * done at the lower level where that join occurred). */ if (bms_is_subset(ininfo->righthand, rel1->relids) && !bms_equal(ininfo->righthand, rel1->relids)) @@ -500,12 +496,11 @@ make_join_rel(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2, * innerrel is exactly RHS; conversely JOIN_REVERSE_IN handles * RHS/LHS. * - * JOIN_UNIQUE_OUTER will work if outerrel is exactly RHS; - * conversely JOIN_UNIQUE_INNER will work if innerrel is - * exactly RHS. + * JOIN_UNIQUE_OUTER will work if outerrel is exactly RHS; conversely + * JOIN_UNIQUE_INNER will work if innerrel is exactly RHS. * - * But none of these will work if we already found another IN - * that needs to trigger here. + * But none of these will work if we already found another IN that + * needs to trigger here. */ if (jointype != JOIN_INNER) { @@ -532,8 +527,8 @@ make_join_rel(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2, } /* - * Find or build the join RelOptInfo, and compute the restrictlist - * that goes with this particular joining. + * Find or build the join RelOptInfo, and compute the restrictlist that + * goes with this particular joining. */ joinrel = build_join_rel(root, joinrelids, rel1, rel2, jointype, &restrictlist); diff --git a/src/backend/optimizer/path/orindxpath.c b/src/backend/optimizer/path/orindxpath.c index eb1e1a6ffc..be5a0c3434 100644 --- a/src/backend/optimizer/path/orindxpath.c +++ b/src/backend/optimizer/path/orindxpath.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/path/orindxpath.c,v 1.74 2005/07/28 20:26:20 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/path/orindxpath.c,v 1.75 2005/10/15 02:49:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -99,14 +99,14 @@ create_or_index_quals(PlannerInfo *root, RelOptInfo *rel) if (restriction_is_or_clause(rinfo)) { /* - * Use the generate_bitmap_or_paths() machinery to estimate - * the value of each OR clause. We can use regular - * restriction clauses along with the OR clause contents to - * generate indexquals. We pass outer_relids = NULL so that - * sub-clauses that are actually joins will be ignored. + * Use the generate_bitmap_or_paths() machinery to estimate the + * value of each OR clause. We can use regular restriction + * clauses along with the OR clause contents to generate + * indexquals. We pass outer_relids = NULL so that sub-clauses + * that are actually joins will be ignored. */ - List *orpaths; - ListCell *k; + List *orpaths; + ListCell *k; orpaths = generate_bitmap_or_paths(root, rel, list_make1(rinfo), @@ -116,7 +116,7 @@ create_or_index_quals(PlannerInfo *root, RelOptInfo *rel) /* Locate the cheapest OR path */ foreach(k, orpaths) { - BitmapOrPath *path = (BitmapOrPath *) lfirst(k); + BitmapOrPath *path = (BitmapOrPath *) lfirst(k); Assert(IsA(path, BitmapOrPath)); if (bestpath == NULL || @@ -134,8 +134,8 @@ create_or_index_quals(PlannerInfo *root, RelOptInfo *rel) return false; /* - * Convert the path's indexclauses structure to a RestrictInfo tree. - * We include any partial-index predicates so as to get a reasonable + * Convert the path's indexclauses structure to a RestrictInfo tree. We + * include any partial-index predicates so as to get a reasonable * representation of what the path is actually scanning. */ newrinfos = make_restrictinfo_from_bitmapqual((Path *) bestpath, @@ -155,12 +155,12 @@ create_or_index_quals(PlannerInfo *root, RelOptInfo *rel) rel->baserestrictinfo = list_concat(rel->baserestrictinfo, newrinfos); /* - * Adjust the original OR clause's cached selectivity to compensate - * for the selectivity of the added (but redundant) lower-level qual. - * This should result in the join rel getting approximately the same - * rows estimate as it would have gotten without all these - * shenanigans. (XXX major hack alert ... this depends on the - * assumption that the selectivity will stay cached ...) + * Adjust the original OR clause's cached selectivity to compensate for + * the selectivity of the added (but redundant) lower-level qual. This + * should result in the join rel getting approximately the same rows + * estimate as it would have gotten without all these shenanigans. (XXX + * major hack alert ... this depends on the assumption that the + * selectivity will stay cached ...) */ or_selec = clause_selectivity(root, (Node *) or_rinfo, 0, JOIN_INNER); diff --git a/src/backend/optimizer/path/pathkeys.c b/src/backend/optimizer/path/pathkeys.c index 09ad68ecd9..a262692982 100644 --- a/src/backend/optimizer/path/pathkeys.c +++ b/src/backend/optimizer/path/pathkeys.c @@ -11,7 +11,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/path/pathkeys.c,v 1.72 2005/08/27 22:13:43 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/path/pathkeys.c,v 1.73 2005/10/15 02:49:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -33,17 +33,17 @@ static PathKeyItem *makePathKeyItem(Node *key, Oid sortop, bool checkType); static void generate_outer_join_implications(PlannerInfo *root, - List *equi_key_set, - Relids *relids); + List *equi_key_set, + Relids *relids); static void sub_generate_join_implications(PlannerInfo *root, - List *equi_key_set, Relids *relids, - Node *item1, Oid sortop1, - Relids item1_relids); + List *equi_key_set, Relids *relids, + Node *item1, Oid sortop1, + Relids item1_relids); static void process_implied_const_eq(PlannerInfo *root, - List *equi_key_set, Relids *relids, - Node *item1, Oid sortop1, - Relids item1_relids, - bool delete_it); + List *equi_key_set, Relids *relids, + Node *item1, Oid sortop1, + Relids item1_relids, + bool delete_it); static List *make_canonical_pathkey(PlannerInfo *root, PathKeyItem *item); static Var *find_indexkey_var(PlannerInfo *root, RelOptInfo *rel, AttrNumber varattno); @@ -59,12 +59,11 @@ makePathKeyItem(Node *key, Oid sortop, bool checkType) PathKeyItem *item = makeNode(PathKeyItem); /* - * Some callers pass expressions that are not necessarily of the same - * type as the sort operator expects as input (for example when - * dealing with an index that uses binary-compatible operators). We - * must relabel these with the correct type so that the key - * expressions will be seen as equal() to expressions that have been - * correctly labeled. + * Some callers pass expressions that are not necessarily of the same type + * as the sort operator expects as input (for example when dealing with an + * index that uses binary-compatible operators). We must relabel these + * with the correct type so that the key expressions will be seen as + * equal() to expressions that have been correctly labeled. */ if (checkType) { @@ -116,20 +115,19 @@ add_equijoined_keys(PlannerInfo *root, RestrictInfo *restrictinfo) return; /* - * Our plan is to make a two-element set, then sweep through the - * existing equijoin sets looking for matches to item1 or item2. When - * we find one, we remove that set from equi_key_list and union it - * into our new set. When done, we add the new set to the front of - * equi_key_list. + * Our plan is to make a two-element set, then sweep through the existing + * equijoin sets looking for matches to item1 or item2. When we find one, + * we remove that set from equi_key_list and union it into our new set. + * When done, we add the new set to the front of equi_key_list. * * It may well be that the two items we're given are already known to be * equijoin-equivalent, in which case we don't need to change our data * structure. If we find both of them in the same equivalence set to * start with, we can quit immediately. * - * This is a standard UNION-FIND problem, for which there exist better - * data structures than simple lists. If this code ever proves to be - * a bottleneck then it could be sped up --- but for now, simple is + * This is a standard UNION-FIND problem, for which there exist better data + * structures than simple lists. If this code ever proves to be a + * bottleneck then it could be sped up --- but for now, simple is * beautiful. */ newset = NIL; @@ -148,8 +146,7 @@ add_equijoined_keys(PlannerInfo *root, RestrictInfo *restrictinfo) if (item1here || item2here) { /* - * If find both in same equivalence set, no need to do any - * more + * If find both in same equivalence set, no need to do any more */ if (item1here && item2here) { @@ -228,18 +225,18 @@ generate_implied_equalities(PlannerInfo *root) int i1; /* - * A set containing only two items cannot imply any equalities - * beyond the one that created the set, so we can skip it --- - * unless outer joins appear in the query. + * A set containing only two items cannot imply any equalities beyond + * the one that created the set, so we can skip it --- unless outer + * joins appear in the query. */ if (nitems < 3 && !root->hasOuterJoins) continue; /* - * Collect info about relids mentioned in each item. For this - * routine we only really care whether there are any at all in - * each item, but process_implied_equality() needs the exact sets, - * so we may as well pull them here. + * Collect info about relids mentioned in each item. For this routine + * we only really care whether there are any at all in each item, but + * process_implied_equality() needs the exact sets, so we may as well + * pull them here. */ relids = (Relids *) palloc(nitems * sizeof(Relids)); have_consts = false; @@ -258,9 +255,9 @@ generate_implied_equalities(PlannerInfo *root) * Match each item in the set with all that appear after it (it's * sufficient to generate A=B, need not process B=A too). * - * A set containing only two items cannot imply any equalities - * beyond the one that created the set, so we can skip this - * processing in that case. + * A set containing only two items cannot imply any equalities beyond the + * one that created the set, so we can skip this processing in that + * case. */ if (nitems >= 3) { @@ -346,7 +343,7 @@ generate_implied_equalities(PlannerInfo *root) * the time it gets here, the restriction will look like * COALESCE(LEFTVAR, RIGHTVAR) = CONSTANT * and we will have a join clause LEFTVAR = RIGHTVAR that we can match the - * COALESCE expression to. In this situation we can push LEFTVAR = CONSTANT + * COALESCE expression to. In this situation we can push LEFTVAR = CONSTANT * and RIGHTVAR = CONSTANT into the input relations, since any rows not * meeting these conditions cannot contribute to the join result. * @@ -397,8 +394,8 @@ generate_outer_join_implications(PlannerInfo *root, */ static void sub_generate_join_implications(PlannerInfo *root, - List *equi_key_set, Relids *relids, - Node *item1, Oid sortop1, Relids item1_relids) + List *equi_key_set, Relids *relids, + Node *item1, Oid sortop1, Relids item1_relids) { ListCell *l; @@ -410,34 +407,36 @@ sub_generate_join_implications(PlannerInfo *root, foreach(l, root->left_join_clauses) { RestrictInfo *rinfo = (RestrictInfo *) lfirst(l); - Node *leftop = get_leftop(rinfo->clause); + Node *leftop = get_leftop(rinfo->clause); if (equal(leftop, item1) && rinfo->left_sortop == sortop1) { /* - * Match, so find constant member(s) of set and generate - * implied INNERVAR = CONSTANT + * Match, so find constant member(s) of set and generate implied + * INNERVAR = CONSTANT */ - Node *rightop = get_rightop(rinfo->clause); + Node *rightop = get_rightop(rinfo->clause); process_implied_const_eq(root, equi_key_set, relids, rightop, rinfo->right_sortop, rinfo->right_relids, false); + /* * We can remove explicit tests of this outer-join qual, too, - * since we now have tests forcing each of its sides - * to the same value. + * since we now have tests forcing each of its sides to the same + * value. */ process_implied_equality(root, leftop, rightop, rinfo->left_sortop, rinfo->right_sortop, rinfo->left_relids, rinfo->right_relids, true); + /* - * And recurse to see if we can deduce anything from - * INNERVAR = CONSTANT + * And recurse to see if we can deduce anything from INNERVAR = + * CONSTANT */ sub_generate_join_implications(root, equi_key_set, relids, rightop, @@ -450,34 +449,36 @@ sub_generate_join_implications(PlannerInfo *root, foreach(l, root->right_join_clauses) { RestrictInfo *rinfo = (RestrictInfo *) lfirst(l); - Node *rightop = get_rightop(rinfo->clause); + Node *rightop = get_rightop(rinfo->clause); if (equal(rightop, item1) && rinfo->right_sortop == sortop1) { /* - * Match, so find constant member(s) of set and generate - * implied INNERVAR = CONSTANT + * Match, so find constant member(s) of set and generate implied + * INNERVAR = CONSTANT */ - Node *leftop = get_leftop(rinfo->clause); + Node *leftop = get_leftop(rinfo->clause); process_implied_const_eq(root, equi_key_set, relids, leftop, rinfo->left_sortop, rinfo->left_relids, false); + /* * We can remove explicit tests of this outer-join qual, too, - * since we now have tests forcing each of its sides - * to the same value. + * since we now have tests forcing each of its sides to the same + * value. */ process_implied_equality(root, leftop, rightop, rinfo->left_sortop, rinfo->right_sortop, rinfo->left_relids, rinfo->right_relids, true); + /* - * And recurse to see if we can deduce anything from - * INNERVAR = CONSTANT + * And recurse to see if we can deduce anything from INNERVAR = + * CONSTANT */ sub_generate_join_implications(root, equi_key_set, relids, leftop, @@ -492,8 +493,8 @@ sub_generate_join_implications(PlannerInfo *root, if (IsA(item1, CoalesceExpr)) { CoalesceExpr *cexpr = (CoalesceExpr *) item1; - Node *cfirst; - Node *csecond; + Node *cfirst; + Node *csecond; if (list_length(cexpr->args) != 2) return; @@ -501,26 +502,26 @@ sub_generate_join_implications(PlannerInfo *root, csecond = (Node *) lsecond(cexpr->args); /* - * Examine each mergejoinable full-join clause, looking for a - * clause of the form "x = y" matching the COALESCE(x,y) expression + * Examine each mergejoinable full-join clause, looking for a clause + * of the form "x = y" matching the COALESCE(x,y) expression */ foreach(l, root->full_join_clauses) { RestrictInfo *rinfo = (RestrictInfo *) lfirst(l); - Node *leftop = get_leftop(rinfo->clause); - Node *rightop = get_rightop(rinfo->clause); + Node *leftop = get_leftop(rinfo->clause); + Node *rightop = get_rightop(rinfo->clause); /* - * We can assume the COALESCE() inputs are in the same order - * as the join clause, since both were automatically generated - * in the cases we care about. + * We can assume the COALESCE() inputs are in the same order as + * the join clause, since both were automatically generated in the + * cases we care about. * - * XXX currently this may fail to match in cross-type cases - * because the COALESCE will contain typecast operations while - * the join clause may not (if there is a cross-type mergejoin - * operator available for the two column types). - * Is it OK to strip implicit coercions from the COALESCE - * arguments? What of the sortops in such cases? + * XXX currently this may fail to match in cross-type cases because + * the COALESCE will contain typecast operations while the join + * clause may not (if there is a cross-type mergejoin operator + * available for the two column types). Is it OK to strip implicit + * coercions from the COALESCE arguments? What of the sortops in + * such cases? */ if (equal(leftop, cfirst) && equal(rightop, csecond) && @@ -548,10 +549,11 @@ sub_generate_join_implications(PlannerInfo *root, sortop1, item1_relids, true); + /* * We can remove explicit tests of this outer-join qual, too, - * since we now have tests forcing each of its sides - * to the same value. + * since we now have tests forcing each of its sides to the + * same value. */ process_implied_equality(root, leftop, rightop, @@ -560,9 +562,10 @@ sub_generate_join_implications(PlannerInfo *root, rinfo->left_relids, rinfo->right_relids, true); + /* - * And recurse to see if we can deduce anything from - * LEFTVAR = CONSTANT + * And recurse to see if we can deduce anything from LEFTVAR = + * CONSTANT */ sub_generate_join_implications(root, equi_key_set, relids, leftop, @@ -700,19 +703,19 @@ canonicalize_pathkeys(PlannerInfo *root, List *pathkeys) List *cpathkey; /* - * It's sufficient to look at the first entry in the sublist; if - * there are more entries, they're already part of an equivalence - * set by definition. + * It's sufficient to look at the first entry in the sublist; if there + * are more entries, they're already part of an equivalence set by + * definition. */ Assert(pathkey != NIL); item = (PathKeyItem *) linitial(pathkey); cpathkey = make_canonical_pathkey(root, item); /* - * Eliminate redundant ordering requests --- ORDER BY A,A is the - * same as ORDER BY A. We want to check this only after we have - * canonicalized the keys, so that equivalent-key knowledge is - * used when deciding if an item is redundant. + * Eliminate redundant ordering requests --- ORDER BY A,A is the same + * as ORDER BY A. We want to check this only after we have + * canonicalized the keys, so that equivalent-key knowledge is used + * when deciding if an item is redundant. */ new_pathkeys = list_append_unique_ptr(new_pathkeys, cpathkey); } @@ -769,8 +772,8 @@ compare_pathkeys(List *keys1, List *keys2) List *subkey2 = (List *) lfirst(key2); /* - * XXX would like to check that we've been given canonicalized - * input, but PlannerInfo not accessible here... + * XXX would like to check that we've been given canonicalized input, + * but PlannerInfo not accessible here... */ #ifdef NOT_USED Assert(list_member_ptr(root->equi_key_list, subkey1)); @@ -778,10 +781,10 @@ compare_pathkeys(List *keys1, List *keys2) #endif /* - * We will never have two subkeys where one is a subset of the - * other, because of the canonicalization process. Either they - * are equal or they ain't. Furthermore, we only need pointer - * comparison to detect equality. + * We will never have two subkeys where one is a subset of the other, + * because of the canonicalization process. Either they are equal or + * they ain't. Furthermore, we only need pointer comparison to detect + * equality. */ if (subkey1 != subkey2) return PATHKEYS_DIFFERENT; /* no need to keep looking */ @@ -789,9 +792,9 @@ compare_pathkeys(List *keys1, List *keys2) /* * If we reached the end of only one list, the other is longer and - * therefore not a subset. (We assume the additional sublist(s) of - * the other list are not NIL --- no pathkey list should ever have a - * NIL sublist.) + * therefore not a subset. (We assume the additional sublist(s) of the + * other list are not NIL --- no pathkey list should ever have a NIL + * sublist.) */ if (key1 == NULL && key2 == NULL) return PATHKEYS_EQUAL; @@ -840,8 +843,8 @@ get_cheapest_path_for_pathkeys(List *paths, List *pathkeys, Path *path = (Path *) lfirst(l); /* - * Since cost comparison is a lot cheaper than pathkey comparison, - * do that first. (XXX is that still true?) + * Since cost comparison is a lot cheaper than pathkey comparison, do + * that first. (XXX is that still true?) */ if (matched_path != NULL && compare_path_costs(matched_path, path, cost_criterion) <= 0) @@ -879,11 +882,11 @@ get_cheapest_fractional_path_for_pathkeys(List *paths, Path *path = (Path *) lfirst(l); /* - * Since cost comparison is a lot cheaper than pathkey comparison, - * do that first. + * Since cost comparison is a lot cheaper than pathkey comparison, do + * that first. */ if (matched_path != NULL && - compare_fractional_path_costs(matched_path, path, fraction) <= 0) + compare_fractional_path_costs(matched_path, path, fraction) <= 0) continue; if (pathkeys_contained_in(pathkeys, path->pathkeys)) @@ -954,8 +957,8 @@ build_index_pathkeys(PlannerInfo *root, cpathkey = make_canonical_pathkey(root, item); /* - * Eliminate redundant ordering info; could happen if query is - * such that index keys are equijoined... + * Eliminate redundant ordering info; could happen if query is such + * that index keys are equijoined... */ retval = list_append_unique_ptr(retval, cpathkey); @@ -1003,7 +1006,7 @@ find_indexkey_var(PlannerInfo *root, RelOptInfo *rel, AttrNumber varattno) /* * convert_subquery_pathkeys * Build a pathkeys list that describes the ordering of a subquery's - * result, in the terms of the outer query. This is essentially a + * result, in the terms of the outer query. This is essentially a * task of conversion. * * 'rel': outer query's RelOptInfo for the subquery relation. @@ -1033,19 +1036,18 @@ convert_subquery_pathkeys(PlannerInfo *root, RelOptInfo *rel, /* * The sub_pathkey could contain multiple elements (representing - * knowledge that multiple items are effectively equal). Each - * element might match none, one, or more of the output columns - * that are visible to the outer query. This means we may have - * multiple possible representations of the sub_pathkey in the - * context of the outer query. Ideally we would generate them all - * and put them all into a pathkey list of the outer query, - * thereby propagating equality knowledge up to the outer query. - * Right now we cannot do so, because the outer query's canonical - * pathkey sets are already frozen when this is called. Instead - * we prefer the one that has the highest "score" (number of - * canonical pathkey peers, plus one if it matches the outer - * query_pathkeys). This is the most likely to be useful in the - * outer query. + * knowledge that multiple items are effectively equal). Each element + * might match none, one, or more of the output columns that are + * visible to the outer query. This means we may have multiple + * possible representations of the sub_pathkey in the context of the + * outer query. Ideally we would generate them all and put them all + * into a pathkey list of the outer query, thereby propagating + * equality knowledge up to the outer query. Right now we cannot do + * so, because the outer query's canonical pathkey sets are already + * frozen when this is called. Instead we prefer the one that has the + * highest "score" (number of canonical pathkey peers, plus one if it + * matches the outer query_pathkeys). This is the most likely to be + * useful in the outer query. */ foreach(j, sub_pathkey) { @@ -1144,13 +1146,13 @@ build_join_pathkeys(PlannerInfo *root, return NIL; /* - * This used to be quite a complex bit of code, but now that all - * pathkey sublists start out life canonicalized, we don't have to do - * a darn thing here! The inner-rel vars we used to need to add are - * *already* part of the outer pathkey! + * This used to be quite a complex bit of code, but now that all pathkey + * sublists start out life canonicalized, we don't have to do a darn thing + * here! The inner-rel vars we used to need to add are *already* part of + * the outer pathkey! * - * We do, however, need to truncate the pathkeys list, since it may - * contain pathkeys that were useful for forming this joinrel but are + * We do, however, need to truncate the pathkeys list, since it may contain + * pathkeys that were useful for forming this joinrel but are * uninteresting to higher levels. */ return truncate_useless_pathkeys(root, joinrel, outer_pathkeys); @@ -1289,22 +1291,20 @@ find_mergeclauses_for_pathkeys(PlannerInfo *root, /* * We can match a pathkey against either left or right side of any - * mergejoin clause. (We examine both sides since we aren't told - * if the given pathkeys are for inner or outer input path; no - * confusion is possible.) Furthermore, if there are multiple - * matching clauses, take them all. In plain inner-join scenarios - * we expect only one match, because redundant-mergeclause - * elimination will have removed any redundant mergeclauses from - * the input list. However, in outer-join scenarios there might be - * multiple matches. An example is + * mergejoin clause. (We examine both sides since we aren't told if + * the given pathkeys are for inner or outer input path; no confusion + * is possible.) Furthermore, if there are multiple matching clauses, + * take them all. In plain inner-join scenarios we expect only one + * match, because redundant-mergeclause elimination will have removed + * any redundant mergeclauses from the input list. However, in + * outer-join scenarios there might be multiple matches. An example is * - * select * from a full join b on a.v1 = b.v1 and a.v2 = b.v2 and - * a.v1 = b.v2; + * select * from a full join b on a.v1 = b.v1 and a.v2 = b.v2 and a.v1 = + * b.v2; * * Given the pathkeys ((a.v1), (a.v2)) it is okay to return all three - * clauses (in the order a.v1=b.v1, a.v1=b.v2, a.v2=b.v2) and - * indeed we *must* do so or we will be unable to form a valid - * plan. + * clauses (in the order a.v1=b.v1, a.v1=b.v2, a.v2=b.v2) and indeed + * we *must* do so or we will be unable to form a valid plan. */ foreach(j, restrictinfos) { @@ -1325,15 +1325,15 @@ find_mergeclauses_for_pathkeys(PlannerInfo *root, /* * If we didn't find a mergeclause, we're done --- any additional - * sort-key positions in the pathkeys are useless. (But we can - * still mergejoin if we found at least one mergeclause.) + * sort-key positions in the pathkeys are useless. (But we can still + * mergejoin if we found at least one mergeclause.) */ if (matched_restrictinfos == NIL) break; /* - * If we did find usable mergeclause(s) for this sort-key - * position, add them to result list. + * If we did find usable mergeclause(s) for this sort-key position, + * add them to result list. */ mergeclauses = list_concat(mergeclauses, matched_restrictinfos); } @@ -1390,14 +1390,13 @@ make_pathkeys_for_mergeclauses(PlannerInfo *root, } /* - * When we are given multiple merge clauses, it's possible that - * some clauses refer to the same vars as earlier clauses. There's - * no reason for us to specify sort keys like (A,B,A) when (A,B) - * will do --- and adding redundant sort keys makes add_path think - * that this sort order is different from ones that are really the - * same, so don't do it. Since we now have a canonicalized - * pathkey, a simple ptrMember test is sufficient to detect - * redundant keys. + * When we are given multiple merge clauses, it's possible that some + * clauses refer to the same vars as earlier clauses. There's no + * reason for us to specify sort keys like (A,B,A) when (A,B) will do + * --- and adding redundant sort keys makes add_path think that this + * sort order is different from ones that are really the same, so + * don't do it. Since we now have a canonicalized pathkey, a simple + * ptrMember test is sufficient to detect redundant keys. */ pathkeys = list_append_unique_ptr(pathkeys, pathkey); } @@ -1447,8 +1446,8 @@ pathkeys_useful_for_merging(PlannerInfo *root, RelOptInfo *rel, List *pathkeys) cache_mergeclause_pathkeys(root, restrictinfo); /* - * We can compare canonical pathkey sublists by simple - * pointer equality; see compare_pathkeys. + * We can compare canonical pathkey sublists by simple pointer + * equality; see compare_pathkeys. */ if (pathkey == restrictinfo->left_pathkey || pathkey == restrictinfo->right_pathkey) @@ -1460,8 +1459,8 @@ pathkeys_useful_for_merging(PlannerInfo *root, RelOptInfo *rel, List *pathkeys) /* * If we didn't find a mergeclause, we're done --- any additional - * sort-key positions in the pathkeys are useless. (But we can - * still mergejoin if we found at least one mergeclause.) + * sort-key positions in the pathkeys are useless. (But we can still + * mergejoin if we found at least one mergeclause.) */ if (matched) useful++; diff --git a/src/backend/optimizer/path/tidpath.c b/src/backend/optimizer/path/tidpath.c index 348524372e..26058dc1b6 100644 --- a/src/backend/optimizer/path/tidpath.c +++ b/src/backend/optimizer/path/tidpath.c @@ -11,7 +11,7 @@ * WHERE ctid IN (tid1, tid2, ...) * * There is currently no special support for joins involving CTID; in - * particular nothing corresponding to best_inner_indexscan(). Since it's + * particular nothing corresponding to best_inner_indexscan(). Since it's * not very useful to store TIDs of one table in another table, there * doesn't seem to be enough use-case to justify adding a lot of code * for that. @@ -22,7 +22,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/path/tidpath.c,v 1.24 2005/08/23 20:49:47 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/path/tidpath.c,v 1.25 2005/10/15 02:49:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -50,7 +50,7 @@ static List *TidQualFromRestrictinfo(int varno, List *restrictinfo); * * If it is, return the pseudoconstant subnode; if not, return NULL. * - * We check that the CTID Var belongs to relation "varno". That is probably + * We check that the CTID Var belongs to relation "varno". That is probably * redundant considering this is only applied to restriction clauses, but * let's be safe. */ diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c index b7af04e1b9..f0dd654871 100644 --- a/src/backend/optimizer/plan/createplan.c +++ b/src/backend/optimizer/plan/createplan.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/plan/createplan.c,v 1.200 2005/10/13 00:06:46 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/plan/createplan.c,v 1.201 2005/10/15 02:49:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -50,10 +50,10 @@ static IndexScan *create_indexscan_plan(PlannerInfo *root, IndexPath *best_path, List *tlist, List *scan_clauses, List **nonlossy_clauses); static BitmapHeapScan *create_bitmap_scan_plan(PlannerInfo *root, - BitmapHeapPath *best_path, - List *tlist, List *scan_clauses); + BitmapHeapPath *best_path, + List *tlist, List *scan_clauses); static Plan *create_bitmap_subplan(PlannerInfo *root, Path *bitmapqual, - List **qual, List **indexqual); + List **qual, List **indexqual); static TidScan *create_tidscan_plan(PlannerInfo *root, TidPath *best_path, List *tlist, List *scan_clauses); static SubqueryScan *create_subqueryscan_plan(PlannerInfo *root, Path *best_path, @@ -72,7 +72,7 @@ static void fix_indexqual_references(List *indexquals, IndexPath *index_path, List **indexstrategy, List **indexsubtype); static Node *fix_indexqual_operand(Node *node, IndexOptInfo *index, - Oid *opclass); + Oid *opclass); static List *get_switched_clauses(List *clauses, Relids outerrelids); static void copy_path_costsize(Plan *dest, Path *src); static void copy_plan_costsize(Plan *dest, Plan *src); @@ -82,15 +82,15 @@ static IndexScan *make_indexscan(List *qptlist, List *qpqual, Index scanrelid, List *indexstrategy, List *indexsubtype, ScanDirection indexscandir); static BitmapIndexScan *make_bitmap_indexscan(Index scanrelid, Oid indexid, - List *indexqual, - List *indexqualorig, - List *indexstrategy, - List *indexsubtype); + List *indexqual, + List *indexqualorig, + List *indexstrategy, + List *indexsubtype); static BitmapHeapScan *make_bitmap_heapscan(List *qptlist, - List *qpqual, - Plan *lefttree, - List *bitmapqualorig, - Index scanrelid); + List *qpqual, + Plan *lefttree, + List *bitmapqualorig, + Index scanrelid); static TidScan *make_tidscan(List *qptlist, List *qpqual, Index scanrelid, List *tideval); static FunctionScan *make_functionscan(List *qptlist, List *qpqual, @@ -164,7 +164,7 @@ create_plan(PlannerInfo *root, Path *best_path) break; case T_Material: plan = (Plan *) create_material_plan(root, - (MaterialPath *) best_path); + (MaterialPath *) best_path); break; case T_Unique: plan = (Plan *) create_unique_plan(root, @@ -195,12 +195,12 @@ create_scan_plan(PlannerInfo *root, Path *best_path) Scan *plan; /* - * For table scans, rather than using the relation targetlist (which - * is only those Vars actually needed by the query), we prefer to - * generate a tlist containing all Vars in order. This will allow the - * executor to optimize away projection of the table tuples, if - * possible. (Note that planner.c may replace the tlist we generate - * here, forcing projection to occur.) + * For table scans, rather than using the relation targetlist (which is + * only those Vars actually needed by the query), we prefer to generate a + * tlist containing all Vars in order. This will allow the executor to + * optimize away projection of the table tuples, if possible. (Note that + * planner.c may replace the tlist we generate here, forcing projection to + * occur.) */ if (use_physical_tlist(rel)) { @@ -213,8 +213,8 @@ create_scan_plan(PlannerInfo *root, Path *best_path) tlist = build_relation_tlist(rel); /* - * Extract the relevant restriction clauses from the parent relation; - * the executor must apply all these restrictions during the scan. + * Extract the relevant restriction clauses from the parent relation; the + * executor must apply all these restrictions during the scan. */ scan_clauses = rel->baserestrictinfo; @@ -237,7 +237,7 @@ create_scan_plan(PlannerInfo *root, Path *best_path) case T_BitmapHeapScan: plan = (Scan *) create_bitmap_scan_plan(root, - (BitmapHeapPath *) best_path, + (BitmapHeapPath *) best_path, tlist, scan_clauses); break; @@ -308,8 +308,8 @@ use_physical_tlist(RelOptInfo *rel) int i; /* - * OK for subquery and function scans; otherwise, can't do it for - * anything except real relations. + * OK for subquery and function scans; otherwise, can't do it for anything + * except real relations. */ if (rel->rtekind != RTE_RELATION) { @@ -328,9 +328,9 @@ use_physical_tlist(RelOptInfo *rel) return false; /* - * Can't do it if any system columns are requested, either. (This - * could possibly be fixed but would take some fragile assumptions in - * setrefs.c, I think.) + * Can't do it if any system columns are requested, either. (This could + * possibly be fixed but would take some fragile assumptions in setrefs.c, + * I think.) */ for (i = rel->min_attr; i <= 0; i++) { @@ -415,14 +415,14 @@ create_join_plan(PlannerInfo *root, JoinPath *best_path) #ifdef NOT_USED /* - * * Expensive function pullups may have pulled local predicates * - * into this path node. Put them in the qpqual of the plan node. * - * JMH, 6/15/92 + * * Expensive function pullups may have pulled local predicates * into + * this path node. Put them in the qpqual of the plan node. * JMH, + * 6/15/92 */ if (get_loc_restrictinfo(best_path) != NIL) set_qpqual((Plan) plan, list_concat(get_qpqual((Plan) plan), - get_actual_clauses(get_loc_restrictinfo(best_path)))); + get_actual_clauses(get_loc_restrictinfo(best_path)))); #endif return plan; @@ -444,13 +444,13 @@ create_append_plan(PlannerInfo *root, AppendPath *best_path) ListCell *subpaths; /* - * It is possible for the subplans list to contain only one entry, - * or even no entries. Handle these cases specially. + * It is possible for the subplans list to contain only one entry, or even + * no entries. Handle these cases specially. * - * XXX ideally, if there's just one entry, we'd not bother to generate - * an Append node but just return the single child. At the moment this - * does not work because the varno of the child scan plan won't match - * the parent-rel Vars it'll be asked to emit. + * XXX ideally, if there's just one entry, we'd not bother to generate an + * Append node but just return the single child. At the moment this does + * not work because the varno of the child scan plan won't match the + * parent-rel Vars it'll be asked to emit. */ if (best_path->subpaths == NIL) { @@ -618,8 +618,8 @@ create_unique_plan(PlannerInfo *root, UniquePath *best_path) if (newitems) { /* - * If the top plan node can't do projections, we need to add a - * Result node to help it along. + * If the top plan node can't do projections, we need to add a Result + * node to help it along. */ if (!is_projection_capable_plan(subplan)) subplan = (Plan *) make_result(newtlist, NULL, subplan); @@ -628,8 +628,8 @@ create_unique_plan(PlannerInfo *root, UniquePath *best_path) } /* - * Build control information showing which subplan output columns are - * to be examined by the grouping step. Unfortunately we can't merge this + * Build control information showing which subplan output columns are to + * be examined by the grouping step. Unfortunately we can't merge this * with the previous loop, since we didn't then know which version of the * subplan tlist we'd end up using. */ @@ -656,9 +656,9 @@ create_unique_plan(PlannerInfo *root, UniquePath *best_path) numGroups = (long) Min(best_path->rows, (double) LONG_MAX); /* - * Since the Agg node is going to project anyway, we can give it - * the minimum output tlist, without any stuff we might have added - * to the subplan tlist. + * Since the Agg node is going to project anyway, we can give it the + * minimum output tlist, without any stuff we might have added to the + * subplan tlist. */ plan = (Plan *) make_agg(root, build_relation_tlist(best_path->path.parent), @@ -776,9 +776,9 @@ create_indexscan_plan(PlannerInfo *root, stripped_indexquals = get_actual_clauses(indexquals); /* - * The executor needs a copy with the indexkey on the left of each - * clause and with index attr numbers substituted for table ones. This - * pass also gets strategy info and looks for "lossy" operators. + * The executor needs a copy with the indexkey on the left of each clause + * and with index attr numbers substituted for table ones. This pass also + * gets strategy info and looks for "lossy" operators. */ fix_indexqual_references(indexquals, best_path, &fixed_indexquals, @@ -792,12 +792,11 @@ create_indexscan_plan(PlannerInfo *root, /* * If this is an innerjoin scan, the indexclauses will contain join - * clauses that are not present in scan_clauses (since the passed-in - * value is just the rel's baserestrictinfo list). We must add these - * clauses to scan_clauses to ensure they get checked. In most cases - * we will remove the join clauses again below, but if a join clause - * contains a special operator, we need to make sure it gets into the - * scan_clauses. + * clauses that are not present in scan_clauses (since the passed-in value + * is just the rel's baserestrictinfo list). We must add these clauses to + * scan_clauses to ensure they get checked. In most cases we will remove + * the join clauses again below, but if a join clause contains a special + * operator, we need to make sure it gets into the scan_clauses. * * Note: pointer comparison should be enough to determine RestrictInfo * matches. @@ -806,25 +805,25 @@ create_indexscan_plan(PlannerInfo *root, scan_clauses = list_union_ptr(scan_clauses, best_path->indexclauses); /* - * The qpqual list must contain all restrictions not automatically - * handled by the index. All the predicates in the indexquals will be - * checked (either by the index itself, or by nodeIndexscan.c), but if - * there are any "special" operators involved then they must be included - * in qpqual. Also, any lossy index operators must be rechecked in - * the qpqual. The upshot is that qpqual must contain scan_clauses - * minus whatever appears in nonlossy_indexquals. + * The qpqual list must contain all restrictions not automatically handled + * by the index. All the predicates in the indexquals will be checked + * (either by the index itself, or by nodeIndexscan.c), but if there are + * any "special" operators involved then they must be included in qpqual. + * Also, any lossy index operators must be rechecked in the qpqual. The + * upshot is that qpqual must contain scan_clauses minus whatever appears + * in nonlossy_indexquals. * - * In normal cases simple pointer equality checks will be enough to - * spot duplicate RestrictInfos, so we try that first. In some situations - * (particularly with OR'd index conditions) we may have scan_clauses - * that are not equal to, but are logically implied by, the index quals; - * so we also try a predicate_implied_by() check to see if we can discard - * quals that way. (predicate_implied_by assumes its first input contains - * only immutable functions, so we have to check that.) We can also - * discard quals that are implied by a partial index's predicate. + * In normal cases simple pointer equality checks will be enough to spot + * duplicate RestrictInfos, so we try that first. In some situations + * (particularly with OR'd index conditions) we may have scan_clauses that + * are not equal to, but are logically implied by, the index quals; so we + * also try a predicate_implied_by() check to see if we can discard quals + * that way. (predicate_implied_by assumes its first input contains only + * immutable functions, so we have to check that.) We can also discard + * quals that are implied by a partial index's predicate. * - * While at it, we strip off the RestrictInfos to produce a list of - * plain expressions. + * While at it, we strip off the RestrictInfos to produce a list of plain + * expressions. */ qpqual = NIL; foreach(l, scan_clauses) @@ -836,7 +835,7 @@ create_indexscan_plan(PlannerInfo *root, continue; if (!contain_mutable_functions((Node *) rinfo->clause)) { - List *clausel = list_make1(rinfo->clause); + List *clausel = list_make1(rinfo->clause); if (predicate_implied_by(clausel, nonlossy_indexquals)) continue; @@ -898,13 +897,12 @@ create_bitmap_scan_plan(PlannerInfo *root, scan_clauses = get_actual_clauses(scan_clauses); /* - * If this is a innerjoin scan, the indexclauses will contain join - * clauses that are not present in scan_clauses (since the passed-in - * value is just the rel's baserestrictinfo list). We must add these - * clauses to scan_clauses to ensure they get checked. In most cases - * we will remove the join clauses again below, but if a join clause - * contains a special operator, we need to make sure it gets into the - * scan_clauses. + * If this is a innerjoin scan, the indexclauses will contain join clauses + * that are not present in scan_clauses (since the passed-in value is just + * the rel's baserestrictinfo list). We must add these clauses to + * scan_clauses to ensure they get checked. In most cases we will remove + * the join clauses again below, but if a join clause contains a special + * operator, we need to make sure it gets into the scan_clauses. */ if (best_path->isjoininner) { @@ -912,12 +910,12 @@ create_bitmap_scan_plan(PlannerInfo *root, } /* - * The qpqual list must contain all restrictions not automatically - * handled by the index. All the predicates in the indexquals will be - * checked (either by the index itself, or by nodeBitmapHeapscan.c), - * but if there are any "special" or lossy operators involved then they - * must be added to qpqual. The upshot is that qpquals must contain - * scan_clauses minus whatever appears in indexquals. + * The qpqual list must contain all restrictions not automatically handled + * by the index. All the predicates in the indexquals will be checked + * (either by the index itself, or by nodeBitmapHeapscan.c), but if there + * are any "special" or lossy operators involved then they must be added + * to qpqual. The upshot is that qpquals must contain scan_clauses minus + * whatever appears in indexquals. * * In normal cases simple equal() checks will be enough to spot duplicate * clauses, so we try that first. In some situations (particularly with @@ -930,25 +928,25 @@ create_bitmap_scan_plan(PlannerInfo *root, * * XXX For the moment, we only consider partial index predicates in the * simple single-index-scan case. Is it worth trying to be smart about - * more complex cases? Perhaps create_bitmap_subplan should be made to + * more complex cases? Perhaps create_bitmap_subplan should be made to * include predicate info in what it constructs. */ qpqual = NIL; foreach(l, scan_clauses) { - Node *clause = (Node *) lfirst(l); + Node *clause = (Node *) lfirst(l); if (list_member(indexquals, clause)) continue; if (!contain_mutable_functions(clause)) { - List *clausel = list_make1(clause); + List *clausel = list_make1(clause); if (predicate_implied_by(clausel, indexquals)) continue; if (IsA(best_path->bitmapqual, IndexPath)) { - IndexPath *ipath = (IndexPath *) best_path->bitmapqual; + IndexPath *ipath = (IndexPath *) best_path->bitmapqual; if (predicate_implied_by(clausel, ipath->indexinfo->indpred)) continue; @@ -1010,15 +1008,15 @@ create_bitmap_subplan(PlannerInfo *root, Path *bitmapqual, /* * There may well be redundant quals among the subplans, since a * top-level WHERE qual might have gotten used to form several - * different index quals. We don't try exceedingly hard to - * eliminate redundancies, but we do eliminate obvious duplicates - * by using list_concat_unique. + * different index quals. We don't try exceedingly hard to eliminate + * redundancies, but we do eliminate obvious duplicates by using + * list_concat_unique. */ foreach(l, apath->bitmapquals) { - Plan *subplan; - List *subqual; - List *subindexqual; + Plan *subplan; + List *subqual; + List *subindexqual; subplan = create_bitmap_subplan(root, (Path *) lfirst(l), &subqual, &subindexqual); @@ -1048,7 +1046,7 @@ create_bitmap_subplan(PlannerInfo *root, Path *bitmapqual, /* * Here, we only detect qual-free subplans. A qual-free subplan would * cause us to generate "... OR true ..." which we may as well reduce - * to just "true". We do not try to eliminate redundant subclauses + * to just "true". We do not try to eliminate redundant subclauses * because (a) it's not as likely as in the AND case, and (b) we might * well be working with hundreds or even thousands of OR conditions, * perhaps from a long IN list. The performance of list_append_unique @@ -1056,9 +1054,9 @@ create_bitmap_subplan(PlannerInfo *root, Path *bitmapqual, */ foreach(l, opath->bitmapquals) { - Plan *subplan; - List *subqual; - List *subindexqual; + Plan *subplan; + List *subqual; + List *subindexqual; subplan = create_bitmap_subplan(root, (Path *) lfirst(l), &subqual, &subindexqual); @@ -1080,6 +1078,7 @@ create_bitmap_subplan(PlannerInfo *root, Path *bitmapqual, plan->plan_rows = clamp_row_est(opath->bitmapselectivity * opath->path.parent->tuples); plan->plan_width = 0; /* meaningless */ + /* * If there were constant-TRUE subquals, the OR reduces to constant * TRUE. Also, avoid generating one-element ORs, which could happen @@ -1100,9 +1099,9 @@ create_bitmap_subplan(PlannerInfo *root, Path *bitmapqual, } else if (IsA(bitmapqual, IndexPath)) { - IndexPath *ipath = (IndexPath *) bitmapqual; - IndexScan *iscan; - List *nonlossy_clauses; + IndexPath *ipath = (IndexPath *) bitmapqual; + IndexScan *iscan; + List *nonlossy_clauses; /* Use the regular indexscan plan build machinery... */ iscan = create_indexscan_plan(root, ipath, NIL, NIL, @@ -1245,18 +1244,18 @@ create_nestloop_plan(PlannerInfo *root, if (IsA(best_path->innerjoinpath, IndexPath)) { /* - * An index is being used to reduce the number of tuples scanned - * in the inner relation. If there are join clauses being used - * with the index, we may remove those join clauses from the list - * of clauses that have to be checked as qpquals at the join node. + * An index is being used to reduce the number of tuples scanned in + * the inner relation. If there are join clauses being used with the + * index, we may remove those join clauses from the list of clauses + * that have to be checked as qpquals at the join node. * * We can also remove any join clauses that are redundant with those - * being used in the index scan; prior redundancy checks will not - * have caught this case because the join clauses would never have - * been put in the same joininfo list. + * being used in the index scan; prior redundancy checks will not have + * caught this case because the join clauses would never have been put + * in the same joininfo list. * - * We can skip this if the index path is an ordinary indexpath and - * not a special innerjoin path. + * We can skip this if the index path is an ordinary indexpath and not a + * special innerjoin path. */ IndexPath *innerpath = (IndexPath *) best_path->innerjoinpath; @@ -1266,7 +1265,7 @@ create_nestloop_plan(PlannerInfo *root, select_nonredundant_join_clauses(root, joinrestrictclauses, innerpath->indexclauses, - IS_OUTER_JOIN(best_path->jointype)); + IS_OUTER_JOIN(best_path->jointype)); } } else if (IsA(best_path->innerjoinpath, BitmapHeapPath)) @@ -1275,11 +1274,11 @@ create_nestloop_plan(PlannerInfo *root, * Same deal for bitmapped index scans. * * Note: both here and above, we ignore any implicit index restrictions - * associated with the use of partial indexes. This is OK because + * associated with the use of partial indexes. This is OK because * we're only trying to prove we can dispense with some join quals; * failing to prove that doesn't result in an incorrect plan. It is - * the right way to proceed because adding more quals to the stuff - * we got from the original query would just make it harder to detect + * the right way to proceed because adding more quals to the stuff we + * got from the original query would just make it harder to detect * duplication. */ BitmapHeapPath *innerpath = (BitmapHeapPath *) best_path->innerjoinpath; @@ -1296,7 +1295,7 @@ create_nestloop_plan(PlannerInfo *root, select_nonredundant_join_clauses(root, joinrestrictclauses, bitmapclauses, - IS_OUTER_JOIN(best_path->jointype)); + IS_OUTER_JOIN(best_path->jointype)); } } @@ -1355,18 +1354,18 @@ create_mergejoin_plan(PlannerInfo *root, } /* - * Remove the mergeclauses from the list of join qual clauses, leaving - * the list of quals that must be checked as qpquals. + * Remove the mergeclauses from the list of join qual clauses, leaving the + * list of quals that must be checked as qpquals. */ mergeclauses = get_actual_clauses(best_path->path_mergeclauses); joinclauses = list_difference(joinclauses, mergeclauses); /* - * Rearrange mergeclauses, if needed, so that the outer variable is - * always on the left. + * Rearrange mergeclauses, if needed, so that the outer variable is always + * on the left. */ mergeclauses = get_switched_clauses(best_path->path_mergeclauses, - best_path->jpath.outerjoinpath->parent->relids); + best_path->jpath.outerjoinpath->parent->relids); /* Sort clauses into best execution order */ /* NB: do NOT reorder the mergeclauses */ @@ -1375,8 +1374,8 @@ create_mergejoin_plan(PlannerInfo *root, /* * Create explicit sort nodes for the outer and inner join paths if - * necessary. The sort cost was already accounted for in the path. - * Make sure there are no excess columns in the inputs if sorting. + * necessary. The sort cost was already accounted for in the path. Make + * sure there are no excess columns in the inputs if sorting. */ if (best_path->outersortkeys) { @@ -1439,18 +1438,18 @@ create_hashjoin_plan(PlannerInfo *root, } /* - * Remove the hashclauses from the list of join qual clauses, leaving - * the list of quals that must be checked as qpquals. + * Remove the hashclauses from the list of join qual clauses, leaving the + * list of quals that must be checked as qpquals. */ hashclauses = get_actual_clauses(best_path->path_hashclauses); joinclauses = list_difference(joinclauses, hashclauses); /* - * Rearrange hashclauses, if needed, so that the outer variable is - * always on the left. + * Rearrange hashclauses, if needed, so that the outer variable is always + * on the left. */ hashclauses = get_switched_clauses(best_path->path_hashclauses, - best_path->jpath.outerjoinpath->parent->relids); + best_path->jpath.outerjoinpath->parent->relids); /* Sort clauses into best execution order */ joinclauses = order_qual_clauses(root, joinclauses); @@ -1551,23 +1550,22 @@ fix_indexqual_references(List *indexquals, IndexPath *index_path, /* * Make a copy that will become the fixed clause. * - * We used to try to do a shallow copy here, but that fails if there - * is a subplan in the arguments of the opclause. So just do a - * full copy. + * We used to try to do a shallow copy here, but that fails if there is a + * subplan in the arguments of the opclause. So just do a full copy. */ newclause = (OpExpr *) copyObject((Node *) clause); /* - * Check to see if the indexkey is on the right; if so, commute - * the clause. The indexkey should be the side that refers to - * (only) the base relation. + * Check to see if the indexkey is on the right; if so, commute the + * clause. The indexkey should be the side that refers to (only) the + * base relation. */ if (!bms_equal(rinfo->left_relids, index->rel->relids)) CommuteClause(newclause); /* - * Now, determine which index attribute this is, change the - * indexkey operand as needed, and get the index opclass. + * Now, determine which index attribute this is, change the indexkey + * operand as needed, and get the index opclass. */ linitial(newclause->args) = fix_indexqual_operand(linitial(newclause->args), @@ -1577,10 +1575,9 @@ fix_indexqual_references(List *indexquals, IndexPath *index_path, *fixed_indexquals = lappend(*fixed_indexquals, newclause); /* - * Look up the (possibly commuted) operator in the operator class - * to get its strategy numbers and the recheck indicator. This - * also double-checks that we found an operator matching the - * index. + * Look up the (possibly commuted) operator in the operator class to + * get its strategy numbers and the recheck indicator. This also + * double-checks that we found an operator matching the index. */ get_op_opclass_properties(newclause->opno, opclass, &stratno, &stratsubtype, &recheck); @@ -1598,11 +1595,11 @@ static Node * fix_indexqual_operand(Node *node, IndexOptInfo *index, Oid *opclass) { /* - * We represent index keys by Var nodes having the varno of the base - * table but varattno equal to the index's attribute number (index - * column position). This is a bit hokey ... would be cleaner to use - * a special-purpose node type that could not be mistaken for a - * regular Var. But it will do for now. + * We represent index keys by Var nodes having the varno of the base table + * but varattno equal to the index's attribute number (index column + * position). This is a bit hokey ... would be cleaner to use a + * special-purpose node type that could not be mistaken for a regular Var. + * But it will do for now. */ Var *result; int pos; @@ -1692,8 +1689,8 @@ get_switched_clauses(List *clauses, Relids outerrelids) if (bms_is_subset(restrictinfo->right_relids, outerrelids)) { /* - * Duplicate just enough of the structure to allow commuting - * the clause without changing the original list. Could use + * 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. */ OpExpr *temp = makeNode(OpExpr); @@ -1934,9 +1931,9 @@ make_subqueryscan(List *qptlist, Plan *plan = &node->scan.plan; /* - * Cost is figured here for the convenience of prepunion.c. Note this - * is only correct for the case where qpqual is empty; otherwise - * caller should overwrite cost with a better estimate. + * Cost is figured here for the convenience of prepunion.c. Note this is + * only correct for the case where qpqual is empty; otherwise caller + * should overwrite cost with a better estimate. */ copy_plan_costsize(plan, subplan); plan->total_cost += cpu_tuple_cost * subplan->plan_rows; @@ -1977,9 +1974,9 @@ make_append(List *appendplans, bool isTarget, List *tlist) ListCell *subnode; /* - * Compute cost as sum of subplan costs. We charge nothing extra for - * the Append itself, which perhaps is too optimistic, but since it - * doesn't do any selection or projection, it is a pretty cheap node. + * Compute cost as sum of subplan costs. We charge nothing extra for the + * Append itself, which perhaps is too optimistic, but since it doesn't do + * any selection or projection, it is a pretty cheap node. */ plan->startup_cost = 0; plan->total_cost = 0; @@ -2094,8 +2091,8 @@ make_hash(Plan *lefttree) copy_plan_costsize(plan, lefttree); /* - * For plausibility, make startup & total costs equal total cost of - * input plan; this only affects EXPLAIN display not decisions. + * For plausibility, make startup & total costs equal total cost of input + * plan; this only affects EXPLAIN display not decisions. */ plan->startup_cost = plan->total_cost; plan->targetlist = copyObject(lefttree->targetlist); @@ -2217,8 +2214,7 @@ make_sort_from_pathkeys(PlannerInfo *root, Plan *lefttree, List *pathkeys) Oid *sortOperators; /* - * We will need at most list_length(pathkeys) sort columns; possibly - * less + * We will need at most list_length(pathkeys) sort columns; possibly less */ numsortkeys = list_length(pathkeys); sortColIdx = (AttrNumber *) palloc(numsortkeys * sizeof(AttrNumber)); @@ -2236,14 +2232,14 @@ make_sort_from_pathkeys(PlannerInfo *root, Plan *lefttree, List *pathkeys) /* * We can sort by any one of the sort key items listed in this * sublist. For now, we take the first one that corresponds to an - * available Var in the tlist. If there isn't any, use the first - * one that is an expression in the input's vars. + * available Var in the tlist. If there isn't any, use the first one + * that is an expression in the input's vars. * - * XXX if we have a choice, is there any way of figuring out which - * might be cheapest to execute? (For example, int4lt is likely - * much cheaper to execute than numericlt, but both might appear - * in the same pathkey sublist...) Not clear that we ever will - * have a choice in practice, so it may not matter. + * XXX if we have a choice, is there any way of figuring out which might + * be cheapest to execute? (For example, int4lt is likely much + * cheaper to execute than numericlt, but both might appear in the + * same pathkey sublist...) Not clear that we ever will have a choice + * in practice, so it may not matter. */ foreach(j, keysublist) { @@ -2296,13 +2292,13 @@ make_sort_from_pathkeys(PlannerInfo *root, Plan *lefttree, List *pathkeys) } /* - * The column might already be selected as a sort key, if the - * pathkeys contain duplicate entries. (This can happen in - * scenarios where multiple mergejoinable clauses mention the same - * var, for example.) So enter it only once in the sort arrays. + * The column might already be selected as a sort key, if the pathkeys + * contain duplicate entries. (This can happen in scenarios where + * multiple mergejoinable clauses mention the same var, for example.) + * So enter it only once in the sort arrays. */ numsortkeys = add_sort_column(tle->resno, pathkey->sortop, - numsortkeys, sortColIdx, sortOperators); + numsortkeys, sortColIdx, sortOperators); } Assert(numsortkeys > 0); @@ -2328,8 +2324,7 @@ make_sort_from_sortclauses(PlannerInfo *root, List *sortcls, Plan *lefttree) Oid *sortOperators; /* - * We will need at most list_length(sortcls) sort columns; possibly - * less + * We will need at most list_length(sortcls) sort columns; possibly less */ numsortkeys = list_length(sortcls); sortColIdx = (AttrNumber *) palloc(numsortkeys * sizeof(AttrNumber)); @@ -2348,7 +2343,7 @@ make_sort_from_sortclauses(PlannerInfo *root, List *sortcls, Plan *lefttree) * redundantly. */ numsortkeys = add_sort_column(tle->resno, sortcl->sortop, - numsortkeys, sortColIdx, sortOperators); + numsortkeys, sortColIdx, sortOperators); } Assert(numsortkeys > 0); @@ -2384,8 +2379,7 @@ make_sort_from_groupcols(PlannerInfo *root, Oid *sortOperators; /* - * We will need at most list_length(groupcls) sort columns; possibly - * less + * We will need at most list_length(groupcls) sort columns; possibly less */ numsortkeys = list_length(groupcls); sortColIdx = (AttrNumber *) palloc(numsortkeys * sizeof(AttrNumber)); @@ -2404,7 +2398,7 @@ make_sort_from_groupcols(PlannerInfo *root, * redundantly. */ numsortkeys = add_sort_column(tle->resno, grpcl->sortop, - numsortkeys, sortColIdx, sortOperators); + numsortkeys, sortColIdx, sortOperators); grpno++; } @@ -2492,8 +2486,8 @@ make_agg(PlannerInfo *root, List *tlist, List *qual, plan->total_cost = agg_path.total_cost; /* - * We will produce a single output tuple if not grouping, and a tuple - * per group otherwise. + * We will produce a single output tuple if not grouping, and a tuple per + * group otherwise. */ if (aggstrategy == AGG_PLAIN) plan->plan_rows = 1; @@ -2501,13 +2495,13 @@ make_agg(PlannerInfo *root, List *tlist, List *qual, plan->plan_rows = numGroups; /* - * We also need to account for the cost of evaluation of the qual (ie, - * the HAVING clause) and the tlist. Note that cost_qual_eval doesn't - * charge anything for Aggref nodes; this is okay since they are - * really comparable to Vars. + * We also need to account for the cost of evaluation of the qual (ie, the + * HAVING clause) and the tlist. Note that cost_qual_eval doesn't charge + * anything for Aggref nodes; this is okay since they are really + * comparable to Vars. * - * See notes in grouping_planner about why this routine and make_group - * are the only ones in this file that worry about tlist eval cost. + * See notes in grouping_planner about why this routine and make_group are + * the only ones in this file that worry about tlist eval cost. */ if (qual) { @@ -2559,16 +2553,15 @@ make_group(PlannerInfo *root, plan->plan_rows = numGroups; /* - * We also need to account for the cost of evaluation of the qual (ie, - * the HAVING clause) and the tlist. + * We also need to account for the cost of evaluation of the qual (ie, the + * HAVING clause) and the tlist. * - * XXX this double-counts the cost of evaluation of any expressions used - * for grouping, since in reality those will have been evaluated at a - * lower plan level and will only be copied by the Group node. Worth - * fixing? + * XXX this double-counts the cost of evaluation of any expressions used for + * grouping, since in reality those will have been evaluated at a lower + * plan level and will only be copied by the Group node. Worth fixing? * - * See notes in grouping_planner about why this routine and make_agg are - * the only ones in this file that worry about tlist eval cost. + * See notes in grouping_planner about why this routine and make_agg are the + * only ones in this file that worry about tlist eval cost. */ if (qual) { @@ -2607,16 +2600,16 @@ make_unique(Plan *lefttree, List *distinctList) copy_plan_costsize(plan, lefttree); /* - * Charge one cpu_operator_cost per comparison per input tuple. We - * assume all columns get compared at most of the tuples. (XXX - * probably this is an overestimate.) + * Charge one cpu_operator_cost per comparison per input tuple. We assume + * all columns get compared at most of the tuples. (XXX probably this is + * an overestimate.) */ plan->total_cost += cpu_operator_cost * plan->plan_rows * numCols; /* - * plan->plan_rows is left as a copy of the input subplan's plan_rows; - * ie, we assume the filter removes nothing. The caller must alter - * this if he has a better idea. + * plan->plan_rows is left as a copy of the input subplan's plan_rows; ie, + * we assume the filter removes nothing. The caller must alter this if he + * has a better idea. */ plan->targetlist = copyObject(lefttree->targetlist); @@ -2625,8 +2618,7 @@ make_unique(Plan *lefttree, List *distinctList) plan->righttree = NULL; /* - * convert SortClause list into array of attr indexes, as wanted by - * exec + * convert SortClause list into array of attr indexes, as wanted by exec */ Assert(numCols > 0); uniqColIdx = (AttrNumber *) palloc(sizeof(AttrNumber) * numCols); @@ -2664,8 +2656,8 @@ make_setop(SetOpCmd cmd, Plan *lefttree, copy_plan_costsize(plan, lefttree); /* - * Charge one cpu_operator_cost per comparison per input tuple. We - * assume all columns get compared at most of the tuples. + * Charge one cpu_operator_cost per comparison per input tuple. We assume + * all columns get compared at most of the tuples. */ plan->total_cost += cpu_operator_cost * plan->plan_rows * numCols; @@ -2683,8 +2675,7 @@ make_setop(SetOpCmd cmd, Plan *lefttree, plan->righttree = NULL; /* - * convert SortClause list into array of attr indexes, as wanted by - * exec + * convert SortClause list into array of attr indexes, as wanted by exec */ Assert(numCols > 0); dupColIdx = (AttrNumber *) palloc(sizeof(AttrNumber) * numCols); @@ -2727,8 +2718,8 @@ make_limit(Plan *lefttree, Node *limitOffset, Node *limitCount, * building a subquery then it's important to report correct info to the * outer planner. * - * When the offset or count couldn't be estimated, use 10% of the - * estimated number of rows emitted from the subplan. + * When the offset or count couldn't be estimated, use 10% of the estimated + * number of rows emitted from the subplan. */ if (offset_est != 0) { diff --git a/src/backend/optimizer/plan/initsplan.c b/src/backend/optimizer/plan/initsplan.c index 7e3d5bca55..dd8fc4fa2d 100644 --- a/src/backend/optimizer/plan/initsplan.c +++ b/src/backend/optimizer/plan/initsplan.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/plan/initsplan.c,v 1.109 2005/09/28 21:17:02 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/plan/initsplan.c,v 1.110 2005/10/15 02:49:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -221,7 +221,7 @@ distribute_quals_to_rels(PlannerInfo *root, Node *jtnode, result = bms_add_members(result, distribute_quals_to_rels(root, lfirst(l), - below_outer_join)); + below_outer_join)); } /* @@ -243,17 +243,17 @@ distribute_quals_to_rels(PlannerInfo *root, Node *jtnode, ListCell *qual; /* - * Order of operations here is subtle and critical. First we - * recurse to handle sub-JOINs. Their join quals will be placed - * without regard for whether this level is an outer join, which - * is correct. Then we place our own join quals, which are - * restricted by lower outer joins in any case, and are forced to - * this level if this is an outer join and they mention the outer - * side. Finally, if this is an outer join, we mark baserels - * contained within the inner side(s) with our own rel set; this - * will prevent quals above us in the join tree that use those - * rels from being pushed down below this level. (It's okay for - * upper quals to be pushed down to the outer side, however.) + * Order of operations here is subtle and critical. First we recurse + * to handle sub-JOINs. Their join quals will be placed without + * regard for whether this level is an outer join, which is correct. + * Then we place our own join quals, which are restricted by lower + * outer joins in any case, and are forced to this level if this is an + * outer join and they mention the outer side. Finally, if this is an + * outer join, we mark baserels contained within the inner side(s) + * with our own rel set; this will prevent quals above us in the join + * tree that use those rels from being pushed down below this level. + * (It's okay for upper quals to be pushed down to the outer side, + * however.) */ switch (j->jointype) { @@ -302,19 +302,19 @@ distribute_quals_to_rels(PlannerInfo *root, Node *jtnode, case JOIN_UNION: /* - * This is where we fail if upper levels of planner - * haven't rewritten UNION JOIN as an Append ... + * This is where we fail if upper levels of planner haven't + * rewritten UNION JOIN as an Append ... */ ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("UNION JOIN is not implemented"))); - nonnullable_rels = NULL; /* keep compiler quiet */ + nonnullable_rels = NULL; /* keep compiler quiet */ nullable_rels = NULL; break; default: elog(ERROR, "unrecognized join type: %d", (int) j->jointype); - nonnullable_rels = NULL; /* keep compiler quiet */ + nonnullable_rels = NULL; /* keep compiler quiet */ nullable_rels = NULL; break; } @@ -349,19 +349,19 @@ mark_baserels_for_outer_join(PlannerInfo *root, Relids rels, Relids outerrels) RelOptInfo *rel = find_base_rel(root, relno); /* - * Since we do this bottom-up, any outer-rels previously marked - * should be within the new outer join set. + * Since we do this bottom-up, any outer-rels previously marked should + * be within the new outer join set. */ Assert(bms_is_subset(rel->outerjoinset, outerrels)); /* * Presently the executor cannot support FOR UPDATE/SHARE marking of * rels appearing on the nullable side of an outer join. (It's - * somewhat unclear what that would mean, anyway: what should we - * mark when a result row is generated from no element of the - * nullable relation?) So, complain if target rel is FOR UPDATE/SHARE. - * It's sufficient to make this check once per rel, so do it only - * if rel wasn't already known nullable. + * somewhat unclear what that would mean, anyway: what should we mark + * when a result row is generated from no element of the nullable + * relation?) So, complain if target rel is FOR UPDATE/SHARE. It's + * sufficient to make this check once per rel, so do it only if rel + * wasn't already known nullable. */ if (rel->outerjoinset == NULL) { @@ -430,9 +430,9 @@ distribute_qual_to_rels(PlannerInfo *root, Node *clause, /* * If the clause is variable-free, we force it to be evaluated at its * original syntactic level. Note that this should not happen for - * top-level clauses, because query_planner() special-cases them. But - * it will happen for variable-free JOIN/ON clauses. We don't have to - * be real smart about such a case, we just have to be correct. + * top-level clauses, because query_planner() special-cases them. But it + * will happen for variable-free JOIN/ON clauses. We don't have to be + * real smart about such a case, we just have to be correct. */ if (bms_is_empty(relids)) relids = qualscope; @@ -446,8 +446,8 @@ distribute_qual_to_rels(PlannerInfo *root, Node *clause, /* * If the qual came from implied-equality deduction, we always * evaluate the qual at its natural semantic level. It is the - * responsibility of the deducer not to create any quals that - * should be delayed by outer-join rules. + * responsibility of the deducer not to create any quals that should + * be delayed by outer-join rules. */ Assert(bms_equal(relids, qualscope)); /* Needn't feed it back for more deductions */ @@ -457,28 +457,28 @@ distribute_qual_to_rels(PlannerInfo *root, Node *clause, else if (bms_overlap(relids, outerjoin_nonnullable)) { /* - * The qual is attached to an outer join and mentions (some of - * the) rels on the nonnullable side. Force the qual to be - * evaluated exactly at the level of joining corresponding to the - * outer join. We cannot let it get pushed down into the - * nonnullable side, since then we'd produce no output rows, - * rather than the intended single null-extended row, for any - * nonnullable-side rows failing the qual. + * The qual is attached to an outer join and mentions (some of the) + * rels on the nonnullable side. Force the qual to be evaluated + * exactly at the level of joining corresponding to the outer join. We + * cannot let it get pushed down into the nonnullable side, since then + * we'd produce no output rows, rather than the intended single + * null-extended row, for any nonnullable-side rows failing the qual. * - * Note: an outer-join qual that mentions only nullable-side rels can - * be pushed down into the nullable side without changing the join + * Note: an outer-join qual that mentions only nullable-side rels can be + * pushed down into the nullable side without changing the join * result, so we treat it the same as an ordinary inner-join qual, * except for not setting maybe_equijoin (see below). */ relids = qualscope; + /* - * We can't use such a clause to deduce equijoin (the left and - * right sides might be unequal above the join because one of - * them has gone to NULL) ... but we might be able to use it - * for more limited purposes. Note: for the current uses of - * deductions from an outer-join clause, it seems safe to make - * the deductions even when the clause is below a higher-level - * outer join; so we do not check below_outer_join here. + * We can't use such a clause to deduce equijoin (the left and right + * sides might be unequal above the join because one of them has gone + * to NULL) ... but we might be able to use it for more limited + * purposes. Note: for the current uses of deductions from an + * outer-join clause, it seems safe to make the deductions even when + * the clause is below a higher-level outer join; so we do not check + * below_outer_join here. */ maybe_equijoin = false; maybe_outer_join = true; @@ -486,15 +486,14 @@ distribute_qual_to_rels(PlannerInfo *root, Node *clause, else { /* - * For a non-outer-join qual, we can evaluate the qual as soon as - * (1) we have all the rels it mentions, and (2) we are at or - * above any outer joins that can null any of these rels and are - * below the syntactic location of the given qual. To enforce the - * latter, scan the base rels listed in relids, and merge their - * outer-join sets into the clause's own reference list. At the - * time we are called, the outerjoinset of each baserel will show - * exactly those outer joins that are below the qual in the join - * tree. + * For a non-outer-join qual, we can evaluate the qual as soon as (1) + * we have all the rels it mentions, and (2) we are at or above any + * outer joins that can null any of these rels and are below the + * syntactic location of the given qual. To enforce the latter, scan + * the base rels listed in relids, and merge their outer-join sets + * into the clause's own reference list. At the time we are called, + * the outerjoinset of each baserel will show exactly those outer + * joins that are below the qual in the join tree. */ Relids addrelids = NULL; Relids tmprelids; @@ -513,13 +512,13 @@ distribute_qual_to_rels(PlannerInfo *root, Node *clause, if (bms_is_subset(addrelids, relids)) { /* - * Qual is not delayed by any lower outer-join restriction. - * If it is not itself below or within an outer join, we - * can consider it "valid everywhere", so consider feeding - * it to the equijoin machinery. (If it is within an outer - * join, we can't consider it "valid everywhere": once the - * contained variables have gone to NULL, we'd be asserting - * things like NULL = NULL, which is not true.) + * Qual is not delayed by any lower outer-join restriction. If it + * is not itself below or within an outer join, we can consider it + * "valid everywhere", so consider feeding it to the equijoin + * machinery. (If it is within an outer join, we can't consider + * it "valid everywhere": once the contained variables have gone + * to NULL, we'd be asserting things like NULL = NULL, which is + * not true.) */ if (!below_outer_join && outerjoin_nonnullable == NULL) maybe_equijoin = true; @@ -533,8 +532,8 @@ distribute_qual_to_rels(PlannerInfo *root, Node *clause, Assert(bms_is_subset(relids, qualscope)); /* - * Because application of the qual will be delayed by outer - * join, we mustn't assume its vars are equal everywhere. + * Because application of the qual will be delayed by outer join, + * we mustn't assume its vars are equal everywhere. */ maybe_equijoin = false; } @@ -543,11 +542,10 @@ distribute_qual_to_rels(PlannerInfo *root, Node *clause, } /* - * Mark the qual as "pushed down" if it can be applied at a level - * below its original syntactic level. This allows us to distinguish - * original JOIN/ON quals from higher-level quals pushed down to the - * same joinrel. A qual originating from WHERE is always considered - * "pushed down". + * Mark the qual as "pushed down" if it can be applied at a level below + * its original syntactic level. This allows us to distinguish original + * JOIN/ON quals from higher-level quals pushed down to the same joinrel. + * A qual originating from WHERE is always considered "pushed down". */ if (!is_pushed_down) is_pushed_down = !bms_equal(relids, qualscope); @@ -573,25 +571,24 @@ distribute_qual_to_rels(PlannerInfo *root, Node *clause, rel = find_base_rel(root, bms_singleton_member(relids)); /* - * Check for a "mergejoinable" clause even though it's not a - * join clause. This is so that we can recognize that "a.x = - * a.y" makes x and y eligible to be considered equal, even - * when they belong to the same rel. Without this, we would - * not recognize that "a.x = a.y AND a.x = b.z AND a.y = c.q" - * allows us to consider z and q equal after their rels are - * joined. + * Check for a "mergejoinable" clause even though it's not a join + * clause. This is so that we can recognize that "a.x = a.y" + * makes x and y eligible to be considered equal, even when they + * belong to the same rel. Without this, we would not recognize + * that "a.x = a.y AND a.x = b.z AND a.y = c.q" allows us to + * consider z and q equal after their rels are joined. */ check_mergejoinable(restrictinfo); /* - * If the clause was deduced from implied equality, check to - * see whether it is redundant with restriction clauses we - * already have for this rel. Note we cannot apply this check - * to user-written clauses, since we haven't found the - * canonical pathkey sets yet while processing user clauses. - * (NB: no comparable check is done in the join-clause case; - * redundancy will be detected when the join clause is moved - * into a join rel's restriction list.) + * If the clause was deduced from implied equality, check to see + * whether it is redundant with restriction clauses we already + * have for this rel. Note we cannot apply this check to + * user-written clauses, since we haven't found the canonical + * pathkey sets yet while processing user clauses. (NB: no + * comparable check is done in the join-clause case; redundancy + * will be detected when the join clause is moved into a join + * rel's restriction list.) */ if (!is_deduced || !qual_is_redundant(root, restrictinfo, @@ -605,17 +602,17 @@ distribute_qual_to_rels(PlannerInfo *root, Node *clause, case BMS_MULTIPLE: /* - * 'clause' is a join clause, since there is more than one rel - * in the relid set. + * 'clause' is a join clause, since there is more than one rel in + * the relid set. */ /* * Check for hash or mergejoinable operators. * - * We don't bother setting the hashjoin info if we're not going - * to need it. We do want to know about mergejoinable ops in - * all cases, however, because we use mergejoinable ops for - * other purposes such as detecting redundant clauses. + * We don't bother setting the hashjoin info if we're not going to + * need it. We do want to know about mergejoinable ops in all + * cases, however, because we use mergejoinable ops for other + * purposes such as detecting redundant clauses. */ check_mergejoinable(restrictinfo); if (enable_hashjoin) @@ -628,9 +625,9 @@ distribute_qual_to_rels(PlannerInfo *root, Node *clause, /* * Add vars used in the join clause to targetlists of their - * relations, so that they will be emitted by the plan nodes - * that scan those relations (else they won't be available at - * the join node!). + * relations, so that they will be emitted by the plan nodes that + * scan those relations (else they won't be available at the join + * node!). */ vars = pull_var_clause(clause, false); add_vars_to_targetlist(root, vars, relids); @@ -639,17 +636,16 @@ distribute_qual_to_rels(PlannerInfo *root, Node *clause, default: /* - * 'clause' references no rels, and therefore we have no place - * to attach it. Shouldn't get here if callers are working - * properly. + * 'clause' references no rels, and therefore we have no place to + * attach it. Shouldn't get here if callers are working properly. */ elog(ERROR, "cannot cope with variable-free clause"); break; } /* - * If the clause has a mergejoinable operator, we may be able to - * deduce more things from it under the principle of transitivity. + * If the clause has a mergejoinable operator, we may be able to deduce + * more things from it under the principle of transitivity. * * If it is not an outer-join qualification nor bubbled up due to an outer * join, then the two sides represent equivalent PathKeyItems for path @@ -744,8 +740,8 @@ process_implied_equality(PlannerInfo *root, /* * If the exprs involve a single rel, we need to look at that rel's - * baserestrictinfo list. If multiple rels, we can scan the joininfo - * list of any of 'em. + * baserestrictinfo list. If multiple rels, we can scan the joininfo list + * of any of 'em. */ if (membership == BMS_SINGLETON) { @@ -767,8 +763,8 @@ process_implied_equality(PlannerInfo *root, } /* - * Scan to see if equality is already known. If so, we're done in the - * add case, and done after removing it in the delete case. + * Scan to see if equality is already known. If so, we're done in the add + * case, and done after removing it in the delete case. */ foreach(itm, restrictlist) { @@ -791,7 +787,7 @@ process_implied_equality(PlannerInfo *root, { /* delete it from local restrictinfo list */ rel1->baserestrictinfo = list_delete_ptr(rel1->baserestrictinfo, - restrictinfo); + restrictinfo); } else { @@ -808,8 +804,8 @@ process_implied_equality(PlannerInfo *root, return; /* - * This equality is new information, so construct a clause - * representing it to add to the query data structures. + * This equality is new information, so construct a clause representing it + * to add to the query data structures. */ ltype = exprType(item1); rtype = exprType(item2); @@ -818,14 +814,14 @@ process_implied_equality(PlannerInfo *root, if (!HeapTupleIsValid(eq_operator)) { /* - * Would it be safe to just not add the equality to the query if - * we have no suitable equality operator for the combination of + * Would it be safe to just not add the equality to the query if we + * have no suitable equality operator for the combination of * datatypes? NO, because sortkey selection may screw up anyway. */ ereport(ERROR, (errcode(ERRCODE_UNDEFINED_FUNCTION), - errmsg("could not identify an equality operator for types %s and %s", - format_type_be(ltype), format_type_be(rtype)))); + errmsg("could not identify an equality operator for types %s and %s", + format_type_be(ltype), format_type_be(rtype)))); } pgopform = (Form_pg_operator) GETSTRUCT(eq_operator); @@ -856,8 +852,8 @@ process_implied_equality(PlannerInfo *root, /* * Push the new clause into all the appropriate restrictinfo lists. * - * Note: we mark the qual "pushed down" to ensure that it can never be - * taken for an original JOIN/ON clause. + * Note: we mark the qual "pushed down" to ensure that it can never be taken + * for an original JOIN/ON clause. */ distribute_qual_to_rels(root, (Node *) clause, true, true, false, NULL, relids); @@ -911,9 +907,9 @@ qual_is_redundant(PlannerInfo *root, return false; /* - * Scan existing quals to find those referencing same pathkeys. - * Usually there will be few, if any, so build a list of just the - * interesting ones. + * Scan existing quals to find those referencing same pathkeys. Usually + * there will be few, if any, so build a list of just the interesting + * ones. */ oldquals = NIL; foreach(olditem, restrictlist) @@ -933,11 +929,10 @@ qual_is_redundant(PlannerInfo *root, /* * Now, we want to develop a list of exprs that are known equal to the - * left side of the new qual. We traverse the old-quals list - * repeatedly to transitively expand the exprs list. If at any point - * we find we can reach the right-side expr of the new qual, we are - * done. We give up when we can't expand the equalexprs list any - * more. + * left side of the new qual. We traverse the old-quals list repeatedly + * to transitively expand the exprs list. If at any point we find we can + * reach the right-side expr of the new qual, we are done. We give up + * when we can't expand the equalexprs list any more. */ equalexprs = list_make1(newleft); do diff --git a/src/backend/optimizer/plan/planagg.c b/src/backend/optimizer/plan/planagg.c index f2002a5228..7c2f0211f1 100644 --- a/src/backend/optimizer/plan/planagg.c +++ b/src/backend/optimizer/plan/planagg.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/plan/planagg.c,v 1.9 2005/09/21 19:15:27 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/plan/planagg.c,v 1.10 2005/10/15 02:49:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -43,12 +43,12 @@ typedef struct static bool find_minmax_aggs_walker(Node *node, List **context); static bool build_minmax_path(PlannerInfo *root, RelOptInfo *rel, - MinMaxAggInfo *info); + MinMaxAggInfo *info); static ScanDirection match_agg_to_index_col(MinMaxAggInfo *info, - IndexOptInfo *index, int indexcol); + IndexOptInfo *index, int indexcol); static void make_agg_subplan(PlannerInfo *root, MinMaxAggInfo *info, - List *constant_quals); -static Node *replace_aggs_with_params_mutator(Node *node, List **context); + List *constant_quals); +static Node *replace_aggs_with_params_mutator(Node *node, List **context); static Oid fetch_agg_sort_op(Oid aggfnoid); @@ -62,7 +62,7 @@ static Oid fetch_agg_sort_op(Oid aggfnoid); * generic scan-all-the-rows plan. * * We are passed the preprocessed tlist, and the best path - * devised for computing the input of a standard Agg node. If we are able + * devised for computing the input of a standard Agg node. If we are able * to optimize all the aggregates, and the result is estimated to be cheaper * than the generic aggregate method, then generate and return a Plan that * does it that way. Otherwise, return NULL. @@ -87,24 +87,24 @@ optimize_minmax_aggregates(PlannerInfo *root, List *tlist, Path *best_path) if (!parse->hasAggs) return NULL; - Assert(!parse->setOperations); /* shouldn't get here if a setop */ - Assert(parse->rowMarks == NIL); /* nor if FOR UPDATE */ + Assert(!parse->setOperations); /* shouldn't get here if a setop */ + Assert(parse->rowMarks == NIL); /* nor if FOR UPDATE */ /* * Reject unoptimizable cases. * - * We don't handle GROUP BY, because our current implementations of - * grouping require looking at all the rows anyway, and so there's not - * much point in optimizing MIN/MAX. + * We don't handle GROUP BY, because our current implementations of grouping + * require looking at all the rows anyway, and so there's not much point + * in optimizing MIN/MAX. */ if (parse->groupClause) return NULL; /* - * We also restrict the query to reference exactly one table, since - * join conditions can't be handled reasonably. (We could perhaps - * handle a query containing cartesian-product joins, but it hardly - * seems worth the trouble.) + * We also restrict the query to reference exactly one table, since join + * conditions can't be handled reasonably. (We could perhaps handle a + * query containing cartesian-product joins, but it hardly seems worth the + * trouble.) */ Assert(parse->jointree != NULL && IsA(parse->jointree, FromExpr)); if (list_length(parse->jointree->fromlist) != 1) @@ -118,8 +118,8 @@ optimize_minmax_aggregates(PlannerInfo *root, List *tlist, Path *best_path) rel = find_base_rel(root, rtr->rtindex); /* - * Also reject cases with subplans or volatile functions in WHERE. - * This may be overly paranoid, but it's not entirely clear if the + * Also reject cases with subplans or volatile functions in WHERE. This + * may be overly paranoid, but it's not entirely clear if the * transformation is safe then. */ if (contain_subplans(parse->jointree->quals) || @@ -127,17 +127,16 @@ optimize_minmax_aggregates(PlannerInfo *root, List *tlist, Path *best_path) return NULL; /* - * Since this optimization is not applicable all that often, we want - * to fall out before doing very much work if possible. Therefore - * we do the work in several passes. The first pass scans the tlist - * and HAVING qual to find all the aggregates and verify that - * each of them is a MIN/MAX aggregate. If that succeeds, the second - * pass looks at each aggregate to see if it is optimizable; if so - * we make an IndexPath describing how we would scan it. (We do not - * try to optimize if only some aggs are optimizable, since that means - * we'll have to scan all the rows anyway.) If that succeeds, we have - * enough info to compare costs against the generic implementation. - * Only if that test passes do we build a Plan. + * Since this optimization is not applicable all that often, we want to + * fall out before doing very much work if possible. Therefore we do the + * work in several passes. The first pass scans the tlist and HAVING qual + * to find all the aggregates and verify that each of them is a MIN/MAX + * aggregate. If that succeeds, the second pass looks at each aggregate + * to see if it is optimizable; if so we make an IndexPath describing how + * we would scan it. (We do not try to optimize if only some aggs are + * optimizable, since that means we'll have to scan all the rows anyway.) + * If that succeeds, we have enough info to compare costs against the + * generic implementation. Only if that test passes do we build a Plan. */ /* Pass 1: find all the aggregates */ @@ -161,9 +160,9 @@ optimize_minmax_aggregates(PlannerInfo *root, List *tlist, Path *best_path) /* * Make the cost comparison. * - * Note that we don't include evaluation cost of the tlist here; - * this is OK since it isn't included in best_path's cost either, - * and should be the same in either case. + * Note that we don't include evaluation cost of the tlist here; this is OK + * since it isn't included in best_path's cost either, and should be the + * same in either case. */ cost_agg(&agg_p, root, AGG_PLAIN, list_length(aggs_list), 0, 0, @@ -174,13 +173,13 @@ optimize_minmax_aggregates(PlannerInfo *root, List *tlist, Path *best_path) return NULL; /* too expensive */ /* - * OK, we are going to generate an optimized plan. The first thing we - * need to do is look for any non-variable WHERE clauses that query_planner - * might have removed from the basic plan. (Normal WHERE clauses will - * be properly incorporated into the sub-plans by create_plan.) If there - * are any, they will be in a gating Result node atop the best_path. - * They have to be incorporated into a gating Result in each sub-plan - * in order to produce the semantically correct result. + * OK, we are going to generate an optimized plan. The first thing we + * need to do is look for any non-variable WHERE clauses that + * query_planner might have removed from the basic plan. (Normal WHERE + * clauses will be properly incorporated into the sub-plans by + * create_plan.) If there are any, they will be in a gating Result node + * atop the best_path. They have to be incorporated into a gating Result + * in each sub-plan in order to produce the semantically correct result. */ if (IsA(best_path, ResultPath)) { @@ -275,8 +274,8 @@ find_minmax_aggs_walker(Node *node, List **context) *context = lappend(*context, info); /* - * We need not recurse into the argument, since it can't contain - * any aggregates. + * We need not recurse into the argument, since it can't contain any + * aggregates. */ return false; } @@ -325,8 +324,8 @@ build_minmax_path(PlannerInfo *root, RelOptInfo *rel, MinMaxAggInfo *info) /* * Look for a match to one of the index columns. (In a stupidly - * designed index, there could be multiple matches, but we only - * care about the first one.) + * designed index, there could be multiple matches, but we only care + * about the first one.) */ for (indexcol = 0; indexcol < index->ncolumns; indexcol++) { @@ -340,12 +339,12 @@ build_minmax_path(PlannerInfo *root, RelOptInfo *rel, MinMaxAggInfo *info) /* * If the match is not at the first index column, we have to verify * that there are "x = something" restrictions on all the earlier - * index columns. Since we'll need the restrictclauses list anyway - * to build the path, it's convenient to extract that first and then - * look through it for the equality restrictions. + * index columns. Since we'll need the restrictclauses list anyway to + * build the path, it's convenient to extract that first and then look + * through it for the equality restrictions. */ restrictclauses = group_clauses_by_indexkey(index, - index->rel->baserestrictinfo, + index->rel->baserestrictinfo, NIL, NULL, &found_clause); @@ -354,8 +353,8 @@ build_minmax_path(PlannerInfo *root, RelOptInfo *rel, MinMaxAggInfo *info) continue; /* definitely haven't got enough */ for (prevcol = 0; prevcol < indexcol; prevcol++) { - List *rinfos = (List *) list_nth(restrictclauses, prevcol); - ListCell *ll; + List *rinfos = (List *) list_nth(restrictclauses, prevcol); + ListCell *ll; foreach(ll, rinfos) { @@ -453,9 +452,9 @@ make_agg_subplan(PlannerInfo *root, MinMaxAggInfo *info, List *constant_quals) NullTest *ntest; /* - * Generate a suitably modified query. Much of the work here is - * probably unnecessary in the normal case, but we want to make it look - * good if someone tries to EXPLAIN the result. + * Generate a suitably modified query. Much of the work here is probably + * unnecessary in the normal case, but we want to make it look good if + * someone tries to EXPLAIN the result. */ memcpy(&subroot, root, sizeof(PlannerInfo)); subroot.parse = subparse = (Query *) copyObject(root->parse); @@ -489,18 +488,17 @@ make_agg_subplan(PlannerInfo *root, MinMaxAggInfo *info, List *constant_quals) false, true); /* - * Generate the plan for the subquery. We already have a Path for - * the basic indexscan, but we have to convert it to a Plan and - * attach a LIMIT node above it. We might need a gating Result, too, - * to handle any non-variable qual clauses. + * Generate the plan for the subquery. We already have a Path for the + * basic indexscan, but we have to convert it to a Plan and attach a LIMIT + * node above it. We might need a gating Result, too, to handle any + * non-variable qual clauses. * - * Also we must add a "WHERE foo IS NOT NULL" restriction to the - * indexscan, to be sure we don't return a NULL, which'd be contrary - * to the standard behavior of MIN/MAX. XXX ideally this should be - * done earlier, so that the selectivity of the restriction could be - * included in our cost estimates. But that looks painful, and in - * most cases the fraction of NULLs isn't high enough to change the - * decision. + * Also we must add a "WHERE foo IS NOT NULL" restriction to the indexscan, + * to be sure we don't return a NULL, which'd be contrary to the standard + * behavior of MIN/MAX. XXX ideally this should be done earlier, so that + * the selectivity of the restriction could be included in our cost + * estimates. But that looks painful, and in most cases the fraction of + * NULLs isn't high enough to change the decision. */ plan = create_plan(&subroot, (Path *) info->path); @@ -517,7 +515,7 @@ make_agg_subplan(PlannerInfo *root, MinMaxAggInfo *info, List *constant_quals) copyObject(constant_quals), plan); - plan = (Plan *) make_limit(plan, + plan = (Plan *) make_limit(plan, subparse->limitOffset, subparse->limitCount, 0, 1); @@ -534,7 +532,7 @@ make_agg_subplan(PlannerInfo *root, MinMaxAggInfo *info, List *constant_quals) * Replace original aggregate calls with subplan output Params */ static Node * -replace_aggs_with_params_mutator(Node *node, List **context) +replace_aggs_with_params_mutator(Node *node, List **context) { if (node == NULL) return NULL; diff --git a/src/backend/optimizer/plan/planmain.c b/src/backend/optimizer/plan/planmain.c index 24d53be9e9..ecbf44400c 100644 --- a/src/backend/optimizer/plan/planmain.c +++ b/src/backend/optimizer/plan/planmain.c @@ -14,7 +14,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/plan/planmain.c,v 1.88 2005/09/28 21:17:02 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/plan/planmain.c,v 1.89 2005/10/15 02:49:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -57,7 +57,7 @@ * does not use grouping * * Note: the PlannerInfo node also includes a query_pathkeys field, which is - * both an input and an output of query_planner(). The input value signals + * both an input and an output of query_planner(). The input value signals * query_planner that the indicated sort order is wanted in the final output * plan. But this value has not yet been "canonicalized", since the needed * info does not get computed until we scan the qual clauses. We canonicalize @@ -99,7 +99,7 @@ query_planner(PlannerInfo *root, List *tlist, double tuple_fraction, if (parse->jointree->fromlist == NIL) { *cheapest_path = (Path *) create_result_path(NULL, NULL, - (List *) parse->jointree->quals); + (List *) parse->jointree->quals); *sorted_path = NULL; return; } @@ -107,21 +107,21 @@ query_planner(PlannerInfo *root, List *tlist, double tuple_fraction, /* * Pull out any non-variable WHERE clauses so these can be put in a * toplevel "Result" node, where they will gate execution of the whole - * plan (the Result will not invoke its descendant plan unless the - * quals are true). Note that any *really* non-variable quals will - * have been optimized away by eval_const_expressions(). What we're - * mostly interested in here is quals that depend only on outer-level - * vars, although if the qual reduces to "WHERE FALSE" this path will - * also be taken. + * plan (the Result will not invoke its descendant plan unless the quals + * are true). Note that any *really* non-variable quals will have been + * optimized away by eval_const_expressions(). What we're mostly + * interested in here is quals that depend only on outer-level vars, + * although if the qual reduces to "WHERE FALSE" this path will also be + * taken. */ parse->jointree->quals = (Node *) pull_constant_clauses((List *) parse->jointree->quals, &constant_quals); /* - * Init planner lists to empty. We create the base_rel_array with a - * size that will be sufficient if no pullups or inheritance additions - * happen ... otherwise it will be enlarged as needed. + * Init planner lists to empty. We create the base_rel_array with a size + * that will be sufficient if no pullups or inheritance additions happen + * ... otherwise it will be enlarged as needed. * * NOTE: in_info_list was set up by subquery_planner, do not touch here */ @@ -141,33 +141,32 @@ query_planner(PlannerInfo *root, List *tlist, double tuple_fraction, add_base_rels_to_query(root, (Node *) parse->jointree); /* - * Examine the targetlist and qualifications, adding entries to - * baserel targetlists for all referenced Vars. Restrict and join - * clauses are added to appropriate lists belonging to the mentioned - * relations. We also build lists of equijoined keys for pathkey - * construction. + * Examine the targetlist and qualifications, adding entries to baserel + * targetlists for all referenced Vars. Restrict and join clauses are + * added to appropriate lists belonging to the mentioned relations. We + * also build lists of equijoined keys for pathkey construction. * - * Note: all subplan nodes will have "flat" (var-only) tlists. This - * implies that all expression evaluations are done at the root of the - * plan tree. Once upon a time there was code to try to push - * expensive function calls down to lower plan nodes, but that's dead - * code and has been for a long time... + * Note: all subplan nodes will have "flat" (var-only) tlists. This implies + * that all expression evaluations are done at the root of the plan tree. + * Once upon a time there was code to try to push expensive function calls + * down to lower plan nodes, but that's dead code and has been for a long + * time... */ build_base_rel_tlists(root, tlist); (void) distribute_quals_to_rels(root, (Node *) parse->jointree, false); /* - * Use the completed lists of equijoined keys to deduce any implied - * but unstated equalities (for example, A=B and B=C imply A=C). + * Use the completed lists of equijoined keys to deduce any implied but + * unstated equalities (for example, A=B and B=C imply A=C). */ generate_implied_equalities(root); /* - * We should now have all the pathkey equivalence sets built, so it's - * now possible to convert the requested query_pathkeys to canonical - * form. Also canonicalize the groupClause and sortClause pathkeys - * for use later. + * We should now have all the pathkey equivalence sets built, so it's now + * possible to convert the requested query_pathkeys to canonical form. + * Also canonicalize the groupClause and sortClause pathkeys for use + * later. */ root->query_pathkeys = canonicalize_pathkeys(root, root->query_pathkeys); root->group_pathkeys = canonicalize_pathkeys(root, root->group_pathkeys); @@ -182,13 +181,13 @@ query_planner(PlannerInfo *root, List *tlist, double tuple_fraction, elog(ERROR, "failed to construct the join relation"); /* - * If there's grouping going on, estimate the number of result groups. - * We couldn't do this any earlier because it depends on relation size + * If there's grouping going on, estimate the number of result groups. We + * couldn't do this any earlier because it depends on relation size * estimates that were set up above. * - * Then convert tuple_fraction to fractional form if it is absolute, - * and adjust it based on the knowledge that grouping_planner will be - * doing grouping or aggregation work with our result. + * Then convert tuple_fraction to fractional form if it is absolute, and + * adjust it based on the knowledge that grouping_planner will be doing + * grouping or aggregation work with our result. * * This introduces some undesirable coupling between this code and * grouping_planner, but the alternatives seem even uglier; we couldn't @@ -205,18 +204,18 @@ query_planner(PlannerInfo *root, List *tlist, double tuple_fraction, final_rel->rows); /* - * In GROUP BY mode, an absolute LIMIT is relative to the number - * of groups not the number of tuples. If the caller gave us - * a fraction, keep it as-is. (In both cases, we are effectively - * assuming that all the groups are about the same size.) + * In GROUP BY mode, an absolute LIMIT is relative to the number of + * groups not the number of tuples. If the caller gave us a fraction, + * keep it as-is. (In both cases, we are effectively assuming that + * all the groups are about the same size.) */ if (tuple_fraction >= 1.0) tuple_fraction /= *num_groups; /* * If both GROUP BY and ORDER BY are specified, we will need two - * levels of sort --- and, therefore, certainly need to read all - * the tuples --- unless ORDER BY is a subset of GROUP BY. + * levels of sort --- and, therefore, certainly need to read all the + * tuples --- unless ORDER BY is a subset of GROUP BY. */ if (parse->groupClause && parse->sortClause && !pathkeys_contained_in(root->sort_pathkeys, root->group_pathkeys)) @@ -225,8 +224,8 @@ query_planner(PlannerInfo *root, List *tlist, double tuple_fraction, else if (parse->hasAggs || root->hasHavingQual) { /* - * Ungrouped aggregate will certainly want to read all the tuples, - * and it will deliver a single result row (so leave *num_groups 1). + * Ungrouped aggregate will certainly want to read all the tuples, and + * it will deliver a single result row (so leave *num_groups 1). */ tuple_fraction = 0.0; } @@ -234,11 +233,11 @@ query_planner(PlannerInfo *root, List *tlist, double tuple_fraction, { /* * Since there was no grouping or aggregation, it's reasonable to - * assume the UNIQUE filter has effects comparable to GROUP BY. - * Return the estimated number of output rows for use by caller. - * (If DISTINCT is used with grouping, we ignore its effects for - * rowcount estimation purposes; this amounts to assuming the grouped - * rows are distinct already.) + * assume the UNIQUE filter has effects comparable to GROUP BY. Return + * the estimated number of output rows for use by caller. (If DISTINCT + * is used with grouping, we ignore its effects for rowcount + * estimation purposes; this amounts to assuming the grouped rows are + * distinct already.) */ List *distinctExprs; @@ -257,26 +256,26 @@ query_planner(PlannerInfo *root, List *tlist, double tuple_fraction, else { /* - * Plain non-grouped, non-aggregated query: an absolute tuple - * fraction can be divided by the number of tuples. + * Plain non-grouped, non-aggregated query: an absolute tuple fraction + * can be divided by the number of tuples. */ if (tuple_fraction >= 1.0) tuple_fraction /= final_rel->rows; } /* - * Pick out the cheapest-total path and the cheapest presorted path - * for the requested pathkeys (if there is one). We should take the - * tuple fraction into account when selecting the cheapest presorted - * path, but not when selecting the cheapest-total path, since if we - * have to sort then we'll have to fetch all the tuples. (But there's - * a special case: if query_pathkeys is NIL, meaning order doesn't - * matter, then the "cheapest presorted" path will be the cheapest - * overall for the tuple fraction.) + * Pick out the cheapest-total path and the cheapest presorted path for + * the requested pathkeys (if there is one). We should take the tuple + * fraction into account when selecting the cheapest presorted path, but + * not when selecting the cheapest-total path, since if we have to sort + * then we'll have to fetch all the tuples. (But there's a special case: + * if query_pathkeys is NIL, meaning order doesn't matter, then the + * "cheapest presorted" path will be the cheapest overall for the tuple + * fraction.) * - * The cheapest-total path is also the one to use if grouping_planner - * decides to use hashed aggregation, so we return it separately even - * if this routine thinks the presorted path is the winner. + * The cheapest-total path is also the one to use if grouping_planner decides + * to use hashed aggregation, so we return it separately even if this + * routine thinks the presorted path is the winner. */ cheapestpath = final_rel->cheapest_total_path; @@ -291,8 +290,8 @@ query_planner(PlannerInfo *root, List *tlist, double tuple_fraction, /* * Forget about the presorted path if it would be cheaper to sort the - * cheapest-total path. Here we need consider only the behavior at - * the tuple fraction point. + * cheapest-total path. Here we need consider only the behavior at the + * tuple fraction point. */ if (sortedpath) { @@ -323,8 +322,7 @@ query_planner(PlannerInfo *root, List *tlist, double tuple_fraction, } /* - * If we have constant quals, add a toplevel Result step to process - * them. + * If we have constant quals, add a toplevel Result step to process them. */ if (constant_quals) { diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c index ace53d692f..762dfb4b64 100644 --- a/src/backend/optimizer/plan/planner.c +++ b/src/backend/optimizer/plan/planner.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/plan/planner.c,v 1.193 2005/09/24 22:54:37 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/plan/planner.c,v 1.194 2005/10/15 02:49:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -59,8 +59,8 @@ static void preprocess_qual_conditions(PlannerInfo *root, Node *jtnode); static Plan *inheritance_planner(PlannerInfo *root, List *inheritlist); static Plan *grouping_planner(PlannerInfo *root, double tuple_fraction); static double preprocess_limit(PlannerInfo *root, - double tuple_fraction, - int *offset_est, int *count_est); + double tuple_fraction, + int *offset_est, int *count_est); static bool choose_hashed_grouping(PlannerInfo *root, double tuple_fraction, Path *cheapest_path, Path *sorted_path, double dNumGroups, AggClauseCounts *agg_counts); @@ -95,14 +95,13 @@ planner(Query *parse, bool isCursor, int cursorOptions, * these global state variables must be saved and restored. * * Query level and the param list cannot be moved into the per-query - * PlannerInfo structure since their whole purpose is communication - * across multiple sub-queries. Also, boundParams is explicitly info - * from outside the query, and so is likewise better handled as a global - * variable. + * PlannerInfo structure since their whole purpose is communication across + * multiple sub-queries. Also, boundParams is explicitly info from outside + * the query, and so is likewise better handled as a global variable. * - * Note we do NOT save and restore PlannerPlanId: it exists to assign - * unique IDs to SubPlan nodes, and we want those IDs to be unique for - * the life of a backend. Also, PlannerInitPlan is saved/restored in + * Note we do NOT save and restore PlannerPlanId: it exists to assign unique + * IDs to SubPlan nodes, and we want those IDs to be unique for the life + * of a backend. Also, PlannerInitPlan is saved/restored in * subquery_planner, not here. */ save_PlannerQueryLevel = PlannerQueryLevel; @@ -118,10 +117,10 @@ planner(Query *parse, bool isCursor, int cursorOptions, if (isCursor) { /* - * We have no real idea how many tuples the user will ultimately - * FETCH from a cursor, but it seems a good bet that he doesn't - * want 'em all. Optimize for 10% retrieval (you gotta better - * number? Should this be a SETtable parameter?) + * We have no real idea how many tuples the user will ultimately FETCH + * from a cursor, but it seems a good bet that he doesn't want 'em + * all. Optimize for 10% retrieval (you gotta better number? Should + * this be a SETtable parameter?) */ tuple_fraction = 0.10; } @@ -207,10 +206,10 @@ subquery_planner(Query *parse, double tuple_fraction, root->parse = parse; /* - * Look for IN clauses at the top level of WHERE, and transform them - * into joins. Note that this step only handles IN clauses originally - * at top level of WHERE; if we pull up any subqueries in the next - * step, their INs are processed just before pulling them up. + * Look for IN clauses at the top level of WHERE, and transform them into + * joins. Note that this step only handles IN clauses originally at top + * level of WHERE; if we pull up any subqueries in the next step, their + * INs are processed just before pulling them up. */ root->in_info_list = NIL; if (parse->hasSubLinks) @@ -225,14 +224,14 @@ subquery_planner(Query *parse, double tuple_fraction, pull_up_subqueries(root, (Node *) parse->jointree, false); /* - * Detect whether any rangetable entries are RTE_JOIN kind; if not, we - * can avoid the expense of doing flatten_join_alias_vars(). Also - * check for outer joins --- if none, we can skip reduce_outer_joins() - * and some other processing. This must be done after we have done + * Detect whether any rangetable entries are RTE_JOIN kind; if not, we can + * avoid the expense of doing flatten_join_alias_vars(). Also check for + * outer joins --- if none, we can skip reduce_outer_joins() and some + * other processing. This must be done after we have done * pull_up_subqueries, of course. * * Note: if reduce_outer_joins manages to eliminate all outer joins, - * root->hasOuterJoins is not reset currently. This is OK since its + * root->hasOuterJoins is not reset currently. This is OK since its * purpose is merely to suppress unnecessary processing in simple cases. */ root->hasJoinRTEs = false; @@ -255,8 +254,8 @@ subquery_planner(Query *parse, double tuple_fraction, /* * Set hasHavingQual to remember if HAVING clause is present. Needed - * because preprocess_expression will reduce a constant-true condition - * to an empty qual list ... but "HAVING TRUE" is not a semantic no-op. + * because preprocess_expression will reduce a constant-true condition to + * an empty qual list ... but "HAVING TRUE" is not a semantic no-op. */ root->hasHavingQual = (parse->havingQual != NULL); @@ -292,29 +291,29 @@ subquery_planner(Query *parse, double tuple_fraction, } /* - * In some cases we may want to transfer a HAVING clause into WHERE. - * We cannot do so if the HAVING clause contains aggregates (obviously) - * or volatile functions (since a HAVING clause is supposed to be executed + * In some cases we may want to transfer a HAVING clause into WHERE. We + * cannot do so if the HAVING clause contains aggregates (obviously) or + * volatile functions (since a HAVING clause is supposed to be executed * only once per group). Also, it may be that the clause is so expensive * to execute that we're better off doing it only once per group, despite * the loss of selectivity. This is hard to estimate short of doing the * entire planning process twice, so we use a heuristic: clauses - * containing subplans are left in HAVING. Otherwise, we move or copy - * the HAVING clause into WHERE, in hopes of eliminating tuples before + * containing subplans are left in HAVING. Otherwise, we move or copy the + * HAVING clause into WHERE, in hopes of eliminating tuples before * aggregation instead of after. * - * If the query has explicit grouping then we can simply move such a - * clause into WHERE; any group that fails the clause will not be - * in the output because none of its tuples will reach the grouping - * or aggregation stage. Otherwise we must have a degenerate - * (variable-free) HAVING clause, which we put in WHERE so that - * query_planner() can use it in a gating Result node, but also keep - * in HAVING to ensure that we don't emit a bogus aggregated row. - * (This could be done better, but it seems not worth optimizing.) + * If the query has explicit grouping then we can simply move such a clause + * into WHERE; any group that fails the clause will not be in the output + * because none of its tuples will reach the grouping or aggregation + * stage. Otherwise we must have a degenerate (variable-free) HAVING + * clause, which we put in WHERE so that query_planner() can use it in a + * gating Result node, but also keep in HAVING to ensure that we don't + * emit a bogus aggregated row. (This could be done better, but it seems + * not worth optimizing.) * * Note that both havingQual and parse->jointree->quals are in - * implicitly-ANDed-list form at this point, even though they are - * declared as Node *. + * implicitly-ANDed-list form at this point, even though they are declared + * as Node *. */ newHaving = NIL; foreach(l, (List *) parse->havingQual) @@ -346,28 +345,27 @@ subquery_planner(Query *parse, double tuple_fraction, parse->havingQual = (Node *) newHaving; /* - * If we have any outer joins, try to reduce them to plain inner - * joins. This step is most easily done after we've done expression + * If we have any outer joins, try to reduce them to plain inner joins. + * This step is most easily done after we've done expression * preprocessing. */ if (root->hasOuterJoins) reduce_outer_joins(root); /* - * See if we can simplify the jointree; opportunities for this may - * come from having pulled up subqueries, or from flattening explicit - * JOIN syntax. We must do this after flattening JOIN alias - * variables, since eliminating explicit JOIN nodes from the jointree - * will cause get_relids_for_join() to fail. But it should happen - * after reduce_outer_joins, anyway. + * See if we can simplify the jointree; opportunities for this may come + * from having pulled up subqueries, or from flattening explicit JOIN + * syntax. We must do this after flattening JOIN alias variables, since + * eliminating explicit JOIN nodes from the jointree will cause + * get_relids_for_join() to fail. But it should happen after + * reduce_outer_joins, anyway. */ parse->jointree = (FromExpr *) simplify_jointree(root, (Node *) parse->jointree); /* - * Do the main planning. If we have an inherited target relation, - * that needs special processing, else go straight to - * grouping_planner. + * Do the main planning. If we have an inherited target relation, that + * needs special processing, else go straight to grouping_planner. */ if (parse->resultRelation && (lst = expand_inherited_rtentry(root, parse->resultRelation)) != NIL) @@ -377,8 +375,8 @@ subquery_planner(Query *parse, double tuple_fraction, /* * If any subplans were generated, or if we're inside a subplan, build - * initPlan list and extParam/allParam sets for plan nodes, and attach - * the initPlans to the top plan node. + * initPlan list and extParam/allParam sets for plan nodes, and attach the + * initPlans to the top plan node. */ if (PlannerPlanId != saved_planid || PlannerQueryLevel > 1) SS_finalize_plan(plan, parse->rtable); @@ -405,9 +403,9 @@ static Node * preprocess_expression(PlannerInfo *root, Node *expr, int kind) { /* - * Fall out quickly if expression is empty. This occurs often enough - * to be worth checking. Note that null->null is the correct conversion - * for implicit-AND result format, too. + * Fall out quickly if expression is empty. This occurs often enough to + * be worth checking. Note that null->null is the correct conversion for + * implicit-AND result format, too. */ if (expr == NULL) return NULL; @@ -415,8 +413,7 @@ preprocess_expression(PlannerInfo *root, Node *expr, int kind) /* * If the query has any join RTEs, replace join alias variables with * base-relation variables. We must do this before sublink processing, - * else sublinks expanded out from join aliases wouldn't get - * processed. + * else sublinks expanded out from join aliases wouldn't get processed. */ if (root->hasJoinRTEs) expr = flatten_join_alias_vars(root, expr); @@ -429,13 +426,13 @@ preprocess_expression(PlannerInfo *root, Node *expr, int kind) * careful to maintain AND/OR flatness --- that is, do not generate a tree * with AND directly under AND, nor OR directly under OR. * - * Because this is a relatively expensive process, we skip it when the - * query is trivial, such as "SELECT 2+2;" or "INSERT ... VALUES()". - * The expression will only be evaluated once anyway, so no point in + * Because this is a relatively expensive process, we skip it when the query + * is trivial, such as "SELECT 2+2;" or "INSERT ... VALUES()". The + * expression will only be evaluated once anyway, so no point in * pre-simplifying; we can't execute it any faster than the executor can, * and we will waste cycles copying the tree. Notice however that we - * still must do it for quals (to get AND/OR flatness); and if we are - * in a subquery we should not assume it will be done only once. + * still must do it for quals (to get AND/OR flatness); and if we are in a + * subquery we should not assume it will be done only once. */ if (root->parse->jointree->fromlist != NIL || kind == EXPRKIND_QUAL || @@ -460,8 +457,8 @@ preprocess_expression(PlannerInfo *root, Node *expr, int kind) expr = SS_process_sublinks(expr, (kind == EXPRKIND_QUAL)); /* - * XXX do not insert anything here unless you have grokked the - * comments in SS_replace_correlation_vars ... + * XXX do not insert anything here unless you have grokked the comments in + * SS_replace_correlation_vars ... */ /* Replace uplevel vars with Param nodes */ @@ -469,9 +466,9 @@ preprocess_expression(PlannerInfo *root, Node *expr, int kind) expr = SS_replace_correlation_vars(expr); /* - * If it's a qual or havingQual, convert it to implicit-AND format. - * (We don't want to do this before eval_const_expressions, since the - * latter would be unable to simplify a top-level AND correctly. Also, + * If it's a qual or havingQual, convert it to implicit-AND format. (We + * don't want to do this before eval_const_expressions, since the latter + * would be unable to simplify a top-level AND correctly. Also, * SS_process_sublinks expects explicit-AND format.) */ if (kind == EXPRKIND_QUAL) @@ -557,9 +554,9 @@ inheritance_planner(PlannerInfo *root, List *inheritlist) Plan *subplan; /* - * Generate modified query with this rel as target. We have to - * be prepared to translate varnos in in_info_list as well as in - * the Query proper. + * Generate modified query with this rel as target. We have to be + * prepared to translate varnos in in_info_list as well as in the + * Query proper. */ memcpy(&subroot, root, sizeof(PlannerInfo)); subroot.parse = (Query *) @@ -580,26 +577,26 @@ inheritance_planner(PlannerInfo *root, List *inheritlist) * XXX my goodness this next bit is ugly. Really need to think about * ways to rein in planner's habit of scribbling on its input. * - * Planning of the subquery might have modified the rangetable, - * either by addition of RTEs due to expansion of inherited source - * tables, or by changes of the Query structures inside subquery - * RTEs. We have to ensure that this gets propagated back to the - * master copy. However, if we aren't done planning yet, we also - * need to ensure that subsequent calls to grouping_planner have - * virgin sub-Queries to work from. So, if we are at the last - * list entry, just copy the subquery rangetable back to the master - * copy; if we are not, then extend the master copy by adding - * whatever the subquery added. (We assume these added entries - * will go untouched by the future grouping_planner calls. We are - * also effectively assuming that sub-Queries will get planned - * identically each time, or at least that the impacts on their - * rangetables will be the same each time. Did I say this is ugly?) + * Planning of the subquery might have modified the rangetable, either by + * addition of RTEs due to expansion of inherited source tables, or by + * changes of the Query structures inside subquery RTEs. We have to + * ensure that this gets propagated back to the master copy. However, + * if we aren't done planning yet, we also need to ensure that + * subsequent calls to grouping_planner have virgin sub-Queries to + * work from. So, if we are at the last list entry, just copy the + * subquery rangetable back to the master copy; if we are not, then + * extend the master copy by adding whatever the subquery added. (We + * assume these added entries will go untouched by the future + * grouping_planner calls. We are also effectively assuming that + * sub-Queries will get planned identically each time, or at least + * that the impacts on their rangetables will be the same each time. + * Did I say this is ugly?) */ if (lnext(l) == NULL) parse->rtable = subroot.parse->rtable; else { - int subrtlength = list_length(subroot.parse->rtable); + int subrtlength = list_length(subroot.parse->rtable); if (subrtlength > mainrtlength) { @@ -666,38 +663,37 @@ grouping_planner(PlannerInfo *root, double tuple_fraction) List *set_sortclauses; /* - * If there's a top-level ORDER BY, assume we have to fetch all - * the tuples. This might seem too simplistic given all the - * hackery below to possibly avoid the sort ... but a nonzero - * tuple_fraction is only of use to plan_set_operations() when - * the setop is UNION ALL, and the result of UNION ALL is always - * unsorted. + * If there's a top-level ORDER BY, assume we have to fetch all the + * tuples. This might seem too simplistic given all the hackery below + * to possibly avoid the sort ... but a nonzero tuple_fraction is only + * of use to plan_set_operations() when the setop is UNION ALL, and + * the result of UNION ALL is always unsorted. */ if (parse->sortClause) tuple_fraction = 0.0; /* - * Construct the plan for set operations. The result will not - * need any work except perhaps a top-level sort and/or LIMIT. + * Construct the plan for set operations. The result will not need + * any work except perhaps a top-level sort and/or LIMIT. */ result_plan = plan_set_operations(root, tuple_fraction, &set_sortclauses); /* - * Calculate pathkeys representing the sort order (if any) of the - * set operation's result. We have to do this before overwriting - * the sort key information... + * Calculate pathkeys representing the sort order (if any) of the set + * operation's result. We have to do this before overwriting the sort + * key information... */ current_pathkeys = make_pathkeys_for_sortclauses(set_sortclauses, - result_plan->targetlist); + result_plan->targetlist); current_pathkeys = canonicalize_pathkeys(root, current_pathkeys); /* - * We should not need to call preprocess_targetlist, since we must - * be in a SELECT query node. Instead, use the targetlist - * returned by plan_set_operations (since this tells whether it - * returned any resjunk columns!), and transfer any sort key - * information from the original tlist. + * We should not need to call preprocess_targetlist, since we must be + * in a SELECT query node. Instead, use the targetlist returned by + * plan_set_operations (since this tells whether it returned any + * resjunk columns!), and transfer any sort key information from the + * original tlist. */ Assert(parse->commandType == CMD_SELECT); @@ -741,11 +737,11 @@ grouping_planner(PlannerInfo *root, double tuple_fraction) tlist = preprocess_targetlist(root, tlist); /* - * Generate appropriate target list for subplan; may be different - * from tlist if grouping or aggregation is needed. + * Generate appropriate target list for subplan; may be different from + * tlist if grouping or aggregation is needed. */ sub_tlist = make_subplanTargetList(root, tlist, - &groupColIdx, &need_tlist_eval); + &groupColIdx, &need_tlist_eval); /* * Calculate pathkeys that represent grouping/ordering requirements. @@ -763,10 +759,10 @@ grouping_planner(PlannerInfo *root, double tuple_fraction) * Note: we do not attempt to detect duplicate aggregates here; a * somewhat-overestimated count is okay for our present purposes. * - * Note: think not that we can turn off hasAggs if we find no aggs. - * It is possible for constant-expression simplification to remove - * all explicit references to aggs, but we still have to follow - * the aggregate semantics (eg, producing only one output row). + * Note: think not that we can turn off hasAggs if we find no aggs. It is + * possible for constant-expression simplification to remove all + * explicit references to aggs, but we still have to follow the + * aggregate semantics (eg, producing only one output row). */ if (parse->hasAggs) { @@ -777,13 +773,12 @@ grouping_planner(PlannerInfo *root, double tuple_fraction) /* * Figure out whether we need a sorted result from query_planner. * - * If we have a GROUP BY clause, then we want a result sorted - * properly for grouping. Otherwise, if there is an ORDER BY - * clause, we want to sort by the ORDER BY clause. (Note: if we - * have both, and ORDER BY is a superset of GROUP BY, it would be - * tempting to request sort by ORDER BY --- but that might just - * leave us failing to exploit an available sort order at all. - * Needs more thought...) + * If we have a GROUP BY clause, then we want a result sorted properly + * for grouping. Otherwise, if there is an ORDER BY clause, we want + * to sort by the ORDER BY clause. (Note: if we have both, and ORDER + * BY is a superset of GROUP BY, it would be tempting to request sort + * by ORDER BY --- but that might just leave us failing to exploit an + * available sort order at all. Needs more thought...) */ if (parse->groupClause) root->query_pathkeys = root->group_pathkeys; @@ -793,10 +788,10 @@ grouping_planner(PlannerInfo *root, double tuple_fraction) root->query_pathkeys = NIL; /* - * Generate the best unsorted and presorted paths for this Query - * (but note there may not be any presorted path). query_planner - * will also estimate the number of groups in the query, and - * canonicalize all the pathkeys. + * Generate the best unsorted and presorted paths for this Query (but + * note there may not be any presorted path). query_planner will also + * estimate the number of groups in the query, and canonicalize all + * the pathkeys. */ query_planner(root, sub_tlist, tuple_fraction, &cheapest_path, &sorted_path, &dNumGroups); @@ -820,8 +815,8 @@ grouping_planner(PlannerInfo *root, double tuple_fraction) /* * Select the best path. If we are doing hashed grouping, we will - * always read all the input tuples, so use the cheapest-total - * path. Otherwise, trust query_planner's decision about which to use. + * always read all the input tuples, so use the cheapest-total path. + * Otherwise, trust query_planner's decision about which to use. */ if (use_hashed_grouping || !sorted_path) best_path = cheapest_path; @@ -829,10 +824,10 @@ grouping_planner(PlannerInfo *root, double tuple_fraction) best_path = sorted_path; /* - * Check to see if it's possible to optimize MIN/MAX aggregates. - * If so, we will forget all the work we did so far to choose a - * "regular" path ... but we had to do it anyway to be able to - * tell which way is cheaper. + * Check to see if it's possible to optimize MIN/MAX aggregates. If + * so, we will forget all the work we did so far to choose a "regular" + * path ... but we had to do it anyway to be able to tell which way is + * cheaper. */ result_plan = optimize_minmax_aggregates(root, tlist, @@ -840,8 +835,8 @@ grouping_planner(PlannerInfo *root, double tuple_fraction) if (result_plan != NULL) { /* - * optimize_minmax_aggregates generated the full plan, with - * the right tlist, and it has no sort order. + * optimize_minmax_aggregates generated the full plan, with the + * right tlist, and it has no sort order. */ current_pathkeys = NIL; } @@ -985,8 +980,8 @@ grouping_planner(PlannerInfo *root, double tuple_fraction) * GROUP BY without aggregation, so insert a group node (plus * the appropriate sort node, if necessary). * - * Add an explicit sort if we couldn't make the path come - * out the way the GROUP node needs it. + * Add an explicit sort if we couldn't make the path come out the + * way the GROUP node needs it. */ if (!pathkeys_contained_in(group_pathkeys, current_pathkeys)) { @@ -1014,11 +1009,12 @@ grouping_planner(PlannerInfo *root, double tuple_fraction) * This is a degenerate case in which we are supposed to emit * either 0 or 1 row depending on whether HAVING succeeds. * Furthermore, there cannot be any variables in either HAVING - * or the targetlist, so we actually do not need the FROM table - * at all! We can just throw away the plan-so-far and generate - * a Result node. This is a sufficiently unusual corner case - * that it's not worth contorting the structure of this routine - * to avoid having to generate the plan in the first place. + * or the targetlist, so we actually do not need the FROM + * table at all! We can just throw away the plan-so-far and + * generate a Result node. This is a sufficiently unusual + * corner case that it's not worth contorting the structure of + * this routine to avoid having to generate the plan in the + * first place. */ result_plan = (Plan *) make_result(tlist, parse->havingQual, @@ -1028,8 +1024,8 @@ grouping_planner(PlannerInfo *root, double tuple_fraction) } /* end of if (setOperations) */ /* - * If we were not able to make the plan come out in the right order, - * add an explicit sort step. + * If we were not able to make the plan come out in the right order, add + * an explicit sort step. */ if (parse->sortClause) { @@ -1051,9 +1047,9 @@ grouping_planner(PlannerInfo *root, double tuple_fraction) result_plan = (Plan *) make_unique(result_plan, parse->distinctClause); /* - * If there was grouping or aggregation, leave plan_rows as-is - * (ie, assume the result was already mostly unique). If not, - * use the number of distinct-groups calculated by query_planner. + * If there was grouping or aggregation, leave plan_rows as-is (ie, + * assume the result was already mostly unique). If not, use the + * number of distinct-groups calculated by query_planner. */ if (!parse->groupClause && !root->hasHavingQual && !parse->hasAggs) result_plan->plan_rows = dNumGroups; @@ -1072,8 +1068,8 @@ grouping_planner(PlannerInfo *root, double tuple_fraction) } /* - * Return the actual output ordering in query_pathkeys for possible - * use by an outer query level. + * Return the actual output ordering in query_pathkeys for possible use by + * an outer query level. */ root->query_pathkeys = current_pathkeys; @@ -1084,7 +1080,7 @@ grouping_planner(PlannerInfo *root, double tuple_fraction) * preprocess_limit - do pre-estimation for LIMIT and/or OFFSET clauses * * We try to estimate the values of the LIMIT/OFFSET clauses, and pass the - * results back in *count_est and *offset_est. These variables are set to + * results back in *count_est and *offset_est. These variables are set to * 0 if the corresponding clause is not present, and -1 if it's present * but we couldn't estimate the value for it. (The "0" convention is OK * for OFFSET but a little bit bogus for LIMIT: effectively we estimate @@ -1093,7 +1089,7 @@ grouping_planner(PlannerInfo *root, double tuple_fraction) * be passed to make_limit, which see if you change this code. * * The return value is the suitably adjusted tuple_fraction to use for - * planning the query. This adjustment is not overridable, since it reflects + * planning the query. This adjustment is not overridable, since it reflects * plan actions that grouping_planner() will certainly take, not assumptions * about context. */ @@ -1120,7 +1116,7 @@ preprocess_limit(PlannerInfo *root, double tuple_fraction, if (((Const *) est)->constisnull) { /* NULL indicates LIMIT ALL, ie, no limit */ - *count_est = 0; /* treat as not present */ + *count_est = 0; /* treat as not present */ } else { @@ -1143,7 +1139,7 @@ preprocess_limit(PlannerInfo *root, double tuple_fraction, if (((Const *) est)->constisnull) { /* Treat NULL as no offset; the executor will too */ - *offset_est = 0; /* treat as not present */ + *offset_est = 0; /* treat as not present */ } else { @@ -1217,11 +1213,11 @@ preprocess_limit(PlannerInfo *root, double tuple_fraction, else if (*offset_est != 0 && tuple_fraction > 0.0) { /* - * We have an OFFSET but no LIMIT. This acts entirely differently - * from the LIMIT case: here, we need to increase rather than - * decrease the caller's tuple_fraction, because the OFFSET acts - * to cause more tuples to be fetched instead of fewer. This only - * matters if we got a tuple_fraction > 0, however. + * We have an OFFSET but no LIMIT. This acts entirely differently + * from the LIMIT case: here, we need to increase rather than decrease + * the caller's tuple_fraction, because the OFFSET acts to cause more + * tuples to be fetched instead of fewer. This only matters if we got + * a tuple_fraction > 0, however. * * As above, use 10% if OFFSET is present but unestimatable. */ @@ -1232,9 +1228,9 @@ preprocess_limit(PlannerInfo *root, double tuple_fraction, /* * If we have absolute counts from both caller and OFFSET, add them - * together; likewise if they are both fractional. If one is - * fractional and the other absolute, we want to take the larger, - * and we heuristically assume that's the fractional one. + * together; likewise if they are both fractional. If one is + * fractional and the other absolute, we want to take the larger, and + * we heuristically assume that's the fractional one. */ if (tuple_fraction >= 1.0) { @@ -1260,7 +1256,7 @@ preprocess_limit(PlannerInfo *root, double tuple_fraction, /* both fractional, so add them together */ tuple_fraction += limit_fraction; if (tuple_fraction >= 1.0) - tuple_fraction = 0.0; /* assume fetch all */ + tuple_fraction = 0.0; /* assume fetch all */ } } } @@ -1303,9 +1299,8 @@ choose_hashed_grouping(PlannerInfo *root, double tuple_fraction, * Don't do it if it doesn't look like the hashtable will fit into * work_mem. * - * Beware here of the possibility that cheapest_path->parent is NULL. - * This could happen if user does something silly like - * SELECT 'foo' GROUP BY 1; + * Beware here of the possibility that cheapest_path->parent is NULL. This + * could happen if user does something silly like SELECT 'foo' GROUP BY 1; */ if (cheapest_path->parent) { @@ -1314,8 +1309,8 @@ choose_hashed_grouping(PlannerInfo *root, double tuple_fraction, } else { - cheapest_path_rows = 1; /* assume non-set result */ - cheapest_path_width = 100; /* arbitrary */ + cheapest_path_rows = 1; /* assume non-set result */ + cheapest_path_width = 100; /* arbitrary */ } /* Estimate per-hash-entry space at tuple width... */ @@ -1329,23 +1324,19 @@ choose_hashed_grouping(PlannerInfo *root, double tuple_fraction, return false; /* - * See if the estimated cost is no more than doing it the other way. - * While avoiding the need for sorted input is usually a win, the fact - * that the output won't be sorted may be a loss; so we need to do an - * actual cost comparison. + * See if the estimated cost is no more than doing it the other way. While + * avoiding the need for sorted input is usually a win, the fact that the + * output won't be sorted may be a loss; so we need to do an actual cost + * comparison. * - * We need to consider - * cheapest_path + hashagg [+ final sort] - * versus either - * cheapest_path [+ sort] + group or agg [+ final sort] - * or - * presorted_path + group or agg [+ final sort] - * where brackets indicate a step that may not be needed. We assume - * query_planner() will have returned a presorted path only if it's a - * winner compared to cheapest_path for this purpose. + * We need to consider cheapest_path + hashagg [+ final sort] versus either + * cheapest_path [+ sort] + group or agg [+ final sort] or presorted_path + * + group or agg [+ final sort] where brackets indicate a step that may + * not be needed. We assume query_planner() will have returned a presorted + * path only if it's a winner compared to cheapest_path for this purpose. * - * These path variables are dummies that just hold cost fields; we don't - * make actual Paths for these steps. + * These path variables are dummies that just hold cost fields; we don't make + * actual Paths for these steps. */ cost_agg(&hashed_p, root, AGG_HASHED, agg_counts->numAggs, numGroupCols, dNumGroups, @@ -1502,8 +1493,8 @@ make_subplanTargetList(PlannerInfo *root, /* * Otherwise, start with a "flattened" tlist (having just the vars - * mentioned in the targetlist and HAVING qual --- but not upper- - * level Vars; they will be replaced by Params later on). + * mentioned in the targetlist and HAVING qual --- but not upper- level + * Vars; they will be replaced by Params later on). */ sub_tlist = flatten_tlist(tlist); extravars = pull_var_clause(parse->havingQual, false); @@ -1513,9 +1504,8 @@ make_subplanTargetList(PlannerInfo *root, /* * If grouping, create sub_tlist entries for all GROUP BY expressions - * (GROUP BY items that are simple Vars should be in the list - * already), and make an array showing where the group columns are in - * the sub_tlist. + * (GROUP BY items that are simple Vars should be in the list already), + * and make an array showing where the group columns are in the sub_tlist. */ numCols = list_length(parse->groupClause); if (numCols > 0) @@ -1634,7 +1624,7 @@ postprocess_setop_tlist(List *new_tlist, List *orig_tlist) Assert(orig_tlist_item != NULL); orig_tle = (TargetEntry *) lfirst(orig_tlist_item); orig_tlist_item = lnext(orig_tlist_item); - if (orig_tle->resjunk) /* should not happen */ + if (orig_tle->resjunk) /* should not happen */ elog(ERROR, "resjunk output columns are not implemented"); Assert(new_tle->resno == orig_tle->resno); new_tle->ressortgroupref = orig_tle->ressortgroupref; diff --git a/src/backend/optimizer/plan/setrefs.c b/src/backend/optimizer/plan/setrefs.c index fe01555a3c..2ca616e118 100644 --- a/src/backend/optimizer/plan/setrefs.c +++ b/src/backend/optimizer/plan/setrefs.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/plan/setrefs.c,v 1.114 2005/09/05 18:59:38 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/plan/setrefs.c,v 1.115 2005/10/15 02:49:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -38,7 +38,7 @@ typedef struct int num_vars; /* number of plain Var tlist entries */ bool has_non_vars; /* are there non-plain-Var entries? */ /* array of num_vars entries: */ - tlist_vinfo vars[1]; /* VARIABLE LENGTH ARRAY */ + tlist_vinfo vars[1]; /* VARIABLE LENGTH ARRAY */ } indexed_tlist; /* VARIABLE LENGTH STRUCT */ typedef struct @@ -64,28 +64,28 @@ static void fix_expr_references(Plan *plan, Node *node); static bool fix_expr_references_walker(Node *node, void *context); static void set_join_references(Join *join, List *rtable); static void set_inner_join_references(Plan *inner_plan, - List *rtable, - indexed_tlist *outer_itlist); + List *rtable, + indexed_tlist *outer_itlist); static void set_uppernode_references(Plan *plan, Index subvarno); static indexed_tlist *build_tlist_index(List *tlist); static Var *search_indexed_tlist_for_var(Var *var, - indexed_tlist *itlist, - Index newvarno); + indexed_tlist *itlist, + Index newvarno); static Var *search_indexed_tlist_for_non_var(Node *node, - indexed_tlist *itlist, - Index newvarno); + indexed_tlist *itlist, + Index newvarno); static List *join_references(List *clauses, - List *rtable, - indexed_tlist *outer_itlist, - indexed_tlist *inner_itlist, - Index acceptable_rel); + List *rtable, + indexed_tlist *outer_itlist, + indexed_tlist *inner_itlist, + Index acceptable_rel); static Node *join_references_mutator(Node *node, join_references_context *context); static Node *replace_vars_with_subplan_refs(Node *node, - indexed_tlist *subplan_itlist, - Index subvarno); + indexed_tlist *subplan_itlist, + Index subvarno); static Node *replace_vars_with_subplan_refs_mutator(Node *node, - replace_vars_with_subplan_refs_context *context); + replace_vars_with_subplan_refs_context *context); static bool fix_opfuncids_walker(Node *node, void *context); static void set_sa_opfuncid(ScalarArrayOpExpr *opexpr); @@ -99,7 +99,7 @@ static void set_sa_opfuncid(ScalarArrayOpExpr *opexpr); /* * set_plan_references * - * This is the final processing pass of the planner/optimizer. The plan + * This is the final processing pass of the planner/optimizer. The plan * tree is complete; we just have to adjust some representational details * for the convenience of the executor. We update Vars in upper plan nodes * to refer to the outputs of their subplans, and we compute regproc OIDs @@ -150,22 +150,22 @@ set_plan_references(Plan *plan, List *rtable) fix_expr_references(plan, (Node *) ((IndexScan *) plan)->indexqual); fix_expr_references(plan, - (Node *) ((IndexScan *) plan)->indexqualorig); + (Node *) ((IndexScan *) plan)->indexqualorig); break; case T_BitmapIndexScan: /* no need to fix targetlist and qual */ Assert(plan->targetlist == NIL); Assert(plan->qual == NIL); fix_expr_references(plan, - (Node *) ((BitmapIndexScan *) plan)->indexqual); + (Node *) ((BitmapIndexScan *) plan)->indexqual); fix_expr_references(plan, - (Node *) ((BitmapIndexScan *) plan)->indexqualorig); + (Node *) ((BitmapIndexScan *) plan)->indexqualorig); break; case T_BitmapHeapScan: fix_expr_references(plan, (Node *) plan->targetlist); fix_expr_references(plan, (Node *) plan->qual); fix_expr_references(plan, - (Node *) ((BitmapHeapScan *) plan)->bitmapqualorig); + (Node *) ((BitmapHeapScan *) plan)->bitmapqualorig); break; case T_TidScan: fix_expr_references(plan, (Node *) plan->targetlist); @@ -200,7 +200,7 @@ set_plan_references(Plan *plan, List *rtable) fix_expr_references(plan, (Node *) plan->qual); fix_expr_references(plan, (Node *) ((Join *) plan)->joinqual); fix_expr_references(plan, - (Node *) ((MergeJoin *) plan)->mergeclauses); + (Node *) ((MergeJoin *) plan)->mergeclauses); break; case T_HashJoin: set_join_references((Join *) plan, rtable); @@ -208,7 +208,7 @@ set_plan_references(Plan *plan, List *rtable) fix_expr_references(plan, (Node *) plan->qual); fix_expr_references(plan, (Node *) ((Join *) plan)->joinqual); fix_expr_references(plan, - (Node *) ((HashJoin *) plan)->hashclauses); + (Node *) ((HashJoin *) plan)->hashclauses); break; case T_Hash: case T_Material: @@ -218,24 +218,24 @@ set_plan_references(Plan *plan, List *rtable) /* * These plan types don't actually bother to evaluate their - * targetlists (because they just return their unmodified - * input tuples). The optimizer is lazy about creating really - * valid targetlists for them --- it tends to just put in a - * pointer to the child plan node's tlist. Hence, we leave - * the tlist alone. In particular, we do not want to process - * subplans in the tlist, since we will likely end up reprocessing - * subplans that also appear in lower levels of the plan tree! + * targetlists (because they just return their unmodified input + * tuples). The optimizer is lazy about creating really valid + * targetlists for them --- it tends to just put in a pointer to + * the child plan node's tlist. Hence, we leave the tlist alone. + * In particular, we do not want to process subplans in the tlist, + * since we will likely end up reprocessing subplans that also + * appear in lower levels of the plan tree! * - * Since these plan types don't check quals either, we should - * not find any qual expression attached to them. + * Since these plan types don't check quals either, we should not + * find any qual expression attached to them. */ Assert(plan->qual == NIL); break; case T_Limit: /* - * Like the plan types above, Limit doesn't evaluate its tlist - * or quals. It does have live expressions for limit/offset, + * Like the plan types above, Limit doesn't evaluate its tlist or + * quals. It does have live expressions for limit/offset, * however. */ Assert(plan->qual == NIL); @@ -251,8 +251,8 @@ set_plan_references(Plan *plan, List *rtable) case T_Result: /* - * Result may or may not have a subplan; no need to fix up - * subplan references if it hasn't got one... + * Result may or may not have a subplan; no need to fix up subplan + * references if it hasn't got one... * * XXX why does Result use a different subvarno from Agg/Group? */ @@ -300,9 +300,9 @@ set_plan_references(Plan *plan, List *rtable) * NOTE: it is essential that we recurse into child plans AFTER we set * subplan references in this plan's tlist and quals. If we did the * reference-adjustments bottom-up, then we would fail to match this - * plan's var nodes against the already-modified nodes of the - * children. Fortunately, that consideration doesn't apply to SubPlan - * nodes; else we'd need two passes over the expression trees. + * plan's var nodes against the already-modified nodes of the children. + * Fortunately, that consideration doesn't apply to SubPlan nodes; else + * we'd need two passes over the expression trees. */ plan->lefttree = set_plan_references(plan->lefttree, rtable); plan->righttree = set_plan_references(plan->righttree, rtable); @@ -339,8 +339,8 @@ set_subqueryscan_references(SubqueryScan *plan, List *rtable) rte->subquery->rtable); /* - * We have to process any initplans too; set_plan_references can't do - * it for us because of the possibility of double-processing. + * We have to process any initplans too; set_plan_references can't do it + * for us because of the possibility of double-processing. */ foreach(l, plan->scan.plan.initPlan) { @@ -353,12 +353,12 @@ set_subqueryscan_references(SubqueryScan *plan, List *rtable) if (trivial_subqueryscan(plan)) { /* - * We can omit the SubqueryScan node and just pull up the subplan. - * We have to merge its rtable into the outer rtable, which means + * We can omit the SubqueryScan node and just pull up the subplan. We + * have to merge its rtable into the outer rtable, which means * adjusting varnos throughout the subtree. */ - int rtoffset = list_length(rtable); - List *sub_rtable; + int rtoffset = list_length(rtable); + List *sub_rtable; sub_rtable = copyObject(rte->subquery->rtable); range_table_walker(sub_rtable, @@ -382,11 +382,11 @@ set_subqueryscan_references(SubqueryScan *plan, List *rtable) else { /* - * Keep the SubqueryScan node. We have to do the processing that - * set_plan_references would otherwise have done on it. Notice - * we do not do set_uppernode_references() here, because a - * SubqueryScan will always have been created with correct - * references to its subplan's outputs to begin with. + * Keep the SubqueryScan node. We have to do the processing that + * set_plan_references would otherwise have done on it. Notice we do + * not do set_uppernode_references() here, because a SubqueryScan will + * always have been created with correct references to its subplan's + * outputs to begin with. */ result = (Plan *) plan; @@ -532,9 +532,9 @@ adjust_plan_varnos(Plan *plan, int rtoffset) case T_SetOp: /* - * Even though the targetlist won't be used by the executor, - * we fix it up for possible use by EXPLAIN (not to mention - * ease of debugging --- wrong varnos are very confusing). + * Even though the targetlist won't be used by the executor, we + * fix it up for possible use by EXPLAIN (not to mention ease of + * debugging --- wrong varnos are very confusing). */ adjust_expr_varnos((Node *) plan->targetlist, rtoffset); Assert(plan->qual == NIL); @@ -542,8 +542,8 @@ adjust_plan_varnos(Plan *plan, int rtoffset) case T_Limit: /* - * Like the plan types above, Limit doesn't evaluate its tlist - * or quals. It does have live expressions for limit/offset, + * Like the plan types above, Limit doesn't evaluate its tlist or + * quals. It does have live expressions for limit/offset, * however. */ adjust_expr_varnos((Node *) plan->targetlist, rtoffset); @@ -590,8 +590,8 @@ adjust_plan_varnos(Plan *plan, int rtoffset) /* * Now recurse into child plans. * - * We don't need to (and in fact mustn't) recurse into subqueries, - * so no need to examine initPlan list. + * We don't need to (and in fact mustn't) recurse into subqueries, so no need + * to examine initPlan list. */ adjust_plan_varnos(plan->lefttree, rtoffset); adjust_plan_varnos(plan->righttree, rtoffset); @@ -603,7 +603,7 @@ adjust_plan_varnos(Plan *plan, int rtoffset) * * This is different from the rewriter's OffsetVarNodes in that it has to * work on an already-planned expression tree; in particular, we should not - * disturb INNER and OUTER references. On the other hand, we don't have to + * disturb INNER and OUTER references. On the other hand, we don't have to * recurse into subqueries nor deal with outer-level Vars, so it's pretty * simple. */ @@ -763,10 +763,10 @@ set_inner_join_references(Plan *inner_plan, if (IsA(inner_plan, IndexScan)) { /* - * An index is being used to reduce the number of tuples - * scanned in the inner relation. If there are join clauses - * being used with the index, we must update their outer-rel - * var nodes to refer to the outer side of the join. + * An index is being used to reduce the number of tuples scanned in + * the inner relation. If there are join clauses being used with the + * index, we must update their outer-rel var nodes to refer to the + * outer side of the join. */ IndexScan *innerscan = (IndexScan *) inner_plan; List *indexqualorig = innerscan->indexqualorig; @@ -789,9 +789,9 @@ set_inner_join_references(Plan *inner_plan, innerrel); /* - * We must fix the inner qpqual too, if it has join - * clauses (this could happen if special operators are - * involved: some indexquals may get rechecked as qpquals). + * We must fix the inner qpqual too, if it has join clauses (this + * could happen if special operators are involved: some indexquals + * may get rechecked as qpquals). */ if (NumRelids((Node *) inner_plan->qual) > 1) inner_plan->qual = join_references(inner_plan->qual, @@ -832,11 +832,11 @@ set_inner_join_references(Plan *inner_plan, else if (IsA(inner_plan, BitmapHeapScan)) { /* - * The inner side is a bitmap scan plan. Fix the top node, - * and recurse to get the lower nodes. + * The inner side is a bitmap scan plan. Fix the top node, and + * recurse to get the lower nodes. * - * Note: create_bitmap_scan_plan removes clauses from bitmapqualorig - * if they are duplicated in qpqual, so must test these independently. + * Note: create_bitmap_scan_plan removes clauses from bitmapqualorig if + * they are duplicated in qpqual, so must test these independently. */ BitmapHeapScan *innerscan = (BitmapHeapScan *) inner_plan; Index innerrel = innerscan->scan.scanrelid; @@ -851,9 +851,9 @@ set_inner_join_references(Plan *inner_plan, innerrel); /* - * We must fix the inner qpqual too, if it has join - * clauses (this could happen if special operators are - * involved: some indexquals may get rechecked as qpquals). + * We must fix the inner qpqual too, if it has join clauses (this + * could happen if special operators are involved: some indexquals may + * get rechecked as qpquals). */ if (NumRelids((Node *) inner_plan->qual) > 1) inner_plan->qual = join_references(inner_plan->qual, @@ -870,8 +870,8 @@ set_inner_join_references(Plan *inner_plan, else if (IsA(inner_plan, BitmapAnd)) { /* All we need do here is recurse */ - BitmapAnd *innerscan = (BitmapAnd *) inner_plan; - ListCell *l; + BitmapAnd *innerscan = (BitmapAnd *) inner_plan; + ListCell *l; foreach(l, innerscan->bitmapplans) { @@ -883,8 +883,8 @@ set_inner_join_references(Plan *inner_plan, else if (IsA(inner_plan, BitmapOr)) { /* All we need do here is recurse */ - BitmapOr *innerscan = (BitmapOr *) inner_plan; - ListCell *l; + BitmapOr *innerscan = (BitmapOr *) inner_plan; + ListCell *l; foreach(l, innerscan->bitmapplans) { @@ -963,7 +963,7 @@ set_uppernode_references(Plan *plan, Index subvarno) * * In most cases, subplan tlists will be "flat" tlists with only Vars, * so we try to optimize that case by extracting information about Vars - * in advance. Matching a parent tlist to a child is still an O(N^2) + * in advance. Matching a parent tlist to a child is still an O(N^2) * operation, but at least with a much smaller constant factor than plain * tlist_member() searches. * @@ -994,7 +994,7 @@ build_tlist_index(List *tlist) if (tle->expr && IsA(tle->expr, Var)) { - Var *var = (Var *) tle->expr; + Var *var = (Var *) tle->expr; vinfo->varno = var->varno; vinfo->varattno = var->varattno; @@ -1068,7 +1068,7 @@ search_indexed_tlist_for_non_var(Node *node, exprType((Node *) tle->expr), exprTypmod((Node *) tle->expr), 0); - newvar->varnoold = 0; /* wasn't ever a plain Var */ + newvar->varnoold = 0; /* wasn't ever a plain Var */ newvar->varoattno = 0; return newvar; } @@ -1213,7 +1213,7 @@ replace_vars_with_subplan_refs(Node *node, static Node * replace_vars_with_subplan_refs_mutator(Node *node, - replace_vars_with_subplan_refs_context *context) + replace_vars_with_subplan_refs_context *context) { Var *newvar; diff --git a/src/backend/optimizer/plan/subselect.c b/src/backend/optimizer/plan/subselect.c index ec037db514..b0dc9c5bf7 100644 --- a/src/backend/optimizer/plan/subselect.c +++ b/src/backend/optimizer/plan/subselect.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/plan/subselect.c,v 1.99 2005/06/05 22:32:56 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/plan/subselect.c,v 1.100 2005/10/15 02:49:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -110,19 +110,18 @@ replace_outer_var(Var *var) abslevel = PlannerQueryLevel - var->varlevelsup; /* - * If there's already a PlannerParamList entry for this same Var, just - * use it. NOTE: in sufficiently complex querytrees, it is possible - * for the same varno/abslevel to refer to different RTEs in different - * parts of the parsetree, so that different fields might end up - * sharing the same Param number. As long as we check the vartype as - * well, I believe that this sort of aliasing will cause no trouble. - * The correct field should get stored into the Param slot at - * execution in each part of the tree. + * If there's already a PlannerParamList entry for this same Var, just use + * it. NOTE: in sufficiently complex querytrees, it is possible for the + * same varno/abslevel to refer to different RTEs in different parts of + * the parsetree, so that different fields might end up sharing the same + * Param number. As long as we check the vartype as well, I believe that + * this sort of aliasing will cause no trouble. The correct field should + * get stored into the Param slot at execution in each part of the tree. * - * We also need to demand a match on vartypmod. This does not matter for - * the Param itself, since those are not typmod-dependent, but it does - * matter when make_subplan() instantiates a modified copy of the Var - * for a subplan's args list. + * We also need to demand a match on vartypmod. This does not matter for the + * Param itself, since those are not typmod-dependent, but it does matter + * when make_subplan() instantiates a modified copy of the Var for a + * subplan's args list. */ i = 0; foreach(ppl, PlannerParamList) @@ -179,8 +178,8 @@ replace_outer_agg(Aggref *agg) abslevel = PlannerQueryLevel - agg->agglevelsup; /* - * It does not seem worthwhile to try to match duplicate outer aggs. - * Just make a new slot every time. + * It does not seem worthwhile to try to match duplicate outer aggs. Just + * make a new slot every time. */ agg = (Aggref *) copyObject(agg); IncrementVarSublevelsUp((Node *) agg, -((int) agg->agglevelsup), 0); @@ -253,33 +252,32 @@ make_subplan(SubLink *slink, List *lefthand, bool isTopQual) Node *result; /* - * Copy the source Query node. This is a quick and dirty kluge to - * resolve the fact that the parser can generate trees with multiple - * links to the same sub-Query node, but the planner wants to scribble - * on the Query. Try to clean this up when we do querytree redesign... + * Copy the source Query node. This is a quick and dirty kluge to resolve + * the fact that the parser can generate trees with multiple links to the + * same sub-Query node, but the planner wants to scribble on the Query. + * Try to clean this up when we do querytree redesign... */ subquery = (Query *) copyObject(subquery); /* - * For an EXISTS subplan, tell lower-level planner to expect that only - * the first tuple will be retrieved. For ALL and ANY subplans, we - * will be able to stop evaluating if the test condition fails, so - * very often not all the tuples will be retrieved; for lack of a - * better idea, specify 50% retrieval. For EXPR and MULTIEXPR - * subplans, use default behavior (we're only expecting one row out, - * anyway). + * For an EXISTS subplan, tell lower-level planner to expect that only the + * first tuple will be retrieved. For ALL and ANY subplans, we will be + * able to stop evaluating if the test condition fails, so very often not + * all the tuples will be retrieved; for lack of a better idea, specify + * 50% retrieval. For EXPR and MULTIEXPR subplans, use default behavior + * (we're only expecting one row out, anyway). * - * NOTE: if you change these numbers, also change cost_qual_eval_walker() - * in path/costsize.c. + * NOTE: if you change these numbers, also change cost_qual_eval_walker() in + * path/costsize.c. * * XXX If an ALL/ANY subplan is uncorrelated, we may decide to hash or - * materialize its result below. In that case it would've been better - * to specify full retrieval. At present, however, we can only detect + * materialize its result below. In that case it would've been better to + * specify full retrieval. At present, however, we can only detect * correlation or lack of it after we've made the subplan :-(. Perhaps - * detection of correlation should be done as a separate step. - * Meanwhile, we don't want to be too optimistic about the percentage - * of tuples retrieved, for fear of selecting a plan that's bad for - * the materialization case. + * detection of correlation should be done as a separate step. Meanwhile, + * we don't want to be too optimistic about the percentage of tuples + * retrieved, for fear of selecting a plan that's bad for the + * materialization case. */ if (slink->subLinkType == EXISTS_SUBLINK) tuple_fraction = 1.0; /* just like a LIMIT 1 */ @@ -294,8 +292,7 @@ make_subplan(SubLink *slink, List *lefthand, bool isTopQual) */ node->plan = plan = subquery_planner(subquery, tuple_fraction, NULL); - node->plan_id = PlannerPlanId++; /* Assign unique ID to this - * SubPlan */ + node->plan_id = PlannerPlanId++; /* Assign unique ID to this SubPlan */ node->rtable = subquery->rtable; @@ -314,8 +311,8 @@ make_subplan(SubLink *slink, List *lefthand, bool isTopQual) node->args = NIL; /* - * Make parParam list of params that current query level will pass to - * this child plan. + * Make parParam list of params that current query level will pass to this + * child plan. */ tmpset = bms_copy(plan->extParam); while ((paramid = bms_first_member(tmpset)) >= 0) @@ -328,13 +325,12 @@ make_subplan(SubLink *slink, List *lefthand, bool isTopQual) bms_free(tmpset); /* - * Un-correlated or undirect correlated plans of EXISTS, EXPR, ARRAY, - * or MULTIEXPR types can be used as initPlans. For EXISTS, EXPR, or - * ARRAY, we just produce a Param referring to the result of - * evaluating the initPlan. For MULTIEXPR, we must build an AND or - * OR-clause of the individual comparison operators, using the - * appropriate lefthand side expressions and Params for the initPlan's - * target items. + * Un-correlated or undirect correlated plans of EXISTS, EXPR, ARRAY, or + * MULTIEXPR types can be used as initPlans. For EXISTS, EXPR, or ARRAY, + * we just produce a Param referring to the result of evaluating the + * initPlan. For MULTIEXPR, we must build an AND or OR-clause of the + * individual comparison operators, using the appropriate lefthand side + * expressions and Params for the initPlan's target items. */ if (node->parParam == NIL && slink->subLinkType == EXISTS_SUBLINK) { @@ -387,9 +383,8 @@ make_subplan(SubLink *slink, List *lefthand, bool isTopQual) PlannerInitPlan = lappend(PlannerInitPlan, node); /* - * The executable expressions are returned to become part of the - * outer plan's expression tree; they are not kept in the initplan - * node. + * The executable expressions are returned to become part of the outer + * plan's expression tree; they are not kept in the initplan node. */ if (list_length(exprs) > 1) result = (Node *) (node->useOr ? make_orclause(exprs) : @@ -403,22 +398,22 @@ make_subplan(SubLink *slink, List *lefthand, bool isTopQual) ListCell *l; /* - * We can't convert subplans of ALL_SUBLINK or ANY_SUBLINK types - * to initPlans, even when they are uncorrelated or undirect - * correlated, because we need to scan the output of the subplan - * for each outer tuple. But if it's an IN (= ANY) test, we might - * be able to use a hashtable to avoid comparing all the tuples. + * We can't convert subplans of ALL_SUBLINK or ANY_SUBLINK types to + * initPlans, even when they are uncorrelated or undirect correlated, + * because we need to scan the output of the subplan for each outer + * tuple. But if it's an IN (= ANY) test, we might be able to use a + * hashtable to avoid comparing all the tuples. */ if (subplan_is_hashable(slink, node)) node->useHashTable = true; /* - * Otherwise, we have the option to tack a MATERIAL node onto the - * top of the subplan, to reduce the cost of reading it - * repeatedly. This is pointless for a direct-correlated subplan, - * since we'd have to recompute its results each time anyway. For - * uncorrelated/undirect correlated subplans, we add MATERIAL unless - * the subplan's top plan node would materialize its output anyway. + * Otherwise, we have the option to tack a MATERIAL node onto the top + * of the subplan, to reduce the cost of reading it repeatedly. This + * is pointless for a direct-correlated subplan, since we'd have to + * recompute its results each time anyway. For uncorrelated/undirect + * correlated subplans, we add MATERIAL unless the subplan's top plan + * node would materialize its output anyway. */ else if (node->parParam == NIL) { @@ -455,9 +450,9 @@ make_subplan(SubLink *slink, List *lefthand, bool isTopQual) PlannerParamItem *pitem = list_nth(PlannerParamList, lfirst_int(l)); /* - * The Var or Aggref has already been adjusted to have the - * correct varlevelsup or agglevelsup. We probably don't even - * need to copy it again, but be safe. + * The Var or Aggref has already been adjusted to have the correct + * varlevelsup or agglevelsup. We probably don't even need to + * copy it again, but be safe. */ args = lappend(args, copyObject(pitem->item)); } @@ -545,8 +540,8 @@ convert_sublink_opers(List *lefthand, List *operOids, * * Note: we use make_op_expr in case runtime type conversion function * calls must be inserted for this operator! (But we are not - * expecting to have to resolve unknown Params, so it's okay to - * pass a null pstate.) + * expecting to have to resolve unknown Params, so it's okay to pass a + * null pstate.) */ result = lappend(result, make_op_expr(NULL, @@ -580,8 +575,8 @@ subplan_is_hashable(SubLink *slink, SubPlan *node) /* * The sublink type must be "= ANY" --- that is, an IN operator. (We * require the operator name to be unqualified, which may be overly - * paranoid, or may not be.) XXX since we also check that the - * operators are hashable, the test on operator name may be redundant? + * paranoid, or may not be.) XXX since we also check that the operators + * are hashable, the test on operator name may be redundant? */ if (slink->subLinkType != ANY_SUBLINK) return false; @@ -591,15 +586,15 @@ subplan_is_hashable(SubLink *slink, SubPlan *node) /* * The subplan must not have any direct correlation vars --- else we'd - * have to recompute its output each time, so that the hashtable - * wouldn't gain anything. + * have to recompute its output each time, so that the hashtable wouldn't + * gain anything. */ if (node->parParam != NIL) return false; /* - * The estimated size of the subquery result must fit in work_mem. - * (XXX what about hashtable overhead?) + * The estimated size of the subquery result must fit in work_mem. (XXX + * what about hashtable overhead?) */ subquery_size = node->plan->plan_rows * (MAXALIGN(node->plan->plan_width) + MAXALIGN(sizeof(HeapTupleData))); @@ -607,18 +602,17 @@ subplan_is_hashable(SubLink *slink, SubPlan *node) return false; /* - * The combining operators must be hashable, strict, and - * self-commutative. The need for hashability is obvious, since we - * want to use hashing. Without strictness, behavior in the presence - * of nulls is too unpredictable. (We actually must assume even more - * than plain strictness, see nodeSubplan.c for details.) And - * commutativity ensures that the left and right datatypes are the - * same; this allows us to assume that the combining operators are - * equality for the righthand datatype, so that they can be used to - * compare righthand tuples as well as comparing lefthand to righthand - * tuples. (This last restriction could be relaxed by using two - * different sets of operators with the hash table, but there is no - * obvious usefulness to that at present.) + * The combining operators must be hashable, strict, and self-commutative. + * The need for hashability is obvious, since we want to use hashing. + * Without strictness, behavior in the presence of nulls is too + * unpredictable. (We actually must assume even more than plain + * strictness, see nodeSubplan.c for details.) And commutativity ensures + * that the left and right datatypes are the same; this allows us to + * assume that the combining operators are equality for the righthand + * datatype, so that they can be used to compare righthand tuples as well + * as comparing lefthand to righthand tuples. (This last restriction + * could be relaxed by using two different sets of operators with the hash + * table, but there is no obvious usefulness to that at present.) */ foreach(l, slink->operOids) { @@ -679,24 +673,24 @@ convert_IN_to_join(PlannerInfo *root, SubLink *sublink) return NULL; /* - * The sub-select must not refer to any Vars of the parent query. - * (Vars of higher levels should be okay, though.) + * The sub-select must not refer to any Vars of the parent query. (Vars of + * higher levels should be okay, though.) */ if (contain_vars_of_level((Node *) subselect, 1)) return NULL; /* - * The left-hand expressions must contain some Vars of the current - * query, else it's not gonna be a join. + * The left-hand expressions must contain some Vars of the current query, + * else it's not gonna be a join. */ left_varnos = pull_varnos((Node *) sublink->lefthand); if (bms_is_empty(left_varnos)) return NULL; /* - * The left-hand expressions mustn't be volatile. (Perhaps we should - * test the combining operators, too? We'd only need to point the - * function directly at the sublink ...) + * The left-hand expressions mustn't be volatile. (Perhaps we should test + * the combining operators, too? We'd only need to point the function + * directly at the sublink ...) */ if (contain_volatile_functions((Node *) sublink->lefthand)) return NULL; @@ -704,10 +698,10 @@ convert_IN_to_join(PlannerInfo *root, SubLink *sublink) /* * Okay, pull up the sub-select into top range table and jointree. * - * We rely here on the assumption that the outer query has no references - * to the inner (necessarily true, other than the Vars that we build - * below). Therefore this is a lot easier than what - * pull_up_subqueries has to go through. + * We rely here on the assumption that the outer query has no references to + * the inner (necessarily true, other than the Vars that we build below). + * Therefore this is a lot easier than what pull_up_subqueries has to go + * through. */ rte = addRangeTableEntryForSubquery(NULL, subselect, @@ -729,8 +723,8 @@ convert_IN_to_join(PlannerInfo *root, SubLink *sublink) /* * Build the result qual expressions. As a side effect, - * ininfo->sub_targetlist is filled with a list of Vars representing - * the subselect outputs. + * ininfo->sub_targetlist is filled with a list of Vars representing the + * subselect outputs. */ exprs = convert_sublink_opers(sublink->lefthand, sublink->operOids, @@ -811,8 +805,7 @@ process_sublinks_mutator(Node *node, bool *isTopQual) List *lefthand; /* - * First, recursively process the lefthand-side expressions, if - * any. + * First, recursively process the lefthand-side expressions, if any. */ locTopQual = false; lefthand = (List *) @@ -825,22 +818,22 @@ process_sublinks_mutator(Node *node, bool *isTopQual) } /* - * We should never see a SubPlan expression in the input (since this - * is the very routine that creates 'em to begin with). We shouldn't - * find ourselves invoked directly on a Query, either. + * We should never see a SubPlan expression in the input (since this is + * the very routine that creates 'em to begin with). We shouldn't find + * ourselves invoked directly on a Query, either. */ Assert(!is_subplan(node)); Assert(!IsA(node, Query)); /* * Because make_subplan() could return an AND or OR clause, we have to - * take steps to preserve AND/OR flatness of a qual. We assume the - * input has been AND/OR flattened and so we need no recursion here. + * take steps to preserve AND/OR flatness of a qual. We assume the input + * has been AND/OR flattened and so we need no recursion here. * * If we recurse down through anything other than an AND node, we are - * definitely not at top qual level anymore. (Due to the coding here, - * we will not get called on the List subnodes of an AND, so no check - * is needed for List.) + * definitely not at top qual level anymore. (Due to the coding here, we + * will not get called on the List subnodes of an AND, so no check is + * needed for List.) */ if (and_clause(node)) { @@ -909,8 +902,8 @@ SS_finalize_plan(Plan *plan, List *rtable) /* * First, scan the param list to discover the sets of params that are - * available from outer query levels and my own query level. We do - * this once to save time in the per-plan recursion steps. + * available from outer query levels and my own query level. We do this + * once to save time in the per-plan recursion steps. */ paramid = 0; foreach(l, PlannerParamList) @@ -942,13 +935,12 @@ SS_finalize_plan(Plan *plan, List *rtable) bms_free(valid_params); /* - * Finally, attach any initPlans to the topmost plan node, - * and add their extParams to the topmost node's, too. + * Finally, attach any initPlans to the topmost plan node, and add their + * extParams to the topmost node's, too. * - * We also add the total_cost of each initPlan to the startup cost of - * the top node. This is a conservative overestimate, since in - * fact each initPlan might be executed later than plan startup, - * or even not at all. + * We also add the total_cost of each initPlan to the startup cost of the top + * node. This is a conservative overestimate, since in fact each initPlan + * might be executed later than plan startup, or even not at all. */ plan->initPlan = PlannerInitPlan; PlannerInitPlan = NIL; /* make sure they're not attached twice */ @@ -988,10 +980,10 @@ finalize_plan(Plan *plan, List *rtable, context.outer_params = outer_params; /* - * When we call finalize_primnode, context.paramids sets are - * automatically merged together. But when recursing to self, we have - * to do it the hard way. We want the paramids set to include params - * in subplans as well as at this level. + * When we call finalize_primnode, context.paramids sets are automatically + * merged together. But when recursing to self, we have to do it the hard + * way. We want the paramids set to include params in subplans as well as + * at this level. */ /* Find params in targetlist and qual */ @@ -1011,17 +1003,18 @@ finalize_plan(Plan *plan, List *rtable, &context); /* - * we need not look at indexqualorig, since it will have the - * same param references as indexqual. + * we need not look at indexqualorig, since it will have the same + * param references as indexqual. */ break; case T_BitmapIndexScan: finalize_primnode((Node *) ((BitmapIndexScan *) plan)->indexqual, &context); + /* - * we need not look at indexqualorig, since it will have the - * same param references as indexqual. + * we need not look at indexqualorig, since it will have the same + * param references as indexqual. */ break; @@ -1038,14 +1031,14 @@ finalize_plan(Plan *plan, List *rtable, case T_SubqueryScan: /* - * In a SubqueryScan, SS_finalize_plan has already been run on - * the subplan by the inner invocation of subquery_planner, so - * there's no need to do it again. Instead, just pull out the - * subplan's extParams list, which represents the params it - * needs from my level and higher levels. + * In a SubqueryScan, SS_finalize_plan has already been run on the + * subplan by the inner invocation of subquery_planner, so there's + * no need to do it again. Instead, just pull out the subplan's + * extParams list, which represents the params it needs from my + * level and higher levels. */ context.paramids = bms_add_members(context.paramids, - ((SubqueryScan *) plan)->subplan->extParam); + ((SubqueryScan *) plan)->subplan->extParam); break; case T_FunctionScan: @@ -1170,8 +1163,8 @@ finalize_plan(Plan *plan, List *rtable, plan->allParam = context.paramids; /* - * For speed at execution time, make sure extParam/allParam are - * actually NULL if they are empty sets. + * For speed at execution time, make sure extParam/allParam are actually + * NULL if they are empty sets. */ if (bms_is_empty(plan->extParam)) { @@ -1212,8 +1205,8 @@ finalize_primnode(Node *node, finalize_primnode_context *context) /* Add outer-level params needed by the subplan to paramids */ context->paramids = bms_join(context->paramids, - bms_intersect(subplan->plan->extParam, - context->outer_params)); + bms_intersect(subplan->plan->extParam, + context->outer_params)); /* fall through to recurse into subplan args */ } return expression_tree_walker(node, finalize_primnode, @@ -1241,7 +1234,7 @@ SS_make_initplan_from_plan(PlannerInfo *root, Plan *plan, int paramid; /* - * Set up for a new level of subquery. This is just to keep + * Set up for a new level of subquery. This is just to keep * SS_finalize_plan from becoming confused. */ PlannerQueryLevel++; @@ -1262,16 +1255,15 @@ SS_make_initplan_from_plan(PlannerInfo *root, Plan *plan, node = makeNode(SubPlan); node->subLinkType = EXPR_SUBLINK; node->plan = plan; - node->plan_id = PlannerPlanId++; /* Assign unique ID to this - * SubPlan */ + node->plan_id = PlannerPlanId++; /* Assign unique ID to this SubPlan */ node->rtable = root->parse->rtable; PlannerInitPlan = lappend(PlannerInitPlan, node); /* - * Make parParam list of params that current query level will pass to - * this child plan. (In current usage there probably aren't any.) + * Make parParam list of params that current query level will pass to this + * child plan. (In current usage there probably aren't any.) */ tmpset = bms_copy(plan->extParam); while ((paramid = bms_first_member(tmpset)) >= 0) diff --git a/src/backend/optimizer/prep/prepjointree.c b/src/backend/optimizer/prep/prepjointree.c index 9624a4ad13..ece6133c14 100644 --- a/src/backend/optimizer/prep/prepjointree.c +++ b/src/backend/optimizer/prep/prepjointree.c @@ -16,7 +16,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/prep/prepjointree.c,v 1.30 2005/08/01 20:31:09 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/prep/prepjointree.c,v 1.31 2005/10/15 02:49:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -143,8 +143,8 @@ pull_up_subqueries(PlannerInfo *root, Node *jtnode, bool below_outer_join) Query *subquery = rte->subquery; /* - * Is this a subquery RTE, and if so, is the subquery simple - * enough to pull up? (If not, do nothing at this node.) + * Is this a subquery RTE, and if so, is the subquery simple enough to + * pull up? (If not, do nothing at this node.) * * If we are inside an outer join, only pull up subqueries whose * targetlists are nullable --- otherwise substituting their tlist @@ -153,8 +153,8 @@ pull_up_subqueries(PlannerInfo *root, Node *jtnode, bool below_outer_join) * * XXX This could be improved by generating pseudo-variables for such * expressions; we'd have to figure out how to get the pseudo- - * variables evaluated at the right place in the modified plan - * tree. Fix it someday. + * variables evaluated at the right place in the modified plan tree. + * Fix it someday. */ if (rte->rtekind == RTE_SUBQUERY && is_simple_subquery(subquery) && @@ -166,53 +166,53 @@ pull_up_subqueries(PlannerInfo *root, Node *jtnode, bool below_outer_join) ListCell *rt; /* - * Need a modifiable copy of the subquery to hack on. Even if - * we didn't sometimes choose not to pull up below, we must do - * this to avoid problems if the same subquery is referenced - * from multiple jointree items (which can't happen normally, - * but might after rule rewriting). + * Need a modifiable copy of the subquery to hack on. Even if we + * didn't sometimes choose not to pull up below, we must do this + * to avoid problems if the same subquery is referenced from + * multiple jointree items (which can't happen normally, but might + * after rule rewriting). */ subquery = copyObject(subquery); /* * Create a PlannerInfo data structure for this subquery. * - * NOTE: the next few steps should match the first processing - * in subquery_planner(). Can we refactor to avoid code - * duplication, or would that just make things uglier? + * NOTE: the next few steps should match the first processing in + * subquery_planner(). Can we refactor to avoid code duplication, + * or would that just make things uglier? */ subroot = makeNode(PlannerInfo); subroot->parse = subquery; /* - * Pull up any IN clauses within the subquery's WHERE, so that - * we don't leave unoptimized INs behind. + * Pull up any IN clauses within the subquery's WHERE, so that we + * don't leave unoptimized INs behind. */ subroot->in_info_list = NIL; if (subquery->hasSubLinks) subquery->jointree->quals = pull_up_IN_clauses(subroot, - subquery->jointree->quals); + subquery->jointree->quals); /* * Recursively pull up the subquery's subqueries, so that this * routine's processing is complete for its jointree and * rangetable. * - * Note: 'false' is correct here even if we are within an outer - * join in the upper query; the lower query starts with a - * clean slate for outer-join semantics. + * Note: 'false' is correct here even if we are within an outer join + * in the upper query; the lower query starts with a clean slate + * for outer-join semantics. */ subquery->jointree = (FromExpr *) pull_up_subqueries(subroot, (Node *) subquery->jointree, false); /* - * Now we must recheck whether the subquery is still simple - * enough to pull up. If not, abandon processing it. + * Now we must recheck whether the subquery is still simple enough + * to pull up. If not, abandon processing it. * - * We don't really need to recheck all the conditions involved, - * but it's easier just to keep this "if" looking the same as - * the one above. + * We don't really need to recheck all the conditions involved, but + * it's easier just to keep this "if" looking the same as the one + * above. */ if (is_simple_subquery(subquery) && (!below_outer_join || has_nullable_targetlist(subquery))) @@ -224,10 +224,10 @@ pull_up_subqueries(PlannerInfo *root, Node *jtnode, bool below_outer_join) /* * Give up, return unmodified RangeTblRef. * - * Note: The work we just did will be redone when the - * subquery gets planned on its own. Perhaps we could - * avoid that by storing the modified subquery back into - * the rangetable, but I'm not gonna risk it now. + * Note: The work we just did will be redone when the subquery + * gets planned on its own. Perhaps we could avoid that by + * storing the modified subquery back into the rangetable, but + * I'm not gonna risk it now. */ return jtnode; } @@ -242,8 +242,8 @@ pull_up_subqueries(PlannerInfo *root, Node *jtnode, bool below_outer_join) OffsetVarNodes((Node *) subroot->in_info_list, rtoffset, 0); /* - * Upper-level vars in subquery are now one level closer to - * their parent than before. + * Upper-level vars in subquery are now one level closer to their + * parent than before. */ IncrementVarSublevelsUp((Node *) subquery, -1, 1); IncrementVarSublevelsUp((Node *) subroot->in_info_list, -1, 1); @@ -251,9 +251,8 @@ pull_up_subqueries(PlannerInfo *root, Node *jtnode, bool below_outer_join) /* * Replace all of the top query's references to the subquery's * outputs with copies of the adjusted subtlist items, being - * careful not to replace any of the jointree structure. - * (This'd be a lot cleaner if we could use - * query_tree_mutator.) + * careful not to replace any of the jointree structure. (This'd + * be a lot cleaner if we could use query_tree_mutator.) */ subtlist = subquery->targetList; parse->targetList = (List *) @@ -284,9 +283,9 @@ pull_up_subqueries(PlannerInfo *root, Node *jtnode, bool below_outer_join) } /* - * Now append the adjusted rtable entries to upper query. (We - * hold off until after fixing the upper rtable entries; no - * point in running that code on the subquery ones too.) + * Now append the adjusted rtable entries to upper query. (We hold + * off until after fixing the upper rtable entries; no point in + * running that code on the subquery ones too.) */ parse->rtable = list_concat(parse->rtable, subquery->rtable); @@ -295,8 +294,8 @@ pull_up_subqueries(PlannerInfo *root, Node *jtnode, bool below_outer_join) * already adjusted the marker values, so just list_concat the * list.) * - * Executor can't handle multiple FOR UPDATE/SHARE/NOWAIT flags, - * so complain if they are valid but different + * Executor can't handle multiple FOR UPDATE/SHARE/NOWAIT flags, so + * complain if they are valid but different */ if (parse->rowMarks && subquery->rowMarks) { @@ -307,7 +306,7 @@ pull_up_subqueries(PlannerInfo *root, Node *jtnode, bool below_outer_join) if (parse->rowNoWait != subquery->rowNoWait) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot use both wait and NOWAIT in one query"))); + errmsg("cannot use both wait and NOWAIT in one query"))); } parse->rowMarks = list_concat(parse->rowMarks, subquery->rowMarks); if (subquery->rowMarks) @@ -317,10 +316,9 @@ pull_up_subqueries(PlannerInfo *root, Node *jtnode, bool below_outer_join) } /* - * We also have to fix the relid sets of any parent - * InClauseInfo nodes. (This could perhaps be done by - * ResolveNew, but it would clutter that routine's API - * unreasonably.) + * We also have to fix the relid sets of any parent InClauseInfo + * nodes. (This could perhaps be done by ResolveNew, but it would + * clutter that routine's API unreasonably.) */ if (root->in_info_list) { @@ -392,8 +390,8 @@ pull_up_subqueries(PlannerInfo *root, Node *jtnode, bool below_outer_join) case JOIN_UNION: /* - * This is where we fail if upper levels of planner - * haven't rewritten UNION JOIN as an Append ... + * This is where we fail if upper levels of planner haven't + * rewritten UNION JOIN as an Append ... */ ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), @@ -436,8 +434,8 @@ is_simple_subquery(Query *subquery) return false; /* - * Can't pull up a subquery involving grouping, aggregation, sorting, - * or limiting. + * Can't pull up a subquery involving grouping, aggregation, sorting, or + * limiting. */ if (subquery->hasAggs || subquery->groupClause || @@ -449,21 +447,20 @@ is_simple_subquery(Query *subquery) return false; /* - * Don't pull up a subquery that has any set-returning functions in - * its targetlist. Otherwise we might well wind up inserting - * set-returning functions into places where they mustn't go, such as - * quals of higher queries. + * Don't pull up a subquery that has any set-returning functions in its + * targetlist. Otherwise we might well wind up inserting set-returning + * functions into places where they mustn't go, such as quals of higher + * queries. */ if (expression_returns_set((Node *) subquery->targetList)) return false; /* * Hack: don't try to pull up a subquery with an empty jointree. - * query_planner() will correctly generate a Result plan for a - * jointree that's totally empty, but I don't think the right things - * happen if an empty FromExpr appears lower down in a jointree. Not - * worth working hard on this, just to collapse SubqueryScan/Result - * into Result... + * query_planner() will correctly generate a Result plan for a jointree + * that's totally empty, but I don't think the right things happen if an + * empty FromExpr appears lower down in a jointree. Not worth working hard + * on this, just to collapse SubqueryScan/Result into Result... */ if (subquery->jointree->fromlist == NIL) return false; @@ -545,8 +542,8 @@ resolvenew_in_jointree(Node *jtnode, int varno, subtlist, CMD_SELECT, 0); /* - * We don't bother to update the colvars list, since it won't be - * used again ... + * We don't bother to update the colvars list, since it won't be used + * again ... */ } else @@ -583,14 +580,13 @@ reduce_outer_joins(PlannerInfo *root) reduce_outer_joins_state *state; /* - * To avoid doing strictness checks on more quals than necessary, we - * want to stop descending the jointree as soon as there are no outer - * joins below our current point. This consideration forces a - * two-pass process. The first pass gathers information about which - * base rels appear below each side of each join clause, and about - * whether there are outer join(s) below each side of each join - * clause. The second pass examines qual clauses and changes join - * types as it descends the tree. + * To avoid doing strictness checks on more quals than necessary, we want + * to stop descending the jointree as soon as there are no outer joins + * below our current point. This consideration forces a two-pass process. + * The first pass gathers information about which base rels appear below + * each side of each join clause, and about whether there are outer + * join(s) below each side of each join clause. The second pass examines + * qual clauses and changes join types as it descends the tree. */ state = reduce_outer_joins_pass1((Node *) root->parse->jointree); @@ -768,12 +764,11 @@ reduce_outer_joins_pass2(Node *jtnode, /* * If this join is (now) inner, we can add any nonnullability - * constraints its quals provide to those we got from above. - * But if it is outer, we can only pass down the local - * constraints into the nullable side, because an outer join - * never eliminates any rows from its non-nullable side. If - * it's a FULL join then it doesn't eliminate anything from - * either side. + * constraints its quals provide to those we got from above. But + * if it is outer, we can only pass down the local constraints + * into the nullable side, because an outer join never eliminates + * any rows from its non-nullable side. If it's a FULL join then + * it doesn't eliminate anything from either side. */ if (jointype != JOIN_FULL) { @@ -782,8 +777,7 @@ reduce_outer_joins_pass2(Node *jtnode, nonnullable_rels); } else - local_nonnullable = NULL; /* no use in calculating - * it */ + local_nonnullable = NULL; /* no use in calculating it */ if (left_state->contains_outer) { @@ -886,8 +880,8 @@ find_nonnullable_rels(Node *node, bool top_level) NullTest *expr = (NullTest *) node; /* - * IS NOT NULL can be considered strict, but only at top level; - * else we might have something like NOT (x IS NOT NULL). + * IS NOT NULL can be considered strict, but only at top level; else + * we might have something like NOT (x IS NOT NULL). */ if (top_level && expr->nulltesttype == IS_NOT_NULL) result = find_nonnullable_rels((Node *) expr->arg, false); @@ -960,10 +954,10 @@ simplify_jointree(PlannerInfo *root, Node *jtnode) if (child && IsA(child, FromExpr)) { /* - * Yes, so do we want to merge it into parent? Always do - * so if child has just one element (since that doesn't - * make the parent's list any longer). Otherwise merge if - * the resulting join list would be no longer than + * Yes, so do we want to merge it into parent? Always do so + * if child has just one element (since that doesn't make the + * parent's list any longer). Otherwise merge if the + * resulting join list would be no longer than * from_collapse_limit. */ FromExpr *subf = (FromExpr *) child; @@ -976,9 +970,9 @@ simplify_jointree(PlannerInfo *root, Node *jtnode) newlist = list_concat(newlist, subf->fromlist); /* - * By now, the quals have been converted to - * implicit-AND lists, so we just need to join the - * lists. NOTE: we put the pulled-up quals first. + * By now, the quals have been converted to implicit-AND + * lists, so we just need to join the lists. NOTE: we put + * the pulled-up quals first. */ f->quals = (Node *) list_concat((List *) subf->quals, (List *) f->quals); @@ -1000,8 +994,8 @@ simplify_jointree(PlannerInfo *root, Node *jtnode) j->rarg = simplify_jointree(root, j->rarg); /* - * If it is an outer join, we must not flatten it. An inner join - * is semantically equivalent to a FromExpr; we convert it to one, + * If it is an outer join, we must not flatten it. An inner join is + * semantically equivalent to a FromExpr; we convert it to one, * allowing it to be flattened into its parent, if the resulting * FromExpr would have no more than join_collapse_limit members. */ diff --git a/src/backend/optimizer/prep/prepqual.c b/src/backend/optimizer/prep/prepqual.c index 2c39859a81..9fad52acfe 100644 --- a/src/backend/optimizer/prep/prepqual.c +++ b/src/backend/optimizer/prep/prepqual.c @@ -25,7 +25,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/prep/prepqual.c,v 1.50 2005/07/29 21:40:02 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/prep/prepqual.c,v 1.51 2005/10/15 02:49:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -73,10 +73,10 @@ canonicalize_qual(Expr *qual) return NULL; /* - * Push down NOTs. We do this only in the top-level boolean - * expression, without examining arguments of operators/functions. The - * main reason for doing this is to expose as much top-level AND/OR - * structure as we can, so there's no point in descending further. + * Push down NOTs. We do this only in the top-level boolean expression, + * without examining arguments of operators/functions. The main reason for + * doing this is to expose as much top-level AND/OR structure as we can, + * so there's no point in descending further. */ newqual = find_nots(qual); @@ -110,12 +110,12 @@ pull_ands(List *andlist) /* * Note: we can destructively concat the subexpression's arglist * because we know the recursive invocation of pull_ands will have - * built a new arglist not shared with any other expr. Otherwise - * we'd need a list_copy here. + * built a new arglist not shared with any other expr. Otherwise we'd + * need a list_copy here. */ if (and_clause(subexpr)) out_list = list_concat(out_list, - pull_ands(((BoolExpr *) subexpr)->args)); + pull_ands(((BoolExpr *) subexpr)->args)); else out_list = lappend(out_list, subexpr); } @@ -142,12 +142,12 @@ pull_ors(List *orlist) /* * Note: we can destructively concat the subexpression's arglist * because we know the recursive invocation of pull_ors will have - * built a new arglist not shared with any other expr. Otherwise - * we'd need a list_copy here. + * built a new arglist not shared with any other expr. Otherwise we'd + * need a list_copy here. */ if (or_clause(subexpr)) out_list = list_concat(out_list, - pull_ors(((BoolExpr *) subexpr)->args)); + pull_ors(((BoolExpr *) subexpr)->args)); else out_list = lappend(out_list, subexpr); } @@ -249,8 +249,8 @@ push_nots(Expr *qual) { /* * Another NOT cancels this NOT, so eliminate the NOT and stop - * negating this branch. But search the subexpression for more - * NOTs to simplify. + * negating this branch. But search the subexpression for more NOTs + * to simplify. */ return find_nots(get_notclausearg(qual)); } @@ -307,8 +307,8 @@ find_duplicate_ors(Expr *qual) orlist = lappend(orlist, find_duplicate_ors(lfirst(temp))); /* - * Don't need pull_ors() since this routine will never introduce - * an OR where there wasn't one before. + * Don't need pull_ors() since this routine will never introduce an OR + * where there wasn't one before. */ return process_duplicate_ors(orlist); } @@ -353,10 +353,10 @@ process_duplicate_ors(List *orlist) return linitial(orlist); /* - * Choose the shortest AND clause as the reference list --- obviously, - * any subclause not in this clause isn't in all the clauses. If we - * find a clause that's not an AND, we can treat it as a one-element - * AND clause, which necessarily wins as shortest. + * Choose the shortest AND clause as the reference list --- obviously, any + * subclause not in this clause isn't in all the clauses. If we find a + * clause that's not an AND, we can treat it as a one-element AND clause, + * which necessarily wins as shortest. */ foreach(temp, orlist) { @@ -386,8 +386,8 @@ process_duplicate_ors(List *orlist) reference = list_union(NIL, reference); /* - * Check each element of the reference list to see if it's in all the - * OR clauses. Build a new list of winning clauses. + * Check each element of the reference list to see if it's in all the OR + * clauses. Build a new list of winning clauses. */ winners = NIL; foreach(temp, reference) @@ -431,13 +431,12 @@ process_duplicate_ors(List *orlist) /* * Generate new OR list consisting of the remaining sub-clauses. * - * If any clause degenerates to empty, then we have a situation like (A - * AND B) OR (A), which can be reduced to just A --- that is, the - * additional conditions in other arms of the OR are irrelevant. + * If any clause degenerates to empty, then we have a situation like (A AND + * B) OR (A), which can be reduced to just A --- that is, the additional + * conditions in other arms of the OR are irrelevant. * - * Note that because we use list_difference, any multiple occurrences of - * a winning clause in an AND sub-clause will be removed - * automatically. + * Note that because we use list_difference, any multiple occurrences of a + * winning clause in an AND sub-clause will be removed automatically. */ neworlist = NIL; foreach(temp, orlist) @@ -475,10 +474,10 @@ process_duplicate_ors(List *orlist) } /* - * Append reduced OR to the winners list, if it's not degenerate, - * handling the special case of one element correctly (can that really - * happen?). Also be careful to maintain AND/OR flatness in case we - * pulled up a sub-sub-OR-clause. + * Append reduced OR to the winners list, if it's not degenerate, handling + * the special case of one element correctly (can that really happen?). + * Also be careful to maintain AND/OR flatness in case we pulled up a + * sub-sub-OR-clause. */ if (neworlist != NIL) { diff --git a/src/backend/optimizer/prep/preptlist.c b/src/backend/optimizer/prep/preptlist.c index fa56c5fc29..f23d0554e7 100644 --- a/src/backend/optimizer/prep/preptlist.c +++ b/src/backend/optimizer/prep/preptlist.c @@ -15,7 +15,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/prep/preptlist.c,v 1.77 2005/06/05 22:32:56 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/prep/preptlist.c,v 1.78 2005/10/15 02:49:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -45,10 +45,10 @@ static List *expand_targetlist(List *tlist, int command_type, List * preprocess_targetlist(PlannerInfo *root, List *tlist) { - Query *parse = root->parse; - int result_relation = parse->resultRelation; - List *range_table = parse->rtable; - CmdType command_type = parse->commandType; + Query *parse = root->parse; + int result_relation = parse->resultRelation; + List *range_table = parse->rtable; + CmdType command_type = parse->commandType; /* * Sanity check: if there is a result relation, it'd better be a real @@ -63,20 +63,20 @@ preprocess_targetlist(PlannerInfo *root, List *tlist) } /* - * for heap_formtuple to work, the targetlist must match the exact - * order of the attributes. We also need to fill in any missing - * attributes. -ay 10/94 + * for heap_formtuple to work, the targetlist must match the exact order + * of the attributes. We also need to fill in any missing attributes. + * -ay 10/94 */ if (command_type == CMD_INSERT || command_type == CMD_UPDATE) tlist = expand_targetlist(tlist, command_type, result_relation, range_table); /* - * for "update" and "delete" queries, add ctid of the result relation - * into the target list so that the ctid will propagate through - * execution and ExecutePlan() will be able to identify the right - * tuple to replace or delete. This extra field is marked "junk" so - * that it is not stored back into the tuple. + * for "update" and "delete" queries, add ctid of the result relation into + * the target list so that the ctid will propagate through execution and + * ExecutePlan() will be able to identify the right tuple to replace or + * delete. This extra field is marked "junk" so that it is not stored + * back into the tuple. */ if (command_type == CMD_UPDATE || command_type == CMD_DELETE) { @@ -92,9 +92,9 @@ preprocess_targetlist(PlannerInfo *root, List *tlist) true); /* - * For an UPDATE, expand_targetlist already created a fresh tlist. - * For DELETE, better do a listCopy so that we don't destructively - * modify the original tlist (is this really necessary?). + * For an UPDATE, expand_targetlist already created a fresh tlist. For + * DELETE, better do a listCopy so that we don't destructively modify + * the original tlist (is this really necessary?). */ if (command_type == CMD_DELETE) tlist = list_copy(tlist); @@ -103,31 +103,28 @@ preprocess_targetlist(PlannerInfo *root, List *tlist) } /* - * Add TID targets for rels selected FOR UPDATE/SHARE. The executor - * uses the TID to know which rows to lock, much as for UPDATE or - * DELETE. + * Add TID targets for rels selected FOR UPDATE/SHARE. The executor uses + * the TID to know which rows to lock, much as for UPDATE or DELETE. */ if (parse->rowMarks) { ListCell *l; /* - * We've got trouble if the FOR UPDATE/SHARE appears inside - * grouping, since grouping renders a reference to individual - * tuple CTIDs invalid. This is also checked at parse time, - * but that's insufficient because of rule substitution, query - * pullup, etc. + * We've got trouble if the FOR UPDATE/SHARE appears inside grouping, + * since grouping renders a reference to individual tuple CTIDs + * invalid. This is also checked at parse time, but that's + * insufficient because of rule substitution, query pullup, etc. */ CheckSelectLocking(parse, parse->forUpdate); /* - * Currently the executor only supports FOR UPDATE/SHARE at top - * level + * Currently the executor only supports FOR UPDATE/SHARE at top level */ if (PlannerQueryLevel > 1) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("SELECT FOR UPDATE/SHARE is not allowed in subqueries"))); + errmsg("SELECT FOR UPDATE/SHARE is not allowed in subqueries"))); foreach(l, parse->rowMarks) { @@ -185,14 +182,13 @@ expand_targetlist(List *tlist, int command_type, tlist_item = list_head(tlist); /* - * The rewriter should have already ensured that the TLEs are in - * correct order; but we have to insert TLEs for any missing - * attributes. + * The rewriter should have already ensured that the TLEs are in correct + * order; but we have to insert TLEs for any missing attributes. * - * Scan the tuple description in the relation's relcache entry to make - * sure we have all the user attributes in the right order. We assume - * that the rewriter already acquired at least AccessShareLock on the - * relation, so we need no lock here. + * Scan the tuple description in the relation's relcache entry to make sure + * we have all the user attributes in the right order. We assume that the + * rewriter already acquired at least AccessShareLock on the relation, so + * we need no lock here. */ rel = heap_open(getrelid(result_relation, range_table), NoLock); @@ -220,23 +216,22 @@ expand_targetlist(List *tlist, int command_type, * Didn't find a matching tlist entry, so make one. * * For INSERT, generate a NULL constant. (We assume the rewriter - * would have inserted any available default value.) Also, if - * the column isn't dropped, apply any domain constraints that - * might exist --- this is to catch domain NOT NULL. + * would have inserted any available default value.) Also, if the + * column isn't dropped, apply any domain constraints that might + * exist --- this is to catch domain NOT NULL. * - * For UPDATE, generate a Var reference to the existing value of - * the attribute, so that it gets copied to the new tuple. But - * generate a NULL for dropped columns (we want to drop any - * old values). + * For UPDATE, generate a Var reference to the existing value of the + * attribute, so that it gets copied to the new tuple. But + * generate a NULL for dropped columns (we want to drop any old + * values). * - * When generating a NULL constant for a dropped column, we label - * it INT4 (any other guaranteed-to-exist datatype would do as - * well). We can't label it with the dropped column's - * datatype since that might not exist anymore. It does not - * really matter what we claim the type is, since NULL is NULL - * --- its representation is datatype-independent. This could - * perhaps confuse code comparing the finished plan to the - * target relation, however. + * When generating a NULL constant for a dropped column, we label it + * INT4 (any other guaranteed-to-exist datatype would do as well). + * We can't label it with the dropped column's datatype since that + * might not exist anymore. It does not really matter what we + * claim the type is, since NULL is NULL --- its representation is + * datatype-independent. This could perhaps confuse code + * comparing the finished plan to the target relation, however. */ Oid atttype = att_tup->atttypid; int32 atttypmod = att_tup->atttypmod; @@ -305,12 +300,12 @@ expand_targetlist(List *tlist, int command_type, } /* - * The remaining tlist entries should be resjunk; append them all to - * the end of the new tlist, making sure they have resnos higher than - * the last real attribute. (Note: although the rewriter already did - * such renumbering, we have to do it again here in case we are doing - * an UPDATE in a table with dropped columns, or an inheritance child - * table with extra columns.) + * The remaining tlist entries should be resjunk; append them all to the + * end of the new tlist, making sure they have resnos higher than the last + * real attribute. (Note: although the rewriter already did such + * renumbering, we have to do it again here in case we are doing an UPDATE + * in a table with dropped columns, or an inheritance child table with + * extra columns.) */ while (tlist_item) { diff --git a/src/backend/optimizer/prep/prepunion.c b/src/backend/optimizer/prep/prepunion.c index c8e9309354..dc7d94e1c6 100644 --- a/src/backend/optimizer/prep/prepunion.c +++ b/src/backend/optimizer/prep/prepunion.c @@ -14,7 +14,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/prep/prepunion.c,v 1.126 2005/08/02 20:27:45 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/prep/prepunion.c,v 1.127 2005/10/15 02:49:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -51,19 +51,19 @@ typedef struct } adjust_inherited_attrs_context; static Plan *recurse_set_operations(Node *setOp, PlannerInfo *root, - double tuple_fraction, - List *colTypes, bool junkOK, - int flag, List *refnames_tlist, - List **sortClauses); + double tuple_fraction, + List *colTypes, bool junkOK, + int flag, List *refnames_tlist, + List **sortClauses); static Plan *generate_union_plan(SetOperationStmt *op, PlannerInfo *root, - double tuple_fraction, - List *refnames_tlist, List **sortClauses); + double tuple_fraction, + List *refnames_tlist, List **sortClauses); static Plan *generate_nonunion_plan(SetOperationStmt *op, PlannerInfo *root, List *refnames_tlist, List **sortClauses); static List *recurse_union_children(Node *setOp, PlannerInfo *root, - double tuple_fraction, - SetOperationStmt *top_union, - List *refnames_tlist); + double tuple_fraction, + SetOperationStmt *top_union, + List *refnames_tlist); static List *generate_setop_tlist(List *colTypes, int flag, Index varno, bool hack_constants, @@ -117,8 +117,8 @@ plan_set_operations(PlannerInfo *root, double tuple_fraction, Assert(parse->distinctClause == NIL); /* - * Find the leftmost component Query. We need to use its column names - * for all generated tlists (else SELECT INTO won't work right). + * Find the leftmost component Query. We need to use its column names for + * all generated tlists (else SELECT INTO won't work right). */ node = topop->larg; while (node && IsA(node, SetOperationStmt)) @@ -129,10 +129,10 @@ plan_set_operations(PlannerInfo *root, double tuple_fraction, Assert(leftmostQuery != NULL); /* - * Recurse on setOperations tree to generate plans for set ops. The - * final output plan should have just the column types shown as the - * output from the top-level node, plus possibly resjunk working - * columns (we can rely on upper-level nodes to deal with that). + * Recurse on setOperations tree to generate plans for set ops. The final + * output plan should have just the column types shown as the output from + * the top-level node, plus possibly resjunk working columns (we can rely + * on upper-level nodes to deal with that). */ return recurse_set_operations((Node *) topop, root, tuple_fraction, topop->colTypes, true, -1, @@ -187,8 +187,8 @@ recurse_set_operations(Node *setOp, PlannerInfo *root, subplan); /* - * We don't bother to determine the subquery's output ordering - * since it won't be reflected in the set-op result anyhow. + * We don't bother to determine the subquery's output ordering since + * it won't be reflected in the set-op result anyhow. */ *sortClauses = NIL; @@ -214,13 +214,13 @@ recurse_set_operations(Node *setOp, PlannerInfo *root, * output columns. * * XXX you don't really want to know about this: setrefs.c will apply - * replace_vars_with_subplan_refs() to the Result node's tlist. - * This would fail if the Vars generated by generate_setop_tlist() - * were not exactly equal() to the corresponding tlist entries of - * the subplan. However, since the subplan was generated by - * generate_union_plan() or generate_nonunion_plan(), and hence - * its tlist was generated by generate_append_tlist(), this will - * work. We just tell generate_setop_tlist() to use varno 0. + * replace_vars_with_subplan_refs() to the Result node's tlist. This + * would fail if the Vars generated by generate_setop_tlist() were not + * exactly equal() to the corresponding tlist entries of the subplan. + * However, since the subplan was generated by generate_union_plan() + * or generate_nonunion_plan(), and hence its tlist was generated by + * generate_append_tlist(), this will work. We just tell + * generate_setop_tlist() to use varno 0. */ if (flag >= 0 || !tlist_same_datatypes(plan->targetlist, colTypes, junkOK)) @@ -260,22 +260,22 @@ generate_union_plan(SetOperationStmt *op, PlannerInfo *root, /* * If plain UNION, tell children to fetch all tuples. * - * Note: in UNION ALL, we pass the top-level tuple_fraction unmodified - * to each arm of the UNION ALL. One could make a case for reducing - * the tuple fraction for later arms (discounting by the expected size - * of the earlier arms' results) but it seems not worth the trouble. - * The normal case where tuple_fraction isn't already zero is a LIMIT - * at top level, and passing it down as-is is usually enough to get the - * desired result of preferring fast-start plans. + * Note: in UNION ALL, we pass the top-level tuple_fraction unmodified to + * each arm of the UNION ALL. One could make a case for reducing the + * tuple fraction for later arms (discounting by the expected size of the + * earlier arms' results) but it seems not worth the trouble. The normal + * case where tuple_fraction isn't already zero is a LIMIT at top level, + * and passing it down as-is is usually enough to get the desired result + * of preferring fast-start plans. */ if (!op->all) tuple_fraction = 0.0; /* - * If any of my children are identical UNION nodes (same op, all-flag, - * and colTypes) then they can be merged into this node so that we - * generate only one Append and Sort for the lot. Recurse to find - * such nodes and compute their children's plans. + * If any of my children are identical UNION nodes (same op, all-flag, and + * colTypes) then they can be merged into this node so that we generate + * only one Append and Sort for the lot. Recurse to find such nodes and + * compute their children's plans. */ planlist = list_concat(recurse_union_children(op->larg, root, tuple_fraction, @@ -288,8 +288,8 @@ generate_union_plan(SetOperationStmt *op, PlannerInfo *root, * Generate tlist for Append plan node. * * The tlist for an Append plan isn't important as far as the Append is - * concerned, but we must make it look real anyway for the benefit of - * the next plan level up. + * concerned, but we must make it look real anyway for the benefit of the + * next plan level up. */ tlist = generate_append_tlist(op->colTypes, false, planlist, refnames_tlist); @@ -300,8 +300,8 @@ generate_union_plan(SetOperationStmt *op, PlannerInfo *root, plan = (Plan *) make_append(planlist, false, tlist); /* - * For UNION ALL, we just need the Append plan. For UNION, need to - * add Sort and Unique nodes to produce unique output. + * For UNION ALL, we just need the Append plan. For UNION, need to add + * Sort and Unique nodes to produce unique output. */ if (!op->all) { @@ -340,12 +340,12 @@ generate_nonunion_plan(SetOperationStmt *op, PlannerInfo *root, /* Recurse on children, ensuring their outputs are marked */ lplan = recurse_set_operations(op->larg, root, - 0.0 /* all tuples needed */, + 0.0 /* all tuples needed */ , op->colTypes, false, 0, refnames_tlist, &child_sortclauses); rplan = recurse_set_operations(op->rarg, root, - 0.0 /* all tuples needed */, + 0.0 /* all tuples needed */ , op->colTypes, false, 1, refnames_tlist, &child_sortclauses); @@ -355,10 +355,10 @@ generate_nonunion_plan(SetOperationStmt *op, PlannerInfo *root, * Generate tlist for Append plan node. * * The tlist for an Append plan isn't important as far as the Append is - * concerned, but we must make it look real anyway for the benefit of - * the next plan level up. In fact, it has to be real enough that the - * flag column is shown as a variable not a constant, else setrefs.c - * will get confused. + * concerned, but we must make it look real anyway for the benefit of the + * next plan level up. In fact, it has to be real enough that the flag + * column is shown as a variable not a constant, else setrefs.c will get + * confused. */ tlist = generate_append_tlist(op->colTypes, true, planlist, refnames_tlist); @@ -439,12 +439,11 @@ recurse_union_children(Node *setOp, PlannerInfo *root, /* * Not same, so plan this child separately. * - * Note we disallow any resjunk columns in child results. This is - * necessary since the Append node that implements the union won't do - * any projection, and upper levels will get confused if some of our - * output tuples have junk and some don't. This case only arises when - * we have an EXCEPT or INTERSECT as child, else there won't be - * resjunk anyway. + * Note we disallow any resjunk columns in child results. This is necessary + * since the Append node that implements the union won't do any + * projection, and upper levels will get confused if some of our output + * tuples have junk and some don't. This case only arises when we have an + * EXCEPT or INTERSECT as child, else there won't be resjunk anyway. */ return list_make1(recurse_set_operations(setOp, root, tuple_fraction, @@ -492,17 +491,17 @@ generate_setop_tlist(List *colTypes, int flag, Assert(!reftle->resjunk); /* - * Generate columns referencing input columns and having - * appropriate data types and column names. Insert datatype - * coercions where necessary. + * Generate columns referencing input columns and having appropriate + * data types and column names. Insert datatype coercions where + * necessary. * - * HACK: constants in the input's targetlist are copied up as-is - * rather than being referenced as subquery outputs. This is - * mainly to ensure that when we try to coerce them to the output - * column's datatype, the right things happen for UNKNOWN - * constants. But do this only at the first level of - * subquery-scan plans; we don't want phony constants appearing in - * the output tlists of upper-level nodes! + * HACK: constants in the input's targetlist are copied up as-is rather + * than being referenced as subquery outputs. This is mainly to + * ensure that when we try to coerce them to the output column's + * datatype, the right things happen for UNKNOWN constants. But do + * this only at the first level of subquery-scan plans; we don't want + * phony constants appearing in the output tlists of upper-level + * nodes! */ if (hack_constants && inputtle->expr && IsA(inputtle->expr, Const)) expr = (Node *) inputtle->expr; @@ -710,7 +709,7 @@ find_all_inheritors(Oid parentrel) List *rels_list; ListCell *l; - /* + /* * We build a list starting with the given rel and adding all direct and * indirect children. We can use a single list as both the record of * already-found rels and the agenda of rels yet to be scanned for more @@ -728,11 +727,11 @@ find_all_inheritors(Oid parentrel) currentchildren = find_inheritance_children(currentrel); /* - * Add to the queue only those children not already seen. This - * avoids making duplicate entries in case of multiple inheritance - * paths from the same parent. (It'll also keep us from getting - * into an infinite loop, though theoretically there can't be any - * cycles in the inheritance graph anyway.) + * Add to the queue only those children not already seen. This avoids + * making duplicate entries in case of multiple inheritance paths from + * the same parent. (It'll also keep us from getting into an infinite + * loop, though theoretically there can't be any cycles in the + * inheritance graph anyway.) */ rels_list = list_concat_unique_oid(rels_list, currentchildren); } @@ -790,8 +789,8 @@ expand_inherited_rtentry(PlannerInfo *root, Index rti) /* * Check that there's at least one descendant, else treat as no-child - * case. This could happen despite above has_subclass() check, if - * table once had a child but no longer does. + * case. This could happen despite above has_subclass() check, if table + * once had a child but no longer does. */ if (list_length(inhOIDs) < 2) { @@ -809,19 +808,19 @@ expand_inherited_rtentry(PlannerInfo *root, Index rti) Index childRTindex; /* - * It is possible that the parent table has children that are - * temp tables of other backends. We cannot safely access such - * tables (because of buffering issues), and the best thing to do - * seems to be to silently ignore them. + * It is possible that the parent table has children that are temp + * tables of other backends. We cannot safely access such tables + * (because of buffering issues), and the best thing to do seems to be + * to silently ignore them. */ if (childOID != parentOID && isOtherTempNamespace(get_rel_namespace(childOID))) continue; /* - * Build an RTE for the child, and attach to query's rangetable - * list. We copy most fields of the parent's RTE, but replace - * relation OID, and set inh = false. + * Build an RTE for the child, and attach to query's rangetable list. + * We copy most fields of the parent's RTE, but replace relation OID, + * and set inh = false. */ childrte = copyObject(rte); childrte->relid = childOID; @@ -833,7 +832,8 @@ expand_inherited_rtentry(PlannerInfo *root, Index rti) /* * If all the children were temp tables, pretend it's a non-inheritance - * situation. The duplicate RTE we added for the parent table is harmless. + * situation. The duplicate RTE we added for the parent table is + * harmless. */ if (list_length(inhRTIs) < 2) { @@ -843,11 +843,11 @@ expand_inherited_rtentry(PlannerInfo *root, Index rti) } /* - * The executor will check the parent table's access permissions when - * it examines the parent's inheritlist entry. There's no need to - * check twice, so turn off access check bits in the original RTE. - * (If we are invoked more than once, extra copies of the child RTEs - * will also not cause duplicate permission checks.) + * The executor will check the parent table's access permissions when it + * examines the parent's inheritlist entry. There's no need to check + * twice, so turn off access check bits in the original RTE. (If we are + * invoked more than once, extra copies of the child RTEs will also not + * cause duplicate permission checks.) */ rte->requiredPerms = 0; @@ -882,9 +882,8 @@ adjust_inherited_attrs(Node *node, } /* - * We assume that by now the planner has acquired at least - * AccessShareLock on both rels, and so we need no additional lock - * now. + * We assume that by now the planner has acquired at least AccessShareLock + * on both rels, and so we need no additional lock now. */ oldrelation = heap_open(old_relid, NoLock); newrelation = heap_open(new_relid, NoLock); @@ -1035,7 +1034,7 @@ adjust_inherited_attrs_mutator(Node *node, JoinExpr *j; j = (JoinExpr *) expression_tree_mutator(node, - adjust_inherited_attrs_mutator, + adjust_inherited_attrs_mutator, (void *) context); /* now fix JoinExpr's rtindex */ if (j->rtindex == context->old_rt_index) @@ -1048,8 +1047,8 @@ adjust_inherited_attrs_mutator(Node *node, InClauseInfo *ininfo; ininfo = (InClauseInfo *) expression_tree_mutator(node, - adjust_inherited_attrs_mutator, - (void *) context); + adjust_inherited_attrs_mutator, + (void *) context); /* now fix InClauseInfo's relid sets */ ininfo->lefthand = adjust_relid_set(ininfo->lefthand, context->old_rt_index, @@ -1119,10 +1118,10 @@ adjust_inherited_attrs_mutator(Node *node, /* * BUT: although we don't need to recurse into subplans, we do need to * make sure that they are copied, not just referenced as - * expression_tree_mutator will do by default. Otherwise we'll have - * the same subplan node referenced from each arm of the inheritance - * APPEND plan, which will cause trouble in the executor. This is a - * kluge that should go away when we redesign querytrees. + * expression_tree_mutator will do by default. Otherwise we'll have the + * same subplan node referenced from each arm of the inheritance APPEND + * plan, which will cause trouble in the executor. This is a kluge that + * should go away when we redesign querytrees. */ if (is_subplan(node)) { @@ -1205,8 +1204,8 @@ adjust_inherited_tlist(List *tlist, /* * If we changed anything, re-sort the tlist by resno, and make sure * resjunk entries have resnos above the last real resno. The sort - * algorithm is a bit stupid, but for such a seldom-taken path, small - * is probably better than fast. + * algorithm is a bit stupid, but for such a seldom-taken path, small is + * probably better than fast. */ if (!changed_it) return tlist; diff --git a/src/backend/optimizer/util/clauses.c b/src/backend/optimizer/util/clauses.c index 496a4b03f4..5e2718dc63 100644 --- a/src/backend/optimizer/util/clauses.c +++ b/src/backend/optimizer/util/clauses.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.200 2005/07/03 21:14:17 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.201 2005/10/15 02:49:21 momjian Exp $ * * HISTORY * AUTHOR DATE MAJOR EVENT @@ -91,7 +91,7 @@ static Expr *inline_function(Oid funcid, Oid result_type, List *args, static Node *substitute_actual_parameters(Node *expr, int nargs, List *args, int *usecounts); static Node *substitute_actual_parameters_mutator(Node *node, - substitute_actual_parameters_context *context); + substitute_actual_parameters_context *context); static void sql_inline_error_callback(void *arg); static Expr *evaluate_expr(Expr *expr, Oid result_type); @@ -308,10 +308,10 @@ List * make_ands_implicit(Expr *clause) { /* - * NB: because the parser sets the qual field to NULL in a query that - * has no WHERE clause, we must consider a NULL input clause as TRUE, - * even though one might more reasonably think it FALSE. Grumble. If - * this causes trouble, consider changing the parser's behavior. + * NB: because the parser sets the qual field to NULL in a query that has + * no WHERE clause, we must consider a NULL input clause as TRUE, even + * though one might more reasonably think it FALSE. Grumble. If this + * causes trouble, consider changing the parser's behavior. */ if (clause == NULL) return NIL; /* NULL -> NIL list == TRUE */ @@ -357,8 +357,7 @@ contain_agg_clause_walker(Node *node, void *context) if (IsA(node, Aggref)) { Assert(((Aggref *) node)->agglevelsup == 0); - return true; /* abort the tree traversal and return - * true */ + return true; /* abort the tree traversal and return true */ } Assert(!IsA(node, SubLink)); return expression_tree_walker(node, contain_agg_clause_walker, context); @@ -438,9 +437,9 @@ count_agg_clauses_walker(Node *node, AggClauseCounts *counts) /* * If the transition type is pass-by-value then it doesn't add - * anything to the required size of the hashtable. If it is - * pass-by-reference then we have to add the estimated size of - * the value itself, plus palloc overhead. + * anything to the required size of the hashtable. If it is + * pass-by-reference then we have to add the estimated size of the + * value itself, plus palloc overhead. */ if (!get_typbyval(aggtranstype)) { @@ -470,7 +469,7 @@ count_agg_clauses_walker(Node *node, AggClauseCounts *counts) if (contain_agg_clause((Node *) aggref->target)) ereport(ERROR, (errcode(ERRCODE_GROUPING_ERROR), - errmsg("aggregate function calls may not be nested"))); + errmsg("aggregate function calls may not be nested"))); /* * Having checked that, we need not recurse into the argument. @@ -579,8 +578,7 @@ contain_subplans_walker(Node *node, void *context) return false; if (IsA(node, SubPlan) || IsA(node, SubLink)) - return true; /* abort the tree traversal and return - * true */ + return true; /* abort the tree traversal and return true */ return expression_tree_walker(node, contain_subplans_walker, context); } @@ -882,9 +880,9 @@ is_pseudo_constant_clause(Node *clause) { /* * We could implement this check in one recursive scan. But since the - * check for volatile functions is both moderately expensive and - * unlikely to fail, it seems better to look for Vars first and only - * check for volatile functions if we find no Vars. + * check for volatile functions is both moderately expensive and unlikely + * to fail, it seems better to look for Vars first and only check for + * volatile functions if we find no Vars. */ if (!contain_var_clause(clause) && !contain_volatile_functions(clause)) @@ -958,13 +956,12 @@ has_distinct_on_clause(Query *query) /* * If the DISTINCT list contains all the nonjunk targetlist items, and - * nothing else (ie, no junk tlist items), then it's a simple - * DISTINCT, else it's DISTINCT ON. We do not require the lists to be - * in the same order (since the parser may have adjusted the DISTINCT - * clause ordering to agree with ORDER BY). Furthermore, a - * non-DISTINCT junk tlist item that is in the sortClause is also - * evidence of DISTINCT ON, since we don't allow ORDER BY on junk - * tlist items when plain DISTINCT is used. + * nothing else (ie, no junk tlist items), then it's a simple DISTINCT, + * else it's DISTINCT ON. We do not require the lists to be in the same + * order (since the parser may have adjusted the DISTINCT clause ordering + * to agree with ORDER BY). Furthermore, a non-DISTINCT junk tlist item + * that is in the sortClause is also evidence of DISTINCT ON, since we + * don't allow ORDER BY on junk tlist items when plain DISTINCT is used. * * This code assumes that the DISTINCT list is valid, ie, all its entries * match some entry of the tlist. @@ -1224,7 +1221,7 @@ eval_const_expressions(Node *node) * * Currently the extra steps that are taken in this mode are: * 1. Substitute values for Params, where a bound Param value has been made - * available by the caller of planner(). + * available by the caller of planner(). * 2. Fold stable, as well as immutable, functions to constants. *-------------------- */ @@ -1264,11 +1261,11 @@ eval_const_expressions_mutator(Node *node, if (paramInfo) { /* - * Found it, so return a Const representing the param - * value. Note that we don't copy pass-by-ref datatypes, - * so the Const will only be valid as long as the bound - * parameter list exists. This is okay for intended uses - * of estimate_expression_value(). + * Found it, so return a Const representing the param value. + * Note that we don't copy pass-by-ref datatypes, so the Const + * will only be valid as long as the bound parameter list + * exists. This is okay for intended uses of + * estimate_expression_value(). */ int16 typLen; bool typByVal; @@ -1294,16 +1291,16 @@ eval_const_expressions_mutator(Node *node, /* * Reduce constants in the FuncExpr's arguments. We know args is - * either NIL or a List node, so we can call - * expression_tree_mutator directly rather than recursing to self. + * either NIL or a List node, so we can call expression_tree_mutator + * directly rather than recursing to self. */ args = (List *) expression_tree_mutator((Node *) expr->args, - eval_const_expressions_mutator, + eval_const_expressions_mutator, (void *) context); /* - * Code for op/func reduction is pretty bulky, so split it out as - * a separate function. + * Code for op/func reduction is pretty bulky, so split it out as a + * separate function. */ simple = simplify_function(expr->funcid, expr->funcresulttype, args, true, context); @@ -1312,8 +1309,8 @@ eval_const_expressions_mutator(Node *node, /* * The expression cannot be simplified any further, so build and - * return a replacement FuncExpr node using the - * possibly-simplified arguments. + * return a replacement FuncExpr node using the possibly-simplified + * arguments. */ newexpr = makeNode(FuncExpr); newexpr->funcid = expr->funcid; @@ -1331,23 +1328,23 @@ eval_const_expressions_mutator(Node *node, OpExpr *newexpr; /* - * Reduce constants in the OpExpr's arguments. We know args is - * either NIL or a List node, so we can call - * expression_tree_mutator directly rather than recursing to self. + * Reduce constants in the OpExpr's arguments. We know args is either + * NIL or a List node, so we can call expression_tree_mutator directly + * rather than recursing to self. */ args = (List *) expression_tree_mutator((Node *) expr->args, - eval_const_expressions_mutator, + eval_const_expressions_mutator, (void *) context); /* - * Need to get OID of underlying function. Okay to scribble on - * input to this extent. + * Need to get OID of underlying function. Okay to scribble on input + * to this extent. */ set_opfuncid(expr); /* - * Code for op/func reduction is pretty bulky, so split it out as - * a separate function. + * Code for op/func reduction is pretty bulky, so split it out as a + * separate function. */ simple = simplify_function(expr->opfuncid, expr->opresulttype, args, true, context); @@ -1355,8 +1352,8 @@ eval_const_expressions_mutator(Node *node, return (Node *) simple; /* - * If the operator is boolean equality, we know how to simplify - * cases involving one constant and one non-constant argument. + * If the operator is boolean equality, we know how to simplify cases + * involving one constant and one non-constant argument. */ if (expr->opno == BooleanEqualOperator) { @@ -1390,18 +1387,17 @@ eval_const_expressions_mutator(Node *node, DistinctExpr *newexpr; /* - * Reduce constants in the DistinctExpr's arguments. We know args - * is either NIL or a List node, so we can call - * expression_tree_mutator directly rather than recursing to self. + * Reduce constants in the DistinctExpr's arguments. We know args is + * either NIL or a List node, so we can call expression_tree_mutator + * directly rather than recursing to self. */ args = (List *) expression_tree_mutator((Node *) expr->args, - eval_const_expressions_mutator, + eval_const_expressions_mutator, (void *) context); /* * We must do our own check for NULLs because DistinctExpr has - * different results for NULL input than the underlying operator - * does. + * different results for NULL input than the underlying operator does. */ foreach(arg, args) { @@ -1429,15 +1425,14 @@ eval_const_expressions_mutator(Node *node, /* (NOT okay to try to inline it, though!) */ /* - * Need to get OID of underlying function. Okay to scribble - * on input to this extent. + * Need to get OID of underlying function. Okay to scribble on + * input to this extent. */ - set_opfuncid((OpExpr *) expr); /* rely on struct - * equivalence */ + set_opfuncid((OpExpr *) expr); /* rely on struct equivalence */ /* - * Code for op/func reduction is pretty bulky, so split it out - * as a separate function. + * Code for op/func reduction is pretty bulky, so split it out as + * a separate function. */ simple = simplify_function(expr->opfuncid, expr->opresulttype, args, false, context); @@ -1482,7 +1477,7 @@ eval_const_expressions_mutator(Node *node, bool forceTrue = false; newargs = simplify_or_arguments(expr->args, context, - &haveNull, &forceTrue); + &haveNull, &forceTrue); if (forceTrue) return makeBoolConst(true, false); if (haveNull) @@ -1503,7 +1498,7 @@ eval_const_expressions_mutator(Node *node, bool forceFalse = false; newargs = simplify_and_arguments(expr->args, context, - &haveNull, &forceFalse); + &haveNull, &forceFalse); if (forceFalse) return makeBoolConst(false, false); if (haveNull) @@ -1554,17 +1549,17 @@ eval_const_expressions_mutator(Node *node, /* * Return a SubPlan unchanged --- too late to do anything with it. * - * XXX should we ereport() here instead? Probably this routine - * should never be invoked after SubPlan creation. + * XXX should we ereport() here instead? Probably this routine should + * never be invoked after SubPlan creation. */ return node; } if (IsA(node, RelabelType)) { /* - * If we can simplify the input to a constant, then we don't need - * the RelabelType node anymore: just change the type field of the - * Const node. Otherwise, must copy the RelabelType node. + * If we can simplify the input to a constant, then we don't need the + * RelabelType node anymore: just change the type field of the Const + * node. Otherwise, must copy the RelabelType node. */ RelabelType *relabel = (RelabelType *) node; Node *arg; @@ -1573,8 +1568,8 @@ eval_const_expressions_mutator(Node *node, context); /* - * If we find stacked RelabelTypes (eg, from foo :: int :: oid) we - * can discard all but the top one. + * If we find stacked RelabelTypes (eg, from foo :: int :: oid) we can + * discard all but the top one. */ while (arg && IsA(arg, RelabelType)) arg = (Node *) ((RelabelType *) arg)->arg; @@ -1586,10 +1581,9 @@ eval_const_expressions_mutator(Node *node, con->consttype = relabel->resulttype; /* - * relabel's resulttypmod is discarded, which is OK for now; - * if the type actually needs a runtime length coercion then - * there should be a function call to do it just above this - * node. + * relabel's resulttypmod is discarded, which is OK for now; if + * the type actually needs a runtime length coercion then there + * should be a function call to do it just above this node. */ return (Node *) con; } @@ -1692,7 +1686,7 @@ eval_const_expressions_mutator(Node *node, /* * Found a TRUE condition, so none of the remaining alternatives - * can be reached. We treat the result as the default result. + * can be reached. We treat the result as the default result. */ defresult = caseresult; break; @@ -1720,9 +1714,9 @@ eval_const_expressions_mutator(Node *node, if (IsA(node, CaseTestExpr)) { /* - * If we know a constant test value for the current CASE - * construct, substitute it for the placeholder. Else just - * return the placeholder as-is. + * If we know a constant test value for the current CASE construct, + * substitute it for the placeholder. Else just return the + * placeholder as-is. */ if (context->case_val) return copyObject(context->case_val); @@ -1803,15 +1797,15 @@ eval_const_expressions_mutator(Node *node, if (IsA(node, FieldSelect)) { /* - * We can optimize field selection from a whole-row Var into a - * simple Var. (This case won't be generated directly by the - * parser, because ParseComplexProjection short-circuits it. But - * it can arise while simplifying functions.) Also, we can - * optimize field selection from a RowExpr construct. + * We can optimize field selection from a whole-row Var into a simple + * Var. (This case won't be generated directly by the parser, because + * ParseComplexProjection short-circuits it. But it can arise while + * simplifying functions.) Also, we can optimize field selection from + * a RowExpr construct. * - * We must however check that the declared type of the field is still - * the same as when the FieldSelect was created --- this can - * change if someone did ALTER COLUMN TYPE on the rowtype. + * We must however check that the declared type of the field is still the + * same as when the FieldSelect was created --- this can change if + * someone did ALTER COLUMN TYPE on the rowtype. */ FieldSelect *fselect = (FieldSelect *) node; FieldSelect *newfselect; @@ -1840,7 +1834,7 @@ eval_const_expressions_mutator(Node *node, fselect->fieldnum <= list_length(rowexpr->args)) { Node *fld = (Node *) list_nth(rowexpr->args, - fselect->fieldnum - 1); + fselect->fieldnum - 1); if (rowtype_field_matches(rowexpr->row_typeid, fselect->fieldnum, @@ -1861,10 +1855,10 @@ eval_const_expressions_mutator(Node *node, /* * For any node type not handled above, we recurse using - * expression_tree_mutator, which will copy the node unchanged but try - * to simplify its arguments (if any) using this routine. For example: - * we cannot eliminate an ArrayRef node, but we might be able to - * simplify constant expressions in its subscripts. + * expression_tree_mutator, which will copy the node unchanged but try to + * simplify its arguments (if any) using this routine. For example: we + * cannot eliminate an ArrayRef node, but we might be able to simplify + * constant expressions in its subscripts. */ return expression_tree_mutator(node, eval_const_expressions_mutator, (void *) context); @@ -1900,7 +1894,7 @@ simplify_or_arguments(List *args, /* * Since the parser considers OR to be a binary operator, long OR lists * become deeply nested expressions. We must flatten these into long - * argument lists of a single OR operator. To avoid blowing out the stack + * argument lists of a single OR operator. To avoid blowing out the stack * with recursion of eval_const_expressions, we resort to some tenseness * here: we keep a list of not-yet-processed inputs, and handle flattening * of nested ORs by prepending to the to-do list instead of recursing. @@ -1915,14 +1909,14 @@ simplify_or_arguments(List *args, /* flatten nested ORs as per above comment */ if (or_clause(arg)) { - List *subargs = list_copy(((BoolExpr *) arg)->args); + List *subargs = list_copy(((BoolExpr *) arg)->args); /* overly tense code to avoid leaking unused list header */ if (!unprocessed_args) unprocessed_args = subargs; else { - List *oldhdr = unprocessed_args; + List *oldhdr = unprocessed_args; unprocessed_args = list_concat(subargs, unprocessed_args); pfree(oldhdr); @@ -1934,23 +1928,22 @@ simplify_or_arguments(List *args, arg = eval_const_expressions_mutator(arg, context); /* - * It is unlikely but not impossible for simplification of a - * non-OR clause to produce an OR. Recheck, but don't be - * too tense about it since it's not a mainstream case. - * In particular we don't worry about const-simplifying - * the input twice. + * It is unlikely but not impossible for simplification of a non-OR + * clause to produce an OR. Recheck, but don't be too tense about it + * since it's not a mainstream case. In particular we don't worry + * about const-simplifying the input twice. */ if (or_clause(arg)) { - List *subargs = list_copy(((BoolExpr *) arg)->args); + List *subargs = list_copy(((BoolExpr *) arg)->args); unprocessed_args = list_concat(subargs, unprocessed_args); continue; } /* - * OK, we have a const-simplified non-OR argument. Process it - * per comments above. + * OK, we have a const-simplified non-OR argument. Process it per + * comments above. */ if (IsA(arg, Const)) { @@ -2018,14 +2011,14 @@ simplify_and_arguments(List *args, /* flatten nested ANDs as per above comment */ if (and_clause(arg)) { - List *subargs = list_copy(((BoolExpr *) arg)->args); + List *subargs = list_copy(((BoolExpr *) arg)->args); /* overly tense code to avoid leaking unused list header */ if (!unprocessed_args) unprocessed_args = subargs; else { - List *oldhdr = unprocessed_args; + List *oldhdr = unprocessed_args; unprocessed_args = list_concat(subargs, unprocessed_args); pfree(oldhdr); @@ -2037,23 +2030,22 @@ simplify_and_arguments(List *args, arg = eval_const_expressions_mutator(arg, context); /* - * It is unlikely but not impossible for simplification of a - * non-AND clause to produce an AND. Recheck, but don't be - * too tense about it since it's not a mainstream case. - * In particular we don't worry about const-simplifying - * the input twice. + * It is unlikely but not impossible for simplification of a non-AND + * clause to produce an AND. Recheck, but don't be too tense about it + * since it's not a mainstream case. In particular we don't worry + * about const-simplifying the input twice. */ if (and_clause(arg)) { - List *subargs = list_copy(((BoolExpr *) arg)->args); + List *subargs = list_copy(((BoolExpr *) arg)->args); unprocessed_args = list_concat(subargs, unprocessed_args); continue; } /* - * OK, we have a const-simplified non-AND argument. Process it - * per comments above. + * OK, we have a const-simplified non-AND argument. Process it per + * comments above. */ if (IsA(arg, Const)) { @@ -2111,7 +2103,7 @@ simplify_boolean_equality(List *args) { Assert(!((Const *) leftop)->constisnull); if (DatumGetBool(((Const *) leftop)->constvalue)) - return rightop; /* true = foo */ + return rightop; /* true = foo */ else return make_notclause(rightop); /* false = foo */ } @@ -2119,7 +2111,7 @@ simplify_boolean_equality(List *args) { Assert(!((Const *) rightop)->constisnull); if (DatumGetBool(((Const *) rightop)->constvalue)) - return leftop; /* foo = true */ + return leftop; /* foo = true */ else return make_notclause(leftop); /* foo = false */ } @@ -2146,12 +2138,12 @@ simplify_function(Oid funcid, Oid result_type, List *args, Expr *newexpr; /* - * We have two strategies for simplification: either execute the - * function to deliver a constant result, or expand in-line the body - * of the function definition (which only works for simple - * SQL-language functions, but that is a common case). In either case - * we need access to the function's pg_proc tuple, so fetch it just - * once to use in both attempts. + * We have two strategies for simplification: either execute the function + * to deliver a constant result, or expand in-line the body of the + * function definition (which only works for simple SQL-language + * functions, but that is a common case). In either case we need access + * to the function's pg_proc tuple, so fetch it just once to use in both + * attempts. */ func_tuple = SearchSysCache(PROCOID, ObjectIdGetDatum(funcid), @@ -2200,15 +2192,15 @@ evaluate_function(Oid funcid, Oid result_type, List *args, return NULL; /* - * Can't simplify if it returns RECORD. The immediate problem is that - * it will be needing an expected tupdesc which we can't supply here. + * Can't simplify if it returns RECORD. The immediate problem is that it + * will be needing an expected tupdesc which we can't supply here. * * In the case where it has OUT parameters, it could get by without an * expected tupdesc, but we still have issues: get_expr_result_type() - * doesn't know how to extract type info from a RECORD constant, and - * in the case of a NULL function result there doesn't seem to be any - * clean way to fix that. In view of the likelihood of there being - * still other gotchas, seems best to leave the function call unreduced. + * doesn't know how to extract type info from a RECORD constant, and in + * the case of a NULL function result there doesn't seem to be any clean + * way to fix that. In view of the likelihood of there being still other + * gotchas, seems best to leave the function call unreduced. */ if (funcform->prorettype == RECORDOID) return NULL; @@ -2225,10 +2217,10 @@ evaluate_function(Oid funcid, Oid result_type, List *args, } /* - * If the function is strict and has a constant-NULL input, it will - * never be called at all, so we can replace the call by a NULL - * constant, even if there are other inputs that aren't constant, and - * even if the function is not otherwise immutable. + * If the function is strict and has a constant-NULL input, it will never + * be called at all, so we can replace the call by a NULL constant, even + * if there are other inputs that aren't constant, and even if the + * function is not otherwise immutable. */ if (funcform->proisstrict && has_null_input) return (Expr *) makeNullConst(result_type); @@ -2242,16 +2234,16 @@ evaluate_function(Oid funcid, Oid result_type, List *args, return NULL; /* - * Ordinarily we are only allowed to simplify immutable functions. - * But for purposes of estimation, we consider it okay to simplify - * functions that are merely stable; the risk that the result might - * change from planning time to execution time is worth taking in - * preference to not being able to estimate the value at all. + * Ordinarily we are only allowed to simplify immutable functions. But for + * purposes of estimation, we consider it okay to simplify functions that + * are merely stable; the risk that the result might change from planning + * time to execution time is worth taking in preference to not being able + * to estimate the value at all. */ if (funcform->provolatile == PROVOLATILE_IMMUTABLE) - /* okay */ ; + /* okay */ ; else if (context->estimate && funcform->provolatile == PROVOLATILE_STABLE) - /* okay */ ; + /* okay */ ; else return NULL; @@ -2318,8 +2310,8 @@ inline_function(Oid funcid, Oid result_type, List *args, int i; /* - * Forget it if the function is not SQL-language or has other - * showstopper properties. (The nargs check is just paranoia.) + * Forget it if the function is not SQL-language or has other showstopper + * properties. (The nargs check is just paranoia.) */ if (funcform->prolang != SQLlanguageId || funcform->prosecdef || @@ -2336,8 +2328,8 @@ inline_function(Oid funcid, Oid result_type, List *args, return NULL; /* - * Setup error traceback support for ereport(). This is so that we - * can finger the function that bad information came from. + * Setup error traceback support for ereport(). This is so that we can + * finger the function that bad information came from. */ sqlerrcontext.callback = sql_inline_error_callback; sqlerrcontext.arg = func_tuple; @@ -2345,8 +2337,8 @@ inline_function(Oid funcid, Oid result_type, List *args, error_context_stack = &sqlerrcontext; /* - * Make a temporary memory context, so that we don't leak all the - * stuff that parsing might create. + * Make a temporary memory context, so that we don't leak all the stuff + * that parsing might create. */ mycxt = AllocSetContextCreate(CurrentMemoryContext, "inline_function", @@ -2383,10 +2375,10 @@ inline_function(Oid funcid, Oid result_type, List *args, src = DatumGetCString(DirectFunctionCall1(textout, tmp)); /* - * We just do parsing and parse analysis, not rewriting, because - * rewriting will not affect table-free-SELECT-only queries, which is - * all that we care about. Also, we can punt as soon as we detect - * more than one command in the function body. + * We just do parsing and parse analysis, not rewriting, because rewriting + * will not affect table-free-SELECT-only queries, which is all that we + * care about. Also, we can punt as soon as we detect more than one + * command in the function body. */ raw_parsetree_list = pg_parse_query(src); if (list_length(raw_parsetree_list) != 1) @@ -2425,24 +2417,24 @@ inline_function(Oid funcid, Oid result_type, List *args, newexpr = (Node *) ((TargetEntry *) linitial(querytree->targetList))->expr; /* - * If the function has any arguments declared as polymorphic types, - * then it wasn't type-checked at definition time; must do so now. - * (This will raise an error if wrong, but that's okay since the - * function would fail at runtime anyway. Note we do not try this - * until we have verified that no rewriting was needed; that's - * probably not important, but let's be careful.) + * If the function has any arguments declared as polymorphic types, then + * it wasn't type-checked at definition time; must do so now. (This will + * raise an error if wrong, but that's okay since the function would fail + * at runtime anyway. Note we do not try this until we have verified that + * no rewriting was needed; that's probably not important, but let's be + * careful.) */ if (polymorphic) (void) check_sql_fn_retval(funcid, result_type, querytree_list, NULL); /* - * Additional validity checks on the expression. It mustn't return a - * set, and it mustn't be more volatile than the surrounding function - * (this is to avoid breaking hacks that involve pretending a function - * is immutable when it really ain't). If the surrounding function is - * declared strict, then the expression must contain only strict - * constructs and must use all of the function parameters (this is - * overkill, but an exact analysis is hard). + * Additional validity checks on the expression. It mustn't return a set, + * and it mustn't be more volatile than the surrounding function (this is + * to avoid breaking hacks that involve pretending a function is immutable + * when it really ain't). If the surrounding function is declared strict, + * then the expression must contain only strict constructs and must use + * all of the function parameters (this is overkill, but an exact analysis + * is hard). */ if (expression_returns_set(newexpr)) goto fail; @@ -2459,10 +2451,10 @@ inline_function(Oid funcid, Oid result_type, List *args, goto fail; /* - * We may be able to do it; there are still checks on parameter usage - * to make, but those are most easily done in combination with the - * actual substitution of the inputs. So start building expression - * with inputs substituted. + * We may be able to do it; there are still checks on parameter usage to + * make, but those are most easily done in combination with the actual + * substitution of the inputs. So start building expression with inputs + * substituted. */ usecounts = (int *) palloc0(funcform->pronargs * sizeof(int)); newexpr = substitute_actual_parameters(newexpr, funcform->pronargs, @@ -2486,8 +2478,8 @@ inline_function(Oid funcid, Oid result_type, List *args, QualCost eval_cost; /* - * We define "expensive" as "contains any subplan or more than - * 10 operators". Note that the subplan search has to be done + * We define "expensive" as "contains any subplan or more than 10 + * operators". Note that the subplan search has to be done * explicitly, since cost_qual_eval() will barf on unplanned * subselects. */ @@ -2509,8 +2501,8 @@ inline_function(Oid funcid, Oid result_type, List *args, } /* - * Whew --- we can make the substitution. Copy the modified - * expression out of the temporary memory context, and clean up. + * Whew --- we can make the substitution. Copy the modified expression + * out of the temporary memory context, and clean up. */ MemoryContextSwitchTo(oldcxt); @@ -2519,8 +2511,8 @@ inline_function(Oid funcid, Oid result_type, List *args, MemoryContextDelete(mycxt); /* - * Recursively try to simplify the modified expression. Here we must - * add the current function to the context list of active functions. + * Recursively try to simplify the modified expression. Here we must add + * the current function to the context list of active functions. */ context->active_fns = lcons_oid(funcid, context->active_fns); newexpr = eval_const_expressions_mutator(newexpr, context); @@ -2557,7 +2549,7 @@ substitute_actual_parameters(Node *expr, int nargs, List *args, static Node * substitute_actual_parameters_mutator(Node *node, - substitute_actual_parameters_context *context) + substitute_actual_parameters_context *context) { if (node == NULL) return NULL; @@ -2646,10 +2638,10 @@ evaluate_expr(Expr *expr, Oid result_type) /* * And evaluate it. * - * It is OK to use a default econtext because none of the ExecEvalExpr() - * code used in this situation will use econtext. That might seem - * fortuitous, but it's not so unreasonable --- a constant expression - * does not depend on context, by definition, n'est ce pas? + * It is OK to use a default econtext because none of the ExecEvalExpr() code + * used in this situation will use econtext. That might seem fortuitous, + * but it's not so unreasonable --- a constant expression does not depend + * on context, by definition, n'est ce pas? */ const_val = ExecEvalExprSwitchContext(exprstate, GetPerTupleExprContext(estate), @@ -2779,12 +2771,12 @@ expression_tree_walker(Node *node, ListCell *temp; /* - * The walker has already visited the current node, and so we need - * only recurse into any sub-nodes it has. + * The walker has already visited the current node, and so we need only + * recurse into any sub-nodes it has. * - * We assume that the walker is not interested in List nodes per se, so - * when we expect a List we just recurse directly to self without - * bothering to call the walker. + * We assume that the walker is not interested in List nodes per se, so when + * we expect a List we just recurse directly to self without bothering to + * call the walker. */ if (node == NULL) return false; @@ -2877,8 +2869,8 @@ expression_tree_walker(Node *node, return true; /* - * Also invoke the walker on the sublink's Query node, so - * it can recurse into the sub-query if it wants to. + * Also invoke the walker on the sublink's Query node, so it + * can recurse into the sub-query if it wants to. */ return walker(sublink->subselect, context); } @@ -3167,8 +3159,8 @@ expression_tree_mutator(Node *node, void *context) { /* - * The mutator has already decided not to modify the current node, but - * we must call the mutator for any sub-nodes. + * The mutator has already decided not to modify the current node, but we + * must call the mutator for any sub-nodes. */ #define FLATCOPY(newnode, node, nodetype) \ @@ -3286,8 +3278,8 @@ expression_tree_mutator(Node *node, MUTATE(newnode->lefthand, sublink->lefthand, List *); /* - * Also invoke the mutator on the sublink's Query node, so - * it can recurse into the sub-query if it wants to. + * Also invoke the mutator on the sublink's Query node, so it + * can recurse into the sub-query if it wants to. */ MUTATE(newnode->subselect, sublink->subselect, Node *); return (Node *) newnode; @@ -3468,10 +3460,9 @@ expression_tree_mutator(Node *node, case T_List: { /* - * We assume the mutator isn't interested in the list - * nodes per se, so just invoke it on each list element. - * NOTE: this would fail badly on a list with integer - * elements! + * We assume the mutator isn't interested in the list nodes + * per se, so just invoke it on each list element. NOTE: this + * would fail badly on a list with integer elements! */ List *resultlist; ListCell *temp; diff --git a/src/backend/optimizer/util/pathnode.c b/src/backend/optimizer/util/pathnode.c index fc76c89329..934daf8b28 100644 --- a/src/backend/optimizer/util/pathnode.c +++ b/src/backend/optimizer/util/pathnode.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/util/pathnode.c,v 1.124 2005/07/22 19:12:01 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/util/pathnode.c,v 1.125 2005/10/15 02:49:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -59,8 +59,8 @@ compare_path_costs(Path *path1, Path *path2, CostSelector criterion) return +1; /* - * If paths have the same startup cost (not at all unlikely), - * order them by total cost. + * If paths have the same startup cost (not at all unlikely), order + * them by total cost. */ if (path1->total_cost < path2->total_cost) return -1; @@ -111,8 +111,8 @@ compare_fuzzy_path_costs(Path *path1, Path *path2, CostSelector criterion) return -1; /* - * If paths have the same startup cost (not at all unlikely), - * order them by total cost. + * If paths have the same startup cost (not at all unlikely), order + * them by total cost. */ if (path1->total_cost > path2->total_cost * 1.01) return +1; @@ -253,22 +253,21 @@ set_cheapest(RelOptInfo *parent_rel) void add_path(RelOptInfo *parent_rel, Path *new_path) { - bool accept_new = true; /* unless we find a superior old - * path */ + bool accept_new = true; /* unless we find a superior old path */ ListCell *insert_after = NULL; /* where to insert new item */ ListCell *p1_prev = NULL; ListCell *p1; /* - * This is a convenient place to check for query cancel --- no part - * of the planner goes very long without calling add_path(). + * This is a convenient place to check for query cancel --- no part of the + * planner goes very long without calling add_path(). */ CHECK_FOR_INTERRUPTS(); /* - * Loop to check proposed new path against old paths. Note it is - * possible for more than one old path to be tossed out because - * new_path dominates it. + * Loop to check proposed new path against old paths. Note it is possible + * for more than one old path to be tossed out because new_path dominates + * it. */ p1 = list_head(parent_rel->pathlist); /* cannot use foreach here */ while (p1 != NULL) @@ -278,20 +277,20 @@ add_path(RelOptInfo *parent_rel, Path *new_path) int costcmp; /* - * As of Postgres 8.0, we use fuzzy cost comparison to avoid - * wasting cycles keeping paths that are really not significantly - * different in cost. + * As of Postgres 8.0, we use fuzzy cost comparison to avoid wasting + * cycles keeping paths that are really not significantly different in + * cost. */ costcmp = compare_fuzzy_path_costs(new_path, old_path, TOTAL_COST); /* - * If the two paths compare differently for startup and total - * cost, then we want to keep both, and we can skip the (much - * slower) comparison of pathkeys. If they compare the same, - * proceed with the pathkeys comparison. Note: this test relies - * on the fact that compare_fuzzy_path_costs will only return 0 if - * both costs are effectively equal (and, therefore, there's no - * need to call it twice in that case). + * If the two paths compare differently for startup and total cost, + * then we want to keep both, and we can skip the (much slower) + * comparison of pathkeys. If they compare the same, proceed with the + * pathkeys comparison. Note: this test relies on the fact that + * compare_fuzzy_path_costs will only return 0 if both costs are + * effectively equal (and, therefore, there's no need to call it twice + * in that case). */ if (costcmp == 0 || costcmp == compare_fuzzy_path_costs(new_path, old_path, @@ -307,16 +306,15 @@ add_path(RelOptInfo *parent_rel, Path *new_path) else { /* - * Same pathkeys, and fuzzily the same cost, so - * keep just one --- but we'll do an exact cost - * comparison to decide which. + * Same pathkeys, and fuzzily the same cost, so keep + * just one --- but we'll do an exact cost comparison + * to decide which. */ if (compare_path_costs(new_path, old_path, TOTAL_COST) < 0) remove_old = true; /* new dominates old */ else - accept_new = false; /* old equals or dominates - * new */ + accept_new = false; /* old equals or dominates new */ } break; case PATHKEYS_BETTER1: @@ -340,6 +338,7 @@ add_path(RelOptInfo *parent_rel, Path *new_path) { parent_rel->pathlist = list_delete_cell(parent_rel->pathlist, p1, p1_prev); + /* * Delete the data pointed-to by the deleted cell, if possible */ @@ -442,10 +441,9 @@ create_index_path(PlannerInfo *root, /* * For a join inner scan, there's no point in marking the path with any * pathkeys, since it will only ever be used as the inner path of a - * nestloop, and so its ordering does not matter. For the same reason - * we don't really care what order it's scanned in. (We could expect - * the caller to supply the correct values, but it's easier to force - * it here.) + * nestloop, and so its ordering does not matter. For the same reason we + * don't really care what order it's scanned in. (We could expect the + * caller to supply the correct values, but it's easier to force it here.) */ if (isjoininner) { @@ -476,15 +474,15 @@ create_index_path(PlannerInfo *root, /* * We must compute the estimated number of output rows for the * indexscan. This is less than rel->rows because of the additional - * selectivity of the join clauses. Since clause_groups may - * contain both restriction and join clauses, we have to do a set - * union to get the full set of clauses that must be considered to - * compute the correct selectivity. (Without the union operation, - * we might have some restriction clauses appearing twice, which'd - * mislead clauselist_selectivity into double-counting their - * selectivity. However, since RestrictInfo nodes aren't copied when - * linking them into different lists, it should be sufficient to use - * pointer comparison to remove duplicates.) + * selectivity of the join clauses. Since clause_groups may contain + * both restriction and join clauses, we have to do a set union to get + * the full set of clauses that must be considered to compute the + * correct selectivity. (Without the union operation, we might have + * some restriction clauses appearing twice, which'd mislead + * clauselist_selectivity into double-counting their selectivity. + * However, since RestrictInfo nodes aren't copied when linking them + * into different lists, it should be sufficient to use pointer + * comparison to remove duplicates.) * * Always assume the join type is JOIN_INNER; even if some of the join * clauses come from other contexts, that's not our problem. @@ -493,7 +491,7 @@ create_index_path(PlannerInfo *root, pathnode->rows = rel->tuples * clauselist_selectivity(root, allclauses, - rel->relid, /* do not use 0! */ + rel->relid, /* do not use 0! */ JOIN_INNER); /* Like costsize.c, force estimate to be at least one row */ pathnode->rows = clamp_row_est(pathnode->rows); @@ -501,8 +499,8 @@ create_index_path(PlannerInfo *root, else { /* - * The number of rows is the same as the parent rel's estimate, - * since this isn't a join inner indexscan. + * The number of rows is the same as the parent rel's estimate, since + * this isn't a join inner indexscan. */ pathnode->rows = rel->rows; } @@ -528,7 +526,7 @@ create_bitmap_heap_path(PlannerInfo *root, pathnode->path.pathtype = T_BitmapHeapScan; pathnode->path.parent = rel; - pathnode->path.pathkeys = NIL; /* always unordered */ + pathnode->path.pathkeys = NIL; /* always unordered */ pathnode->bitmapqual = bitmapqual; pathnode->isjoininner = isjoininner; @@ -539,9 +537,9 @@ create_bitmap_heap_path(PlannerInfo *root, * We must compute the estimated number of output rows for the * indexscan. This is less than rel->rows because of the additional * selectivity of the join clauses. We make use of the selectivity - * estimated for the bitmap to do this; this isn't really quite - * right since there may be restriction conditions not included - * in the bitmap ... + * estimated for the bitmap to do this; this isn't really quite right + * since there may be restriction conditions not included in the + * bitmap ... */ Cost indexTotalCost; Selectivity indexSelectivity; @@ -556,8 +554,8 @@ create_bitmap_heap_path(PlannerInfo *root, else { /* - * The number of rows is the same as the parent rel's estimate, - * since this isn't a join inner indexscan. + * The number of rows is the same as the parent rel's estimate, since + * this isn't a join inner indexscan. */ pathnode->rows = rel->rows; } @@ -580,7 +578,7 @@ create_bitmap_and_path(PlannerInfo *root, pathnode->path.pathtype = T_BitmapAnd; pathnode->path.parent = rel; - pathnode->path.pathkeys = NIL; /* always unordered */ + pathnode->path.pathkeys = NIL; /* always unordered */ pathnode->bitmapquals = bitmapquals; @@ -603,7 +601,7 @@ create_bitmap_or_path(PlannerInfo *root, pathnode->path.pathtype = T_BitmapOr; pathnode->path.parent = rel; - pathnode->path.pathkeys = NIL; /* always unordered */ + pathnode->path.pathkeys = NIL; /* always unordered */ pathnode->bitmapquals = bitmapquals; @@ -759,8 +757,8 @@ create_unique_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath) return (UniquePath *) rel->cheapest_unique_path; /* - * We must ensure path struct is allocated in same context as parent - * rel; otherwise GEQO memory management causes trouble. (Compare + * We must ensure path struct is allocated in same context as parent rel; + * otherwise GEQO memory management causes trouble. (Compare * best_inner_indexscan().) */ oldcontext = MemoryContextSwitchTo(GetMemoryChunkContext(rel)); @@ -774,17 +772,17 @@ create_unique_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath) pathnode->path.parent = rel; /* - * Treat the output as always unsorted, since we don't necessarily - * have pathkeys to represent it. + * Treat the output as always unsorted, since we don't necessarily have + * pathkeys to represent it. */ pathnode->path.pathkeys = NIL; pathnode->subpath = subpath; /* - * Try to identify the targetlist that will actually be unique-ified. - * In current usage, this routine is only used for sub-selects of IN - * clauses, so we should be able to find the tlist in in_info_list. + * Try to identify the targetlist that will actually be unique-ified. In + * current usage, this routine is only used for sub-selects of IN clauses, + * so we should be able to find the tlist in in_info_list. */ sub_targetlist = NIL; foreach(l, root->in_info_list) @@ -799,19 +797,19 @@ create_unique_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath) } /* - * If the input is a subquery whose output must be unique already, - * then we don't need to do anything. The test for uniqueness has - * to consider exactly which columns we are extracting; for example - * "SELECT DISTINCT x,y" doesn't guarantee that x alone is distinct. - * So we cannot check for this optimization unless we found our own - * targetlist above, and it consists only of simple Vars referencing - * subquery outputs. (Possibly we could do something with expressions - * in the subquery outputs, too, but for now keep it simple.) + * If the input is a subquery whose output must be unique already, then we + * don't need to do anything. The test for uniqueness has to consider + * exactly which columns we are extracting; for example "SELECT DISTINCT + * x,y" doesn't guarantee that x alone is distinct. So we cannot check for + * this optimization unless we found our own targetlist above, and it + * consists only of simple Vars referencing subquery outputs. (Possibly + * we could do something with expressions in the subquery outputs, too, + * but for now keep it simple.) */ if (sub_targetlist && rel->rtekind == RTE_SUBQUERY) { RangeTblEntry *rte = rt_fetch(rel->relid, root->parse->rtable); - List *sub_tlist_colnos; + List *sub_tlist_colnos; sub_tlist_colnos = translate_sub_tlist(sub_targetlist, rel->relid); @@ -854,24 +852,23 @@ create_unique_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath) rel->width); /* - * Charge one cpu_operator_cost per comparison per input tuple. We - * assume all columns get compared at most of the tuples. (XXX - * probably this is an overestimate.) This should agree with - * make_unique. + * Charge one cpu_operator_cost per comparison per input tuple. We assume + * all columns get compared at most of the tuples. (XXX probably this is + * an overestimate.) This should agree with make_unique. */ sort_path.total_cost += cpu_operator_cost * rel->rows * numCols; /* - * Is it safe to use a hashed implementation? If so, estimate and - * compare costs. We only try this if we know the targetlist for sure - * (else we can't be sure about the datatypes involved). + * Is it safe to use a hashed implementation? If so, estimate and compare + * costs. We only try this if we know the targetlist for sure (else we + * can't be sure about the datatypes involved). */ pathnode->umethod = UNIQUE_PATH_SORT; if (enable_hashagg && sub_targetlist && hash_safe_tlist(sub_targetlist)) { /* - * Estimate the overhead per hashtable entry at 64 bytes (same as - * in planner.c). + * Estimate the overhead per hashtable entry at 64 bytes (same as in + * planner.c). */ int hashentrysize = rel->width + 64; @@ -923,7 +920,7 @@ translate_sub_tlist(List *tlist, int relid) foreach(l, tlist) { - Var *var = (Var *) lfirst(l); + Var *var = (Var *) lfirst(l); if (!var || !IsA(var, Var) || var->varno != relid) @@ -987,8 +984,8 @@ query_is_distinct_for(Query *query, List *colnos) else { /* - * If we have no GROUP BY, but do have aggregates or HAVING, then - * the result is at most one row so it's surely unique. + * If we have no GROUP BY, but do have aggregates or HAVING, then the + * result is at most one row so it's surely unique. */ if (query->hasAggs || query->havingQual) return true; @@ -1167,8 +1164,8 @@ create_mergejoin_path(PlannerInfo *root, MergePath *pathnode = makeNode(MergePath); /* - * If the given paths are already well enough ordered, we can skip - * doing an explicit sort. + * If the given paths are already well enough ordered, we can skip doing + * an explicit sort. */ if (outersortkeys && pathkeys_contained_in(outersortkeys, outer_path->pathkeys)) @@ -1178,15 +1175,15 @@ create_mergejoin_path(PlannerInfo *root, innersortkeys = NIL; /* - * If we are not sorting the inner path, we may need a materialize - * node to ensure it can be marked/restored. (Sort does support - * mark/restore, so no materialize is needed in that case.) + * If we are not sorting the inner path, we may need a materialize node to + * ensure it can be marked/restored. (Sort does support mark/restore, so + * no materialize is needed in that case.) * - * Since the inner side must be ordered, and only Sorts and IndexScans - * can create order to begin with, you might think there's no problem - * --- but you'd be wrong. Nestloop and merge joins can *preserve* - * the order of their inputs, so they can be selected as the input of - * a mergejoin, and they don't support mark/restore at present. + * Since the inner side must be ordered, and only Sorts and IndexScans can + * create order to begin with, you might think there's no problem --- but + * you'd be wrong. Nestloop and merge joins can *preserve* the order of + * their inputs, so they can be selected as the input of a mergejoin, and + * they don't support mark/restore at present. */ if (innersortkeys == NIL && !ExecSupportsMarkRestore(inner_path->pathtype)) diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c index d1656350f2..1686893940 100644 --- a/src/backend/optimizer/util/plancat.c +++ b/src/backend/optimizer/util/plancat.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/util/plancat.c,v 1.113 2005/07/23 21:05:47 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/util/plancat.c,v 1.114 2005/10/15 02:49:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -41,7 +41,7 @@ static void estimate_rel_size(Relation rel, int32 *attr_widths, - BlockNumber *pages, double *tuples); + BlockNumber *pages, double *tuples); /* @@ -71,18 +71,18 @@ get_relation_info(Oid relationObjectId, RelOptInfo *rel) /* * Normally, we can assume the rewriter already acquired at least - * AccessShareLock on each relation used in the query. However this - * will not be the case for relations added to the query because they - * are inheritance children of some relation mentioned explicitly. - * For them, this is the first access during the parse/rewrite/plan - * pipeline, and so we need to obtain and keep a suitable lock. + * AccessShareLock on each relation used in the query. However this will + * not be the case for relations added to the query because they are + * inheritance children of some relation mentioned explicitly. For them, + * this is the first access during the parse/rewrite/plan pipeline, and so + * we need to obtain and keep a suitable lock. * - * XXX really, a suitable lock is RowShareLock if the relation is - * an UPDATE/DELETE target, and AccessShareLock otherwise. However - * we cannot easily tell here which to get, so for the moment just - * get AccessShareLock always. The executor will get the right lock - * when it runs, which means there is a very small chance of deadlock - * trying to upgrade our lock. + * XXX really, a suitable lock is RowShareLock if the relation is an + * UPDATE/DELETE target, and AccessShareLock otherwise. However we cannot + * easily tell here which to get, so for the moment just get + * AccessShareLock always. The executor will get the right lock when it + * runs, which means there is a very small chance of deadlock trying to + * upgrade our lock. */ if (rel->reloptkind == RELOPT_BASEREL) relation = heap_open(relationObjectId, NoLock); @@ -105,8 +105,7 @@ get_relation_info(Oid relationObjectId, RelOptInfo *rel) &rel->pages, &rel->tuples); /* - * Make list of indexes. Ignore indexes on system catalogs if told - * to. + * Make list of indexes. Ignore indexes on system catalogs if told to. */ if (IsIgnoringSystemIndexes() && IsSystemClass(relation->rd_rel)) hasindex = false; @@ -133,10 +132,10 @@ get_relation_info(Oid relationObjectId, RelOptInfo *rel) /* * Extract info from the relation descriptor for the index. * - * Note that we take no lock on the index; we assume our lock on - * the parent table will protect the index's schema information. - * When and if the executor actually uses the index, it will take - * a lock as needed to protect the access to the index contents. + * Note that we take no lock on the index; we assume our lock on the + * parent table will protect the index's schema information. When + * and if the executor actually uses the index, it will take a + * lock as needed to protect the access to the index contents. */ indexRelation = index_open(indexoid); index = indexRelation->rd_index; @@ -148,8 +147,8 @@ get_relation_info(Oid relationObjectId, RelOptInfo *rel) info->ncolumns = ncolumns = index->indnatts; /* - * Need to make classlist and ordering arrays large enough to - * put a terminating 0 at the end of each one. + * Need to make classlist and ordering arrays large enough to put + * a terminating 0 at the end of each one. */ info->indexkeys = (int *) palloc(sizeof(int) * ncolumns); info->classlist = (Oid *) palloc0(sizeof(Oid) * (ncolumns + 1)); @@ -166,8 +165,7 @@ get_relation_info(Oid relationObjectId, RelOptInfo *rel) info->amoptionalkey = indexRelation->rd_am->amoptionalkey; /* - * Fetch the ordering operators associated with the index, if - * any. + * Fetch the ordering operators associated with the index, if any. */ amorderstrategy = indexRelation->rd_am->amorderstrategy; if (amorderstrategy != 0) @@ -184,8 +182,8 @@ get_relation_info(Oid relationObjectId, RelOptInfo *rel) /* * Fetch the index expressions and predicate, if any. We must * modify the copies we obtain from the relcache to have the - * correct varno for the parent relation, so that they match - * up correctly against qual clauses. + * correct varno for the parent relation, so that they match up + * correctly against qual clauses. */ info->indexprs = RelationGetIndexExpressions(indexRelation); info->indpred = RelationGetIndexPredicate(indexRelation); @@ -197,11 +195,11 @@ get_relation_info(Oid relationObjectId, RelOptInfo *rel) info->unique = index->indisunique; /* - * Estimate the index size. If it's not a partial index, we - * lock the number-of-tuples estimate to equal the parent table; - * if it is partial then we have to use the same methods as we - * would for a table, except we can be sure that the index is - * not larger than the table. + * Estimate the index size. If it's not a partial index, we lock + * the number-of-tuples estimate to equal the parent table; if it + * is partial then we have to use the same methods as we would for + * a table, except we can be sure that the index is not larger + * than the table. */ if (info->indpred == NIL) { @@ -241,8 +239,8 @@ static void estimate_rel_size(Relation rel, int32 *attr_widths, BlockNumber *pages, double *tuples) { - BlockNumber curpages; - BlockNumber relpages; + BlockNumber curpages; + BlockNumber relpages; double reltuples; double density; @@ -256,22 +254,22 @@ estimate_rel_size(Relation rel, int32 *attr_widths, /* * HACK: if the relation has never yet been vacuumed, use a - * minimum estimate of 10 pages. This emulates a desirable - * aspect of pre-8.0 behavior, which is that we wouldn't assume - * a newly created relation is really small, which saves us from - * making really bad plans during initial data loading. (The - * plans are not wrong when they are made, but if they are cached - * and used again after the table has grown a lot, they are bad.) - * It would be better to force replanning if the table size has - * changed a lot since the plan was made ... but we don't - * currently have any infrastructure for redoing cached plans at - * all, so we have to kluge things here instead. + * minimum estimate of 10 pages. This emulates a desirable aspect + * of pre-8.0 behavior, which is that we wouldn't assume a newly + * created relation is really small, which saves us from making + * really bad plans during initial data loading. (The plans are + * not wrong when they are made, but if they are cached and used + * again after the table has grown a lot, they are bad.) It would + * be better to force replanning if the table size has changed a + * lot since the plan was made ... but we don't currently have any + * infrastructure for redoing cached plans at all, so we have to + * kluge things here instead. * - * We approximate "never vacuumed" by "has relpages = 0", which - * means this will also fire on genuinely empty relations. Not - * great, but fortunately that's a seldom-seen case in the real - * world, and it shouldn't degrade the quality of the plan too - * much anyway to err in this direction. + * We approximate "never vacuumed" by "has relpages = 0", which means + * this will also fire on genuinely empty relations. Not great, + * but fortunately that's a seldom-seen case in the real world, + * and it shouldn't degrade the quality of the plan too much + * anyway to err in this direction. */ if (curpages < 10 && rel->rd_rel->relpages == 0) curpages = 10; @@ -287,6 +285,7 @@ estimate_rel_size(Relation rel, int32 *attr_widths, /* coerce values in pg_class to more desirable types */ relpages = (BlockNumber) rel->rd_rel->relpages; reltuples = (double) rel->rd_rel->reltuples; + /* * If it's an index, discount the metapage. This is a kluge * because it assumes more than it ought to about index contents; @@ -307,19 +306,19 @@ estimate_rel_size(Relation rel, int32 *attr_widths, * When we have no data because the relation was truncated, * estimate tuple width from attribute datatypes. We assume * here that the pages are completely full, which is OK for - * tables (since they've presumably not been VACUUMed yet) - * but is probably an overestimate for indexes. Fortunately + * tables (since they've presumably not been VACUUMed yet) but + * is probably an overestimate for indexes. Fortunately * get_relation_info() can clamp the overestimate to the * parent table's size. * * Note: this code intentionally disregards alignment - * considerations, because (a) that would be gilding the - * lily considering how crude the estimate is, and (b) - * it creates platform dependencies in the default plans - * which are kind of a headache for regression testing. + * considerations, because (a) that would be gilding the lily + * considering how crude the estimate is, and (b) it creates + * platform dependencies in the default plans which are kind + * of a headache for regression testing. */ - int32 tuple_width = 0; - int i; + int32 tuple_width = 0; + int i; for (i = 1; i <= RelationGetNumberOfAttributes(rel); i++) { @@ -391,12 +390,12 @@ get_relation_constraints(Oid relationObjectId, RelOptInfo *rel) constr = relation->rd_att->constr; if (constr != NULL) { - int num_check = constr->num_check; - int i; + int num_check = constr->num_check; + int i; for (i = 0; i < num_check; i++) { - Node *cexpr; + Node *cexpr; cexpr = stringToNode(constr->check[i].ccbin); @@ -425,8 +424,8 @@ get_relation_constraints(Oid relationObjectId, RelOptInfo *rel) ChangeVarNodes(cexpr, 1, varno, 0); /* - * Finally, convert to implicit-AND format (that is, a List) - * and append the resulting item(s) to our output list. + * Finally, convert to implicit-AND format (that is, a List) and + * append the resulting item(s) to our output list. */ result = list_concat(result, make_ands_implicit((Expr *) cexpr)); @@ -532,11 +531,12 @@ build_physical_tlist(PlannerInfo *root, RelOptInfo *rel) break; case RTE_FUNCTION: - expandRTE(rte, varno, 0, true /* include dropped */, + expandRTE(rte, varno, 0, true /* include dropped */ , NULL, &colvars); foreach(l, colvars) { var = (Var *) lfirst(l); + /* * A non-Var in expandRTE's output means a dropped column; * must punt. @@ -727,11 +727,11 @@ has_unique_index(RelOptInfo *rel, AttrNumber attno) IndexOptInfo *index = (IndexOptInfo *) lfirst(ilist); /* - * Note: ignore partial indexes, since they don't allow us to - * conclude that all attr values are distinct. We don't take any - * interest in expressional indexes either. Also, a multicolumn - * unique index doesn't allow us to conclude that just the - * specified attr is unique. + * Note: ignore partial indexes, since they don't allow us to conclude + * that all attr values are distinct. We don't take any interest in + * expressional indexes either. Also, a multicolumn unique index + * doesn't allow us to conclude that just the specified attr is + * unique. */ if (index->unique && index->ncolumns == 1 && diff --git a/src/backend/optimizer/util/predtest.c b/src/backend/optimizer/util/predtest.c index 2a0896fa63..48ae77ac55 100644 --- a/src/backend/optimizer/util/predtest.c +++ b/src/backend/optimizer/util/predtest.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/util/predtest.c,v 1.3 2005/10/06 16:01:55 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/util/predtest.c,v 1.4 2005/10/15 02:49:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -31,7 +31,7 @@ static bool predicate_refuted_by_recurse(Node *clause, Node *predicate); static bool predicate_implied_by_simple_clause(Expr *predicate, Node *clause); static bool predicate_refuted_by_simple_clause(Expr *predicate, Node *clause); static bool btree_predicate_proof(Expr *predicate, Node *clause, - bool refute_it); + bool refute_it); /* @@ -66,9 +66,9 @@ predicate_implied_by(List *predicate_list, List *restrictinfo_list) /* * In all cases where the predicate is an AND-clause, * predicate_implied_by_recurse() will prefer to iterate over the - * predicate's components. So we can just do that to start with here, - * and eliminate the need for predicate_implied_by_recurse() to handle - * a bare List on the predicate side. + * predicate's components. So we can just do that to start with here, and + * eliminate the need for predicate_implied_by_recurse() to handle a bare + * List on the predicate side. * * Logic is: restriction must imply each of the AND'ed predicate items. */ @@ -110,11 +110,11 @@ predicate_refuted_by(List *predicate_list, List *restrictinfo_list) return false; /* no restriction: refutation must fail */ /* - * Unlike the implication case, predicate_refuted_by_recurse needs to - * be able to see the top-level AND structure on both sides --- otherwise - * it will fail to handle the case where one restriction clause is an OR - * that can refute the predicate AND as a whole, but not each predicate - * clause separately. + * Unlike the implication case, predicate_refuted_by_recurse needs to be + * able to see the top-level AND structure on both sides --- otherwise it + * will fail to handle the case where one restriction clause is an OR that + * can refute the predicate AND as a whole, but not each predicate clause + * separately. */ return predicate_refuted_by_recurse((Node *) restrictinfo_list, (Node *) predicate_list); @@ -137,7 +137,7 @@ predicate_refuted_by(List *predicate_list, List *restrictinfo_list) * OR-expr A => AND-expr B iff: A => each of B's components * OR-expr A => OR-expr B iff: each of A's components => any of B's * - * An "atom" is anything other than an AND or OR node. Notice that we don't + * An "atom" is anything other than an AND or OR node. Notice that we don't * have any special logic to handle NOT nodes; these should have been pushed * down or eliminated where feasible by prepqual.c. * @@ -152,7 +152,7 @@ predicate_refuted_by(List *predicate_list, List *restrictinfo_list) * under the assumption that both inputs have been AND/OR flattened. * * A bare List node on the restriction side is interpreted as an AND clause, - * in order to handle the top-level restriction List properly. However we + * in order to handle the top-level restriction List properly. However we * need not consider a List on the predicate side since predicate_implied_by() * already expanded it. * @@ -228,8 +228,8 @@ predicate_implied_by_recurse(Node *clause, Node *predicate) if (or_clause(predicate)) { /* - * OR-clause => OR-clause if each of A's items implies any of - * B's items. Messy but can't do it any more simply. + * OR-clause => OR-clause if each of A's items implies any of B's + * items. Messy but can't do it any more simply. */ foreach(item, ((BoolExpr *) clause)->args) { @@ -242,7 +242,7 @@ predicate_implied_by_recurse(Node *clause, Node *predicate) break; } if (item2 == NULL) - return false; /* doesn't imply any of B's */ + return false; /* doesn't imply any of B's */ } return true; } @@ -520,7 +520,7 @@ predicate_implied_by_simple_clause(Expr *predicate, Node *clause) * * When the predicate is of the form "foo IS NULL", we can conclude that * the predicate is refuted if the clause is a strict operator or function - * that has "foo" as an input. See notes for implication case. + * that has "foo" as an input. See notes for implication case. * * Finally, we may be able to deduce something using knowledge about btree * operator classes; this is encapsulated in btree_predicate_proof(). @@ -602,28 +602,28 @@ static const StrategyNumber BT_implic_table[6][6] = { /* * The target operator: * - * LT LE EQ GE GT NE + * LT LE EQ GE GT NE */ - {BTGE, BTGE, 0 , 0 , 0 , BTGE}, /* LT */ - {BTGT, BTGE, 0 , 0 , 0 , BTGT}, /* LE */ - {BTGT, BTGE, BTEQ, BTLE, BTLT, BTNE}, /* EQ */ - {0 , 0 , 0 , BTLE, BTLT, BTLT}, /* GE */ - {0 , 0 , 0 , BTLE, BTLE, BTLE}, /* GT */ - {0 , 0 , 0 , 0 , 0 , BTEQ} /* NE */ + {BTGE, BTGE, 0, 0, 0, BTGE}, /* LT */ + {BTGT, BTGE, 0, 0, 0, BTGT}, /* LE */ + {BTGT, BTGE, BTEQ, BTLE, BTLT, BTNE}, /* EQ */ + {0, 0, 0, BTLE, BTLT, BTLT}, /* GE */ + {0, 0, 0, BTLE, BTLE, BTLE}, /* GT */ + {0, 0, 0, 0, 0, BTEQ} /* NE */ }; static const StrategyNumber BT_refute_table[6][6] = { /* * The target operator: * - * LT LE EQ GE GT NE + * LT LE EQ GE GT NE */ - {0 , 0 , BTGE, BTGE, BTGE, 0 }, /* LT */ - {0 , 0 , BTGT, BTGT, BTGE, 0 }, /* LE */ - {BTLE, BTLT, BTNE, BTGT, BTGE, BTEQ}, /* EQ */ - {BTLE, BTLT, BTLT, 0 , 0 , 0 }, /* GE */ - {BTLE, BTLE, BTLE, 0 , 0 , 0 }, /* GT */ - {0 , 0 , BTEQ, 0 , 0 , 0 } /* NE */ + {0, 0, BTGE, BTGE, BTGE, 0}, /* LT */ + {0, 0, BTGT, BTGT, BTGE, 0}, /* LE */ + {BTLE, BTLT, BTNE, BTGT, BTGE, BTEQ}, /* EQ */ + {BTLE, BTLT, BTLT, 0, 0, 0}, /* GE */ + {BTLE, BTLE, BTLE, 0, 0, 0}, /* GT */ + {0, 0, BTEQ, 0, 0, 0} /* NE */ }; @@ -683,13 +683,13 @@ btree_predicate_proof(Expr *predicate, Node *clause, bool refute_it) MemoryContext oldcontext; /* - * Both expressions must be binary opclauses with a - * Const on one side, and identical subexpressions on the other sides. - * Note we don't have to think about binary relabeling of the Const - * node, since that would have been folded right into the Const. + * Both expressions must be binary opclauses with a Const on one side, and + * identical subexpressions on the other sides. Note we don't have to + * think about binary relabeling of the Const node, since that would have + * been folded right into the Const. * - * If either Const is null, we also fail right away; this assumes that - * the test operator will always be strict. + * If either Const is null, we also fail right away; this assumes that the + * test operator will always be strict. */ if (!is_opclause(predicate)) return false; @@ -738,11 +738,11 @@ btree_predicate_proof(Expr *predicate, Node *clause, bool refute_it) return false; /* - * Check for matching subexpressions on the non-Const sides. We used - * to only allow a simple Var, but it's about as easy to allow any - * expression. Remember we already know that the pred expression does - * not contain any non-immutable functions, so identical expressions - * should yield identical results. + * Check for matching subexpressions on the non-Const sides. We used to + * only allow a simple Var, but it's about as easy to allow any + * expression. Remember we already know that the pred expression does not + * contain any non-immutable functions, so identical expressions should + * yield identical results. */ if (!equal(pred_var, clause_var)) return false; @@ -772,24 +772,24 @@ btree_predicate_proof(Expr *predicate, Node *clause, bool refute_it) * * We must find a btree opclass that contains both operators, else the * implication can't be determined. Also, the pred_op has to be of - * default subtype (implying left and right input datatypes are the - * same); otherwise it's unsafe to put the pred_const on the left side - * of the test. Also, the opclass must contain a suitable test - * operator matching the clause_const's type (which we take to mean - * that it has the same subtype as the original clause_operator). + * default subtype (implying left and right input datatypes are the same); + * otherwise it's unsafe to put the pred_const on the left side of the + * test. Also, the opclass must contain a suitable test operator matching + * the clause_const's type (which we take to mean that it has the same + * subtype as the original clause_operator). * * If there are multiple matching opclasses, assume we can use any one to - * determine the logical relationship of the two operators and the - * correct corresponding test operator. This should work for any - * logically consistent opclasses. + * determine the logical relationship of the two operators and the correct + * corresponding test operator. This should work for any logically + * consistent opclasses. */ catlist = SearchSysCacheList(AMOPOPID, 1, ObjectIdGetDatum(pred_op), 0, 0, 0); /* - * If we couldn't find any opclass containing the pred_op, perhaps it - * is a <> operator. See if it has a negator that is in an opclass. + * If we couldn't find any opclass containing the pred_op, perhaps it is a + * <> operator. See if it has a negator that is in an opclass. */ pred_op_negated = false; if (catlist->n_members == 0) @@ -800,7 +800,7 @@ btree_predicate_proof(Expr *predicate, Node *clause, bool refute_it) pred_op_negated = true; ReleaseSysCacheList(catlist); catlist = SearchSysCacheList(AMOPOPID, 1, - ObjectIdGetDatum(pred_op_negator), + ObjectIdGetDatum(pred_op_negator), 0, 0, 0); } } @@ -837,8 +837,8 @@ btree_predicate_proof(Expr *predicate, Node *clause, bool refute_it) } /* - * From the same opclass, find a strategy number for the - * clause_op, if possible + * From the same opclass, find a strategy number for the clause_op, if + * possible */ clause_tuple = SearchSysCache(AMOPOPID, ObjectIdGetDatum(clause_op), @@ -857,7 +857,7 @@ btree_predicate_proof(Expr *predicate, Node *clause, bool refute_it) else if (OidIsValid(clause_op_negator)) { clause_tuple = SearchSysCache(AMOPOPID, - ObjectIdGetDatum(clause_op_negator), + ObjectIdGetDatum(clause_op_negator), ObjectIdGetDatum(opclass_id), 0, 0); if (HeapTupleIsValid(clause_tuple)) @@ -896,8 +896,8 @@ btree_predicate_proof(Expr *predicate, Node *clause, bool refute_it) } /* - * See if opclass has an operator for the test strategy and the - * clause datatype. + * See if opclass has an operator for the test strategy and the clause + * datatype. */ if (test_strategy == BTNE) { @@ -918,9 +918,9 @@ btree_predicate_proof(Expr *predicate, Node *clause, bool refute_it) * * Note that we require only the test_op to be immutable, not the * original clause_op. (pred_op is assumed to have been checked - * immutable by the caller.) Essentially we are assuming that - * the opclass is consistent even if it contains operators that - * are merely stable. + * immutable by the caller.) Essentially we are assuming that the + * opclass is consistent even if it contains operators that are + * merely stable. */ if (op_volatile(test_op) == PROVOLATILE_IMMUTABLE) { @@ -958,7 +958,7 @@ btree_predicate_proof(Expr *predicate, Node *clause, bool refute_it) /* And execute it. */ test_result = ExecEvalExprSwitchContext(test_exprstate, - GetPerTupleExprContext(estate), + GetPerTupleExprContext(estate), &isNull, NULL); /* Get back to outer memory context */ diff --git a/src/backend/optimizer/util/relnode.c b/src/backend/optimizer/util/relnode.c index e595749c29..3ca43759e9 100644 --- a/src/backend/optimizer/util/relnode.c +++ b/src/backend/optimizer/util/relnode.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/util/relnode.c,v 1.71 2005/07/28 22:27:00 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/util/relnode.c,v 1.72 2005/10/15 02:49:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -31,9 +31,9 @@ typedef struct JoinHashEntry } JoinHashEntry; static RelOptInfo *make_reloptinfo(PlannerInfo *root, int relid, - RelOptKind reloptkind); + RelOptKind reloptkind); static void build_joinrel_tlist(PlannerInfo *root, RelOptInfo *joinrel, - RelOptInfo *input_rel); + RelOptInfo *input_rel); static List *build_joinrel_restrictlist(PlannerInfo *root, RelOptInfo *joinrel, RelOptInfo *outer_rel, @@ -165,8 +165,8 @@ make_reloptinfo(PlannerInfo *root, int relid, RelOptKind reloptkind) /* Add the finished struct to the base_rel_array */ if (relid >= root->base_rel_array_size) { - int oldsize = root->base_rel_array_size; - int newsize; + int oldsize = root->base_rel_array_size; + int newsize; newsize = Max(oldsize * 2, relid + 1); root->base_rel_array = (RelOptInfo **) @@ -225,7 +225,7 @@ build_join_rel_hash(PlannerInfo *root) hashtab = hash_create("JoinRelHashTable", 256L, &hash_ctl, - HASH_ELEM | HASH_FUNCTION | HASH_COMPARE | HASH_CONTEXT); + HASH_ELEM | HASH_FUNCTION | HASH_COMPARE | HASH_CONTEXT); /* Insert all the already-existing joinrels */ foreach(l, root->join_rel_list) @@ -254,7 +254,7 @@ RelOptInfo * find_join_rel(PlannerInfo *root, Relids relids) { /* - * Switch to using hash lookup when list grows "too long". The threshold + * Switch to using hash lookup when list grows "too long". The threshold * is arbitrary and is known only here. */ if (!root->join_rel_hash && list_length(root->join_rel_list) > 32) @@ -263,10 +263,10 @@ find_join_rel(PlannerInfo *root, Relids relids) /* * Use either hashtable lookup or linear search, as appropriate. * - * Note: the seemingly redundant hashkey variable is used to avoid - * taking the address of relids; unless the compiler is exceedingly - * smart, doing so would force relids out of a register and thus - * probably slow down the list-search case. + * Note: the seemingly redundant hashkey variable is used to avoid taking the + * address of relids; unless the compiler is exceedingly smart, doing so + * would force relids out of a register and thus probably slow down the + * list-search case. */ if (root->join_rel_hash) { @@ -331,8 +331,8 @@ build_join_rel(PlannerInfo *root, if (joinrel) { /* - * Yes, so we only need to figure the restrictlist for this - * particular pair of component relations. + * Yes, so we only need to figure the restrictlist for this particular + * pair of component relations. */ if (restrictlist_ptr) *restrictlist_ptr = build_joinrel_restrictlist(root, @@ -375,21 +375,20 @@ build_join_rel(PlannerInfo *root, joinrel->index_inner_paths = NIL; /* - * Create a new tlist containing just the vars that need to be output - * from this join (ie, are needed for higher joinclauses or final - * output). + * Create a new tlist containing just the vars that need to be output from + * this join (ie, are needed for higher joinclauses or final output). * - * NOTE: the tlist order for a join rel will depend on which pair of - * outer and inner rels we first try to build it from. But the - * contents should be the same regardless. + * NOTE: the tlist order for a join rel will depend on which pair of outer + * and inner rels we first try to build it from. But the contents should + * be the same regardless. */ build_joinrel_tlist(root, joinrel, outer_rel); build_joinrel_tlist(root, joinrel, inner_rel); /* * Construct restrict and join clause lists for the new joinrel. (The - * caller might or might not need the restrictlist, but I need it - * anyway for set_joinrel_size_estimates().) + * caller might or might not need the restrictlist, but I need it anyway + * for set_joinrel_size_estimates().) */ restrictlist = build_joinrel_restrictlist(root, joinrel, @@ -407,9 +406,9 @@ build_join_rel(PlannerInfo *root, jointype, restrictlist); /* - * Add the joinrel to the query's joinrel list, and store it into - * the auxiliary hashtable if there is one. NB: GEQO requires us - * to append the new joinrel to the end of the list! + * Add the joinrel to the query's joinrel list, and store it into the + * auxiliary hashtable if there is one. NB: GEQO requires us to append + * the new joinrel to the end of the list! */ root->join_rel_list = lappend(root->join_rel_list, joinrel); @@ -527,18 +526,18 @@ build_joinrel_restrictlist(PlannerInfo *root, * Collect all the clauses that syntactically belong at this level. */ rlist = list_concat(subbuild_joinrel_restrictlist(joinrel, - outer_rel->joininfo), + outer_rel->joininfo), subbuild_joinrel_restrictlist(joinrel, - inner_rel->joininfo)); + inner_rel->joininfo)); /* * Eliminate duplicate and redundant clauses. * - * We must eliminate duplicates, since we will see many of the same - * clauses arriving from both input relations. Also, if a clause is a - * mergejoinable clause, it's possible that it is redundant with - * previous clauses (see optimizer/README for discussion). We detect - * that case and omit the redundant clause from the result list. + * We must eliminate duplicates, since we will see many of the same clauses + * arriving from both input relations. Also, if a clause is a + * mergejoinable clause, it's possible that it is redundant with previous + * clauses (see optimizer/README for discussion). We detect that case and + * omit the redundant clause from the result list. */ result = remove_redundant_join_clauses(root, rlist, IS_OUTER_JOIN(jointype)); @@ -571,18 +570,17 @@ subbuild_joinrel_restrictlist(RelOptInfo *joinrel, if (bms_is_subset(rinfo->required_relids, joinrel->relids)) { /* - * This clause becomes a restriction clause for the joinrel, - * since it refers to no outside rels. We don't bother to - * check for duplicates here --- build_joinrel_restrictlist - * will do that. + * This clause becomes a restriction clause for the joinrel, since + * it refers to no outside rels. We don't bother to check for + * duplicates here --- build_joinrel_restrictlist will do that. */ restrictlist = lappend(restrictlist, rinfo); } else { /* - * This clause is still a join clause at this level, so we - * ignore it in this routine. + * This clause is still a join clause at this level, so we ignore + * it in this routine. */ } } @@ -603,17 +601,17 @@ subbuild_joinrel_joinlist(RelOptInfo *joinrel, if (bms_is_subset(rinfo->required_relids, joinrel->relids)) { /* - * This clause becomes a restriction clause for the joinrel, - * since it refers to no outside rels. So we can ignore it - * in this routine. + * This clause becomes a restriction clause for the joinrel, since + * it refers to no outside rels. So we can ignore it in this + * routine. */ } else { /* - * This clause is still a join clause at this level, so add - * it to the joininfo list for the joinrel, being careful to - * eliminate duplicates. (Since RestrictInfo nodes are normally + * This clause is still a join clause at this level, so add it to + * the joininfo list for the joinrel, being careful to eliminate + * duplicates. (Since RestrictInfo nodes are normally * multiply-linked rather than copied, pointer equality should be * a sufficient test. If two equal() nodes should happen to sneak * in, no great harm is done --- they'll be detected by diff --git a/src/backend/optimizer/util/restrictinfo.c b/src/backend/optimizer/util/restrictinfo.c index 47b90aef46..d277cac735 100644 --- a/src/backend/optimizer/util/restrictinfo.c +++ b/src/backend/optimizer/util/restrictinfo.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/util/restrictinfo.c,v 1.40 2005/10/13 00:06:46 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/util/restrictinfo.c,v 1.41 2005/10/15 02:49:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -51,8 +51,8 @@ RestrictInfo * make_restrictinfo(Expr *clause, bool is_pushed_down, Relids required_relids) { /* - * If it's an OR clause, build a modified copy with RestrictInfos - * inserted above each subclause of the top-level AND/OR structure. + * If it's an OR clause, build a modified copy with RestrictInfos inserted + * above each subclause of the top-level AND/OR structure. */ if (or_clause((Node *) clause)) return (RestrictInfo *) make_sub_restrictinfos(clause, is_pushed_down); @@ -101,9 +101,9 @@ make_restrictinfo_from_bitmapqual(Path *bitmapqual, /* * There may well be redundant quals among the subplans, since a * top-level WHERE qual might have gotten used to form several - * different index quals. We don't try exceedingly hard to - * eliminate redundancies, but we do eliminate obvious duplicates - * by using list_concat_unique. + * different index quals. We don't try exceedingly hard to eliminate + * redundancies, but we do eliminate obvious duplicates by using + * list_concat_unique. */ result = NIL; foreach(l, apath->bitmapquals) @@ -125,7 +125,7 @@ make_restrictinfo_from_bitmapqual(Path *bitmapqual, /* * Here, we only detect qual-free subplans. A qual-free subplan would * cause us to generate "... OR true ..." which we may as well reduce - * to just "true". We do not try to eliminate redundant subclauses + * to just "true". We do not try to eliminate redundant subclauses * because (a) it's not as likely as in the AND case, and (b) we might * well be working with hundreds or even thousands of OR conditions, * perhaps from a long IN list. The performance of list_append_unique @@ -142,8 +142,8 @@ make_restrictinfo_from_bitmapqual(Path *bitmapqual, { /* * If we find a qual-less subscan, it represents a constant - * TRUE, and hence the OR result is also constant TRUE, so - * we can stop here. + * TRUE, and hence the OR result is also constant TRUE, so we + * can stop here. */ return NIL; } @@ -157,8 +157,8 @@ make_restrictinfo_from_bitmapqual(Path *bitmapqual, } /* - * Avoid generating one-element ORs, which could happen - * due to redundancy elimination. + * Avoid generating one-element ORs, which could happen due to + * redundancy elimination. */ if (list_length(withris) <= 1) result = withris; @@ -174,20 +174,20 @@ make_restrictinfo_from_bitmapqual(Path *bitmapqual, } else if (IsA(bitmapqual, IndexPath)) { - IndexPath *ipath = (IndexPath *) bitmapqual; + IndexPath *ipath = (IndexPath *) bitmapqual; result = list_copy(ipath->indexclauses); if (include_predicates && ipath->indexinfo->indpred != NIL) { foreach(l, ipath->indexinfo->indpred) { - Expr *pred = (Expr *) lfirst(l); + Expr *pred = (Expr *) lfirst(l); /* - * We know that the index predicate must have been implied - * by the query condition as a whole, but it may or may not - * be implied by the conditions that got pushed into the - * bitmapqual. Avoid generating redundant conditions. + * We know that the index predicate must have been implied by + * the query condition as a whole, but it may or may not be + * implied by the conditions that got pushed into the + * bitmapqual. Avoid generating redundant conditions. */ if (!predicate_implied_by(list_make1(pred), result)) result = lappend(result, @@ -223,8 +223,8 @@ make_restrictinfo_internal(Expr *clause, Expr *orclause, restrictinfo->can_join = false; /* may get set below */ /* - * If it's a binary opclause, set up left/right relids info. In any - * case set up the total clause relids info. + * If it's a binary opclause, set up left/right relids info. In any case + * set up the total clause relids info. */ if (is_opclause(clause) && list_length(((OpExpr *) clause)->args) == 2) { @@ -232,13 +232,13 @@ make_restrictinfo_internal(Expr *clause, Expr *orclause, restrictinfo->right_relids = pull_varnos(get_rightop(clause)); restrictinfo->clause_relids = bms_union(restrictinfo->left_relids, - restrictinfo->right_relids); + restrictinfo->right_relids); /* * Does it look like a normal join clause, i.e., a binary operator - * relating expressions that come from distinct relations? If so - * we might be able to use it in a join algorithm. Note that this - * is a purely syntactic test that is made regardless of context. + * relating expressions that come from distinct relations? If so we + * might be able to use it in a join algorithm. Note that this is a + * purely syntactic test that is made regardless of context. */ if (!bms_is_empty(restrictinfo->left_relids) && !bms_is_empty(restrictinfo->right_relids) && @@ -262,11 +262,11 @@ make_restrictinfo_internal(Expr *clause, Expr *orclause, restrictinfo->required_relids = restrictinfo->clause_relids; /* - * Fill in all the cacheable fields with "not yet set" markers. None - * of these will be computed until/unless needed. Note in particular - * that we don't mark a binary opclause as mergejoinable or - * hashjoinable here; that happens only if it appears in the right - * context (top level of a joinclause list). + * Fill in all the cacheable fields with "not yet set" markers. None of + * these will be computed until/unless needed. Note in particular that we + * don't mark a binary opclause as mergejoinable or hashjoinable here; + * that happens only if it appears in the right context (top level of a + * joinclause list). */ restrictinfo->eval_cost.startup = -1; restrictinfo->this_selec = -1; @@ -420,17 +420,16 @@ remove_redundant_join_clauses(PlannerInfo *root, List *restrictinfo_list, QualCost cost; /* - * If there are any redundant clauses, we want to eliminate the ones - * that are more expensive in favor of the ones that are less so. Run + * If there are any redundant clauses, we want to eliminate the ones that + * are more expensive in favor of the ones that are less so. Run * cost_qual_eval() to ensure the eval_cost fields are set up. */ cost_qual_eval(&cost, restrictinfo_list); /* - * We don't have enough knowledge yet to be able to estimate the - * number of times a clause might be evaluated, so it's hard to weight - * the startup and per-tuple costs appropriately. For now just weight - * 'em the same. + * We don't have enough knowledge yet to be able to estimate the number of + * times a clause might be evaluated, so it's hard to weight the startup + * and per-tuple costs appropriately. For now just weight 'em the same. */ #define CLAUSECOST(r) ((r)->eval_cost.startup + (r)->eval_cost.per_tuple) diff --git a/src/backend/optimizer/util/tlist.c b/src/backend/optimizer/util/tlist.c index 1672cda77c..955aceefff 100644 --- a/src/backend/optimizer/util/tlist.c +++ b/src/backend/optimizer/util/tlist.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/util/tlist.c,v 1.69 2005/04/06 16:34:06 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/util/tlist.c,v 1.70 2005/10/15 02:49:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -93,7 +93,7 @@ add_to_flat_tlist(List *tlist, List *vars) { TargetEntry *tle; - tle = makeTargetEntry(copyObject(var), /* copy needed?? */ + tle = makeTargetEntry(copyObject(var), /* copy needed?? */ next_resno++, NULL, false); diff --git a/src/backend/optimizer/util/var.c b/src/backend/optimizer/util/var.c index abd01ca157..dc1004cbd0 100644 --- a/src/backend/optimizer/util/var.c +++ b/src/backend/optimizer/util/var.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/util/var.c,v 1.65 2005/06/05 22:32:56 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/util/var.c,v 1.66 2005/10/15 02:49:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -88,8 +88,8 @@ pull_varnos(Node *node) context.sublevels_up = 0; /* - * Must be prepared to start with a Query or a bare expression tree; - * if it's a Query, we don't want to increment sublevels_up. + * Must be prepared to start with a Query or a bare expression tree; if + * it's a Query, we don't want to increment sublevels_up. */ query_or_expression_tree_walker(node, pull_varnos_walker, @@ -149,8 +149,8 @@ contain_var_reference(Node *node, int varno, int varattno, int levelsup) context.sublevels_up = levelsup; /* - * Must be prepared to start with a Query or a bare expression tree; - * if it's a Query, we don't want to increment sublevels_up. + * Must be prepared to start with a Query or a bare expression tree; if + * it's a Query, we don't want to increment sublevels_up. */ return query_or_expression_tree_walker(node, contain_var_reference_walker, @@ -215,8 +215,7 @@ contain_var_clause_walker(Node *node, void *context) if (IsA(node, Var)) { if (((Var *) node)->varlevelsup == 0) - return true; /* abort the tree traversal and return - * true */ + return true; /* abort the tree traversal and return true */ return false; } return expression_tree_walker(node, contain_var_clause_walker, context); @@ -286,7 +285,7 @@ contain_vars_above_level(Node *node, int levelsup) int sublevels_up = levelsup; return query_or_expression_tree_walker(node, - contain_vars_above_level_walker, + contain_vars_above_level_walker, (void *) &sublevels_up, 0); } @@ -370,8 +369,8 @@ find_minimum_var_level_walker(Node *node, context->min_varlevel = varlevelsup; /* - * As soon as we find a local variable, we can abort the - * tree traversal, since min_varlevel is then certainly 0. + * As soon as we find a local variable, we can abort the tree + * traversal, since min_varlevel is then certainly 0. */ if (varlevelsup == 0) return true; @@ -380,10 +379,9 @@ find_minimum_var_level_walker(Node *node, } /* - * An Aggref must be treated like a Var of its level. Normally we'd - * get the same result from looking at the Vars in the aggregate's - * argument, but this fails in the case of a Var-less aggregate call - * (COUNT(*)). + * An Aggref must be treated like a Var of its level. Normally we'd get + * the same result from looking at the Vars in the aggregate's argument, + * but this fails in the case of a Var-less aggregate call (COUNT(*)). */ if (IsA(node, Aggref)) { @@ -400,8 +398,8 @@ find_minimum_var_level_walker(Node *node, context->min_varlevel = agglevelsup; /* - * As soon as we find a local aggregate, we can abort the - * tree traversal, since min_varlevel is then certainly 0. + * As soon as we find a local aggregate, we can abort the tree + * traversal, since min_varlevel is then certainly 0. */ if (agglevelsup == 0) return true; @@ -553,8 +551,8 @@ flatten_join_alias_vars_mutator(Node *node, newvar = (Node *) list_nth(rte->joinaliasvars, var->varattno - 1); /* - * If we are expanding an alias carried down from an upper query, - * must adjust its varlevelsup fields. + * If we are expanding an alias carried down from an upper query, must + * adjust its varlevelsup fields. */ if (context->sublevels_up != 0) { @@ -570,8 +568,8 @@ flatten_join_alias_vars_mutator(Node *node, InClauseInfo *ininfo; ininfo = (InClauseInfo *) expression_tree_mutator(node, - flatten_join_alias_vars_mutator, - (void *) context); + flatten_join_alias_vars_mutator, + (void *) context); /* now fix InClauseInfo's relid sets */ if (context->sublevels_up == 0) { diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c index be91872df5..46dbb3f148 100644 --- a/src/backend/parser/analyze.c +++ b/src/backend/parser/analyze.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.325 2005/10/02 23:50:09 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.326 2005/10/15 02:49:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -59,14 +59,13 @@ typedef struct List *indexes; /* CREATE INDEX items */ List *triggers; /* CREATE TRIGGER items */ List *grants; /* GRANT items */ - List *fwconstraints; /* Forward referencing FOREIGN KEY - * constraints */ + List *fwconstraints; /* Forward referencing FOREIGN KEY constraints */ List *alters; /* Generated ALTER items (from the above) */ List *ixconstraints; /* index-creating constraints */ List *blist; /* "before list" of things to do before * creating the schema */ - List *alist; /* "after list" of things to do after - * creating the schema */ + List *alist; /* "after list" of things to do after creating + * the schema */ } CreateSchemaStmtContext; /* State shared by transformCreateStmt and its subroutines */ @@ -83,8 +82,8 @@ typedef struct List *ixconstraints; /* index-creating constraints */ List *blist; /* "before list" of things to do before * creating the table */ - List *alist; /* "after list" of things to do after - * creating the table */ + List *alist; /* "after list" of things to do after creating + * the table */ IndexStmt *pkey; /* PRIMARY KEY index, if any */ } CreateStmtContext; @@ -140,7 +139,7 @@ static void transformColumnType(ParseState *pstate, ColumnDef *column); static void release_pstate_resources(ParseState *pstate); static FromExpr *makeFromExpr(List *fromlist, Node *quals); static bool check_parameter_resolution_walker(Node *node, - check_parameter_resolution_context *context); + check_parameter_resolution_context *context); /* @@ -255,11 +254,10 @@ do_parse_analyze(Node *parseTree, ParseState *pstate) result = list_concat(result, parse_sub_analyze(lfirst(l), pstate)); /* - * Make sure that only the original query is marked original. We have - * to do this explicitly since recursive calls of do_parse_analyze - * will have marked some of the added-on queries as "original". Also - * mark only the original query as allowed to set the command-result - * tag. + * Make sure that only the original query is marked original. We have to + * do this explicitly since recursive calls of do_parse_analyze will have + * marked some of the added-on queries as "original". Also mark only the + * original query as allowed to set the command-result tag. */ foreach(l, result) { @@ -371,19 +369,19 @@ transformStmt(ParseState *pstate, Node *parseTree, (SelectStmt *) parseTree); else result = transformSetOperationStmt(pstate, - (SelectStmt *) parseTree); + (SelectStmt *) parseTree); break; case T_DeclareCursorStmt: result = transformDeclareCursorStmt(pstate, - (DeclareCursorStmt *) parseTree); + (DeclareCursorStmt *) parseTree); break; default: /* - * other statements don't require any transformation-- just - * return the original parsetree, yea! + * other statements don't require any transformation-- just return + * the original parsetree, yea! */ result = makeNode(Query); result->commandType = CMD_UTILITY; @@ -396,10 +394,9 @@ transformStmt(ParseState *pstate, Node *parseTree, result->canSetTag = true; /* - * Check that we did not produce too many resnos; at the very - * least we cannot allow more than 2^16, since that would exceed - * the range of a AttrNumber. It seems safest to use - * MaxTupleAttributeNumber. + * Check that we did not produce too many resnos; at the very least we + * cannot allow more than 2^16, since that would exceed the range of a + * AttrNumber. It seems safest to use MaxTupleAttributeNumber. */ if (pstate->p_next_resno - 1 > MaxTupleAttributeNumber) ereport(ERROR, @@ -423,11 +420,11 @@ transformViewStmt(ParseState *pstate, ViewStmt *stmt, extras_before, extras_after); /* - * If a list of column names was given, run through and insert these - * into the actual query tree. - thomas 2000-03-08 + * If a list of column names was given, run through and insert these into + * the actual query tree. - thomas 2000-03-08 * - * Outer loop is over targetlist to make it easier to skip junk - * targetlist entries. + * Outer loop is over targetlist to make it easier to skip junk targetlist + * entries. */ if (stmt->aliases != NIL) { @@ -472,17 +469,17 @@ transformDeleteStmt(ParseState *pstate, DeleteStmt *stmt) /* set up range table with just the result rel */ qry->resultRelation = setTargetTable(pstate, stmt->relation, - interpretInhOption(stmt->relation->inhOpt), + interpretInhOption(stmt->relation->inhOpt), true, ACL_DELETE); qry->distinctClause = NIL; /* - * The USING clause is non-standard SQL syntax, and is equivalent - * in functionality to the FROM list that can be specified for - * UPDATE. The USING keyword is used rather than FROM because FROM - * is already a keyword in the DELETE syntax. + * The USING clause is non-standard SQL syntax, and is equivalent in + * functionality to the FROM list that can be specified for UPDATE. The + * USING keyword is used rather than FROM because FROM is already a + * keyword in the DELETE syntax. */ transformFromClause(pstate, stmt->usingClause); @@ -526,11 +523,11 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt, /* * If a non-nil rangetable/namespace was passed in, and we are doing * INSERT/SELECT, arrange to pass the rangetable/namespace down to the - * SELECT. This can only happen if we are inside a CREATE RULE, and - * in that case we want the rule's OLD and NEW rtable entries to - * appear as part of the SELECT's rtable, not as outer references for - * it. (Kluge!) The SELECT's joinlist is not affected however. We - * must do this before adding the target table to the INSERT's rtable. + * SELECT. This can only happen if we are inside a CREATE RULE, and in + * that case we want the rule's OLD and NEW rtable entries to appear as + * part of the SELECT's rtable, not as outer references for it. (Kluge!) + * The SELECT's joinlist is not affected however. We must do this before + * adding the target table to the INSERT's rtable. */ if (stmt->selectStmt) { @@ -549,10 +546,10 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt, } /* - * Must get write lock on INSERT target table before scanning SELECT, - * else we will grab the wrong kind of initial lock if the target - * table is also mentioned in the SELECT part. Note that the target - * table is not added to the joinlist or namespace. + * Must get write lock on INSERT target table before scanning SELECT, else + * we will grab the wrong kind of initial lock if the target table is also + * mentioned in the SELECT part. Note that the target table is not added + * to the joinlist or namespace. */ qry->resultRelation = setTargetTable(pstate, stmt->relation, false, false, ACL_INSERT); @@ -563,11 +560,11 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt, if (stmt->selectStmt) { /* - * We make the sub-pstate a child of the outer pstate so that it - * can see any Param definitions supplied from above. Since the - * outer pstate's rtable and namespace are presently empty, there - * are no side-effects of exposing names the sub-SELECT shouldn't - * be able to see. + * We make the sub-pstate a child of the outer pstate so that it can + * see any Param definitions supplied from above. Since the outer + * pstate's rtable and namespace are presently empty, there are no + * side-effects of exposing names the sub-SELECT shouldn't be able to + * see. */ ParseState *sub_pstate = make_parsestate(pstate); RangeTblEntry *rte; @@ -576,19 +573,18 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt, /* * Process the source SELECT. * - * It is important that this be handled just like a standalone - * SELECT; otherwise the behavior of SELECT within INSERT might be - * different from a stand-alone SELECT. (Indeed, Postgres up - * through 6.5 had bugs of just that nature...) + * It is important that this be handled just like a standalone SELECT; + * otherwise the behavior of SELECT within INSERT might be different + * from a stand-alone SELECT. (Indeed, Postgres up through 6.5 had + * bugs of just that nature...) */ sub_pstate->p_rtable = sub_rtable; sub_pstate->p_relnamespace = sub_relnamespace; sub_pstate->p_varnamespace = sub_varnamespace; /* - * Note: we are not expecting that extras_before and extras_after - * are going to be used by the transformation of the SELECT - * statement. + * Note: we are not expecting that extras_before and extras_after are + * going to be used by the transformation of the SELECT statement. */ selectQuery = transformStmt(sub_pstate, stmt->selectStmt, extras_before, extras_after); @@ -604,8 +600,8 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt, errmsg("INSERT ... SELECT may not specify INTO"))); /* - * Make the source be a subquery in the INSERT's rangetable, and - * add it to the INSERT's joinlist. + * Make the source be a subquery in the INSERT's rangetable, and add + * it to the INSERT's joinlist. */ rte = addRangeTableEntryForSubquery(pstate, selectQuery, @@ -640,7 +636,7 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt, if (tle->resjunk) continue; if (tle->expr && - (IsA(tle->expr, Const) || IsA(tle->expr, Param)) && + (IsA(tle->expr, Const) ||IsA(tle->expr, Param)) && exprType((Node *) tle->expr) == UNKNOWNOID) expr = tle->expr; else @@ -659,8 +655,8 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt, else { /* - * For INSERT ... VALUES, transform the given list of values to - * form a targetlist for the INSERT. + * For INSERT ... VALUES, transform the given list of values to form a + * targetlist for the INSERT. */ qry->targetList = transformTargetList(pstate, stmt->targetList); } @@ -690,7 +686,7 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt, if (icols == NULL || attnos == NULL) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("INSERT has more expressions than target columns"))); + errmsg("INSERT has more expressions than target columns"))); col = (ResTarget *) lfirst(icols); Assert(IsA(col, ResTarget)); @@ -711,7 +707,7 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt, if (stmt->cols != NIL && (icols != NULL || attnos != NULL)) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("INSERT has more target columns than expressions"))); + errmsg("INSERT has more target columns than expressions"))); /* done building the range table and jointree */ qry->rtable = pstate->p_rtable; @@ -756,8 +752,8 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt, cxt.hasoids = interpretOidsOption(stmt->hasoids); /* - * Run through each primary element in the table creation clause. - * Separate column defs from constraints, and do preliminary analysis. + * Run through each primary element in the table creation clause. Separate + * column defs from constraints, and do preliminary analysis. */ foreach(elements, stmt->tableElts) { @@ -870,11 +866,11 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt, * * Although we use ChooseRelationName, it's not guaranteed that the * selected sequence name won't conflict; given sufficiently long - * field names, two different serial columns in the same table - * could be assigned the same sequence name, and we'd not notice - * since we aren't creating the sequence quite yet. In practice - * this seems quite unlikely to be a problem, especially since few - * people would need two serial columns in one table. + * field names, two different serial columns in the same table could + * be assigned the same sequence name, and we'd not notice since we + * aren't creating the sequence quite yet. In practice this seems + * quite unlikely to be a problem, especially since few people would + * need two serial columns in one table. */ snamespaceid = RangeVarGetCreationNamespace(cxt->relation); snamespace = get_namespace_name(snamespaceid); @@ -889,9 +885,9 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt, cxt->relation->relname, column->colname))); /* - * Build a CREATE SEQUENCE command to create the sequence object, - * and add it to the list of things to be done before this - * CREATE/ALTER TABLE. + * Build a CREATE SEQUENCE command to create the sequence object, and + * add it to the list of things to be done before this CREATE/ALTER + * TABLE. */ seqstmt = makeNode(CreateSeqStmt); seqstmt->sequence = makeRangeVar(snamespace, sname); @@ -907,14 +903,13 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt, /* * Create appropriate constraints for SERIAL. We do this in full, - * rather than shortcutting, so that we will detect any - * conflicting constraints the user wrote (like a different - * DEFAULT). + * rather than shortcutting, so that we will detect any conflicting + * constraints the user wrote (like a different DEFAULT). * * Create an expression tree representing the function call - * nextval('sequencename'). We cannot reduce the raw tree - * to cooked form until after the sequence is created, but - * there's no need to do so. + * nextval('sequencename'). We cannot reduce the raw tree to cooked + * form until after the sequence is created, but there's no need to do + * so. */ qstring = quote_qualified_identifier(snamespace, sname); snamenode = makeNode(A_Const); @@ -949,9 +944,9 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt, constraint = lfirst(clist); /* - * If this column constraint is a FOREIGN KEY constraint, then we - * fill in the current attribute's name and throw it into the list - * of FK constraints to be processed later. + * If this column constraint is a FOREIGN KEY constraint, then we fill + * in the current attribute's name and throw it into the list of FK + * constraints to be processed later. */ if (IsA(constraint, FkConstraint)) { @@ -971,7 +966,7 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt, ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("conflicting NULL/NOT NULL declarations for column \"%s\" of table \"%s\"", - column->colname, cxt->relation->relname))); + column->colname, cxt->relation->relname))); column->is_not_null = FALSE; saw_nullable = true; break; @@ -981,7 +976,7 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt, ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("conflicting NULL/NOT NULL declarations for column \"%s\" of table \"%s\"", - column->colname, cxt->relation->relname))); + column->colname, cxt->relation->relname))); column->is_not_null = TRUE; saw_nullable = true; break; @@ -991,7 +986,7 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt, ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("multiple default values specified for column \"%s\" of table \"%s\"", - column->colname, cxt->relation->relname))); + column->colname, cxt->relation->relname))); column->raw_default = constraint->raw_expr; Assert(constraint->cooked_expr == NULL); break; @@ -1113,8 +1108,8 @@ transformInhRelation(ParseState *pstate, CreateStmtContext *cxt, /* * Create a new inherited column. * - * For constraints, ONLY the NOT NULL constraint is inherited by the - * new column definition per SQL99. + * For constraints, ONLY the NOT NULL constraint is inherited by the new + * column definition per SQL99. */ def = makeNode(ColumnDef); def->colname = pstrdup(attributeName); @@ -1158,8 +1153,8 @@ transformInhRelation(ParseState *pstate, CreateStmtContext *cxt, Assert(this_default != NULL); /* - * If default expr could contain any vars, we'd need to fix - * 'em, but it can't; so default is ready to apply to child. + * If default expr could contain any vars, we'd need to fix 'em, + * but it can't; so default is ready to apply to child. */ def->cooked_default = pstrdup(this_default); @@ -1168,8 +1163,8 @@ transformInhRelation(ParseState *pstate, CreateStmtContext *cxt, /* * Close the parent rel, but keep our AccessShareLock on it until xact - * commit. That will prevent someone else from deleting or ALTERing - * the parent before the child is committed. + * commit. That will prevent someone else from deleting or ALTERing the + * parent before the child is committed. */ heap_close(relation, NoLock); } @@ -1183,10 +1178,9 @@ transformIndexConstraints(ParseState *pstate, CreateStmtContext *cxt) ListCell *l; /* - * Run through the constraints that need to generate an index. For - * PRIMARY KEY, mark each column as NOT NULL and create an index. For - * UNIQUE, create an index as for PRIMARY KEY, but do not insist on - * NOT NULL. + * Run through the constraints that need to generate an index. For PRIMARY + * KEY, mark each column as NOT NULL and create an index. For UNIQUE, + * create an index as for PRIMARY KEY, but do not insist on NOT NULL. */ foreach(listptr, cxt->ixconstraints) { @@ -1212,8 +1206,8 @@ transformIndexConstraints(ParseState *pstate, CreateStmtContext *cxt) cxt->pkey = index; /* - * In ALTER TABLE case, a primary index might already exist, - * but DefineIndex will check for it. + * In ALTER TABLE case, a primary index might already exist, but + * DefineIndex will check for it. */ } index->isconstraint = true; @@ -1230,10 +1224,10 @@ transformIndexConstraints(ParseState *pstate, CreateStmtContext *cxt) index->whereClause = NULL; /* - * Make sure referenced keys exist. If we are making a PRIMARY - * KEY index, also make sure they are NOT NULL, if possible. - * (Although we could leave it to DefineIndex to mark the columns - * NOT NULL, it's more efficient to get it right the first time.) + * Make sure referenced keys exist. If we are making a PRIMARY KEY + * index, also make sure they are NOT NULL, if possible. (Although we + * could leave it to DefineIndex to mark the columns NOT NULL, it's + * more efficient to get it right the first time.) */ foreach(keys, constraint->keys) { @@ -1261,9 +1255,9 @@ transformIndexConstraints(ParseState *pstate, CreateStmtContext *cxt) else if (SystemAttributeByName(key, cxt->hasoids) != NULL) { /* - * column will be a system column in the new table, so - * accept it. System columns can't ever be null, so no - * need to worry about PRIMARY/NOT NULL constraint. + * column will be a system column in the new table, so accept + * it. System columns can't ever be null, so no need to worry + * about PRIMARY/NOT NULL constraint. */ found = true; } @@ -1283,8 +1277,8 @@ transformIndexConstraints(ParseState *pstate, CreateStmtContext *cxt) if (rel->rd_rel->relkind != RELKIND_RELATION) ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), - errmsg("inherited relation \"%s\" is not a table", - inh->relname))); + errmsg("inherited relation \"%s\" is not a table", + inh->relname))); for (count = 0; count < rel->rd_att->natts; count++) { Form_pg_attribute inhattr = rel->rd_att->attrs[count]; @@ -1298,10 +1292,9 @@ transformIndexConstraints(ParseState *pstate, CreateStmtContext *cxt) /* * We currently have no easy way to force an - * inherited column to be NOT NULL at - * creation, if its parent wasn't so already. - * We leave it to DefineIndex to fix things up - * in this case. + * inherited column to be NOT NULL at creation, if + * its parent wasn't so already. We leave it to + * DefineIndex to fix things up in this case. */ break; } @@ -1313,16 +1306,16 @@ transformIndexConstraints(ParseState *pstate, CreateStmtContext *cxt) } /* - * In the ALTER TABLE case, don't complain about index keys - * not created in the command; they may well exist already. - * DefineIndex will complain about them if not, and will also - * take care of marking them NOT NULL. + * In the ALTER TABLE case, don't complain about index keys not + * created in the command; they may well exist already. + * DefineIndex will complain about them if not, and will also take + * care of marking them NOT NULL. */ if (!found && !cxt->isalter) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_COLUMN), - errmsg("column \"%s\" named in key does not exist", - key))); + errmsg("column \"%s\" named in key does not exist", + key))); /* Check for PRIMARY KEY(foo, foo) */ foreach(columns, index->indexParams) @@ -1355,14 +1348,13 @@ transformIndexConstraints(ParseState *pstate, CreateStmtContext *cxt) } /* - * Scan the index list and remove any redundant index specifications. - * This can happen if, for instance, the user writes UNIQUE PRIMARY - * KEY. A strict reading of SQL92 would suggest raising an error - * instead, but that strikes me as too anal-retentive. - tgl - * 2001-02-14 + * Scan the index list and remove any redundant index specifications. This + * can happen if, for instance, the user writes UNIQUE PRIMARY KEY. A + * strict reading of SQL92 would suggest raising an error instead, but + * that strikes me as too anal-retentive. - tgl 2001-02-14 * - * XXX in ALTER TABLE case, it'd be nice to look for duplicate - * pre-existing indexes, too. + * XXX in ALTER TABLE case, it'd be nice to look for duplicate pre-existing + * indexes, too. */ cxt->alist = NIL; if (cxt->pkey != NULL) @@ -1430,10 +1422,10 @@ transformFKConstraints(ParseState *pstate, CreateStmtContext *cxt, } /* - * For CREATE TABLE or ALTER TABLE ADD COLUMN, gin up an ALTER TABLE - * ADD CONSTRAINT command to execute after the basic command is - * complete. (If called from ADD CONSTRAINT, that routine will add the - * FK constraints to its own subcommand list.) + * For CREATE TABLE or ALTER TABLE ADD COLUMN, gin up an ALTER TABLE ADD + * CONSTRAINT command to execute after the basic command is complete. (If + * called from ADD CONSTRAINT, that routine will add the FK constraints to + * its own subcommand list.) * * Note: the ADD CONSTRAINT command must also execute after any index * creation commands. Thus, this should run after @@ -1481,11 +1473,11 @@ transformIndexStmt(ParseState *pstate, IndexStmt *stmt) if (stmt->whereClause) { /* - * Put the parent table into the rtable so that the WHERE clause - * can refer to its fields without qualification. Note that this - * only works if the parent table already exists --- so we can't - * easily support predicates on indexes created implicitly by - * CREATE TABLE. Fortunately, that's not necessary. + * Put the parent table into the rtable so that the WHERE clause can + * refer to its fields without qualification. Note that this only + * works if the parent table already exists --- so we can't easily + * support predicates on indexes created implicitly by CREATE TABLE. + * Fortunately, that's not necessary. */ rte = addRangeTableEntry(pstate, stmt->relation, NULL, false, true); @@ -1514,14 +1506,14 @@ transformIndexStmt(ParseState *pstate, IndexStmt *stmt) ielem->expr = transformExpr(pstate, ielem->expr); /* - * We check only that the result type is legitimate; this is - * for consistency with what transformWhereClause() checks for - * the predicate. DefineIndex() will make more checks. + * We check only that the result type is legitimate; this is for + * consistency with what transformWhereClause() checks for the + * predicate. DefineIndex() will make more checks. */ if (expression_returns_set(ielem->expr)) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("index expression may not return a set"))); + errmsg("index expression may not return a set"))); } } @@ -1560,9 +1552,9 @@ transformRuleStmt(ParseState *pstate, RuleStmt *stmt, rel = heap_openrv(stmt->relation, AccessExclusiveLock); /* - * NOTE: 'OLD' must always have a varno equal to 1 and 'NEW' equal to - * 2. Set up their RTEs in the main pstate for use in parsing the - * rule qualification. + * NOTE: 'OLD' must always have a varno equal to 1 and 'NEW' equal to 2. + * Set up their RTEs in the main pstate for use in parsing the rule + * qualification. */ Assert(pstate->p_rtable == NIL); oldrte = addRangeTableEntryForRelation(pstate, rel, @@ -1576,11 +1568,11 @@ transformRuleStmt(ParseState *pstate, RuleStmt *stmt, newrte->requiredPerms = 0; /* - * They must be in the namespace too for lookup purposes, but only add - * the one(s) that are relevant for the current kind of rule. In an - * UPDATE rule, quals must refer to OLD.field or NEW.field to be - * unambiguous, but there's no need to be so picky for INSERT & - * DELETE. We do not add them to the joinlist. + * They must be in the namespace too for lookup purposes, but only add the + * one(s) that are relevant for the current kind of rule. In an UPDATE + * rule, quals must refer to OLD.field or NEW.field to be unambiguous, but + * there's no need to be so picky for INSERT & DELETE. We do not add them + * to the joinlist. */ switch (stmt->event) { @@ -1616,17 +1608,16 @@ transformRuleStmt(ParseState *pstate, RuleStmt *stmt, if (pstate->p_hasAggs) ereport(ERROR, (errcode(ERRCODE_GROUPING_ERROR), - errmsg("rule WHERE condition may not contain aggregate functions"))); + errmsg("rule WHERE condition may not contain aggregate functions"))); /* save info about sublinks in where clause */ qry->hasSubLinks = pstate->p_hasSubLinks; /* - * 'instead nothing' rules with a qualification need a query - * rangetable so the rewrite handler can add the negated rule - * qualification to the original query. We create a query with the new - * command type CMD_NOTHING here that is treated specially by the - * rewrite system. + * 'instead nothing' rules with a qualification need a query rangetable so + * the rewrite handler can add the negated rule qualification to the + * original query. We create a query with the new command type CMD_NOTHING + * here that is treated specially by the rewrite system. */ if (stmt->actions == NIL) { @@ -1656,11 +1647,11 @@ transformRuleStmt(ParseState *pstate, RuleStmt *stmt, has_new; /* - * Set up OLD/NEW in the rtable for this statement. The - * entries are added only to relnamespace, not varnamespace, - * because we don't want them to be referred to by unqualified - * field names nor "*" in the rule actions. We decide later - * whether to put them in the joinlist. + * Set up OLD/NEW in the rtable for this statement. The entries + * are added only to relnamespace, not varnamespace, because we + * don't want them to be referred to by unqualified field names + * nor "*" in the rule actions. We decide later whether to put + * them in the joinlist. */ oldrte = addRangeTableEntryForRelation(sub_pstate, rel, makeAlias("*OLD*", NIL), @@ -1678,9 +1669,9 @@ transformRuleStmt(ParseState *pstate, RuleStmt *stmt, extras_before, extras_after); /* - * We cannot support utility-statement actions (eg NOTIFY) - * with nonempty rule WHERE conditions, because there's no way - * to make the utility action execute conditionally. + * We cannot support utility-statement actions (eg NOTIFY) with + * nonempty rule WHERE conditions, because there's no way to make + * the utility action execute conditionally. */ if (top_subqry->commandType == CMD_UTILITY && stmt->whereClause != NULL) @@ -1689,18 +1680,17 @@ transformRuleStmt(ParseState *pstate, RuleStmt *stmt, errmsg("rules with WHERE conditions may only have SELECT, INSERT, UPDATE, or DELETE actions"))); /* - * If the action is INSERT...SELECT, OLD/NEW have been pushed - * down into the SELECT, and that's what we need to look at. - * (Ugly kluge ... try to fix this when we redesign - * querytrees.) + * If the action is INSERT...SELECT, OLD/NEW have been pushed down + * into the SELECT, and that's what we need to look at. (Ugly + * kluge ... try to fix this when we redesign querytrees.) */ sub_qry = getInsertSelectQuery(top_subqry, NULL); /* - * If the sub_qry is a setop, we cannot attach any - * qualifications to it, because the planner won't notice - * them. This could perhaps be relaxed someday, but for now, - * we may as well reject such a rule immediately. + * If the sub_qry is a setop, we cannot attach any qualifications + * to it, because the planner won't notice them. This could + * perhaps be relaxed someday, but for now, we may as well reject + * such a rule immediately. */ if (sub_qry->setOperations != NULL && stmt->whereClause != NULL) ereport(ERROR, @@ -1722,12 +1712,12 @@ transformRuleStmt(ParseState *pstate, RuleStmt *stmt, case CMD_SELECT: if (has_old) ereport(ERROR, - (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("ON SELECT rule may not use OLD"))); + (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), + errmsg("ON SELECT rule may not use OLD"))); if (has_new) ereport(ERROR, - (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("ON SELECT rule may not use NEW"))); + (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), + errmsg("ON SELECT rule may not use NEW"))); break; case CMD_UPDATE: /* both are OK */ @@ -1735,14 +1725,14 @@ transformRuleStmt(ParseState *pstate, RuleStmt *stmt, case CMD_INSERT: if (has_old) ereport(ERROR, - (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("ON INSERT rule may not use OLD"))); + (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), + errmsg("ON INSERT rule may not use OLD"))); break; case CMD_DELETE: if (has_new) ereport(ERROR, - (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("ON DELETE rule may not use NEW"))); + (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), + errmsg("ON DELETE rule may not use NEW"))); break; default: elog(ERROR, "unrecognized event type: %d", @@ -1751,28 +1741,26 @@ transformRuleStmt(ParseState *pstate, RuleStmt *stmt, } /* - * For efficiency's sake, add OLD to the rule action's - * jointree only if it was actually referenced in the - * statement or qual. + * For efficiency's sake, add OLD to the rule action's jointree + * only if it was actually referenced in the statement or qual. * - * For INSERT, NEW is not really a relation (only a reference to - * the to-be-inserted tuple) and should never be added to the + * For INSERT, NEW is not really a relation (only a reference to the + * to-be-inserted tuple) and should never be added to the * jointree. * * For UPDATE, we treat NEW as being another kind of reference to - * OLD, because it represents references to *transformed* - * tuples of the existing relation. It would be wrong to - * enter NEW separately in the jointree, since that would - * cause a double join of the updated relation. It's also - * wrong to fail to make a jointree entry if only NEW and not - * OLD is mentioned. + * OLD, because it represents references to *transformed* tuples + * of the existing relation. It would be wrong to enter NEW + * separately in the jointree, since that would cause a double + * join of the updated relation. It's also wrong to fail to make + * a jointree entry if only NEW and not OLD is mentioned. */ if (has_old || (has_new && stmt->event == CMD_UPDATE)) { /* - * If sub_qry is a setop, manipulating its jointree will - * do no good at all, because the jointree is dummy. (This - * should be a can't-happen case because of prior tests.) + * If sub_qry is a setop, manipulating its jointree will do no + * good at all, because the jointree is dummy. (This should be + * a can't-happen case because of prior tests.) */ if (sub_qry->setOperations != NULL) ereport(ERROR, @@ -1919,8 +1907,8 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt) qry->commandType = CMD_SELECT; /* - * Find leftmost leaf SelectStmt; extract the one-time-only items from - * it and from the top-level node. + * Find leftmost leaf SelectStmt; extract the one-time-only items from it + * and from the top-level node. */ leftmostSelect = stmt->larg; while (leftmostSelect && leftmostSelect->op != SETOP_NONE) @@ -1935,9 +1923,9 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt) leftmostSelect->intoColNames = NIL; /* - * These are not one-time, exactly, but we want to process them here - * and not let transformSetOperationTree() see them --- else it'll - * just recurse right back here! + * These are not one-time, exactly, but we want to process them here and + * not let transformSetOperationTree() see them --- else it'll just + * recurse right back here! */ sortClause = stmt->sortClause; limitOffset = stmt->limitOffset; @@ -1976,13 +1964,13 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt) /* * Generate dummy targetlist for outer query using column names of * leftmost select and common datatypes of topmost set operation. Also - * make lists of the dummy vars and their names for use in parsing - * ORDER BY. + * make lists of the dummy vars and their names for use in parsing ORDER + * BY. * - * Note: we use leftmostRTI as the varno of the dummy variables. It - * shouldn't matter too much which RT index they have, as long as they - * have one that corresponds to a real RT entry; else funny things may - * happen when the tree is mashed by rule rewriting. + * Note: we use leftmostRTI as the varno of the dummy variables. It shouldn't + * matter too much which RT index they have, as long as they have one that + * corresponds to a real RT entry; else funny things may happen when the + * tree is mashed by rule rewriting. */ qry->targetList = NIL; targetvars = NIL; @@ -2017,9 +2005,9 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt) /* * Handle SELECT INTO/CREATE TABLE AS. * - * Any column names from CREATE TABLE AS need to be attached to both the - * top level and the leftmost subquery. We do not do this earlier - * because we do *not* want the targetnames list to be affected. + * Any column names from CREATE TABLE AS need to be attached to both the top + * level and the leftmost subquery. We do not do this earlier because we + * do *not* want the targetnames list to be affected. */ qry->into = into; if (intoColNames) @@ -2029,15 +2017,14 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt) } /* - * As a first step towards supporting sort clauses that are - * expressions using the output columns, generate a varnamespace entry - * that makes the output columns visible. A Join RTE node is handy - * for this, since we can easily control the Vars generated upon - * matches. + * As a first step towards supporting sort clauses that are expressions + * using the output columns, generate a varnamespace entry that makes the + * output columns visible. A Join RTE node is handy for this, since we + * can easily control the Vars generated upon matches. * - * Note: we don't yet do anything useful with such cases, but at least - * "ORDER BY upper(foo)" will draw the right error message rather than - * "foo not found". + * Note: we don't yet do anything useful with such cases, but at least "ORDER + * BY upper(foo)" will draw the right error message rather than "foo not + * found". */ jrte = addRangeTableEntryForJoin(NULL, targetnames, @@ -2050,7 +2037,7 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt) pstate->p_rtable = list_make1(jrte); sv_relnamespace = pstate->p_relnamespace; - pstate->p_relnamespace = NIL; /* no qualified names allowed */ + pstate->p_relnamespace = NIL; /* no qualified names allowed */ sv_varnamespace = pstate->p_varnamespace; pstate->p_varnamespace = list_make1(jrte); @@ -2058,15 +2045,15 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt) /* * For now, we don't support resjunk sort clauses on the output of a * setOperation tree --- you can only use the SQL92-spec options of - * selecting an output column by name or number. Enforce by checking - * that transformSortClause doesn't add any items to tlist. + * selecting an output column by name or number. Enforce by checking that + * transformSortClause doesn't add any items to tlist. */ tllen = list_length(qry->targetList); qry->sortClause = transformSortClause(pstate, sortClause, &qry->targetList, - false /* no unknowns expected */ ); + false /* no unknowns expected */ ); pstate->p_rtable = sv_rtable; pstate->p_relnamespace = sv_relnamespace; @@ -2122,9 +2109,9 @@ transformSetOperationTree(ParseState *pstate, SelectStmt *stmt) /* * If an internal node of a set-op tree has ORDER BY, UPDATE, or LIMIT - * clauses attached, we need to treat it like a leaf node to generate - * an independent sub-Query tree. Otherwise, it can be represented by - * a SetOperationStmt node underneath the parent Query. + * clauses attached, we need to treat it like a leaf node to generate an + * independent sub-Query tree. Otherwise, it can be represented by a + * SetOperationStmt node underneath the parent Query. */ if (stmt->op == SETOP_NONE) { @@ -2153,9 +2140,9 @@ transformSetOperationTree(ParseState *pstate, SelectStmt *stmt) /* * Transform SelectStmt into a Query. * - * Note: previously transformed sub-queries don't affect the parsing - * of this sub-query, because they are not in the toplevel - * pstate's namespace list. + * Note: previously transformed sub-queries don't affect the parsing of + * this sub-query, because they are not in the toplevel pstate's + * namespace list. */ selectList = parse_sub_analyze((Node *) stmt, pstate); @@ -2164,10 +2151,10 @@ transformSetOperationTree(ParseState *pstate, SelectStmt *stmt) Assert(IsA(selectQuery, Query)); /* - * Check for bogus references to Vars on the current query level - * (but upper-level references are okay). Normally this can't - * happen because the namespace will be empty, but it could happen - * if we are inside a rule. + * Check for bogus references to Vars on the current query level (but + * upper-level references are okay). Normally this can't happen + * because the namespace will be empty, but it could happen if we are + * inside a rule. */ if (pstate->p_relnamespace || pstate->p_varnamespace) { @@ -2188,8 +2175,7 @@ transformSetOperationTree(ParseState *pstate, SelectStmt *stmt) false); /* - * Return a RangeTblRef to replace the SelectStmt in the set-op - * tree. + * Return a RangeTblRef to replace the SelectStmt in the set-op tree. */ rtr = makeNode(RangeTblRef); /* assume new rte is at end */ @@ -2229,8 +2215,8 @@ transformSetOperationTree(ParseState *pstate, SelectStmt *stmt) if (list_length(lcoltypes) != list_length(rcoltypes)) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("each %s query must have the same number of columns", - context))); + errmsg("each %s query must have the same number of columns", + context))); op->colTypes = NIL; forboth(l, lcoltypes, r, rcoltypes) @@ -2300,7 +2286,7 @@ applyColumnNames(List *dst, List *src) if (list_length(src) > list_length(dst)) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("CREATE TABLE AS specifies too many column names"))); + errmsg("CREATE TABLE AS specifies too many column names"))); forboth(dst_item, dst, src_item, src) { @@ -2329,13 +2315,13 @@ transformUpdateStmt(ParseState *pstate, UpdateStmt *stmt) pstate->p_is_update = true; qry->resultRelation = setTargetTable(pstate, stmt->relation, - interpretInhOption(stmt->relation->inhOpt), + interpretInhOption(stmt->relation->inhOpt), true, ACL_UPDATE); /* - * the FROM clause is non-standard SQL syntax. We used to be able to - * do this with REPLACE in POSTQUEL so we keep the feature. + * the FROM clause is non-standard SQL syntax. We used to be able to do + * this with REPLACE in POSTQUEL so we keep the feature. */ transformFromClause(pstate, stmt->fromClause); @@ -2371,10 +2357,10 @@ transformUpdateStmt(ParseState *pstate, UpdateStmt *stmt) if (tle->resjunk) { /* - * Resjunk nodes need no additional processing, but be sure - * they have resnos that do not match any target columns; else - * rewriter or planner might get confused. They don't need a - * resname either. + * Resjunk nodes need no additional processing, but be sure they + * have resnos that do not match any target columns; else rewriter + * or planner might get confused. They don't need a resname + * either. */ tle->resno = (AttrNumber) pstate->p_next_resno++; tle->resname = NULL; @@ -2428,9 +2414,9 @@ transformAlterTableStmt(ParseState *pstate, AlterTableStmt *stmt, cxt.pkey = NULL; /* - * The only subtypes that currently require parse transformation - * handling are ADD COLUMN and ADD CONSTRAINT. These largely re-use - * code from CREATE TABLE. + * The only subtypes that currently require parse transformation handling + * are ADD COLUMN and ADD CONSTRAINT. These largely re-use code from + * CREATE TABLE. */ foreach(lcmd, stmt->cmds) { @@ -2472,8 +2458,8 @@ transformAlterTableStmt(ParseState *pstate, AlterTableStmt *stmt, } /* - * All constraints are processed in other ways. Remove - * the original list + * All constraints are processed in other ways. Remove the + * original list */ def->constraints = NIL; @@ -2482,8 +2468,7 @@ transformAlterTableStmt(ParseState *pstate, AlterTableStmt *stmt, case AT_AddConstraint: /* - * The original AddConstraint cmd node doesn't go to - * newcmds + * The original AddConstraint cmd node doesn't go to newcmds */ if (IsA(cmd->def, Constraint)) @@ -2502,8 +2487,8 @@ transformAlterTableStmt(ParseState *pstate, AlterTableStmt *stmt, case AT_ProcessedConstraint: /* - * Already-transformed ADD CONSTRAINT, so just make it - * look like the standard case. + * Already-transformed ADD CONSTRAINT, so just make it look + * like the standard case. */ cmd->subtype = AT_AddConstraint; newcmds = lappend(newcmds, cmd); @@ -2521,8 +2506,8 @@ transformAlterTableStmt(ParseState *pstate, AlterTableStmt *stmt, transformFKConstraints(pstate, &cxt, skipValidation, true); /* - * Push any index-creation commands into the ALTER, so that they can - * be scheduled nicely by tablecmds.c. + * Push any index-creation commands into the ALTER, so that they can be + * scheduled nicely by tablecmds.c. */ foreach(l, cxt.alist) { @@ -2669,8 +2654,8 @@ transformExecuteStmt(ParseState *pstate, ExecuteStmt *stmt) if (nparams != nexpected) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("wrong number of parameters for prepared statement \"%s\"", - stmt->name), + errmsg("wrong number of parameters for prepared statement \"%s\"", + stmt->name), errdetail("Expected %d parameters but got %d.", nexpected, nparams))); @@ -2686,7 +2671,7 @@ transformExecuteStmt(ParseState *pstate, ExecuteStmt *stmt) if (pstate->p_hasSubLinks) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot use subquery in EXECUTE parameter"))); + errmsg("cannot use subquery in EXECUTE parameter"))); if (pstate->p_hasAggs) ereport(ERROR, (errcode(ERRCODE_GROUPING_ERROR), @@ -2706,7 +2691,7 @@ transformExecuteStmt(ParseState *pstate, ExecuteStmt *stmt) i, format_type_be(given_type_id), format_type_be(expected_type_id)), - errhint("You will need to rewrite or cast the expression."))); + errhint("You will need to rewrite or cast the expression."))); lfirst(l) = expr; i++; @@ -2730,28 +2715,28 @@ CheckSelectLocking(Query *qry, bool forUpdate) if (qry->setOperations) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - /* translator: %s is a SQL command, like SELECT FOR UPDATE */ - errmsg("%s is not allowed with UNION/INTERSECT/EXCEPT", operation))); + /* translator: %s is a SQL command, like SELECT FOR UPDATE */ + errmsg("%s is not allowed with UNION/INTERSECT/EXCEPT", operation))); if (qry->distinctClause != NIL) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - /* translator: %s is a SQL command, like SELECT FOR UPDATE */ - errmsg("%s is not allowed with DISTINCT clause", operation))); + /* translator: %s is a SQL command, like SELECT FOR UPDATE */ + errmsg("%s is not allowed with DISTINCT clause", operation))); if (qry->groupClause != NIL) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - /* translator: %s is a SQL command, like SELECT FOR UPDATE */ - errmsg("%s is not allowed with GROUP BY clause", operation))); + /* translator: %s is a SQL command, like SELECT FOR UPDATE */ + errmsg("%s is not allowed with GROUP BY clause", operation))); if (qry->havingQual != NULL) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - /* translator: %s is a SQL command, like SELECT FOR UPDATE */ + /* translator: %s is a SQL command, like SELECT FOR UPDATE */ errmsg("%s is not allowed with HAVING clause", operation))); if (qry->hasAggs) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - /* translator: %s is a SQL command, like SELECT FOR UPDATE */ - errmsg("%s is not allowed with aggregate functions", operation))); + /* translator: %s is a SQL command, like SELECT FOR UPDATE */ + errmsg("%s is not allowed with aggregate functions", operation))); } /* @@ -2775,7 +2760,7 @@ transformLockingClause(Query *qry, LockingClause *lc) if (lc->forUpdate != qry->forUpdate) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot use both FOR UPDATE and FOR SHARE in one query"))); + errmsg("cannot use both FOR UPDATE and FOR SHARE in one query"))); if (lc->nowait != qry->rowNoWait) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), @@ -2788,7 +2773,7 @@ transformLockingClause(Query *qry, LockingClause *lc) /* make a clause we can pass down to subqueries to select all rels */ allrels = makeNode(LockingClause); - allrels->lockedRels = NIL; /* indicates all rels */ + allrels->lockedRels = NIL; /* indicates all rels */ allrels->forUpdate = lc->forUpdate; allrels->nowait = lc->nowait; @@ -2813,8 +2798,8 @@ transformLockingClause(Query *qry, LockingClause *lc) case RTE_SUBQUERY: /* - * FOR UPDATE/SHARE of subquery is propagated to all - * of subquery's rels + * FOR UPDATE/SHARE of subquery is propagated to all of + * subquery's rels */ transformLockingClause(rte->subquery, allrels); break; @@ -2856,18 +2841,18 @@ transformLockingClause(Query *qry, LockingClause *lc) break; case RTE_JOIN: ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("SELECT FOR UPDATE/SHARE cannot be applied to a join"))); + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("SELECT FOR UPDATE/SHARE cannot be applied to a join"))); break; case RTE_SPECIAL: ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("SELECT FOR UPDATE/SHARE cannot be applied to NEW or OLD"))); + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("SELECT FOR UPDATE/SHARE cannot be applied to NEW or OLD"))); break; case RTE_FUNCTION: ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("SELECT FOR UPDATE/SHARE cannot be applied to a function"))); + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("SELECT FOR UPDATE/SHARE cannot be applied to a function"))); break; default: elog(ERROR, "unrecognized RTE type: %d", @@ -2940,7 +2925,7 @@ transformConstraintAttrs(List *constraintList) !IsA(lastprimarynode, FkConstraint)) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("misplaced NOT DEFERRABLE clause"))); + errmsg("misplaced NOT DEFERRABLE clause"))); if (saw_deferrability) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), @@ -2958,7 +2943,7 @@ transformConstraintAttrs(List *constraintList) !IsA(lastprimarynode, FkConstraint)) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("misplaced INITIALLY DEFERRED clause"))); + errmsg("misplaced INITIALLY DEFERRED clause"))); if (saw_initially) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), @@ -2967,8 +2952,7 @@ transformConstraintAttrs(List *constraintList) ((FkConstraint *) lastprimarynode)->initdeferred = true; /* - * If only INITIALLY DEFERRED appears, assume - * DEFERRABLE + * If only INITIALLY DEFERRED appears, assume DEFERRABLE */ if (!saw_deferrability) ((FkConstraint *) lastprimarynode)->deferrable = true; @@ -2982,7 +2966,7 @@ transformConstraintAttrs(List *constraintList) !IsA(lastprimarynode, FkConstraint)) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("misplaced INITIALLY IMMEDIATE clause"))); + errmsg("misplaced INITIALLY IMMEDIATE clause"))); if (saw_initially) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), @@ -3082,8 +3066,8 @@ analyzeCreateSchemaStmt(CreateSchemaStmt *stmt) cxt.alist = NIL; /* - * Run through each schema element in the schema element list. - * Separate statements by type, and do preliminary analysis. + * Run through each schema element in the schema element list. Separate + * statements by type, and do preliminary analysis. */ foreach(elements, stmt->schemaElts) { @@ -3173,7 +3157,7 @@ analyzeCreateSchemaStmt(CreateSchemaStmt *stmt) */ static bool check_parameter_resolution_walker(Node *node, - check_parameter_resolution_context *context) + check_parameter_resolution_context *context) { if (node == NULL) return false; @@ -3194,8 +3178,8 @@ check_parameter_resolution_walker(Node *node, if (param->paramtype != context->paramTypes[paramno - 1]) ereport(ERROR, (errcode(ERRCODE_AMBIGUOUS_PARAMETER), - errmsg("could not determine data type of parameter $%d", - paramno))); + errmsg("could not determine data type of parameter $%d", + paramno))); } return false; } diff --git a/src/backend/parser/keywords.c b/src/backend/parser/keywords.c index 6733d1b124..f80b655280 100644 --- a/src/backend/parser/keywords.c +++ b/src/backend/parser/keywords.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/keywords.c,v 1.165 2005/08/23 22:40:27 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/keywords.c,v 1.166 2005/10/15 02:49:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -393,8 +393,8 @@ ScanKeywordLookup(const char *text) return NULL; /* - * Apply an ASCII-only downcasing. We must not use tolower() since it - * may produce the wrong translation in some locales (eg, Turkish). + * Apply an ASCII-only downcasing. We must not use tolower() since it may + * produce the wrong translation in some locales (eg, Turkish). */ for (i = 0; i < len; i++) { diff --git a/src/backend/parser/parse_agg.c b/src/backend/parser/parse_agg.c index 799bacd233..743442895a 100644 --- a/src/backend/parser/parse_agg.c +++ b/src/backend/parser/parse_agg.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/parse_agg.c,v 1.69 2005/06/05 22:32:57 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_agg.c,v 1.70 2005/10/15 02:49:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -56,22 +56,22 @@ transformAggregateCall(ParseState *pstate, Aggref *agg) /* * The aggregate's level is the same as the level of the lowest-level - * variable or aggregate in its argument; or if it contains no - * variables at all, we presume it to be local. + * variable or aggregate in its argument; or if it contains no variables + * at all, we presume it to be local. */ min_varlevel = find_minimum_var_level((Node *) agg->target); /* - * An aggregate can't directly contain another aggregate call of the - * same level (though outer aggs are okay). We can skip this check if - * we didn't find any local vars or aggs. + * An aggregate can't directly contain another aggregate call of the same + * level (though outer aggs are okay). We can skip this check if we + * didn't find any local vars or aggs. */ if (min_varlevel == 0) { if (checkExprHasAggs((Node *) agg->target)) ereport(ERROR, (errcode(ERRCODE_GROUPING_ERROR), - errmsg("aggregate function calls may not be nested"))); + errmsg("aggregate function calls may not be nested"))); } if (min_varlevel < 0) @@ -127,8 +127,8 @@ parseCheckAggregates(ParseState *pstate, Query *qry) /* * No aggregates allowed in GROUP BY clauses, either. * - * While we are at it, build a list of the acceptable GROUP BY - * expressions for use by check_ungrouped_columns(). + * While we are at it, build a list of the acceptable GROUP BY expressions + * for use by check_ungrouped_columns(). */ foreach(l, qry->groupClause) { @@ -141,15 +141,15 @@ parseCheckAggregates(ParseState *pstate, Query *qry) if (checkExprHasAggs(expr)) ereport(ERROR, (errcode(ERRCODE_GROUPING_ERROR), - errmsg("aggregates not allowed in GROUP BY clause"))); + errmsg("aggregates not allowed in GROUP BY clause"))); groupClauses = lcons(expr, groupClauses); } /* - * If there are join alias vars involved, we have to flatten them to - * the underlying vars, so that aliased and unaliased vars will be - * correctly taken as equal. We can skip the expense of doing this if - * no rangetable entries are RTE_JOIN kind. + * If there are join alias vars involved, we have to flatten them to the + * underlying vars, so that aliased and unaliased vars will be correctly + * taken as equal. We can skip the expense of doing this if no rangetable + * entries are RTE_JOIN kind. */ hasJoinRTEs = false; foreach(l, pstate->p_rtable) @@ -165,8 +165,8 @@ parseCheckAggregates(ParseState *pstate, Query *qry) /* * We use the planner's flatten_join_alias_vars routine to do the - * flattening; it wants a PlannerInfo root node, which fortunately - * can be mostly dummy. + * flattening; it wants a PlannerInfo root node, which fortunately can be + * mostly dummy. */ if (hasJoinRTEs) { @@ -175,15 +175,15 @@ parseCheckAggregates(ParseState *pstate, Query *qry) root->hasJoinRTEs = true; groupClauses = (List *) flatten_join_alias_vars(root, - (Node *) groupClauses); + (Node *) groupClauses); } else root = NULL; /* keep compiler quiet */ /* - * Detect whether any of the grouping expressions aren't simple Vars; - * if they're all Vars then we don't have to work so hard in the - * recursive scans. (Note we have to flatten aliases before this.) + * Detect whether any of the grouping expressions aren't simple Vars; if + * they're all Vars then we don't have to work so hard in the recursive + * scans. (Note we have to flatten aliases before this.) */ have_non_var_grouping = false; foreach(l, groupClauses) @@ -259,23 +259,23 @@ check_ungrouped_columns_walker(Node *node, return false; /* constants are always acceptable */ /* - * If we find an aggregate call of the original level, do not recurse - * into its arguments; ungrouped vars in the arguments are not an - * error. We can also skip looking at the arguments of aggregates of - * higher levels, since they could not possibly contain Vars that are - * of concern to us (see transformAggregateCall). We do need to look - * into the arguments of aggregates of lower levels, however. + * If we find an aggregate call of the original level, do not recurse into + * its arguments; ungrouped vars in the arguments are not an error. We can + * also skip looking at the arguments of aggregates of higher levels, + * since they could not possibly contain Vars that are of concern to us + * (see transformAggregateCall). We do need to look into the arguments of + * aggregates of lower levels, however. */ if (IsA(node, Aggref) && (int) ((Aggref *) node)->agglevelsup >= context->sublevels_up) return false; /* - * If we have any GROUP BY items that are not simple Vars, check to - * see if subexpression as a whole matches any GROUP BY item. We need - * to do this at every recursion level so that we recognize GROUPed-BY - * expressions before reaching variables within them. But this only - * works at the outer query level, as noted above. + * If we have any GROUP BY items that are not simple Vars, check to see if + * subexpression as a whole matches any GROUP BY item. We need to do this + * at every recursion level so that we recognize GROUPed-BY expressions + * before reaching variables within them. But this only works at the outer + * query level, as noted above. */ if (context->have_non_var_grouping && context->sublevels_up == 0) { @@ -288,10 +288,9 @@ check_ungrouped_columns_walker(Node *node, /* * If we have an ungrouped Var of the original query level, we have a - * failure. Vars below the original query level are not a problem, - * and neither are Vars from above it. (If such Vars are ungrouped as - * far as their own query level is concerned, that's someone else's - * problem...) + * failure. Vars below the original query level are not a problem, and + * neither are Vars from above it. (If such Vars are ungrouped as far as + * their own query level is concerned, that's someone else's problem...) */ if (IsA(node, Var)) { @@ -321,7 +320,7 @@ check_ungrouped_columns_walker(Node *node, /* Found an ungrouped local variable; generate error message */ Assert(var->varno > 0 && - (int) var->varno <= list_length(context->pstate->p_rtable)); + (int) var->varno <= list_length(context->pstate->p_rtable)); rte = rt_fetch(var->varno, context->pstate->p_rtable); attname = get_rte_attribute_name(rte, var->varattno); if (context->sublevels_up == 0) @@ -390,10 +389,10 @@ build_aggregate_fnexprs(Oid agg_input_type, transfn_nargs = get_func_nargs(transfn_oid); /* - * Build arg list to use in the transfn FuncExpr node. We really only - * care that transfn can discover the actual argument types at runtime - * using get_fn_expr_argtype(), so it's okay to use Param nodes that - * don't correspond to any real Param. + * Build arg list to use in the transfn FuncExpr node. We really only care + * that transfn can discover the actual argument types at runtime using + * get_fn_expr_argtype(), so it's okay to use Param nodes that don't + * correspond to any real Param. */ arg0 = makeNode(Param); arg0->paramkind = PARAM_EXEC; diff --git a/src/backend/parser/parse_clause.c b/src/backend/parser/parse_clause.c index 593f8f1f4b..95e1045ba2 100644 --- a/src/backend/parser/parse_clause.c +++ b/src/backend/parser/parse_clause.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/parse_clause.c,v 1.142 2005/06/05 00:38:09 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_clause.c,v 1.143 2005/10/15 02:49:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -87,10 +87,10 @@ transformFromClause(ParseState *pstate, List *frmList) ListCell *fl; /* - * The grammar will have produced a list of RangeVars, - * RangeSubselects, RangeFunctions, and/or JoinExprs. Transform each - * one (possibly adding entries to the rtable), check for duplicate - * refnames, and then add it to the joinlist and namespaces. + * The grammar will have produced a list of RangeVars, RangeSubselects, + * RangeFunctions, and/or JoinExprs. Transform each one (possibly adding + * entries to the rtable), check for duplicate refnames, and then add it + * to the joinlist and namespaces. */ foreach(fl, frmList) { @@ -148,8 +148,8 @@ setTargetTable(ParseState *pstate, RangeVar *relation, heap_close(pstate->p_target_relation, NoLock); /* - * Open target rel and grab suitable lock (which we will hold till end - * of transaction). + * Open target rel and grab suitable lock (which we will hold till end of + * transaction). * * analyze.c will eventually do the corresponding heap_close(), but *not* * release the lock. @@ -168,14 +168,13 @@ setTargetTable(ParseState *pstate, RangeVar *relation, Assert(rte == rt_fetch(rtindex, pstate->p_rtable)); /* - * Override addRangeTableEntry's default ACL_SELECT permissions check, - * and instead mark target table as requiring exactly the specified + * Override addRangeTableEntry's default ACL_SELECT permissions check, and + * instead mark target table as requiring exactly the specified * permissions. * - * If we find an explicit reference to the rel later during parse - * analysis, scanRTEForColumn will add the ACL_SELECT bit back again. - * That can't happen for INSERT but it is possible for UPDATE and - * DELETE. + * If we find an explicit reference to the rel later during parse analysis, + * scanRTEForColumn will add the ACL_SELECT bit back again. That can't + * happen for INSERT but it is possible for UPDATE and DELETE. */ rte->requiredPerms = requiredPerms; @@ -294,10 +293,9 @@ transformJoinUsingClause(ParseState *pstate, List *leftVars, List *rightVars) *rvars; /* - * We cheat a little bit here by building an untransformed operator - * tree whose leaves are the already-transformed Vars. This is OK - * because transformExpr() won't complain about already-transformed - * subnodes. + * We cheat a little bit here by building an untransformed operator tree + * whose leaves are the already-transformed Vars. This is OK because + * transformExpr() won't complain about already-transformed subnodes. */ forboth(lvars, leftVars, rvars, rightVars) { @@ -319,10 +317,10 @@ transformJoinUsingClause(ParseState *pstate, List *leftVars, List *rightVars) } /* - * Since the references are already Vars, and are certainly from the - * input relations, we don't have to go through the same pushups that - * transformJoinOnClause() does. Just invoke transformExpr() to fix - * up the operators, and we're done. + * Since the references are already Vars, and are certainly from the input + * relations, we don't have to go through the same pushups that + * transformJoinOnClause() does. Just invoke transformExpr() to fix up + * the operators, and we're done. */ result = transformExpr(pstate, result); @@ -349,14 +347,13 @@ transformJoinOnClause(ParseState *pstate, JoinExpr *j, int varno; /* - * This is a tad tricky, for two reasons. First, the namespace that - * the join expression should see is just the two subtrees of the JOIN - * plus any outer references from upper pstate levels. So, - * temporarily set this pstate's namespace accordingly. (We need not - * check for refname conflicts, because transformFromClauseItem() - * already did.) NOTE: this code is OK only because the ON clause - * can't legally alter the namespace by causing implicit relation refs - * to be added. + * This is a tad tricky, for two reasons. First, the namespace that the + * join expression should see is just the two subtrees of the JOIN plus + * any outer references from upper pstate levels. So, temporarily set + * this pstate's namespace accordingly. (We need not check for refname + * conflicts, because transformFromClauseItem() already did.) NOTE: this + * code is OK only because the ON clause can't legally alter the namespace + * by causing implicit relation refs to be added. */ save_relnamespace = pstate->p_relnamespace; save_varnamespace = pstate->p_varnamespace; @@ -371,11 +368,10 @@ transformJoinOnClause(ParseState *pstate, JoinExpr *j, /* * Second, we need to check that the ON condition doesn't refer to any - * rels outside the input subtrees of the JOIN. It could do that - * despite our hack on the namespace if it uses fully-qualified names. - * So, grovel through the transformed clause and make sure there are - * no bogus references. (Outer references are OK, and are ignored - * here.) + * rels outside the input subtrees of the JOIN. It could do that despite + * our hack on the namespace if it uses fully-qualified names. So, grovel + * through the transformed clause and make sure there are no bogus + * references. (Outer references are OK, and are ignored here.) */ clause_varnos = pull_varnos(result); clause_varnos = bms_del_members(clause_varnos, containedRels); @@ -383,8 +379,8 @@ transformJoinOnClause(ParseState *pstate, JoinExpr *j, { ereport(ERROR, (errcode(ERRCODE_INVALID_COLUMN_REFERENCE), - errmsg("JOIN/ON clause refers to \"%s\", which is not part of JOIN", - rt_fetch(varno, pstate->p_rtable)->eref->aliasname))); + errmsg("JOIN/ON clause refers to \"%s\", which is not part of JOIN", + rt_fetch(varno, pstate->p_rtable)->eref->aliasname))); } bms_free(clause_varnos); @@ -400,9 +396,9 @@ transformTableEntry(ParseState *pstate, RangeVar *r) RangeTblEntry *rte; /* - * mark 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 + * mark 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. */ @@ -424,9 +420,9 @@ transformRangeSubselect(ParseState *pstate, RangeSubselect *r) RangeTblEntry *rte; /* - * We require user to supply an alias for a subselect, per SQL92. To - * relax this, we'd have to be prepared to gin up a unique alias for - * an unlabeled subselect. + * We require user to supply an alias for a subselect, per SQL92. To relax + * this, we'd have to be prepared to gin up a unique alias for an + * unlabeled subselect. */ if (r->alias == NULL) ereport(ERROR, @@ -439,9 +435,9 @@ transformRangeSubselect(ParseState *pstate, RangeSubselect *r) parsetrees = parse_sub_analyze(r->subquery, pstate); /* - * Check that we got something reasonable. Most of these conditions - * are probably impossible given restrictions of the grammar, but - * check 'em anyway. + * Check that we got something reasonable. Most of these conditions are + * probably impossible given restrictions of the grammar, but check 'em + * anyway. */ if (list_length(parsetrees) != 1) elog(ERROR, "unexpected parse analysis result for subquery in FROM"); @@ -457,19 +453,17 @@ transformRangeSubselect(ParseState *pstate, RangeSubselect *r) errmsg("subquery in FROM may not have SELECT INTO"))); /* - * The subquery cannot make use of any variables from FROM items - * created earlier in the current query. Per SQL92, the scope of a - * FROM item does not include other FROM items. Formerly we hacked - * the namespace so that the other variables weren't even visible, but - * it seems more useful to leave them visible and give a specific - * error message. + * The subquery cannot make use of any variables from FROM items created + * earlier in the current query. Per SQL92, the scope of a FROM item does + * not include other FROM items. Formerly we hacked the namespace so that + * the other variables weren't even visible, but it seems more useful to + * leave them visible and give a specific error message. * * XXX this will need further work to support SQL99's LATERAL() feature, * wherein such references would indeed be legal. * - * We can skip groveling through the subquery if there's not anything - * visible in the current query. Also note that outer references are - * OK. + * We can skip groveling through the subquery if there's not anything visible + * in the current query. Also note that outer references are OK. */ if (pstate->p_relnamespace || pstate->p_varnamespace) { @@ -500,9 +494,9 @@ transformRangeFunction(ParseState *pstate, RangeFunction *r) /* * Get function name for possible use as alias. We use the same - * transformation rules as for a SELECT output expression. For a - * FuncCall node, the result will be the function name, but it is - * possible for the grammar to hand back other node types. + * transformation rules as for a SELECT output expression. For a FuncCall + * node, the result will be the function name, but it is possible for the + * grammar to hand back other node types. */ funcname = FigureColname(r->funccallnode); @@ -514,8 +508,8 @@ transformRangeFunction(ParseState *pstate, RangeFunction *r) /* * The function parameters cannot make use of any variables from other * FROM items. (Compare to transformRangeSubselect(); the coding is - * different though because we didn't parse as a sub-select with its - * own level of namespace.) + * different though because we didn't parse as a sub-select with its own + * level of namespace.) * * XXX this will need further work to support SQL99's LATERAL() feature, * wherein such references would indeed be legal. @@ -529,8 +523,8 @@ transformRangeFunction(ParseState *pstate, RangeFunction *r) } /* - * Disallow aggregate functions in the expression. (No reason to - * postpone this check until parseCheckAggregates.) + * Disallow aggregate functions in the expression. (No reason to postpone + * this check until parseCheckAggregates.) */ if (pstate->p_hasAggs) { @@ -541,8 +535,8 @@ transformRangeFunction(ParseState *pstate, RangeFunction *r) } /* - * If a coldeflist is supplied, ensure it defines a legal set of names - * (no duplicates) and datatypes (no pseudo-types, for instance). + * If a coldeflist is supplied, ensure it defines a legal set of names (no + * duplicates) and datatypes (no pseudo-types, for instance). */ if (r->coldeflist) { @@ -576,7 +570,7 @@ transformRangeFunction(ParseState *pstate, RangeFunction *r) * (We could extract this from the function return node, but it saves cycles * to pass it back separately.) * - * *top_rti: receives the rangetable index of top_rte. (Ditto.) + * *top_rti: receives the rangetable index of top_rte. (Ditto.) * * *relnamespace: receives a List of the RTEs exposed as relation names * by this item. @@ -599,7 +593,7 @@ transformFromClauseItem(ParseState *pstate, Node *n, /* Plain relation reference */ RangeTblRef *rtr; RangeTblEntry *rte; - int rtindex; + int rtindex; rte = transformTableEntry(pstate, (RangeVar *) n); /* assume new rte is at end */ @@ -618,7 +612,7 @@ transformFromClauseItem(ParseState *pstate, Node *n, /* sub-SELECT is like a plain relation */ RangeTblRef *rtr; RangeTblEntry *rte; - int rtindex; + int rtindex; rte = transformRangeSubselect(pstate, (RangeSubselect *) n); /* assume new rte is at end */ @@ -637,7 +631,7 @@ transformFromClauseItem(ParseState *pstate, Node *n, /* function is like a plain relation */ RangeTblRef *rtr; RangeTblEntry *rte; - int rtindex; + int rtindex; rte = transformRangeFunction(pstate, (RangeFunction *) n); /* assume new rte is at end */ @@ -688,8 +682,8 @@ transformFromClauseItem(ParseState *pstate, Node *n, &r_containedRels); /* - * Check for conflicting refnames in left and right subtrees. Must - * do this because higher levels will assume I hand back a self- + * Check for conflicting refnames in left and right subtrees. Must do + * this because higher levels will assume I hand back a self- * consistent namespace subtree. */ checkNameSpaceConflicts(pstate, l_relnamespace, r_relnamespace); @@ -715,12 +709,12 @@ transformFromClauseItem(ParseState *pstate, Node *n, /* * Natural join does not explicitly specify columns; must generate - * columns to join. Need to run through the list of columns from - * each table or join result and match up the column names. Use - * the first table, and check every column in the second table for - * a match. (We'll check that the matches were unique later on.) - * The result of this step is a list of column names just like an - * explicitly-written USING list. + * columns to join. Need to run through the list of columns from each + * table or join result and match up the column names. Use the first + * table, and check every column in the second table for a match. + * (We'll check that the matches were unique later on.) The result of + * this step is a list of column names just like an explicitly-written + * USING list. */ if (j->isNatural) { @@ -763,9 +757,9 @@ transformFromClauseItem(ParseState *pstate, Node *n, if (j->using) { /* - * JOIN/USING (or NATURAL JOIN, as transformed above). - * Transform the list into an explicit ON-condition, and - * generate a list of merged result columns. + * JOIN/USING (or NATURAL JOIN, as transformed above). Transform + * the list into an explicit ON-condition, and generate a list of + * merged result columns. */ List *ucols = j->using; List *l_usingvars = NIL; @@ -917,10 +911,10 @@ transformFromClauseItem(ParseState *pstate, Node *n, *top_rti = j->rtindex; /* - * Prepare returned namespace list. If the JOIN has an alias - * then it hides the contained RTEs as far as the relnamespace - * goes; otherwise, put the contained RTEs and *not* the JOIN - * into relnamespace. + * Prepare returned namespace list. If the JOIN has an alias then it + * hides the contained RTEs as far as the relnamespace goes; + * otherwise, put the contained RTEs and *not* the JOIN into + * relnamespace. */ if (j->alias) { @@ -975,10 +969,10 @@ buildMergedJoinVar(ParseState *pstate, JoinType jointype, } /* - * Insert coercion functions if needed. Note that a difference in - * typmod can only happen if input has typmod but outcoltypmod is -1. - * In that case we insert a RelabelType to clearly mark that result's - * typmod is not same as input. We never need coerce_type_typmod. + * Insert coercion functions if needed. Note that a difference in typmod + * can only happen if input has typmod but outcoltypmod is -1. In that + * case we insert a RelabelType to clearly mark that result's typmod is + * not same as input. We never need coerce_type_typmod. */ if (l_colvar->vartype != outcoltype) l_node = coerce_type(pstate, (Node *) l_colvar, l_colvar->vartype, @@ -1030,8 +1024,8 @@ buildMergedJoinVar(ParseState *pstate, JoinType jointype, case JOIN_FULL: { /* - * Here we must build a COALESCE expression to ensure that - * the join output is non-null if either input is. + * Here we must build a COALESCE expression to ensure that the + * join output is non-null if either input is. */ CoalesceExpr *c = makeNode(CoalesceExpr); @@ -1095,9 +1089,9 @@ transformLimitClause(ParseState *pstate, Node *clause, qual = coerce_to_integer(pstate, qual, constructName); /* - * LIMIT can't refer to any vars or aggregates of the current query; - * we don't allow subselects either (though that case would at least - * be sensible) + * LIMIT can't refer to any vars or aggregates of the current query; we + * don't allow subselects either (though that case would at least be + * sensible) */ if (contain_vars_of_level(qual, 0)) { @@ -1193,20 +1187,19 @@ findTargetlistEntry(ParseState *pstate, Node *node, List **tlist, int clause) { /* * In GROUP BY, we must prefer a match against a FROM-clause - * column to one against the targetlist. Look to see if there - * is a matching column. If so, fall through to let - * transformExpr() do the rest. NOTE: if name could refer - * ambiguously to more than one column name exposed by FROM, - * colNameToVar will ereport(ERROR). That's just what we want - * here. + * column to one against the targetlist. Look to see if there is + * a matching column. If so, fall through to let transformExpr() + * do the rest. NOTE: if name could refer ambiguously to more + * than one column name exposed by FROM, colNameToVar will + * ereport(ERROR). That's just what we want here. * - * Small tweak for 7.4.3: ignore matches in upper query levels. - * This effectively changes the search order for bare names to - * (1) local FROM variables, (2) local targetlist aliases, (3) - * outer FROM variables, whereas before it was (1) (3) (2). - * SQL92 and SQL99 do not allow GROUPing BY an outer - * reference, so this breaks no cases that are legal per spec, - * and it seems a more self-consistent behavior. + * Small tweak for 7.4.3: ignore matches in upper query levels. This + * effectively changes the search order for bare names to (1) + * local FROM variables, (2) local targetlist aliases, (3) outer + * FROM variables, whereas before it was (1) (3) (2). SQL92 and + * SQL99 do not allow GROUPing BY an outer reference, so this + * breaks no cases that are legal per spec, and it seems a more + * self-consistent behavior. */ if (colNameToVar(pstate, name, true) != NULL) name = NULL; @@ -1292,9 +1285,9 @@ findTargetlistEntry(ParseState *pstate, Node *node, List **tlist, int clause) } /* - * If no matches, construct a new target entry which is appended to - * the end of the target list. This target is given resjunk = TRUE so - * that it will not be projected into the final tuple. + * If no matches, construct a new target entry which is appended to the + * end of the target list. This target is given resjunk = TRUE so that it + * will not be projected into the final tuple. */ target_result = transformTargetEntry(pstate, node, expr, NULL, true); @@ -1349,11 +1342,11 @@ transformGroupClause(ParseState *pstate, List *grouplist, /* * If the GROUP BY clause matches the ORDER BY clause, we want to - * adopt the ordering operators from the latter rather than using - * the default ops. This allows "GROUP BY foo ORDER BY foo DESC" - * to be done with only one sort step. Note we are assuming that - * any user-supplied ordering operator will bring equal values - * together, which is all that GROUP BY needs. + * adopt the ordering operators from the latter rather than using the + * default ops. This allows "GROUP BY foo ORDER BY foo DESC" to be + * done with only one sort step. Note we are assuming that any + * user-supplied ordering operator will bring equal values together, + * which is all that GROUP BY needs. */ if (sortItem && ((SortClause *) lfirst(sortItem))->tleSortGroupRef == @@ -1435,11 +1428,11 @@ transformDistinctClause(ParseState *pstate, List *distinctlist, /* We had SELECT DISTINCT */ /* - * All non-resjunk elements from target list that are not already - * in the sort list should be added to it. (We don't really care - * what order the DISTINCT fields are checked in, so we can leave - * the user's ORDER BY spec alone, and just add additional sort - * keys to it to ensure that all targetlist items get sorted.) + * All non-resjunk elements from target list that are not already in + * the sort list should be added to it. (We don't really care what + * order the DISTINCT fields are checked in, so we can leave the + * user's ORDER BY spec alone, and just add additional sort keys to it + * to ensure that all targetlist items get sorted.) */ *sortClause = addAllTargetsToSortList(pstate, *sortClause, @@ -1449,9 +1442,9 @@ transformDistinctClause(ParseState *pstate, List *distinctlist, /* * Now, DISTINCT list consists of all non-resjunk sortlist items. * Actually, all the sortlist items had better be non-resjunk! - * Otherwise, user wrote SELECT DISTINCT with an ORDER BY item - * that does not appear anywhere in the SELECT targetlist, and we - * can't implement that with only one sorting pass... + * Otherwise, user wrote SELECT DISTINCT with an ORDER BY item that + * does not appear anywhere in the SELECT targetlist, and we can't + * implement that with only one sorting pass... */ foreach(slitem, *sortClause) { @@ -1474,16 +1467,16 @@ transformDistinctClause(ParseState *pstate, List *distinctlist, * If the user writes both DISTINCT ON and ORDER BY, then the two * expression lists must match (until one or the other runs out). * Otherwise the ORDER BY requires a different sort order than the - * DISTINCT does, and we can't implement that with only one sort - * pass (and if we do two passes, the results will be rather + * DISTINCT does, and we can't implement that with only one sort pass + * (and if we do two passes, the results will be rather * unpredictable). However, it's OK to have more DISTINCT ON - * expressions than ORDER BY expressions; we can just add the - * extra DISTINCT values to the sort list, much as we did above - * for ordinary DISTINCT fields. + * expressions than ORDER BY expressions; we can just add the extra + * DISTINCT values to the sort list, much as we did above for ordinary + * DISTINCT fields. * - * Actually, it'd be OK for the common prefixes of the two lists to - * match in any order, but implementing that check seems like more - * trouble than it's worth. + * Actually, it'd be OK for the common prefixes of the two lists to match + * in any order, but implementing that check seems like more trouble + * than it's worth. */ ListCell *nextsortlist = list_head(*sortClause); @@ -1508,12 +1501,12 @@ transformDistinctClause(ParseState *pstate, List *distinctlist, else { *sortClause = addTargetToSortList(pstate, tle, - *sortClause, *targetlist, + *sortClause, *targetlist, SORTBY_ASC, NIL, true); /* - * Probably, the tle should always have been added at the - * end of the sort list ... but search to be safe. + * Probably, the tle should always have been added at the end + * of the sort list ... but search to be safe. */ foreach(slitem, *sortClause) { @@ -1638,7 +1631,7 @@ assignSortGroupRef(TargetEntry *tle, List *tlist) Index maxRef; ListCell *l; - if (tle->ressortgroupref) /* already has one? */ + if (tle->ressortgroupref) /* already has one? */ return tle->ressortgroupref; /* easiest way to pick an unused refnumber: max used + 1 */ diff --git a/src/backend/parser/parse_coerce.c b/src/backend/parser/parse_coerce.c index 32a20fc362..3bee3c31ad 100644 --- a/src/backend/parser/parse_coerce.c +++ b/src/backend/parser/parse_coerce.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.131 2005/06/04 19:19:42 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.132 2005/10/15 02:49:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -82,9 +82,9 @@ coerce_to_target_type(ParseState *pstate, Node *expr, Oid exprtype, ccontext, cformat); /* - * If the target is a fixed-length type, it may need a length coercion - * as well as a type coercion. If we find ourselves adding both, - * force the inner coercion node to implicit display form. + * If the target is a fixed-length type, it may need a length coercion as + * well as a type coercion. If we find ourselves adding both, force the + * inner coercion node to implicit display form. */ result = coerce_type_typmod(result, targettype, targettypmod, @@ -140,9 +140,9 @@ coerce_type(ParseState *pstate, Node *node, if (inputTypeId == UNKNOWNOID && IsA(node, Const)) { /* - * Input is a string constant with previously undetermined type. - * Apply the target type's typinput function to it to produce a - * constant of the target type. + * Input is a string constant with previously undetermined type. Apply + * the target type's typinput function to it to produce a constant of + * the target type. * * NOTE: this case cannot be folded together with the other * constant-input case, since the typinput function does not @@ -151,10 +151,10 @@ coerce_type(ParseState *pstate, Node *node, * float-to-int type conversion will round to integer. * * XXX if the typinput function is not immutable, we really ought to - * postpone evaluation of the function call until runtime. But - * there is no way to represent a typinput function call as an - * expression tree, because C-string values are not Datums. (XXX - * This *is* possible as of 7.3, do we want to do it?) + * postpone evaluation of the function call until runtime. But there + * is no way to represent a typinput function call as an expression + * tree, because C-string values are not Datums. (XXX This *is* + * possible as of 7.3, do we want to do it?) */ Const *con = (Const *) node; Const *newcon = makeNode(Const); @@ -176,14 +176,13 @@ coerce_type(ParseState *pstate, Node *node, /* * We pass typmod -1 to the input routine, primarily because - * existing input routines follow implicit-coercion semantics - * for length checks, which is not always what we want here. - * Any length constraint will be applied later by our caller. + * existing input routines follow implicit-coercion semantics for + * length checks, which is not always what we want here. Any + * length constraint will be applied later by our caller. * - * Note that we call stringTypeDatum using the domain's pg_type - * row, if it's a domain. This works because the domain row - * has the same typinput and typelem as the base type --- - * ugly... + * Note that we call stringTypeDatum using the domain's pg_type row, + * if it's a domain. This works because the domain row has the + * same typinput and typelem as the base type --- ugly... */ newcon->constvalue = stringTypeDatum(targetType, val, -1); } @@ -204,8 +203,8 @@ coerce_type(ParseState *pstate, Node *node, pstate != NULL && pstate->p_variableparams) { /* - * Input is a Param of previously undetermined type, and we want - * to update our knowledge of the Param's type. Find the topmost + * Input is a Param of previously undetermined type, and we want to + * update our knowledge of the Param's type. Find the topmost * ParseState and update the state. */ Param *param = (Param *) node; @@ -236,10 +235,10 @@ coerce_type(ParseState *pstate, Node *node, /* Ooops */ ereport(ERROR, (errcode(ERRCODE_AMBIGUOUS_PARAMETER), - errmsg("inconsistent types deduced for parameter $%d", - paramno), + errmsg("inconsistent types deduced for parameter $%d", + paramno), errdetail("%s versus %s", - format_type_be(toppstate->p_paramtypes[paramno - 1]), + format_type_be(toppstate->p_paramtypes[paramno - 1]), format_type_be(targetTypeId)))); } @@ -252,11 +251,11 @@ coerce_type(ParseState *pstate, Node *node, if (OidIsValid(funcId)) { /* - * Generate an expression tree representing run-time - * application of the conversion function. If we are dealing - * with a domain target type, the conversion function will - * yield the base type, and we need to extract the correct - * typmod to use from the domain's typtypmod. + * Generate an expression tree representing run-time application + * of the conversion function. If we are dealing with a domain + * target type, the conversion function will yield the base type, + * and we need to extract the correct typmod to use from the + * domain's typtypmod. */ Oid baseTypeId = getBaseType(targetTypeId); int32 baseTypeMod; @@ -269,13 +268,12 @@ coerce_type(ParseState *pstate, Node *node, result = build_coercion_expression(node, funcId, baseTypeId, baseTypeMod, cformat, - (cformat != COERCE_IMPLICIT_CAST)); + (cformat != COERCE_IMPLICIT_CAST)); /* - * If domain, coerce to the domain type and relabel with - * domain type ID. We can skip the internal length-coercion - * step if the selected coercion function was a type-and-length - * coercion. + * If domain, coerce to the domain type and relabel with domain + * type ID. We can skip the internal length-coercion step if the + * selected coercion function was a type-and-length coercion. */ if (targetTypeId != baseTypeId) result = coerce_to_domain(result, baseTypeId, targetTypeId, @@ -286,10 +284,9 @@ coerce_type(ParseState *pstate, Node *node, else { /* - * We don't need to do a physical conversion, but we do need - * to attach a RelabelType node so that the expression will be - * seen to have the intended type when inspected by - * higher-level code. + * We don't need to do a physical conversion, but we do need to + * attach a RelabelType node so that the expression will be seen + * to have the intended type when inspected by higher-level code. * * Also, domains may have value restrictions beyond the base type * that must be accounted for. If the destination is a domain @@ -300,11 +297,10 @@ coerce_type(ParseState *pstate, Node *node, if (result == node) { /* - * XXX could we label result with exprTypmod(node) instead - * of default -1 typmod, to save a possible - * length-coercion later? Would work if both types have - * same interpretation of typmod, which is likely but not - * certain. + * XXX could we label result with exprTypmod(node) instead of + * default -1 typmod, to save a possible length-coercion + * later? Would work if both types have same interpretation of + * typmod, which is likely but not certain. */ result = (Node *) makeRelabelType((Expr *) result, targetTypeId, -1, @@ -331,8 +327,8 @@ coerce_type(ParseState *pstate, Node *node, { /* * Input class type is a subclass of target, so generate an - * appropriate runtime conversion (removing unneeded columns - * and possibly rearranging the ones that are wanted). + * appropriate runtime conversion (removing unneeded columns and + * possibly rearranging the ones that are wanted). */ ConvertRowtypeExpr *r = makeNode(ConvertRowtypeExpr); @@ -386,23 +382,23 @@ can_coerce_type(int nargs, Oid *input_typeids, Oid *target_typeids, } /* - * If input is an untyped string constant, assume we can convert - * it to anything. + * If input is an untyped string constant, assume we can convert it to + * anything. */ if (inputTypeId == UNKNOWNOID) continue; /* - * If pg_cast shows that we can coerce, accept. This test now - * covers both binary-compatible and coercion-function cases. + * If pg_cast shows that we can coerce, accept. This test now covers + * both binary-compatible and coercion-function cases. */ if (find_coercion_pathway(targetTypeId, inputTypeId, ccontext, &funcId)) continue; /* - * If input is RECORD and target is a composite type, assume we - * can coerce (may need tighter checking here) + * If input is RECORD and target is a composite type, assume we can + * coerce (may need tighter checking here) */ if (inputTypeId == RECORDOID && ISCOMPLEX(targetTypeId)) @@ -472,22 +468,21 @@ coerce_to_domain(Node *arg, Oid baseTypeId, Oid typeId, hide_coercion_node(arg); /* - * If the domain applies a typmod to its base type, build the - * appropriate coercion step. Mark it implicit for display purposes, - * because we don't want it shown separately by ruleutils.c; but the - * isExplicit flag passed to the conversion function depends on the - * manner in which the domain coercion is invoked, so that the - * semantics of implicit and explicit coercion differ. (Is that - * really the behavior we want?) + * If the domain applies a typmod to its base type, build the appropriate + * coercion step. Mark it implicit for display purposes, because we don't + * want it shown separately by ruleutils.c; but the isExplicit flag passed + * to the conversion function depends on the manner in which the domain + * coercion is invoked, so that the semantics of implicit and explicit + * coercion differ. (Is that really the behavior we want?) * * NOTE: because we apply this as part of the fixed expression structure, - * ALTER DOMAIN cannot alter the typtypmod. But it's unclear that - * that would be safe to do anyway, without lots of knowledge about - * what the base type thinks the typmod means. + * ALTER DOMAIN cannot alter the typtypmod. But it's unclear that that + * would be safe to do anyway, without lots of knowledge about what the + * base type thinks the typmod means. */ if (!lengthCoercionDone) { - int32 typmod = get_typtypmod(typeId); + int32 typmod = get_typtypmod(typeId); if (typmod >= 0) arg = coerce_type_typmod(arg, baseTypeId, typmod, @@ -497,10 +492,9 @@ coerce_to_domain(Node *arg, Oid baseTypeId, Oid typeId, } /* - * Now build the domain coercion node. This represents run-time - * checking of any constraints currently attached to the domain. This - * also ensures that the expression is properly labeled as to result - * type. + * Now build the domain coercion node. This represents run-time checking + * of any constraints currently attached to the domain. This also ensures + * that the expression is properly labeled as to result type. */ result = makeNode(CoerceToDomain); result->arg = (Expr *) arg; @@ -541,8 +535,8 @@ coerce_type_typmod(Node *node, Oid targetTypeId, int32 targetTypMod, Oid funcId; /* - * A negative typmod is assumed to mean that no coercion is wanted. - * Also, skip coercion if already done. + * A negative typmod is assumed to mean that no coercion is wanted. Also, + * skip coercion if already done. */ if (targetTypMod < 0 || targetTypMod == exprTypmod(node)) return node; @@ -616,9 +610,9 @@ build_coercion_expression(Node *node, Oid funcId, procstruct = (Form_pg_proc) GETSTRUCT(tp); /* - * Asserts essentially check that function is a legal coercion - * function. We can't make the seemingly obvious tests on prorettype - * and proargtypes[0], because of various binary-compatibility cases. + * Asserts essentially check that function is a legal coercion function. + * We can't make the seemingly obvious tests on prorettype and + * proargtypes[0], because of various binary-compatibility cases. */ /* Assert(targetTypeId == procstruct->prorettype); */ Assert(!procstruct->proretset); @@ -685,8 +679,8 @@ coerce_record_to_complex(ParseState *pstate, Node *node, if (node && IsA(node, RowExpr)) { /* - * Since the RowExpr must be of type RECORD, we needn't worry - * about it containing any dropped columns. + * Since the RowExpr must be of type RECORD, we needn't worry about it + * containing any dropped columns. */ args = ((RowExpr *) node)->args; } @@ -721,8 +715,8 @@ coerce_record_to_complex(ParseState *pstate, Node *node, if (tupdesc->attrs[i]->attisdropped) { /* - * can't use atttypid here, but it doesn't really matter what - * type the Const claims to be. + * can't use atttypid here, but it doesn't really matter what type + * the Const claims to be. */ newargs = lappend(newargs, makeNullConst(INT4OID)); continue; @@ -752,7 +746,7 @@ coerce_record_to_complex(ParseState *pstate, Node *node, format_type_be(targetTypeId)), errdetail("Cannot cast type %s to %s in column %d.", format_type_be(exprtype), - format_type_be(tupdesc->attrs[i]->atttypid), + format_type_be(tupdesc->attrs[i]->atttypid), ucolno))); newargs = lappend(newargs, expr); ucolno++; @@ -798,8 +792,8 @@ coerce_to_boolean(ParseState *pstate, Node *node, ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), /* translator: first %s is name of a SQL construct, eg WHERE */ - errmsg("argument of %s must be type boolean, not type %s", - constructName, format_type_be(inputTypeId)))); + errmsg("argument of %s must be type boolean, not type %s", + constructName, format_type_be(inputTypeId)))); } if (expression_returns_set(node)) @@ -837,8 +831,8 @@ coerce_to_integer(ParseState *pstate, Node *node, ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), /* translator: first %s is name of a SQL construct, eg LIMIT */ - errmsg("argument of %s must be type integer, not type %s", - constructName, format_type_be(inputTypeId)))); + errmsg("argument of %s must be type integer, not type %s", + constructName, format_type_be(inputTypeId)))); } if (expression_returns_set(node)) @@ -889,15 +883,13 @@ select_common_type(List *typeids, const char *context) else if (TypeCategory(ntype) != pcategory) { /* - * both types in different categories? then not much - * hope... + * both types in different categories? then not much hope... */ ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), /* - * translator: first %s is name of a SQL construct, eg - * CASE + * translator: first %s is name of a SQL construct, eg CASE */ errmsg("%s types %s and %s cannot be matched", context, @@ -905,13 +897,12 @@ select_common_type(List *typeids, const char *context) format_type_be(ntype)))); } else if (!IsPreferredType(pcategory, ptype) && - can_coerce_type(1, &ptype, &ntype, COERCION_IMPLICIT) && - !can_coerce_type(1, &ntype, &ptype, COERCION_IMPLICIT)) + can_coerce_type(1, &ptype, &ntype, COERCION_IMPLICIT) && + !can_coerce_type(1, &ntype, &ptype, COERCION_IMPLICIT)) { /* - * take new type if can coerce to it implicitly but not - * the other way; but if we have a preferred type, stay on - * it. + * take new type if can coerce to it implicitly but not the + * other way; but if we have a preferred type, stay on it. */ ptype = ntype; pcategory = TypeCategory(ptype); @@ -920,15 +911,15 @@ select_common_type(List *typeids, const char *context) } /* - * If all the inputs were UNKNOWN type --- ie, unknown-type literals - * --- then resolve as type TEXT. This situation comes up with - * constructs like SELECT (CASE WHEN foo THEN 'bar' ELSE 'baz' END); - * SELECT 'foo' UNION SELECT 'bar'; It might seem desirable to leave - * the construct's output type as UNKNOWN, but that really doesn't - * work, because we'd probably end up needing a runtime coercion from - * UNKNOWN to something else, and we usually won't have it. We need - * to coerce the unknown literals while they are still literals, so a - * decision has to be made now. + * If all the inputs were UNKNOWN type --- ie, unknown-type literals --- + * then resolve as type TEXT. This situation comes up with constructs + * like SELECT (CASE WHEN foo THEN 'bar' ELSE 'baz' END); SELECT 'foo' + * UNION SELECT 'bar'; It might seem desirable to leave the construct's + * output type as UNKNOWN, but that really doesn't work, because we'd + * probably end up needing a runtime coercion from UNKNOWN to something + * else, and we usually won't have it. We need to coerce the unknown + * literals while they are still literals, so a decision has to be made + * now. */ if (ptype == UNKNOWNOID) ptype = TEXTOID; @@ -1005,9 +996,8 @@ check_generic_type_consistency(Oid *actual_arg_types, bool have_anyelement = false; /* - * Loop through the arguments to see if we have any that are ANYARRAY - * or ANYELEMENT. If so, require the actual types to be - * self-consistent + * Loop through the arguments to see if we have any that are ANYARRAY or + * ANYELEMENT. If so, require the actual types to be self-consistent */ for (j = 0; j < nargs; j++) { @@ -1050,8 +1040,7 @@ check_generic_type_consistency(Oid *actual_arg_types, if (!OidIsValid(elem_typeid)) { /* - * if we don't have an element type yet, use the one we just - * got + * if we don't have an element type yet, use the one we just got */ elem_typeid = array_typelem; } @@ -1118,9 +1107,8 @@ enforce_generic_type_consistency(Oid *actual_arg_types, bool have_anyelement = (rettype == ANYELEMENTOID); /* - * Loop through the arguments to see if we have any that are ANYARRAY - * or ANYELEMENT. If so, require the actual types to be - * self-consistent + * Loop through the arguments to see if we have any that are ANYARRAY or + * ANYELEMENT. If so, require the actual types to be self-consistent */ for (j = 0; j < nargs; j++) { @@ -1137,7 +1125,7 @@ enforce_generic_type_consistency(Oid *actual_arg_types, if (OidIsValid(elem_typeid) && actual_type != elem_typeid) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("arguments declared \"anyelement\" are not all alike"), + errmsg("arguments declared \"anyelement\" are not all alike"), errdetail("%s versus %s", format_type_be(elem_typeid), format_type_be(actual_type)))); @@ -1154,7 +1142,7 @@ enforce_generic_type_consistency(Oid *actual_arg_types, if (OidIsValid(array_typeid) && actual_type != array_typeid) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("arguments declared \"anyarray\" are not all alike"), + errmsg("arguments declared \"anyarray\" are not all alike"), errdetail("%s versus %s", format_type_be(array_typeid), format_type_be(actual_type)))); @@ -1163,8 +1151,8 @@ enforce_generic_type_consistency(Oid *actual_arg_types, } /* - * Fast Track: if none of the arguments are ANYARRAY or ANYELEMENT, - * return the unmodified rettype. + * Fast Track: if none of the arguments are ANYARRAY or ANYELEMENT, return + * the unmodified rettype. */ if (!have_generics) return rettype; @@ -1190,8 +1178,7 @@ enforce_generic_type_consistency(Oid *actual_arg_types, if (!OidIsValid(elem_typeid)) { /* - * if we don't have an element type yet, use the one we just - * got + * if we don't have an element type yet, use the one we just got */ elem_typeid = array_typelem; } @@ -1236,8 +1223,8 @@ enforce_generic_type_consistency(Oid *actual_arg_types, if (!OidIsValid(array_typeid)) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), - errmsg("could not find array type for data type %s", - format_type_be(elem_typeid)))); + errmsg("could not find array type for data type %s", + format_type_be(elem_typeid)))); } declared_arg_types[j] = array_typeid; } @@ -1253,8 +1240,8 @@ enforce_generic_type_consistency(Oid *actual_arg_types, if (!OidIsValid(array_typeid)) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), - errmsg("could not find array type for data type %s", - format_type_be(elem_typeid)))); + errmsg("could not find array type for data type %s", + format_type_be(elem_typeid)))); } return array_typeid; } @@ -1307,8 +1294,8 @@ resolve_generic_type(Oid declared_type, if (!OidIsValid(array_typeid)) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), - errmsg("could not find array type for data type %s", - format_type_be(context_actual_type)))); + errmsg("could not find array type for data type %s", + format_type_be(context_actual_type)))); return array_typeid; } } @@ -1471,8 +1458,8 @@ IsPreferredType(CATEGORY category, Oid type) return false; /* - * This switch should agree with TypeCategory(), above. Note that at - * this point, category certainly matches the type. + * This switch should agree with TypeCategory(), above. Note that at this + * point, category certainly matches the type. */ switch (category) { @@ -1679,17 +1666,16 @@ find_coercion_pathway(Oid targetTypeId, Oid sourceTypeId, else { /* - * If there's no pg_cast entry, perhaps we are dealing with a pair - * of array types. If so, and if the element types have a - * suitable cast, use array_type_coerce() or - * array_type_length_coerce(). + * If there's no pg_cast entry, perhaps we are dealing with a pair of + * array types. If so, and if the element types have a suitable cast, + * use array_type_coerce() or array_type_length_coerce(). * - * Hack: disallow coercions to oidvector and int2vector, which - * otherwise tend to capture coercions that should go to "real" array - * types. We want those types to be considered "real" arrays for many - * purposes, but not this one. (Also, array_type_coerce isn't - * guaranteed to produce an output that meets the restrictions of - * these datatypes, such as being 1-dimensional.) + * Hack: disallow coercions to oidvector and int2vector, which otherwise + * tend to capture coercions that should go to "real" array types. We + * want those types to be considered "real" arrays for many purposes, + * but not this one. (Also, array_type_coerce isn't guaranteed to + * produce an output that meets the restrictions of these datatypes, + * such as being 1-dimensional.) */ Oid targetElemType; Oid sourceElemType; @@ -1699,7 +1685,7 @@ find_coercion_pathway(Oid targetTypeId, Oid sourceTypeId, return false; if ((targetElemType = get_element_type(targetTypeId)) != InvalidOid && - (sourceElemType = get_element_type(sourceTypeId)) != InvalidOid) + (sourceElemType = get_element_type(sourceTypeId)) != InvalidOid) { if (find_coercion_pathway(targetElemType, sourceElemType, ccontext, &elemfuncid)) diff --git a/src/backend/parser/parse_expr.c b/src/backend/parser/parse_expr.c index fdb4c4dcf2..ab9279abd3 100644 --- a/src/backend/parser/parse_expr.c +++ b/src/backend/parser/parse_expr.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.184 2005/06/26 22:05:39 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.185 2005/10/15 02:49:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -278,8 +278,8 @@ transformIndirection(ParseState *pstate, Node *basenode, List *indirection) /* * We have to split any field-selection operations apart from - * subscripting. Adjacent A_Indices nodes have to be treated as a - * single multidimensional subscript operation. + * subscripting. Adjacent A_Indices nodes have to be treated as a single + * multidimensional subscript operation. */ foreach(i, indirection) { @@ -295,7 +295,7 @@ transformIndirection(ParseState *pstate, Node *basenode, List *indirection) if (subscripts) result = (Node *) transformArraySubscripts(pstate, result, - exprType(result), + exprType(result), InvalidOid, -1, subscripts, @@ -365,10 +365,10 @@ transformColumnRef(ParseState *pstate, ColumnRef *cref) /* * Not known as a column of any range-table entry. * - * Consider the possibility that it's VALUE in a domain - * check expression. (We handle VALUE as a name, not - * a keyword, to avoid breaking a lot of applications - * that have used VALUE as a column name in the past.) + * Consider the possibility that it's VALUE in a domain check + * expression. (We handle VALUE as a name, not a keyword, + * to avoid breaking a lot of applications that have used + * VALUE as a column name in the past.) */ if (pstate->p_value_substitute != NULL && strcmp(name, "value") == 0) @@ -379,12 +379,12 @@ transformColumnRef(ParseState *pstate, ColumnRef *cref) /* * Try to find the name as a relation. Note that only - * relations already entered into the rangetable will - * be recognized. + * relations already entered into the rangetable will be + * recognized. * * This is a hack for backwards compatibility with - * PostQUEL-inspired syntax. The preferred form now - * is "rel.*". + * PostQUEL-inspired syntax. The preferred form now is + * "rel.*". */ if (refnameRangeTblEntry(pstate, NULL, name, &levels_up) != NULL) @@ -414,13 +414,13 @@ transformColumnRef(ParseState *pstate, ColumnRef *cref) if (node == NULL) { /* - * Not known as a column of any range-table entry, so - * try it as a function call. Here, we will create an + * Not known as a column of any range-table entry, so try + * it as a function call. Here, we will create an * implicit RTE for tables not already entered. */ node = transformWholeRowRef(pstate, NULL, name1); node = ParseFuncOrColumn(pstate, - list_make1(makeString(name2)), + list_make1(makeString(name2)), list_make1(node), false, false, true); } @@ -446,7 +446,7 @@ transformColumnRef(ParseState *pstate, ColumnRef *cref) /* Try it as a function call */ node = transformWholeRowRef(pstate, name1, name2); node = ParseFuncOrColumn(pstate, - list_make1(makeString(name3)), + list_make1(makeString(name3)), list_make1(node), false, false, true); } @@ -482,7 +482,7 @@ transformColumnRef(ParseState *pstate, ColumnRef *cref) /* Try it as a function call */ node = transformWholeRowRef(pstate, name2, name3); node = ParseFuncOrColumn(pstate, - list_make1(makeString(name4)), + list_make1(makeString(name4)), list_make1(node), false, false, true); } @@ -491,8 +491,8 @@ transformColumnRef(ParseState *pstate, ColumnRef *cref) default: ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("improper qualified name (too many dotted names): %s", - NameListToString(cref->fields)))); + errmsg("improper qualified name (too many dotted names): %s", + NameListToString(cref->fields)))); node = NULL; /* keep compiler quiet */ break; } @@ -515,7 +515,7 @@ transformParamRef(ParseState *pstate, ParamRef *pref) toppstate = toppstate->parentParseState; /* Check parameter number is in range */ - if (paramno <= 0) /* probably can't happen? */ + if (paramno <= 0) /* probably can't happen? */ ereport(ERROR, (errcode(ERRCODE_UNDEFINED_PARAMETER), errmsg("there is no parameter $%d", paramno))); @@ -563,9 +563,9 @@ transformAExprOp(ParseState *pstate, A_Expr *a) Node *result; /* - * Special-case "foo = NULL" and "NULL = foo" for compatibility - * with standards-broken products (like Microsoft's). Turn these - * into IS NULL exprs. + * Special-case "foo = NULL" and "NULL = foo" for compatibility with + * standards-broken products (like Microsoft's). Turn these into IS NULL + * exprs. */ if (Transform_null_equals && list_length(a->name) == 1 && @@ -588,10 +588,9 @@ transformAExprOp(ParseState *pstate, A_Expr *a) ((SubLink *) rexpr)->subLinkType == EXPR_SUBLINK) { /* - * Convert "row op subselect" into a MULTIEXPR sublink. - * Formerly the grammar did this, but now that a row construct - * is allowed anywhere in expressions, it's easier to do it - * here. + * Convert "row op subselect" into a MULTIEXPR sublink. Formerly the + * grammar did this, but now that a row construct is allowed anywhere + * in expressions, it's easier to do it here. */ SubLink *s = (SubLink *) rexpr; @@ -738,8 +737,8 @@ static Node * transformAExprOf(ParseState *pstate, A_Expr *a) { /* - * Checking an expression for match to type. Will result in a - * boolean constant node. + * Checking an expression for match to type. Will result in a boolean + * constant node. */ ListCell *telem; A_Const *n; @@ -758,8 +757,8 @@ transformAExprOf(ParseState *pstate, A_Expr *a) } /* - * Expect two forms: equals or not equals. Flip the sense of the - * result for not equals. + * Expect two forms: equals or not equals. Flip the sense of the result + * for not equals. */ if (strcmp(strVal(linitial(a->name)), "!=") == 0) matched = (!matched); @@ -779,12 +778,11 @@ transformFuncCall(ParseState *pstate, FuncCall *fn) ListCell *args; /* - * Transform the list of arguments. We use a shallow list copy - * and then transform-in-place to avoid O(N^2) behavior from - * repeated lappend's. + * Transform the list of arguments. We use a shallow list copy and then + * transform-in-place to avoid O(N^2) behavior from repeated lappend's. * - * XXX: repeated lappend() would no longer result in O(n^2) - * behavior; worth reconsidering this design? + * XXX: repeated lappend() would no longer result in O(n^2) behavior; worth + * reconsidering this design? */ targs = list_copy(fn->args); foreach(args, targs) @@ -826,11 +824,11 @@ transformCaseExpr(ParseState *pstate, CaseExpr *c) if (arg) { /* - * If test expression is an untyped literal, force it to text. - * We have to do something now because we won't be able to do - * this coercion on the placeholder. This is not as flexible - * as what was done in 7.4 and before, but it's good enough to - * handle the sort of silly coding commonly seen. + * If test expression is an untyped literal, force it to text. We have + * to do something now because we won't be able to do this coercion on + * the placeholder. This is not as flexible as what was done in 7.4 + * and before, but it's good enough to handle the sort of silly coding + * commonly seen. */ if (exprType(arg) == UNKNOWNOID) arg = coerce_to_common_type(pstate, arg, TEXTOID, "CASE"); @@ -891,9 +889,8 @@ transformCaseExpr(ParseState *pstate, CaseExpr *c) /* * Note: default result is considered the most significant type in - * determining preferred type. This is how the code worked before, - * but it seems a little bogus to me - * --- tgl + * determining preferred type. This is how the code worked before, but it + * seems a little bogus to me --- tgl */ typeids = lcons_oid(exprType((Node *) newc->defresult), typeids); @@ -947,8 +944,8 @@ transformSubLink(ParseState *pstate, SubLink *sublink) if (sublink->subLinkType == EXISTS_SUBLINK) { /* - * EXISTS needs no lefthand or combining operator. These - * fields should be NIL already, but make sure. + * EXISTS needs no lefthand or combining operator. These fields + * should be NIL already, but make sure. */ sublink->lefthand = NIL; sublink->operName = NIL; @@ -961,8 +958,8 @@ transformSubLink(ParseState *pstate, SubLink *sublink) ListCell *tlist_item = list_head(qtree->targetList); /* - * Make sure the subselect delivers a single column (ignoring - * resjunk targets). + * Make sure the subselect delivers a single column (ignoring resjunk + * targets). */ if (tlist_item == NULL || ((TargetEntry *) lfirst(tlist_item))->resjunk) @@ -978,9 +975,8 @@ transformSubLink(ParseState *pstate, SubLink *sublink) } /* - * EXPR and ARRAY need no lefthand or combining - * operator. These fields should be NIL already, but make - * sure. + * EXPR and ARRAY need no lefthand or combining operator. These fields + * should be NIL already, but make sure. */ sublink->lefthand = NIL; sublink->operName = NIL; @@ -1004,9 +1000,9 @@ transformSubLink(ParseState *pstate, SubLink *sublink) lfirst(l) = transformExpr(pstate, lfirst(l)); /* - * If the expression is "<> ALL" (with unqualified opname) - * then convert it to "NOT IN". This is a hack to improve - * efficiency of expressions output by pre-7.4 Postgres. + * If the expression is "<> ALL" (with unqualified opname) then + * convert it to "NOT IN". This is a hack to improve efficiency of + * expressions output by pre-7.4 Postgres. */ if (sublink->subLinkType == ALL_SUBLINK && list_length(op) == 1 && strcmp(opname, "<>") == 0) @@ -1035,10 +1031,10 @@ transformSubLink(ParseState *pstate, SubLink *sublink) /* * To build the list of combining operator OIDs, we must scan - * subquery's targetlist to find values that will be matched - * against lefthand values. We need to ignore resjunk - * targets, so doing the outer iteration over right_list is - * easier than doing it over left_list. + * subquery's targetlist to find values that will be matched against + * lefthand values. We need to ignore resjunk targets, so doing the + * outer iteration over right_list is easier than doing it over + * left_list. */ sublink->operOids = NIL; @@ -1061,9 +1057,8 @@ transformSubLink(ParseState *pstate, SubLink *sublink) ll_item = lnext(ll_item); /* - * It's OK to use oper() not compatible_oper() here, - * because make_subplan() will insert type coercion calls - * if needed. + * It's OK to use oper() not compatible_oper() here, because + * make_subplan() will insert type coercion calls if needed. */ optup = oper(op, exprType(lexpr), @@ -1074,9 +1069,9 @@ transformSubLink(ParseState *pstate, SubLink *sublink) if (opform->oprresult != BOOLOID) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("operator %s must return type boolean, not type %s", - opname, - format_type_be(opform->oprresult)), + errmsg("operator %s must return type boolean, not type %s", + opname, + format_type_be(opform->oprresult)), errhint("The operator of a quantified predicate subquery must return type boolean."))); if (get_func_retset(opform->oprcode)) @@ -1300,7 +1295,7 @@ transformBooleanTest(ParseState *pstate, BooleanTest *b) default: elog(ERROR, "unrecognized booltesttype: %d", (int) b->booltesttype); - clausename = NULL; /* keep compiler quiet */ + clausename = NULL; /* keep compiler quiet */ } b->arg = (Expr *) transformExpr(pstate, (Node *) b->arg); @@ -1385,10 +1380,10 @@ transformWholeRowRef(ParseState *pstate, char *schemaname, char *relname) default: /* - * RTE is a join or subselect. We represent this as a - * whole-row Var of RECORD type. (Note that in most cases the - * Var will be expanded to a RowExpr during planning, but that - * is not our concern here.) + * RTE is a join or subselect. We represent this as a whole-row + * Var of RECORD type. (Note that in most cases the Var will be + * expanded to a RowExpr during planning, but that is not our + * concern here.) */ result = (Node *) makeVar(vnum, InvalidAttrNumber, @@ -1469,7 +1464,7 @@ exprType(Node *expr) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("could not find array type for data type %s", - format_type_be(exprType((Node *) tent->expr))))); + format_type_be(exprType((Node *) tent->expr))))); } } else @@ -1482,10 +1477,9 @@ exprType(Node *expr) case T_SubPlan: { /* - * Although the parser does not ever deal with - * already-planned expression trees, we support SubPlan - * nodes in this routine for the convenience of - * ruleutils.c. + * Although the parser does not ever deal with already-planned + * expression trees, we support SubPlan nodes in this routine + * for the convenience of ruleutils.c. */ SubPlan *subplan = (SubPlan *) expr; @@ -1506,7 +1500,7 @@ exprType(Node *expr) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("could not find array type for data type %s", - format_type_be(exprType((Node *) tent->expr))))); + format_type_be(exprType((Node *) tent->expr))))); } } else @@ -1600,7 +1594,7 @@ exprTypmod(Node *expr) case BPCHAROID: if (!con->constisnull) { - int32 len = VARSIZE(DatumGetPointer(con->constvalue)) - VARHDRSZ; + int32 len = VARSIZE(DatumGetPointer(con->constvalue)) - VARHDRSZ; /* if multi-byte, take len and find # characters */ if (pg_database_encoding_max_length() > 1) @@ -1629,8 +1623,8 @@ exprTypmod(Node *expr) case T_CaseExpr: { /* - * If all the alternatives agree on type/typmod, return - * that typmod, else use -1 + * If all the alternatives agree on type/typmod, return that + * typmod, else use -1 */ CaseExpr *cexpr = (CaseExpr *) expr; Oid casetype = cexpr->casetype; @@ -1662,8 +1656,8 @@ exprTypmod(Node *expr) case T_CoalesceExpr: { /* - * If all the alternatives agree on type/typmod, return - * that typmod, else use -1 + * If all the alternatives agree on type/typmod, return that + * typmod, else use -1 */ CoalesceExpr *cexpr = (CoalesceExpr *) expr; Oid coalescetype = cexpr->coalescetype; @@ -1686,8 +1680,8 @@ exprTypmod(Node *expr) case T_MinMaxExpr: { /* - * If all the alternatives agree on type/typmod, return - * that typmod, else use -1 + * If all the alternatives agree on type/typmod, return that + * typmod, else use -1 */ MinMaxExpr *mexpr = (MinMaxExpr *) expr; Oid minmaxtype = mexpr->minmaxtype; @@ -1760,9 +1754,9 @@ exprIsLengthCoercion(Node *expr, int32 *coercedTypmod) return false; /* - * If it's not a two-argument or three-argument function with the - * second argument being an int4 constant, it can't have been created - * from a length coercion (it must be a type coercion, instead). + * If it's not a two-argument or three-argument function with the second + * argument being an int4 constant, it can't have been created from a + * length coercion (it must be a type coercion, instead). */ nargs = list_length(func->args); if (nargs < 2 || nargs > 3) @@ -1844,9 +1838,9 @@ make_row_op(ParseState *pstate, List *opname, Node *ltree, Node *rtree) errmsg("unequal number of entries in row expression"))); /* - * XXX it's really wrong to generate a simple AND combination for < <= - * > >=. We probably need to invent a new runtime node type to handle - * those correctly. For the moment, though, keep on doing this ... + * XXX it's really wrong to generate a simple AND combination for < <= > + * >=. We probably need to invent a new runtime node type to handle those + * correctly. For the moment, though, keep on doing this ... */ oprname = strVal(llast(opname)); @@ -1862,8 +1856,8 @@ make_row_op(ParseState *pstate, List *opname, Node *ltree, Node *rtree) { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("operator %s is not supported for row expressions", - oprname))); + errmsg("operator %s is not supported for row expressions", + oprname))); boolop = 0; /* keep compiler quiet */ } @@ -1957,7 +1951,7 @@ make_distinct_op(ParseState *pstate, List *opname, Node *ltree, Node *rtree) if (((OpExpr *) result)->opresulttype != BOOLOID) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("IS DISTINCT FROM requires = operator to yield boolean"))); + errmsg("IS DISTINCT FROM requires = operator to yield boolean"))); /* * We rely on DistinctExpr and OpExpr being same struct diff --git a/src/backend/parser/parse_func.c b/src/backend/parser/parse_func.c index 88132bdbd5..a3a4232648 100644 --- a/src/backend/parser/parse_func.c +++ b/src/backend/parser/parse_func.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/parse_func.c,v 1.181 2005/06/22 15:19:43 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_func.c,v 1.182 2005/10/15 02:49:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -74,10 +74,10 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, FuncDetailCode fdresult; /* - * Most of the rest of the parser just assumes that functions do not - * have more than FUNC_MAX_ARGS parameters. We have to test here to - * protect against array overruns, etc. Of course, this may not be a - * function, but the test doesn't hurt. + * Most of the rest of the parser just assumes that functions do not have + * more than FUNC_MAX_ARGS parameters. We have to test here to protect + * against array overruns, etc. Of course, this may not be a function, + * but the test doesn't hurt. */ if (list_length(fargs) > FUNC_MAX_ARGS) ereport(ERROR, @@ -88,11 +88,11 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, /* * Extract arg type info in preparation for function lookup. * - * If any arguments are Param markers of type VOID, we discard them - * from the parameter list. This is a hack to allow the JDBC driver - * to not have to distinguish "input" and "output" parameter symbols - * while parsing function-call constructs. We can't use foreach() - * because we may modify the list ... + * If any arguments are Param markers of type VOID, we discard them from the + * parameter list. This is a hack to allow the JDBC driver to not have to + * distinguish "input" and "output" parameter symbols while parsing + * function-call constructs. We can't use foreach() because we may modify + * the list ... */ nargs = 0; for (l = list_head(fargs); l != NULL; l = nextl) @@ -102,7 +102,7 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, nextl = lnext(l); - if (argtype == VOIDOID && IsA(arg, Param) && !is_column) + if (argtype == VOIDOID && IsA(arg, Param) &&!is_column) { fargs = list_delete_ptr(fargs, arg); continue; @@ -119,9 +119,9 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, /* * Check for column projection: if function has one argument, and that - * argument is of complex type, and function name is not qualified, - * then the "function call" could be a projection. We also check that - * there wasn't any aggregate decoration. + * argument is of complex type, and function name is not qualified, then + * the "function call" could be a projection. We also check that there + * wasn't any aggregate decoration. */ if (nargs == 1 && !agg_star && !agg_distinct && list_length(funcname) == 1) { @@ -136,8 +136,8 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, return retval; /* - * If ParseComplexProjection doesn't recognize it as a - * projection, just press on. + * If ParseComplexProjection doesn't recognize it as a projection, + * just press on. */ } } @@ -147,8 +147,8 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, * func_get_detail looks up the function in the catalogs, does * disambiguation for polymorphic functions, handles inheritance, and * returns the funcid and type and set or singleton status of the - * function's return value. it also returns the true argument types - * to the function. + * function's return value. it also returns the true argument types to + * the function. */ fdresult = func_get_detail(funcname, fargs, nargs, actual_arg_types, &funcid, &rettype, &retset, @@ -156,8 +156,8 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, if (fdresult == FUNCDETAIL_COERCION) { /* - * We can do it as a trivial coercion. coerce_type can handle - * these cases, so why duplicate code... + * We can do it as a trivial coercion. coerce_type can handle these + * cases, so why duplicate code... */ return coerce_type(pstate, linitial(fargs), actual_arg_types[0], rettype, -1, @@ -166,28 +166,28 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, else if (fdresult == FUNCDETAIL_NORMAL) { /* - * Normal function found; was there anything indicating it must be - * an aggregate? + * Normal function found; was there anything indicating it must be an + * aggregate? */ if (agg_star) ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), - errmsg("%s(*) specified, but %s is not an aggregate function", - NameListToString(funcname), - NameListToString(funcname)))); + errmsg("%s(*) specified, but %s is not an aggregate function", + NameListToString(funcname), + NameListToString(funcname)))); if (agg_distinct) ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), - errmsg("DISTINCT specified, but %s is not an aggregate function", - NameListToString(funcname)))); + errmsg("DISTINCT specified, but %s is not an aggregate function", + NameListToString(funcname)))); } else if (fdresult != FUNCDETAIL_AGGREGATE) { /* * Oops. Time to die. * - * If we are dealing with the attribute notation rel.function, give - * an error message that is appropriate for that case. + * If we are dealing with the attribute notation rel.function, give an + * error message that is appropriate for that case. */ if (is_column) { @@ -205,22 +205,22 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, errmsg("function %s is not unique", func_signature_string(funcname, nargs, actual_arg_types)), - errhint("Could not choose a best candidate function. " - "You may need to add explicit type casts."))); + errhint("Could not choose a best candidate function. " + "You may need to add explicit type casts."))); else ereport(ERROR, (errcode(ERRCODE_UNDEFINED_FUNCTION), errmsg("function %s does not exist", func_signature_string(funcname, nargs, actual_arg_types)), - errhint("No function matches the given name and argument types. " - "You may need to add explicit type casts."))); + errhint("No function matches the given name and argument types. " + "You may need to add explicit type casts."))); } /* - * enforce consistency with ANYARRAY and ANYELEMENT argument and - * return types, possibly adjusting return type or declared_arg_types - * (which will be used as the cast destination by make_fn_arguments) + * enforce consistency with ANYARRAY and ANYELEMENT argument and return + * types, possibly adjusting return type or declared_arg_types (which will + * be used as the cast destination by make_fn_arguments) */ rettype = enforce_generic_type_consistency(actual_arg_types, declared_arg_types, @@ -394,15 +394,14 @@ func_select_candidate(int nargs, FUNC_MAX_ARGS))); /* - * If any input types are domains, reduce them to their base types. - * This ensures that we will consider functions on the base type to be - * "exact matches" in the exact-match heuristic; it also makes it - * possible to do something useful with the type-category heuristics. - * Note that this makes it difficult, but not impossible, to use - * functions declared to take a domain as an input datatype. Such a - * function will be selected over the base-type function only if it is - * an exact match at all argument positions, and so was already chosen - * by our caller. + * If any input types are domains, reduce them to their base types. This + * ensures that we will consider functions on the base type to be "exact + * matches" in the exact-match heuristic; it also makes it possible to do + * something useful with the type-category heuristics. Note that this + * makes it difficult, but not impossible, to use functions declared to + * take a domain as an input datatype. Such a function will be selected + * over the base-type function only if it is an exact match at all + * argument positions, and so was already chosen by our caller. */ for (i = 0; i < nargs; i++) input_base_typeids[i] = getBaseType(input_typeids[i]); @@ -452,12 +451,11 @@ func_select_candidate(int nargs, return candidates; /* - * Still too many candidates? Now look for candidates which have - * either exact matches or preferred types at the args that will - * require coercion. (Restriction added in 7.4: preferred type must be - * of same category as input type; give no preference to - * cross-category conversions to preferred types.) Keep all - * candidates if none match. + * Still too many candidates? Now look for candidates which have either + * exact matches or preferred types at the args that will require + * coercion. (Restriction added in 7.4: preferred type must be of same + * category as input type; give no preference to cross-category + * conversions to preferred types.) Keep all candidates if none match. */ for (i = 0; i < nargs; i++) /* avoid multiple lookups */ slot_category[i] = TypeCategory(input_base_typeids[i]); @@ -502,30 +500,28 @@ func_select_candidate(int nargs, return candidates; /* - * Still too many candidates? Try assigning types for the unknown - * columns. + * Still too many candidates? Try assigning types for the unknown columns. * - * NOTE: for a binary operator with one unknown and one non-unknown - * input, we already tried the heuristic of looking for a candidate - * with the known input type on both sides (see binary_oper_exact()). - * That's essentially a special case of the general algorithm we try - * next. + * NOTE: for a binary operator with one unknown and one non-unknown input, we + * already tried the heuristic of looking for a candidate with the known + * input type on both sides (see binary_oper_exact()). That's essentially + * a special case of the general algorithm we try next. * - * We do this by examining each unknown argument position to see if we - * can determine a "type category" for it. If any candidate has an - * input datatype of STRING category, use STRING category (this bias - * towards STRING is appropriate since unknown-type literals look like - * strings). Otherwise, if all the candidates agree on the type - * category of this argument position, use that category. Otherwise, - * fail because we cannot determine a category. + * We do this by examining each unknown argument position to see if we can + * determine a "type category" for it. If any candidate has an input + * datatype of STRING category, use STRING category (this bias towards + * STRING is appropriate since unknown-type literals look like strings). + * Otherwise, if all the candidates agree on the type category of this + * argument position, use that category. Otherwise, fail because we + * cannot determine a category. * - * If we are able to determine a type category, also notice whether any - * of the candidates takes a preferred datatype within the category. + * If we are able to determine a type category, also notice whether any of + * the candidates takes a preferred datatype within the category. * - * Having completed this examination, remove candidates that accept the - * wrong category at any unknown position. Also, if at least one - * candidate accepted a preferred type at a position, remove - * candidates that accept non-preferred types. + * Having completed this examination, remove candidates that accept the wrong + * category at any unknown position. Also, if at least one candidate + * accepted a preferred type at a position, remove candidates that accept + * non-preferred types. * * If we are down to one candidate at the end, we win. */ @@ -573,8 +569,7 @@ func_select_candidate(int nargs, else { /* - * Remember conflict, but keep going (might find - * STRING) + * Remember conflict, but keep going (might find STRING) */ have_conflict = true; } @@ -687,8 +682,8 @@ func_get_detail(List *funcname, raw_candidates = FuncnameGetCandidates(funcname, nargs); /* - * Quickly check if there is an exact match to the input datatypes - * (there can be only one) + * Quickly check if there is an exact match to the input datatypes (there + * can be only one) */ for (best_candidate = raw_candidates; best_candidate != NULL; @@ -703,32 +698,30 @@ func_get_detail(List *funcname, /* * If we didn't find an exact match, next consider the possibility * that this is really a type-coercion request: a single-argument - * function call where the function name is a type name. If so, - * and if we can do the coercion trivially (no run-time function - * call needed), then go ahead and treat the "function call" as a - * coercion. This interpretation needs to be given higher - * priority than interpretations involving a type coercion - * followed by a function call, otherwise we can produce - * surprising results. For example, we want "text(varchar)" to be - * interpreted as a trivial coercion, not as "text(name(varchar))" - * which the code below this point is entirely capable of - * selecting. + * function call where the function name is a type name. If so, and + * if we can do the coercion trivially (no run-time function call + * needed), then go ahead and treat the "function call" as a coercion. + * This interpretation needs to be given higher priority than + * interpretations involving a type coercion followed by a function + * call, otherwise we can produce surprising results. For example, we + * want "text(varchar)" to be interpreted as a trivial coercion, not + * as "text(name(varchar))" which the code below this point is + * entirely capable of selecting. * - * "Trivial" coercions are ones that involve binary-compatible types - * and ones that are coercing a previously-unknown-type literal - * constant to a specific type. + * "Trivial" coercions are ones that involve binary-compatible types and + * ones that are coercing a previously-unknown-type literal constant + * to a specific type. * - * The reason we can restrict our check to binary-compatible - * coercions here is that we expect non-binary-compatible - * coercions to have an implementation function named after the - * target type. That function will be found by normal lookup if - * appropriate. + * The reason we can restrict our check to binary-compatible coercions + * here is that we expect non-binary-compatible coercions to have an + * implementation function named after the target type. That function + * will be found by normal lookup if appropriate. * - * NB: it's important that this code stays in sync with what - * coerce_type can do, because the caller will try to apply - * coerce_type if we return FUNCDETAIL_COERCION. If we return - * that result for something coerce_type can't handle, we'll cause - * infinite recursion between this module and coerce_type! + * NB: it's important that this code stays in sync with what coerce_type + * can do, because the caller will try to apply coerce_type if we + * return FUNCDETAIL_COERCION. If we return that result for something + * coerce_type can't handle, we'll cause infinite recursion between + * this module and coerce_type! */ if (nargs == 1 && fargs != NIL) { @@ -761,8 +754,7 @@ func_get_detail(List *funcname, } /* - * didn't find an exact match, so now try to match up - * candidates... + * didn't find an exact match, so now try to match up candidates... */ if (raw_candidates != NULL) { @@ -788,8 +780,8 @@ func_get_detail(List *funcname, current_candidates); /* - * If we were able to choose a best candidate, we're - * done. Otherwise, ambiguous function call. + * If we were able to choose a best candidate, we're done. + * Otherwise, ambiguous function call. */ if (!best_candidate) return FUNCDETAIL_MULTIPLE; @@ -853,11 +845,10 @@ typeInheritsFrom(Oid subclassTypeId, Oid superclassTypeId) inhrel = heap_open(InheritsRelationId, AccessShareLock); /* - * Use queue to do a breadth-first traversal of the inheritance graph - * from the relid supplied up to the root. Notice that we append to - * the queue inside the loop --- this is okay because the foreach() - * macro doesn't advance queue_item until the next loop iteration - * begins. + * Use queue to do a breadth-first traversal of the inheritance graph from + * the relid supplied up to the root. Notice that we append to the queue + * inside the loop --- this is okay because the foreach() macro doesn't + * advance queue_item until the next loop iteration begins. */ foreach(queue_item, queue) { @@ -872,9 +863,9 @@ typeInheritsFrom(Oid subclassTypeId, Oid superclassTypeId) /* * Okay, this is a not-yet-seen relid. Add it to the list of - * already-visited OIDs, then find all the types this relid - * inherits from and add them to the queue. The one exception is - * we don't add the original relation to 'visited'. + * already-visited OIDs, then find all the types this relid inherits + * from and add them to the queue. The one exception is we don't add + * the original relation to 'visited'. */ if (queue_item != list_head(queue)) visited = lappend_oid(visited, this_relid); @@ -889,7 +880,7 @@ typeInheritsFrom(Oid subclassTypeId, Oid superclassTypeId) while ((inhtup = heap_getnext(inhscan, ForwardScanDirection)) != NULL) { Form_pg_inherits inh = (Form_pg_inherits) GETSTRUCT(inhtup); - Oid inhparent = inh->inhparent; + Oid inhparent = inh->inhparent; /* If this is the target superclass, we're done */ if (get_rel_type_id(inhparent) == superclassTypeId) @@ -968,14 +959,14 @@ ParseComplexProjection(ParseState *pstate, char *funcname, Node *first_arg) int i; /* - * Special case for whole-row Vars so that we can resolve (foo.*).bar - * even when foo is a reference to a subselect, join, or RECORD - * function. A bonus is that we avoid generating an unnecessary - * FieldSelect; our result can omit the whole-row Var and just be a - * Var for the selected field. + * Special case for whole-row Vars so that we can resolve (foo.*).bar even + * when foo is a reference to a subselect, join, or RECORD function. A + * bonus is that we avoid generating an unnecessary FieldSelect; our + * result can omit the whole-row Var and just be a Var for the selected + * field. * - * This case could be handled by expandRecordVariable, but it's - * more efficient to do it this way when possible. + * This case could be handled by expandRecordVariable, but it's more + * efficient to do it this way when possible. */ if (IsA(first_arg, Var) && ((Var *) first_arg)->varattno == InvalidAttrNumber) @@ -992,9 +983,9 @@ ParseComplexProjection(ParseState *pstate, char *funcname, Node *first_arg) /* * Else do it the hard way with get_expr_result_type(). * - * If it's a Var of type RECORD, we have to work even harder: we have - * to find what the Var refers to, and pass that to get_expr_result_type. - * That task is handled by expandRecordVariable(). + * If it's a Var of type RECORD, we have to work even harder: we have to find + * what the Var refers to, and pass that to get_expr_result_type. That + * task is handled by expandRecordVariable(). */ if (IsA(first_arg, Var) && ((Var *) first_arg)->vartype == RECORDOID) @@ -1057,8 +1048,8 @@ unknown_attribute(ParseState *pstate, Node *relref, char *attname) else if (relTypeId == RECORDOID) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_COLUMN), - errmsg("could not identify column \"%s\" in record data type", - attname))); + errmsg("could not identify column \"%s\" in record data type", + attname))); else ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), @@ -1161,7 +1152,7 @@ find_aggregate_func(List *aggname, Oid basetype, bool noError) ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), errmsg("function %s(%s) is not an aggregate", - NameListToString(aggname), format_type_be(basetype)))); + NameListToString(aggname), format_type_be(basetype)))); } ReleaseSysCache(ftup); @@ -1198,7 +1189,7 @@ LookupFuncName(List *funcname, int nargs, const Oid *argtypes, bool noError) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_FUNCTION), errmsg("function %s does not exist", - func_signature_string(funcname, nargs, argtypes)))); + func_signature_string(funcname, nargs, argtypes)))); return InvalidOid; } diff --git a/src/backend/parser/parse_node.c b/src/backend/parser/parse_node.c index 20999f81ff..f0900ec99c 100644 --- a/src/backend/parser/parse_node.c +++ b/src/backend/parser/parse_node.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/parse_node.c,v 1.89 2005/05/30 01:20:49 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_node.c,v 1.90 2005/10/15 02:49:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -92,8 +92,8 @@ transformArrayType(Oid arrayType) if (elementType == InvalidOid) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("cannot subscript type %s because it is not an array", - format_type_be(arrayType)))); + errmsg("cannot subscript type %s because it is not an array", + format_type_be(arrayType)))); ReleaseSysCache(type_tuple_array); @@ -145,11 +145,11 @@ transformArraySubscripts(ParseState *pstate, /* * A list containing only single subscripts refers to a single array - * element. If any of the items are double subscripts (lower:upper), - * then the subscript expression means an array slice operation. In - * this case, we supply a default lower bound of 1 for any items that - * contain only a single subscript. We have to prescan the - * indirection list to see if there are any double subscripts. + * element. If any of the items are double subscripts (lower:upper), then + * the subscript expression means an array slice operation. In this case, + * we supply a default lower bound of 1 for any items that contain only a + * single subscript. We have to prescan the indirection list to see if + * there are any double subscripts. */ foreach(idx, indirection) { @@ -163,9 +163,9 @@ transformArraySubscripts(ParseState *pstate, } /* - * The type represented by the subscript expression is the element - * type if we are fetching a single element, but it is the same as the - * array type if we are fetching a slice or storing. + * The type represented by the subscript expression is the element type if + * we are fetching a single element, but it is the same as the array type + * if we are fetching a slice or storing. */ if (isSlice || assignFrom != NULL) resultType = arrayType; @@ -188,14 +188,14 @@ transformArraySubscripts(ParseState *pstate, subexpr = transformExpr(pstate, ai->lidx); /* If it's not int4 already, try to coerce */ subexpr = coerce_to_target_type(pstate, - subexpr, exprType(subexpr), + subexpr, exprType(subexpr), INT4OID, -1, COERCION_ASSIGNMENT, COERCE_IMPLICIT_CAST); if (subexpr == NULL) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("array subscript must have type integer"))); + errmsg("array subscript must have type integer"))); } else { @@ -224,8 +224,7 @@ transformArraySubscripts(ParseState *pstate, /* * If doing an array store, coerce the source value to the right type. - * (This should agree with the coercion done by - * updateTargetListEntry.) + * (This should agree with the coercion done by updateTargetListEntry.) */ if (assignFrom != NULL) { @@ -244,7 +243,7 @@ transformArraySubscripts(ParseState *pstate, " but expression is of type %s", format_type_be(typeneeded), format_type_be(typesource)), - errhint("You will need to rewrite or cast the expression."))); + errhint("You will need to rewrite or cast the expression."))); } /* @@ -308,7 +307,7 @@ make_const(Value *value) * It might actually fit in int32. Probably only INT_MIN can * occur, but we'll code the test generally just to be sure. */ - int32 val32 = (int32) val64; + int32 val32 = (int32) val64; if (val64 == (int64) val32) { @@ -324,7 +323,7 @@ make_const(Value *value) typeid = INT8OID; typelen = sizeof(int64); - typebyval = false; /* XXX might change someday */ + typebyval = false; /* XXX might change someday */ } } else @@ -341,6 +340,7 @@ make_const(Value *value) break; case T_String: + /* * We assume here that UNKNOWN's internal representation is the * same as CSTRING @@ -348,7 +348,7 @@ make_const(Value *value) val = CStringGetDatum(strVal(value)); typeid = UNKNOWNOID; /* will be coerced later */ - typelen = -2; /* cstring-style varwidth type */ + typelen = -2; /* cstring-style varwidth type */ typebyval = false; break; diff --git a/src/backend/parser/parse_oper.c b/src/backend/parser/parse_oper.c index 4b615542c8..764f729529 100644 --- a/src/backend/parser/parse_oper.c +++ b/src/backend/parser/parse_oper.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/parse_oper.c,v 1.81 2004/12/31 22:00:27 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_oper.c,v 1.82 2005/10/15 02:49:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -142,16 +142,16 @@ equality_oper(Oid argtype, bool noError) /* * Look for an "=" operator for the datatype. We require it to be an - * exact or binary-compatible match, since most callers are not - * prepared to cope with adding any run-time type coercion steps. + * exact or binary-compatible match, since most callers are not prepared + * to cope with adding any run-time type coercion steps. */ typentry = lookup_type_cache(argtype, TYPECACHE_EQ_OPR); oproid = typentry->eq_opr; /* - * If the datatype is an array, then we can use array_eq ... but only - * if there is a suitable equality operator for the element type. - * (This check is not in the raw typcache.c code ... should it be?) + * If the datatype is an array, then we can use array_eq ... but only if + * there is a suitable equality operator for the element type. (This check + * is not in the raw typcache.c code ... should it be?) */ if (oproid == ARRAY_EQ_OP) { @@ -182,8 +182,8 @@ equality_oper(Oid argtype, bool noError) if (!noError) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_FUNCTION), - errmsg("could not identify an equality operator for type %s", - format_type_be(argtype)))); + errmsg("could not identify an equality operator for type %s", + format_type_be(argtype)))); return NULL; } @@ -200,22 +200,22 @@ ordering_oper(Oid argtype, bool noError) Operator optup; /* - * Look for a "<" operator for the datatype. We require it to be an - * exact or binary-compatible match, since most callers are not - * prepared to cope with adding any run-time type coercion steps. + * Look for a "<" operator for the datatype. We require it to be an exact + * or binary-compatible match, since most callers are not prepared to cope + * with adding any run-time type coercion steps. * * Note: the search algorithm used by typcache.c ensures that if a "<" * operator is returned, it will be consistent with the "=" operator - * returned by equality_oper. This is critical for sorting and - * grouping purposes. + * returned by equality_oper. This is critical for sorting and grouping + * purposes. */ typentry = lookup_type_cache(argtype, TYPECACHE_LT_OPR); oproid = typentry->lt_opr; /* - * If the datatype is an array, then we can use array_lt ... but only - * if there is a suitable less-than operator for the element type. - * (This check is not in the raw typcache.c code ... should it be?) + * If the datatype is an array, then we can use array_lt ... but only if + * there is a suitable less-than operator for the element type. (This + * check is not in the raw typcache.c code ... should it be?) */ if (oproid == ARRAY_LT_OP) { @@ -246,9 +246,9 @@ ordering_oper(Oid argtype, bool noError) if (!noError) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_FUNCTION), - errmsg("could not identify an ordering operator for type %s", - format_type_be(argtype)), - errhint("Use an explicit ordering operator or modify the query."))); + errmsg("could not identify an ordering operator for type %s", + format_type_be(argtype)), + errhint("Use an explicit ordering operator or modify the query."))); return NULL; } @@ -265,22 +265,22 @@ reverse_ordering_oper(Oid argtype, bool noError) Operator optup; /* - * Look for a ">" operator for the datatype. We require it to be an - * exact or binary-compatible match, since most callers are not - * prepared to cope with adding any run-time type coercion steps. + * Look for a ">" operator for the datatype. We require it to be an exact + * or binary-compatible match, since most callers are not prepared to cope + * with adding any run-time type coercion steps. * * Note: the search algorithm used by typcache.c ensures that if a ">" * operator is returned, it will be consistent with the "=" operator - * returned by equality_oper. This is critical for sorting and - * grouping purposes. + * returned by equality_oper. This is critical for sorting and grouping + * purposes. */ typentry = lookup_type_cache(argtype, TYPECACHE_GT_OPR); oproid = typentry->gt_opr; /* - * If the datatype is an array, then we can use array_gt ... but only - * if there is a suitable greater-than operator for the element type. - * (This check is not in the raw typcache.c code ... should it be?) + * If the datatype is an array, then we can use array_gt ... but only if + * there is a suitable greater-than operator for the element type. (This + * check is not in the raw typcache.c code ... should it be?) */ if (oproid == ARRAY_GT_OP) { @@ -311,9 +311,9 @@ reverse_ordering_oper(Oid argtype, bool noError) if (!noError) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_FUNCTION), - errmsg("could not identify an ordering operator for type %s", - format_type_be(argtype)), - errhint("Use an explicit ordering operator or modify the query."))); + errmsg("could not identify an ordering operator for type %s", + format_type_be(argtype)), + errhint("Use an explicit ordering operator or modify the query."))); return NULL; } @@ -528,8 +528,8 @@ oper(List *opname, Oid ltypeId, Oid rtypeId, bool noError) */ /* - * Unspecified type for one of the arguments? then use the - * other (XXX this is probably dead code?) + * Unspecified type for one of the arguments? then use the other + * (XXX this is probably dead code?) */ if (rtypeId == InvalidOid) rtypeId = ltypeId; @@ -654,9 +654,8 @@ right_oper(List *op, Oid arg, bool noError) if (!OidIsValid(operOid)) { /* - * We must run oper_select_candidate even if only one - * candidate, otherwise we may falsely return a - * non-type-compatible operator. + * We must run oper_select_candidate even if only one candidate, + * otherwise we may falsely return a non-type-compatible operator. */ fdresult = oper_select_candidate(1, &arg, clist, &operOid); } @@ -703,9 +702,9 @@ left_oper(List *op, Oid arg, bool noError) * First, quickly check to see if there is an exactly matching * operator (there can be only one such entry in the list). * - * The returned list has args in the form (0, oprright). Move the - * useful data into args[0] to keep oper_select_candidate simple. - * XXX we are assuming here that we may scribble on the list! + * The returned list has args in the form (0, oprright). Move the useful + * data into args[0] to keep oper_select_candidate simple. XXX we are + * assuming here that we may scribble on the list! */ FuncCandidateList clisti; @@ -722,9 +721,8 @@ left_oper(List *op, Oid arg, bool noError) if (!OidIsValid(operOid)) { /* - * We must run oper_select_candidate even if only one - * candidate, otherwise we may falsely return a - * non-type-compatible operator. + * We must run oper_select_candidate even if only one candidate, + * otherwise we may falsely return a non-type-compatible operator. */ fdresult = oper_select_candidate(1, &arg, clist, &operOid); } @@ -784,8 +782,8 @@ op_error(List *op, char oprkind, Oid arg1, Oid arg2, FuncDetailCode fdresult) (errcode(ERRCODE_UNDEFINED_FUNCTION), errmsg("operator does not exist: %s", op_signature_string(op, oprkind, arg1, arg2)), - errhint("No operator matches the given name and argument type(s). " - "You may need to add explicit type casts."))); + errhint("No operator matches the given name and argument type(s). " + "You may need to add explicit type casts."))); } /* @@ -862,9 +860,9 @@ make_scalar_array_op(ParseState *pstate, List *opname, atypeId = exprType(rtree); /* - * The right-hand input of the operator will be the element type of - * the array. However, if we currently have just an untyped literal - * on the right, stay with that and hope we can resolve the operator. + * The right-hand input of the operator will be the element type of the + * array. However, if we currently have just an untyped literal on the + * right, stay with that and hope we can resolve the operator. */ if (atypeId == UNKNOWNOID) rtypeId = UNKNOWNOID; @@ -874,7 +872,7 @@ make_scalar_array_op(ParseState *pstate, List *opname, if (!OidIsValid(rtypeId)) ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), - errmsg("op ANY/ALL (array) requires array on right side"))); + errmsg("op ANY/ALL (array) requires array on right side"))); } /* Now resolve the operator */ @@ -888,9 +886,9 @@ make_scalar_array_op(ParseState *pstate, List *opname, declared_arg_types[1] = opform->oprright; /* - * enforce consistency with ANYARRAY and ANYELEMENT argument and - * return types, possibly adjusting return type or declared_arg_types - * (which will be used as the cast destination by make_fn_arguments) + * enforce consistency with ANYARRAY and ANYELEMENT argument and return + * types, possibly adjusting return type or declared_arg_types (which will + * be used as the cast destination by make_fn_arguments) */ rettype = enforce_generic_type_consistency(actual_arg_types, declared_arg_types, @@ -903,11 +901,11 @@ make_scalar_array_op(ParseState *pstate, List *opname, if (rettype != BOOLOID) ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), - errmsg("op ANY/ALL (array) requires operator to yield boolean"))); + errmsg("op ANY/ALL (array) requires operator to yield boolean"))); if (get_func_retset(opform->oprcode)) ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), - errmsg("op ANY/ALL (array) requires operator not to return a set"))); + errmsg("op ANY/ALL (array) requires operator not to return a set"))); /* * Now switch back to the array type on the right, arranging for any @@ -985,9 +983,9 @@ make_op_expr(ParseState *pstate, Operator op, } /* - * enforce consistency with ANYARRAY and ANYELEMENT argument and - * return types, possibly adjusting return type or declared_arg_types - * (which will be used as the cast destination by make_fn_arguments) + * enforce consistency with ANYARRAY and ANYELEMENT argument and return + * types, possibly adjusting return type or declared_arg_types (which will + * be used as the cast destination by make_fn_arguments) */ rettype = enforce_generic_type_consistency(actual_arg_types, declared_arg_types, diff --git a/src/backend/parser/parse_relation.c b/src/backend/parser/parse_relation.c index 196936bb09..61a0549ee0 100644 --- a/src/backend/parser/parse_relation.c +++ b/src/backend/parser/parse_relation.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/parse_relation.c,v 1.114 2005/10/06 19:51:13 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_relation.c,v 1.115 2005/10/15 02:49:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -35,7 +35,7 @@ bool add_missing_from; static RangeTblEntry *scanNameSpaceForRefname(ParseState *pstate, - const char *refname); + const char *refname); static RangeTblEntry *scanNameSpaceForRelid(ParseState *pstate, Oid relid); static bool isLockedRel(ParseState *pstate, char *refname); static void expandRelation(Oid relid, Alias *eref, @@ -43,9 +43,9 @@ static void expandRelation(Oid relid, Alias *eref, bool include_dropped, List **colnames, List **colvars); static void expandTupleDesc(TupleDesc tupdesc, Alias *eref, - int rtindex, int sublevels_up, - bool include_dropped, - List **colnames, List **colvars); + int rtindex, int sublevels_up, + bool include_dropped, + List **colnames, List **colvars); static int specialAttNum(const char *attname); static void warnAutoRange(ParseState *pstate, RangeVar *relation); @@ -297,15 +297,14 @@ scanRTEForColumn(ParseState *pstate, RangeTblEntry *rte, char *colname) * Scan the user column names (or aliases) for a match. Complain if * multiple matches. * - * Note: eref->colnames may include entries for dropped columns, but - * those will be empty strings that cannot match any legal SQL - * identifier, so we don't bother to test for that case here. + * Note: eref->colnames may include entries for dropped columns, but those + * will be empty strings that cannot match any legal SQL identifier, so we + * don't bother to test for that case here. * - * Should this somehow go wrong and we try to access a dropped column, - * we'll still catch it by virtue of the checks in - * get_rte_attribute_type(), which is called by make_var(). That - * routine has to do a cache lookup anyway, so the check there is - * cheap. + * Should this somehow go wrong and we try to access a dropped column, we'll + * still catch it by virtue of the checks in get_rte_attribute_type(), + * which is called by make_var(). That routine has to do a cache lookup + * anyway, so the check there is cheap. */ foreach(c, rte->eref->colnames) { @@ -385,8 +384,8 @@ colNameToVar(ParseState *pstate, char *colname, bool localonly) if (result) ereport(ERROR, (errcode(ERRCODE_AMBIGUOUS_COLUMN), - errmsg("column reference \"%s\" is ambiguous", - colname))); + errmsg("column reference \"%s\" is ambiguous", + colname))); result = newresult; } } @@ -502,7 +501,7 @@ buildRelationAliases(TupleDesc tupdesc, Alias *alias, Alias *eref) ereport(ERROR, (errcode(ERRCODE_INVALID_COLUMN_REFERENCE), errmsg("table \"%s\" has %d columns available but %d columns specified", - eref->aliasname, maxattrs - numdropped, numaliases))); + eref->aliasname, maxattrs - numdropped, numaliases))); } /* @@ -531,8 +530,8 @@ buildScalarFunctionAlias(Node *funcexpr, char *funcname, if (list_length(alias->colnames) != 1) ereport(ERROR, (errcode(ERRCODE_INVALID_COLUMN_REFERENCE), - errmsg("too many column aliases specified for function %s", - funcname))); + errmsg("too many column aliases specified for function %s", + funcname))); eref->colnames = copyObject(alias->colnames); return; } @@ -583,26 +582,26 @@ addRangeTableEntry(ParseState *pstate, rte->alias = alias; /* - * Get the rel's OID. This access also ensures that we have an - * up-to-date relcache entry for the rel. Since this is typically the - * first access to a rel in a statement, be careful to get the right - * access level depending on whether we're doing SELECT FOR UPDATE/SHARE. + * Get the rel's OID. This access also ensures that we have an up-to-date + * relcache entry for the rel. Since this is typically the first access + * to a rel in a statement, be careful to get the right access level + * depending on whether we're doing SELECT FOR UPDATE/SHARE. */ lockmode = isLockedRel(pstate, refname) ? RowShareLock : AccessShareLock; rel = heap_openrv(relation, lockmode); rte->relid = RelationGetRelid(rel); /* - * Build the list of effective column names using user-supplied - * aliases and/or actual column names. + * Build the list of effective column names using user-supplied aliases + * and/or actual column names. */ rte->eref = makeAlias(refname, NIL); buildRelationAliases(rel->rd_att, alias, rte->eref); /* - * Drop the rel refcount, but keep the access lock till end of - * transaction so that the table can't be deleted or have its schema - * modified underneath us. + * Drop the rel refcount, but keep the access lock till end of transaction + * so that the table can't be deleted or have its schema modified + * underneath us. */ heap_close(rel, NoLock); @@ -623,8 +622,8 @@ addRangeTableEntry(ParseState *pstate, rte->checkAsUser = InvalidOid; /* not set-uid by default, either */ /* - * Add completed RTE to pstate's range table list, but not to join - * list nor namespace --- caller must do that if appropriate. + * Add completed RTE to pstate's range table list, but not to join list + * nor namespace --- caller must do that if appropriate. */ if (pstate != NULL) pstate->p_rtable = lappend(pstate->p_rtable, rte); @@ -653,8 +652,8 @@ addRangeTableEntryForRelation(ParseState *pstate, rte->relid = RelationGetRelid(rel); /* - * Build the list of effective column names using user-supplied - * aliases and/or actual column names. + * Build the list of effective column names using user-supplied aliases + * and/or actual column names. */ rte->eref = makeAlias(refname, NIL); buildRelationAliases(rel->rd_att, alias, rte->eref); @@ -676,8 +675,8 @@ addRangeTableEntryForRelation(ParseState *pstate, rte->checkAsUser = InvalidOid; /* not set-uid by default, either */ /* - * Add completed RTE to pstate's range table list, but not to join - * list nor namespace --- caller must do that if appropriate. + * Add completed RTE to pstate's range table list, but not to join list + * nor namespace --- caller must do that if appropriate. */ if (pstate != NULL) pstate->p_rtable = lappend(pstate->p_rtable, rte); @@ -754,8 +753,8 @@ addRangeTableEntryForSubquery(ParseState *pstate, rte->checkAsUser = InvalidOid; /* - * Add completed RTE to pstate's range table list, but not to join - * list nor namespace --- caller must do that if appropriate. + * Add completed RTE to pstate's range table list, but not to join list + * nor namespace --- caller must do that if appropriate. */ if (pstate != NULL) pstate->p_rtable = lappend(pstate->p_rtable, rte); @@ -801,8 +800,8 @@ addRangeTableEntryForFunction(ParseState *pstate, &tupdesc); /* - * A coldeflist is required if the function returns RECORD and hasn't - * got a predetermined record type, and is prohibited otherwise. + * A coldeflist is required if the function returns RECORD and hasn't got + * a predetermined record type, and is prohibited otherwise. */ if (coldeflist != NIL) { @@ -848,8 +847,8 @@ addRangeTableEntryForFunction(ParseState *pstate, else ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("function \"%s\" in FROM has unsupported return type %s", - funcname, format_type_be(funcrettype)))); + errmsg("function \"%s\" in FROM has unsupported return type %s", + funcname, format_type_be(funcrettype)))); /*---------- * Flags: @@ -868,8 +867,8 @@ addRangeTableEntryForFunction(ParseState *pstate, rte->checkAsUser = InvalidOid; /* - * Add completed RTE to pstate's range table list, but not to join - * list nor namespace --- caller must do that if appropriate. + * Add completed RTE to pstate's range table list, but not to join list + * nor namespace --- caller must do that if appropriate. */ if (pstate != NULL) pstate->p_rtable = lappend(pstate->p_rtable, rte); @@ -907,7 +906,7 @@ addRangeTableEntryForJoin(ParseState *pstate, /* fill in any unspecified alias columns */ if (numaliases < list_length(colnames)) eref->colnames = list_concat(eref->colnames, - list_copy_tail(colnames, numaliases)); + list_copy_tail(colnames, numaliases)); rte->eref = eref; @@ -927,8 +926,8 @@ addRangeTableEntryForJoin(ParseState *pstate, rte->checkAsUser = InvalidOid; /* - * Add completed RTE to pstate's range table list, but not to join - * list nor namespace --- caller must do that if appropriate. + * Add completed RTE to pstate's range table list, but not to join list + * nor namespace --- caller must do that if appropriate. */ if (pstate != NULL) pstate->p_rtable = lappend(pstate->p_rtable, rte); @@ -983,7 +982,7 @@ addRTEtoQuery(ParseState *pstate, RangeTblEntry *rte, { if (addToJoinList) { - int rtindex = RTERangeTablePosn(pstate, rte, NULL); + int rtindex = RTERangeTablePosn(pstate, rte, NULL); RangeTblRef *rtr = makeNode(RangeTblRef); rtr->rtindex = rtindex; @@ -1111,7 +1110,7 @@ expandRTE(RangeTblEntry *rte, int rtindex, int sublevels_up, /* Base data type, i.e. scalar */ if (colnames) *colnames = lappend(*colnames, - linitial(rte->eref->colnames)); + linitial(rte->eref->colnames)); if (colvars) { @@ -1184,11 +1183,11 @@ expandRTE(RangeTblEntry *rte, int rtindex, int sublevels_up, /* * During ordinary parsing, there will never be any - * deleted columns in the join; but we have to check - * since this routine is also used by the rewriter, - * and joins found in stored rules might have join - * columns for since-deleted columns. This will be - * signaled by a NULL Const in the alias-vars list. + * deleted columns in the join; but we have to check since + * this routine is also used by the rewriter, and joins + * found in stored rules might have join columns for + * since-deleted columns. This will be signaled by a NULL + * Const in the alias-vars list. */ if (IsA(avar, Const)) { @@ -1274,8 +1273,8 @@ expandTupleDesc(TupleDesc tupdesc, Alias *eref, if (colvars) { /* - * can't use atttypid here, but it doesn't really - * matter what type the Const claims to be. + * can't use atttypid here, but it doesn't really matter + * what type the Const claims to be. */ *colvars = lappend(*colvars, makeNullConst(INT4OID)); } @@ -1342,8 +1341,7 @@ expandRelAttrs(ParseState *pstate, RangeTblEntry *rte, te_list = lappend(te_list, te); } - Assert(name == NULL && var == NULL); /* lists not the same - * length? */ + Assert(name == NULL && var == NULL); /* lists not the same length? */ return te_list; } @@ -1382,8 +1380,7 @@ get_rte_attribute_name(RangeTblEntry *rte, AttrNumber attnum) return get_relid_attribute_name(rte->relid, attnum); /* - * Otherwise use the column name from eref. There should always be - * one. + * Otherwise use the column name from eref. There should always be one. */ if (attnum > 0 && attnum <= list_length(rte->eref->colnames)) return strVal(list_nth(rte->eref->colnames, attnum - 1)); @@ -1420,15 +1417,15 @@ get_rte_attribute_type(RangeTblEntry *rte, AttrNumber attnum, att_tup = (Form_pg_attribute) GETSTRUCT(tp); /* - * If dropped column, pretend it ain't there. See notes - * in scanRTEForColumn. + * If dropped column, pretend it ain't there. See notes in + * scanRTEForColumn. */ if (att_tup->attisdropped) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_COLUMN), - errmsg("column \"%s\" of relation \"%s\" does not exist", - NameStr(att_tup->attname), - get_rel_name(rte->relid)))); + errmsg("column \"%s\" of relation \"%s\" does not exist", + NameStr(att_tup->attname), + get_rel_name(rte->relid)))); *vartype = att_tup->atttypid; *vartypmod = att_tup->atttypmod; ReleaseSysCache(tp); @@ -1468,15 +1465,15 @@ get_rte_attribute_type(RangeTblEntry *rte, AttrNumber attnum, if (attnum < 1 || attnum > tupdesc->natts) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_COLUMN), - errmsg("column %d of relation \"%s\" does not exist", - attnum, - rte->eref->aliasname))); + errmsg("column %d of relation \"%s\" does not exist", + attnum, + rte->eref->aliasname))); att_tup = tupdesc->attrs[attnum - 1]; /* - * If dropped column, pretend it ain't there. See - * notes in scanRTEForColumn. + * If dropped column, pretend it ain't there. See notes + * in scanRTEForColumn. */ if (att_tup->attisdropped) ereport(ERROR, @@ -1510,8 +1507,7 @@ get_rte_attribute_type(RangeTblEntry *rte, AttrNumber attnum, case RTE_JOIN: { /* - * Join RTE --- get type info from join RTE's alias - * variable + * Join RTE --- get type info from join RTE's alias variable */ Node *aliasvar; @@ -1540,8 +1536,7 @@ get_rte_attribute_is_dropped(RangeTblEntry *rte, AttrNumber attnum) case RTE_RELATION: { /* - * Plain relation RTE --- get the attribute's catalog - * entry + * Plain relation RTE --- get the attribute's catalog entry */ HeapTuple tp; Form_pg_attribute att_tup; @@ -1565,12 +1560,11 @@ get_rte_attribute_is_dropped(RangeTblEntry *rte, AttrNumber attnum) case RTE_JOIN: { /* - * A join RTE would not have dropped columns when - * constructed, but one in a stored rule might contain - * columns that were dropped from the underlying tables, - * if said columns are nowhere explicitly referenced in - * the rule. This will be signaled to us by a NULL Const - * in the joinaliasvars list. + * A join RTE would not have dropped columns when constructed, + * but one in a stored rule might contain columns that were + * dropped from the underlying tables, if said columns are + * nowhere explicitly referenced in the rule. This will be + * signaled to us by a NULL Const in the joinaliasvars list. */ Var *aliasvar; @@ -1766,8 +1760,8 @@ warnAutoRange(ParseState *pstate, RangeVar *relation) if (pstate->parentParseState != NULL) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_TABLE), - errmsg("missing FROM-clause entry in subquery for table \"%s\"", - relation->relname))); + errmsg("missing FROM-clause entry in subquery for table \"%s\"", + relation->relname))); else ereport(ERROR, (errcode(ERRCODE_UNDEFINED_TABLE), @@ -1785,7 +1779,7 @@ warnAutoRange(ParseState *pstate, RangeVar *relation) else ereport(NOTICE, (errcode(ERRCODE_UNDEFINED_TABLE), - errmsg("adding missing FROM-clause entry for table \"%s\"", - relation->relname))); + errmsg("adding missing FROM-clause entry for table \"%s\"", + relation->relname))); } } diff --git a/src/backend/parser/parse_target.c b/src/backend/parser/parse_target.c index 00185a05e1..88c29ebf1e 100644 --- a/src/backend/parser/parse_target.c +++ b/src/backend/parser/parse_target.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/parse_target.c,v 1.137 2005/06/26 22:05:40 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_target.c,v 1.138 2005/10/15 02:49:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -32,7 +32,7 @@ static void markTargetListOrigin(ParseState *pstate, TargetEntry *tle, - Var *var, int levelsup); + Var *var, int levelsup); static Node *transformAssignmentIndirection(ParseState *pstate, Node *basenode, const char *targetName, @@ -73,8 +73,8 @@ transformTargetEntry(ParseState *pstate, if (colname == NULL && !resjunk) { /* - * Generate a suitable column name for a column without any - * explicit 'AS ColumnName' clause. + * Generate a suitable column name for a column without any explicit + * 'AS ColumnName' clause. */ colname = FigureColname(node); } @@ -105,8 +105,8 @@ transformTargetList(ParseState *pstate, List *targetlist) /* * Check for "something.*". Depending on the complexity of the - * "something", the star could appear as the last name in - * ColumnRef, or as the last indirection item in A_Indirection. + * "something", the star could appear as the last name in ColumnRef, + * or as the last indirection item in A_Indirection. */ if (IsA(res->val, ColumnRef)) { @@ -130,7 +130,7 @@ transformTargetList(ParseState *pstate, List *targetlist) { /* It is something.*, expand into multiple items */ p_target = list_concat(p_target, - ExpandIndirectionStar(pstate, ind)); + ExpandIndirectionStar(pstate, ind)); continue; } } @@ -271,11 +271,11 @@ updateTargetListEntry(ParseState *pstate, /* * If the expression is a DEFAULT placeholder, insert the attribute's - * type/typmod into it so that exprType will report the right things. - * (We expect that the eventually substituted default expression will - * in fact have this type and typmod.) Also, reject trying to update - * a subfield or array element with DEFAULT, since there can't be any - * default for portions of a column. + * type/typmod into it so that exprType will report the right things. (We + * expect that the eventually substituted default expression will in fact + * have this type and typmod.) Also, reject trying to update a subfield + * or array element with DEFAULT, since there can't be any default for + * portions of a column. */ if (tle->expr && IsA(tle->expr, SetToDefault)) { @@ -288,7 +288,7 @@ updateTargetListEntry(ParseState *pstate, if (IsA(linitial(indirection), A_Indices)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot set an array element to DEFAULT"))); + errmsg("cannot set an array element to DEFAULT"))); else ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), @@ -301,9 +301,9 @@ updateTargetListEntry(ParseState *pstate, /* * If there is indirection on the target column, prepare an array or - * subfield assignment expression. This will generate a new column - * value that the source value has been inserted into, which can then - * be placed in the new tuple constructed by INSERT or UPDATE. + * subfield assignment expression. This will generate a new column value + * that the source value has been inserted into, which can then be placed + * in the new tuple constructed by INSERT or UPDATE. */ if (indirection) { @@ -312,9 +312,9 @@ updateTargetListEntry(ParseState *pstate, if (pstate->p_is_insert) { /* - * The command is INSERT INTO table (col.something) ... so - * there is not really a source value to work with. Insert a - * NULL constant as the source value. + * The command is INSERT INTO table (col.something) ... so there + * is not really a source value to work with. Insert a NULL + * constant as the source value. */ colVar = (Node *) makeNullConst(attrtype); } @@ -358,15 +358,14 @@ updateTargetListEntry(ParseState *pstate, colname, format_type_be(attrtype), format_type_be(type_id)), - errhint("You will need to rewrite or cast the expression."))); + errhint("You will need to rewrite or cast the expression."))); } /* * Set the resno to identify the target column --- the rewriter and - * planner depend on this. We also set the resname to identify the - * target column, but this is only for debugging purposes; it should - * not be relied on. (In particular, it might be out of date in a - * stored rule.) + * planner depend on this. We also set the resname to identify the target + * column, but this is only for debugging purposes; it should not be + * relied on. (In particular, it might be out of date in a stored rule.) */ tle->resno = (AttrNumber) attrno; tle->resname = colname; @@ -424,8 +423,8 @@ transformAssignmentIndirection(ParseState *pstate, /* * We have to split any field-selection operations apart from - * subscripting. Adjacent A_Indices nodes have to be treated as a - * single multidimensional subscript operation. + * subscripting. Adjacent A_Indices nodes have to be treated as a single + * multidimensional subscript operation. */ for_each_cell(i, indirection) { @@ -561,7 +560,7 @@ transformAssignmentIndirection(ParseState *pstate, targetName, format_type_be(targetTypeId), format_type_be(exprType(rhs))), - errhint("You will need to rewrite or cast the expression."))); + errhint("You will need to rewrite or cast the expression."))); else ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), @@ -570,7 +569,7 @@ transformAssignmentIndirection(ParseState *pstate, targetName, format_type_be(targetTypeId), format_type_be(exprType(rhs))), - errhint("You will need to rewrite or cast the expression."))); + errhint("You will need to rewrite or cast the expression."))); } return result; @@ -631,8 +630,8 @@ checkInsertTargets(ParseState *pstate, List *cols, List **attrnos) attrno = attnameAttNum(pstate->p_target_relation, name, false); /* - * Check for duplicates, but only of whole columns --- we - * allow INSERT INTO foo (col.subcol1, col.subcol2) + * Check for duplicates, but only of whole columns --- we allow + * INSERT INTO foo (col.subcol1, col.subcol2) */ if (col->indirection == NIL) { @@ -641,8 +640,8 @@ checkInsertTargets(ParseState *pstate, List *cols, List **attrnos) bms_is_member(attrno, partialcols)) ereport(ERROR, (errcode(ERRCODE_DUPLICATE_COLUMN), - errmsg("column \"%s\" specified more than once", - name))); + errmsg("column \"%s\" specified more than once", + name))); wholecols = bms_add_member(wholecols, attrno); } else @@ -651,8 +650,8 @@ checkInsertTargets(ParseState *pstate, List *cols, List **attrnos) if (bms_is_member(attrno, wholecols)) ereport(ERROR, (errcode(ERRCODE_DUPLICATE_COLUMN), - errmsg("column \"%s\" specified more than once", - name))); + errmsg("column \"%s\" specified more than once", + name))); partialcols = bms_add_member(partialcols, attrno); } @@ -727,8 +726,8 @@ ExpandColumnRefStar(ParseState *pstate, ColumnRef *cref) default: ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("improper qualified name (too many dotted names): %s", - NameListToString(fields)))); + errmsg("improper qualified name (too many dotted names): %s", + NameListToString(fields)))); schemaname = NULL; /* keep compiler quiet */ relname = NULL; break; @@ -765,12 +764,12 @@ ExpandAllTables(ParseState *pstate) if (!pstate->p_varnamespace) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("SELECT * with no tables specified is not valid"))); + errmsg("SELECT * with no tables specified is not valid"))); foreach(l, pstate->p_varnamespace) { RangeTblEntry *rte = (RangeTblEntry *) lfirst(l); - int rtindex = RTERangeTablePosn(pstate, rte, NULL); + int rtindex = RTERangeTablePosn(pstate, rte, NULL); target = list_concat(target, expandRelAttrs(pstate, rte, rtindex, 0)); @@ -804,14 +803,14 @@ ExpandIndirectionStar(ParseState *pstate, A_Indirection *ind) /* * Verify it's a composite type, and get the tupdesc. We use - * get_expr_result_type() because that can handle references to - * functions returning anonymous record types. If that fails, - * use lookup_rowtype_tupdesc(), which will almost certainly fail - * as well, but it will give an appropriate error message. + * get_expr_result_type() because that can handle references to functions + * returning anonymous record types. If that fails, use + * lookup_rowtype_tupdesc(), which will almost certainly fail as well, but + * it will give an appropriate error message. * - * If it's a Var of type RECORD, we have to work even harder: we have - * to find what the Var refers to, and pass that to get_expr_result_type. - * That task is handled by expandRecordVariable(). + * If it's a Var of type RECORD, we have to work even harder: we have to find + * what the Var refers to, and pass that to get_expr_result_type. That + * task is handled by expandRecordVariable(). */ if (IsA(expr, Var) && ((Var *) expr)->vartype == RECORDOID) @@ -832,9 +831,9 @@ ExpandIndirectionStar(ParseState *pstate, A_Indirection *ind) continue; /* - * If we got a whole-row Var from the rowtype reference, we can - * expand the fields as simple Vars. Otherwise we must generate - * multiple copies of the rowtype reference and do FieldSelects. + * If we got a whole-row Var from the rowtype reference, we can expand + * the fields as simple Vars. Otherwise we must generate multiple + * copies of the rowtype reference and do FieldSelects. */ if (IsA(expr, Var) && ((Var *) expr)->varattno == InvalidAttrNumber) @@ -874,7 +873,7 @@ ExpandIndirectionStar(ParseState *pstate, A_Indirection *ind) * Get the tuple descriptor for a Var of type RECORD, if possible. * * Since no actual table or view column is allowed to have type RECORD, such - * a Var must refer to a JOIN or FUNCTION RTE or to a subquery output. We + * a Var must refer to a JOIN or FUNCTION RTE or to a subquery output. We * drill down to find the ultimate defining expression and attempt to infer * the tupdesc from it. We ereport if we can't determine the tupdesc. * @@ -934,6 +933,7 @@ expandRecordVariable(ParseState *pstate, Var *var, int levelsup) { case RTE_RELATION: case RTE_SPECIAL: + /* * This case should not occur: a column of a table shouldn't have * type RECORD. Fall through and fail (most likely) at the @@ -954,7 +954,7 @@ expandRecordVariable(ParseState *pstate, Var *var, int levelsup) { /* * Recurse into the sub-select to see what its Var refers - * to. We have to build an additional level of ParseState + * to. We have to build an additional level of ParseState * to keep in step with varlevelsup in the subselect. */ ParseState mypstate; @@ -978,18 +978,19 @@ expandRecordVariable(ParseState *pstate, Var *var, int levelsup) /* else fall through to inspect the expression */ break; case RTE_FUNCTION: + /* - * We couldn't get here unless a function is declared with one - * of its result columns as RECORD, which is not allowed. + * We couldn't get here unless a function is declared with one of + * its result columns as RECORD, which is not allowed. */ break; } /* * We now have an expression we can't expand any more, so see if - * get_expr_result_type() can do anything with it. If not, pass - * to lookup_rowtype_tupdesc() which will probably fail, but will - * give an appropriate error message while failing. + * get_expr_result_type() can do anything with it. If not, pass to + * lookup_rowtype_tupdesc() which will probably fail, but will give an + * appropriate error message while failing. */ if (get_expr_result_type(expr, NULL, &tupleDesc) != TYPEFUNC_COMPOSITE) tupleDesc = lookup_rowtype_tupdesc(exprType(expr), exprTypmod(expr)); @@ -1125,7 +1126,7 @@ FigureColnameInternal(Node *node, char **name) return 2; case T_MinMaxExpr: /* make greatest/least act like a regular function */ - switch (((MinMaxExpr*) node)->op) + switch (((MinMaxExpr *) node)->op) { case IS_GREATEST: *name = "greatest"; diff --git a/src/backend/parser/parse_type.c b/src/backend/parser/parse_type.c index 008c1fe6a5..ec8dfef68d 100644 --- a/src/backend/parser/parse_type.c +++ b/src/backend/parser/parse_type.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/parse_type.c,v 1.76 2005/08/01 20:31:10 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_type.c,v 1.77 2005/10/15 02:49:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -59,8 +59,8 @@ LookupTypeName(const TypeName *typename) case 1: ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("improper %%TYPE reference (too few dotted names): %s", - NameListToString(typename->names)))); + errmsg("improper %%TYPE reference (too few dotted names): %s", + NameListToString(typename->names)))); break; case 2: rel->relname = strVal(linitial(typename->names)); @@ -91,8 +91,8 @@ LookupTypeName(const TypeName *typename) if (attnum == InvalidAttrNumber) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_COLUMN), - errmsg("column \"%s\" of relation \"%s\" does not exist", - field, rel->relname))); + errmsg("column \"%s\" of relation \"%s\" does not exist", + field, rel->relname))); restype = get_atttype(relid, attnum); /* this construct should never have an array indicator */ @@ -364,8 +364,8 @@ pts_error_callback(void *arg) /* * Currently we just suppress any syntax error position report, rather - * than transforming to an "internal query" error. It's unlikely that - * a type name is complex enough to need positioning. + * than transforming to an "internal query" error. It's unlikely that a + * type name is complex enough to need positioning. */ errposition(0); } @@ -406,8 +406,8 @@ parseTypeString(const char *str, Oid *type_id, int32 *typmod) error_context_stack = ptserrcontext.previous; /* - * Make sure we got back exactly what we expected and no more; - * paranoia is justified since the string might contain anything. + * Make sure we got back exactly what we expected and no more; paranoia is + * justified since the string might contain anything. */ if (list_length(raw_parsetree_list) != 1) goto fail; diff --git a/src/backend/parser/scansup.c b/src/backend/parser/scansup.c index cf588c1de8..efa851ea0b 100644 --- a/src/backend/parser/scansup.c +++ b/src/backend/parser/scansup.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/scansup.c,v 1.29 2004/12/31 22:00:27 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/parser/scansup.c,v 1.30 2005/10/15 02:49:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -53,8 +53,8 @@ scanstr(const 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]; @@ -135,13 +135,13 @@ downcase_truncate_identifier(const char *ident, int len, bool warn) result = palloc(len + 1); /* - * SQL99 specifies Unicode-aware case normalization, which we don't - * yet have the infrastructure for. Instead we use tolower() to - * provide a locale-aware translation. However, there are some - * locales where this is not right either (eg, Turkish may do strange - * things with 'i' and 'I'). Our current compromise is to use - * tolower() for characters with the high bit set, and use an - * ASCII-only downcasing for 7-bit characters. + * SQL99 specifies Unicode-aware case normalization, which we don't yet + * have the infrastructure for. Instead we use tolower() to provide a + * locale-aware translation. However, there are some locales where this + * is not right either (eg, Turkish may do strange things with 'i' and + * 'I'). Our current compromise is to use tolower() for characters with + * the high bit set, and use an ASCII-only downcasing for 7-bit + * characters. */ for (i = 0; i < len; i++) { @@ -179,8 +179,8 @@ truncate_identifier(char *ident, int len, bool warn) if (warn) ereport(NOTICE, (errcode(ERRCODE_NAME_TOO_LONG), - errmsg("identifier \"%s\" will be truncated to \"%.*s\"", - ident, len, ident))); + errmsg("identifier \"%s\" will be truncated to \"%.*s\"", + ident, len, ident))); ident[len] = '\0'; } } diff --git a/src/backend/port/beos/sem.c b/src/backend/port/beos/sem.c index 5de018b22b..2d0dabadb3 100644 --- a/src/backend/port/beos/sem.c +++ b/src/backend/port/beos/sem.c @@ -129,8 +129,8 @@ semctl(int semId, int semNum, int flag, union semun semun) delete_sem(Address[2 * i + 1]); /* - * Reset to an invalid semId (in case other process try to get - * the infos from a cloned area + * Reset to an invalid semId (in case other process try to get the + * infos from a cloned area */ Address[2 * i + 1] = 0; } @@ -139,9 +139,9 @@ semctl(int semId, int semNum, int flag, union semun semun) Address[0] = 0; /* - * Delete the area (it might be cloned by other process. Let them - * live with it, in all cases semIds are 0 so if another process - * try to use it, it will fail + * Delete the area (it might be cloned by other process. Let them live + * with it, in all cases semIds are 0 so if another process try to use + * it, it will fail */ delete_area(semId); @@ -202,8 +202,8 @@ semget(int semKey, int semNum, int flags) /* Get an area clone (in case it's not in our address space) */ /* - * TODO : a check of address space might be done to avoid - * duplicate areas in the same address space + * TODO : a check of address space might be done to avoid duplicate + * areas in the same address space */ parea = clone_area(Nom, &Address, B_ANY_ADDRESS, B_READ_AREA | B_WRITE_AREA, parea); return parea; @@ -218,8 +218,8 @@ semget(int semKey, int semNum, int flags) long i; /* - * Limit to 250 (8 byte per sem : 4 for the semid and 4 for - * the last pid which accessed the semaphore in a pool + * Limit to 250 (8 byte per sem : 4 for the semid and 4 for the + * last pid which accessed the semaphore in a pool */ if (semNum > 250) { @@ -291,8 +291,8 @@ semop(int semId, struct sembuf * sops, int nsops) if (sops[i].sem_op < 0) { /* - * Try acquiring the semaphore till we are not interrupted by - * a signal + * Try acquiring the semaphore till we are not interrupted by a + * signal */ if (sops[i].sem_flg == IPC_NOWAIT) { diff --git a/src/backend/port/beos/shm.c b/src/backend/port/beos/shm.c index 94da461ea2..c7791ce7b4 100644 --- a/src/backend/port/beos/shm.c +++ b/src/backend/port/beos/shm.c @@ -48,16 +48,15 @@ shmat(int memId, int m1, int m2) if (ainfo.team == teinfo.team) { /* - * the area is already in our address space, just return the - * address + * the area is already in our address space, just return the address */ return (int *) ainfo.address; } else { /* - * the area is not in our address space, clone it before and - * return the address + * the area is not in our address space, clone it before and return + * the address */ area_id narea; @@ -131,8 +130,8 @@ shmget(int memKey, int size, int flag) return -1; /* - * area does not exist and its creation is requested, create it (be - * sure to have a 4ko multiple size + * area does not exist and its creation is requested, create it (be sure + * to have a 4ko multiple size */ return create_area(nom, &Address, B_ANY_ADDRESS, ((size / 4096) + 1) * 4096, B_NO_LOCK, B_READ_AREA | B_WRITE_AREA); } diff --git a/src/backend/port/beos/support.c b/src/backend/port/beos/support.c index 3bfb6ae0d4..228889f68e 100644 --- a/src/backend/port/beos/support.c +++ b/src/backend/port/beos/support.c @@ -168,13 +168,12 @@ beos_startup(int argc, char **argv) /* Main server loop */ for (;;) { - int32 opcode = 0; + int32 opcode = 0; char datas[4000]; /* - * Wait for a message from the backend : 1 : load a shared - * object 2 : unload a shared object any other : exit support - * server + * Wait for a message from the backend : 1 : load a shared object + * 2 : unload a shared object any other : exit support server */ read_port(port_in, &opcode, datas, 4000); @@ -216,8 +215,8 @@ beos_startup(int argc, char **argv) case 2: /* - * Unload shared object and send back the result of - * the operation + * Unload shared object and send back the result of the + * operation */ write_port(port_out, unload_add_on(*((int *) (datas))), NULL, 0); break; @@ -234,10 +233,9 @@ beos_startup(int argc, char **argv) if (get_image_symbol(addon, datas, B_SYMBOL_TYPE_TEXT, &fpt) == B_OK); { /* - * Sometime the loader return B_OK for an - * inexistant function with an invalid address !!! - * Check that the return address is in the image - * range + * Sometime the loader return B_OK for an inexistant + * function with an invalid address !!! Check that the + * return address is in the image range */ get_image_info(addon, &info_im); diff --git a/src/backend/port/dynloader/aix.c b/src/backend/port/dynloader/aix.c index a5d355c2cc..3ace7fc391 100644 --- a/src/backend/port/dynloader/aix.c +++ b/src/backend/port/dynloader/aix.c @@ -84,8 +84,8 @@ dlopen(const char *path, int mode) static void *mainModule; /* - * Upon the first call register a terminate handler that will close - * all libraries. Also get a reference to the main module for use with + * Upon the first call register a terminate handler that will close all + * libraries. Also get a reference to the main module for use with * loadbind. */ if (!mainModule) @@ -121,8 +121,8 @@ dlopen(const char *path, int mode) } /* - * load should be declared load(const char *...). Thus we cast the - * path to a normal char *. Ugly. + * load should be declared load(const char *...). Thus we cast the path to + * a normal char *. Ugly. */ if ((mp->entry = (void *) load((char *) path, L_NOAUTODEFER, NULL)) == NULL) { @@ -134,8 +134,8 @@ dlopen(const char *path, int mode) strcat(errbuf, ": "); /* - * If AIX says the file is not executable, the error can be - * further described by querying the loader about the last error. + * If AIX says the file is not executable, the error can be further + * described by querying the loader about the last error. */ if (errno == ENOEXEC) { @@ -203,8 +203,8 @@ dlopen(const char *path, int mode) errvalid = 0; /* - * If the shared object was compiled using xlC we will need to call - * static constructors (and later on dlclose destructors). + * If the shared object was compiled using xlC we will need to call static + * constructors (and later on dlclose destructors). */ if (mp->cdtors = (CdtorPtr) dlsym(mp, "__cdtors")) { @@ -268,8 +268,8 @@ dlsym(void *handle, const char *symbol) int i; /* - * Could speed up the search, but I assume that one assigns the result - * to function pointers anyways. + * Could speed up the search, but I assume that one assigns the result to + * function pointers anyways. */ for (ep = mp->exports, i = mp->nExports; i; i--, ep++) if (strcmp(ep->name, symbol) == 0) @@ -377,8 +377,8 @@ readExports(ModulePtr mp) } /* - * The module might be loaded due to the LIBPATH environment - * variable. Search for the loaded module using L_GETINFO. + * The module might be loaded due to the LIBPATH environment variable. + * Search for the loaded module using L_GETINFO. */ if ((buf = malloc(size)) == NULL) { @@ -409,8 +409,8 @@ readExports(ModulePtr mp) } /* - * Traverse the list of loaded modules. The entry point returned - * by load() does actually point to the data segment origin. + * Traverse the list of loaded modules. The entry point returned by + * load() does actually point to the data segment origin. */ lp = (struct ld_info *) buf; while (lp) @@ -445,8 +445,8 @@ readExports(ModulePtr mp) /* * Get the padding for the data section. This is needed for AIX 4.1 - * compilers. This is used when building the final function pointer to - * the exported symbol. + * compilers. This is used when building the final function pointer to the + * exported symbol. */ if (ldnshread(ldp, _DATA, &shdata) != SUCCESS) { @@ -466,8 +466,8 @@ readExports(ModulePtr mp) } /* - * We read the complete loader section in one chunk, this makes - * finding long symbol names residing in the string table easier. + * We read the complete loader section in one chunk, this makes finding + * long symbol names residing in the string table easier. */ if ((ldbuf = (char *) malloc(sh.s_size)) == NULL) { @@ -520,8 +520,8 @@ readExports(ModulePtr mp) } /* - * Fill in the export table. All entries are relative to the entry - * point we got from load. + * Fill in the export table. All entries are relative to the entry point + * we got from load. */ ep = mp->exports; ls = (LDSYM *) (ldbuf + LDHDRSZ); @@ -538,8 +538,8 @@ readExports(ModulePtr mp) { /* * The l_name member is not zero terminated, we must copy the - * first SYMNMLEN chars and make sure we have a zero byte at - * the end. + * first SYMNMLEN chars and make sure we have a zero byte at the + * end. */ strncpy(tmpsym, ls->l_name, SYMNMLEN); tmpsym[SYMNMLEN] = '\0'; @@ -598,8 +598,8 @@ findMain(void) } /* - * The first entry is the main module. The entry point returned by - * load() does actually point to the data segment origin. + * The first entry is the main module. The entry point returned by load() + * does actually point to the data segment origin. */ lp = (struct ld_info *) buf; ret = lp->ldinfo_dataorg; diff --git a/src/backend/port/dynloader/aix.h b/src/backend/port/dynloader/aix.h index 69e20ebae3..29d385986e 100644 --- a/src/backend/port/dynloader/aix.h +++ b/src/backend/port/dynloader/aix.h @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/src/backend/port/dynloader/aix.h,v 1.12 2003/11/29 22:39:51 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/port/dynloader/aix.h,v 1.13 2005/10/15 02:49:23 momjian Exp $ * * @(#)dlfcn.h 1.4 revision of 95/04/25 09:36:52 * This is an unpublished work copyright (c) 1992 HELIOS Software GmbH @@ -12,7 +12,6 @@ #ifdef HAVE_DLOPEN #include - #else /* HAVE_DLOPEN */ #ifdef __cplusplus @@ -42,7 +41,6 @@ void *dlopen(const char *path, int mode); void *dlsym(void *handle, const char *symbol); char *dlerror(void); int dlclose(void *handle); - #else void *dlopen(); void *dlsym(); diff --git a/src/backend/port/dynloader/bsdi.c b/src/backend/port/dynloader/bsdi.c index 6b17a929f4..bc51569a30 100644 --- a/src/backend/port/dynloader/bsdi.c +++ b/src/backend/port/dynloader/bsdi.c @@ -11,7 +11,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/port/dynloader/bsdi.c,v 1.26 2004/12/31 22:00:32 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/port/dynloader/bsdi.c,v 1.27 2005/10/15 02:49:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -26,8 +26,8 @@ pg_dlopen(char *filename) static int dl_initialized = 0; /* - * initializes the dynamic loader with the executable's pathname. - * (only needs to do this the first time pg_dlopen is called.) + * initializes the dynamic loader with the executable's pathname. (only + * needs to do this the first time pg_dlopen is called.) */ if (!dl_initialized) { @@ -48,9 +48,8 @@ pg_dlopen(char *filename) return NULL; /* - * If undefined symbols: try to link with the C and math libraries! - * This could be smarter, if the dynamic linker was able to handle - * shared libs! + * If undefined symbols: try to link with the C and math libraries! This + * could be smarter, if the dynamic linker was able to handle shared libs! */ if (dld_undefined_sym_count > 0) { diff --git a/src/backend/port/dynloader/bsdi.h b/src/backend/port/dynloader/bsdi.h index c7f2ab5e8c..b73fa6141f 100644 --- a/src/backend/port/dynloader/bsdi.h +++ b/src/backend/port/dynloader/bsdi.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/port/dynloader/bsdi.h,v 1.21 2004/12/31 22:00:32 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/port/dynloader/bsdi.h,v 1.22 2005/10/15 02:49:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -37,7 +37,6 @@ #define pg_dlsym dlsym #define pg_dlclose dlclose #define pg_dlerror dlerror - #else /* not HAVE_DLOPEN */ #define pg_dlsym(handle, funcname) ((PGFunction) dld_get_func((funcname))) diff --git a/src/backend/port/dynloader/hpux.c b/src/backend/port/dynloader/hpux.c index b424e5b4c9..6a516387ba 100644 --- a/src/backend/port/dynloader/hpux.c +++ b/src/backend/port/dynloader/hpux.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/port/dynloader/hpux.c,v 1.27 2004/12/31 22:00:32 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/port/dynloader/hpux.c,v 1.28 2005/10/15 02:49:23 momjian Exp $ * * NOTES * all functions are defined here -- it's impossible to trace the @@ -34,7 +34,7 @@ pg_dlopen(char *filename) * call the library! */ shl_t handle = shl_load(filename, - BIND_IMMEDIATE | BIND_VERBOSE | DYNAMIC_PATH, + BIND_IMMEDIATE | BIND_VERBOSE | DYNAMIC_PATH, 0L); return (void *) handle; diff --git a/src/backend/port/dynloader/linux.c b/src/backend/port/dynloader/linux.c index 325e8f9920..e62431140c 100644 --- a/src/backend/port/dynloader/linux.c +++ b/src/backend/port/dynloader/linux.c @@ -11,7 +11,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/port/dynloader/linux.c,v 1.30 2004/12/31 22:00:32 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/port/dynloader/linux.c,v 1.31 2005/10/15 02:49:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -38,8 +38,8 @@ pg_dlopen(char *filename) static int dl_initialized = 0; /* - * initializes the dynamic loader with the executable's pathname. - * (only needs to do this the first time pg_dlopen is called.) + * initializes the dynamic loader with the executable's pathname. (only + * needs to do this the first time pg_dlopen is called.) */ if (!dl_initialized) { @@ -60,9 +60,8 @@ pg_dlopen(char *filename) return NULL; /* - * If undefined symbols: try to link with the C and math libraries! - * This could be smarter, if the dynamic linker was able to handle - * shared libs! + * If undefined symbols: try to link with the C and math libraries! This + * could be smarter, if the dynamic linker was able to handle shared libs! */ if (dld_undefined_sym_count > 0) { diff --git a/src/backend/port/dynloader/ultrix4.c b/src/backend/port/dynloader/ultrix4.c index c0e4555a38..c631538083 100644 --- a/src/backend/port/dynloader/ultrix4.c +++ b/src/backend/port/dynloader/ultrix4.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/port/dynloader/ultrix4.c,v 1.22 2004/12/31 22:00:32 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/port/dynloader/ultrix4.c,v 1.23 2005/10/15 02:49:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -26,8 +26,8 @@ pg_dlopen(char *filename) void *handle; /* - * initializes the dynamic loader with the executable's pathname. - * (only needs to do this the first time pg_dlopen is called.) + * initializes the dynamic loader with the executable's pathname. (only + * needs to do this the first time pg_dlopen is called.) */ if (!dl_initialized) { @@ -43,8 +43,8 @@ pg_dlopen(char *filename) } /* - * open the file. We do the symbol resolution right away so that we - * will know if there are undefined symbols. (This is in fact the same + * open the file. We do the symbol resolution right away so that we will + * know if there are undefined symbols. (This is in fact the same * semantics as "ld -A". ie. you cannot have undefined symbols. */ if ((handle = dl_open(filename, DL_NOW)) == NULL) diff --git a/src/backend/port/dynloader/win32.c b/src/backend/port/dynloader/win32.c index c2c496a529..c2547f5a28 100644 --- a/src/backend/port/dynloader/win32.c +++ b/src/backend/port/dynloader/win32.c @@ -1,31 +1,32 @@ -/* $PostgreSQL: pgsql/src/backend/port/dynloader/win32.c,v 1.6 2005/08/12 21:23:10 momjian Exp $ */ +/* $PostgreSQL: pgsql/src/backend/port/dynloader/win32.c,v 1.7 2005/10/15 02:49:23 momjian Exp $ */ #include #include -char *dlerror(void); -int dlclose(void *handle); -void *dlsym(void *handle, const char *symbol); -void *dlopen(const char *path, int mode); +char *dlerror(void); +int dlclose(void *handle); +void *dlsym(void *handle, const char *symbol); +void *dlopen(const char *path, int mode); static char last_dyn_error[512]; -static void set_dl_error(void) +static void +set_dl_error(void) { - DWORD err = GetLastError(); + DWORD err = GetLastError(); if (FormatMessage(FORMAT_MESSAGE_IGNORE_INSERTS | - FORMAT_MESSAGE_FROM_SYSTEM, - NULL, - err, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - last_dyn_error, - sizeof(last_dyn_error)-1, - NULL) == 0) + FORMAT_MESSAGE_FROM_SYSTEM, + NULL, + err, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + last_dyn_error, + sizeof(last_dyn_error) - 1, + NULL) == 0) { - snprintf(last_dyn_error, sizeof(last_dyn_error)-1, - "unknown error %lu", err); - } + snprintf(last_dyn_error, sizeof(last_dyn_error) - 1, + "unknown error %lu", err); + } } char * @@ -52,9 +53,10 @@ dlclose(void *handle) void * dlsym(void *handle, const char *symbol) { - void *ptr; + void *ptr; + ptr = GetProcAddress((HMODULE) handle, symbol); - if (!ptr) + if (!ptr) { set_dl_error(); return NULL; @@ -66,15 +68,15 @@ dlsym(void *handle, const char *symbol) void * dlopen(const char *path, int mode) { - HMODULE h; - int prevmode; + HMODULE h; + int prevmode; /* Disable popup error messages when loading DLLs */ prevmode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); h = LoadLibrary(path); SetErrorMode(prevmode); - - if (!h) + + if (!h) { set_dl_error(); return NULL; diff --git a/src/backend/port/ipc_test.c b/src/backend/port/ipc_test.c index 3e2068f19a..89ebe1ded7 100644 --- a/src/backend/port/ipc_test.c +++ b/src/backend/port/ipc_test.c @@ -21,7 +21,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/port/ipc_test.c,v 1.17 2005/02/05 20:07:16 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/port/ipc_test.c,v 1.18 2005/10/15 02:49:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -75,7 +75,7 @@ proc_exit(int code) shmem_exit(code); while (--on_proc_exit_index >= 0) (*on_proc_exit_list[on_proc_exit_index].function) (code, - on_proc_exit_list[on_proc_exit_index].arg); + on_proc_exit_list[on_proc_exit_index].arg); exit(code); } @@ -84,7 +84,7 @@ shmem_exit(int code) { while (--on_shmem_exit_index >= 0) (*on_shmem_exit_list[on_shmem_exit_index].function) (code, - on_shmem_exit_list[on_shmem_exit_index].arg); + on_shmem_exit_list[on_shmem_exit_index].arg); on_shmem_exit_index = 0; } diff --git a/src/backend/port/posix_sema.c b/src/backend/port/posix_sema.c index d222901107..2024b3ebde 100644 --- a/src/backend/port/posix_sema.c +++ b/src/backend/port/posix_sema.c @@ -11,7 +11,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/port/posix_sema.c,v 1.13 2004/12/31 22:00:29 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/port/posix_sema.c,v 1.14 2005/10/15 02:49:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -93,14 +93,13 @@ PosixSemaphoreCreate(void) } /* - * Unlink the semaphore immediately, so it can't be accessed - * externally. This also ensures that it will go away if we crash. + * Unlink the semaphore immediately, so it can't be accessed externally. + * This also ensures that it will go away if we crash. */ sem_unlink(semname); return mySem; } - #else /* !USE_NAMED_POSIX_SEMAPHORES */ /* @@ -243,38 +242,36 @@ PGSemaphoreLock(PGSemaphore sema, bool interruptOK) int errStatus; /* - * Note: if errStatus is -1 and errno == EINTR then it means we - * returned from the operation prematurely because we were sent a - * signal. So we try and lock the semaphore again. + * Note: if errStatus is -1 and errno == EINTR then it means we returned + * from the operation prematurely because we were sent a signal. So we + * try and lock the semaphore again. * - * Each time around the loop, we check for a cancel/die interrupt. We - * assume that if such an interrupt comes in while we are waiting, it - * will cause the sem_wait() call to exit with errno == EINTR, so that - * we will be able to service the interrupt (if not in a critical - * section already). + * Each time around the loop, we check for a cancel/die interrupt. We assume + * that if such an interrupt comes in while we are waiting, it will cause + * the sem_wait() call to exit with errno == EINTR, so that we will be + * able to service the interrupt (if not in a critical section already). * * Once we acquire the lock, we do NOT check for an interrupt before - * returning. The caller needs to be able to record ownership of the - * lock before any interrupt can be accepted. + * returning. The caller needs to be able to record ownership of the lock + * before any interrupt can be accepted. * - * There is a window of a few instructions between CHECK_FOR_INTERRUPTS - * and entering the sem_wait() call. If a cancel/die interrupt occurs - * in that window, we would fail to notice it until after we acquire - * the lock (or get another interrupt to escape the sem_wait()). We - * can avoid this problem by temporarily setting ImmediateInterruptOK - * to true before we do CHECK_FOR_INTERRUPTS; then, a die() interrupt - * in this interval will execute directly. However, there is a huge - * pitfall: there is another window of a few instructions after the - * sem_wait() before we are able to reset ImmediateInterruptOK. If an - * interrupt occurs then, we'll lose control, which means that the - * lock has been acquired but our caller did not get a chance to - * record the fact. Therefore, we only set ImmediateInterruptOK if the - * caller tells us it's OK to do so, ie, the caller does not need to - * record acquiring the lock. (This is currently true for lockmanager - * locks, since the process that granted us the lock did all the - * necessary state updates. It's not true for Posix semaphores used to - * implement LW locks or emulate spinlocks --- but the wait time for - * such locks should not be very long, anyway.) + * There is a window of a few instructions between CHECK_FOR_INTERRUPTS and + * entering the sem_wait() call. If a cancel/die interrupt occurs in that + * window, we would fail to notice it until after we acquire the lock (or + * get another interrupt to escape the sem_wait()). We can avoid this + * problem by temporarily setting ImmediateInterruptOK to true before we + * do CHECK_FOR_INTERRUPTS; then, a die() interrupt in this interval will + * execute directly. However, there is a huge pitfall: there is another + * window of a few instructions after the sem_wait() before we are able to + * reset ImmediateInterruptOK. If an interrupt occurs then, we'll lose + * control, which means that the lock has been acquired but our caller did + * not get a chance to record the fact. Therefore, we only set + * ImmediateInterruptOK if the caller tells us it's OK to do so, ie, the + * caller does not need to record acquiring the lock. (This is currently + * true for lockmanager locks, since the process that granted us the lock + * did all the necessary state updates. It's not true for Posix semaphores + * used to implement LW locks or emulate spinlocks --- but the wait time + * for such locks should not be very long, anyway.) */ do { @@ -299,10 +296,10 @@ PGSemaphoreUnlock(PGSemaphore sema) int errStatus; /* - * Note: if errStatus is -1 and errno == EINTR then it means we - * returned from the operation prematurely because we were sent a - * signal. So we try and unlock the semaphore again. Not clear this - * can really happen, but might as well cope. + * Note: if errStatus is -1 and errno == EINTR then it means we returned + * from the operation prematurely because we were sent a signal. So we + * try and unlock the semaphore again. Not clear this can really happen, + * but might as well cope. */ do { @@ -324,9 +321,9 @@ PGSemaphoreTryLock(PGSemaphore sema) int errStatus; /* - * Note: if errStatus is -1 and errno == EINTR then it means we - * returned from the operation prematurely because we were sent a - * signal. So we try and lock the semaphore again. + * Note: if errStatus is -1 and errno == EINTR then it means we returned + * from the operation prematurely because we were sent a signal. So we + * try and lock the semaphore again. */ do { diff --git a/src/backend/port/qnx4/sem.c b/src/backend/port/qnx4/sem.c index 484a85b6fc..4a8d6a348f 100644 --- a/src/backend/port/qnx4/sem.c +++ b/src/backend/port/qnx4/sem.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/port/qnx4/sem.c,v 1.12 2003/11/29 19:51:54 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/port/qnx4/sem.c,v 1.13 2005/10/15 02:49:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -47,8 +47,7 @@ struct sem_set_info int nsems; sem_t sem[SEMMAX]; /* array of POSIX semaphores */ struct sem semV[SEMMAX]; /* array of System V semaphore structures */ - struct pending_ops pendingOps[SEMMAX]; /* array of pending - * operations */ + struct pending_ops pendingOps[SEMMAX]; /* array of pending operations */ }; struct sem_info @@ -189,7 +188,7 @@ semget(key_t key, int nsems, int semflg) fprintf(stderr, "Found a pre-existing shared memory block for the semaphore memory\n" "of a different size (%ld instead %ld). Make sure that all executables\n" - "are from the same release or remove the file \"/dev/shmem/%s\"\n" + "are from the same release or remove the file \"/dev/shmem/%s\"\n" "left by a previous version.\n", (long) statbuf.st_size, (long) sem_info_size, diff --git a/src/backend/port/qnx4/shm.c b/src/backend/port/qnx4/shm.c index fc2a70aa8f..7dde22773e 100644 --- a/src/backend/port/qnx4/shm.c +++ b/src/backend/port/qnx4/shm.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/port/qnx4/shm.c,v 1.9 2003/11/29 19:51:54 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/port/qnx4/shm.c,v 1.10 2005/10/15 02:49:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -200,8 +200,8 @@ shmctl(int shmid, int cmd, struct shmid_ds * buf) case IPC_STAT: /* - * we have to open it first. stat() does no prefix tracking -> - * the call would go to fsys instead of proc + * we have to open it first. stat() does no prefix tracking -> the + * call would go to fsys instead of proc */ keytoname(shmid, name); fd = shm_open(name, 0, MODE); @@ -210,8 +210,8 @@ shmctl(int shmid, int cmd, struct shmid_ds * buf) result = fstat(fd, &statbuf); /* - * if the file exists, subtract 2 from linkcount : one for - * our own open and one for the dir entry + * if the file exists, subtract 2 from linkcount : one for our + * own open and one for the dir entry */ if (!result) buf->shm_nattch = statbuf.st_nlink - 2; @@ -221,8 +221,8 @@ shmctl(int shmid, int cmd, struct shmid_ds * buf) else { /* - * if there's no entry for this key it doesn't matter the - * next shmget() would get a different shm anyway + * if there's no entry for this key it doesn't matter the next + * shmget() would get a different shm anyway */ buf->shm_nattch = 0; return 0; diff --git a/src/backend/port/sysv_sema.c b/src/backend/port/sysv_sema.c index 1d44a40033..d42e8c8768 100644 --- a/src/backend/port/sysv_sema.c +++ b/src/backend/port/sysv_sema.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/port/sysv_sema.c,v 1.16 2004/12/31 22:00:29 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/port/sysv_sema.c,v 1.17 2005/10/15 02:49:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -58,8 +58,7 @@ typedef int IpcSemaphoreId; /* semaphore ID returned by semget(2) */ #define PGSemaMagic 537 /* must be less than SEMVMX */ -static IpcSemaphoreId *mySemaSets; /* IDs of sema sets acquired so - * far */ +static IpcSemaphoreId *mySemaSets; /* IDs of sema sets acquired so far */ static int numSemaSets; /* number of sema sets acquired so far */ static int maxSemaSets; /* allocated size of mySemaSets array */ static IpcSemaphoreKey nextSemaKey; /* next key to try using */ @@ -97,11 +96,10 @@ InternalIpcSemaphoreCreate(IpcSemaphoreKey semKey, int numSems) if (semId < 0) { /* - * Fail quietly if error indicates a collision with existing set. - * One would expect EEXIST, given that we said IPC_EXCL, but - * perhaps we could get a permission violation instead? Also, - * EIDRM might occur if an old set is slated for destruction but - * not gone yet. + * Fail quietly if error indicates a collision with existing set. One + * would expect EEXIST, given that we said IPC_EXCL, but perhaps we + * could get a permission violation instead? Also, EIDRM might occur + * if an old set is slated for destruction but not gone yet. */ if (errno == EEXIST || errno == EACCES #ifdef EIDRM @@ -120,13 +118,13 @@ InternalIpcSemaphoreCreate(IpcSemaphoreKey semKey, int numSems) IPC_CREAT | IPC_EXCL | IPCProtection), (errno == ENOSPC) ? errhint("This error does *not* mean that you have run out of disk space.\n" - "It occurs when either the system limit for the maximum number of " - "semaphore sets (SEMMNI), or the system wide maximum number of " - "semaphores (SEMMNS), would be exceeded. You need to raise the " - "respective kernel parameter. Alternatively, reduce PostgreSQL's " - "consumption of semaphores by reducing its max_connections parameter " + "It occurs when either the system limit for the maximum number of " + "semaphore sets (SEMMNI), or the system wide maximum number of " + "semaphores (SEMMNS), would be exceeded. You need to raise the " + "respective kernel parameter. Alternatively, reduce PostgreSQL's " + "consumption of semaphores by reducing its max_connections parameter " "(currently %d).\n" - "The PostgreSQL documentation contains more information about " + "The PostgreSQL documentation contains more information about " "configuring your system for PostgreSQL.", MaxBackends) : 0)); } @@ -149,7 +147,7 @@ IpcSemaphoreInitialize(IpcSemaphoreId semId, int semNum, int value) semId, semNum, value), (errno == ERANGE) ? errhint("You possibly need to raise your kernel's SEMVMX value to be at least " - "%d. Look into the PostgreSQL documentation for details.", + "%d. Look into the PostgreSQL documentation for details.", value) : 0)); } @@ -224,8 +222,8 @@ IpcSemaphoreCreate(int numSems) continue; /* sema belongs to a non-Postgres app */ /* - * If the creator PID is my own PID or does not belong to any - * extant process, it's safe to zap it. + * If the creator PID is my own PID or does not belong to any extant + * process, it's safe to zap it. */ creatorPID = IpcSemaphoreGetLastPID(semId, numSems); if (creatorPID <= 0) @@ -237,11 +235,10 @@ IpcSemaphoreCreate(int numSems) } /* - * The sema set appears to be from a dead Postgres process, or - * from a previous cycle of life in this same process. Zap it, if - * possible. This probably shouldn't fail, but if it does, assume - * the sema set belongs to someone else after all, and continue - * quietly. + * The sema set appears to be from a dead Postgres process, or from a + * previous cycle of life in this same process. Zap it, if possible. + * This probably shouldn't fail, but if it does, assume the sema set + * belongs to someone else after all, and continue quietly. */ semun.val = 0; /* unused, but keep compiler quiet */ if (semctl(semId, 0, IPC_RMID, semun) < 0) @@ -255,17 +252,17 @@ IpcSemaphoreCreate(int numSems) break; /* successful create */ /* - * Can only get here if some other process managed to create the - * same sema key before we did. Let him have that one, loop - * around to try next key. + * Can only get here if some other process managed to create the same + * sema key before we did. Let him have that one, loop around to try + * next key. */ } /* - * OK, we created a new sema set. Mark it as created by this process. - * We do this by setting the spare semaphore to PGSemaMagic-1 and then - * incrementing it with semop(). That leaves it with value - * PGSemaMagic and sempid referencing this process. + * OK, we created a new sema set. Mark it as created by this process. We + * do this by setting the spare semaphore to PGSemaMagic-1 and then + * incrementing it with semop(). That leaves it with value PGSemaMagic + * and sempid referencing this process. */ IpcSemaphoreInitialize(semId, numSems, PGSemaMagic - 1); mysema.semId = semId; @@ -303,8 +300,7 @@ PGReserveSemaphores(int maxSemas, int port) elog(PANIC, "out of memory"); numSemaSets = 0; nextSemaKey = port * 1000; - nextSemaNumber = SEMAS_PER_SET; /* force sema set alloc on 1st - * call */ + nextSemaNumber = SEMAS_PER_SET; /* force sema set alloc on 1st call */ on_shmem_exit(ReleaseSemaphores, 0); } @@ -378,38 +374,36 @@ PGSemaphoreLock(PGSemaphore sema, bool interruptOK) sops.sem_num = sema->semNum; /* - * Note: if errStatus is -1 and errno == EINTR then it means we - * returned from the operation prematurely because we were sent a - * signal. So we try and lock the semaphore again. + * Note: if errStatus is -1 and errno == EINTR then it means we returned + * from the operation prematurely because we were sent a signal. So we + * try and lock the semaphore again. * - * Each time around the loop, we check for a cancel/die interrupt. We - * assume that if such an interrupt comes in while we are waiting, it - * will cause the semop() call to exit with errno == EINTR, so that we - * will be able to service the interrupt (if not in a critical section - * already). + * Each time around the loop, we check for a cancel/die interrupt. We assume + * that if such an interrupt comes in while we are waiting, it will cause + * the semop() call to exit with errno == EINTR, so that we will be able + * to service the interrupt (if not in a critical section already). * * Once we acquire the lock, we do NOT check for an interrupt before - * returning. The caller needs to be able to record ownership of the - * lock before any interrupt can be accepted. + * returning. The caller needs to be able to record ownership of the lock + * before any interrupt can be accepted. * - * There is a window of a few instructions between CHECK_FOR_INTERRUPTS - * and entering the semop() call. If a cancel/die interrupt occurs in - * that window, we would fail to notice it until after we acquire the - * lock (or get another interrupt to escape the semop()). We can - * avoid this problem by temporarily setting ImmediateInterruptOK to - * true before we do CHECK_FOR_INTERRUPTS; then, a die() interrupt in - * this interval will execute directly. However, there is a huge - * pitfall: there is another window of a few instructions after the - * semop() before we are able to reset ImmediateInterruptOK. If an - * interrupt occurs then, we'll lose control, which means that the - * lock has been acquired but our caller did not get a chance to - * record the fact. Therefore, we only set ImmediateInterruptOK if the - * caller tells us it's OK to do so, ie, the caller does not need to - * record acquiring the lock. (This is currently true for lockmanager - * locks, since the process that granted us the lock did all the - * necessary state updates. It's not true for SysV semaphores used to - * implement LW locks or emulate spinlocks --- but the wait time for - * such locks should not be very long, anyway.) + * There is a window of a few instructions between CHECK_FOR_INTERRUPTS and + * entering the semop() call. If a cancel/die interrupt occurs in that + * window, we would fail to notice it until after we acquire the lock (or + * get another interrupt to escape the semop()). We can avoid this + * problem by temporarily setting ImmediateInterruptOK to true before we + * do CHECK_FOR_INTERRUPTS; then, a die() interrupt in this interval will + * execute directly. However, there is a huge pitfall: there is another + * window of a few instructions after the semop() before we are able to + * reset ImmediateInterruptOK. If an interrupt occurs then, we'll lose + * control, which means that the lock has been acquired but our caller did + * not get a chance to record the fact. Therefore, we only set + * ImmediateInterruptOK if the caller tells us it's OK to do so, ie, the + * caller does not need to record acquiring the lock. (This is currently + * true for lockmanager locks, since the process that granted us the lock + * did all the necessary state updates. It's not true for SysV semaphores + * used to implement LW locks or emulate spinlocks --- but the wait time + * for such locks should not be very long, anyway.) */ do { @@ -439,10 +433,10 @@ PGSemaphoreUnlock(PGSemaphore sema) sops.sem_num = sema->semNum; /* - * Note: if errStatus is -1 and errno == EINTR then it means we - * returned from the operation prematurely because we were sent a - * signal. So we try and unlock the semaphore again. Not clear this - * can really happen, but might as well cope. + * Note: if errStatus is -1 and errno == EINTR then it means we returned + * from the operation prematurely because we were sent a signal. So we + * try and unlock the semaphore again. Not clear this can really happen, + * but might as well cope. */ do { @@ -469,9 +463,9 @@ PGSemaphoreTryLock(PGSemaphore sema) sops.sem_num = sema->semNum; /* - * Note: if errStatus is -1 and errno == EINTR then it means we - * returned from the operation prematurely because we were sent a - * signal. So we try and lock the semaphore again. + * Note: if errStatus is -1 and errno == EINTR then it means we returned + * from the operation prematurely because we were sent a signal. So we + * try and lock the semaphore again. */ do { diff --git a/src/backend/port/sysv_shmem.c b/src/backend/port/sysv_shmem.c index 23b945f085..3092ca2a37 100644 --- a/src/backend/port/sysv_shmem.c +++ b/src/backend/port/sysv_shmem.c @@ -10,7 +10,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/port/sysv_shmem.c,v 1.43 2005/08/20 23:26:13 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/port/sysv_shmem.c,v 1.44 2005/10/15 02:49:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -81,11 +81,10 @@ InternalIpcMemoryCreate(IpcMemoryKey memKey, Size size) if (shmid < 0) { /* - * Fail quietly if error indicates a collision with existing - * segment. One would expect EEXIST, given that we said IPC_EXCL, - * but perhaps we could get a permission violation instead? Also, - * EIDRM might occur if an old seg is slated for destruction but - * not gone yet. + * Fail quietly if error indicates a collision with existing segment. + * One would expect EEXIST, given that we said IPC_EXCL, but perhaps + * we could get a permission violation instead? Also, EIDRM might + * occur if an old seg is slated for destruction but not gone yet. */ if (errno == EEXIST || errno == EACCES #ifdef EIDRM @@ -99,41 +98,41 @@ InternalIpcMemoryCreate(IpcMemoryKey memKey, Size size) */ ereport(FATAL, (errmsg("could not create shared memory segment: %m"), - errdetail("Failed system call was shmget(key=%lu, size=%lu, 0%o).", - (unsigned long) memKey, (unsigned long) size, - IPC_CREAT | IPC_EXCL | IPCProtection), + errdetail("Failed system call was shmget(key=%lu, size=%lu, 0%o).", + (unsigned long) memKey, (unsigned long) size, + IPC_CREAT | IPC_EXCL | IPCProtection), (errno == EINVAL) ? errhint("This error usually means that PostgreSQL's request for a shared memory " - "segment exceeded your kernel's SHMMAX parameter. You can either " + "segment exceeded your kernel's SHMMAX parameter. You can either " "reduce the request size or reconfigure the kernel with larger SHMMAX. " - "To reduce the request size (currently %lu bytes), reduce " - "PostgreSQL's shared_buffers parameter (currently %d) and/or " + "To reduce the request size (currently %lu bytes), reduce " + "PostgreSQL's shared_buffers parameter (currently %d) and/or " "its max_connections parameter (currently %d).\n" "If the request size is already small, it's possible that it is less than " "your kernel's SHMMIN parameter, in which case raising the request size or " "reconfiguring SHMMIN is called for.\n" - "The PostgreSQL documentation contains more information about shared " + "The PostgreSQL documentation contains more information about shared " "memory configuration.", (unsigned long) size, NBuffers, MaxBackends) : 0, (errno == ENOMEM) ? errhint("This error usually means that PostgreSQL's request for a shared " - "memory segment exceeded available memory or swap space. " - "To reduce the request size (currently %lu bytes), reduce " - "PostgreSQL's shared_buffers parameter (currently %d) and/or " + "memory segment exceeded available memory or swap space. " + "To reduce the request size (currently %lu bytes), reduce " + "PostgreSQL's shared_buffers parameter (currently %d) and/or " "its max_connections parameter (currently %d).\n" - "The PostgreSQL documentation contains more information about shared " + "The PostgreSQL documentation contains more information about shared " "memory configuration.", (unsigned long) size, NBuffers, MaxBackends) : 0, (errno == ENOSPC) ? errhint("This error does *not* mean that you have run out of disk space. " "It occurs either if all available shared memory IDs have been taken, " "in which case you need to raise the SHMMNI parameter in your kernel, " - "or because the system's overall limit for shared memory has been " - "reached. If you cannot increase the shared memory limit, " - "reduce PostgreSQL's shared memory request (currently %lu bytes), " - "by reducing its shared_buffers parameter (currently %d) and/or " + "or because the system's overall limit for shared memory has been " + "reached. If you cannot increase the shared memory limit, " + "reduce PostgreSQL's shared memory request (currently %lu bytes), " + "by reducing its shared_buffers parameter (currently %d) and/or " "its max_connections parameter (currently %d).\n" - "The PostgreSQL documentation contains more information about shared " + "The PostgreSQL documentation contains more information about shared " "memory configuration.", (unsigned long) size, NBuffers, MaxBackends) : 0)); } @@ -187,7 +186,7 @@ IpcMemoryDelete(int status, Datum shmId) * Is a previously-existing shmem segment still existing and in use? * * The point of this exercise is to detect the case where a prior postmaster - * crashed, but it left child backends that are still running. Therefore + * crashed, but it left child backends that are still running. Therefore * we only care about shmem segments that are associated with the intended * DataDir. This is an important consideration since accidental matches of * shmem segment IDs are reasonably common. @@ -197,35 +196,38 @@ PGSharedMemoryIsInUse(unsigned long id1, unsigned long id2) { IpcMemoryId shmId = (IpcMemoryId) id2; struct shmid_ds shmStat; + #ifndef WIN32 struct stat statbuf; PGShmemHeader *hdr; #endif /* - * We detect whether a shared memory segment is in use by seeing - * whether it (a) exists and (b) has any processes are attached to it. + * We detect whether a shared memory segment is in use by seeing whether + * it (a) exists and (b) has any processes are attached to it. */ if (shmctl(shmId, IPC_STAT, &shmStat) < 0) { /* * EINVAL actually has multiple possible causes documented in the - * shmctl man page, but we assume it must mean the segment no - * longer exists. + * shmctl man page, but we assume it must mean the segment no longer + * exists. */ if (errno == EINVAL) return false; + /* - * EACCES implies that the segment belongs to some other userid, - * which means it is not a Postgres shmem segment (or at least, - * not one that is relevant to our data directory). + * EACCES implies that the segment belongs to some other userid, which + * means it is not a Postgres shmem segment (or at least, not one that + * is relevant to our data directory). */ if (errno == EACCES) return false; + /* - * Otherwise, we had better assume that the segment is in use. - * The only likely case is EIDRM, which implies that the segment - * has been IPC_RMID'd but there are still processes attached to it. + * Otherwise, we had better assume that the segment is in use. The + * only likely case is EIDRM, which implies that the segment has been + * IPC_RMID'd but there are still processes attached to it. */ return true; } @@ -295,6 +297,7 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port) void *memAddress; PGShmemHeader *hdr; IpcMemoryId shmid; + #ifndef WIN32 struct stat statbuf; #endif @@ -338,11 +341,10 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port) } /* - * The segment appears to be from a dead Postgres process, or from - * a previous cycle of life in this same process. Zap it, if - * possible. This probably shouldn't fail, but if it does, assume - * the segment belongs to someone else after all, and continue - * quietly. + * The segment appears to be from a dead Postgres process, or from a + * previous cycle of life in this same process. Zap it, if possible. + * This probably shouldn't fail, but if it does, assume the segment + * belongs to someone else after all, and continue quietly. */ shmdt(memAddress); if (shmctl(shmid, IPC_RMID, NULL) < 0) @@ -356,17 +358,16 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port) break; /* successful create and attach */ /* - * Can only get here if some other process managed to create the - * same shmem key before we did. Let him have that one, loop - * around to try next key. + * Can only get here if some other process managed to create the same + * shmem key before we did. Let him have that one, loop around to try + * next key. */ } /* - * OK, we created a new segment. Mark it as created by this process. - * The order of assignments here is critical so that another Postgres - * process can't see the header as valid but belonging to an invalid - * PID! + * OK, we created a new segment. Mark it as created by this process. The + * order of assignments here is critical so that another Postgres process + * can't see the header as valid but belonging to an invalid PID! */ hdr = (PGShmemHeader *) memAddress; hdr->creatorPID = getpid(); @@ -401,7 +402,7 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port) /* * PGSharedMemoryReAttach * - * Re-attach to an already existing shared memory segment. In the non + * Re-attach to an already existing shared memory segment. In the non * EXEC_BACKEND case this is not used, because postmaster children inherit * the shared memory segment attachment via fork(). * @@ -436,8 +437,7 @@ PGSharedMemoryReAttach(void) UsedShmemSegAddr = hdr; /* probably redundant */ } - -#endif /* EXEC_BACKEND */ +#endif /* EXEC_BACKEND */ /* * PGSharedMemoryDetach diff --git a/src/backend/port/win32/error.c b/src/backend/port/win32/error.c index c7f0a24f10..eb660a3ef8 100644 --- a/src/backend/port/win32/error.c +++ b/src/backend/port/win32/error.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/port/win32/error.c,v 1.5 2005/10/07 16:34:48 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/port/win32/error.c,v 1.6 2005/10/15 02:49:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -178,7 +178,7 @@ _dosmaperr(unsigned long e) errno = doserrors[i].doserr; ereport(DEBUG5, (errmsg_internal("mapped win32 error code %lu to %d", - e, errno))); + e, errno))); return; } } diff --git a/src/backend/port/win32/security.c b/src/backend/port/win32/security.c index 9283f3f694..f610b89361 100644 --- a/src/backend/port/win32/security.c +++ b/src/backend/port/win32/security.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/port/win32/security.c,v 1.8 2004/12/31 22:00:37 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/port/win32/security.c,v 1.9 2005/10/15 02:49:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -15,8 +15,8 @@ static BOOL pgwin32_get_dynamic_tokeninfo(HANDLE token, - TOKEN_INFORMATION_CLASS class, char **InfoBuffer, - char *errbuf, int errsize); + TOKEN_INFORMATION_CLASS class, char **InfoBuffer, + char *errbuf, int errsize); /* * Returns nonzero if the current user has administrative privileges, @@ -30,7 +30,7 @@ pgwin32_is_admin(void) { HANDLE AccessToken; char *InfoBuffer = NULL; - char errbuf[256]; + char errbuf[256]; PTOKEN_GROUPS Groups; PSID AdministratorsSid; PSID PowerUsersSid; @@ -57,7 +57,7 @@ pgwin32_is_admin(void) CloseHandle(AccessToken); if (!AllocateAndInitializeSid(&NtAuthority, 2, - SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, + SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &AdministratorsSid)) { write_stderr("could not get SID for Administrators group: error code %d\n", @@ -66,7 +66,7 @@ pgwin32_is_admin(void) } if (!AllocateAndInitializeSid(&NtAuthority, 2, - SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_POWER_USERS, 0, 0, 0, 0, 0, + SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_POWER_USERS, 0, 0, 0, 0, 0, 0, &PowerUsersSid)) { write_stderr("could not get SID for PowerUsers group: error code %d\n", @@ -114,8 +114,8 @@ pgwin32_is_service(void) { static int _is_service = -1; HANDLE AccessToken; - char *InfoBuffer = NULL; - char errbuf[256]; + char *InfoBuffer = NULL; + char errbuf[256]; PTOKEN_GROUPS Groups; PTOKEN_USER User; PSID ServiceSid; @@ -138,14 +138,14 @@ pgwin32_is_service(void) if (!pgwin32_get_dynamic_tokeninfo(AccessToken, TokenUser, &InfoBuffer, errbuf, sizeof(errbuf))) { - fprintf(stderr,errbuf); + fprintf(stderr, errbuf); return -1; } User = (PTOKEN_USER) InfoBuffer; if (!AllocateAndInitializeSid(&NtAuthority, 1, - SECURITY_LOCAL_SYSTEM_RID, 0, 0, 0, 0, 0, 0, 0, + SECURITY_LOCAL_SYSTEM_RID, 0, 0, 0, 0, 0, 0, 0, &LocalSystemSid)) { fprintf(stderr, "could not get SID for local system account\n"); @@ -169,14 +169,14 @@ pgwin32_is_service(void) if (!pgwin32_get_dynamic_tokeninfo(AccessToken, TokenGroups, &InfoBuffer, errbuf, sizeof(errbuf))) { - fprintf(stderr,errbuf); + fprintf(stderr, errbuf); return -1; } Groups = (PTOKEN_GROUPS) InfoBuffer; if (!AllocateAndInitializeSid(&NtAuthority, 1, - SECURITY_SERVICE_RID, 0, 0, 0, 0, 0, 0, 0, + SECURITY_SERVICE_RID, 0, 0, 0, 0, 0, 0, 0, &ServiceSid)) { fprintf(stderr, "could not get SID for service group\n"); @@ -213,17 +213,17 @@ static BOOL pgwin32_get_dynamic_tokeninfo(HANDLE token, TOKEN_INFORMATION_CLASS class, char **InfoBuffer, char *errbuf, int errsize) { - DWORD InfoBufferSize; + DWORD InfoBufferSize; if (GetTokenInformation(token, class, NULL, 0, &InfoBufferSize)) { - snprintf(errbuf,errsize,"could not get token information: got zero size\n"); + snprintf(errbuf, errsize, "could not get token information: got zero size\n"); return FALSE; } if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) { - snprintf(errbuf,errsize,"could not get token information: error code %d\n", + snprintf(errbuf, errsize, "could not get token information: error code %d\n", (int) GetLastError()); return FALSE; } @@ -231,18 +231,18 @@ pgwin32_get_dynamic_tokeninfo(HANDLE token, TOKEN_INFORMATION_CLASS class, *InfoBuffer = malloc(InfoBufferSize); if (*InfoBuffer == NULL) { - snprintf(errbuf,errsize,"could not allocate %d bytes for token information\n", + snprintf(errbuf, errsize, "could not allocate %d bytes for token information\n", (int) InfoBufferSize); return FALSE; } - if (!GetTokenInformation(token, class, *InfoBuffer, + if (!GetTokenInformation(token, class, *InfoBuffer, InfoBufferSize, &InfoBufferSize)) { - snprintf(errbuf,errsize,"could not get token information: error code %d\n", + snprintf(errbuf, errsize, "could not get token information: error code %d\n", (int) GetLastError()); return FALSE; } - + return TRUE; } diff --git a/src/backend/port/win32/sema.c b/src/backend/port/win32/sema.c index 7942e696e3..a9d62f057f 100644 --- a/src/backend/port/win32/sema.c +++ b/src/backend/port/win32/sema.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/port/win32/sema.c,v 1.10 2004/12/31 22:00:37 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/port/win32/sema.c,v 1.11 2005/10/15 02:49:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -216,8 +216,8 @@ semop(int semId, struct sembuf * sops, int nsops) if (nsops != 1) { /* - * Not supported (we return on 1st success, and don't cancel - * earlier ops) + * Not supported (we return on 1st success, and don't cancel earlier + * ops) */ errno = E2BIG; return -1; diff --git a/src/backend/port/win32/shmem.c b/src/backend/port/win32/shmem.c index 49f5696ceb..dbb9cdc0f1 100644 --- a/src/backend/port/win32/shmem.c +++ b/src/backend/port/win32/shmem.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/port/win32/shmem.c,v 1.10 2004/12/31 22:00:37 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/port/win32/shmem.c,v 1.11 2005/10/15 02:49:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -35,7 +35,7 @@ shmat(int memId, void *shmaddr, int flag) /* TODO -- shmat needs to count # attached to shared mem */ void *lpmem = MapViewOfFileEx((HANDLE) memId, FILE_MAP_WRITE | FILE_MAP_READ, - 0, 0, /* (DWORD)pshmdsc->segsize */ 0 /* s_segsize */ , shmaddr); + 0, 0, /* (DWORD)pshmdsc->segsize */ 0 /* s_segsize */ , shmaddr); if (lpmem == NULL) { diff --git a/src/backend/port/win32/signal.c b/src/backend/port/win32/signal.c index e0c9dba16f..a32427f28f 100644 --- a/src/backend/port/win32/signal.c +++ b/src/backend/port/win32/signal.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/port/win32/signal.c,v 1.11 2004/12/31 22:00:37 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/port/win32/signal.c,v 1.12 2005/10/15 02:49:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -26,7 +26,7 @@ static pqsigfunc pg_signal_defaults[PG_SIGNAL_COUNT]; static int pg_signal_mask; DLLIMPORT HANDLE pgwin32_signal_event; -HANDLE pgwin32_initial_signal_pipe = INVALID_HANDLE_VALUE; +HANDLE pgwin32_initial_signal_pipe = INVALID_HANDLE_VALUE; /* Signal handling thread function */ @@ -73,12 +73,12 @@ pgwin32_signal_initialize(void) signal_thread_handle = CreateThread(NULL, 0, pg_signal_thread, NULL, 0, NULL); if (signal_thread_handle == NULL) ereport(FATAL, - (errmsg_internal("failed to create signal handler thread"))); + (errmsg_internal("failed to create signal handler thread"))); /* Create console control handle to pick up Ctrl-C etc */ if (!SetConsoleCtrlHandler(pg_console_handler, TRUE)) ereport(FATAL, - (errmsg_internal("failed to set console control handler"))); + (errmsg_internal("failed to set console control handler"))); } @@ -112,9 +112,9 @@ pgwin32_dispatch_queued_signals(void) LeaveCriticalSection(&pg_signal_crit_sec); sig(i); EnterCriticalSection(&pg_signal_crit_sec); - break; /* Restart outer loop, in case signal mask - * or queue has been modified inside - * signal handler */ + break; /* Restart outer loop, in case signal mask or + * queue has been modified inside signal + * handler */ } } } @@ -133,8 +133,8 @@ pqsigsetmask(int mask) pg_signal_mask = mask; /* - * Dispatch any signals queued up right away, in case we have - * unblocked one or more signals previously queued + * Dispatch any signals queued up right away, in case we have unblocked + * one or more signals previously queued */ pgwin32_dispatch_queued_signals(); @@ -165,7 +165,7 @@ pgwin32_create_signal_listener(pid_t pid) wsprintf(pipename, "\\\\.\\pipe\\pgsignal_%d", (int) pid); pipe = CreateNamedPipe(pipename, PIPE_ACCESS_DUPLEX, - PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, + PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, PIPE_UNLIMITED_INSTANCES, 16, 16, 1000, NULL); if (pipe == INVALID_HANDLE_VALUE) @@ -218,8 +218,8 @@ pg_signal_dispatch_thread(LPVOID param) CloseHandle(pipe); return 0; } - WriteFile(pipe, &sigNum, 1, &bytes, NULL); /* Don't care if it works - * or not.. */ + WriteFile(pipe, &sigNum, 1, &bytes, NULL); /* Don't care if it works or + * not.. */ FlushFileBuffers(pipe); DisconnectNamedPipe(pipe); CloseHandle(pipe); @@ -233,7 +233,7 @@ static DWORD WINAPI pg_signal_thread(LPVOID param) { char pipename[128]; - HANDLE pipe = pgwin32_initial_signal_pipe; + HANDLE pipe = pgwin32_initial_signal_pipe; wsprintf(pipename, "\\\\.\\pipe\\pgsignal_%d", GetCurrentProcessId()); @@ -245,8 +245,8 @@ pg_signal_thread(LPVOID param) if (pipe == INVALID_HANDLE_VALUE) { pipe = CreateNamedPipe(pipename, PIPE_ACCESS_DUPLEX, - PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, - PIPE_UNLIMITED_INSTANCES, 16, 16, 1000, NULL); + PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, + PIPE_UNLIMITED_INSTANCES, 16, 16, 1000, NULL); if (pipe == INVALID_HANDLE_VALUE) { @@ -260,7 +260,7 @@ pg_signal_thread(LPVOID param) if (fConnected) { hThread = CreateThread(NULL, 0, - (LPTHREAD_START_ROUTINE) pg_signal_dispatch_thread, + (LPTHREAD_START_ROUTINE) pg_signal_dispatch_thread, (LPVOID) pipe, 0, NULL); if (hThread == INVALID_HANDLE_VALUE) write_stderr("could not create signal dispatch thread: error code %d\n", diff --git a/src/backend/port/win32/socket.c b/src/backend/port/win32/socket.c index e65197e4d9..808977a237 100644 --- a/src/backend/port/win32/socket.c +++ b/src/backend/port/win32/socket.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/port/win32/socket.c,v 1.8 2004/12/31 22:00:37 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/port/win32/socket.c,v 1.9 2005/10/15 02:49:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -178,8 +178,8 @@ pgwin32_accept(SOCKET s, struct sockaddr * addr, int *addrlen) SOCKET rs; /* - * Poll for signals, but don't return with EINTR, since we don't - * handle that in pqcomm.c + * Poll for signals, but don't return with EINTR, since we don't handle + * that in pqcomm.c */ pgwin32_poll_signals(); @@ -351,8 +351,8 @@ pgwin32_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, c if (WSAGetLastError() != WSAEWOULDBLOCK) /* - * Not completed, and not just "would block", so an - * error occured + * Not completed, and not just "would block", so an error + * occured */ FD_SET(writefds->fd_array[i], &outwritefds); } @@ -423,8 +423,8 @@ pgwin32_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, c if (r != WAIT_TIMEOUT && r != WAIT_IO_COMPLETION && r != (WAIT_OBJECT_0 + numevents)) { /* - * We scan all events, even those not signalled, in case more than - * one event has been tagged but Wait.. can only return one. + * We scan all events, even those not signalled, in case more than one + * event has been tagged but Wait.. can only return one. */ WSANETWORKEVENTS resEvents; diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c index 9aeecec7a6..1081cf83e9 100644 --- a/src/backend/postmaster/autovacuum.c +++ b/src/backend/postmaster/autovacuum.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.4 2005/08/15 16:25:17 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.5 2005/10/15 02:49:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -69,17 +69,17 @@ static time_t last_autovac_start_time = 0; static time_t last_autovac_stop_time = 0; /* Memory context for long-lived data */ -static MemoryContext AutovacMemCxt; +static MemoryContext AutovacMemCxt; /* struct to keep list of candidate databases for vacuum */ typedef struct autovac_dbase { - Oid oid; - char *name; - TransactionId frozenxid; - TransactionId vacuumxid; + Oid oid; + char *name; + TransactionId frozenxid; + TransactionId vacuumxid; PgStat_StatDBEntry *entry; - int32 age; + int32 age; } autovac_dbase; /* struct to keep track of tables to vacuum and/or analyze */ @@ -102,12 +102,12 @@ static void process_whole_db(void); static void do_autovacuum(PgStat_StatDBEntry *dbentry); static List *autovac_get_database_list(void); static void test_rel_for_autovac(Oid relid, PgStat_StatTabEntry *tabentry, - Form_pg_class classForm, - Form_pg_autovacuum avForm, - List **vacuum_tables, - List **toast_table_ids); + Form_pg_class classForm, + Form_pg_autovacuum avForm, + List **vacuum_tables, + List **toast_table_ids); static void autovacuum_do_vac_analyze(List *relids, bool dovacuum, - bool doanalyze, bool freeze); + bool doanalyze, bool freeze); /* @@ -126,16 +126,16 @@ autovac_start(void) return 0; /* - * Do nothing if too soon since last autovacuum exit. This limits - * how often the daemon runs. Since the time per iteration can be - * quite variable, it seems more useful to measure/control the time - * since last subprocess exit than since last subprocess launch. + * Do nothing if too soon since last autovacuum exit. This limits how + * often the daemon runs. Since the time per iteration can be quite + * variable, it seems more useful to measure/control the time since last + * subprocess exit than since last subprocess launch. * - * However, we *also* check the time since last subprocess launch; - * this prevents thrashing under fork-failure conditions. + * However, we *also* check the time since last subprocess launch; this + * prevents thrashing under fork-failure conditions. * - * Note that since we will be re-called from the postmaster main loop, - * we will get another chance later if we do nothing now. + * Note that since we will be re-called from the postmaster main loop, we + * will get another chance later if we do nothing now. * * XXX todo: implement sleep scale factor that existed in contrib code. */ @@ -151,14 +151,14 @@ autovac_start(void) last_autovac_start_time = curtime; #ifdef EXEC_BACKEND - switch((AutoVacPID = autovac_forkexec())) + switch ((AutoVacPID = autovac_forkexec())) #else - switch((AutoVacPID = fork_process())) + switch ((AutoVacPID = fork_process())) #endif { case -1: ereport(LOG, - (errmsg("could not fork autovacuum process: %m"))); + (errmsg("could not fork autovacuum process: %m"))); return 0; #ifndef EXEC_BACKEND @@ -201,14 +201,14 @@ autovac_forkexec(void) av[ac++] = "postgres"; av[ac++] = "-forkautovac"; - av[ac++] = NULL; /* filled in by postmaster_forkexec */ + av[ac++] = NULL; /* filled in by postmaster_forkexec */ av[ac] = NULL; Assert(ac < lengthof(av)); return postmaster_forkexec(ac, av); } -#endif /* EXEC_BACKEND */ +#endif /* EXEC_BACKEND */ /* * AutoVacMain @@ -216,12 +216,12 @@ autovac_forkexec(void) NON_EXEC_STATIC void AutoVacMain(int argc, char *argv[]) { - ListCell *cell; - List *dblist; - TransactionId nextXid; - autovac_dbase *db; - bool whole_db; - sigjmp_buf local_sigjmp_buf; + ListCell *cell; + List *dblist; + TransactionId nextXid; + autovac_dbase *db; + bool whole_db; + sigjmp_buf local_sigjmp_buf; /* we are a postmaster subprocess now */ IsUnderPostmaster = true; @@ -240,18 +240,18 @@ AutoVacMain(int argc, char *argv[]) SetProcessingMode(InitProcessing); /* - * Set up signal handlers. We operate on databases much like a - * regular backend, so we use the same signal handling. See - * equivalent code in tcop/postgres.c. + * Set up signal handlers. We operate on databases much like a regular + * backend, so we use the same signal handling. See equivalent code in + * tcop/postgres.c. * - * Currently, we don't pay attention to postgresql.conf changes - * that happen during a single daemon iteration, so we can ignore - * SIGHUP. + * Currently, we don't pay attention to postgresql.conf changes that happen + * during a single daemon iteration, so we can ignore SIGHUP. */ pqsignal(SIGHUP, SIG_IGN); + /* - * Presently, SIGINT will lead to autovacuum shutdown, because that's - * how we handle ereport(ERROR). It could be improved however. + * Presently, SIGINT will lead to autovacuum shutdown, because that's how + * we handle ereport(ERROR). It could be improved however. */ pqsignal(SIGINT, StatementCancelHandler); pqsignal(SIGTERM, die); @@ -282,9 +282,9 @@ AutoVacMain(int argc, char *argv[]) EmitErrorReport(); /* - * We can now go away. Note that because we'll call InitProcess, - * a callback will be registered to do ProcKill, which will clean - * up necessary state. + * We can now go away. Note that because we'll call InitProcess, a + * callback will be registered to do ProcKill, which will clean up + * necessary state. */ proc_exit(0); } @@ -298,9 +298,8 @@ AutoVacMain(int argc, char *argv[]) dblist = autovac_get_database_list(); /* - * Get the next Xid that was current as of the last checkpoint. - * We need it to determine whether databases are about to need - * database-wide vacuums. + * Get the next Xid that was current as of the last checkpoint. We need it + * to determine whether databases are about to need database-wide vacuums. */ nextXid = GetRecentNextXid(); @@ -309,37 +308,36 @@ AutoVacMain(int argc, char *argv[]) * recently auto-vacuumed, or one that needs database-wide vacuum (to * prevent Xid wraparound-related data loss). * - * Note that a database with no stats entry is not considered, except - * for Xid wraparound purposes. The theory is that if no one has ever - * connected to it since the stats were last initialized, it doesn't - * need vacuuming. + * Note that a database with no stats entry is not considered, except for Xid + * wraparound purposes. The theory is that if no one has ever connected + * to it since the stats were last initialized, it doesn't need vacuuming. * * XXX This could be improved if we had more info about whether it needs * vacuuming before connecting to it. Perhaps look through the pgstats * data for the database's tables? One idea is to keep track of the * number of new and dead tuples per database in pgstats. However it - * isn't clear how to construct a metric that measures that and not - * cause starvation for less busy databases. + * isn't clear how to construct a metric that measures that and not cause + * starvation for less busy databases. */ db = NULL; whole_db = false; foreach(cell, dblist) { - autovac_dbase *tmp = lfirst(cell); - bool this_whole_db; - int32 freeze_age, - vacuum_age; + autovac_dbase *tmp = lfirst(cell); + bool this_whole_db; + int32 freeze_age, + vacuum_age; /* * We look for the database that most urgently needs a database-wide - * vacuum. We decide that a database-wide vacuum is needed 100000 + * vacuum. We decide that a database-wide vacuum is needed 100000 * transactions sooner than vacuum.c's vac_truncate_clog() would * decide to start giving warnings. If any such db is found, we * ignore all other dbs. * - * Unlike vacuum.c, we also look at vacuumxid. This is so that - * pg_clog can be kept trimmed to a reasonable size. + * Unlike vacuum.c, we also look at vacuumxid. This is so that pg_clog + * can be kept trimmed to a reasonable size. */ freeze_age = (int32) (nextXid - tmp->frozenxid); vacuum_age = (int32) (nextXid - tmp->vacuumxid); @@ -373,8 +371,8 @@ AutoVacMain(int argc, char *argv[]) * modified, after the database was dropped from the pg_database * table. (This is of course a not-very-bulletproof test, but it's * cheap to make. If we do mistakenly choose a recently dropped - * database, InitPostgres will fail and we'll drop out until the - * next autovac run.) + * database, InitPostgres will fail and we'll drop out until the next + * autovac run.) */ if (tmp->entry->destroy != 0) continue; @@ -390,12 +388,12 @@ AutoVacMain(int argc, char *argv[]) if (db) { /* - * Report autovac startup to the stats collector. We deliberately - * do this before InitPostgres, so that the last_autovac_time will - * get updated even if the connection attempt fails. This is to - * prevent autovac from getting "stuck" repeatedly selecting an - * unopenable database, rather than making any progress on stuff - * it can connect to. + * Report autovac startup to the stats collector. We deliberately do + * this before InitPostgres, so that the last_autovac_time will get + * updated even if the connection attempt fails. This is to prevent + * autovac from getting "stuck" repeatedly selecting an unopenable + * database, rather than making any progress on stuff it can connect + * to. */ pgstat_report_autovac(db->oid); @@ -431,18 +429,18 @@ AutoVacMain(int argc, char *argv[]) /* * autovac_get_database_list * - * Return a list of all databases. Note we cannot use pg_database, + * Return a list of all databases. Note we cannot use pg_database, * because we aren't connected yet; we use the flat database file. */ static List * autovac_get_database_list(void) { - char *filename; - List *dblist = NIL; - char thisname[NAMEDATALEN]; - FILE *db_file; - Oid db_id; - Oid db_tablespace; + char *filename; + List *dblist = NIL; + char thisname[NAMEDATALEN]; + FILE *db_file; + Oid db_id; + Oid db_tablespace; TransactionId db_frozenxid; TransactionId db_vacuumxid; @@ -457,7 +455,7 @@ autovac_get_database_list(void) &db_tablespace, &db_frozenxid, &db_vacuumxid)) { - autovac_dbase *db; + autovac_dbase *db; db = (autovac_dbase *) palloc(sizeof(autovac_dbase)); @@ -486,12 +484,12 @@ autovac_get_database_list(void) static void process_whole_db(void) { - Relation dbRel; - ScanKeyData entry[1]; - SysScanDesc scan; - HeapTuple tup; + Relation dbRel; + ScanKeyData entry[1]; + SysScanDesc scan; + HeapTuple tup; Form_pg_database dbForm; - bool freeze; + bool freeze; /* Start a transaction so our commands have one to play into. */ StartTransactionCommand(); @@ -545,23 +543,22 @@ process_whole_db(void) static void do_autovacuum(PgStat_StatDBEntry *dbentry) { - Relation classRel, - avRel; - HeapTuple tuple; - HeapScanDesc relScan; - List *vacuum_tables = NIL; - List *toast_table_ids = NIL; - ListCell *cell; + Relation classRel, + avRel; + HeapTuple tuple; + HeapScanDesc relScan; + List *vacuum_tables = NIL; + List *toast_table_ids = NIL; + ListCell *cell; PgStat_StatDBEntry *shared; /* Start a transaction so our commands have one to play into. */ StartTransactionCommand(); /* - * StartTransactionCommand and CommitTransactionCommand will - * automatically switch to other contexts. We need this one - * to keep the list of relations to vacuum/analyze across - * transactions. + * StartTransactionCommand and CommitTransactionCommand will automatically + * switch to other contexts. We need this one to keep the list of + * relations to vacuum/analyze across transactions. */ MemoryContextSwitchTo(AutovacMemCxt); @@ -574,19 +571,19 @@ do_autovacuum(PgStat_StatDBEntry *dbentry) /* * Scan pg_class and determine which tables to vacuum. * - * The stats subsystem collects stats for toast tables independently - * of the stats for their parent tables. We need to check those stats - * since in cases with short, wide tables there might be proportionally - * much more activity in the toast table than in its parent. + * The stats subsystem collects stats for toast tables independently of the + * stats for their parent tables. We need to check those stats since in + * cases with short, wide tables there might be proportionally much more + * activity in the toast table than in its parent. * * Since we can only issue VACUUM against the parent table, we need to * transpose a decision to vacuum a toast table into a decision to vacuum - * its parent. There's no point in considering ANALYZE on a toast table, - * either. To support this, we keep a list of OIDs of toast tables that + * its parent. There's no point in considering ANALYZE on a toast table, + * either. To support this, we keep a list of OIDs of toast tables that * need vacuuming alongside the list of regular tables. Regular tables * will be entered into the table list even if they appear not to need - * vacuuming; we go back and re-mark them after finding all the - * vacuumable toast tables. + * vacuuming; we go back and re-mark them after finding all the vacuumable + * toast tables. */ relScan = heap_beginscan(classRel, SnapshotNow, 0, NULL); @@ -595,9 +592,9 @@ do_autovacuum(PgStat_StatDBEntry *dbentry) Form_pg_class classForm = (Form_pg_class) GETSTRUCT(tuple); Form_pg_autovacuum avForm = NULL; PgStat_StatTabEntry *tabentry; - SysScanDesc avScan; + SysScanDesc avScan; HeapTuple avTup; - ScanKeyData entry[1]; + ScanKeyData entry[1]; Oid relid; /* Consider only regular and toast tables. */ @@ -606,8 +603,8 @@ do_autovacuum(PgStat_StatDBEntry *dbentry) continue; /* - * Skip temp tables (i.e. those in temp namespaces). We cannot - * safely process other backends' temp tables. + * Skip temp tables (i.e. those in temp namespaces). We cannot safely + * process other backends' temp tables. */ if (isTempNamespace(classForm->relnamespace)) continue; @@ -687,7 +684,7 @@ do_autovacuum(PgStat_StatDBEntry *dbentry) /* * test_rel_for_autovac * - * Check whether a table needs to be vacuumed or analyzed. Add it to the + * Check whether a table needs to be vacuumed or analyzed. Add it to the * appropriate output list if so. * * A table needs to be vacuumed if the number of dead tuples exceeds a @@ -718,33 +715,37 @@ test_rel_for_autovac(Oid relid, PgStat_StatTabEntry *tabentry, List **vacuum_tables, List **toast_table_ids) { - Relation rel; - float4 reltuples; /* pg_class.reltuples */ + Relation rel; + float4 reltuples; /* pg_class.reltuples */ + /* constants from pg_autovacuum or GUC variables */ - int vac_base_thresh, - anl_base_thresh; - float4 vac_scale_factor, - anl_scale_factor; + int vac_base_thresh, + anl_base_thresh; + float4 vac_scale_factor, + anl_scale_factor; + /* thresholds calculated from above constants */ - float4 vacthresh, - anlthresh; + float4 vacthresh, + anlthresh; + /* number of vacuum (resp. analyze) tuples at this time */ - float4 vactuples, - anltuples; + float4 vactuples, + anltuples; + /* cost-based vacuum delay parameters */ - int vac_cost_limit; - int vac_cost_delay; - bool dovacuum; - bool doanalyze; + int vac_cost_limit; + int vac_cost_delay; + bool dovacuum; + bool doanalyze; /* User disabled it in pg_autovacuum? */ if (avForm && !avForm->enabled) return; /* - * Skip a table not found in stat hash. If it's not acted upon, - * there's no need to vacuum it. (Note that database-level check - * will take care of Xid wraparound.) + * Skip a table not found in stat hash. If it's not acted upon, there's + * no need to vacuum it. (Note that database-level check will take care + * of Xid wraparound.) */ if (!PointerIsValid(tabentry)) return; @@ -805,9 +806,9 @@ test_rel_for_autovac(Oid relid, PgStat_StatTabEntry *tabentry, anlthresh = (float4) anl_base_thresh + anl_scale_factor * reltuples; /* - * Note that we don't need to take special consideration for stat - * reset, because if that happens, the last vacuum and analyze counts - * will be reset too. + * Note that we don't need to take special consideration for stat reset, + * because if that happens, the last vacuum and analyze counts will be + * reset too. */ elog(DEBUG3, "%s: vac: %.0f (threshold %.0f), anl: %.0f (threshold %.0f)", @@ -863,27 +864,27 @@ test_rel_for_autovac(Oid relid, PgStat_StatTabEntry *tabentry, /* * autovacuum_do_vac_analyze - * Vacuum and/or analyze a list of tables; or all tables if relids = NIL + * Vacuum and/or analyze a list of tables; or all tables if relids = NIL */ static void autovacuum_do_vac_analyze(List *relids, bool dovacuum, bool doanalyze, bool freeze) { - VacuumStmt *vacstmt; - MemoryContext old_cxt; - + VacuumStmt *vacstmt; + MemoryContext old_cxt; + /* * The node must survive transaction boundaries, so make sure we create it * in a long-lived context */ old_cxt = MemoryContextSwitchTo(AutovacMemCxt); - + vacstmt = makeNode(VacuumStmt); /* * Point QueryContext to the autovac memory context to fake out the - * PreventTransactionChain check inside vacuum(). Note that this - * is also why we palloc vacstmt instead of just using a local variable. + * PreventTransactionChain check inside vacuum(). Note that this is also + * why we palloc vacstmt instead of just using a local variable. */ QueryContext = CurrentMemoryContext; @@ -904,8 +905,8 @@ autovacuum_do_vac_analyze(List *relids, bool dovacuum, bool doanalyze, /* * AutoVacuumingActive - * Check GUC vars and report whether the autovacuum process should be - * running. + * Check GUC vars and report whether the autovacuum process should be + * running. */ bool AutoVacuumingActive(void) @@ -918,7 +919,7 @@ AutoVacuumingActive(void) /* * autovac_init - * This is called at postmaster initialization. + * This is called at postmaster initialization. * * Annoy the user if he got it wrong. */ @@ -933,6 +934,7 @@ autovac_init(void) ereport(WARNING, (errmsg("autovacuum not started because of misconfiguration"), errhint("Enable options \"stats_start_collector\" and \"stats_row_level\"."))); + /* * Set the GUC var so we don't fork autovacuum uselessly, and also to * help debugging. @@ -943,7 +945,7 @@ autovac_init(void) /* * IsAutoVacuumProcess - * Return whether this process is an autovacuum process. + * Return whether this process is an autovacuum process. */ bool IsAutoVacuumProcess(void) diff --git a/src/backend/postmaster/bgwriter.c b/src/backend/postmaster/bgwriter.c index ed1a7b2f27..78fecf4dd6 100644 --- a/src/backend/postmaster/bgwriter.c +++ b/src/backend/postmaster/bgwriter.c @@ -37,7 +37,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/postmaster/bgwriter.c,v 1.20 2005/09/12 22:20:16 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/postmaster/bgwriter.c,v 1.21 2005/10/15 02:49:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -171,11 +171,11 @@ BackgroundWriterMain(void) * * Note: we deliberately ignore SIGTERM, because during a standard Unix * system shutdown cycle, init will SIGTERM all processes at once. We - * want to wait for the backends to exit, whereupon the postmaster - * will tell us it's okay to shut down (via SIGUSR2). + * want to wait for the backends to exit, whereupon the postmaster will + * tell us it's okay to shut down (via SIGUSR2). * - * SIGUSR1 is presently unused; keep it spare in case someday we want - * this process to participate in sinval messaging. + * SIGUSR1 is presently unused; keep it spare in case someday we want this + * process to participate in sinval messaging. */ pqsignal(SIGHUP, BgSigHupHandler); /* set flag to read config file */ pqsignal(SIGINT, ReqCheckpointHandler); /* request checkpoint */ @@ -203,15 +203,15 @@ BackgroundWriterMain(void) #endif /* - * Initialize so that first time-driven checkpoint happens at the - * correct time. + * Initialize so that first time-driven checkpoint happens at the correct + * time. */ last_checkpoint_time = time(NULL); /* - * Create a memory context that we will do all our work in. We do this - * so that we can reset the context during error recovery and thereby - * avoid possible memory leaks. Formerly this code just ran in + * Create a memory context that we will do all our work in. We do this so + * that we can reset the context during error recovery and thereby avoid + * possible memory leaks. Formerly this code just ran in * TopMemoryContext, but resetting that would be a really bad idea. */ bgwriter_context = AllocSetContextCreate(TopMemoryContext, @@ -258,8 +258,8 @@ BackgroundWriterMain(void) } /* - * Now return to normal top-level context and clear ErrorContext - * for next time. + * Now return to normal top-level context and clear ErrorContext for + * next time. */ MemoryContextSwitchTo(bgwriter_context); FlushErrorState(); @@ -271,9 +271,9 @@ BackgroundWriterMain(void) RESUME_INTERRUPTS(); /* - * Sleep at least 1 second after any error. A write error is - * likely to be repeated, and we don't want to be filling the - * error logs as fast as we can. + * Sleep at least 1 second after any error. A write error is likely + * to be repeated, and we don't want to be filling the error logs as + * fast as we can. */ pg_usleep(1000000L); } @@ -329,8 +329,8 @@ BackgroundWriterMain(void) } /* - * Do an unforced checkpoint if too much time has elapsed since - * the last one. + * Do an unforced checkpoint if too much time has elapsed since the + * last one. */ now = time(NULL); elapsed_secs = now - last_checkpoint_time; @@ -346,8 +346,8 @@ BackgroundWriterMain(void) /* * We will warn if (a) too soon since last checkpoint (whatever * caused it) and (b) somebody has set the ckpt_time_warn flag - * since the last checkpoint start. Note in particular that - * this implementation will not generate warnings caused by + * since the last checkpoint start. Note in particular that this + * implementation will not generate warnings caused by * CheckPointTimeout < CheckPointWarning. */ if (BgWriterShmem->ckpt_time_warn && @@ -368,8 +368,7 @@ BackgroundWriterMain(void) /* * After any checkpoint, close all smgr files. This is so we - * won't hang onto smgr references to deleted files - * indefinitely. + * won't hang onto smgr references to deleted files indefinitely. */ smgrcloseall(); @@ -381,8 +380,8 @@ BackgroundWriterMain(void) /* * Note we record the checkpoint start time not end time as - * last_checkpoint_time. This is so that time-driven - * checkpoints happen at a predictable spacing. + * last_checkpoint_time. This is so that time-driven checkpoints + * happen at a predictable spacing. */ last_checkpoint_time = now; } @@ -390,13 +389,13 @@ BackgroundWriterMain(void) BgBufferSync(); /* - * Nap for the configured time, or sleep for 10 seconds if there - * is no bgwriter activity configured. + * Nap for the configured time, or sleep for 10 seconds if there is no + * bgwriter activity configured. * - * On some platforms, signals won't interrupt the sleep. To ensure - * we respond reasonably promptly when someone signals us, break - * down the sleep into 1-second increments, and check for - * interrupts after each nap. + * On some platforms, signals won't interrupt the sleep. To ensure we + * respond reasonably promptly when someone signals us, break down the + * sleep into 1-second increments, and check for interrupts after each + * nap. * * We absorb pending requests after each short sleep. */ @@ -437,13 +436,13 @@ bg_quickdie(SIGNAL_ARGS) /* * DO NOT proc_exit() -- we're here because shared memory may be - * corrupted, so we don't want to try to clean up our transaction. - * Just nail the windows shut and get out of town. + * corrupted, so we don't want to try to clean up our transaction. Just + * nail the windows shut and get out of town. * - * Note we do exit(1) not exit(0). This is to force the postmaster into - * a system reset cycle if some idiot DBA sends a manual SIGQUIT to a - * random backend. This is necessary precisely because we don't clean - * up our shared memory state. + * Note we do exit(1) not exit(0). This is to force the postmaster into a + * system reset cycle if some idiot DBA sends a manual SIGQUIT to a random + * backend. This is necessary precisely because we don't clean up our + * shared memory state. */ exit(1); } @@ -485,8 +484,8 @@ BgWriterShmemSize(void) Size size; /* - * Currently, the size of the requests[] array is arbitrarily set - * equal to NBuffers. This may prove too large or small ... + * Currently, the size of the requests[] array is arbitrarily set equal to + * NBuffers. This may prove too large or small ... */ size = offsetof(BgWriterShmemStruct, requests); size = add_size(size, mul_size(NBuffers, sizeof(BgWriterRequest))); @@ -546,9 +545,8 @@ RequestCheckpoint(bool waitforit, bool warnontime) CreateCheckPoint(false, true); /* - * After any checkpoint, close all smgr files. This is so we - * won't hang onto smgr references to deleted files - * indefinitely. + * After any checkpoint, close all smgr files. This is so we won't + * hang onto smgr references to deleted files indefinitely. */ smgrcloseall(); @@ -571,8 +569,8 @@ RequestCheckpoint(bool waitforit, bool warnontime) "could not signal for checkpoint: %m"); /* - * If requested, wait for completion. We detect completion according - * to the algorithm given above. + * If requested, wait for completion. We detect completion according to + * the algorithm given above. */ if (waitforit) { @@ -585,13 +583,12 @@ RequestCheckpoint(bool waitforit, bool warnontime) /* * We are waiting for ckpt_done >= old_started, in a modulo sense. - * This is a little tricky since we don't know the width or - * signedness of sig_atomic_t. We make the lowest common - * denominator assumption that it is only as wide as "char". This - * means that this algorithm will cope correctly as long as we - * don't sleep for more than 127 completed checkpoints. (If we - * do, we will get another chance to exit after 128 more - * checkpoints...) + * This is a little tricky since we don't know the width or signedness + * of sig_atomic_t. We make the lowest common denominator assumption + * that it is only as wide as "char". This means that this algorithm + * will cope correctly as long as we don't sleep for more than 127 + * completed checkpoints. (If we do, we will get another chance to + * exit after 128 more checkpoints...) */ while (((signed char) (bgs->ckpt_done - old_started)) < 0) { @@ -666,17 +663,17 @@ AbsorbFsyncRequests(void) return; /* - * We have to PANIC if we fail to absorb all the pending requests - * (eg, because our hashtable runs out of memory). This is because - * the system cannot run safely if we are unable to fsync what we - * have been told to fsync. Fortunately, the hashtable is so small - * that the problem is quite unlikely to arise in practice. + * We have to PANIC if we fail to absorb all the pending requests (eg, + * because our hashtable runs out of memory). This is because the system + * cannot run safely if we are unable to fsync what we have been told to + * fsync. Fortunately, the hashtable is so small that the problem is + * quite unlikely to arise in practice. */ START_CRIT_SECTION(); /* - * We try to avoid holding the lock for a long time by copying the - * request array. + * We try to avoid holding the lock for a long time by copying the request + * array. */ LWLockAcquire(BgWriterCommLock, LW_EXCLUSIVE); diff --git a/src/backend/postmaster/fork_process.c b/src/backend/postmaster/fork_process.c index 4064d7ccd4..54395b0654 100644 --- a/src/backend/postmaster/fork_process.c +++ b/src/backend/postmaster/fork_process.c @@ -1,13 +1,13 @@ /* * fork_process.c - * A simple wrapper on top of fork(). This does not handle the - * EXEC_BACKEND case; it might be extended to do so, but it would be - * considerably more complex. + * A simple wrapper on top of fork(). This does not handle the + * EXEC_BACKEND case; it might be extended to do so, but it would be + * considerably more complex. * * Copyright (c) 1996-2005, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/postmaster/fork_process.c,v 1.3 2005/03/16 00:02:39 neilc Exp $ + * $PostgreSQL: pgsql/src/backend/postmaster/fork_process.c,v 1.4 2005/10/15 02:49:23 momjian Exp $ */ #include "postgres.h" #include "postmaster/fork_process.h" @@ -25,29 +25,29 @@ pid_t fork_process(void) { - pid_t result; + pid_t result; + #ifdef LINUX_PROFILE struct itimerval prof_itimer; #endif /* - * 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); #ifdef LINUX_PROFILE + /* - * Linux's fork() resets the profiling timer in the child process. If - * we want to profile child processes then we need to save and restore - * the timer setting. This is a waste of time if not profiling, - * however, so only do it if commanded by specific -DLINUX_PROFILE - * switch. + * Linux's fork() resets the profiling timer in the child process. If we + * want to profile child processes then we need to save and restore the + * timer setting. This is a waste of time if not profiling, however, so + * only do it if commanded by specific -DLINUX_PROFILE switch. */ getitimer(ITIMER_PROF, &prof_itimer); #endif @@ -81,4 +81,5 @@ fork_process(void) return result; } -#endif /* ! WIN32 */ + +#endif /* ! WIN32 */ diff --git a/src/backend/postmaster/pgarch.c b/src/backend/postmaster/pgarch.c index 2f52053a2c..61019d7a5e 100644 --- a/src/backend/postmaster/pgarch.c +++ b/src/backend/postmaster/pgarch.c @@ -19,7 +19,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/postmaster/pgarch.c,v 1.17 2005/07/04 04:51:47 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/postmaster/pgarch.c,v 1.18 2005/10/15 02:49:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -49,11 +49,11 @@ * Timer definitions. * ---------- */ -#define PGARCH_AUTOWAKE_INTERVAL 60 /* How often to force a poll of - * the archive status directory; - * in seconds. */ -#define PGARCH_RESTART_INTERVAL 10 /* How often to attempt to restart - * a failed archiver; in seconds. */ +#define PGARCH_AUTOWAKE_INTERVAL 60 /* How often to force a poll of the + * archive status directory; in + * seconds. */ +#define PGARCH_RESTART_INTERVAL 10 /* How often to attempt to restart a + * failed archiver; in seconds. */ /* ---------- * Archiver control info. @@ -131,10 +131,9 @@ pgarch_start(void) /* * Do nothing if too soon since last archiver start. This is a safety - * valve to protect against continuous respawn attempts if the - * archiver is dying immediately at launch. Note that since we will be - * re-called from the postmaster main loop, we will get another chance - * later. + * valve to protect against continuous respawn attempts if the archiver is + * dying immediately at launch. Note that since we will be re-called from + * the postmaster main loop, we will get another chance later. */ curtime = time(NULL); if ((unsigned int) (curtime - last_pgarch_start_time) < @@ -292,9 +291,9 @@ pgarch_MainLoop(void) /* * We run the copy loop immediately upon entry, in case there are - * unarchived files left over from a previous database run (or maybe - * the archiver died unexpectedly). After that we wait for a signal - * or timeout before doing more. + * unarchived files left over from a previous database run (or maybe the + * archiver died unexpectedly). After that we wait for a signal or + * timeout before doing more. */ wakened = true; @@ -319,11 +318,11 @@ pgarch_MainLoop(void) } /* - * There shouldn't be anything for the archiver to do except to - * wait for a signal, ... however, the archiver exists to - * protect our data, so she wakes up occasionally to allow - * herself to be proactive. In particular this avoids getting - * stuck if a signal arrives just before we sleep. + * There shouldn't be anything for the archiver to do except to wait + * for a signal, ... however, the archiver exists to protect our data, + * so she wakes up occasionally to allow herself to be proactive. In + * particular this avoids getting stuck if a signal arrives just + * before we sleep. */ if (!wakened) { @@ -349,9 +348,9 @@ pgarch_ArchiverCopyLoop(void) /* * loop through all xlogs with archive_status of .ready and archive - * them...mostly we expect this to be a single file, though it is - * possible some backend will add files onto the list of those that - * need archiving while we are still copying earlier archives + * them...mostly we expect this to be a single file, though it is possible + * some backend will add files onto the list of those that need archiving + * while we are still copying earlier archives */ while (pgarch_readyXlog(xlog)) { @@ -488,10 +487,10 @@ static bool pgarch_readyXlog(char *xlog) { /* - * open xlog status directory and read through list of xlogs that have - * the .ready suffix, looking for earliest file. It is possible to - * optimise this code, though only a single file is expected on the - * vast majority of calls, so.... + * open xlog status directory and read through list of xlogs that have the + * .ready suffix, looking for earliest file. It is possible to optimise + * this code, though only a single file is expected on the vast majority + * of calls, so.... */ char XLogArchiveStatusDir[MAXPGPATH]; char newxlog[MAX_XFN_CHARS + 6 + 1]; @@ -504,8 +503,8 @@ pgarch_readyXlog(char *xlog) if (rldir == NULL) ereport(ERROR, (errcode_for_file_access(), - errmsg("could not open archive status directory \"%s\": %m", - XLogArchiveStatusDir))); + errmsg("could not open archive status directory \"%s\": %m", + XLogArchiveStatusDir))); while ((rlde = ReadDir(rldir, XLogArchiveStatusDir)) != NULL) { diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c index d03f812476..8d767a0b4c 100644 --- a/src/backend/postmaster/pgstat.c +++ b/src/backend/postmaster/pgstat.c @@ -13,7 +13,7 @@ * * Copyright (c) 2001-2005, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.109 2005/10/06 02:29:17 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.110 2005/10/15 02:49:23 momjian Exp $ * ---------- */ #include "postgres.h" @@ -66,19 +66,18 @@ * Timer definitions. * ---------- */ -#define PGSTAT_STAT_INTERVAL 500 /* How often to write the status - * file; in milliseconds. */ +#define PGSTAT_STAT_INTERVAL 500 /* How often to write the status file; + * in milliseconds. */ -#define PGSTAT_DESTROY_DELAY 10000 /* How long to keep destroyed - * objects known, to give delayed - * UDP packets time to arrive; in - * milliseconds. */ +#define PGSTAT_DESTROY_DELAY 10000 /* How long to keep destroyed objects + * known, to give delayed UDP packets + * time to arrive; in milliseconds. */ #define PGSTAT_DESTROY_COUNT (PGSTAT_DESTROY_DELAY / PGSTAT_STAT_INTERVAL) -#define PGSTAT_RESTART_INTERVAL 60 /* How often to attempt to restart - * a failed statistics collector; - * in seconds. */ +#define PGSTAT_RESTART_INTERVAL 60 /* How often to attempt to restart a + * failed statistics collector; in + * seconds. */ /* ---------- * Amount of space reserved in pgstat_recvbuffer(). @@ -110,7 +109,7 @@ bool pgstat_collect_blocklevel = false; * ---------- */ NON_EXEC_STATIC int pgStatSock = -1; -NON_EXEC_STATIC int pgStatPipe[2] = {-1,-1}; +NON_EXEC_STATIC int pgStatPipe[2] = {-1, -1}; static struct sockaddr_storage pgStatAddr; static pid_t pgStatCollectorPid = 0; @@ -127,15 +126,15 @@ static bool pgStatRunningInCollector = FALSE; */ typedef struct TabStatArray { - int tsa_alloc; /* num allocated */ - int tsa_used; /* num actually used */ + int tsa_alloc; /* num allocated */ + int tsa_used; /* num actually used */ PgStat_MsgTabstat **tsa_messages; /* the array itself */ } TabStatArray; #define TABSTAT_QUANTUM 4 /* we alloc this many at a time */ -static TabStatArray RegularTabStat = { 0, 0, NULL }; -static TabStatArray SharedTabStat = { 0, 0, NULL }; +static TabStatArray RegularTabStat = {0, 0, NULL}; +static TabStatArray SharedTabStat = {0, 0, NULL}; static int pgStatXactCommit = 0; static int pgStatXactRollback = 0; @@ -266,12 +265,12 @@ pgstat_init(void) } /* - * On some platforms, getaddrinfo_all() may return multiple addresses - * only one of which will actually work (eg, both IPv6 and IPv4 - * addresses when kernel will reject IPv6). Worse, the failure may - * occur at the bind() or perhaps even connect() stage. So we must - * loop through the results till we find a working combination. We - * will generate LOG messages, but no error, for bogus combinations. + * On some platforms, getaddrinfo_all() may return multiple addresses only + * one of which will actually work (eg, both IPv6 and IPv4 addresses when + * kernel will reject IPv6). Worse, the failure may occur at the bind() + * or perhaps even connect() stage. So we must loop through the results + * till we find a working combination. We will generate LOG messages, but + * no error, for bogus combinations. */ for (addr = addrs; addr; addr = addr->ai_next) { @@ -288,19 +287,19 @@ pgstat_init(void) { ereport(LOG, (errcode_for_socket_access(), - errmsg("could not create socket for statistics collector: %m"))); + errmsg("could not create socket for statistics collector: %m"))); continue; } /* - * Bind it to a kernel assigned port on localhost and get the - * assigned port via getsockname(). + * Bind it to a kernel assigned port on localhost and get the assigned + * port via getsockname(). */ if (bind(pgStatSock, addr->ai_addr, addr->ai_addrlen) < 0) { ereport(LOG, (errcode_for_socket_access(), - errmsg("could not bind socket for statistics collector: %m"))); + errmsg("could not bind socket for statistics collector: %m"))); closesocket(pgStatSock); pgStatSock = -1; continue; @@ -318,26 +317,26 @@ pgstat_init(void) } /* - * Connect the socket to its own address. This saves a few cycles - * by not having to respecify the target address on every send. - * This also provides a kernel-level check that only packets from - * this same address will be received. + * Connect the socket to its own address. This saves a few cycles by + * not having to respecify the target address on every send. This also + * provides a kernel-level check that only packets from this same + * address will be received. */ if (connect(pgStatSock, (struct sockaddr *) & pgStatAddr, alen) < 0) { ereport(LOG, (errcode_for_socket_access(), - errmsg("could not connect socket for statistics collector: %m"))); + errmsg("could not connect socket for statistics collector: %m"))); closesocket(pgStatSock); pgStatSock = -1; continue; } /* - * Try to send and receive a one-byte test message on the socket. - * This is to catch situations where the socket can be created but - * will not actually pass data (for instance, because kernel - * packet filtering rules prevent it). + * Try to send and receive a one-byte test message on the socket. This + * is to catch situations where the socket can be created but will not + * actually pass data (for instance, because kernel packet filtering + * rules prevent it). */ test_byte = TESTBYTEVAL; if (send(pgStatSock, &test_byte, 1, 0) != 1) @@ -351,9 +350,9 @@ pgstat_init(void) } /* - * There could possibly be a little delay before the message can - * be received. We arbitrarily allow up to half a second before - * deciding it's broken. + * There could possibly be a little delay before the message can be + * received. We arbitrarily allow up to half a second before deciding + * it's broken. */ for (;;) /* need a loop to handle EINTR */ { @@ -369,7 +368,7 @@ pgstat_init(void) { ereport(LOG, (errcode_for_socket_access(), - errmsg("select() failed in statistics collector: %m"))); + errmsg("select() failed in statistics collector: %m"))); closesocket(pgStatSock); pgStatSock = -1; continue; @@ -377,8 +376,8 @@ pgstat_init(void) if (sel_res == 0 || !FD_ISSET(pgStatSock, &rset)) { /* - * This is the case we actually think is likely, so take pains - * to give a specific message for it. + * This is the case we actually think is likely, so take pains to + * give a specific message for it. * * errno will not be set meaningfully here, so don't use it. */ @@ -421,10 +420,10 @@ pgstat_init(void) goto startup_failed; /* - * Set the socket to non-blocking IO. This ensures that if the - * collector falls behind (despite the buffering process), statistics - * messages will be discarded; backends won't block waiting to send - * messages to the collector. + * Set the socket to non-blocking IO. This ensures that if the collector + * falls behind (despite the buffering process), statistics messages will + * be discarded; backends won't block waiting to send messages to the + * collector. */ if (!pg_set_noblock(pgStatSock)) { @@ -440,7 +439,7 @@ pgstat_init(void) startup_failed: ereport(LOG, - (errmsg("disabling statistics collector for lack of working socket"))); + (errmsg("disabling statistics collector for lack of working socket"))); if (addrs) freeaddrinfo_all(hints.ai_family, addrs); @@ -459,7 +458,7 @@ startup_failed: /* * pgstat_reset_all() - * - * Remove the stats file. This is used on server start if the + * Remove the stats file. This is used on server start if the * stats_reset_on_server_start feature is enabled, or if WAL * recovery is needed after a crash. */ @@ -560,11 +559,10 @@ pgstat_start(void) return 0; /* - * Do nothing if too soon since last collector start. This is a - * safety valve to protect against continuous respawn attempts if the - * collector is dying immediately at launch. Note that since we will - * be re-called from the postmaster main loop, we will get another - * chance later. + * Do nothing if too soon since last collector start. This is a safety + * valve to protect against continuous respawn attempts if the collector + * is dying immediately at launch. Note that since we will be re-called + * from the postmaster main loop, we will get another chance later. */ curtime = time(NULL); if ((unsigned int) (curtime - last_pgstat_start_time) < @@ -650,7 +648,7 @@ pgstat_beterm(int pid) /* ---------- * pgstat_report_autovac() - * - * Called from autovacuum.c to report startup of an autovacuum process. + * Called from autovacuum.c to report startup of an autovacuum process. * We are called before InitPostgres is done, so can't rely on MyDatabaseId; * the db OID must be passed in, instead. * ---------- @@ -693,8 +691,8 @@ pgstat_bestart(void) /* * We may not have a MyProcPort (eg, if this is the autovacuum process). - * For the moment, punt and don't send BESTART --- would be better to - * work out a clean way of handling "unknown clientaddr". + * For the moment, punt and don't send BESTART --- would be better to work + * out a clean way of handling "unknown clientaddr". */ if (MyProcPort) { @@ -738,7 +736,7 @@ pgstat_report_vacuum(Oid tableoid, bool shared, /* -------- * pgstat_report_analyze() - * - * Tell the collector about the table we just analyzed. + * Tell the collector about the table we just analyzed. * -------- */ void @@ -898,8 +896,8 @@ pgstat_vacuum_tabstat(void) return 0; /* - * If not done for this transaction, read the statistics collector - * stats file into some hash tables. + * If not done for this transaction, read the statistics collector stats + * file into some hash tables. */ backend_read_statsfile(); @@ -926,8 +924,8 @@ pgstat_vacuum_tabstat(void) while ((tabentry = (PgStat_StatTabEntry *) hash_seq_search(&hstat)) != NULL) { /* - * Check if this relation is still alive by looking up it's - * pg_class tuple in the system catalog cache. + * Check if this relation is still alive by looking up it's pg_class + * tuple in the system catalog cache. */ reltup = SearchSysCache(RELOID, ObjectIdGetDatum(tabentry->tableid), @@ -1072,7 +1070,7 @@ pgstat_reset_counters(void) if (!superuser()) ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), - errmsg("must be superuser to reset statistics counters"))); + errmsg("must be superuser to reset statistics counters"))); pgstat_setheader(&msg.m_hdr, PGSTAT_MTYPE_RESETCOUNTER); msg.m_databaseid = MyDatabaseId; @@ -1150,7 +1148,7 @@ pgstat_initstats(PgStat_Info *stats, Relation rel) { Oid rel_id = rel->rd_id; PgStat_TableEntry *useent; - TabStatArray *tsarr; + TabStatArray *tsarr; PgStat_MsgTabstat *tsmsg; int mb; int i; @@ -1187,8 +1185,8 @@ pgstat_initstats(PgStat_Info *stats, Relation rel) continue; /* - * Not found, but found a message buffer with an empty slot - * instead. Fine, let's use this one. + * Not found, but found a message buffer with an empty slot instead. + * Fine, let's use this one. */ i = tsmsg->m_nentries++; useent = &tsmsg->m_entry[i]; @@ -1234,9 +1232,9 @@ pgstat_count_xact_commit(void) pgStatXactCommit++; /* - * If there was no relation activity yet, just make one existing - * message buffer used without slots, causing the next report to tell - * new xact-counters. + * If there was no relation activity yet, just make one existing message + * buffer used without slots, causing the next report to tell new + * xact-counters. */ if (RegularTabStat.tsa_alloc == 0) more_tabstat_space(&RegularTabStat); @@ -1266,9 +1264,9 @@ pgstat_count_xact_rollback(void) pgStatXactRollback++; /* - * If there was no relation activity yet, just make one existing - * message buffer used without slots, causing the next report to tell - * new xact-counters. + * If there was no relation activity yet, just make one existing message + * buffer used without slots, causing the next report to tell new + * xact-counters. */ if (RegularTabStat.tsa_alloc == 0) more_tabstat_space(&RegularTabStat); @@ -1294,8 +1292,8 @@ PgStat_StatDBEntry * pgstat_fetch_stat_dbentry(Oid dbid) { /* - * If not done for this transaction, read the statistics collector - * stats file into some hash tables. + * If not done for this transaction, read the statistics collector stats + * file into some hash tables. */ backend_read_statsfile(); @@ -1325,8 +1323,8 @@ pgstat_fetch_stat_tabentry(Oid relid) PgStat_StatTabEntry *tabentry; /* - * If not done for this transaction, read the statistics collector - * stats file into some hash tables. + * If not done for this transaction, read the statistics collector stats + * file into some hash tables. */ backend_read_statsfile(); @@ -1492,21 +1490,20 @@ PgstatBufferMain(int argc, char *argv[]) #endif /* - * Start a buffering process to read from the socket, so we have a - * little more time to process incoming messages. + * Start a buffering process to read from the socket, so we have a little + * more time to process incoming messages. * - * NOTE: the process structure is: postmaster is parent of buffer process - * is parent of collector process. This way, the buffer can detect - * collector failure via SIGCHLD, whereas otherwise it wouldn't notice - * collector failure until it tried to write on the pipe. That would - * mean that after the postmaster started a new collector, we'd have - * two buffer processes competing to read from the UDP socket --- not - * good. + * NOTE: the process structure is: postmaster is parent of buffer process is + * parent of collector process. This way, the buffer can detect collector + * failure via SIGCHLD, whereas otherwise it wouldn't notice collector + * failure until it tried to write on the pipe. That would mean that + * after the postmaster started a new collector, we'd have two buffer + * processes competing to read from the UDP socket --- not good. */ if (pgpipe(pgStatPipe) < 0) ereport(ERROR, (errcode_for_socket_access(), - errmsg("could not create pipe for statistics buffer: %m"))); + errmsg("could not create pipe for statistics buffer: %m"))); /* child becomes collector process */ #ifdef EXEC_BACKEND @@ -1561,10 +1558,10 @@ PgstatCollectorMain(int argc, char *argv[]) MyProcPid = getpid(); /* reset MyProcPid */ /* - * Reset signal handling. With the exception of restoring default - * SIGCHLD and SIGQUIT handling, this is a no-op in the - * non-EXEC_BACKEND case because we'll have inherited these settings - * from the buffer process; but it's not a no-op for EXEC_BACKEND. + * Reset signal handling. With the exception of restoring default SIGCHLD + * and SIGQUIT handling, this is a no-op in the non-EXEC_BACKEND case + * because we'll have inherited these settings from the buffer process; + * but it's not a no-op for EXEC_BACKEND. */ pqsignal(SIGHUP, SIG_IGN); pqsignal(SIGINT, SIG_IGN); @@ -1607,8 +1604,8 @@ PgstatCollectorMain(int argc, char *argv[]) need_statwrite = TRUE; /* - * Read in an existing statistics stats file or initialize the stats - * to zero. + * Read in an existing statistics stats file or initialize the stats to + * zero. */ pgStatRunningInCollector = TRUE; pgstat_read_statsfile(&pgStatDBHash, InvalidOid, NULL, NULL); @@ -1638,9 +1635,9 @@ PgstatCollectorMain(int argc, char *argv[]) for (;;) { /* - * If we need to write the status file again (there have been - * changes in the statistics since we wrote it last) calculate the - * timeout until we have to do so. + * If we need to write the status file again (there have been changes + * in the statistics since we wrote it last) calculate the timeout + * until we have to do so. */ if (need_statwrite) { @@ -1684,7 +1681,7 @@ PgstatCollectorMain(int argc, char *argv[]) continue; ereport(ERROR, (errcode_for_socket_access(), - errmsg("select() failed in statistics collector: %m"))); + errmsg("select() failed in statistics collector: %m"))); } /* @@ -1706,10 +1703,10 @@ PgstatCollectorMain(int argc, char *argv[]) { /* * We may need to issue multiple read calls in case the buffer - * process didn't write the message in a single write, which - * is possible since it dumps its buffer bytewise. In any - * case, we'd need two reads since we don't know the message - * length initially. + * process didn't write the message in a single write, which is + * possible since it dumps its buffer bytewise. In any case, we'd + * need two reads since we don't know the message length + * initially. */ int nread = 0; int targetlen = sizeof(PgStat_MsgHdr); /* initial */ @@ -1742,25 +1739,24 @@ PgstatCollectorMain(int argc, char *argv[]) { /* * Bogus message length implies that we got out of - * sync with the buffer process somehow. Abort so - * that we can restart both processes. + * sync with the buffer process somehow. Abort so that + * we can restart both processes. */ ereport(ERROR, - (errmsg("invalid statistics message length"))); + (errmsg("invalid statistics message length"))); } } } /* - * EOF on the pipe implies that the buffer process exited. - * Fall out of outer loop. + * EOF on the pipe implies that the buffer process exited. Fall + * out of outer loop. */ if (pipeEOF) break; /* - * Distribute the message to the specific function handling - * it. + * Distribute the message to the specific function handling it. */ switch (msg.msg_hdr.m_type) { @@ -1818,8 +1814,8 @@ PgstatCollectorMain(int argc, char *argv[]) pgStatNumMessages++; /* - * If this is the first message after we wrote the stats file - * the last time, setup the timeout that it'd be written. + * If this is the first message after we wrote the stats file the + * last time, setup the timeout that it'd be written. */ if (!need_statwrite) { @@ -1832,20 +1828,20 @@ PgstatCollectorMain(int argc, char *argv[]) } /* - * Note that we do NOT check for postmaster exit inside the loop; - * only EOF on the buffer pipe causes us to fall out. This - * ensures we don't exit prematurely if there are still a few - * messages in the buffer or pipe at postmaster shutdown. + * Note that we do NOT check for postmaster exit inside the loop; only + * EOF on the buffer pipe causes us to fall out. This ensures we + * don't exit prematurely if there are still a few messages in the + * buffer or pipe at postmaster shutdown. */ } /* - * Okay, we saw EOF on the buffer pipe, so there are no more messages - * to process. If the buffer process quit because of postmaster - * shutdown, we want to save the final stats to reuse at next startup. - * But if the buffer process failed, it seems best not to (there may - * even now be a new collector firing up, and we don't want it to read - * a partially-rewritten stats file). + * Okay, we saw EOF on the buffer pipe, so there are no more messages to + * process. If the buffer process quit because of postmaster shutdown, we + * want to save the final stats to reuse at next startup. But if the + * buffer process failed, it seems best not to (there may even now be a + * new collector firing up, and we don't want it to read a + * partially-rewritten stats file). */ if (!PostmasterIsAlive(false)) pgstat_write_statsfile(); @@ -1887,18 +1883,18 @@ pgstat_recvbuffer(void) set_ps_display(""); /* - * We want to die if our child collector process does. There are two - * ways we might notice that it has died: receive SIGCHLD, or get a - * write failure on the pipe leading to the child. We can set SIGPIPE - * to kill us here. Our SIGCHLD handler was already set up before we - * forked (must do it that way, else it's a race condition). + * We want to die if our child collector process does. There are two ways + * we might notice that it has died: receive SIGCHLD, or get a write + * failure on the pipe leading to the child. We can set SIGPIPE to kill + * us here. Our SIGCHLD handler was already set up before we forked (must + * do it that way, else it's a race condition). */ pqsignal(SIGPIPE, SIG_DFL); PG_SETMASK(&UnBlockSig); /* - * Set the write pipe to nonblock mode, so that we cannot block when - * the collector falls behind. + * Set the write pipe to nonblock mode, so that we cannot block when the + * collector falls behind. */ if (!pg_set_noblock(writePipe)) ereport(ERROR, @@ -1951,9 +1947,9 @@ pgstat_recvbuffer(void) } /* - * Wait for some work to do; but not for more than 10 seconds. - * (This determines how quickly we will shut down after an - * ungraceful postmaster termination; so it needn't be very fast.) + * Wait for some work to do; but not for more than 10 seconds. (This + * determines how quickly we will shut down after an ungraceful + * postmaster termination; so it needn't be very fast.) */ timeout.tv_sec = 10; timeout.tv_usec = 0; @@ -1979,7 +1975,7 @@ pgstat_recvbuffer(void) if (len < 0) ereport(ERROR, (errcode_for_socket_access(), - errmsg("could not read statistics message: %m"))); + errmsg("could not read statistics message: %m"))); /* * We ignore messages that are smaller than our common header @@ -2020,14 +2016,14 @@ pgstat_recvbuffer(void) * If the collector is ready to receive, write some data into his * pipe. We may or may not be able to write all that we have. * - * NOTE: if what we have is less than PIPE_BUF bytes but more than - * the space available in the pipe buffer, most kernels will - * refuse to write any of it, and will return EAGAIN. This means - * we will busy-loop until the situation changes (either because - * the collector caught up, or because more data arrives so that - * we have more than PIPE_BUF bytes buffered). This is not good, - * but is there any way around it? We have no way to tell when - * the collector has caught up... + * NOTE: if what we have is less than PIPE_BUF bytes but more than the + * space available in the pipe buffer, most kernels will refuse to + * write any of it, and will return EAGAIN. This means we will + * busy-loop until the situation changes (either because the collector + * caught up, or because more data arrives so that we have more than + * PIPE_BUF bytes buffered). This is not good, but is there any way + * around it? We have no way to tell when the collector has caught + * up... */ if (FD_ISSET(writePipe, &wfds)) { @@ -2042,7 +2038,7 @@ pgstat_recvbuffer(void) continue; /* not enough space in pipe */ ereport(ERROR, (errcode_for_socket_access(), - errmsg("could not write to statistics collector pipe: %m"))); + errmsg("could not write to statistics collector pipe: %m"))); } /* NB: len < xfr is okay */ msg_send += len; @@ -2052,15 +2048,15 @@ pgstat_recvbuffer(void) } /* - * Make sure we forwarded all messages before we check for - * postmaster termination. + * Make sure we forwarded all messages before we check for postmaster + * termination. */ if (msg_have != 0 || FD_ISSET(pgStatSock, &rfds)) continue; /* - * If the postmaster has terminated, we die too. (This is no - * longer the normal exit path, however.) + * If the postmaster has terminated, we die too. (This is no longer + * the normal exit path, however.) */ if (!PostmasterIsAlive(true)) exit(0); @@ -2072,9 +2068,9 @@ static void pgstat_exit(SIGNAL_ARGS) { /* - * For now, we just nail the doors shut and get out of town. It might - * be cleaner to allow any pending messages to be sent, but that - * creates a tradeoff against speed of exit. + * For now, we just nail the doors shut and get out of town. It might be + * cleaner to allow any pending messages to be sent, but that creates a + * tradeoff against speed of exit. */ /* @@ -2115,7 +2111,7 @@ pgstat_add_backend(PgStat_MsgHdr *msg) if (msg->m_backendid < 1 || msg->m_backendid > MaxBackends) { ereport(LOG, - (errmsg("invalid server process ID %d", msg->m_backendid))); + (errmsg("invalid server process ID %d", msg->m_backendid))); return -1; } @@ -2125,20 +2121,20 @@ pgstat_add_backend(PgStat_MsgHdr *msg) beentry = &pgStatBeTable[msg->m_backendid - 1]; /* - * If the slot contains the PID of this backend, everything is - * fine and we have nothing to do. Note that all the slots are - * zero'd out when the collector is started. We assume that a slot - * is "empty" iff procpid == 0. + * If the slot contains the PID of this backend, everything is fine and we + * have nothing to do. Note that all the slots are zero'd out when the + * collector is started. We assume that a slot is "empty" iff procpid == + * 0. */ if (beentry->procpid > 0 && beentry->procpid == msg->m_procpid) return 0; /* - * Lookup if this backend is known to be dead. This can be caused due - * to messages arriving in the wrong order - e.g. postmaster's BETERM - * message might have arrived before we received all the backends - * stats messages, or even a new backend with the same backendid was - * faster in sending his BESTART. + * Lookup if this backend is known to be dead. This can be caused due to + * messages arriving in the wrong order - e.g. postmaster's BETERM message + * might have arrived before we received all the backends stats messages, + * or even a new backend with the same backendid was faster in sending his + * BESTART. * * If the backend is known to be dead, we ignore this add. */ @@ -2149,8 +2145,8 @@ pgstat_add_backend(PgStat_MsgHdr *msg) return 1; /* - * Backend isn't known to be dead. If it's slot is currently used, we - * have to kick out the old backend. + * Backend isn't known to be dead. If it's slot is currently used, we have + * to kick out the old backend. */ if (beentry->procpid > 0) pgstat_sub_backend(beentry->procpid); @@ -2165,12 +2161,11 @@ pgstat_add_backend(PgStat_MsgHdr *msg) beentry->activity[0] = '\0'; /* - * We can't initialize the rest of the data in this slot until we - * see the BESTART message. Therefore, we set the database and - * user to sentinel values, to indicate "undefined". There is no - * easy way to do this for the client address, so make sure to - * check that the database or user are defined before accessing - * the client address. + * We can't initialize the rest of the data in this slot until we see the + * BESTART message. Therefore, we set the database and user to sentinel + * values, to indicate "undefined". There is no easy way to do this for + * the client address, so make sure to check that the database or user are + * defined before accessing the client address. */ beentry->userid = InvalidOid; beentry->databaseid = InvalidOid; @@ -2187,8 +2182,8 @@ static PgStat_StatDBEntry * pgstat_get_db_entry(Oid databaseid, bool create) { PgStat_StatDBEntry *result; - bool found; - HASHACTION action = (create ? HASH_ENTER : HASH_FIND); + bool found; + HASHACTION action = (create ? HASH_ENTER : HASH_FIND); /* Lookup or create the hash table entry for this database */ result = (PgStat_StatDBEntry *) hash_search(pgStatDBHash, @@ -2216,9 +2211,9 @@ pgstat_get_db_entry(Oid databaseid, bool create) hash_ctl.entrysize = sizeof(PgStat_StatTabEntry); hash_ctl.hash = oid_hash; result->tables = hash_create("Per-database table", - PGSTAT_TAB_HASH_SIZE, - &hash_ctl, - HASH_ELEM | HASH_FUNCTION); + PGSTAT_TAB_HASH_SIZE, + &hash_ctl, + HASH_ELEM | HASH_FUNCTION); } return result; @@ -2238,22 +2233,21 @@ pgstat_sub_backend(int procpid) bool found; /* - * Search in the known-backends table for the slot containing this - * PID. + * Search in the known-backends table for the slot containing this PID. */ for (i = 0; i < MaxBackends; i++) { if (pgStatBeTable[i].procpid == procpid) { /* - * That's him. Add an entry to the known to be dead backends. - * Due to possible misorder in the arrival of UDP packets it's - * possible that even if we know the backend is dead, there - * could still be messages queued that arrive later. Those - * messages must not cause our number of backends statistics - * to get screwed up, so we remember for a couple of seconds - * that this PID is dead and ignore them (only the counting of - * backends, not the table access stats they sent). + * That's him. Add an entry to the known to be dead backends. Due + * to possible misorder in the arrival of UDP packets it's + * possible that even if we know the backend is dead, there could + * still be messages queued that arrive later. Those messages must + * not cause our number of backends statistics to get screwed up, + * so we remember for a couple of seconds that this PID is dead + * and ignore them (only the counting of backends, not the table + * access stats they sent). */ deadbe = (PgStat_StatBeDead *) hash_search(pgStatBeDead, (void *) &procpid, @@ -2275,8 +2269,8 @@ pgstat_sub_backend(int procpid) } /* - * No big problem if not found. This can happen if UDP messages arrive - * out of order here. + * No big problem if not found. This can happen if UDP messages arrive out + * of order here. */ } @@ -2307,8 +2301,8 @@ pgstat_write_statsfile(void) { ereport(LOG, (errcode_for_file_access(), - errmsg("could not open temporary statistics file \"%s\": %m", - PGSTAT_STAT_TMPFILE))); + errmsg("could not open temporary statistics file \"%s\": %m", + PGSTAT_STAT_TMPFILE))); return; } @@ -2325,8 +2319,8 @@ pgstat_write_statsfile(void) while ((dbentry = (PgStat_StatDBEntry *) hash_seq_search(&hstat)) != NULL) { /* - * If this database is marked destroyed, count down and do so if - * it reaches 0. + * If this database is marked destroyed, count down and do so if it + * reaches 0. */ if (dbentry->destroy > 0) { @@ -2362,8 +2356,8 @@ pgstat_write_statsfile(void) while ((tabentry = (PgStat_StatTabEntry *) hash_seq_search(&tstat)) != NULL) { /* - * If table entry marked for destruction, same as above for - * the database entry. + * If table entry marked for destruction, same as above for the + * database entry. */ if (tabentry->destroy > 0) { @@ -2384,8 +2378,8 @@ pgstat_write_statsfile(void) } /* - * At least we think this is still a live table. Print its - * access stats. + * At least we think this is still a live table. Print its access + * stats. */ fputc('T', fpout); fwrite(tabentry, sizeof(PgStat_StatTabEntry), 1, fpout); @@ -2422,8 +2416,8 @@ pgstat_write_statsfile(void) { ereport(LOG, (errcode_for_file_access(), - errmsg("could not close temporary statistics file \"%s\": %m", - PGSTAT_STAT_TMPFILE))); + errmsg("could not close temporary statistics file \"%s\": %m", + PGSTAT_STAT_TMPFILE))); } else { @@ -2443,8 +2437,7 @@ pgstat_write_statsfile(void) while ((deadbe = (PgStat_StatBeDead *) hash_seq_search(&hstat)) != NULL) { /* - * Count down the destroy delay and remove entries where it - * reaches 0. + * Count down the destroy delay and remove entries where it reaches 0. */ if (--(deadbe->destroy) <= 0) { @@ -2453,8 +2446,8 @@ pgstat_write_statsfile(void) HASH_REMOVE, NULL) == NULL) { ereport(ERROR, - (errmsg("dead-server-process hash table corrupted " - "during cleanup --- abort"))); + (errmsg("dead-server-process hash table corrupted " + "during cleanup --- abort"))); } } } @@ -2491,7 +2484,7 @@ pgstat_read_statsfile(HTAB **dbhash, Oid onlydb, /* * If running in the collector or the autovacuum process, we use the - * DynaHashCxt memory context. If running in a backend, we use the + * DynaHashCxt memory context. If running in a backend, we use the * TopTransactionContext instead, so the caller must only know the last * XactId when this call happened to know if his tables are still valid or * already gone! @@ -2525,8 +2518,8 @@ pgstat_read_statsfile(HTAB **dbhash, Oid onlydb, HASH_ELEM | HASH_FUNCTION | mcxt_flags); /* - * Initialize the number of known backends to zero, just in case we do - * a silent error return below. + * Initialize the number of known backends to zero, just in case we do a + * silent error return below. */ if (numbackends != NULL) *numbackends = 0; @@ -2534,9 +2527,9 @@ pgstat_read_statsfile(HTAB **dbhash, Oid onlydb, *betab = NULL; /* - * Try to open the status file. If it doesn't exist, the backends - * simply return zero for anything and the collector simply starts - * from scratch with empty counters. + * Try to open the status file. If it doesn't exist, the backends simply + * return zero for anything and the collector simply starts from scratch + * with empty counters. */ if ((fpin = AllocateFile(PGSTAT_STAT_FILENAME, PG_BINARY_R)) == NULL) return; @@ -2562,8 +2555,8 @@ pgstat_read_statsfile(HTAB **dbhash, Oid onlydb, { /* * 'D' A PgStat_StatDBEntry struct describing a database - * follows. Subsequently, zero to many 'T' entries will - * follow until a 'd' is encountered. + * follows. Subsequently, zero to many 'T' entries will follow + * until a 'd' is encountered. */ case 'D': if (fread(&dbbuf, 1, sizeof(dbbuf), fpin) != sizeof(dbbuf)) @@ -2577,7 +2570,7 @@ pgstat_read_statsfile(HTAB **dbhash, Oid onlydb, * Add to the DB hash */ dbentry = (PgStat_StatDBEntry *) hash_search(*dbhash, - (void *) &dbbuf.databaseid, + (void *) &dbbuf.databaseid, HASH_ENTER, &found); if (found) @@ -2600,7 +2593,7 @@ pgstat_read_statsfile(HTAB **dbhash, Oid onlydb, { if (dbbuf.databaseid != onlydb && dbbuf.databaseid != InvalidOid) - break; + break; } memset(&hash_ctl, 0, sizeof(hash_ctl)); @@ -2611,11 +2604,11 @@ pgstat_read_statsfile(HTAB **dbhash, Oid onlydb, dbentry->tables = hash_create("Per-database table", PGSTAT_TAB_HASH_SIZE, &hash_ctl, - HASH_ELEM | HASH_FUNCTION | mcxt_flags); + HASH_ELEM | HASH_FUNCTION | mcxt_flags); /* - * Arrange that following 'T's add entries to this - * databases tables hash table. + * Arrange that following 'T's add entries to this databases + * tables hash table. */ tabhash = dbentry->tables; break; @@ -2645,8 +2638,8 @@ pgstat_read_statsfile(HTAB **dbhash, Oid onlydb, break; tabentry = (PgStat_StatTabEntry *) hash_search(tabhash, - (void *) &tabbuf.tableid, - HASH_ENTER, &found); + (void *) &tabbuf.tableid, + HASH_ENTER, &found); if (found) { @@ -2684,7 +2677,7 @@ pgstat_read_statsfile(HTAB **dbhash, Oid onlydb, else *betab = (PgStat_StatBeEntry *) MemoryContextAlloc(use_mcxt, - sizeof(PgStat_StatBeEntry) * maxbackends); + sizeof(PgStat_StatBeEntry) * maxbackends); break; /* @@ -2811,9 +2804,9 @@ pgstat_recv_bestart(PgStat_MsgBestart *msg, int len) PgStat_StatBeEntry *entry; /* - * If the backend is known dead, we ignore the message -- we don't - * want to update the backend entry's state since this BESTART - * message refers to an old, dead backend + * If the backend is known dead, we ignore the message -- we don't want to + * update the backend entry's state since this BESTART message refers to + * an old, dead backend */ if (pgstat_add_backend(&msg->m_hdr) != 0) return; @@ -2840,7 +2833,7 @@ pgstat_recv_beterm(PgStat_MsgBeterm *msg, int len) /* ---------- * pgstat_recv_autovac() - * - * Process an autovacuum signalling message. + * Process an autovacuum signalling message. * ---------- */ static void @@ -2851,10 +2844,9 @@ pgstat_recv_autovac(PgStat_MsgAutovacStart *msg, int len) /* * Lookup the database in the hashtable. Don't create the entry if it * doesn't exist, because autovacuum may be processing a template - * database. If this isn't the case, the database is most likely to - * have an entry already. (If it doesn't, not much harm is done - * anyway -- it'll get created as soon as somebody actually uses - * the database.) + * database. If this isn't the case, the database is most likely to have + * an entry already. (If it doesn't, not much harm is done anyway -- + * it'll get created as soon as somebody actually uses the database.) */ dbentry = pgstat_get_db_entry(msg->m_databaseid, false); if (dbentry == NULL) @@ -2869,7 +2861,7 @@ pgstat_recv_autovac(PgStat_MsgAutovacStart *msg, int len) /* ---------- * pgstat_recv_vacuum() - * - * Process a VACUUM message. + * Process a VACUUM message. * ---------- */ static void @@ -2881,10 +2873,10 @@ pgstat_recv_vacuum(PgStat_MsgVacuum *msg, int len) bool create; /* - * If we don't know about the database, ignore the message, because it - * may be autovacuum processing a template database. But if the message - * is for database InvalidOid, don't ignore it, because we are getting - * a message from vacuuming a shared relation. + * If we don't know about the database, ignore the message, because it may + * be autovacuum processing a template database. But if the message is + * for database InvalidOid, don't ignore it, because we are getting a + * message from vacuuming a shared relation. */ create = (msg->m_databaseid == InvalidOid); @@ -2933,7 +2925,7 @@ pgstat_recv_vacuum(PgStat_MsgVacuum *msg, int len) /* ---------- * pgstat_recv_analyze() - * - * Process an ANALYZE message. + * Process an ANALYZE message. * ---------- */ static void @@ -2944,9 +2936,9 @@ pgstat_recv_analyze(PgStat_MsgAnalyze *msg, int len) bool found; /* - * Note that we do create the database entry here, as opposed to what - * we do on AutovacStart and Vacuum messages. This is because - * autovacuum never executes ANALYZE on template databases. + * Note that we do create the database entry here, as opposed to what we + * do on AutovacStart and Vacuum messages. This is because autovacuum + * never executes ANALYZE on template databases. */ dbentry = pgstat_get_db_entry(msg->m_databaseid, true); @@ -2995,9 +2987,8 @@ pgstat_recv_activity(PgStat_MsgActivity *msg, int len) PgStat_StatBeEntry *entry; /* - * Here we check explicitly for 0 return, since we don't want to - * mangle the activity of an active backend by a delayed packet from a - * dead one. + * Here we check explicitly for 0 return, since we don't want to mangle + * the activity of an active backend by a delayed packet from a dead one. */ if (pgstat_add_backend(&msg->m_hdr) != 0) return; @@ -3034,8 +3025,8 @@ pgstat_recv_tabstat(PgStat_MsgTabstat *msg, int len) dbentry = pgstat_get_db_entry(msg->m_databaseid, true); /* - * If the database is marked for destroy, this is a delayed UDP packet - * and not worth being counted. + * If the database is marked for destroy, this is a delayed UDP packet and + * not worth being counted. */ if (dbentry->destroy > 0) return; @@ -3049,14 +3040,14 @@ pgstat_recv_tabstat(PgStat_MsgTabstat *msg, int len) for (i = 0; i < msg->m_nentries; i++) { tabentry = (PgStat_StatTabEntry *) hash_search(dbentry->tables, - (void *) &(tabmsg[i].t_id), - HASH_ENTER, &found); + (void *) &(tabmsg[i].t_id), + HASH_ENTER, &found); if (!found) { /* - * If it's a new table entry, initialize counters to the - * values we just got. + * If it's a new table entry, initialize counters to the values we + * just got. */ tabentry->numscans = tabmsg[i].t_numscans; tabentry->tuples_returned = tabmsg[i].t_tuples_returned; @@ -3064,7 +3055,7 @@ pgstat_recv_tabstat(PgStat_MsgTabstat *msg, int len) tabentry->tuples_inserted = tabmsg[i].t_tuples_inserted; tabentry->tuples_updated = tabmsg[i].t_tuples_updated; tabentry->tuples_deleted = tabmsg[i].t_tuples_deleted; - + tabentry->n_live_tuples = tabmsg[i].t_tuples_inserted; tabentry->n_dead_tuples = tabmsg[i].t_tuples_updated + tabmsg[i].t_tuples_deleted; @@ -3132,8 +3123,8 @@ pgstat_recv_tabpurge(PgStat_MsgTabpurge *msg, int len) return; /* - * If the database is marked for destroy, this is a delayed UDP packet - * and the tables will go away at DB destruction. + * If the database is marked for destroy, this is a delayed UDP packet and + * the tables will go away at DB destruction. */ if (dbentry->destroy > 0) return; @@ -3144,7 +3135,7 @@ pgstat_recv_tabpurge(PgStat_MsgTabpurge *msg, int len) for (i = 0; i < msg->m_nentries; i++) { tabentry = (PgStat_StatTabEntry *) hash_search(dbentry->tables, - (void *) &(msg->m_tableid[i]), + (void *) &(msg->m_tableid[i]), HASH_FIND, NULL); if (tabentry) tabentry->destroy = PGSTAT_DESTROY_COUNT; @@ -3209,8 +3200,8 @@ pgstat_recv_resetcounter(PgStat_MsgResetcounter *msg, int len) return; /* - * We simply throw away all the database's table entries by - * recreating a new hash table for them. + * We simply throw away all the database's table entries by recreating a + * new hash table for them. */ if (dbentry->tables != NULL) hash_destroy(dbentry->tables); diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index aee26add55..fd7b27193c 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -37,7 +37,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.468 2005/09/22 15:33:35 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.469 2005/10/15 02:49:23 momjian Exp $ * * NOTES * @@ -301,9 +301,10 @@ static pid_t internal_forkexec(int argc, char *argv[], Port *port); #ifdef WIN32 typedef struct { - SOCKET origsocket; /* Original socket value, or -1 if not a socket */ + SOCKET origsocket; /* Original socket value, or -1 if not a + * socket */ WSAPROTOCOL_INFO wsainfo; -} InheritableSocket; +} InheritableSocket; #else typedef int InheritableSocket; #endif @@ -315,51 +316,51 @@ typedef struct LWLock LWLock; /* ugly kluge */ */ typedef struct { - Port port; + Port port; InheritableSocket portsocket; - char DataDir[MAXPGPATH]; - int ListenSocket[MAXLISTEN]; - long MyCancelKey; + char DataDir[MAXPGPATH]; + int ListenSocket[MAXLISTEN]; + long MyCancelKey; unsigned long UsedShmemSegID; - void *UsedShmemSegAddr; - slock_t *ShmemLock; - slock_t *ShmemIndexLock; + void *UsedShmemSegAddr; + slock_t *ShmemLock; + slock_t *ShmemIndexLock; VariableCache ShmemVariableCache; - void *ShmemIndexAlloc; - Backend *ShmemBackendArray; - LWLock *LWLockArray; - slock_t *ProcStructLock; + void *ShmemIndexAlloc; + Backend *ShmemBackendArray; + LWLock *LWLockArray; + slock_t *ProcStructLock; InheritableSocket pgStatSock; InheritableSocket pgStatPipe0; InheritableSocket pgStatPipe1; - pid_t PostmasterPid; + pid_t PostmasterPid; TimestampTz PgStartTime; #ifdef WIN32 - HANDLE PostmasterHandle; - HANDLE initial_signal_pipe; - HANDLE syslogPipe[2]; + HANDLE PostmasterHandle; + HANDLE initial_signal_pipe; + HANDLE syslogPipe[2]; #else - int syslogPipe[2]; + int syslogPipe[2]; #endif - char my_exec_path[MAXPGPATH]; - char pkglib_path[MAXPGPATH]; - char ExtraOptions[MAXPGPATH]; - char lc_collate[LOCALE_NAME_BUFLEN]; - char lc_ctype[LOCALE_NAME_BUFLEN]; -} BackendParameters; + char my_exec_path[MAXPGPATH]; + char pkglib_path[MAXPGPATH]; + char ExtraOptions[MAXPGPATH]; + char lc_collate[LOCALE_NAME_BUFLEN]; + char lc_ctype[LOCALE_NAME_BUFLEN]; +} BackendParameters; static void read_backend_variables(char *id, Port *port); -static void restore_backend_variables(BackendParameters *param, Port *port); +static void restore_backend_variables(BackendParameters * param, Port *port); + #ifndef WIN32 -static bool save_backend_variables(BackendParameters *param, Port *port); +static bool save_backend_variables(BackendParameters * param, Port *port); #else -static bool save_backend_variables(BackendParameters *param, Port *port, - HANDLE childProcess, pid_t childPid); +static bool save_backend_variables(BackendParameters * param, Port *port, + HANDLE childProcess, pid_t childPid); #endif static void ShmemBackendArrayAdd(Backend *bn); static void ShmemBackendArrayRemove(pid_t pid); - #endif /* EXEC_BACKEND */ #define StartupDataBase() StartChildProcess(BS_XLOG_STARTUP) @@ -378,7 +379,7 @@ PostmasterMain(int argc, char *argv[]) int i; /* This will call exit() if strdup() fails. */ - progname = get_progname(argv[0]); + progname = get_progname(argv[0]); MyProcPid = PostmasterPid = getpid(); @@ -408,8 +409,7 @@ PostmasterMain(int argc, char *argv[]) #endif /* - * for security, no dir or file created can be group or other - * accessible + * for security, no dir or file created can be group or other accessible */ umask((mode_t) 0077); @@ -419,10 +419,10 @@ PostmasterMain(int argc, char *argv[]) MemoryContextInit(); /* - * By default, palloc() requests in the postmaster will be allocated - * in the PostmasterContext, which is space that can be recycled by - * backends. Allocated data that needs to be available to backends - * should be allocated in TopMemoryContext. + * By default, palloc() requests in the postmaster will be allocated in + * the PostmasterContext, which is space that can be recycled by backends. + * Allocated data that needs to be available to backends should be + * allocated in TopMemoryContext. */ PostmasterContext = AllocSetContextCreate(TopMemoryContext, "Postmaster", @@ -496,8 +496,7 @@ PostmasterMain(int argc, char *argv[]) /* * ignore this flag. This may be passed in because the - * program was run as 'postgres -M' instead of - * 'postmaster' + * program was run as 'postgres -M' instead of 'postmaster' */ break; case 'N': @@ -511,8 +510,7 @@ PostmasterMain(int argc, char *argv[]) case 'o': /* - * Other options to pass to the backend on the command - * line + * Other options to pass to the backend on the command line */ snprintf(ExtraOptions + strlen(ExtraOptions), sizeof(ExtraOptions) - strlen(ExtraOptions), @@ -524,20 +522,18 @@ PostmasterMain(int argc, char *argv[]) case 'S': /* - * Start in 'S'ilent mode (disassociate from controlling - * tty). You may also think of this as 'S'ysV mode since - * it's most badly needed on SysV-derived systems like - * SVR4 and HP-UX. + * Start in 'S'ilent mode (disassociate from controlling tty). + * You may also think of this as 'S'ysV mode since it's most + * badly needed on SysV-derived systems like SVR4 and HP-UX. */ SetConfigOption("silent_mode", "true", PGC_POSTMASTER, PGC_S_ARGV); break; case 's': /* - * In the event that some backend dumps core, send - * SIGSTOP, rather than SIGQUIT, to all its peers. This - * lets the wily post_hacker collect core dumps from - * everyone. + * In the event that some backend dumps core, send SIGSTOP, + * rather than SIGQUIT, to all its peers. This lets the wily + * post_hacker collect core dumps from everyone. */ SendStop = true; break; @@ -593,13 +589,13 @@ PostmasterMain(int argc, char *argv[]) if (find_other_exec(argv[0], "postgres", PG_VERSIONSTR, postgres_exec_path) < 0) ereport(FATAL, - (errmsg("%s: could not locate matching postgres executable", - progname))); + (errmsg("%s: could not locate matching postgres executable", + progname))); #endif /* - * Locate the proper configuration files and data directory, and - * read postgresql.conf for the first time. + * Locate the proper configuration files and data directory, and read + * postgresql.conf for the first time. */ if (!SelectConfigFiles(userDoption, progname)) ExitPostmaster(2); @@ -616,9 +612,8 @@ PostmasterMain(int argc, char *argv[]) if (NBuffers < 2 * MaxBackends || NBuffers < 16) { /* - * Do not accept -B so small that backends are likely to starve - * for lack of buffers. The specific choices here are somewhat - * arbitrary. + * Do not accept -B so small that backends are likely to starve for + * lack of buffers. The specific choices here are somewhat arbitrary. */ write_stderr("%s: the number of buffers (-B) must be at least twice the number of allowed connections (-N) and at least 16\n", progname); ExitPostmaster(1); @@ -654,15 +649,15 @@ PostmasterMain(int argc, char *argv[]) char **p; ereport(DEBUG3, - (errmsg_internal("%s: PostmasterMain: initial environ dump:", - progname))); + (errmsg_internal("%s: PostmasterMain: initial environ dump:", + progname))); ereport(DEBUG3, - (errmsg_internal("-----------------------------------------"))); + (errmsg_internal("-----------------------------------------"))); for (p = environ; *p; ++p) ereport(DEBUG3, (errmsg_internal("\t%s", *p))); ereport(DEBUG3, - (errmsg_internal("-----------------------------------------"))); + (errmsg_internal("-----------------------------------------"))); } /* @@ -683,8 +678,8 @@ PostmasterMain(int argc, char *argv[]) /* * Fork away from controlling terminal, if -S specified. * - * Must do this before we grab any interlock files, else the interlocks - * will show the wrong PID. + * Must do this before we grab any interlock files, else the interlocks will + * show the wrong PID. */ if (SilentMode) pmdaemonize(); @@ -692,18 +687,17 @@ PostmasterMain(int argc, char *argv[]) /* * Create lockfile for data directory. * - * We want to do this before we try to grab the input sockets, because - * the data directory interlock is more reliable than the socket-file - * interlock (thanks to whoever decided to put socket files in /tmp - * :-(). For the same reason, it's best to grab the TCP socket(s) - * before the Unix socket. + * We want to do this before we try to grab the input sockets, because the + * data directory interlock is more reliable than the socket-file + * interlock (thanks to whoever decided to put socket files in /tmp :-(). + * For the same reason, it's best to grab the TCP socket(s) before the + * Unix socket. */ CreateDataDirLockFile(true); /* * Remove old temporary files. At this point there can be no other - * Postgres processes running in this directory, so this should be - * safe. + * Postgres processes running in this directory, so this should be safe. */ RemovePgTempFiles(); @@ -729,7 +723,7 @@ PostmasterMain(int argc, char *argv[]) /* syntax error in list */ ereport(FATAL, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("invalid list syntax for \"listen_addresses\""))); + errmsg("invalid list syntax for \"listen_addresses\""))); } foreach(l, elemlist) @@ -750,8 +744,8 @@ PostmasterMain(int argc, char *argv[]) success++; else ereport(WARNING, - (errmsg("could not create listen socket for \"%s\"", - curhost))); + (errmsg("could not create listen socket for \"%s\"", + curhost))); } if (!success && list_length(elemlist)) @@ -771,7 +765,7 @@ PostmasterMain(int argc, char *argv[]) "", htonl(PostPortNumber), "", - (DNSServiceRegistrationReply) reg_reply, + (DNSServiceRegistrationReply) reg_reply, NULL); } #endif @@ -799,9 +793,8 @@ PostmasterMain(int argc, char *argv[]) reset_shared(PostPortNumber); /* - * Estimate number of openable files. This must happen after setting - * up semaphores, because on some platforms semaphores count as open - * files. + * Estimate number of openable files. This must happen after setting up + * semaphores, because on some platforms semaphores count as open files. */ set_max_safe_fds(); @@ -836,14 +829,13 @@ PostmasterMain(int argc, char *argv[]) TRUE, DUPLICATE_SAME_ACCESS) == 0) ereport(FATAL, - (errmsg_internal("could not duplicate postmaster handle: error code %d", - (int) GetLastError()))); + (errmsg_internal("could not duplicate postmaster handle: error code %d", + (int) GetLastError()))); #endif /* - * Record postmaster options. We delay this till now to avoid - * recording bogus options (eg, NBuffers too high for available - * memory). + * Record postmaster options. We delay this till now to avoid recording + * bogus options (eg, NBuffers too high for available memory). */ if (!CreateOptsFile(argc, argv, my_exec_path)) ExitPostmaster(1); @@ -904,8 +896,8 @@ PostmasterMain(int argc, char *argv[]) SysLoggerPID = SysLogger_Start(); /* - * Reset whereToSendOutput from Debug (its starting state) to None. - * This stops ereport from sending log messages to stderr unless + * Reset whereToSendOutput from Debug (its starting state) to None. This + * stops ereport from sending log messages to stderr unless * Log_destination permits. We don't do this until the postmaster is * fully launched, since startup failures may as well be reported to * stderr. @@ -941,8 +933,7 @@ PostmasterMain(int argc, char *argv[]) status = ServerLoop(); /* - * ServerLoop probably shouldn't ever return, but if it does, close - * down. + * ServerLoop probably shouldn't ever return, but if it does, close down. */ ExitPostmaster(status != STATUS_OK); @@ -972,8 +963,8 @@ checkDataDir(void) else ereport(FATAL, (errcode_for_file_access(), - errmsg("could not read permissions of directory \"%s\": %m", - DataDir))); + errmsg("could not read permissions of directory \"%s\": %m", + DataDir))); } /* @@ -997,13 +988,13 @@ checkDataDir(void) /* * Check if the directory has group or world access. If so, reject. * - * It would be possible to allow weaker constraints (for example, allow - * group access) but we cannot make a general assumption that that is - * okay; for example there are platforms where nearly all users customarily - * belong to the same group. Perhaps this test should be configurable. + * It would be possible to allow weaker constraints (for example, allow group + * access) but we cannot make a general assumption that that is okay; for + * example there are platforms where nearly all users customarily belong + * to the same group. Perhaps this test should be configurable. * - * XXX temporarily suppress check when on Windows, because there may not - * be proper support for Unix-y file permissions. Need to think of a + * XXX temporarily suppress check when on Windows, because there may not be + * proper support for Unix-y file permissions. Need to think of a * reasonable check to apply on Windows. */ #if !defined(WIN32) && !defined(__CYGWIN__) @@ -1129,9 +1120,9 @@ usage(const char *progname) printf(_(" -s send SIGSTOP to all backend servers if one dies\n")); printf(_("\nPlease read the documentation for the complete list of run-time\n" - "configuration settings and how to set them on the command line or in\n" - "the configuration file.\n\n" - "Report bugs to .\n")); + "configuration settings and how to set them on the command line or in\n" + "the configuration file.\n\n" + "Report bugs to .\n")); } @@ -1165,9 +1156,9 @@ ServerLoop(void) /* * Wait for something to happen. * - * We wait at most one minute, or the minimum autovacuum delay, to - * ensure that the other background tasks handled below get done - * even when no requests are arriving. + * We wait at most one minute, or the minimum autovacuum delay, to ensure + * that the other background tasks handled below get done even when no + * requests are arriving. */ memcpy((char *) &rmask, (char *) &readmask, sizeof(fd_set)); @@ -1179,8 +1170,8 @@ ServerLoop(void) selres = select(nSockets, &rmask, NULL, NULL, &timeout); /* - * Block all signals until we wait again. (This makes it safe for - * our signal handlers to do nontrivial work.) + * Block all signals until we wait again. (This makes it safe for our + * signal handlers to do nontrivial work.) */ PG_SETMASK(&BlockSig); @@ -1196,14 +1187,13 @@ ServerLoop(void) } /* - * New connection pending on any of our sockets? If so, fork a - * child process to deal with it. + * New connection pending on any of our sockets? If so, fork a child + * process to deal with it. */ if (selres > 0) { /* - * Select a random seed at the time of first receiving a - * request. + * Select a random seed at the time of first receiving a request. */ while (random_seed == 0) { @@ -1212,8 +1202,8 @@ ServerLoop(void) /* * We are not sure how much precision is in tv_usec, so we * swap the high and low 16 bits of 'later' and XOR them with - * 'earlier'. On the off chance that the result is 0, we - * loop until it isn't. + * 'earlier'. On the off chance that the result is 0, we loop + * until it isn't. */ random_seed = earlier.tv_usec ^ ((later.tv_usec << 16) | @@ -1232,8 +1222,8 @@ ServerLoop(void) BackendStartup(port); /* - * We no longer need the open socket or port - * structure in this process + * We no longer need the open socket or port structure + * in this process */ StreamClose(port->sock); ConnFree(port); @@ -1261,8 +1251,8 @@ ServerLoop(void) /* * Start a new autovacuum process, if there isn't one running already. - * (It'll die relatively quickly.) We check that it's not started - * too frequently in autovac_start. + * (It'll die relatively quickly.) We check that it's not started too + * frequently in autovac_start. */ if (AutoVacuumingActive() && AutoVacPID == 0 && StartupPID == 0 && !FatalError && Shutdown == NoShutdown) @@ -1279,10 +1269,9 @@ ServerLoop(void) PgStatPID = pgstat_start(); /* - * Touch the socket and lock file every 58 minutes, to - * ensure that they are not removed by overzealous /tmp-cleaning - * tasks. We assume no one runs cleaners with cutoff times of - * less than an hour ... + * Touch the socket and lock file every 58 minutes, to ensure that + * they are not removed by overzealous /tmp-cleaning tasks. We assume + * no one runs cleaners with cutoff times of less than an hour ... */ now = time(NULL); if (now - last_touch_time >= 58 * SECS_PER_MINUTE) @@ -1345,8 +1334,8 @@ ProcessStartupPacket(Port *port, bool SSLdone) { /* * EOF after SSLdone probably means the client didn't like our - * response to NEGOTIATE_SSL_CODE. That's not an error condition, - * so don't clutter the log with a complaint. + * response to NEGOTIATE_SSL_CODE. That's not an error condition, so + * don't clutter the log with a complaint. */ if (!SSLdone) ereport(COMMERROR, @@ -1369,9 +1358,9 @@ ProcessStartupPacket(Port *port, bool SSLdone) /* * Allocate at least the size of an old-style startup packet, plus one - * extra byte, and make sure all are zeroes. This ensures we will - * have null termination of all strings, in both fixed- and - * variable-length packet layouts. + * extra byte, and make sure all are zeroes. This ensures we will have + * null termination of all strings, in both fixed- and variable-length + * packet layouts. */ if (len <= (int32) sizeof(StartupPacket)) buf = palloc0(sizeof(StartupPacket) + 1); @@ -1415,7 +1404,7 @@ ProcessStartupPacket(Port *port, bool SSLdone) { ereport(COMMERROR, (errcode_for_socket_access(), - errmsg("failed to send SSL negotiation response: %m"))); + errmsg("failed to send SSL negotiation response: %m"))); return STATUS_ERROR; /* close the connection */ } @@ -1431,32 +1420,32 @@ ProcessStartupPacket(Port *port, bool SSLdone) /* Could add additional special packet types here */ /* - * Set FrontendProtocol now so that ereport() knows what format to - * send if we fail during startup. + * Set FrontendProtocol now so that ereport() knows what format to send if + * we fail during startup. */ FrontendProtocol = proto; /* Check we can handle the protocol the frontend is using. */ if (PG_PROTOCOL_MAJOR(proto) < PG_PROTOCOL_MAJOR(PG_PROTOCOL_EARLIEST) || - PG_PROTOCOL_MAJOR(proto) > PG_PROTOCOL_MAJOR(PG_PROTOCOL_LATEST) || - (PG_PROTOCOL_MAJOR(proto) == PG_PROTOCOL_MAJOR(PG_PROTOCOL_LATEST) && - PG_PROTOCOL_MINOR(proto) > PG_PROTOCOL_MINOR(PG_PROTOCOL_LATEST))) + PG_PROTOCOL_MAJOR(proto) > PG_PROTOCOL_MAJOR(PG_PROTOCOL_LATEST) || + (PG_PROTOCOL_MAJOR(proto) == PG_PROTOCOL_MAJOR(PG_PROTOCOL_LATEST) && + PG_PROTOCOL_MINOR(proto) > PG_PROTOCOL_MINOR(PG_PROTOCOL_LATEST))) ereport(FATAL, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("unsupported frontend protocol %u.%u: server supports %u.0 to %u.%u", - PG_PROTOCOL_MAJOR(proto), PG_PROTOCOL_MINOR(proto), + PG_PROTOCOL_MAJOR(proto), PG_PROTOCOL_MINOR(proto), PG_PROTOCOL_MAJOR(PG_PROTOCOL_EARLIEST), PG_PROTOCOL_MAJOR(PG_PROTOCOL_LATEST), PG_PROTOCOL_MINOR(PG_PROTOCOL_LATEST)))); /* - * Now fetch parameters out of startup packet and save them into the - * Port structure. All data structures attached to the Port struct - * must be allocated in TopMemoryContext so that they won't disappear - * when we pass them to PostgresMain (see BackendRun). We need not - * worry about leaking this storage on failure, since we aren't in the - * postmaster process anymore. + * Now fetch parameters out of startup packet and save them into the Port + * structure. All data structures attached to the Port struct must be + * allocated in TopMemoryContext so that they won't disappear when we pass + * them to PostgresMain (see BackendRun). We need not worry about leaking + * this storage on failure, since we aren't in the postmaster process + * anymore. */ oldcontext = MemoryContextSwitchTo(TopMemoryContext); @@ -1465,9 +1454,9 @@ ProcessStartupPacket(Port *port, bool SSLdone) int32 offset = sizeof(ProtocolVersion); /* - * Scan packet body for name/option pairs. We can assume any - * string beginning within the packet body is null-terminated, - * thanks to zeroing extra byte above. + * Scan packet body for name/option pairs. We can assume any string + * beginning within the packet body is null-terminated, thanks to + * zeroing extra byte above. */ port->guc_options = NIL; @@ -1513,11 +1502,10 @@ ProcessStartupPacket(Port *port, bool SSLdone) else { /* - * Get the parameters from the old-style, fixed-width-fields - * startup packet as C strings. The packet destination was - * cleared first so a short packet has zeros silently added. We - * have to be prepared to truncate the pstrdup result for oversize - * fields, though. + * Get the parameters from the old-style, fixed-width-fields startup + * packet as C strings. The packet destination was cleared first so a + * short packet has zeros silently added. We have to be prepared to + * truncate the pstrdup result for oversize fields, though. */ StartupPacket *packet = (StartupPacket *) buf; @@ -1537,7 +1525,7 @@ ProcessStartupPacket(Port *port, bool SSLdone) if (port->user_name == NULL || port->user_name[0] == '\0') ereport(FATAL, (errcode(ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION), - errmsg("no PostgreSQL user name specified in startup packet"))); + errmsg("no PostgreSQL user name specified in startup packet"))); /* The database defaults to the user name. */ if (port->database_name == NULL || port->database_name[0] == '\0') @@ -1546,10 +1534,10 @@ ProcessStartupPacket(Port *port, bool SSLdone) if (Db_user_namespace) { /* - * If user@, it is a global user, remove '@'. We only want to do - * this if there is an '@' at the end and no earlier in the user - * string or they may fake as a local user of another database - * attaching to this database. + * If user@, it is a global user, remove '@'. We only want to do this + * if there is an '@' at the end and no earlier in the user string or + * they may fake as a local user of another database attaching to this + * database. */ if (strchr(port->user_name, '@') == port->user_name + strlen(port->user_name) - 1) @@ -1567,8 +1555,8 @@ ProcessStartupPacket(Port *port, bool SSLdone) } /* - * Truncate given database and user names to length of a Postgres - * name. This avoids lookup failures when overlength names are given. + * Truncate given database and user names to length of a Postgres name. + * This avoids lookup failures when overlength names are given. */ if (strlen(port->database_name) >= NAMEDATALEN) port->database_name[NAMEDATALEN - 1] = '\0'; @@ -1581,9 +1569,9 @@ ProcessStartupPacket(Port *port, bool SSLdone) MemoryContextSwitchTo(oldcontext); /* - * If we're going to reject the connection due to database state, say - * so now instead of wasting cycles on an authentication exchange. - * (This also allows a pg_ping utility to be written.) + * If we're going to reject the connection due to database state, say so + * now instead of wasting cycles on an authentication exchange. (This also + * allows a pg_ping utility to be written.) */ switch (port->canAcceptConnections) { @@ -1628,6 +1616,7 @@ processCancelRequest(Port *port, void *pkt) int backendPID; long cancelAuthCode; Backend *bp; + #ifndef EXEC_BACKEND Dlelem *curr; #else @@ -1638,9 +1627,9 @@ processCancelRequest(Port *port, void *pkt) cancelAuthCode = (long) ntohl(canc->cancelAuthCode); /* - * See if we have a matching backend. In the EXEC_BACKEND case, we - * can no longer access the postmaster's own backend list, and must - * rely on the duplicate array in shared memory. + * See if we have a matching backend. In the EXEC_BACKEND case, we can no + * longer access the postmaster's own backend list, and must rely on the + * duplicate array in shared memory. */ #ifndef EXEC_BACKEND for (curr = DLGetHead(BackendList); curr; curr = DLGetSucc(curr)) @@ -1664,8 +1653,8 @@ processCancelRequest(Port *port, void *pkt) else /* Right PID, wrong key: no way, Jose */ ereport(DEBUG2, - (errmsg_internal("bad key in cancel request for process %d", - backendPID))); + (errmsg_internal("bad key in cancel request for process %d", + backendPID))); return; } } @@ -1694,10 +1683,10 @@ canAcceptConnections(void) * Don't start too many children. * * We allow more connections than we can have backends here because some - * might still be authenticating; they might fail auth, or some - * existing backend might exit before the auth cycle is completed. The - * exact MaxBackends limit is enforced when a new backend tries to - * join the shared-inval backend array. + * might still be authenticating; they might fail auth, or some existing + * backend might exit before the auth cycle is completed. The exact + * MaxBackends limit is enforced when a new backend tries to join the + * shared-inval backend array. */ if (CountChildren() >= 2 * MaxBackends) return CAC_TOOMANY; @@ -1731,12 +1720,11 @@ ConnCreate(int serverFd) else { /* - * Precompute password salt values to use for this connection. - * It's slightly annoying to do this long in advance of knowing - * whether we'll need 'em or not, but we must do the random() - * calls before we fork, not after. Else the postmaster's random - * sequence won't get advanced, and all backends would end up - * using the same salt... + * Precompute password salt values to use for this connection. It's + * slightly annoying to do this long in advance of knowing whether + * we'll need 'em or not, but we must do the random() calls before we + * fork, not after. Else the postmaster's random sequence won't get + * advanced, and all backends would end up using the same salt... */ RandomSalt(port->cryptSalt, port->md5Salt); } @@ -1808,10 +1796,10 @@ reset_shared(int port) /* * Create or re-create shared memory and semaphores. * - * Note: in each "cycle of life" we will normally assign the same IPC - * keys (if using SysV shmem and/or semas), since the port number is - * used to determine IPC keys. This helps ensure that we will clean - * up dead IPC objects if the postmaster crashes and is restarted. + * Note: in each "cycle of life" we will normally assign the same IPC keys + * (if using SysV shmem and/or semas), since the port number is used to + * determine IPC keys. This helps ensure that we will clean up dead IPC + * objects if the postmaster crashes and is restarted. */ CreateSharedMemoryAndSemaphores(false, port); } @@ -1830,7 +1818,7 @@ SIGHUP_handler(SIGNAL_ARGS) if (Shutdown <= SmartShutdown) { ereport(LOG, - (errmsg("received SIGHUP, reloading configuration files"))); + (errmsg("received SIGHUP, reloading configuration files"))); ProcessConfigFile(PGC_SIGHUP); SignalChildren(SIGHUP); if (BgWriterPID != 0) @@ -1925,8 +1913,8 @@ pmdie(SIGNAL_ARGS) /* * Fast Shutdown: * - * Abort all children with SIGTERM (rollback active transactions - * and exit) and shut down when they are gone. + * Abort all children with SIGTERM (rollback active transactions and + * exit) and shut down when they are gone. */ if (Shutdown >= FastShutdown) break; @@ -1951,8 +1939,8 @@ pmdie(SIGNAL_ARGS) /* * No children left. Begin shutdown of data base system. * - * Note: if we previously got SIGTERM then we may send SIGUSR2 to - * the bgwriter a second time here. This should be harmless. + * Note: if we previously got SIGTERM then we may send SIGUSR2 to the + * bgwriter a second time here. This should be harmless. */ if (StartupPID != 0 || FatalError) break; /* let reaper() handle this */ @@ -2011,7 +1999,6 @@ reaper(SIGNAL_ARGS) #ifdef HAVE_WAITPID int status; /* backend exit status */ - #else #ifndef WIN32 union wait status; /* backend exit status */ @@ -2037,10 +2024,9 @@ reaper(SIGNAL_ARGS) while ((pid = win32_waitpid(&exitstatus)) > 0) { /* - * We need to do this here, and not in CleanupBackend, since this - * is to be called on all children when we are done with them. - * Could move to LogChildExit, but that seems like asking for - * future trouble... + * We need to do this here, and not in CleanupBackend, since this is + * to be called on all children when we are done with them. Could move + * to LogChildExit, but that seems like asking for future trouble... */ win32_RemoveChild(pid); #endif /* WIN32 */ @@ -2057,7 +2043,7 @@ reaper(SIGNAL_ARGS) LogChildExit(LOG, _("startup process"), pid, exitstatus); ereport(LOG, - (errmsg("aborting startup due to startup process failure"))); + (errmsg("aborting startup due to startup process failure"))); ExitPostmaster(1); } @@ -2068,9 +2054,9 @@ reaper(SIGNAL_ARGS) FatalError = false; /* - * Load the flat authorization file into postmaster's cache. - * The startup process has recomputed this from the database - * contents, so we wait till it finishes before loading it. + * Load the flat authorization file into postmaster's cache. The + * startup process has recomputed this from the database contents, + * so we wait till it finishes before loading it. */ load_role(); @@ -2083,8 +2069,8 @@ reaper(SIGNAL_ARGS) /* * Go to shutdown mode if a shutdown request was pending. - * Otherwise, try to start the archiver and stats collector - * too. (We could, but don't, try to start autovacuum here.) + * Otherwise, try to start the archiver and stats collector too. + * (We could, but don't, try to start autovacuum here.) */ if (Shutdown > NoShutdown && BgWriterPID != 0) kill(BgWriterPID, SIGUSR2); @@ -2109,16 +2095,15 @@ reaper(SIGNAL_ARGS) !DLGetHead(BackendList) && AutoVacPID == 0) { /* - * Normal postmaster exit is here: we've seen normal exit - * of the bgwriter after it's been told to shut down. We - * expect that it wrote a shutdown checkpoint. (If for - * some reason it didn't, recovery will occur on next - * postmaster start.) + * Normal postmaster exit is here: we've seen normal exit of + * the bgwriter after it's been told to shut down. We expect + * that it wrote a shutdown checkpoint. (If for some reason + * it didn't, recovery will occur on next postmaster start.) * - * Note: we do not wait around for exit of the archiver or - * stats processes. They've been sent SIGQUIT by this - * point, and in any case contain logic to commit - * hara-kiri if they notice the postmaster is gone. + * Note: we do not wait around for exit of the archiver or stats + * processes. They've been sent SIGQUIT by this point, and in + * any case contain logic to commit hara-kiri if they notice + * the postmaster is gone. */ ExitPostmaster(0); } @@ -2132,9 +2117,9 @@ reaper(SIGNAL_ARGS) } /* - * Was it the autovacuum process? Normal exit can be ignored; - * we'll start a new one at the next iteration of the postmaster's - * main loop, if necessary. + * Was it the autovacuum process? Normal exit can be ignored; we'll + * start a new one at the next iteration of the postmaster's main + * loop, if necessary. * * An unexpected exit must crash the system. */ @@ -2149,9 +2134,9 @@ reaper(SIGNAL_ARGS) } /* - * Was it the archiver? If so, just try to start a new one; no - * need to force reset of the rest of the system. (If fail, we'll - * try again in future cycles of the main loop.) + * Was it the archiver? If so, just try to start a new one; no need + * to force reset of the rest of the system. (If fail, we'll try + * again in future cycles of the main loop.) */ if (PgArchPID != 0 && pid == PgArchPID) { @@ -2166,9 +2151,9 @@ reaper(SIGNAL_ARGS) } /* - * Was it the statistics collector? If so, just try to start a - * new one; no need to force reset of the rest of the system. (If - * fail, we'll try again in future cycles of the main loop.) + * Was it the statistics collector? If so, just try to start a new + * one; no need to force reset of the rest of the system. (If fail, + * we'll try again in future cycles of the main loop.) */ if (PgStatPID != 0 && pid == PgStatPID) { @@ -2203,14 +2188,14 @@ reaper(SIGNAL_ARGS) { /* * Wait for all important children to exit, then reset shmem and - * StartupDataBase. (We can ignore the archiver and stats - * processes here since they are not connected to shmem.) + * StartupDataBase. (We can ignore the archiver and stats processes + * here since they are not connected to shmem.) */ if (DLGetHead(BackendList) || StartupPID != 0 || BgWriterPID != 0 || AutoVacPID != 0) goto reaper_done; ereport(LOG, - (errmsg("all server processes terminated; reinitializing"))); + (errmsg("all server processes terminated; reinitializing"))); shmem_exit(0); reset_shared(PostPortNumber); @@ -2259,10 +2244,10 @@ CleanupBackend(int pid, LogChildExit(DEBUG2, _("server process"), pid, exitstatus); /* - * If a backend dies in an ugly way (i.e. exit status not 0) then we - * must signal all other backends to quickdie. If exit status is zero - * we assume everything is hunky dory and simply remove the backend - * from the active backend list. + * If a backend dies in an ugly way (i.e. exit status not 0) then we must + * signal all other backends to quickdie. If exit status is zero we + * assume everything is hunky dory and simply remove the backend from the + * active backend list. */ if (exitstatus != 0) { @@ -2303,15 +2288,14 @@ HandleChildCrash(int pid, int exitstatus, const char *procname) Backend *bp; /* - * Make log entry unless there was a previous crash (if so, nonzero - * exit status is to be expected in SIGQUIT response; don't clutter - * log) + * Make log entry unless there was a previous crash (if so, nonzero exit + * status is to be expected in SIGQUIT response; don't clutter log) */ if (!FatalError) { LogChildExit(LOG, procname, pid, exitstatus); ereport(LOG, - (errmsg("terminating any other active server processes"))); + (errmsg("terminating any other active server processes"))); } /* Process regular backends */ @@ -2337,19 +2321,19 @@ HandleChildCrash(int pid, int exitstatus, const char *procname) else { /* - * This backend is still alive. Unless we did so already, - * tell it to commit hara-kiri. + * This backend is still alive. Unless we did so already, tell it + * to commit hara-kiri. * - * SIGQUIT is the special signal that says exit without proc_exit - * and let the user know what's going on. But if SendStop is - * set (-s on command line), then we send SIGSTOP instead, so - * that we can get core dumps from all backends by hand. + * SIGQUIT is the special signal that says exit without proc_exit and + * let the user know what's going on. But if SendStop is set (-s + * on command line), then we send SIGSTOP instead, so that we can + * get core dumps from all backends by hand. */ if (!FatalError) { ereport(DEBUG2, (errmsg_internal("sending %s to process %d", - (SendStop ? "SIGSTOP" : "SIGQUIT"), + (SendStop ? "SIGSTOP" : "SIGQUIT"), (int) bp->pid))); kill(bp->pid, (SendStop ? SIGSTOP : SIGQUIT)); } @@ -2417,8 +2401,8 @@ LogChildExit(int lev, const char *procname, int pid, int exitstatus) ereport(lev, /* - * translator: %s is a noun phrase describing a child process, - * such as "server process" + * translator: %s is a noun phrase describing a child process, such as + * "server process" */ (errmsg("%s (PID %d) exited with exit code %d", procname, pid, WEXITSTATUS(exitstatus)))); @@ -2426,8 +2410,8 @@ LogChildExit(int lev, const char *procname, int pid, int exitstatus) ereport(lev, /* - * translator: %s is a noun phrase describing a child process, - * such as "server process" + * translator: %s is a noun phrase describing a child process, such as + * "server process" */ (errmsg("%s (PID %d) was terminated by signal %d", procname, pid, WTERMSIG(exitstatus)))); @@ -2435,8 +2419,8 @@ LogChildExit(int lev, const char *procname, int pid, int exitstatus) ereport(lev, /* - * translator: %s is a noun phrase describing a child process, - * such as "server process" + * translator: %s is a noun phrase describing a child process, such as + * "server process" */ (errmsg("%s (PID %d) exited with unexpected status %d", procname, pid, exitstatus))); @@ -2480,8 +2464,8 @@ BackendStartup(Port *port) MyCancelKey = PostmasterRandom(); /* - * Make room for backend data structure. Better before the fork() so - * we can handle failure cleanly. + * Make room for backend data structure. Better before the fork() so we + * can handle failure cleanly. */ bn = (Backend *) malloc(sizeof(Backend)); if (!bn) @@ -2514,7 +2498,7 @@ BackendStartup(Port *port) free(bn); errno = save_errno; ereport(LOG, - (errmsg("could not fork new process for connection: %m"))); + (errmsg("could not fork new process for connection: %m"))); report_fork_failure_to_client(port, save_errno); return STATUS_ERROR; } @@ -2525,8 +2509,8 @@ BackendStartup(Port *port) (int) pid, port->sock))); /* - * Everything's been successful, it's safe to add this backend to our - * list of backends. + * Everything's been successful, it's safe to add this backend to our list + * of backends. */ bn->pid = pid; bn->cancel_key = MyCancelKey; @@ -2638,10 +2622,10 @@ BackendRun(Port *port) /* * PreAuthDelay is a debugging aid for investigating problems in the - * authentication cycle: it can be set in postgresql.conf to allow - * time to attach to the newly-forked backend with a debugger. (See - * also the -W backend switch, which we allow clients to pass through - * PGOPTIONS, but it is not honored until after authentication.) + * authentication cycle: it can be set in postgresql.conf to allow time to + * attach to the newly-forked backend with a debugger. (See also the -W + * backend switch, which we allow clients to pass through PGOPTIONS, but + * it is not honored until after authentication.) */ if (PreAuthDelay > 0) pg_usleep(PreAuthDelay * 1000000L); @@ -2657,18 +2641,17 @@ BackendRun(Port *port) port->commandTag = ""; /* - * Initialize libpq and enable reporting of ereport errors to the - * client. Must do this now because authentication uses libpq to send - * messages. + * Initialize libpq and enable reporting of ereport errors to the client. + * Must do this now because authentication uses libpq to send messages. */ pq_init(); /* initialize libpq to talk to client */ whereToSendOutput = Remote; /* now safe to ereport to client */ /* - * We arrange for a simple exit(0) if we receive SIGTERM or SIGQUIT - * during any client authentication related communication. Otherwise - * the postmaster cannot shutdown the database FAST or IMMED cleanly - * if a buggy client blocks a backend during authentication. + * We arrange for a simple exit(0) if we receive SIGTERM or SIGQUIT during + * any client authentication related communication. Otherwise the + * postmaster cannot shutdown the database FAST or IMMED cleanly if a + * buggy client blocks a backend during authentication. */ pqsignal(SIGTERM, authdie); pqsignal(SIGQUIT, authdie); @@ -2683,12 +2666,12 @@ BackendRun(Port *port) if (getnameinfo_all(&port->raddr.addr, port->raddr.salen, remote_host, sizeof(remote_host), remote_port, sizeof(remote_port), - (log_hostname ? 0 : NI_NUMERICHOST) | NI_NUMERICSERV)) + (log_hostname ? 0 : NI_NUMERICHOST) | NI_NUMERICSERV)) { int ret = getnameinfo_all(&port->raddr.addr, port->raddr.salen, - remote_host, sizeof(remote_host), - remote_port, sizeof(remote_port), - NI_NUMERICHOST | NI_NUMERICSERV); + remote_host, sizeof(remote_host), + remote_port, sizeof(remote_port), + NI_NUMERICHOST | NI_NUMERICSERV); if (ret) ereport(WARNING, @@ -2713,9 +2696,9 @@ BackendRun(Port *port) /* * In EXEC_BACKEND case, we didn't inherit the contents of pg_hba.conf - * etcetera from the postmaster, and have to load them ourselves. - * Build the PostmasterContext (which didn't exist before, in this - * process) to contain the data. + * etcetera from the postmaster, and have to load them ourselves. Build + * the PostmasterContext (which didn't exist before, in this process) to + * contain the data. * * FIXME: [fork/exec] Ugh. Is there a way around this overhead? */ @@ -2734,16 +2717,16 @@ BackendRun(Port *port) #endif /* - * Ready to begin client interaction. We will give up and exit(0) - * after a time delay, so that a broken client can't hog a connection + * Ready to begin client interaction. We will give up and exit(0) after a + * time delay, so that a broken client can't hog a connection * indefinitely. PreAuthDelay doesn't count against the time limit. */ if (!enable_sig_alarm(AuthenticationTimeout * 1000, false)) elog(FATAL, "could not set timer for authorization timeout"); /* - * Receive the startup packet (which might turn out to be a cancel - * request packet). + * Receive the startup packet (which might turn out to be a cancel request + * packet). */ status = ProcessStartupPacket(port, false); @@ -2752,8 +2735,7 @@ BackendRun(Port *port) /* * Now that we have the user and database name, we can set the process - * title for ps. It's good to do this as early as possible in - * startup. + * title for ps. It's good to do this as early as possible in startup. */ init_ps_display(port->user_name, port->database_name, remote_ps_data); set_ps_display("authentication"); @@ -2764,8 +2746,8 @@ BackendRun(Port *port) ClientAuthentication(port); /* might not return, if failure */ /* - * Done with authentication. Disable timeout, and prevent - * SIGTERM/SIGQUIT again until backend startup is complete. + * Done with authentication. Disable timeout, and prevent SIGTERM/SIGQUIT + * again until backend startup is complete. */ if (!disable_sig_alarm(false)) elog(FATAL, "could not disable timer for authorization timeout"); @@ -2778,8 +2760,8 @@ BackendRun(Port *port) /* * Don't want backend to be able to see the postmaster random number - * generator state. We have to clobber the static random_seed *and* - * start a new random sequence in the random() library function. + * generator state. We have to clobber the static random_seed *and* start + * a new random sequence in the random() library function. */ random_seed = 0; srandom((unsigned int) (MyProcPid ^ port->session_start.tv_usec)); @@ -2826,8 +2808,8 @@ BackendRun(Port *port) av[ac++] = port->database_name; /* - * Pass the (insecure) option switches from the connection request. - * (It's OK to mangle port->cmdline_options now.) + * Pass the (insecure) option switches from the connection request. (It's + * OK to mangle port->cmdline_options now.) */ if (port->cmdline_options) split_opts(av, &ac, port->cmdline_options); @@ -2837,11 +2819,11 @@ BackendRun(Port *port) Assert(ac < maxac); /* - * Release postmaster's working memory context so that backend can - * recycle the space. Note this does not trash *MyProcPort, because - * ConnCreate() allocated that space with malloc() ... else we'd need - * to copy the Port data here. Also, subsidiary data such as the - * username isn't lost either; see ProcessStartupPacket(). + * Release postmaster's working memory context so that backend can recycle + * the space. Note this does not trash *MyProcPort, because ConnCreate() + * allocated that space with malloc() ... else we'd need to copy the Port + * data here. Also, subsidiary data such as the username isn't lost + * either; see ProcessStartupPacket(). */ MemoryContextSwitchTo(TopMemoryContext); MemoryContextDelete(PostmasterContext); @@ -2852,15 +2834,14 @@ BackendRun(Port *port) */ ereport(DEBUG3, (errmsg_internal("%s child[%d]: starting with (", - progname, (int)getpid()))); + progname, (int) getpid()))); for (i = 0; i < ac; ++i) ereport(DEBUG3, (errmsg_internal("\t%s", av[i]))); ereport(DEBUG3, (errmsg_internal(")"))); - ClientAuthInProgress = false; /* client_min_messages is active - * now */ + ClientAuthInProgress = false; /* client_min_messages is active now */ return (PostgresMain(ac, av, port->user_name)); } @@ -2926,7 +2907,7 @@ internal_forkexec(int argc, char *argv[], Port *port) pid_t pid; char tmpfilename[MAXPGPATH]; BackendParameters param; - FILE *fp; + FILE *fp; if (!save_backend_variables(¶m, port)) return -1; /* log made by save_backend_variables */ @@ -2994,21 +2975,19 @@ internal_forkexec(int argc, char *argv[], Port *port) } } - return pid; /* Parent returns pid, or -1 on fork - * failure */ + return pid; /* Parent returns pid, or -1 on fork failure */ } - -#else /* WIN32 */ +#else /* WIN32 */ /* * internal_forkexec win32 implementation * * - starts backend using CreateProcess(), in suspended state * - writes out backend variables to the parameter file - * - during this, duplicates handles and sockets required for - * inheritance into the new process + * - during this, duplicates handles and sockets required for + * inheritance into the new process * - resumes execution of the new process once the backend parameter - * file is complete. + * file is complete. */ static pid_t internal_forkexec(int argc, char *argv[], Port *port) @@ -3020,10 +2999,10 @@ internal_forkexec(int argc, char *argv[], Port *port) char cmdLine[MAXPGPATH * 2]; HANDLE childHandleCopy; HANDLE waiterThread; - HANDLE paramHandle; + HANDLE paramHandle; BackendParameters *param; SECURITY_ATTRIBUTES sa; - char paramHandleStr[32]; + char paramHandleStr[32]; /* Make sure caller set up argv properly */ Assert(argc >= 3); @@ -3032,7 +3011,7 @@ internal_forkexec(int argc, char *argv[], Port *port) Assert(argv[2] == NULL); /* Set up shared memory for parameter passing */ - ZeroMemory(&sa,sizeof(sa)); + ZeroMemory(&sa, sizeof(sa)); sa.nLength = sizeof(sa); sa.bInheritHandle = TRUE; paramHandle = CreateFileMapping(INVALID_HANDLE_VALUE, @@ -3058,7 +3037,7 @@ internal_forkexec(int argc, char *argv[], Port *port) } /* Insert temp file name after -fork argument */ - sprintf(paramHandleStr, "%lu", (DWORD)paramHandle); + sprintf(paramHandleStr, "%lu", (DWORD) paramHandle); argv[2] = paramHandleStr; /* Format the cmd line */ @@ -3080,9 +3059,10 @@ internal_forkexec(int argc, char *argv[], Port *port) memset(&pi, 0, sizeof(pi)); memset(&si, 0, sizeof(si)); si.cb = sizeof(si); + /* - * Create the subprocess in a suspended state. This will be resumed - * later, once we have written out the parameter file. + * Create the subprocess in a suspended state. This will be resumed later, + * once we have written out the parameter file. */ if (!CreateProcess(NULL, cmdLine, NULL, NULL, TRUE, CREATE_SUSPENDED, NULL, NULL, &si, &pi)) @@ -3095,8 +3075,8 @@ internal_forkexec(int argc, char *argv[], Port *port) if (!save_backend_variables(param, port, pi.hProcess, pi.dwProcessId)) { /* - * log made by save_backend_variables, but we have to clean - * up the mess with the half-started process + * log made by save_backend_variables, but we have to clean up the + * mess with the half-started process */ if (!TerminateProcess(pi.hProcess, 255)) ereport(ERROR, @@ -3116,9 +3096,9 @@ internal_forkexec(int argc, char *argv[], Port *port) (int) GetLastError()); /* - * Now that the backend variables are written out, we start the - * child thread so it can start initializing while we set up - * the rest of the parent state. + * Now that the backend variables are written out, we start the child + * thread so it can start initializing while we set up the rest of the + * parent state. */ if (ResumeThread(pi.hThread) == -1) { @@ -3154,15 +3134,15 @@ internal_forkexec(int argc, char *argv[], Port *port) FALSE, DUPLICATE_SAME_ACCESS) == 0) ereport(FATAL, - (errmsg_internal("could not duplicate child handle: error code %d", - (int) GetLastError()))); + (errmsg_internal("could not duplicate child handle: error code %d", + (int) GetLastError()))); waiterThread = CreateThread(NULL, 64 * 1024, win32_sigchld_waiter, (LPVOID) childHandleCopy, 0, NULL); if (!waiterThread) ereport(FATAL, - (errmsg_internal("could not create sigchld waiter thread: error code %d", - (int) GetLastError()))); + (errmsg_internal("could not create sigchld waiter thread: error code %d", + (int) GetLastError()))); CloseHandle(waiterThread); if (IsUnderPostmaster) @@ -3171,8 +3151,7 @@ internal_forkexec(int argc, char *argv[], Port *port) return pi.dwProcessId; } - -#endif /* WIN32 */ +#endif /* WIN32 */ /* @@ -3213,9 +3192,9 @@ SubPostmasterMain(int argc, char *argv[]) elog(FATAL, "invalid subpostmaster invocation"); /* - * If appropriate, physically re-attach to shared memory segment. - * We want to do this before going any further to ensure that we - * can attach at the same address the postmaster used. + * If appropriate, physically re-attach to shared memory segment. We want + * to do this before going any further to ensure that we can attach at the + * same address the postmaster used. */ if (strcmp(argv[1], "-forkbackend") == 0 || strcmp(argv[1], "-forkautovac") == 0 || @@ -3223,9 +3202,9 @@ SubPostmasterMain(int argc, char *argv[]) PGSharedMemoryReAttach(); /* - * Start our win32 signal implementation. This has to be done - * after we read the backend variables, because we need to pick - * up the signal pipe from the parent process. + * Start our win32 signal implementation. This has to be done after we + * read the backend variables, because we need to pick up the signal pipe + * from the parent process. */ #ifdef WIN32 pgwin32_signal_initialize(); @@ -3247,10 +3226,11 @@ SubPostmasterMain(int argc, char *argv[]) CreateSharedMemoryAndSemaphores(false, 0); #ifdef USE_SSL + /* - * Need to reinitialize the SSL library in the backend, - * since the context structures contain function pointers - * and cannot be passed through the parameter file. + * Need to reinitialize the SSL library in the backend, since the + * context structures contain function pointers and cannot be passed + * through the parameter file. */ if (EnableSSL) secure_initialize(); @@ -3304,8 +3284,8 @@ SubPostmasterMain(int argc, char *argv[]) if (strcmp(argv[1], "-forkcol") == 0) { /* - * Do NOT close postmaster sockets here, because we are forking - * from pgstat buffer process, which already did it. + * Do NOT close postmaster sockets here, because we are forking from + * pgstat buffer process, which already did it. */ /* Do not want to attach to shared memory */ @@ -3326,7 +3306,6 @@ SubPostmasterMain(int argc, char *argv[]) return 1; /* shouldn't get here */ } - #endif /* EXEC_BACKEND */ @@ -3341,8 +3320,8 @@ ExitPostmaster(int status) /* should cleanup shared memory and kill all backends */ /* - * Not sure of the semantics here. When the Postmaster dies, should - * the backends all be killed? probably not. + * Not sure of the semantics here. When the Postmaster dies, should the + * backends all be killed? probably not. * * MUST -- vadim 05-10-1999 */ @@ -3371,9 +3350,8 @@ sigusr1_handler(SIGNAL_ARGS) if (CheckPostmasterSignal(PMSIGNAL_WAKEN_CHILDREN)) { /* - * Send SIGUSR1 to all children (triggers - * CatchupInterruptHandler). See storage/ipc/sinval[adt].c for the - * use of this. + * Send SIGUSR1 to all children (triggers CatchupInterruptHandler). + * See storage/ipc/sinval[adt].c for the use of this. */ if (Shutdown <= SmartShutdown) { @@ -3387,8 +3365,8 @@ sigusr1_handler(SIGNAL_ARGS) PgArchPID != 0 && Shutdown == NoShutdown) { /* - * Send SIGUSR1 to archiver process, to wake it up and begin - * archiving next transaction log file. + * Send SIGUSR1 to archiver process, to wake it up and begin archiving + * next transaction log file. */ kill(PgArchPID, SIGUSR1); } @@ -3397,7 +3375,7 @@ sigusr1_handler(SIGNAL_ARGS) SysLoggerPID != 0) { /* Tell syslogger to rotate logfile */ - kill(SysLoggerPID, SIGUSR1); + kill(SysLoggerPID, SIGUSR1); } PG_SETMASK(&UnBlockSig); @@ -3459,9 +3437,9 @@ RandomSalt(char *cryptSalt, char *md5Salt) * bytes, since only one of the two salts will be sent to the client. * After that we need to compute more random bits. * - * We use % 255, sacrificing one possible byte value, so as to ensure - * that all bits of the random() value participate in the result. - * While at it, add one to avoid generating any null bytes. + * We use % 255, sacrificing one possible byte value, so as to ensure that + * all bits of the random() value participate in the result. While at it, + * add one to avoid generating any null bytes. */ md5Salt[0] = (rand % 255) + 1; rand = PostmasterRandom(); @@ -3508,7 +3486,7 @@ CountChildren(void) /* * StartChildProcess -- start a non-backend child process for the postmaster * - * xlop determines what kind of child will be started. All child types + * xlop determines what kind of child will be started. All child types * initially go to BootstrapMain, which will handle common setup. * * Return value of StartChildProcess is subprocess' PID, or 0 if failed @@ -3548,8 +3526,7 @@ StartChildProcess(int xlop) if (pid == 0) /* child */ { - IsUnderPostmaster = true; /* we are a postmaster subprocess - * now */ + IsUnderPostmaster = true; /* we are a postmaster subprocess now */ /* Close the postmaster's sockets */ ClosePostmasterPorts(false); @@ -3571,6 +3548,7 @@ StartChildProcess(int xlop) { /* in parent, fork failed */ int save_errno = errno; + errno = save_errno; switch (xlop) { @@ -3580,7 +3558,7 @@ StartChildProcess(int xlop) break; case BS_XLOG_BGWRITER: ereport(LOG, - (errmsg("could not fork background writer process: %m"))); + (errmsg("could not fork background writer process: %m"))); break; default: ereport(LOG, @@ -3589,8 +3567,8 @@ StartChildProcess(int xlop) } /* - * fork failure is fatal during startup, but there's no need to - * choke immediately if starting other child types fails. + * fork failure is fatal during startup, but there's no need to choke + * immediately if starting other child types fails. */ if (xlop == BS_XLOG_STARTUP) ExitPostmaster(1); @@ -3648,26 +3626,26 @@ extern void *ShmemIndexAlloc; extern LWLock *LWLockArray; extern slock_t *ProcStructLock; extern int pgStatSock; -extern int pgStatPipe[2]; +extern int pgStatPipe[2]; #ifndef WIN32 #define write_inheritable_socket(dest, src, childpid) (*(dest) = (src)) #define read_inheritable_socket(dest, src) (*(dest) = *(src)) #else -static void write_duplicated_handle(HANDLE *dest, HANDLE src, HANDLE child); -static void write_inheritable_socket(InheritableSocket *dest, SOCKET src, - pid_t childPid); -static void read_inheritable_socket(SOCKET *dest, InheritableSocket *src); +static void write_duplicated_handle(HANDLE * dest, HANDLE src, HANDLE child); +static void write_inheritable_socket(InheritableSocket * dest, SOCKET src, + pid_t childPid); +static void read_inheritable_socket(SOCKET * dest, InheritableSocket * src); #endif /* Save critical backend variables into the BackendParameters struct */ #ifndef WIN32 static bool -save_backend_variables(BackendParameters *param, Port *port) +save_backend_variables(BackendParameters * param, Port *port) #else static bool -save_backend_variables(BackendParameters *param, Port *port, +save_backend_variables(BackendParameters * param, Port *port, HANDLE childProcess, pid_t childPid) #endif { @@ -3726,9 +3704,9 @@ save_backend_variables(BackendParameters *param, Port *port, * process instance of the handle to the parameter file. */ static void -write_duplicated_handle(HANDLE *dest, HANDLE src, HANDLE childProcess) +write_duplicated_handle(HANDLE * dest, HANDLE src, HANDLE childProcess) { - HANDLE hChild = INVALID_HANDLE_VALUE; + HANDLE hChild = INVALID_HANDLE_VALUE; if (!DuplicateHandle(GetCurrentProcess(), src, @@ -3752,7 +3730,7 @@ write_duplicated_handle(HANDLE *dest, HANDLE src, HANDLE childProcess) * straight socket inheritance. */ static void -write_inheritable_socket(InheritableSocket *dest, SOCKET src, pid_t childpid) +write_inheritable_socket(InheritableSocket * dest, SOCKET src, pid_t childpid) { dest->origsocket = src; if (src != 0 && src != -1) @@ -3769,11 +3747,11 @@ write_inheritable_socket(InheritableSocket *dest, SOCKET src, pid_t childpid) * Read a duplicate socket structure back, and get the socket descriptor. */ static void -read_inheritable_socket(SOCKET *dest, InheritableSocket *src) +read_inheritable_socket(SOCKET * dest, InheritableSocket * src) { - SOCKET s; + SOCKET s; - if (src->origsocket == -1 || src->origsocket == 0) + if (src->origsocket == -1 || src->origsocket == 0) { /* Not a real socket! */ *dest = src->origsocket; @@ -3796,9 +3774,9 @@ read_inheritable_socket(SOCKET *dest, InheritableSocket *src) *dest = s; /* - * To make sure we don't get two references to the same socket, - * close the original one. (This would happen when inheritance - * actually works.. + * To make sure we don't get two references to the same socket, close + * the original one. (This would happen when inheritance actually + * works.. */ closesocket(src->origsocket); } @@ -3812,7 +3790,7 @@ read_backend_variables(char *id, Port *port) #ifndef WIN32 /* Non-win32 implementation reads from file */ - FILE *fp; + FILE *fp; /* Open file */ fp = AllocateFile(id, PG_BINARY_R); @@ -3840,10 +3818,10 @@ read_backend_variables(char *id, Port *port) } #else /* Win32 version uses mapped file */ - HANDLE paramHandle; + HANDLE paramHandle; BackendParameters *paramp; - paramHandle = (HANDLE)atol(id); + paramHandle = (HANDLE) atol(id); paramp = MapViewOfFile(paramHandle, FILE_MAP_READ, 0, 0, 0); if (!paramp) { @@ -3874,7 +3852,7 @@ read_backend_variables(char *id, Port *port) /* Restore critical backend variables from the BackendParameters struct */ static void -restore_backend_variables(BackendParameters *param, Port *port) +restore_backend_variables(BackendParameters * param, Port *port) { memcpy(port, ¶m->port, sizeof(Port)); read_inheritable_socket(&port->sock, ¶m->portsocket); @@ -3975,7 +3953,6 @@ ShmemBackendArrayRemove(pid_t pid) (errmsg_internal("could not find backend entry with pid %d", (int) pid))); } - #endif /* EXEC_BACKEND */ @@ -4059,7 +4036,7 @@ win32_waitpid(int *exitstatus) case WAIT_FAILED: ereport(LOG, (errmsg_internal("failed to wait on %lu of %lu children: error code %d", - num, win32_numChildren, (int) GetLastError()))); + num, win32_numChildren, (int) GetLastError()))); return -1; case WAIT_TIMEOUT: @@ -4069,21 +4046,21 @@ win32_waitpid(int *exitstatus) default: /* - * Get the exit code, and return the PID of, the - * respective process + * Get the exit code, and return the PID of, the respective + * process */ index = offset + ret - WAIT_OBJECT_0; Assert(index >= 0 && index < win32_numChildren); if (!GetExitCodeProcess(win32_childHNDArray[index], &exitCode)) { /* - * If we get this far, this should never happen, but, - * then again... No choice other than to assume a - * catastrophic failure. + * If we get this far, this should never happen, but, then + * again... No choice other than to assume a catastrophic + * failure. */ ereport(FATAL, - (errmsg_internal("failed to get exit code for child %lu", - (unsigned long) win32_childPIDArray[index]))); + (errmsg_internal("failed to get exit code for child %lu", + (unsigned long) win32_childPIDArray[index]))); } *exitstatus = (int) exitCode; return win32_childPIDArray[index]; diff --git a/src/backend/postmaster/syslogger.c b/src/backend/postmaster/syslogger.c index e5aa153dd4..b2e3add6a8 100644 --- a/src/backend/postmaster/syslogger.c +++ b/src/backend/postmaster/syslogger.c @@ -18,7 +18,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.19 2005/08/12 03:23:51 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.20 2005/10/15 02:49:24 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -87,7 +87,6 @@ static char *last_file_name = NULL; /* These must be exported for EXEC_BACKEND case ... annoying */ #ifndef WIN32 int syslogPipe[2] = {-1, -1}; - #else HANDLE syslogPipe[2] = {0, 0}; #endif @@ -149,22 +148,21 @@ SysLoggerMain(int argc, char *argv[]) set_ps_display(""); /* - * If we restarted, our stderr is already redirected into our own - * input pipe. This is of course pretty useless, not to mention that - * it interferes with detecting pipe EOF. Point stderr to /dev/null. - * This assumes that all interesting messages generated in the - * syslogger will come through elog.c and will be sent to - * write_syslogger_file. + * If we restarted, our stderr is already redirected into our own input + * pipe. This is of course pretty useless, not to mention that it + * interferes with detecting pipe EOF. Point stderr to /dev/null. This + * assumes that all interesting messages generated in the syslogger will + * come through elog.c and will be sent to write_syslogger_file. */ if (redirection_done) { int fd = open(NULL_DEV, O_WRONLY); /* - * The closes might look redundant, but they are not: we want to - * be darn sure the pipe gets closed even if the open failed. We - * can survive running with stderr pointing nowhere, but we can't - * afford to have extra pipe input descriptors hanging around. + * The closes might look redundant, but they are not: we want to be + * darn sure the pipe gets closed even if the open failed. We can + * survive running with stderr pointing nowhere, but we can't afford + * to have extra pipe input descriptors hanging around. */ close(fileno(stdout)); close(fileno(stderr)); @@ -174,9 +172,9 @@ SysLoggerMain(int argc, char *argv[]) } /* - * Also close our copy of the write end of the pipe. This is needed - * to ensure we can detect pipe EOF correctly. (But note that in the - * restart case, the postmaster already did this.) + * Also close our copy of the write end of the pipe. This is needed to + * ensure we can detect pipe EOF correctly. (But note that in the restart + * case, the postmaster already did this.) */ #ifndef WIN32 if (syslogPipe[1] >= 0) @@ -191,9 +189,9 @@ SysLoggerMain(int argc, char *argv[]) /* * Properly accept or ignore signals the postmaster might send us * - * Note: we ignore all termination signals, and instead exit only when - * all upstream processes are gone, to ensure we don't miss any dying - * gasps of broken backends... + * Note: we ignore all termination signals, and instead exit only when all + * upstream processes are gone, to ensure we don't miss any dying gasps of + * broken backends... */ pqsignal(SIGHUP, sigHupHandler); /* set flag to read config file */ @@ -202,7 +200,7 @@ SysLoggerMain(int argc, char *argv[]) pqsignal(SIGQUIT, SIG_IGN); pqsignal(SIGALRM, SIG_IGN); pqsignal(SIGPIPE, SIG_IGN); - pqsignal(SIGUSR1, sigUsr1Handler); /* request log rotation */ + pqsignal(SIGUSR1, sigUsr1Handler); /* request log rotation */ pqsignal(SIGUSR2, SIG_IGN); /* @@ -253,8 +251,8 @@ SysLoggerMain(int argc, char *argv[]) ProcessConfigFile(PGC_SIGHUP); /* - * Check if the log directory or filename pattern changed in - * postgresql.conf. If so, force rotation to make sure we're + * Check if the log directory or filename pattern changed in + * postgresql.conf. If so, force rotation to make sure we're * writing the logfiles in the right place. */ if (strcmp(Log_directory, currentLogDir) != 0) @@ -269,6 +267,7 @@ SysLoggerMain(int argc, char *argv[]) currentLogFilename = pstrdup(Log_filename); rotation_requested = true; } + /* * If rotation time parameter changed, reset next rotation time, * but don't immediately force a rotation. @@ -316,7 +315,7 @@ SysLoggerMain(int argc, char *argv[]) if (errno != EINTR) ereport(LOG, (errcode_for_socket_access(), - errmsg("select() failed in logger process: %m"))); + errmsg("select() failed in logger process: %m"))); } else if (rc > 0 && FD_ISSET(syslogPipe[0], &rfds)) { @@ -328,7 +327,7 @@ SysLoggerMain(int argc, char *argv[]) if (errno != EINTR) ereport(LOG, (errcode_for_socket_access(), - errmsg("could not read from logger pipe: %m"))); + errmsg("could not read from logger pipe: %m"))); } else if (bytesRead > 0) { @@ -338,11 +337,10 @@ SysLoggerMain(int argc, char *argv[]) else { /* - * Zero bytes read when select() is saying read-ready - * means EOF on the pipe: that is, there are no longer any - * processes with the pipe write end open. Therefore, the - * postmaster and all backends are shut down, and we are - * done. + * Zero bytes read when select() is saying read-ready means + * EOF on the pipe: that is, there are no longer any processes + * with the pipe write end open. Therefore, the postmaster + * and all backends are shut down, and we are done. */ pipe_eof_seen = true; } @@ -350,9 +348,9 @@ SysLoggerMain(int argc, char *argv[]) #else /* WIN32 */ /* - * On Windows we leave it to a separate thread to transfer data - * and detect pipe EOF. The main thread just wakes up once a - * second to check for SIGHUP and rotation conditions. + * On Windows we leave it to a separate thread to transfer data and + * detect pipe EOF. The main thread just wakes up once a second to + * check for SIGHUP and rotation conditions. */ pgwin32_backend_usleep(1000000); #endif /* WIN32 */ @@ -364,10 +362,10 @@ SysLoggerMain(int argc, char *argv[]) /* * Normal exit from the syslogger is here. Note that we - * deliberately do not close syslogFile before exiting; this - * is to allow for the possibility of elog messages being - * generated inside proc_exit. Regular exit() will take care - * of flushing and closing stdio channels. + * deliberately do not close syslogFile before exiting; this is to + * allow for the possibility of elog messages being generated + * inside proc_exit. Regular exit() will take care of flushing + * and closing stdio channels. */ proc_exit(0); } @@ -390,13 +388,13 @@ SysLogger_Start(void) * If first time through, create the pipe which will receive stderr * output. * - * If the syslogger crashes and needs to be restarted, we continue to use - * the same pipe (indeed must do so, since extant backends will be - * writing into that pipe). + * If the syslogger crashes and needs to be restarted, we continue to use the + * same pipe (indeed must do so, since extant backends will be writing + * into that pipe). * - * This means the postmaster must continue to hold the read end of the - * pipe open, so we can pass it down to the reincarnated syslogger. - * This is a bit klugy but we have little choice. + * This means the postmaster must continue to hold the read end of the pipe + * open, so we can pass it down to the reincarnated syslogger. This is a + * bit klugy but we have little choice. */ #ifndef WIN32 if (syslogPipe[0] < 0) @@ -404,7 +402,7 @@ SysLogger_Start(void) if (pgpipe(syslogPipe) < 0) ereport(FATAL, (errcode_for_socket_access(), - (errmsg("could not create pipe for syslog: %m")))); + (errmsg("could not create pipe for syslog: %m")))); } #else if (!syslogPipe[0]) @@ -418,7 +416,7 @@ SysLogger_Start(void) if (!CreatePipe(&syslogPipe[0], &syslogPipe[1], &sa, 32768)) ereport(FATAL, (errcode_for_file_access(), - (errmsg("could not create pipe for syslog: %m")))); + (errmsg("could not create pipe for syslog: %m")))); } #endif @@ -428,8 +426,8 @@ SysLogger_Start(void) mkdir(Log_directory, 0700); /* - * The initial logfile is created right in the postmaster, to verify - * that the Log_directory is writable. + * The initial logfile is created right in the postmaster, to verify that + * the Log_directory is writable. */ filename = logfile_getname(time(NULL)); @@ -730,9 +728,9 @@ logfile_rotate(bool time_based_rotation) rotation_requested = false; /* - * When doing a time-based rotation, invent the new logfile name based - * on the planned rotation time, not current time, to avoid "slippage" - * in the file name when we don't do the rotation immediately. + * When doing a time-based rotation, invent the new logfile name based on + * the planned rotation time, not current time, to avoid "slippage" in the + * file name when we don't do the rotation immediately. */ if (time_based_rotation) filename = logfile_getname(next_rotation_time); @@ -742,14 +740,14 @@ logfile_rotate(bool time_based_rotation) /* * Decide whether to overwrite or append. We can overwrite if (a) * Log_truncate_on_rotation is set, (b) the rotation was triggered by - * elapsed time and not something else, and (c) the computed file name - * is different from what we were previously logging into. + * elapsed time and not something else, and (c) the computed file name is + * different from what we were previously logging into. * * Note: during the first rotation after forking off from the postmaster, * last_file_name will be NULL. (We don't bother to set it in the - * postmaster because it ain't gonna work in the EXEC_BACKEND case.) - * So we will always append in that situation, even though truncating - * would usually be safe. + * postmaster because it ain't gonna work in the EXEC_BACKEND case.) So we + * will always append in that situation, even though truncating would + * usually be safe. */ if (Log_truncate_on_rotation && time_based_rotation && last_file_name != NULL && strcmp(filename, last_file_name) != 0) @@ -767,15 +765,15 @@ logfile_rotate(bool time_based_rotation) filename))); /* - * ENFILE/EMFILE are not too surprising on a busy system; just - * keep using the old file till we manage to get a new one. - * Otherwise, assume something's wrong with Log_directory and stop - * trying to create files. + * ENFILE/EMFILE are not too surprising on a busy system; just keep + * using the old file till we manage to get a new one. Otherwise, + * assume something's wrong with Log_directory and stop trying to + * create files. */ if (saveerrno != ENFILE && saveerrno != EMFILE) { ereport(LOG, - (errmsg("disabling automatic rotation (use SIGHUP to reenable)"))); + (errmsg("disabling automatic rotation (use SIGHUP to reenable)"))); Log_RotationAge = 0; Log_RotationSize = 0; } @@ -828,7 +826,7 @@ logfile_getname(pg_time_t timestamp) tm = pg_localtime(×tamp, global_timezone); pg_strftime(filename + len, MAXPGPATH - len, Log_filename, tm); } - else + else { /* no strftime escapes, so append timestamp to new filename */ snprintf(filename + len, MAXPGPATH - len, "%s.%lu", @@ -855,10 +853,10 @@ set_next_rotation_time(void) /* * The requirements here are to choose the next time > now that is a * "multiple" of the log rotation interval. "Multiple" can be interpreted - * fairly loosely. In this version we align to local time rather than + * fairly loosely. In this version we align to local time rather than * GMT. */ - rotinterval = Log_RotationAge * SECS_PER_MINUTE; /* convert to seconds */ + rotinterval = Log_RotationAge * SECS_PER_MINUTE; /* convert to seconds */ now = time(NULL); tm = pg_localtime(&now, global_timezone); now += tm->tm_gmtoff; diff --git a/src/backend/regex/regc_color.c b/src/backend/regex/regc_color.c index fc62626d1f..33a6c79206 100644 --- a/src/backend/regex/regc_color.c +++ b/src/backend/regex/regc_color.c @@ -28,7 +28,7 @@ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $PostgreSQL: pgsql/src/backend/regex/regc_color.c,v 1.4 2003/11/29 19:51:55 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/regex/regc_color.c,v 1.5 2005/10/15 02:49:24 momjian Exp $ * * * Note that there are some incestuous relationships between this code and @@ -179,7 +179,7 @@ setcolor(struct colormap * cm, if (t == fillt || t == cb) { /* must allocate a new block */ newt = (union tree *) MALLOC((bottom) ? - sizeof(struct colors) : sizeof(struct ptrs)); + sizeof(struct colors) : sizeof(struct ptrs)); if (newt == NULL) { CERR(REG_ESPACE); @@ -256,7 +256,7 @@ newcolor(struct colormap * cm) } else new = (struct colordesc *) REALLOC(cm->cd, - n * sizeof(struct colordesc)); + n * sizeof(struct colordesc)); if (new == NULL) { CERR(REG_ESPACE); diff --git a/src/backend/regex/regc_cvec.c b/src/backend/regex/regc_cvec.c index 1abeacc246..719c4c5ef3 100644 --- a/src/backend/regex/regc_cvec.c +++ b/src/backend/regex/regc_cvec.c @@ -28,7 +28,7 @@ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $PostgreSQL: pgsql/src/backend/regex/regc_cvec.c,v 1.4 2003/11/29 19:51:55 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/regex/regc_cvec.c,v 1.5 2005/10/15 02:49:24 momjian Exp $ * */ @@ -52,8 +52,7 @@ newcvec(int nchrs, /* to hold this many chrs... */ if (cv == NULL) return NULL; cv->chrspace = nchrs; - cv->chrs = (chr *) &cv->mcces[nmcces]; /* chrs just after MCCE - * ptrs */ + cv->chrs = (chr *) &cv->mcces[nmcces]; /* chrs just after MCCE ptrs */ cv->mccespace = nmcces; cv->ranges = cv->chrs + nchrs + nmcces * (MAXMCCE + 1); cv->rangespace = nranges; diff --git a/src/backend/regex/regc_lex.c b/src/backend/regex/regc_lex.c index 55ef530c3e..df45701e5a 100644 --- a/src/backend/regex/regc_lex.c +++ b/src/backend/regex/regc_lex.c @@ -28,7 +28,7 @@ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $PostgreSQL: pgsql/src/backend/regex/regc_lex.c,v 1.4 2003/11/29 19:51:55 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/regex/regc_lex.c,v 1.5 2005/10/15 02:49:24 momjian Exp $ * */ @@ -712,8 +712,7 @@ next(struct vars * v) * lexescape - parse an ARE backslash escape (backslash already eaten) * Note slightly nonstandard use of the CCLASS type code. */ -static int /* not actually used, but convenient for - * RETV */ +static int /* not actually used, but convenient for RETV */ lexescape(struct vars * v) { chr c; @@ -816,8 +815,7 @@ lexescape(struct vars * v) break; case CHR('x'): NOTE(REG_UUNPORT); - c = lexdigits(v, 16, 1, 255); /* REs >255 long outside - * spec */ + c = lexdigits(v, 16, 1, 255); /* REs >255 long outside spec */ if (ISERR()) FAILW(REG_EESCAPE); RETV(PLAIN, c); @@ -844,8 +842,7 @@ lexescape(struct vars * v) case CHR('9'): save = v->now; v->now--; /* put first digit back */ - c = lexdigits(v, 10, 1, 255); /* REs >255 long outside - * spec */ + c = lexdigits(v, 10, 1, 255); /* REs >255 long outside spec */ if (ISERR()) FAILW(REG_EESCAPE); /* ugly heuristic (first test is "exactly 1 digit?") */ diff --git a/src/backend/regex/regc_locale.c b/src/backend/regex/regc_locale.c index 06c5f46a12..75f3273049 100644 --- a/src/backend/regex/regc_locale.c +++ b/src/backend/regex/regc_locale.c @@ -47,7 +47,7 @@ * permission to use and distribute the software in accordance with the * terms specified in this license. * - * $PostgreSQL: pgsql/src/backend/regex/regc_locale.c,v 1.6 2004/05/07 00:24:57 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/regex/regc_locale.c,v 1.7 2005/10/15 02:49:24 momjian Exp $ */ /* ASCII character-name table */ @@ -520,10 +520,9 @@ range(struct vars * v, /* context */ } /* - * When case-independent, it's hard to decide when cvec ranges are - * usable, so for now at least, we won't try. We allocate enough - * space for two case variants plus a little extra for the two title - * case variants. + * When case-independent, it's hard to decide when cvec ranges are usable, + * so for now at least, we won't try. We allocate enough space for two + * case variants plus a little extra for the two title case variants. */ nchrs = (b - a + 1) * 2 + 4; @@ -656,8 +655,7 @@ cclass(struct vars * v, /* context */ /* * Now compute the character class contents. * - * For the moment, assume that only char codes < 256 can be in these - * classes. + * For the moment, assume that only char codes < 256 can be in these classes. */ switch ((enum classes) index) diff --git a/src/backend/regex/regc_nfa.c b/src/backend/regex/regc_nfa.c index ad081bf71e..fa68d021bc 100644 --- a/src/backend/regex/regc_nfa.c +++ b/src/backend/regex/regc_nfa.c @@ -28,7 +28,7 @@ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $PostgreSQL: pgsql/src/backend/regex/regc_nfa.c,v 1.3 2003/11/29 19:51:55 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/regex/regc_nfa.c,v 1.4 2005/10/15 02:49:24 momjian Exp $ * * * One or two things that technically ought to be in here @@ -218,8 +218,7 @@ freestate(struct nfa * nfa, nfa->states = s->next; } s->prev = NULL; - s->next = nfa->free; /* don't delete it, put it on the free - * list */ + s->next = nfa->free; /* don't delete it, put it on the free list */ nfa->free = s; } @@ -275,10 +274,10 @@ newarc(struct nfa * nfa, a->from = from; /* - * Put the new arc on the beginning, not the end, of the chains. Not - * only is this easier, it has the very useful side effect that - * deleting the most-recently-added arc is the cheapest case rather - * than the most expensive one. + * Put the new arc on the beginning, not the end, of the chains. Not only + * is this easier, it has the very useful side effect that deleting the + * most-recently-added arc is the cheapest case rather than the most + * expensive one. */ a->inchain = to->ins; to->ins = a; @@ -1155,8 +1154,7 @@ cleanup(struct nfa * nfa) static void markreachable(struct nfa * nfa, struct state * s, - struct state * okay, /* consider only states with this - * mark */ + struct state * okay, /* consider only states with this mark */ struct state * mark) /* the value to mark with */ { struct arc *a; @@ -1175,8 +1173,7 @@ markreachable(struct nfa * nfa, static void markcanreach(struct nfa * nfa, struct state * s, - struct state * okay, /* consider only states with this - * mark */ + struct state * okay, /* consider only states with this mark */ struct state * mark) /* the value to mark with */ { struct arc *a; diff --git a/src/backend/regex/regcomp.c b/src/backend/regex/regcomp.c index 8ba3451245..069244060b 100644 --- a/src/backend/regex/regcomp.c +++ b/src/backend/regex/regcomp.c @@ -28,7 +28,7 @@ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $PostgreSQL: pgsql/src/backend/regex/regcomp.c,v 1.43 2005/05/25 21:40:40 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/regex/regcomp.c,v 1.44 2005/10/15 02:49:24 momjian Exp $ * */ @@ -208,8 +208,7 @@ struct vars regex_t *re; chr *now; /* scan pointer into string */ chr *stop; /* end of string */ - chr *savenow; /* saved now and stop for "subroutine - * call" */ + chr *savenow; /* saved now and stop for "subroutine call" */ chr *savestop; int err; /* error code (0 if none) */ int cflags; /* copy of compile flags */ @@ -251,8 +250,7 @@ struct vars #define NOERR() {if (ISERR()) return;} /* if error seen, return */ #define NOERRN() {if (ISERR()) return NULL;} /* NOERR with retval */ #define NOERRZ() {if (ISERR()) return 0;} /* NOERR with retval */ -#define INSIST(c, e) ((c) ? 0 : ERR(e)) /* if condition false, - * error */ +#define INSIST(c, e) ((c) ? 0 : ERR(e)) /* if condition false, error */ #define NOTE(b) (v->re->re_info |= (b)) /* note visible condition */ #define EMPTYARC(x, y) newarc(v->nfa, EMPTY, 0, x, y) @@ -306,7 +304,6 @@ pg_regcomp(regex_t *re, #ifdef REG_DEBUG FILE *debug = (flags & REG_PROGRESS) ? stdout : (FILE *) NULL; - #else FILE *debug = (FILE *) NULL; #endif @@ -572,11 +569,10 @@ makesearch(struct vars * v, /* * Now here's the subtle part. Because many REs have no lookback * constraints, often knowing when you were in the pre state tells you - * little; it's the next state(s) that are informative. But some of - * them may have other inarcs, i.e. it may be possible to make actual - * progress and then return to one of them. We must de-optimize such - * cases, splitting each such state into progress and no-progress - * states. + * little; it's the next state(s) that are informative. But some of them + * may have other inarcs, i.e. it may be possible to make actual progress + * and then return to one of them. We must de-optimize such cases, + * splitting each such state into progress and no-progress states. */ /* first, make a list of the states */ @@ -591,8 +587,8 @@ makesearch(struct vars * v, { /* must be split */ if (s->tmp == NULL) { /* if not already in the list */ - /* (fixes bugs 505048, 230589, */ - /* 840258, 504785) */ + /* (fixes bugs 505048, 230589, */ + /* 840258, 504785) */ s->tmp = slist; slist = s; } @@ -1043,9 +1039,8 @@ parseqatom(struct vars * v, } /* - * hard part: something messy That is, capturing parens, back - * reference, short/long clash, or an atom with substructure - * containing one of those. + * hard part: something messy That is, capturing parens, back reference, + * short/long clash, or an atom with substructure containing one of those. */ /* now we'll need a subre for the contents even if they're boring */ @@ -1522,9 +1517,8 @@ brackpart(struct vars * v, endc = startc; /* - * Ranges are unportable. Actually, standard C does guarantee that - * digits are contiguous, but making that an exception is just too - * complicated. + * Ranges are unportable. Actually, standard C does guarantee that digits + * are contiguous, but making that an exception is just too complicated. */ if (startc != endc) NOTE(REG_UUNPORT); @@ -1600,8 +1594,7 @@ leaders(struct vars * v, assert(s != v->mccepend); } p++; - assert(*p != 0 && *(p + 1) == 0); /* only 2-char MCCEs for - * now */ + assert(*p != 0 && *(p + 1) == 0); /* only 2-char MCCEs for now */ newarc(v->nfa, PLAIN, subcolor(v->cm, *p), s, v->mccepend); okcolors(v->nfa, v->cm); } @@ -2053,7 +2046,7 @@ newlacon(struct vars * v, else { v->lacons = (struct subre *) REALLOC(v->lacons, - (v->nlacons + 1) * sizeof(struct subre)); + (v->nlacons + 1) * sizeof(struct subre)); n = v->nlacons++; } if (v->lacons == NULL) diff --git a/src/backend/regex/rege_dfa.c b/src/backend/regex/rege_dfa.c index c612761d87..c769994d12 100644 --- a/src/backend/regex/rege_dfa.c +++ b/src/backend/regex/rege_dfa.c @@ -28,7 +28,7 @@ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $PostgreSQL: pgsql/src/backend/regex/rege_dfa.c,v 1.5 2005/09/24 22:54:38 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/regex/rege_dfa.c,v 1.6 2005/10/15 02:49:24 momjian Exp $ * */ @@ -145,8 +145,7 @@ shortest(struct vars * v, chr *start, /* where the match should start */ chr *min, /* match must end at or after here */ chr *max, /* match must end at or before here */ - chr **coldp, /* store coldstart pointer here, if - * nonNULL */ + chr **coldp, /* store coldstart pointer here, if nonNULL */ int *hitstopp) /* record whether hit v->stop, if non-NULL */ { chr *cp; @@ -222,8 +221,7 @@ shortest(struct vars * v, if (ss == NULL) return NULL; - if (coldp != NULL) /* report last no-progress state set, if - * any */ + if (coldp != NULL) /* report last no-progress state set, if any */ *coldp = lastcold(v, d); if ((ss->flags & POSTSTATE) && cp > min) diff --git a/src/backend/regex/regexec.c b/src/backend/regex/regexec.c index 7d32c26898..d8adec6cf0 100644 --- a/src/backend/regex/regexec.c +++ b/src/backend/regex/regexec.c @@ -27,7 +27,7 @@ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $PostgreSQL: pgsql/src/backend/regex/regexec.c,v 1.26 2005/09/24 22:54:38 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/regex/regexec.c,v 1.27 2005/10/15 02:49:24 momjian Exp $ * */ @@ -75,8 +75,7 @@ struct dfa struct cnfa *cnfa; struct colormap *cm; chr *lastpost; /* location of last cache-flushed success */ - chr *lastnopr; /* location of last cache-flushed - * NOPROGRESS */ + chr *lastnopr; /* location of last cache-flushed NOPROGRESS */ struct sset *search; /* replacement-search-pointer memory */ int cptsmalloced; /* were the areas individually malloced? */ char *mallocarea; /* self, or master malloced area, or NULL */ @@ -122,8 +121,7 @@ struct vars #define ISERR() VISERR(v) #define VERR(vv,e) (((vv)->err) ? (vv)->err : ((vv)->err = (e))) #define ERR(e) VERR(v, e) /* record an error */ -#define NOERR() {if (ISERR()) return v->err;} /* if error seen, return - * it */ +#define NOERR() {if (ISERR()) return v->err;} /* if error seen, return it */ #define OFF(p) ((p) - v->start) #define LOFF(p) ((long)OFF(p)) @@ -279,8 +277,7 @@ find(struct vars * v, chr *begin; chr *end = NULL; chr *cold; - chr *open; /* open and close of range of possible - * starts */ + chr *open; /* open and close of range of possible starts */ chr *close; int hitend; int shorter = (v->g->tree->flags & SHORTER) ? 1 : 0; @@ -408,8 +405,7 @@ cfindloop(struct vars * v, chr *begin; chr *end; chr *cold; - chr *open; /* open and close of range of possible - * starts */ + chr *open; /* open and close of range of possible starts */ chr *close; chr *estart; chr *estop; @@ -1033,8 +1029,7 @@ caltdissect(struct vars * v, #define UNTRIED 0 /* not yet tried at all */ #define TRYING 1 /* top matched, trying submatches */ -#define TRIED 2 /* top didn't match or submatches - * exhausted */ +#define TRIED 2 /* top didn't match or submatches exhausted */ if (t == NULL) return REG_NOMATCH; diff --git a/src/backend/rewrite/rewriteDefine.c b/src/backend/rewrite/rewriteDefine.c index c28ea627e5..76b2576646 100644 --- a/src/backend/rewrite/rewriteDefine.c +++ b/src/backend/rewrite/rewriteDefine.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/rewrite/rewriteDefine.c,v 1.105 2005/06/28 05:08:59 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/rewrite/rewriteDefine.c,v 1.106 2005/10/15 02:49:24 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -101,8 +101,8 @@ InsertRule(char *rulname, if (!replace) ereport(ERROR, (errcode(ERRCODE_DUPLICATE_OBJECT), - errmsg("rule \"%s\" for relation \"%s\" already exists", - rulname, get_rel_name(eventrel_oid)))); + errmsg("rule \"%s\" for relation \"%s\" already exists", + rulname, get_rel_name(eventrel_oid)))); /* * When replacing, we don't need to replace every attribute @@ -143,8 +143,8 @@ InsertRule(char *rulname, /* * Install dependency on rule's relation to ensure it will go away on * relation deletion. If the rule is ON SELECT, make the dependency - * implicit --- this prevents deleting a view's SELECT rule. Other - * kinds of rules can be AUTO. + * implicit --- this prevents deleting a view's SELECT rule. Other kinds + * of rules can be AUTO. */ myself.classId = RewriteRelationId; myself.objectId = rewriteObjectId; @@ -155,7 +155,7 @@ InsertRule(char *rulname, referenced.objectSubId = 0; recordDependencyOn(&myself, &referenced, - (evtype == CMD_SELECT) ? DEPENDENCY_INTERNAL : DEPENDENCY_AUTO); + (evtype == CMD_SELECT) ? DEPENDENCY_INTERNAL : DEPENDENCY_AUTO); /* * Also install dependencies on objects referenced in action and qual. @@ -199,11 +199,10 @@ DefineQueryRewrite(RuleStmt *stmt) /* * If we are installing an ON SELECT rule, we had better grab - * AccessExclusiveLock to ensure no SELECTs are currently running on - * the event relation. For other types of rules, it might be - * sufficient to grab ShareLock to lock out insert/update/delete - * actions. But for now, let's just grab AccessExclusiveLock all the - * time. + * AccessExclusiveLock to ensure no SELECTs are currently running on the + * event relation. For other types of rules, it might be sufficient to + * grab ShareLock to lock out insert/update/delete actions. But for now, + * let's just grab AccessExclusiveLock all the time. */ event_relation = heap_openrv(event_obj, AccessExclusiveLock); ev_relid = RelationGetRelid(event_relation); @@ -253,7 +252,7 @@ DefineQueryRewrite(RuleStmt *stmt) if (list_length(action) == 0) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("INSTEAD NOTHING rules on SELECT are not implemented"), + errmsg("INSTEAD NOTHING rules on SELECT are not implemented"), errhint("Use views instead."))); /* @@ -271,7 +270,7 @@ DefineQueryRewrite(RuleStmt *stmt) if (!is_instead || query->commandType != CMD_SELECT) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("rules on SELECT must have action INSTEAD SELECT"))); + errmsg("rules on SELECT must have action INSTEAD SELECT"))); /* * ... there can be no rule qual, ... @@ -299,18 +298,17 @@ DefineQueryRewrite(RuleStmt *stmt) if (i > event_relation->rd_att->natts) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("SELECT rule's target list has too many entries"))); + errmsg("SELECT rule's target list has too many entries"))); attr = event_relation->rd_att->attrs[i - 1]; attname = NameStr(attr->attname); /* - * Disallow dropped columns in the relation. This won't - * happen in the cases we actually care about (namely creating - * a view via CREATE TABLE then CREATE RULE). Trying to cope - * with it is much more trouble than it's worth, because we'd - * have to modify the rule to insert dummy NULLs at the right - * positions. + * Disallow dropped columns in the relation. This won't happen in + * the cases we actually care about (namely creating a view via + * CREATE TABLE then CREATE RULE). Trying to cope with it is much + * more trouble than it's worth, because we'd have to modify the + * rule to insert dummy NULLs at the right positions. */ if (attr->attisdropped) ereport(ERROR, @@ -328,11 +326,10 @@ DefineQueryRewrite(RuleStmt *stmt) errmsg("SELECT rule's target entry %d has different type from column \"%s\"", i, attname))); /* - * Allow typmods to be different only if one of them is -1, - * ie, "unspecified". This is necessary for cases like - * "numeric", where the table will have a filled-in default - * length but the select rule's expression will probably have - * typmod = -1. + * Allow typmods to be different only if one of them is -1, ie, + * "unspecified". This is necessary for cases like "numeric", + * where the table will have a filled-in default length but the + * select rule's expression will probably have typmod = -1. */ tletypmod = exprTypmod((Node *) tle->expr); if (attr->atttypmod != tletypmod && @@ -345,7 +342,7 @@ DefineQueryRewrite(RuleStmt *stmt) if (i != event_relation->rd_att->natts) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("SELECT rule's target list has too few entries"))); + errmsg("SELECT rule's target list has too few entries"))); /* * ... there must not be another ON SELECT rule already ... @@ -359,9 +356,9 @@ DefineQueryRewrite(RuleStmt *stmt) rule = event_relation->rd_rules->rules[i]; if (rule->event == CMD_SELECT) ereport(ERROR, - (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), - errmsg("\"%s\" is already a view", - RelationGetRelationName(event_relation)))); + (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), + errmsg("\"%s\" is already a view", + RelationGetRelationName(event_relation)))); } } @@ -371,30 +368,30 @@ DefineQueryRewrite(RuleStmt *stmt) if (strcmp(stmt->rulename, ViewSelectRuleName) != 0) { /* - * In versions before 7.3, the expected name was _RETviewname. - * For backwards compatibility with old pg_dump output, accept - * that and silently change it to _RETURN. Since this is just - * a quick backwards-compatibility hack, limit the number of - * characters checked to a few less than NAMEDATALEN; this - * saves having to worry about where a multibyte character - * might have gotten truncated. + * In versions before 7.3, the expected name was _RETviewname. For + * backwards compatibility with old pg_dump output, accept that + * and silently change it to _RETURN. Since this is just a quick + * backwards-compatibility hack, limit the number of characters + * checked to a few less than NAMEDATALEN; this saves having to + * worry about where a multibyte character might have gotten + * truncated. */ if (strncmp(stmt->rulename, "_RET", 4) != 0 || strncmp(stmt->rulename + 4, event_obj->relname, NAMEDATALEN - 4 - 4) != 0) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("view rule for \"%s\" must be named \"%s\"", - event_obj->relname, ViewSelectRuleName))); + errmsg("view rule for \"%s\" must be named \"%s\"", + event_obj->relname, ViewSelectRuleName))); stmt->rulename = pstrdup(ViewSelectRuleName); } /* * Are we converting a relation to a view? * - * If so, check that the relation is empty because the storage for - * the relation is going to be deleted. Also insist that the rel - * not have any triggers, indexes, or child tables. + * If so, check that the relation is empty because the storage for the + * relation is going to be deleted. Also insist that the rel not have + * any triggers, indexes, or child tables. */ if (event_relation->rd_rel->relkind != RELKIND_VIEW) { @@ -403,29 +400,29 @@ DefineQueryRewrite(RuleStmt *stmt) scanDesc = heap_beginscan(event_relation, SnapshotNow, 0, NULL); if (heap_getnext(scanDesc, ForwardScanDirection) != NULL) ereport(ERROR, - (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), - errmsg("could not convert table \"%s\" to a view because it is not empty", - event_obj->relname))); + (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), + errmsg("could not convert table \"%s\" to a view because it is not empty", + event_obj->relname))); heap_endscan(scanDesc); if (event_relation->rd_rel->reltriggers != 0) ereport(ERROR, - (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), - errmsg("could not convert table \"%s\" to a view because it has triggers", - event_obj->relname), - errhint("In particular, the table may not be involved in any foreign key relationships."))); + (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), + errmsg("could not convert table \"%s\" to a view because it has triggers", + event_obj->relname), + errhint("In particular, the table may not be involved in any foreign key relationships."))); if (event_relation->rd_rel->relhasindex) ereport(ERROR, - (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), - errmsg("could not convert table \"%s\" to a view because it has indexes", - event_obj->relname))); + (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), + errmsg("could not convert table \"%s\" to a view because it has indexes", + event_obj->relname))); if (event_relation->rd_rel->relhassubclass) ereport(ERROR, - (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), - errmsg("could not convert table \"%s\" to a view because it has child tables", - event_obj->relname))); + (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), + errmsg("could not convert table \"%s\" to a view because it has child tables", + event_obj->relname))); RelisBecomingView = true; } @@ -438,11 +435,10 @@ DefineQueryRewrite(RuleStmt *stmt) event_attype = InvalidOid; /* - * We want the rule's table references to be checked as though by the - * rule owner, not the user referencing the rule. Therefore, scan - * through the rule's rtables and set the checkAsUser field on all - * rtable entries. We have to look at event_qual as well, in case it - * contains sublinks. + * We want the rule's table references to be checked as though by the rule + * owner, not the user referencing the rule. Therefore, scan through the + * rule's rtables and set the checkAsUser field on all rtable entries. We + * have to look at event_qual as well, in case it contains sublinks. */ foreach(l, action) { @@ -468,17 +464,15 @@ DefineQueryRewrite(RuleStmt *stmt) * appropriate, also modify the 'relkind' field to show that the * relation is now a view. * - * Important side effect: an SI notice is broadcast to force all - * backends (including me!) to update relcache entries with the - * new rule. + * Important side effect: an SI notice is broadcast to force all backends + * (including me!) to update relcache entries with the new rule. */ SetRelationRuleStatus(ev_relid, true, RelisBecomingView); } /* - * IF the relation is becoming a view, delete the storage files - * associated with it. NB: we had better have AccessExclusiveLock to - * do this ... + * IF the relation is becoming a view, delete the storage files associated + * with it. NB: we had better have AccessExclusiveLock to do this ... * * XXX what about getting rid of its TOAST table? For now, we don't. */ diff --git a/src/backend/rewrite/rewriteHandler.c b/src/backend/rewrite/rewriteHandler.c index 1c58ccd7ca..3513cf67c4 100644 --- a/src/backend/rewrite/rewriteHandler.c +++ b/src/backend/rewrite/rewriteHandler.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/rewrite/rewriteHandler.c,v 1.157 2005/08/01 20:31:10 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/rewrite/rewriteHandler.c,v 1.158 2005/10/15 02:49:24 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -53,7 +53,7 @@ static TargetEntry *process_matched_tle(TargetEntry *src_tle, const char *attrName); static Node *get_assignment_input(Node *node); static void markQueryForLocking(Query *qry, bool forUpdate, bool noWait, - bool skipOldNew); + bool skipOldNew); static List *matchLocks(CmdType event, RuleLock *rulelocks, int varno, Query *parsetree); static Query *fireRIRrules(Query *parsetree, List *activeRIRs); @@ -115,17 +115,17 @@ AcquireRewriteLocks(Query *parsetree) switch (rte->rtekind) { case RTE_RELATION: + /* - * Grab the appropriate lock type for the relation, and - * do not release it until end of transaction. This protects - * the rewriter and planner against schema changes mid-query. + * Grab the appropriate lock type for the relation, and do not + * release it until end of transaction. This protects the + * rewriter and planner against schema changes mid-query. * - * If the relation is the query's result relation, then we - * need RowExclusiveLock. Otherwise, check to see if the - * relation is accessed FOR UPDATE/SHARE or not. We can't - * just grab AccessShareLock because then the executor - * would be trying to upgrade the lock, leading to possible - * deadlocks. + * If the relation is the query's result relation, then we need + * RowExclusiveLock. Otherwise, check to see if the relation + * is accessed FOR UPDATE/SHARE or not. We can't just grab + * AccessShareLock because then the executor would be trying + * to upgrade the lock, leading to possible deadlocks. */ if (rt_index == parsetree->resultRelation) lockmode = RowExclusiveLock; @@ -139,14 +139,15 @@ AcquireRewriteLocks(Query *parsetree) break; case RTE_JOIN: + /* - * Scan the join's alias var list to see if any columns - * have been dropped, and if so replace those Vars with - * NULL Consts. + * Scan the join's alias var list to see if any columns have + * been dropped, and if so replace those Vars with NULL + * Consts. * - * Since a join has only two inputs, we can expect to - * see multiple references to the same input RTE; optimize - * away multiple fetches. + * Since a join has only two inputs, we can expect to see + * multiple references to the same input RTE; optimize away + * multiple fetches. */ newaliasvars = NIL; curinputvarno = 0; @@ -159,19 +160,19 @@ AcquireRewriteLocks(Query *parsetree) * If the list item isn't a simple Var, then it must * represent a merged column, ie a USING column, and so it * couldn't possibly be dropped, since it's referenced in - * the join clause. (Conceivably it could also be a - * NULL constant already? But that's OK too.) + * the join clause. (Conceivably it could also be a NULL + * constant already? But that's OK too.) */ if (IsA(aliasvar, Var)) { /* * The elements of an alias list have to refer to - * earlier RTEs of the same rtable, because that's - * the order the planner builds things in. So we - * already processed the referenced RTE, and so it's - * safe to use get_rte_attribute_is_dropped on it. - * (This might not hold after rewriting or planning, - * but it's OK to assume here.) + * earlier RTEs of the same rtable, because that's the + * order the planner builds things in. So we already + * processed the referenced RTE, and so it's safe to + * use get_rte_attribute_is_dropped on it. (This might + * not hold after rewriting or planning, but it's OK + * to assume here.) */ Assert(aliasvar->varlevelsup == 0); if (aliasvar->varno != curinputvarno) @@ -200,6 +201,7 @@ AcquireRewriteLocks(Query *parsetree) break; case RTE_SUBQUERY: + /* * The subquery RTE itself is all right, but we have to * recurse to process the represented subquery. @@ -214,8 +216,8 @@ AcquireRewriteLocks(Query *parsetree) } /* - * Recurse into sublink subqueries, too. But we already did the ones - * in the rtable. + * Recurse into sublink subqueries, too. But we already did the ones in + * the rtable. */ if (parsetree->hasSubLinks) query_tree_walker(parsetree, acquireLocksOnSubLinks, NULL, @@ -266,8 +268,8 @@ rewriteRuleAction(Query *parsetree, Query **sub_action_ptr; /* - * Make modifiable copies of rule action and qual (what we're passed - * are the stored versions in the relcache; don't touch 'em!). + * Make modifiable copies of rule action and qual (what we're passed are + * the stored versions in the relcache; don't touch 'em!). */ rule_action = (Query *) copyObject(rule_action); rule_qual = (Node *) copyObject(rule_qual); @@ -283,12 +285,12 @@ rewriteRuleAction(Query *parsetree, new_varno = PRS2_NEW_VARNO + rt_length; /* - * Adjust rule action and qual to offset its varnos, so that we can - * merge its rtable with the main parsetree's rtable. + * Adjust rule action and qual to offset its varnos, so that we can merge + * its rtable with the main parsetree's rtable. * - * If the rule action is an INSERT...SELECT, the OLD/NEW rtable entries - * will be in the SELECT part, and we have to modify that rather than - * the top-level INSERT (kluge!). + * If the rule action is an INSERT...SELECT, the OLD/NEW rtable entries will + * be in the SELECT part, and we have to modify that rather than the + * top-level INSERT (kluge!). */ sub_action = getInsertSelectQuery(rule_action, &sub_action_ptr); @@ -303,50 +305,47 @@ rewriteRuleAction(Query *parsetree, /* * Generate expanded rtable consisting of main parsetree's rtable plus * rule action's rtable; this becomes the complete rtable for the rule - * action. Some of the entries may be unused after we finish - * rewriting, but we leave them all in place for two reasons: + * action. Some of the entries may be unused after we finish rewriting, + * but we leave them all in place for two reasons: * - * We'd have a much harder job to adjust the query's varnos if we - * selectively removed RT entries. + * We'd have a much harder job to adjust the query's varnos if we selectively + * removed RT entries. * - * If the rule is INSTEAD, then the original query won't be executed at - * all, and so its rtable must be preserved so that the executor will - * do the correct permissions checks on it. + * If the rule is INSTEAD, then the original query won't be executed at all, + * and so its rtable must be preserved so that the executor will do the + * correct permissions checks on it. * * RT entries that are not referenced in the completed jointree will be - * ignored by the planner, so they do not affect query semantics. But - * any permissions checks specified in them will be applied during - * executor startup (see ExecCheckRTEPerms()). This allows us to - * check that the caller has, say, insert-permission on a view, when - * the view is not semantically referenced at all in the resulting - * query. + * ignored by the planner, so they do not affect query semantics. But any + * permissions checks specified in them will be applied during executor + * startup (see ExecCheckRTEPerms()). This allows us to check that the + * caller has, say, insert-permission on a view, when the view is not + * semantically referenced at all in the resulting query. * - * When a rule is not INSTEAD, the permissions checks done on its copied - * RT entries will be redundant with those done during execution of - * the original query, but we don't bother to treat that case - * differently. + * When a rule is not INSTEAD, the permissions checks done on its copied RT + * entries will be redundant with those done during execution of the + * original query, but we don't bother to treat that case differently. * - * NOTE: because planner will destructively alter rtable, we must ensure - * that rule action's rtable is separate and shares no substructure - * with the main rtable. Hence do a deep copy here. + * NOTE: because planner will destructively alter rtable, we must ensure that + * rule action's rtable is separate and shares no substructure with the + * main rtable. Hence do a deep copy here. */ sub_action->rtable = list_concat((List *) copyObject(parsetree->rtable), sub_action->rtable); /* * Each rule action's jointree should be the main parsetree's jointree - * plus that rule's jointree, but usually *without* the original - * rtindex that we're replacing (if present, which it won't be for - * INSERT). Note that if the rule action refers to OLD, its jointree - * will add a reference to rt_index. If the rule action doesn't refer - * to OLD, but either the rule_qual or the user query quals do, then - * we need to keep the original rtindex in the jointree to provide - * data for the quals. We don't want the original rtindex to be - * joined twice, however, so avoid keeping it if the rule action - * mentions it. + * plus that rule's jointree, but usually *without* the original rtindex + * that we're replacing (if present, which it won't be for INSERT). Note + * that if the rule action refers to OLD, its jointree will add a + * reference to rt_index. If the rule action doesn't refer to OLD, but + * either the rule_qual or the user query quals do, then we need to keep + * the original rtindex in the jointree to provide data for the quals. We + * don't want the original rtindex to be joined twice, however, so avoid + * keeping it if the rule action mentions it. * - * As above, the action's jointree must not share substructure with the - * main parsetree's. + * As above, the action's jointree must not share substructure with the main + * parsetree's. */ if (sub_action->commandType != CMD_UTILITY) { @@ -357,15 +356,15 @@ rewriteRuleAction(Query *parsetree, keeporig = (!rangeTableEntry_used((Node *) sub_action->jointree, rt_index, 0)) && (rangeTableEntry_used(rule_qual, rt_index, 0) || - rangeTableEntry_used(parsetree->jointree->quals, rt_index, 0)); + rangeTableEntry_used(parsetree->jointree->quals, rt_index, 0)); newjointree = adjustJoinTreeList(parsetree, !keeporig, rt_index); if (newjointree != NIL) { /* - * If sub_action is a setop, manipulating its jointree will do - * no good at all, because the jointree is dummy. (Perhaps - * someday we could push the joining and quals down to the - * member statements of the setop?) + * If sub_action is a setop, manipulating its jointree will do no + * good at all, because the jointree is dummy. (Perhaps someday + * we could push the joining and quals down to the member + * statements of the setop?) */ if (sub_action->setOperations != NULL) ereport(ERROR, @@ -378,9 +377,9 @@ rewriteRuleAction(Query *parsetree, } /* - * Event Qualification forces copying of parsetree and splitting into - * two queries one w/rule_qual, one w/NOT rule_qual. Also add user - * query qual onto rule action + * Event Qualification forces copying of parsetree and splitting into two + * queries one w/rule_qual, one w/NOT rule_qual. Also add user query qual + * onto rule action */ AddQual(sub_action, rule_qual); @@ -390,9 +389,9 @@ rewriteRuleAction(Query *parsetree, * Rewrite new.attribute w/ right hand side of target-list entry for * appropriate field name in insert/update. * - * KLUGE ALERT: since ResolveNew returns a mutated copy, we can't just - * apply it to sub_action; we have to remember to update the sublink - * inside rule_action, too. + * KLUGE ALERT: since ResolveNew returns a mutated copy, we can't just apply + * it to sub_action; we have to remember to update the sublink inside + * rule_action, too. */ if ((event == CMD_INSERT || event == CMD_UPDATE) && sub_action->commandType != CMD_UTILITY) @@ -440,8 +439,7 @@ adjustJoinTreeList(Query *parsetree, bool removert, int rt_index) newjointree = list_delete_ptr(newjointree, rtr); /* - * foreach is safe because we exit loop after - * list_delete... + * foreach is safe because we exit loop after list_delete... */ break; } @@ -494,13 +492,13 @@ rewriteTargetList(Query *parsetree, Relation target_relation) ListCell *temp; /* - * We process the normal (non-junk) attributes by scanning the input - * tlist once and transferring TLEs into an array, then scanning the - * array to build an output tlist. This avoids O(N^2) behavior for - * large numbers of attributes. + * We process the normal (non-junk) attributes by scanning the input tlist + * once and transferring TLEs into an array, then scanning the array to + * build an output tlist. This avoids O(N^2) behavior for large numbers + * of attributes. * - * Junk attributes are tossed into a separate list during the same - * tlist scan, then appended to the reconstructed tlist. + * Junk attributes are tossed into a separate list during the same tlist + * scan, then appended to the reconstructed tlist. */ numattrs = RelationGetNumberOfAttributes(target_relation); new_tles = (TargetEntry **) palloc0(numattrs * sizeof(TargetEntry *)); @@ -531,11 +529,11 @@ rewriteTargetList(Query *parsetree, Relation target_relation) else { /* - * Copy all resjunk tlist entries to junk_tlist, and - * assign them resnos above the last real resno. + * Copy all resjunk tlist entries to junk_tlist, and assign them + * resnos above the last real resno. * - * Typical junk entries include ORDER BY or GROUP BY expressions - * (are these actually possible in an INSERT or UPDATE?), system + * Typical junk entries include ORDER BY or GROUP BY expressions (are + * these actually possible in an INSERT or UPDATE?), system * attribute references, etc. */ @@ -561,9 +559,9 @@ rewriteTargetList(Query *parsetree, Relation target_relation) continue; /* - * Handle the two cases where we need to insert a default - * expression: it's an INSERT and there's no tlist entry for the - * column, or the tlist entry is a DEFAULT placeholder node. + * Handle the two cases where we need to insert a default expression: + * it's an INSERT and there's no tlist entry for the column, or the + * tlist entry is a DEFAULT placeholder node. */ if ((new_tle == NULL && commandType == CMD_INSERT) || (new_tle && new_tle->expr && IsA(new_tle->expr, SetToDefault))) @@ -573,12 +571,11 @@ rewriteTargetList(Query *parsetree, Relation target_relation) new_expr = build_column_default(target_relation, attrno); /* - * If there is no default (ie, default is effectively NULL), - * we can omit the tlist entry in the INSERT case, since the - * planner can insert a NULL for itself, and there's no point - * in spending any more rewriter cycles on the entry. But in - * the UPDATE case we've got to explicitly set the column to - * NULL. + * If there is no default (ie, default is effectively NULL), we + * can omit the tlist entry in the INSERT case, since the planner + * can insert a NULL for itself, and there's no point in spending + * any more rewriter cycles on the entry. But in the UPDATE case + * we've got to explicitly set the column to NULL. */ if (!new_expr) { @@ -640,8 +637,7 @@ process_matched_tle(TargetEntry *src_tle, if (prior_tle == NULL) { /* - * Normal case where this is the first assignment to the - * attribute. + * Normal case where this is the first assignment to the attribute. */ return src_tle; } @@ -682,8 +678,7 @@ process_matched_tle(TargetEntry *src_tle, attrName))); /* - * Prior TLE could be a nest of assignments if we do this more than - * once. + * Prior TLE could be a nest of assignments if we do this more than once. */ priorbottom = prior_input; for (;;) @@ -713,10 +708,10 @@ process_matched_tle(TargetEntry *src_tle, memcpy(fstore, prior_expr, sizeof(FieldStore)); fstore->newvals = list_concat(list_copy(((FieldStore *) prior_expr)->newvals), - list_copy(((FieldStore *) src_expr)->newvals)); + list_copy(((FieldStore *) src_expr)->newvals)); fstore->fieldnums = list_concat(list_copy(((FieldStore *) prior_expr)->fieldnums), - list_copy(((FieldStore *) src_expr)->fieldnums)); + list_copy(((FieldStore *) src_expr)->fieldnums)); } else { @@ -809,8 +804,7 @@ build_column_default(Relation rel, int attrno) if (expr == NULL) { /* - * No per-column default, so look for a default for the type - * itself. + * No per-column default, so look for a default for the type itself. */ expr = get_typdefault(atttype); } @@ -821,8 +815,8 @@ build_column_default(Relation rel, int attrno) /* * Make sure the value is coerced to the target column type; this will * generally be true already, but there seem to be some corner cases - * involving domain defaults where it might not be true. This should - * match the parser's processing of non-defaulted expressions --- see + * involving domain defaults where it might not be true. This should match + * the parser's processing of non-defaulted expressions --- see * updateTargetListEntry(). */ exprtype = exprType(expr); @@ -840,7 +834,7 @@ build_column_default(Relation rel, int attrno) NameStr(att_tup->attname), format_type_be(atttype), format_type_be(exprtype)), - errhint("You will need to rewrite or cast the expression."))); + errhint("You will need to rewrite or cast the expression."))); return expr; } @@ -913,8 +907,8 @@ ApplyRetrieveRule(Query *parsetree, elog(ERROR, "cannot handle per-attribute ON SELECT rule"); /* - * Make a modifiable copy of the view query, and acquire needed locks - * on the relations it mentions. + * Make a modifiable copy of the view query, and acquire needed locks on + * the relations it mentions. */ rule_action = copyObject(linitial(rule->actions)); @@ -926,8 +920,8 @@ ApplyRetrieveRule(Query *parsetree, rule_action = fireRIRrules(rule_action, activeRIRs); /* - * VIEWs are really easy --- just plug the view query in as a - * subselect, replacing the relation's original RTE. + * VIEWs are really easy --- just plug the view query in as a subselect, + * replacing the relation's original RTE. */ rte = rt_fetch(rt_index, parsetree->rtable); @@ -937,8 +931,8 @@ ApplyRetrieveRule(Query *parsetree, rte->inh = false; /* must not be set for a subquery */ /* - * We move the view's permission check data down to its rangetable. - * The checks will actually be done against the *OLD* entry therein. + * We move the view's permission check data down to its rangetable. The + * checks will actually be done against the *OLD* entry therein. */ subrte = rt_fetch(PRS2_OLD_VARNO, rule_action->rtable); Assert(subrte->relid == relation->rd_id); @@ -954,9 +948,9 @@ ApplyRetrieveRule(Query *parsetree, if (list_member_int(parsetree->rowMarks, rt_index)) { /* - * Remove the view from the list of rels that will actually be - * marked FOR UPDATE/SHARE by the executor. It will still be access- - * checked for write access, though. + * Remove the view from the list of rels that will actually be marked + * FOR UPDATE/SHARE by the executor. It will still be access- checked + * for write access, though. */ parsetree->rowMarks = list_delete_int(parsetree->rowMarks, rt_index); @@ -989,7 +983,7 @@ markQueryForLocking(Query *qry, bool forUpdate, bool noWait, bool skipOldNew) if (forUpdate != qry->forUpdate) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot use both FOR UPDATE and FOR SHARE in one query"))); + errmsg("cannot use both FOR UPDATE and FOR SHARE in one query"))); if (noWait != qry->rowNoWait) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), @@ -1052,8 +1046,8 @@ fireRIRonSubLink(Node *node, List *activeRIRs) } /* - * Do NOT recurse into Query nodes, because fireRIRrules already - * processed subselects of subselects for us. + * Do NOT recurse into Query nodes, because fireRIRrules already processed + * subselects of subselects for us. */ return expression_tree_walker(node, fireRIRonSubLink, (void *) activeRIRs); @@ -1070,8 +1064,8 @@ fireRIRrules(Query *parsetree, List *activeRIRs) int rt_index; /* - * don't try to convert this into a foreach loop, because rtable list - * can get changed each time through... + * don't try to convert this into a foreach loop, because rtable list can + * get changed each time through... */ rt_index = 0; while (rt_index < list_length(parsetree->rtable)) @@ -1088,8 +1082,8 @@ fireRIRrules(Query *parsetree, List *activeRIRs) rte = rt_fetch(rt_index, parsetree->rtable); /* - * A subquery RTE can't have associated rules, so there's nothing - * to do to this level of the query, but we must recurse into the + * A subquery RTE can't have associated rules, so there's nothing to + * do to this level of the query, but we must recurse into the * subquery to expand any rule references in it. */ if (rte->rtekind == RTE_SUBQUERY) @@ -1108,8 +1102,8 @@ fireRIRrules(Query *parsetree, List *activeRIRs) * If the table is not referenced in the query, then we ignore it. * This prevents infinite expansion loop due to new rtable entries * inserted by expansion of a rule. A table is referenced if it is - * part of the join set (a source table), or is referenced by any - * Var nodes, or is the result table. + * part of the join set (a source table), or is referenced by any Var + * nodes, or is the result table. */ if (rt_index != parsetree->resultRelation && !rangeTableEntry_used((Node *) parsetree, rt_index, 0)) @@ -1181,8 +1175,8 @@ fireRIRrules(Query *parsetree, List *activeRIRs) } /* - * Recurse into sublink subqueries, too. But we already did the ones - * in the rtable. + * Recurse into sublink subqueries, too. But we already did the ones in + * the rtable. */ if (parsetree->hasSubLinks) query_tree_walker(parsetree, fireRIRonSubLink, (void *) activeRIRs, @@ -1217,8 +1211,8 @@ CopyAndAddInvertedQual(Query *parsetree, /* * In case there are subqueries in the qual, acquire necessary locks and * fix any deleted JOIN RTE entries. (This is somewhat redundant with - * rewriteRuleAction, but not entirely ... consider restructuring so - * that we only need to process the qual this way once.) + * rewriteRuleAction, but not entirely ... consider restructuring so that + * we only need to process the qual this way once.) */ (void) acquireLocksOnSubLinks(new_qual, NULL); @@ -1302,13 +1296,13 @@ fireRules(Query *parsetree, if (qsrc == QSRC_QUAL_INSTEAD_RULE) { /* - * If there are INSTEAD rules with qualifications, the - * original query is still performed. But all the negated rule - * qualifications of the INSTEAD rules are added so it does - * its actions only in cases where the rule quals of all - * INSTEAD rules are false. Think of it as the default action - * in a case. We save this in *qual_product so RewriteQuery() - * can add it to the query list after we mangled it up enough. + * If there are INSTEAD rules with qualifications, the original + * query is still performed. But all the negated rule + * qualifications of the INSTEAD rules are added so it does its + * actions only in cases where the rule quals of all INSTEAD rules + * are false. Think of it as the default action in a case. We save + * this in *qual_product so RewriteQuery() can add it to the query + * list after we mangled it up enough. * * If we have already found an unqualified INSTEAD rule, then * *qual_product won't be used, so don't bother building it. @@ -1364,9 +1358,9 @@ RewriteQuery(Query *parsetree, List *rewrite_events) /* * If the statement is an update, insert or delete - fire rules on it. * - * SELECT rules are handled later when we have all the queries that - * should get executed. Also, utilities aren't rewritten at all (do - * we still need that check?) + * SELECT rules are handled later when we have all the queries that should + * get executed. Also, utilities aren't rewritten at all (do we still + * need that check?) */ if (event != CMD_SELECT && event != CMD_UTILITY) { @@ -1387,10 +1381,9 @@ RewriteQuery(Query *parsetree, List *rewrite_events) rt_entry_relation = heap_open(rt_entry->relid, NoLock); /* - * If it's an INSERT or UPDATE, rewrite the targetlist into - * standard form. This will be needed by the planner anyway, and - * doing it now ensures that any references to NEW.field will - * behave sanely. + * If it's an INSERT or UPDATE, rewrite the targetlist into standard + * form. This will be needed by the planner anyway, and doing it now + * ensures that any references to NEW.field will behave sanely. */ if (event == CMD_INSERT || event == CMD_UPDATE) rewriteTargetList(parsetree, rt_entry_relation); @@ -1413,8 +1406,8 @@ RewriteQuery(Query *parsetree, List *rewrite_events) &qual_product); /* - * If we got any product queries, recursively rewrite them --- - * but first check for recursion! + * If we got any product queries, recursively rewrite them --- but + * first check for recursion! */ if (product_queries != NIL) { @@ -1427,9 +1420,9 @@ RewriteQuery(Query *parsetree, List *rewrite_events) if (rev->relation == RelationGetRelid(rt_entry_relation) && rev->event == event) ereport(ERROR, - (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("infinite recursion detected in rules for relation \"%s\"", - RelationGetRelationName(rt_entry_relation)))); + (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), + errmsg("infinite recursion detected in rules for relation \"%s\"", + RelationGetRelationName(rt_entry_relation)))); } rev = (rewrite_event *) palloc(sizeof(rewrite_event)); @@ -1454,13 +1447,12 @@ RewriteQuery(Query *parsetree, List *rewrite_events) } /* - * For INSERTs, the original query is done first; for UPDATE/DELETE, - * it is done last. This is needed because update and delete rule - * actions might not do anything if they are invoked after the update - * or delete is performed. The command counter increment between the - * query executions makes the deleted (and maybe the updated) tuples - * disappear so the scans for them in the rule actions cannot find - * them. + * For INSERTs, the original query is done first; for UPDATE/DELETE, it is + * done last. This is needed because update and delete rule actions might + * not do anything if they are invoked after the update or delete is + * performed. The command counter increment between the query executions + * makes the deleted (and maybe the updated) tuples disappear so the scans + * for them in the rule actions cannot find them. * * If we found any unqualified INSTEAD, the original query is not done at * all, in any form. Otherwise, we add the modified form if qualified @@ -1569,19 +1561,18 @@ QueryRewrite(Query *parsetree) /* * Step 3 * - * Determine which, if any, of the resulting queries is supposed to set - * the command-result tag; and update the canSetTag fields - * accordingly. + * Determine which, if any, of the resulting queries is supposed to set the + * command-result tag; and update the canSetTag fields accordingly. * * If the original query is still in the list, it sets the command tag. - * Otherwise, the last INSTEAD query of the same kind as the original - * is allowed to set the tag. (Note these rules can leave us with no - * query setting the tag. The tcop code has to cope with this by - * setting up a default tag based on the original un-rewritten query.) + * Otherwise, the last INSTEAD query of the same kind as the original is + * allowed to set the tag. (Note these rules can leave us with no query + * setting the tag. The tcop code has to cope with this by setting up a + * default tag based on the original un-rewritten query.) * * The Asserts verify that at most one query in the result list is marked - * canSetTag. If we aren't checking asserts, we can fall out of the - * loop as soon as we find the original query. + * canSetTag. If we aren't checking asserts, we can fall out of the loop + * as soon as we find the original query. */ origCmdType = parsetree->commandType; foundOriginalQuery = false; diff --git a/src/backend/rewrite/rewriteManip.c b/src/backend/rewrite/rewriteManip.c index 353e4ca76f..9e6bc4808e 100644 --- a/src/backend/rewrite/rewriteManip.c +++ b/src/backend/rewrite/rewriteManip.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/rewrite/rewriteManip.c,v 1.91 2005/06/04 19:19:42 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/rewrite/rewriteManip.c,v 1.92 2005/10/15 02:49:24 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -53,8 +53,8 @@ checkExprHasAggs(Node *node) context.sublevels_up = 0; /* - * Must be prepared to start with a Query or a bare expression tree; - * if it's a Query, we don't want to increment sublevels_up. + * Must be prepared to start with a Query or a bare expression tree; if + * it's a Query, we don't want to increment sublevels_up. */ return query_or_expression_tree_walker(node, checkExprHasAggs_walker, @@ -70,8 +70,7 @@ checkExprHasAggs_walker(Node *node, checkExprHasAggs_context *context) if (IsA(node, Aggref)) { if (((Aggref *) node)->agglevelsup == context->sublevels_up) - return true; /* abort the tree traversal and return - * true */ + return true; /* abort the tree traversal and return true */ /* else fall through to examine argument */ } if (IsA(node, Query)) @@ -113,8 +112,7 @@ checkExprHasSubLink_walker(Node *node, void *context) if (node == NULL) return false; if (IsA(node, SubLink)) - return true; /* abort the tree traversal and return - * true */ + return true; /* abort the tree traversal and return true */ return expression_tree_walker(node, checkExprHasSubLink_walker, context); } @@ -208,8 +206,8 @@ OffsetVarNodes(Node *node, int offset, int sublevels_up) context.sublevels_up = sublevels_up; /* - * Must be prepared to start with a Query or a bare expression tree; - * if it's a Query, go straight to query_tree_walker to make sure that + * Must be prepared to start with a Query or a bare expression tree; if + * it's a Query, go straight to query_tree_walker to make sure that * sublevels_up doesn't get incremented prematurely. */ if (node && IsA(node, Query)) @@ -217,11 +215,11 @@ OffsetVarNodes(Node *node, int offset, int sublevels_up) Query *qry = (Query *) node; /* - * If we are starting at a Query, and sublevels_up is zero, then - * we must also fix rangetable indexes in the Query itself --- - * namely resultRelation and rowMarks entries. sublevels_up - * cannot be zero when recursing into a subquery, so there's no - * need to have the same logic inside OffsetVarNodes_walker. + * If we are starting at a Query, and sublevels_up is zero, then we + * must also fix rangetable indexes in the Query itself --- namely + * resultRelation and rowMarks entries. sublevels_up cannot be zero + * when recursing into a subquery, so there's no need to have the same + * logic inside OffsetVarNodes_walker. */ if (sublevels_up == 0) { @@ -349,8 +347,8 @@ ChangeVarNodes(Node *node, int rt_index, int new_index, int sublevels_up) context.sublevels_up = sublevels_up; /* - * Must be prepared to start with a Query or a bare expression tree; - * if it's a Query, go straight to query_tree_walker to make sure that + * Must be prepared to start with a Query or a bare expression tree; if + * it's a Query, go straight to query_tree_walker to make sure that * sublevels_up doesn't get incremented prematurely. */ if (node && IsA(node, Query)) @@ -358,11 +356,11 @@ ChangeVarNodes(Node *node, int rt_index, int new_index, int sublevels_up) Query *qry = (Query *) node; /* - * If we are starting at a Query, and sublevels_up is zero, then - * we must also fix rangetable indexes in the Query itself --- - * namely resultRelation and rowMarks entries. sublevels_up - * cannot be zero when recursing into a subquery, so there's no - * need to have the same logic inside ChangeVarNodes_walker. + * If we are starting at a Query, and sublevels_up is zero, then we + * must also fix rangetable indexes in the Query itself --- namely + * resultRelation and rowMarks entries. sublevels_up cannot be zero + * when recursing into a subquery, so there's no need to have the same + * logic inside ChangeVarNodes_walker. */ if (sublevels_up == 0) { @@ -473,8 +471,8 @@ IncrementVarSublevelsUp(Node *node, int delta_sublevels_up, context.min_sublevels_up = min_sublevels_up; /* - * Must be prepared to start with a Query or a bare expression tree; - * if it's a Query, we don't want to increment sublevels_up. + * Must be prepared to start with a Query or a bare expression tree; if + * it's a Query, we don't want to increment sublevels_up. */ query_or_expression_tree_walker(node, IncrementVarSublevelsUp_walker, @@ -562,8 +560,8 @@ rangeTableEntry_used(Node *node, int rt_index, int sublevels_up) context.sublevels_up = sublevels_up; /* - * Must be prepared to start with a Query or a bare expression tree; - * if it's a Query, we don't want to increment sublevels_up. + * Must be prepared to start with a Query or a bare expression tree; if + * it's a Query, we don't want to increment sublevels_up. */ return query_or_expression_tree_walker(node, rangeTableEntry_used_walker, @@ -626,8 +624,8 @@ attribute_used(Node *node, int rt_index, int attno, int sublevels_up) context.sublevels_up = sublevels_up; /* - * Must be prepared to start with a Query or a bare expression tree; - * if it's a Query, we don't want to increment sublevels_up. + * Must be prepared to start with a Query or a bare expression tree; if + * it's a Query, we don't want to increment sublevels_up. */ return query_or_expression_tree_walker(node, attribute_used_walker, @@ -671,10 +669,10 @@ getInsertSelectQuery(Query *parsetree, Query ***subquery_ptr) * they've been pushed down to the SELECT. */ if (list_length(parsetree->rtable) >= 2 && - strcmp(rt_fetch(PRS2_OLD_VARNO, parsetree->rtable)->eref->aliasname, - "*OLD*") == 0 && - strcmp(rt_fetch(PRS2_NEW_VARNO, parsetree->rtable)->eref->aliasname, - "*NEW*") == 0) + strcmp(rt_fetch(PRS2_OLD_VARNO, parsetree->rtable)->eref->aliasname, + "*OLD*") == 0 && + strcmp(rt_fetch(PRS2_NEW_VARNO, parsetree->rtable)->eref->aliasname, + "*NEW*") == 0) return parsetree; Assert(parsetree->jointree && IsA(parsetree->jointree, FromExpr)); if (list_length(parsetree->jointree->fromlist) != 1) @@ -687,10 +685,10 @@ getInsertSelectQuery(Query *parsetree, Query ***subquery_ptr) selectquery->commandType == CMD_SELECT)) elog(ERROR, "expected to find SELECT subquery"); if (list_length(selectquery->rtable) >= 2 && - strcmp(rt_fetch(PRS2_OLD_VARNO, selectquery->rtable)->eref->aliasname, - "*OLD*") == 0 && - strcmp(rt_fetch(PRS2_NEW_VARNO, selectquery->rtable)->eref->aliasname, - "*NEW*") == 0) + strcmp(rt_fetch(PRS2_OLD_VARNO, selectquery->rtable)->eref->aliasname, + "*OLD*") == 0 && + strcmp(rt_fetch(PRS2_NEW_VARNO, selectquery->rtable)->eref->aliasname, + "*NEW*") == 0) { if (subquery_ptr) *subquery_ptr = &(selectrte->subquery); @@ -717,30 +715,30 @@ AddQual(Query *parsetree, Node *qual) /* * There's noplace to put the qual on a utility statement. * - * If it's a NOTIFY, silently ignore the qual; this means that the - * NOTIFY will execute, whether or not there are any qualifying - * rows. While clearly wrong, this is much more useful than - * refusing to execute the rule at all, and extra NOTIFY events - * are harmless for typical uses of NOTIFY. + * If it's a NOTIFY, silently ignore the qual; this means that the NOTIFY + * will execute, whether or not there are any qualifying rows. While + * clearly wrong, this is much more useful than refusing to execute + * the rule at all, and extra NOTIFY events are harmless for typical + * uses of NOTIFY. * * If it isn't a NOTIFY, error out, since unconditional execution of - * other utility stmts is unlikely to be wanted. (This case is - * not currently allowed anyway, but keep the test for safety.) + * other utility stmts is unlikely to be wanted. (This case is not + * currently allowed anyway, but keep the test for safety.) */ if (parsetree->utilityStmt && IsA(parsetree->utilityStmt, NotifyStmt)) return; else ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("conditional utility statements are not implemented"))); + errmsg("conditional utility statements are not implemented"))); } if (parsetree->setOperations != NULL) { /* - * There's noplace to put the qual on a setop statement, either. - * (This could be fixed, but right now the planner simply ignores - * any qual condition on a setop query.) + * There's noplace to put the qual on a setop statement, either. (This + * could be fixed, but right now the planner simply ignores any qual + * condition on a setop query.) */ ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), @@ -759,8 +757,8 @@ AddQual(Query *parsetree, Node *qual) Assert(!checkExprHasAggs(copy)); /* - * Make sure query is marked correctly if added qual has sublinks. - * Need not search qual when query is already marked. + * Make sure query is marked correctly if added qual has sublinks. Need + * not search qual when query is already marked. */ if (!parsetree->hasSubLinks) parsetree->hasSubLinks = checkExprHasSubLink(copy); @@ -880,9 +878,9 @@ ResolveNew_mutator(Node *node, ResolveNew_context *context) /* * If generating an expansion for a var of a named rowtype - * (ie, this is a plain relation RTE), then we must - * include dummy items for dropped columns. If the var is - * RECORD (ie, this is a JOIN), then omit dropped columns. + * (ie, this is a plain relation RTE), then we must include + * dummy items for dropped columns. If the var is RECORD (ie, + * this is a JOIN), then omit dropped columns. */ expandRTE(context->target_rte, this_varno, this_varlevelsup, @@ -943,8 +941,8 @@ ResolveNew(Node *node, int target_varno, int sublevels_up, context.inserted_sublink = false; /* - * Must be prepared to start with a Query or a bare expression tree; - * if it's a Query, we don't want to increment sublevels_up. + * Must be prepared to start with a Query or a bare expression tree; if + * it's a Query, we don't want to increment sublevels_up. */ return query_or_expression_tree_mutator(node, ResolveNew_mutator, diff --git a/src/backend/rewrite/rewriteRemove.c b/src/backend/rewrite/rewriteRemove.c index f06d23cc32..900b3489df 100644 --- a/src/backend/rewrite/rewriteRemove.c +++ b/src/backend/rewrite/rewriteRemove.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/rewrite/rewriteRemove.c,v 1.62 2005/04/14 20:03:25 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/rewrite/rewriteRemove.c,v 1.63 2005/10/15 02:49:24 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -117,10 +117,10 @@ RemoveRewriteRuleById(Oid ruleOid) elog(ERROR, "could not find tuple for rule %u", ruleOid); /* - * We had better grab AccessExclusiveLock so that we know no other - * rule additions/deletions are going on for this relation. Else we - * cannot set relhasrules correctly. Besides, we don't want to be - * changing the ruleset while queries are executing on the rel. + * We had better grab AccessExclusiveLock so that we know no other rule + * additions/deletions are going on for this relation. Else we cannot set + * relhasrules correctly. Besides, we don't want to be changing the + * ruleset while queries are executing on the rel. */ eventRelationOid = ((Form_pg_rewrite) GETSTRUCT(tuple))->ev_class; event_relation = heap_open(eventRelationOid, AccessExclusiveLock); diff --git a/src/backend/rewrite/rewriteSupport.c b/src/backend/rewrite/rewriteSupport.c index 8fd3bba7cd..6150c904d7 100644 --- a/src/backend/rewrite/rewriteSupport.c +++ b/src/backend/rewrite/rewriteSupport.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/rewrite/rewriteSupport.c,v 1.61 2005/04/14 20:03:25 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/rewrite/rewriteSupport.c,v 1.62 2005/10/15 02:49:24 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -56,8 +56,7 @@ SetRelationRuleStatus(Oid relationId, bool relHasRules, Form_pg_class classForm; /* - * Find the tuple to update in pg_class, using syscache for the - * lookup. + * Find the tuple to update in pg_class, using syscache for the lookup. */ relationRelation = heap_open(RelationRelationId, RowExclusiveLock); tuple = SearchSysCacheCopy(RELOID, diff --git a/src/backend/storage/buffer/buf_init.c b/src/backend/storage/buffer/buf_init.c index d74d356f0e..fa0ea2dc6d 100644 --- a/src/backend/storage/buffer/buf_init.c +++ b/src/backend/storage/buffer/buf_init.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/buffer/buf_init.c,v 1.76 2005/08/20 23:26:17 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/storage/buffer/buf_init.c,v 1.77 2005/10/15 02:49:24 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -120,8 +120,8 @@ InitBufferPool(void) buf->buf_id = i; /* - * Initially link all the buffers together as unused. - * Subsequent management of this list is done by freelist.c. + * Initially link all the buffers together as unused. Subsequent + * management of this list is done by freelist.c. */ buf->freeNext = i + 1; diff --git a/src/backend/storage/buffer/buf_table.c b/src/backend/storage/buffer/buf_table.c index 99dbbacd29..8d1ad267f7 100644 --- a/src/backend/storage/buffer/buf_table.c +++ b/src/backend/storage/buffer/buf_table.c @@ -3,7 +3,7 @@ * buf_table.c * routines for mapping BufferTags to buffer indexes. * - * Note: the routines in this file do no locking of their own. The caller + * Note: the routines in this file do no locking of their own. The caller * must hold a suitable lock on the BufMappingLock, as specified in the * comments. * @@ -13,7 +13,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/buffer/buf_table.c,v 1.42 2005/08/20 23:26:17 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/storage/buffer/buf_table.c,v 1.43 2005/10/15 02:49:24 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -93,7 +93,7 @@ BufTableLookup(BufferTag *tagPtr) * Insert a hashtable entry for given tag and buffer ID, * unless an entry already exists for that tag * - * Returns -1 on successful insertion. If a conflicting entry exists + * Returns -1 on successful insertion. If a conflicting entry exists * already, returns the buffer ID in that entry. * * Caller must hold write lock on BufMappingLock @@ -105,7 +105,7 @@ BufTableInsert(BufferTag *tagPtr, int buf_id) bool found; Assert(buf_id >= 0); /* -1 is reserved for not-in-table */ - Assert(tagPtr->blockNum != P_NEW); /* invalid tag */ + Assert(tagPtr->blockNum != P_NEW); /* invalid tag */ result = (BufferLookupEnt *) hash_search(SharedBufHash, (void *) tagPtr, HASH_ENTER, &found); diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c index fb3efcbca9..8341a25e05 100644 --- a/src/backend/storage/buffer/bufmgr.c +++ b/src/backend/storage/buffer/bufmgr.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/buffer/bufmgr.c,v 1.196 2005/10/12 16:45:13 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/storage/buffer/bufmgr.c,v 1.197 2005/10/15 02:49:24 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -58,7 +58,7 @@ #define BufferGetLSN(bufHdr) (*((XLogRecPtr*) BufHdrGetBlock(bufHdr))) /* Note: this macro only works on local buffers, not shared ones! */ -#define LocalBufHdrGetBlock(bufHdr) \ +#define LocalBufHdrGetBlock(bufHdr) \ LocalBufferBlockPointers[-((bufHdr)->buf_id + 2)] @@ -70,14 +70,15 @@ int bgwriter_lru_maxpages = 5; int bgwriter_all_maxpages = 5; -long NDirectFileRead; /* some I/O's are direct file access. - * bypass bufmgr */ +long NDirectFileRead; /* some I/O's are direct file access. bypass + * bufmgr */ long NDirectFileWrite; /* e.g., I/O in psort and hashjoin. */ /* local state for StartBufferIO and related functions */ static volatile BufferDesc *InProgressBuf = NULL; static bool IsForInput; + /* local state for LockBufferForCleanup */ static volatile BufferDesc *PinCountWaitBuf = NULL; @@ -89,7 +90,7 @@ static bool SyncOneBuffer(int buf_id, bool skip_pinned); static void WaitIO(volatile BufferDesc *buf); static bool StartBufferIO(volatile BufferDesc *buf, bool forInput); static void TerminateBufferIO(volatile BufferDesc *buf, bool clear_dirty, - int set_flag_bits); + int set_flag_bits); static void buffer_write_error_callback(void *arg); static volatile BufferDesc *BufferAlloc(Relation reln, BlockNumber blockNum, bool *foundPtr); @@ -149,8 +150,8 @@ ReadBuffer(Relation reln, BlockNumber blockNum) ReadBufferCount++; /* - * lookup the buffer. IO_IN_PROGRESS is set if the requested - * block is not currently in memory. + * lookup the buffer. IO_IN_PROGRESS is set if the requested block is + * not currently in memory. */ bufHdr = BufferAlloc(reln, blockNum, &found); if (found) @@ -173,17 +174,16 @@ ReadBuffer(Relation reln, BlockNumber blockNum) /* * if we have gotten to this point, we have allocated a buffer for the - * page but its contents are not yet valid. IO_IN_PROGRESS is set for - * it, if it's a shared buffer. + * page but its contents are not yet valid. IO_IN_PROGRESS is set for it, + * if it's a shared buffer. * - * Note: if smgrextend fails, we will end up with a buffer that is - * allocated but not marked BM_VALID. P_NEW will still select the - * same block number (because the relation didn't get any longer on - * disk) and so future attempts to extend the relation will find the - * same buffer (if it's not been recycled) but come right back here to - * try smgrextend again. + * Note: if smgrextend fails, we will end up with a buffer that is allocated + * but not marked BM_VALID. P_NEW will still select the same block number + * (because the relation didn't get any longer on disk) and so future + * attempts to extend the relation will find the same buffer (if it's not + * been recycled) but come right back here to try smgrextend again. */ - Assert(!(bufHdr->flags & BM_VALID)); /* spinlock not needed */ + Assert(!(bufHdr->flags & BM_VALID)); /* spinlock not needed */ bufBlock = isLocalBuf ? LocalBufHdrGetBlock(bufHdr) : BufHdrGetBlock(bufHdr); @@ -201,25 +201,24 @@ ReadBuffer(Relation reln, BlockNumber blockNum) if (!PageHeaderIsValid((PageHeader) bufBlock)) { /* - * During WAL recovery, the first access to any data page - * should overwrite the whole page from the WAL; so a - * clobbered page header is not reason to fail. Hence, when - * InRecovery we may always act as though zero_damaged_pages - * is ON. + * During WAL recovery, the first access to any data page should + * overwrite the whole page from the WAL; so a clobbered page + * header is not reason to fail. Hence, when InRecovery we may + * always act as though zero_damaged_pages is ON. */ if (zero_damaged_pages || InRecovery) { ereport(WARNING, (errcode(ERRCODE_DATA_CORRUPTED), errmsg("invalid page header in block %u of relation \"%s\"; zeroing out page", - blockNum, RelationGetRelationName(reln)))); + blockNum, RelationGetRelationName(reln)))); MemSet((char *) bufBlock, 0, BLCKSZ); } else ereport(ERROR, (errcode(ERRCODE_DATA_CORRUPTED), - errmsg("invalid page header in block %u of relation \"%s\"", - blockNum, RelationGetRelationName(reln)))); + errmsg("invalid page header in block %u of relation \"%s\"", + blockNum, RelationGetRelationName(reln)))); } } @@ -277,8 +276,8 @@ BufferAlloc(Relation reln, { /* * Found it. Now, pin the buffer so no one can steal it from the - * buffer pool, and check to see if the correct data has been - * loaded into the buffer. + * buffer pool, and check to see if the correct data has been loaded + * into the buffer. */ buf = &BufferDescriptors[buf_id]; @@ -292,17 +291,17 @@ BufferAlloc(Relation reln, if (!valid) { /* - * We can only get here if (a) someone else is still reading - * in the page, or (b) a previous read attempt failed. We - * have to wait for any active read attempt to finish, and - * then set up our own read attempt if the page is still not - * BM_VALID. StartBufferIO does it all. + * We can only get here if (a) someone else is still reading in + * the page, or (b) a previous read attempt failed. We have to + * wait for any active read attempt to finish, and then set up our + * own read attempt if the page is still not BM_VALID. + * StartBufferIO does it all. */ if (StartBufferIO(buf, true)) { /* - * If we get here, previous attempts to read the buffer - * must have failed ... but we shall bravely try again. + * If we get here, previous attempts to read the buffer must + * have failed ... but we shall bravely try again. */ *foundPtr = FALSE; } @@ -313,7 +312,7 @@ BufferAlloc(Relation reln, /* * Didn't find it in the buffer pool. We'll have to initialize a new - * buffer. Remember to unlock BufMappingLock while doing the work. + * buffer. Remember to unlock BufMappingLock while doing the work. */ LWLockRelease(BufMappingLock); @@ -321,10 +320,10 @@ BufferAlloc(Relation reln, for (;;) { /* - * Select a victim buffer. The buffer is returned with its - * header spinlock still held! Also the BufFreelistLock is - * still held, since it would be bad to hold the spinlock - * while possibly waking up other processes. + * Select a victim buffer. The buffer is returned with its header + * spinlock still held! Also the BufFreelistLock is still held, since + * it would be bad to hold the spinlock while possibly waking up other + * processes. */ buf = StrategyGetBuffer(); @@ -341,8 +340,8 @@ BufferAlloc(Relation reln, /* * If the buffer was dirty, try to write it out. There is a race - * condition here, in that someone might dirty it after we released - * it above, or even while we are writing it out (since our share-lock + * condition here, in that someone might dirty it after we released it + * above, or even while we are writing it out (since our share-lock * won't prevent hint-bit updates). We will recheck the dirty bit * after re-locking the buffer header. */ @@ -350,14 +349,14 @@ BufferAlloc(Relation reln, { /* * We need a share-lock on the buffer contents to write it out - * (else we might write invalid data, eg because someone else - * is compacting the page contents while we write). We must use - * a conditional lock acquisition here to avoid deadlock. Even + * (else we might write invalid data, eg because someone else is + * compacting the page contents while we write). We must use a + * conditional lock acquisition here to avoid deadlock. Even * though the buffer was not pinned (and therefore surely not * locked) when StrategyGetBuffer returned it, someone else could - * have pinned and exclusive-locked it by the time we get here. - * If we try to get the lock unconditionally, we'd block waiting - * for them; if they later block waiting for us, deadlock ensues. + * have pinned and exclusive-locked it by the time we get here. If + * we try to get the lock unconditionally, we'd block waiting for + * them; if they later block waiting for us, deadlock ensues. * (This has been observed to happen when two backends are both * trying to split btree index pages, and the second one just * happens to be trying to split the page the first one got from @@ -371,8 +370,8 @@ BufferAlloc(Relation reln, else { /* - * Someone else has pinned the buffer, so give it up and - * loop back to get another one. + * Someone else has pinned the buffer, so give it up and loop + * back to get another one. */ UnpinBuffer(buf, true, false /* evidently recently used */ ); continue; @@ -380,8 +379,8 @@ BufferAlloc(Relation reln, } /* - * Acquire exclusive mapping lock in preparation for changing - * the buffer's association. + * Acquire exclusive mapping lock in preparation for changing the + * buffer's association. */ LWLockAcquire(BufMappingLock, LW_EXCLUSIVE); @@ -389,20 +388,19 @@ BufferAlloc(Relation reln, * Try to make a hashtable entry for the buffer under its new tag. * This could fail because while we were writing someone else * allocated another buffer for the same block we want to read in. - * Note that we have not yet removed the hashtable entry for the - * old tag. + * Note that we have not yet removed the hashtable entry for the old + * tag. */ buf_id = BufTableInsert(&newTag, buf->buf_id); if (buf_id >= 0) { /* - * Got a collision. Someone has already done what we were about - * to do. We'll just handle this as if it were found in - * the buffer pool in the first place. First, give up the - * buffer we were planning to use. Don't allow it to be - * thrown in the free list (we don't want to hold both - * global locks at once). + * Got a collision. Someone has already done what we were about to + * do. We'll just handle this as if it were found in the buffer + * pool in the first place. First, give up the buffer we were + * planning to use. Don't allow it to be thrown in the free list + * (we don't want to hold both global locks at once). */ UnpinBuffer(buf, true, false); @@ -421,7 +419,7 @@ BufferAlloc(Relation reln, { /* * We can only get here if (a) someone else is still reading - * in the page, or (b) a previous read attempt failed. We + * in the page, or (b) a previous read attempt failed. We * have to wait for any active read attempt to finish, and * then set up our own read attempt if the page is still not * BM_VALID. StartBufferIO does it all. @@ -446,9 +444,9 @@ BufferAlloc(Relation reln, /* * Somebody could have pinned or re-dirtied the buffer while we were - * doing the I/O and making the new hashtable entry. If so, we - * can't recycle this buffer; we must undo everything we've done and - * start over with a new victim buffer. + * doing the I/O and making the new hashtable entry. If so, we can't + * recycle this buffer; we must undo everything we've done and start + * over with a new victim buffer. */ if (buf->refcount == 1 && !(buf->flags & BM_DIRTY)) break; @@ -462,9 +460,9 @@ BufferAlloc(Relation reln, /* * Okay, it's finally safe to rename the buffer. * - * Clearing BM_VALID here is necessary, clearing the dirtybits - * is just paranoia. We also clear the usage_count since any - * recency of use of the old content is no longer relevant. + * Clearing BM_VALID here is necessary, clearing the dirtybits is just + * paranoia. We also clear the usage_count since any recency of use of + * the old content is no longer relevant. */ oldTag = buf->tag; oldFlags = buf->flags; @@ -482,9 +480,8 @@ BufferAlloc(Relation reln, /* * Buffer contents are currently invalid. Try to get the io_in_progress - * lock. If StartBufferIO returns false, then someone else managed - * to read it before we did, so there's nothing left for BufferAlloc() - * to do. + * lock. If StartBufferIO returns false, then someone else managed to + * read it before we did, so there's nothing left for BufferAlloc() to do. */ if (StartBufferIO(buf, true)) *foundPtr = FALSE; @@ -505,7 +502,7 @@ BufferAlloc(Relation reln, * This is used only in contexts such as dropping a relation. We assume * that no other backend could possibly be interested in using the page, * so the only reason the buffer might be pinned is if someone else is - * trying to write it out. We have to let them finish before we can + * trying to write it out. We have to let them finish before we can * reclaim the buffer. * * The buffer could get reclaimed by someone else while we are waiting @@ -523,9 +520,10 @@ InvalidateBuffer(volatile BufferDesc *buf) UnlockBufHdr(buf); retry: + /* - * Acquire exclusive mapping lock in preparation for changing - * the buffer's association. + * Acquire exclusive mapping lock in preparation for changing the buffer's + * association. */ LWLockAcquire(BufMappingLock, LW_EXCLUSIVE); @@ -541,13 +539,13 @@ retry: } /* - * We assume the only reason for it to be pinned is that someone else - * is flushing the page out. Wait for them to finish. (This could be - * an infinite loop if the refcount is messed up... it would be nice - * to time out after awhile, but there seems no way to be sure how - * many loops may be needed. Note that if the other guy has pinned - * the buffer but not yet done StartBufferIO, WaitIO will fall through - * and we'll effectively be busy-looping here.) + * We assume the only reason for it to be pinned is that someone else is + * flushing the page out. Wait for them to finish. (This could be an + * infinite loop if the refcount is messed up... it would be nice to time + * out after awhile, but there seems no way to be sure how many loops may + * be needed. Note that if the other guy has pinned the buffer but not + * yet done StartBufferIO, WaitIO will fall through and we'll effectively + * be busy-looping here.) */ if (buf->refcount != 0) { @@ -561,8 +559,8 @@ retry: } /* - * Clear out the buffer's tag and flags. We must do this to ensure - * that linear scans of the buffer array don't think the buffer is valid. + * Clear out the buffer's tag and flags. We must do this to ensure that + * linear scans of the buffer array don't think the buffer is valid. */ oldFlags = buf->flags; CLEAR_BUFFERTAG(buf->tag); @@ -666,7 +664,7 @@ WriteNoReleaseBuffer(Buffer buffer) * * Formerly, this saved one cycle of acquiring/releasing the BufMgrLock * compared to calling the two routines separately. Now it's mainly just - * a convenience function. However, if the passed buffer is valid and + * a convenience function. However, if the passed buffer is valid and * already contains the desired block, we just return it as-is; and that * does save considerable work compared to a full release and reacquire. * @@ -718,7 +716,7 @@ ReleaseAndReadBuffer(Buffer buffer, * * Note that ResourceOwnerEnlargeBuffers must have been done already. * - * Returns TRUE if buffer is BM_VALID, else FALSE. This provision allows + * Returns TRUE if buffer is BM_VALID, else FALSE. This provision allows * some callers to avoid an extra spinlock cycle. */ static bool @@ -731,8 +729,8 @@ PinBuffer(volatile BufferDesc *buf) { /* * Use NoHoldoff here because we don't want the unlock to be a - * potential place to honor a QueryCancel request. - * (The caller should be holding off interrupts anyway.) + * potential place to honor a QueryCancel request. (The caller should + * be holding off interrupts anyway.) */ LockBufHdr_NoHoldoff(buf); buf->refcount++; @@ -799,7 +797,7 @@ UnpinBuffer(volatile BufferDesc *buf, bool fixOwner, bool trashOK) PrivateRefCount[b]--; if (PrivateRefCount[b] == 0) { - bool trash_buffer = false; + bool trash_buffer = false; /* I'd better not still hold any locks on the buffer */ Assert(!LWLockHeldByMe(buf->content_lock)); @@ -818,7 +816,7 @@ UnpinBuffer(volatile BufferDesc *buf, bool fixOwner, bool trashOK) if (buf->usage_count < BM_MAX_USAGE_COUNT) buf->usage_count++; } - else if (trashOK && + else if (trashOK && buf->refcount == 0 && buf->usage_count == 0) trash_buffer = true; @@ -827,7 +825,7 @@ UnpinBuffer(volatile BufferDesc *buf, bool fixOwner, bool trashOK) buf->refcount == 1) { /* we just released the last pin other than the waiter's */ - int wait_backend_pid = buf->wait_backend_pid; + int wait_backend_pid = buf->wait_backend_pid; buf->flags &= ~BM_PIN_COUNT_WAITER; UnlockBufHdr_NoHoldoff(buf); @@ -837,9 +835,9 @@ UnpinBuffer(volatile BufferDesc *buf, bool fixOwner, bool trashOK) UnlockBufHdr_NoHoldoff(buf); /* - * If VACUUM is releasing an otherwise-unused buffer, send it to - * the freelist for near-term reuse. We put it at the tail so that - * it won't be used before any invalid buffers that may exist. + * If VACUUM is releasing an otherwise-unused buffer, send it to the + * freelist for near-term reuse. We put it at the tail so that it + * won't be used before any invalid buffers that may exist. */ if (trash_buffer) StrategyFreeBuffer(buf, false); @@ -897,19 +895,19 @@ BgBufferSync(void) * To minimize work at checkpoint time, we want to try to keep all the * buffers clean; this motivates a scan that proceeds sequentially through * all buffers. But we are also charged with ensuring that buffers that - * will be recycled soon are clean when needed; these buffers are the - * ones just ahead of the StrategySyncStart point. We make a separate - * scan through those. + * will be recycled soon are clean when needed; these buffers are the ones + * just ahead of the StrategySyncStart point. We make a separate scan + * through those. */ /* - * This loop runs over all buffers, including pinned ones. The - * starting point advances through the buffer pool on successive calls. + * This loop runs over all buffers, including pinned ones. The starting + * point advances through the buffer pool on successive calls. * - * Note that we advance the static counter *before* trying to write. - * This ensures that, if we have a persistent write failure on a dirty - * buffer, we'll still be able to make progress writing other buffers. - * (The bgwriter will catch the error and just call us again later.) + * Note that we advance the static counter *before* trying to write. This + * ensures that, if we have a persistent write failure on a dirty buffer, + * we'll still be able to make progress writing other buffers. (The + * bgwriter will catch the error and just call us again later.) */ if (bgwriter_all_percent > 0.0 && bgwriter_all_maxpages > 0) { @@ -958,7 +956,7 @@ BgBufferSync(void) * If skip_pinned is true, we don't write currently-pinned buffers, nor * buffers marked recently used, as these are not replacement candidates. * - * Returns true if buffer was written, else false. (This could be in error + * Returns true if buffer was written, else false. (This could be in error * if FlushBuffers finds the buffer clean after locking it, but we don't * care all that much.) * @@ -972,12 +970,11 @@ SyncOneBuffer(int buf_id, bool skip_pinned) /* * Check whether buffer needs writing. * - * We can make this check without taking the buffer content lock - * so long as we mark pages dirty in access methods *before* logging - * changes with XLogInsert(): if someone marks the buffer dirty - * just after our check we don't worry because our checkpoint.redo - * points before log record for upcoming changes and so we are not - * required to write such dirty buffer. + * We can make this check without taking the buffer content lock so long as + * we mark pages dirty in access methods *before* logging changes with + * XLogInsert(): if someone marks the buffer dirty just after our check we + * don't worry because our checkpoint.redo points before log record for + * upcoming changes and so we are not required to write such dirty buffer. */ LockBufHdr(bufHdr); if (!(bufHdr->flags & BM_VALID) || !(bufHdr->flags & BM_DIRTY)) @@ -993,8 +990,8 @@ SyncOneBuffer(int buf_id, bool skip_pinned) } /* - * Pin it, share-lock it, write it. (FlushBuffer will do nothing - * if the buffer is clean by the time we've locked it.) + * Pin it, share-lock it, write it. (FlushBuffer will do nothing if the + * buffer is clean by the time we've locked it.) */ PinBuffer_Locked(bufHdr); LWLockAcquire(bufHdr->content_lock, LW_SHARED); @@ -1031,10 +1028,10 @@ ShowBufferUsage(void) localhitrate = (float) LocalBufferHitCount *100.0 / ReadLocalBufferCount; appendStringInfo(&str, - "!\tShared blocks: %10ld read, %10ld written, buffer hit rate = %.2f%%\n", - ReadBufferCount - BufferHitCount, BufferFlushCount, hitrate); + "!\tShared blocks: %10ld read, %10ld written, buffer hit rate = %.2f%%\n", + ReadBufferCount - BufferHitCount, BufferFlushCount, hitrate); appendStringInfo(&str, - "!\tLocal blocks: %10ld read, %10ld written, buffer hit rate = %.2f%%\n", + "!\tLocal blocks: %10ld read, %10ld written, buffer hit rate = %.2f%%\n", ReadLocalBufferCount - LocalBufferHitCount, LocalBufferFlushCount, localhitrate); appendStringInfo(&str, "!\tDirect blocks: %10ld read, %10ld written\n", @@ -1259,8 +1256,8 @@ FlushBuffer(volatile BufferDesc *buf, SMgrRelation reln) /* * Acquire the buffer's io_in_progress lock. If StartBufferIO returns - * false, then someone else flushed the buffer before we could, so - * we need not do anything. + * false, then someone else flushed the buffer before we could, so we need + * not do anything. */ if (!StartBufferIO(buf, false)) return; @@ -1277,16 +1274,16 @@ FlushBuffer(volatile BufferDesc *buf, SMgrRelation reln) /* * Force XLOG flush up to buffer's LSN. This implements the basic WAL - * rule that log updates must hit disk before any of the data-file - * changes they describe do. + * rule that log updates must hit disk before any of the data-file changes + * they describe do. */ recptr = BufferGetLSN(buf); XLogFlush(recptr); /* * Now it's safe to write buffer to disk. Note that no one else should - * have been able to write it while we were busy with log flushing - * because we have the io_in_progress lock. + * have been able to write it while we were busy with log flushing because + * we have the io_in_progress lock. */ /* To check if block content changes while flushing. - vadim 01/17/97 */ @@ -1302,8 +1299,8 @@ FlushBuffer(volatile BufferDesc *buf, SMgrRelation reln) BufferFlushCount++; /* - * Mark the buffer as clean (unless BM_JUST_DIRTIED has become set) - * and end the io_in_progress state. + * Mark the buffer as clean (unless BM_JUST_DIRTIED has become set) and + * end the io_in_progress state. */ TerminateBufferIO(buf, true, 0); @@ -1351,7 +1348,7 @@ RelationTruncate(Relation rel, BlockNumber nblocks) * specified relation that have block numbers >= firstDelBlock. * (In particular, with firstDelBlock = 0, all pages are removed.) * Dirty pages are simply dropped, without bothering to write them - * out first. Therefore, this is NOT rollback-able, and so should be + * out first. Therefore, this is NOT rollback-able, and so should be * used only with extreme caution! * * Currently, this is called only from smgr.c when the underlying file @@ -1360,7 +1357,7 @@ RelationTruncate(Relation rel, BlockNumber nblocks) * be deleted momentarily anyway, and there is no point in writing it. * It is the responsibility of higher-level code to ensure that the * deletion or truncation does not lose any data that could be needed - * later. It is also the responsibility of higher-level code to ensure + * later. It is also the responsibility of higher-level code to ensure * that no other process could be trying to load more pages of the * relation into buffers. * @@ -1406,7 +1403,7 @@ DropRelFileNodeBuffers(RelFileNode rnode, bool istemp, LockBufHdr(bufHdr); if (RelFileNodeEquals(bufHdr->tag.rnode, rnode) && bufHdr->tag.blockNum >= firstDelBlock) - InvalidateBuffer(bufHdr); /* releases spinlock */ + InvalidateBuffer(bufHdr); /* releases spinlock */ else UnlockBufHdr(bufHdr); } @@ -1439,7 +1436,7 @@ DropBuffers(Oid dbid) bufHdr = &BufferDescriptors[i]; LockBufHdr(bufHdr); if (bufHdr->tag.rnode.dbNode == dbid) - InvalidateBuffer(bufHdr); /* releases spinlock */ + InvalidateBuffer(bufHdr); /* releases spinlock */ else UnlockBufHdr(bufHdr); } @@ -1703,9 +1700,8 @@ UnlockBuffers(void) LockBufHdr_NoHoldoff(buf); /* - * Don't complain if flag bit not set; it could have been - * reset but we got a cancel/die interrupt before getting the - * signal. + * Don't complain if flag bit not set; it could have been reset but we + * got a cancel/die interrupt before getting the signal. */ if ((buf->flags & BM_PIN_COUNT_WAITER) != 0 && buf->wait_backend_pid == MyProcPid) @@ -1744,10 +1740,10 @@ LockBuffer(Buffer buffer, int mode) LWLockAcquire(buf->content_lock, LW_EXCLUSIVE); /* - * This is not the best place to mark buffer dirty (eg indices do - * not always change buffer they lock in excl mode). But please - * remember that it's critical to set dirty bit *before* logging - * changes with XLogInsert() - see comments in SyncOneBuffer(). + * This is not the best place to mark buffer dirty (eg indices do not + * always change buffer they lock in excl mode). But please remember + * that it's critical to set dirty bit *before* logging changes with + * XLogInsert() - see comments in SyncOneBuffer(). */ LockBufHdr_NoHoldoff(buf); buf->flags |= (BM_DIRTY | BM_JUST_DIRTIED); @@ -1776,10 +1772,10 @@ ConditionalLockBuffer(Buffer buffer) if (LWLockConditionalAcquire(buf->content_lock, LW_EXCLUSIVE)) { /* - * This is not the best place to mark buffer dirty (eg indices do - * not always change buffer they lock in excl mode). But please - * remember that it's critical to set dirty bit *before* logging - * changes with XLogInsert() - see comments in SyncOneBuffer(). + * This is not the best place to mark buffer dirty (eg indices do not + * always change buffer they lock in excl mode). But please remember + * that it's critical to set dirty bit *before* logging changes with + * XLogInsert() - see comments in SyncOneBuffer(). */ LockBufHdr_NoHoldoff(buf); buf->flags |= (BM_DIRTY | BM_JUST_DIRTIED); @@ -1880,18 +1876,17 @@ WaitIO(volatile BufferDesc *buf) /* * Changed to wait until there's no IO - Inoue 01/13/2000 * - * Note this is *necessary* because an error abort in the process doing - * I/O could release the io_in_progress_lock prematurely. See - * AbortBufferIO. + * Note this is *necessary* because an error abort in the process doing I/O + * could release the io_in_progress_lock prematurely. See AbortBufferIO. */ for (;;) { BufFlags sv_flags; /* - * It may not be necessary to acquire the spinlock to check the - * flag here, but since this test is essential for correctness, - * we'd better play it safe. + * It may not be necessary to acquire the spinlock to check the flag + * here, but since this test is essential for correctness, we'd better + * play it safe. */ LockBufHdr(buf); sv_flags = buf->flags; @@ -2027,11 +2022,10 @@ AbortBufferIO(void) if (buf) { /* - * Since LWLockReleaseAll has already been called, we're not - * holding the buffer's io_in_progress_lock. We have to re-acquire - * it so that we can use TerminateBufferIO. Anyone who's executing - * WaitIO on the buffer will be in a busy spin until we succeed in - * doing this. + * Since LWLockReleaseAll has already been called, we're not holding + * the buffer's io_in_progress_lock. We have to re-acquire it so that + * we can use TerminateBufferIO. Anyone who's executing WaitIO on the + * buffer will be in a busy spin until we succeed in doing this. */ LWLockAcquire(buf->io_in_progress_lock, LW_EXCLUSIVE); diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 4739512ad3..e204b0d009 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/buffer/freelist.c,v 1.53 2005/10/12 16:45:13 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/storage/buffer/freelist.c,v 1.54 2005/10/15 02:49:25 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -28,11 +28,11 @@ typedef struct int nextVictimBuffer; int firstFreeBuffer; /* Head of list of unused buffers */ - int lastFreeBuffer; /* Tail of list of unused buffers */ + int lastFreeBuffer; /* Tail of list of unused buffers */ /* - * NOTE: lastFreeBuffer is undefined when firstFreeBuffer is -1 - * (that is, when the list is empty) + * NOTE: lastFreeBuffer is undefined when firstFreeBuffer is -1 (that is, + * when the list is empty) */ } BufferStrategyControl; @@ -79,10 +79,10 @@ StrategyGetBuffer(void) buf->freeNext = FREENEXT_NOT_IN_LIST; /* - * If the buffer is pinned or has a nonzero usage_count, - * we cannot use it; discard it and retry. (This can only happen - * if VACUUM put a valid buffer in the freelist and then someone - * else used it before we got to it.) + * If the buffer is pinned or has a nonzero usage_count, we cannot use + * it; discard it and retry. (This can only happen if VACUUM put a + * valid buffer in the freelist and then someone else used it before + * we got to it.) */ LockBufHdr(buf); if (buf->refcount == 0 && buf->usage_count == 0) @@ -100,8 +100,8 @@ StrategyGetBuffer(void) StrategyControl->nextVictimBuffer = 0; /* - * If the buffer is pinned or has a nonzero usage_count, - * we cannot use it; decrement the usage_count and keep scanning. + * If the buffer is pinned or has a nonzero usage_count, we cannot use + * it; decrement the usage_count and keep scanning. */ LockBufHdr(buf); if (buf->refcount == 0 && buf->usage_count == 0) @@ -114,11 +114,11 @@ StrategyGetBuffer(void) else if (--trycounter == 0) { /* - * We've scanned all the buffers without making any state - * changes, so all the buffers are pinned (or were when we - * looked at them). We could hope that someone will free - * one eventually, but it's probably better to fail than to - * risk getting stuck in an infinite loop. + * We've scanned all the buffers without making any state changes, + * so all the buffers are pinned (or were when we looked at them). + * We could hope that someone will free one eventually, but it's + * probably better to fail than to risk getting stuck in an + * infinite loop. */ UnlockBufHdr(buf); elog(ERROR, "no unpinned buffers available"); @@ -143,8 +143,8 @@ StrategyFreeBuffer(volatile BufferDesc *buf, bool at_head) LWLockAcquire(BufFreelistLock, LW_EXCLUSIVE); /* - * It is possible that we are told to put something in the freelist - * that is already in it; don't screw up the list if so. + * It is possible that we are told to put something in the freelist that + * is already in it; don't screw up the list if so. */ if (buf->freeNext == FREENEXT_NOT_IN_LIST) { @@ -181,8 +181,8 @@ StrategySyncStart(void) int result; /* - * We could probably dispense with the locking here, but just to be - * safe ... + * We could probably dispense with the locking here, but just to be safe + * ... */ LWLockAcquire(BufFreelistLock, LW_EXCLUSIVE); result = StrategyControl->nextVictimBuffer; diff --git a/src/backend/storage/buffer/localbuf.c b/src/backend/storage/buffer/localbuf.c index 6dce508656..ca80255e15 100644 --- a/src/backend/storage/buffer/localbuf.c +++ b/src/backend/storage/buffer/localbuf.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/buffer/localbuf.c,v 1.69 2005/08/20 23:26:17 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/storage/buffer/localbuf.c,v 1.70 2005/10/15 02:49:25 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -33,7 +33,7 @@ typedef struct } LocalBufferLookupEnt; /* Note: this macro only works on local buffers, not shared ones! */ -#define LocalBufHdrGetBlock(bufHdr) \ +#define LocalBufHdrGetBlock(bufHdr) \ LocalBufferBlockPointers[-((bufHdr)->buf_id + 2)] int NLocBuffer = 0; /* until buffers are initialized */ @@ -107,8 +107,8 @@ LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool *foundPtr) #endif /* - * Need to get a new buffer. We use a clock sweep algorithm - * (essentially the same as what freelist.c does now...) + * Need to get a new buffer. We use a clock sweep algorithm (essentially + * the same as what freelist.c does now...) */ trycounter = NLocBuffer; for (;;) @@ -140,8 +140,8 @@ LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool *foundPtr) } /* - * this buffer is not referenced but it might still be dirty. if - * that's the case, write it out before reusing it! + * this buffer is not referenced but it might still be dirty. if that's + * the case, write it out before reusing it! */ if (bufHdr->flags & BM_DIRTY) { @@ -183,7 +183,7 @@ LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool *foundPtr) hresult = (LocalBufferLookupEnt *) hash_search(LocalBufHash, (void *) &bufHdr->tag, HASH_REMOVE, NULL); - if (!hresult) /* shouldn't happen */ + if (!hresult) /* shouldn't happen */ elog(ERROR, "local buffer hash table corrupted"); /* mark buffer invalid just in case hash insert fails */ CLEAR_BUFFERTAG(bufHdr->tag); @@ -192,7 +192,7 @@ LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool *foundPtr) hresult = (LocalBufferLookupEnt *) hash_search(LocalBufHash, (void *) &newTag, HASH_ENTER, &found); - if (found) /* shouldn't happen */ + if (found) /* shouldn't happen */ elog(ERROR, "local buffer hash table corrupted"); hresult->id = b; @@ -271,10 +271,10 @@ InitLocalBuffers(void) BufferDesc *buf = &LocalBufferDescriptors[i]; /* - * negative to indicate local buffer. This is tricky: shared - * buffers start with 0. We have to start with -2. (Note that the - * routine BufferDescriptorGetBuffer adds 1 to buf_id so our first - * buffer id is -1.) + * negative to indicate local buffer. This is tricky: shared buffers + * start with 0. We have to start with -2. (Note that the routine + * BufferDescriptorGetBuffer adds 1 to buf_id so our first buffer id + * is -1.) */ buf->buf_id = -i - 2; } diff --git a/src/backend/storage/file/buffile.c b/src/backend/storage/file/buffile.c index 29a01f02c9..95f2885c61 100644 --- a/src/backend/storage/file/buffile.c +++ b/src/backend/storage/file/buffile.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/file/buffile.c,v 1.21 2004/12/31 22:00:51 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/storage/file/buffile.c,v 1.22 2005/10/15 02:49:25 momjian Exp $ * * NOTES: * @@ -59,8 +59,8 @@ struct BufFile long *offsets; /* palloc'd array with numFiles entries */ /* - * offsets[i] is the current seek position of files[i]. We use this - * to avoid making redundant FileSeek calls. + * offsets[i] is the current seek position of files[i]. We use this to + * avoid making redundant FileSeek calls. */ bool isTemp; /* can only add files if this is TRUE */ @@ -68,9 +68,8 @@ struct BufFile bool dirty; /* does buffer need to be written? */ /* - * "current pos" is position of start of buffer within the logical - * file. Position as seen by user of BufFile is (curFile, curOffset + - * pos). + * "current pos" is position of start of buffer within the logical file. + * Position as seen by user of BufFile is (curFile, curOffset + pos). */ int curFile; /* file index (0..n) part of current pos */ int curOffset; /* offset part of current pos */ @@ -125,7 +124,7 @@ extendBufFile(BufFile *file) file->files = (File *) repalloc(file->files, (file->numFiles + 1) * sizeof(File)); file->offsets = (long *) repalloc(file->offsets, - (file->numFiles + 1) * sizeof(long)); + (file->numFiles + 1) * sizeof(long)); file->files[file->numFiles] = pfile; file->offsets[file->numFiles] = 0L; file->numFiles++; @@ -270,8 +269,8 @@ BufFileDumpBuffer(BufFile *file) } /* - * Enforce per-file size limit only for temp files, else just try - * to write as much as asked... + * Enforce per-file size limit only for temp files, else just try to + * write as much as asked... */ bytestowrite = file->nbytes - wpos; if (file->isTemp) @@ -302,11 +301,10 @@ BufFileDumpBuffer(BufFile *file) file->dirty = false; /* - * At this point, curOffset has been advanced to the end of the - * buffer, ie, its original value + nbytes. We need to make it point - * to the logical file position, ie, original value + pos, in case - * that is less (as could happen due to a small backwards seek in a - * dirty buffer!) + * At this point, curOffset has been advanced to the end of the buffer, + * ie, its original value + nbytes. We need to make it point to the + * logical file position, ie, original value + pos, in case that is less + * (as could happen due to a small backwards seek in a dirty buffer!) */ file->curOffset -= (file->nbytes - file->pos); if (file->curOffset < 0) /* handle possible segment crossing */ @@ -317,8 +315,7 @@ BufFileDumpBuffer(BufFile *file) } /* - * Now we can set the buffer empty without changing the logical - * position + * Now we can set the buffer empty without changing the logical position */ file->pos = 0; file->nbytes = 0; @@ -467,8 +464,8 @@ BufFileSeek(BufFile *file, int fileno, long offset, int whence) /* * Relative seek considers only the signed offset, ignoring - * fileno. Note that large offsets (> 1 gig) risk overflow in - * this add... + * fileno. Note that large offsets (> 1 gig) risk overflow in this + * add... */ newFile = file->curFile; newOffset = (file->curOffset + file->pos) + offset; @@ -507,8 +504,8 @@ BufFileSeek(BufFile *file, int fileno, long offset, int whence) /* * At this point and no sooner, check for seek past last segment. The - * above flush could have created a new segment, so checking sooner - * would not work (at least not with this code). + * above flush could have created a new segment, so checking sooner would + * not work (at least not with this code). */ if (file->isTemp) { diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c index 11ca95e833..2db12ebd11 100644 --- a/src/backend/storage/file/fd.c +++ b/src/backend/storage/file/fd.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/file/fd.c,v 1.120 2005/08/08 03:11:49 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/storage/file/fd.c,v 1.121 2005/10/15 02:49:25 momjian Exp $ * * NOTES: * @@ -123,7 +123,7 @@ typedef struct vfd { signed short fd; /* current FD, or VFD_CLOSED if none */ unsigned short fdstate; /* bitflags for VFD's state */ - SubTransactionId create_subid; /* for TEMPORARY fds, creating subxact */ + SubTransactionId create_subid; /* for TEMPORARY fds, creating subxact */ File nextFree; /* link to next free VFD, if in freelist */ File lruMoreRecently; /* doubly linked recency-of-use list */ File lruLessRecently; @@ -268,7 +268,7 @@ pg_fsync_writethrough(int fd) #ifdef WIN32 return _commit(fd); #elif defined(__darwin__) - return (fcntl(fd, F_FULLFSYNC, 0) == -1) ? -1 : 0; + return (fcntl(fd, F_FULLFSYNC, 0) == -1) ? -1 : 0; #else return -1; #endif @@ -305,7 +305,7 @@ pg_fdatasync(int fd) void InitFileAccess(void) { - Assert(SizeVfdCache == 0); /* call me only once */ + Assert(SizeVfdCache == 0); /* call me only once */ /* initialize cache header entry */ VfdCache = (Vfd *) malloc(sizeof(Vfd)); @@ -330,7 +330,7 @@ InitFileAccess(void) * We stop counting if usable_fds reaches max_to_probe. Note: a small * value of max_to_probe might result in an underestimate of already_open; * we must fill in any "gaps" in the set of used FDs before the calculation - * of already_open will give the right answer. In practice, max_to_probe + * of already_open will give the right answer. In practice, max_to_probe * of a couple of dozen should be enough to ensure good results. * * We assume stdin (FD 0) is available for dup'ing @@ -382,9 +382,9 @@ count_usable_fds(int max_to_probe, int *usable_fds, int *already_open) pfree(fd); /* - * Return results. usable_fds is just the number of successful dups. - * We assume that the system limit is highestfd+1 (remember 0 is a - * legal FD number) and so already_open is highestfd+1 - usable_fds. + * Return results. usable_fds is just the number of successful dups. We + * assume that the system limit is highestfd+1 (remember 0 is a legal FD + * number) and so already_open is highestfd+1 - usable_fds. */ *usable_fds = used; *already_open = highestfd + 1 - used; @@ -466,7 +466,7 @@ tryAgain: ereport(LOG, (errcode(ERRCODE_INSUFFICIENT_RESOURCES), - errmsg("out of file descriptors: %m; release and retry"))); + errmsg("out of file descriptors: %m; release and retry"))); errno = 0; if (ReleaseLruFile()) goto tryAgain; @@ -587,9 +587,9 @@ LruInsert(File file) } /* - * The open could still fail for lack of file descriptors, eg due - * to overall system file table being full. So, be prepared to - * release another FD if necessary... + * The open could still fail for lack of file descriptors, eg due to + * overall system file table being full. So, be prepared to release + * another FD if necessary... */ vfdP->fd = BasicOpenFile(vfdP->fileName, vfdP->fileFlags, vfdP->fileMode); @@ -631,8 +631,8 @@ ReleaseLruFile(void) if (nfile > 0) { /* - * There are opened files and so there should be at least one used - * vfd in the ring. + * There are opened files and so there should be at least one used vfd + * in the ring. */ Assert(VfdCache[0].lruMoreRecently != 0); LruDelete(VfdCache[0].lruMoreRecently); @@ -649,14 +649,14 @@ AllocateVfd(void) DO_DB(elog(LOG, "AllocateVfd. Size %d", SizeVfdCache)); - Assert(SizeVfdCache > 0); /* InitFileAccess not called? */ + Assert(SizeVfdCache > 0); /* InitFileAccess not called? */ 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. + * 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; Vfd *newVfdCache; @@ -745,9 +745,8 @@ 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)) @@ -759,9 +758,8 @@ FileAccess(File file) else if (VfdCache[0].lruLessRecently != file) { /* - * We now know that the file is open and that it is not the last - * one accessed, so we need to move it to the head of the Lru - * ring. + * We now know that the file is open and that it is not the last one + * accessed, so we need to move it to the head of the Lru ring. */ Delete(file); @@ -889,8 +887,8 @@ OpenTemporaryFile(bool interXact) MyProcPid, tempFileCounter++); /* - * Open the file. Note: we don't use O_EXCL, in case there is an - * orphaned temp file that can be reused. + * Open the file. Note: we don't use O_EXCL, in case there is an orphaned + * temp file that can be reused. */ file = FileNameOpenFile(tempfilepath, O_RDWR | O_CREAT | O_TRUNC | PG_BINARY, @@ -900,12 +898,12 @@ OpenTemporaryFile(bool interXact) char *dirpath; /* - * We might need to create the pg_tempfiles subdirectory, if no - * one has yet done so. + * We might need to create the pg_tempfiles subdirectory, if no one + * has yet done so. * - * Don't check for error from mkdir; it could fail if someone else - * just did the same thing. If it doesn't work then we'll bomb - * out on the second create attempt, instead. + * Don't check for error from mkdir; it could fail if someone else just + * did the same thing. If it doesn't work then we'll bomb out on the + * second create attempt, instead. */ dirpath = make_database_relative(PG_TEMP_FILES_DIR); mkdir(dirpath, S_IRWXU); @@ -1190,9 +1188,9 @@ AllocateFile(char *name, char *mode) /* * The test against MAX_ALLOCATED_DESCS prevents us from overflowing - * allocatedFiles[]; the test against max_safe_fds prevents - * AllocateFile from hogging every one of the available FDs, which'd - * lead to infinite looping. + * allocatedFiles[]; the test against max_safe_fds prevents AllocateFile + * from hogging every one of the available FDs, which'd lead to infinite + * looping. */ if (numAllocatedDescs >= MAX_ALLOCATED_DESCS || numAllocatedDescs >= max_safe_fds - 1) @@ -1216,7 +1214,7 @@ TryAgain: ereport(LOG, (errcode(ERRCODE_INSUFFICIENT_RESOURCES), - errmsg("out of file descriptors: %m; release and retry"))); + errmsg("out of file descriptors: %m; release and retry"))); errno = 0; if (ReleaseLruFile()) goto TryAgain; @@ -1305,9 +1303,9 @@ AllocateDir(const char *dirname) /* * The test against MAX_ALLOCATED_DESCS prevents us from overflowing - * allocatedDescs[]; the test against max_safe_fds prevents - * AllocateDir from hogging every one of the available FDs, which'd - * lead to infinite looping. + * allocatedDescs[]; the test against max_safe_fds prevents AllocateDir + * from hogging every one of the available FDs, which'd lead to infinite + * looping. */ if (numAllocatedDescs >= MAX_ALLOCATED_DESCS || numAllocatedDescs >= max_safe_fds - 1) @@ -1331,7 +1329,7 @@ TryAgain: ereport(LOG, (errcode(ERRCODE_INSUFFICIENT_RESOURCES), - errmsg("out of file descriptors: %m; release and retry"))); + errmsg("out of file descriptors: %m; release and retry"))); errno = 0; if (ReleaseLruFile()) goto TryAgain; @@ -1345,7 +1343,7 @@ TryAgain: * Read a directory opened with AllocateDir, ereport'ing any error. * * This is easier to use than raw readdir() since it takes care of some - * otherwise rather tedious and error-prone manipulation of errno. Also, + * otherwise rather tedious and error-prone manipulation of errno. Also, * if you are happy with a generic error message for AllocateDir failure, * you can just do * @@ -1378,9 +1376,10 @@ ReadDir(DIR *dir, const char *dirname) return dent; #ifdef WIN32 + /* - * This fix is in mingw cvs (runtime/mingwex/dirent.c rev 1.4), but - * not in released version + * This fix is in mingw cvs (runtime/mingwex/dirent.c rev 1.4), but not in + * released version */ if (GetLastError() == ERROR_NO_MORE_FILES) errno = 0; @@ -1542,9 +1541,9 @@ CleanupTempFiles(bool isProcExit) if ((fdstate & FD_TEMPORARY) && VfdCache[i].fileName != NULL) { /* - * If we're in the process of exiting a backend process, - * close all temporary files. Otherwise, only close - * temporary files local to the current transaction. + * If we're in the process of exiting a backend process, close + * all temporary files. Otherwise, only close temporary files + * local to the current transaction. */ if (isProcExit || (fdstate & FD_XACT_TEMPORARY)) FileClose(i); @@ -1596,8 +1595,8 @@ RemovePgTempFiles(void) FreeDir(db_dir); /* - * In EXEC_BACKEND case there is a pgsql_tmp directory at the top - * level of DataDir as well. + * In EXEC_BACKEND case there is a pgsql_tmp directory at the top level of + * DataDir as well. */ #ifdef EXEC_BACKEND RemovePgTempFilesInDir(PG_TEMP_FILES_DIR); diff --git a/src/backend/storage/freespace/freespace.c b/src/backend/storage/freespace/freespace.c index 11fc45ea8e..1bc1d60d4a 100644 --- a/src/backend/storage/freespace/freespace.c +++ b/src/backend/storage/freespace/freespace.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/freespace/freespace.c,v 1.48 2005/08/20 23:26:20 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/storage/freespace/freespace.c,v 1.49 2005/10/15 02:49:25 momjian Exp $ * * * NOTES: @@ -222,7 +222,7 @@ static HTAB *FreeSpaceMapRelHash; /* points to (what used to be) static void CheckFreeSpaceMapStatistics(int elevel, int numRels, - double needed); + double needed); static FSMRelation *lookup_fsm_rel(RelFileNode *rel); static FSMRelation *create_fsm_rel(RelFileNode *rel); static void delete_fsm_rel(FSMRelation *fsmrel); @@ -295,7 +295,7 @@ InitFreeSpaceMap(void) if (!FreeSpaceMapRelHash) ereport(FATAL, (errcode(ERRCODE_OUT_OF_MEMORY), - errmsg("insufficient shared memory for free space map"))); + errmsg("insufficient shared memory for free space map"))); if (found) return; @@ -307,14 +307,14 @@ InitFreeSpaceMap(void) if (nchunks <= MaxFSMRelations) ereport(FATAL, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("max_fsm_pages must exceed max_fsm_relations * %d", - CHUNKPAGES))); + errmsg("max_fsm_pages must exceed max_fsm_relations * %d", + CHUNKPAGES))); FreeSpaceMap->arena = (char *) ShmemAlloc((Size) nchunks * CHUNKBYTES); if (FreeSpaceMap->arena == NULL) ereport(FATAL, (errcode(ERRCODE_OUT_OF_MEMORY), - errmsg("insufficient shared memory for free space map"))); + errmsg("insufficient shared memory for free space map"))); FreeSpaceMap->totalChunks = nchunks; FreeSpaceMap->usedChunks = 0; @@ -371,10 +371,10 @@ GetPageWithFreeSpace(RelFileNode *rel, Size spaceNeeded) fsmrel = create_fsm_rel(rel); /* - * Update the moving average of space requests. This code implements - * an exponential moving average with an equivalent period of about 63 - * requests. Ignore silly requests, however, to ensure that the - * average stays sane. + * Update the moving average of space requests. This code implements an + * exponential moving average with an equivalent period of about 63 + * requests. Ignore silly requests, however, to ensure that the average + * stays sane. */ if (spaceNeeded > 0 && spaceNeeded < BLCKSZ) { @@ -478,10 +478,10 @@ RecordRelationFreeSpace(RelFileNode *rel, LWLockAcquire(FreeSpaceLock, LW_EXCLUSIVE); /* - * Note we don't record info about a relation unless there's already - * an FSM entry for it, implying someone has done GetPageWithFreeSpace - * for it. Inactive rels thus will not clutter the map simply by - * being vacuumed. + * Note we don't record info about a relation unless there's already an + * FSM entry for it, implying someone has done GetPageWithFreeSpace for + * it. Inactive rels thus will not clutter the map simply by being + * vacuumed. */ fsmrel = lookup_fsm_rel(rel); if (fsmrel) @@ -494,8 +494,8 @@ RecordRelationFreeSpace(RelFileNode *rel, curAllocPages = curAlloc * CHUNKPAGES; /* - * If the data fits in our current allocation, just copy it; - * otherwise must compress. + * If the data fits in our current allocation, just copy it; otherwise + * must compress. */ newLocation = (FSMPageData *) (FreeSpaceMap->arena + fsmrel->firstChunk * CHUNKBYTES); @@ -567,10 +567,9 @@ RecordIndexFreeSpace(RelFileNode *rel, LWLockAcquire(FreeSpaceLock, LW_EXCLUSIVE); /* - * Note we don't record info about a relation unless there's already - * an FSM entry for it, implying someone has done GetFreeIndexPage for - * it. Inactive rels thus will not clutter the map simply by being - * vacuumed. + * Note we don't record info about a relation unless there's already an + * FSM entry for it, implying someone has done GetFreeIndexPage for it. + * Inactive rels thus will not clutter the map simply by being vacuumed. */ fsmrel = lookup_fsm_rel(rel); if (fsmrel) @@ -584,9 +583,9 @@ RecordIndexFreeSpace(RelFileNode *rel, curAllocPages = curAlloc * INDEXCHUNKPAGES; /* - * If the data fits in our current allocation, just copy it; - * otherwise must compress. But compression is easy: we merely - * forget extra pages. + * If the data fits in our current allocation, just copy it; otherwise + * must compress. But compression is easy: we merely forget extra + * pages. */ newLocation = (IndexFSMPageData *) (FreeSpaceMap->arena + fsmrel->firstChunk * CHUNKBYTES); @@ -708,34 +707,34 @@ PrintFreeSpaceMapStatistics(int elevel) ereport(elevel, (errmsg("free space map contains %d pages in %d relations", storedPages, numRels), - errdetail("A total of %.0f page slots are in use (including overhead).\n" - "%.0f page slots are required to track all free space.\n" - "Current limits are: %d page slots, %d relations, using %.0f KB.", - Min(needed, MaxFSMPages), - needed, MaxFSMPages, MaxFSMRelations, - (double) FreeSpaceShmemSize() / 1024.0))); + errdetail("A total of %.0f page slots are in use (including overhead).\n" + "%.0f page slots are required to track all free space.\n" + "Current limits are: %d page slots, %d relations, using %.0f KB.", + Min(needed, MaxFSMPages), + needed, MaxFSMPages, MaxFSMRelations, + (double) FreeSpaceShmemSize() / 1024.0))); CheckFreeSpaceMapStatistics(NOTICE, numRels, needed); /* Print to server logs too because is deals with a config variable. */ CheckFreeSpaceMapStatistics(LOG, numRels, needed); } - + static void CheckFreeSpaceMapStatistics(int elevel, int numRels, double needed) { - if (numRels == MaxFSMRelations) + if (numRels == MaxFSMRelations) ereport(elevel, - (errmsg("max_fsm_relations(%d) equals the number of relations checked", - MaxFSMRelations), - errhint("You have >= %d relations.\n" - "Consider increasing the configuration parameter \"max_fsm_relations\".", - numRels))); + (errmsg("max_fsm_relations(%d) equals the number of relations checked", + MaxFSMRelations), + errhint("You have >= %d relations.\n" + "Consider increasing the configuration parameter \"max_fsm_relations\".", + numRels))); else if (needed > MaxFSMPages) ereport(elevel, - (errmsg("the number of page slots needed (%.0f) exceeds max_fsm_pages (%d)", - needed, MaxFSMPages), - errhint("Consider increasing the configuration parameter \"max_fsm_pages\"\n" - "to a value over %.0f.", needed))); + (errmsg("the number of page slots needed (%.0f) exceeds max_fsm_pages (%d)", + needed, MaxFSMPages), + errhint("Consider increasing the configuration parameter \"max_fsm_pages\"\n" + "to a value over %.0f.", needed))); } /* @@ -753,7 +752,7 @@ DumpFreeSpaceMap(int code, Datum arg) FSMRelation *fsmrel; /* Try to create file */ - unlink(FSM_CACHE_FILENAME); /* in case it exists w/wrong permissions */ + unlink(FSM_CACHE_FILENAME); /* in case it exists w/wrong permissions */ fp = AllocateFile(FSM_CACHE_FILENAME, PG_BINARY_W); if (fp == NULL) @@ -917,11 +916,11 @@ LoadFreeSpaceMap(void) } /* - * Okay, create the FSM entry and insert data into it. Since the - * rels were stored in reverse usage order, at the end of the loop - * they will be correctly usage-ordered in memory; and if - * MaxFSMRelations is less than it used to be, we will correctly - * drop the least recently used ones. + * Okay, create the FSM entry and insert data into it. Since the rels + * were stored in reverse usage order, at the end of the loop they + * will be correctly usage-ordered in memory; and if MaxFSMRelations + * is less than it used to be, we will correctly drop the least + * recently used ones. */ fsmrel = create_fsm_rel(&relheader.key); fsmrel->avgRequest = relheader.avgRequest; @@ -936,8 +935,8 @@ LoadFreeSpaceMap(void) /* * If the data fits in our current allocation, just copy it; - * otherwise must compress. But compression is easy: we - * merely forget extra pages. + * otherwise must compress. But compression is easy: we merely + * forget extra pages. */ newLocation = (IndexFSMPageData *) (FreeSpaceMap->arena + fsmrel->firstChunk * CHUNKBYTES); @@ -1105,10 +1104,10 @@ realloc_fsm_rel(FSMRelation *fsmrel, int nPages, bool isIndex) myAlloc = fsm_calc_target_allocation(myRequest); /* - * Need to reallocate space if (a) my target allocation is more than - * my current allocation, AND (b) my actual immediate need - * (myRequest+1 chunks) is more than my current allocation. Otherwise - * just store the new data in-place. + * Need to reallocate space if (a) my target allocation is more than my + * current allocation, AND (b) my actual immediate need (myRequest+1 + * chunks) is more than my current allocation. Otherwise just store the + * new data in-place. */ curAlloc = fsm_current_allocation(fsmrel); if (myAlloc > curAlloc && (myRequest + 1) > curAlloc && nPages > 0) @@ -1241,8 +1240,7 @@ find_free_space(FSMRelation *fsmrel, Size spaceNeeded) if (spaceAvail >= spaceNeeded) { /* - * Found what we want --- adjust the entry, and update - * nextPage. + * Found what we want --- adjust the entry, and update nextPage. */ FSMPageSetSpace(page, spaceAvail - spaceNeeded); fsmrel->nextPage = pageIndex + 1; @@ -1266,10 +1264,10 @@ find_index_free_space(FSMRelation *fsmrel) BlockNumber result; /* - * If isIndex isn't set, it could be that RecordIndexFreeSpace() has - * never yet been called on this relation, and we're still looking at - * the default setting from create_fsm_rel(). If so, just act as - * though there's no space. + * If isIndex isn't set, it could be that RecordIndexFreeSpace() has never + * yet been called on this relation, and we're still looking at the + * default setting from create_fsm_rel(). If so, just act as though + * there's no space. */ if (!fsmrel->isIndex) { @@ -1279,10 +1277,10 @@ find_index_free_space(FSMRelation *fsmrel) } /* - * For indexes, there's no need for the nextPage state variable; we - * just remove and return the first available page. (We could save - * cycles here by returning the last page, but it seems better to - * encourage re-use of lower-numbered pages.) + * For indexes, there's no need for the nextPage state variable; we just + * remove and return the first available page. (We could save cycles here + * by returning the last page, but it seems better to encourage re-use of + * lower-numbered pages.) */ if (fsmrel->storedPages <= 0) return InvalidBlockNumber; /* no pages available */ @@ -1318,10 +1316,10 @@ fsm_record_free_space(FSMRelation *fsmrel, BlockNumber page, Size spaceAvail) else { /* - * No existing entry; ignore the call. We used to add the page to - * the FSM --- but in practice, if the page hasn't got enough - * space to satisfy the caller who's kicking it back to us, then - * it's probably uninteresting to everyone else as well. + * No existing entry; ignore the call. We used to add the page to the + * FSM --- but in practice, if the page hasn't got enough space to + * satisfy the caller who's kicking it back to us, then it's probably + * uninteresting to everyone else as well. */ } } @@ -1454,25 +1452,23 @@ compact_fsm_storage(void) /* * It's possible that we have to move data down, not up, if the - * allocations of previous rels expanded. This normally means - * that our allocation expanded too (or at least got no worse), - * and ditto for later rels. So there should be room to move all - * our data down without dropping any --- but we might have to - * push down following rels to acquire the room. We don't want to - * do the push more than once, so pack everything against the end - * of the arena if so. + * allocations of previous rels expanded. This normally means that + * our allocation expanded too (or at least got no worse), and ditto + * for later rels. So there should be room to move all our data down + * without dropping any --- but we might have to push down following + * rels to acquire the room. We don't want to do the push more than + * once, so pack everything against the end of the arena if so. * * In corner cases where we are on the short end of a roundoff choice * that we were formerly on the long end of, it's possible that we - * have to move down and compress our data too. In fact, even - * after pushing down the following rels, there might not be as - * much space as we computed for this rel above --- that would - * imply that some following rel(s) are also on the losing end of - * roundoff choices. We could handle this fairly by doing the - * per-rel compactions out-of-order, but that seems like way too - * much complexity to deal with a very infrequent corner case. - * Instead, we simply drop pages from the end of the current rel's - * data until it fits. + * have to move down and compress our data too. In fact, even after + * pushing down the following rels, there might not be as much space + * as we computed for this rel above --- that would imply that some + * following rel(s) are also on the losing end of roundoff choices. We + * could handle this fairly by doing the per-rel compactions + * out-of-order, but that seems like way too much complexity to deal + * with a very infrequent corner case. Instead, we simply drop pages + * from the end of the current rel's data until it fits. */ if (newChunkIndex > oldChunkIndex) { @@ -1508,12 +1504,11 @@ compact_fsm_storage(void) newAlloc = limitChunkIndex - newChunkIndex; /* - * If newAlloc < 0 at this point, we are moving the - * rel's firstChunk into territory currently assigned - * to a later rel. This is okay so long as we do not - * copy any data. The rels will be back in - * nondecreasing firstChunk order at completion of the - * compaction pass. + * If newAlloc < 0 at this point, we are moving the rel's + * firstChunk into territory currently assigned to a later + * rel. This is okay so long as we do not copy any data. + * The rels will be back in nondecreasing firstChunk order + * at completion of the compaction pass. */ if (newAlloc < 0) newAlloc = 0; @@ -1530,9 +1525,9 @@ compact_fsm_storage(void) else if (newAllocPages < fsmrel->storedPages) { /* - * Need to compress the page data. For an index, - * "compression" just means dropping excess pages; otherwise - * we try to keep the ones with the most space. + * Need to compress the page data. For an index, "compression" + * just means dropping excess pages; otherwise we try to keep the + * ones with the most space. */ if (fsmrel->isIndex) { @@ -1863,7 +1858,7 @@ DumpFreeSpace(void) relNum++; fprintf(stderr, "Map %d: rel %u/%u/%u isIndex %d avgRequest %u lastPageCount %d nextPage %d\nMap= ", relNum, - fsmrel->key.spcNode, fsmrel->key.dbNode, fsmrel->key.relNode, + fsmrel->key.spcNode, fsmrel->key.dbNode, fsmrel->key.relNode, (int) fsmrel->isIndex, fsmrel->avgRequest, fsmrel->lastPageCount, fsmrel->nextPage); if (fsmrel->isIndex) diff --git a/src/backend/storage/ipc/ipc.c b/src/backend/storage/ipc/ipc.c index 2976bf654d..39e8d3e527 100644 --- a/src/backend/storage/ipc/ipc.c +++ b/src/backend/storage/ipc/ipc.c @@ -13,7 +13,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/ipc/ipc.c,v 1.90 2004/12/31 22:00:56 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/storage/ipc/ipc.c,v 1.91 2005/10/15 02:49:25 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -74,8 +74,8 @@ void proc_exit(int code) { /* - * Once we set this flag, we are committed to exit. Any ereport() - * will NOT send control back to the main loop, but right back here. + * Once we set this flag, we are committed to exit. Any ereport() will + * NOT send control back to the main loop, but right back here. */ proc_exit_inprogress = true; @@ -100,15 +100,14 @@ proc_exit(int code) /* * call all the callbacks registered before calling exit(). * - * Note that since we decrement on_proc_exit_index each time, if a - * callback calls ereport(ERROR) or ereport(FATAL) then it won't be - * invoked again when control comes back here (nor will the - * previously-completed callbacks). So, an infinite loop should not - * be possible. + * Note that since we decrement on_proc_exit_index each time, if a callback + * calls ereport(ERROR) or ereport(FATAL) then it won't be invoked again + * when control comes back here (nor will the previously-completed + * callbacks). So, an infinite loop should not be possible. */ while (--on_proc_exit_index >= 0) (*on_proc_exit_list[on_proc_exit_index].function) (code, - on_proc_exit_list[on_proc_exit_index].arg); + on_proc_exit_list[on_proc_exit_index].arg); elog(DEBUG3, "exit(%d)", code); exit(code); @@ -128,12 +127,12 @@ shmem_exit(int code) /* * call all the registered callbacks. * - * As with proc_exit(), we remove each callback from the list before - * calling it, to avoid infinite loop in case of error. + * As with proc_exit(), we remove each callback from the list before calling + * it, to avoid infinite loop in case of error. */ while (--on_shmem_exit_index >= 0) (*on_shmem_exit_list[on_shmem_exit_index].function) (code, - on_shmem_exit_list[on_shmem_exit_index].arg); + on_shmem_exit_list[on_shmem_exit_index].arg); on_shmem_exit_index = 0; } diff --git a/src/backend/storage/ipc/ipci.c b/src/backend/storage/ipc/ipci.c index 48ef94a3ec..997c38a45c 100644 --- a/src/backend/storage/ipc/ipci.c +++ b/src/backend/storage/ipc/ipci.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/ipc/ipci.c,v 1.78 2005/08/20 23:26:20 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/storage/ipc/ipci.c,v 1.79 2005/10/15 02:49:25 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -66,13 +66,12 @@ CreateSharedMemoryAndSemaphores(bool makePrivate, int port) /* * Size of the Postgres 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. * - * We take some care during this phase to ensure that the total - * size request doesn't overflow size_t. If this gets through, - * we don't need to be so careful during the actual allocation - * phase. + * We take some care during this phase to ensure that the total size + * request doesn't overflow size_t. If this gets through, we don't + * need to be so careful during the actual allocation phase. */ size = 100000; size = add_size(size, hash_estimate_size(SHMEM_INDEX_SIZE, @@ -115,9 +114,9 @@ CreateSharedMemoryAndSemaphores(bool makePrivate, int port) else { /* - * We are reattaching to an existing shared memory segment. - * This should only be reached in the EXEC_BACKEND case, and - * even then only with makePrivate == false. + * We are reattaching to an existing shared memory segment. This + * should only be reached in the EXEC_BACKEND case, and even then only + * with makePrivate == false. */ #ifdef EXEC_BACKEND Assert(!makePrivate); diff --git a/src/backend/storage/ipc/pmsignal.c b/src/backend/storage/ipc/pmsignal.c index a916688717..98a742f24f 100644 --- a/src/backend/storage/ipc/pmsignal.c +++ b/src/backend/storage/ipc/pmsignal.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/ipc/pmsignal.c,v 1.19 2005/08/20 23:26:20 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/storage/ipc/pmsignal.c,v 1.20 2005/10/15 02:49:25 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -112,9 +112,9 @@ PostmasterIsAlive(bool amDirectChild) { /* * Use kill() to see if the postmaster is still alive. This can - * sometimes give a false positive result, since the postmaster's - * PID may get recycled, but it is good enough for existing uses - * by indirect children. + * sometimes give a false positive result, since the postmaster's PID + * may get recycled, but it is good enough for existing uses by + * indirect children. */ return (kill(PostmasterPid, 0) == 0); } diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c index f2950bece3..1387ec6bd9 100644 --- a/src/backend/storage/ipc/procarray.c +++ b/src/backend/storage/ipc/procarray.c @@ -16,14 +16,14 @@ * prepared transactions. The xid and subxids fields of these are valid, * as is the procLocks list. They can be distinguished from regular backend * PGPROCs at need by checking for pid == 0. - * + * * * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/ipc/procarray.c,v 1.6 2005/08/20 23:26:20 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/storage/ipc/procarray.c,v 1.7 2005/10/15 02:49:25 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -44,8 +44,8 @@ typedef struct ProcArrayStruct int maxProcs; /* allocated size of procs array */ /* - * We declare procs[] as 1 entry because C wants a fixed-size array, - * but actually it is maxProcs entries long. + * We declare procs[] as 1 entry because C wants a fixed-size array, but + * actually it is maxProcs entries long. */ PGPROC *procs[1]; /* VARIABLE LENGTH ARRAY */ } ProcArrayStruct; @@ -67,14 +67,12 @@ static long xc_slow_answer = 0; #define xc_slow_answer_inc() (xc_slow_answer++) static void DisplayXidCache(void); - #else /* !XIDCACHE_DEBUG */ #define xc_by_recent_xmin_inc() ((void) 0) #define xc_by_main_xid_inc() ((void) 0) #define xc_by_child_xid_inc() ((void) 0) #define xc_slow_answer_inc() ((void) 0) - #endif /* XIDCACHE_DEBUG */ @@ -88,7 +86,7 @@ ProcArrayShmemSize(void) size = offsetof(ProcArrayStruct, procs); size = add_size(size, mul_size(sizeof(PGPROC *), - add_size(MaxBackends, max_prepared_xacts))); + add_size(MaxBackends, max_prepared_xacts))); return size; } @@ -128,9 +126,9 @@ ProcArrayAdd(PGPROC *proc) if (arrayP->numProcs >= arrayP->maxProcs) { /* - * Ooops, no room. (This really shouldn't happen, since there is - * a fixed supply of PGPROC structs too, and so we should have - * failed earlier.) + * Ooops, no room. (This really shouldn't happen, since there is a + * fixed supply of PGPROC structs too, and so we should have failed + * earlier.) */ LWLockRelease(ProcArrayLock); ereport(FATAL, @@ -213,8 +211,8 @@ TransactionIdIsInProgress(TransactionId xid) bool locked; /* - * Don't bother checking a transaction older than RecentXmin; it - * could not possibly still be running. + * Don't bother checking a transaction older than RecentXmin; it could not + * possibly still be running. */ if (TransactionIdPrecedes(xid, RecentXmin)) { @@ -249,8 +247,8 @@ TransactionIdIsInProgress(TransactionId xid) } /* - * We can ignore main Xids that are younger than the target - * Xid, since the target could not possibly be their child. + * We can ignore main Xids that are younger than the target Xid, since + * the target could not possibly be their child. */ if (TransactionIdPrecedes(xid, pxid)) continue; @@ -272,11 +270,11 @@ TransactionIdIsInProgress(TransactionId xid) } /* - * Save the main Xid for step 3. We only need to remember - * main Xids that have uncached children. (Note: there is no - * race condition here because the overflowed flag cannot be - * cleared, only set, while we hold ProcArrayLock. So we can't - * miss an Xid that we need to worry about.) + * Save the main Xid for step 3. We only need to remember main Xids + * that have uncached children. (Note: there is no race condition + * here because the overflowed flag cannot be cleared, only set, while + * we hold ProcArrayLock. So we can't miss an Xid that we need to + * worry about.) */ if (proc->subxids.overflowed) xids[nxids++] = pxid; @@ -295,11 +293,10 @@ TransactionIdIsInProgress(TransactionId xid) /* * Step 3: have to check pg_subtrans. * - * At this point, we know it's either a subtransaction of one of the Xids - * in xids[], or it's not running. If it's an already-failed - * subtransaction, we want to say "not running" even though its parent - * may still be running. So first, check pg_clog to see if it's been - * aborted. + * At this point, we know it's either a subtransaction of one of the Xids in + * xids[], or it's not running. If it's an already-failed subtransaction, + * we want to say "not running" even though its parent may still be + * running. So first, check pg_clog to see if it's been aborted. */ xc_slow_answer_inc(); @@ -307,10 +304,9 @@ TransactionIdIsInProgress(TransactionId xid) goto result_known; /* - * It isn't aborted, so check whether the transaction tree it belongs - * to is still running (or, more precisely, whether it was running - * when this routine started -- note that we already released - * ProcArrayLock). + * It isn't aborted, so check whether the transaction tree it belongs to + * is still running (or, more precisely, whether it was running when this + * routine started -- note that we already released ProcArrayLock). */ topxid = SubTransGetTopmostTransaction(xid); Assert(TransactionIdIsValid(topxid)); @@ -350,8 +346,8 @@ TransactionIdIsActive(TransactionId xid) int i; /* - * Don't bother checking a transaction older than RecentXmin; it - * could not possibly still be running. + * Don't bother checking a transaction older than RecentXmin; it could not + * possibly still be running. */ if (TransactionIdPrecedes(xid, RecentXmin)) return false; @@ -413,9 +409,9 @@ GetOldestXmin(bool allDbs) /* * Normally we start the min() calculation with our own XID. But if * called by checkpointer, we will not be inside a transaction, so use - * next XID as starting point for min() calculation. (Note that if - * there are no xacts running at all, that will be the subtrans - * truncation point!) + * next XID as starting point for min() calculation. (Note that if there + * are no xacts running at all, that will be the subtrans truncation + * point!) */ if (IsTransactionState()) result = GetTopTransactionId(); @@ -463,7 +459,7 @@ GetOldestXmin(bool allDbs) * This ensures that the set of transactions seen as "running" by the * current xact will not change after it takes the snapshot. * - * Note that only top-level XIDs are included in the snapshot. We can + * Note that only top-level XIDs are included in the snapshot. We can * still apply the xmin and xmax limits to subtransaction XIDs, but we * need to work a bit harder to see if XIDs in [xmin..xmax) are running. * @@ -474,7 +470,7 @@ GetOldestXmin(bool allDbs) * RecentXmin: the xmin computed for the most recent snapshot. XIDs * older than this are known not running any more. * RecentGlobalXmin: the global xmin (oldest TransactionXmin across all - * running transactions). This is the same computation done by + * running transactions). This is the same computation done by * GetOldestXmin(TRUE). *---------- */ @@ -496,14 +492,14 @@ GetSnapshotData(Snapshot snapshot, bool serializable) TransactionIdIsValid(MyProc->xmin)); /* - * Allocating space for maxProcs xids is usually overkill; - * numProcs would be sufficient. But it seems better to do the - * malloc while not holding the lock, so we can't look at numProcs. + * Allocating space for maxProcs xids is usually overkill; numProcs would + * be sufficient. But it seems better to do the malloc while not holding + * the lock, so we can't look at numProcs. * * This does open a possibility for avoiding repeated malloc/free: since - * maxProcs does not change at runtime, we can simply reuse the - * previous xip array if any. (This relies on the fact that all - * callers pass static SnapshotData structs.) + * maxProcs does not change at runtime, we can simply reuse the previous + * xip array if any. (This relies on the fact that all callers pass + * static SnapshotData structs.) */ if (snapshot->xip == NULL) { @@ -563,13 +559,12 @@ GetSnapshotData(Snapshot snapshot, bool serializable) TransactionId xid = proc->xid; /* - * Ignore my own proc (dealt with my xid above), procs not - * running a transaction, and xacts started since we read the - * next transaction ID. There's no need to store XIDs above - * what we got from ReadNewTransactionId, since we'll treat - * them as running anyway. We also assume that such xacts - * can't compute an xmin older than ours, so they needn't be - * considered in computing globalxmin. + * Ignore my own proc (dealt with my xid above), procs not running a + * transaction, and xacts started since we read the next transaction + * ID. There's no need to store XIDs above what we got from + * ReadNewTransactionId, since we'll treat them as running anyway. We + * also assume that such xacts can't compute an xmin older than ours, + * so they needn't be considered in computing globalxmin. */ if (proc == MyProc || !TransactionIdIsNormal(xid) || @@ -594,9 +589,9 @@ GetSnapshotData(Snapshot snapshot, bool serializable) LWLockRelease(ProcArrayLock); /* - * Update globalxmin to include actual process xids. This is a - * slightly different way of computing it than GetOldestXmin uses, but - * should give the same result. + * Update globalxmin to include actual process xids. This is a slightly + * different way of computing it than GetOldestXmin uses, but should give + * the same result. */ if (TransactionIdPrecedes(xmin, globalxmin)) globalxmin = xmin; @@ -696,14 +691,14 @@ BackendPidGetProc(int pid) * Returns 0 if not found or it's a prepared transaction. Note that * it is up to the caller to be sure that the question remains * meaningful for long enough for the answer to be used ... - * + * * Only main transaction Ids are considered. This function is mainly * useful for determining what backend owns a lock. */ int BackendXidGetPid(TransactionId xid) { - int result = 0; + int result = 0; ProcArrayStruct *arrayP = procArray; int index; @@ -754,9 +749,8 @@ CountActiveBackends(void) /* * Note: for speed, we don't acquire ProcArrayLock. This is a little bit - * bogus, but since we are only testing fields for zero or nonzero, - * it should be OK. The result is only used for heuristic purposes - * anyway... + * bogus, but since we are only testing fields for zero or nonzero, it + * should be OK. The result is only used for heuristic purposes anyway... */ for (index = 0; index < arrayP->numProcs; index++) { @@ -854,17 +848,16 @@ XidCacheRemoveRunningXids(TransactionId xid, int nxids, TransactionId *xids) /* * We must hold ProcArrayLock exclusively in order to remove transactions - * from the PGPROC array. (See notes in GetSnapshotData.) It's - * possible this could be relaxed since we know this routine is only - * used to abort subtransactions, but pending closer analysis we'd - * best be conservative. + * from the PGPROC array. (See notes in GetSnapshotData.) It's possible + * this could be relaxed since we know this routine is only used to abort + * subtransactions, but pending closer analysis we'd best be conservative. */ LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE); /* - * Under normal circumstances xid and xids[] will be in increasing - * order, as will be the entries in subxids. Scan backwards to avoid - * O(N^2) behavior when removing a lot of xids. + * Under normal circumstances xid and xids[] will be in increasing order, + * as will be the entries in subxids. Scan backwards to avoid O(N^2) + * behavior when removing a lot of xids. */ for (i = nxids - 1; i >= 0; i--) { @@ -878,11 +871,13 @@ XidCacheRemoveRunningXids(TransactionId xid, int nxids, TransactionId *xids) break; } } + /* - * Ordinarily we should have found it, unless the cache has overflowed. - * However it's also possible for this routine to be invoked multiple - * times for the same subtransaction, in case of an error during - * AbortSubTransaction. So instead of Assert, emit a debug warning. + * Ordinarily we should have found it, unless the cache has + * overflowed. However it's also possible for this routine to be + * invoked multiple times for the same subtransaction, in case of an + * error during AbortSubTransaction. So instead of Assert, emit a + * debug warning. */ if (j < 0 && !MyProc->subxids.overflowed) elog(WARNING, "did not find subXID %u in MyProc", anxid); diff --git a/src/backend/storage/ipc/shmem.c b/src/backend/storage/ipc/shmem.c index d7498389b5..443c153c90 100644 --- a/src/backend/storage/ipc/shmem.c +++ b/src/backend/storage/ipc/shmem.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/ipc/shmem.c,v 1.86 2005/10/07 21:42:38 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/storage/ipc/shmem.c,v 1.87 2005/10/15 02:49:25 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -71,13 +71,13 @@ SHMEM_OFFSET ShmemBase; /* start address of shared memory */ static SHMEM_OFFSET ShmemEnd; /* end+1 address of shared memory */ -slock_t *ShmemLock; /* spinlock for shared memory and LWLock allocation */ +slock_t *ShmemLock; /* spinlock for shared memory and LWLock + * allocation */ NON_EXEC_STATIC slock_t *ShmemIndexLock; /* spinlock for ShmemIndex */ -NON_EXEC_STATIC void *ShmemIndexAlloc = NULL; /* Memory actually - * allocated for - * ShmemIndex */ +NON_EXEC_STATIC void *ShmemIndexAlloc = NULL; /* Memory actually allocated + * for ShmemIndex */ static HTAB *ShmemIndex = NULL; /* primary index hashtable for shmem */ @@ -205,11 +205,10 @@ InitShmemIndex(void) bool found; /* - * Since ShmemInitHash calls ShmemInitStruct, which expects the - * ShmemIndex hashtable to exist already, we have a bit of a - * circularity problem in initializing the ShmemIndex itself. The - * special "ShmemIndex" hash table name will tell ShmemInitStruct - * to fake it. + * Since ShmemInitHash calls ShmemInitStruct, which expects the ShmemIndex + * hashtable to exist already, we have a bit of a circularity problem in + * initializing the ShmemIndex itself. The special "ShmemIndex" hash + * table name will tell ShmemInitStruct to fake it. */ /* create the shared memory shmem index */ @@ -274,9 +273,9 @@ ShmemInitHash(const char *name, /* table string name for shmem index */ void *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. So, make - * sure we make it big enough to start with. + * Hash tables allocated in shared memory have a fixed directory; it can't + * grow or other backends wouldn't be able to find it. So, make sure we + * make it big enough to start with. * * The shared memory allocator must be specified too. */ @@ -286,19 +285,19 @@ ShmemInitHash(const char *name, /* table string name for shmem index */ /* look it up in the shmem index */ location = ShmemInitStruct(name, - sizeof(HASHHDR) + infoP->dsize * sizeof(HASHSEGMENT), + sizeof(HASHHDR) + infoP->dsize * sizeof(HASHSEGMENT), &found); /* - * shmem index is corrupted. Let someone else give the error - * message since they have more information + * shmem index is corrupted. Let someone else give the error message + * since they have more information */ if (location == NULL) return NULL; /* - * if it already exists, attach to it rather than allocate and - * initialize new space + * if it already exists, attach to it rather than allocate and initialize + * new space */ if (found) hash_flags |= HASH_ATTACH; @@ -348,11 +347,11 @@ ShmemInitStruct(const char *name, Size size, bool *foundPtr) else { /* - * If the shmem index doesn't exist, we are bootstrapping: we - * must be trying to init the shmem index itself. + * If the shmem index doesn't exist, we are bootstrapping: we must + * be trying to init the shmem index itself. * - * Notice that the ShmemIndexLock is held until the shmem index - * has been completely initialized. + * Notice that the ShmemIndexLock is held until the shmem index has + * been completely initialized. */ *foundPtr = FALSE; ShmemIndexAlloc = ShmemAlloc(size); @@ -375,9 +374,9 @@ ShmemInitStruct(const char *name, Size size, bool *foundPtr) if (*foundPtr) { /* - * Structure is in the shmem index so someone else has allocated - * it already. The size better be the same as the size we are - * trying to initialize to or there is a name conflict (or worse). + * Structure is in the shmem index so someone else has allocated it + * already. The size better be the same as the size we are trying to + * initialize to or there is a name conflict (or worse). */ if (result->size != size) { @@ -402,7 +401,7 @@ ShmemInitStruct(const char *name, Size size, bool *foundPtr) ereport(WARNING, (errcode(ERRCODE_OUT_OF_MEMORY), - errmsg("could not allocate shared memory segment \"%s\"", name))); + errmsg("could not allocate shared memory segment \"%s\"", name))); *foundPtr = FALSE; return NULL; } diff --git a/src/backend/storage/ipc/sinval.c b/src/backend/storage/ipc/sinval.c index 0d7b01f796..b5efb510d7 100644 --- a/src/backend/storage/ipc/sinval.c +++ b/src/backend/storage/ipc/sinval.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/ipc/sinval.c,v 1.77 2005/08/20 23:26:21 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/storage/ipc/sinval.c,v 1.78 2005/10/15 02:49:25 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -109,7 +109,7 @@ SendSharedInvalidMessage(SharedInvalidationMessage *msg) */ void ReceiveSharedInvalidMessages( - void (*invalFunction) (SharedInvalidationMessage *msg), + void (*invalFunction) (SharedInvalidationMessage *msg), void (*resetFunction) (void)) { SharedInvalidationMessage data; @@ -119,20 +119,20 @@ ReceiveSharedInvalidMessages( for (;;) { /* - * We can discard any pending catchup event, since we will not - * exit this loop until we're fully caught up. + * We can discard any pending catchup event, since we will not exit + * this loop until we're fully caught up. */ catchupInterruptOccurred = 0; /* - * We can run SIGetDataEntry in parallel with other backends - * running SIGetDataEntry for themselves, since each instance will - * modify only fields of its own backend's ProcState, and no - * instance will look at fields of other backends' ProcStates. We - * express this by grabbing SInvalLock in shared mode. Note that - * this is not exactly the normal (read-only) interpretation of a - * shared lock! Look closely at the interactions before allowing - * SInvalLock to be grabbed in shared mode for any other reason! + * We can run SIGetDataEntry in parallel with other backends running + * SIGetDataEntry for themselves, since each instance will modify only + * fields of its own backend's ProcState, and no instance will look at + * fields of other backends' ProcStates. We express this by grabbing + * SInvalLock in shared mode. Note that this is not exactly the + * normal (read-only) interpretation of a shared lock! Look closely at + * the interactions before allowing SInvalLock to be grabbed in shared + * mode for any other reason! */ LWLockAcquire(SInvalLock, LW_SHARED); getResult = SIGetDataEntry(shmInvalBuffer, MyBackendId, &data); @@ -195,19 +195,18 @@ CatchupInterruptHandler(SIGNAL_ARGS) bool save_ImmediateInterruptOK = ImmediateInterruptOK; /* - * We may be called while ImmediateInterruptOK is true; turn it - * off while messing with the catchup state. (We would have to - * save and restore it anyway, because PGSemaphore operations - * inside ProcessCatchupEvent() might reset it.) + * We may be called while ImmediateInterruptOK is true; turn it off + * while messing with the catchup state. (We would have to save and + * restore it anyway, because PGSemaphore operations inside + * ProcessCatchupEvent() might reset it.) */ ImmediateInterruptOK = false; /* * I'm not sure whether some flavors of Unix might allow another - * SIGUSR1 occurrence to recursively interrupt this routine. To - * cope with the possibility, we do the same sort of dance that - * EnableCatchupInterrupt must do --- see that routine for - * comments. + * SIGUSR1 occurrence to recursively interrupt this routine. To cope + * with the possibility, we do the same sort of dance that + * EnableCatchupInterrupt must do --- see that routine for comments. */ catchupInterruptEnabled = 0; /* disable any recursive signal */ catchupInterruptOccurred = 1; /* do at least one iteration */ @@ -225,8 +224,7 @@ CatchupInterruptHandler(SIGNAL_ARGS) } /* - * Restore ImmediateInterruptOK, and check for interrupts if - * needed. + * Restore ImmediateInterruptOK, and check for interrupts if needed. */ ImmediateInterruptOK = save_ImmediateInterruptOK; if (save_ImmediateInterruptOK) @@ -235,8 +233,7 @@ CatchupInterruptHandler(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: */ catchupInterruptOccurred = 1; } @@ -258,27 +255,25 @@ void EnableCatchupInterrupt(void) { /* - * This code is tricky because we are communicating with a signal - * handler that could interrupt us at any point. If we just checked - * catchupInterruptOccurred and then set catchupInterruptEnabled, 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 - * ProcessCatchupEvent() if another interrupt occurs.) If an interrupt - * comes in between the setting and clearing of - * catchupInterruptEnabled, then it will have done the service work - * and left catchupInterruptOccurred 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 + * This code is tricky because we are communicating with a signal handler + * that could interrupt us at any point. If we just checked + * catchupInterruptOccurred and then set catchupInterruptEnabled, 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 ProcessCatchupEvent() if + * another interrupt occurs.) If an interrupt comes in between the setting + * and clearing of catchupInterruptEnabled, then it will have done the + * service work and left catchupInterruptOccurred 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. + * NB: an overenthusiastic optimizing compiler could easily break this code. + * Hopefully, they all understand what "volatile" means these days. */ for (;;) { @@ -330,17 +325,17 @@ ProcessCatchupEvent(void) notify_enabled = DisableNotifyInterrupt(); /* - * What we need to do here is cause ReceiveSharedInvalidMessages() to - * run, which will do the necessary work and also reset the - * catchupInterruptOccurred flag. If we are inside a transaction we - * can just call AcceptInvalidationMessages() to do this. If we - * aren't, we start and immediately end a transaction; the call to + * What we need to do here is cause ReceiveSharedInvalidMessages() to run, + * which will do the necessary work and also reset the + * catchupInterruptOccurred flag. If we are inside a transaction we can + * just call AcceptInvalidationMessages() to do this. If we aren't, we + * start and immediately end a transaction; the call to * AcceptInvalidationMessages() happens down inside transaction start. * - * It is awfully tempting to just call AcceptInvalidationMessages() - * without the rest of the xact start/stop overhead, and I think that - * would actually work in the normal case; but I am not sure that - * things would clean up nicely if we got an error partway through. + * It is awfully tempting to just call AcceptInvalidationMessages() without + * the rest of the xact start/stop overhead, and I think that would + * actually work in the normal case; but I am not sure that things would + * clean up nicely if we got an error partway through. */ if (IsTransactionOrTransactionBlock()) { diff --git a/src/backend/storage/ipc/sinvaladt.c b/src/backend/storage/ipc/sinvaladt.c index 612f437322..3d11c0d29b 100644 --- a/src/backend/storage/ipc/sinvaladt.c +++ b/src/backend/storage/ipc/sinvaladt.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/ipc/sinvaladt.c,v 1.60 2005/08/20 23:26:21 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/storage/ipc/sinvaladt.c,v 1.61 2005/10/15 02:49:25 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -198,8 +198,8 @@ SIInsertDataEntry(SISeg *segP, SharedInvalidationMessage *data) { /* * Don't panic just yet: slowest backend might have consumed some - * messages but not yet have done SIDelExpiredDataEntries() to - * advance minMsgNum. So, make sure minMsgNum is up-to-date. + * messages but not yet have done SIDelExpiredDataEntries() to advance + * minMsgNum. So, make sure minMsgNum is up-to-date. */ SIDelExpiredDataEntries(segP); numMsgs = segP->maxMsgNum - segP->minMsgNum; @@ -213,9 +213,9 @@ SIInsertDataEntry(SISeg *segP, SharedInvalidationMessage *data) /* * Try to prevent table overflow. When the table is 70% full send a - * WAKEN_CHILDREN request to the postmaster. The postmaster will send - * a SIGUSR1 signal to all the backends, which will cause sinval.c to - * read any pending SI entries. + * WAKEN_CHILDREN request to the postmaster. The postmaster will send a + * SIGUSR1 signal to all the backends, which will cause sinval.c to read + * any pending SI entries. * * This should never happen if all the backends are actively executing * queries, but if a backend is sitting idle then it won't be starting @@ -302,9 +302,9 @@ SIGetDataEntry(SISeg *segP, int backendId, stateP->nextMsgNum++; /* - * There may be other backends that haven't read the message, so we - * cannot delete it here. SIDelExpiredDataEntries() should be called - * to remove dead messages. + * There may be other backends that haven't read the message, so we cannot + * delete it here. SIDelExpiredDataEntries() should be called to remove + * dead messages. */ return 1; /* got a message */ } @@ -338,8 +338,8 @@ SIDelExpiredDataEntries(SISeg *segP) segP->minMsgNum = min; /* - * When minMsgNum gets really large, decrement all message counters so - * as to forestall overflow of the counters. + * When minMsgNum gets really large, decrement all message counters so as + * to forestall overflow of the counters. */ if (min >= MSGNUMWRAPAROUND) { diff --git a/src/backend/storage/large_object/inv_api.c b/src/backend/storage/large_object/inv_api.c index 9762c76916..74409f3cd0 100644 --- a/src/backend/storage/large_object/inv_api.c +++ b/src/backend/storage/large_object/inv_api.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/large_object/inv_api.c,v 1.112 2005/08/12 01:35:58 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/storage/large_object/inv_api.c,v 1.113 2005/10/15 02:49:26 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -82,8 +82,8 @@ close_lo_relation(bool isCommit) if (lo_heap_r || lo_index_r) { /* - * Only bother to close if committing; else abort cleanup will - * handle it + * Only bother to close if committing; else abort cleanup will handle + * it */ if (isCommit) { @@ -176,9 +176,9 @@ Oid inv_create(Oid lobjId) { /* - * Allocate an OID to be the LO's identifier, unless we were told - * what to use. We can use the index on pg_largeobject for checking - * OID uniqueness, even though it has additional columns besides OID. + * Allocate an OID to be the LO's identifier, unless we were told what to + * use. We can use the index on pg_largeobject for checking OID + * uniqueness, even though it has additional columns besides OID. */ if (!OidIsValid(lobjId)) { @@ -188,8 +188,8 @@ inv_create(Oid lobjId) } /* - * Create the LO by writing an empty first page for it in - * pg_largeobject (will fail if duplicate) + * Create the LO by writing an empty first page for it in pg_largeobject + * (will fail if duplicate) */ LargeObjectCreate(lobjId); @@ -305,8 +305,8 @@ inv_getsize(LargeObjectDesc *obj_desc) /* * Because the pg_largeobject index is on both loid and pageno, but we * constrain only loid, a backwards scan should visit all pages of the - * large object in reverse pageno order. So, it's sufficient to - * examine the first valid tuple (== last valid page). + * large object in reverse pageno order. So, it's sufficient to examine + * the first valid tuple (== last valid page). */ while ((tuple = index_getnext(sd, BackwardScanDirection)) != NULL) { @@ -423,8 +423,8 @@ inv_read(LargeObjectDesc *obj_desc, char *buf, int nbytes) /* * We assume the indexscan will deliver pages in order. However, - * there may be missing pages if the LO contains unwritten - * "holes". We want missing sections to read out as zeroes. + * there may be missing pages if the LO contains unwritten "holes". We + * want missing sections to read out as zeroes. */ pageoff = ((uint32) data->pageno) * LOBLKSIZE; if (pageoff > obj_desc->offset) @@ -536,9 +536,8 @@ inv_write(LargeObjectDesc *obj_desc, char *buf, int nbytes) while (nwritten < nbytes) { /* - * If possible, get next pre-existing page of the LO. We assume - * the indexscan will deliver these in order --- but there may be - * holes. + * If possible, get next pre-existing page of the LO. We assume the + * indexscan will deliver these in order --- but there may be holes. */ if (neednextpage) { @@ -551,8 +550,8 @@ inv_write(LargeObjectDesc *obj_desc, char *buf, int nbytes) } /* - * If we have a pre-existing page, see if it is the page we want - * to write, or a later one. + * If we have a pre-existing page, see if it is the page we want to + * write, or a later one. */ if (olddata != NULL && olddata->pageno == pageno) { @@ -660,8 +659,8 @@ inv_write(LargeObjectDesc *obj_desc, char *buf, int nbytes) CatalogCloseIndexes(indstate); /* - * Advance command counter so that my tuple updates will be seen by - * later large-object operations in this transaction. + * Advance command counter so that my tuple updates will be seen by later + * large-object operations in this transaction. */ CommandCounterIncrement(); diff --git a/src/backend/storage/lmgr/deadlock.c b/src/backend/storage/lmgr/deadlock.c index 7edabff6dd..06de6071f1 100644 --- a/src/backend/storage/lmgr/deadlock.c +++ b/src/backend/storage/lmgr/deadlock.c @@ -12,7 +12,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/lmgr/deadlock.c,v 1.34 2005/04/29 22:28:24 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/storage/lmgr/deadlock.c,v 1.35 2005/10/15 02:49:26 momjian Exp $ * * Interface: * @@ -130,15 +130,15 @@ InitDeadLockChecking(void) oldcxt = MemoryContextSwitchTo(TopMemoryContext); /* - * FindLockCycle needs at most MaxBackends entries in visitedProcs[] - * and deadlockDetails[]. + * FindLockCycle needs at most MaxBackends entries in visitedProcs[] and + * deadlockDetails[]. */ visitedProcs = (PGPROC **) palloc(MaxBackends * sizeof(PGPROC *)); deadlockDetails = (DEADLOCK_INFO *) palloc(MaxBackends * sizeof(DEADLOCK_INFO)); /* - * TopoSort needs to consider at most MaxBackends wait-queue entries, - * and it needn't run concurrently with FindLockCycle. + * TopoSort needs to consider at most MaxBackends wait-queue entries, and + * it needn't run concurrently with FindLockCycle. */ topoProcs = visitedProcs; /* re-use this space */ beforeConstraints = (int *) palloc(MaxBackends * sizeof(int)); @@ -146,33 +146,32 @@ InitDeadLockChecking(void) /* * We need to consider rearranging at most MaxBackends/2 wait queues - * (since it takes at least two waiters in a queue to create a soft - * edge), and the expanded form of the wait queues can't involve more - * than MaxBackends total waiters. + * (since it takes at least two waiters in a queue to create a soft edge), + * and the expanded form of the wait queues can't involve more than + * MaxBackends total waiters. */ waitOrders = (WAIT_ORDER *) palloc((MaxBackends / 2) * sizeof(WAIT_ORDER)); waitOrderProcs = (PGPROC **) palloc(MaxBackends * sizeof(PGPROC *)); /* - * Allow at most MaxBackends distinct constraints in a configuration. - * (Is this enough? In practice it seems it should be, but I don't - * quite see how to prove it. If we run out, we might fail to find a - * workable wait queue rearrangement even though one exists.) NOTE - * that this number limits the maximum recursion depth of - * DeadLockCheckRecurse. Making it really big might potentially allow - * a stack-overflow problem. + * Allow at most MaxBackends distinct constraints in a configuration. (Is + * this enough? In practice it seems it should be, but I don't quite see + * how to prove it. If we run out, we might fail to find a workable wait + * queue rearrangement even though one exists.) NOTE that this number + * limits the maximum recursion depth of DeadLockCheckRecurse. Making it + * really big might potentially allow a stack-overflow problem. */ maxCurConstraints = MaxBackends; curConstraints = (EDGE *) palloc(maxCurConstraints * sizeof(EDGE)); /* * Allow up to 3*MaxBackends constraints to be saved without having to - * re-run TestConfiguration. (This is probably more than enough, but - * we can survive if we run low on space by doing excess runs of - * TestConfiguration to re-compute constraint lists each time needed.) - * The last MaxBackends entries in possibleConstraints[] are reserved - * as output workspace for FindLockCycle. + * re-run TestConfiguration. (This is probably more than enough, but we + * can survive if we run low on space by doing excess runs of + * TestConfiguration to re-compute constraint lists each time needed.) The + * last MaxBackends entries in possibleConstraints[] are reserved as + * output workspace for FindLockCycle. */ maxPossibleConstraints = MaxBackends * 4; possibleConstraints = @@ -361,9 +360,9 @@ TestConfiguration(PGPROC *startProc) return -1; /* - * Check for cycles involving startProc or any of the procs mentioned - * in constraints. We check startProc last because if it has a soft - * cycle still to be dealt with, we want to deal with that first. + * Check for cycles involving startProc or any of the procs mentioned in + * constraints. We check startProc last because if it has a soft cycle + * still to be dealt with, we want to deal with that first. */ for (i = 0; i < nCurConstraints; i++) { @@ -447,8 +446,8 @@ FindLockCycleRecurse(PGPROC *checkProc, if (i == 0) { /* - * record total length of cycle --- outer levels will now - * fill deadlockDetails[] + * record total length of cycle --- outer levels will now fill + * deadlockDetails[] */ Assert(depth <= MaxBackends); nDeadlockDetails = depth; @@ -457,8 +456,8 @@ FindLockCycleRecurse(PGPROC *checkProc, } /* - * Otherwise, we have a cycle but it does not include the - * start point, so say "no deadlock". + * Otherwise, we have a cycle but it does not include the start + * point, so say "no deadlock". */ return false; } @@ -480,8 +479,8 @@ FindLockCycleRecurse(PGPROC *checkProc, conflictMask = lockMethodTable->conflictTab[checkProc->waitLockMode]; /* - * Scan for procs that already hold conflicting locks. These are - * "hard" edges in the waits-for graph. + * Scan for procs that already hold conflicting locks. These are "hard" + * edges in the waits-for graph. */ procLocks = &(lock->procLocks); @@ -520,15 +519,14 @@ FindLockCycleRecurse(PGPROC *checkProc, } proclock = (PROCLOCK *) SHMQueueNext(procLocks, &proclock->lockLink, - offsetof(PROCLOCK, lockLink)); + offsetof(PROCLOCK, lockLink)); } /* * Scan for procs that are ahead of this one in the lock's wait queue. - * Those that have conflicting requests soft-block this one. This - * must be done after the hard-block search, since if another proc - * both hard- and soft-blocks this one, we want to call it a hard - * edge. + * Those that have conflicting requests soft-block this one. This must be + * done after the hard-block search, since if another proc both hard- and + * soft-blocks this one, we want to call it a hard edge. * * If there is a proposed re-ordering of the lock's wait order, use that * rather than the current wait order. @@ -569,8 +567,7 @@ FindLockCycleRecurse(PGPROC *checkProc, info->pid = checkProc->pid; /* - * Add this edge to the list of soft edges in the - * cycle + * Add this edge to the list of soft edges in the cycle */ Assert(*nSoftEdges < MaxBackends); softEdges[*nSoftEdges].waiter = checkProc; @@ -610,8 +607,7 @@ FindLockCycleRecurse(PGPROC *checkProc, info->pid = checkProc->pid; /* - * Add this edge to the list of soft edges in the - * cycle + * Add this edge to the list of soft edges in the cycle */ Assert(*nSoftEdges < MaxBackends); softEdges[*nSoftEdges].waiter = checkProc; @@ -655,8 +651,8 @@ ExpandConstraints(EDGE *constraints, /* * Scan constraint list backwards. This is because the last-added - * constraint is the only one that could fail, and so we want to test - * it for inconsistency first. + * constraint is the only one that could fail, and so we want to test it + * for inconsistency first. */ for (i = nConstraints; --i >= 0;) { @@ -679,8 +675,8 @@ ExpandConstraints(EDGE *constraints, Assert(nWaitOrderProcs <= MaxBackends); /* - * Do the topo sort. TopoSort need not examine constraints after - * this one, since they must be for different locks. + * Do the topo sort. TopoSort need not examine constraints after this + * one, since they must be for different locks. */ if (!TopoSort(lock, constraints, i + 1, waitOrders[nWaitOrders].procs)) @@ -739,15 +735,14 @@ TopoSort(LOCK *lock, } /* - * Scan the constraints, and for each proc in the array, generate a - * count of the number of constraints that say it must be before - * something else, plus a list of the constraints that say it must be - * after something else. The count for the j'th proc is stored in - * beforeConstraints[j], and the head of its list in - * afterConstraints[j]. Each constraint stores its list link in - * constraints[i].link (note any constraint will be in just one list). - * The array index for the before-proc of the i'th constraint is - * remembered in constraints[i].pred. + * Scan the constraints, and for each proc in the array, generate a count + * of the number of constraints that say it must be before something else, + * plus a list of the constraints that say it must be after something + * else. The count for the j'th proc is stored in beforeConstraints[j], + * and the head of its list in afterConstraints[j]. Each constraint + * stores its list link in constraints[i].link (note any constraint will + * be in just one list). The array index for the before-proc of the i'th + * constraint is remembered in constraints[i].pred. */ MemSet(beforeConstraints, 0, queue_size * sizeof(int)); MemSet(afterConstraints, 0, queue_size * sizeof(int)); @@ -933,7 +928,7 @@ DeadLockReport(void) DescribeLockTag(&buf2, &info->locktag); appendStringInfo(&buf, - _("Process %d waits for %s on %s; blocked by process %d."), + _("Process %d waits for %s on %s; blocked by process %d."), info->pid, GetLockmodeName(info->lockmode), buf2.data, diff --git a/src/backend/storage/lmgr/lmgr.c b/src/backend/storage/lmgr/lmgr.c index 7a4ef9f755..8ffeced997 100644 --- a/src/backend/storage/lmgr/lmgr.c +++ b/src/backend/storage/lmgr/lmgr.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/lmgr/lmgr.c,v 1.78 2005/08/01 20:31:11 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/storage/lmgr/lmgr.c,v 1.79 2005/10/15 02:49:26 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -145,11 +145,11 @@ LockRelation(Relation relation, LOCKMODE lockmode) lockmode, false, false); /* - * Check to see if the relcache entry has been invalidated while we - * were waiting to lock it. If so, rebuild it, or ereport() trying. - * Increment the refcount to ensure that RelationFlushRelation will - * rebuild it and not just delete it. We can skip this if the lock - * was already held, however. + * Check to see if the relcache entry has been invalidated while we were + * waiting to lock it. If so, rebuild it, or ereport() trying. Increment + * the refcount to ensure that RelationFlushRelation will rebuild it and + * not just delete it. We can skip this if the lock was already held, + * however. */ if (res != LOCKACQUIRE_ALREADY_HELD) { @@ -185,11 +185,11 @@ ConditionalLockRelation(Relation relation, LOCKMODE lockmode) return false; /* - * Check to see if the relcache entry has been invalidated while we - * were waiting to lock it. If so, rebuild it, or ereport() trying. - * Increment the refcount to ensure that RelationFlushRelation will - * rebuild it and not just delete it. We can skip this if the lock - * was already held, however. + * Check to see if the relcache entry has been invalidated while we were + * waiting to lock it. If so, rebuild it, or ereport() trying. Increment + * the refcount to ensure that RelationFlushRelation will rebuild it and + * not just delete it. We can skip this if the lock was already held, + * however. */ if (res != LOCKACQUIRE_ALREADY_HELD) { @@ -429,7 +429,7 @@ XactLockTableInsert(TransactionId xid) * * Delete the lock showing that the given transaction ID is running. * (This is never used for main transaction IDs; those locks are only - * released implicitly at transaction end. But we do use it for subtrans + * released implicitly at transaction end. But we do use it for subtrans * IDs.) */ void @@ -451,7 +451,7 @@ XactLockTableDelete(TransactionId xid) * subtransaction, we will exit as soon as it aborts or its top parent commits. * It takes some extra work to ensure this, because to save on shared memory * the XID lock of a subtransaction is released when it ends, whether - * successfully or unsuccessfully. So we have to check if it's "still running" + * successfully or unsuccessfully. So we have to check if it's "still running" * and if so wait for its parent. */ void @@ -477,8 +477,8 @@ XactLockTableWait(TransactionId xid) } /* - * Transaction was committed/aborted/crashed - we have to update - * pg_clog if transaction is still marked as running. + * Transaction was committed/aborted/crashed - we have to update pg_clog + * if transaction is still marked as running. */ if (!TransactionIdDidCommit(xid) && !TransactionIdDidAbort(xid)) TransactionIdAbort(xid); @@ -514,8 +514,8 @@ ConditionalXactLockTableWait(TransactionId xid) } /* - * Transaction was committed/aborted/crashed - we have to update - * pg_clog if transaction is still marked as running. + * Transaction was committed/aborted/crashed - we have to update pg_clog + * 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 c11070a130..245b8eeee2 100644 --- a/src/backend/storage/lmgr/lock.c +++ b/src/backend/storage/lmgr/lock.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/lmgr/lock.c,v 1.157 2005/08/20 23:26:23 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/storage/lmgr/lock.c,v 1.158 2005/10/15 02:49:26 momjian Exp $ * * NOTES * Outside modules can create a lock table and acquire/release @@ -46,7 +46,7 @@ /* This configuration variable is used to set the lock table size */ int max_locks_per_xact; /* set by guc.c */ -#define NLOCKENTS() \ +#define NLOCKENTS() \ mul_size(max_locks_per_xact, add_size(MaxBackends, max_prepared_xacts)) @@ -155,12 +155,11 @@ PROCLOCK_PRINT(const char *where, const PROCLOCK *proclockP) { if (LOCK_DEBUG_ENABLED((LOCK *) MAKE_PTR(proclockP->tag.lock))) elog(LOG, - "%s: proclock(%lx) lock(%lx) method(%u) proc(%lx) hold(%x)", + "%s: proclock(%lx) lock(%lx) method(%u) proc(%lx) hold(%x)", where, MAKE_OFFSET(proclockP), proclockP->tag.lock, PROCLOCK_LOCKMETHOD(*(proclockP)), proclockP->tag.proc, (int) proclockP->holdMask); } - #else /* not LOCK_DEBUG */ #define LOCK_PRINT(where, lock, type) @@ -171,11 +170,11 @@ PROCLOCK_PRINT(const char *where, const PROCLOCK *proclockP) static void RemoveLocalLock(LOCALLOCK *locallock); static void GrantLockLocal(LOCALLOCK *locallock, ResourceOwner owner); static void WaitOnLock(LOCKMETHODID lockmethodid, LOCALLOCK *locallock, - ResourceOwner owner); + ResourceOwner owner); static bool UnGrantLock(LOCK *lock, LOCKMODE lockmode, - PROCLOCK *proclock, LockMethod lockMethodTable); + PROCLOCK *proclock, LockMethod lockMethodTable); static void CleanUpLock(LOCKMETHODID lockmethodid, LOCK *lock, - PROCLOCK *proclock, bool wakeupNeeded); + PROCLOCK *proclock, bool wakeupNeeded); /* @@ -320,14 +319,13 @@ LockMethodTableInit(const char *tabName, elog(FATAL, "could not initialize lock table \"%s\"", tabName); /* - * allocate a non-shared hash table for LOCALLOCK structs. This is - * used to store lock counts and resource owner information. + * allocate a non-shared hash table for LOCALLOCK structs. This is used + * to store lock counts and resource owner information. * - * The non-shared table could already exist in this process (this occurs - * when the postmaster is recreating shared memory after a backend - * crash). If so, delete and recreate it. (We could simply leave it, - * since it ought to be empty in the postmaster, but for safety let's - * zap it.) + * The non-shared table could already exist in this process (this occurs when + * the postmaster is recreating shared memory after a backend crash). If + * so, delete and recreate it. (We could simply leave it, since it ought + * to be empty in the postmaster, but for safety let's zap it.) */ if (LockMethodLocalHash[lockmethodid]) hash_destroy(LockMethodLocalHash[lockmethodid]); @@ -499,7 +497,7 @@ LockAcquire(LOCKMETHODID lockmethodid, locallock->lockOwners = NULL; locallock->lockOwners = (LOCALLOCKOWNER *) MemoryContextAlloc(TopMemoryContext, - locallock->maxLockOwners * sizeof(LOCALLOCKOWNER)); + locallock->maxLockOwners * sizeof(LOCALLOCKOWNER)); } else { @@ -518,8 +516,7 @@ LockAcquire(LOCKMETHODID lockmethodid, } /* - * If we already hold the lock, we can just increase the count - * locally. + * If we already hold the lock, we can just increase the count locally. */ if (locallock->nLocks > 0) { @@ -537,8 +534,8 @@ LockAcquire(LOCKMETHODID lockmethodid, /* * Find or create a lock with this tag. * - * Note: if the locallock object already existed, it might have a pointer - * to the lock already ... but we probably should not assume that that + * Note: if the locallock object already existed, it might have a pointer to + * the lock already ... but we probably should not assume that that * pointer is valid, since a lock object with no locks can go away * anytime. */ @@ -551,7 +548,7 @@ LockAcquire(LOCKMETHODID lockmethodid, ereport(ERROR, (errcode(ERRCODE_OUT_OF_MEMORY), errmsg("out of shared memory"), - errhint("You may need to increase max_locks_per_transaction."))); + errhint("You may need to increase max_locks_per_transaction."))); } locallock->lock = lock; @@ -581,7 +578,7 @@ LockAcquire(LOCKMETHODID lockmethodid, /* * Create the hash key for the proclock table. */ - MemSet(&proclocktag, 0, sizeof(PROCLOCKTAG)); /* must clear padding */ + MemSet(&proclocktag, 0, sizeof(PROCLOCKTAG)); /* must clear padding */ proclocktag.lock = MAKE_OFFSET(lock); proclocktag.proc = MAKE_OFFSET(MyProc); @@ -612,7 +609,7 @@ LockAcquire(LOCKMETHODID lockmethodid, ereport(ERROR, (errcode(ERRCODE_OUT_OF_MEMORY), errmsg("out of shared memory"), - errhint("You may need to increase max_locks_per_transaction."))); + errhint("You may need to increase max_locks_per_transaction."))); } locallock->proclock = proclock; @@ -636,29 +633,28 @@ LockAcquire(LOCKMETHODID lockmethodid, #ifdef CHECK_DEADLOCK_RISK /* - * Issue warning if we already hold a lower-level lock on this - * object and do not hold a lock of the requested level or higher. - * This indicates a deadlock-prone coding practice (eg, we'd have - * a deadlock if another backend were following the same code path - * at about the same time). + * Issue warning if we already hold a lower-level lock on this object + * and do not hold a lock of the requested level or higher. This + * indicates a deadlock-prone coding practice (eg, we'd have a + * deadlock if another backend were following the same code path at + * about the same time). * - * This is not enabled by default, because it may generate log - * entries about user-level coding practices that are in fact safe - * in context. It can be enabled to help find system-level - * problems. + * This is not enabled by default, because it may generate log entries + * about user-level coding practices that are in fact safe in context. + * It can be enabled to help find system-level problems. * * XXX Doing numeric comparison on the lockmodes is a hack; it'd be * better to use a table. For now, though, this works. */ { - int i; + int i; for (i = lockMethodTable->numLockModes; i > 0; i--) { if (proclock->holdMask & LOCKBIT_ON(i)) { if (i >= (int) lockmode) - break; /* safe: we have a lock >= req level */ + break; /* safe: we have a lock >= req level */ elog(LOG, "deadlock risk: raising lock level" " from %s to %s on object %u/%u/%u", lock_mode_names[i], lock_mode_names[lockmode], @@ -673,16 +669,16 @@ LockAcquire(LOCKMETHODID lockmethodid, /* * lock->nRequested and lock->requested[] count the total number of - * requests, whether granted or waiting, so increment those - * immediately. The other counts don't increment till we get the lock. + * requests, whether granted or waiting, so increment those immediately. + * The other counts don't increment till we get the lock. */ lock->nRequested++; lock->requested[lockmode]++; Assert((lock->nRequested > 0) && (lock->requested[lockmode] > 0)); /* - * We shouldn't already hold the desired lock; else locallock table - * is broken. + * We shouldn't already hold the desired lock; else locallock table is + * broken. */ if (proclock->holdMask & LOCKBIT_ON(lockmode)) elog(ERROR, "lock %s on object %u/%u/%u is already held", @@ -691,9 +687,9 @@ LockAcquire(LOCKMETHODID lockmethodid, lock->tag.locktag_field3); /* - * If lock requested conflicts with locks requested by waiters, must - * join wait queue. Otherwise, check for conflict with already-held - * locks. (That's last because most complex check.) + * If lock requested conflicts with locks requested by waiters, must join + * wait queue. Otherwise, check for conflict with already-held locks. + * (That's last because most complex check.) */ if (lockMethodTable->conflictTab[lockmode] & lock->waitMask) status = STATUS_FOUND; @@ -713,8 +709,8 @@ LockAcquire(LOCKMETHODID lockmethodid, /* * We can't acquire the lock immediately. If caller specified no - * blocking, remove useless table entries and return NOT_AVAIL - * without waiting. + * blocking, remove useless table entries and return NOT_AVAIL without + * waiting. */ if (dontWait) { @@ -753,8 +749,7 @@ LockAcquire(LOCKMETHODID lockmethodid, /* * NOTE: do not do any material change of state between here and * return. All required changes in locktable state must have been - * done when the lock was granted to us --- see notes in - * WaitOnLock. + * done when the lock was granted to us --- see notes in WaitOnLock. */ /* @@ -820,13 +815,13 @@ LockCheckConflicts(LockMethod lockMethodTable, int i; /* - * first check for global conflicts: If no locks conflict with my - * request, then I get the lock. + * first check for global conflicts: If no locks conflict with my request, + * then I get the lock. * - * Checking for conflict: lock->grantMask represents the types of - * currently held locks. conflictTable[lockmode] has a bit set for - * each type of lock that conflicts with request. Bitwise compare - * tells if there is a conflict. + * Checking for conflict: lock->grantMask represents the types of currently + * held locks. conflictTable[lockmode] has a bit set for each type of + * lock that conflicts with request. Bitwise compare tells if there is a + * conflict. */ if (!(lockMethodTable->conflictTab[lockmode] & lock->grantMask)) { @@ -835,15 +830,15 @@ LockCheckConflicts(LockMethod lockMethodTable, } /* - * Rats. Something conflicts. But it could still be my own lock. - * We have to construct a conflict mask that does not reflect our own - * locks, but only lock types held by other processes. + * Rats. Something conflicts. But it could still be my own lock. We have + * to construct a conflict mask that does not reflect our own locks, but + * only lock types held by other processes. */ myLocks = proclock->holdMask; otherLocks = 0; for (i = 1; i <= numLockModes; i++) { - int myHolding = (myLocks & LOCKBIT_ON(i)) ? 1 : 0; + int myHolding = (myLocks & LOCKBIT_ON(i)) ? 1 : 0; if (lock->granted[i] > myHolding) otherLocks |= LOCKBIT_ON(i); @@ -851,8 +846,8 @@ LockCheckConflicts(LockMethod lockMethodTable, /* * now check again for conflicts. 'otherLocks' describes the types of - * locks held by other processes. If one of these conflicts with the - * kind of lock that I want, there is a conflict and I have to sleep. + * locks held by other processes. If one of these conflicts with the kind + * of lock that I want, there is a conflict and I have to sleep. */ if (!(lockMethodTable->conflictTab[lockmode] & otherLocks)) { @@ -891,7 +886,7 @@ GrantLock(LOCK *lock, PROCLOCK *proclock, LOCKMODE lockmode) } /* - * UnGrantLock -- opposite of GrantLock. + * UnGrantLock -- opposite of GrantLock. * * Updates the lock and proclock data structures to show that the lock * is no longer held nor requested by the current holder. @@ -903,7 +898,7 @@ static bool UnGrantLock(LOCK *lock, LOCKMODE lockmode, PROCLOCK *proclock, LockMethod lockMethodTable) { - bool wakeupNeeded = false; + bool wakeupNeeded = false; Assert((lock->nRequested > 0) && (lock->requested[lockmode] > 0)); Assert((lock->nGranted > 0) && (lock->granted[lockmode] > 0)); @@ -926,13 +921,13 @@ UnGrantLock(LOCK *lock, LOCKMODE lockmode, LOCK_PRINT("UnGrantLock: updated", lock, lockmode); /* - * We need only run ProcLockWakeup if the released lock conflicts with - * at least one of the lock types requested by waiter(s). Otherwise - * whatever conflict made them wait must still exist. NOTE: before - * MVCC, we could skip wakeup if lock->granted[lockmode] was still - * positive. But that's not true anymore, because the remaining - * granted locks might belong to some waiter, who could now be - * awakened because he doesn't conflict with his own locks. + * We need only run ProcLockWakeup if the released lock conflicts with at + * least one of the lock types requested by waiter(s). Otherwise whatever + * conflict made them wait must still exist. NOTE: before MVCC, we could + * skip wakeup if lock->granted[lockmode] was still positive. But that's + * not true anymore, because the remaining granted locks might belong to + * some waiter, who could now be awakened because he doesn't conflict with + * his own locks. */ if (lockMethodTable->conflictTab[lockmode] & lock->waitMask) wakeupNeeded = true; @@ -947,7 +942,7 @@ UnGrantLock(LOCK *lock, LOCKMODE lockmode, } /* - * CleanUpLock -- clean up after releasing a lock. We garbage-collect the + * CleanUpLock -- clean up after releasing a lock. We garbage-collect the * proclock and lock objects if possible, and call ProcLockWakeup if there * are remaining requests and the caller says it's OK. (Normally, this * should be called after UnGrantLock, and wakeupNeeded is the result from @@ -961,8 +956,8 @@ CleanUpLock(LOCKMETHODID lockmethodid, LOCK *lock, PROCLOCK *proclock, bool wakeupNeeded) { /* - * If this was my last hold on this lock, delete my entry in the - * proclock table. + * If this was my last hold on this lock, delete my entry in the proclock + * table. */ if (proclock->holdMask == 0) { @@ -978,8 +973,8 @@ CleanUpLock(LOCKMETHODID lockmethodid, LOCK *lock, PROCLOCK *proclock, if (lock->nRequested == 0) { /* - * The caller just released the last lock, so garbage-collect the - * lock object. + * The caller just released the last lock, so garbage-collect the lock + * object. */ LOCK_PRINT("CleanUpLock: deleting", lock, 0); Assert(SHMQueueEmpty(&(lock->procLocks))); @@ -991,7 +986,7 @@ CleanUpLock(LOCKMETHODID lockmethodid, LOCK *lock, PROCLOCK *proclock, else if (wakeupNeeded) { /* There are waiters on this lock, so wake them up. */ - ProcLockWakeup(LockMethods[lockmethodid], lock); + ProcLockWakeup(LockMethods[lockmethodid], lock); } } @@ -1075,16 +1070,15 @@ WaitOnLock(LOCKMETHODID lockmethodid, LOCALLOCK *locallock, /* * NOTE: Think not to put any shared-state cleanup after the call to - * ProcSleep, in either the normal or failure path. The lock state - * must be fully set by the lock grantor, or by CheckDeadLock if we - * give up waiting for the lock. This is necessary because of the - * possibility that a cancel/die interrupt will interrupt ProcSleep - * after someone else grants us the lock, but before we've noticed it. - * Hence, after granting, the locktable state must fully reflect the - * fact that we own the lock; we can't do additional work on return. - * Contrariwise, if we fail, any cleanup must happen in xact abort - * processing, not here, to ensure it will also happen in the - * cancel/die case. + * ProcSleep, in either the normal or failure path. The lock state must + * be fully set by the lock grantor, or by CheckDeadLock if we give up + * waiting for the lock. This is necessary because of the possibility + * that a cancel/die interrupt will interrupt ProcSleep after someone else + * grants us the lock, but before we've noticed it. Hence, after granting, + * the locktable state must fully reflect the fact that we own the lock; + * we can't do additional work on return. Contrariwise, if we fail, any + * cleanup must happen in xact abort processing, not here, to ensure it + * will also happen in the cancel/die case. */ if (ProcSleep(lockMethodTable, @@ -1093,8 +1087,7 @@ WaitOnLock(LOCKMETHODID lockmethodid, LOCALLOCK *locallock, locallock->proclock) != STATUS_OK) { /* - * We failed as a result of a deadlock, see CheckDeadLock(). Quit - * now. + * We failed as a result of a deadlock, see CheckDeadLock(). Quit now. */ awaitedLock = NULL; LOCK_PRINT("WaitOnLock: aborting on lock", @@ -1102,8 +1095,8 @@ WaitOnLock(LOCKMETHODID lockmethodid, LOCALLOCK *locallock, LWLockRelease(lockMethodTable->masterLock); /* - * Now that we aren't holding the LockMgrLock, we can give an - * error report including details about the detected deadlock. + * Now that we aren't holding the LockMgrLock, we can give an error + * report including details about the detected deadlock. */ DeadLockReport(); /* not reached */ @@ -1163,15 +1156,15 @@ RemoveFromWaitQueue(PGPROC *proc) * Delete the proclock immediately if it represents no already-held locks. * (This must happen now because if the owner of the lock decides to * release it, and the requested/granted counts then go to zero, - * LockRelease expects there to be no remaining proclocks.) - * Then see if any other waiters for the lock can be woken up now. + * LockRelease expects there to be no remaining proclocks.) Then see if + * any other waiters for the lock can be woken up now. */ CleanUpLock(lockmethodid, waitLock, proclock, true); } /* * LockRelease -- look up 'locktag' in lock table 'lockmethodid' and - * release one 'lockmode' lock on it. Release a session lock if + * release one 'lockmode' lock on it. Release a session lock if * 'sessionLock' is true, else release a regular transaction lock. * * Side Effects: find any waiting processes that are now wakable, @@ -1219,8 +1212,7 @@ LockRelease(LOCKMETHODID lockmethodid, LOCKTAG *locktag, HASH_FIND, NULL); /* - * let the caller print its own error message, too. Do not - * ereport(ERROR). + * let the caller print its own error message, too. Do not ereport(ERROR). */ if (!locallock || locallock->nLocks <= 0) { @@ -1268,8 +1260,8 @@ LockRelease(LOCKMETHODID lockmethodid, LOCKTAG *locktag, } /* - * Decrease the total local count. If we're still holding the lock, - * we're done. + * Decrease the total local count. If we're still holding the lock, we're + * done. */ locallock->nLocks--; @@ -1285,8 +1277,8 @@ LockRelease(LOCKMETHODID lockmethodid, LOCKTAG *locktag, /* * We don't need to re-find the lock or proclock, since we kept their - * addresses in the locallock table, and they couldn't have been - * removed while we were holding a lock on them. + * addresses in the locallock table, and they couldn't have been removed + * while we were holding a lock on them. */ lock = locallock->lock; LOCK_PRINT("LockRelease: found", lock, lockmode); @@ -1294,8 +1286,8 @@ LockRelease(LOCKMETHODID lockmethodid, LOCKTAG *locktag, PROCLOCK_PRINT("LockRelease: found", proclock); /* - * Double-check that we are actually holding a lock of the type we - * want to release. + * Double-check that we are actually holding a lock of the type we want to + * release. */ if (!(proclock->holdMask & LOCKBIT_ON(lockmode))) { @@ -1356,10 +1348,10 @@ LockReleaseAll(LOCKMETHODID lockmethodid, bool allLocks) /* * First we run through the locallock table and get rid of unwanted - * entries, then we scan the process's proclocks and get rid of those. - * We do this separately because we may have multiple locallock - * entries pointing to the same proclock, and we daren't end up with - * any dangling pointers. + * entries, then we scan the process's proclocks and get rid of those. We + * do this separately because we may have multiple locallock entries + * pointing to the same proclock, and we daren't end up with any dangling + * pointers. */ hash_seq_init(&status, LockMethodLocalHash[lockmethodid]); @@ -1368,8 +1360,8 @@ LockReleaseAll(LOCKMETHODID lockmethodid, bool allLocks) if (locallock->proclock == NULL || locallock->lock == NULL) { /* - * We must've run out of shared memory while trying to set up - * this lock. Just forget the local entry. + * We must've run out of shared memory while trying to set up this + * lock. Just forget the local entry. */ Assert(locallock->nLocks == 0); RemoveLocalLock(locallock); @@ -1381,9 +1373,9 @@ LockReleaseAll(LOCKMETHODID lockmethodid, bool allLocks) continue; /* - * If we are asked to release all locks, we can just zap the - * entry. Otherwise, must scan to see if there are session locks. - * We assume there is at most one lockOwners entry for session locks. + * If we are asked to release all locks, we can just zap the entry. + * Otherwise, must scan to see if there are session locks. We assume + * there is at most one lockOwners entry for session locks. */ if (!allLocks) { @@ -1431,7 +1423,7 @@ LockReleaseAll(LOCKMETHODID lockmethodid, bool allLocks) /* Get link first, since we may unlink/delete this proclock */ nextplock = (PROCLOCK *) SHMQueueNext(procLocks, &proclock->procLink, - offsetof(PROCLOCK, procLink)); + offsetof(PROCLOCK, procLink)); Assert(proclock->tag.proc == MAKE_OFFSET(MyProc)); @@ -1581,8 +1573,8 @@ LockReassignCurrentOwner(void) continue; /* - * Scan to see if there are any locks belonging to current owner - * or its parent + * Scan to see if there are any locks belonging to current owner or + * its parent */ lockOwners = locallock->lockOwners; for (i = locallock->numLockOwners - 1; i >= 0; i--) @@ -1644,7 +1636,7 @@ AtPrepare_Locks(void) { TwoPhaseLockRecord record; LOCALLOCKOWNER *lockOwners = locallock->lockOwners; - int i; + int i; /* Ignore items that are not of the lockmethod to be processed */ if (LOCALLOCK_LOCKMETHOD(*locallock) != lockmethodid) @@ -1722,12 +1714,12 @@ PostPrepare_Locks(TransactionId xid) /* * First we run through the locallock table and get rid of unwanted - * entries, then we scan the process's proclocks and transfer them - * to the target proc. + * entries, then we scan the process's proclocks and transfer them to the + * target proc. * - * We do this separately because we may have multiple locallock - * entries pointing to the same proclock, and we daren't end up with - * any dangling pointers. + * We do this separately because we may have multiple locallock entries + * pointing to the same proclock, and we daren't end up with any dangling + * pointers. */ hash_seq_init(&status, LockMethodLocalHash[lockmethodid]); @@ -1736,8 +1728,8 @@ PostPrepare_Locks(TransactionId xid) if (locallock->proclock == NULL || locallock->lock == NULL) { /* - * We must've run out of shared memory while trying to set up - * this lock. Just forget the local entry. + * We must've run out of shared memory while trying to set up this + * lock. Just forget the local entry. */ Assert(locallock->nLocks == 0); RemoveLocalLock(locallock); @@ -1771,7 +1763,7 @@ PostPrepare_Locks(TransactionId xid) /* Get link first, since we may unlink/delete this proclock */ nextplock = (PROCLOCK *) SHMQueueNext(procLocks, &proclock->procLink, - offsetof(PROCLOCK, procLink)); + offsetof(PROCLOCK, procLink)); Assert(proclock->tag.proc == MAKE_OFFSET(MyProc)); @@ -1797,13 +1789,13 @@ PostPrepare_Locks(TransactionId xid) holdMask = proclock->holdMask; /* - * We cannot simply modify proclock->tag.proc to reassign ownership - * of the lock, because that's part of the hash key and the proclock + * We cannot simply modify proclock->tag.proc to reassign ownership of + * the lock, because that's part of the hash key and the proclock * would then be in the wrong hash chain. So, unlink and delete the - * old proclock; create a new one with the right contents; and link - * it into place. We do it in this order to be certain we won't - * run out of shared memory (the way dynahash.c works, the deleted - * object is certain to be available for reallocation). + * old proclock; create a new one with the right contents; and link it + * into place. We do it in this order to be certain we won't run out + * of shared memory (the way dynahash.c works, the deleted object is + * certain to be available for reallocation). */ SHMQueueDelete(&proclock->lockLink); SHMQueueDelete(&proclock->procLink); @@ -1823,7 +1815,7 @@ PostPrepare_Locks(TransactionId xid) (void *) &proclocktag, HASH_ENTER_NULL, &found); if (!newproclock) - ereport(PANIC, /* should not happen */ + ereport(PANIC, /* should not happen */ (errcode(ERRCODE_OUT_OF_MEMORY), errmsg("out of shared memory"), errdetail("Not enough memory for reassigning the prepared transaction's locks."))); @@ -1881,11 +1873,11 @@ LockShmemSize(void) size = add_size(size, hash_estimate_size(max_table_size, sizeof(PROCLOCK))); /* - * Note we count only one pair of hash tables, since the userlocks - * table actually overlays the main one. + * Note we count only one pair of hash tables, since the userlocks table + * actually overlays the main one. * - * 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 = add_size(size, size / 10); @@ -2000,7 +1992,7 @@ DumpLocks(PGPROC *proc) LOCK_PRINT("DumpLocks", lock, 0); proclock = (PROCLOCK *) SHMQueueNext(procLocks, &proclock->procLink, - offsetof(PROCLOCK, procLink)); + offsetof(PROCLOCK, procLink)); } } @@ -2046,7 +2038,6 @@ DumpAllLocks(void) elog(LOG, "DumpAllLocks: proclock->tag.lock = NULL"); } } - #endif /* LOCK_DEBUG */ /* @@ -2066,7 +2057,7 @@ lock_twophase_recover(TransactionId xid, uint16 info, { TwoPhaseLockRecord *rec = (TwoPhaseLockRecord *) recdata; PGPROC *proc = TwoPhaseGetDummyProc(xid); - LOCKTAG *locktag; + LOCKTAG *locktag; LOCKMODE lockmode; LOCKMETHODID lockmethodid; LOCK *lock; @@ -2102,7 +2093,7 @@ lock_twophase_recover(TransactionId xid, uint16 info, ereport(ERROR, (errcode(ERRCODE_OUT_OF_MEMORY), errmsg("out of shared memory"), - errhint("You may need to increase max_locks_per_transaction."))); + errhint("You may need to increase max_locks_per_transaction."))); } /* @@ -2131,7 +2122,7 @@ lock_twophase_recover(TransactionId xid, uint16 info, /* * Create the hash key for the proclock table. */ - MemSet(&proclocktag, 0, sizeof(PROCLOCKTAG)); /* must clear padding */ + MemSet(&proclocktag, 0, sizeof(PROCLOCKTAG)); /* must clear padding */ proclocktag.lock = MAKE_OFFSET(lock); proclocktag.proc = MAKE_OFFSET(proc); @@ -2162,7 +2153,7 @@ lock_twophase_recover(TransactionId xid, uint16 info, ereport(ERROR, (errcode(ERRCODE_OUT_OF_MEMORY), errmsg("out of shared memory"), - errhint("You may need to increase max_locks_per_transaction."))); + errhint("You may need to increase max_locks_per_transaction."))); } /* @@ -2185,8 +2176,7 @@ lock_twophase_recover(TransactionId xid, uint16 info, /* * lock->nRequested and lock->requested[] count the total number of - * requests, whether granted or waiting, so increment those - * immediately. + * requests, whether granted or waiting, so increment those immediately. */ lock->nRequested++; lock->requested[lockmode]++; @@ -2220,7 +2210,7 @@ lock_twophase_postcommit(TransactionId xid, uint16 info, { TwoPhaseLockRecord *rec = (TwoPhaseLockRecord *) recdata; PGPROC *proc = TwoPhaseGetDummyProc(xid); - LOCKTAG *locktag; + LOCKTAG *locktag; LOCKMODE lockmode; LOCKMETHODID lockmethodid; PROCLOCKTAG proclocktag; @@ -2256,7 +2246,7 @@ lock_twophase_postcommit(TransactionId xid, uint16 info, /* * Re-find the proclock object (ditto). */ - MemSet(&proclocktag, 0, sizeof(PROCLOCKTAG)); /* must clear padding */ + MemSet(&proclocktag, 0, sizeof(PROCLOCKTAG)); /* must clear padding */ proclocktag.lock = MAKE_OFFSET(lock); proclocktag.proc = MAKE_OFFSET(proc); proclock = (PROCLOCK *) hash_search(LockMethodProcLockHash[lockmethodid], @@ -2266,8 +2256,8 @@ lock_twophase_postcommit(TransactionId xid, uint16 info, elog(PANIC, "failed to re-find shared proclock object"); /* - * Double-check that we are actually holding a lock of the type we - * want to release. + * Double-check that we are actually holding a lock of the type we want to + * release. */ if (!(proclock->holdMask & LOCKBIT_ON(lockmode))) { diff --git a/src/backend/storage/lmgr/lwlock.c b/src/backend/storage/lmgr/lwlock.c index ce0606a3c4..5526c77a67 100644 --- a/src/backend/storage/lmgr/lwlock.c +++ b/src/backend/storage/lmgr/lwlock.c @@ -15,7 +15,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/lmgr/lwlock.c,v 1.33 2005/10/12 16:55:59 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/storage/lmgr/lwlock.c,v 1.34 2005/10/15 02:49:26 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -44,10 +44,10 @@ typedef struct LWLock /* * All the LWLock structs are allocated as an array in shared memory. - * (LWLockIds are indexes into the array.) We force the array stride to + * (LWLockIds are indexes into the array.) We force the array stride to * be a power of 2, which saves a few cycles in indexing, but more * importantly also ensures that individual LWLocks don't cross cache line - * boundaries. This reduces cache contention problems, especially on AMD + * boundaries. This reduces cache contention problems, especially on AMD * Opterons. (Of course, we have to also ensure that the array start * address is suitably aligned.) * @@ -101,7 +101,6 @@ LOG_LWDEBUG(const char *where, LWLockId lockid, const char *msg) if (Trace_lwlocks) elog(LOG, "%s(%d): %s", where, (int) lockid, msg); } - #else /* not LOCK_DEBUG */ #define PRINT_LWDEBUG(a,b,c) #define LOG_LWDEBUG(a,b,c) @@ -117,10 +116,10 @@ NumLWLocks(void) int numLocks; /* - * Possibly this logic should be spread out among the affected - * modules, the same way that shmem space estimation is done. But for - * now, there are few enough users of LWLocks that we can get away - * with just keeping the knowledge here. + * Possibly this logic should be spread out among the affected modules, + * the same way that shmem space estimation is done. But for now, there + * are few enough users of LWLocks that we can get away with just keeping + * the knowledge here. */ /* Predefined LWLocks */ @@ -136,8 +135,8 @@ NumLWLocks(void) numLocks += NUM_SLRU_BUFFERS; /* - * multixact.c needs one per MultiXact buffer, but there are - * two SLRU areas for MultiXact + * multixact.c needs one per MultiXact buffer, but there are two SLRU + * areas for MultiXact */ numLocks += 2 * NUM_SLRU_BUFFERS; @@ -226,6 +225,7 @@ LWLockId LWLockAssign(void) { LWLockId result; + /* use volatile pointer to prevent code rearrangement */ volatile int *LWLockCounter; @@ -261,8 +261,8 @@ LWLockAcquire(LWLockId lockid, LWLockMode mode) /* * We can't wait if we haven't got a PGPROC. This should only occur - * during bootstrap or shared memory initialization. Put an Assert - * here to catch unsafe coding practices. + * during bootstrap or shared memory initialization. Put an Assert here + * to catch unsafe coding practices. */ Assert(!(proc == NULL && IsUnderPostmaster)); @@ -271,9 +271,9 @@ LWLockAcquire(LWLockId lockid, LWLockMode mode) elog(ERROR, "too many LWLocks taken"); /* - * Lock out cancel/die interrupts until we exit the code section - * protected by the LWLock. This ensures that interrupts will not - * interfere with manipulations of data structures in shared memory. + * Lock out cancel/die interrupts until we exit the code section protected + * by the LWLock. This ensures that interrupts will not interfere with + * manipulations of data structures in shared memory. */ HOLD_INTERRUPTS(); @@ -282,17 +282,16 @@ LWLockAcquire(LWLockId lockid, LWLockMode mode) * LWLockRelease. * * NOTE: it might seem better to have LWLockRelease actually grant us the - * lock, rather than retrying and possibly having to go back to sleep. - * But in practice that is no good because it means a process swap for - * every lock acquisition when two or more processes are contending - * for the same lock. Since LWLocks are normally used to protect - * not-very-long sections of computation, a process needs to be able - * to acquire and release the same lock many times during a single CPU - * time slice, even in the presence of contention. The efficiency of - * being able to do that outweighs the inefficiency of sometimes - * wasting a process dispatch cycle because the lock is not free when - * a released waiter finally gets to run. See pgsql-hackers archives - * for 29-Dec-01. + * lock, rather than retrying and possibly having to go back to sleep. But + * in practice that is no good because it means a process swap for every + * lock acquisition when two or more processes are contending for the same + * lock. Since LWLocks are normally used to protect not-very-long + * sections of computation, a process needs to be able to acquire and + * release the same lock many times during a single CPU time slice, even + * in the presence of contention. The efficiency of being able to do that + * outweighs the inefficiency of sometimes wasting a process dispatch + * cycle because the lock is not free when a released waiter finally gets + * to run. See pgsql-hackers archives for 29-Dec-01. */ for (;;) { @@ -334,8 +333,8 @@ LWLockAcquire(LWLockId lockid, LWLockMode mode) * Add myself to wait queue. * * If we don't have a PGPROC structure, there's no way to wait. This - * should never occur, since MyProc should only be null during - * shared memory initialization. + * should never occur, since MyProc should only be null during shared + * memory initialization. */ if (proc == NULL) elog(FATAL, "cannot wait without a PGPROC structure"); @@ -356,13 +355,13 @@ LWLockAcquire(LWLockId lockid, LWLockMode mode) * Wait until awakened. * * Since we share the process wait semaphore with the regular lock - * manager and ProcWaitForSignal, and we may need to acquire an - * LWLock while one of those is pending, it is possible that we - * get awakened for a reason other than being signaled by - * LWLockRelease. If so, loop back and wait again. Once we've - * gotten the LWLock, re-increment the sema by the number of - * additional signals received, so that the lock manager or signal - * manager will see the received signal when it next waits. + * manager and ProcWaitForSignal, and we may need to acquire an LWLock + * while one of those is pending, it is possible that we get awakened + * for a reason other than being signaled by LWLockRelease. If so, + * loop back and wait again. Once we've gotten the LWLock, + * re-increment the sema by the number of additional signals received, + * so that the lock manager or signal manager will see the received + * signal when it next waits. */ LOG_LWDEBUG("LWLockAcquire", lockid, "waiting"); @@ -414,9 +413,9 @@ LWLockConditionalAcquire(LWLockId lockid, LWLockMode mode) elog(ERROR, "too many LWLocks taken"); /* - * Lock out cancel/die interrupts until we exit the code section - * protected by the LWLock. This ensures that interrupts will not - * interfere with manipulations of data structures in shared memory. + * Lock out cancel/die interrupts until we exit the code section protected + * by the LWLock. This ensures that interrupts will not interfere with + * manipulations of data structures in shared memory. */ HOLD_INTERRUPTS(); @@ -477,8 +476,8 @@ LWLockRelease(LWLockId lockid) PRINT_LWDEBUG("LWLockRelease", lockid, lock); /* - * Remove lock from list of locks held. Usually, but not always, it - * will be the latest-acquired lock; so search array backwards. + * Remove lock from list of locks held. Usually, but not always, it will + * be the latest-acquired lock; so search array backwards. */ for (i = num_held_lwlocks; --i >= 0;) { @@ -504,10 +503,10 @@ LWLockRelease(LWLockId lockid) } /* - * See if I need to awaken any waiters. If I released a non-last - * shared hold, there cannot be anything to do. Also, do not awaken - * any waiters if someone has already awakened waiters that haven't - * yet acquired the lock. + * See if I need to awaken any waiters. If I released a non-last shared + * hold, there cannot be anything to do. Also, do not awaken any waiters + * if someone has already awakened waiters that haven't yet acquired the + * lock. */ head = lock->head; if (head != NULL) @@ -515,9 +514,9 @@ LWLockRelease(LWLockId lockid) if (lock->exclusive == 0 && lock->shared == 0 && lock->releaseOK) { /* - * Remove the to-be-awakened PGPROCs from the queue. If the - * front waiter wants exclusive lock, awaken him only. - * Otherwise awaken as many waiters as want shared access. + * Remove the to-be-awakened PGPROCs from the queue. If the front + * waiter wants exclusive lock, awaken him only. Otherwise awaken + * as many waiters as want shared access. */ proc = head; if (!proc->lwExclusive) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 6005cb7ee5..1c26a5934b 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/lmgr/proc.c,v 1.166 2005/10/13 06:24:05 neilc Exp $ + * $PostgreSQL: pgsql/src/backend/storage/lmgr/proc.c,v 1.167 2005/10/15 02:49:26 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -166,8 +166,7 @@ InitProcGlobal(void) ProcGlobal->spins_per_delay = DEFAULT_SPINS_PER_DELAY; /* - * Pre-create the PGPROC structures and create a semaphore for - * each. + * Pre-create the PGPROC structures and create a semaphore for each. */ procs = (PGPROC *) ShmemAlloc(MaxBackends * sizeof(PGPROC)); if (!procs) @@ -207,8 +206,8 @@ InitProcess(void) volatile PROC_HDR *procglobal = ProcGlobal; /* - * ProcGlobal should be set by a previous call to InitProcGlobal (if - * we are a backend, we inherit this by fork() from the postmaster). + * ProcGlobal should be set by a previous call to InitProcGlobal (if we + * are a backend, we inherit this by fork() from the postmaster). */ if (procglobal == NULL) elog(PANIC, "proc header uninitialized"); @@ -217,11 +216,11 @@ InitProcess(void) elog(ERROR, "you already exist"); /* - * Try to get a proc struct from the free list. If this fails, we - * must be out of PGPROC structures (not to mention semaphores). + * Try to get a proc struct from the free list. If this fails, we must be + * out of PGPROC structures (not to mention semaphores). * - * While we are holding the ProcStructLock, also copy the current - * shared estimate of spins_per_delay to local storage. + * While we are holding the ProcStructLock, also copy the current shared + * estimate of spins_per_delay to local storage. */ SpinLockAcquire(ProcStructLock); @@ -238,9 +237,9 @@ InitProcess(void) else { /* - * If we reach here, all the PGPROCs are in use. This is one of - * the possible places to detect "too many backends", so give the - * standard error message. + * If we reach here, all the PGPROCs are in use. This is one of the + * possible places to detect "too many backends", so give the standard + * error message. */ SpinLockRelease(ProcStructLock); ereport(FATAL, @@ -278,14 +277,14 @@ InitProcess(void) on_shmem_exit(ProcKill, 0); /* - * We might be reusing a semaphore that belonged to a failed process. - * So be careful and reinitialize its value here. + * We might be reusing a semaphore that belonged to a failed process. So + * be careful and reinitialize its value here. */ PGSemaphoreReset(&MyProc->sem); /* - * Now that we have a PGPROC, we could try to acquire locks, so - * initialize the deadlock checker. + * Now that we have a PGPROC, we could try to acquire locks, so initialize + * the deadlock checker. */ InitDeadLockChecking(); } @@ -322,8 +321,8 @@ InitDummyProcess(int proctype) * Just for paranoia's sake, we use the ProcStructLock to protect * assignment and releasing of DummyProcs entries. * - * While we are holding the ProcStructLock, also copy the current - * shared estimate of spins_per_delay to local storage. + * While we are holding the ProcStructLock, also copy the current shared + * estimate of spins_per_delay to local storage. */ SpinLockAcquire(ProcStructLock); @@ -347,8 +346,8 @@ InitDummyProcess(int proctype) SpinLockRelease(ProcStructLock); /* - * Initialize all fields of MyProc, except MyProc->sem which was set - * up by InitProcGlobal. + * Initialize all fields of MyProc, except MyProc->sem which was set up by + * InitProcGlobal. */ SHMQueueElemInit(&(MyProc->links)); MyProc->waitStatus = STATUS_OK; @@ -369,8 +368,8 @@ InitDummyProcess(int proctype) on_shmem_exit(DummyProcKill, Int32GetDatum(proctype)); /* - * We might be reusing a semaphore that belonged to a failed process. - * So be careful and reinitialize its value here. + * We might be reusing a semaphore that belonged to a failed process. So + * be careful and reinitialize its value here. */ PGSemaphoreReset(&MyProc->sem); } @@ -385,6 +384,7 @@ HaveNFreeProcs(int n) { SHMEM_OFFSET offset; PGPROC *proc; + /* use volatile pointer to prevent code rearrangement */ volatile PROC_HDR *procglobal = ProcGlobal; @@ -436,9 +436,9 @@ LockWaitCancel(void) { /* * Somebody kicked us off the lock queue already. Perhaps they - * granted us the lock, or perhaps they detected a deadlock. If - * they did grant us the lock, we'd better remember it in our - * local lock table. + * granted us the lock, or perhaps they detected a deadlock. If they + * did grant us the lock, we'd better remember it in our local lock + * table. */ if (MyProc->waitStatus == STATUS_OK) GrantAwaitedLock(); @@ -451,17 +451,17 @@ LockWaitCancel(void) /* * Reset the proc wait semaphore to zero. This is necessary in the * scenario where someone else granted us the lock we wanted before we - * were able to remove ourselves from the wait-list. The semaphore - * will have been bumped to 1 by the would-be grantor, and since we - * are no longer going to wait on the sema, we have to force it back - * to zero. Otherwise, our next attempt to wait for a lock will fall - * through prematurely. + * were able to remove ourselves from the wait-list. The semaphore will + * have been bumped to 1 by the would-be grantor, and since we are no + * longer going to wait on the sema, we have to force it back to zero. + * Otherwise, our next attempt to wait for a lock will fall through + * prematurely. */ PGSemaphoreReset(&MyProc->sem); /* - * Return true even if we were kicked off the lock before we were able - * to remove ourselves. + * Return true even if we were kicked off the lock before we were able to + * remove ourselves. */ return true; } @@ -508,8 +508,8 @@ ProcKill(int code, Datum arg) Assert(MyProc != NULL); /* - * Release any LW locks I am holding. There really shouldn't be any, - * but it's cheap to check again before we cut the knees off the LWLock + * Release any LW locks I am holding. There really shouldn't be any, but + * it's cheap to check again before we cut the knees off the LWLock * facility by releasing our PGPROC ... */ LWLockReleaseAll(); @@ -640,20 +640,19 @@ ProcSleep(LockMethod lockMethodTable, /* * Determine where to add myself in the wait queue. * - * Normally I should go at the end of the queue. However, if I already - * hold locks that conflict with the request of any previous waiter, - * put myself in the queue just in front of the first such waiter. - * This is not a necessary step, since deadlock detection would move - * me to before that waiter anyway; but it's relatively cheap to - * detect such a conflict immediately, and avoid delaying till - * deadlock timeout. + * Normally I should go at the end of the queue. However, if I already hold + * locks that conflict with the request of any previous waiter, put myself + * in the queue just in front of the first such waiter. This is not a + * necessary step, since deadlock detection would move me to before that + * waiter anyway; but it's relatively cheap to detect such a conflict + * immediately, and avoid delaying till deadlock timeout. * - * Special case: if I find I should go in front of some waiter, check to - * see if I conflict with already-held locks or the requests before - * that waiter. If not, then just grant myself the requested lock - * immediately. This is the same as the test for immediate grant in - * LockAcquire, except we are only considering the part of the wait - * queue before my insertion point. + * Special case: if I find I should go in front of some waiter, check to see + * if I conflict with already-held locks or the requests before that + * waiter. If not, then just grant myself the requested lock immediately. + * This is the same as the test for immediate grant in LockAcquire, except + * we are only considering the part of the wait queue before my insertion + * point. */ if (myHeldLocks != 0) { @@ -669,12 +668,11 @@ ProcSleep(LockMethod lockMethodTable, if (lockMethodTable->conflictTab[lockmode] & proc->heldLocks) { /* - * Yes, so we have a deadlock. Easiest way to clean - * up correctly is to call RemoveFromWaitQueue(), but - * we can't do that until we are *on* the wait queue. - * So, set a flag to check below, and break out of - * loop. Also, record deadlock info for later - * message. + * Yes, so we have a deadlock. Easiest way to clean up + * correctly is to call RemoveFromWaitQueue(), but we + * can't do that until we are *on* the wait queue. So, set + * a flag to check below, and break out of loop. Also, + * record deadlock info for later message. */ RememberSimpleDeadLock(MyProc, lockmode, lock, proc); early_deadlock = true; @@ -702,8 +700,8 @@ ProcSleep(LockMethod lockMethodTable, } /* - * If we fall out of loop normally, proc points to waitQueue head, - * so we will insert at tail of queue as desired. + * If we fall out of loop normally, proc points to waitQueue head, so + * we will insert at tail of queue as desired. */ } else @@ -713,8 +711,7 @@ ProcSleep(LockMethod lockMethodTable, } /* - * Insert self into queue, ahead of the given proc (or at tail of - * queue). + * Insert self into queue, ahead of the given proc (or at tail of queue). */ SHMQueueInsertBefore(&(proc->links), &(MyProc->links)); waitQueue->size++; @@ -729,9 +726,9 @@ ProcSleep(LockMethod lockMethodTable, MyProc->waitStatus = STATUS_ERROR; /* initialize result for error */ /* - * If we detected deadlock, give up without waiting. This must agree - * with CheckDeadLock's recovery code, except that we shouldn't - * release the semaphore since we haven't tried to lock it yet. + * If we detected deadlock, give up without waiting. This must agree with + * CheckDeadLock's recovery code, except that we shouldn't release the + * semaphore since we haven't tried to lock it yet. */ if (early_deadlock) { @@ -746,39 +743,38 @@ ProcSleep(LockMethod lockMethodTable, * Release the locktable's masterLock. * * NOTE: this may also cause us to exit critical-section state, possibly - * allowing a cancel/die interrupt to be accepted. This is OK because - * we have recorded the fact that we are waiting for a lock, and so + * allowing a cancel/die interrupt to be accepted. This is OK because we + * have recorded the fact that we are waiting for a lock, and so * LockWaitCancel will clean up if cancel/die happens. */ LWLockRelease(masterLock); /* - * Set timer so we can wake up after awhile and check for a deadlock. - * If a deadlock is detected, the handler releases the process's - * semaphore and sets MyProc->waitStatus = STATUS_ERROR, allowing us - * to know that we must report failure rather than success. + * Set timer so we can wake up after awhile and check for a deadlock. If a + * deadlock is detected, the handler releases the process's semaphore and + * sets MyProc->waitStatus = STATUS_ERROR, allowing us to know that we + * must report failure rather than success. * - * By delaying the check until we've waited for a bit, we can avoid - * running the rather expensive deadlock-check code in most cases. + * By delaying the check until we've waited for a bit, we can avoid running + * the rather expensive deadlock-check code in most cases. */ if (!enable_sig_alarm(DeadlockTimeout, false)) elog(FATAL, "could not set timer for process wakeup"); /* * If someone wakes us between LWLockRelease and PGSemaphoreLock, - * PGSemaphoreLock will not block. The wakeup is "saved" by the - * semaphore implementation. Note also that if CheckDeadLock is - * invoked but does not detect a deadlock, PGSemaphoreLock() will - * continue to wait. There used to be a loop here, but it was useless - * code... + * PGSemaphoreLock will not block. The wakeup is "saved" by the semaphore + * implementation. Note also that if CheckDeadLock is invoked but does + * not detect a deadlock, PGSemaphoreLock() will continue to wait. There + * used to be a loop here, but it was useless code... * - * We pass interruptOK = true, which eliminates a window in which - * cancel/die interrupts would be held off undesirably. This is a - * promise that we don't mind losing control to a cancel/die interrupt - * here. We don't, because we have no shared-state-change work to do - * after being granted the lock (the grantor did it all). We do have - * to worry about updating the locallock table, but if we lose control - * to an error, LockWaitCancel will fix that up. + * We pass interruptOK = true, which eliminates a window in which cancel/die + * interrupts would be held off undesirably. This is a promise that we + * don't mind losing control to a cancel/die interrupt here. We don't, + * because we have no shared-state-change work to do after being granted + * the lock (the grantor did it all). We do have to worry about updating + * the locallock table, but if we lose control to an error, LockWaitCancel + * will fix that up. */ PGSemaphoreLock(&MyProc->sem, true); @@ -789,9 +785,9 @@ ProcSleep(LockMethod lockMethodTable, elog(FATAL, "could not disable timer for process wakeup"); /* - * Re-acquire the locktable's masterLock. We have to do this to hold - * off cancel/die interrupts before we can mess with waitingForLock - * (else we might have a missed or duplicated locallock update). + * Re-acquire the locktable's masterLock. We have to do this to hold off + * cancel/die interrupts before we can mess with waitingForLock (else we + * might have a missed or duplicated locallock update). */ LWLockAcquire(masterLock, LW_EXCLUSIVE); @@ -879,8 +875,8 @@ ProcLockWakeup(LockMethod lockMethodTable, LOCK *lock) LOCKMODE lockmode = proc->waitLockMode; /* - * Waken if (a) doesn't conflict with requests of earlier waiters, - * and (b) doesn't conflict with already-held locks. + * Waken if (a) doesn't conflict with requests of earlier waiters, and + * (b) doesn't conflict with already-held locks. */ if ((lockMethodTable->conflictTab[lockmode] & aheadRequests) == 0 && LockCheckConflicts(lockMethodTable, @@ -894,16 +890,15 @@ ProcLockWakeup(LockMethod lockMethodTable, LOCK *lock) proc = ProcWakeup(proc, STATUS_OK); /* - * ProcWakeup removes proc from the lock's waiting process - * queue and returns the next proc in chain; don't use proc's - * next-link, because it's been cleared. + * ProcWakeup removes proc from the lock's waiting process queue + * and returns the next proc in chain; don't use proc's next-link, + * because it's been cleared. */ } else { /* - * Cannot wake this guy. Remember his request for later - * checks. + * Cannot wake this guy. Remember his request for later checks. */ aheadRequests |= LOCKBIT_ON(lockmode); proc = (PGPROC *) MAKE_PTR(proc->links.next); @@ -928,22 +923,21 @@ CheckDeadLock(void) * Acquire locktable lock. Note that the deadlock check interrupt had * better not be enabled anywhere that this process itself holds the * locktable lock, else this will wait forever. Also note that - * LWLockAcquire creates a critical section, so that this routine - * cannot be interrupted by cancel/die interrupts. + * LWLockAcquire creates a critical section, so that this routine cannot + * be interrupted by cancel/die interrupts. */ LWLockAcquire(LockMgrLock, LW_EXCLUSIVE); /* * Check to see if we've been awoken by anyone in the interim. * - * If we have we can return and resume our transaction -- happy day. - * Before we are awoken the process releasing the lock grants it to us - * so we know that we don't have to wait anymore. + * If we have we can return and resume our transaction -- happy day. Before + * we are awoken the process releasing the lock grants it to us so we know + * that we don't have to wait anymore. * * We check by looking to see if we've been unlinked from the wait queue. - * This is quicker than checking our semaphore's state, since no - * kernel call is needed, and it is safe because we hold the locktable - * lock. + * This is quicker than checking our semaphore's state, since no kernel + * call is needed, and it is safe because we hold the locktable lock. */ if (MyProc->links.prev == INVALID_OFFSET || MyProc->links.next == INVALID_OFFSET) @@ -972,8 +966,8 @@ CheckDeadLock(void) RemoveFromWaitQueue(MyProc); /* - * Set MyProc->waitStatus to STATUS_ERROR so that ProcSleep will - * report an error after we return from the signal handler. + * Set MyProc->waitStatus to STATUS_ERROR so that ProcSleep will report an + * error after we return from the signal handler. */ MyProc->waitStatus = STATUS_ERROR; @@ -984,14 +978,14 @@ CheckDeadLock(void) PGSemaphoreUnlock(&MyProc->sem); /* - * We're done here. Transaction abort caused by the error that - * ProcSleep will raise will cause any other locks we hold to be - * released, thus allowing other processes to wake up; we don't need - * to do that here. NOTE: an exception is that releasing locks we hold - * doesn't consider the possibility of waiters that were blocked - * behind us on the lock we just failed to get, and might now be - * wakable because we're not in front of them anymore. However, - * RemoveFromWaitQueue took care of waking up any such processes. + * We're done here. Transaction abort caused by the error that ProcSleep + * will raise will cause any other locks we hold to be released, thus + * allowing other processes to wake up; we don't need to do that here. + * NOTE: an exception is that releasing locks we hold doesn't consider the + * possibility of waiters that were blocked behind us on the lock we just + * failed to get, and might now be wakable because we're not in front of + * them anymore. However, RemoveFromWaitQueue took care of waking up any + * such processes. */ LWLockRelease(LockMgrLock); } @@ -1061,7 +1055,6 @@ enable_sig_alarm(int delayms, bool is_statement_timeout) #ifndef __BEOS__ struct itimerval timeval; - #else bigtime_t time_interval; #endif @@ -1092,16 +1085,16 @@ enable_sig_alarm(int delayms, bool is_statement_timeout) /* * Begin deadlock timeout with statement-level timeout active * - * Here, we want to interrupt at the closer of the two timeout times. - * If fin_time >= statement_fin_time then we need not touch the - * existing timer setting; else set up to interrupt at the - * deadlock timeout time. + * Here, we want to interrupt at the closer of the two timeout times. If + * fin_time >= statement_fin_time then we need not touch the existing + * timer setting; else set up to interrupt at the deadlock timeout + * time. * * NOTE: in this case it is possible that this routine will be * interrupted by the previously-set timer alarm. This is okay - * because the signal handler will do only what it should do - * according to the state variables. The deadlock checker may get - * run earlier than normal, but that does no harm. + * because the signal handler will do only what it should do according + * to the state variables. The deadlock checker may get run earlier + * than normal, but that does no harm. */ deadlock_timeout_active = true; if (fin_time.tv_sec > statement_fin_time.tv_sec || diff --git a/src/backend/storage/lmgr/s_lock.c b/src/backend/storage/lmgr/s_lock.c index 1fb069d4f3..f1c92d70da 100644 --- a/src/backend/storage/lmgr/s_lock.c +++ b/src/backend/storage/lmgr/s_lock.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/lmgr/s_lock.c,v 1.39 2005/10/11 20:41:32 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/storage/lmgr/s_lock.c,v 1.40 2005/10/15 02:49:26 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -50,47 +50,45 @@ void s_lock(volatile slock_t *lock, const char *file, int line) { /* - * We loop tightly for awhile, then delay using pg_usleep() and try - * again. Preferably, "awhile" should be a small multiple of the - * maximum time we expect a spinlock to be held. 100 iterations seems - * about right as an initial guess. However, on a uniprocessor the - * loop is a waste of cycles, while in a multi-CPU scenario it's usually - * better to spin a bit longer than to call the kernel, so we try to - * adapt the spin loop count depending on whether we seem to be in - * a uniprocessor or multiprocessor. + * We loop tightly for awhile, then delay using pg_usleep() and try again. + * Preferably, "awhile" should be a small multiple of the maximum time we + * expect a spinlock to be held. 100 iterations seems about right as an + * initial guess. However, on a uniprocessor the loop is a waste of + * cycles, while in a multi-CPU scenario it's usually better to spin a bit + * longer than to call the kernel, so we try to adapt the spin loop count + * depending on whether we seem to be in a uniprocessor or multiprocessor. * - * Note: you might think MIN_SPINS_PER_DELAY should be just 1, but you'd - * be wrong; there are platforms where that can result in a "stuck - * spinlock" failure. This has been seen particularly on Alphas; it - * seems that the first TAS after returning from kernel space will always - * fail on that hardware. + * Note: you might think MIN_SPINS_PER_DELAY should be just 1, but you'd be + * wrong; there are platforms where that can result in a "stuck spinlock" + * failure. This has been seen particularly on Alphas; it seems that the + * first TAS after returning from kernel space will always fail on that + * hardware. * - * Once we do decide to block, we use randomly increasing pg_usleep() - * delays. The first delay is 1 msec, then the delay randomly - * increases to about one second, after which we reset to 1 msec and - * start again. The idea here is that in the presence of heavy - * contention we need to increase the delay, else the spinlock holder - * may never get to run and release the lock. (Consider situation - * where spinlock holder has been nice'd down in priority by the - * scheduler --- it will not get scheduled until all would-be - * acquirers are sleeping, so if we always use a 1-msec sleep, there - * is a real possibility of starvation.) But we can't just clamp the - * delay to an upper bound, else it would take a long time to make a - * reasonable number of tries. + * Once we do decide to block, we use randomly increasing pg_usleep() delays. + * The first delay is 1 msec, then the delay randomly increases to about + * one second, after which we reset to 1 msec and start again. The idea + * here is that in the presence of heavy contention we need to increase + * the delay, else the spinlock holder may never get to run and release + * the lock. (Consider situation where spinlock holder has been nice'd + * down in priority by the scheduler --- it will not get scheduled until + * all would-be acquirers are sleeping, so if we always use a 1-msec + * sleep, there is a real possibility of starvation.) But we can't just + * clamp the delay to an upper bound, else it would take a long time to + * make a reasonable number of tries. * - * We time out and declare error after NUM_DELAYS delays (thus, exactly - * that many tries). With the given settings, this will usually take - * 2 or so minutes. It seems better to fix the total number of tries - * (and thus the probability of unintended failure) than to fix the - * total time spent. + * We time out and declare error after NUM_DELAYS delays (thus, exactly that + * many tries). With the given settings, this will usually take 2 or so + * minutes. It seems better to fix the total number of tries (and thus + * the probability of unintended failure) than to fix the total time + * spent. * - * The pg_usleep() delays are measured in milliseconds because 1 msec - * is a common resolution limit at the OS level for newer platforms. - * On older platforms the resolution limit is usually 10 msec, in - * which case the total delay before timeout will be a bit more. + * The pg_usleep() delays are measured in milliseconds because 1 msec is a + * common resolution limit at the OS level for newer platforms. On older + * platforms the resolution limit is usually 10 msec, in which case the + * total delay before timeout will be a bit more. */ -#define MIN_SPINS_PER_DELAY 10 -#define MAX_SPINS_PER_DELAY 1000 +#define MIN_SPINS_PER_DELAY 10 +#define MAX_SPINS_PER_DELAY 1000 #define NUM_DELAYS 1000 #define MIN_DELAY_MSEC 1 #define MAX_DELAY_MSEC 1000 @@ -110,7 +108,7 @@ s_lock(volatile slock_t *lock, const char *file, int line) if (++delays > NUM_DELAYS) s_lock_stuck(lock, file, line); - if (cur_delay == 0) /* first time to delay? */ + if (cur_delay == 0) /* first time to delay? */ cur_delay = MIN_DELAY_MSEC; pg_usleep(cur_delay * 1000L); @@ -122,7 +120,7 @@ s_lock(volatile slock_t *lock, const char *file, int line) /* increase delay by a random fraction between 1X and 2X */ cur_delay += (int) (cur_delay * - (((double) random()) / ((double) MAX_RANDOM_VALUE)) + 0.5); + (((double) random()) / ((double) MAX_RANDOM_VALUE)) + 0.5); /* wrap back to minimum delay when max is exceeded */ if (cur_delay > MAX_DELAY_MSEC) cur_delay = MIN_DELAY_MSEC; @@ -133,18 +131,18 @@ s_lock(volatile slock_t *lock, const char *file, int line) /* * If we were able to acquire the lock without delaying, it's a good - * indication we are in a multiprocessor. If we had to delay, it's - * a sign (but not a sure thing) that we are in a uniprocessor. - * Hence, we decrement spins_per_delay slowly when we had to delay, - * and increase it rapidly when we didn't. It's expected that - * spins_per_delay will converge to the minimum value on a uniprocessor - * and to the maximum value on a multiprocessor. + * indication we are in a multiprocessor. If we had to delay, it's a sign + * (but not a sure thing) that we are in a uniprocessor. Hence, we + * decrement spins_per_delay slowly when we had to delay, and increase it + * rapidly when we didn't. It's expected that spins_per_delay will + * converge to the minimum value on a uniprocessor and to the maximum + * value on a multiprocessor. * - * Note: spins_per_delay is local within our current process. - * We want to average these observations across multiple backends, - * since it's relatively rare for this function to even get entered, - * and so a single backend might not live long enough to converge on - * a good value. That is handled by the two routines below. + * Note: spins_per_delay is local within our current process. We want to + * average these observations across multiple backends, since it's + * relatively rare for this function to even get entered, and so a single + * backend might not live long enough to converge on a good value. That + * is handled by the two routines below. */ if (cur_delay == 0) { @@ -180,15 +178,14 @@ int update_spins_per_delay(int shared_spins_per_delay) { /* - * We use an exponential moving average with a relatively slow - * adaption rate, so that noise in any one backend's result won't - * affect the shared value too much. As long as both inputs are - * within the allowed range, the result must be too, so we need not - * worry about clamping the result. + * We use an exponential moving average with a relatively slow adaption + * rate, so that noise in any one backend's result won't affect the shared + * value too much. As long as both inputs are within the allowed range, + * the result must be too, so we need not worry about clamping the result. * - * We deliberately truncate rather than rounding; this is so that - * single adjustments inside a backend can affect the shared estimate - * (see the asymmetric adjustment rules above). + * We deliberately truncate rather than rounding; this is so that single + * adjustments inside a backend can affect the shared estimate (see the + * asymmetric adjustment rules above). */ return (shared_spins_per_delay * 15 + spins_per_delay) / 16; } @@ -227,7 +224,7 @@ tas_dummy() __asm__ __volatile__( #if defined(__NetBSD__) && defined(__ELF__) /* no underscore for label and % for registers */ - "\ + "\ .global tas \n\ tas: \n\ movel %sp@(0x4),%a0 \n\ @@ -239,7 +236,7 @@ _success: \n\ moveq #0,%d0 \n\ rts \n" #else - "\ + "\ .global _tas \n\ _tas: \n\ movel sp@(0x4),a0 \n\ @@ -251,11 +248,10 @@ _success: \n\ moveq #0,d0 \n\ rts \n" #endif /* __NetBSD__ && __ELF__ */ -); + ); } #endif /* __m68k__ && !__linux__ */ - #else /* not __GNUC__ */ /* diff --git a/src/backend/storage/lmgr/spin.c b/src/backend/storage/lmgr/spin.c index 4e7e47afcd..dfec2a7769 100644 --- a/src/backend/storage/lmgr/spin.c +++ b/src/backend/storage/lmgr/spin.c @@ -16,7 +16,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/lmgr/spin.c,v 1.16 2004/12/31 22:01:05 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/storage/lmgr/spin.c,v 1.17 2005/10/15 02:49:26 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -37,7 +37,6 @@ SpinlockSemas(void) { return 0; } - #else /* !HAVE_SPINLOCKS */ /* @@ -52,11 +51,11 @@ int SpinlockSemas(void) { /* - * It would be cleaner to distribute this logic into the affected - * modules, similar to the way shmem space estimation is handled. + * It would be cleaner to distribute this logic into the affected modules, + * similar to the way shmem space estimation is handled. * - * For now, though, we just need a few spinlocks (10 should be plenty) - * plus one for each LWLock. + * For now, though, we just need a few spinlocks (10 should be plenty) plus + * one for each LWLock. */ return NumLWLocks() + 10; } diff --git a/src/backend/storage/page/bufpage.c b/src/backend/storage/page/bufpage.c index 25ab0d0902..fd19fd8736 100644 --- a/src/backend/storage/page/bufpage.c +++ b/src/backend/storage/page/bufpage.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/page/bufpage.c,v 1.66 2005/09/22 16:45:59 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/storage/page/bufpage.c,v 1.67 2005/10/15 02:49:26 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -133,7 +133,7 @@ PageAddItem(Page page, ereport(PANIC, (errcode(ERRCODE_DATA_CORRUPTED), errmsg("corrupted page pointers: lower = %u, upper = %u, special = %u", - phdr->pd_lower, phdr->pd_upper, phdr->pd_special))); + phdr->pd_lower, phdr->pd_upper, phdr->pd_special))); /* * Select offsetNumber to place the new item at @@ -184,8 +184,8 @@ PageAddItem(Page page, /* * Compute new lower and upper pointers for page, see if it'll fit. * - * Note: do arithmetic as signed ints, to avoid mistakes if, say, - * alignedSize > pd_upper. + * Note: do arithmetic as signed ints, to avoid mistakes if, say, alignedSize + * > pd_upper. */ if (offsetNumber == limit || needshuffle) lower = phdr->pd_lower + sizeof(ItemIdData); @@ -200,8 +200,7 @@ PageAddItem(Page page, return InvalidOffsetNumber; /* - * OK to insert the item. First, shuffle the existing pointers if - * needed. + * OK to insert the item. First, shuffle the existing pointers if needed. */ itemId = PageGetItemId(phdr, offsetNumber); @@ -318,11 +317,11 @@ PageRepairFragmentation(Page page, OffsetNumber *unused) Offset upper; /* - * It's worth the trouble to be more paranoid here than in most - * places, because we are about to reshuffle data in (what is usually) - * a shared disk buffer. If we aren't careful then corrupted - * pointers, lengths, etc could cause us to clobber adjacent disk - * buffers, spreading the data loss further. So, check everything. + * It's worth the trouble to be more paranoid here than in most places, + * because we are about to reshuffle data in (what is usually) a shared + * disk buffer. If we aren't careful then corrupted pointers, lengths, + * etc could cause us to clobber adjacent disk buffers, spreading the data + * loss further. So, check everything. */ if (pd_lower < SizeOfPageHeaderData || pd_lower > pd_upper || @@ -389,8 +388,8 @@ PageRepairFragmentation(Page page, OffsetNumber *unused) if (totallen > (Size) (pd_special - pd_lower)) ereport(ERROR, (errcode(ERRCODE_DATA_CORRUPTED), - errmsg("corrupted item lengths: total %u, available space %u", - (unsigned int) totallen, pd_special - pd_lower))); + errmsg("corrupted item lengths: total %u, available space %u", + (unsigned int) totallen, pd_special - pd_lower))); /* sort itemIdSortData array into decreasing itemoff order */ qsort((char *) itemidbase, nused, sizeof(itemIdSortData), @@ -470,7 +469,7 @@ PageIndexTupleDelete(Page page, OffsetNumber offnum) ereport(ERROR, (errcode(ERRCODE_DATA_CORRUPTED), errmsg("corrupted page pointers: lower = %u, upper = %u, special = %u", - phdr->pd_lower, phdr->pd_upper, phdr->pd_special))); + phdr->pd_lower, phdr->pd_upper, phdr->pd_special))); nline = PageGetMaxOffsetNumber(page); if ((int) offnum <= 0 || (int) offnum > nline) @@ -491,10 +490,10 @@ PageIndexTupleDelete(Page page, OffsetNumber offnum) offset, (unsigned int) size))); /* - * First, we want to get rid of the pd_linp entry for the index tuple. - * We copy all subsequent linp's back one slot in the array. We don't - * use PageGetItemId, because we are manipulating the _array_, not - * individual linp's. + * First, we want to get rid of the pd_linp entry for the index tuple. We + * copy all subsequent linp's back one slot in the array. We don't use + * PageGetItemId, because we are manipulating the _array_, not individual + * linp's. */ nbytes = phdr->pd_lower - ((char *) &phdr->pd_linp[offidx + 1] - (char *) phdr); @@ -506,11 +505,10 @@ PageIndexTupleDelete(Page page, OffsetNumber offnum) /* * Now move everything between the old upper bound (beginning of tuple - * space) and the beginning of the deleted tuple forward, so that - * space in the middle of the page is left free. If we've just - * deleted the tuple at the beginning of tuple space, then there's no - * need to do the copy (and bcopy on some architectures SEGV's if - * asked to move zero bytes). + * space) and the beginning of the deleted tuple forward, so that space in + * the middle of the page is left free. If we've just deleted the tuple + * at the beginning of tuple space, then there's no need to do the copy + * (and bcopy on some architectures SEGV's if asked to move zero bytes). */ /* beginning of tuple space */ @@ -526,8 +524,8 @@ PageIndexTupleDelete(Page page, OffsetNumber offnum) /* * Finally, we need to adjust the linp entries that remain. * - * Anything that used to be before the deleted tuple's data was moved - * forward by the size of the deleted tuple. + * Anything that used to be before the deleted tuple's data was moved forward + * by the size of the deleted tuple. */ if (!PageIsEmpty(page)) { @@ -549,7 +547,7 @@ PageIndexTupleDelete(Page page, OffsetNumber offnum) * PageIndexMultiDelete * * This routine handles the case of deleting multiple tuples from an - * index page at once. It is considerably faster than a loop around + * index page at once. It is considerably faster than a loop around * PageIndexTupleDelete ... however, the caller *must* supply the array * of item numbers to be deleted in item number order! */ @@ -599,12 +597,12 @@ PageIndexMultiDelete(Page page, OffsetNumber *itemnos, int nitems) ereport(ERROR, (errcode(ERRCODE_DATA_CORRUPTED), errmsg("corrupted page pointers: lower = %u, upper = %u, special = %u", - pd_lower, pd_upper, pd_special))); + pd_lower, pd_upper, pd_special))); /* - * Scan the item pointer array and build a list of just the ones we - * are going to keep. Notice we do not modify the page yet, since - * we are still validity-checking. + * Scan the item pointer array and build a list of just the ones we are + * going to keep. Notice we do not modify the page yet, since we are + * still validity-checking. */ nline = PageGetMaxOffsetNumber(page); itemidbase = (itemIdSort) palloc(sizeof(itemIdSortData) * nline); @@ -632,7 +630,7 @@ PageIndexMultiDelete(Page page, OffsetNumber *itemnos, int nitems) } else { - itemidptr->offsetindex = nused; /* where it will go */ + itemidptr->offsetindex = nused; /* where it will go */ itemidptr->itemoff = offset; itemidptr->olditemid = *lp; itemidptr->alignedlen = MAXALIGN(size); @@ -649,8 +647,8 @@ PageIndexMultiDelete(Page page, OffsetNumber *itemnos, int nitems) if (totallen > (Size) (pd_special - pd_lower)) ereport(ERROR, (errcode(ERRCODE_DATA_CORRUPTED), - errmsg("corrupted item lengths: total %u, available space %u", - (unsigned int) totallen, pd_special - pd_lower))); + errmsg("corrupted item lengths: total %u, available space %u", + (unsigned int) totallen, pd_special - pd_lower))); /* sort itemIdSortData array into decreasing itemoff order */ qsort((char *) itemidbase, nused, sizeof(itemIdSortData), diff --git a/src/backend/storage/smgr/md.c b/src/backend/storage/smgr/md.c index 3a0a1f1262..f8d15ee3ff 100644 --- a/src/backend/storage/smgr/md.c +++ b/src/backend/storage/smgr/md.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/smgr/md.c,v 1.117 2005/07/04 04:51:49 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/storage/smgr/md.c,v 1.118 2005/10/15 02:49:26 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -114,9 +114,9 @@ mdinit(void) ALLOCSET_DEFAULT_MAXSIZE); /* - * Create pending-operations hashtable if we need it. Currently, we - * need it if we are standalone (not under a postmaster) OR if we are - * a bootstrap-mode subprocess of a postmaster (that is, a startup or + * Create pending-operations hashtable if we need it. Currently, we need + * it if we are standalone (not under a postmaster) OR if we are a + * bootstrap-mode subprocess of a postmaster (that is, a startup or * bgwriter process). */ if (!IsUnderPostmaster || IsBootstrapProcessingMode()) @@ -131,7 +131,7 @@ mdinit(void) pendingOpsTable = hash_create("Pending Ops Table", 100L, &hash_ctl, - HASH_ELEM | HASH_FUNCTION | HASH_CONTEXT); + HASH_ELEM | HASH_FUNCTION | HASH_CONTEXT); } return true; @@ -162,11 +162,10 @@ mdcreate(SMgrRelation reln, bool isRedo) int save_errno = errno; /* - * During bootstrap, there are cases where a system relation will - * be accessed (by internal backend processes) before the - * bootstrap script nominally creates it. Therefore, allow the - * file to exist already, even if isRedo is not set. (See also - * mdopen) + * During bootstrap, there are cases where a system relation will be + * accessed (by internal backend processes) before the bootstrap + * script nominally creates it. Therefore, allow the file to exist + * already, even if isRedo is not set. (See also mdopen) */ if (isRedo || IsBootstrapProcessingMode()) fd = PathNameOpenFile(path, O_RDWR | PG_BINARY, 0600); @@ -283,13 +282,13 @@ mdextend(SMgrRelation reln, BlockNumber blocknum, char *buffer, bool isTemp) #endif /* - * Note: because caller obtained blocknum by calling _mdnblocks, which - * did a seek(SEEK_END), this seek is often redundant and will be - * optimized away by fd.c. It's not redundant, however, if there is a - * partial page at the end of the file. In that case we want to try - * to overwrite the partial page with a full page. It's also not - * redundant if bufmgr.c had to dump another buffer of the same file - * to make room for the new page's buffer. + * Note: because caller obtained blocknum by calling _mdnblocks, which did + * a seek(SEEK_END), this seek is often redundant and will be optimized + * away by fd.c. It's not redundant, however, if there is a partial page + * at the end of the file. In that case we want to try to overwrite the + * partial page with a full page. It's also not redundant if bufmgr.c had + * to dump another buffer of the same file to make room for the new page's + * buffer. */ if (FileSeek(v->mdfd_vfd, seekpos, SEEK_SET) != seekpos) return false; @@ -345,11 +344,10 @@ mdopen(SMgrRelation reln, bool allowNotFound) if (fd < 0) { /* - * During bootstrap, there are cases where a system relation will - * be accessed (by internal backend processes) before the - * bootstrap script nominally creates it. Therefore, accept - * mdopen() as a substitute for mdcreate() in bootstrap mode only. - * (See mdcreate) + * During bootstrap, there are cases where a system relation will be + * accessed (by internal backend processes) before the bootstrap + * script nominally creates it. Therefore, accept mdopen() as a + * substitute for mdcreate() in bootstrap mode only. (See mdcreate) */ if (IsBootstrapProcessingMode()) fd = PathNameOpenFile(path, O_RDWR | O_CREAT | O_EXCL | PG_BINARY, 0600); @@ -445,8 +443,8 @@ mdread(SMgrRelation reln, BlockNumber blocknum, char *buffer) if ((nbytes = FileRead(v->mdfd_vfd, buffer, BLCKSZ)) != BLCKSZ) { /* - * If we are at or past EOF, return zeroes without complaining. - * Also substitute zeroes if we found a partial block at EOF. + * If we are at or past EOF, return zeroes without complaining. Also + * substitute zeroes if we found a partial block at EOF. * * XXX this is really ugly, bad design. However the current * implementation of hash indexes requires it, because hash index @@ -515,13 +513,12 @@ mdnblocks(SMgrRelation reln) BlockNumber segno = 0; /* - * Skip through any segments that aren't the last one, to avoid - * redundant seeks on them. We have previously verified that these - * segments are exactly RELSEG_SIZE long, and it's useless to recheck - * that each time. (NOTE: this assumption could only be wrong if - * another backend has truncated the relation. We rely on higher code - * levels to handle that scenario by closing and re-opening the md - * fd.) + * Skip through any segments that aren't the last one, to avoid redundant + * seeks on them. We have previously verified that these segments are + * exactly RELSEG_SIZE long, and it's useless to recheck that each time. + * (NOTE: this assumption could only be wrong if another backend has + * truncated the relation. We rely on higher code levels to handle that + * scenario by closing and re-opening the md fd.) */ while (v->mdfd_chain != NULL) { @@ -545,11 +542,10 @@ mdnblocks(SMgrRelation reln) if (v->mdfd_chain == NULL) { /* - * Because we pass O_CREAT, we will create the next segment - * (with zero length) immediately, if the last segment is of - * length REL_SEGSIZE. This is unnecessary but harmless, and - * testing for the case would take more cycles than it seems - * worth. + * Because we pass O_CREAT, we will create the next segment (with + * zero length) immediately, if the last segment is of length + * REL_SEGSIZE. This is unnecessary but harmless, and testing for + * the case would take more cycles than it seems worth. */ v->mdfd_chain = _mdfd_openseg(reln, segno, O_CREAT); if (v->mdfd_chain == NULL) @@ -601,11 +597,11 @@ mdtruncate(SMgrRelation reln, BlockNumber nblocks, bool isTemp) if (priorblocks > nblocks) { /* - * This segment is no longer wanted at all (and has already - * been unlinked from the mdfd_chain). We truncate the file - * before deleting it because if other backends are holding - * the file open, the unlink will fail on some platforms. - * Better a zero-size file gets left around than a big file... + * This segment is no longer wanted at all (and has already been + * unlinked from the mdfd_chain). We truncate the file before + * deleting it because if other backends are holding the file + * open, the unlink will fail on some platforms. Better a + * zero-size file gets left around than a big file... */ FileTruncate(v->mdfd_vfd, 0); FileUnlink(v->mdfd_vfd); @@ -616,12 +612,12 @@ mdtruncate(SMgrRelation reln, BlockNumber nblocks, bool isTemp) else if (priorblocks + ((BlockNumber) RELSEG_SIZE) > nblocks) { /* - * This is the last segment we want to keep. Truncate the file - * to the right length, and clear chain link that points to - * any remaining segments (which we shall zap). NOTE: if - * nblocks is exactly a multiple K of RELSEG_SIZE, we will - * truncate the K+1st segment to 0 length but keep it. This is - * mainly so that the right thing happens if nblocks==0. + * This is the last segment we want to keep. Truncate the file to + * the right length, and clear chain link that points to any + * remaining segments (which we shall zap). NOTE: if nblocks is + * exactly a multiple K of RELSEG_SIZE, we will truncate the K+1st + * segment to 0 length but keep it. This is mainly so that the + * right thing happens if nblocks==0. */ BlockNumber lastsegblocks = nblocks - priorblocks; @@ -638,8 +634,8 @@ mdtruncate(SMgrRelation reln, BlockNumber nblocks, bool isTemp) else { /* - * We still need this segment and 0 or more blocks beyond it, - * so nothing to do here. + * We still need this segment and 0 or more blocks beyond it, so + * nothing to do here. */ v = v->mdfd_chain; } @@ -712,9 +708,9 @@ mdsync(void) /* * If we are in the bgwriter, the sync had better include all fsync - * requests that were queued by backends before the checkpoint REDO - * point was determined. We go that a little better by accepting all - * requests queued up to the point where we start fsync'ing. + * requests that were queued by backends before the checkpoint REDO point + * was determined. We go that a little better by accepting all requests + * queued up to the point where we start fsync'ing. */ AbsorbFsyncRequests(); @@ -722,9 +718,9 @@ mdsync(void) while ((entry = (PendingOperationEntry *) hash_seq_search(&hstat)) != NULL) { /* - * If fsync is off then we don't have to bother opening the file - * at all. (We delay checking until this point so that changing - * fsync on the fly behaves sensibly.) + * If fsync is off then we don't have to bother opening the file at + * all. (We delay checking until this point so that changing fsync on + * the fly behaves sensibly.) */ if (enableFsync) { @@ -732,28 +728,28 @@ mdsync(void) MdfdVec *seg; /* - * Find or create an smgr hash entry for this relation. This - * may seem a bit unclean -- md calling smgr? But it's really - * the best solution. It ensures that the open file reference - * isn't permanently leaked if we get an error here. (You may - * say "but an unreferenced SMgrRelation is still a leak!" Not - * really, because the only case in which a checkpoint is done - * by a process that isn't about to shut down is in the - * bgwriter, and it will periodically do smgrcloseall(). This - * fact justifies our not closing the reln in the success path - * either, which is a good thing since in non-bgwriter cases - * we couldn't safely do that.) Furthermore, in many cases - * the relation will have been dirtied through this same smgr - * relation, and so we can save a file open/close cycle. + * Find or create an smgr hash entry for this relation. This may + * seem a bit unclean -- md calling smgr? But it's really the + * best solution. It ensures that the open file reference isn't + * permanently leaked if we get an error here. (You may say "but + * an unreferenced SMgrRelation is still a leak!" Not really, + * because the only case in which a checkpoint is done by a + * process that isn't about to shut down is in the bgwriter, and + * it will periodically do smgrcloseall(). This fact justifies + * our not closing the reln in the success path either, which is a + * good thing since in non-bgwriter cases we couldn't safely do + * that.) Furthermore, in many cases the relation will have been + * dirtied through this same smgr relation, and so we can save a + * file open/close cycle. */ reln = smgropen(entry->rnode); /* - * It is possible that the relation has been dropped or - * truncated since the fsync request was entered. Therefore, - * we have to allow file-not-found errors. This applies both - * during _mdfd_getseg() and during FileSync, since fd.c might - * have closed the file behind our back. + * It is possible that the relation has been dropped or truncated + * since the fsync request was entered. Therefore, we have to + * allow file-not-found errors. This applies both during + * _mdfd_getseg() and during FileSync, since fd.c might have + * closed the file behind our back. */ seg = _mdfd_getseg(reln, entry->segno * ((BlockNumber) RELSEG_SIZE), @@ -925,26 +921,25 @@ _mdfd_getseg(SMgrRelation reln, BlockNumber blkno, bool allowNotFound) { /* * We will create the next segment only if the target block is - * within it. This prevents Sorcerer's Apprentice syndrome if - * a bug at higher levels causes us to be handed a - * ridiculously large blkno --- otherwise we could create many - * thousands of empty segment files before reaching the - * "target" block. We should never need to create more than - * one new segment per call, so this restriction seems - * reasonable. + * within it. This prevents Sorcerer's Apprentice syndrome if a + * bug at higher levels causes us to be handed a ridiculously + * large blkno --- otherwise we could create many thousands of + * empty segment files before reaching the "target" block. We + * should never need to create more than one new segment per call, + * so this restriction seems reasonable. * * BUT: when doing WAL recovery, disable this logic and create - * segments unconditionally. In this case it seems better - * to assume the given blkno is good (it presumably came from - * a CRC-checked WAL record); furthermore this lets us cope - * in the case where we are replaying WAL data that has a write - * into a high-numbered segment of a relation that was later - * deleted. We want to go ahead and create the segments so - * we can finish out the replay. + * segments unconditionally. In this case it seems better to + * assume the given blkno is good (it presumably came from a + * CRC-checked WAL record); furthermore this lets us cope in the + * case where we are replaying WAL data that has a write into a + * high-numbered segment of a relation that was later deleted. We + * want to go ahead and create the segments so we can finish out + * the replay. */ v->mdfd_chain = _mdfd_openseg(reln, nextsegno, - (segstogo == 1 || InRecovery) ? O_CREAT : 0); + (segstogo == 1 || InRecovery) ? O_CREAT : 0); if (v->mdfd_chain == NULL) { if (allowNotFound && errno == ENOENT) diff --git a/src/backend/storage/smgr/smgr.c b/src/backend/storage/smgr/smgr.c index ac1767588d..17d14e3870 100644 --- a/src/backend/storage/smgr/smgr.c +++ b/src/backend/storage/smgr/smgr.c @@ -11,7 +11,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/smgr/smgr.c,v 1.92 2005/08/08 03:12:02 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/storage/smgr/smgr.c,v 1.93 2005/10/15 02:49:26 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -155,7 +155,7 @@ smgrinit(void) if (!(*(smgrsw[i].smgr_init)) ()) elog(FATAL, "smgr initialization failed on %s: %m", DatumGetCString(DirectFunctionCall1(smgrout, - Int16GetDatum(i)))); + Int16GetDatum(i)))); } } @@ -178,7 +178,7 @@ smgrshutdown(int code, Datum arg) if (!(*(smgrsw[i].smgr_shutdown)) ()) elog(FATAL, "smgr shutdown failed on %s: %m", DatumGetCString(DirectFunctionCall1(smgrout, - Int16GetDatum(i)))); + Int16GetDatum(i)))); } } } @@ -234,8 +234,8 @@ void smgrsetowner(SMgrRelation *owner, SMgrRelation reln) { /* - * First, unhook any old owner. (Normally there shouldn't be any, but - * it seems possible that this can happen during swap_relation_files() + * First, unhook any old owner. (Normally there shouldn't be any, but it + * seems possible that this can happen during swap_relation_files() * depending on the order of processing. It's ok to close the old * relcache entry early in that case.) */ @@ -271,9 +271,8 @@ smgrclose(SMgrRelation reln) elog(ERROR, "SMgrRelation hashtable corrupted"); /* - * Unhook the owner pointer, if any. We do this last since in the - * remote possibility of failure above, the SMgrRelation object will still - * exist. + * Unhook the owner pointer, if any. We do this last since in the remote + * possibility of failure above, the SMgrRelation object will still exist. */ if (owner) *owner = NULL; @@ -345,11 +344,10 @@ smgrcreate(SMgrRelation reln, bool isTemp, bool isRedo) * We may be using the target table space for the first time in this * database, so create a per-database subdirectory if needed. * - * XXX this is a fairly ugly violation of module layering, but this seems - * to be the best place to put the check. Maybe - * TablespaceCreateDbspace should be here and not in - * commands/tablespace.c? But that would imply importing a lot of - * stuff that smgr.c oughtn't know, either. + * XXX this is a fairly ugly violation of module layering, but this seems to + * be the best place to put the check. Maybe TablespaceCreateDbspace + * should be here and not in commands/tablespace.c? But that would imply + * importing a lot of stuff that smgr.c oughtn't know, either. */ TablespaceCreateDbspace(reln->smgr_rnode.spcNode, reln->smgr_rnode.dbNode, @@ -368,9 +366,8 @@ smgrcreate(SMgrRelation reln, bool isTemp, bool isRedo) /* * Make a non-transactional XLOG entry showing the file creation. It's - * non-transactional because we should replay it whether the - * transaction commits or not; if not, the file will be dropped at - * abort time. + * non-transactional because we should replay it whether the transaction + * commits or not; if not, the file will be dropped at abort time. */ xlrec.rnode = reln->smgr_rnode; @@ -418,13 +415,13 @@ smgrscheduleunlink(SMgrRelation reln, bool isTemp) pendingDeletes = pending; /* - * NOTE: if the relation was created in this transaction, it will now - * be present in the pending-delete list twice, once with atCommit - * true and once with atCommit false. Hence, it will be physically - * deleted at end of xact in either case (and the other entry will be - * ignored by smgrDoPendingDeletes, so no error will occur). We could - * instead remove the existing list entry and delete the physical file - * immediately, but for now I'll keep the logic simple. + * NOTE: if the relation was created in this transaction, it will now be + * present in the pending-delete list twice, once with atCommit true and + * once with atCommit false. Hence, it will be physically deleted at end + * of xact in either case (and the other entry will be ignored by + * smgrDoPendingDeletes, so no error will occur). We could instead remove + * the existing list entry and delete the physical file immediately, but + * for now I'll keep the logic simple. */ /* Now close the file and throw away the hashtable entry */ @@ -467,17 +464,16 @@ smgr_internal_unlink(RelFileNode rnode, int which, bool isTemp, bool isRedo) DropRelFileNodeBuffers(rnode, isTemp, 0); /* - * Tell the free space map to forget this relation. It won't be - * accessed any more anyway, but we may as well recycle the map space - * quickly. + * Tell the free space map to forget this relation. It won't be accessed + * any more anyway, but we may as well recycle the map space quickly. */ FreeSpaceMapForgetRel(&rnode); /* * And delete the physical files. * - * Note: we treat deletion failure as a WARNING, not an error, because - * we've already decided to commit or abort the current xact. + * Note: we treat deletion failure as a WARNING, not an error, because we've + * already decided to commit or abort the current xact. */ if (!(*(smgrsw[which].smgr_unlink)) (rnode, isRedo)) ereport(WARNING, @@ -524,11 +520,11 @@ smgrread(SMgrRelation reln, BlockNumber blocknum, char *buffer) if (!(*(smgrsw[reln->smgr_which].smgr_read)) (reln, blocknum, buffer)) ereport(ERROR, (errcode_for_file_access(), - errmsg("could not read block %u of relation %u/%u/%u: %m", - blocknum, - reln->smgr_rnode.spcNode, - reln->smgr_rnode.dbNode, - reln->smgr_rnode.relNode))); + errmsg("could not read block %u of relation %u/%u/%u: %m", + blocknum, + reln->smgr_rnode.spcNode, + reln->smgr_rnode.dbNode, + reln->smgr_rnode.relNode))); } /* @@ -549,11 +545,11 @@ smgrwrite(SMgrRelation reln, BlockNumber blocknum, char *buffer, bool isTemp) isTemp)) ereport(ERROR, (errcode_for_file_access(), - errmsg("could not write block %u of relation %u/%u/%u: %m", - blocknum, - reln->smgr_rnode.spcNode, - reln->smgr_rnode.dbNode, - reln->smgr_rnode.relNode))); + errmsg("could not write block %u of relation %u/%u/%u: %m", + blocknum, + reln->smgr_rnode.spcNode, + reln->smgr_rnode.dbNode, + reln->smgr_rnode.relNode))); } /* @@ -600,15 +596,15 @@ smgrtruncate(SMgrRelation reln, BlockNumber nblocks, bool isTemp) BlockNumber newblks; /* - * Get rid of any buffers for the about-to-be-deleted blocks. - * bufmgr will just drop them without bothering to write the contents. + * Get rid of any buffers for the about-to-be-deleted blocks. bufmgr will + * just drop them without bothering to write the contents. */ DropRelFileNodeBuffers(reln->smgr_rnode, isTemp, nblocks); /* - * Tell the free space map to forget anything it may have stored for - * the about-to-be-deleted blocks. We want to be sure it won't return - * bogus block numbers later on. + * Tell the free space map to forget anything it may have stored for the + * about-to-be-deleted blocks. We want to be sure it won't return bogus + * block numbers later on. */ FreeSpaceMapTruncateRel(&reln->smgr_rnode, nblocks); @@ -618,19 +614,19 @@ smgrtruncate(SMgrRelation reln, BlockNumber nblocks, bool isTemp) if (newblks == InvalidBlockNumber) ereport(ERROR, (errcode_for_file_access(), - errmsg("could not truncate relation %u/%u/%u to %u blocks: %m", - reln->smgr_rnode.spcNode, - reln->smgr_rnode.dbNode, - reln->smgr_rnode.relNode, - nblocks))); + errmsg("could not truncate relation %u/%u/%u to %u blocks: %m", + reln->smgr_rnode.spcNode, + reln->smgr_rnode.dbNode, + reln->smgr_rnode.relNode, + nblocks))); if (!isTemp) { /* - * Make a non-transactional XLOG entry showing the file - * truncation. It's non-transactional because we should replay it - * whether the transaction commits or not; the underlying file - * change is certainly not reversible. + * Make a non-transactional XLOG entry showing the file truncation. + * It's non-transactional because we should replay it whether the + * transaction commits or not; the underlying file change is certainly + * not reversible. */ XLogRecPtr lsn; XLogRecData rdata; @@ -841,7 +837,7 @@ smgrcommit(void) if (!(*(smgrsw[i].smgr_commit)) ()) elog(ERROR, "transaction commit failed on %s: %m", DatumGetCString(DirectFunctionCall1(smgrout, - Int16GetDatum(i)))); + Int16GetDatum(i)))); } } } @@ -861,7 +857,7 @@ smgrabort(void) if (!(*(smgrsw[i].smgr_abort)) ()) elog(ERROR, "transaction abort failed on %s: %m", DatumGetCString(DirectFunctionCall1(smgrout, - Int16GetDatum(i)))); + Int16GetDatum(i)))); } } } @@ -881,7 +877,7 @@ smgrsync(void) if (!(*(smgrsw[i].smgr_sync)) ()) elog(ERROR, "storage sync failed on %s: %m", DatumGetCString(DirectFunctionCall1(smgrout, - Int16GetDatum(i)))); + Int16GetDatum(i)))); } } } @@ -912,30 +908,30 @@ smgr_redo(XLogRecPtr lsn, XLogRecord *record) /* * First, force bufmgr to drop any buffers it has for the to-be- - * truncated blocks. We must do this, else subsequent - * XLogReadBuffer operations will not re-extend the file properly. + * truncated blocks. We must do this, else subsequent XLogReadBuffer + * operations will not re-extend the file properly. */ DropRelFileNodeBuffers(xlrec->rnode, false, xlrec->blkno); /* - * Tell the free space map to forget anything it may have stored - * for the about-to-be-deleted blocks. We want to be sure it - * won't return bogus block numbers later on. + * Tell the free space map to forget anything it may have stored for + * the about-to-be-deleted blocks. We want to be sure it won't return + * bogus block numbers later on. */ FreeSpaceMapTruncateRel(&reln->smgr_rnode, xlrec->blkno); /* Do the truncation */ newblks = (*(smgrsw[reln->smgr_which].smgr_truncate)) (reln, - xlrec->blkno, + xlrec->blkno, false); if (newblks == InvalidBlockNumber) ereport(WARNING, (errcode_for_file_access(), - errmsg("could not truncate relation %u/%u/%u to %u blocks: %m", - reln->smgr_rnode.spcNode, - reln->smgr_rnode.dbNode, - reln->smgr_rnode.relNode, - xlrec->blkno))); + errmsg("could not truncate relation %u/%u/%u to %u blocks: %m", + reln->smgr_rnode.spcNode, + reln->smgr_rnode.dbNode, + reln->smgr_rnode.relNode, + xlrec->blkno))); } else elog(PANIC, "smgr_redo: unknown op code %u", info); diff --git a/src/backend/tcop/dest.c b/src/backend/tcop/dest.c index 2b60c2c46e..da164ecd0b 100644 --- a/src/backend/tcop/dest.c +++ b/src/backend/tcop/dest.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/tcop/dest.c,v 1.65 2005/03/16 21:38:08 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/tcop/dest.c,v 1.66 2005/10/15 02:49:26 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -173,9 +173,8 @@ NullCommand(CommandDest dest) case RemoteExecute: /* - * tell the fe that we saw an empty query string. In - * protocols before 3.0 this has a useless empty-string - * message body. + * tell the fe that we saw an empty query string. In protocols + * before 3.0 this has a useless empty-string message body. */ if (PG_PROTOCOL_MAJOR(FrontendProtocol) >= 3) pq_putemptymessage('I'); diff --git a/src/backend/tcop/fastpath.c b/src/backend/tcop/fastpath.c index fa105c560e..7c7de52e57 100644 --- a/src/backend/tcop/fastpath.c +++ b/src/backend/tcop/fastpath.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/tcop/fastpath.c,v 1.82 2005/09/24 17:53:15 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/tcop/fastpath.c,v 1.83 2005/10/15 02:49:26 momjian Exp $ * * NOTES * This cruft is the server side of PQfn. @@ -103,8 +103,8 @@ GetOldFunctionMessage(StringInfo buf) /* FATAL here since no hope of regaining message sync */ ereport(FATAL, (errcode(ERRCODE_PROTOCOL_VIOLATION), - errmsg("invalid argument size %d in function call message", - argsize))); + errmsg("invalid argument size %d in function call message", + argsize))); } /* and arg contents */ if (argsize > 0) @@ -204,11 +204,10 @@ fetch_fp_info(Oid func_id, struct fp_info * fip) /* * Since the validity of this structure is determined by whether the * funcid is OK, we clear the funcid here. It must not be set to the - * correct value until we are about to return with a good struct - * fp_info, since we can be interrupted (i.e., with an ereport(ERROR, - * ...)) at any time. [No longer really an issue since we don't save - * the struct fp_info across transactions anymore, but keep it - * anyway.] + * correct value until we are about to return with a good struct fp_info, + * since we can be interrupted (i.e., with an ereport(ERROR, ...)) at any + * time. [No longer really an issue since we don't save the struct + * fp_info across transactions anymore, but keep it anyway.] */ MemSet(fip, 0, sizeof(struct fp_info)); fip->funcid = InvalidOid; @@ -294,14 +293,14 @@ HandleFunctionRequest(StringInfo msgBuf) /* * Now that we've eaten the input message, check to see if we actually - * want to do the function call or not. It's now safe to ereport(); - * we won't lose sync with the frontend. + * want to do the function call or not. It's now safe to ereport(); we + * won't lose sync with the frontend. */ if (IsAbortedTransactionBlockState()) ereport(ERROR, (errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION), errmsg("current transaction is aborted, " - "commands ignored until end of transaction block"))); + "commands ignored until end of transaction block"))); /* * Begin parsing the buffer contents. @@ -440,8 +439,8 @@ parse_fcall_arguments(StringInfo msgBuf, struct fp_info * fip, if (argsize < 0) ereport(ERROR, (errcode(ERRCODE_PROTOCOL_VIOLATION), - errmsg("invalid argument size %d in function call message", - argsize))); + errmsg("invalid argument size %d in function call message", + argsize))); /* Reset abuf to empty, and insert raw data into it */ abuf.len = 0; @@ -500,8 +499,8 @@ parse_fcall_arguments(StringInfo msgBuf, struct fp_info * fip, if (abuf.cursor != abuf.len) ereport(ERROR, (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION), - errmsg("incorrect binary data format in function argument %d", - i + 1))); + errmsg("incorrect binary data format in function argument %d", + i + 1))); } else ereport(ERROR, @@ -543,9 +542,9 @@ parse_fcall_arguments_20(StringInfo msgBuf, struct fp_info * fip, * Copy supplied arguments into arg vector. In protocol 2.0 these are * always assumed to be supplied in binary format. * - * Note: although the original protocol 2.0 code did not have any way for - * the frontend to specify a NULL argument, we now choose to interpret - * length == -1 as meaning a NULL. + * Note: although the original protocol 2.0 code did not have any way for the + * frontend to specify a NULL argument, we now choose to interpret length + * == -1 as meaning a NULL. */ for (i = 0; i < nargs; ++i) { @@ -563,8 +562,8 @@ parse_fcall_arguments_20(StringInfo msgBuf, struct fp_info * fip, if (argsize < 0) ereport(ERROR, (errcode(ERRCODE_PROTOCOL_VIOLATION), - errmsg("invalid argument size %d in function call message", - argsize))); + errmsg("invalid argument size %d in function call message", + argsize))); /* Reset abuf to empty, and insert raw data into it */ abuf.len = 0; @@ -587,8 +586,8 @@ parse_fcall_arguments_20(StringInfo msgBuf, struct fp_info * fip, if (abuf.cursor != abuf.len) ereport(ERROR, (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION), - errmsg("incorrect binary data format in function argument %d", - i + 1))); + errmsg("incorrect binary data format in function argument %d", + i + 1))); } /* Desired result format is always binary in protocol 2.0 */ diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 8b722c2e01..93bcc93660 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.465 2005/10/13 22:57:27 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.466 2005/10/15 02:49:27 momjian Exp $ * * NOTES * this is the "main" module of the postgres backend and @@ -71,8 +71,7 @@ extern char *optarg; * global variables * ---------------- */ -const char *debug_query_string; /* for pgmonitor and - * log_min_error_statement */ +const char *debug_query_string; /* for pgmonitor and log_min_error_statement */ /* Note: whereToSendOutput is initialized for the bootstrap/standalone case */ CommandDest whereToSendOutput = Debug; @@ -96,7 +95,7 @@ static int max_stack_depth_bytes = 2048 * 1024; /* stack base pointer (initialized by PostgresMain) */ /* Do not make static so PL/Java can modifiy it */ -char *stack_base_ptr = NULL; +char *stack_base_ptr = NULL; /* @@ -142,9 +141,7 @@ static bool EchoQuery = false; /* default don't echo */ * tcop/tcopdebug.h */ #ifndef TCOP_DONTUSENEWLINE -static int UseNewLine = 1; /* Use newlines query delimiters (the - * default) */ - +static int UseNewLine = 1; /* Use newlines query delimiters (the default) */ #else static int UseNewLine = 0; /* Use EOF as query delimiters */ #endif /* TCOP_DONTUSENEWLINE */ @@ -204,8 +201,8 @@ InteractiveBackend(StringInfo inBuf) if (UseNewLine) { /* - * if we are using \n as a delimiter, then read characters - * until the \n. + * if we are using \n as a delimiter, then read characters until + * the \n. */ while ((c = getc(stdin)) != EOF) { @@ -297,12 +294,12 @@ SocketBackend(StringInfo inBuf) } /* - * Validate message type code before trying to read body; if we have - * lost sync, better to say "command unknown" than to run out of - * memory because we used garbage as a length word. + * Validate message type code before trying to read body; if we have lost + * sync, better to say "command unknown" than to run out of memory because + * we used garbage as a length word. * - * This also gives us a place to set the doing_extended_query_message - * flag as soon as possible. + * This also gives us a place to set the doing_extended_query_message flag as + * soon as possible. */ switch (qtype) { @@ -315,7 +312,7 @@ SocketBackend(StringInfo inBuf) { ereport(COMMERROR, (errcode(ERRCODE_PROTOCOL_VIOLATION), - errmsg("unexpected EOF on client connection"))); + errmsg("unexpected EOF on client connection"))); return EOF; } } @@ -342,7 +339,7 @@ SocketBackend(StringInfo inBuf) if (PG_PROTOCOL_MAJOR(FrontendProtocol) < 3) ereport(FATAL, (errcode(ERRCODE_PROTOCOL_VIOLATION), - errmsg("invalid frontend message type %d", qtype))); + errmsg("invalid frontend message type %d", qtype))); break; case 'S': /* sync */ @@ -354,7 +351,7 @@ SocketBackend(StringInfo inBuf) if (PG_PROTOCOL_MAJOR(FrontendProtocol) < 3) ereport(FATAL, (errcode(ERRCODE_PROTOCOL_VIOLATION), - errmsg("invalid frontend message type %d", qtype))); + errmsg("invalid frontend message type %d", qtype))); break; case 'd': /* copy data */ @@ -365,15 +362,15 @@ SocketBackend(StringInfo inBuf) if (PG_PROTOCOL_MAJOR(FrontendProtocol) < 3) ereport(FATAL, (errcode(ERRCODE_PROTOCOL_VIOLATION), - errmsg("invalid frontend message type %d", qtype))); + errmsg("invalid frontend message type %d", qtype))); break; default: /* - * Otherwise we got garbage from the frontend. We treat this - * as fatal because we have probably lost message boundary - * sync, and there's no good way to recover. + * Otherwise we got garbage from the frontend. We treat this as + * fatal because we have probably lost message boundary sync, and + * there's no good way to recover. */ ereport(FATAL, (errcode(ERRCODE_PROTOCOL_VIOLATION), @@ -382,9 +379,9 @@ SocketBackend(StringInfo inBuf) } /* - * In protocol version 3, all frontend messages have a length word - * next after the type code; we can read the message contents - * independently of the type. + * In protocol version 3, all frontend messages have a length word next + * after the type code; we can read the message contents independently of + * the type. */ if (PG_PROTOCOL_MAJOR(FrontendProtocol) >= 3) { @@ -532,14 +529,14 @@ pg_parse_query(const char *query_string) static bool log_after_parse(List *raw_parsetree_list, const char *query_string, - char **prepare_string) + char **prepare_string) { ListCell *parsetree_item; bool log_this_statement = (log_statement == LOGSTMT_ALL); *prepare_string = NULL; - /* Check if we need to log the statement, and get prepare_string. */ + /* Check if we need to log the statement, and get prepare_string. */ foreach(parsetree_item, raw_parsetree_list) { Node *parsetree = (Node *) lfirst(parsetree_item); @@ -554,7 +551,7 @@ log_after_parse(List *raw_parsetree_list, const char *query_string, if (IsA(parsetree, SelectStmt) && ((SelectStmt *) parsetree)->into == NULL) - continue; /* optimization for frequent command */ + continue; /* optimization for frequent command */ if (log_statement == LOGSTMT_MOD && (IsA(parsetree, InsertStmt) || @@ -562,23 +559,23 @@ log_after_parse(List *raw_parsetree_list, const char *query_string, IsA(parsetree, DeleteStmt) || IsA(parsetree, TruncateStmt) || (IsA(parsetree, CopyStmt) && - ((CopyStmt *) parsetree)->is_from))) /* COPY FROM */ + ((CopyStmt *) parsetree)->is_from))) /* COPY FROM */ log_this_statement = true; commandTag = CreateCommandTag(parsetree); if ((log_statement == LOGSTMT_MOD || log_statement == LOGSTMT_DDL) && (strncmp(commandTag, "CREATE ", strlen("CREATE ")) == 0 || - IsA(parsetree, SelectStmt) || /* SELECT INTO, CREATE AS */ + IsA(parsetree, SelectStmt) || /* SELECT INTO, CREATE AS */ strncmp(commandTag, "ALTER ", strlen("ALTER ")) == 0 || strncmp(commandTag, "DROP ", strlen("DROP ")) == 0 || - IsA(parsetree, GrantStmt) || /* GRANT or REVOKE */ + IsA(parsetree, GrantStmt) || /* GRANT or REVOKE */ IsA(parsetree, CommentStmt))) log_this_statement = true; /* - * For the first EXECUTE we find, record the client statement - * used by the PREPARE. + * For the first EXECUTE we find, record the client statement used by + * the PREPARE. */ if (IsA(parsetree, ExecuteStmt)) { @@ -589,13 +586,13 @@ log_after_parse(List *raw_parsetree_list, const char *query_string, entry->query_string) { *prepare_string = palloc(strlen(entry->query_string) + - strlen(" [client PREPARE: %s]") - 1); + strlen(" [client PREPARE: %s]") - 1); sprintf(*prepare_string, " [client PREPARE: %s]", - entry->query_string); + entry->query_string); } } } - + if (log_this_statement) { ereport(LOG, @@ -657,8 +654,8 @@ pg_rewrite_queries(List *querytree_list) ResetUsage(); /* - * 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. */ foreach(list_item, querytree_list) { @@ -690,8 +687,7 @@ pg_rewrite_queries(List *querytree_list) #ifdef COPY_PARSE_PLAN_TREES /* - * Optional debugging check: pass querytree output through - * copyObject() + * Optional debugging check: pass querytree output through copyObject() */ new_list = (List *) copyObject(querytree_list); /* This checks both copyObject() and the equal() routines... */ @@ -734,8 +730,8 @@ pg_plan_query(Query *querytree, ParamListInfo boundParams) Plan *new_plan = (Plan *) copyObject(plan); /* - * equal() currently does not have routines to compare Plan nodes, - * so don't try to test equality here. Perhaps fix someday? + * equal() currently does not have routines to compare Plan nodes, so + * don't try to test equality here. Perhaps fix someday? */ #ifdef NOT_USED /* This checks both copyObject() and the equal() routines... */ @@ -813,13 +809,14 @@ exec_simple_query(const char *query_string) MemoryContext oldcontext; List *parsetree_list; ListCell *parsetree_item; - struct timeval start_t, stop_t; + struct timeval start_t, + stop_t; bool save_log_duration = log_duration; int save_log_min_duration_statement = log_min_duration_statement; bool save_log_statement_stats = log_statement_stats; - char *prepare_string = NULL; + char *prepare_string = NULL; bool was_logged = false; - + /* * Report query to various monitoring facilities. */ @@ -829,9 +826,9 @@ exec_simple_query(const char *query_string) /* * We use save_log_* so "SET log_duration = true" and "SET - * log_min_duration_statement = true" don't report incorrect time - * because gettimeofday() wasn't called. Similarly, - * log_statement_stats has to be captured once. + * log_min_duration_statement = true" don't report incorrect time because + * gettimeofday() wasn't called. Similarly, log_statement_stats has to be + * captured once. */ if (save_log_duration || save_log_min_duration_statement != -1) gettimeofday(&start_t, NULL); @@ -842,17 +839,17 @@ exec_simple_query(const char *query_string) /* * Start up a transaction command. All queries generated by the * query_string will be in this same command block, *unless* we find a - * BEGIN/COMMIT/ABORT statement; we have to force a new xact command - * after one of those, else bad things will happen in xact.c. (Note - * that this will normally change current memory context.) + * BEGIN/COMMIT/ABORT statement; we have to force a new xact command after + * one of those, else bad things will happen in xact.c. (Note that this + * will normally change current memory context.) */ start_xact_command(); /* - * Zap any pre-existing unnamed statement. (While not strictly - * necessary, it seems best to define simple-Query mode as if it used - * the unnamed statement and portal; this ensures we recover any - * storage used by prior unnamed operations.) + * Zap any pre-existing unnamed statement. (While not strictly necessary, + * it seems best to define simple-Query mode as if it used the unnamed + * statement and portal; this ensures we recover any storage used by prior + * unnamed operations.) */ unnamed_stmt_pstmt = NULL; if (unnamed_stmt_context) @@ -870,14 +867,14 @@ exec_simple_query(const char *query_string) QueryContext = CurrentMemoryContext; /* - * Do basic parsing of the query or queries (this should be safe even - * if we are in aborted transaction state!) + * Do basic parsing of the query or queries (this should be safe even if + * we are in aborted transaction state!) */ parsetree_list = pg_parse_query(query_string); if (log_statement != LOGSTMT_NONE || save_log_min_duration_statement != -1) was_logged = log_after_parse(parsetree_list, query_string, - &prepare_string); + &prepare_string); /* * Switch back to transaction context to enter the loop. @@ -899,10 +896,10 @@ exec_simple_query(const char *query_string) int16 format; /* - * Get the command name for use in status display (it also becomes - * the default completion tag, down inside PortalRun). Set - * ps_status and do any special start-of-SQL-command processing - * needed by the destination. + * Get the command name for use in status display (it also becomes the + * default completion tag, down inside PortalRun). Set ps_status and + * do any special start-of-SQL-command processing needed by the + * destination. */ commandTag = CreateCommandTag(parsetree); @@ -912,11 +909,11 @@ exec_simple_query(const char *query_string) /* * If we are in an aborted transaction, reject all commands except - * COMMIT/ABORT. It is important that this test occur before we - * try to do parse analysis, rewrite, or planning, since all those - * phases try to do database accesses, which may fail in abort - * state. (It might be safe to allow some additional utility - * commands in this state, but not many...) + * COMMIT/ABORT. It is important that this test occur before we try + * to do parse analysis, rewrite, or planning, since all those phases + * try to do database accesses, which may fail in abort state. (It + * might be safe to allow some additional utility commands in this + * state, but not many...) */ if (IsAbortedTransactionBlockState()) { @@ -937,7 +934,7 @@ exec_simple_query(const char *query_string) ereport(ERROR, (errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION), errmsg("current transaction is aborted, " - "commands ignored until end of transaction block"))); + "commands ignored until end of transaction block"))); } /* Make sure we are in a transaction command */ @@ -980,10 +977,10 @@ exec_simple_query(const char *query_string) PortalStart(portal, NULL, InvalidSnapshot); /* - * Select the appropriate output format: text unless we are doing - * a FETCH from a binary cursor. (Pretty grotty to have to do - * this here --- but it avoids grottiness in other places. Ah, - * the joys of backward compatibility...) + * Select the appropriate output format: text unless we are doing a + * FETCH from a binary cursor. (Pretty grotty to have to do this here + * --- but it avoids grottiness in other places. Ah, the joys of + * backward compatibility...) */ format = 0; /* TEXT is default */ if (IsA(parsetree, FetchStmt)) @@ -1012,8 +1009,7 @@ exec_simple_query(const char *query_string) MemoryContextSwitchTo(oldcontext); /* - * Run the portal to completion, and then drop it (and the - * receiver). + * Run the portal to completion, and then drop it (and the receiver). */ (void) PortalRun(portal, FETCH_ALL, @@ -1028,24 +1024,22 @@ exec_simple_query(const char *query_string) if (IsA(parsetree, TransactionStmt)) { /* - * If this was a transaction control statement, commit it. We - * will start a new xact command for the next command (if - * any). + * If this was a transaction control statement, commit it. We will + * start a new xact command for the next command (if any). */ finish_xact_command(); } else if (lnext(parsetree_item) == NULL) { /* - * If this is the last parsetree of the query string, close - * down transaction statement before reporting - * command-complete. This is so that any end-of-transaction - * errors are reported before the command-complete message is - * issued, to avoid confusing clients who will expect either a - * command-complete message or an error, not one and then the - * other. But for compatibility with historical Postgres - * behavior, we do not force a transaction boundary between - * queries appearing in a single query string. + * If this is the last parsetree of the query string, close down + * transaction statement before reporting command-complete. This + * is so that any end-of-transaction errors are reported before + * the command-complete message is issued, to avoid confusing + * clients who will expect either a command-complete message or an + * error, not one and then the other. But for compatibility with + * historical Postgres behavior, we do not force a transaction + * boundary between queries appearing in a single query string. */ finish_xact_command(); } @@ -1059,11 +1053,10 @@ exec_simple_query(const char *query_string) } /* - * Tell client that we're done with this query. Note we emit - * exactly one EndCommand report for each raw parsetree, thus one - * for each SQL command the client sent, regardless of rewriting. - * (But a command aborted by error will not send an EndCommand - * report at all.) + * Tell client that we're done with this query. Note we emit exactly + * one EndCommand report for each raw parsetree, thus one for each SQL + * command the client sent, regardless of rewriting. (But a command + * aborted by error will not send an EndCommand report at all.) */ EndCommand(completionTag, dest); } /* end loop over parsetrees */ @@ -1082,8 +1075,8 @@ exec_simple_query(const char *query_string) QueryContext = NULL; /* - * Combine processing here as we need to calculate the query duration - * in both instances. + * Combine processing here as we need to calculate the query duration in + * both instances. */ if (save_log_duration || save_log_min_duration_statement != -1) { @@ -1096,28 +1089,28 @@ exec_simple_query(const char *query_string) stop_t.tv_usec += 1000000; } usecs = (long) (stop_t.tv_sec - start_t.tv_sec) * 1000000 + - (long) (stop_t.tv_usec - start_t.tv_usec); + (long) (stop_t.tv_usec - start_t.tv_usec); /* Only print duration if we previously printed the statement. */ if (was_logged && save_log_duration) ereport(LOG, (errmsg("duration: %ld.%03ld ms", - (long) ((stop_t.tv_sec - start_t.tv_sec) * 1000 + - (stop_t.tv_usec - start_t.tv_usec) / 1000), - (long) (stop_t.tv_usec - start_t.tv_usec) % 1000))); + (long) ((stop_t.tv_sec - start_t.tv_sec) * 1000 + + (stop_t.tv_usec - start_t.tv_usec) / 1000), + (long) (stop_t.tv_usec - start_t.tv_usec) % 1000))); /* - * Output a duration_statement to the log if the query has - * exceeded the min duration, or if we are to print all durations. + * Output a duration_statement to the log if the query has exceeded + * the min duration, or if we are to print all durations. */ if (save_log_min_duration_statement == 0 || (save_log_min_duration_statement > 0 && usecs >= save_log_min_duration_statement * 1000)) ereport(LOG, (errmsg("duration: %ld.%03ld ms statement: %s%s", - (long) ((stop_t.tv_sec - start_t.tv_sec) * 1000 + - (stop_t.tv_usec - start_t.tv_usec) / 1000), - (long) (stop_t.tv_usec - start_t.tv_usec) % 1000, + (long) ((stop_t.tv_sec - start_t.tv_sec) * 1000 + + (stop_t.tv_usec - start_t.tv_usec) / 1000), + (long) (stop_t.tv_usec - start_t.tv_usec) % 1000, query_string, prepare_string ? prepare_string : ""))); } @@ -1170,9 +1163,9 @@ exec_parse_message(const char *query_string, /* string to execute */ query_string))); /* - * Start up a transaction command so we can run parse analysis etc. - * (Note that this will normally change current memory context.) - * Nothing happens if we are already in one. + * Start up a transaction command so we can run parse analysis etc. (Note + * that this will normally change current memory context.) Nothing happens + * if we are already in one. */ start_xact_command(); @@ -1182,13 +1175,12 @@ exec_parse_message(const char *query_string, /* string to execute */ * We have two strategies depending on whether the prepared statement is * named or not. For a named prepared statement, we do parsing in * MessageContext and copy the finished trees into the prepared - * statement's private context; then the reset of MessageContext - * releases temporary space used by parsing and planning. For an - * unnamed prepared statement, we assume the statement isn't going to - * hang around long, so getting rid of temp space quickly is probably - * not worth the costs of copying parse/plan trees. So in this case, - * we set up a special context for the unnamed statement, and do all - * the parsing/planning therein. + * statement's private context; then the reset of MessageContext releases + * temporary space used by parsing and planning. For an unnamed prepared + * statement, we assume the statement isn't going to hang around long, so + * getting rid of temp space quickly is probably not worth the costs of + * copying parse/plan trees. So in this case, we set up a special context + * for the unnamed statement, and do all the parsing/planning therein. */ is_named = (stmt_name[0] != '\0'); if (is_named) @@ -1219,20 +1211,20 @@ exec_parse_message(const char *query_string, /* string to execute */ QueryContext = CurrentMemoryContext; /* - * Do basic parsing of the query or queries (this should be safe even - * if we are in aborted transaction state!) + * Do basic parsing of the query or queries (this should be safe even if + * we are in aborted transaction state!) */ parsetree_list = pg_parse_query(query_string); /* - * We only allow a single user statement in a prepared statement. This - * is mainly to keep the protocol simple --- otherwise we'd need to - * worry about multiple result tupdescs and things like that. + * We only allow a single user statement in a prepared statement. This is + * mainly to keep the protocol simple --- otherwise we'd need to worry + * about multiple result tupdescs and things like that. */ if (list_length(parsetree_list) > 1) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("cannot insert multiple commands into a prepared statement"))); + errmsg("cannot insert multiple commands into a prepared statement"))); if (parsetree_list != NIL) { @@ -1246,11 +1238,11 @@ exec_parse_message(const char *query_string, /* string to execute */ /* * If we are in an aborted transaction, reject all commands except - * COMMIT/ROLLBACK. It is important that this test occur before - * we try to do parse analysis, rewrite, or planning, since all - * those phases try to do database accesses, which may fail in - * abort state. (It might be safe to allow some additional utility - * commands in this state, but not many...) + * COMMIT/ROLLBACK. It is important that this test occur before we + * try to do parse analysis, rewrite, or planning, since all those + * phases try to do database accesses, which may fail in abort state. + * (It might be safe to allow some additional utility commands in this + * state, but not many...) */ if (IsAbortedTransactionBlockState()) { @@ -1271,13 +1263,13 @@ exec_parse_message(const char *query_string, /* string to execute */ ereport(ERROR, (errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION), errmsg("current transaction is aborted, " - "commands ignored until end of transaction block"))); + "commands ignored until end of transaction block"))); } /* * OK to analyze, rewrite, and plan this query. Note that the - * originally specified parameter set is not required to be - * complete, so we have to use parse_analyze_varparams(). + * originally specified parameter set is not required to be complete, + * so we have to use parse_analyze_varparams(). */ if (log_parser_stats) ResetUsage(); @@ -1298,8 +1290,8 @@ exec_parse_message(const char *query_string, /* string to execute */ if (ptype == InvalidOid || ptype == UNKNOWNOID) ereport(ERROR, (errcode(ERRCODE_INDETERMINATE_DATATYPE), - errmsg("could not determine data type of parameter $%d", - i + 1))); + errmsg("could not determine data type of parameter $%d", + i + 1))); param_list = lappend_oid(param_list, ptype); } @@ -1309,8 +1301,8 @@ exec_parse_message(const char *query_string, /* string to execute */ querytree_list = pg_rewrite_queries(querytree_list); /* - * If this is the unnamed statement and it has parameters, defer - * query planning until Bind. Otherwise do it now. + * If this is the unnamed statement and it has parameters, defer query + * planning until Bind. Otherwise do it now. */ if (!is_named && numParams > 0) plantree_list = NIL; @@ -1363,10 +1355,9 @@ exec_parse_message(const char *query_string, /* string to execute */ QueryContext = NULL; /* - * We do NOT close the open transaction command here; that only - * happens when the client sends Sync. Instead, do - * CommandCounterIncrement just in case something happened during - * parse/plan. + * We do NOT close the open transaction command here; that only happens + * when the client sends Sync. Instead, do CommandCounterIncrement just + * in case something happened during parse/plan. */ CommandCounterIncrement(); @@ -1408,9 +1399,9 @@ exec_bind_message(StringInfo input_message) set_ps_display("BIND"); /* - * Start up a transaction command so we can call functions etc. (Note - * that this will normally change current memory context.) Nothing - * happens if we are already in one. + * Start up a transaction command so we can call functions etc. (Note that + * this will normally change current memory context.) Nothing happens if + * we are already in one. */ start_xact_command(); @@ -1436,8 +1427,8 @@ exec_bind_message(StringInfo input_message) if (numPFormats > 1 && numPFormats != numParams) ereport(ERROR, (errcode(ERRCODE_PROTOCOL_VIOLATION), - errmsg("bind message has %d parameter formats but %d parameters", - numPFormats, numParams))); + errmsg("bind message has %d parameter formats but %d parameters", + numPFormats, numParams))); /* Find prepared statement */ if (stmt_name[0] != '\0') @@ -1449,18 +1440,18 @@ exec_bind_message(StringInfo input_message) if (!pstmt) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_PSTATEMENT), - errmsg("unnamed prepared statement does not exist"))); + errmsg("unnamed prepared statement does not exist"))); } if (numParams != list_length(pstmt->argtype_list)) ereport(ERROR, (errcode(ERRCODE_PROTOCOL_VIOLATION), errmsg("bind message supplies %d parameters, but prepared statement \"%s\" requires %d", - numParams, stmt_name, list_length(pstmt->argtype_list)))); + numParams, stmt_name, list_length(pstmt->argtype_list)))); /* - * Create the portal. Allow silent replacement of an existing portal - * only if the unnamed portal is specified. + * Create the portal. Allow silent replacement of an existing portal only + * if the unnamed portal is specified. */ if (portal_name[0] == '\0') portal = CreatePortal(portal_name, true, true); @@ -1475,9 +1466,9 @@ exec_bind_message(StringInfo input_message) /* * Fetch parameters, if any, and store in the portal's memory context. * - * In an aborted transaction, we can't risk calling user-defined - * functions, but we can't fail to Bind either, so bind all parameters - * to null values. + * In an aborted transaction, we can't risk calling user-defined functions, + * but we can't fail to Bind either, so bind all parameters to null + * values. */ if (numParams > 0) { @@ -1522,13 +1513,13 @@ exec_bind_message(StringInfo input_message) pformat = 0; /* default = text */ /* - * Rather than copying data around, we just set up a - * phony StringInfo pointing to the correct portion of - * the message buffer. We assume we can scribble on - * the message buffer so as to maintain the convention - * that StringInfos have a trailing null. This is - * grotty but is a big win when dealing with very - * large parameter strings. + * Rather than copying data around, we just set up a phony + * StringInfo pointing to the correct portion of the + * message buffer. We assume we can scribble on the + * message buffer so as to maintain the convention that + * StringInfos have a trailing null. This is grotty but + * is a big win when dealing with very large parameter + * strings. */ pbuf.data = (char *) pvalue; pbuf.maxlen = plength + 1; @@ -1547,8 +1538,8 @@ exec_bind_message(StringInfo input_message) getTypeInputInfo(ptype, &typinput, &typioparam); /* - * We have to do encoding conversion before - * calling the typinput routine. + * We have to do encoding conversion before calling + * the typinput routine. */ pstring = pg_client_to_server(pbuf.data, plength); params[i].value = @@ -1566,8 +1557,7 @@ exec_bind_message(StringInfo input_message) Oid typioparam; /* - * Call the parameter type's binary input - * converter + * Call the parameter type's binary input converter */ getTypeBinaryInputInfo(ptype, &typreceive, &typioparam); @@ -1580,9 +1570,9 @@ exec_bind_message(StringInfo input_message) /* Trouble if it didn't eat the whole buffer */ if (pbuf.cursor != pbuf.len) ereport(ERROR, - (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION), - errmsg("incorrect binary data format in bind parameter %d", - i + 1))); + (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION), + errmsg("incorrect binary data format in bind parameter %d", + i + 1))); } else { @@ -1624,8 +1614,8 @@ exec_bind_message(StringInfo input_message) pq_getmsgend(input_message); /* - * If we didn't plan the query before, do it now. This allows the - * planner to make use of the concrete parameter values we now have. + * If we didn't plan the query before, do it now. This allows the planner + * to make use of the concrete parameter values we now have. * * This happens only for unnamed statements, and so switching into the * statement context for planning is correct (see notes in @@ -1679,7 +1669,8 @@ exec_execute_message(const char *portal_name, long max_rows) bool is_trans_exit = false; bool completed; char completionTag[COMPLETION_TAG_BUFSIZE]; - struct timeval start_t, stop_t; + struct timeval start_t, + stop_t; bool save_log_duration = log_duration; int save_log_min_duration_statement = log_min_duration_statement; bool save_log_statement_stats = log_statement_stats; @@ -1697,10 +1688,10 @@ exec_execute_message(const char *portal_name, long max_rows) errmsg("portal \"%s\" does not exist", portal_name))); /* - * If we re-issue an Execute protocol request against an existing - * portal, then we are only fetching more rows rather than - * completely re-executing the query from the start. atStart is never - * reset for a v3 portal, so we are safe to use this check. + * If we re-issue an Execute protocol request against an existing portal, + * then we are only fetching more rows rather than completely re-executing + * the query from the start. atStart is never reset for a v3 portal, so we + * are safe to use this check. */ if (!portal->atStart) execute_is_fetch = true; @@ -1737,9 +1728,9 @@ exec_execute_message(const char *portal_name, long max_rows) /* * We use save_log_* so "SET log_duration = true" and "SET - * log_min_duration_statement = true" don't report incorrect time - * because gettimeofday() wasn't called. Similarly, - * log_statement_stats has to be captured once. + * log_min_duration_statement = true" don't report incorrect time because + * gettimeofday() wasn't called. Similarly, log_statement_stats has to be + * captured once. */ if (save_log_duration || save_log_min_duration_statement != -1) gettimeofday(&start_t, NULL); @@ -1778,9 +1769,8 @@ exec_execute_message(const char *portal_name, long max_rows) } /* - * Create dest receiver in MessageContext (we don't want it in - * transaction context, because that may get deleted if portal - * contains VACUUM). + * Create dest receiver in MessageContext (we don't want it in transaction + * context, because that may get deleted if portal contains VACUUM). */ receiver = CreateDestReceiver(dest, portal); @@ -1800,7 +1790,7 @@ exec_execute_message(const char *portal_name, long max_rows) ereport(ERROR, (errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION), errmsg("current transaction is aborted, " - "commands ignored until end of transaction block"))); + "commands ignored until end of transaction block"))); } /* Check for cancel signal before we start execution */ @@ -1826,8 +1816,7 @@ exec_execute_message(const char *portal_name, long max_rows) { /* * If this was a transaction control statement, commit it. We - * will start a new xact command for the next command (if - * any). + * will start a new xact command for the next command (if any). */ finish_xact_command(); } @@ -1851,8 +1840,8 @@ exec_execute_message(const char *portal_name, long max_rows) } /* - * Combine processing here as we need to calculate the query duration - * in both instances. + * Combine processing here as we need to calculate the query duration in + * both instances. */ if (save_log_duration || save_log_min_duration_statement != -1) { @@ -1865,30 +1854,30 @@ exec_execute_message(const char *portal_name, long max_rows) stop_t.tv_usec += 1000000; } usecs = (long) (stop_t.tv_sec - start_t.tv_sec) * 1000000 + - (long) (stop_t.tv_usec - start_t.tv_usec); + (long) (stop_t.tv_usec - start_t.tv_usec); /* Only print duration if we previously printed the statement. */ if (log_statement == LOGSTMT_ALL && save_log_duration) ereport(LOG, (errmsg("duration: %ld.%03ld ms", - (long) ((stop_t.tv_sec - start_t.tv_sec) * 1000 + - (stop_t.tv_usec - start_t.tv_usec) / 1000), - (long) (stop_t.tv_usec - start_t.tv_usec) % 1000))); + (long) ((stop_t.tv_sec - start_t.tv_sec) * 1000 + + (stop_t.tv_usec - start_t.tv_usec) / 1000), + (long) (stop_t.tv_usec - start_t.tv_usec) % 1000))); /* - * Output a duration_statement to the log if the query has - * exceeded the min duration, or if we are to print all durations. + * Output a duration_statement to the log if the query has exceeded + * the min duration, or if we are to print all durations. */ if (save_log_min_duration_statement == 0 || (save_log_min_duration_statement > 0 && usecs >= save_log_min_duration_statement * 1000)) ereport(LOG, (errmsg("duration: %ld.%03ld ms statement: %sEXECUTE %s [PREPARE: %s]", - (long) ((stop_t.tv_sec - start_t.tv_sec) * 1000 + - (stop_t.tv_usec - start_t.tv_usec) / 1000), - (long) (stop_t.tv_usec - start_t.tv_usec) % 1000, + (long) ((stop_t.tv_sec - start_t.tv_sec) * 1000 + + (stop_t.tv_usec - start_t.tv_usec) / 1000), + (long) (stop_t.tv_usec - start_t.tv_usec) % 1000, (execute_is_fetch) ? "FETCH from " : "", - (*portal_name != '\0') ? portal_name : "", + (*portal_name != '\0') ? portal_name : "", portal->sourceText ? portal->sourceText : ""))); } @@ -1921,7 +1910,7 @@ exec_describe_statement_message(const char *stmt_name) if (!pstmt) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_PSTATEMENT), - errmsg("unnamed prepared statement does not exist"))); + errmsg("unnamed prepared statement does not exist"))); } if (whereToSendOutput != Remote) @@ -1999,7 +1988,7 @@ start_xact_command(void) enable_sig_alarm(StatementTimeout, true); else cancel_from_timeout = false; - + xact_started = true; } } @@ -2052,28 +2041,28 @@ quickdie(SIGNAL_ARGS) PG_SETMASK(&BlockSig); /* - * Ideally this should be ereport(FATAL), but then we'd not get - * control back... + * Ideally this should be ereport(FATAL), but then we'd not get control + * back... */ ereport(WARNING, (errcode(ERRCODE_CRASH_SHUTDOWN), errmsg("terminating connection because of crash of another server process"), - errdetail("The postmaster has commanded this server process to roll back" - " the current transaction and exit, because another" - " server process exited abnormally and possibly corrupted" - " shared memory."), + errdetail("The postmaster has commanded this server process to roll back" + " the current transaction and exit, because another" + " server process exited abnormally and possibly corrupted" + " shared memory."), errhint("In a moment you should be able to reconnect to the" " database and repeat your command."))); /* * DO NOT proc_exit() -- we're here because shared memory may be - * corrupted, so we don't want to try to clean up our transaction. - * Just nail the windows shut and get out of town. + * corrupted, so we don't want to try to clean up our transaction. Just + * nail the windows shut and get out of town. * - * Note we do exit(1) not exit(0). This is to force the postmaster into - * a system reset cycle if some idiot DBA sends a manual SIGQUIT to a - * random backend. This is necessary precisely because we don't clean - * up our shared memory state. + * Note we do exit(1) not exit(0). This is to force the postmaster into a + * system reset cycle if some idiot DBA sends a manual SIGQUIT to a random + * backend. This is necessary precisely because we don't clean up our + * shared memory state. */ exit(1); } @@ -2094,8 +2083,8 @@ die(SIGNAL_ARGS) ProcDiePending = true; /* - * If it's safe to interrupt, and we're waiting for input or a - * lock, service the interrupt immediately + * If it's safe to interrupt, and we're waiting for input or a lock, + * service the interrupt immediately */ if (ImmediateInterruptOK && InterruptHoldoffCount == 0 && CritSectionCount == 0) @@ -2147,9 +2136,9 @@ StatementCancelHandler(SIGNAL_ARGS) QueryCancelPending = true; /* - * If it's safe to interrupt, and we're waiting for a lock, - * service the interrupt immediately. No point in interrupting if - * we're waiting for input, however. + * If it's safe to interrupt, and we're waiting for a lock, service + * the interrupt immediately. No point in interrupting if we're + * waiting for input, however. */ if (ImmediateInterruptOK && InterruptHoldoffCount == 0 && CritSectionCount == 0) @@ -2179,9 +2168,9 @@ FloatExceptionHandler(SIGNAL_ARGS) ereport(ERROR, (errcode(ERRCODE_FLOATING_POINT_EXCEPTION), errmsg("floating-point exception"), - errdetail("An invalid floating-point operation was signaled. " - "This probably means an out-of-range result or an " - "invalid operation, such as division by zero."))); + errdetail("An invalid floating-point operation was signaled. " + "This probably means an out-of-range result or an " + "invalid operation, such as division by zero."))); } /* SIGHUP: set flag to re-read config file at next convenient time */ @@ -2215,7 +2204,7 @@ ProcessInterrupts(void) DisableCatchupInterrupt(); ereport(FATAL, (errcode(ERRCODE_ADMIN_SHUTDOWN), - errmsg("terminating connection due to administrator command"))); + errmsg("terminating connection due to administrator command"))); } if (QueryCancelPending) { @@ -2255,15 +2244,14 @@ check_stack_depth(void) /* * Compute distance from PostgresMain's local variables to my own * - * Note: in theory stack_depth should be ptrdiff_t or some such, but - * since the whole point of this code is to bound the value to - * something much less than integer-sized, int should work fine. + * Note: in theory stack_depth should be ptrdiff_t or some such, but since + * the whole point of this code is to bound the value to something much + * less than integer-sized, int should work fine. */ stack_depth = (int) (stack_base_ptr - &stack_top_loc); /* - * Take abs value, since stacks grow up on some machines, down on - * others + * Take abs value, since stacks grow up on some machines, down on others */ if (stack_depth < 0) stack_depth = -stack_depth; @@ -2271,10 +2259,9 @@ check_stack_depth(void) /* * Trouble? * - * The test on stack_base_ptr prevents us from erroring out if called - * during process setup or in a non-backend process. Logically it - * should be done first, but putting it here avoids wasting cycles - * during normal cases. + * The test on stack_base_ptr prevents us from erroring out if called during + * process setup or in a non-backend process. Logically it should be done + * first, but putting it here avoids wasting cycles during normal cases. */ if (stack_depth > max_stack_depth_bytes && stack_base_ptr != NULL) @@ -2385,8 +2372,8 @@ PostgresMain(int argc, char *argv[], const char *username) char *userDoption = NULL; bool secure; int errs = 0; - int debug_flag = -1; /* -1 means not given */ - List *guc_names = NIL; /* for SUSET options */ + int debug_flag = -1; /* -1 means not given */ + List *guc_names = NIL; /* for SUSET options */ List *guc_values = NIL; GucContext ctx; GucSource gucsource; @@ -2595,9 +2582,9 @@ PostgresMain(int argc, char *argv[], const char *username) /* * ignore system indexes * - * As of PG 7.4 this is safe to allow from the client, since - * it only disables reading the system indexes, not - * writing them. Worst case consequence is slowness. + * As of PG 7.4 this is safe to allow from the client, since it + * only disables reading the system indexes, not writing them. + * Worst case consequence is slowness. */ IgnoreSystemIndexes(true); break; @@ -2621,8 +2608,7 @@ PostgresMain(int argc, char *argv[], const char *username) { dbname = strdup(optarg); - secure = false; /* subsequent switches are NOT - * secure */ + secure = false; /* subsequent switches are NOT secure */ ctx = PGC_BACKEND; gucsource = PGC_S_CLIENT; } @@ -2641,8 +2627,8 @@ PostgresMain(int argc, char *argv[], const char *username) /* * s - report usage statistics (timings) after each query * - * Since log options are SUSET, we need to postpone unless - * still in secure context + * Since log options are SUSET, we need to postpone unless still + * in secure context */ if (ctx == PGC_BACKEND) PendingConfigOption("log_statement_stats", "true"); @@ -2724,8 +2710,8 @@ PostgresMain(int argc, char *argv[], const char *username) } /* - * If a SUSET option, must postpone evaluation, unless - * we are still reading secure switches. + * If a SUSET option, must postpone evaluation, unless we + * are still reading secure switches. */ if (ctx == PGC_BACKEND && IsSuperuserConfigOption(name)) PendingConfigOption(name, value); @@ -2744,8 +2730,8 @@ PostgresMain(int argc, char *argv[], const char *username) } /* - * Process any additional GUC variable settings passed in startup - * packet. These are handled exactly like command-line variables. + * Process any additional GUC variable settings passed in startup packet. + * These are handled exactly like command-line variables. */ if (MyProcPort != NULL) { @@ -2779,16 +2765,16 @@ PostgresMain(int argc, char *argv[], const char *username) /* * Set up signal handlers and masks. * - * Note that postmaster blocked all signals before forking child process, - * so there is no race condition whereby we might receive a signal - * before we have set up the handler. + * Note that postmaster blocked all signals before forking child process, so + * there is no race condition whereby we might receive a signal before we + * have set up the handler. * - * Also note: it's best not to use any signals that are SIG_IGNored in - * the postmaster. If such a signal arrives before we are able to - * change the handler to non-SIG_IGN, it'll get dropped. Instead, - * make a dummy handler in the postmaster to reserve the signal. (Of - * course, this isn't an issue for signals that are locally generated, - * such as SIGALRM and SIGPIPE.) + * Also note: it's best not to use any signals that are SIG_IGNored in the + * postmaster. If such a signal arrives before we are able to change the + * handler to non-SIG_IGN, it'll get dropped. Instead, make a dummy + * handler in the postmaster to reserve the signal. (Of course, this isn't + * an issue for signals that are locally generated, such as SIGALRM and + * SIGPIPE.) */ pqsignal(SIGHUP, SigHupHandler); /* set flag to read config file */ pqsignal(SIGINT, StatementCancelHandler); /* cancel current query */ @@ -2799,8 +2785,8 @@ PostgresMain(int argc, char *argv[], const char *username) /* * 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... + * returns to outer loop. This seems safer than forcing exit in the midst + * of output during who-knows-what operation... */ pqsignal(SIGPIPE, SIG_IGN); pqsignal(SIGUSR1, CatchupInterruptHandler); @@ -2808,11 +2794,9 @@ PostgresMain(int argc, char *argv[], const char *username) pqsignal(SIGFPE, FloatExceptionHandler); /* - * Reset some signals that are accepted by postmaster but not by - * backend + * Reset some signals that are accepted by postmaster but not by backend */ - pqsignal(SIGCHLD, SIG_DFL); /* system() requires this on some - * platforms */ + pqsignal(SIGCHLD, SIG_DFL); /* system() requires this on some platforms */ pqinitmask(); @@ -2833,8 +2817,8 @@ PostgresMain(int argc, char *argv[], const char *username) { ereport(FATAL, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("invalid command-line arguments for server process"), - errhint("Try \"%s --help\" for more information.", argv[0]))); + errmsg("invalid command-line arguments for server process"), + errhint("Try \"%s --help\" for more information.", argv[0]))); } BaseInit(); @@ -2848,7 +2832,7 @@ PostgresMain(int argc, char *argv[], const char *username) (errcode(ERRCODE_SYNTAX_ERROR), errmsg("%s: invalid command-line arguments", argv[0]), - errhint("Try \"%s --help\" for more information.", argv[0]))); + errhint("Try \"%s --help\" for more information.", argv[0]))); } else if (argc - optind == 1) dbname = argv[optind]; @@ -2861,8 +2845,8 @@ PostgresMain(int argc, char *argv[], const char *username) } /* - * Validate we have been given a reasonable-looking DataDir (if - * under postmaster, assume postmaster did this already). + * Validate we have been given a reasonable-looking DataDir (if under + * postmaster, assume postmaster did this already). */ Assert(DataDir); ValidatePgVersion(DataDir); @@ -2885,15 +2869,15 @@ PostgresMain(int argc, char *argv[], const char *username) on_shmem_exit(ShutdownXLOG, 0); /* - * Read any existing FSM cache file, and register to write one out - * at exit. + * Read any existing FSM cache file, and register to write one out at + * exit. */ LoadFreeSpaceMap(); on_shmem_exit(DumpFreeSpaceMap, 0); /* - * We have to build the flat file for pg_database, but not for - * the user and group tables, since we won't try to do authentication. + * We have to build the flat file for pg_database, but not for the + * user and group tables, since we won't try to do authentication. */ BuildFlatFiles(true); } @@ -2901,9 +2885,9 @@ PostgresMain(int argc, char *argv[], const char *username) /* * General initialization. * - * NOTE: if you are tempted to add code in this vicinity, consider - * putting it inside InitPostgres() instead. In particular, anything - * that involves database access should be there, not here. + * NOTE: if you are tempted to add code in this vicinity, consider putting it + * inside InitPostgres() instead. In particular, anything that involves + * database access should be there, not here. */ ereport(DEBUG3, (errmsg_internal("InitPostgres"))); @@ -2943,8 +2927,8 @@ PostgresMain(int argc, char *argv[], const char *username) BeginReportingGUCOptions(); /* - * Also set up handler to log session end; we have to wait till now - * to be sure Log_disconnections has its final value. + * Also set up handler to log session end; we have to wait till now to be + * sure Log_disconnections has its final value. */ if (IsUnderPostmaster && Log_disconnections) on_proc_exit(log_disconnections, 0); @@ -2989,17 +2973,16 @@ PostgresMain(int argc, char *argv[], const char *username) /* * POSTGRES main processing loop begins here * - * If an exception is encountered, processing resumes here so we abort - * the current transaction and start a new one. + * If an exception is encountered, processing resumes here so we abort the + * current transaction and start a new one. * - * You might wonder why this isn't coded as an infinite loop around a - * PG_TRY construct. The reason is that this is the bottom of the - * exception stack, and so with PG_TRY there would be no exception - * handler in force at all during the CATCH part. By leaving the - * outermost setjmp always active, we have at least some chance of - * recovering from an error during error recovery. (If we get into an - * infinite loop thereby, it will soon be stopped by overflow of - * elog.c's internal state stack.) + * You might wonder why this isn't coded as an infinite loop around a PG_TRY + * construct. The reason is that this is the bottom of the exception + * stack, and so with PG_TRY there would be no exception handler in force + * at all during the CATCH part. By leaving the outermost setjmp always + * active, we have at least some chance of recovering from an error during + * error recovery. (If we get into an infinite loop thereby, it will soon + * be stopped by overflow of elog.c's internal state stack.) */ if (sigsetjmp(local_sigjmp_buf, 1) != 0) @@ -3008,9 +2991,8 @@ PostgresMain(int argc, char *argv[], const char *username) * NOTE: if you are tempted to add more code in this if-block, * consider the high probability that it should be in * AbortTransaction() instead. The only stuff done directly here - * should be stuff that is guaranteed to apply *only* for - * outer-level error recovery, such as adjusting the FE/BE - * protocol status. + * should be stuff that is guaranteed to apply *only* for outer-level + * error recovery, such as adjusting the FE/BE protocol status. */ /* Since not using PG_TRY, must reset error stack by hand */ @@ -3020,18 +3002,17 @@ PostgresMain(int argc, char *argv[], const char *username) HOLD_INTERRUPTS(); /* - * Forget any pending QueryCancel request, since we're returning - * to the idle loop anyway, and cancel the statement timer if - * running. + * Forget any pending QueryCancel request, since we're returning to + * the idle loop anyway, and cancel the statement timer if running. */ QueryCancelPending = false; disable_sig_alarm(true); QueryCancelPending = false; /* again in case timeout occurred */ /* - * Turn off these interrupts too. This is only needed here and - * not in other exception-catching places since these interrupts - * are only enabled while we wait for client input. + * Turn off these interrupts too. This is only needed here and not in + * other exception-catching places since these interrupts are only + * enabled while we wait for client input. */ DoingCommandRead = false; DisableNotifyInterrupt(); @@ -3044,8 +3025,8 @@ PostgresMain(int argc, char *argv[], const char *username) EmitErrorReport(); /* - * Make sure debug_query_string gets reset before we possibly - * clobber the storage it points at. + * Make sure debug_query_string gets reset before we possibly clobber + * the storage it points at. */ debug_query_string = NULL; @@ -3055,16 +3036,16 @@ PostgresMain(int argc, char *argv[], const char *username) AbortCurrentTransaction(); /* - * Now return to normal top-level context and clear ErrorContext - * for next time. + * Now return to normal top-level context and clear ErrorContext for + * next time. */ MemoryContextSwitchTo(TopMemoryContext); FlushErrorState(); QueryContext = NULL; /* - * If we were handling an extended-query-protocol message, - * initiate skip till next Sync. This also causes us not to issue + * If we were handling an extended-query-protocol message, initiate + * skip till next Sync. This also causes us not to issue * ReadyForQuery (until we get Sync). */ if (doing_extended_query_message) @@ -3098,8 +3079,8 @@ PostgresMain(int argc, char *argv[], const char *username) doing_extended_query_message = false; /* - * Release storage left over from prior query cycle, and create a - * new query input buffer in the cleared MessageContext. + * Release storage left over from prior query cycle, and create a new + * query input buffer in the cleared MessageContext. */ MemoryContextSwitchTo(MessageContext); MemoryContextResetAndDeleteChildren(MessageContext); @@ -3107,16 +3088,16 @@ PostgresMain(int argc, char *argv[], const char *username) initStringInfo(&input_message); /* - * (1) If we've reached idle state, tell the frontend we're ready - * for a new query. + * (1) If we've reached idle state, tell the frontend we're ready for + * a new query. * * Note: this includes fflush()'ing the last of the prior output. * * This is also a good time to send collected statistics to the * collector, and to update the PS stats display. We avoid doing - * those every time through the message loop because it'd slow - * down processing of batched messages, and because we don't want - * to report uncommitted updates (that confuses autovacuum). + * those every time through the message loop because it'd slow down + * processing of batched messages, and because we don't want to report + * uncommitted updates (that confuses autovacuum). */ if (send_rfq) { @@ -3138,10 +3119,10 @@ PostgresMain(int argc, char *argv[], const char *username) } /* - * (2) Allow asynchronous signals to be executed immediately - * if they come in while we are waiting for client input. - * (This must be conditional since we don't want, say, reads on - * behalf of COPY FROM STDIN doing the same thing.) + * (2) Allow asynchronous signals to be executed immediately if they + * come in while we are waiting for client input. (This must be + * conditional since we don't want, say, reads on behalf of COPY FROM + * STDIN doing the same thing.) */ QueryCancelPending = false; /* forget any earlier CANCEL signal */ DoingCommandRead = true; @@ -3157,8 +3138,8 @@ PostgresMain(int argc, char *argv[], const char *username) DoingCommandRead = false; /* - * (5) check for any other interesting events that happened while - * we slept. + * (5) check for any other interesting events that happened while we + * slept. */ if (got_SIGHUP) { @@ -3216,8 +3197,8 @@ PostgresMain(int argc, char *argv[], const char *username) case 'B': /* bind */ /* - * this message is complex enough that it seems best to - * put the field extraction out-of-line + * this message is complex enough that it seems best to put + * the field extraction out-of-line */ exec_bind_message(&input_message); break; @@ -3306,8 +3287,8 @@ PostgresMain(int argc, char *argv[], const char *username) default: ereport(ERROR, (errcode(ERRCODE_PROTOCOL_VIOLATION), - errmsg("invalid CLOSE message subtype %d", - close_type))); + errmsg("invalid CLOSE message subtype %d", + close_type))); break; } @@ -3336,8 +3317,8 @@ PostgresMain(int argc, char *argv[], const char *username) default: ereport(ERROR, (errcode(ERRCODE_PROTOCOL_VIOLATION), - errmsg("invalid DESCRIBE message subtype %d", - describe_type))); + errmsg("invalid DESCRIBE message subtype %d", + describe_type))); break; } } @@ -3356,16 +3337,16 @@ PostgresMain(int argc, char *argv[], const char *username) break; /* - * 'X' means that the frontend is closing down the socket. - * EOF means unexpected loss of frontend connection. - * Either way, perform normal shutdown. + * 'X' means that the frontend is closing down the socket. EOF + * means unexpected loss of frontend connection. Either way, + * perform normal shutdown. */ case 'X': case EOF: /* - * Reset whereToSendOutput to prevent ereport from - * attempting to send any more messages to client. + * Reset whereToSendOutput to prevent ereport from attempting + * to send any more messages to client. */ if (whereToSendOutput == Remote) whereToSendOutput = None; @@ -3373,9 +3354,9 @@ PostgresMain(int argc, char *argv[], const char *username) /* * NOTE: if you are tempted to add more code here, DON'T! * Whatever you had in mind to do should be set up as an - * on_proc_exit or on_shmem_exit callback, instead. - * Otherwise it will fail to be called during other - * backend-shutdown scenarios. + * on_proc_exit or on_shmem_exit callback, instead. Otherwise + * it will fail to be called during other backend-shutdown + * scenarios. */ proc_exit(0); @@ -3385,8 +3366,8 @@ PostgresMain(int argc, char *argv[], const char *username) /* * Accept but ignore these messages, per protocol spec; we - * probably got here because a COPY failed, and the - * frontend is still sending data. + * probably got here because a COPY failed, and the frontend + * is still sending data. */ break; @@ -3454,23 +3435,22 @@ ShowUsage(const char *title) /* * the only stats we don't show here are for memory usage -- i can't - * figure out how to interpret the relevant fields in the rusage - * struct, and they change names across o/s platforms, anyway. if you - * can figure out what the entries mean, you can somehow extract - * resident set size, shared text size, and unshared data and stack - * sizes. + * figure out how to interpret the relevant fields in the rusage struct, + * and they change names across o/s platforms, anyway. if you can figure + * out what the entries mean, you can somehow extract resident set size, + * shared text size, and unshared data and stack sizes. */ initStringInfo(&str); appendStringInfo(&str, "! system usage stats:\n"); appendStringInfo(&str, - "!\t%ld.%06ld elapsed %ld.%06ld user %ld.%06ld system sec\n", + "!\t%ld.%06ld elapsed %ld.%06ld user %ld.%06ld system sec\n", (long) (elapse_t.tv_sec - Save_t.tv_sec), (long) (elapse_t.tv_usec - Save_t.tv_usec), (long) (r.ru_utime.tv_sec - Save_r.ru_utime.tv_sec), - (long) (r.ru_utime.tv_usec - Save_r.ru_utime.tv_usec), + (long) (r.ru_utime.tv_usec - Save_r.ru_utime.tv_usec), (long) (r.ru_stime.tv_sec - Save_r.ru_stime.tv_sec), - (long) (r.ru_stime.tv_usec - Save_r.ru_stime.tv_usec)); + (long) (r.ru_stime.tv_usec - Save_r.ru_stime.tv_usec)); appendStringInfo(&str, "!\t[%ld.%06ld user %ld.%06ld sys total]\n", (long) user.tv_sec, @@ -3486,21 +3466,21 @@ ShowUsage(const char *title) r.ru_oublock - Save_r.ru_oublock, r.ru_inblock, r.ru_oublock); appendStringInfo(&str, - "!\t%ld/%ld [%ld/%ld] page faults/reclaims, %ld [%ld] swaps\n", + "!\t%ld/%ld [%ld/%ld] page faults/reclaims, %ld [%ld] swaps\n", r.ru_majflt - Save_r.ru_majflt, r.ru_minflt - Save_r.ru_minflt, r.ru_majflt, r.ru_minflt, r.ru_nswap - Save_r.ru_nswap, r.ru_nswap); appendStringInfo(&str, - "!\t%ld [%ld] signals rcvd, %ld/%ld [%ld/%ld] messages rcvd/sent\n", + "!\t%ld [%ld] signals rcvd, %ld/%ld [%ld/%ld] messages rcvd/sent\n", r.ru_nsignals - Save_r.ru_nsignals, r.ru_nsignals, r.ru_msgrcv - Save_r.ru_msgrcv, r.ru_msgsnd - Save_r.ru_msgsnd, r.ru_msgrcv, r.ru_msgsnd); appendStringInfo(&str, - "!\t%ld/%ld [%ld/%ld] voluntary/involuntary context switches\n", + "!\t%ld/%ld [%ld/%ld] voluntary/involuntary context switches\n", r.ru_nvcsw - Save_r.ru_nvcsw, r.ru_nivcsw - Save_r.ru_nivcsw, r.ru_nvcsw, r.ru_nivcsw); @@ -3527,11 +3507,11 @@ ShowUsage(const char *title) static void log_disconnections(int code, Datum arg) { - Port *port = MyProcPort; - struct timeval end; - int hours, - minutes, - seconds; + Port *port = MyProcPort; + struct timeval end; + int hours, + minutes, + seconds; gettimeofday(&end, NULL); if (end.tv_usec < port->session_start.tv_usec) @@ -3553,5 +3533,5 @@ log_disconnections(int code, Datum arg) "user=%s database=%s host=%s%s%s", hours, minutes, seconds, (int) (end.tv_usec / 10000), port->user_name, port->database_name, port->remote_host, - port->remote_port[0] ? " port=" : "", port->remote_port))); + port->remote_port[0] ? " port=" : "", port->remote_port))); } diff --git a/src/backend/tcop/pquery.c b/src/backend/tcop/pquery.c index 75eb75f6de..edf2ba44ae 100644 --- a/src/backend/tcop/pquery.c +++ b/src/backend/tcop/pquery.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/tcop/pquery.c,v 1.94 2005/06/22 17:45:46 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/tcop/pquery.c,v 1.95 2005/10/15 02:49:27 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -72,7 +72,7 @@ CreateQueryDesc(Query *parsetree, qd->parsetree = parsetree; /* parse tree */ qd->plantree = plantree; /* plan */ qd->snapshot = snapshot; /* snapshot */ - qd->crosscheck_snapshot = crosscheck_snapshot; /* RI check snapshot */ + qd->crosscheck_snapshot = crosscheck_snapshot; /* RI check snapshot */ qd->dest = dest; /* output dest */ qd->params = params; /* parameter values passed into query */ qd->doInstrument = doInstrument; /* instrumentation wanted? */ @@ -138,16 +138,16 @@ ProcessQuery(Query *parsetree, * SELECT INTO table (a/k/a CREATE AS ... SELECT). * * Override the normal communication destination; execMain.c - * special-cases this case. (Perhaps would be cleaner to have - * an additional destination type?) + * special-cases this case. (Perhaps would be cleaner to have an + * additional destination type?) */ dest = None_Receiver; } } /* - * Must always set snapshot for plannable queries. Note we assume - * that caller will take care of restoring ActiveSnapshot on exit/error. + * Must always set snapshot for plannable queries. Note we assume that + * caller will take care of restoring ActiveSnapshot on exit/error. */ ActiveSnapshot = CopySnapshot(GetTransactionSnapshot()); @@ -191,7 +191,7 @@ ProcessQuery(Query *parsetree, else lastOid = InvalidOid; snprintf(completionTag, COMPLETION_TAG_BUFSIZE, - "INSERT %u %u", lastOid, queryDesc->estate->es_processed); + "INSERT %u %u", lastOid, queryDesc->estate->es_processed); break; case CMD_UPDATE: snprintf(completionTag, COMPLETION_TAG_BUFSIZE, @@ -270,31 +270,31 @@ FetchPortalTargetList(Portal portal) return ((Query *) linitial(portal->parseTrees))->targetList; if (portal->strategy == PORTAL_UTIL_SELECT) { - Node *utilityStmt; + Node *utilityStmt; utilityStmt = ((Query *) linitial(portal->parseTrees))->utilityStmt; switch (nodeTag(utilityStmt)) { case T_FetchStmt: - { - FetchStmt *substmt = (FetchStmt *) utilityStmt; - Portal subportal; + { + FetchStmt *substmt = (FetchStmt *) utilityStmt; + Portal subportal; - Assert(!substmt->ismove); - subportal = GetPortalByName(substmt->portalname); - Assert(PortalIsValid(subportal)); - return FetchPortalTargetList(subportal); - } + Assert(!substmt->ismove); + subportal = GetPortalByName(substmt->portalname); + Assert(PortalIsValid(subportal)); + return FetchPortalTargetList(subportal); + } case T_ExecuteStmt: - { - ExecuteStmt *substmt = (ExecuteStmt *) utilityStmt; - PreparedStatement *entry; + { + ExecuteStmt *substmt = (ExecuteStmt *) utilityStmt; + PreparedStatement *entry; - Assert(!substmt->into); - entry = FetchPreparedStatement(substmt->name, true); - return FetchPreparedStatementTargetList(entry); - } + Assert(!substmt->into); + entry = FetchPreparedStatement(substmt->name, true); + return FetchPreparedStatementTargetList(entry); + } default: break; @@ -335,8 +335,7 @@ PortalStart(Portal portal, ParamListInfo params, Snapshot snapshot) AssertState(portal->status == PORTAL_NEW); /* else extra PortalStart */ /* - * Set up global portal context pointers. (Should we set - * QueryContext?) + * Set up global portal context pointers. (Should we set QueryContext?) */ saveActivePortal = ActivePortal; saveActiveSnapshot = ActiveSnapshot; @@ -345,7 +344,7 @@ PortalStart(Portal portal, ParamListInfo params, Snapshot snapshot) PG_TRY(); { ActivePortal = portal; - ActiveSnapshot = NULL; /* will be set later */ + ActiveSnapshot = NULL; /* will be set later */ CurrentResourceOwner = portal->resowner; PortalContext = PortalGetHeapMemory(portal); @@ -367,7 +366,7 @@ PortalStart(Portal portal, ParamListInfo params, Snapshot snapshot) case PORTAL_ONE_SELECT: /* - * Must set snapshot before starting executor. Be sure to + * Must set snapshot before starting executor. Be sure to * copy it into the portal's context. */ if (snapshot) @@ -376,11 +375,11 @@ PortalStart(Portal portal, ParamListInfo params, Snapshot snapshot) ActiveSnapshot = CopySnapshot(GetTransactionSnapshot()); /* - * Create QueryDesc in portal's context; for the moment, - * set the destination to None. + * Create QueryDesc in portal's context; for the moment, set + * the destination to None. */ queryDesc = CreateQueryDesc((Query *) linitial(portal->parseTrees), - (Plan *) linitial(portal->planTrees), + (Plan *) linitial(portal->planTrees), ActiveSnapshot, InvalidSnapshot, None_Receiver, @@ -388,10 +387,10 @@ PortalStart(Portal portal, ParamListInfo params, Snapshot snapshot) false); /* - * We do *not* call AfterTriggerBeginQuery() here. We - * assume that a SELECT cannot queue any triggers. It - * would be messy to support triggers since the execution - * of the portal may be interleaved with other queries. + * We do *not* call AfterTriggerBeginQuery() here. We assume + * that a SELECT cannot queue any triggers. It would be messy + * to support triggers since the execution of the portal may + * be interleaved with other queries. */ /* @@ -421,8 +420,8 @@ PortalStart(Portal portal, ParamListInfo params, Snapshot snapshot) case PORTAL_UTIL_SELECT: /* - * We don't set snapshot here, because - * PortalRunUtility will take care of it if needed. + * We don't set snapshot here, because PortalRunUtility will + * take care of it if needed. */ portal->tupDesc = UtilityTupleDescriptor(((Query *) linitial(portal->parseTrees))->utilityStmt); @@ -579,14 +578,14 @@ PortalRun(Portal portal, long count, * * We have to play a special game here to support utility commands like * VACUUM and CLUSTER, which internally start and commit transactions. - * When we are called to execute such a command, CurrentResourceOwner - * will be pointing to the TopTransactionResourceOwner --- which will - * be destroyed and replaced in the course of the internal commit and - * restart. So we need to be prepared to restore it as pointing to - * the exit-time TopTransactionResourceOwner. (Ain't that ugly? This - * idea of internally starting whole new transactions is not good.) - * CurrentMemoryContext has a similar problem, but the other pointers - * we save here will be NULL or pointing to longer-lived objects. + * When we are called to execute such a command, CurrentResourceOwner will + * be pointing to the TopTransactionResourceOwner --- which will be + * destroyed and replaced in the course of the internal commit and + * restart. So we need to be prepared to restore it as pointing to the + * exit-time TopTransactionResourceOwner. (Ain't that ugly? This idea of + * internally starting whole new transactions is not good.) + * CurrentMemoryContext has a similar problem, but the other pointers we + * save here will be NULL or pointing to longer-lived objects. */ saveTopTransactionResourceOwner = TopTransactionResourceOwner; saveTopTransactionContext = TopTransactionContext; @@ -599,7 +598,7 @@ PortalRun(Portal portal, long count, PG_TRY(); { ActivePortal = portal; - ActiveSnapshot = NULL; /* will be set later */ + ActiveSnapshot = NULL; /* will be set later */ CurrentResourceOwner = portal->resowner; PortalContext = PortalGetHeapMemory(portal); QueryContext = portal->queryContext; @@ -618,8 +617,7 @@ PortalRun(Portal portal, long count, portal->status = PORTAL_READY; /* - * Since it's a forward fetch, say DONE iff atEnd is now - * true. + * Since it's a forward fetch, say DONE iff atEnd is now true. */ result = portal->atEnd; break; @@ -658,8 +656,7 @@ PortalRun(Portal portal, long count, portal->status = PORTAL_READY; /* - * Since it's a forward fetch, say DONE iff atEnd is now - * true. + * Since it's a forward fetch, say DONE iff atEnd is now true. */ result = portal->atEnd; break; @@ -750,8 +747,8 @@ PortalRunSelect(Portal portal, uint32 nprocessed; /* - * NB: queryDesc will be NULL if we are fetching from a held cursor or - * a completed utility query; can't use it in that path. + * NB: queryDesc will be NULL if we are fetching from a held cursor or a + * completed utility query; can't use it in that path. */ queryDesc = PortalGetQueryDesc(portal); @@ -768,15 +765,15 @@ PortalRunSelect(Portal portal, queryDesc->dest = dest; /* - * Determine which direction to go in, and check to see if we're - * already at the end of the available tuples in that direction. If - * so, set the direction to NoMovement to avoid trying to fetch any - * tuples. (This check exists because not all plan node types are - * robust about being called again if they've already returned NULL - * once.) Then call the executor (we must not skip this, because the - * destination needs to see a setup and shutdown even if no tuples are - * available). Finally, update the portal position state depending on - * the number of tuples that were retrieved. + * Determine which direction to go in, and check to see if we're already + * at the end of the available tuples in that direction. If so, set the + * direction to NoMovement to avoid trying to fetch any tuples. (This + * check exists because not all plan node types are robust about being + * called again if they've already returned NULL once.) Then call the + * executor (we must not skip this, because the destination needs to see a + * setup and shutdown even if no tuples are available). Finally, update + * the portal position state depending on the number of tuples that were + * retrieved. */ if (forward) { @@ -924,9 +921,9 @@ RunFromStore(Portal portal, ScanDirection direction, long count, ExecClearTuple(slot); /* - * check our tuple count.. if we've processed the proper - * number then quit, else loop again and process more tuples. - * Zero count means no limit. + * check our tuple count.. if we've processed the proper number + * then quit, else loop again and process more tuples. Zero count + * means no limit. */ current_tuple_count++; if (count && count == current_tuple_count) @@ -955,19 +952,18 @@ PortalRunUtility(Portal portal, Query *query, (errmsg_internal("ProcessUtility"))); /* - * Set snapshot if utility stmt needs one. Most reliable way to do - * this seems to be to enumerate those that do not need one; this is a - * short list. Transaction control, LOCK, and SET must *not* set a - * snapshot since they need to be executable at the start of a - * serializable transaction without freezing a snapshot. By extension - * we allow SHOW not to set a snapshot. The other stmts listed are - * just efficiency hacks. Beware of listing anything that can modify - * the database --- if, say, it has to update an index with - * expressions that invoke user-defined functions, then it had better - * have a snapshot. + * Set snapshot if utility stmt needs one. Most reliable way to do this + * seems to be to enumerate those that do not need one; this is a short + * list. Transaction control, LOCK, and SET must *not* set a snapshot + * since they need to be executable at the start of a serializable + * transaction without freezing a snapshot. By extension we allow SHOW + * not to set a snapshot. The other stmts listed are just efficiency + * hacks. Beware of listing anything that can modify the database --- if, + * say, it has to update an index with expressions that invoke + * user-defined functions, then it had better have a snapshot. * - * Note we assume that caller will take care of restoring ActiveSnapshot - * on exit/error. + * Note we assume that caller will take care of restoring ActiveSnapshot on + * exit/error. */ if (!(IsA(utilityStmt, TransactionStmt) || IsA(utilityStmt, LockStmt) || @@ -1020,13 +1016,13 @@ PortalRunMulti(Portal portal, /* * If the destination is RemoteExecute, change to None. The reason is - * that the client won't be expecting any tuples, and indeed has no - * way to know what they are, since there is no provision for Describe - * to send a RowDescription message when this portal execution - * strategy is in effect. This presently will only affect SELECT - * commands added to non-SELECT queries by rewrite rules: such - * commands will be executed, but the results will be discarded unless - * you use "simple Query" protocol. + * that the client won't be expecting any tuples, and indeed has no way to + * know what they are, since there is no provision for Describe to send a + * RowDescription message when this portal execution strategy is in + * effect. This presently will only affect SELECT commands added to + * non-SELECT queries by rewrite rules: such commands will be executed, + * but the results will be discarded unless you use "simple Query" + * protocol. */ if (dest->mydest == RemoteExecute) dest = None_Receiver; @@ -1034,8 +1030,8 @@ PortalRunMulti(Portal portal, altdest = None_Receiver; /* - * Loop to handle the individual queries generated from a single - * parsetree by analysis and rewrite. + * Loop to handle the individual queries generated from a single parsetree + * by analysis and rewrite. */ forboth(querylist_item, portal->parseTrees, planlist_item, portal->planTrees) @@ -1087,8 +1083,8 @@ PortalRunMulti(Portal portal, } /* - * Increment command counter between queries, but not after the - * last one. + * Increment command counter between queries, but not after the last + * one. */ if (lnext(planlist_item) != NULL) CommandCounterIncrement(); @@ -1102,12 +1098,12 @@ PortalRunMulti(Portal portal, } /* - * If a command completion tag was supplied, use it. Otherwise use - * the portal's commandTag as the default completion tag. + * If a command completion tag was supplied, use it. Otherwise use the + * portal's commandTag as the default completion tag. * - * Exception: clients will expect INSERT/UPDATE/DELETE tags to have - * counts, so fake something up if necessary. (This could happen if - * the original query was replaced by a DO INSTEAD rule.) + * Exception: clients will expect INSERT/UPDATE/DELETE tags to have counts, + * so fake something up if necessary. (This could happen if the original + * query was replaced by a DO INSTEAD rule.) */ if (completionTag && completionTag[0] == '\0') { @@ -1164,7 +1160,7 @@ PortalRunFetch(Portal portal, PG_TRY(); { ActivePortal = portal; - ActiveSnapshot = NULL; /* will be set later */ + ActiveSnapshot = NULL; /* will be set later */ CurrentResourceOwner = portal->resowner; PortalContext = PortalGetHeapMemory(portal); QueryContext = portal->queryContext; @@ -1276,11 +1272,11 @@ DoPortalRunFetch(Portal portal, if (count > 0) { /* - * Definition: Rewind to start, advance count-1 rows, - * return next row (if any). In practice, if the goal is - * less than halfway back to the start, it's better to - * scan from where we are. In any case, we arrange to - * fetch the target row going forwards. + * Definition: Rewind to start, advance count-1 rows, return + * next row (if any). In practice, if the goal is less than + * halfway back to the start, it's better to scan from where + * we are. In any case, we arrange to fetch the target row + * going forwards. */ if (portal->posOverflow || portal->portalPos == LONG_MAX || count - 1 <= portal->portalPos / 2) @@ -1309,11 +1305,10 @@ DoPortalRunFetch(Portal portal, { /* * Definition: Advance to end, back up abs(count)-1 rows, - * return prior row (if any). We could optimize this if - * we knew in advance where the end was, but typically we - * won't. (Is it worth considering case where count > half - * of size of query? We could rewind once we know the - * size ...) + * return prior row (if any). We could optimize this if we + * knew in advance where the end was, but typically we won't. + * (Is it worth considering case where count > half of size of + * query? We could rewind once we know the size ...) */ PortalRunSelect(portal, true, FETCH_ALL, None_Receiver); if (count < -1) @@ -1332,8 +1327,7 @@ DoPortalRunFetch(Portal portal, if (count > 0) { /* - * Definition: advance count-1 rows, return next row (if - * any). + * Definition: advance count-1 rows, return next row (if any). */ if (count > 1) PortalRunSelect(portal, true, count - 1, None_Receiver); @@ -1342,8 +1336,8 @@ DoPortalRunFetch(Portal portal, else if (count < 0) { /* - * Definition: back up abs(count)-1 rows, return prior row - * (if any). + * Definition: back up abs(count)-1 rows, return prior row (if + * any). */ if (count < -1) PortalRunSelect(portal, false, -count - 1, None_Receiver); @@ -1362,8 +1356,8 @@ DoPortalRunFetch(Portal portal, } /* - * Get here with fdirection == FETCH_FORWARD or FETCH_BACKWARD, and - * count >= 0. + * Get here with fdirection == FETCH_FORWARD or FETCH_BACKWARD, and count + * >= 0. */ forward = (fdirection == FETCH_FORWARD); @@ -1385,11 +1379,11 @@ DoPortalRunFetch(Portal portal, else { /* - * If we are sitting on a row, back up one so we can re-fetch - * it. If we are not sitting on a row, we still have to start - * up and shut down the executor so that the destination is - * initialized and shut down correctly; so keep going. To - * PortalRunSelect, count == 0 means we will retrieve no row. + * If we are sitting on a row, back up one so we can re-fetch it. + * If we are not sitting on a row, we still have to start up and + * shut down the executor so that the destination is initialized + * and shut down correctly; so keep going. To PortalRunSelect, + * count == 0 means we will retrieve no row. */ if (on_row) { diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c index dd89832da8..8e3c900053 100644 --- a/src/backend/tcop/utility.c +++ b/src/backend/tcop/utility.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.244 2005/10/06 21:30:36 neilc Exp $ + * $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.245 2005/10/15 02:49:27 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -214,8 +214,8 @@ CheckRelationOwnership(RangeVar *rel, bool noCatalogs) IsSystemClass((Form_pg_class) GETSTRUCT(tuple))) ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), - errmsg("permission denied: \"%s\" is a system catalog", - rel->relname))); + errmsg("permission denied: \"%s\" is a system catalog", + rel->relname))); } ReleaseSysCache(tuple); @@ -236,9 +236,9 @@ QueryIsReadOnly(Query *parsetree) { case CMD_SELECT: if (parsetree->into != NULL) - return false; /* SELECT INTO */ + return false; /* SELECT INTO */ else if (parsetree->rowMarks != NIL) - return false; /* SELECT FOR UPDATE/SHARE */ + return false; /* SELECT FOR UPDATE/SHARE */ else return true; case CMD_UPDATE: @@ -269,8 +269,8 @@ check_xact_readonly(Node *parsetree) return; /* - * Note: Commands that need to do more complicated checking are - * handled elsewhere. + * Note: Commands that need to do more complicated checking are handled + * elsewhere. */ switch (nodeTag(parsetree)) @@ -367,8 +367,8 @@ ProcessUtility(Node *parsetree, switch (stmt->kind) { /* - * START TRANSACTION, as defined by SQL99: - * Identical to BEGIN. Same code for both. + * START TRANSACTION, as defined by SQL99: Identical + * to BEGIN. Same code for both. */ case TRANS_STMT_BEGIN: case TRANS_STMT_START: @@ -498,8 +498,8 @@ ProcessUtility(Node *parsetree, RELKIND_RELATION); /* - * Let AlterTableCreateToastTable decide if this one needs - * a secondary relation too. + * Let AlterTableCreateToastTable decide if this one needs a + * secondary relation too. */ CommandCounterIncrement(); AlterTableCreateToastTable(relOid, true); @@ -558,8 +558,7 @@ ProcessUtility(Node *parsetree, case OBJECT_DOMAIN: /* - * RemoveDomain does its own permissions - * checks + * RemoveDomain does its own permissions checks */ RemoveDomain(names, stmt->behavior); break; @@ -571,8 +570,7 @@ ProcessUtility(Node *parsetree, case OBJECT_SCHEMA: /* - * RemoveSchema does its own permissions - * checks + * RemoveSchema does its own permissions checks */ RemoveSchema(names, stmt->behavior); break; @@ -584,8 +582,8 @@ ProcessUtility(Node *parsetree, } /* - * We used to need to do CommandCounterIncrement() - * here, but now it's done inside performDeletion(). + * We used to need to do CommandCounterIncrement() here, + * but now it's done inside performDeletion(). */ } } @@ -651,8 +649,8 @@ ProcessUtility(Node *parsetree, case 'T': /* ALTER DOMAIN DEFAULT */ /* - * Recursively alter column default for table and, - * if requested, for descendants + * Recursively alter column default for table and, if + * requested, for descendants */ AlterDomainDefault(stmt->typename, stmt->def); @@ -691,8 +689,7 @@ ProcessUtility(Node *parsetree, break; /* - * ******************************** object creation / - * destruction ******************************** + * ******************************** object creation / destruction ******************************** * */ case T_DefineStmt: @@ -738,7 +735,7 @@ ProcessUtility(Node *parsetree, CreateFunction((CreateFunctionStmt *) parsetree); break; - case T_AlterFunctionStmt: /* ALTER FUNCTION */ + case T_AlterFunctionStmt: /* ALTER FUNCTION */ AlterFunction((AlterFunctionStmt *) parsetree); break; @@ -750,7 +747,7 @@ ProcessUtility(Node *parsetree, DefineIndex(stmt->relation, /* relation */ stmt->idxname, /* index name */ - InvalidOid, /* no predefined OID */ + InvalidOid, /* no predefined OID */ stmt->accessMethod, /* am name */ stmt->tableSpace, stmt->indexParams, /* parameters */ @@ -865,8 +862,8 @@ ProcessUtility(Node *parsetree, VariableSetStmt *n = (VariableSetStmt *) parsetree; /* - * Special cases for special SQL syntax that effectively - * sets more than one variable per statement. + * Special cases for special SQL syntax that effectively sets + * more than one variable per statement. */ if (strcmp(n->name, "TRANSACTION") == 0) { @@ -878,10 +875,10 @@ ProcessUtility(Node *parsetree, if (strcmp(item->defname, "transaction_isolation") == 0) SetPGVariable("transaction_isolation", - list_make1(item->arg), n->is_local); + list_make1(item->arg), n->is_local); else if (strcmp(item->defname, "transaction_read_only") == 0) SetPGVariable("transaction_read_only", - list_make1(item->arg), n->is_local); + list_make1(item->arg), n->is_local); } } else if (strcmp(n->name, "SESSION CHARACTERISTICS") == 0) @@ -894,10 +891,10 @@ ProcessUtility(Node *parsetree, if (strcmp(item->defname, "transaction_isolation") == 0) SetPGVariable("default_transaction_isolation", - list_make1(item->arg), n->is_local); + list_make1(item->arg), n->is_local); else if (strcmp(item->defname, "transaction_read_only") == 0) SetPGVariable("default_transaction_read_only", - list_make1(item->arg), n->is_local); + list_make1(item->arg), n->is_local); } } else @@ -1380,30 +1377,30 @@ CreateCommandTag(Node *parsetree) break; case T_AlterObjectSchemaStmt: - switch (((AlterObjectSchemaStmt *) parsetree)->objectType) - { + switch (((AlterObjectSchemaStmt *) parsetree)->objectType) + { case OBJECT_AGGREGATE: - tag = "ALTER AGGREGATE"; - break; + tag = "ALTER AGGREGATE"; + break; case OBJECT_DOMAIN: - tag = "ALTER DOMAIN"; - break; + tag = "ALTER DOMAIN"; + break; case OBJECT_FUNCTION: - tag = "ALTER FUNCTION"; - break; + tag = "ALTER FUNCTION"; + break; case OBJECT_SEQUENCE: - tag = "ALTER SEQUENCE"; - break; + tag = "ALTER SEQUENCE"; + break; case OBJECT_TABLE: - tag = "ALTER TABLE"; - break; + tag = "ALTER TABLE"; + break; case OBJECT_TYPE: - tag = "ALTER TYPE"; - break; + tag = "ALTER TYPE"; + break; default: tag = "???"; break; - } + } break; case T_AlterOwnerStmt: @@ -1480,7 +1477,7 @@ CreateCommandTag(Node *parsetree) case T_GrantRoleStmt: { - GrantRoleStmt *stmt = (GrantRoleStmt *) parsetree; + GrantRoleStmt *stmt = (GrantRoleStmt *) parsetree; tag = (stmt->is_grant) ? "GRANT ROLE" : "REVOKE ROLE"; } @@ -1717,9 +1714,10 @@ CreateQueryTag(Query *parsetree) switch (parsetree->commandType) { case CMD_SELECT: + /* - * We take a little extra care here so that the result will - * be useful for complaints about read-only statements + * We take a little extra care here so that the result will be + * useful for complaints about read-only statements */ if (parsetree->into != NULL) tag = "SELECT INTO"; diff --git a/src/backend/utils/adt/acl.c b/src/backend/utils/adt/acl.c index 9909640ad4..5fcb9b25fc 100644 --- a/src/backend/utils/adt/acl.c +++ b/src/backend/utils/adt/acl.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/acl.c,v 1.125 2005/10/10 18:49:03 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/acl.c,v 1.126 2005/10/15 02:49:27 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -59,9 +59,9 @@ * The cache is valid if cached_member_role is not InvalidOid. */ static Oid cached_privs_role = InvalidOid; -static List *cached_privs_roles = NIL; +static List *cached_privs_roles = NIL; static Oid cached_member_role = InvalidOid; -static List *cached_membership_roles = NIL; +static List *cached_membership_roles = NIL; static const char *getid(const char *s, char *n); @@ -73,7 +73,7 @@ static void check_circularity(const Acl *old_acl, const AclItem *mod_aip, Oid ownerId); static Acl *recursive_revoke(Acl *acl, Oid grantee, AclMode revoke_privs, Oid ownerId, DropBehavior behavior); -static int oidComparator(const void *arg1, const void *arg2); +static int oidComparator(const void *arg1, const void *arg2); static AclMode convert_priv_string(text *priv_type_text); @@ -143,8 +143,8 @@ getid(const char *s, char *n) ereport(ERROR, (errcode(ERRCODE_NAME_TOO_LONG), errmsg("identifier too long"), - errdetail("Identifier must be less than %d characters.", - NAMEDATALEN))); + errdetail("Identifier must be less than %d characters.", + NAMEDATALEN))); n[len++] = *s; } @@ -230,7 +230,7 @@ aclparse(const char *s, AclItem *aip) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), errmsg("unrecognized key word: \"%s\"", name), - errhint("ACL key word must be \"group\" or \"user\"."))); + errhint("ACL key word must be \"group\" or \"user\"."))); s = getid(s, name); /* move s to the name beyond the keyword */ if (name[0] == '\0') ereport(ERROR, @@ -289,8 +289,8 @@ aclparse(const char *s, AclItem *aip) default: ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid mode character: must be one of \"%s\"", - ACL_ALL_RIGHTS_STR))); + errmsg("invalid mode character: must be one of \"%s\"", + ACL_ALL_RIGHTS_STR))); } privs |= read; @@ -302,8 +302,8 @@ aclparse(const char *s, AclItem *aip) aip->ai_grantee = get_roleid_checked(name); /* - * XXX Allow a degree of backward compatibility by defaulting the - * grantor to the superuser. + * XXX Allow a degree of backward compatibility by defaulting the grantor + * to the superuser. */ if (*s == '/') { @@ -380,7 +380,7 @@ aclitemin(PG_FUNCTION_ARGS) if (*s) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("extra garbage at the end of the ACL specification"))); + errmsg("extra garbage at the end of the ACL specification"))); PG_RETURN_ACLITEM_P(aip); } @@ -565,14 +565,14 @@ acldefault(GrantObjectType objtype, Oid ownerId) } /* - * Note that the owner's entry shows all ordinary privileges but no - * grant options. This is because his grant options come "from the - * system" and not from his own efforts. (The SQL spec says that the - * owner's rights come from a "_SYSTEM" authid.) However, we do - * consider that the owner's ordinary privileges are self-granted; - * this lets him revoke them. We implement the owner's grant options - * without any explicit "_SYSTEM"-like ACL entry, by internally - * special-casing the owner whereever we are testing grant options. + * Note that the owner's entry shows all ordinary privileges but no grant + * options. This is because his grant options come "from the system" and + * not from his own efforts. (The SQL spec says that the owner's rights + * come from a "_SYSTEM" authid.) However, we do consider that the + * owner's ordinary privileges are self-granted; this lets him revoke + * them. We implement the owner's grant options without any explicit + * "_SYSTEM"-like ACL entry, by internally special-casing the owner + * whereever we are testing grant options. */ aip->ai_grantee = ownerId; aip->ai_grantor = ownerId; @@ -631,10 +631,10 @@ aclupdate(const Acl *old_acl, const AclItem *mod_aip, old_aip = ACL_DAT(old_acl); /* - * Search the ACL for an existing entry for this grantee and grantor. - * If one exists, just modify the entry in-place (well, in the same - * position, since we actually return a copy); otherwise, insert the - * new entry at the end. + * Search the ACL for an existing entry for this grantee and grantor. If + * one exists, just modify the entry in-place (well, in the same position, + * since we actually return a copy); otherwise, insert the new entry at + * the end. */ for (dst = 0; dst < num; ++dst) @@ -676,7 +676,7 @@ aclupdate(const Acl *old_acl, const AclItem *mod_aip, break; case ACL_MODECHG_DEL: ACLITEM_SET_RIGHTS(new_aip[dst], - old_rights & ~ACLITEM_GET_RIGHTS(*mod_aip)); + old_rights & ~ACLITEM_GET_RIGHTS(*mod_aip)); break; case ACL_MODECHG_EQL: ACLITEM_SET_RIGHTS(new_aip[dst], @@ -700,8 +700,8 @@ aclupdate(const Acl *old_acl, const AclItem *mod_aip, } /* - * Remove abandoned privileges (cascading revoke). Currently we can - * only handle this when the grantee is not PUBLIC. + * Remove abandoned privileges (cascading revoke). Currently we can only + * handle this when the grantee is not PUBLIC. */ if ((old_goptions & ~new_goptions) != 0) { @@ -742,8 +742,8 @@ aclnewowner(const Acl *old_acl, Oid oldOwnerId, Oid newOwnerId) /* * Make a copy of the given ACL, substituting new owner ID for old - * wherever it appears as either grantor or grantee. Also note if the - * new owner ID is already present. + * wherever it appears as either grantor or grantee. Also note if the new + * owner ID is already present. */ num = ACL_NUM(old_acl); old_aip = ACL_DAT(old_acl); @@ -763,21 +763,20 @@ aclnewowner(const Acl *old_acl, Oid oldOwnerId, Oid newOwnerId) } /* - * If the old ACL contained any references to the new owner, then we - * may now have generated an ACL containing duplicate entries. Find - * them and merge them so that there are not duplicates. (This is - * relatively expensive since we use a stupid O(N^2) algorithm, but - * it's unlikely to be the normal case.) + * If the old ACL contained any references to the new owner, then we may + * now have generated an ACL containing duplicate entries. Find them and + * merge them so that there are not duplicates. (This is relatively + * expensive since we use a stupid O(N^2) algorithm, but it's unlikely to + * be the normal case.) * - * To simplify deletion of duplicate entries, we temporarily leave them - * in the array but set their privilege masks to zero; when we reach - * such an entry it's just skipped. (Thus, a side effect of this code - * will be to remove privilege-free entries, should there be any in - * the input.) dst is the next output slot, targ is the currently - * considered input slot (always >= dst), and src scans entries to the - * right of targ looking for duplicates. Once an entry has been - * emitted to dst it is known duplicate-free and need not be - * considered anymore. + * To simplify deletion of duplicate entries, we temporarily leave them in + * the array but set their privilege masks to zero; when we reach such an + * entry it's just skipped. (Thus, a side effect of this code will be to + * remove privilege-free entries, should there be any in the input.) dst + * is the next output slot, targ is the currently considered input slot + * (always >= dst), and src scans entries to the right of targ looking for + * duplicates. Once an entry has been emitted to dst it is known + * duplicate-free and need not be considered anymore. */ if (newpresent) { @@ -877,14 +876,14 @@ cc_restart: own_privs = aclmask(acl, mod_aip->ai_grantor, ownerId, - ACL_GRANT_OPTION_FOR(ACLITEM_GET_GOPTIONS(*mod_aip)), + ACL_GRANT_OPTION_FOR(ACLITEM_GET_GOPTIONS(*mod_aip)), ACLMASK_ALL); own_privs = ACL_OPTION_TO_PRIVS(own_privs); if ((ACLITEM_GET_GOPTIONS(*mod_aip) & ~own_privs) != 0) ereport(ERROR, (errcode(ERRCODE_INVALID_GRANT_OPERATION), - errmsg("grant options cannot be granted back to your own grantor"))); + errmsg("grant options cannot be granted back to your own grantor"))); pfree(acl); } @@ -1041,11 +1040,11 @@ aclmask(const Acl *acl, Oid roleid, Oid ownerId, } /* - * Check privileges granted indirectly via role memberships. - * We do this in a separate pass to minimize expensive indirect - * membership tests. In particular, it's worth testing whether - * a given ACL entry grants any privileges still of interest before - * we perform the has_privs_of_role test. + * Check privileges granted indirectly via role memberships. We do this in + * a separate pass to minimize expensive indirect membership tests. In + * particular, it's worth testing whether a given ACL entry grants any + * privileges still of interest before we perform the has_privs_of_role + * test. */ remaining = mask & ~result; for (i = 0; i < num; i++) @@ -1140,11 +1139,11 @@ aclmask_direct(const Acl *acl, Oid roleid, Oid ownerId, int aclmembers(const Acl *acl, Oid **roleids) { - Oid *list; + Oid *list; const AclItem *acldat; - int i, - j, - k; + int i, + j, + k; if (acl == NULL || ACL_NUM(acl) == 0) { @@ -1183,8 +1182,8 @@ aclmembers(const Acl *acl, Oid **roleids) } /* - * We could repalloc the array down to minimum size, but it's hardly - * worth it since it's only transient memory. + * We could repalloc the array down to minimum size, but it's hardly worth + * it since it's only transient memory. */ *roleids = list; @@ -1198,8 +1197,8 @@ aclmembers(const Acl *acl, Oid **roleids) static int oidComparator(const void *arg1, const void *arg2) { - Oid oid1 = * (const Oid *) arg1; - Oid oid2 = * (const Oid *) arg2; + Oid oid1 = *(const Oid *) arg1; + Oid oid2 = *(const Oid *) arg2; if (oid1 > oid2) return 1; @@ -1257,7 +1256,7 @@ Datum makeaclitem(PG_FUNCTION_ARGS) { Oid grantee = PG_GETARG_OID(0); - Oid grantor = PG_GETARG_OID(1); + Oid grantor = PG_GETARG_OID(1); text *privtext = PG_GETARG_TEXT_P(2); bool goption = PG_GETARG_BOOL(3); AclItem *result; @@ -1282,7 +1281,7 @@ convert_priv_string(text *priv_type_text) char *priv_type; priv_type = DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(priv_type_text))); + PointerGetDatum(priv_type_text))); if (pg_strcasecmp(priv_type, "SELECT") == 0) return ACL_SELECT; @@ -1410,7 +1409,7 @@ has_table_privilege_id(PG_FUNCTION_ARGS) { Oid tableoid = PG_GETARG_OID(0); text *priv_type_text = PG_GETARG_TEXT_P(1); - Oid roleid; + Oid roleid; AclMode mode; AclResult aclresult; @@ -1493,7 +1492,7 @@ convert_table_priv_string(text *priv_type_text) char *priv_type; priv_type = DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(priv_type_text))); + PointerGetDatum(priv_type_text))); /* * Return mode from priv_type string @@ -1704,7 +1703,7 @@ convert_database_name(text *databasename) Oid oid; dbname = DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(databasename))); + PointerGetDatum(databasename))); oid = get_database_oid(dbname); if (!OidIsValid(oid)) @@ -1725,7 +1724,7 @@ convert_database_priv_string(text *priv_type_text) char *priv_type; priv_type = DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(priv_type_text))); + PointerGetDatum(priv_type_text))); /* * Return mode from priv_type string @@ -1916,10 +1915,10 @@ convert_function_name(text *functionname) Oid oid; funcname = DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(functionname))); + PointerGetDatum(functionname))); oid = DatumGetObjectId(DirectFunctionCall1(regprocedurein, - CStringGetDatum(funcname))); + CStringGetDatum(funcname))); if (!OidIsValid(oid)) ereport(ERROR, @@ -1939,7 +1938,7 @@ convert_function_priv_string(text *priv_type_text) char *priv_type; priv_type = DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(priv_type_text))); + PointerGetDatum(priv_type_text))); /* * Return mode from priv_type string @@ -2120,7 +2119,7 @@ convert_language_name(text *languagename) Oid oid; langname = DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(languagename))); + PointerGetDatum(languagename))); oid = GetSysCacheOid(LANGNAME, CStringGetDatum(langname), @@ -2143,7 +2142,7 @@ convert_language_priv_string(text *priv_type_text) char *priv_type; priv_type = DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(priv_type_text))); + PointerGetDatum(priv_type_text))); /* * Return mode from priv_type string @@ -2324,7 +2323,7 @@ convert_schema_name(text *schemaname) Oid oid; nspname = DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(schemaname))); + PointerGetDatum(schemaname))); oid = GetSysCacheOid(NAMESPACENAME, CStringGetDatum(nspname), @@ -2347,7 +2346,7 @@ convert_schema_priv_string(text *priv_type_text) char *priv_type; priv_type = DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(priv_type_text))); + PointerGetDatum(priv_type_text))); /* * Return mode from priv_type string @@ -2462,7 +2461,7 @@ has_tablespace_privilege_id(PG_FUNCTION_ARGS) { Oid tablespaceoid = PG_GETARG_OID(0); text *priv_type_text = PG_GETARG_TEXT_P(1); - Oid roleid; + Oid roleid; AclMode mode; AclResult aclresult; @@ -2532,7 +2531,7 @@ convert_tablespace_name(text *tablespacename) Oid oid; spcname = DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(tablespacename))); + PointerGetDatum(tablespacename))); oid = get_tablespace_oid(spcname); if (!OidIsValid(oid)) @@ -2553,7 +2552,7 @@ convert_tablespace_priv_string(text *priv_type_text) char *priv_type; priv_type = DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(priv_type_text))); + PointerGetDatum(priv_type_text))); /* * Return mode from priv_type string @@ -2663,7 +2662,7 @@ pg_has_role_id(PG_FUNCTION_ARGS) { Oid roleoid = PG_GETARG_OID(0); text *priv_type_text = PG_GETARG_TEXT_P(1); - Oid roleid; + Oid roleid; AclMode mode; AclResult aclresult; @@ -2739,7 +2738,7 @@ convert_role_priv_string(text *priv_type_text) char *priv_type; priv_type = DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(priv_type_text))); + PointerGetDatum(priv_type_text))); /* * Return mode from priv_type string @@ -2795,8 +2794,8 @@ initialize_acl(void) if (!IsBootstrapProcessingMode()) { /* - * In normal mode, set a callback on any syscache - * invalidation of pg_auth_members rows + * In normal mode, set a callback on any syscache invalidation of + * pg_auth_members rows */ CacheRegisterSyscacheCallback(AUTHMEMROLEMEM, RoleMembershipCacheCallback, @@ -2806,7 +2805,7 @@ initialize_acl(void) /* * RoleMembershipCacheCallback - * Syscache inval callback function + * Syscache inval callback function */ static void RoleMembershipCacheCallback(Datum arg, Oid relid) @@ -2853,19 +2852,19 @@ has_rolinherit(Oid roleid) static List * roles_has_privs_of(Oid roleid) { - List *roles_list; - ListCell *l; - List *new_cached_privs_roles; - MemoryContext oldctx; + List *roles_list; + ListCell *l; + List *new_cached_privs_roles; + MemoryContext oldctx; /* If cache is already valid, just return the list */ if (OidIsValid(cached_privs_role) && cached_privs_role == roleid) return cached_privs_roles; - /* - * Find all the roles that roleid is a member of, - * including multi-level recursion. The role itself will always - * be the first element of the resulting list. + /* + * Find all the roles that roleid is a member of, including multi-level + * recursion. The role itself will always be the first element of the + * resulting list. * * Each element of the list is scanned to see if it adds any indirect * memberships. We can use a single list as both the record of @@ -2877,9 +2876,9 @@ roles_has_privs_of(Oid roleid) foreach(l, roles_list) { - Oid memberid = lfirst_oid(l); - CatCList *memlist; - int i; + Oid memberid = lfirst_oid(l); + CatCList *memlist; + int i; /* Ignore non-inheriting roles */ if (!has_rolinherit(memberid)) @@ -2892,12 +2891,12 @@ roles_has_privs_of(Oid roleid) for (i = 0; i < memlist->n_members; i++) { HeapTuple tup = &memlist->members[i]->tuple; - Oid otherid = ((Form_pg_auth_members) GETSTRUCT(tup))->roleid; + Oid otherid = ((Form_pg_auth_members) GETSTRUCT(tup))->roleid; /* * Even though there shouldn't be any loops in the membership - * graph, we must test for having already seen this role. - * It is legal for instance to have both A->B and A->C->B. + * graph, we must test for having already seen this role. It is + * legal for instance to have both A->B and A->C->B. */ roles_list = list_append_unique_oid(roles_list, otherid); } @@ -2915,7 +2914,7 @@ roles_has_privs_of(Oid roleid) /* * Now safe to assign to state variable */ - cached_privs_role = InvalidOid; /* just paranoia */ + cached_privs_role = InvalidOid; /* just paranoia */ list_free(cached_privs_roles); cached_privs_roles = new_cached_privs_roles; cached_privs_role = roleid; @@ -2937,19 +2936,19 @@ roles_has_privs_of(Oid roleid) static List * roles_is_member_of(Oid roleid) { - List *roles_list; - ListCell *l; - List *new_cached_membership_roles; - MemoryContext oldctx; + List *roles_list; + ListCell *l; + List *new_cached_membership_roles; + MemoryContext oldctx; /* If cache is already valid, just return the list */ if (OidIsValid(cached_member_role) && cached_member_role == roleid) return cached_membership_roles; - /* - * Find all the roles that roleid is a member of, - * including multi-level recursion. The role itself will always - * be the first element of the resulting list. + /* + * Find all the roles that roleid is a member of, including multi-level + * recursion. The role itself will always be the first element of the + * resulting list. * * Each element of the list is scanned to see if it adds any indirect * memberships. We can use a single list as both the record of @@ -2961,9 +2960,9 @@ roles_is_member_of(Oid roleid) foreach(l, roles_list) { - Oid memberid = lfirst_oid(l); - CatCList *memlist; - int i; + Oid memberid = lfirst_oid(l); + CatCList *memlist; + int i; /* Find roles that memberid is directly a member of */ memlist = SearchSysCacheList(AUTHMEMMEMROLE, 1, @@ -2972,12 +2971,12 @@ roles_is_member_of(Oid roleid) for (i = 0; i < memlist->n_members; i++) { HeapTuple tup = &memlist->members[i]->tuple; - Oid otherid = ((Form_pg_auth_members) GETSTRUCT(tup))->roleid; + Oid otherid = ((Form_pg_auth_members) GETSTRUCT(tup))->roleid; /* * Even though there shouldn't be any loops in the membership - * graph, we must test for having already seen this role. - * It is legal for instance to have both A->B and A->C->B. + * graph, we must test for having already seen this role. It is + * legal for instance to have both A->B and A->C->B. */ roles_list = list_append_unique_oid(roles_list, otherid); } @@ -3023,7 +3022,7 @@ has_privs_of_role(Oid member, Oid role) if (superuser_arg(member)) return true; - /* + /* * Find all the roles that member has the privileges of, including * multi-level recursion, then see if target role is any one of them. */ @@ -3047,7 +3046,7 @@ is_member_of_role(Oid member, Oid role) if (superuser_arg(member)) return true; - /* + /* * Find all the roles that member is a member of, including multi-level * recursion, then see if target role is any one of them. */ @@ -3080,8 +3079,8 @@ bool is_admin_of_role(Oid member, Oid role) { bool result = false; - List *roles_list; - ListCell *l; + List *roles_list; + ListCell *l; /* Fast path for simple case */ if (member == role) @@ -3091,18 +3090,18 @@ is_admin_of_role(Oid member, Oid role) if (superuser_arg(member)) return true; - /* - * Find all the roles that member is a member of, - * including multi-level recursion. We build a list in the same way - * that is_member_of_role does to track visited and unvisited roles. + /* + * Find all the roles that member is a member of, including multi-level + * recursion. We build a list in the same way that is_member_of_role does + * to track visited and unvisited roles. */ roles_list = list_make1_oid(member); foreach(l, roles_list) { - Oid memberid = lfirst_oid(l); - CatCList *memlist; - int i; + Oid memberid = lfirst_oid(l); + CatCList *memlist; + int i; /* Find roles that memberid is directly a member of */ memlist = SearchSysCacheList(AUTHMEMMEMROLE, 1, @@ -3111,7 +3110,7 @@ is_admin_of_role(Oid member, Oid role) for (i = 0; i < memlist->n_members; i++) { HeapTuple tup = &memlist->members[i]->tuple; - Oid otherid = ((Form_pg_auth_members) GETSTRUCT(tup))->roleid; + Oid otherid = ((Form_pg_auth_members) GETSTRUCT(tup))->roleid; if (otherid == role && ((Form_pg_auth_members) GETSTRUCT(tup))->admin_option) @@ -3138,7 +3137,7 @@ is_admin_of_role(Oid member, Oid role) static int count_one_bits(AclMode mask) { - int nbits = 0; + int nbits = 0; /* this code relies on AclMode being an unsigned type */ while (mask) @@ -3157,14 +3156,14 @@ count_one_bits(AclMode mask) * The grantor must always be either the object owner or some role that has * been explicitly granted grant options. This ensures that all granted * privileges appear to flow from the object owner, and there are never - * multiple "original sources" of a privilege. Therefore, if the would-be + * multiple "original sources" of a privilege. Therefore, if the would-be * grantor is a member of a role that has the needed grant options, we have * to do the grant as that role instead. * * It is possible that the would-be grantor is a member of several roles * that have different subsets of the desired grant options, but no one * role has 'em all. In this case we pick a role with the largest number - * of desired options. Ties are broken in favor of closer ancestors. + * of desired options. Ties are broken in favor of closer ancestors. * * roleId: the role attempting to do the GRANT/REVOKE * privileges: the privileges to be granted/revoked @@ -3181,15 +3180,15 @@ select_best_grantor(Oid roleId, AclMode privileges, Oid *grantorId, AclMode *grantOptions) { AclMode needed_goptions = ACL_GRANT_OPTION_FOR(privileges); - List *roles_list; + List *roles_list; int nrights; ListCell *l; /* - * The object owner is always treated as having all grant options, - * so if roleId is the owner it's easy. Also, if roleId is a superuser - * it's easy: superusers are implicitly members of every role, so they - * act as the object owner. + * The object owner is always treated as having all grant options, so if + * roleId is the owner it's easy. Also, if roleId is a superuser it's + * easy: superusers are implicitly members of every role, so they act as + * the object owner. */ if (roleId == ownerId || superuser_arg(roleId)) { @@ -3200,8 +3199,8 @@ select_best_grantor(Oid roleId, AclMode privileges, /* * Otherwise we have to do a careful search to see if roleId has the - * privileges of any suitable role. Note: we can hang onto the result - * of roles_has_privs_of() throughout this loop, because aclmask_direct() + * privileges of any suitable role. Note: we can hang onto the result of + * roles_has_privs_of() throughout this loop, because aclmask_direct() * doesn't query any role memberships. */ roles_list = roles_has_privs_of(roleId); @@ -3213,8 +3212,8 @@ select_best_grantor(Oid roleId, AclMode privileges, foreach(l, roles_list) { - Oid otherrole = lfirst_oid(l); - AclMode otherprivs; + Oid otherrole = lfirst_oid(l); + AclMode otherprivs; otherprivs = aclmask_direct(acl, otherrole, ownerId, needed_goptions, ACLMASK_ALL); @@ -3225,13 +3224,14 @@ select_best_grantor(Oid roleId, AclMode privileges, *grantOptions = otherprivs; return; } + /* * If it has just some of the needed privileges, remember best * candidate. */ if (otherprivs != ACL_NO_RIGHTS) { - int nnewrights = count_one_bits(otherprivs); + int nnewrights = count_one_bits(otherprivs); if (nnewrights > nrights) { diff --git a/src/backend/utils/adt/array_userfuncs.c b/src/backend/utils/adt/array_userfuncs.c index fd83025d6e..08a7072634 100644 --- a/src/backend/utils/adt/array_userfuncs.c +++ b/src/backend/utils/adt/array_userfuncs.c @@ -6,7 +6,7 @@ * Copyright (c) 2003-2005, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/array_userfuncs.c,v 1.15 2005/01/01 20:44:17 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/array_userfuncs.c,v 1.16 2005/10/15 02:49:27 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -96,17 +96,17 @@ array_push(PG_FUNCTION_ARGS) else ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION), - errmsg("argument must be empty or one-dimensional array"))); + errmsg("argument must be empty or one-dimensional array"))); /* - * We arrange to look up info about element type only once per series - * of calls, assuming the element type doesn't change underneath us. + * We arrange to look up info about element type only once per series of + * calls, assuming the element type doesn't change underneath us. */ my_extra = (ArrayMetaState *) fcinfo->flinfo->fn_extra; if (my_extra == NULL) { fcinfo->flinfo->fn_extra = MemoryContextAlloc(fcinfo->flinfo->fn_mcxt, - sizeof(ArrayMetaState)); + sizeof(ArrayMetaState)); my_extra = (ArrayMetaState *) fcinfo->flinfo->fn_extra; my_extra->element_type = InvalidOid; } @@ -194,8 +194,8 @@ array_cat(PG_FUNCTION_ARGS) ndims2 = ARR_NDIM(v2); /* - * short circuit - if one input array is empty, and the other is not, - * we return the non-empty one as the result + * short circuit - if one input array is empty, and the other is not, we + * return the non-empty one as the result * * if both are empty, return the first one */ @@ -245,8 +245,8 @@ array_cat(PG_FUNCTION_ARGS) ereport(ERROR, (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR), errmsg("cannot concatenate incompatible arrays"), - errdetail("Arrays with differing element dimensions are " - "not compatible for concatenation."))); + errdetail("Arrays with differing element dimensions are " + "not compatible for concatenation."))); dims[i] = dims1[i]; lbs[i] = lbs1[i]; @@ -255,9 +255,8 @@ array_cat(PG_FUNCTION_ARGS) else if (ndims1 == ndims2 - 1) { /* - * resulting array has the second argument as the outer array, - * with the first argument appended to the front of the outer - * dimension + * resulting array has the second argument as the outer array, with + * the first argument appended to the front of the outer dimension */ ndims = ndims2; dims = (int *) palloc(ndims * sizeof(int)); @@ -278,8 +277,8 @@ array_cat(PG_FUNCTION_ARGS) ereport(ERROR, (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR), errmsg("cannot concatenate incompatible arrays"), - errdetail("Arrays with differing dimensions are not " - "compatible for concatenation."))); + errdetail("Arrays with differing dimensions are not " + "compatible for concatenation."))); } } else @@ -287,8 +286,8 @@ array_cat(PG_FUNCTION_ARGS) /* * (ndims1 == ndims2 + 1) * - * resulting array has the first argument as the outer array, with - * the second argument appended to the end of the outer dimension + * resulting array has the first argument as the outer array, with the + * second argument appended to the end of the outer dimension */ ndims = ndims1; dims = (int *) palloc(ndims * sizeof(int)); @@ -306,8 +305,8 @@ array_cat(PG_FUNCTION_ARGS) ereport(ERROR, (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR), errmsg("cannot concatenate incompatible arrays"), - errdetail("Arrays with differing dimensions are not " - "compatible for concatenation."))); + errdetail("Arrays with differing dimensions are not " + "compatible for concatenation."))); } } @@ -351,7 +350,7 @@ create_singleton_array(FunctionCallInfo fcinfo, if (element_type == 0) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("invalid array element type OID: %u", element_type))); + errmsg("invalid array element type OID: %u", element_type))); if (ndims < 1) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), @@ -371,14 +370,14 @@ create_singleton_array(FunctionCallInfo fcinfo, } /* - * We arrange to look up info about element type only once per series - * of calls, assuming the element type doesn't change underneath us. + * We arrange to look up info about element type only once per series of + * calls, assuming the element type doesn't change underneath us. */ my_extra = (ArrayMetaState *) fcinfo->flinfo->fn_extra; if (my_extra == NULL) { fcinfo->flinfo->fn_extra = MemoryContextAlloc(fcinfo->flinfo->fn_mcxt, - sizeof(ArrayMetaState)); + sizeof(ArrayMetaState)); my_extra = (ArrayMetaState *) fcinfo->flinfo->fn_extra; my_extra->element_type = InvalidOid; } diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c index efb4ea9dc1..5304d47fa8 100644 --- a/src/backend/utils/adt/arrayfuncs.c +++ b/src/backend/utils/adt/arrayfuncs.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.122 2005/08/15 19:40:20 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.123 2005/10/15 02:49:27 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -130,8 +130,7 @@ array_in(PG_FUNCTION_ARGS) char *string = PG_GETARG_CSTRING(0); /* external form */ Oid element_type = PG_GETARG_OID(1); /* type of an array * element */ - int32 typmod = PG_GETARG_INT32(2); /* typmod for array - * elements */ + int32 typmod = PG_GETARG_INT32(2); /* typmod for array elements */ int typlen; bool typbyval; char typalign; @@ -151,14 +150,14 @@ array_in(PG_FUNCTION_ARGS) /* * We arrange to look up info about element type, including its input - * conversion proc, only once per series of calls, assuming the - * element type doesn't change underneath us. + * conversion proc, only once per series of calls, assuming the element + * type doesn't change underneath us. */ my_extra = (ArrayMetaState *) fcinfo->flinfo->fn_extra; if (my_extra == NULL) { fcinfo->flinfo->fn_extra = MemoryContextAlloc(fcinfo->flinfo->fn_mcxt, - sizeof(ArrayMetaState)); + sizeof(ArrayMetaState)); my_extra = (ArrayMetaState *) fcinfo->flinfo->fn_extra; my_extra->element_type = ~element_type; } @@ -166,8 +165,7 @@ array_in(PG_FUNCTION_ARGS) if (my_extra->element_type != element_type) { /* - * Get info about element type, including its input conversion - * proc + * Get info about element type, including its input conversion proc */ get_type_io_data(element_type, IOFunc_input, &my_extra->typlen, &my_extra->typbyval, @@ -191,8 +189,8 @@ array_in(PG_FUNCTION_ARGS) * Otherwise, we require the input to be in curly-brace style, and we * prescan the input to determine dimensions. * - * Dimension info takes the form of one or more [n] or [m:n] items. The - * outer loop iterates once per dimension item. + * Dimension info takes the form of one or more [n] or [m:n] items. The outer + * loop iterates once per dimension item. */ p = string_save; ndim = 0; @@ -250,7 +248,7 @@ array_in(PG_FUNCTION_ARGS) if (ub < lBound[ndim]) ereport(ERROR, (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR), - errmsg("upper bound cannot be less than lower bound"))); + errmsg("upper bound cannot be less than lower bound"))); dim[ndim] = ub - lBound[ndim] + 1; ndim++; @@ -282,8 +280,8 @@ array_in(PG_FUNCTION_ARGS) p++; /* - * intuit dimensions from brace structure -- it better match what - * we were given + * intuit dimensions from brace structure -- it better match what we + * were given */ if (*p != '{') ereport(ERROR, @@ -293,13 +291,13 @@ array_in(PG_FUNCTION_ARGS) if (ndim_braces != ndim) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("array dimensions incompatible with array literal"))); + errmsg("array dimensions incompatible with array literal"))); for (i = 0; i < ndim; ++i) { if (dim[i] != dim_braces[i]) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("array dimensions incompatible with array literal"))); + errmsg("array dimensions incompatible with array literal"))); } } @@ -406,22 +404,22 @@ ArrayCount(char *str, int *dim, char typdelim) /* Signal a premature end of the string */ ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("malformed array literal: \"%s\"", str))); + errmsg("malformed array literal: \"%s\"", str))); break; case '\\': /* - * An escape must be after a level start, after an - * element start, or after an element delimiter. In - * any case we now must be past an element start. + * An escape must be after a level start, after an element + * start, or after an element delimiter. In any case we + * now must be past an element start. */ if (parse_state != ARRAY_LEVEL_STARTED && parse_state != ARRAY_ELEM_STARTED && parse_state != ARRAY_QUOTED_ELEM_STARTED && parse_state != ARRAY_ELEM_DELIMITED) ereport(ERROR, - (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("malformed array literal: \"%s\"", str))); + (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), + errmsg("malformed array literal: \"%s\"", str))); if (parse_state != ARRAY_QUOTED_ELEM_STARTED) parse_state = ARRAY_ELEM_STARTED; /* skip the escaped character */ @@ -429,22 +427,22 @@ ArrayCount(char *str, int *dim, char typdelim) ptr++; else ereport(ERROR, - (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("malformed array literal: \"%s\"", str))); + (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), + errmsg("malformed array literal: \"%s\"", str))); break; case '\"': /* * A quote must be after a level start, after a quoted - * element start, or after an element delimiter. In - * any case we now must be past an element start. + * element start, or after an element delimiter. In any + * case we now must be past an element start. */ if (parse_state != ARRAY_LEVEL_STARTED && parse_state != ARRAY_QUOTED_ELEM_STARTED && parse_state != ARRAY_ELEM_DELIMITED) ereport(ERROR, - (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("malformed array literal: \"%s\"", str))); + (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), + errmsg("malformed array literal: \"%s\"", str))); in_quotes = !in_quotes; if (in_quotes) parse_state = ARRAY_QUOTED_ELEM_STARTED; @@ -455,22 +453,22 @@ ArrayCount(char *str, int *dim, char typdelim) if (!in_quotes) { /* - * A left brace can occur if no nesting has - * occurred yet, after a level start, or after a - * level delimiter. + * A left brace can occur if no nesting has occurred + * yet, after a level start, or after a level + * delimiter. */ if (parse_state != ARRAY_NO_LEVEL && parse_state != ARRAY_LEVEL_STARTED && parse_state != ARRAY_LEVEL_DELIMITED) ereport(ERROR, - (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("malformed array literal: \"%s\"", str))); + (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), + errmsg("malformed array literal: \"%s\"", str))); parse_state = ARRAY_LEVEL_STARTED; if (nest_level >= MAXDIM) ereport(ERROR, - (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), - errmsg("number of array dimensions (%d) exceeds the maximum allowed (%d)", - nest_level, MAXDIM))); + (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), + errmsg("number of array dimensions (%d) exceeds the maximum allowed (%d)", + nest_level, MAXDIM))); temp[nest_level] = 0; nest_level++; if (ndim < nest_level) @@ -481,9 +479,9 @@ ArrayCount(char *str, int *dim, char typdelim) if (!in_quotes) { /* - * A right brace can occur after an element start, - * an element completion, a quoted element - * completion, or a level completion. + * A right brace can occur after an element start, an + * element completion, a quoted element completion, or + * a level completion. */ if (parse_state != ARRAY_ELEM_STARTED && parse_state != ARRAY_ELEM_COMPLETED && @@ -491,22 +489,22 @@ ArrayCount(char *str, int *dim, char typdelim) parse_state != ARRAY_LEVEL_COMPLETED && !(nest_level == 1 && parse_state == ARRAY_LEVEL_STARTED)) ereport(ERROR, - (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("malformed array literal: \"%s\"", str))); + (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), + errmsg("malformed array literal: \"%s\"", str))); parse_state = ARRAY_LEVEL_COMPLETED; if (nest_level == 0) ereport(ERROR, - (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("malformed array literal: \"%s\"", str))); + (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), + errmsg("malformed array literal: \"%s\"", str))); nest_level--; if ((nelems_last[nest_level] != 1) && - (nelems[nest_level] != nelems_last[nest_level])) + (nelems[nest_level] != nelems_last[nest_level])) ereport(ERROR, - (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("multidimensional arrays must have " - "array expressions with matching " - "dimensions"))); + (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), + errmsg("multidimensional arrays must have " + "array expressions with matching " + "dimensions"))); nelems_last[nest_level] = nelems[nest_level]; nelems[nest_level] = 1; if (nest_level == 0) @@ -527,17 +525,17 @@ ArrayCount(char *str, int *dim, char typdelim) if (*ptr == typdelim) { /* - * Delimiters can occur after an element - * start, an element completion, a quoted - * element completion, or a level completion. + * Delimiters can occur after an element start, an + * element completion, a quoted element + * completion, or a level completion. */ if (parse_state != ARRAY_ELEM_STARTED && parse_state != ARRAY_ELEM_COMPLETED && - parse_state != ARRAY_QUOTED_ELEM_COMPLETED && + parse_state != ARRAY_QUOTED_ELEM_COMPLETED && parse_state != ARRAY_LEVEL_COMPLETED) ereport(ERROR, - (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("malformed array literal: \"%s\"", str))); + (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), + errmsg("malformed array literal: \"%s\"", str))); if (parse_state == ARRAY_LEVEL_COMPLETED) parse_state = ARRAY_LEVEL_DELIMITED; else @@ -549,16 +547,16 @@ ArrayCount(char *str, int *dim, char typdelim) { /* * Other non-space characters must be after a - * level start, after an element start, or - * after an element delimiter. In any case we - * now must be past an element start. + * level start, after an element start, or after + * an element delimiter. In any case we now must + * be past an element start. */ if (parse_state != ARRAY_LEVEL_STARTED && parse_state != ARRAY_ELEM_STARTED && parse_state != ARRAY_ELEM_DELIMITED) ereport(ERROR, - (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("malformed array literal: \"%s\"", str))); + (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), + errmsg("malformed array literal: \"%s\"", str))); parse_state = ARRAY_ELEM_STARTED; } } @@ -637,18 +635,18 @@ ReadArrayStr(char *arrayStr, MemSet(indx, 0, sizeof(indx)); /* - * We have to remove " and \ characters to create a clean item value - * to pass to the datatype input routine. We overwrite each item - * value in-place within arrayStr to do this. srcptr is the current - * scan point, and dstptr is where we are copying to. + * We have to remove " and \ characters to create a clean item value to + * pass to the datatype input routine. We overwrite each item value + * in-place within arrayStr to do this. srcptr is the current scan point, + * and dstptr is where we are copying to. * - * We also want to suppress leading and trailing unquoted whitespace. - * We use the leadingspace flag to suppress leading space. Trailing - * space is tracked by using dstendptr to point to the last significant - * output character. + * We also want to suppress leading and trailing unquoted whitespace. We use + * the leadingspace flag to suppress leading space. Trailing space is + * tracked by using dstendptr to point to the last significant output + * character. * - * The error checking in this routine is mostly pro-forma, since we - * expect that ArrayCount() already validated the string. + * The error checking in this routine is mostly pro-forma, since we expect + * that ArrayCount() already validated the string. */ srcptr = arrayStr; while (!eoArray) @@ -706,9 +704,9 @@ ReadArrayStr(char *arrayStr, { if (nest_level >= ndim) ereport(ERROR, - (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("malformed array literal: \"%s\"", - origStr))); + (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), + errmsg("malformed array literal: \"%s\"", + origStr))); nest_level++; indx[nest_level - 1] = 0; srcptr++; @@ -721,9 +719,9 @@ ReadArrayStr(char *arrayStr, { if (nest_level == 0) ereport(ERROR, - (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("malformed array literal: \"%s\"", - origStr))); + (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), + errmsg("malformed array literal: \"%s\"", + origStr))); if (i == -1) i = ArrayGetOffset0(ndim, indx, prod); indx[nest_level - 1] = 0; @@ -751,8 +749,8 @@ ReadArrayStr(char *arrayStr, else if (isspace((unsigned char) *srcptr)) { /* - * If leading space, drop it immediately. Else, - * copy but don't advance dstendptr. + * If leading space, drop it immediately. Else, copy + * but don't advance dstendptr. */ if (leadingspace) srcptr++; @@ -913,14 +911,14 @@ array_out(PG_FUNCTION_ARGS) /* * We arrange to look up info about element type, including its output - * conversion proc, only once per series of calls, assuming the - * element type doesn't change underneath us. + * conversion proc, only once per series of calls, assuming the element + * type doesn't change underneath us. */ my_extra = (ArrayMetaState *) fcinfo->flinfo->fn_extra; if (my_extra == NULL) { fcinfo->flinfo->fn_extra = MemoryContextAlloc(fcinfo->flinfo->fn_mcxt, - sizeof(ArrayMetaState)); + sizeof(ArrayMetaState)); my_extra = (ArrayMetaState *) fcinfo->flinfo->fn_extra; my_extra->element_type = InvalidOid; } @@ -928,8 +926,7 @@ array_out(PG_FUNCTION_ARGS) if (my_extra->element_type != element_type) { /* - * Get info about element type, including its output conversion - * proc + * Get info about element type, including its output conversion proc */ get_type_io_data(element_type, IOFunc_output, &my_extra->typlen, &my_extra->typbyval, @@ -956,8 +953,8 @@ array_out(PG_FUNCTION_ARGS) } /* - * we will need to add explicit dimensions if any dimension has a - * lower bound other than one + * we will need to add explicit dimensions if any dimension has a lower + * bound other than one */ for (i = 0; i < ndim; i++) { @@ -969,9 +966,9 @@ array_out(PG_FUNCTION_ARGS) } /* - * Convert all values to string form, count total space needed - * (including any overhead such as escaping backslashes), and detect - * whether each item needs double quotes. + * Convert all values to string form, count total space needed (including + * any overhead such as escaping backslashes), and detect whether each + * item needs double quotes. */ values = (char **) palloc(nitems * sizeof(char *)); needquotes = (bool *) palloc(nitems * sizeof(bool)); @@ -991,7 +988,7 @@ array_out(PG_FUNCTION_ARGS) /* count data plus backslashes; detect chars needing quotes */ if (values[i][0] == '\0') - needquote = true; /* force quotes for empty string */ + needquote = true; /* force quotes for empty string */ else needquote = false; @@ -1121,8 +1118,7 @@ array_recv(PG_FUNCTION_ARGS) StringInfo buf = (StringInfo) PG_GETARG_POINTER(0); Oid spec_element_type = PG_GETARG_OID(1); /* type of an array * element */ - int32 typmod = PG_GETARG_INT32(2); /* typmod for array - * elements */ + int32 typmod = PG_GETARG_INT32(2); /* typmod for array elements */ Oid element_type; int typlen; bool typbyval; @@ -1174,15 +1170,15 @@ array_recv(PG_FUNCTION_ARGS) nitems = ArrayGetNItems(ndim, dim); /* - * We arrange to look up info about element type, including its - * receive conversion proc, only once per series of calls, assuming - * the element type doesn't change underneath us. + * We arrange to look up info about element type, including its receive + * conversion proc, only once per series of calls, assuming the element + * type doesn't change underneath us. */ my_extra = (ArrayMetaState *) fcinfo->flinfo->fn_extra; if (my_extra == NULL) { fcinfo->flinfo->fn_extra = MemoryContextAlloc(fcinfo->flinfo->fn_mcxt, - sizeof(ArrayMetaState)); + sizeof(ArrayMetaState)); my_extra = (ArrayMetaState *) fcinfo->flinfo->fn_extra; my_extra->element_type = ~element_type; } @@ -1197,8 +1193,8 @@ array_recv(PG_FUNCTION_ARGS) if (!OidIsValid(my_extra->typiofunc)) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_FUNCTION), - errmsg("no binary input function available for type %s", - format_type_be(element_type)))); + errmsg("no binary input function available for type %s", + format_type_be(element_type)))); fmgr_info_cxt(my_extra->typiofunc, &my_extra->proc, fcinfo->flinfo->fn_mcxt); my_extra->element_type = element_type; @@ -1278,10 +1274,10 @@ ReadArrayBinary(StringInfo buf, errmsg("insufficient data left in message"))); /* - * Rather than copying data around, we just set up a phony - * StringInfo pointing to the correct portion of the input buffer. - * We assume we can scribble on the input buffer so as to maintain - * the convention that StringInfos have a trailing null. + * Rather than copying data around, we just set up a phony StringInfo + * pointing to the correct portion of the input buffer. We assume we + * can scribble on the input buffer so as to maintain the convention + * that StringInfos have a trailing null. */ elem_buf.data = &buf->data[buf->cursor]; elem_buf.maxlen = itemlen + 1; @@ -1359,14 +1355,14 @@ array_send(PG_FUNCTION_ARGS) /* * We arrange to look up info about element type, including its send - * conversion proc, only once per series of calls, assuming the - * element type doesn't change underneath us. + * conversion proc, only once per series of calls, assuming the element + * type doesn't change underneath us. */ my_extra = (ArrayMetaState *) fcinfo->flinfo->fn_extra; if (my_extra == NULL) { fcinfo->flinfo->fn_extra = MemoryContextAlloc(fcinfo->flinfo->fn_mcxt, - sizeof(ArrayMetaState)); + sizeof(ArrayMetaState)); my_extra = (ArrayMetaState *) fcinfo->flinfo->fn_extra; my_extra->element_type = InvalidOid; } @@ -1381,8 +1377,8 @@ array_send(PG_FUNCTION_ARGS) if (!OidIsValid(my_extra->typiofunc)) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_FUNCTION), - errmsg("no binary output function available for type %s", - format_type_be(element_type)))); + errmsg("no binary output function available for type %s", + format_type_be(element_type)))); fmgr_info_cxt(my_extra->typiofunc, &my_extra->proc, fcinfo->flinfo->fn_mcxt); my_extra->element_type = element_type; @@ -1646,14 +1642,14 @@ array_get_slice(ArrayType *array, if (arraylen > 0) { /* - * fixed-length arrays -- currently, cannot slice these because - * parser labels output as being of the fixed-length array type! - * Code below shows how we could support it if the parser were - * changed to label output as a suitable varlena array type. + * fixed-length arrays -- currently, cannot slice these because parser + * labels output as being of the fixed-length array type! Code below + * shows how we could support it if the parser were changed to label + * output as a suitable varlena array type. */ ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("slices of fixed-length arrays not implemented"))); + errmsg("slices of fixed-length arrays not implemented"))); /* * fixed-length arrays -- these are assumed to be 1-d, 0-based XXX @@ -1678,10 +1674,9 @@ array_get_slice(ArrayType *array, } /* - * Check provided subscripts. A slice exceeding the current array - * limits is silently truncated to the array limits. If we end up - * with an empty slice, return NULL (should it be an empty array - * instead?) + * Check provided subscripts. A slice exceeding the current array limits + * is silently truncated to the array limits. If we end up with an empty + * slice, return NULL (should it be an empty array instead?) */ if (ndim < nSubscripts || ndim <= 0 || ndim > MAXDIM) RETURN_NULL(ArrayType *); @@ -1719,8 +1714,8 @@ array_get_slice(ArrayType *array, memcpy(ARR_DIMS(newarray), span, ndim * sizeof(int)); /* - * Lower bounds of the new array are set to 1. Formerly (before 7.3) - * we copied the given lowerIndx values ... but that seems confusing. + * Lower bounds of the new array are set to 1. Formerly (before 7.3) we + * copied the given lowerIndx values ... but that seems confusing. */ newlb = ARR_LBOUND(newarray); for (i = 0; i < ndim; i++) @@ -1815,9 +1810,9 @@ array_set(ArrayType *array, ndim = ARR_NDIM(array); /* - * if number of dims is zero, i.e. an empty array, create an array - * with nSubscripts dimensions, and set the lower bounds to the - * supplied subscripts + * if number of dims is zero, i.e. an empty array, create an array with + * nSubscripts dimensions, and set the lower bounds to the supplied + * subscripts */ if (ndim == 0) { @@ -1987,7 +1982,7 @@ array_set_slice(ArrayType *array, */ ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("updates on slices of fixed-length arrays not implemented"))); + errmsg("updates on slices of fixed-length arrays not implemented"))); } /* detoast arrays if necessary */ @@ -1999,9 +1994,9 @@ array_set_slice(ArrayType *array, ndim = ARR_NDIM(array); /* - * if number of dims is zero, i.e. an empty array, create an array - * with nSubscripts dimensions, and set the upper and lower bounds to - * the supplied subscripts + * if number of dims is zero, i.e. an empty array, create an array with + * nSubscripts dimensions, and set the upper and lower bounds to the + * supplied subscripts */ if (ndim == 0) { @@ -2038,10 +2033,9 @@ array_set_slice(ArrayType *array, memcpy(lb, ARR_LBOUND(array), ndim * sizeof(int)); /* - * Check provided subscripts. A slice exceeding the current array - * limits throws an error, *except* in the 1-D case where we will - * extend the array as long as no hole is created. An empty slice is - * an error, too. + * Check provided subscripts. A slice exceeding the current array limits + * throws an error, *except* in the 1-D case where we will extend the + * array as long as no hole is created. An empty slice is an error, too. */ for (i = 0; i < nSubscripts; i++) { @@ -2083,8 +2077,8 @@ array_set_slice(ArrayType *array, } /* - * Make sure source array has enough entries. Note we ignore the - * shape of the source array and just read entries serially. + * Make sure source array has enough entries. Note we ignore the shape of + * the source array and just read entries serially. */ mda_get_range(ndim, span, lowerIndx, upperIndx); nsrcitems = ArrayGetNItems(ndim, span); @@ -2104,8 +2098,8 @@ array_set_slice(ArrayType *array, if (ndim > 1) { /* - * here we do not need to cope with extension of the array; it - * would be a lot more complicated if we had to do so... + * here we do not need to cope with extension of the array; it would + * be a lot more complicated if we had to do so... */ olditemsize = array_slice_size(ndim, dim, lb, ARR_DATA_PTR(array), lowerIndx, upperIndx, @@ -2115,8 +2109,7 @@ array_set_slice(ArrayType *array, else { /* - * here we must allow for possibility of slice larger than orig - * array + * here we must allow for possibility of slice larger than orig array */ int oldlb = ARR_LBOUND(array)[0]; int oldub = oldlb + ARR_DIMS(array)[0] - 1; @@ -2148,8 +2141,8 @@ array_set_slice(ArrayType *array, if (ndim > 1) { /* - * here we do not need to cope with extension of the array; it - * would be a lot more complicated if we had to do so... + * here we do not need to cope with extension of the array; it would + * be a lot more complicated if we had to do so... */ array_insert_slice(ndim, dim, lb, ARR_DATA_PTR(array), olddatasize, ARR_DATA_PTR(newarray), @@ -2192,7 +2185,7 @@ array_set_slice(ArrayType *array, * or binary-compatible with, the first argument type of fn(). * * retType: OID of element type of output array. This must be the same as, * or binary-compatible with, the result type of fn(). - * * amstate: workspace for array_map. Must be zeroed by caller before + * * amstate: workspace for array_map. Must be zeroed by caller before * first call, and not touched after that. * * It is legitimate to pass a freshly-zeroed ArrayMapState on each call, @@ -2250,9 +2243,9 @@ array_map(FunctionCallInfo fcinfo, Oid inpType, Oid retType, } /* - * We arrange to look up info about input and return element types - * only once per series of calls, assuming the element type doesn't - * change underneath us. + * We arrange to look up info about input and return element types only + * once per series of calls, assuming the element type doesn't change + * underneath us. */ inp_extra = &amstate->inp_extra; ret_extra = &amstate->ret_extra; @@ -2297,9 +2290,9 @@ array_map(FunctionCallInfo fcinfo, Oid inpType, Oid retType, /* * Apply the given function to source elt and extra args. * - * We assume the extra args are non-NULL, so need not check whether - * fn() is strict. Would need to do more work here to support - * arrays containing nulls, too. + * We assume the extra args are non-NULL, so need not check whether fn() + * is strict. Would need to do more work here to support arrays + * containing nulls, too. */ fcinfo->arg[0] = elt; fcinfo->argnull[0] = false; @@ -2329,8 +2322,7 @@ array_map(FunctionCallInfo fcinfo, Oid inpType, Oid retType, memcpy(ARR_DIMS(result), ARR_DIMS(v), 2 * ndim * sizeof(int)); /* - * Note: do not risk trying to pfree the results of the called - * function + * Note: do not risk trying to pfree the results of the called function */ CopyArrayEls(ARR_DATA_PTR(result), values, nitems, typlen, typbyval, typalign, false); @@ -2543,7 +2535,7 @@ array_eq(PG_FUNCTION_ARGS) if (element_type != ARR_ELEMTYPE(array2)) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("cannot compare arrays of different element types"))); + errmsg("cannot compare arrays of different element types"))); /* fast path if the arrays do not have the same number of elements */ if (nitems1 != nitems2) @@ -2551,10 +2543,10 @@ array_eq(PG_FUNCTION_ARGS) else { /* - * We arrange to look up the equality function only once per - * series of calls, assuming the element type doesn't change - * underneath us. The typcache is used so that we have no memory - * leakage when being used as an index support function. + * We arrange to look up the equality function only once per series of + * calls, assuming the element type doesn't change underneath us. The + * typcache is used so that we have no memory leakage when being used + * as an index support function. */ typentry = (TypeCacheEntry *) fcinfo->flinfo->fn_extra; if (typentry == NULL || @@ -2565,8 +2557,8 @@ array_eq(PG_FUNCTION_ARGS) if (!OidIsValid(typentry->eq_opr_finfo.fn_oid)) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_FUNCTION), - errmsg("could not identify an equality operator for type %s", - format_type_be(element_type)))); + errmsg("could not identify an equality operator for type %s", + format_type_be(element_type)))); fcinfo->flinfo->fn_extra = (void *) typentry; } typlen = typentry->typlen; @@ -2697,13 +2689,13 @@ array_cmp(FunctionCallInfo fcinfo) if (element_type != ARR_ELEMTYPE(array2)) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("cannot compare arrays of different element types"))); + errmsg("cannot compare arrays of different element types"))); /* - * We arrange to look up the comparison function only once per series - * of calls, assuming the element type doesn't change underneath us. - * The typcache is used so that we have no memory leakage when being - * used as an index support function. + * We arrange to look up the comparison function only once per series of + * calls, assuming the element type doesn't change underneath us. The + * typcache is used so that we have no memory leakage when being used as + * an index support function. */ typentry = (TypeCacheEntry *) fcinfo->flinfo->fn_extra; if (typentry == NULL || @@ -2714,8 +2706,8 @@ array_cmp(FunctionCallInfo fcinfo) if (!OidIsValid(typentry->cmp_proc_finfo.fn_oid)) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_FUNCTION), - errmsg("could not identify a comparison function for type %s", - format_type_be(element_type)))); + errmsg("could not identify a comparison function for type %s", + format_type_be(element_type)))); fcinfo->flinfo->fn_extra = (void *) typentry; } typlen = typentry->typlen; @@ -3121,11 +3113,11 @@ array_type_length_coerce_internal(ArrayType *src, errmsg("target type is not an array"))); /* - * We don't deal with domain constraints yet, so bail out. This - * isn't currently a problem, because we also don't support arrays - * of domain type elements either. But in the future we might. At - * that point consideration should be given to removing the check - * below and adding a domain constraints check to the coercion. + * We don't deal with domain constraints yet, so bail out. This isn't + * currently a problem, because we also don't support arrays of domain + * type elements either. But in the future we might. At that point + * consideration should be given to removing the check below and + * adding a domain constraints check to the coercion. */ if (getBaseType(tgt_elem_type) != tgt_elem_type) ereport(ERROR, @@ -3150,8 +3142,8 @@ array_type_length_coerce_internal(ArrayType *src, } /* - * If it's binary-compatible, modify the element type in the array - * header, but otherwise leave the array as we received it. + * If it's binary-compatible, modify the element type in the array header, + * but otherwise leave the array as we received it. */ if (my_extra->coerce_finfo.fn_oid == InvalidOid) { @@ -3166,8 +3158,8 @@ array_type_length_coerce_internal(ArrayType *src, /* * Use array_map to apply the function to each array element. * - * We pass on the desttypmod and isExplicit flags whether or not the - * function wants them. + * We pass on the desttypmod and isExplicit flags whether or not the function + * wants them. */ InitFunctionCallInfoData(locfcinfo, &my_extra->coerce_finfo, 3, NULL, NULL); @@ -3207,8 +3199,8 @@ array_length_coerce(PG_FUNCTION_ARGS) PG_RETURN_ARRAYTYPE_P(v); /* - * We arrange to look up the element type's coercion function only - * once per series of calls, assuming the element type doesn't change + * We arrange to look up the element type's coercion function only once + * per series of calls, assuming the element type doesn't change * underneath us. */ my_extra = (alc_extra *) fmgr_info->fn_extra; @@ -3303,7 +3295,7 @@ accumArrayResult(ArrayBuildState *astate, if ((astate->nelems % ARRAY_ELEMS_CHUNKSIZE) == 0) astate->dvalues = (Datum *) repalloc(astate->dvalues, - (astate->nelems + ARRAY_ELEMS_CHUNKSIZE) * sizeof(Datum)); + (astate->nelems + ARRAY_ELEMS_CHUNKSIZE) * sizeof(Datum)); } if (disnull) @@ -3381,9 +3373,9 @@ makeMdArrayResult(ArrayBuildState *astate, Datum array_larger(PG_FUNCTION_ARGS) { - ArrayType *v1, - *v2, - *result; + ArrayType *v1, + *v2, + *result; v1 = PG_GETARG_ARRAYTYPE_P(0); v2 = PG_GETARG_ARRAYTYPE_P(1); @@ -3396,9 +3388,9 @@ array_larger(PG_FUNCTION_ARGS) Datum array_smaller(PG_FUNCTION_ARGS) { - ArrayType *v1, - *v2, - *result; + ArrayType *v1, + *v2, + *result; v1 = PG_GETARG_ARRAYTYPE_P(0); v2 = PG_GETARG_ARRAYTYPE_P(1); diff --git a/src/backend/utils/adt/ascii.c b/src/backend/utils/adt/ascii.c index 361dec59f5..599b37b1f3 100644 --- a/src/backend/utils/adt/ascii.c +++ b/src/backend/utils/adt/ascii.c @@ -5,7 +5,7 @@ * Portions Copyright (c) 1999-2005, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/ascii.c,v 1.25 2005/09/24 17:53:15 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/ascii.c,v 1.26 2005/10/15 02:49:28 momjian Exp $ * *----------------------------------------------------------------------- */ @@ -73,8 +73,8 @@ pg_to_ascii(unsigned char *src, unsigned char *src_end, unsigned char *dest, int { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("encoding conversion from %s to ASCII not supported", - pg_encoding_to_char(enc)))); + errmsg("encoding conversion from %s to ASCII not supported", + pg_encoding_to_char(enc)))); return; /* keep compiler quiet */ } diff --git a/src/backend/utils/adt/cash.c b/src/backend/utils/adt/cash.c index 8788af9f87..f9e2f10325 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. * - * $PostgreSQL: pgsql/src/backend/utils/adt/cash.c,v 1.65 2005/07/21 04:41:43 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/cash.c,v 1.66 2005/10/15 02:49:28 momjian Exp $ */ #include "postgres.h" @@ -85,14 +85,14 @@ cash_in(PG_FUNCTION_ARGS) struct lconv *lconvert = PGLC_localeconv(); /* - * frac_digits will be CHAR_MAX in some locales, notably C. However, - * just testing for == CHAR_MAX is risky, because of compilers like - * gcc that "helpfully" let you alter the platform-standard definition - * of whether char is signed or not. If we are so unfortunate as to - * get compiled with a nonstandard -fsigned-char or -funsigned-char - * switch, then our idea of CHAR_MAX will not agree with libc's. The - * safest course is not to test for CHAR_MAX at all, but to impose a - * range check for plausible frac_digits values. + * frac_digits will be CHAR_MAX in some locales, notably C. However, just + * testing for == CHAR_MAX is risky, because of compilers like gcc that + * "helpfully" let you alter the platform-standard definition of whether + * char is signed or not. If we are so unfortunate as to get compiled + * with a nonstandard -fsigned-char or -funsigned-char switch, then our + * idea of CHAR_MAX will not agree with libc's. The safest course is not + * to test for CHAR_MAX at all, but to impose a range check for plausible + * frac_digits values. */ fpoint = lconvert->frac_digits; if (fpoint < 0 || fpoint > 10) @@ -195,7 +195,7 @@ cash_in(PG_FUNCTION_ARGS) if (*s != '\0') ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type money: \"%s\"", str))); + errmsg("invalid input syntax for type money: \"%s\"", str))); result = value * sgn; @@ -238,8 +238,8 @@ cash_out(PG_FUNCTION_ARGS) points = 2; /* best guess in this case, I think */ /* - * As with frac_digits, must apply a range check to mon_grouping to - * avoid being fooled by variant CHAR_MAX values. + * As with frac_digits, must apply a range check to mon_grouping to avoid + * being fooled by variant CHAR_MAX values. */ mon_group = *lconvert->mon_grouping; if (mon_group <= 0 || mon_group > 6) diff --git a/src/backend/utils/adt/char.c b/src/backend/utils/adt/char.c index bc208164c1..663fac909e 100644 --- a/src/backend/utils/adt/char.c +++ b/src/backend/utils/adt/char.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/char.c,v 1.42 2004/12/31 22:01:21 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/char.c,v 1.43 2005/10/15 02:49:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -187,9 +187,9 @@ text_char(PG_FUNCTION_ARGS) char result; /* - * An empty input string is converted to \0 (for consistency with - * charin). If the input is longer than one character, the excess data - * is silently discarded. + * An empty input string is converted to \0 (for consistency with charin). + * If the input is longer than one character, the excess data is silently + * discarded. */ if (VARSIZE(arg1) > VARHDRSZ) result = *(VARDATA(arg1)); diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c index ec1d808544..619a099b65 100644 --- a/src/backend/utils/adt/date.c +++ b/src/backend/utils/adt/date.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.121 2005/10/09 17:21:46 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.122 2005/10/15 02:49:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include "access/hash.h" #include "libpq/pqformat.h" @@ -38,10 +38,10 @@ #endif -static int time2tm(TimeADT time, struct pg_tm *tm, fsec_t *fsec); -static int timetz2tm(TimeTzADT *time, struct pg_tm *tm, fsec_t *fsec, int *tzp); -static int tm2time(struct pg_tm *tm, fsec_t fsec, TimeADT *result); -static int tm2timetz(struct pg_tm *tm, fsec_t fsec, int tz, TimeTzADT *result); +static int time2tm(TimeADT time, struct pg_tm * tm, fsec_t *fsec); +static int timetz2tm(TimeTzADT *time, struct pg_tm * tm, fsec_t *fsec, int *tzp); +static int tm2time(struct pg_tm * tm, fsec_t fsec, TimeADT *result); +static int tm2timetz(struct pg_tm * tm, fsec_t fsec, int tz, TimeTzADT *result); static void AdjustTimeForTypmod(TimeADT *time, int32 typmod); /***************************************************************************** @@ -56,7 +56,7 @@ Datum date_in(PG_FUNCTION_ARGS) { char *str = PG_GETARG_CSTRING(0); - DateADT date; + DateADT date; fsec_t fsec; struct pg_tm tt, *tm = &tt; @@ -83,7 +83,7 @@ date_in(PG_FUNCTION_ARGS) case DTK_CURRENT: ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("date/time value \"current\" is no longer supported"))); + errmsg("date/time value \"current\" is no longer supported"))); GetCurrentDateTime(tm); break; @@ -108,13 +108,13 @@ date_in(PG_FUNCTION_ARGS) Datum date_out(PG_FUNCTION_ARGS) { - DateADT date = PG_GETARG_DATEADT(0); + DateADT date = PG_GETARG_DATEADT(0); char *result; struct pg_tm tt, *tm = &tt; char buf[MAXDATELEN + 1]; - j2date(date +POSTGRES_EPOCH_JDATE, + j2date(date + POSTGRES_EPOCH_JDATE, &(tm->tm_year), &(tm->tm_mon), &(tm->tm_mday)); EncodeDateOnly(tm, DateStyle, buf); @@ -140,7 +140,7 @@ date_recv(PG_FUNCTION_ARGS) Datum date_send(PG_FUNCTION_ARGS) { - DateADT date = PG_GETARG_DATEADT(0); + DateADT date = PG_GETARG_DATEADT(0); StringInfoData buf; pq_begintypsend(&buf); @@ -306,7 +306,7 @@ date2timestamptz(DateADT dateVal) #ifdef HAVE_INT64_TIMESTAMP result = dateVal * USECS_PER_DAY + tz * USECS_PER_SEC; #else - result = dateVal * (double)SECS_PER_DAY + tz; + result = dateVal * (double) SECS_PER_DAY + tz; #endif return result; @@ -715,7 +715,7 @@ date_timestamp(PG_FUNCTION_ARGS) Datum timestamp_date(PG_FUNCTION_ARGS) { - Timestamp timestamp = PG_GETARG_TIMESTAMP(0); + Timestamp timestamp = PG_GETARG_TIMESTAMP(0); DateADT result; struct pg_tm tt, *tm = &tt; @@ -797,11 +797,11 @@ abstime_date(PG_FUNCTION_ARGS) case NOEND_ABSTIME: ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot convert reserved abstime value to date"))); + errmsg("cannot convert reserved abstime value to date"))); /* - * pretend to drop through to make compiler think that result - * will be set + * pretend to drop through to make compiler think that result will + * be set */ default: @@ -821,7 +821,7 @@ Datum date_text(PG_FUNCTION_ARGS) { /* Input is a Date, but may as well leave it in Datum form */ - Datum date = PG_GETARG_DATUM(0); + Datum date = PG_GETARG_DATUM(0); text *result; char *str; int len; @@ -914,11 +914,11 @@ time_in(PG_FUNCTION_ARGS) * Convert a tm structure to a time data type. */ static int -tm2time(struct pg_tm *tm, fsec_t fsec, TimeADT *result) +tm2time(struct pg_tm * tm, fsec_t fsec, TimeADT *result) { #ifdef HAVE_INT64_TIMESTAMP *result = ((((tm->tm_hour * MINS_PER_HOUR + tm->tm_min) * SECS_PER_MINUTE) + tm->tm_sec) - * USECS_PER_SEC) + fsec; + * USECS_PER_SEC) + fsec; #else *result = ((tm->tm_hour * MINS_PER_HOUR + tm->tm_min) * SECS_PER_MINUTE) + tm->tm_sec + fsec; #endif @@ -931,7 +931,7 @@ tm2time(struct pg_tm *tm, fsec_t fsec, TimeADT *result) * local time zone. If out of this range, leave as GMT. - tgl 97/05/27 */ static int -time2tm(TimeADT time, struct pg_tm *tm, fsec_t *fsec) +time2tm(TimeADT time, struct pg_tm * tm, fsec_t *fsec) { #ifdef HAVE_INT64_TIMESTAMP tm->tm_hour = time / USECS_PER_HOUR; @@ -946,8 +946,8 @@ time2tm(TimeADT time, struct pg_tm *tm, fsec_t *fsec) recalc: trem = time; - TMODULO(trem, tm->tm_hour, (double)SECS_PER_HOUR); - TMODULO(trem, tm->tm_min, (double)SECS_PER_MINUTE); + TMODULO(trem, tm->tm_hour, (double) SECS_PER_HOUR); + TMODULO(trem, tm->tm_min, (double) SECS_PER_MINUTE); TMODULO(trem, tm->tm_sec, 1.0); trem = TIMEROUND(trem); /* roundoff may need to propagate to higher-order fields */ @@ -989,6 +989,7 @@ Datum time_recv(PG_FUNCTION_ARGS) { StringInfo buf = (StringInfo) PG_GETARG_POINTER(0); + #ifdef NOT_USED Oid typelem = PG_GETARG_OID(1); #endif @@ -1072,7 +1073,6 @@ AdjustTimeForTypmod(TimeADT *time, int32 typmod) INT64CONST(5), INT64CONST(0) }; - #else /* note MAX_TIME_PRECISION differs in this case */ static const double TimeScales[MAX_TIME_PRECISION + 1] = { @@ -1093,21 +1093,21 @@ AdjustTimeForTypmod(TimeADT *time, int32 typmod) if (typmod >= 0 && typmod <= MAX_TIME_PRECISION) { /* - * Note: this round-to-nearest code is not completely consistent - * about rounding values that are exactly halfway between integral - * values. On most platforms, rint() will implement - * round-to-nearest-even, but the integer code always rounds up - * (away from zero). Is it worth trying to be consistent? + * Note: this round-to-nearest code is not completely consistent about + * rounding values that are exactly halfway between integral values. + * On most platforms, rint() will implement round-to-nearest-even, but + * the integer code always rounds up (away from zero). Is it worth + * trying to be consistent? */ #ifdef HAVE_INT64_TIMESTAMP if (*time >= INT64CONST(0)) *time = ((*time + TimeOffsets[typmod]) / TimeScales[typmod]) * - TimeScales[typmod]; + TimeScales[typmod]; else *time = -((((-*time) + TimeOffsets[typmod]) / TimeScales[typmod]) * - TimeScales[typmod]); + TimeScales[typmod]); #else - *time = rint((double) * time * TimeScales[typmod]) / TimeScales[typmod]; + *time = rint((double) *time * TimeScales[typmod]) / TimeScales[typmod]; #endif } } @@ -1208,8 +1208,8 @@ Datum overlaps_time(PG_FUNCTION_ARGS) { /* - * The arguments are TimeADT, but we leave them as generic Datums to - * avoid dereferencing nulls (TimeADT is pass-by-reference!) + * The arguments are TimeADT, but we leave them as generic Datums to avoid + * dereferencing nulls (TimeADT is pass-by-reference!) */ Datum ts1 = PG_GETARG_DATUM(0); Datum te1 = PG_GETARG_DATUM(1); @@ -1226,9 +1226,9 @@ overlaps_time(PG_FUNCTION_ARGS) (DatumGetTimeADT(t1) < DatumGetTimeADT(t2)) /* - * If both endpoints of interval 1 are null, the result is null - * (unknown). If just one endpoint is null, take ts1 as the non-null - * one. Otherwise, take ts1 as the lesser endpoint. + * If both endpoints of interval 1 are null, the result is null (unknown). + * If just one endpoint is null, take ts1 as the non-null one. Otherwise, + * take ts1 as the lesser endpoint. */ if (ts1IsNull) { @@ -1276,8 +1276,8 @@ overlaps_time(PG_FUNCTION_ARGS) if (TIMEADT_GT(ts1, ts2)) { /* - * This case is ts1 < te2 OR te1 < te2, which may look redundant - * but in the presence of nulls it's not quite completely so. + * This case is ts1 < te2 OR te1 < te2, which may look redundant but + * in the presence of nulls it's not quite completely so. */ if (te2IsNull) PG_RETURN_NULL(); @@ -1287,8 +1287,8 @@ overlaps_time(PG_FUNCTION_ARGS) PG_RETURN_NULL(); /* - * If te1 is not null then we had ts1 <= te1 above, and we just - * found ts1 >= te2, hence te1 >= te2. + * If te1 is not null then we had ts1 <= te1 above, and we just found + * ts1 >= te2, hence te1 >= te2. */ PG_RETURN_BOOL(false); } @@ -1303,8 +1303,8 @@ overlaps_time(PG_FUNCTION_ARGS) PG_RETURN_NULL(); /* - * If te2 is not null then we had ts2 <= te2 above, and we just - * found ts2 >= te1, hence te2 >= te1. + * If te2 is not null then we had ts2 <= te2 above, and we just found + * ts2 >= te1, hence te2 >= te1. */ PG_RETURN_BOOL(false); } @@ -1312,8 +1312,7 @@ overlaps_time(PG_FUNCTION_ARGS) { /* * For ts1 = ts2 the spec says te1 <> te2 OR te1 = te2, which is a - * rather silly way of saying "true if both are nonnull, else - * null". + * rather silly way of saying "true if both are nonnull, else null". */ if (te1IsNull || te2IsNull) PG_RETURN_NULL(); @@ -1330,7 +1329,7 @@ overlaps_time(PG_FUNCTION_ARGS) Datum timestamp_time(PG_FUNCTION_ARGS) { - Timestamp timestamp = PG_GETARG_TIMESTAMP(0); + Timestamp timestamp = PG_GETARG_TIMESTAMP(0); TimeADT result; struct pg_tm tt, *tm = &tt; @@ -1351,7 +1350,7 @@ timestamp_time(PG_FUNCTION_ARGS) * USECS_PER_DAY) - timestamp; */ result = ((((tm->tm_hour * MINS_PER_HOUR + tm->tm_min) * SECS_PER_MINUTE) + tm->tm_sec) * - USECS_PER_SEC) + fsec; + USECS_PER_SEC) + fsec; #else result = ((tm->tm_hour * MINS_PER_HOUR + tm->tm_min) * SECS_PER_MINUTE) + tm->tm_sec + fsec; #endif @@ -1388,7 +1387,7 @@ timestamptz_time(PG_FUNCTION_ARGS) * USECS_PER_DAY) - timestamp; */ result = ((((tm->tm_hour * MINS_PER_HOUR + tm->tm_min) * SECS_PER_MINUTE) + tm->tm_sec) * - USECS_PER_SEC) + fsec; + USECS_PER_SEC) + fsec; #else result = ((tm->tm_hour * MINS_PER_HOUR + tm->tm_min) * SECS_PER_MINUTE) + tm->tm_sec + fsec; #endif @@ -1402,12 +1401,12 @@ timestamptz_time(PG_FUNCTION_ARGS) Datum datetime_timestamp(PG_FUNCTION_ARGS) { - DateADT date = PG_GETARG_DATEADT(0); + DateADT date = PG_GETARG_DATEADT(0); TimeADT time = PG_GETARG_TIMEADT(1); Timestamp result; result = DatumGetTimestamp(DirectFunctionCall1(date_timestamp, - DateADTGetDatum(date))); + DateADTGetDatum(date))); result += time; PG_RETURN_TIMESTAMP(result); @@ -1461,8 +1460,8 @@ interval_time(PG_FUNCTION_ARGS) } #else result = span->time; - if (result >= (double)SECS_PER_DAY || result < 0) - result -= floor(result / (double)SECS_PER_DAY) * (double)SECS_PER_DAY; + if (result >= (double) SECS_PER_DAY || result < 0) + result -= floor(result / (double) SECS_PER_DAY) * (double) SECS_PER_DAY; #endif PG_RETURN_TIMEADT(result); @@ -1506,7 +1505,7 @@ time_pl_interval(PG_FUNCTION_ARGS) TimeADT time1; result = time + span->time; - TMODULO(result, time1, (double)SECS_PER_DAY); + TMODULO(result, time1, (double) SECS_PER_DAY); if (result < 0) result += SECS_PER_DAY; #endif @@ -1533,7 +1532,7 @@ time_mi_interval(PG_FUNCTION_ARGS) TimeADT time1; result = time - span->time; - TMODULO(result, time1, (double)SECS_PER_DAY); + TMODULO(result, time1, (double) SECS_PER_DAY); if (result < 0) result += SECS_PER_DAY; #endif @@ -1678,8 +1677,8 @@ time_part(PG_FUNCTION_ARGS) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("\"time\" units \"%s\" not recognized", - DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(units)))))); + DatumGetCString(DirectFunctionCall1(textout, + PointerGetDatum(units)))))); result = 0; } @@ -1698,7 +1697,7 @@ time_part(PG_FUNCTION_ARGS) (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("\"time\" units \"%s\" not recognized", DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(units)))))); + PointerGetDatum(units)))))); result = 0; } @@ -1714,7 +1713,7 @@ time_part(PG_FUNCTION_ARGS) * Convert a tm structure to a time data type. */ static int -tm2timetz(struct pg_tm *tm, fsec_t fsec, int tz, TimeTzADT *result) +tm2timetz(struct pg_tm * tm, fsec_t fsec, int tz, TimeTzADT *result) { #ifdef HAVE_INT64_TIMESTAMP result->time = ((((tm->tm_hour * MINS_PER_HOUR + tm->tm_min) * SECS_PER_MINUTE) + tm->tm_sec) * @@ -1787,6 +1786,7 @@ Datum timetz_recv(PG_FUNCTION_ARGS) { StringInfo buf = (StringInfo) PG_GETARG_POINTER(0); + #ifdef NOT_USED Oid typelem = PG_GETARG_OID(1); #endif @@ -1831,7 +1831,7 @@ timetz_send(PG_FUNCTION_ARGS) * Convert TIME WITH TIME ZONE data type to POSIX time structure. */ static int -timetz2tm(TimeTzADT *time, struct pg_tm *tm, fsec_t *fsec, int *tzp) +timetz2tm(TimeTzADT *time, struct pg_tm * tm, fsec_t *fsec, int *tzp) { #ifdef HAVE_INT64_TIMESTAMP int64 trem = time->time; @@ -1846,8 +1846,8 @@ timetz2tm(TimeTzADT *time, struct pg_tm *tm, fsec_t *fsec, int *tzp) double trem = time->time; recalc: - TMODULO(trem, tm->tm_hour, (double)SECS_PER_HOUR); - TMODULO(trem, tm->tm_min, (double)SECS_PER_MINUTE); + TMODULO(trem, tm->tm_hour, (double) SECS_PER_HOUR); + TMODULO(trem, tm->tm_min, (double) SECS_PER_MINUTE); TMODULO(trem, tm->tm_sec, 1.0); trem = TIMEROUND(trem); /* roundoff may need to propagate to higher-order fields */ @@ -1995,8 +1995,8 @@ timetz_hash(PG_FUNCTION_ARGS) /* * Specify hash length as sizeof(double) + sizeof(int4), not as - * sizeof(TimeTzADT), so that any garbage pad bytes in the structure - * won't be included in the hash! + * sizeof(TimeTzADT), so that any garbage pad bytes in the structure won't + * be included in the hash! */ return hash_any((unsigned char *) key, sizeof(key->time) + sizeof(key->zone)); } @@ -2052,7 +2052,7 @@ timetz_pl_interval(PG_FUNCTION_ARGS) result->time += USECS_PER_DAY; #else result->time = time->time + span->time; - TMODULO(result->time, time1.time, (double)SECS_PER_DAY); + TMODULO(result->time, time1.time, (double) SECS_PER_DAY); if (result->time < 0) result->time += SECS_PER_DAY; #endif @@ -2085,7 +2085,7 @@ timetz_mi_interval(PG_FUNCTION_ARGS) result->time += USECS_PER_DAY; #else result->time = time->time - span->time; - TMODULO(result->time, time1.time, (double)SECS_PER_DAY); + TMODULO(result->time, time1.time, (double) SECS_PER_DAY); if (result->time < 0) result->time += SECS_PER_DAY; #endif @@ -2105,8 +2105,8 @@ Datum overlaps_timetz(PG_FUNCTION_ARGS) { /* - * The arguments are TimeTzADT *, but we leave them as generic Datums - * for convenience of notation --- and to avoid dereferencing nulls. + * The arguments are TimeTzADT *, but we leave them as generic Datums for + * convenience of notation --- and to avoid dereferencing nulls. */ Datum ts1 = PG_GETARG_DATUM(0); Datum te1 = PG_GETARG_DATUM(1); @@ -2123,9 +2123,9 @@ overlaps_timetz(PG_FUNCTION_ARGS) DatumGetBool(DirectFunctionCall2(timetz_lt,t1,t2)) /* - * If both endpoints of interval 1 are null, the result is null - * (unknown). If just one endpoint is null, take ts1 as the non-null - * one. Otherwise, take ts1 as the lesser endpoint. + * If both endpoints of interval 1 are null, the result is null (unknown). + * If just one endpoint is null, take ts1 as the non-null one. Otherwise, + * take ts1 as the lesser endpoint. */ if (ts1IsNull) { @@ -2173,8 +2173,8 @@ overlaps_timetz(PG_FUNCTION_ARGS) if (TIMETZ_GT(ts1, ts2)) { /* - * This case is ts1 < te2 OR te1 < te2, which may look redundant - * but in the presence of nulls it's not quite completely so. + * This case is ts1 < te2 OR te1 < te2, which may look redundant but + * in the presence of nulls it's not quite completely so. */ if (te2IsNull) PG_RETURN_NULL(); @@ -2184,8 +2184,8 @@ overlaps_timetz(PG_FUNCTION_ARGS) PG_RETURN_NULL(); /* - * If te1 is not null then we had ts1 <= te1 above, and we just - * found ts1 >= te2, hence te1 >= te2. + * If te1 is not null then we had ts1 <= te1 above, and we just found + * ts1 >= te2, hence te1 >= te2. */ PG_RETURN_BOOL(false); } @@ -2200,8 +2200,8 @@ overlaps_timetz(PG_FUNCTION_ARGS) PG_RETURN_NULL(); /* - * If te2 is not null then we had ts2 <= te2 above, and we just - * found ts2 >= te1, hence te2 >= te1. + * If te2 is not null then we had ts2 <= te2 above, and we just found + * ts2 >= te1, hence te2 >= te1. */ PG_RETURN_BOOL(false); } @@ -2209,8 +2209,7 @@ overlaps_timetz(PG_FUNCTION_ARGS) { /* * For ts1 = ts2 the spec says te1 <> te2 OR te1 = te2, which is a - * rather silly way of saying "true if both are nonnull, else - * null". + * rather silly way of saying "true if both are nonnull, else null". */ if (te1IsNull || te2IsNull) PG_RETURN_NULL(); @@ -2297,14 +2296,14 @@ timestamptz_timetz(PG_FUNCTION_ARGS) Datum datetimetz_timestamptz(PG_FUNCTION_ARGS) { - DateADT date = PG_GETARG_DATEADT(0); + DateADT date = PG_GETARG_DATEADT(0); TimeTzADT *time = PG_GETARG_TIMETZADT_P(1); TimestampTz result; #ifdef HAVE_INT64_TIMESTAMP result = date * USECS_PER_DAY + time->time + time->zone * USECS_PER_SEC; #else - result = date * (double)SECS_PER_DAY + time->time + time->zone; + result = date * (double) SECS_PER_DAY + time->time + time->zone; #endif PG_RETURN_TIMESTAMP(result); @@ -2355,8 +2354,8 @@ text_timetz(PG_FUNCTION_ARGS) if (VARSIZE(str) - VARHDRSZ > MAXDATELEN) ereport(ERROR, (errcode(ERRCODE_INVALID_DATETIME_FORMAT), - errmsg("invalid input syntax for type time with time zone: \"%s\"", - VARDATA(str)))); + errmsg("invalid input syntax for type time with time zone: \"%s\"", + VARDATA(str)))); sp = VARDATA(str); dp = dstr; @@ -2410,12 +2409,12 @@ timetz_part(PG_FUNCTION_ARGS) case DTK_TZ_MINUTE: result = -tz; result /= SECS_PER_MINUTE; - FMODULO(result, dummy, (double)SECS_PER_MINUTE); + FMODULO(result, dummy, (double) SECS_PER_MINUTE); break; case DTK_TZ_HOUR: dummy = -tz; - FMODULO(dummy, result, (double)SECS_PER_HOUR); + FMODULO(dummy, result, (double) SECS_PER_HOUR); break; case DTK_MICROSEC: @@ -2460,9 +2459,9 @@ timetz_part(PG_FUNCTION_ARGS) default: ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("\"time with time zone\" units \"%s\" not recognized", - DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(units)))))); + errmsg("\"time with time zone\" units \"%s\" not recognized", + DatumGetCString(DirectFunctionCall1(textout, + PointerGetDatum(units)))))); result = 0; } @@ -2479,9 +2478,9 @@ timetz_part(PG_FUNCTION_ARGS) { ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("\"time with time zone\" units \"%s\" not recognized", - DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(units)))))); + errmsg("\"time with time zone\" units \"%s\" not recognized", + DatumGetCString(DirectFunctionCall1(textout, + PointerGetDatum(units)))))); result = 0; } @@ -2500,15 +2499,15 @@ timetz_zone(PG_FUNCTION_ARGS) TimeTzADT *t = PG_GETARG_TIMETZADT_P(1); TimeTzADT *result; int tz; - char tzname[TZ_STRLEN_MAX + 1]; - int len; + char tzname[TZ_STRLEN_MAX + 1]; + int len; pg_tz *tzp; /* - * Look up the requested timezone. First we look in the timezone - * database (to handle cases like "America/New_York"), and if that - * fails, we look in the date token table (to handle cases like "EST"). - */ + * Look up the requested timezone. First we look in the timezone database + * (to handle cases like "America/New_York"), and if that fails, we look + * in the date token table (to handle cases like "EST"). + */ len = Min(VARSIZE(zone) - VARHDRSZ, TZ_STRLEN_MAX); memcpy(tzname, VARDATA(zone), len); tzname[len] = '\0'; @@ -2516,7 +2515,7 @@ timetz_zone(PG_FUNCTION_ARGS) if (tzp) { /* Get the offset-from-GMT that is valid today for the selected zone */ - pg_time_t now; + pg_time_t now; struct pg_tm *tm; now = time(NULL); @@ -2546,7 +2545,7 @@ timetz_zone(PG_FUNCTION_ARGS) } result = (TimeTzADT *) palloc(sizeof(TimeTzADT)); - + #ifdef HAVE_INT64_TIMESTAMP result->time = t->time + (t->zone - tz) * USECS_PER_SEC; while (result->time < INT64CONST(0)) @@ -2582,7 +2581,7 @@ timetz_izone(PG_FUNCTION_ARGS) (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("\"interval\" time zone \"%s\" not valid", DatumGetCString(DirectFunctionCall1(interval_out, - PointerGetDatum(zone)))))); + PointerGetDatum(zone)))))); #ifdef HAVE_INT64_TIMESTAMP tz = -(zone->time / USECS_PER_SEC); diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c index faacdb2eba..5b3fc46d9c 100644 --- a/src/backend/utils/adt/datetime.c +++ b/src/backend/utils/adt/datetime.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.159 2005/10/14 11:47:57 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.160 2005/10/15 02:49:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -28,16 +28,16 @@ static int DecodeNumber(int flen, char *field, bool haveTextMonth, int fmask, int *tmask, - struct pg_tm *tm, fsec_t *fsec, int *is2digits); + struct pg_tm * tm, fsec_t *fsec, int *is2digits); static int DecodeNumberField(int len, char *str, int fmask, int *tmask, - struct pg_tm *tm, fsec_t *fsec, int *is2digits); + struct pg_tm * tm, fsec_t *fsec, int *is2digits); static int DecodeTime(char *str, int fmask, int *tmask, - struct pg_tm *tm, fsec_t *fsec); + struct pg_tm * tm, fsec_t *fsec); static int DecodeTimezone(char *str, int *tzp); static int DecodePosixTimezone(char *str, int *tzp); static datetkn *datebsearch(char *key, datetkn *base, unsigned int nel); -static int DecodeDate(char *str, int fmask, int *tmask, struct pg_tm *tm); +static int DecodeDate(char *str, int fmask, int *tmask, struct pg_tm * tm); static void TrimTrailingZeros(char *str); @@ -308,8 +308,7 @@ static datetkn datetktbl[] = { {"lhdt", DTZ, POS(44)}, /* Lord Howe Daylight Time, Australia */ {"lhst", TZ, POS(42)}, /* Lord Howe Standard Time, Australia */ {"ligt", TZ, POS(40)}, /* From Melbourne, Australia */ - {"lint", TZ, POS(56)}, /* Line Islands Time (Kiribati; +14 - * hours!) */ + {"lint", TZ, POS(56)}, /* Line Islands Time (Kiribati; +14 hours!) */ {"lkt", TZ, POS(24)}, /* Lanka Time */ {"m", UNITS, DTK_MONTH}, /* "month" for ISO input */ {"magst", DTZ, POS(48)}, /* Magadan Summer Time */ @@ -681,7 +680,7 @@ j2day(int date) * Get the transaction start time ("now()") broken down as a struct pg_tm. */ void -GetCurrentDateTime(struct pg_tm *tm) +GetCurrentDateTime(struct pg_tm * tm) { int tz; fsec_t fsec; @@ -698,7 +697,7 @@ GetCurrentDateTime(struct pg_tm *tm) * including fractional seconds and timezone offset. */ void -GetCurrentTimeUsec(struct pg_tm *tm, fsec_t *fsec, int *tzp) +GetCurrentTimeUsec(struct pg_tm * tm, fsec_t *fsec, int *tzp) { int tz; @@ -741,8 +740,8 @@ TrimTrailingZeros(char *str) * * timestr - the input string * workbuf - workspace for field string storage. This must be - * larger than the largest legal input for this datetime type -- - * some additional space will be needed to NUL terminate fields. + * larger than the largest legal input for this datetime type -- + * some additional space will be needed to NUL terminate fields. * buflen - the size of workbuf * field[] - pointers to field strings are returned in this array * ftype[] - field type indicators are returned in this array @@ -776,10 +775,10 @@ ParseDateTime(const char *timestr, char *workbuf, size_t buflen, const char *bufend = workbuf + buflen; /* - * Set the character pointed-to by "bufptr" to "newchar", and - * increment "bufptr". "end" gives the end of the buffer -- we - * return an error if there is no space left to append a character - * to the buffer. Note that "bufptr" is evaluated twice. + * Set the character pointed-to by "bufptr" to "newchar", and increment + * "bufptr". "end" gives the end of the buffer -- we return an error if + * there is no space left to append a character to the buffer. Note that + * "bufptr" is evaluated twice. */ #define APPEND_CHAR(bufptr, end, newchar) \ do \ @@ -835,8 +834,8 @@ ParseDateTime(const char *timestr, char *workbuf, size_t buflen, APPEND_CHAR(bufp, bufend, *cp++); /* - * insist that the delimiters match to get a - * three-field date. + * insist that the delimiters match to get a three-field + * date. */ if (*cp == delim) { @@ -855,8 +854,8 @@ ParseDateTime(const char *timestr, char *workbuf, size_t buflen, } /* - * otherwise, number only and will determine year, month, day, - * or concatenated fields later... + * otherwise, number only and will determine year, month, day, or + * concatenated fields later... */ else ftype[nf] = DTK_NUMBER; @@ -872,8 +871,7 @@ ParseDateTime(const char *timestr, char *workbuf, size_t buflen, } /* - * text? then date string, month, day of week, special, or - * timezone + * text? then date string, month, day of week, special, or timezone */ else if (isalpha((unsigned char) *cp)) { @@ -883,8 +881,8 @@ ParseDateTime(const char *timestr, char *workbuf, size_t buflen, APPEND_CHAR(bufp, bufend, pg_tolower((unsigned char) *cp++)); /* - * Full date string with leading text month? Could also be a - * POSIX time zone... + * Full date string with leading text month? Could also be a POSIX + * time zone... */ if (*cp == '-' || *cp == '/' || *cp == '.') { @@ -969,13 +967,12 @@ ParseDateTime(const char *timestr, char *workbuf, size_t buflen, */ int DecodeDateTime(char **field, int *ftype, int nf, - int *dtype, struct pg_tm *tm, fsec_t *fsec, int *tzp) + int *dtype, struct pg_tm * tm, fsec_t *fsec, int *tzp) { int fmask = 0, tmask, type; - int ptype = 0; /* "prefix type" for ISO y2001m02d04 - * format */ + int ptype = 0; /* "prefix type" for ISO y2001m02d04 format */ int i; int val; int dterr; @@ -1054,8 +1051,8 @@ DecodeDateTime(char **field, int *ftype, int nf, /* * Starts with a digit but we already have a time - * field? Then we are in trouble with a date and - * time already... + * field? Then we are in trouble with a date and time + * already... */ if ((fmask & DTK_TIME_M) == DTK_TIME_M) return DTERR_BAD_FORMAT; @@ -1070,8 +1067,8 @@ DecodeDateTime(char **field, int *ftype, int nf, *cp = '\0'; /* - * Then read the rest of the field as a - * concatenated time + * Then read the rest of the field as a concatenated + * time */ dterr = DecodeNumberField(strlen(field[i]), field[i], fmask, @@ -1115,8 +1112,8 @@ DecodeDateTime(char **field, int *ftype, int nf, * DecodeTime() */ /* test for > 24:00:00 */ - if (tm->tm_hour > 24 || - (tm->tm_hour == 24 && (tm->tm_min > 0 || tm->tm_sec > 0))) + if (tm->tm_hour > 24 || + (tm->tm_hour == 24 && (tm->tm_min > 0 || tm->tm_sec > 0))) return DTERR_FIELD_OVERFLOW; break; @@ -1132,9 +1129,8 @@ DecodeDateTime(char **field, int *ftype, int nf, return dterr; /* - * Already have a time zone? Then maybe this is the - * second field of a POSIX time: EST+3 (equivalent to - * PST) + * Already have a time zone? Then maybe this is the second + * field of a POSIX time: EST+3 (equivalent to PST) */ if (i > 0 && (fmask & DTK_M(TZ)) != 0 && ftype[i - 1] == DTK_TZ && @@ -1278,7 +1274,7 @@ DecodeDateTime(char **field, int *ftype, int nf, case DTK_TIME: /* previous field was "t" for ISO time */ dterr = DecodeNumberField(strlen(field[i]), field[i], - (fmask | DTK_DATE_M), + (fmask | DTK_DATE_M), &tmask, tm, fsec, &is2digits); if (dterr < 0) @@ -1316,9 +1312,9 @@ DecodeDateTime(char **field, int *ftype, int nf, else if (cp != NULL && flen - strlen(cp) > 2) { /* - * Interpret as a concatenated date or time Set - * the type field to allow decoding other fields - * later. Example: 20011223 or 040506 + * Interpret as a concatenated date or time Set the + * type field to allow decoding other fields later. + * Example: 20011223 or 040506 */ dterr = DecodeNumberField(flen, field[i], fmask, &tmask, tm, @@ -1363,8 +1359,8 @@ DecodeDateTime(char **field, int *ftype, int nf, { case DTK_CURRENT: ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("date/time value \"current\" is no longer supported"))); + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("date/time value \"current\" is no longer supported"))); return DTERR_BAD_FORMAT; break; @@ -1380,7 +1376,7 @@ DecodeDateTime(char **field, int *ftype, int nf, *dtype = DTK_DATE; GetCurrentDateTime(tm); j2date(date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) - 1, - &tm->tm_year, &tm->tm_mon, &tm->tm_mday); + &tm->tm_year, &tm->tm_mon, &tm->tm_mday); tm->tm_hour = 0; tm->tm_min = 0; tm->tm_sec = 0; @@ -1400,7 +1396,7 @@ DecodeDateTime(char **field, int *ftype, int nf, *dtype = DTK_DATE; GetCurrentDateTime(tm); j2date(date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) + 1, - &tm->tm_year, &tm->tm_mon, &tm->tm_mday); + &tm->tm_year, &tm->tm_mon, &tm->tm_mday); tm->tm_hour = 0; tm->tm_min = 0; tm->tm_sec = 0; @@ -1425,8 +1421,8 @@ DecodeDateTime(char **field, int *ftype, int nf, case MONTH: /* - * already have a (numeric) month? then see if we - * can substitute... + * 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 && @@ -1442,8 +1438,8 @@ DecodeDateTime(char **field, int *ftype, int nf, 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; @@ -1455,8 +1451,8 @@ DecodeDateTime(char **field, int *ftype, int nf, case DTZ: /* - * set mask for TZ here _or_ check for DTZ later - * when getting default timezone + * set mask for TZ here _or_ check for DTZ later when + * getting default timezone */ tmask |= DTK_M(TZ); tm->tm_isdst = 1; @@ -1497,9 +1493,8 @@ DecodeDateTime(char **field, int *ftype, int nf, case ISOTIME: /* - * This is a filler field "t" indicating that the - * next field is time. Try to verify that this is - * sensible. + * This is a filler field "t" indicating that the next + * field is time. Try to verify that this is sensible. */ tmask = 0; @@ -1546,8 +1541,8 @@ DecodeDateTime(char **field, int *ftype, int nf, else ereport(ERROR, (errcode(ERRCODE_INVALID_DATETIME_FORMAT), - errmsg("inconsistent use of year %04d and \"BC\"", - tm->tm_year))); + errmsg("inconsistent use of year %04d and \"BC\"", + tm->tm_year))); } else if (is2digits) { @@ -1597,9 +1592,9 @@ DecodeDateTime(char **field, int *ftype, int nf, } /* - * Check for valid day of month, now that we know for sure the - * month and year. Note we don't use MD_FIELD_OVERFLOW here, - * since it seems unlikely that "Feb 29" is a YMD-order error. + * Check for valid day of month, now that we know for sure the month + * and year. Note we don't use MD_FIELD_OVERFLOW here, since it seems + * unlikely that "Feb 29" is a YMD-order error. */ if (tm->tm_mday > day_tab[isleap(tm->tm_year)][tm->tm_mon - 1]) return DTERR_FIELD_OVERFLOW; @@ -1608,8 +1603,8 @@ DecodeDateTime(char **field, int *ftype, int nf, if (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 DTERR_BAD_FORMAT; @@ -1634,7 +1629,7 @@ DecodeDateTime(char **field, int *ftype, int nf, * of mktime(), anyway. */ int -DetermineTimeZoneOffset(struct pg_tm *tm, pg_tz *tzp) +DetermineTimeZoneOffset(struct pg_tm * tm, pg_tz *tzp) { int date, sec; @@ -1658,15 +1653,15 @@ DetermineTimeZoneOffset(struct pg_tm *tm, pg_tz *tzp) /* * First, generate the pg_time_t value corresponding to the given - * y/m/d/h/m/s taken as GMT time. If this overflows, punt and decide - * the timezone is GMT. (We only need to worry about overflow on - * machines where pg_time_t is 32 bits.) + * y/m/d/h/m/s taken as GMT time. If this overflows, punt and decide the + * timezone is GMT. (We only need to worry about overflow on machines + * where pg_time_t is 32 bits.) */ if (!IS_VALID_JULIAN(tm->tm_year, tm->tm_mon, tm->tm_mday)) goto overflow; date = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) - UNIX_EPOCH_JDATE; - day = ((pg_time_t) date) *SECS_PER_DAY; + day = ((pg_time_t) date) * SECS_PER_DAY; if (day / SECS_PER_DAY != date) goto overflow; sec = tm->tm_sec + (tm->tm_min + tm->tm_hour * MINS_PER_HOUR) * SECS_PER_MINUTE; @@ -1676,10 +1671,10 @@ DetermineTimeZoneOffset(struct pg_tm *tm, pg_tz *tzp) goto overflow; /* - * Find the DST time boundary just before or following the target time. - * We assume that all zones have GMT offsets less than 24 hours, and - * that DST boundaries can't be closer together than 48 hours, so - * backing up 24 hours and finding the "next" boundary will work. + * Find the DST time boundary just before or following the target time. We + * assume that all zones have GMT offsets less than 24 hours, and that DST + * boundaries can't be closer together than 48 hours, so backing up 24 + * hours and finding the "next" boundary will work. */ prevtime = mytime - SECS_PER_DAY; if (mytime < 0 && prevtime > 0) @@ -1689,7 +1684,7 @@ DetermineTimeZoneOffset(struct pg_tm *tm, pg_tz *tzp) &before_gmtoff, &before_isdst, &boundary, &after_gmtoff, &after_isdst, - tzp); + tzp); if (res < 0) goto overflow; /* failure? */ @@ -1697,7 +1692,7 @@ DetermineTimeZoneOffset(struct pg_tm *tm, pg_tz *tzp) { /* Non-DST zone, life is simple */ tm->tm_isdst = before_isdst; - return - (int) before_gmtoff; + return -(int) before_gmtoff; } /* @@ -1722,24 +1717,25 @@ DetermineTimeZoneOffset(struct pg_tm *tm, pg_tz *tzp) if (beforetime <= boundary && aftertime < boundary) { tm->tm_isdst = before_isdst; - return - (int) before_gmtoff; + return -(int) before_gmtoff; } if (beforetime > boundary && aftertime >= boundary) { tm->tm_isdst = after_isdst; - return - (int) after_gmtoff; + return -(int) after_gmtoff; } + /* - * It's an invalid or ambiguous time due to timezone transition. - * Prefer the standard-time interpretation. + * It's an invalid or ambiguous time due to timezone transition. Prefer + * the standard-time interpretation. */ if (after_isdst == 0) { tm->tm_isdst = after_isdst; - return - (int) after_gmtoff; + return -(int) after_gmtoff; } tm->tm_isdst = before_isdst; - return - (int) before_gmtoff; + return -(int) before_gmtoff; overflow: /* Given date is out of range, so assume UTC */ @@ -1762,7 +1758,7 @@ overflow: */ int DecodeTimeOnly(char **field, int *ftype, int nf, - int *dtype, struct pg_tm *tm, fsec_t *fsec, int *tzp) + int *dtype, struct pg_tm * tm, fsec_t *fsec, int *tzp) { int fmask = 0, tmask, @@ -1792,8 +1788,8 @@ DecodeTimeOnly(char **field, int *ftype, int nf, case DTK_DATE: /* - * Time zone not allowed? Then should not accept dates or - * time zones no matter what else! + * Time zone not allowed? Then should not accept dates or time + * zones no matter what else! */ if (tzp == NULL) return DTERR_BAD_FORMAT; @@ -1815,15 +1811,13 @@ DecodeTimeOnly(char **field, int *ftype, int nf, /* * Starts with a digit but we already have a time - * field? Then we are in trouble with time - * already... + * field? Then we are in trouble with time already... */ if ((fmask & DTK_TIME_M) == DTK_TIME_M) return DTERR_BAD_FORMAT; /* - * Should not get here and fail. Sanity check - * only... + * Should not get here and fail. Sanity check only... */ if ((cp = strchr(field[i], '-')) == NULL) return DTERR_BAD_FORMAT; @@ -1835,8 +1829,8 @@ DecodeTimeOnly(char **field, int *ftype, int nf, *cp = '\0'; /* - * Then read the rest of the field as a - * concatenated time + * Then read the rest of the field as a concatenated + * time */ dterr = DecodeNumberField(strlen(field[i]), field[i], (fmask | DTK_DATE_M), @@ -1879,9 +1873,8 @@ DecodeTimeOnly(char **field, int *ftype, int nf, return dterr; /* - * Already have a time zone? Then maybe this is the - * second field of a POSIX time: EST+3 (equivalent to - * PST) + * Already have a time zone? Then maybe this is the second + * field of a POSIX time: EST+3 (equivalent to PST) */ if (i > 0 && (fmask & DTK_M(TZ)) != 0 && ftype[i - 1] == DTK_TZ && @@ -2025,10 +2018,10 @@ DecodeTimeOnly(char **field, int *ftype, int nf, tmask |= DTK_TIME_M; #ifdef HAVE_INT64_TIMESTAMP dt2time(time * USECS_PER_DAY, - &tm->tm_hour, &tm->tm_min, &tm->tm_sec, fsec); + &tm->tm_hour, &tm->tm_min, &tm->tm_sec, fsec); #else dt2time(time * SECS_PER_DAY, - &tm->tm_hour, &tm->tm_min, &tm->tm_sec, fsec); + &tm->tm_hour, &tm->tm_min, &tm->tm_sec, fsec); #endif } break; @@ -2036,7 +2029,7 @@ DecodeTimeOnly(char **field, int *ftype, int nf, case DTK_TIME: /* previous field was "t" for ISO time */ dterr = DecodeNumberField(strlen(field[i]), field[i], - (fmask | DTK_DATE_M), + (fmask | DTK_DATE_M), &tmask, tm, fsec, &is2digits); if (dterr < 0) @@ -2080,12 +2073,12 @@ DecodeTimeOnly(char **field, int *ftype, int nf, else if (flen - strlen(cp) > 2) { /* - * Interpret as a concatenated date or time - * Set the type field to allow decoding other - * fields later. Example: 20011223 or 040506 + * Interpret as a concatenated date or time Set + * the type field to allow decoding other fields + * later. Example: 20011223 or 040506 */ dterr = DecodeNumberField(flen, field[i], - (fmask | DTK_DATE_M), + (fmask | DTK_DATE_M), &tmask, tm, fsec, &is2digits); if (dterr < 0) @@ -2133,8 +2126,8 @@ DecodeTimeOnly(char **field, int *ftype, int nf, { case DTK_CURRENT: ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("date/time value \"current\" is no longer supported"))); + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("date/time value \"current\" is no longer supported"))); return DTERR_BAD_FORMAT; break; @@ -2162,8 +2155,8 @@ DecodeTimeOnly(char **field, int *ftype, int nf, 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; @@ -2175,8 +2168,8 @@ DecodeTimeOnly(char **field, int *ftype, int nf, case DTZ: /* - * set mask for TZ here _or_ check for DTZ later - * when getting default timezone + * set mask for TZ here _or_ check for DTZ later when + * getting default timezone */ tmask |= DTK_M(TZ); tm->tm_isdst = 1; @@ -2247,14 +2240,14 @@ DecodeTimeOnly(char **field, int *ftype, int nf, if (tm->tm_hour < 0 || tm->tm_min < 0 || tm->tm_min > 59 || tm->tm_sec < 0 || tm->tm_sec > 60 || tm->tm_hour > 24 || - /* test for > 24:00:00 */ - (tm->tm_hour == 24 && (tm->tm_min > 0 || tm->tm_sec > 0 || + /* test for > 24:00:00 */ + (tm->tm_hour == 24 && (tm->tm_min > 0 || tm->tm_sec > 0 || #ifdef HAVE_INT64_TIMESTAMP - *fsec > INT64CONST(0))) || + *fsec > INT64CONST(0))) || *fsec < INT64CONST(0) || *fsec >= USECS_PER_SEC) return DTERR_FIELD_OVERFLOW; #else - *fsec > 0)) || + *fsec > 0)) || *fsec < 0 || *fsec >= 1) return DTERR_FIELD_OVERFLOW; #endif @@ -2269,8 +2262,7 @@ DecodeTimeOnly(char **field, int *ftype, int nf, *tmp = &tt; /* - * 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 DTERR_BAD_FORMAT; @@ -2300,7 +2292,7 @@ DecodeTimeOnly(char **field, int *ftype, int nf, * Insist on a complete set of fields. */ static int -DecodeDate(char *str, int fmask, int *tmask, struct pg_tm *tm) +DecodeDate(char *str, int fmask, int *tmask, struct pg_tm * tm) { fsec_t fsec; int nf = 0; @@ -2458,7 +2450,7 @@ DecodeDate(char *str, int fmask, int *tmask, struct pg_tm *tm) * can be used to represent time spans. */ static int -DecodeTime(char *str, int fmask, int *tmask, struct pg_tm *tm, fsec_t *fsec) +DecodeTime(char *str, int fmask, int *tmask, struct pg_tm * tm, fsec_t *fsec) { char *cp; @@ -2522,7 +2514,7 @@ DecodeTime(char *str, int fmask, int *tmask, struct pg_tm *tm, fsec_t *fsec) */ static int DecodeNumber(int flen, char *str, bool haveTextMonth, int fmask, - int *tmask, struct pg_tm *tm, fsec_t *fsec, int *is2digits) + int *tmask, struct pg_tm * tm, fsec_t *fsec, int *is2digits) { int val; char *cp; @@ -2539,8 +2531,8 @@ DecodeNumber(int flen, char *str, bool haveTextMonth, int fmask, double frac; /* - * More than two digits before decimal point? Then could be a date - * or a run-together time: 2001.360 20011225 040506.789 + * More than two digits before decimal point? Then could be a date or + * a run-together time: 2001.360 20011225 040506.789 */ if (cp - str > 2) { @@ -2581,9 +2573,9 @@ DecodeNumber(int flen, char *str, bool haveTextMonth, int fmask, case 0: /* - * Nothing so far; make a decision about what we think the - * input is. There used to be lots of heuristics here, but - * the consensus now is to be paranoid. It *must* be either + * Nothing so far; make a decision about what we think the input + * is. There used to be lots of heuristics here, but the + * consensus now is to be paranoid. It *must* be either * YYYY-MM-DD (with a more-than-two-digit year field), or the * field order defined by DateOrder. */ @@ -2614,12 +2606,11 @@ DecodeNumber(int flen, char *str, bool haveTextMonth, int fmask, if (haveTextMonth) { /* - * We are at the first numeric field of a date that - * included a textual month name. We want to support the - * variants MON-DD-YYYY, DD-MON-YYYY, and YYYY-MON-DD as - * unambiguous inputs. We will also accept MON-DD-YY or - * DD-MON-YY in either DMY or MDY modes, as well as - * YY-MON-DD in YMD mode. + * We are at the first numeric field of a date that included a + * textual month name. We want to support the variants + * MON-DD-YYYY, DD-MON-YYYY, and YYYY-MON-DD as unambiguous + * inputs. We will also accept MON-DD-YY or DD-MON-YY in + * either DMY or MDY modes, as well as YY-MON-DD in YMD mode. */ if (flen >= 3 || DateOrder == DATEORDER_YMD) { @@ -2693,8 +2684,8 @@ DecodeNumber(int flen, char *str, bool haveTextMonth, int fmask, } /* - * When processing a year field, mark it for adjustment if it's only - * one or two digits. + * When processing a year field, mark it for adjustment if it's only one + * or two digits. */ if (*tmask == DTK_M(YEAR)) *is2digits = (flen <= 2); @@ -2712,13 +2703,13 @@ DecodeNumber(int flen, char *str, bool haveTextMonth, int fmask, */ static int DecodeNumberField(int len, char *str, int fmask, - int *tmask, struct pg_tm *tm, fsec_t *fsec, int *is2digits) + int *tmask, struct pg_tm * tm, fsec_t *fsec, int *is2digits) { char *cp; /* - * Have a decimal point? Then this is a date or something with a - * seconds field... + * Have a decimal point? Then this is a date or something with a seconds + * field... */ if ((cp = strchr(str, '.')) != NULL) { @@ -2970,7 +2961,7 @@ DecodeSpecial(int field, char *lowtoken, int *val) * preceding an hh:mm:ss field. - thomas 1998-04-30 */ int -DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct pg_tm *tm, fsec_t *fsec) +DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct pg_tm * tm, fsec_t *fsec) { int is_before = FALSE; char *cp; @@ -3014,9 +3005,9 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct pg_tm *tm, f Assert(*field[i] == '-' || *field[i] == '+'); /* - * A single signed number ends up here, but will be - * rejected by DecodeTime(). So, work this out to drop - * through to DTK_NUMBER, which *can* tolerate this. + * A single signed number ends up here, but will be rejected + * by DecodeTime(). So, work this out to drop through to + * DTK_NUMBER, which *can* tolerate this. */ cp = field[i] + 1; while (*cp != '\0' && *cp != ':' && *cp != '.') @@ -3035,8 +3026,8 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct pg_tm *tm, f /* * Set the next type to be a day, if units are not - * specified. This handles the case of '1 +02:03' - * since we are reading right to left. + * specified. This handles the case of '1 +02:03' since we + * are reading right to left. */ type = DTK_DAY; tmask = DTK_M(TZ); @@ -3366,7 +3357,7 @@ DateTimeParseError(int dterr, const char *str, const char *datatype) (errcode(ERRCODE_DATETIME_FIELD_OVERFLOW), errmsg("date/time field value out of range: \"%s\"", str), - errhint("Perhaps you need a different \"datestyle\" setting."))); + errhint("Perhaps you need a different \"datestyle\" setting."))); break; case DTERR_INTERVAL_OVERFLOW: ereport(ERROR, @@ -3376,9 +3367,9 @@ DateTimeParseError(int dterr, const char *str, const char *datatype) break; case DTERR_TZDISP_OVERFLOW: ereport(ERROR, - (errcode(ERRCODE_INVALID_TIME_ZONE_DISPLACEMENT_VALUE), - errmsg("time zone displacement out of range: \"%s\"", - str))); + (errcode(ERRCODE_INVALID_TIME_ZONE_DISPLACEMENT_VALUE), + errmsg("time zone displacement out of range: \"%s\"", + str))); break; case DTERR_BAD_FORMAT: default: @@ -3424,7 +3415,7 @@ datebsearch(char *key, datetkn *base, unsigned int nel) * Encode date as local time. */ int -EncodeDateOnly(struct pg_tm *tm, int style, char *str) +EncodeDateOnly(struct pg_tm * tm, int style, char *str) { if (tm->tm_mon < 1 || tm->tm_mon > MONTHS_PER_YEAR) return -1; @@ -3438,7 +3429,7 @@ EncodeDateOnly(struct pg_tm *tm, int style, char *str) tm->tm_year, tm->tm_mon, tm->tm_mday); else sprintf(str, "%04d-%02d-%02d %s", - -(tm->tm_year - 1), tm->tm_mon, tm->tm_mday, "BC"); + -(tm->tm_year - 1), tm->tm_mon, tm->tm_mday, "BC"); break; case USE_SQL_DATES: @@ -3484,7 +3475,7 @@ EncodeDateOnly(struct pg_tm *tm, int style, char *str) * Encode time fields only. */ int -EncodeTimeOnly(struct pg_tm *tm, fsec_t fsec, int *tzp, int style, char *str) +EncodeTimeOnly(struct pg_tm * tm, fsec_t fsec, int *tzp, int style, char *str) { if (tm->tm_hour < 0 || tm->tm_hour > HOURS_PER_DAY) return -1; @@ -3492,8 +3483,8 @@ EncodeTimeOnly(struct pg_tm *tm, fsec_t fsec, int *tzp, int style, char *str) sprintf(str, "%02d:%02d", tm->tm_hour, tm->tm_min); /* - * Print fractional seconds if any. The fractional field widths - * here should be equal to the larger of MAX_TIME_PRECISION and + * Print fractional seconds if any. The fractional field widths here + * should be equal to the larger of MAX_TIME_PRECISION and * MAX_TIMESTAMP_PRECISION. */ if (fsec != 0) @@ -3534,15 +3525,15 @@ EncodeTimeOnly(struct pg_tm *tm, fsec_t fsec, int *tzp, int style, char *str) * European - dd/mm/yyyy */ int -EncodeDateTime(struct pg_tm *tm, fsec_t fsec, int *tzp, char **tzn, int style, char *str) +EncodeDateTime(struct pg_tm * tm, fsec_t fsec, int *tzp, char **tzn, int style, char *str) { int day, hour, min; /* - * Why are we checking only the month field? Change this to an - * assert... if (tm->tm_mon < 1 || tm->tm_mon > MONTHS_PER_YEAR) return -1; + * Why are we checking only the month field? Change this to an assert... + * if (tm->tm_mon < 1 || tm->tm_mon > MONTHS_PER_YEAR) return -1; */ Assert(tm->tm_mon >= 1 && tm->tm_mon <= MONTHS_PER_YEAR); @@ -3556,11 +3547,11 @@ EncodeDateTime(struct pg_tm *tm, fsec_t fsec, int *tzp, char **tzn, int style, c tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min); /* - * Print fractional seconds if any. The field widths here - * should be at least equal to MAX_TIMESTAMP_PRECISION. + * Print fractional seconds if any. The field widths here should + * be at least equal to MAX_TIMESTAMP_PRECISION. * - * In float mode, don't print fractional seconds before 1 AD, - * since it's unlikely there's any precision left ... + * In float mode, don't print fractional seconds before 1 AD, since + * it's unlikely there's any precision left ... */ #ifdef HAVE_INT64_TIMESTAMP if (fsec != 0) @@ -3579,10 +3570,10 @@ EncodeDateTime(struct pg_tm *tm, fsec_t fsec, int *tzp, char **tzn, int style, c sprintf(str + strlen(str), ":%02d", tm->tm_sec); /* - * tzp == NULL indicates that we don't want *any* time zone - * info in the output string. *tzn != NULL indicates that we - * have alpha time zone info available. tm_isdst != -1 - * indicates that we have a valid time zone translation. + * tzp == NULL indicates that we don't want *any* time zone info + * in the output string. *tzn != NULL indicates that we have alpha + * time zone info available. tm_isdst != -1 indicates that we have + * a valid time zone translation. */ if (tzp != NULL && tm->tm_isdst >= 0) { @@ -3608,11 +3599,11 @@ EncodeDateTime(struct pg_tm *tm, fsec_t fsec, int *tzp, char **tzn, int style, c tm->tm_hour, tm->tm_min); /* - * Print fractional seconds if any. The field widths here - * should be at least equal to MAX_TIMESTAMP_PRECISION. + * Print fractional seconds if any. The field widths here should + * be at least equal to MAX_TIMESTAMP_PRECISION. * - * In float mode, don't print fractional seconds before 1 AD, - * since it's unlikely there's any precision left ... + * In float mode, don't print fractional seconds before 1 AD, since + * it's unlikely there's any precision left ... */ #ifdef HAVE_INT64_TIMESTAMP if (fsec != 0) @@ -3656,11 +3647,11 @@ EncodeDateTime(struct pg_tm *tm, fsec_t fsec, int *tzp, char **tzn, int style, c tm->tm_hour, tm->tm_min); /* - * Print fractional seconds if any. The field widths here - * should be at least equal to MAX_TIMESTAMP_PRECISION. + * Print fractional seconds if any. The field widths here should + * be at least equal to MAX_TIMESTAMP_PRECISION. * - * In float mode, don't print fractional seconds before 1 AD, - * since it's unlikely there's any precision left ... + * In float mode, don't print fractional seconds before 1 AD, since + * it's unlikely there's any precision left ... */ #ifdef HAVE_INT64_TIMESTAMP if (fsec != 0) @@ -3703,7 +3694,7 @@ EncodeDateTime(struct pg_tm *tm, fsec_t fsec, int *tzp, char **tzn, int style, c strncpy(str, days[tm->tm_wday], 3); strcpy(str + 3, " "); - + if (DateOrder == DATEORDER_DMY) sprintf(str + 4, "%02d %3s", tm->tm_mday, months[tm->tm_mon - 1]); else @@ -3712,11 +3703,11 @@ EncodeDateTime(struct pg_tm *tm, fsec_t fsec, int *tzp, char **tzn, int style, c sprintf(str + 10, " %02d:%02d", tm->tm_hour, tm->tm_min); /* - * Print fractional seconds if any. The field widths here - * should be at least equal to MAX_TIMESTAMP_PRECISION. + * Print fractional seconds if any. The field widths here should + * be at least equal to MAX_TIMESTAMP_PRECISION. * - * In float mode, don't print fractional seconds before 1 AD, - * since it's unlikely there's any precision left ... + * In float mode, don't print fractional seconds before 1 AD, since + * it's unlikely there's any precision left ... */ #ifdef HAVE_INT64_TIMESTAMP if (fsec != 0) @@ -3735,7 +3726,7 @@ EncodeDateTime(struct pg_tm *tm, fsec_t fsec, int *tzp, char **tzn, int style, c sprintf(str + strlen(str), ":%02d", tm->tm_sec); sprintf(str + strlen(str), " %04d", - (tm->tm_year > 0) ? tm->tm_year : -(tm->tm_year - 1)); + (tm->tm_year > 0) ? tm->tm_year : -(tm->tm_year - 1)); if (tzp != NULL && tm->tm_isdst >= 0) { @@ -3745,10 +3736,9 @@ EncodeDateTime(struct pg_tm *tm, fsec_t fsec, int *tzp, char **tzn, int style, c { /* * We have a time zone, but no string version. Use the - * numeric form, but be sure to include a leading - * space to avoid formatting something which would be - * rejected by the date/time parser later. - thomas - * 2001-10-19 + * numeric form, but be sure to include a leading space to + * avoid formatting something which would be rejected by + * the date/time parser later. - thomas 2001-10-19 */ hour = -(*tzp / SECS_PER_HOUR); min = (abs(*tzp) / MINS_PER_HOUR) % MINS_PER_HOUR; @@ -3774,7 +3764,7 @@ EncodeDateTime(struct pg_tm *tm, fsec_t fsec, int *tzp, char **tzn, int style, c * - thomas 1998-04-30 */ int -EncodeInterval(struct pg_tm *tm, fsec_t fsec, int style, char *str) +EncodeInterval(struct pg_tm * tm, fsec_t fsec, int style, char *str) { int is_before = FALSE; int is_nonzero = FALSE; @@ -3782,9 +3772,8 @@ EncodeInterval(struct pg_tm *tm, fsec_t fsec, int style, char *str) /* * The sign of year and month are guaranteed to match, since they are - * stored internally as "month". But we'll need to check for is_before - * and is_nonzero when determining the signs of hour/minute/seconds - * fields. + * stored internally as "month". But we'll need to check for is_before and + * is_nonzero when determining the signs of hour/minute/seconds fields. */ switch (style) { diff --git a/src/backend/utils/adt/datum.c b/src/backend/utils/adt/datum.c index 03e02278d1..0b229e2059 100644 --- a/src/backend/utils/adt/datum.c +++ b/src/backend/utils/adt/datum.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/datum.c,v 1.30 2004/12/31 22:01:21 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/datum.c,v 1.31 2005/10/15 02:49:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -179,11 +179,10 @@ datumIsEqual(Datum value1, Datum value2, bool typByVal, int typLen) if (typByVal) { /* - * just compare the two datums. NOTE: just comparing "len" bytes - * will not do the work, because we do not know how these bytes - * are aligned inside the "Datum". We assume instead that any - * given datatype is consistent about how it fills extraneous bits - * in the Datum. + * just compare the two datums. NOTE: just comparing "len" bytes will + * not do the work, because we do not know how these bytes are aligned + * inside the "Datum". We assume instead that any given datatype is + * consistent about how it fills extraneous bits in the Datum. */ res = (value1 == value2); } diff --git a/src/backend/utils/adt/dbsize.c b/src/backend/utils/adt/dbsize.c index c8917b145c..4a0ac3dcfb 100644 --- a/src/backend/utils/adt/dbsize.c +++ b/src/backend/utils/adt/dbsize.c @@ -5,7 +5,7 @@ * Copyright (c) 2002-2005, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/dbsize.c,v 1.5 2005/09/29 22:04:36 alvherre Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/dbsize.c,v 1.6 2005/10/15 02:49:28 momjian Exp $ * */ @@ -31,22 +31,22 @@ static int64 db_dir_size(const char *path) { int64 dirsize = 0; - struct dirent *direntry; - DIR *dirdesc; - char filename[MAXPGPATH]; + struct dirent *direntry; + DIR *dirdesc; + char filename[MAXPGPATH]; dirdesc = AllocateDir(path); if (!dirdesc) - return 0; + return 0; while ((direntry = ReadDir(dirdesc, path)) != NULL) { - struct stat fst; + struct stat fst; - if (strcmp(direntry->d_name, ".") == 0 || + if (strcmp(direntry->d_name, ".") == 0 || strcmp(direntry->d_name, "..") == 0) - continue; + continue; snprintf(filename, MAXPGPATH, "%s/%s", path, direntry->d_name); @@ -54,8 +54,8 @@ db_dir_size(const char *path) ereport(ERROR, (errcode_for_file_access(), errmsg("could not stat \"%s\": %m", filename))); - - dirsize += fst.st_size; + + dirsize += fst.st_size; } FreeDir(dirdesc); @@ -69,10 +69,10 @@ static int64 calculate_database_size(Oid dbOid) { int64 totalsize; - DIR *dirdesc; - struct dirent *direntry; - char dirpath[MAXPGPATH]; - char pathname[MAXPGPATH]; + DIR *dirdesc; + struct dirent *direntry; + char dirpath[MAXPGPATH]; + char pathname[MAXPGPATH]; /* Shared storage in pg_global is not counted */ @@ -84,16 +84,16 @@ calculate_database_size(Oid dbOid) snprintf(dirpath, MAXPGPATH, "%s/pg_tblspc", DataDir); dirdesc = AllocateDir(dirpath); if (!dirdesc) - ereport(ERROR, + ereport(ERROR, (errcode_for_file_access(), errmsg("could not open tablespace directory \"%s\": %m", dirpath))); while ((direntry = ReadDir(dirdesc, dirpath)) != NULL) { - if (strcmp(direntry->d_name, ".") == 0 || + if (strcmp(direntry->d_name, ".") == 0 || strcmp(direntry->d_name, "..") == 0) - continue; + continue; snprintf(pathname, MAXPGPATH, "%s/pg_tblspc/%s/%u", DataDir, direntry->d_name, dbOid); @@ -104,7 +104,7 @@ calculate_database_size(Oid dbOid) /* Complain if we found no trace of the DB at all */ if (!totalsize) - ereport(ERROR, + ereport(ERROR, (ERRCODE_UNDEFINED_DATABASE, errmsg("database with OID %u does not exist", dbOid))); @@ -114,7 +114,7 @@ calculate_database_size(Oid dbOid) Datum pg_database_size_oid(PG_FUNCTION_ARGS) { - Oid dbOid = PG_GETARG_OID(0); + Oid dbOid = PG_GETARG_OID(0); PG_RETURN_INT64(calculate_database_size(dbOid)); } @@ -122,8 +122,8 @@ pg_database_size_oid(PG_FUNCTION_ARGS) Datum pg_database_size_name(PG_FUNCTION_ARGS) { - Name dbName = PG_GETARG_NAME(0); - Oid dbOid = get_database_oid(NameStr(*dbName)); + Name dbName = PG_GETARG_NAME(0); + Oid dbOid = get_database_oid(NameStr(*dbName)); if (!OidIsValid(dbOid)) ereport(ERROR, @@ -141,16 +141,16 @@ pg_database_size_name(PG_FUNCTION_ARGS) static int64 calculate_tablespace_size(Oid tblspcOid) { - char tblspcPath[MAXPGPATH]; - char pathname[MAXPGPATH]; - int64 totalsize=0; - DIR *dirdesc; - struct dirent *direntry; + char tblspcPath[MAXPGPATH]; + char pathname[MAXPGPATH]; + int64 totalsize = 0; + DIR *dirdesc; + struct dirent *direntry; if (tblspcOid == DEFAULTTABLESPACE_OID) - snprintf(tblspcPath, MAXPGPATH, "%s/base", DataDir); + snprintf(tblspcPath, MAXPGPATH, "%s/base", DataDir); else if (tblspcOid == GLOBALTABLESPACE_OID) - snprintf(tblspcPath, MAXPGPATH, "%s/global", DataDir); + snprintf(tblspcPath, MAXPGPATH, "%s/global", DataDir); else snprintf(tblspcPath, MAXPGPATH, "%s/pg_tblspc/%u", DataDir, tblspcOid); @@ -164,11 +164,11 @@ calculate_tablespace_size(Oid tblspcOid) while ((direntry = ReadDir(dirdesc, tblspcPath)) != NULL) { - struct stat fst; + struct stat fst; - if (strcmp(direntry->d_name, ".") == 0 || + if (strcmp(direntry->d_name, ".") == 0 || strcmp(direntry->d_name, "..") == 0) - continue; + continue; snprintf(pathname, MAXPGPATH, "%s/%s", tblspcPath, direntry->d_name); @@ -178,29 +178,29 @@ calculate_tablespace_size(Oid tblspcOid) errmsg("could not stat \"%s\": %m", pathname))); if (fst.st_mode & S_IFDIR) - totalsize += db_dir_size(pathname); - - totalsize += fst.st_size; + totalsize += db_dir_size(pathname); + + totalsize += fst.st_size; } FreeDir(dirdesc); - + return totalsize; } Datum pg_tablespace_size_oid(PG_FUNCTION_ARGS) { - Oid tblspcOid = PG_GETARG_OID(0); - + Oid tblspcOid = PG_GETARG_OID(0); + PG_RETURN_INT64(calculate_tablespace_size(tblspcOid)); } Datum pg_tablespace_size_name(PG_FUNCTION_ARGS) { - Name tblspcName = PG_GETARG_NAME(0); - Oid tblspcOid = get_tablespace_oid(NameStr(*tblspcName)); + Name tblspcName = PG_GETARG_NAME(0); + Oid tblspcOid = get_tablespace_oid(NameStr(*tblspcName)); if (!OidIsValid(tblspcOid)) ereport(ERROR, @@ -226,22 +226,22 @@ calculate_relation_size(RelFileNode *rfn) Assert(OidIsValid(rfn->spcNode)); if (rfn->spcNode == DEFAULTTABLESPACE_OID) - snprintf(dirpath, MAXPGPATH, "%s/base/%u", DataDir, rfn->dbNode); + snprintf(dirpath, MAXPGPATH, "%s/base/%u", DataDir, rfn->dbNode); else if (rfn->spcNode == GLOBALTABLESPACE_OID) - snprintf(dirpath, MAXPGPATH, "%s/global", DataDir); + snprintf(dirpath, MAXPGPATH, "%s/global", DataDir); else - snprintf(dirpath, MAXPGPATH, "%s/pg_tblspc/%u/%u", + snprintf(dirpath, MAXPGPATH, "%s/pg_tblspc/%u/%u", DataDir, rfn->spcNode, rfn->dbNode); - for (segcount = 0; ; segcount++) + for (segcount = 0;; segcount++) { struct stat fst; if (segcount == 0) - snprintf(pathname, MAXPGPATH, "%s/%u", + snprintf(pathname, MAXPGPATH, "%s/%u", dirpath, rfn->relNode); else - snprintf(pathname, MAXPGPATH, "%s/%u.%u", + snprintf(pathname, MAXPGPATH, "%s/%u.%u", dirpath, rfn->relNode, segcount); if (stat(pathname, &fst) < 0) @@ -262,7 +262,7 @@ calculate_relation_size(RelFileNode *rfn) Datum pg_relation_size_oid(PG_FUNCTION_ARGS) { - Oid relOid=PG_GETARG_OID(0); + Oid relOid = PG_GETARG_OID(0); Relation rel; int64 size; @@ -282,12 +282,12 @@ pg_relation_size_name(PG_FUNCTION_ARGS) RangeVar *relrv; Relation rel; int64 size; - - relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname)); + + relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname)); rel = relation_openrv(relrv, AccessShareLock); - + size = calculate_relation_size(&(rel->rd_node)); - + relation_close(rel, AccessShareLock); PG_RETURN_INT64(size); @@ -295,9 +295,9 @@ pg_relation_size_name(PG_FUNCTION_ARGS) /* - * Compute the on-disk size of files for the relation according to the - * stat function, optionally including heap data, index data, and/or - * toast data. + * Compute the on-disk size of files for the relation according to the + * stat function, optionally including heap data, index data, and/or + * toast data. */ static int64 calculate_total_relation_size(Oid Relid) @@ -317,7 +317,7 @@ calculate_total_relation_size(Oid Relid) if (heapRel->rd_rel->relhasindex) { /* recursively include any dependent indexes */ - List *index_oids = RelationGetIndexList(heapRel); + List *index_oids = RelationGetIndexList(heapRel); foreach(cell, index_oids) { @@ -344,13 +344,13 @@ calculate_total_relation_size(Oid Relid) } /* - * Compute on-disk size of files for 'relation' including - * heap data, index data, and toasted data. + * Compute on-disk size of files for 'relation' including + * heap data, index data, and toasted data. */ Datum pg_total_relation_size_oid(PG_FUNCTION_ARGS) { - Oid relid = PG_GETARG_OID(0); + Oid relid = PG_GETARG_OID(0); PG_RETURN_INT64(calculate_total_relation_size(relid)); } @@ -361,10 +361,10 @@ pg_total_relation_size_name(PG_FUNCTION_ARGS) text *relname = PG_GETARG_TEXT_P(0); RangeVar *relrv; Oid relid; - - relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname)); + + relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname)); relid = RangeVarGetRelid(relrv, false); - + PG_RETURN_INT64(calculate_total_relation_size(relid)); } @@ -374,35 +374,35 @@ pg_total_relation_size_name(PG_FUNCTION_ARGS) Datum pg_size_pretty(PG_FUNCTION_ARGS) { - int64 size = PG_GETARG_INT64(0); - char *result = palloc(50 + VARHDRSZ); - int64 limit = 10 * 1024; - int64 mult = 1; + int64 size = PG_GETARG_INT64(0); + char *result = palloc(50 + VARHDRSZ); + int64 limit = 10 * 1024; + int64 mult = 1; if (size < limit * mult) - snprintf(VARDATA(result), 50, INT64_FORMAT " bytes", size); + snprintf(VARDATA(result), 50, INT64_FORMAT " bytes", size); else { mult *= 1024; if (size < limit * mult) - snprintf(VARDATA(result), 50, INT64_FORMAT " kB", - (size + mult / 2) / mult); + snprintf(VARDATA(result), 50, INT64_FORMAT " kB", + (size + mult / 2) / mult); else { mult *= 1024; if (size < limit * mult) - snprintf(VARDATA(result), 50, INT64_FORMAT " MB", + snprintf(VARDATA(result), 50, INT64_FORMAT " MB", (size + mult / 2) / mult); else { mult *= 1024; if (size < limit * mult) - snprintf(VARDATA(result), 50, INT64_FORMAT " GB", + snprintf(VARDATA(result), 50, INT64_FORMAT " GB", (size + mult / 2) / mult); else { - mult *= 1024; - snprintf(VARDATA(result), 50, INT64_FORMAT " TB", + mult *= 1024; + snprintf(VARDATA(result), 50, INT64_FORMAT " TB", (size + mult / 2) / mult); } } diff --git a/src/backend/utils/adt/encode.c b/src/backend/utils/adt/encode.c index 659263230f..1f23a8419e 100644 --- a/src/backend/utils/adt/encode.c +++ b/src/backend/utils/adt/encode.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/encode.c,v 1.15 2005/09/24 17:53:15 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/encode.c,v 1.16 2005/10/15 02:49:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -175,7 +175,7 @@ hex_decode(const char *src, unsigned len, char *dst) if (s >= srcend) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("invalid hexadecimal data: odd number of digits"))); + errmsg("invalid hexadecimal data: odd number of digits"))); v2 = get_hex(*s++); *p++ = v1 | v2; @@ -428,8 +428,8 @@ esc_decode(const char *src, unsigned srclen, char *dst) else { /* - * One backslash, not followed by ### valid octal. Should - * never get here, since esc_dec_len does same check. + * One backslash, not followed by ### valid octal. Should never + * get here, since esc_dec_len does same check. */ ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), diff --git a/src/backend/utils/adt/float.c b/src/backend/utils/adt/float.c index c943ee2c71..fb37e36624 100644 --- a/src/backend/utils/adt/float.c +++ b/src/backend/utils/adt/float.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.114 2005/04/06 23:56:07 neilc Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.115 2005/10/15 02:49:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -235,11 +235,11 @@ CheckFloat8Val(double val) if (fabs(val) > FLOAT8_MAX) ereport(ERROR, (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), - errmsg("type \"double precision\" value out of range: overflow"))); + errmsg("type \"double precision\" value out of range: overflow"))); if (val != 0.0 && fabs(val) < FLOAT8_MIN) ereport(ERROR, (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), - errmsg("type \"double precision\" value out of range: underflow"))); + errmsg("type \"double precision\" value out of range: underflow"))); } /* @@ -258,15 +258,15 @@ float4in(PG_FUNCTION_ARGS) char *endptr; /* - * endptr points to the first character _after_ the sequence we - * recognized as a valid floating point number. orig_num points to the - * original input string. + * endptr points to the first character _after_ the sequence we recognized + * as a valid floating point number. orig_num points to the original input + * string. */ orig_num = num; /* - * Check for an empty-string input to begin with, to avoid the - * vagaries of strtod() on different platforms. + * Check for an empty-string input to begin with, to avoid the vagaries of + * strtod() on different platforms. */ if (*num == '\0') ereport(ERROR, @@ -285,10 +285,9 @@ float4in(PG_FUNCTION_ARGS) if (endptr == num || errno != 0) { /* - * C99 requires that strtod() accept NaN and [-]Infinity, but not - * all platforms support that yet (and some accept them but set - * ERANGE anyway...) Therefore, we check for these inputs - * ourselves. + * C99 requires that strtod() accept NaN and [-]Infinity, but not all + * platforms support that yet (and some accept them but set ERANGE + * anyway...) Therefore, we check for these inputs ourselves. */ if (pg_strncasecmp(num, "NaN", 3) == 0) { @@ -320,9 +319,9 @@ float4in(PG_FUNCTION_ARGS) else { /* - * Many versions of Solaris have a bug wherein strtod sets endptr - * to point one byte beyond the end of the string when given "inf" - * or "infinity". + * Many versions of Solaris have a bug wherein strtod sets endptr to + * point one byte beyond the end of the string when given "inf" or + * "infinity". */ if (endptr != num && endptr[-1] == '\0') endptr--; @@ -341,8 +340,8 @@ float4in(PG_FUNCTION_ARGS) orig_num))); /* - * if we get here, we have a legal double, still need to check to see - * if it's a legal float4 + * if we get here, we have a legal double, still need to check to see if + * it's a legal float4 */ if (!isinf(val)) CheckFloat4Val(val); @@ -426,21 +425,21 @@ float8in(PG_FUNCTION_ARGS) char *endptr; /* - * endptr points to the first character _after_ the sequence we - * recognized as a valid floating point number. orig_num points to the - * original input string. + * endptr points to the first character _after_ the sequence we recognized + * as a valid floating point number. orig_num points to the original input + * string. */ orig_num = num; /* - * Check for an empty-string input to begin with, to avoid the - * vagaries of strtod() on different platforms. + * Check for an empty-string input to begin with, to avoid the vagaries of + * strtod() on different platforms. */ if (*num == '\0') ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type double precision: \"%s\"", - orig_num))); + errmsg("invalid input syntax for type double precision: \"%s\"", + orig_num))); /* skip leading whitespace */ while (*num != '\0' && isspace((unsigned char) *num)) @@ -453,10 +452,9 @@ float8in(PG_FUNCTION_ARGS) if (endptr == num || errno != 0) { /* - * C99 requires that strtod() accept NaN and [-]Infinity, but not - * all platforms support that yet (and some accept them but set - * ERANGE anyway...) Therefore, we check for these inputs - * ourselves. + * C99 requires that strtod() accept NaN and [-]Infinity, but not all + * platforms support that yet (and some accept them but set ERANGE + * anyway...) Therefore, we check for these inputs ourselves. */ if (pg_strncasecmp(num, "NaN", 3) == 0) { @@ -476,21 +474,21 @@ float8in(PG_FUNCTION_ARGS) else if (errno == ERANGE) ereport(ERROR, (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), - errmsg("\"%s\" is out of range for type double precision", - orig_num))); + errmsg("\"%s\" is out of range for type double precision", + orig_num))); else ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type double precision: \"%s\"", - orig_num))); + errmsg("invalid input syntax for type double precision: \"%s\"", + orig_num))); } #ifdef HAVE_BUGGY_SOLARIS_STRTOD else { /* - * Many versions of Solaris have a bug wherein strtod sets endptr - * to point one byte beyond the end of the string when given "inf" - * or "infinity". + * Many versions of Solaris have a bug wherein strtod sets endptr to + * point one byte beyond the end of the string when given "inf" or + * "infinity". */ if (endptr != num && endptr[-1] == '\0') endptr--; @@ -505,8 +503,8 @@ float8in(PG_FUNCTION_ARGS) if (*endptr != '\0') ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type double precision: \"%s\"", - orig_num))); + errmsg("invalid input syntax for type double precision: \"%s\"", + orig_num))); if (!isinf(val)) CheckFloat8Val(val); @@ -860,9 +858,9 @@ static int float4_cmp_internal(float4 a, float4 b) { /* - * We consider all NANs to be equal and larger than any non-NAN. This - * is somewhat arbitrary; the important thing is to have a consistent - * sort order. + * We consider all NANs to be equal and larger than any non-NAN. This is + * somewhat arbitrary; the important thing is to have a consistent sort + * order. */ if (isnan(a)) { @@ -956,9 +954,9 @@ static int float8_cmp_internal(float8 a, float8 b) { /* - * We consider all NANs to be equal and larger than any non-NAN. This - * is somewhat arbitrary; the important thing is to have a consistent - * sort order. + * We consider all NANs to be equal and larger than any non-NAN. This is + * somewhat arbitrary; the important thing is to have a consistent sort + * order. */ if (isnan(a)) { @@ -1465,8 +1463,8 @@ dpow(PG_FUNCTION_ARGS) float8 result; /* - * The SQL spec requires that we emit a particular SQLSTATE error code - * for certain error conditions. + * The SQL spec requires that we emit a particular SQLSTATE error code for + * certain error conditions. */ if ((arg1 == 0 && arg2 < 0) || (arg1 < 0 && floor(arg2) != arg2)) @@ -1475,8 +1473,8 @@ dpow(PG_FUNCTION_ARGS) errmsg("invalid argument for power function"))); /* - * We must check both for errno getting set and for a NaN result, in - * order to deal with the vagaries of different platforms... + * We must check both for errno getting set and for a NaN result, in order + * to deal with the vagaries of different platforms... */ errno = 0; result = pow(arg1, arg2); @@ -1504,9 +1502,9 @@ dexp(PG_FUNCTION_ARGS) float8 result; /* - * We must check both for errno getting set and for a NaN result, in - * order to deal with the vagaries of different platforms. Also, a - * zero result implies unreported underflow. + * We must check both for errno getting set and for a NaN result, in order + * to deal with the vagaries of different platforms. Also, a zero result + * implies unreported underflow. */ errno = 0; result = exp(arg1); @@ -1534,8 +1532,8 @@ dlog1(PG_FUNCTION_ARGS) float8 result; /* - * Emit particular SQLSTATE error codes for ln(). This is required by - * the SQL standard. + * Emit particular SQLSTATE error codes for ln(). This is required by the + * SQL standard. */ if (arg1 == 0.0) ereport(ERROR, @@ -1563,9 +1561,9 @@ dlog10(PG_FUNCTION_ARGS) float8 result; /* - * Emit particular SQLSTATE error codes for log(). The SQL spec - * doesn't define log(), but it does define ln(), so it makes sense to - * emit the same error code for an analogous error condition. + * Emit particular SQLSTATE error codes for log(). The SQL spec doesn't + * define log(), but it does define ln(), so it makes sense to emit the + * same error code for an analogous error condition. */ if (arg1 == 0.0) ereport(ERROR, @@ -1914,9 +1912,8 @@ float8_accum(PG_FUNCTION_ARGS) /* * If we're invoked by nodeAgg, we can cheat and modify our first - * parameter in-place to reduce palloc overhead. Otherwise we - * construct a new array with the updated transition data and - * return it. + * parameter in-place to reduce palloc overhead. Otherwise we construct a + * new array with the updated transition data and return it. */ if (fcinfo->context && IsA(fcinfo->context, AggState)) { @@ -1937,7 +1934,7 @@ float8_accum(PG_FUNCTION_ARGS) result = construct_array(transdatums, 3, FLOAT8OID, - sizeof(float8), false /* float8 byval */ , 'd'); + sizeof(float8), false /* float8 byval */ , 'd'); PG_RETURN_ARRAYTYPE_P(result); } @@ -1968,9 +1965,8 @@ float4_accum(PG_FUNCTION_ARGS) /* * If we're invoked by nodeAgg, we can cheat and modify our first - * parameter in-place to reduce palloc overhead. Otherwise we - * construct a new array with the updated transition data and - * return it. + * parameter in-place to reduce palloc overhead. Otherwise we construct a + * new array with the updated transition data and return it. */ if (fcinfo->context && IsA(fcinfo->context, AggState)) { @@ -1991,7 +1987,7 @@ float4_accum(PG_FUNCTION_ARGS) result = construct_array(transdatums, 3, FLOAT8OID, - sizeof(float8), false /* float8 byval */ , 'd'); + sizeof(float8), false /* float8 byval */ , 'd'); PG_RETURN_ARRAYTYPE_P(result); } diff --git a/src/backend/utils/adt/format_type.c b/src/backend/utils/adt/format_type.c index 0280196af9..adbfb58858 100644 --- a/src/backend/utils/adt/format_type.c +++ b/src/backend/utils/adt/format_type.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/format_type.c,v 1.40 2005/03/29 00:17:08 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/format_type.c,v 1.41 2005/10/15 02:49:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -138,12 +138,12 @@ format_type_internal(Oid type_oid, int32 typemod, typeform = (Form_pg_type) GETSTRUCT(tuple); /* - * Check if it's an array (and not a domain --- we don't want to show - * the substructure of a domain type). Fixed-length array types such - * as "name" shouldn't get deconstructed either. As of Postgres 8.1, - * rather than checking typlen we check the toast property, and don't - * deconstruct "plain storage" array types --- this is because we don't - * want to show oidvector as oid[]. + * Check if it's an array (and not a domain --- we don't want to show the + * substructure of a domain type). Fixed-length array types such as + * "name" shouldn't get deconstructed either. As of Postgres 8.1, rather + * than checking typlen we check the toast property, and don't deconstruct + * "plain storage" array types --- this is because we don't want to show + * oidvector as oid[]. */ array_base_type = typeform->typelem; @@ -171,14 +171,14 @@ format_type_internal(Oid type_oid, int32 typemod, is_array = false; /* - * See if we want to special-case the output for certain built-in - * types. Note that these special cases should all correspond to - * special productions in gram.y, to ensure that the type name will be - * taken as a system type, not a user type of the same name. + * See if we want to special-case the output for certain built-in types. + * Note that these special cases should all correspond to special + * productions in gram.y, to ensure that the type name will be taken as a + * system type, not a user type of the same name. * * If we do not provide a special-case output here, the type name will be - * handled the same way as a user type name --- in particular, it will - * be double-quoted if it matches any lexer keyword. This behavior is + * handled the same way as a user type name --- in particular, it will be + * double-quoted if it matches any lexer keyword. This behavior is * essential for some cases, such as types "bit" and "char". */ buf = NULL; /* flag for no special case */ @@ -193,8 +193,8 @@ format_type_internal(Oid type_oid, int32 typemod, { /* * bit with typmod -1 is not the same as BIT, which means - * BIT(1) per SQL spec. Report it as the quoted typename - * so that parser will not assign a bogus typmod. + * BIT(1) per SQL spec. Report it as the quoted typename so + * that parser will not assign a bogus typmod. */ } else @@ -212,9 +212,9 @@ format_type_internal(Oid type_oid, int32 typemod, else if (typemod_given) { /* - * bpchar with typmod -1 is not the same as CHARACTER, - * which means CHARACTER(1) per SQL spec. Report it as - * bpchar so that parser will not assign a bogus typmod. + * bpchar with typmod -1 is not the same as CHARACTER, which + * means CHARACTER(1) per SQL spec. Report it as bpchar so + * that parser will not assign a bogus typmod. */ } else @@ -382,9 +382,9 @@ format_type_internal(Oid type_oid, int32 typemod, { /* * Default handling: report the name as it appears in the catalog. - * Here, we must qualify the name if it is not visible in the - * search path, and we must double-quote it if it's not a standard - * identifier or if it matches any keyword. + * Here, we must qualify the name if it is not visible in the search + * path, and we must double-quote it if it's not a standard identifier + * or if it matches any keyword. */ char *nspname; char *typname; diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c index 1e3553816d..90e940e7b9 100644 --- a/src/backend/utils/adt/formatting.c +++ b/src/backend/utils/adt/formatting.c @@ -1,7 +1,7 @@ /* ----------------------------------------------------------------------- * formatting.c * - * $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.99 2005/08/18 13:43:08 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.100 2005/10/15 02:49:28 momjian Exp $ * * * Portions Copyright (c) 1999-2005, PostgreSQL Global Development Group @@ -135,9 +135,9 @@ typedef struct { const char *name; /* keyword */ int len; /* keyword length */ - int (*action) (int arg, char *inout, /* action for keyword */ - int suf, bool is_to_char, bool is_interval, - FormatNode *node, void *data); + int (*action) (int arg, char *inout, /* action for keyword */ + int suf, bool is_to_char, bool is_interval, + FormatNode *node, void *data); int id; /* keyword id */ bool isitdigit; /* is expected output/input digit */ } KeyWord; @@ -252,7 +252,7 @@ static char *numth[] = {"st", "nd", "rd", "th", NULL}; * Flags for DCH version * ---------- */ -static bool DCH_global_fx = false; +static bool DCH_global_fx = false; /* ---------- @@ -379,7 +379,7 @@ typedef struct q, j, us, - yysz; /* is it YY or YYYY ? */ + yysz; /* is it YY or YYYY ? */ } TmFromChar; #define ZERO_tmfc(_X) memset(_X, 0, sizeof(TmFromChar)) @@ -442,17 +442,17 @@ do { \ errmsg("invalid format specification for an interval value"), \ errhint("Intervals are not tied to specific calendar dates."))); \ } while(0) - + /***************************************************************************** * KeyWords definition & action *****************************************************************************/ -static int dch_global(int arg, char *inout, int suf, bool is_to_char, - bool is_interval, FormatNode *node, void *data); -static int dch_time(int arg, char *inout, int suf, bool is_to_char, - bool is_interval, FormatNode *node, void *data); -static int dch_date(int arg, char *inout, int suf, bool is_to_char, - bool is_interval, FormatNode *node, void *data); +static int dch_global(int arg, char *inout, int suf, bool is_to_char, + bool is_interval, FormatNode *node, void *data); +static int dch_time(int arg, char *inout, int suf, bool is_to_char, + bool is_interval, FormatNode *node, void *data); +static int dch_date(int arg, char *inout, int suf, bool is_to_char, + bool is_interval, FormatNode *node, void *data); /* ---------- * Suffixes: @@ -803,7 +803,7 @@ static const KeyWord NUM_keywords[] = { * KeyWords index for DATE-TIME version * ---------- */ -static const int DCH_index[KeyWord_INDEX_SIZE] = { +static const int DCH_index[KeyWord_INDEX_SIZE] = { /* 0 1 2 3 4 5 6 7 8 9 */ @@ -827,7 +827,7 @@ static const int DCH_index[KeyWord_INDEX_SIZE] = { * KeyWords index for NUMBER version * ---------- */ -static const int NUM_index[KeyWord_INDEX_SIZE] = { +static const int NUM_index[KeyWord_INDEX_SIZE] = { /* 0 1 2 3 4 5 6 7 8 9 */ @@ -871,8 +871,7 @@ typedef struct NUMProc *number_p, /* pointer to current number position */ *inout, /* in / out buffer */ *inout_p, /* pointer to current inout position */ - *last_relevant, /* last relevant number after decimal - * point */ + *last_relevant, /* last relevant number after decimal point */ *L_negative_sign, /* Locale */ *L_positive_sign, @@ -887,13 +886,13 @@ typedef struct NUMProc * ---------- */ static const KeyWord *index_seq_search(char *str, const KeyWord *kw, - const int *index); + const int *index); static KeySuffix *suff_search(char *str, KeySuffix *suf, int type); static void NUMDesc_prepare(NUMDesc *num, FormatNode *n); static void parse_format(FormatNode *node, char *str, const KeyWord *kw, KeySuffix *suf, const int *index, int ver, NUMDesc *Num); static char *DCH_processor(FormatNode *node, char *inout, bool is_to_char, - bool is_interval, void *data); + bool is_interval, void *data); #ifdef DEBUG_TO_FROM_CHAR static void dump_index(const KeyWord *k, const int *index); @@ -909,7 +908,7 @@ static char *str_tolower(char *buff); /* static int is_acdc(char *str, int *len); */ static int seq_search(char *name, char **array, int type, int max, int *len); static void do_to_timestamp(text *date_txt, text *fmt, - struct pg_tm *tm, fsec_t *fsec); + struct pg_tm * tm, fsec_t *fsec); static char *fill_str(char *str, int c, int max); static FormatNode *NUM_cache(int len, NUMDesc *Num, char *pars_str, bool *shouldFree); static char *int_to_roman(int number); @@ -1047,7 +1046,7 @@ NUMDesc_prepare(NUMDesc *num, FormatNode *n) NUM_cache_remove(last_NUMCacheEntry); ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("cannot use \"V\" and decimal point together"))); + errmsg("cannot use \"V\" and decimal point together"))); } num->flag |= NUM_F_DECIMAL; break; @@ -1152,7 +1151,7 @@ NUMDesc_prepare(NUMDesc *num, FormatNode *n) NUM_cache_remove(last_NUMCacheEntry); ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("cannot use \"V\" and decimal point together"))); + errmsg("cannot use \"V\" and decimal point together"))); } num->flag |= NUM_F_MULTI; break; @@ -1324,11 +1323,11 @@ DCH_processor(FormatNode *node, char *inout, bool is_to_char, if (!is_to_char && *s == '\0') /* - * The input string is shorter than format picture, so it's - * good time to break this loop... + * The input string is shorter than format picture, so it's good + * time to break this loop... * - * Note: this isn't relevant for TO_CHAR mode, beacuse it use - * 'inout' allocated by format picture length. + * Note: this isn't relevant for TO_CHAR mode, beacuse it use 'inout' + * allocated by format picture length. */ break; @@ -1393,7 +1392,7 @@ dump_node(FormatNode *node, int max) { if (n->type == NODE_TYPE_ACTION) elog(DEBUG_elog_output, "%d:\t NODE_TYPE_ACTION '%s'\t(%s,%s)", - a, n->key->name, DUMP_THth(n->suffix), DUMP_FM(n->suffix)); + a, n->key->name, DUMP_THth(n->suffix), DUMP_FM(n->suffix)); else if (n->type == NODE_TYPE_CHAR) elog(DEBUG_elog_output, "%d:\t NODE_TYPE_CHAR '%c'", a, n->character); else if (n->type == NODE_TYPE_END) @@ -1578,8 +1577,8 @@ seq_search(char *name, char **array, int type, int max, int *len) #ifdef DEBUG_TO_FROM_CHAR /* - * elog(DEBUG_elog_output, "N: %c, P: %c, A: %s (%s)", *n, *p, - * *a, name); + * elog(DEBUG_elog_output, "N: %c, P: %c, A: %s (%s)", *n, *p, *a, + * name); */ #endif if (*n != *p) @@ -1637,7 +1636,7 @@ dump_index(const KeyWord *k, const int *index) */ static int dch_global(int arg, char *inout, int suf, bool is_to_char, bool is_interval, - FormatNode *node, void *data) + FormatNode *node, void *data) { if (arg == DCH_FX) DCH_global_fx = true; @@ -1704,7 +1703,7 @@ strdigits_len(char *str) */ static int dch_time(int arg, char *inout, int suf, bool is_to_char, bool is_interval, - FormatNode *node, void *data) + FormatNode *node, void *data) { char *p_inout = inout; struct pg_tm *tm = NULL; @@ -1727,7 +1726,7 @@ dch_time(int arg, char *inout, int suf, bool is_to_char, bool is_interval, if (is_to_char) { strcpy(inout, ((tm->tm_hour > 11 - && tm->tm_hour < HOURS_PER_DAY) ? P_M_STR : A_M_STR)); + && tm->tm_hour < HOURS_PER_DAY) ? P_M_STR : A_M_STR)); return strlen(p_inout); } else @@ -1747,7 +1746,7 @@ dch_time(int arg, char *inout, int suf, bool is_to_char, bool is_interval, if (is_to_char) { strcpy(inout, ((tm->tm_hour > 11 - && tm->tm_hour < HOURS_PER_DAY) ? PM_STR : AM_STR)); + && tm->tm_hour < HOURS_PER_DAY) ? PM_STR : AM_STR)); return strlen(p_inout); } else @@ -1767,7 +1766,7 @@ dch_time(int arg, char *inout, int suf, bool is_to_char, bool is_interval, if (is_to_char) { strcpy(inout, ((tm->tm_hour > 11 - && tm->tm_hour < HOURS_PER_DAY) ? p_m_STR : a_m_STR)); + && tm->tm_hour < HOURS_PER_DAY) ? p_m_STR : a_m_STR)); return strlen(p_inout); } else @@ -1787,7 +1786,7 @@ dch_time(int arg, char *inout, int suf, bool is_to_char, bool is_interval, if (is_to_char) { strcpy(inout, ((tm->tm_hour > 11 - && tm->tm_hour < HOURS_PER_DAY) ? pm_STR : am_STR)); + && tm->tm_hour < HOURS_PER_DAY) ? pm_STR : am_STR)); return strlen(p_inout); } else @@ -1925,15 +1924,13 @@ dch_time(int arg, char *inout, int suf, bool is_to_char, bool is_interval, } /* - * 25 is 0.25 and 250 is 0.25 too; 025 is 0.025 and not - * 0.25 + * 25 is 0.25 and 250 is 0.25 too; 025 is 0.025 and not 0.25 */ tmfc->ms *= x == 1 ? 100 : x == 2 ? 10 : 1; /* - * elog(DEBUG3, "X: %d, MS: %d, LEN: %d", x, tmfc->ms, - * len); + * elog(DEBUG3, "X: %d, MS: %d, LEN: %d", x, tmfc->ms, len); */ return len + SKIP_THth(suf); } @@ -1974,8 +1971,7 @@ dch_time(int arg, char *inout, int suf, bool is_to_char, bool is_interval, x == 5 ? 10 : 1; /* - * elog(DEBUG3, "X: %d, US: %d, LEN: %d", x, tmfc->us, - * len); + * elog(DEBUG3, "X: %d, US: %d, LEN: %d", x, tmfc->us, len); */ return len + SKIP_THth(suf); } @@ -2049,7 +2045,7 @@ do { \ */ static int dch_date(int arg, char *inout, int suf, bool is_to_char, bool is_interval, - FormatNode *node, void *data) + FormatNode *node, void *data) { char buff[DCH_CACHE_SIZE], workbuff[32], @@ -2069,8 +2065,8 @@ dch_date(int arg, char *inout, int suf, bool is_to_char, bool is_interval, tmfc = (TmFromChar *) data; /* - * In the FROM-char is not difference between "January" or "JANUARY" - * or "january", all is before search convert to "first-upper". This + * In the FROM-char is not difference between "January" or "JANUARY" or + * "january", all is before search convert to "first-upper". This * convention is used for MONTH, MON, DAY, DY */ if (!is_to_char) @@ -2193,7 +2189,7 @@ dch_date(int arg, char *inout, int suf, bool is_to_char, bool is_interval, return strlen(p_inout); case DCH_MON: - INVALID_FOR_INTERVAL; + INVALID_FOR_INTERVAL; if (!tm->tm_mon) return -1; strcpy(inout, months[tm->tm_mon - 1]); @@ -2201,14 +2197,14 @@ dch_date(int arg, char *inout, int suf, bool is_to_char, bool is_interval, return strlen(p_inout); case DCH_Mon: - INVALID_FOR_INTERVAL; + INVALID_FOR_INTERVAL; if (!tm->tm_mon) return -1; strcpy(inout, months[tm->tm_mon - 1]); return strlen(p_inout); case DCH_mon: - INVALID_FOR_INTERVAL; + INVALID_FOR_INTERVAL; if (!tm->tm_mon) return -1; strcpy(inout, months[tm->tm_mon - 1]); @@ -2238,38 +2234,38 @@ dch_date(int arg, char *inout, int suf, bool is_to_char, bool is_interval, } break; case DCH_DAY: - INVALID_FOR_INTERVAL; + INVALID_FOR_INTERVAL; strcpy(workbuff, days[tm->tm_wday]); sprintf(inout, "%*s", S_FM(suf) ? 0 : -9, str_toupper(workbuff)); return strlen(p_inout); case DCH_Day: - INVALID_FOR_INTERVAL; + INVALID_FOR_INTERVAL; sprintf(inout, "%*s", S_FM(suf) ? 0 : -9, days[tm->tm_wday]); return strlen(p_inout); case DCH_day: - INVALID_FOR_INTERVAL; + INVALID_FOR_INTERVAL; sprintf(inout, "%*s", S_FM(suf) ? 0 : -9, days[tm->tm_wday]); *inout = pg_tolower((unsigned char) *inout); return strlen(p_inout); case DCH_DY: - INVALID_FOR_INTERVAL; + INVALID_FOR_INTERVAL; strcpy(inout, days[tm->tm_wday]); str_toupper(inout); - return 3; /* truncate */ + return 3; /* truncate */ case DCH_Dy: - INVALID_FOR_INTERVAL; + INVALID_FOR_INTERVAL; strcpy(inout, days[tm->tm_wday]); - return 3; /* truncate */ + return 3; /* truncate */ case DCH_dy: - INVALID_FOR_INTERVAL; + INVALID_FOR_INTERVAL; strcpy(inout, days[tm->tm_wday]); *inout = pg_tolower((unsigned char) *inout); - return 3; /* truncate */ + return 3; /* truncate */ case DCH_DDD: if (is_to_char) @@ -2316,7 +2312,7 @@ dch_date(int arg, char *inout, int suf, bool is_to_char, bool is_interval, } break; case DCH_D: - INVALID_FOR_INTERVAL; + INVALID_FOR_INTERVAL; if (is_to_char) { sprintf(inout, "%d", tm->tm_wday + 1); @@ -2357,7 +2353,7 @@ dch_date(int arg, char *inout, int suf, bool is_to_char, bool is_interval, if (is_to_char) { sprintf(inout, "%0*d", S_FM(suf) ? 0 : 2, - date2isoweek(tm->tm_year, tm->tm_mon, tm->tm_mday)); + date2isoweek(tm->tm_year, tm->tm_mon, tm->tm_mday)); if (S_THth(suf)) str_numth(p_inout, inout, S_TH_TYPE(suf)); return strlen(p_inout); @@ -2447,17 +2443,17 @@ dch_date(int arg, char *inout, int suf, bool is_to_char, bool is_interval, arg == DCH_YYYY ? ADJUST_YEAR(tm->tm_year, is_interval) : ADJUST_YEAR(date2isoyear( - tm->tm_year, - tm->tm_mon, - tm->tm_mday), is_interval)); + tm->tm_year, + tm->tm_mon, + tm->tm_mday), is_interval)); else sprintf(inout, "%d", arg == DCH_YYYY ? ADJUST_YEAR(tm->tm_year, is_interval) : ADJUST_YEAR(date2isoyear( - tm->tm_year, - tm->tm_mon, - tm->tm_mday), is_interval)); + tm->tm_year, + tm->tm_mon, + tm->tm_mday), is_interval)); if (S_THth(suf)) str_numth(p_inout, inout, S_TH_TYPE(suf)); return strlen(p_inout); @@ -2486,8 +2482,8 @@ dch_date(int arg, char *inout, int suf, bool is_to_char, bool is_interval, arg == DCH_YYY ? ADJUST_YEAR(tm->tm_year, is_interval) : ADJUST_YEAR(date2isoyear(tm->tm_year, - tm->tm_mon, tm->tm_mday), - is_interval)); + tm->tm_mon, tm->tm_mday), + is_interval)); i = strlen(buff); strcpy(inout, buff + (i - 3)); if (S_THth(suf)) @@ -2518,8 +2514,8 @@ dch_date(int arg, char *inout, int suf, bool is_to_char, bool is_interval, arg == DCH_YY ? ADJUST_YEAR(tm->tm_year, is_interval) : ADJUST_YEAR(date2isoyear(tm->tm_year, - tm->tm_mon, tm->tm_mday), - is_interval)); + tm->tm_mon, tm->tm_mday), + is_interval)); i = strlen(buff); strcpy(inout, buff + (i - 2)); if (S_THth(suf)) @@ -2531,8 +2527,8 @@ dch_date(int arg, char *inout, int suf, bool is_to_char, bool is_interval, sscanf(inout, "%02d", &tmfc->year); /* - * 2-digit year: '00' ... '69' = 2000 ... 2069 '70' ... - * '99' = 1970 ... 1999 + * 2-digit year: '00' ... '69' = 2000 ... 2069 '70' ... '99' + * = 1970 ... 1999 */ if (tmfc->year < 70) tmfc->year += 2000; @@ -2550,8 +2546,8 @@ dch_date(int arg, char *inout, int suf, bool is_to_char, bool is_interval, arg == DCH_Y ? ADJUST_YEAR(tm->tm_year, is_interval) : ADJUST_YEAR(date2isoyear(tm->tm_year, - tm->tm_mon, tm->tm_mday), - is_interval)); + tm->tm_mon, tm->tm_mday), + is_interval)); i = strlen(buff); strcpy(inout, buff + (i - 1)); if (S_THth(suf)) @@ -2751,8 +2747,8 @@ datetime_to_char_body(TmToChar *tmtc, text *fmt, bool is_interval) result = palloc((fmt_len * DCH_MAX_ITEM_SIZ) + 1); /* - * Allocate new memory if format picture is bigger than static cache - * and not use cache (call parser always) + * Allocate new memory if format picture is bigger than static cache and + * not use cache (call parser always) */ if (fmt_len > DCH_CACHE_SIZE) { @@ -2778,8 +2774,8 @@ datetime_to_char_body(TmToChar *tmtc, text *fmt, bool is_interval) ent = DCH_cache_getnew(fmt_str); /* - * Not in the cache, must run parser and save a new - * format-picture to the cache. + * Not in the cache, must run parser and save a new format-picture + * to the cache. */ parse_format(ent->format, fmt_str, DCH_keywords, DCH_suff, DCH_index, DCH_TYPE, NULL); @@ -2802,8 +2798,8 @@ datetime_to_char_body(TmToChar *tmtc, text *fmt, bool is_interval) pfree(fmt_str); /* - * for result is allocated max memory, which current format-picture - * needs, now it allocate result with real size + * for result is allocated max memory, which current format-picture needs, + * now it allocate result with real size */ if (result && *result) { @@ -2965,7 +2961,7 @@ to_date(PG_FUNCTION_ARGS) */ static void do_to_timestamp(text *date_txt, text *fmt, - struct pg_tm *tm, fsec_t *fsec) + struct pg_tm * tm, fsec_t *fsec) { FormatNode *format; TmFromChar tmfc; @@ -2990,8 +2986,8 @@ do_to_timestamp(text *date_txt, text *fmt, *(fmt_str + fmt_len) = '\0'; /* - * Allocate new memory if format picture is bigger than static - * cache and not use cache (call parser always) + * Allocate new memory if format picture is bigger than static cache + * and not use cache (call parser always) */ if (fmt_len > DCH_CACHE_SIZE) { @@ -3059,8 +3055,8 @@ do_to_timestamp(text *date_txt, text *fmt, DEBUG_TMFC(&tmfc); /* - * Convert values that user define for FROM_CHAR - * (to_date/to_timestamp) to standard 'tm' + * Convert values that user define for FROM_CHAR (to_date/to_timestamp) to + * standard 'tm' */ if (tmfc.ssss) { @@ -3125,18 +3121,19 @@ do_to_timestamp(text *date_txt, text *fmt, if (tmfc.year) { - if (tmfc.yysz==2 && tmfc.cc) + if (tmfc.yysz == 2 && tmfc.cc) { - /* CC and YY defined - * why -[2000|1900]? See dch_date() DCH_YY code. + /* + * CC and YY defined why -[2000|1900]? See dch_date() DCH_YY code. */ - tm->tm_year = (tmfc.cc-1)*100 + (tmfc.year >= 2000 ? tmfc.year-2000 : tmfc.year-1900); + tm->tm_year = (tmfc.cc - 1) * 100 + (tmfc.year >= 2000 ? tmfc.year - 2000 : tmfc.year - 1900); } - else if (tmfc.yysz==1 && tmfc.cc) + else if (tmfc.yysz == 1 && tmfc.cc) { - /* CC and Y defined + /* + * CC and Y defined */ - tm->tm_year = (tmfc.cc-1)*100 + tmfc.year-2000; + tm->tm_year = (tmfc.cc - 1) * 100 + tmfc.year - 2000; } else /* set year (and ignore CC if defined) */ @@ -3184,7 +3181,7 @@ do_to_timestamp(text *date_txt, text *fmt, if (!tm->tm_year) ereport(ERROR, (errcode(ERRCODE_INVALID_DATETIME_FORMAT), - errmsg("cannot calculate day of year without year information"))); + errmsg("cannot calculate day of year without year information"))); y = ysum[isleap(tm->tm_year)]; @@ -3369,9 +3366,9 @@ NUM_cache(int len, NUMDesc *Num, char *pars_str, bool *shouldFree) *(str + len) = '\0'; /* - * Allocate new memory if format picture is bigger than static cache - * and not use cache (call parser always). This branches sets - * shouldFree to true, accordingly. + * Allocate new memory if format picture is bigger than static cache and + * not use cache (call parser always). This branches sets shouldFree to + * true, accordingly. */ if (len > NUM_CACHE_SIZE) { @@ -3402,8 +3399,8 @@ NUM_cache(int len, NUMDesc *Num, char *pars_str, bool *shouldFree) ent = NUM_cache_getnew(str); /* - * Not in the cache, must run parser and save a new - * format-picture to the cache. + * Not in the cache, must run parser and save a new format-picture + * to the cache. */ parse_format(ent->format, str, NUM_keywords, NULL, NUM_index, NUM_TYPE, &ent->Num); @@ -3591,18 +3588,18 @@ get_last_relevant_decnum(char *num) static void NUM_numpart_from_char(NUMProc *Np, int id, int plen) { - bool isread = FALSE; - + bool isread = FALSE; + #ifdef DEBUG_TO_FROM_CHAR elog(DEBUG_elog_output, " --- scan start --- id=%s", - (id==NUM_0 || id==NUM_9) ? "NUM_0/9" : id==NUM_DEC ? "NUM_DEC" : "???"); + (id == NUM_0 || id == NUM_9) ? "NUM_0/9" : id == NUM_DEC ? "NUM_DEC" : "???"); #endif if (*Np->inout_p == ' ') Np->inout_p++; #define OVERLOAD_TEST (Np->inout_p >= Np->inout + plen) -#define AMOUNT_TEST(_s) (plen-(Np->inout_p-Np->inout) >= _s) +#define AMOUNT_TEST(_s) (plen-(Np->inout_p-Np->inout) >= _s) if (*Np->inout_p == ' ') Np->inout_p++; @@ -3613,13 +3610,13 @@ NUM_numpart_from_char(NUMProc *Np, int id, int plen) /* * read sign before number */ - if (*Np->number == ' ' && (id == NUM_0 || id == NUM_9 ) && - (Np->read_pre + Np->read_post)==0) + if (*Np->number == ' ' && (id == NUM_0 || id == NUM_9) && + (Np->read_pre + Np->read_post) == 0) { #ifdef DEBUG_TO_FROM_CHAR - elog(DEBUG_elog_output, "Try read sign (%c), locale positive: %s, negative: %s", - *Np->inout_p, Np->L_positive_sign, Np->L_negative_sign); + elog(DEBUG_elog_output, "Try read sign (%c), locale positive: %s, negative: %s", + *Np->inout_p, Np->L_positive_sign, Np->L_negative_sign); #endif /* @@ -3627,20 +3624,21 @@ NUM_numpart_from_char(NUMProc *Np, int id, int plen) */ if (IS_LSIGN(Np->Num) && Np->Num->lsign == NUM_LSIGN_PRE) { - int x=0; + int x = 0; + #ifdef DEBUG_TO_FROM_CHAR elog(DEBUG_elog_output, "Try read locale pre-sign (%c)", *Np->inout_p); #endif - if ((x = strlen(Np->L_negative_sign)) && + if ((x = strlen(Np->L_negative_sign)) && AMOUNT_TEST(x) && - strncmp(Np->inout_p, Np->L_negative_sign, x)==0) + strncmp(Np->inout_p, Np->L_negative_sign, x) == 0) { Np->inout_p += x; *Np->number = '-'; } - else if ((x = strlen(Np->L_positive_sign)) && - AMOUNT_TEST(x) && - strncmp(Np->inout_p, Np->L_positive_sign, x)==0) + else if ((x = strlen(Np->L_positive_sign)) && + AMOUNT_TEST(x) && + strncmp(Np->inout_p, Np->L_positive_sign, x) == 0) { Np->inout_p += x; *Np->number = '+'; @@ -3651,6 +3649,7 @@ NUM_numpart_from_char(NUMProc *Np, int id, int plen) #ifdef DEBUG_TO_FROM_CHAR elog(DEBUG_elog_output, "Try read simple sign (%c)", *Np->inout_p); #endif + /* * simple + - < > */ @@ -3658,14 +3657,14 @@ NUM_numpart_from_char(NUMProc *Np, int id, int plen) *Np->inout_p == '<')) { - *Np->number = '-'; /* set - */ + *Np->number = '-'; /* set - */ Np->inout_p++; } else if (*Np->inout_p == '+') { - *Np->number = '+'; /* set + */ + *Np->number = '+'; /* set + */ Np->inout_p++; } } @@ -3673,11 +3672,11 @@ NUM_numpart_from_char(NUMProc *Np, int id, int plen) if (OVERLOAD_TEST) return; - + #ifdef DEBUG_TO_FROM_CHAR elog(DEBUG_elog_output, "Scan for numbers (%c), current number: '%s'", *Np->inout_p, Np->number); #endif - + /* * read digit */ @@ -3696,13 +3695,14 @@ NUM_numpart_from_char(NUMProc *Np, int id, int plen) Np->read_pre++; isread = TRUE; - + #ifdef DEBUG_TO_FROM_CHAR elog(DEBUG_elog_output, "Read digit (%c)", *Np->inout_p); #endif - /* - * read decimal point - */ + + /* + * read decimal point + */ } else if (IS_DECIMAL(Np->Num) && Np->read_dec == FALSE) { @@ -3726,7 +3726,7 @@ NUM_numpart_from_char(NUMProc *Np, int id, int plen) elog(DEBUG_elog_output, "Try read locale point (%c)", *Np->inout_p); #endif - if (x && AMOUNT_TEST(x) && strncmp(Np->inout_p, Np->decimal, x)==0) + if (x && AMOUNT_TEST(x) && strncmp(Np->inout_p, Np->decimal, x) == 0) { Np->inout_p += x - 1; *Np->number_p = '.'; @@ -3739,69 +3739,68 @@ NUM_numpart_from_char(NUMProc *Np, int id, int plen) if (OVERLOAD_TEST) return; - + /* * Read sign behind "last" number * - * We need sign detection because determine exact position of - * post-sign is difficult: + * We need sign detection because determine exact position of post-sign is + * difficult: * - * FM9999.9999999S -> 123.001- - * 9.9S -> .5- - * FM9.999999MI -> 5.01- + * FM9999.9999999S -> 123.001- 9.9S -> .5- FM9.999999MI + * -> 5.01- */ if (*Np->number == ' ' && Np->read_pre + Np->read_post > 0) { /* - * locale sign (NUM_S) is always anchored behind a last number, if: - * - locale sign expected - * - last read char was NUM_0/9 or NUM_DEC - * - and next char is not digit - */ - if (IS_LSIGN(Np->Num) && isread && - (Np->inout_p+1) <= Np->inout + plen && - !isdigit((unsigned char) *(Np->inout_p+1))) + * locale sign (NUM_S) is always anchored behind a last number, if: - + * locale sign expected - last read char was NUM_0/9 or NUM_DEC - and + * next char is not digit + */ + if (IS_LSIGN(Np->Num) && isread && + (Np->inout_p + 1) <= Np->inout + plen && + !isdigit((unsigned char) *(Np->inout_p + 1))) { - int x; - char *tmp = Np->inout_p++; - + int x; + char *tmp = Np->inout_p++; + #ifdef DEBUG_TO_FROM_CHAR elog(DEBUG_elog_output, "Try read locale post-sign (%c)", *Np->inout_p); #endif - if ((x = strlen(Np->L_negative_sign)) && + if ((x = strlen(Np->L_negative_sign)) && AMOUNT_TEST(x) && - strncmp(Np->inout_p, Np->L_negative_sign, x)==0) + strncmp(Np->inout_p, Np->L_negative_sign, x) == 0) { - Np->inout_p += x-1; /* -1 .. NUM_processor() do inout_p++ */ + Np->inout_p += x - 1; /* -1 .. NUM_processor() do inout_p++ */ *Np->number = '-'; } - else if ((x = strlen(Np->L_positive_sign)) && - AMOUNT_TEST(x) && - strncmp(Np->inout_p, Np->L_positive_sign, x)==0) + else if ((x = strlen(Np->L_positive_sign)) && + AMOUNT_TEST(x) && + strncmp(Np->inout_p, Np->L_positive_sign, x) == 0) { - Np->inout_p += x-1; /* -1 .. NUM_processor() do inout_p++ */ + Np->inout_p += x - 1; /* -1 .. NUM_processor() do inout_p++ */ *Np->number = '+'; } if (*Np->number == ' ') /* no sign read */ Np->inout_p = tmp; } - + /* * try read non-locale sign, it's happen only if format is not exact * and we cannot determine sign position of MI/PL/SG, an example: * - * FM9.999999MI -> 5.01- + * FM9.999999MI -> 5.01- * - * if (.... && IS_LSIGN(Np->Num)==FALSE) prevents read wrong formats - * like to_number('1 -', '9S') where sign is not anchored to last number. + * if (.... && IS_LSIGN(Np->Num)==FALSE) prevents read wrong formats like + * to_number('1 -', '9S') where sign is not anchored to last number. */ - else if (isread==FALSE && IS_LSIGN(Np->Num)==FALSE && - (IS_PLUS(Np->Num) || IS_MINUS(Np->Num))) + else if (isread == FALSE && IS_LSIGN(Np->Num) == FALSE && + (IS_PLUS(Np->Num) || IS_MINUS(Np->Num))) { #ifdef DEBUG_TO_FROM_CHAR elog(DEBUG_elog_output, "Try read simple post-sign (%c)", *Np->inout_p); #endif + /* * simple + - */ @@ -3848,8 +3847,8 @@ NUM_numpart_to_char(NUMProc *Np, int id) Np->num_in = FALSE; /* - * Write sign if real number will write to output Note: - * IS_PREDEC_SPACE() handle "9.9" --> " .1" + * Write sign if real number will write to output Note: IS_PREDEC_SPACE() + * handle "9.9" --> " .1" */ if (Np->sign_wrote == FALSE && (Np->num_curr >= Np->num_pre || (IS_ZERO(Np->Num) && Np->Num->zero_start == Np->num_curr)) && @@ -4032,7 +4031,7 @@ NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number, Np->inout = inout; Np->last_relevant = NULL; Np->read_post = 0; - Np->read_pre = 0; + Np->read_pre = 0; Np->read_dec = FALSE; if (Np->Num->zero_start) @@ -4114,8 +4113,8 @@ NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number, if (IS_DECIMAL(Np->Num)) Np->last_relevant = get_last_relevant_decnum( Np->number + - ((Np->Num->zero_end - Np->num_pre > 0) ? - Np->Num->zero_end - Np->num_pre : 0)); + ((Np->Num->zero_end - Np->num_pre > 0) ? + Np->Num->zero_end - Np->num_pre : 0)); } if (Np->sign_wrote == FALSE && Np->num_pre == 0) @@ -4185,10 +4184,10 @@ NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number, /* * Create/reading digit/zero/blank/sing * - * 'NUM_S' note: - * The locale sign is anchored to number and we read/write it - * when we work with first or last number (NUM_0/NUM_9). This - * is reason why NUM_S missing in follow switch(). + * 'NUM_S' note: The locale sign is anchored to number and we + * read/write it when we work with first or last number + * (NUM_0/NUM_9). This is reason why NUM_S missing in follow + * switch(). */ switch (n->key->id) { @@ -4497,7 +4496,7 @@ numeric_to_number(PG_FUNCTION_ARGS) result = DirectFunctionCall3(numeric_in, CStringGetDatum(numstr), ObjectIdGetDatum(InvalidOid), - Int32GetDatum(((precision << 16) | scale) + VARHDRSZ)); + Int32GetDatum(((precision << 16) | scale) + VARHDRSZ)); pfree(numstr); return result; } @@ -4536,7 +4535,7 @@ numeric_to_char(PG_FUNCTION_ARGS) Int32GetDatum(0))); numstr = orgnum = int_to_roman(DatumGetInt32(DirectFunctionCall1(numeric_int4, - NumericGetDatum(x)))); + NumericGetDatum(x)))); pfree(x); } else @@ -4546,16 +4545,16 @@ numeric_to_char(PG_FUNCTION_ARGS) if (IS_MULTI(&Num)) { Numeric a = DatumGetNumeric(DirectFunctionCall1(int4_numeric, - Int32GetDatum(10))); + Int32GetDatum(10))); Numeric b = DatumGetNumeric(DirectFunctionCall1(int4_numeric, - Int32GetDatum(Num.multi))); + Int32GetDatum(Num.multi))); x = DatumGetNumeric(DirectFunctionCall2(numeric_power, NumericGetDatum(a), NumericGetDatum(b))); val = DatumGetNumeric(DirectFunctionCall2(numeric_mul, - NumericGetDatum(value), - NumericGetDatum(x))); + NumericGetDatum(value), + NumericGetDatum(x))); pfree(x); pfree(a); pfree(b); @@ -4639,7 +4638,7 @@ int4_to_char(PG_FUNCTION_ARGS) else { orgnum = DatumGetCString(DirectFunctionCall1(int4out, - Int32GetDatum(value))); + Int32GetDatum(value))); } len = strlen(orgnum); @@ -4711,7 +4710,7 @@ int8_to_char(PG_FUNCTION_ARGS) { /* Currently don't support int8 conversion to roman... */ numstr = orgnum = int_to_roman(DatumGetInt32( - DirectFunctionCall1(int84, Int64GetDatum(value)))); + DirectFunctionCall1(int84, Int64GetDatum(value)))); } else { @@ -4720,14 +4719,14 @@ int8_to_char(PG_FUNCTION_ARGS) double multi = pow((double) 10, (double) Num.multi); value = DatumGetInt64(DirectFunctionCall2(int8mul, - Int64GetDatum(value), - DirectFunctionCall1(dtoi8, - Float8GetDatum(multi)))); + Int64GetDatum(value), + DirectFunctionCall1(dtoi8, + Float8GetDatum(multi)))); Num.pre += Num.multi; } orgnum = DatumGetCString(DirectFunctionCall1(int8out, - Int64GetDatum(value))); + Int64GetDatum(value))); len = strlen(orgnum); if (*orgnum == '-') diff --git a/src/backend/utils/adt/genfile.c b/src/backend/utils/adt/genfile.c index cbbf9ca1c3..06ff9afe03 100644 --- a/src/backend/utils/adt/genfile.c +++ b/src/backend/utils/adt/genfile.c @@ -5,11 +5,11 @@ * * * Copyright (c) 2004-2005, PostgreSQL Global Development Group - * + * * Author: Andreas Pflug * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/genfile.c,v 1.6 2005/08/29 19:39:39 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/genfile.c,v 1.7 2005/10/15 02:49:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -30,10 +30,10 @@ #include "utils/memutils.h" -typedef struct +typedef struct { - char *location; - DIR *dirdesc; + char *location; + DIR *dirdesc; } directory_fctx; @@ -46,9 +46,9 @@ typedef struct static char * check_and_make_absolute(text *arg) { - int input_len = VARSIZE(arg) - VARHDRSZ; - char *filename = palloc(input_len + 1); - + int input_len = VARSIZE(arg) - VARHDRSZ; + char *filename = palloc(input_len + 1); + memcpy(filename, VARDATA(arg), input_len); filename[input_len] = '\0'; @@ -58,7 +58,7 @@ check_and_make_absolute(text *arg) if (path_contains_parent_reference(filename)) ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), - (errmsg("reference to parent directory (\"..\") not allowed")))); + (errmsg("reference to parent directory (\"..\") not allowed")))); if (is_absolute_path(filename)) { @@ -70,14 +70,15 @@ check_and_make_absolute(text *arg) path_is_prefix_of_path(Log_directory, filename)) return filename; - ereport(ERROR, + ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), (errmsg("absolute path not allowed")))); return NULL; /* keep compiler quiet */ } else { - char *absname = palloc(strlen(DataDir) + strlen(filename) + 2); + char *absname = palloc(strlen(DataDir) + strlen(filename) + 2); + sprintf(absname, "%s/%s", DataDir, filename); pfree(filename); return absname; @@ -94,13 +95,13 @@ pg_read_file(PG_FUNCTION_ARGS) text *filename_t = PG_GETARG_TEXT_P(0); int64 seek_offset = PG_GETARG_INT64(1); int64 bytes_to_read = PG_GETARG_INT64(2); - char *buf; + char *buf; size_t nbytes; - FILE *file; - char *filename; + FILE *file; + char *filename; if (!superuser()) - ereport(ERROR, + ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), (errmsg("must be superuser to read files")))); @@ -128,7 +129,7 @@ pg_read_file(PG_FUNCTION_ARGS) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("requested length too large"))); - + buf = palloc((Size) bytes_to_read + VARHDRSZ); nbytes = fread(VARDATA(buf), 1, (size_t) bytes_to_read, file); @@ -153,7 +154,7 @@ Datum pg_stat_file(PG_FUNCTION_ARGS) { text *filename_t = PG_GETARG_TEXT_P(0); - char *filename; + char *filename; struct stat fst; Datum values[6]; bool isnull[6]; @@ -161,7 +162,7 @@ pg_stat_file(PG_FUNCTION_ARGS) TupleDesc tupdesc; if (!superuser()) - ereport(ERROR, + ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), (errmsg("must be superuser to get file information")))); @@ -173,8 +174,8 @@ pg_stat_file(PG_FUNCTION_ARGS) errmsg("could not stat file \"%s\": %m", filename))); /* - * This record type had better match the output parameters declared - * for me in pg_proc.h (actually, in system_views.sql at the moment). + * This record type had better match the output parameters declared for me + * in pg_proc.h (actually, in system_views.sql at the moment). */ tupdesc = CreateTemplateTupleDesc(6, false); TupleDescInitEntry(tupdesc, (AttrNumber) 1, @@ -220,12 +221,12 @@ pg_stat_file(PG_FUNCTION_ARGS) Datum pg_ls_dir(PG_FUNCTION_ARGS) { - FuncCallContext *funcctx; - struct dirent *de; - directory_fctx *fctx; + FuncCallContext *funcctx; + struct dirent *de; + directory_fctx *fctx; if (!superuser()) - ereport(ERROR, + ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), (errmsg("must be superuser to get directory listings")))); @@ -242,7 +243,7 @@ pg_ls_dir(PG_FUNCTION_ARGS) fctx->dirdesc = AllocateDir(fctx->location); if (!fctx->dirdesc) - ereport(ERROR, + ereport(ERROR, (errcode_for_file_access(), errmsg("could not open directory \"%s\": %m", fctx->location))); @@ -252,16 +253,16 @@ pg_ls_dir(PG_FUNCTION_ARGS) } funcctx = SRF_PERCALL_SETUP(); - fctx = (directory_fctx*) funcctx->user_fctx; + fctx = (directory_fctx *) funcctx->user_fctx; while ((de = ReadDir(fctx->dirdesc, fctx->location)) != NULL) { int len = strlen(de->d_name); - text *result; + text *result; if (strcmp(de->d_name, ".") == 0 || strcmp(de->d_name, "..") == 0) - continue; + continue; result = palloc(len + VARHDRSZ); VARATT_SIZEP(result) = len + VARHDRSZ; diff --git a/src/backend/utils/adt/geo_ops.c b/src/backend/utils/adt/geo_ops.c index 1786da6dd1..2f1714a034 100644 --- a/src/backend/utils/adt/geo_ops.c +++ b/src/backend/utils/adt/geo_ops.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/geo_ops.c,v 1.90 2005/07/01 19:19:02 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/geo_ops.c,v 1.91 2005/10/15 02:49:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -387,7 +387,7 @@ box_in(PG_FUNCTION_ARGS) || (*s != '\0')) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type box: \"%s\"", str))); + errmsg("invalid input syntax for type box: \"%s\"", str))); /* reorder corners if necessary... */ if (box->high.x < box->low.x) @@ -951,7 +951,7 @@ line_in(PG_FUNCTION_ARGS) || (*s != '\0')) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type line: \"%s\"", str))); + errmsg("invalid input syntax for type line: \"%s\"", str))); line = (LINE *) palloc(sizeof(LINE)); line_construct_pts(line, &lseg.p[0], &lseg.p[1]); @@ -1292,10 +1292,9 @@ line_interpt_internal(LINE *l1, LINE *l2) y; /* - * NOTE: if the lines are identical then we will find they are - * parallel and report "no intersection". This is a little weird, but - * since there's no *unique* intersection, maybe it's appropriate - * behavior. + * NOTE: if the lines are identical then we will find they are parallel + * and report "no intersection". This is a little weird, but since + * there's no *unique* intersection, maybe it's appropriate behavior. */ if (DatumGetBool(DirectFunctionCall2(line_parallel, LinePGetDatum(l1), @@ -1400,7 +1399,7 @@ path_in(PG_FUNCTION_ARGS) if ((npts = pair_count(str, ',')) <= 0) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type path: \"%s\"", str))); + errmsg("invalid input syntax for type path: \"%s\"", str))); s = str; while (isspace((unsigned char) *s)) @@ -1420,10 +1419,10 @@ path_in(PG_FUNCTION_ARGS) path->npts = npts; if ((!path_decode(TRUE, npts, s, &isopen, &s, &(path->p[0]))) - && (!((depth == 0) && (*s == '\0'))) && !((depth >= 1) && (*s == RDELIM))) + && (!((depth == 0) && (*s == '\0'))) && !((depth >= 1) && (*s == RDELIM))) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type path: \"%s\"", str))); + errmsg("invalid input syntax for type path: \"%s\"", str))); path->closed = (!isopen); @@ -1460,7 +1459,7 @@ path_recv(PG_FUNCTION_ARGS) if (npts < 0 || npts >= (int32) ((INT_MAX - offsetof(PATH, p[0])) / sizeof(Point))) ereport(ERROR, (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION), - errmsg("invalid number of points in external \"path\" value"))); + errmsg("invalid number of points in external \"path\" value"))); size = offsetof(PATH, p[0]) +sizeof(path->p[0]) * npts; path = (PATH *) palloc(size); @@ -1730,7 +1729,7 @@ path_distance(PG_FUNCTION_ARGS) tmp = DatumGetFloat8(DirectFunctionCall2(lseg_distance, LsegPGetDatum(&seg1), - LsegPGetDatum(&seg2))); + LsegPGetDatum(&seg2))); if (!have_min || tmp < min) { min = tmp; @@ -1801,7 +1800,7 @@ point_in(PG_FUNCTION_ARGS) if (!pair_decode(str, &x, &y, &s) || (*s != '\0')) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type point: \"%s\"", str))); + errmsg("invalid input syntax for type point: \"%s\"", str))); point = (Point *) palloc(sizeof(Point)); @@ -1976,7 +1975,7 @@ point_dt(Point *pt1, Point *pt2) { #ifdef GEODEBUG printf("point_dt- segment (%f,%f),(%f,%f) length is %f\n", - pt1->x, pt1->y, pt2->x, pt2->y, HYPOT(pt1->x - pt2->x, pt1->y - pt2->y)); + pt1->x, pt1->y, pt2->x, pt2->y, HYPOT(pt1->x - pt2->x, pt1->y - pt2->y)); #endif return HYPOT(pt1->x - pt2->x, pt1->y - pt2->y); } @@ -2029,7 +2028,7 @@ lseg_in(PG_FUNCTION_ARGS) || (*s != '\0')) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type lseg: \"%s\"", str))); + errmsg("invalid input syntax for type lseg: \"%s\"", str))); #ifdef NOT_USED lseg->m = point_sl(&lseg->p[0], &lseg->p[1]); @@ -2374,8 +2373,8 @@ lseg_interpt(PG_FUNCTION_ARGS) PG_RETURN_NULL(); /* - * If the line intersection point isn't within l1 (or equivalently - * l2), there is no valid segment intersection point at all. + * If the line intersection point isn't within l1 (or equivalently l2), + * there is no valid segment intersection point at all. */ if (!on_ps_internal(result, l1) || !on_ps_internal(result, l2)) @@ -2393,7 +2392,7 @@ lseg_interpt(PG_FUNCTION_ARGS) result->y = l1->p[0].y; } else if ((FPeq(l1->p[1].x, l2->p[0].x) && FPeq(l1->p[1].y, l2->p[0].y)) || - (FPeq(l1->p[1].x, l2->p[1].x) && FPeq(l1->p[1].y, l2->p[1].y))) + (FPeq(l1->p[1].x, l2->p[1].x) && FPeq(l1->p[1].y, l2->p[1].y))) { result->x = l1->p[1].x; result->y = l1->p[1].y; @@ -2521,8 +2520,8 @@ dist_ppath(PG_FUNCTION_ARGS) Assert(path->npts > 1); /* - * the distance from a point to a path is the smallest - * distance from the point to any of its constituent segments. + * the distance from a point to a path is the smallest distance + * from the point to any of its constituent segments. */ for (i = 0; i < path->npts; i++) { @@ -2534,8 +2533,7 @@ dist_ppath(PG_FUNCTION_ARGS) { if (!path->closed) continue; - iprev = path->npts - 1; /* include the closure - * segment */ + iprev = path->npts - 1; /* include the closure segment */ } statlseg_construct(&lseg, &path->p[iprev], &path->p[i]); @@ -2853,8 +2851,8 @@ close_ps(PG_FUNCTION_ARGS) } /* - * vert. and horiz. cases are down, now check if the closest point is - * one of the end points or someplace on the lseg. + * vert. and horiz. cases are down, now check if the closest point is one + * of the end points or someplace on the lseg. */ invm = -1.0 / point_sl(&(lseg->p[0]), &(lseg->p[1])); @@ -2862,8 +2860,8 @@ close_ps(PG_FUNCTION_ARGS) * "band" */ if (pt->y < (tmp->A * pt->x + tmp->C)) { /* we are below the lower edge */ - result = point_copy(&lseg->p[!yh]); /* below the lseg, take - * lower end pt */ + result = point_copy(&lseg->p[!yh]); /* below the lseg, take lower + * end pt */ #ifdef GEODEBUG printf("close_ps below: tmp A %f B %f C %f m %f\n", tmp->A, tmp->B, tmp->C, tmp->m); @@ -2874,8 +2872,8 @@ close_ps(PG_FUNCTION_ARGS) * "band" */ if (pt->y > (tmp->A * pt->x + tmp->C)) { /* we are below the lower edge */ - result = point_copy(&lseg->p[yh]); /* above the lseg, take - * higher end pt */ + result = point_copy(&lseg->p[yh]); /* above the lseg, take higher + * end pt */ #ifdef GEODEBUG printf("close_ps above: tmp A %f B %f C %f m %f\n", tmp->A, tmp->B, tmp->C, tmp->m); @@ -2884,8 +2882,8 @@ close_ps(PG_FUNCTION_ARGS) } /* - * at this point the "normal" from point will hit lseg. The closet - * point will be somewhere on the lseg + * at this point the "normal" from point will hit lseg. The closet point + * will be somewhere on the lseg */ tmp = line_construct_pm(pt, invm); #ifdef GEODEBUG @@ -2927,22 +2925,22 @@ close_lseg(PG_FUNCTION_ARGS) if ((d = dist_ps_internal(&l2->p[0], l1)) < dist) { result = DatumGetPointP(DirectFunctionCall2(close_ps, - PointPGetDatum(&l2->p[0]), + PointPGetDatum(&l2->p[0]), LsegPGetDatum(l1))); memcpy(&point, result, sizeof(Point)); result = DatumGetPointP(DirectFunctionCall2(close_ps, - PointPGetDatum(&point), + PointPGetDatum(&point), LsegPGetDatum(l2))); } if ((d = dist_ps_internal(&l2->p[1], l1)) < dist) { result = DatumGetPointP(DirectFunctionCall2(close_ps, - PointPGetDatum(&l2->p[1]), + PointPGetDatum(&l2->p[1]), LsegPGetDatum(l1))); memcpy(&point, result, sizeof(Point)); result = DatumGetPointP(DirectFunctionCall2(close_ps, - PointPGetDatum(&point), + PointPGetDatum(&point), LsegPGetDatum(l2))); } @@ -3235,11 +3233,11 @@ on_sl(PG_FUNCTION_ARGS) LINE *line = PG_GETARG_LINE_P(1); PG_RETURN_BOOL(DatumGetBool(DirectFunctionCall2(on_pl, - PointPGetDatum(&lseg->p[0]), - LinePGetDatum(line))) && + PointPGetDatum(&lseg->p[0]), + LinePGetDatum(line))) && DatumGetBool(DirectFunctionCall2(on_pl, - PointPGetDatum(&lseg->p[1]), - LinePGetDatum(line)))); + PointPGetDatum(&lseg->p[1]), + LinePGetDatum(line)))); } Datum @@ -3249,10 +3247,10 @@ on_sb(PG_FUNCTION_ARGS) BOX *box = PG_GETARG_BOX_P(1); PG_RETURN_BOOL(DatumGetBool(DirectFunctionCall2(on_pb, - PointPGetDatum(&lseg->p[0]), + PointPGetDatum(&lseg->p[0]), BoxPGetDatum(box))) && DatumGetBool(DirectFunctionCall2(on_pb, - PointPGetDatum(&lseg->p[1]), + PointPGetDatum(&lseg->p[1]), BoxPGetDatum(box)))); } @@ -3437,7 +3435,7 @@ poly_in(PG_FUNCTION_ARGS) if ((npts = pair_count(str, ',')) <= 0) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type polygon: \"%s\"", str))); + errmsg("invalid input syntax for type polygon: \"%s\"", str))); size = offsetof(POLYGON, p[0]) +sizeof(poly->p[0]) * npts; poly = (POLYGON *) palloc0(size); /* zero any holes */ @@ -3449,7 +3447,7 @@ poly_in(PG_FUNCTION_ARGS) || (*s != '\0')) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type polygon: \"%s\"", str))); + errmsg("invalid input syntax for type polygon: \"%s\"", str))); make_bound_box(poly); @@ -3489,7 +3487,7 @@ poly_recv(PG_FUNCTION_ARGS) if (npts < 0 || npts >= (int32) ((INT_MAX - offsetof(POLYGON, p[0])) / sizeof(Point))) ereport(ERROR, (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION), - errmsg("invalid number of points in external \"polygon\" value"))); + errmsg("invalid number of points in external \"polygon\" value"))); size = offsetof(POLYGON, p[0]) +sizeof(poly->p[0]) * npts; poly = (POLYGON *) palloc0(size); /* zero any holes */ @@ -3544,8 +3542,7 @@ poly_left(PG_FUNCTION_ARGS) result = polya->boundbox.high.x < polyb->boundbox.low.x; /* - * Avoid leaking memory for toasted inputs ... needed for rtree - * indexes + * Avoid leaking memory for toasted inputs ... needed for rtree indexes */ PG_FREE_IF_COPY(polya, 0); PG_FREE_IF_COPY(polyb, 1); @@ -3568,8 +3565,7 @@ poly_overleft(PG_FUNCTION_ARGS) result = polya->boundbox.high.x <= polyb->boundbox.high.x; /* - * Avoid leaking memory for toasted inputs ... needed for rtree - * indexes + * Avoid leaking memory for toasted inputs ... needed for rtree indexes */ PG_FREE_IF_COPY(polya, 0); PG_FREE_IF_COPY(polyb, 1); @@ -3592,8 +3588,7 @@ poly_right(PG_FUNCTION_ARGS) result = polya->boundbox.low.x > polyb->boundbox.high.x; /* - * Avoid leaking memory for toasted inputs ... needed for rtree - * indexes + * Avoid leaking memory for toasted inputs ... needed for rtree indexes */ PG_FREE_IF_COPY(polya, 0); PG_FREE_IF_COPY(polyb, 1); @@ -3616,8 +3611,7 @@ poly_overright(PG_FUNCTION_ARGS) result = polya->boundbox.low.x >= polyb->boundbox.low.x; /* - * Avoid leaking memory for toasted inputs ... needed for rtree - * indexes + * Avoid leaking memory for toasted inputs ... needed for rtree indexes */ PG_FREE_IF_COPY(polya, 0); PG_FREE_IF_COPY(polyb, 1); @@ -3640,8 +3634,7 @@ poly_below(PG_FUNCTION_ARGS) result = polya->boundbox.high.y < polyb->boundbox.low.y; /* - * Avoid leaking memory for toasted inputs ... needed for rtree - * indexes + * Avoid leaking memory for toasted inputs ... needed for rtree indexes */ PG_FREE_IF_COPY(polya, 0); PG_FREE_IF_COPY(polyb, 1); @@ -3664,8 +3657,7 @@ poly_overbelow(PG_FUNCTION_ARGS) result = polya->boundbox.high.y <= polyb->boundbox.high.y; /* - * Avoid leaking memory for toasted inputs ... needed for rtree - * indexes + * Avoid leaking memory for toasted inputs ... needed for rtree indexes */ PG_FREE_IF_COPY(polya, 0); PG_FREE_IF_COPY(polyb, 1); @@ -3688,8 +3680,7 @@ poly_above(PG_FUNCTION_ARGS) result = polya->boundbox.low.y > polyb->boundbox.high.y; /* - * Avoid leaking memory for toasted inputs ... needed for rtree - * indexes + * Avoid leaking memory for toasted inputs ... needed for rtree indexes */ PG_FREE_IF_COPY(polya, 0); PG_FREE_IF_COPY(polyb, 1); @@ -3712,8 +3703,7 @@ poly_overabove(PG_FUNCTION_ARGS) result = polya->boundbox.low.y >= polyb->boundbox.low.y; /* - * Avoid leaking memory for toasted inputs ... needed for rtree - * indexes + * Avoid leaking memory for toasted inputs ... needed for rtree indexes */ PG_FREE_IF_COPY(polya, 0); PG_FREE_IF_COPY(polyb, 1); @@ -3742,8 +3732,7 @@ poly_same(PG_FUNCTION_ARGS) result = plist_same(polya->npts, polya->p, polyb->p); /* - * Avoid leaking memory for toasted inputs ... needed for rtree - * indexes + * Avoid leaking memory for toasted inputs ... needed for rtree indexes */ PG_FREE_IF_COPY(polya, 0); PG_FREE_IF_COPY(polyb, 1); @@ -3767,8 +3756,7 @@ poly_overlap(PG_FUNCTION_ARGS) result = box_ov(&polya->boundbox, &polyb->boundbox); /* - * Avoid leaking memory for toasted inputs ... needed for rtree - * indexes + * Avoid leaking memory for toasted inputs ... needed for rtree indexes */ PG_FREE_IF_COPY(polya, 0); PG_FREE_IF_COPY(polyb, 1); @@ -3833,8 +3821,7 @@ poly_contain(PG_FUNCTION_ARGS) } /* - * Avoid leaking memory for toasted inputs ... needed for rtree - * indexes + * Avoid leaking memory for toasted inputs ... needed for rtree indexes */ PG_FREE_IF_COPY(polya, 0); PG_FREE_IF_COPY(polyb, 1); @@ -4169,7 +4156,7 @@ path_mul_pt(PG_FUNCTION_ARGS) for (i = 0; i < path->npts; i++) { p = DatumGetPointP(DirectFunctionCall2(point_mul, - PointPGetDatum(&path->p[i]), + PointPGetDatum(&path->p[i]), PointPGetDatum(point))); path->p[i].x = p->x; path->p[i].y = p->y; @@ -4189,7 +4176,7 @@ path_div_pt(PG_FUNCTION_ARGS) for (i = 0; i < path->npts; i++) { p = DatumGetPointP(DirectFunctionCall2(point_div, - PointPGetDatum(&path->p[i]), + PointPGetDatum(&path->p[i]), PointPGetDatum(point))); path->p[i].x = p->x; path->p[i].y = p->y; @@ -4392,7 +4379,7 @@ circle_in(PG_FUNCTION_ARGS) if (!pair_decode(s, &circle->center.x, &circle->center.y, &s)) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type circle: \"%s\"", str))); + errmsg("invalid input syntax for type circle: \"%s\"", str))); if (*s == DELIM) s++; @@ -4402,7 +4389,7 @@ circle_in(PG_FUNCTION_ARGS) if ((!single_decode(s, &circle->radius, &s)) || (circle->radius < 0)) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type circle: \"%s\"", str))); + errmsg("invalid input syntax for type circle: \"%s\"", str))); while (depth > 0) { @@ -4417,13 +4404,13 @@ circle_in(PG_FUNCTION_ARGS) else ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type circle: \"%s\"", str))); + errmsg("invalid input syntax for type circle: \"%s\"", str))); } if (*s != '\0') ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type circle: \"%s\"", str))); + errmsg("invalid input syntax for type circle: \"%s\"", str))); PG_RETURN_CIRCLE_P(circle); } @@ -4780,7 +4767,7 @@ circle_mul_pt(PG_FUNCTION_ARGS) result = circle_copy(circle); p = DatumGetPointP(DirectFunctionCall2(point_mul, - PointPGetDatum(&circle->center), + PointPGetDatum(&circle->center), PointPGetDatum(point))); result->center.x = p->x; result->center.y = p->y; @@ -4800,7 +4787,7 @@ circle_div_pt(PG_FUNCTION_ARGS) result = circle_copy(circle); p = DatumGetPointP(DirectFunctionCall2(point_div, - PointPGetDatum(&circle->center), + PointPGetDatum(&circle->center), PointPGetDatum(point))); result->center.x = p->x; result->center.y = p->y; @@ -5001,7 +4988,7 @@ circle_poly(PG_FUNCTION_ARGS) if (FPzero(circle->radius)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot convert circle with radius zero to polygon"))); + errmsg("cannot convert circle with radius zero to polygon"))); if (npts < 2) ereport(ERROR, diff --git a/src/backend/utils/adt/inet_net_ntop.c b/src/backend/utils/adt/inet_net_ntop.c index 67a55be571..abbfcd592c 100644 --- a/src/backend/utils/adt/inet_net_ntop.c +++ b/src/backend/utils/adt/inet_net_ntop.c @@ -14,7 +14,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $PostgreSQL: pgsql/src/backend/utils/adt/inet_net_ntop.c,v 1.20 2005/09/24 22:54:38 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/inet_net_ntop.c,v 1.21 2005/10/15 02:49:28 momjian Exp $ */ #if defined(LIBC_SCCS) && !defined(lint) @@ -412,11 +412,11 @@ static char * inet_net_ntop_ipv6(const u_char *src, int bits, char *dst, size_t size) { /* - * Note that int32_t and int16_t need only be "at least" large enough - * to contain a value of the specified size. On some systems, like - * Crays, there is no such thing as an integer variable with 16 bits. - * Keep this in mind if you think this function should have been coded - * to use pointer overlays. All the world's not a VAX. + * Note that int32_t and int16_t need only be "at least" large enough to + * contain a value of the specified size. On some systems, like Crays, + * there is no such thing as an integer variable with 16 bits. Keep this + * in mind if you think this function should have been coded to use + * pointer overlays. All the world's not a VAX. */ char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255/128"]; char *tp; @@ -435,8 +435,8 @@ inet_net_ntop_ipv6(const u_char *src, int bits, char *dst, size_t size) } /* - * Preprocess: Copy the input (bytewise) array into a wordwise array. - * Find the longest run of 0x00's in src[] for :: shorthanding. + * Preprocess: Copy the input (bytewise) array into a wordwise array. Find + * the longest run of 0x00's in src[] for :: shorthanding. */ memset(words, '\0', sizeof words); for (i = 0; i < NS_IN6ADDRSZ; i++) @@ -491,8 +491,8 @@ inet_net_ntop_ipv6(const u_char *src, int bits, char *dst, size_t size) *tp++ = ':'; /* Is this address an encapsulated IPv4? */ if (i == 6 && best.base == 0 && (best.len == 6 || - (best.len == 7 && words[7] != 0x0001) || - (best.len == 5 && words[5] == 0xffff))) + (best.len == 7 && words[7] != 0x0001) || + (best.len == 5 && words[5] == 0xffff))) { int n; diff --git a/src/backend/utils/adt/inet_net_pton.c b/src/backend/utils/adt/inet_net_pton.c index a6911740cd..e9239e317e 100644 --- a/src/backend/utils/adt/inet_net_pton.c +++ b/src/backend/utils/adt/inet_net_pton.c @@ -14,7 +14,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $PostgreSQL: pgsql/src/backend/utils/adt/inet_net_pton.c,v 1.20 2005/02/01 00:59:09 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/inet_net_pton.c,v 1.21 2005/10/15 02:49:28 momjian Exp $ */ #if defined(LIBC_SCCS) && !defined(lint) @@ -207,7 +207,8 @@ inet_cidr_pton_ipv4(const char *src, u_char *dst, size_t size) bits = 24; else if (*odst >= 128) /* Class B */ bits = 16; - else /* Class A */ + else + /* Class A */ bits = 8; /* If imputed mask is narrower than specified octets, widen. */ if (bits < ((dst - odst) * 8)) diff --git a/src/backend/utils/adt/int.c b/src/backend/utils/adt/int.c index d35af1c913..e41e584ffe 100644 --- a/src/backend/utils/adt/int.c +++ b/src/backend/utils/adt/int.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/int.c,v 1.67 2005/07/10 21:36:21 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/int.c,v 1.68 2005/10/15 02:49:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -120,7 +120,7 @@ int2send(PG_FUNCTION_ARGS) int2vector * buildint2vector(const int2 *int2s, int n) { - int2vector *result; + int2vector *result; result = (int2vector *) palloc0(Int2VectorSize(n)); @@ -128,8 +128,8 @@ buildint2vector(const int2 *int2s, int n) memcpy(result->values, int2s, n * sizeof(int2)); /* - * Attach standard array header. For historical reasons, we set the - * index lower bound to 0 not 1. + * Attach standard array header. For historical reasons, we set the index + * lower bound to 0 not 1. */ result->size = Int2VectorSize(n); result->ndim = 1; @@ -212,7 +212,7 @@ Datum int2vectorrecv(PG_FUNCTION_ARGS) { StringInfo buf = (StringInfo) PG_GETARG_POINTER(0); - int2vector *result; + int2vector *result; result = (int2vector *) DatumGetPointer(DirectFunctionCall3(array_recv, @@ -686,10 +686,11 @@ int4pl(PG_FUNCTION_ARGS) int32 result; result = arg1 + arg2; + /* - * Overflow check. If the inputs are of different signs then their sum - * cannot overflow. If the inputs are of the same sign, their sum - * had better be that sign too. + * Overflow check. If the inputs are of different signs then their sum + * cannot overflow. If the inputs are of the same sign, their sum had + * better be that sign too. */ if (SAMESIGN(arg1, arg2) && !SAMESIGN(result, arg1)) ereport(ERROR, @@ -706,10 +707,11 @@ int4mi(PG_FUNCTION_ARGS) int32 result; result = arg1 - arg2; + /* - * Overflow check. If the inputs are of the same sign then their - * difference cannot overflow. If they are of different signs then - * the result should be of the same sign as the first input. + * Overflow check. If the inputs are of the same sign then their + * difference cannot overflow. If they are of different signs then the + * result should be of the same sign as the first input. */ if (!SAMESIGN(arg1, arg2) && !SAMESIGN(result, arg1)) ereport(ERROR, @@ -726,21 +728,22 @@ int4mul(PG_FUNCTION_ARGS) int32 result; result = arg1 * arg2; + /* - * Overflow check. We basically check to see if result / arg2 gives - * arg1 again. There are two cases where this fails: arg2 = 0 (which - * cannot overflow) and arg1 = INT_MIN, arg2 = -1 (where the division - * itself will overflow and thus incorrectly match). + * Overflow check. We basically check to see if result / arg2 gives arg1 + * again. There are two cases where this fails: arg2 = 0 (which cannot + * overflow) and arg1 = INT_MIN, arg2 = -1 (where the division itself will + * overflow and thus incorrectly match). * * Since the division is likely much more expensive than the actual - * multiplication, we'd like to skip it where possible. The best - * bang for the buck seems to be to check whether both inputs are in - * the int16 range; if so, no overflow is possible. + * multiplication, we'd like to skip it where possible. The best bang for + * the buck seems to be to check whether both inputs are in the int16 + * range; if so, no overflow is possible. */ if (!(arg1 >= (int32) SHRT_MIN && arg1 <= (int32) SHRT_MAX && arg2 >= (int32) SHRT_MIN && arg2 <= (int32) SHRT_MAX) && arg2 != 0 && - (result/arg2 != arg1 || (arg2 == -1 && arg1 < 0 && result < 0))) + (result / arg2 != arg1 || (arg2 == -1 && arg1 < 0 && result < 0))) ereport(ERROR, (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), errmsg("integer out of range"))); @@ -760,10 +763,11 @@ int4div(PG_FUNCTION_ARGS) errmsg("division by zero"))); result = arg1 / arg2; + /* - * Overflow check. The only possible overflow case is for - * arg1 = INT_MIN, arg2 = -1, where the correct result is -INT_MIN, - * which can't be represented on a two's-complement machine. + * Overflow check. The only possible overflow case is for arg1 = INT_MIN, + * arg2 = -1, where the correct result is -INT_MIN, which can't be + * represented on a two's-complement machine. */ if (arg2 == -1 && arg1 < 0 && result < 0) ereport(ERROR, @@ -819,10 +823,11 @@ int2pl(PG_FUNCTION_ARGS) int16 result; result = arg1 + arg2; + /* - * Overflow check. If the inputs are of different signs then their sum - * cannot overflow. If the inputs are of the same sign, their sum - * had better be that sign too. + * Overflow check. If the inputs are of different signs then their sum + * cannot overflow. If the inputs are of the same sign, their sum had + * better be that sign too. */ if (SAMESIGN(arg1, arg2) && !SAMESIGN(result, arg1)) ereport(ERROR, @@ -839,10 +844,11 @@ int2mi(PG_FUNCTION_ARGS) int16 result; result = arg1 - arg2; + /* - * Overflow check. If the inputs are of the same sign then their - * difference cannot overflow. If they are of different signs then - * the result should be of the same sign as the first input. + * Overflow check. If the inputs are of the same sign then their + * difference cannot overflow. If they are of different signs then the + * result should be of the same sign as the first input. */ if (!SAMESIGN(arg1, arg2) && !SAMESIGN(result, arg1)) ereport(ERROR, @@ -859,11 +865,11 @@ int2mul(PG_FUNCTION_ARGS) int32 result32; /* - * The most practical way to detect overflow is to do the arithmetic - * in int32 (so that the result can't overflow) and then do a range - * check. + * The most practical way to detect overflow is to do the arithmetic in + * int32 (so that the result can't overflow) and then do a range check. */ - result32 = (int32) arg1 * (int32) arg2; + result32 = (int32) arg1 *(int32) arg2; + if (result32 < SHRT_MIN || result32 > SHRT_MAX) ereport(ERROR, (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), @@ -885,10 +891,11 @@ int2div(PG_FUNCTION_ARGS) errmsg("division by zero"))); result = arg1 / arg2; + /* - * Overflow check. The only possible overflow case is for - * arg1 = SHRT_MIN, arg2 = -1, where the correct result is -SHRT_MIN, - * which can't be represented on a two's-complement machine. + * Overflow check. The only possible overflow case is for arg1 = + * SHRT_MIN, arg2 = -1, where the correct result is -SHRT_MIN, which can't + * be represented on a two's-complement machine. */ if (arg2 == -1 && arg1 < 0 && result < 0) ereport(ERROR, @@ -905,10 +912,11 @@ int24pl(PG_FUNCTION_ARGS) int32 result; result = arg1 + arg2; + /* - * Overflow check. If the inputs are of different signs then their sum - * cannot overflow. If the inputs are of the same sign, their sum - * had better be that sign too. + * Overflow check. If the inputs are of different signs then their sum + * cannot overflow. If the inputs are of the same sign, their sum had + * better be that sign too. */ if (SAMESIGN(arg1, arg2) && !SAMESIGN(result, arg1)) ereport(ERROR, @@ -925,10 +933,11 @@ int24mi(PG_FUNCTION_ARGS) int32 result; result = arg1 - arg2; + /* - * Overflow check. If the inputs are of the same sign then their - * difference cannot overflow. If they are of different signs then - * the result should be of the same sign as the first input. + * Overflow check. If the inputs are of the same sign then their + * difference cannot overflow. If they are of different signs then the + * result should be of the same sign as the first input. */ if (!SAMESIGN(arg1, arg2) && !SAMESIGN(result, arg1)) ereport(ERROR, @@ -945,18 +954,19 @@ int24mul(PG_FUNCTION_ARGS) int32 result; result = arg1 * arg2; + /* - * Overflow check. We basically check to see if result / arg2 gives - * arg1 again. There is one case where this fails: arg2 = 0 (which - * cannot overflow). + * Overflow check. We basically check to see if result / arg2 gives arg1 + * again. There is one case where this fails: arg2 = 0 (which cannot + * overflow). * * Since the division is likely much more expensive than the actual - * multiplication, we'd like to skip it where possible. The best - * bang for the buck seems to be to check whether both inputs are in - * the int16 range; if so, no overflow is possible. + * multiplication, we'd like to skip it where possible. The best bang for + * the buck seems to be to check whether both inputs are in the int16 + * range; if so, no overflow is possible. */ if (!(arg2 >= (int32) SHRT_MIN && arg2 <= (int32) SHRT_MAX) && - result/arg2 != arg1) + result / arg2 != arg1) ereport(ERROR, (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), errmsg("integer out of range"))); @@ -985,10 +995,11 @@ int42pl(PG_FUNCTION_ARGS) int32 result; result = arg1 + arg2; + /* - * Overflow check. If the inputs are of different signs then their sum - * cannot overflow. If the inputs are of the same sign, their sum - * had better be that sign too. + * Overflow check. If the inputs are of different signs then their sum + * cannot overflow. If the inputs are of the same sign, their sum had + * better be that sign too. */ if (SAMESIGN(arg1, arg2) && !SAMESIGN(result, arg1)) ereport(ERROR, @@ -1005,10 +1016,11 @@ int42mi(PG_FUNCTION_ARGS) int32 result; result = arg1 - arg2; + /* - * Overflow check. If the inputs are of the same sign then their - * difference cannot overflow. If they are of different signs then - * the result should be of the same sign as the first input. + * Overflow check. If the inputs are of the same sign then their + * difference cannot overflow. If they are of different signs then the + * result should be of the same sign as the first input. */ if (!SAMESIGN(arg1, arg2) && !SAMESIGN(result, arg1)) ereport(ERROR, @@ -1025,18 +1037,19 @@ int42mul(PG_FUNCTION_ARGS) int32 result; result = arg1 * arg2; + /* - * Overflow check. We basically check to see if result / arg1 gives - * arg2 again. There is one case where this fails: arg1 = 0 (which - * cannot overflow). + * Overflow check. We basically check to see if result / arg1 gives arg2 + * again. There is one case where this fails: arg1 = 0 (which cannot + * overflow). * * Since the division is likely much more expensive than the actual - * multiplication, we'd like to skip it where possible. The best - * bang for the buck seems to be to check whether both inputs are in - * the int16 range; if so, no overflow is possible. + * multiplication, we'd like to skip it where possible. The best bang for + * the buck seems to be to check whether both inputs are in the int16 + * range; if so, no overflow is possible. */ if (!(arg1 >= (int32) SHRT_MIN && arg1 <= (int32) SHRT_MAX) && - result/arg1 != arg2) + result / arg1 != arg2) ereport(ERROR, (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), errmsg("integer out of range"))); @@ -1056,10 +1069,11 @@ int42div(PG_FUNCTION_ARGS) errmsg("division by zero"))); result = arg1 / arg2; + /* - * Overflow check. The only possible overflow case is for - * arg1 = INT_MIN, arg2 = -1, where the correct result is -INT_MIN, - * which can't be represented on a two's-complement machine. + * Overflow check. The only possible overflow case is for arg1 = INT_MIN, + * arg2 = -1, where the correct result is -INT_MIN, which can't be + * represented on a two's-complement machine. */ if (arg2 == -1 && arg1 < 0 && result < 0) ereport(ERROR, @@ -1352,8 +1366,7 @@ generate_series_step_int4(PG_FUNCTION_ARGS) funcctx = SRF_FIRSTCALL_INIT(); /* - * switch to memory context appropriate for multiple function - * calls + * switch to memory context appropriate for multiple function calls */ oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); @@ -1376,8 +1389,7 @@ generate_series_step_int4(PG_FUNCTION_ARGS) funcctx = SRF_PERCALL_SETUP(); /* - * get the saved state and use current as the result for this - * iteration + * get the saved state and use current as the result for this iteration */ fctx = funcctx->user_fctx; result = fctx->current; diff --git a/src/backend/utils/adt/int8.c b/src/backend/utils/adt/int8.c index c5c3d30d03..6418da312e 100644 --- a/src/backend/utils/adt/int8.c +++ b/src/backend/utils/adt/int8.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/int8.c,v 1.58 2005/03/12 20:25:06 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/int8.c,v 1.59 2005/10/15 02:49:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -59,8 +59,8 @@ scanint8(const char *str, bool errorOK, int64 *result) int sign = 1; /* - * Do our own scan, rather than relying on sscanf which might be - * broken for long long. + * Do our own scan, rather than relying on sscanf which might be broken + * for long long. */ /* skip leading spaces */ @@ -74,8 +74,7 @@ scanint8(const char *str, bool errorOK, int64 *result) /* * Do an explicit check for INT64_MIN. Ugly though this is, it's - * cleaner than trying to get the loop below to handle it - * portably. + * cleaner than trying to get the loop below to handle it portably. */ #ifndef INT64_IS_BUSTED if (strncmp(ptr, "9223372036854775808", 19) == 0) @@ -115,8 +114,8 @@ scanint8(const char *str, bool errorOK, int64 *result) else ereport(ERROR, (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), - errmsg("value \"%s\" is out of range for type bigint", - str))); + errmsg("value \"%s\" is out of range for type bigint", + str))); } tmp = newtmp; } @@ -524,10 +523,11 @@ int8pl(PG_FUNCTION_ARGS) int64 result; result = arg1 + arg2; + /* - * Overflow check. If the inputs are of different signs then their sum - * cannot overflow. If the inputs are of the same sign, their sum - * had better be that sign too. + * Overflow check. If the inputs are of different signs then their sum + * cannot overflow. If the inputs are of the same sign, their sum had + * better be that sign too. */ if (SAMESIGN(arg1, arg2) && !SAMESIGN(result, arg1)) ereport(ERROR, @@ -544,10 +544,11 @@ int8mi(PG_FUNCTION_ARGS) int64 result; result = arg1 - arg2; + /* - * Overflow check. If the inputs are of the same sign then their - * difference cannot overflow. If they are of different signs then - * the result should be of the same sign as the first input. + * Overflow check. If the inputs are of the same sign then their + * difference cannot overflow. If they are of different signs then the + * result should be of the same sign as the first input. */ if (!SAMESIGN(arg1, arg2) && !SAMESIGN(result, arg1)) ereport(ERROR, @@ -564,21 +565,22 @@ int8mul(PG_FUNCTION_ARGS) int64 result; result = arg1 * arg2; + /* - * Overflow check. We basically check to see if result / arg2 gives - * arg1 again. There are two cases where this fails: arg2 = 0 (which - * cannot overflow) and arg1 = INT64_MIN, arg2 = -1 (where the division - * itself will overflow and thus incorrectly match). + * Overflow check. We basically check to see if result / arg2 gives arg1 + * again. There are two cases where this fails: arg2 = 0 (which cannot + * overflow) and arg1 = INT64_MIN, arg2 = -1 (where the division itself + * will overflow and thus incorrectly match). * * Since the division is likely much more expensive than the actual - * multiplication, we'd like to skip it where possible. The best - * bang for the buck seems to be to check whether both inputs are in - * the int32 range; if so, no overflow is possible. + * multiplication, we'd like to skip it where possible. The best bang for + * the buck seems to be to check whether both inputs are in the int32 + * range; if so, no overflow is possible. */ if (!(arg1 == (int64) ((int32) arg1) && arg2 == (int64) ((int32) arg2)) && arg2 != 0 && - (result/arg2 != arg1 || (arg2 == -1 && arg1 < 0 && result < 0))) + (result / arg2 != arg1 || (arg2 == -1 && arg1 < 0 && result < 0))) ereport(ERROR, (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), errmsg("bigint out of range"))); @@ -598,10 +600,11 @@ int8div(PG_FUNCTION_ARGS) errmsg("division by zero"))); result = arg1 / arg2; + /* - * Overflow check. The only possible overflow case is for - * arg1 = INT64_MIN, arg2 = -1, where the correct result is -INT64_MIN, - * which can't be represented on a two's-complement machine. + * Overflow check. The only possible overflow case is for arg1 = + * INT64_MIN, arg2 = -1, where the correct result is -INT64_MIN, which + * can't be represented on a two's-complement machine. */ if (arg2 == -1 && arg1 < 0 && result < 0) ereport(ERROR, @@ -653,9 +656,9 @@ int8inc(PG_FUNCTION_ARGS) if (fcinfo->context && IsA(fcinfo->context, AggState)) { /* - * Special case to avoid palloc overhead for COUNT(): when called - * from nodeAgg, we know that the argument is modifiable local - * storage, so just update it in-place. + * Special case to avoid palloc overhead for COUNT(): when called from + * nodeAgg, we know that the argument is modifiable local storage, so + * just update it in-place. * * Note: this assumes int8 is a pass-by-ref type; if we ever support * pass-by-val int8, this should be ifdef'd out when int8 is @@ -723,10 +726,11 @@ int84pl(PG_FUNCTION_ARGS) int64 result; result = arg1 + arg2; + /* - * Overflow check. If the inputs are of different signs then their sum - * cannot overflow. If the inputs are of the same sign, their sum - * had better be that sign too. + * Overflow check. If the inputs are of different signs then their sum + * cannot overflow. If the inputs are of the same sign, their sum had + * better be that sign too. */ if (SAMESIGN(arg1, arg2) && !SAMESIGN(result, arg1)) ereport(ERROR, @@ -743,10 +747,11 @@ int84mi(PG_FUNCTION_ARGS) int64 result; result = arg1 - arg2; + /* - * Overflow check. If the inputs are of the same sign then their - * difference cannot overflow. If they are of different signs then - * the result should be of the same sign as the first input. + * Overflow check. If the inputs are of the same sign then their + * difference cannot overflow. If they are of different signs then the + * result should be of the same sign as the first input. */ if (!SAMESIGN(arg1, arg2) && !SAMESIGN(result, arg1)) ereport(ERROR, @@ -763,18 +768,19 @@ int84mul(PG_FUNCTION_ARGS) int64 result; result = arg1 * arg2; + /* - * Overflow check. We basically check to see if result / arg1 gives - * arg2 again. There is one case where this fails: arg1 = 0 (which - * cannot overflow). + * Overflow check. We basically check to see if result / arg1 gives arg2 + * again. There is one case where this fails: arg1 = 0 (which cannot + * overflow). * * Since the division is likely much more expensive than the actual - * multiplication, we'd like to skip it where possible. The best - * bang for the buck seems to be to check whether both inputs are in - * the int32 range; if so, no overflow is possible. + * multiplication, we'd like to skip it where possible. The best bang for + * the buck seems to be to check whether both inputs are in the int32 + * range; if so, no overflow is possible. */ if (arg1 != (int64) ((int32) arg1) && - result/arg1 != arg2) + result / arg1 != arg2) ereport(ERROR, (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), errmsg("bigint out of range"))); @@ -794,10 +800,11 @@ int84div(PG_FUNCTION_ARGS) errmsg("division by zero"))); result = arg1 / arg2; + /* - * Overflow check. The only possible overflow case is for - * arg1 = INT64_MIN, arg2 = -1, where the correct result is -INT64_MIN, - * which can't be represented on a two's-complement machine. + * Overflow check. The only possible overflow case is for arg1 = + * INT64_MIN, arg2 = -1, where the correct result is -INT64_MIN, which + * can't be represented on a two's-complement machine. */ if (arg2 == -1 && arg1 < 0 && result < 0) ereport(ERROR, @@ -814,10 +821,11 @@ int48pl(PG_FUNCTION_ARGS) int64 result; result = arg1 + arg2; + /* - * Overflow check. If the inputs are of different signs then their sum - * cannot overflow. If the inputs are of the same sign, their sum - * had better be that sign too. + * Overflow check. If the inputs are of different signs then their sum + * cannot overflow. If the inputs are of the same sign, their sum had + * better be that sign too. */ if (SAMESIGN(arg1, arg2) && !SAMESIGN(result, arg1)) ereport(ERROR, @@ -834,10 +842,11 @@ int48mi(PG_FUNCTION_ARGS) int64 result; result = arg1 - arg2; + /* - * Overflow check. If the inputs are of the same sign then their - * difference cannot overflow. If they are of different signs then - * the result should be of the same sign as the first input. + * Overflow check. If the inputs are of the same sign then their + * difference cannot overflow. If they are of different signs then the + * result should be of the same sign as the first input. */ if (!SAMESIGN(arg1, arg2) && !SAMESIGN(result, arg1)) ereport(ERROR, @@ -854,18 +863,19 @@ int48mul(PG_FUNCTION_ARGS) int64 result; result = arg1 * arg2; + /* - * Overflow check. We basically check to see if result / arg2 gives - * arg1 again. There is one case where this fails: arg2 = 0 (which - * cannot overflow). + * Overflow check. We basically check to see if result / arg2 gives arg1 + * again. There is one case where this fails: arg2 = 0 (which cannot + * overflow). * * Since the division is likely much more expensive than the actual - * multiplication, we'd like to skip it where possible. The best - * bang for the buck seems to be to check whether both inputs are in - * the int32 range; if so, no overflow is possible. + * multiplication, we'd like to skip it where possible. The best bang for + * the buck seems to be to check whether both inputs are in the int32 + * range; if so, no overflow is possible. */ if (arg2 != (int64) ((int32) arg2) && - result/arg2 != arg1) + result / arg2 != arg1) ereport(ERROR, (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), errmsg("bigint out of range"))); @@ -1027,9 +1037,9 @@ dtoi8(PG_FUNCTION_ARGS) arg = rint(arg); /* - * Does it fit in an int64? Avoid assuming that we have handy - * constants defined for the range boundaries, instead test for - * overflow by reverse-conversion. + * Does it fit in an int64? Avoid assuming that we have handy constants + * defined for the range boundaries, instead test for overflow by + * reverse-conversion. */ result = (int64) arg; @@ -1066,9 +1076,9 @@ ftoi8(PG_FUNCTION_ARGS) darg = rint(arg); /* - * Does it fit in an int64? Avoid assuming that we have handy - * constants defined for the range boundaries, instead test for - * overflow by reverse-conversion. + * Does it fit in an int64? Avoid assuming that we have handy constants + * defined for the range boundaries, instead test for overflow by + * reverse-conversion. */ result = (int64) darg; @@ -1183,8 +1193,7 @@ generate_series_step_int8(PG_FUNCTION_ARGS) funcctx = SRF_FIRSTCALL_INIT(); /* - * switch to memory context appropriate for multiple function - * calls + * switch to memory context appropriate for multiple function calls */ oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); @@ -1207,8 +1216,7 @@ generate_series_step_int8(PG_FUNCTION_ARGS) funcctx = SRF_PERCALL_SETUP(); /* - * get the saved state and use current as the result for this - * iteration + * get the saved state and use current as the result for this iteration */ fctx = funcctx->user_fctx; result = fctx->current; diff --git a/src/backend/utils/adt/like.c b/src/backend/utils/adt/like.c index 1e84474c2a..4bf2cd3387 100644 --- a/src/backend/utils/adt/like.c +++ b/src/backend/utils/adt/like.c @@ -11,7 +11,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/like.c,v 1.61 2005/09/24 17:53:15 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/like.c,v 1.62 2005/10/15 02:49:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -28,13 +28,13 @@ #define LIKE_ABORT (-1) -static int MatchText(char *t, int tlen, char *p, int plen); -static int MatchTextIC(char *t, int tlen, char *p, int plen); -static int MatchBytea(char *t, int tlen, char *p, int plen); +static int MatchText(char *t, int tlen, char *p, int plen); +static int MatchTextIC(char *t, int tlen, char *p, int plen); +static int MatchBytea(char *t, int tlen, char *p, int plen); static text *do_like_escape(text *, text *); -static int MBMatchText(char *t, int tlen, char *p, int plen); -static int MBMatchTextIC(char *t, int tlen, char *p, int plen); +static int MBMatchText(char *t, int tlen, char *p, int plen); +static int MBMatchTextIC(char *t, int tlen, char *p, int plen); static text *MB_do_like_escape(text *, text *); /*-------------------- @@ -48,7 +48,7 @@ wchareq(char *p1, char *p2) int p1_len; /* Optimization: quickly compare the first byte. */ - if(*p1 != *p2) + if (*p1 != *p2) return (0); p1_len = pg_mblen(p1); @@ -80,15 +80,15 @@ iwchareq(char *p1, char *p2) int l; /* - * short cut. if *p1 and *p2 is lower than CHARMAX, then we could - * assume they are ASCII + * short cut. if *p1 and *p2 is lower than CHARMAX, then we could assume + * they are ASCII */ if ((unsigned char) *p1 < CHARMAX && (unsigned char) *p2 < CHARMAX) return (tolower((unsigned char) *p1) == tolower((unsigned char) *p2)); /* - * if one of them is an ASCII while the other is not, then they must - * be different characters + * if one of them is an ASCII while the other is not, then they must be + * different characters */ else if ((unsigned char) *p1 < CHARMAX || (unsigned char) *p2 < CHARMAX) return (0); @@ -452,7 +452,7 @@ like_escape_bytea(PG_FUNCTION_ARGS) ereport(ERROR, (errcode(ERRCODE_INVALID_ESCAPE_SEQUENCE), errmsg("invalid escape string"), - errhint("Escape string must be empty or one character."))); + errhint("Escape string must be empty or one character."))); e = VARDATA(esc); @@ -466,9 +466,9 @@ like_escape_bytea(PG_FUNCTION_ARGS) } /* - * Otherwise, convert occurrences of the specified escape - * character to '\', and double occurrences of '\' --- unless they - * immediately follow an escape character! + * Otherwise, convert occurrences of the specified escape character to + * '\', and double occurrences of '\' --- unless they immediately + * follow an escape character! */ afterescape = false; while (plen > 0) @@ -530,8 +530,8 @@ MatchBytea(char *t, int tlen, char *p, int plen) return LIKE_TRUE; /* - * Otherwise, scan for a text position at which we can match - * the rest of the pattern. + * Otherwise, scan for a text position at which we can match the + * rest of the pattern. */ while (tlen > 0) { @@ -551,16 +551,16 @@ MatchBytea(char *t, int tlen, char *p, int plen) } /* - * End of text with no match, so no point in trying later - * places to start matching this pattern. + * End of text with no match, so no point in trying later places + * to start matching this pattern. */ return LIKE_ABORT; } else if ((*p != '_') && !BYTEA_CHAREQ(t, p)) { /* - * Not the single-character wildcard and no explicit match? - * Then time to quit... + * Not the single-character wildcard and no explicit match? Then + * time to quit... */ return LIKE_FALSE; } @@ -580,8 +580,8 @@ MatchBytea(char *t, int tlen, char *p, int plen) return LIKE_TRUE; /* - * End of text with no match, so no point in trying later places to - * start matching this pattern. + * End of text with no match, so no point in trying later places to start + * matching this pattern. */ return LIKE_ABORT; } /* MatchBytea() */ diff --git a/src/backend/utils/adt/like_match.c b/src/backend/utils/adt/like_match.c index 94ad799761..dc78e89f95 100644 --- a/src/backend/utils/adt/like_match.c +++ b/src/backend/utils/adt/like_match.c @@ -19,7 +19,7 @@ * Copyright (c) 1996-2005, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/like_match.c,v 1.11 2005/09/24 17:53:15 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/like_match.c,v 1.12 2005/10/15 02:49:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -97,8 +97,8 @@ MatchText(char *t, int tlen, char *p, int plen) return LIKE_TRUE; /* - * Otherwise, scan for a text position at which we can match - * the rest of the pattern. + * Otherwise, scan for a text position at which we can match the + * rest of the pattern. */ while (tlen > 0) { @@ -118,16 +118,16 @@ MatchText(char *t, int tlen, char *p, int plen) } /* - * End of text with no match, so no point in trying later - * places to start matching this pattern. + * End of text with no match, so no point in trying later places + * to start matching this pattern. */ return LIKE_ABORT; } else if ((*p != '_') && !CHAREQ(t, p)) { /* - * Not the single-character wildcard and no explicit match? - * Then time to quit... + * Not the single-character wildcard and no explicit match? Then + * time to quit... */ return LIKE_FALSE; } @@ -147,8 +147,8 @@ MatchText(char *t, int tlen, char *p, int plen) return LIKE_TRUE; /* - * End of text with no match, so no point in trying later places to - * start matching this pattern. + * End of text with no match, so no point in trying later places to start + * matching this pattern. */ return LIKE_ABORT; } /* MatchText() */ @@ -183,8 +183,8 @@ MatchTextIC(char *t, int tlen, char *p, int plen) return LIKE_TRUE; /* - * Otherwise, scan for a text position at which we can match - * the rest of the pattern. + * Otherwise, scan for a text position at which we can match the + * rest of the pattern. */ while (tlen > 0) { @@ -204,16 +204,16 @@ MatchTextIC(char *t, int tlen, char *p, int plen) } /* - * End of text with no match, so no point in trying later - * places to start matching this pattern. + * End of text with no match, so no point in trying later places + * to start matching this pattern. */ return LIKE_ABORT; } else if ((*p != '_') && !ICHAREQ(t, p)) { /* - * Not the single-character wildcard and no explicit match? - * Then time to quit... + * Not the single-character wildcard and no explicit match? Then + * time to quit... */ return LIKE_FALSE; } @@ -233,8 +233,8 @@ MatchTextIC(char *t, int tlen, char *p, int plen) return LIKE_TRUE; /* - * End of text with no match, so no point in trying later places to - * start matching this pattern. + * End of text with no match, so no point in trying later places to start + * matching this pattern. */ return LIKE_ABORT; } /* MatchTextIC() */ @@ -289,7 +289,7 @@ do_like_escape(text *pat, text *esc) ereport(ERROR, (errcode(ERRCODE_INVALID_ESCAPE_SEQUENCE), errmsg("invalid escape string"), - errhint("Escape string must be empty or one character."))); + errhint("Escape string must be empty or one character."))); e = VARDATA(esc); @@ -303,9 +303,9 @@ do_like_escape(text *pat, text *esc) } /* - * Otherwise, convert occurrences of the specified escape - * character to '\', and double occurrences of '\' --- unless they - * immediately follow an escape character! + * Otherwise, convert occurrences of the specified escape character to + * '\', and double occurrences of '\' --- unless they immediately + * follow an escape character! */ afterescape = false; while (plen > 0) diff --git a/src/backend/utils/adt/lockfuncs.c b/src/backend/utils/adt/lockfuncs.c index 0bdf918e47..bf7ee788c4 100644 --- a/src/backend/utils/adt/lockfuncs.c +++ b/src/backend/utils/adt/lockfuncs.c @@ -6,7 +6,7 @@ * Copyright (c) 2002-2005, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/lockfuncs.c,v 1.19 2005/06/18 19:33:42 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/lockfuncs.c,v 1.20 2005/10/15 02:49:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -21,7 +21,7 @@ /* This must match enum LockTagType! */ -static const char * const LockTagTypeNames[] = { +static const char *const LockTagTypeNames[] = { "relation", "extend", "page", @@ -57,8 +57,7 @@ pg_lock_status(PG_FUNCTION_ARGS) funcctx = SRF_FIRSTCALL_INIT(); /* - * switch to memory context appropriate for multiple function - * calls + * switch to memory context appropriate for multiple function calls */ oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); @@ -95,8 +94,8 @@ pg_lock_status(PG_FUNCTION_ARGS) funcctx->tuple_desc = BlessTupleDesc(tupdesc); /* - * Collect all the locking information that we will format and - * send out as a result set. + * Collect all the locking information that we will format and send + * out as a result set. */ mystatus = (PG_Lock_Status *) palloc(sizeof(PG_Lock_Status)); funcctx->user_fctx = (void *) mystatus; @@ -130,9 +129,9 @@ pg_lock_status(PG_FUNCTION_ARGS) proc = &(lockData->procs[mystatus->currIdx]); /* - * Look to see if there are any held lock modes in this PROCLOCK. - * If so, report, and destructively modify lockData so we don't - * report again. + * Look to see if there are any held lock modes in this PROCLOCK. If + * so, report, and destructively modify lockData so we don't report + * again. */ granted = false; if (proclock->holdMask) @@ -160,16 +159,16 @@ pg_lock_status(PG_FUNCTION_ARGS) mode = proc->waitLockMode; /* - * We are now done with this PROCLOCK, so advance pointer - * to continue with next one on next call. + * We are now done with this PROCLOCK, so advance pointer to + * continue with next one on next call. */ mystatus->currIdx++; } else { /* - * Okay, we've displayed all the locks associated with - * this PROCLOCK, proceed to the next one. + * Okay, we've displayed all the locks associated with this + * PROCLOCK, proceed to the next one. */ mystatus->currIdx++; continue; @@ -191,7 +190,7 @@ pg_lock_status(PG_FUNCTION_ARGS) locktypename = tnbuf; } values[0] = DirectFunctionCall1(textin, - CStringGetDatum(locktypename)); + CStringGetDatum(locktypename)); switch (lock->tag.locktag_type) @@ -257,7 +256,7 @@ pg_lock_status(PG_FUNCTION_ARGS) else nulls[10] = 'n'; values[11] = DirectFunctionCall1(textin, - CStringGetDatum(GetLockmodeName(mode))); + CStringGetDatum(GetLockmodeName(mode))); values[12] = BoolGetDatum(granted); tuple = heap_formtuple(funcctx->tuple_desc, values, nulls); diff --git a/src/backend/utils/adt/mac.c b/src/backend/utils/adt/mac.c index 4d62c6e025..c974b633ca 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. * - * $PostgreSQL: pgsql/src/backend/utils/adt/mac.c,v 1.34 2004/08/29 05:06:49 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/mac.c,v 1.35 2005/10/15 02:49:28 momjian Exp $ */ #include "postgres.h" @@ -62,14 +62,14 @@ macaddr_in(PG_FUNCTION_ARGS) if (count != 6) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type macaddr: \"%s\"", str))); + errmsg("invalid input syntax for type macaddr: \"%s\"", str))); if ((a < 0) || (a > 255) || (b < 0) || (b > 255) || (c < 0) || (c > 255) || (d < 0) || (d > 255) || (e < 0) || (e > 255) || (f < 0) || (f > 255)) ereport(ERROR, (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), - errmsg("invalid octet value in \"macaddr\" value: \"%s\"", str))); + errmsg("invalid octet value in \"macaddr\" value: \"%s\"", str))); result = (macaddr *) palloc(sizeof(macaddr)); diff --git a/src/backend/utils/adt/misc.c b/src/backend/utils/adt/misc.c index 88f776df06..14bb593c2c 100644 --- a/src/backend/utils/adt/misc.c +++ b/src/backend/utils/adt/misc.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/misc.c,v 1.48 2005/09/16 05:35:40 neilc Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/misc.c,v 1.49 2005/10/15 02:49:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -79,16 +79,16 @@ pg_signal_backend(int pid, int sig) if (!superuser()) ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), - (errmsg("must be superuser to signal other server processes")))); + (errmsg("must be superuser to signal other server processes")))); if (!IsBackendPid(pid)) { /* - * This is just a warning so a loop-through-resultset will not - * abort if one backend terminated on it's own during the run + * This is just a warning so a loop-through-resultset will not abort + * if one backend terminated on it's own during the run */ ereport(WARNING, - (errmsg("PID %d is not a PostgreSQL server process", pid))); + (errmsg("PID %d is not a PostgreSQL server process", pid))); return false; } @@ -111,7 +111,7 @@ pg_cancel_backend(PG_FUNCTION_ARGS) Datum pg_reload_conf(PG_FUNCTION_ARGS) { - if (!superuser()) + if (!superuser()) ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), (errmsg("must be superuser to signal the postmaster")))); @@ -133,7 +133,7 @@ pg_reload_conf(PG_FUNCTION_ARGS) Datum pg_rotate_logfile(PG_FUNCTION_ARGS) { - if (!superuser()) + if (!superuser()) ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), (errmsg("must be superuser to rotate log files")))); @@ -141,7 +141,7 @@ pg_rotate_logfile(PG_FUNCTION_ARGS) if (!Redirect_stderr) { ereport(WARNING, - (errmsg("rotation not possible because log redirection not active"))); + (errmsg("rotation not possible because log redirection not active"))); PG_RETURN_BOOL(false); } @@ -186,8 +186,7 @@ pg_tablespace_databases(PG_FUNCTION_ARGS) fctx = palloc(sizeof(ts_db_fctx)); /* - * size = tablespace dirname length + dir sep - * char + oid + terminator + * size = tablespace dirname length + dir sep char + oid + terminator */ fctx->location = (char *) palloc(10 + 10 + 1); if (tablespaceOid == GLOBALTABLESPACE_OID) @@ -214,7 +213,7 @@ pg_tablespace_databases(PG_FUNCTION_ARGS) errmsg("could not open directory \"%s\": %m", fctx->location))); ereport(WARNING, - (errmsg("%u is not a tablespace OID", tablespaceOid))); + (errmsg("%u is not a tablespace OID", tablespaceOid))); } } funcctx->user_fctx = fctx; diff --git a/src/backend/utils/adt/nabstime.c b/src/backend/utils/adt/nabstime.c index 148ee0abb1..40e7522b87 100644 --- a/src/backend/utils/adt/nabstime.c +++ b/src/backend/utils/adt/nabstime.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/nabstime.c,v 1.144 2005/10/14 11:47:57 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/nabstime.c,v 1.145 2005/10/15 02:49:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -77,11 +77,11 @@ * Function prototypes -- internal to this file only */ -static AbsoluteTime tm2abstime(struct pg_tm *tm, int tz); -static void reltime2tm(RelativeTime time, struct pg_tm *tm); +static AbsoluteTime tm2abstime(struct pg_tm * tm, int tz); +static void reltime2tm(RelativeTime time, struct pg_tm * tm); static void parsetinterval(char *i_string, - AbsoluteTime *i_start, - AbsoluteTime *i_end); + AbsoluteTime *i_start, + AbsoluteTime *i_end); /* @@ -100,21 +100,21 @@ GetCurrentAbsoluteTime(void) void -abstime2tm(AbsoluteTime _time, int *tzp, struct pg_tm *tm, char **tzn) +abstime2tm(AbsoluteTime _time, int *tzp, struct pg_tm * tm, char **tzn) { pg_time_t time = (pg_time_t) _time; struct pg_tm *tx; /* - * If HasCTZSet is true then we have a brute force time zone - * specified. Go ahead and rotate to the local time zone since we will - * later bypass any calls which adjust the tm fields. + * If HasCTZSet is true then we have a brute force time zone specified. Go + * ahead and rotate to the local time zone since we will later bypass any + * calls which adjust the tm fields. */ if (HasCTZSet && (tzp != NULL)) time -= CTimeZone; if (!HasCTZSet && tzp != NULL) - tx = pg_localtime(&time,global_timezone); + tx = pg_localtime(&time, global_timezone); else tx = pg_gmtime(&time); @@ -156,8 +156,8 @@ abstime2tm(AbsoluteTime _time, int *tzp, struct pg_tm *tm, char **tzn) { /* * Copy no more than MAXTZLEN bytes of timezone to tzn, in - * case it contains an error message, which doesn't fit in - * the buffer + * case it contains an error message, which doesn't fit in the + * buffer */ StrNCpy(*tzn, tm->tm_zone, MAXTZLEN + 1); if (strlen(tm->tm_zone) > MAXTZLEN) @@ -178,7 +178,7 @@ abstime2tm(AbsoluteTime _time, int *tzp, struct pg_tm *tm, char **tzn) * Note that tm has full year (not 1900-based) and 1-based month. */ static AbsoluteTime -tm2abstime(struct pg_tm *tm, int tz) +tm2abstime(struct pg_tm * tm, int tz) { int day; AbsoluteTime sec; @@ -188,7 +188,7 @@ tm2abstime(struct pg_tm *tm, int tz) tm->tm_mon < 1 || tm->tm_mon > 12 || tm->tm_mday < 1 || tm->tm_mday > 31 || tm->tm_hour < 0 || - tm->tm_hour > 24 || /* test for > 24:00:00 */ + tm->tm_hour > 24 || /* test for > 24:00:00 */ (tm->tm_hour == 24 && (tm->tm_min > 0 || tm->tm_sec > 0)) || tm->tm_min < 0 || tm->tm_min > 59 || tm->tm_sec < 0 || tm->tm_sec > 60) @@ -204,11 +204,11 @@ tm2abstime(struct pg_tm *tm, int tz) sec = tm->tm_sec + tz + (tm->tm_min + (day * HOURS_PER_DAY + tm->tm_hour) * MINS_PER_HOUR) * SECS_PER_MINUTE; /* - * check for overflow. We need a little slop here because the H/M/S plus + * check for overflow. We need a little slop here because the H/M/S plus * TZ offset could add up to more than 1 day. */ - if ((day >= MAX_DAYNUM-10 && sec < 0) || - (day <= MIN_DAYNUM+10 && sec > 0)) + if ((day >= MAX_DAYNUM - 10 && sec < 0) || + (day <= MIN_DAYNUM + 10 && sec > 0)) return INVALID_ABSTIME; /* check for reserved values (e.g. "current" on edge of usual range */ @@ -254,8 +254,8 @@ abstimein(PG_FUNCTION_ARGS) case DTK_EPOCH: /* - * Don't bother retaining this as a reserved value, but - * instead just set to the actual epoch time (1970-01-01) + * Don't bother retaining this as a reserved value, but instead + * just set to the actual epoch time (1970-01-01) */ result = 0; break; @@ -370,9 +370,9 @@ static int abstime_cmp_internal(AbsoluteTime a, AbsoluteTime b) { /* - * We consider all INVALIDs to be equal and larger than any - * non-INVALID. This is somewhat arbitrary; the important thing is to - * have a consistent sort order. + * We consider all INVALIDs to be equal and larger than any non-INVALID. + * This is somewhat arbitrary; the important thing is to have a consistent + * sort order. */ if (a == INVALID_ABSTIME) { @@ -463,7 +463,7 @@ btabstimecmp(PG_FUNCTION_ARGS) Datum timestamp_abstime(PG_FUNCTION_ARGS) { - Timestamp timestamp = PG_GETARG_TIMESTAMP(0); + Timestamp timestamp = PG_GETARG_TIMESTAMP(0); AbsoluteTime result; fsec_t fsec; int tz; @@ -509,7 +509,7 @@ abstime_timestamp(PG_FUNCTION_ARGS) case INVALID_ABSTIME: ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot convert abstime \"invalid\" to timestamp"))); + errmsg("cannot convert abstime \"invalid\" to timestamp"))); TIMESTAMP_NOBEGIN(result); break; @@ -582,7 +582,7 @@ abstime_timestamptz(PG_FUNCTION_ARGS) case INVALID_ABSTIME: ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot convert abstime \"invalid\" to timestamp"))); + errmsg("cannot convert abstime \"invalid\" to timestamp"))); TIMESTAMP_NOBEGIN(result); break; @@ -703,7 +703,7 @@ reltimesend(PG_FUNCTION_ARGS) static void -reltime2tm(RelativeTime time, struct pg_tm *tm) +reltime2tm(RelativeTime time, struct pg_tm * tm) { double dtime = time; @@ -764,12 +764,12 @@ tintervalout(PG_FUNCTION_ARGS) else { p = DatumGetCString(DirectFunctionCall1(abstimeout, - AbsoluteTimeGetDatum(tinterval->data[0]))); + AbsoluteTimeGetDatum(tinterval->data[0]))); strcat(i_str, p); pfree(p); strcat(i_str, "\" \""); p = DatumGetCString(DirectFunctionCall1(abstimeout, - AbsoluteTimeGetDatum(tinterval->data[1]))); + AbsoluteTimeGetDatum(tinterval->data[1]))); strcat(i_str, p); pfree(p); } @@ -788,16 +788,16 @@ tintervalrecv(PG_FUNCTION_ARGS) tinterval = (TimeInterval) palloc(sizeof(TimeIntervalData)); - tinterval ->status = pq_getmsgint(buf, sizeof(tinterval->status)); + tinterval->status = pq_getmsgint(buf, sizeof(tinterval->status)); if (!(tinterval->status == T_INTERVAL_INVAL || tinterval->status == T_INTERVAL_VALID)) ereport(ERROR, (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION), - errmsg("invalid status in external \"tinterval\" value"))); + errmsg("invalid status in external \"tinterval\" value"))); - tinterval ->data[0] = pq_getmsgint(buf, sizeof(tinterval->data[0])); - tinterval ->data[1] = pq_getmsgint(buf, sizeof(tinterval->data[1])); + tinterval->data[0] = pq_getmsgint(buf, sizeof(tinterval->data[0])); + tinterval->data[1] = pq_getmsgint(buf, sizeof(tinterval->data[1])); PG_RETURN_TIMEINTERVAL(tinterval); } @@ -844,11 +844,11 @@ interval_reltime(PG_FUNCTION_ARGS) #ifdef HAVE_INT64_TIMESTAMP span = ((INT64CONST(365250000) * year + INT64CONST(30000000) * month + - INT64CONST(1000000) * day) * INT64CONST(86400)) + - interval->time; + INT64CONST(1000000) * day) * INT64CONST(86400)) + + interval->time; span /= USECS_PER_SEC; #else - span = (DAYS_PER_YEAR * year + (double)DAYS_PER_MONTH * month + day) * SECS_PER_DAY + interval->time; + span = (DAYS_PER_YEAR * year + (double) DAYS_PER_MONTH * month + day) * SECS_PER_DAY + interval->time; #endif if (span < INT_MIN || span > INT_MAX) @@ -876,7 +876,7 @@ reltime_interval(PG_FUNCTION_ARGS) case INVALID_RELTIME: ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot convert reltime \"invalid\" to interval"))); + errmsg("cannot convert reltime \"invalid\" to interval"))); result->time = 0; result->day = 0; result->month = 0; @@ -954,7 +954,7 @@ timepl(PG_FUNCTION_ARGS) if (AbsoluteTimeIsReal(t1) && RelativeTimeIsValid(t2) && ((t2 > 0 && t1 < NOEND_ABSTIME - t2) || - (t2 <= 0 && t1 > NOSTART_ABSTIME - t2))) /* prevent overflow */ + (t2 <= 0 && t1 > NOSTART_ABSTIME - t2))) /* prevent overflow */ PG_RETURN_ABSOLUTETIME(t1 + t2); PG_RETURN_ABSOLUTETIME(INVALID_ABSTIME); @@ -973,7 +973,7 @@ timemi(PG_FUNCTION_ARGS) if (AbsoluteTimeIsReal(t1) && RelativeTimeIsValid(t2) && ((t2 > 0 && t1 > NOSTART_ABSTIME + t2) || - (t2 <= 0 && t1 < NOEND_ABSTIME + t2))) /* prevent overflow */ + (t2 <= 0 && t1 < NOEND_ABSTIME + t2))) /* prevent overflow */ PG_RETURN_ABSOLUTETIME(t1 - t2); PG_RETURN_ABSOLUTETIME(INVALID_ABSTIME); @@ -993,10 +993,10 @@ intinterval(PG_FUNCTION_ARGS) { if (DatumGetBool(DirectFunctionCall2(abstimege, AbsoluteTimeGetDatum(t), - AbsoluteTimeGetDatum(tinterval->data[0]))) && + AbsoluteTimeGetDatum(tinterval->data[0]))) && DatumGetBool(DirectFunctionCall2(abstimele, AbsoluteTimeGetDatum(t), - AbsoluteTimeGetDatum(tinterval->data[1])))) + AbsoluteTimeGetDatum(tinterval->data[1])))) PG_RETURN_BOOL(true); } PG_RETURN_BOOL(false); @@ -1046,9 +1046,9 @@ static int reltime_cmp_internal(RelativeTime a, RelativeTime b) { /* - * We consider all INVALIDs to be equal and larger than any - * non-INVALID. This is somewhat arbitrary; the important thing is to - * have a consistent sort order. + * We consider all INVALIDs to be equal and larger than any non-INVALID. + * This is somewhat arbitrary; the important thing is to have a consistent + * sort order. */ if (a == INVALID_RELTIME) { @@ -1147,11 +1147,11 @@ tintervalsame(PG_FUNCTION_ARGS) PG_RETURN_BOOL(false); if (DatumGetBool(DirectFunctionCall2(abstimeeq, - AbsoluteTimeGetDatum(i1->data[0]), - AbsoluteTimeGetDatum(i2->data[0]))) && + AbsoluteTimeGetDatum(i1->data[0]), + AbsoluteTimeGetDatum(i2->data[0]))) && DatumGetBool(DirectFunctionCall2(abstimeeq, - AbsoluteTimeGetDatum(i1->data[1]), - AbsoluteTimeGetDatum(i2->data[1])))) + AbsoluteTimeGetDatum(i1->data[1]), + AbsoluteTimeGetDatum(i2->data[1])))) PG_RETURN_BOOL(true); PG_RETURN_BOOL(false); } @@ -1172,16 +1172,16 @@ tinterval_cmp_internal(TimeInterval a, TimeInterval b) AbsoluteTime b_len; /* - * We consider all INVALIDs to be equal and larger than any - * non-INVALID. This is somewhat arbitrary; the important thing is to - * have a consistent sort order. + * We consider all INVALIDs to be equal and larger than any non-INVALID. + * This is somewhat arbitrary; the important thing is to have a consistent + * sort order. */ a_invalid = a->status == T_INTERVAL_INVAL || - a->data[0] == INVALID_ABSTIME || - a->data[1] == INVALID_ABSTIME; + a->data[0] == INVALID_ABSTIME || + a->data[1] == INVALID_ABSTIME; b_invalid = b->status == T_INTERVAL_INVAL || - b->data[0] == INVALID_ABSTIME || - b->data[1] == INVALID_ABSTIME; + b->data[0] == INVALID_ABSTIME || + b->data[1] == INVALID_ABSTIME; if (a_invalid) { @@ -1293,7 +1293,7 @@ tintervalleneq(PG_FUNCTION_ARGS) if (i->status == T_INTERVAL_INVAL || t == INVALID_RELTIME) PG_RETURN_BOOL(false); rt = DatumGetRelativeTime(DirectFunctionCall1(tintervalrel, - TimeIntervalGetDatum(i))); + TimeIntervalGetDatum(i))); PG_RETURN_BOOL(rt != INVALID_RELTIME && rt == t); } @@ -1307,7 +1307,7 @@ tintervallenne(PG_FUNCTION_ARGS) if (i->status == T_INTERVAL_INVAL || t == INVALID_RELTIME) PG_RETURN_BOOL(false); rt = DatumGetRelativeTime(DirectFunctionCall1(tintervalrel, - TimeIntervalGetDatum(i))); + TimeIntervalGetDatum(i))); PG_RETURN_BOOL(rt != INVALID_RELTIME && rt != t); } @@ -1321,7 +1321,7 @@ tintervallenlt(PG_FUNCTION_ARGS) if (i->status == T_INTERVAL_INVAL || t == INVALID_RELTIME) PG_RETURN_BOOL(false); rt = DatumGetRelativeTime(DirectFunctionCall1(tintervalrel, - TimeIntervalGetDatum(i))); + TimeIntervalGetDatum(i))); PG_RETURN_BOOL(rt != INVALID_RELTIME && rt < t); } @@ -1335,7 +1335,7 @@ tintervallengt(PG_FUNCTION_ARGS) if (i->status == T_INTERVAL_INVAL || t == INVALID_RELTIME) PG_RETURN_BOOL(false); rt = DatumGetRelativeTime(DirectFunctionCall1(tintervalrel, - TimeIntervalGetDatum(i))); + TimeIntervalGetDatum(i))); PG_RETURN_BOOL(rt != INVALID_RELTIME && rt > t); } @@ -1349,7 +1349,7 @@ tintervallenle(PG_FUNCTION_ARGS) if (i->status == T_INTERVAL_INVAL || t == INVALID_RELTIME) PG_RETURN_BOOL(false); rt = DatumGetRelativeTime(DirectFunctionCall1(tintervalrel, - TimeIntervalGetDatum(i))); + TimeIntervalGetDatum(i))); PG_RETURN_BOOL(rt != INVALID_RELTIME && rt <= t); } @@ -1363,7 +1363,7 @@ tintervallenge(PG_FUNCTION_ARGS) if (i->status == T_INTERVAL_INVAL || t == INVALID_RELTIME) PG_RETURN_BOOL(false); rt = DatumGetRelativeTime(DirectFunctionCall1(tintervalrel, - TimeIntervalGetDatum(i))); + TimeIntervalGetDatum(i))); PG_RETURN_BOOL(rt != INVALID_RELTIME && rt >= t); } @@ -1379,11 +1379,11 @@ tintervalct(PG_FUNCTION_ARGS) if (i1->status == T_INTERVAL_INVAL || i2->status == T_INTERVAL_INVAL) PG_RETURN_BOOL(false); if (DatumGetBool(DirectFunctionCall2(abstimele, - AbsoluteTimeGetDatum(i1->data[0]), - AbsoluteTimeGetDatum(i2->data[0]))) && + AbsoluteTimeGetDatum(i1->data[0]), + AbsoluteTimeGetDatum(i2->data[0]))) && DatumGetBool(DirectFunctionCall2(abstimege, - AbsoluteTimeGetDatum(i1->data[1]), - AbsoluteTimeGetDatum(i2->data[1])))) + AbsoluteTimeGetDatum(i1->data[1]), + AbsoluteTimeGetDatum(i2->data[1])))) PG_RETURN_BOOL(true); PG_RETURN_BOOL(false); } @@ -1400,11 +1400,11 @@ tintervalov(PG_FUNCTION_ARGS) if (i1->status == T_INTERVAL_INVAL || i2->status == T_INTERVAL_INVAL) PG_RETURN_BOOL(false); if (DatumGetBool(DirectFunctionCall2(abstimelt, - AbsoluteTimeGetDatum(i1->data[1]), - AbsoluteTimeGetDatum(i2->data[0]))) || + AbsoluteTimeGetDatum(i1->data[1]), + AbsoluteTimeGetDatum(i2->data[0]))) || DatumGetBool(DirectFunctionCall2(abstimegt, - AbsoluteTimeGetDatum(i1->data[0]), - AbsoluteTimeGetDatum(i2->data[1])))) + AbsoluteTimeGetDatum(i1->data[0]), + AbsoluteTimeGetDatum(i2->data[1])))) PG_RETURN_BOOL(false); PG_RETURN_BOOL(true); } @@ -1492,8 +1492,7 @@ parsetinterval(char *i_string, goto bogus; /* syntax error */ p++; if (strncmp(INVALID_INTERVAL_STR, p, strlen(INVALID_INTERVAL_STR)) == 0) - goto bogus; /* undefined range, handled like a syntax - * err. */ + goto bogus; /* undefined range, handled like a syntax err. */ /* search for the end of the first date and change it to a \0 */ p1 = p; while ((c = *p1) != '\0') @@ -1507,7 +1506,7 @@ parsetinterval(char *i_string, *p1 = '\0'; /* get the first date */ *i_start = DatumGetAbsoluteTime(DirectFunctionCall1(abstimein, - CStringGetDatum(p))); + CStringGetDatum(p))); /* undo change to \0 */ *p1 = c; p = ++p1; @@ -1537,7 +1536,7 @@ parsetinterval(char *i_string, *p1 = '\0'; /* get the second date */ *i_end = DatumGetAbsoluteTime(DirectFunctionCall1(abstimein, - CStringGetDatum(p))); + CStringGetDatum(p))); /* undo change to \0 */ *p1 = c; p = ++p1; @@ -1566,7 +1565,7 @@ bogus: (errcode(ERRCODE_INVALID_DATETIME_FORMAT), errmsg("invalid input syntax for type tinterval: \"%s\"", i_string))); - *i_start = *i_end = INVALID_ABSTIME; /* keep compiler quiet */ + *i_start = *i_end = INVALID_ABSTIME; /* keep compiler quiet */ } @@ -1595,7 +1594,7 @@ timeofday(PG_FUNCTION_ARGS) gettimeofday(&tp, &tpz); tt = (pg_time_t) tp.tv_sec; pg_strftime(templ, sizeof(templ), "%a %b %d %H:%M:%S.%%06d %Y %Z", - pg_localtime(&tt,global_timezone)); + pg_localtime(&tt, global_timezone)); snprintf(buf, sizeof(buf), templ, tp.tv_usec); len = VARHDRSZ + strlen(buf); diff --git a/src/backend/utils/adt/name.c b/src/backend/utils/adt/name.c index 1200ad9b34..0a52dcfec6 100644 --- a/src/backend/utils/adt/name.c +++ b/src/backend/utils/adt/name.c @@ -14,7 +14,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/name.c,v 1.55 2004/12/31 22:01:22 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/name.c,v 1.56 2005/10/15 02:49:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -258,8 +258,8 @@ namecpy(Name n1, Name n2) int namecat(Name n1, Name n2) { - return namestrcat(n1, NameStr(*n2)); /* n2 can't be any longer - * than n1 */ + return namestrcat(n1, NameStr(*n2)); /* n2 can't be any longer than + * n1 */ } #endif diff --git a/src/backend/utils/adt/network.c b/src/backend/utils/adt/network.c index dc83d7028c..17403c5f33 100644 --- a/src/backend/utils/adt/network.c +++ b/src/backend/utils/adt/network.c @@ -1,7 +1,7 @@ /* * PostgreSQL type definitions for the INET and CIDR types. * - * $PostgreSQL: pgsql/src/backend/utils/adt/network.c,v 1.54 2004/10/08 01:10:31 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/network.c,v 1.55 2005/10/15 02:49:29 momjian Exp $ * * Jon Postel RIP 16 Oct 1998 */ @@ -74,9 +74,9 @@ network_in(char *src, int type) dst = (inet *) palloc0(VARHDRSZ + sizeof(inet_struct)); /* - * First, check to see if this is an IPv6 or IPv4 address. IPv6 - * addresses will have a : somewhere in them (several, in fact) so if - * there is one present, assume it's V6, otherwise assume it's V4. + * First, check to see if this is an IPv6 or IPv4 address. IPv6 addresses + * will have a : somewhere in them (several, in fact) so if there is one + * present, assume it's V6, otherwise assume it's V4. */ if (strchr(src, ':') != NULL) @@ -94,8 +94,7 @@ network_in(char *src, int type) type ? "cidr" : "inet", src))); /* - * Error check: CIDR values must not have any bits set beyond the - * masklen. + * Error check: CIDR values must not have any bits set beyond the masklen. */ if (type) { @@ -195,7 +194,7 @@ inet_recv(PG_FUNCTION_ARGS) ip_family(addr) != PGSQL_AF_INET6) ereport(ERROR, (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION), - errmsg("invalid address family in external \"inet\" value"))); + errmsg("invalid address family in external \"inet\" value"))); bits = pq_getmsgbyte(buf); if (bits < 0 || bits > ip_maxbits(addr)) ereport(ERROR, @@ -221,8 +220,7 @@ inet_recv(PG_FUNCTION_ARGS) addrptr[i] = pq_getmsgbyte(buf); /* - * Error check: CIDR values must not have any bits set beyond the - * masklen. + * Error check: CIDR values must not have any bits set beyond the masklen. */ if (ip_type(addr)) { @@ -457,7 +455,7 @@ network_sub(PG_FUNCTION_ARGS) if (ip_family(a1) == ip_family(a2)) { PG_RETURN_BOOL(ip_bits(a1) > ip_bits(a2) - && bitncmp(ip_addr(a1), ip_addr(a2), ip_bits(a2)) == 0); + && bitncmp(ip_addr(a1), ip_addr(a2), ip_bits(a2)) == 0); } PG_RETURN_BOOL(false); @@ -472,7 +470,7 @@ network_subeq(PG_FUNCTION_ARGS) if (ip_family(a1) == ip_family(a2)) { PG_RETURN_BOOL(ip_bits(a1) >= ip_bits(a2) - && bitncmp(ip_addr(a1), ip_addr(a2), ip_bits(a2)) == 0); + && bitncmp(ip_addr(a1), ip_addr(a2), ip_bits(a2)) == 0); } PG_RETURN_BOOL(false); @@ -487,7 +485,7 @@ network_sup(PG_FUNCTION_ARGS) if (ip_family(a1) == ip_family(a2)) { PG_RETURN_BOOL(ip_bits(a1) < ip_bits(a2) - && bitncmp(ip_addr(a1), ip_addr(a2), ip_bits(a1)) == 0); + && bitncmp(ip_addr(a1), ip_addr(a2), ip_bits(a1)) == 0); } PG_RETURN_BOOL(false); @@ -502,7 +500,7 @@ network_supeq(PG_FUNCTION_ARGS) if (ip_family(a1) == ip_family(a2)) { PG_RETURN_BOOL(ip_bits(a1) <= ip_bits(a2) - && bitncmp(ip_addr(a1), ip_addr(a2), ip_bits(a1)) == 0); + && bitncmp(ip_addr(a1), ip_addr(a2), ip_bits(a1)) == 0); } PG_RETURN_BOOL(false); @@ -870,8 +868,8 @@ convert_network_to_scalar(Datum value, Oid typid) } /* - * Can't get here unless someone tries to use scalarltsel/scalargtsel - * on an operator with one network and one non-network operand. + * Can't get here unless someone tries to use scalarltsel/scalargtsel on + * an operator with one network and one non-network operand. */ elog(ERROR, "unsupported type: %u", typid); return 0; diff --git a/src/backend/utils/adt/numeric.c b/src/backend/utils/adt/numeric.c index 4aa631ee57..a8becf990d 100644 --- a/src/backend/utils/adt/numeric.c +++ b/src/backend/utils/adt/numeric.c @@ -14,7 +14,7 @@ * Copyright (c) 1998-2005, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/numeric.c,v 1.85 2005/07/10 21:13:59 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/numeric.c,v 1.86 2005/10/15 02:49:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -131,8 +131,7 @@ typedef struct NumericVar { int ndigits; /* # of digits in digits[] - can be 0! */ int weight; /* weight of first digit */ - int sign; /* NUMERIC_POS, NUMERIC_NEG, or - * NUMERIC_NAN */ + int sign; /* NUMERIC_POS, NUMERIC_NEG, or NUMERIC_NAN */ int dscale; /* display scale */ NumericDigit *buf; /* start of palloc'd space for digits[] */ NumericDigit *digits; /* base-NBASE digits */ @@ -157,10 +156,8 @@ static NumericVar const_two = #if DEC_DIGITS == 4 static NumericDigit const_zero_point_five_data[1] = {5000}; - #elif DEC_DIGITS == 2 static NumericDigit const_zero_point_five_data[1] = {50}; - #elif DEC_DIGITS == 1 static NumericDigit const_zero_point_five_data[1] = {5}; #endif @@ -169,10 +166,8 @@ static NumericVar const_zero_point_five = #if DEC_DIGITS == 4 static NumericDigit const_zero_point_nine_data[1] = {9000}; - #elif DEC_DIGITS == 2 static NumericDigit const_zero_point_nine_data[1] = {90}; - #elif DEC_DIGITS == 1 static NumericDigit const_zero_point_nine_data[1] = {9}; #endif @@ -183,12 +178,10 @@ static NumericVar const_zero_point_nine = static NumericDigit const_zero_point_01_data[1] = {100}; static NumericVar const_zero_point_01 = {1, -1, NUMERIC_POS, 2, NULL, const_zero_point_01_data}; - #elif DEC_DIGITS == 2 static NumericDigit const_zero_point_01_data[1] = {1}; static NumericVar const_zero_point_01 = {1, -1, NUMERIC_POS, 2, NULL, const_zero_point_01_data}; - #elif DEC_DIGITS == 1 static NumericDigit const_zero_point_01_data[1] = {1}; static NumericVar const_zero_point_01 = @@ -197,10 +190,8 @@ static NumericVar const_zero_point_01 = #if DEC_DIGITS == 4 static NumericDigit const_one_point_one_data[2] = {1, 1000}; - #elif DEC_DIGITS == 2 static NumericDigit const_one_point_one_data[2] = {1, 10}; - #elif DEC_DIGITS == 1 static NumericDigit const_one_point_one_data[2] = {1, 1}; #endif @@ -223,7 +214,6 @@ static const int round_powers[4] = {0, 1000, 100, 10}; #ifdef NUMERIC_DEBUG static void dump_numeric(const char *str, Numeric num); static void dump_var(const char *str, NumericVar *var); - #else #define dump_numeric(s,n) #define dump_var(s,v) @@ -322,8 +312,8 @@ numeric_in(PG_FUNCTION_ARGS) PG_RETURN_NUMERIC(make_result(&const_nan)); /* - * Use set_var_from_str() to parse the input string and return it in - * the packed DB storage format + * Use set_var_from_str() to parse the input string and return it in the + * packed DB storage format */ init_var(&value); set_var_from_str(str, &value); @@ -358,10 +348,10 @@ numeric_out(PG_FUNCTION_ARGS) /* * Get the number in the variable format. * - * Even if we didn't need to change format, we'd still need to copy the - * value to have a modifiable copy for rounding. set_var_from_num() - * also guarantees there is extra digit space in case we produce a - * carry out from rounding. + * Even if we didn't need to change format, we'd still need to copy the value + * to have a modifiable copy for rounding. set_var_from_num() also + * guarantees there is extra digit space in case we produce a carry out + * from rounding. */ init_var(&x); set_var_from_num(num, &x); @@ -383,6 +373,7 @@ Datum numeric_recv(PG_FUNCTION_ARGS) { StringInfo buf = (StringInfo) PG_GETARG_POINTER(0); + #ifdef NOT_USED Oid typelem = PG_GETARG_OID(1); #endif @@ -419,7 +410,7 @@ numeric_recv(PG_FUNCTION_ARGS) if (d < 0 || d >= NBASE) ereport(ERROR, (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION), - errmsg("invalid digit in external \"numeric\" value"))); + errmsg("invalid digit in external \"numeric\" value"))); value.digits[i] = d; } @@ -468,7 +459,7 @@ numeric_send(PG_FUNCTION_ARGS) * scale of the attribute have to be applied on the value. */ Datum -numeric (PG_FUNCTION_ARGS) +numeric(PG_FUNCTION_ARGS) { Numeric num = PG_GETARG_NUMERIC(0); int32 typmod = PG_GETARG_INT32(1); @@ -487,8 +478,8 @@ numeric (PG_FUNCTION_ARGS) PG_RETURN_NUMERIC(make_result(&const_nan)); /* - * If the value isn't a valid type modifier, simply return a copy of - * the input value + * If the value isn't a valid type modifier, simply return a copy of the + * input value */ if (typmod < (int32) (VARHDRSZ)) { @@ -507,9 +498,8 @@ numeric (PG_FUNCTION_ARGS) /* * If the number is certainly in bounds and due to the target scale no - * rounding could be necessary, just make a copy of the input and - * modify its scale fields. (Note we assume the existing dscale is - * honest...) + * rounding could be necessary, just make a copy of the input and modify + * its scale fields. (Note we assume the existing dscale is honest...) */ ddigits = (num->n_weight + 1) * DEC_DIGITS; if (ddigits <= maxdigits && scale >= NUMERIC_DSCALE(num)) @@ -587,9 +577,9 @@ numeric_uminus(PG_FUNCTION_ARGS) memcpy(res, num, num->varlen); /* - * The packed format is known to be totally zero digit trimmed always. - * So we can identify a ZERO by the fact that there are no digits at - * all. Do nothing to a zero. + * The packed format is known to be totally zero digit trimmed always. So + * we can identify a ZERO by the fact that there are no digits at all. Do + * nothing to a zero. */ if (num->varlen != NUMERIC_HDRSZ) { @@ -638,17 +628,16 @@ numeric_sign(PG_FUNCTION_ARGS) init_var(&result); /* - * The packed format is known to be totally zero digit trimmed always. - * So we can identify a ZERO by the fact that there are no digits at - * all. + * The packed format is known to be totally zero digit trimmed always. So + * we can identify a ZERO by the fact that there are no digits at all. */ if (num->varlen == NUMERIC_HDRSZ) set_var_from_var(&const_zero, &result); else { /* - * And if there are some, we return a copy of ONE with the sign of - * our argument + * And if there are some, we return a copy of ONE with the sign of our + * argument */ set_var_from_var(&const_one, &result); result.sign = NUMERIC_SIGN(num); @@ -837,8 +826,8 @@ width_bucket_numeric(PG_FUNCTION_ARGS) if (count <= 0) ereport(ERROR, - (errcode(ERRCODE_INVALID_ARGUMENT_FOR_WIDTH_BUCKET_FUNCTION), - errmsg("count must be greater than zero"))); + (errcode(ERRCODE_INVALID_ARGUMENT_FOR_WIDTH_BUCKET_FUNCTION), + errmsg("count must be greater than zero"))); init_var(&result_var); init_var(&count_var); @@ -850,8 +839,8 @@ width_bucket_numeric(PG_FUNCTION_ARGS) { case 0: ereport(ERROR, - (errcode(ERRCODE_INVALID_ARGUMENT_FOR_WIDTH_BUCKET_FUNCTION), - errmsg("lower bound cannot equal upper bound"))); + (errcode(ERRCODE_INVALID_ARGUMENT_FOR_WIDTH_BUCKET_FUNCTION), + errmsg("lower bound cannot equal upper bound"))); /* bound1 < bound2 */ case -1: @@ -1055,9 +1044,9 @@ cmp_numerics(Numeric num1, Numeric num2) int result; /* - * We consider all NANs to be equal and larger than any non-NAN. This - * is somewhat arbitrary; the important thing is to have a consistent - * sort order. + * We consider all NANs to be equal and larger than any non-NAN. This is + * somewhat arbitrary; the important thing is to have a consistent sort + * order. */ if (NUMERIC_IS_NAN(num1)) { @@ -1208,10 +1197,10 @@ numeric_mul(PG_FUNCTION_ARGS) /* * Unpack the values, let mul_var() compute the result and return it. - * Unlike add_var() and sub_var(), mul_var() will round its result. In - * the case of numeric_mul(), which is invoked for the * operator on - * numerics, we request exact representation for the product (rscale = - * sum(dscale of arg1, dscale of arg2)). + * Unlike add_var() and sub_var(), mul_var() will round its result. In the + * case of numeric_mul(), which is invoked for the * operator on numerics, + * we request exact representation for the product (rscale = sum(dscale of + * arg1, dscale of arg2)). */ init_var(&arg1); init_var(&arg2); @@ -1368,8 +1357,8 @@ numeric_smaller(PG_FUNCTION_ARGS) Numeric num2 = PG_GETARG_NUMERIC(1); /* - * Use cmp_numerics so that this will agree with the comparison - * operators, particularly as regards comparisons involving NaN. + * Use cmp_numerics so that this will agree with the comparison operators, + * particularly as regards comparisons involving NaN. */ if (cmp_numerics(num1, num2) < 0) PG_RETURN_NUMERIC(num1); @@ -1390,8 +1379,8 @@ numeric_larger(PG_FUNCTION_ARGS) Numeric num2 = PG_GETARG_NUMERIC(1); /* - * Use cmp_numerics so that this will agree with the comparison - * operators, particularly as regards comparisons involving NaN. + * Use cmp_numerics so that this will agree with the comparison operators, + * particularly as regards comparisons involving NaN. */ if (cmp_numerics(num1, num2) > 0) PG_RETURN_NUMERIC(num1); @@ -1469,9 +1458,9 @@ numeric_sqrt(PG_FUNCTION_ARGS) PG_RETURN_NUMERIC(make_result(&const_nan)); /* - * Unpack the argument and determine the result scale. We choose a - * scale to give at least NUMERIC_MIN_SIG_DIGITS significant digits; - * but in any case not less than the input's dscale. + * Unpack the argument and determine the result scale. We choose a scale + * to give at least NUMERIC_MIN_SIG_DIGITS significant digits; but in any + * case not less than the input's dscale. */ init_var(&arg); init_var(&result); @@ -1522,9 +1511,9 @@ numeric_exp(PG_FUNCTION_ARGS) PG_RETURN_NUMERIC(make_result(&const_nan)); /* - * Unpack the argument and determine the result scale. We choose a - * scale to give at least NUMERIC_MIN_SIG_DIGITS significant digits; - * but in any case not less than the input's dscale. + * Unpack the argument and determine the result scale. We choose a scale + * to give at least NUMERIC_MIN_SIG_DIGITS significant digits; but in any + * case not less than the input's dscale. */ init_var(&arg); init_var(&result); @@ -1535,8 +1524,8 @@ numeric_exp(PG_FUNCTION_ARGS) val = numericvar_to_double_no_overflow(&arg); /* - * log10(result) = num * log10(e), so this is approximately the - * decimal weight of the result: + * log10(result) = num * log10(e), so this is approximately the decimal + * weight of the result: */ val *= 0.434294481903252; @@ -1646,8 +1635,8 @@ numeric_log(PG_FUNCTION_ARGS) set_var_from_num(num2, &arg2); /* - * Call log_var() to compute and return the result; note it handles - * scale selection itself. + * Call log_var() to compute and return the result; note it handles scale + * selection itself. */ log_var(&arg1, &arg2, &result); @@ -1698,8 +1687,8 @@ numeric_power(PG_FUNCTION_ARGS) trunc_var(&arg2_trunc, 0); /* - * Return special SQLSTATE error codes for a few conditions mandated - * by the standard. + * Return special SQLSTATE error codes for a few conditions mandated by + * the standard. */ if ((cmp_var(&arg1, &const_zero) == 0 && cmp_var(&arg2, &const_zero) < 0) || @@ -2093,8 +2082,8 @@ do_numeric_accum(ArrayType *transarray, Numeric newval) NumericGetDatum(newval)); sumX2 = DirectFunctionCall2(numeric_add, sumX2, DirectFunctionCall2(numeric_mul, - NumericGetDatum(newval), - NumericGetDatum(newval))); + NumericGetDatum(newval), + NumericGetDatum(newval))); transdatums[0] = N; transdatums[1] = sumX; @@ -2252,7 +2241,7 @@ numeric_variance(PG_FUNCTION_ARGS) { mul_var(&vN, &vNminus1, &vNminus1, 0); /* N * (N - 1) */ rscale = select_div_scale(&vsumX2, &vNminus1); - div_var(&vsumX2, &vNminus1, &vsumX, rscale, true); /* variance */ + div_var(&vsumX2, &vNminus1, &vsumX, rscale, true); /* variance */ res = make_result(&vsumX); } @@ -2328,7 +2317,7 @@ numeric_stddev(PG_FUNCTION_ARGS) { mul_var(&vN, &vNminus1, &vNminus1, 0); /* N * (N - 1) */ rscale = select_div_scale(&vsumX2, &vNminus1); - div_var(&vsumX2, &vNminus1, &vsumX, rscale, true); /* variance */ + div_var(&vsumX2, &vNminus1, &vsumX, rscale, true); /* variance */ sqrt_var(&vsumX, &vsumX, rscale); /* stddev */ res = make_result(&vsumX); @@ -2377,12 +2366,12 @@ int2_sum(PG_FUNCTION_ARGS) /* * If we're invoked by nodeAgg, we can cheat and modify out first - * parameter in-place to avoid palloc overhead. If not, we need to - * return the new value of the transition variable. + * parameter in-place to avoid palloc overhead. If not, we need to return + * the new value of the transition variable. */ if (fcinfo->context && IsA(fcinfo->context, AggState)) { - int64 *oldsum = (int64 *) PG_GETARG_POINTER(0); + int64 *oldsum = (int64 *) PG_GETARG_POINTER(0); /* Leave the running sum unchanged in the new input is null */ if (!PG_ARGISNULL(1)) @@ -2422,12 +2411,12 @@ int4_sum(PG_FUNCTION_ARGS) /* * If we're invoked by nodeAgg, we can cheat and modify out first - * parameter in-place to avoid palloc overhead. If not, we need to - * return the new value of the transition variable. + * parameter in-place to avoid palloc overhead. If not, we need to return + * the new value of the transition variable. */ if (fcinfo->context && IsA(fcinfo->context, AggState)) { - int64 *oldsum = (int64 *) PG_GETARG_POINTER(0); + int64 *oldsum = (int64 *) PG_GETARG_POINTER(0); /* Leave the running sum unchanged in the new input is null */ if (!PG_ARGISNULL(1)) @@ -2467,9 +2456,9 @@ int8_sum(PG_FUNCTION_ARGS) } /* - * Note that we cannot special-case the nodeAgg case here, as we - * do for int2_sum and int4_sum: numeric is of variable size, so - * we cannot modify our first parameter in-place. + * Note that we cannot special-case the nodeAgg case here, as we do for + * int2_sum and int4_sum: numeric is of variable size, so we cannot modify + * our first parameter in-place. */ oldsum = PG_GETARG_NUMERIC(0); @@ -2514,8 +2503,8 @@ int2_avg_accum(PG_FUNCTION_ARGS) /* * If we're invoked by nodeAgg, we can cheat and modify our first - * parameter in-place to reduce palloc overhead. Otherwise we need - * to make a copy of it before scribbling on it. + * parameter in-place to reduce palloc overhead. Otherwise we need to make + * a copy of it before scribbling on it. */ if (fcinfo->context && IsA(fcinfo->context, AggState)) transarray = PG_GETARG_ARRAYTYPE_P(0); @@ -2541,8 +2530,8 @@ int4_avg_accum(PG_FUNCTION_ARGS) /* * If we're invoked by nodeAgg, we can cheat and modify our first - * parameter in-place to reduce palloc overhead. Otherwise we need - * to make a copy of it before scribbling on it. + * parameter in-place to reduce palloc overhead. Otherwise we need to make + * a copy of it before scribbling on it. */ if (fcinfo->context && IsA(fcinfo->context, AggState)) transarray = PG_GETARG_ARRAYTYPE_P(0); @@ -2743,8 +2732,8 @@ set_var_from_str(const char *str, NumericVar *dest) NumericDigit *digits; /* - * We first parse the string to extract decimal digits and determine - * the correct decimal weight. Then convert to NBASE representation. + * We first parse the string to extract decimal digits and determine the + * correct decimal weight. Then convert to NBASE representation. */ /* skip leading spaces */ @@ -2777,7 +2766,7 @@ set_var_from_str(const char *str, NumericVar *dest) if (!isdigit((unsigned char) *cp)) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type numeric: \"%s\"", str))); + errmsg("invalid input syntax for type numeric: \"%s\"", str))); decdigits = (unsigned char *) palloc(strlen(cp) + DEC_DIGITS * 2); @@ -2800,8 +2789,8 @@ set_var_from_str(const char *str, NumericVar *dest) if (have_dp) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type numeric: \"%s\"", - str))); + errmsg("invalid input syntax for type numeric: \"%s\"", + str))); have_dp = TRUE; cp++; } @@ -2824,15 +2813,15 @@ set_var_from_str(const char *str, NumericVar *dest) if (endptr == cp) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type numeric: \"%s\"", - str))); + errmsg("invalid input syntax for type numeric: \"%s\"", + str))); cp = endptr; if (exponent > NUMERIC_MAX_PRECISION || exponent < -NUMERIC_MAX_PRECISION) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type numeric: \"%s\"", - str))); + errmsg("invalid input syntax for type numeric: \"%s\"", + str))); dweight += (int) exponent; dscale -= (int) exponent; if (dscale < 0) @@ -2845,16 +2834,16 @@ set_var_from_str(const char *str, NumericVar *dest) if (!isspace((unsigned char) *cp)) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type numeric: \"%s\"", - str))); + errmsg("invalid input syntax for type numeric: \"%s\"", + str))); cp++; } /* - * Okay, convert pure-decimal representation to base NBASE. First we - * need to determine the converted weight and ndigits. offset is the - * number of decimal zeroes to insert before the first given digit to - * have a correctly aligned first NBASE digit. + * Okay, convert pure-decimal representation to base NBASE. First we need + * to determine the converted weight and ndigits. offset is the number of + * decimal zeroes to insert before the first given digit to have a + * correctly aligned first NBASE digit. */ if (dweight >= 0) weight = (dweight + 1 + DEC_DIGITS - 1) / DEC_DIGITS - 1; @@ -2969,10 +2958,10 @@ get_str_from_var(NumericVar *var, int dscale) /* * Allocate space for the result. * - * i is set to to # of decimal digits before decimal point. dscale is the - * # of decimal digits we will print after decimal point. We may - * generate as many as DEC_DIGITS-1 excess digits at the end, and in - * addition we need room for sign, decimal point, null terminator. + * i is set to to # of decimal digits before decimal point. dscale is the # + * of decimal digits we will print after decimal point. We may generate as + * many as DEC_DIGITS-1 excess digits at the end, and in addition we need + * room for sign, decimal point, null terminator. */ i = (var->weight + 1) * DEC_DIGITS; if (i <= 0) @@ -3037,9 +3026,9 @@ get_str_from_var(NumericVar *var, int dscale) } /* - * If requested, output a decimal point and all the digits that follow - * it. We initially put out a multiple of DEC_DIGITS digits, then - * truncate if needed. + * If requested, output a decimal point and all the digits that follow it. + * We initially put out a multiple of DEC_DIGITS digits, then truncate if + * needed. */ if (dscale > 0) { @@ -3179,10 +3168,10 @@ apply_typmod(NumericVar *var, int32 typmod) /* * Check for overflow - note we can't do this before rounding, because - * rounding could raise the weight. Also note that the var's weight - * could be inflated by leading zeroes, which will be stripped before - * storage but perhaps might not have been yet. In any case, we must - * recognize a true zero, whose weight doesn't mean anything. + * rounding could raise the weight. Also note that the var's weight could + * be inflated by leading zeroes, which will be stripped before storage + * but perhaps might not have been yet. In any case, we must recognize a + * true zero, whose weight doesn't mean anything. */ ddigits = (var->weight + 1) * DEC_DIGITS; if (ddigits > maxdigits) @@ -3254,9 +3243,8 @@ numericvar_to_int8(NumericVar *var, int64 *result) } /* - * For input like 10000000000, we must treat stripped digits as real. - * So the loop assumes there are weight+1 digits before the decimal - * point. + * For input like 10000000000, we must treat stripped digits as real. So + * the loop assumes there are weight+1 digits before the decimal point. */ weight = var->weight; Assert(weight >= 0 && ndigits <= weight + 1); @@ -3274,10 +3262,10 @@ numericvar_to_int8(NumericVar *var, int64 *result) /* * The overflow check is a bit tricky because we want to accept - * INT64_MIN, which will overflow the positive accumulator. We - * can detect this case easily though because INT64_MIN is the - * only nonzero value for which -val == val (on a two's complement - * machine, anyway). + * INT64_MIN, which will overflow the positive accumulator. We can + * detect this case easily though because INT64_MIN is the only + * nonzero value for which -val == val (on a two's complement machine, + * anyway). */ if ((val / NBASE) != oldval) /* possible overflow? */ { @@ -3355,8 +3343,8 @@ numeric_to_double_no_overflow(Numeric num) /* shouldn't happen ... */ ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type double precision: \"%s\"", - tmp))); + errmsg("invalid input syntax for type double precision: \"%s\"", + tmp))); } pfree(tmp); @@ -3381,8 +3369,8 @@ numericvar_to_double_no_overflow(NumericVar *var) /* shouldn't happen ... */ ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type double precision: \"%s\"", - tmp))); + errmsg("invalid input syntax for type double precision: \"%s\"", + tmp))); } pfree(tmp); @@ -3454,8 +3442,7 @@ add_var(NumericVar *var1, NumericVar *var2, NumericVar *result) else { /* - * var1 is positive, var2 is negative Must compare absolute - * values + * var1 is positive, var2 is negative Must compare absolute values */ switch (cmp_abs(var1, var2)) { @@ -3715,10 +3702,9 @@ mul_var(NumericVar *var1, NumericVar *var2, NumericVar *result, /* * Determine number of result digits to compute. If the exact result - * would have more than rscale fractional digits, truncate the - * computation with MUL_GUARD_DIGITS guard digits. We do that by - * pretending that one or both inputs have fewer digits than they - * really do. + * would have more than rscale fractional digits, truncate the computation + * with MUL_GUARD_DIGITS guard digits. We do that by pretending that one + * or both inputs have fewer digits than they really do. */ res_ndigits = var1ndigits + var2ndigits + 1; maxdigits = res_weight + 1 + (rscale * DEC_DIGITS) + MUL_GUARD_DIGITS; @@ -3752,12 +3738,12 @@ mul_var(NumericVar *var1, NumericVar *var2, NumericVar *result, /* * We do the arithmetic in an array "dig[]" of signed int's. Since - * INT_MAX is noticeably larger than NBASE*NBASE, this gives us - * headroom to avoid normalizing carries immediately. + * INT_MAX is noticeably larger than NBASE*NBASE, this gives us headroom + * to avoid normalizing carries immediately. * * maxdig tracks the maximum possible value of any dig[] entry; when this - * threatens to exceed INT_MAX, we take the time to propagate carries. - * To avoid overflow in maxdig itself, it actually represents the max + * threatens to exceed INT_MAX, we take the time to propagate carries. To + * avoid overflow in maxdig itself, it actually represents the max * possible value divided by NBASE-1. */ dig = (int *) palloc0(res_ndigits * sizeof(int)); @@ -3801,9 +3787,9 @@ mul_var(NumericVar *var1, NumericVar *var2, NumericVar *result, } /* - * Now we do a final carry propagation pass to normalize the result, - * which we combine with storing the result digits into the output. - * Note that this is still done at full precision w/guard digits. + * Now we do a final carry propagation pass to normalize the result, which + * we combine with storing the result digits into the output. Note that + * this is still done at full precision w/guard digits. */ alloc_var(result, res_ndigits); res_digits = result->digits; @@ -3909,24 +3895,24 @@ div_var(NumericVar *var1, NumericVar *var2, NumericVar *result, /* * We do the arithmetic in an array "div[]" of signed int's. Since - * INT_MAX is noticeably larger than NBASE*NBASE, this gives us - * headroom to avoid normalizing carries immediately. + * INT_MAX is noticeably larger than NBASE*NBASE, this gives us headroom + * to avoid normalizing carries immediately. * - * We start with div[] containing one zero digit followed by the - * dividend's digits (plus appended zeroes to reach the desired - * precision including guard digits). Each step of the main loop - * computes an (approximate) quotient digit and stores it into div[], - * removing one position of dividend space. A final pass of carry - * propagation takes care of any mistaken quotient digits. + * We start with div[] containing one zero digit followed by the dividend's + * digits (plus appended zeroes to reach the desired precision including + * guard digits). Each step of the main loop computes an (approximate) + * quotient digit and stores it into div[], removing one position of + * dividend space. A final pass of carry propagation takes care of any + * mistaken quotient digits. */ div = (int *) palloc0((div_ndigits + 1) * sizeof(int)); for (i = 0; i < var1ndigits; i++) div[i + 1] = var1digits[i]; /* - * We estimate each quotient digit using floating-point arithmetic, - * taking the first four digits of the (current) dividend and divisor. - * This must be float to avoid overflow. + * We estimate each quotient digit using floating-point arithmetic, taking + * the first four digits of the (current) dividend and divisor. This must + * be float to avoid overflow. */ fdivisor = (double) var2digits[0]; for (i = 1; i < 4; i++) @@ -3938,10 +3924,10 @@ div_var(NumericVar *var1, NumericVar *var2, NumericVar *result, fdivisorinverse = 1.0 / fdivisor; /* - * maxdiv tracks the maximum possible absolute value of any div[] - * entry; when this threatens to exceed INT_MAX, we take the time to - * propagate carries. To avoid overflow in maxdiv itself, it actually - * represents the max possible abs. value divided by NBASE-1. + * maxdiv tracks the maximum possible absolute value of any div[] entry; + * when this threatens to exceed INT_MAX, we take the time to propagate + * carries. To avoid overflow in maxdiv itself, it actually represents + * the max possible abs. value divided by NBASE-1. */ maxdiv = 1; @@ -3992,8 +3978,8 @@ div_var(NumericVar *var1, NumericVar *var2, NumericVar *result, div[qi] = newdig; /* - * All the div[] digits except possibly div[qi] are now in - * the range 0..NBASE-1. + * All the div[] digits except possibly div[qi] are now in the + * range 0..NBASE-1. */ maxdiv = Abs(newdig) / (NBASE - 1); maxdiv = Max(maxdiv, 1); @@ -4012,8 +3998,7 @@ div_var(NumericVar *var1, NumericVar *var2, NumericVar *result, /* Compute the (approximate) quotient digit */ fquotient = fdividend * fdivisorinverse; qdigit = (fquotient >= 0.0) ? ((int) fquotient) : - (((int) fquotient) - 1); /* truncate towards - * -infinity */ + (((int) fquotient) - 1); /* truncate towards -infinity */ maxdiv += Abs(qdigit); } @@ -4028,10 +4013,10 @@ div_var(NumericVar *var1, NumericVar *var2, NumericVar *result, } /* - * The dividend digit we are about to replace might still be - * nonzero. Fold it into the next digit position. We don't need - * to worry about overflow here since this should nearly cancel - * with the subtraction of the divisor. + * The dividend digit we are about to replace might still be nonzero. + * Fold it into the next digit position. We don't need to worry about + * overflow here since this should nearly cancel with the subtraction + * of the divisor. */ div[qi + 1] += div[qi] * NBASE; @@ -4050,9 +4035,9 @@ div_var(NumericVar *var1, NumericVar *var2, NumericVar *result, div[qi] = qdigit; /* - * Now we do a final carry propagation pass to normalize the result, - * which we combine with storing the result digits into the output. - * Note that this is still done at full precision w/guard digits. + * Now we do a final carry propagation pass to normalize the result, which + * we combine with storing the result digits into the output. Note that + * this is still done at full precision w/guard digits. */ alloc_var(result, div_ndigits + 1); res_digits = result->digits; @@ -4089,7 +4074,7 @@ div_var(NumericVar *var1, NumericVar *var2, NumericVar *result, round_var(result, rscale); else trunc_var(result, rscale); - + /* Strip leading and trailing zeroes */ strip_var(result); } @@ -4112,8 +4097,8 @@ select_div_scale(NumericVar *var1, NumericVar *var2) int rscale; /* - * The result scale of a division isn't specified in any SQL standard. - * For PostgreSQL we select a result scale that will give at least + * The result scale of a division isn't specified in any SQL standard. For + * PostgreSQL we select a result scale that will give at least * NUMERIC_MIN_SIG_DIGITS significant digits, so that numeric gives a * result no less accurate than float8; but use a scale not less than * either input's display scale. @@ -4274,8 +4259,8 @@ sqrt_var(NumericVar *arg, NumericVar *result, int rscale) } /* - * SQL2003 defines sqrt() in terms of power, so we need to emit the - * right SQLSTATE error code if the operand is negative. + * SQL2003 defines sqrt() in terms of power, so we need to emit the right + * SQLSTATE error code if the operand is negative. */ if (stat < 0) ereport(ERROR, @@ -4445,9 +4430,8 @@ exp_var_internal(NumericVar *arg, NumericVar *result, int rscale) * * exp(x) = 1 + x + x^2/2! + x^3/3! + ... * - * Given the limited range of x, this should converge reasonably quickly. - * We run the series until the terms fall below the local_rscale - * limit. + * Given the limited range of x, this should converge reasonably quickly. We + * run the series until the terms fall below the local_rscale limit. */ add_var(&const_one, &x, result); set_var_from_var(&x, &xpow); @@ -4535,11 +4519,11 @@ ln_var(NumericVar *arg, NumericVar *result, int rscale) * * z + z^3/3 + z^5/5 + ... * - * where z = (x-1)/(x+1) is in the range (approximately) -0.053 .. 0.048 - * due to the above range-reduction of x. + * where z = (x-1)/(x+1) is in the range (approximately) -0.053 .. 0.048 due + * to the above range-reduction of x. * - * The convergence of this is not as fast as one would like, but is - * tolerable given that z is small. + * The convergence of this is not as fast as one would like, but is tolerable + * given that z is small. */ sub_var(&x, &const_one, result); add_var(&x, &const_one, &elem); @@ -4711,8 +4695,7 @@ power_var(NumericVar *base, NumericVar *exp, NumericVar *result) val = numericvar_to_double_no_overflow(&ln_num); /* - * log10(result) = num * log10(e), so this is approximately the - * weight: + * log10(result) = num * log10(e), so this is approximately the weight: */ val *= 0.434294481903252; @@ -4772,8 +4755,7 @@ power_var_int(NumericVar *base, int exp, NumericVar *result, int rscale) /* * The general case repeatedly multiplies base according to the bit - * pattern of exp. We do the multiplications with some extra - * precision. + * pattern of exp. We do the multiplications with some extra precision. */ neg = (exp < 0); exp = Abs(exp); @@ -4866,8 +4848,8 @@ cmp_abs(NumericVar *var1, NumericVar *var2) } /* - * At this point, we've run out of digits on one side or the other; so - * any remaining nonzero digits imply that side is larger + * At this point, we've run out of digits on one side or the other; so any + * remaining nonzero digits imply that side is larger */ while (i1 < var1->ndigits) { @@ -5071,8 +5053,8 @@ round_var(NumericVar *var, int rscale) di = (var->weight + 1) * DEC_DIGITS + rscale; /* - * If di = 0, the value loses all digits, but could round up to 1 if - * its first extra digit is >= 5. If di < 0 the result must be 0. + * If di = 0, the value loses all digits, but could round up to 1 if its + * first extra digit is >= 5. If di < 0 the result must be 0. */ if (di < 0) { diff --git a/src/backend/utils/adt/numutils.c b/src/backend/utils/adt/numutils.c index fb7fd94b8c..ffa225277e 100644 --- a/src/backend/utils/adt/numutils.c +++ b/src/backend/utils/adt/numutils.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/numutils.c,v 1.68 2005/01/09 21:03:19 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/numutils.c,v 1.69 2005/10/15 02:49:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -63,8 +63,8 @@ pg_atoi(char *s, int size, int c) char *badp; /* - * Some versions of strtol treat the empty string as an error, but - * some seem not to. Make an explicit test to be sure we catch it. + * Some versions of strtol treat the empty string as an error, but some + * seem not to. Make an explicit test to be sure we catch it. */ if (s == NULL) elog(ERROR, "NULL pointer"); @@ -85,8 +85,8 @@ pg_atoi(char *s, int size, int c) s))); /* - * Skip any trailing whitespace; if anything but whitespace remains - * before the terminating character, bail out + * Skip any trailing whitespace; if anything but whitespace remains before + * the terminating character, bail out */ while (*badp && *badp != c && isspace((unsigned char) *badp)) badp++; @@ -108,19 +108,19 @@ pg_atoi(char *s, int size, int c) ) ereport(ERROR, (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), - errmsg("value \"%s\" is out of range for type integer", s))); + errmsg("value \"%s\" is out of range for type integer", s))); break; case sizeof(int16): if (errno == ERANGE || l < SHRT_MIN || l > SHRT_MAX) ereport(ERROR, (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), - errmsg("value \"%s\" is out of range for type smallint", s))); + errmsg("value \"%s\" is out of range for type smallint", s))); break; case sizeof(int8): if (errno == ERANGE || l < SCHAR_MIN || l > SCHAR_MAX) ereport(ERROR, (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), - errmsg("value \"%s\" is out of range for 8-bit integer", s))); + errmsg("value \"%s\" is out of range for 8-bit integer", s))); break; default: elog(ERROR, "unsupported result size: %d", size); diff --git a/src/backend/utils/adt/oid.c b/src/backend/utils/adt/oid.c index e9a2c741be..62db042bbd 100644 --- a/src/backend/utils/adt/oid.c +++ b/src/backend/utils/adt/oid.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/oid.c,v 1.63 2005/07/10 21:36:21 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/oid.c,v 1.64 2005/10/15 02:49:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -47,9 +47,9 @@ oidin_subr(const char *funcname, const char *s, char **endloc) cvt = strtoul(s, &endptr, 10); /* - * strtoul() normally only sets ERANGE. On some systems it also may - * set EINVAL, which simply means it couldn't parse the input string. - * This is handled by the second "if" consistent across platforms. + * strtoul() normally only sets ERANGE. On some systems it also may set + * EINVAL, which simply means it couldn't parse the input string. This is + * handled by the second "if" consistent across platforms. */ if (errno && errno != ERANGE && errno != EINVAL) ereport(ERROR, @@ -88,16 +88,16 @@ oidin_subr(const char *funcname, const char *s, char **endloc) result = (Oid) cvt; /* - * Cope with possibility that unsigned long is wider than Oid, in - * which case strtoul will not raise an error for some values that are - * out of the range of Oid. + * Cope with possibility that unsigned long is wider than Oid, in which + * case strtoul will not raise an error for some values that are out of + * the range of Oid. * - * For backwards compatibility, we want to accept inputs that are given - * with a minus sign, so allow the input value if it matches after - * either signed or unsigned extension to long. + * For backwards compatibility, we want to accept inputs that are given with + * a minus sign, so allow the input value if it matches after either + * signed or unsigned extension to long. * - * To ensure consistent results on 32-bit and 64-bit platforms, make sure - * the error message is the same as if strtoul() had returned ERANGE. + * To ensure consistent results on 32-bit and 64-bit platforms, make sure the + * error message is the same as if strtoul() had returned ERANGE. */ #if OID_MAX != ULONG_MAX if (cvt != (unsigned long) result && @@ -171,8 +171,8 @@ buildoidvector(const Oid *oids, int n) memcpy(result->values, oids, n * sizeof(Oid)); /* - * Attach standard array header. For historical reasons, we set the - * index lower bound to 0 not 1. + * Attach standard array header. For historical reasons, we set the index + * lower bound to 0 not 1. */ result->size = OidVectorSize(n); result->ndim = 1; diff --git a/src/backend/utils/adt/oracle_compat.c b/src/backend/utils/adt/oracle_compat.c index 5dd9a44ccf..a1ddc00a78 100644 --- a/src/backend/utils/adt/oracle_compat.c +++ b/src/backend/utils/adt/oracle_compat.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/oracle_compat.c,v 1.61 2005/08/24 17:50:00 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/oracle_compat.c,v 1.62 2005/10/15 02:49:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -87,12 +87,12 @@ texttowcs(const text *txt) if (ncodes == (size_t) -1) { /* - * Invalid multibyte character encountered. We try to give a - * useful error message by letting pg_verifymbstr check the - * string. But it's possible that the string is OK to us, and not - * OK to mbstowcs --- this suggests that the LC_CTYPE locale is - * different from the database encoding. Give a generic error - * message if verifymbstr can't find anything wrong. + * Invalid multibyte character encountered. We try to give a useful + * error message by letting pg_verifymbstr check the string. But it's + * possible that the string is OK to us, and not OK to mbstowcs --- + * this suggests that the LC_CTYPE locale is different from the + * database encoding. Give a generic error message if verifymbstr + * can't find anything wrong. */ pg_verifymbstr(workstr, nbytes, false); ereport(ERROR, @@ -164,11 +164,11 @@ win32_utf8_texttowcs(const text *txt) { int nbytes = VARSIZE(txt) - VARHDRSZ; wchar_t *result; - int r; + int r; /* Overflow paranoia */ if (nbytes < 0 || - nbytes > (int) (INT_MAX / sizeof(wchar_t)) -1) + nbytes > (int) (INT_MAX / sizeof(wchar_t)) - 1) ereport(ERROR, (errcode(ERRCODE_OUT_OF_MEMORY), errmsg("out of memory"))); @@ -206,9 +206,9 @@ win32_utf8_texttowcs(const text *txt) static text * win32_utf8_wcstotext(const wchar_t *str) { - text *result; - int nbytes; - int r; + text *result; + int nbytes; + int r; nbytes = WideCharToMultiByte(CP_UTF8, 0, str, -1, NULL, 0, NULL, NULL); if (nbytes == 0) /* shouldn't happen */ @@ -217,7 +217,7 @@ win32_utf8_wcstotext(const wchar_t *str) errmsg("UTF16 to UTF8 translation failed: %lu", GetLastError()))); - result = palloc(nbytes+VARHDRSZ); + result = palloc(nbytes + VARHDRSZ); r = WideCharToMultiByte(CP_UTF8, 0, str, -1, VARDATA(result), nbytes, NULL, NULL); @@ -227,7 +227,7 @@ win32_utf8_wcstotext(const wchar_t *str) errmsg("UTF16 to UTF8 translation failed: %lu", GetLastError()))); - VARATT_SIZEP(result) = nbytes + VARHDRSZ - 1; /* -1 to ignore null */ + VARATT_SIZEP(result) = nbytes + VARHDRSZ - 1; /* -1 to ignore null */ return result; } @@ -256,8 +256,7 @@ win32_wcstotext(const wchar_t *str, int ncodes) #define texttowcs win32_texttowcs #define wcstotext win32_wcstotext - -#endif /* WIN32 */ +#endif /* WIN32 */ /******************************************************************** @@ -278,10 +277,11 @@ Datum lower(PG_FUNCTION_ARGS) { #ifdef USE_WIDE_UPPER_LOWER + /* - * Use wide char code only when max encoding length > 1 and ctype != C. - * Some operating systems fail with multi-byte encodings and a C locale. - * Also, for a C locale there is no need to process as multibyte. + * Use wide char code only when max encoding length > 1 and ctype != C. + * Some operating systems fail with multi-byte encodings and a C locale. + * Also, for a C locale there is no need to process as multibyte. */ if (pg_database_encoding_max_length() > 1 && !lc_ctype_is_c()) { @@ -309,8 +309,7 @@ lower(PG_FUNCTION_ARGS) int m; /* - * Since we copied the string, we can scribble directly on the - * value + * Since we copied the string, we can scribble directly on the value */ ptr = VARDATA(string); m = VARSIZE(string) - VARHDRSZ; @@ -344,10 +343,11 @@ Datum upper(PG_FUNCTION_ARGS) { #ifdef USE_WIDE_UPPER_LOWER + /* - * Use wide char code only when max encoding length > 1 and ctype != C. - * Some operating systems fail with multi-byte encodings and a C locale. - * Also, for a C locale there is no need to process as multibyte. + * Use wide char code only when max encoding length > 1 and ctype != C. + * Some operating systems fail with multi-byte encodings and a C locale. + * Also, for a C locale there is no need to process as multibyte. */ if (pg_database_encoding_max_length() > 1 && !lc_ctype_is_c()) { @@ -375,8 +375,7 @@ upper(PG_FUNCTION_ARGS) int m; /* - * Since we copied the string, we can scribble directly on the - * value + * Since we copied the string, we can scribble directly on the value */ ptr = VARDATA(string); m = VARSIZE(string) - VARHDRSZ; @@ -413,10 +412,11 @@ Datum initcap(PG_FUNCTION_ARGS) { #ifdef USE_WIDE_UPPER_LOWER + /* - * Use wide char code only when max encoding length > 1 and ctype != C. - * Some operating systems fail with multi-byte encodings and a C locale. - * Also, for a C locale there is no need to process as multibyte. + * Use wide char code only when max encoding length > 1 and ctype != C. + * Some operating systems fail with multi-byte encodings and a C locale. + * Also, for a C locale there is no need to process as multibyte. */ if (pg_database_encoding_max_length() > 1 && !lc_ctype_is_c()) { @@ -452,8 +452,7 @@ initcap(PG_FUNCTION_ARGS) int m; /* - * Since we copied the string, we can scribble directly on the - * value + * Since we copied the string, we can scribble directly on the value */ ptr = VARDATA(string); m = VARSIZE(string) - VARHDRSZ; @@ -732,8 +731,8 @@ dotrim(const char *string, int stringlen, { /* * In the multibyte-encoding case, build arrays of pointers to - * character starts, so that we can avoid inefficient checks - * in the inner loops. + * character starts, so that we can avoid inefficient checks in + * the inner loops. */ const char **stringchars; const char **setchars; @@ -828,8 +827,7 @@ dotrim(const char *string, int stringlen, else { /* - * In the single-byte-encoding case, we don't need such - * overhead. + * In the single-byte-encoding case, we don't need such overhead. */ if (doltrim) { @@ -1152,9 +1150,9 @@ translate(PG_FUNCTION_ARGS) VARATT_SIZEP(result) = retlen + VARHDRSZ; /* - * There may be some wasted space in the result if deletions occurred, - * but it's not worth reallocating it; the function result probably - * won't live long anyway. + * There may be some wasted space in the result if deletions occurred, but + * it's not worth reallocating it; the function result probably won't live + * long anyway. */ PG_RETURN_TEXT_P(result); diff --git a/src/backend/utils/adt/pg_locale.c b/src/backend/utils/adt/pg_locale.c index 7c9c774d91..303fec745a 100644 --- a/src/backend/utils/adt/pg_locale.c +++ b/src/backend/utils/adt/pg_locale.c @@ -4,7 +4,7 @@ * * Portions Copyright (c) 2002-2005, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/backend/utils/adt/pg_locale.c,v 1.31 2005/03/16 00:02:49 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/pg_locale.c,v 1.32 2005/10/15 02:49:29 momjian Exp $ * *----------------------------------------------------------------------- */ @@ -124,9 +124,9 @@ const char * locale_messages_assign(const char *value, bool doit, GucSource source) { #ifndef WIN32 + /* - * LC_MESSAGES category does not exist everywhere, but accept it - * anyway + * LC_MESSAGES category does not exist everywhere, but accept it anyway */ #ifdef LC_MESSAGES if (doit) @@ -138,16 +138,15 @@ locale_messages_assign(const char *value, bool doit, GucSource source) value = locale_xxx_assign(LC_MESSAGES, value, false, source); #endif /* LC_MESSAGES */ return value; - -#else /* WIN32 */ +#else /* WIN32 */ /* * Win32 does not have working setlocale() for LC_MESSAGES. We can only - * use environment variables to change it (per gettext FAQ). This - * means we can't actually check the supplied value, so always assume - * it's good. Also, ignore attempts to set to "", which really means - * "keep using the old value". (Actually it means "use the environment - * value", but we are too lazy to try to implement that exactly.) + * use environment variables to change it (per gettext FAQ). This means + * we can't actually check the supplied value, so always assume it's good. + * Also, ignore attempts to set to "", which really means "keep using the + * old value". (Actually it means "use the environment value", but we are + * too lazy to try to implement that exactly.) */ if (doit && value[0]) { @@ -160,12 +159,12 @@ locale_messages_assign(const char *value, bool doit, GucSource source) if (!SetEnvironmentVariable("LC_MESSAGES", value)) return NULL; - snprintf(env, sizeof(env)-1, "LC_MESSAGES=%s", value); + snprintf(env, sizeof(env) - 1, "LC_MESSAGES=%s", value); if (_putenv(env)) return NULL; } return value; -#endif /* WIN32 */ +#endif /* WIN32 */ } @@ -289,8 +288,8 @@ PGLC_localeconv(void) extlconv = localeconv(); /* - * Must copy all values since restoring internal settings may - * overwrite localeconv()'s results. + * Must copy all values since restoring internal settings may overwrite + * localeconv()'s results. */ CurrentLocaleConv = *extlconv; CurrentLocaleConv.currency_symbol = strdup(extlconv->currency_symbol); diff --git a/src/backend/utils/adt/pg_lzcompress.c b/src/backend/utils/adt/pg_lzcompress.c index d7c34b6a92..48d93d0602 100644 --- a/src/backend/utils/adt/pg_lzcompress.c +++ b/src/backend/utils/adt/pg_lzcompress.c @@ -1,7 +1,7 @@ /* ---------- * pg_lzcompress.c - * - * $PostgreSQL: pgsql/src/backend/utils/adt/pg_lzcompress.c,v 1.19 2005/05/25 21:40:41 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/pg_lzcompress.c,v 1.20 2005/10/15 02:49:29 momjian Exp $ * * This is an implementation of LZ compression for PostgreSQL. * It uses a simple history table and generates 2-3 byte tags @@ -219,11 +219,11 @@ static PGLZ_Strategy strategy_default_data = { 6144, /* Data chunks greater equal 6K force * compression */ /* except compressed result is greater uncompressed data */ - 20, /* Compression rates below 20% mean - * fallback to uncompressed */ + 20, /* Compression rates below 20% mean fallback + * to uncompressed */ /* storage except compression is forced by previous parameter */ - 128, /* Stop history lookup if a match of 128 - * bytes is found */ + 128, /* Stop history lookup if a match of 128 bytes + * is found */ 10 /* Lower good match size by 10% at every * lookup loop iteration. */ }; @@ -233,10 +233,9 @@ PGLZ_Strategy *PGLZ_strategy_default = &strategy_default_data; static PGLZ_Strategy strategy_always_data = { 0, /* Chunks of any size are compressed */ 0, /* */ - 0, /* We want to save at least one single - * byte */ - 128, /* Stop history lookup if a match of 128 - * bytes is found */ + 0, /* We want to save at least one single byte */ + 128, /* Stop history lookup if a match of 128 bytes + * is found */ 6 /* Look harder for a good match. */ }; PGLZ_Strategy *PGLZ_strategy_always = &strategy_always_data; @@ -246,8 +245,7 @@ static PGLZ_Strategy strategy_never_data = { 0, /* */ 0, /* */ 0, /* */ - 0, /* Zero indicates "store uncompressed - * always" */ + 0, /* Zero indicates "store uncompressed always" */ 0 /* */ }; PGLZ_Strategy *PGLZ_strategy_never = &strategy_never_data; @@ -395,8 +393,7 @@ pglz_find_match(PGLZ_HistEntry **hstart, char *input, char *end, int32 off = 0; /* - * Traverse the linked history list until a good enough match is - * found. + * Traverse the linked history list until a good enough match is found. */ hent = hstart[pglz_hist_idx(input, end)]; while (hent) @@ -414,12 +411,12 @@ pglz_find_match(PGLZ_HistEntry **hstart, char *input, char *end, break; /* - * Determine length of match. A better match must be larger than - * the best so far. And if we already have a match of 16 or more - * bytes, it's worth the call overhead to use memcmp() to check if - * this match is equal for the same size. After that we must - * fallback to character by character comparison to know the exact - * position where the diff occurred. + * Determine length of match. A better match must be larger than the + * best so far. And if we already have a match of 16 or more bytes, + * it's worth the call overhead to use memcmp() to check if this match + * is equal for the same size. After that we must fallback to + * character by character comparison to know the exact position where + * the diff occurred. */ thislen = 0; if (len >= 16) @@ -462,8 +459,8 @@ pglz_find_match(PGLZ_HistEntry **hstart, char *input, char *end, hent = hent->next; /* - * Be happy with lesser good matches the more entries we visited. - * But no point in doing calculation if we're at end of list. + * Be happy with lesser good matches the more entries we visited. But + * no point in doing calculation if we're at end of list. */ if (hent) { @@ -565,10 +562,10 @@ pglz_compress(char *source, int32 slen, PGLZ_Header *dest, PGLZ_Strategy *strate memset((void *) hist_start, 0, sizeof(hist_start)); /* - * Compute the maximum result size allowed by the strategy. If the - * input size exceeds force_input_size, the max result size is the - * input size itself. Otherwise, it is the input size minus the - * minimum wanted compression rate. + * Compute the maximum result size allowed by the strategy. If the input + * size exceeds force_input_size, the max result size is the input size + * itself. Otherwise, it is the input size minus the minimum wanted + * compression rate. */ if (slen >= strategy->force_input_size) result_max = slen; @@ -588,8 +585,8 @@ pglz_compress(char *source, int32 slen, PGLZ_Header *dest, PGLZ_Strategy *strate while (dp < dend) { /* - * If we already exceeded the maximum result size, set no - * compression flag and stop this. But don't check too often. + * If we already exceeded the maximum result size, set no compression + * flag and stop this. But don't check too often. */ if (bp - bstart >= result_max) { @@ -632,9 +629,9 @@ pglz_compress(char *source, int32 slen, PGLZ_Header *dest, PGLZ_Strategy *strate } /* - * If we are still in compressing mode, write out the last control - * byte and determine if the compression gained the rate requested by - * the strategy. + * If we are still in compressing mode, write out the last control byte + * and determine if the compression gained the rate requested by the + * strategy. */ if (do_compress) { @@ -647,8 +644,8 @@ pglz_compress(char *source, int32 slen, PGLZ_Header *dest, PGLZ_Strategy *strate /* * Done - if we successfully compressed and matched the strategy's - * constraints, return the compressed result. Otherwise copy the - * original source over it and return the original length. + * constraints, return the compressed result. Otherwise copy the original + * source over it and return the original length. */ if (do_compress) { @@ -704,9 +701,9 @@ pglz_decompress(PGLZ_Header *source, char *dest) /* * Otherwise it contains the match length minus 3 and the * upper 4 bits of the offset. The next following byte - * contains the lower 8 bits of the offset. If the length - * is coded as 18, another extension tag byte tells how - * much longer the match really was (0-255). + * contains the lower 8 bits of the offset. If the length is + * coded as 18, another extension tag byte tells how much + * longer the match really was (0-255). */ len = (dp[0] & 0x0f) + 3; off = ((dp[0] & 0xf0) << 4) | dp[1]; @@ -715,10 +712,10 @@ pglz_decompress(PGLZ_Header *source, char *dest) len += *dp++; /* - * Now we copy the bytes specified by the tag from OUTPUT - * to OUTPUT. It is dangerous and platform dependent to - * use memcpy() here, because the copied areas could - * overlap extremely! + * Now we copy the bytes specified by the tag from OUTPUT to + * OUTPUT. It is dangerous and platform dependent to use + * memcpy() here, because the copied areas could overlap + * extremely! */ while (len--) { @@ -729,8 +726,8 @@ pglz_decompress(PGLZ_Header *source, char *dest) else { /* - * An unset control bit means LITERAL BYTE. So we just - * copy one from INPUT to OUTPUT. + * An unset control bit means LITERAL BYTE. So we just copy + * one from INPUT to OUTPUT. */ *bp++ = *dp++; } @@ -764,8 +761,8 @@ pglz_get_next_decomp_char_from_lzdata(PGLZ_DecompState *dstate) if (dstate->tocopy > 0) { /* - * Copy one byte from output to output until we did it for the - * length specified by the last tag. Return that byte. + * Copy one byte from output to output until we did it for the length + * specified by the last tag. Return that byte. */ dstate->tocopy--; return (*(dstate->cp_out++) = *(dstate->cp_copy++)); @@ -774,21 +771,20 @@ pglz_get_next_decomp_char_from_lzdata(PGLZ_DecompState *dstate) if (dstate->ctrl_count == 0) { /* - * Get the next control byte if we need to, but check for EOF - * before. + * Get the next control byte if we need to, but check for EOF before. */ if (dstate->cp_in == dstate->cp_end) return EOF; /* * This decompression method saves time only, if we stop near the - * beginning of the data (maybe because we're called by a - * comparison function and a difference occurs early). Otherwise, - * all the checks, needed here, cause too much overhead. + * beginning of the data (maybe because we're called by a comparison + * function and a difference occurs early). Otherwise, all the checks, + * needed here, cause too much overhead. * - * Thus we decompress the entire rest at once into the temporary - * buffer and change the decomp state to return the prepared data - * from the buffer by the more simple calls to + * Thus we decompress the entire rest at once into the temporary buffer + * and change the decomp state to return the prepared data from the + * buffer by the more simple calls to * pglz_get_next_decomp_char_from_plain(). */ if (dstate->cp_out - dstate->temp_buf >= 256) @@ -856,8 +852,8 @@ pglz_get_next_decomp_char_from_lzdata(PGLZ_DecompState *dstate) if (dstate->ctrl & 0x01) { /* - * Bit is set, so tag is following. Setup copy information and do - * the copy for the first byte as above. + * Bit is set, so tag is following. Setup copy information and do the + * copy for the first byte as above. */ int off; diff --git a/src/backend/utils/adt/pgstatfuncs.c b/src/backend/utils/adt/pgstatfuncs.c index b1bd11c9c2..8c10bf387d 100644 --- a/src/backend/utils/adt/pgstatfuncs.c +++ b/src/backend/utils/adt/pgstatfuncs.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/pgstatfuncs.c,v 1.24 2005/06/29 22:51:56 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/pgstatfuncs.c,v 1.25 2005/10/15 02:49:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -354,8 +354,8 @@ pg_stat_get_backend_activity_start(PG_FUNCTION_ARGS) result = beentry->activity_start_timestamp; /* - * No time recorded for start of current query -- this is the case if - * the user hasn't enabled query-level stats collection. + * No time recorded for start of current query -- this is the case if the + * user hasn't enabled query-level stats collection. */ if (result == 0) PG_RETURN_NULL(); @@ -366,7 +366,7 @@ pg_stat_get_backend_activity_start(PG_FUNCTION_ARGS) Datum pg_stat_get_backend_start(PG_FUNCTION_ARGS) { - int32 beid = PG_GETARG_INT32(0); + int32 beid = PG_GETARG_INT32(0); TimestampTz result; PgStat_StatBeEntry *beentry; @@ -389,7 +389,7 @@ Datum pg_stat_get_backend_client_addr(PG_FUNCTION_ARGS) { PgStat_StatBeEntry *beentry; - int32 beid; + int32 beid; char remote_host[NI_MAXHOST]; int ret; @@ -432,7 +432,7 @@ Datum pg_stat_get_backend_client_port(PG_FUNCTION_ARGS) { PgStat_StatBeEntry *beentry; - int32 beid; + int32 beid; char remote_port[NI_MAXSERV]; int ret; diff --git a/src/backend/utils/adt/quote.c b/src/backend/utils/adt/quote.c index 808ae6142e..98a8ae765e 100644 --- a/src/backend/utils/adt/quote.c +++ b/src/backend/utils/adt/quote.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/quote.c,v 1.16 2005/07/02 17:01:50 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/quote.c,v 1.17 2005/10/15 02:49:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -65,13 +65,13 @@ quote_literal(PG_FUNCTION_ARGS) cp1 = VARDATA(t); cp2 = VARDATA(result); - for(; len-- > 0; cp1++) + for (; len-- > 0; cp1++) if (*cp1 == '\\') { *cp2++ = ESCAPE_STRING_SYNTAX; break; } - + len = VARSIZE(t) - VARHDRSZ; cp1 = VARDATA(t); *cp2++ = '\''; diff --git a/src/backend/utils/adt/regexp.c b/src/backend/utils/adt/regexp.c index 0aba560aa9..a872762c3c 100644 --- a/src/backend/utils/adt/regexp.c +++ b/src/backend/utils/adt/regexp.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/regexp.c,v 1.58 2005/09/24 17:53:15 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/regexp.c,v 1.59 2005/10/15 02:49:29 momjian Exp $ * * Alistair Crooks added the code for the regex caching * agc - cached the regular expressions used - there's a good chance @@ -85,8 +85,8 @@ static cached_re_str re_array[MAX_CACHED_RES]; /* cached re's */ * * Returns regex_t * - * text_re --- the pattern, expressed as an *untoasted* TEXT object - * cflags --- compile options for the pattern + * text_re --- the pattern, expressed as an *untoasted* TEXT object + * cflags --- compile options for the pattern * * Pattern is given in the database encoding. We internally convert to * array of pg_wchar which is what Spencer's regex package wants. @@ -104,8 +104,8 @@ RE_compile_and_cache(text *text_re, int cflags) /* * Look for a match among previously compiled REs. Since the data - * structure is self-organizing with most-used entries at the front, - * our search strategy can just be to scan from the front. + * structure is self-organizing with most-used entries at the front, our + * search strategy can just be to scan from the front. */ for (i = 0; i < num_res; i++) { @@ -171,8 +171,8 @@ RE_compile_and_cache(text *text_re, int cflags) re_temp.cre_flags = cflags; /* - * Okay, we have a valid new item in re_temp; insert it into the - * storage array. Discard last entry if needed. + * Okay, we have a valid new item in re_temp; insert it into the storage + * array. Discard last entry if needed. */ if (num_res >= MAX_CACHED_RES) { @@ -213,7 +213,7 @@ RE_compile_and_execute(text *text_re, char *dat, int dat_len, size_t data_len; int regexec_result; regex_t re; - char errMsg[100]; + char errMsg[100]; /* Convert data string to wide characters */ data = (pg_wchar *) palloc((dat_len + 1) * sizeof(pg_wchar)); @@ -405,10 +405,10 @@ textregexsubstr(PG_FUNCTION_ARGS) regmatch_t pmatch[2]; /* - * We pass two regmatch_t structs to get info about the overall match - * and the match for the first parenthesized subexpression (if any). - * If there is a parenthesized subexpression, we return what it - * matched; else return what the whole regexp matched. + * We pass two regmatch_t structs to get info about the overall match and + * the match for the first parenthesized subexpression (if any). If there + * is a parenthesized subexpression, we return what it matched; else + * return what the whole regexp matched. */ match = RE_compile_and_execute(p, VARDATA(s), @@ -432,9 +432,9 @@ textregexsubstr(PG_FUNCTION_ARGS) } return DirectFunctionCall3(text_substr, - PointerGetDatum(s), - Int32GetDatum(so + 1), - Int32GetDatum(eo - so)); + PointerGetDatum(s), + Int32GetDatum(so + 1), + Int32GetDatum(eo - so)); } PG_RETURN_NULL(); @@ -442,7 +442,7 @@ textregexsubstr(PG_FUNCTION_ARGS) /* * textregexreplace_noopt() - * Return a replace string matched by a regular expression. + * Return a replace string matched by a regular expression. * This function is a version that doesn't specify the option of * textregexreplace. This is case sensitive, replace the first * instance only. @@ -458,15 +458,15 @@ textregexreplace_noopt(PG_FUNCTION_ARGS) re = RE_compile_and_cache(p, regex_flavor); return DirectFunctionCall4(replace_text_regexp, - PointerGetDatum(s), - PointerGetDatum(&re), - PointerGetDatum(r), - BoolGetDatum(false)); + PointerGetDatum(s), + PointerGetDatum(&re), + PointerGetDatum(r), + BoolGetDatum(false)); } /* * textregexreplace() - * Return a replace string matched by a regular expression. + * Return a replace string matched by a regular expression. */ Datum textregexreplace(PG_FUNCTION_ARGS) @@ -478,7 +478,7 @@ textregexreplace(PG_FUNCTION_ARGS) char *opt_p = VARDATA(opt); int opt_len = (VARSIZE(opt) - VARHDRSZ); int i; - bool global = false; + bool global = false; bool ignorecase = false; regex_t re; @@ -492,12 +492,13 @@ textregexreplace(PG_FUNCTION_ARGS) break; case 'g': global = true; + break; default: ereport(ERROR, - (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("invalid option of regexp_replace: %c", - opt_p[i]))); + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("invalid option of regexp_replace: %c", + opt_p[i]))); break; } } @@ -508,10 +509,10 @@ textregexreplace(PG_FUNCTION_ARGS) re = RE_compile_and_cache(p, regex_flavor); return DirectFunctionCall4(replace_text_regexp, - PointerGetDatum(s), - PointerGetDatum(&re), - PointerGetDatum(r), - BoolGetDatum(global)); + PointerGetDatum(s), + PointerGetDatum(&re), + PointerGetDatum(r), + BoolGetDatum(global)); } /* similar_escape() @@ -555,7 +556,7 @@ similar_escape(PG_FUNCTION_ARGS) ereport(ERROR, (errcode(ERRCODE_INVALID_ESCAPE_SEQUENCE), errmsg("invalid escape string"), - errhint("Escape string must be empty or one character."))); + errhint("Escape string must be empty or one character."))); } /* We need room for ^, $, and up to 2 output bytes per input byte */ @@ -566,7 +567,7 @@ similar_escape(PG_FUNCTION_ARGS) while (plen > 0) { - char pchar = *p; + char pchar = *p; if (afterescape) { diff --git a/src/backend/utils/adt/regproc.c b/src/backend/utils/adt/regproc.c index 3a52c8756d..9a626c2f76 100644 --- a/src/backend/utils/adt/regproc.c +++ b/src/backend/utils/adt/regproc.c @@ -13,7 +13,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/regproc.c,v 1.95 2005/10/02 23:50:10 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/regproc.c,v 1.96 2005/10/15 02:49:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -71,17 +71,17 @@ regprocin(PG_FUNCTION_ARGS) strspn(pro_name_or_oid, "0123456789") == strlen(pro_name_or_oid)) { result = DatumGetObjectId(DirectFunctionCall1(oidin, - CStringGetDatum(pro_name_or_oid))); + CStringGetDatum(pro_name_or_oid))); PG_RETURN_OID(result); } /* Else it's a name, possibly schema-qualified */ /* - * In bootstrap mode we assume the given name is not schema-qualified, - * and just search pg_proc for a unique match. This is needed for - * initializing other system catalogs (pg_namespace may not exist yet, - * and certainly there are no schemas other than pg_catalog). + * In bootstrap mode we assume the given name is not schema-qualified, and + * just search pg_proc for a unique match. This is needed for + * initializing other system catalogs (pg_namespace may not exist yet, and + * certainly there are no schemas other than pg_catalog). */ if (IsBootstrapProcessingMode()) { @@ -113,7 +113,7 @@ regprocin(PG_FUNCTION_ARGS) if (matches == 0) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_FUNCTION), - errmsg("function \"%s\" does not exist", pro_name_or_oid))); + errmsg("function \"%s\" does not exist", pro_name_or_oid))); else if (matches > 1) ereport(ERROR, @@ -125,8 +125,8 @@ regprocin(PG_FUNCTION_ARGS) } /* - * Normal case: parse the name into components and see if it matches - * any pg_proc entries in the current search path. + * Normal case: parse the name into components and see if it matches any + * pg_proc entries in the current search path. */ names = stringToQualifiedNameList(pro_name_or_oid, "regprocin"); clist = FuncnameGetCandidates(names, -1); @@ -134,7 +134,7 @@ regprocin(PG_FUNCTION_ARGS) if (clist == NULL) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_FUNCTION), - errmsg("function \"%s\" does not exist", pro_name_or_oid))); + errmsg("function \"%s\" does not exist", pro_name_or_oid))); else if (clist->next != NULL) ereport(ERROR, (errcode(ERRCODE_AMBIGUOUS_FUNCTION), @@ -172,9 +172,9 @@ regprocout(PG_FUNCTION_ARGS) char *proname = NameStr(procform->proname); /* - * In bootstrap mode, skip the fancy namespace stuff and just - * return the proc name. (This path is only needed for debugging - * output anyway.) + * In bootstrap mode, skip the fancy namespace stuff and just return + * the proc name. (This path is only needed for debugging output + * anyway.) */ if (IsBootstrapProcessingMode()) result = pstrdup(proname); @@ -258,15 +258,15 @@ regprocedurein(PG_FUNCTION_ARGS) strspn(pro_name_or_oid, "0123456789") == strlen(pro_name_or_oid)) { result = DatumGetObjectId(DirectFunctionCall1(oidin, - CStringGetDatum(pro_name_or_oid))); + CStringGetDatum(pro_name_or_oid))); PG_RETURN_OID(result); } /* - * Else it's a name and arguments. Parse the name and arguments, look - * up potential matches in the current namespace search list, and scan - * to see which one exactly matches the given argument types. (There - * will not be more than one match.) + * Else it's a name and arguments. Parse the name and arguments, look up + * potential matches in the current namespace search list, and scan to see + * which one exactly matches the given argument types. (There will not be + * more than one match.) * * XXX at present, this code will not work in bootstrap mode, hence this * datatype cannot be used for any system column that needs to receive @@ -286,7 +286,7 @@ regprocedurein(PG_FUNCTION_ARGS) if (clist == NULL) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_FUNCTION), - errmsg("function \"%s\" does not exist", pro_name_or_oid))); + errmsg("function \"%s\" does not exist", pro_name_or_oid))); result = clist->oid; @@ -323,8 +323,8 @@ format_procedure(Oid procedure_oid) initStringInfo(&buf); /* - * Would this proc be found (given the right args) by - * regprocedurein? If not, we need to qualify it. + * Would this proc be found (given the right args) by regprocedurein? + * If not, we need to qualify it. */ if (FunctionIsVisible(procedure_oid)) nspname = NULL; @@ -421,17 +421,17 @@ regoperin(PG_FUNCTION_ARGS) strspn(opr_name_or_oid, "0123456789") == strlen(opr_name_or_oid)) { result = DatumGetObjectId(DirectFunctionCall1(oidin, - CStringGetDatum(opr_name_or_oid))); + CStringGetDatum(opr_name_or_oid))); PG_RETURN_OID(result); } /* Else it's a name, possibly schema-qualified */ /* - * In bootstrap mode we assume the given name is not schema-qualified, - * and just search pg_operator for a unique match. This is needed for - * initializing other system catalogs (pg_namespace may not exist yet, - * and certainly there are no schemas other than pg_catalog). + * In bootstrap mode we assume the given name is not schema-qualified, and + * just search pg_operator for a unique match. This is needed for + * initializing other system catalogs (pg_namespace may not exist yet, and + * certainly there are no schemas other than pg_catalog). */ if (IsBootstrapProcessingMode()) { @@ -463,7 +463,7 @@ regoperin(PG_FUNCTION_ARGS) if (matches == 0) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_FUNCTION), - errmsg("operator does not exist: %s", opr_name_or_oid))); + errmsg("operator does not exist: %s", opr_name_or_oid))); else if (matches > 1) ereport(ERROR, (errcode(ERRCODE_AMBIGUOUS_FUNCTION), @@ -474,8 +474,8 @@ regoperin(PG_FUNCTION_ARGS) } /* - * Normal case: parse the name into components and see if it matches - * any pg_operator entries in the current search path. + * Normal case: parse the name into components and see if it matches any + * pg_operator entries in the current search path. */ names = stringToQualifiedNameList(opr_name_or_oid, "regoperin"); clist = OpernameGetCandidates(names, '\0'); @@ -521,9 +521,9 @@ regoperout(PG_FUNCTION_ARGS) char *oprname = NameStr(operform->oprname); /* - * In bootstrap mode, skip the fancy namespace stuff and just - * return the oper name. (This path is only needed for debugging - * output anyway.) + * In bootstrap mode, skip the fancy namespace stuff and just return + * the oper name. (This path is only needed for debugging output + * anyway.) */ if (IsBootstrapProcessingMode()) result = pstrdup(oprname); @@ -556,8 +556,7 @@ regoperout(PG_FUNCTION_ARGS) else { /* - * If OID doesn't match any pg_operator entry, return it - * numerically + * If OID doesn't match any pg_operator entry, return it numerically */ result = (char *) palloc(NAMEDATALEN); snprintf(result, NAMEDATALEN, "%u", oprid); @@ -616,15 +615,15 @@ regoperatorin(PG_FUNCTION_ARGS) strspn(opr_name_or_oid, "0123456789") == strlen(opr_name_or_oid)) { result = DatumGetObjectId(DirectFunctionCall1(oidin, - CStringGetDatum(opr_name_or_oid))); + CStringGetDatum(opr_name_or_oid))); PG_RETURN_OID(result); } /* - * Else it's a name and arguments. Parse the name and arguments, look - * up potential matches in the current namespace search list, and scan - * to see which one exactly matches the given argument types. (There - * will not be more than one match.) + * Else it's a name and arguments. Parse the name and arguments, look up + * potential matches in the current namespace search list, and scan to see + * which one exactly matches the given argument types. (There will not be + * more than one match.) * * XXX at present, this code will not work in bootstrap mode, hence this * datatype cannot be used for any system column that needs to receive @@ -696,8 +695,8 @@ format_operator(Oid operator_oid) initStringInfo(&buf); /* - * Would this oper be found (given the right args) by - * regoperatorin? If not, we need to qualify it. + * Would this oper be found (given the right args) by regoperatorin? + * If not, we need to qualify it. */ if (!OperatorIsVisible(operator_oid)) { @@ -727,8 +726,7 @@ format_operator(Oid operator_oid) else { /* - * If OID doesn't match any pg_operator entry, return it - * numerically + * If OID doesn't match any pg_operator entry, return it numerically */ result = (char *) palloc(NAMEDATALEN); snprintf(result, NAMEDATALEN, "%u", operator_oid); @@ -797,20 +795,20 @@ regclassin(PG_FUNCTION_ARGS) /* Numeric OID? */ if (class_name_or_oid[0] >= '0' && class_name_or_oid[0] <= '9' && - strspn(class_name_or_oid, "0123456789") == strlen(class_name_or_oid)) + strspn(class_name_or_oid, "0123456789") == strlen(class_name_or_oid)) { result = DatumGetObjectId(DirectFunctionCall1(oidin, - CStringGetDatum(class_name_or_oid))); + CStringGetDatum(class_name_or_oid))); PG_RETURN_OID(result); } /* Else it's a name, possibly schema-qualified */ /* - * In bootstrap mode we assume the given name is not schema-qualified, - * and just search pg_class for a match. This is needed for - * initializing other system catalogs (pg_namespace may not exist yet, - * and certainly there are no schemas other than pg_catalog). + * In bootstrap mode we assume the given name is not schema-qualified, and + * just search pg_class for a match. This is needed for initializing + * other system catalogs (pg_namespace may not exist yet, and certainly + * there are no schemas other than pg_catalog). */ if (IsBootstrapProcessingMode()) { @@ -833,7 +831,7 @@ regclassin(PG_FUNCTION_ARGS) else ereport(ERROR, (errcode(ERRCODE_UNDEFINED_TABLE), - errmsg("relation \"%s\" does not exist", class_name_or_oid))); + errmsg("relation \"%s\" does not exist", class_name_or_oid))); /* We assume there can be only one match */ @@ -844,8 +842,8 @@ regclassin(PG_FUNCTION_ARGS) } /* - * Normal case: parse the name into components and see if it matches - * any pg_class entries in the current search path. + * Normal case: parse the name into components and see if it matches any + * pg_class entries in the current search path. */ names = stringToQualifiedNameList(class_name_or_oid, "regclassin"); @@ -880,9 +878,9 @@ regclassout(PG_FUNCTION_ARGS) char *classname = NameStr(classform->relname); /* - * In bootstrap mode, skip the fancy namespace stuff and just - * return the class name. (This path is only needed for debugging - * output anyway.) + * In bootstrap mode, skip the fancy namespace stuff and just return + * the class name. (This path is only needed for debugging output + * anyway.) */ if (IsBootstrapProcessingMode()) result = pstrdup(classname); @@ -891,8 +889,7 @@ regclassout(PG_FUNCTION_ARGS) char *nspname; /* - * Would this class be found by regclassin? If not, qualify - * it. + * Would this class be found by regclassin? If not, qualify it. */ if (RelationIsVisible(classid)) nspname = NULL; @@ -966,17 +963,17 @@ regtypein(PG_FUNCTION_ARGS) strspn(typ_name_or_oid, "0123456789") == strlen(typ_name_or_oid)) { result = DatumGetObjectId(DirectFunctionCall1(oidin, - CStringGetDatum(typ_name_or_oid))); + CStringGetDatum(typ_name_or_oid))); PG_RETURN_OID(result); } /* Else it's a type name, possibly schema-qualified or decorated */ /* - * In bootstrap mode we assume the given name is not schema-qualified, - * and just search pg_type for a match. This is needed for - * initializing other system catalogs (pg_namespace may not exist yet, - * and certainly there are no schemas other than pg_catalog). + * In bootstrap mode we assume the given name is not schema-qualified, and + * just search pg_type for a match. This is needed for initializing other + * system catalogs (pg_namespace may not exist yet, and certainly there + * are no schemas other than pg_catalog). */ if (IsBootstrapProcessingMode()) { @@ -999,7 +996,7 @@ regtypein(PG_FUNCTION_ARGS) else ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), - errmsg("type \"%s\" does not exist", typ_name_or_oid))); + errmsg("type \"%s\" does not exist", typ_name_or_oid))); /* We assume there can be only one match */ @@ -1010,8 +1007,8 @@ regtypein(PG_FUNCTION_ARGS) } /* - * Normal case: invoke the full parser to deal with special cases such - * as array syntax. + * Normal case: invoke the full parser to deal with special cases such as + * array syntax. */ parseTypeString(typ_name_or_oid, &result, &typmod); @@ -1043,9 +1040,9 @@ regtypeout(PG_FUNCTION_ARGS) Form_pg_type typeform = (Form_pg_type) GETSTRUCT(typetup); /* - * In bootstrap mode, skip the fancy namespace stuff and just - * return the type name. (This path is only needed for debugging - * output anyway.) + * In bootstrap mode, skip the fancy namespace stuff and just return + * the type name. (This path is only needed for debugging output + * anyway.) */ if (IsBootstrapProcessingMode()) { diff --git a/src/backend/utils/adt/ri_triggers.c b/src/backend/utils/adt/ri_triggers.c index 8de31643a6..c49b17be10 100644 --- a/src/backend/utils/adt/ri_triggers.c +++ b/src/backend/utils/adt/ri_triggers.c @@ -17,7 +17,7 @@ * * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/backend/utils/adt/ri_triggers.c,v 1.80 2005/06/28 05:09:00 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/ri_triggers.c,v 1.81 2005/10/15 02:49:29 momjian Exp $ * * ---------- */ @@ -194,8 +194,7 @@ RI_FKey_check(PG_FUNCTION_ARGS) int match_type; /* - * Check that this is a valid trigger call on the right time and - * event. + * Check that this is a valid trigger call on the right time and event. */ ri_CheckTrigger(fcinfo, "RI_FKey_check", RI_TRIGTYPE_INUP); @@ -203,8 +202,7 @@ RI_FKey_check(PG_FUNCTION_ARGS) tgargs = trigdata->tg_trigger->tgargs; /* - * Get the relation descriptors of the FK and PK tables and the new - * tuple. + * Get the relation descriptors of the FK and PK tables and the new tuple. * * pk_rel is opened in RowShareLock mode since that's what our eventual * SELECT FOR SHARE will get on it. @@ -225,9 +223,9 @@ RI_FKey_check(PG_FUNCTION_ARGS) } /* - * We should not even consider checking the row if it is no longer - * valid since it was either deleted (doesn't matter) or updated (in - * which case it'll be checked with its final values). + * We should not even consider checking the row if it is no longer valid + * since it was either deleted (doesn't matter) or updated (in which case + * it'll be checked with its final values). */ Assert(new_row_buf != InvalidBuffer); if (!HeapTupleSatisfiesItself(new_row->t_data, new_row_buf)) @@ -311,8 +309,8 @@ RI_FKey_check(PG_FUNCTION_ARGS) case RI_KEYS_ALL_NULL: /* - * No check - if NULLs are allowed at all is already checked - * by NOT NULL constraint. + * No check - if NULLs are allowed at all is already checked by + * NOT NULL constraint. * * This is true for MATCH FULL, MATCH PARTIAL, and MATCH * @@ -323,21 +321,21 @@ RI_FKey_check(PG_FUNCTION_ARGS) case RI_KEYS_SOME_NULL: /* - * This is the only case that differs between the three kinds - * of MATCH. + * This is the only case that differs between the three kinds of + * MATCH. */ switch (match_type) { case RI_MATCH_TYPE_FULL: /* - * Not allowed - MATCH FULL says either all or none of - * the attributes can be NULLs + * Not allowed - MATCH FULL says either all or none of the + * attributes can be NULLs */ ereport(ERROR, (errcode(ERRCODE_FOREIGN_KEY_VIOLATION), errmsg("insert or update on table \"%s\" violates foreign key constraint \"%s\"", - RelationGetRelationName(trigdata->tg_relation), + RelationGetRelationName(trigdata->tg_relation), tgargs[RI_CONSTRAINT_NAME_ARGNO]), errdetail("MATCH FULL does not allow mixing of null and nonnull key values."))); heap_close(pk_rel, RowShareLock); @@ -346,8 +344,8 @@ RI_FKey_check(PG_FUNCTION_ARGS) case RI_MATCH_TYPE_UNSPECIFIED: /* - * MATCH - if ANY column is null, we - * have a match. + * MATCH - if ANY column is null, we have a + * match. */ heap_close(pk_rel, RowShareLock); return PointerGetDatum(NULL); @@ -355,14 +353,14 @@ RI_FKey_check(PG_FUNCTION_ARGS) case RI_MATCH_TYPE_PARTIAL: /* - * MATCH PARTIAL - all non-null columns must match. - * (not implemented, can be done by modifying the - * query below to only include non-null columns, or by - * writing a special version here) + * MATCH PARTIAL - all non-null columns must match. (not + * implemented, can be done by modifying the query below + * to only include non-null columns, or by writing a + * special version here) */ ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("MATCH PARTIAL not yet implemented"))); + errmsg("MATCH PARTIAL not yet implemented"))); heap_close(pk_rel, RowShareLock); return PointerGetDatum(NULL); } @@ -370,8 +368,8 @@ RI_FKey_check(PG_FUNCTION_ARGS) case RI_KEYS_NONE_NULL: /* - * Have a full qualified key - continue below for all three - * kinds of MATCH. + * Have a full qualified key - continue below for all three kinds + * of MATCH. */ break; } @@ -385,7 +383,7 @@ RI_FKey_check(PG_FUNCTION_ARGS) if ((qplan = ri_FetchPreparedPlan(&qkey)) == NULL) { char querystr[MAX_QUOTED_REL_NAME_LEN + 100 + - (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS]; + (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS]; char pkrelname[MAX_QUOTED_REL_NAME_LEN]; char attname[MAX_QUOTED_NAME_LEN]; const char *querysep; @@ -406,12 +404,12 @@ RI_FKey_check(PG_FUNCTION_ARGS) for (i = 0; i < qkey.nkeypairs; i++) { quoteOneName(attname, - tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_PK_IDX]); + tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_PK_IDX]); snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), " %s %s = $%d", querysep, attname, i + 1); querysep = "AND"; queryoids[i] = SPI_gettypeid(fk_rel->rd_att, - qkey.keypair[i][RI_KEYPAIR_FK_IDX]); + qkey.keypair[i][RI_KEYPAIR_FK_IDX]); } strcat(querystr, " FOR SHARE OF x"); @@ -493,16 +491,15 @@ ri_Check_Pk_Match(Relation pk_rel, Relation fk_rel, case RI_KEYS_ALL_NULL: /* - * No check - nothing could have been referencing this row - * anyway. + * No check - nothing could have been referencing this row anyway. */ return true; case RI_KEYS_SOME_NULL: /* - * This is the only case that differs between the three kinds - * of MATCH. + * This is the only case that differs between the three kinds of + * MATCH. */ switch (match_type) { @@ -510,30 +507,30 @@ ri_Check_Pk_Match(Relation pk_rel, Relation fk_rel, case RI_MATCH_TYPE_UNSPECIFIED: /* - * MATCH /FULL - if ANY column is null, - * we can't be matching to this row already. + * MATCH /FULL - if ANY column is null, we + * can't be matching to this row already. */ return true; case RI_MATCH_TYPE_PARTIAL: /* - * MATCH PARTIAL - all non-null columns must match. - * (not implemented, can be done by modifying the - * query below to only include non-null columns, or by - * writing a special version here) + * MATCH PARTIAL - all non-null columns must match. (not + * implemented, can be done by modifying the query below + * to only include non-null columns, or by writing a + * special version here) */ ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("MATCH PARTIAL not yet implemented"))); + errmsg("MATCH PARTIAL not yet implemented"))); break; } case RI_KEYS_NONE_NULL: /* - * Have a full qualified key - continue below for all three - * kinds of MATCH. + * Have a full qualified key - continue below for all three kinds + * of MATCH. */ break; } @@ -547,7 +544,7 @@ ri_Check_Pk_Match(Relation pk_rel, Relation fk_rel, if ((qplan = ri_FetchPreparedPlan(&qkey)) == NULL) { char querystr[MAX_QUOTED_REL_NAME_LEN + 100 + - (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS]; + (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS]; char pkrelname[MAX_QUOTED_REL_NAME_LEN]; char attname[MAX_QUOTED_NAME_LEN]; const char *querysep; @@ -568,12 +565,12 @@ ri_Check_Pk_Match(Relation pk_rel, Relation fk_rel, for (i = 0; i < qkey.nkeypairs; i++) { quoteOneName(attname, - tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_PK_IDX]); + tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_PK_IDX]); snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), " %s %s = $%d", querysep, attname, i + 1); querysep = "AND"; queryoids[i] = SPI_gettypeid(pk_rel->rd_att, - qkey.keypair[i][RI_KEYPAIR_PK_IDX]); + qkey.keypair[i][RI_KEYPAIR_PK_IDX]); } strcat(querystr, " FOR SHARE OF x"); @@ -621,8 +618,7 @@ RI_FKey_noaction_del(PG_FUNCTION_ARGS) int match_type; /* - * Check that this is a valid trigger call on the right time and - * event. + * Check that this is a valid trigger call on the right time and event. */ ri_CheckTrigger(fcinfo, "RI_FKey_noaction_del", RI_TRIGTYPE_DELETE); @@ -636,8 +632,7 @@ RI_FKey_noaction_del(PG_FUNCTION_ARGS) return PointerGetDatum(NULL); /* - * Get the relation descriptors of the FK and PK tables and the old - * tuple. + * Get the relation descriptors of the FK and PK tables and the old tuple. * * fk_rel is opened in RowShareLock mode since that's what our eventual * SELECT FOR SHARE will get on it. @@ -699,13 +694,13 @@ RI_FKey_noaction_del(PG_FUNCTION_ARGS) elog(ERROR, "SPI_connect failed"); /* - * Fetch or prepare a saved plan for the restrict delete - * lookup if foreign references exist + * Fetch or prepare a saved plan for the restrict delete lookup if + * foreign references exist */ if ((qplan = ri_FetchPreparedPlan(&qkey)) == NULL) { char querystr[MAX_QUOTED_REL_NAME_LEN + 100 + - (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS]; + (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS]; char fkrelname[MAX_QUOTED_REL_NAME_LEN]; char attname[MAX_QUOTED_NAME_LEN]; const char *querysep; @@ -731,7 +726,7 @@ RI_FKey_noaction_del(PG_FUNCTION_ARGS) querysep, attname, i + 1); querysep = "AND"; queryoids[i] = SPI_gettypeid(pk_rel->rd_att, - qkey.keypair[i][RI_KEYPAIR_PK_IDX]); + qkey.keypair[i][RI_KEYPAIR_PK_IDX]); } strcat(querystr, " FOR SHARE OF x"); @@ -741,8 +736,7 @@ RI_FKey_noaction_del(PG_FUNCTION_ARGS) } /* - * We have a plan now. Run it to check for existing - * references. + * We have a plan now. Run it to check for existing references. */ ri_PerformCheck(&qkey, qplan, fk_rel, pk_rel, @@ -800,8 +794,7 @@ RI_FKey_noaction_upd(PG_FUNCTION_ARGS) int match_type; /* - * Check that this is a valid trigger call on the right time and - * event. + * Check that this is a valid trigger call on the right time and event. */ ri_CheckTrigger(fcinfo, "RI_FKey_noaction_upd", RI_TRIGTYPE_UPDATE); @@ -815,8 +808,8 @@ RI_FKey_noaction_upd(PG_FUNCTION_ARGS) return PointerGetDatum(NULL); /* - * Get the relation descriptors of the FK and PK tables and the new - * and old tuple. + * Get the relation descriptors of the FK and PK tables and the new and + * old tuple. * * fk_rel is opened in RowShareLock mode since that's what our eventual * SELECT FOR SHARE will get on it. @@ -879,8 +872,8 @@ RI_FKey_noaction_upd(PG_FUNCTION_ARGS) match_type, tgnargs, tgargs)) { /* - * There's either another row, or no row could match this - * one. In either case, we don't need to do the check. + * There's either another row, or no row could match this one. + * In either case, we don't need to do the check. */ heap_close(fk_rel, RowShareLock); return PointerGetDatum(NULL); @@ -890,13 +883,13 @@ RI_FKey_noaction_upd(PG_FUNCTION_ARGS) elog(ERROR, "SPI_connect failed"); /* - * Fetch or prepare a saved plan for the noaction update - * lookup if foreign references exist + * Fetch or prepare a saved plan for the noaction update lookup if + * foreign references exist */ if ((qplan = ri_FetchPreparedPlan(&qkey)) == NULL) { char querystr[MAX_QUOTED_REL_NAME_LEN + 100 + - (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS]; + (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS]; char fkrelname[MAX_QUOTED_REL_NAME_LEN]; char attname[MAX_QUOTED_NAME_LEN]; const char *querysep; @@ -922,7 +915,7 @@ RI_FKey_noaction_upd(PG_FUNCTION_ARGS) querysep, attname, i + 1); querysep = "AND"; queryoids[i] = SPI_gettypeid(pk_rel->rd_att, - qkey.keypair[i][RI_KEYPAIR_PK_IDX]); + qkey.keypair[i][RI_KEYPAIR_PK_IDX]); } strcat(querystr, " FOR SHARE OF x"); @@ -932,8 +925,7 @@ RI_FKey_noaction_upd(PG_FUNCTION_ARGS) } /* - * We have a plan now. Run it to check for existing - * references. + * We have a plan now. Run it to check for existing references. */ ri_PerformCheck(&qkey, qplan, fk_rel, pk_rel, @@ -987,8 +979,7 @@ RI_FKey_cascade_del(PG_FUNCTION_ARGS) int i; /* - * Check that this is a valid trigger call on the right time and - * event. + * Check that this is a valid trigger call on the right time and event. */ ri_CheckTrigger(fcinfo, "RI_FKey_cascade_del", RI_TRIGTYPE_DELETE); @@ -1002,11 +993,10 @@ RI_FKey_cascade_del(PG_FUNCTION_ARGS) return PointerGetDatum(NULL); /* - * Get the relation descriptors of the FK and PK tables and the old - * tuple. + * Get the relation descriptors of the FK and PK tables and the old tuple. * - * fk_rel is opened in RowExclusiveLock mode since that's what our - * eventual DELETE will get on it. + * fk_rel is opened in RowExclusiveLock mode since that's what our eventual + * DELETE will get on it. */ fk_rel = heap_open(trigdata->tg_trigger->tgconstrrelid, RowExclusiveLock); pk_rel = trigdata->tg_relation; @@ -1057,7 +1047,7 @@ RI_FKey_cascade_del(PG_FUNCTION_ARGS) if ((qplan = ri_FetchPreparedPlan(&qkey)) == NULL) { char querystr[MAX_QUOTED_REL_NAME_LEN + 100 + - (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS]; + (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS]; char fkrelname[MAX_QUOTED_REL_NAME_LEN]; char attname[MAX_QUOTED_NAME_LEN]; const char *querysep; @@ -1083,7 +1073,7 @@ RI_FKey_cascade_del(PG_FUNCTION_ARGS) querysep, attname, i + 1); querysep = "AND"; queryoids[i] = SPI_gettypeid(pk_rel->rd_att, - qkey.keypair[i][RI_KEYPAIR_PK_IDX]); + qkey.keypair[i][RI_KEYPAIR_PK_IDX]); } /* Prepare and save the plan */ @@ -1092,9 +1082,8 @@ RI_FKey_cascade_del(PG_FUNCTION_ARGS) } /* - * We have a plan now. Build up the arguments from the key - * values in the deleted PK tuple and delete the referencing - * rows + * We have a plan now. Build up the arguments from the key values + * in the deleted PK tuple and delete the referencing rows */ ri_PerformCheck(&qkey, qplan, fk_rel, pk_rel, @@ -1150,8 +1139,7 @@ RI_FKey_cascade_upd(PG_FUNCTION_ARGS) int j; /* - * Check that this is a valid trigger call on the right time and - * event. + * Check that this is a valid trigger call on the right time and event. */ ri_CheckTrigger(fcinfo, "RI_FKey_cascade_upd", RI_TRIGTYPE_UPDATE); @@ -1165,11 +1153,11 @@ RI_FKey_cascade_upd(PG_FUNCTION_ARGS) return PointerGetDatum(NULL); /* - * Get the relation descriptors of the FK and PK tables and the new - * and old tuple. + * Get the relation descriptors of the FK and PK tables and the new and + * old tuple. * - * fk_rel is opened in RowExclusiveLock mode since that's what our - * eventual UPDATE will get on it. + * fk_rel is opened in RowExclusiveLock mode since that's what our eventual + * UPDATE will get on it. */ fk_rel = heap_open(trigdata->tg_trigger->tgconstrrelid, RowExclusiveLock); pk_rel = trigdata->tg_relation; @@ -1232,7 +1220,7 @@ RI_FKey_cascade_upd(PG_FUNCTION_ARGS) if ((qplan = ri_FetchPreparedPlan(&qkey)) == NULL) { char querystr[MAX_QUOTED_REL_NAME_LEN + 100 + - (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS * 2]; + (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS * 2]; char qualstr[(MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS]; char fkrelname[MAX_QUOTED_REL_NAME_LEN]; char attname[MAX_QUOTED_NAME_LEN]; @@ -1266,7 +1254,7 @@ RI_FKey_cascade_upd(PG_FUNCTION_ARGS) querysep = ","; qualsep = "AND"; queryoids[i] = SPI_gettypeid(pk_rel->rd_att, - qkey.keypair[i][RI_KEYPAIR_PK_IDX]); + qkey.keypair[i][RI_KEYPAIR_PK_IDX]); queryoids[j] = queryoids[i]; } strcat(querystr, qualstr); @@ -1277,8 +1265,7 @@ RI_FKey_cascade_upd(PG_FUNCTION_ARGS) } /* - * We have a plan now. Run it to update the existing - * references. + * We have a plan now. Run it to update the existing references. */ ri_PerformCheck(&qkey, qplan, fk_rel, pk_rel, @@ -1339,8 +1326,7 @@ RI_FKey_restrict_del(PG_FUNCTION_ARGS) int i; /* - * Check that this is a valid trigger call on the right time and - * event. + * Check that this is a valid trigger call on the right time and event. */ ri_CheckTrigger(fcinfo, "RI_FKey_restrict_del", RI_TRIGTYPE_DELETE); @@ -1354,8 +1340,7 @@ RI_FKey_restrict_del(PG_FUNCTION_ARGS) return PointerGetDatum(NULL); /* - * Get the relation descriptors of the FK and PK tables and the old - * tuple. + * Get the relation descriptors of the FK and PK tables and the old tuple. * * fk_rel is opened in RowShareLock mode since that's what our eventual * SELECT FOR SHARE will get on it. @@ -1404,13 +1389,13 @@ RI_FKey_restrict_del(PG_FUNCTION_ARGS) elog(ERROR, "SPI_connect failed"); /* - * Fetch or prepare a saved plan for the restrict delete - * lookup if foreign references exist + * Fetch or prepare a saved plan for the restrict delete lookup if + * foreign references exist */ if ((qplan = ri_FetchPreparedPlan(&qkey)) == NULL) { char querystr[MAX_QUOTED_REL_NAME_LEN + 100 + - (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS]; + (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS]; char fkrelname[MAX_QUOTED_REL_NAME_LEN]; char attname[MAX_QUOTED_NAME_LEN]; const char *querysep; @@ -1436,7 +1421,7 @@ RI_FKey_restrict_del(PG_FUNCTION_ARGS) querysep, attname, i + 1); querysep = "AND"; queryoids[i] = SPI_gettypeid(pk_rel->rd_att, - qkey.keypair[i][RI_KEYPAIR_PK_IDX]); + qkey.keypair[i][RI_KEYPAIR_PK_IDX]); } strcat(querystr, " FOR SHARE OF x"); @@ -1446,8 +1431,7 @@ RI_FKey_restrict_del(PG_FUNCTION_ARGS) } /* - * We have a plan now. Run it to check for existing - * references. + * We have a plan now. Run it to check for existing references. */ ri_PerformCheck(&qkey, qplan, fk_rel, pk_rel, @@ -1509,8 +1493,7 @@ RI_FKey_restrict_upd(PG_FUNCTION_ARGS) int i; /* - * Check that this is a valid trigger call on the right time and - * event. + * Check that this is a valid trigger call on the right time and event. */ ri_CheckTrigger(fcinfo, "RI_FKey_restrict_upd", RI_TRIGTYPE_UPDATE); @@ -1524,8 +1507,8 @@ RI_FKey_restrict_upd(PG_FUNCTION_ARGS) return PointerGetDatum(NULL); /* - * Get the relation descriptors of the FK and PK tables and the new - * and old tuple. + * Get the relation descriptors of the FK and PK tables and the new and + * old tuple. * * fk_rel is opened in RowShareLock mode since that's what our eventual * SELECT FOR SHARE will get on it. @@ -1585,13 +1568,13 @@ RI_FKey_restrict_upd(PG_FUNCTION_ARGS) elog(ERROR, "SPI_connect failed"); /* - * Fetch or prepare a saved plan for the restrict update - * lookup if foreign references exist + * Fetch or prepare a saved plan for the restrict update lookup if + * foreign references exist */ if ((qplan = ri_FetchPreparedPlan(&qkey)) == NULL) { char querystr[MAX_QUOTED_REL_NAME_LEN + 100 + - (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS]; + (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS]; char fkrelname[MAX_QUOTED_REL_NAME_LEN]; char attname[MAX_QUOTED_NAME_LEN]; const char *querysep; @@ -1617,7 +1600,7 @@ RI_FKey_restrict_upd(PG_FUNCTION_ARGS) querysep, attname, i + 1); querysep = "AND"; queryoids[i] = SPI_gettypeid(pk_rel->rd_att, - qkey.keypair[i][RI_KEYPAIR_PK_IDX]); + qkey.keypair[i][RI_KEYPAIR_PK_IDX]); } strcat(querystr, " FOR SHARE OF x"); @@ -1627,8 +1610,7 @@ RI_FKey_restrict_upd(PG_FUNCTION_ARGS) } /* - * We have a plan now. Run it to check for existing - * references. + * We have a plan now. Run it to check for existing references. */ ri_PerformCheck(&qkey, qplan, fk_rel, pk_rel, @@ -1682,8 +1664,7 @@ RI_FKey_setnull_del(PG_FUNCTION_ARGS) int i; /* - * Check that this is a valid trigger call on the right time and - * event. + * Check that this is a valid trigger call on the right time and event. */ ri_CheckTrigger(fcinfo, "RI_FKey_setnull_del", RI_TRIGTYPE_DELETE); @@ -1697,11 +1678,10 @@ RI_FKey_setnull_del(PG_FUNCTION_ARGS) return PointerGetDatum(NULL); /* - * Get the relation descriptors of the FK and PK tables and the old - * tuple. + * Get the relation descriptors of the FK and PK tables and the old tuple. * - * fk_rel is opened in RowExclusiveLock mode since that's what our - * eventual UPDATE will get on it. + * fk_rel is opened in RowExclusiveLock mode since that's what our eventual + * UPDATE will get on it. */ fk_rel = heap_open(trigdata->tg_trigger->tgconstrrelid, RowExclusiveLock); pk_rel = trigdata->tg_relation; @@ -1747,13 +1727,12 @@ RI_FKey_setnull_del(PG_FUNCTION_ARGS) elog(ERROR, "SPI_connect failed"); /* - * Fetch or prepare a saved plan for the set null delete - * operation + * Fetch or prepare a saved plan for the set null delete operation */ if ((qplan = ri_FetchPreparedPlan(&qkey)) == NULL) { char querystr[MAX_QUOTED_REL_NAME_LEN + 100 + - (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS * 2]; + (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS * 2]; char qualstr[(MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS]; char fkrelname[MAX_QUOTED_REL_NAME_LEN]; char attname[MAX_QUOTED_NAME_LEN]; @@ -1787,7 +1766,7 @@ RI_FKey_setnull_del(PG_FUNCTION_ARGS) querysep = ","; qualsep = "AND"; queryoids[i] = SPI_gettypeid(pk_rel->rd_att, - qkey.keypair[i][RI_KEYPAIR_PK_IDX]); + qkey.keypair[i][RI_KEYPAIR_PK_IDX]); } strcat(querystr, qualstr); @@ -1797,8 +1776,7 @@ RI_FKey_setnull_del(PG_FUNCTION_ARGS) } /* - * We have a plan now. Run it to check for existing - * references. + * We have a plan now. Run it to check for existing references. */ ri_PerformCheck(&qkey, qplan, fk_rel, pk_rel, @@ -1855,8 +1833,7 @@ RI_FKey_setnull_upd(PG_FUNCTION_ARGS) bool use_cached_query; /* - * Check that this is a valid trigger call on the right time and - * event. + * Check that this is a valid trigger call on the right time and event. */ ri_CheckTrigger(fcinfo, "RI_FKey_setnull_upd", RI_TRIGTYPE_UPDATE); @@ -1870,11 +1847,10 @@ RI_FKey_setnull_upd(PG_FUNCTION_ARGS) return PointerGetDatum(NULL); /* - * Get the relation descriptors of the FK and PK tables and the old - * tuple. + * Get the relation descriptors of the FK and PK tables and the old tuple. * - * fk_rel is opened in RowExclusiveLock mode since that's what our - * eventual UPDATE will get on it. + * fk_rel is opened in RowExclusiveLock mode since that's what our eventual + * UPDATE will get on it. */ fk_rel = heap_open(trigdata->tg_trigger->tgconstrrelid, RowExclusiveLock); pk_rel = trigdata->tg_relation; @@ -1932,17 +1908,16 @@ RI_FKey_setnull_upd(PG_FUNCTION_ARGS) elog(ERROR, "SPI_connect failed"); /* - * "MATCH " only changes columns corresponding to - * the referenced columns that have changed in pk_rel. This - * means the "SET attrn=NULL [, attrn=NULL]" string will be - * change as well. In this case, we need to build a temporary - * plan rather than use our cached plan, unless the update - * happens to change all columns in the key. Fortunately, for - * the most common case of a single-column foreign key, this - * will be true. + * "MATCH " only changes columns corresponding to the + * referenced columns that have changed in pk_rel. This means the + * "SET attrn=NULL [, attrn=NULL]" string will be change as well. + * In this case, we need to build a temporary plan rather than use + * our cached plan, unless the update happens to change all + * columns in the key. Fortunately, for the most common case of a + * single-column foreign key, this will be true. * - * In case you're wondering, the inequality check works because - * we know that the old key value has no NULLs (see above). + * In case you're wondering, the inequality check works because we + * know that the old key value has no NULLs (see above). */ use_cached_query = match_type == RI_MATCH_TYPE_FULL || @@ -1950,14 +1925,14 @@ RI_FKey_setnull_upd(PG_FUNCTION_ARGS) &qkey, RI_KEYPAIR_PK_IDX); /* - * Fetch or prepare a saved plan for the set null update - * operation if possible, or build a temporary plan if not. + * Fetch or prepare a saved plan for the set null update operation + * if possible, or build a temporary plan if not. */ if (!use_cached_query || (qplan = ri_FetchPreparedPlan(&qkey)) == NULL) { char querystr[MAX_QUOTED_REL_NAME_LEN + 100 + - (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS * 2]; + (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS * 2]; char qualstr[(MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS]; char fkrelname[MAX_QUOTED_REL_NAME_LEN]; char attname[MAX_QUOTED_NAME_LEN]; @@ -1986,8 +1961,8 @@ RI_FKey_setnull_upd(PG_FUNCTION_ARGS) tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]); /* - * MATCH - only change columns - * corresponding to changed columns in pk_rel's key + * MATCH - only change columns corresponding + * to changed columns in pk_rel's key */ if (match_type == RI_MATCH_TYPE_FULL || !ri_OneKeyEqual(pk_rel, i, old_row, new_row, &qkey, @@ -2001,7 +1976,7 @@ RI_FKey_setnull_upd(PG_FUNCTION_ARGS) qualsep, attname, i + 1); qualsep = "AND"; queryoids[i] = SPI_gettypeid(pk_rel->rd_att, - qkey.keypair[i][RI_KEYPAIR_PK_IDX]); + qkey.keypair[i][RI_KEYPAIR_PK_IDX]); } strcat(querystr, qualstr); @@ -2015,8 +1990,7 @@ RI_FKey_setnull_upd(PG_FUNCTION_ARGS) } /* - * We have a plan now. Run it to update the existing - * references. + * We have a plan now. Run it to update the existing references. */ ri_PerformCheck(&qkey, qplan, fk_rel, pk_rel, @@ -2069,8 +2043,7 @@ RI_FKey_setdefault_del(PG_FUNCTION_ARGS) void *qplan; /* - * Check that this is a valid trigger call on the right time and - * event. + * Check that this is a valid trigger call on the right time and event. */ ri_CheckTrigger(fcinfo, "RI_FKey_setdefault_del", RI_TRIGTYPE_DELETE); @@ -2084,11 +2057,10 @@ RI_FKey_setdefault_del(PG_FUNCTION_ARGS) return PointerGetDatum(NULL); /* - * Get the relation descriptors of the FK and PK tables and the old - * tuple. + * Get the relation descriptors of the FK and PK tables and the old tuple. * - * fk_rel is opened in RowExclusiveLock mode since that's what our - * eventual UPDATE will get on it. + * fk_rel is opened in RowExclusiveLock mode since that's what our eventual + * UPDATE will get on it. */ fk_rel = heap_open(trigdata->tg_trigger->tgconstrrelid, RowExclusiveLock); pk_rel = trigdata->tg_relation; @@ -2135,12 +2107,12 @@ RI_FKey_setdefault_del(PG_FUNCTION_ARGS) /* * Prepare a plan for the set default delete operation. - * Unfortunately we need to do it on every invocation because - * the default value could potentially change between calls. + * Unfortunately we need to do it on every invocation because the + * default value could potentially change between calls. */ { char querystr[MAX_QUOTED_REL_NAME_LEN + 100 + - (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS * 2]; + (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS * 2]; char qualstr[(MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS]; char fkrelname[MAX_QUOTED_REL_NAME_LEN]; char attname[MAX_QUOTED_NAME_LEN]; @@ -2175,7 +2147,7 @@ RI_FKey_setdefault_del(PG_FUNCTION_ARGS) querysep = ","; qualsep = "AND"; queryoids[i] = SPI_gettypeid(pk_rel->rd_att, - qkey.keypair[i][RI_KEYPAIR_PK_IDX]); + qkey.keypair[i][RI_KEYPAIR_PK_IDX]); } strcat(querystr, qualstr); @@ -2185,8 +2157,7 @@ RI_FKey_setdefault_del(PG_FUNCTION_ARGS) } /* - * We have a plan now. Run it to update the existing - * references. + * We have a plan now. Run it to update the existing references. */ ri_PerformCheck(&qkey, qplan, fk_rel, pk_rel, @@ -2201,12 +2172,12 @@ RI_FKey_setdefault_del(PG_FUNCTION_ARGS) heap_close(fk_rel, RowExclusiveLock); /* - * In the case we delete the row who's key is equal to the - * default values AND a referencing row in the foreign key - * table exists, we would just have updated it to the same - * values. We need to do another lookup now and in case a - * reference exists, abort the operation. That is already - * implemented in the NO ACTION trigger. + * In the case we delete the row who's key is equal to the default + * values AND a referencing row in the foreign key table exists, + * we would just have updated it to the same values. We need to do + * another lookup now and in case a reference exists, abort the + * operation. That is already implemented in the NO ACTION + * trigger. */ RI_FKey_noaction_del(fcinfo); @@ -2251,8 +2222,7 @@ RI_FKey_setdefault_upd(PG_FUNCTION_ARGS) int match_type; /* - * Check that this is a valid trigger call on the right time and - * event. + * Check that this is a valid trigger call on the right time and event. */ ri_CheckTrigger(fcinfo, "RI_FKey_setdefault_upd", RI_TRIGTYPE_UPDATE); @@ -2266,11 +2236,10 @@ RI_FKey_setdefault_upd(PG_FUNCTION_ARGS) return PointerGetDatum(NULL); /* - * Get the relation descriptors of the FK and PK tables and the old - * tuple. + * Get the relation descriptors of the FK and PK tables and the old tuple. * - * fk_rel is opened in RowExclusiveLock mode since that's what our - * eventual UPDATE will get on it. + * fk_rel is opened in RowExclusiveLock mode since that's what our eventual + * UPDATE will get on it. */ fk_rel = heap_open(trigdata->tg_trigger->tgconstrrelid, RowExclusiveLock); pk_rel = trigdata->tg_relation; @@ -2330,12 +2299,12 @@ RI_FKey_setdefault_upd(PG_FUNCTION_ARGS) /* * Prepare a plan for the set default delete operation. - * Unfortunately we need to do it on every invocation because - * the default value could potentially change between calls. + * Unfortunately we need to do it on every invocation because the + * default value could potentially change between calls. */ { char querystr[MAX_QUOTED_REL_NAME_LEN + 100 + - (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS * 2]; + (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS * 2]; char qualstr[(MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS]; char fkrelname[MAX_QUOTED_REL_NAME_LEN]; char attname[MAX_QUOTED_NAME_LEN]; @@ -2365,12 +2334,12 @@ RI_FKey_setdefault_upd(PG_FUNCTION_ARGS) tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]); /* - * MATCH - only change columns - * corresponding to changed columns in pk_rel's key + * MATCH - only change columns corresponding + * to changed columns in pk_rel's key */ if (match_type == RI_MATCH_TYPE_FULL || !ri_OneKeyEqual(pk_rel, i, old_row, - new_row, &qkey, RI_KEYPAIR_PK_IDX)) + new_row, &qkey, RI_KEYPAIR_PK_IDX)) { snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), "%s %s = DEFAULT", querysep, attname); @@ -2380,7 +2349,7 @@ RI_FKey_setdefault_upd(PG_FUNCTION_ARGS) qualsep, attname, i + 1); qualsep = "AND"; queryoids[i] = SPI_gettypeid(pk_rel->rd_att, - qkey.keypair[i][RI_KEYPAIR_PK_IDX]); + qkey.keypair[i][RI_KEYPAIR_PK_IDX]); } strcat(querystr, qualstr); @@ -2390,8 +2359,7 @@ RI_FKey_setdefault_upd(PG_FUNCTION_ARGS) } /* - * We have a plan now. Run it to update the existing - * references. + * We have a plan now. Run it to update the existing references. */ ri_PerformCheck(&qkey, qplan, fk_rel, pk_rel, @@ -2407,11 +2375,11 @@ RI_FKey_setdefault_upd(PG_FUNCTION_ARGS) /* * In the case we updated the row who's key was equal to the - * default values AND a referencing row in the foreign key - * table exists, we would just have updated it to the same - * values. We need to do another lookup now and in case a - * reference exists, abort the operation. That is already - * implemented in the NO ACTION trigger. + * default values AND a referencing row in the foreign key table + * exists, we would just have updated it to the same values. We + * need to do another lookup now and in case a reference exists, + * abort the operation. That is already implemented in the NO + * ACTION trigger. */ RI_FKey_noaction_upd(fcinfo); @@ -2474,11 +2442,11 @@ RI_FKey_keyequal_upd_pk(Trigger *trigger, Relation pk_rel, if (!OidIsValid(trigger->tgconstrrelid)) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("no target table given for trigger \"%s\" on table \"%s\"", - trigger->tgname, - RelationGetRelationName(pk_rel)), - errhint("Remove this referential integrity trigger and its mates, " - "then do ALTER TABLE ADD CONSTRAINT."))); + errmsg("no target table given for trigger \"%s\" on table \"%s\"", + trigger->tgname, + RelationGetRelationName(pk_rel)), + errhint("Remove this referential integrity trigger and its mates, " + "then do ALTER TABLE ADD CONSTRAINT."))); fk_rel = heap_open(trigger->tgconstrrelid, AccessShareLock); @@ -2496,7 +2464,7 @@ RI_FKey_keyequal_upd_pk(Trigger *trigger, Relation pk_rel, return ri_KeysEqual(pk_rel, old_row, new_row, &qkey, RI_KEYPAIR_PK_IDX); - /* Handle MATCH PARTIAL set null delete. */ + /* Handle MATCH PARTIAL set null delete. */ case RI_MATCH_TYPE_PARTIAL: ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), @@ -2548,11 +2516,11 @@ RI_FKey_keyequal_upd_fk(Trigger *trigger, Relation fk_rel, if (!OidIsValid(trigger->tgconstrrelid)) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("no target table given for trigger \"%s\" on table \"%s\"", - trigger->tgname, - RelationGetRelationName(fk_rel)), - errhint("Remove this referential integrity trigger and its mates, " - "then do ALTER TABLE ADD CONSTRAINT."))); + errmsg("no target table given for trigger \"%s\" on table \"%s\"", + trigger->tgname, + RelationGetRelationName(fk_rel)), + errhint("Remove this referential integrity trigger and its mates, " + "then do ALTER TABLE ADD CONSTRAINT."))); pk_rel = heap_open(trigger->tgconstrrelid, AccessShareLock); @@ -2570,7 +2538,7 @@ RI_FKey_keyequal_upd_fk(Trigger *trigger, Relation fk_rel, return ri_KeysEqual(fk_rel, old_row, new_row, &qkey, RI_KEYPAIR_FK_IDX); - /* Handle MATCH PARTIAL set null delete. */ + /* Handle MATCH PARTIAL set null delete. */ case RI_MATCH_TYPE_PARTIAL: ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), @@ -2603,7 +2571,7 @@ RI_Initial_Check(FkConstraint *fkconstraint, Relation rel, Relation pkrel) { const char *constrname = fkconstraint->constr_name; char querystr[MAX_QUOTED_REL_NAME_LEN * 2 + 250 + - (MAX_QUOTED_NAME_LEN + 32) * ((RI_MAX_NUMKEYS * 4) + 1)]; + (MAX_QUOTED_NAME_LEN + 32) * ((RI_MAX_NUMKEYS * 4) + 1)]; char pkrelname[MAX_QUOTED_REL_NAME_LEN]; char relname[MAX_QUOTED_REL_NAME_LEN]; char attname[MAX_QUOTED_NAME_LEN]; @@ -2617,9 +2585,9 @@ RI_Initial_Check(FkConstraint *fkconstraint, Relation rel, Relation pkrel) void *qplan; /* - * Check to make sure current user has enough permissions to do the - * test query. (If not, caller can fall back to the trigger method, - * which works because it changes user IDs on the fly.) + * Check to make sure current user has enough permissions to do the test + * query. (If not, caller can fall back to the trigger method, which + * works because it changes user IDs on the fly.) * * XXX are there any other show-stopper conditions to check? */ @@ -2669,8 +2637,8 @@ RI_Initial_Check(FkConstraint *fkconstraint, Relation rel, Relation pkrel) } /* - * It's sufficient to test any one pk attribute for null to detect a - * join failure. + * It's sufficient to test any one pk attribute for null to detect a join + * failure. */ quoteOneName(attname, strVal(linitial(fkconstraint->pk_attrs))); snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), @@ -2706,13 +2674,12 @@ RI_Initial_Check(FkConstraint *fkconstraint, Relation rel, Relation pkrel) ")"); /* - * Temporarily increase work_mem so that the check query can be - * executed more efficiently. It seems okay to do this because the - * query is simple enough to not use a multiple of work_mem, and one - * typically would not have many large foreign-key validations - * happening concurrently. So this seems to meet the criteria for - * being considered a "maintenance" operation, and accordingly we use - * maintenance_work_mem. + * Temporarily increase work_mem so that the check query can be executed + * more efficiently. It seems okay to do this because the query is simple + * enough to not use a multiple of work_mem, and one typically would not + * have many large foreign-key validations happening concurrently. So + * this seems to meet the criteria for being considered a "maintenance" + * operation, and accordingly we use maintenance_work_mem. * * We do the equivalent of "SET LOCAL work_mem" so that transaction abort * will restore the old value if we lose control due to an error. @@ -2736,8 +2703,8 @@ RI_Initial_Check(FkConstraint *fkconstraint, Relation rel, Relation pkrel) elog(ERROR, "SPI_prepare returned %d for %s", SPI_result, querystr); /* - * Run the plan. For safety we force a current snapshot to be used. - * (In serializable mode, this arguably violates serializability, but we + * Run the plan. For safety we force a current snapshot to be used. (In + * serializable mode, this arguably violates serializability, but we * really haven't got much choice.) We need at most one tuple returned, * so pass limit = 1. */ @@ -2762,8 +2729,8 @@ RI_Initial_Check(FkConstraint *fkconstraint, Relation rel, Relation pkrel) /* * If it's MATCH FULL, and there are any nulls in the FK keys, - * complain about that rather than the lack of a match. MATCH - * FULL disallows partially-null FK rows. + * complain about that rather than the lack of a match. MATCH FULL + * disallows partially-null FK rows. */ if (fkconstraint->fk_matchtype == FKCONSTR_MATCH_FULL) { @@ -2785,8 +2752,8 @@ RI_Initial_Check(FkConstraint *fkconstraint, Relation rel, Relation pkrel) } /* - * Although we didn't cache the query, we need to set up a fake - * query key to pass to ri_ReportViolation. + * Although we didn't cache the query, we need to set up a fake query + * key to pass to ri_ReportViolation. */ MemSet(&qkey, 0, sizeof(qkey)); qkey.constr_queryno = RI_PLAN_CHECK_LOOKUPPK; @@ -2804,8 +2771,8 @@ RI_Initial_Check(FkConstraint *fkconstraint, Relation rel, Relation pkrel) elog(ERROR, "SPI_finish failed"); /* - * Restore work_mem for the remainder of the current transaction. This - * is another SET LOCAL, so it won't affect the session value, nor any + * Restore work_mem for the remainder of the current transaction. This is + * another SET LOCAL, so it won't affect the session value, nor any * tentative value if there is one. */ snprintf(workmembuf, sizeof(workmembuf), "%d", old_work_mem); @@ -2917,8 +2884,8 @@ ri_BuildQueryKeyFull(RI_QueryKey *key, Oid constr_id, int32 constr_queryno, key->nkeypairs = (argc - RI_FIRST_ATTNAME_ARGNO) / 2; /* - * Lookup the attribute numbers of the arguments to the trigger call - * and fill in the keypairs. + * Lookup the attribute numbers of the arguments to the trigger call and + * fill in the keypairs. */ for (i = 0, j = RI_FIRST_ATTNAME_ARGNO; j < argc; i++, j += 2) { @@ -2965,35 +2932,35 @@ ri_CheckTrigger(FunctionCallInfo fcinfo, const char *funcname, int tgkind) !TRIGGER_FIRED_FOR_ROW(trigdata->tg_event)) ereport(ERROR, (errcode(ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED), - errmsg("function \"%s\" must be fired AFTER ROW", funcname))); + errmsg("function \"%s\" must be fired AFTER ROW", funcname))); switch (tgkind) { case RI_TRIGTYPE_INSERT: if (!TRIGGER_FIRED_BY_INSERT(trigdata->tg_event)) ereport(ERROR, - (errcode(ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED), - errmsg("function \"%s\" must be fired for INSERT", funcname))); + (errcode(ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED), + errmsg("function \"%s\" must be fired for INSERT", funcname))); break; case RI_TRIGTYPE_UPDATE: if (!TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event)) ereport(ERROR, - (errcode(ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED), - errmsg("function \"%s\" must be fired for UPDATE", funcname))); + (errcode(ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED), + errmsg("function \"%s\" must be fired for UPDATE", funcname))); break; case RI_TRIGTYPE_INUP: if (!TRIGGER_FIRED_BY_INSERT(trigdata->tg_event) && !TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event)) ereport(ERROR, - (errcode(ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED), - errmsg("function \"%s\" must be fired for INSERT or UPDATE", - funcname))); + (errcode(ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED), + errmsg("function \"%s\" must be fired for INSERT or UPDATE", + funcname))); break; case RI_TRIGTYPE_DELETE: if (!TRIGGER_FIRED_BY_DELETE(trigdata->tg_event)) ereport(ERROR, - (errcode(ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED), - errmsg("function \"%s\" must be fired for DELETE", funcname))); + (errcode(ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED), + errmsg("function \"%s\" must be fired for DELETE", funcname))); break; } @@ -3010,15 +2977,15 @@ ri_CheckTrigger(FunctionCallInfo fcinfo, const char *funcname, int tgkind) funcname))); /* - * Check that tgconstrrelid is known. We need to check here because - * of ancient pg_dump bug; see notes in CreateTrigger(). + * Check that tgconstrrelid is known. We need to check here because of + * ancient pg_dump bug; see notes in CreateTrigger(). */ if (!OidIsValid(trigdata->tg_trigger->tgconstrrelid)) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("no target table given for trigger \"%s\" on table \"%s\"", - trigdata->tg_trigger->tgname, - RelationGetRelationName(trigdata->tg_relation)), + errmsg("no target table given for trigger \"%s\" on table \"%s\"", + trigdata->tg_trigger->tgname, + RelationGetRelationName(trigdata->tg_relation)), errhint("Remove this referential integrity trigger and its mates, then do ALTER TABLE ADD CONSTRAINT."))); } @@ -3105,10 +3072,10 @@ ri_PerformCheck(RI_QueryKey *qkey, void *qplan, query_rel = fk_rel; /* - * The values for the query are taken from the table on which the - * trigger is called - it is normally the other one with respect to - * query_rel. An exception is ri_Check_Pk_Match(), which uses the PK - * table for both (the case when constrname == NULL) + * The values for the query are taken from the table on which the trigger + * is called - it is normally the other one with respect to query_rel. An + * exception is ri_Check_Pk_Match(), which uses the PK table for both (the + * case when constrname == NULL) */ if (qkey->constr_queryno == RI_PLAN_CHECK_LOOKUPPK && constrname != NULL) { @@ -3128,7 +3095,7 @@ ri_PerformCheck(RI_QueryKey *qkey, void *qplan, vals, nulls); if (old_tuple) ri_ExtractValues(qkey, key_idx, source_rel, old_tuple, - vals + qkey->nkeypairs, nulls + qkey->nkeypairs); + vals + qkey->nkeypairs, nulls + qkey->nkeypairs); } else { @@ -3138,17 +3105,16 @@ ri_PerformCheck(RI_QueryKey *qkey, void *qplan, /* * In READ COMMITTED mode, we just need to use an up-to-date regular - * snapshot, and we will see all rows that could be interesting. - * But in SERIALIZABLE mode, we can't change the transaction snapshot. - * If the caller passes detectNewRows == false then it's okay to do the - * query with the transaction snapshot; otherwise we use a current - * snapshot, and tell the executor to error out if it finds any rows under - * the current snapshot that wouldn't be visible per the transaction - * snapshot. + * snapshot, and we will see all rows that could be interesting. But in + * SERIALIZABLE mode, we can't change the transaction snapshot. If the + * caller passes detectNewRows == false then it's okay to do the query + * with the transaction snapshot; otherwise we use a current snapshot, and + * tell the executor to error out if it finds any rows under the current + * snapshot that wouldn't be visible per the transaction snapshot. */ if (IsXactIsoLevelSerializable && detectNewRows) { - CommandCounterIncrement(); /* be sure all my own work is visible */ + CommandCounterIncrement(); /* be sure all my own work is visible */ test_snapshot = CopySnapshot(GetLatestSnapshot()); crosscheck_snapshot = CopySnapshot(GetTransactionSnapshot()); } @@ -3161,9 +3127,9 @@ ri_PerformCheck(RI_QueryKey *qkey, void *qplan, /* * If this is a select query (e.g., for a 'no action' or 'restrict' - * trigger), we only need to see if there is a single row in the - * table, matching the key. Otherwise, limit = 0 - because we want - * the query to affect ALL the matching rows. + * trigger), we only need to see if there is a single row in the table, + * matching the key. Otherwise, limit = 0 - because we want the query to + * affect ALL the matching rows. */ limit = (expect_OK == SPI_OK_SELECT) ? 1 : 0; @@ -3193,7 +3159,7 @@ ri_PerformCheck(RI_QueryKey *qkey, void *qplan, /* XXX wouldn't it be clearer to do this part at the caller? */ if (constrname && expect_OK == SPI_OK_SELECT && - (SPI_processed == 0) == (qkey->constr_queryno == RI_PLAN_CHECK_LOOKUPPK)) + (SPI_processed == 0) == (qkey->constr_queryno == RI_PLAN_CHECK_LOOKUPPK)) ri_ReportViolation(qkey, constrname, pk_rel, fk_rel, new_tuple ? new_tuple : old_tuple, @@ -3257,8 +3223,8 @@ ri_ReportViolation(RI_QueryKey *qkey, const char *constrname, errhint("This is most likely due to a rule having rewritten the query."))); /* - * Determine which relation to complain about. If tupdesc wasn't - * passed by caller, assume the violator tuple came from there. + * Determine which relation to complain about. If tupdesc wasn't passed + * by caller, assume the violator tuple came from there. */ onfk = (qkey->constr_queryno == RI_PLAN_CHECK_LOOKUPPK); if (onfk) @@ -3276,8 +3242,8 @@ ri_ReportViolation(RI_QueryKey *qkey, const char *constrname, /* * Special case - if there are no keys at all, this is a 'no column' - * constraint - no need to try to extract the values, and the message - * in this case looks different. + * constraint - no need to try to extract the values, and the message in + * this case looks different. */ if (qkey->nkeypairs == 0) { @@ -3302,8 +3268,8 @@ ri_ReportViolation(RI_QueryKey *qkey, const char *constrname, val = "null"; /* - * Go to "..." if name or value doesn't fit in buffer. We reserve - * 5 bytes to ensure we can add comma, "...", null. + * Go to "..." if name or value doesn't fit in buffer. We reserve 5 + * bytes to ensure we can add comma, "...", null. */ if (strlen(name) >= (key_names + BUFLENGTH - 5) - name_ptr || strlen(val) >= (key_values + BUFLENGTH - 5) - val_ptr) @@ -3322,18 +3288,18 @@ ri_ReportViolation(RI_QueryKey *qkey, const char *constrname, (errcode(ERRCODE_FOREIGN_KEY_VIOLATION), errmsg("insert or update on table \"%s\" violates foreign key constraint \"%s\"", RelationGetRelationName(fk_rel), constrname), - errdetail("Key (%s)=(%s) is not present in table \"%s\".", - key_names, key_values, - RelationGetRelationName(pk_rel)))); + errdetail("Key (%s)=(%s) is not present in table \"%s\".", + key_names, key_values, + RelationGetRelationName(pk_rel)))); else ereport(ERROR, (errcode(ERRCODE_FOREIGN_KEY_VIOLATION), errmsg("update or delete on \"%s\" violates foreign key constraint \"%s\" on \"%s\"", RelationGetRelationName(pk_rel), constrname, RelationGetRelationName(fk_rel)), - errdetail("Key (%s)=(%s) is still referenced from table \"%s\".", - key_names, key_values, - RelationGetRelationName(fk_rel)))); + errdetail("Key (%s)=(%s) is still referenced from table \"%s\".", + key_names, key_values, + RelationGetRelationName(fk_rel)))); } /* ---------- @@ -3373,8 +3339,8 @@ ri_BuildQueryKeyPkCheck(RI_QueryKey *key, Oid constr_id, int32 constr_queryno, key->nkeypairs = (argc - RI_FIRST_ATTNAME_ARGNO) / 2; /* - * Lookup the attribute numbers of the arguments to the trigger call - * and fill in the keypairs. + * Lookup the attribute numbers of the arguments to the trigger call and + * fill in the keypairs. */ for (i = 0, j = RI_FIRST_ATTNAME_ARGNO + RI_KEYPAIR_PK_IDX; j < argc; i++, j += 2) { @@ -3542,8 +3508,8 @@ ri_KeysEqual(Relation rel, HeapTuple oldtup, HeapTuple newtup, return false; /* - * Get the attribute's type OID and call the '=' operator to - * compare the values. + * Get the attribute's type OID and call the '=' operator to compare + * the values. */ typeid = SPI_gettypeid(rel->rd_att, key->keypair[i][pairidx]); if (!ri_AttributesEqual(typeid, oldvalue, newvalue)) @@ -3591,8 +3557,8 @@ ri_AllKeysUnequal(Relation rel, HeapTuple oldtup, HeapTuple newtup, continue; /* - * Get the attributes type OID and call the '=' operator to - * compare the values. + * Get the attributes type OID and call the '=' operator to compare + * the values. */ typeid = SPI_gettypeid(rel->rd_att, key->keypair[i][pairidx]); if (!ri_AttributesEqual(typeid, oldvalue, newvalue)) @@ -3639,8 +3605,8 @@ ri_OneKeyEqual(Relation rel, int column, HeapTuple oldtup, HeapTuple newtup, return false; /* - * Get the attributes type OID and call the '=' operator to compare - * the values. + * Get the attributes type OID and call the '=' operator to compare the + * values. */ typeid = SPI_gettypeid(rel->rd_att, key->keypair[column][pairidx]); if (!ri_AttributesEqual(typeid, oldvalue, newvalue)) @@ -3672,8 +3638,8 @@ ri_AttributesEqual(Oid typeid, Datum oldvalue, Datum newvalue) if (!OidIsValid(typentry->eq_opr_finfo.fn_oid)) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_FUNCTION), - errmsg("could not identify an equality operator for type %s", - format_type_be(typeid)))); + errmsg("could not identify an equality operator for type %s", + format_type_be(typeid)))); /* * Call the type specific '=' function diff --git a/src/backend/utils/adt/rowtypes.c b/src/backend/utils/adt/rowtypes.c index 07a5cf54ee..1a12185b04 100644 --- a/src/backend/utils/adt/rowtypes.c +++ b/src/backend/utils/adt/rowtypes.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/rowtypes.c,v 1.12 2005/07/10 21:13:59 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/rowtypes.c,v 1.13 2005/10/15 02:49:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -54,6 +54,7 @@ record_in(PG_FUNCTION_ARGS) { char *string = PG_GETARG_CSTRING(0); Oid tupType = PG_GETARG_OID(1); + #ifdef NOT_USED int32 typmod = PG_GETARG_INT32(2); #endif @@ -72,14 +73,14 @@ record_in(PG_FUNCTION_ARGS) /* * Use the passed type unless it's RECORD; we can't support input of - * anonymous types, mainly because there's no good way to figure out - * which anonymous type is wanted. Note that for RECORD, what we'll - * probably actually get is RECORD's typelem, ie, zero. + * anonymous types, mainly because there's no good way to figure out which + * anonymous type is wanted. Note that for RECORD, what we'll probably + * actually get is RECORD's typelem, ie, zero. */ if (tupType == InvalidOid || tupType == RECORDOID) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("input of anonymous composite types is not implemented"))); + errmsg("input of anonymous composite types is not implemented"))); tupTypmod = -1; /* for all non-anonymous types */ tupdesc = lookup_rowtype_tupdesc(tupType, tupTypmod); ncolumns = tupdesc->natts; @@ -153,7 +154,7 @@ record_in(PG_FUNCTION_ARGS) /* *ptr must be ')' */ ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("malformed record literal: \"%s\"", string), + errmsg("malformed record literal: \"%s\"", string), errdetail("Too few columns."))); } @@ -184,10 +185,10 @@ record_in(PG_FUNCTION_ARGS) { if (*ptr == '\0') ereport(ERROR, - (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("malformed record literal: \"%s\"", - string), - errdetail("Unexpected end of input."))); + (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), + errmsg("malformed record literal: \"%s\"", + string), + errdetail("Unexpected end of input."))); appendStringInfoChar(&buf, *ptr++); } else if (ch == '\"') @@ -221,8 +222,8 @@ record_in(PG_FUNCTION_ARGS) values[i] = FunctionCall3(&column_info->proc, CStringGetDatum(buf.data), - ObjectIdGetDatum(column_info->typioparam), - Int32GetDatum(tupdesc->attrs[i]->atttypmod)); + ObjectIdGetDatum(column_info->typioparam), + Int32GetDatum(tupdesc->attrs[i]->atttypmod)); nulls[i] = ' '; } @@ -249,9 +250,9 @@ record_in(PG_FUNCTION_ARGS) tuple = heap_formtuple(tupdesc, values, nulls); /* - * We cannot return tuple->t_data because heap_formtuple allocates it - * as part of a larger chunk, and our caller may expect to be able to - * pfree our result. So must copy the info into a new palloc chunk. + * We cannot return tuple->t_data because heap_formtuple allocates it as + * part of a larger chunk, and our caller may expect to be able to pfree + * our result. So must copy the info into a new palloc chunk. */ result = (HeapTupleHeader) palloc(tuple->t_len); memcpy(result, tuple->t_data, tuple->t_len); @@ -420,6 +421,7 @@ record_recv(PG_FUNCTION_ARGS) { StringInfo buf = (StringInfo) PG_GETARG_POINTER(0); Oid tupType = PG_GETARG_OID(1); + #ifdef NOT_USED int32 typmod = PG_GETARG_INT32(2); #endif @@ -437,14 +439,14 @@ record_recv(PG_FUNCTION_ARGS) /* * Use the passed type unless it's RECORD; we can't support input of - * anonymous types, mainly because there's no good way to figure out - * which anonymous type is wanted. Note that for RECORD, what we'll - * probably actually get is RECORD's typelem, ie, zero. + * anonymous types, mainly because there's no good way to figure out which + * anonymous type is wanted. Note that for RECORD, what we'll probably + * actually get is RECORD's typelem, ie, zero. */ if (tupType == InvalidOid || tupType == RECORDOID) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("input of anonymous composite types is not implemented"))); + errmsg("input of anonymous composite types is not implemented"))); tupTypmod = -1; /* for all non-anonymous types */ tupdesc = lookup_rowtype_tupdesc(tupType, tupTypmod); ncolumns = tupdesc->natts; @@ -537,10 +539,9 @@ record_recv(PG_FUNCTION_ARGS) { /* * Rather than copying data around, we just set up a phony - * StringInfo pointing to the correct portion of the input - * buffer. We assume we can scribble on the input buffer so as - * to maintain the convention that StringInfos have a trailing - * null. + * StringInfo pointing to the correct portion of the input buffer. + * We assume we can scribble on the input buffer so as to maintain + * the convention that StringInfos have a trailing null. */ StringInfoData item_buf; char csave; @@ -568,16 +569,16 @@ record_recv(PG_FUNCTION_ARGS) values[i] = FunctionCall3(&column_info->proc, PointerGetDatum(&item_buf), - ObjectIdGetDatum(column_info->typioparam), - Int32GetDatum(tupdesc->attrs[i]->atttypmod)); + ObjectIdGetDatum(column_info->typioparam), + Int32GetDatum(tupdesc->attrs[i]->atttypmod)); nulls[i] = ' '; /* Trouble if it didn't eat the whole buffer */ if (item_buf.cursor != itemlen) ereport(ERROR, (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION), - errmsg("improper binary format in record column %d", - i + 1))); + errmsg("improper binary format in record column %d", + i + 1))); buf->data[buf->cursor] = csave; } @@ -586,9 +587,9 @@ record_recv(PG_FUNCTION_ARGS) tuple = heap_formtuple(tupdesc, values, nulls); /* - * We cannot return tuple->t_data because heap_formtuple allocates it - * as part of a larger chunk, and our caller may expect to be able to - * pfree our result. So must copy the info into a new palloc chunk. + * We cannot return tuple->t_data because heap_formtuple allocates it as + * part of a larger chunk, and our caller may expect to be able to pfree + * our result. So must copy the info into a new palloc chunk. */ result = (HeapTupleHeader) palloc(tuple->t_len); memcpy(result, tuple->t_data, tuple->t_len); diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 1a226bd49c..04e8eb5516 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -3,7 +3,7 @@ * back to source text * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.206 2005/10/06 19:51:14 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.207 2005/10/15 02:49:29 momjian Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -201,11 +201,11 @@ static void get_agg_expr(Aggref *aggref, deparse_context *context); static void get_const_expr(Const *constval, deparse_context *context); static void get_sublink_expr(SubLink *sublink, deparse_context *context); static void get_from_clause(Query *query, const char *prefix, - deparse_context *context); + deparse_context *context); static void get_from_clause_item(Node *jtnode, Query *query, deparse_context *context); static void get_from_clause_alias(Alias *alias, RangeTblEntry *rte, - deparse_context *context); + deparse_context *context); static void get_from_clause_coldeflist(List *coldeflist, deparse_context *context); static void get_opclass_name(Oid opclass, Oid actual_datatype, @@ -486,8 +486,8 @@ pg_get_triggerdef(PG_FUNCTION_ARGS) trigrec = (Form_pg_trigger) GETSTRUCT(ht_trig); /* - * Start the trigger definition. Note that the trigger's name should - * never be schema-qualified, but the trigger rel's name may be. + * Start the trigger definition. Note that the trigger's name should never + * be schema-qualified, but the trigger rel's name may be. */ initStringInfo(&buf); @@ -527,7 +527,7 @@ pg_get_triggerdef(PG_FUNCTION_ARGS) { if (trigrec->tgconstrrelid != InvalidOid) appendStringInfo(&buf, "FROM %s ", - generate_relation_name(trigrec->tgconstrrelid)); + generate_relation_name(trigrec->tgconstrrelid)); if (!trigrec->tgdeferrable) appendStringInfo(&buf, "NOT "); appendStringInfo(&buf, "DEFERRABLE INITIALLY "); @@ -688,9 +688,9 @@ pg_get_indexdef_worker(Oid indexrelid, int colno, int prettyFlags) amrec = (Form_pg_am) GETSTRUCT(ht_am); /* - * Get the index expressions, if any. (NOTE: we do not use the - * relcache versions of the expressions and predicate, because we want - * to display non-const-folded expressions.) + * Get the index expressions, if any. (NOTE: we do not use the relcache + * versions of the expressions and predicate, because we want to display + * non-const-folded expressions.) */ if (!heap_attisnull(ht_idx, Anum_pg_index_indexprs)) { @@ -714,8 +714,8 @@ pg_get_indexdef_worker(Oid indexrelid, int colno, int prettyFlags) context = deparse_context_for(get_rel_name(indrelid), indrelid); /* - * Start the index definition. Note that the index's name should - * never be schema-qualified, but the indexed rel's name may be. + * Start the index definition. Note that the index's name should never be + * schema-qualified, but the indexed rel's name may be. */ initStringInfo(&buf); @@ -764,7 +764,7 @@ pg_get_indexdef_worker(Oid indexrelid, int colno, int prettyFlags) { /* Need parens if it's not a bare function call */ if (indexkey && IsA(indexkey, FuncExpr) && - ((FuncExpr *) indexkey)->funcformat == COERCE_EXPLICIT_CALL) + ((FuncExpr *) indexkey)->funcformat == COERCE_EXPLICIT_CALL) appendStringInfoString(&buf, str); else appendStringInfo(&buf, "(%s)", str); @@ -831,7 +831,7 @@ pg_get_constraintdef(PG_FUNCTION_ARGS) Oid constraintId = PG_GETARG_OID(0); PG_RETURN_TEXT_P(string_to_text(pg_get_constraintdef_worker(constraintId, - false, 0))); + false, 0))); } Datum @@ -843,7 +843,7 @@ pg_get_constraintdef_ext(PG_FUNCTION_ARGS) prettyFlags = pretty ? PRETTYFLAG_PAREN | PRETTYFLAG_INDENT : 0; PG_RETURN_TEXT_P(string_to_text(pg_get_constraintdef_worker(constraintId, - false, prettyFlags))); + false, prettyFlags))); } /* Internal version that returns a palloc'd C string */ @@ -865,8 +865,8 @@ pg_get_constraintdef_worker(Oid constraintId, bool fullCommand, Form_pg_constraint conForm; /* - * Fetch the pg_constraint row. There's no syscache for pg_constraint - * so we must do it the hard way. + * Fetch the pg_constraint row. There's no syscache for pg_constraint so + * we must do it the hard way. */ conDesc = heap_open(ConstraintRelationId, AccessShareLock); @@ -914,7 +914,7 @@ pg_get_constraintdef_worker(Oid constraintId, bool fullCommand, /* add foreign relation name */ appendStringInfo(&buf, ") REFERENCES %s(", - generate_relation_name(conForm->confrelid)); + generate_relation_name(conForm->confrelid)); /* Fetch and build referenced-column list */ val = heap_getattr(tup, Anum_pg_constraint_confkey, @@ -1067,15 +1067,13 @@ pg_get_constraintdef_worker(Oid constraintId, bool fullCommand, prettyFlags, 0); /* - * Now emit the constraint definition. There are cases - * where the constraint expression will be fully - * parenthesized and we don't need the outer parens ... - * but there are other cases where we do need 'em. Be - * conservative for now. + * Now emit the constraint definition. There are cases where + * the constraint expression will be fully parenthesized and + * we don't need the outer parens ... but there are other + * cases where we do need 'em. Be conservative for now. * * Note that simply checking for leading '(' and trailing ')' - * would NOT be good enough, consider "(x > 0) AND (y > - * 0)". + * would NOT be good enough, consider "(x > 0) AND (y > 0)". */ appendStringInfo(&buf, "CHECK (%s)", consrc); @@ -1259,7 +1257,7 @@ pg_get_serial_sequence(PG_FUNCTION_ARGS) /* Get the number of the column */ column = DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(columnname))); + PointerGetDatum(columnname))); attnum = get_attnum(tableOid, column); if (attnum == InvalidAttrNumber) @@ -1292,8 +1290,8 @@ pg_get_serial_sequence(PG_FUNCTION_ARGS) Form_pg_depend deprec = (Form_pg_depend) GETSTRUCT(tup); /* - * We assume any internal dependency of a relation on a column - * must be what we are looking for. + * We assume any internal dependency of a relation on a column must be + * what we are looking for. */ if (deprec->classid == RelationRelationId && deprec->objsubid == 0 && @@ -1510,7 +1508,7 @@ deparse_context_for_subplan(const char *name, List *tlist, if (var->varnoold > 0 && var->varnoold <= rtablelength) { RangeTblEntry *varrte = rt_fetch(var->varnoold, rtable); - AttrNumber varattnum = var->varoattno; + AttrNumber varattnum = var->varoattno; /* need this test in case it's referencing a resjunk col */ if (varattnum <= list_length(varrte->eref->colnames)) @@ -1637,8 +1635,8 @@ make_ruledef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc, appendStringInfo(buf, " TO %s", generate_relation_name(ev_class)); if (ev_attr > 0) appendStringInfo(buf, ".%s", - quote_identifier(get_relid_attribute_name(ev_class, - ev_attr))); + quote_identifier(get_relid_attribute_name(ev_class, + ev_attr))); /* If the rule has an event qualification, add it */ if (ev_qual == NULL) @@ -1658,15 +1656,15 @@ make_ruledef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc, /* * We need to make a context for recognizing any Vars in the qual - * (which can only be references to OLD and NEW). Use the rtable - * of the first query in the action list for this purpose. + * (which can only be references to OLD and NEW). Use the rtable of + * the first query in the action list for this purpose. */ query = (Query *) linitial(actions); /* * If the action is INSERT...SELECT, OLD/NEW have been pushed down - * into the SELECT, and that's what we need to look at. (Ugly - * kluge ... try to fix this when we redesign querytrees.) + * into the SELECT, and that's what we need to look at. (Ugly kluge + * ... try to fix this when we redesign querytrees.) */ query = getInsertSelectQuery(query, NULL); @@ -1809,9 +1807,9 @@ get_query_def(Query *query, StringInfo buf, List *parentnamespace, /* * Before we begin to examine the query, acquire locks on referenced - * relations, and fix up deleted columns in JOIN RTEs. This ensures - * consistent results. Note we assume it's OK to scribble on the - * passed querytree! + * relations, and fix up deleted columns in JOIN RTEs. This ensures + * consistent results. Note we assume it's OK to scribble on the passed + * querytree! */ AcquireRewriteLocks(query); @@ -1874,9 +1872,9 @@ get_select_query_def(Query *query, deparse_context *context, ListCell *l; /* - * If the Query node has a setOperations tree, then it's the top level - * of a UNION/INTERSECT/EXCEPT query; only the ORDER BY and LIMIT - * fields are interesting in the top query itself. + * If the Query node has a setOperations tree, then it's the top level of + * a UNION/INTERSECT/EXCEPT query; only the ORDER BY and LIMIT fields are + * interesting in the top query itself. */ if (query->setOperations) { @@ -1909,7 +1907,7 @@ get_select_query_def(Query *query, deparse_context *context, sortcoltype = exprType(sortexpr); /* See whether operator is default < or > for datatype */ typentry = lookup_type_cache(sortcoltype, - TYPECACHE_LT_OPR | TYPECACHE_GT_OPR); + TYPECACHE_LT_OPR | TYPECACHE_GT_OPR); if (srt->sortop == typentry->lt_opr) /* ASC is default, so emit nothing */ ; else if (srt->sortop == typentry->gt_opr) @@ -2025,10 +2023,10 @@ get_basic_select_query(Query *query, deparse_context *context, get_rule_expr((Node *) tle->expr, context, true); /* - * Figure out what the result column should be called. In the - * context of a view, use the view's tuple descriptor (so as to - * pick up the effects of any column RENAME that's been done on - * the view). Otherwise, just use what we can find in the TLE. + * Figure out what the result column should be called. In the context + * of a view, use the view's tuple descriptor (so as to pick up the + * effects of any column RENAME that's been done on the view). + * Otherwise, just use what we can find in the TLE. */ if (resultDesc && colno <= resultDesc->natts) colname = NameStr(resultDesc->attrs[colno - 1]->attname); @@ -2130,10 +2128,10 @@ get_setop_query(Node *setOp, Query *query, deparse_context *context, SetOperationStmt *op = (SetOperationStmt *) setOp; /* - * We force parens whenever nesting two SetOperationStmts. There - * are some cases in which parens are needed around a leaf query - * too, but those are more easily handled at the next level down - * (see code above). + * We force parens whenever nesting two SetOperationStmts. There are + * some cases in which parens are needed around a leaf query too, but + * those are more easily handled at the next level down (see code + * above). */ need_paren = !IsA(op->larg, RangeTblRef); @@ -2231,8 +2229,8 @@ get_insert_query_def(Query *query, deparse_context *context) List *strippedexprs; /* - * If it's an INSERT ... SELECT there will be a single subquery RTE - * for the SELECT. + * If it's an INSERT ... SELECT there will be a single subquery RTE for + * the SELECT. */ foreach(l, query->rtable) { @@ -2279,13 +2277,12 @@ get_insert_query_def(Query *query, deparse_context *context) * tle->resname, since resname will fail to track RENAME. */ appendStringInfoString(buf, - quote_identifier(get_relid_attribute_name(rte->relid, - tle->resno))); + quote_identifier(get_relid_attribute_name(rte->relid, + tle->resno))); /* - * Print any indirection needed (subfields or subscripts), and - * strip off the top-level nodes representing the indirection - * assignments. + * Print any indirection needed (subfields or subscripts), and strip + * off the top-level nodes representing the indirection assignments. */ strippedexprs = lappend(strippedexprs, processIndirection((Node *) tle->expr, @@ -2351,13 +2348,12 @@ get_update_query_def(Query *query, deparse_context *context) * tle->resname, since resname will fail to track RENAME. */ appendStringInfoString(buf, - quote_identifier(get_relid_attribute_name(rte->relid, - tle->resno))); + quote_identifier(get_relid_attribute_name(rte->relid, + tle->resno))); /* - * Print any indirection needed (subfields or subscripts), and - * strip off the top-level nodes representing the indirection - * assignments. + * Print any indirection needed (subfields or subscripts), and strip + * off the top-level nodes representing the indirection assignments. */ expr = processIndirection((Node *) tle->expr, context); @@ -2432,8 +2428,8 @@ get_utility_query_def(Query *query, deparse_context *context) appendContextKeyword(context, "", 0, PRETTYINDENT_STD, 1); appendStringInfo(buf, "NOTIFY %s", - quote_qualified_identifier(stmt->relation->schemaname, - stmt->relation->relname)); + quote_qualified_identifier(stmt->relation->schemaname, + stmt->relation->relname)); } else { @@ -2517,10 +2513,9 @@ get_names_for_var(Var *var, int levelsup, deparse_context *context, if (rte->rtekind == RTE_RELATION) { /* - * It's possible that use of the bare refname would find - * another more-closely-nested RTE, or be ambiguous, in which - * case we need to specify the schemaname to avoid these - * errors. + * It's possible that use of the bare refname would find another + * more-closely-nested RTE, or be ambiguous, in which case we need + * to specify the schemaname to avoid these errors. */ if (find_rte_by_refname(rte->eref->aliasname, context) != rte) *schemaname = @@ -2530,20 +2525,20 @@ get_names_for_var(Var *var, int levelsup, deparse_context *context, { /* * If it's an unnamed join, look at the expansion of the alias - * variable. If it's a simple reference to one of the input - * vars then recursively find the name of that var, instead. - * (This allows correct decompiling of cases where there are - * identically named columns on both sides of the join.) - * When it's not a simple reference, we have to just return - * the unqualified variable name (this can only happen with - * columns that were merged by USING or NATURAL clauses). + * variable. If it's a simple reference to one of the input vars + * then recursively find the name of that var, instead. (This + * allows correct decompiling of cases where there are identically + * named columns on both sides of the join.) When it's not a + * simple reference, we have to just return the unqualified + * variable name (this can only happen with columns that were + * merged by USING or NATURAL clauses). */ if (var->varattno > 0) { - Var *aliasvar; + Var *aliasvar; aliasvar = (Var *) list_nth(rte->joinaliasvars, - var->varattno-1); + var->varattno - 1); if (IsA(aliasvar, Var)) { get_names_for_var(aliasvar, @@ -2568,9 +2563,9 @@ get_names_for_var(Var *var, int levelsup, deparse_context *context, * Get the name of a field of a Var of type RECORD. * * Since no actual table or view column is allowed to have type RECORD, such - * a Var must refer to a JOIN or FUNCTION RTE or to a subquery output. We + * a Var must refer to a JOIN or FUNCTION RTE or to a subquery output. We * drill down to find the ultimate defining expression and attempt to infer - * the field name from it. We ereport if we can't determine the name. + * the field name from it. We ereport if we can't determine the name. * * levelsup is an extra offset to interpret the Var's varlevelsup correctly. * @@ -2609,6 +2604,7 @@ get_name_for_var_field(Var *var, int fieldno, { case RTE_RELATION: case RTE_SPECIAL: + /* * This case should not occur: a column of a table shouldn't have * type RECORD. Fall through and fail (most likely) at the @@ -2629,7 +2625,7 @@ get_name_for_var_field(Var *var, int fieldno, { /* * Recurse into the sub-select to see what its Var refers - * to. We have to build an additional level of namespace + * to. We have to build an additional level of namespace * to keep in step with varlevelsup in the subselect. */ deparse_namespace mydpns; @@ -2662,18 +2658,19 @@ get_name_for_var_field(Var *var, int fieldno, /* else fall through to inspect the expression */ break; case RTE_FUNCTION: + /* - * We couldn't get here unless a function is declared with one - * of its result columns as RECORD, which is not allowed. + * We couldn't get here unless a function is declared with one of + * its result columns as RECORD, which is not allowed. */ break; } /* * We now have an expression we can't expand any more, so see if - * get_expr_result_type() can do anything with it. If not, pass - * to lookup_rowtype_tupdesc() which will probably fail, but will - * give an appropriate error message while failing. + * get_expr_result_type() can do anything with it. If not, pass to + * lookup_rowtype_tupdesc() which will probably fail, but will give an + * appropriate error message while failing. */ if (get_expr_result_type(expr, NULL, &tupleDesc) != TYPEFUNC_COMPOSITE) tupleDesc = lookup_rowtype_tupdesc(exprType(expr), exprTypmod(expr)); @@ -2866,8 +2863,8 @@ isSimpleNode(Node *node, Node *parentNode, int prettyFlags) return false; /* - * Operators are same priority --- can skip parens - * only if we have (a - b) - c, not a - (b - c). + * Operators are same priority --- can skip parens only if + * we have (a - b) - c, not a - (b - c). */ if (node == (Node *) linitial(((OpExpr *) parentNode)->args)) return true; @@ -2897,11 +2894,11 @@ isSimpleNode(Node *node, Node *parentNode, int prettyFlags) case T_BoolExpr: /* lower precedence */ case T_ArrayRef: /* other separators */ case T_ArrayExpr: /* other separators */ - case T_RowExpr: /* other separators */ + case T_RowExpr: /* other separators */ case T_CoalesceExpr: /* own parentheses */ case T_MinMaxExpr: /* own parentheses */ case T_NullIfExpr: /* other separators */ - case T_Aggref: /* own parentheses */ + case T_Aggref: /* own parentheses */ case T_CaseExpr: /* other separators */ return true; default: @@ -2945,11 +2942,11 @@ isSimpleNode(Node *node, Node *parentNode, int prettyFlags) } case T_ArrayRef: /* other separators */ case T_ArrayExpr: /* other separators */ - case T_RowExpr: /* other separators */ + case T_RowExpr: /* other separators */ case T_CoalesceExpr: /* own parentheses */ case T_MinMaxExpr: /* own parentheses */ case T_NullIfExpr: /* other separators */ - case T_Aggref: /* own parentheses */ + case T_Aggref: /* own parentheses */ case T_CaseExpr: /* other separators */ return true; default: @@ -3055,10 +3052,10 @@ get_rule_expr(Node *node, deparse_context *context, /* * Each level of get_rule_expr must emit an indivisible term - * (parenthesized if necessary) to ensure result is reparsed into the - * same expression tree. The only exception is that when the input - * is a List, we emit the component items comma-separated with no - * surrounding decoration; this is convenient for most callers. + * (parenthesized if necessary) to ensure result is reparsed into the same + * expression tree. The only exception is that when the input is a List, + * we emit the component items comma-separated with no surrounding + * decoration; this is convenient for most callers. * * There might be some work left here to support additional node types. */ @@ -3129,8 +3126,8 @@ get_rule_expr(Node *node, deparse_context *context, /* * Parenthesize the argument unless it's a simple Var or a - * FieldSelect. (In particular, if it's another ArrayRef, - * we *must* parenthesize to avoid confusion.) + * FieldSelect. (In particular, if it's another ArrayRef, we + * *must* parenthesize to avoid confusion.) */ need_parens = !IsA(aref->refexpr, Var) && !IsA(aref->refexpr, FieldSelect); @@ -3188,7 +3185,7 @@ get_rule_expr(Node *node, deparse_context *context, appendStringInfo(buf, " %s %s (", generate_operator_name(expr->opno, exprType(arg1), - get_element_type(exprType(arg2))), + get_element_type(exprType(arg2))), expr->useOr ? "ANY" : "ALL"); get_rule_expr_paren(arg2, context, true, node); appendStringInfoChar(buf, ')'); @@ -3261,9 +3258,8 @@ get_rule_expr(Node *node, deparse_context *context, case T_SubPlan: { /* - * We cannot see an already-planned subplan in rule - * deparsing, only while EXPLAINing a query plan. For now, - * just punt. + * We cannot see an already-planned subplan in rule deparsing, + * only while EXPLAINing a query plan. For now, just punt. */ if (((SubPlan *) node)->useHashTable) appendStringInfo(buf, "(hashed subplan)"); @@ -3282,12 +3278,11 @@ get_rule_expr(Node *node, deparse_context *context, /* * Parenthesize the argument unless it's an ArrayRef or - * another FieldSelect. Note in particular that it would - * be WRONG to not parenthesize a Var argument; simplicity - * is not the issue here, having the right number of names - * is. + * another FieldSelect. Note in particular that it would be + * WRONG to not parenthesize a Var argument; simplicity is not + * the issue here, having the right number of names is. */ - need_parens = !IsA(arg, ArrayRef) && !IsA(arg, FieldSelect); + need_parens = !IsA(arg, ArrayRef) &&!IsA(arg, FieldSelect); if (need_parens) appendStringInfoChar(buf, '('); get_rule_expr(arg, context, true); @@ -3296,8 +3291,8 @@ get_rule_expr(Node *node, deparse_context *context, /* * If it's a Var of type RECORD, we have to find what the Var - * refers to; otherwise we can use get_expr_result_type. - * If that fails, we try lookup_rowtype_tupdesc, which will + * refers to; otherwise we can use get_expr_result_type. If + * that fails, we try lookup_rowtype_tupdesc, which will * probably fail too, but will ereport an acceptable message. */ if (IsA(arg, Var) && @@ -3324,8 +3319,8 @@ get_rule_expr(Node *node, deparse_context *context, case T_FieldStore: /* - * We shouldn't see FieldStore here; it should have been - * stripped off by processIndirection(). + * We shouldn't see FieldStore here; it should have been stripped + * off by processIndirection(). */ elog(ERROR, "unexpected FieldStore"); break; @@ -3349,8 +3344,8 @@ get_rule_expr(Node *node, deparse_context *context, if (!PRETTY_PAREN(context)) appendStringInfoChar(buf, ')'); appendStringInfo(buf, "::%s", - format_type_with_typemod(relabel->resulttype, - relabel->resulttypmod)); + format_type_with_typemod(relabel->resulttype, + relabel->resulttypmod)); } } break; @@ -3374,7 +3369,7 @@ get_rule_expr(Node *node, deparse_context *context, if (!PRETTY_PAREN(context)) appendStringInfoChar(buf, ')'); appendStringInfo(buf, "::%s", - format_type_with_typemod(convert->resulttype, -1)); + format_type_with_typemod(convert->resulttype, -1)); } } break; @@ -3444,9 +3439,9 @@ get_rule_expr(Node *node, deparse_context *context, char *sep; /* - * If it's a named type and not RECORD, we may have to - * skip dropped columns and/or claim there are NULLs for - * added columns. + * If it's a named type and not RECORD, we may have to skip + * dropped columns and/or claim there are NULLs for added + * columns. */ if (rowexpr->row_typeid != RECORDOID) { @@ -3455,8 +3450,8 @@ get_rule_expr(Node *node, deparse_context *context, } /* - * SQL99 allows "ROW" to be omitted when there is more - * than one column, but for simplicity we always print it. + * SQL99 allows "ROW" to be omitted when there is more than + * one column, but for simplicity we always print it. */ appendStringInfo(buf, "ROW("); sep = ""; @@ -3490,7 +3485,7 @@ get_rule_expr(Node *node, deparse_context *context, appendStringInfo(buf, ")"); if (rowexpr->row_format == COERCE_EXPLICIT_CAST) appendStringInfo(buf, "::%s", - format_type_with_typemod(rowexpr->row_typeid, -1)); + format_type_with_typemod(rowexpr->row_typeid, -1)); } break; @@ -3611,8 +3606,8 @@ get_rule_expr(Node *node, deparse_context *context, if (!PRETTY_PAREN(context)) appendStringInfoChar(buf, ')'); appendStringInfo(buf, "::%s", - format_type_with_typemod(ctest->resulttype, - ctest->resulttypmod)); + format_type_with_typemod(ctest->resulttype, + ctest->resulttypmod)); } } break; @@ -3724,9 +3719,8 @@ get_func_expr(FuncExpr *expr, deparse_context *context, ListCell *l; /* - * If the function call came from an implicit coercion, then just show - * the first argument --- unless caller wants to see implicit - * coercions. + * If the function call came from an implicit coercion, then just show the + * first argument --- unless caller wants to see implicit coercions. */ if (expr->funcformat == COERCE_IMPLICIT_CAST && !showimplicit) { @@ -3755,14 +3749,14 @@ get_func_expr(FuncExpr *expr, deparse_context *context, if (!PRETTY_PAREN(context)) appendStringInfoChar(buf, ')'); appendStringInfo(buf, "::%s", - format_type_with_typemod(rettype, coercedTypmod)); + format_type_with_typemod(rettype, coercedTypmod)); return; } /* - * Normal function: display as proname(args). First we need to - * extract the argument datatypes. + * Normal function: display as proname(args). First we need to extract + * the argument datatypes. */ nargs = 0; foreach(l, expr->args) @@ -3791,7 +3785,7 @@ get_agg_expr(Aggref *aggref, deparse_context *context) Oid argtype = exprType((Node *) aggref->target); appendStringInfo(buf, "%s(%s", - generate_function_name(aggref->aggfnoid, 1, &argtype), + generate_function_name(aggref->aggfnoid, 1, &argtype), aggref->aggdistinct ? "DISTINCT " : ""); if (aggref->aggstar) appendStringInfo(buf, "*"); @@ -3821,11 +3815,11 @@ get_const_expr(Const *constval, deparse_context *context) if (constval->constisnull) { /* - * Always label the type of a NULL constant to prevent - * misdecisions about type when reparsing. + * Always label the type of a NULL constant to prevent misdecisions + * about type when reparsing. */ appendStringInfo(buf, "NULL::%s", - format_type_with_typemod(constval->consttype, -1)); + format_type_with_typemod(constval->consttype, -1)); return; } @@ -3846,14 +3840,13 @@ get_const_expr(Const *constval, deparse_context *context) case NUMERICOID: { /* - * These types are printed without quotes unless they - * contain values that aren't accepted by the scanner - * unquoted (e.g., 'NaN'). Note that strtod() and friends - * might accept NaN, so we can't use that to test. + * These types are printed without quotes unless they contain + * values that aren't accepted by the scanner unquoted (e.g., + * 'NaN'). Note that strtod() and friends might accept NaN, + * so we can't use that to test. * - * In reality we only need to defend against infinity and - * NaN, so we need not get too crazy about pattern - * matching here. + * In reality we only need to defend against infinity and NaN, so + * we need not get too crazy about pattern matching here. */ if (strspn(extval, "0123456789+-eE.") == strlen(extval)) { @@ -3879,13 +3872,14 @@ get_const_expr(Const *constval, deparse_context *context) break; default: + /* * We must quote any funny characters in the constant's * representation. XXX Any MULTIBYTE considerations here? */ for (valptr = extval; *valptr; valptr++) if (*valptr == '\\' || - (unsigned char)*valptr < (unsigned char)' ') + (unsigned char) *valptr < (unsigned char) ' ') { appendStringInfoChar(buf, ESCAPE_STRING_SYNTAX); break; @@ -3901,7 +3895,7 @@ get_const_expr(Const *constval, deparse_context *context) appendStringInfoChar(buf, ch); appendStringInfoChar(buf, ch); } - else if ((unsigned char)ch < (unsigned char)' ') + else if ((unsigned char) ch < (unsigned char) ' ') appendStringInfo(buf, "\\%03o", (int) ch); else appendStringInfoChar(buf, ch); @@ -3913,9 +3907,9 @@ get_const_expr(Const *constval, deparse_context *context) pfree(extval); /* - * Append ::typename unless the constant will be implicitly typed as - * the right type when it is read in. XXX this code has to be kept in - * sync with the behavior of the parser, especially make_const. + * Append ::typename unless the constant will be implicitly typed as the + * right type when it is read in. XXX this code has to be kept in sync + * with the behavior of the parser, especially make_const. */ switch (constval->consttype) { @@ -3935,7 +3929,7 @@ get_const_expr(Const *constval, deparse_context *context) } if (needlabel) appendStringInfo(buf, "::%s", - format_type_with_typemod(constval->consttype, -1)); + format_type_with_typemod(constval->consttype, -1)); } @@ -3969,10 +3963,10 @@ get_sublink_expr(SubLink *sublink, deparse_context *context) need_paren = true; /* - * XXX we regurgitate the originally given operator name, with or - * without schema qualification. This is not necessarily 100% right - * but it's the best we can do, since the operators actually used - * might not all be in the same schema. + * XXX we regurgitate the originally given operator name, with or without + * schema qualification. This is not necessarily 100% right but it's the + * best we can do, since the operators actually used might not all be in + * the same schema. */ switch (sublink->subLinkType) { @@ -4044,11 +4038,11 @@ get_from_clause(Query *query, const char *prefix, deparse_context *context) ListCell *l; /* - * We use the query's jointree as a guide to what to print. However, - * we must ignore auto-added RTEs that are marked not inFromCl. (These - * can only appear at the top level of the jointree, so it's - * sufficient to check here.) This check also ensures we ignore - * the rule pseudo-RTEs for NEW and OLD. + * We use the query's jointree as a guide to what to print. However, we + * must ignore auto-added RTEs that are marked not inFromCl. (These can + * only appear at the top level of the jointree, so it's sufficient to + * check here.) This check also ensures we ignore the rule pseudo-RTEs + * for NEW and OLD. */ foreach(l, query->jointree->fromlist) { @@ -4124,10 +4118,10 @@ get_from_clause_item(Node *jtnode, Query *query, deparse_context *context) strcmp(rte->eref->aliasname, get_rel_name(rte->relid)) != 0) { /* - * Apparently the rel has been renamed since the rule was - * made. Emit a fake alias clause so that variable references - * will still work. This is not a 100% solution but should - * work in most reasonable situations. + * Apparently the rel has been renamed since the rule was made. + * Emit a fake alias clause so that variable references will still + * work. This is not a 100% solution but should work in most + * reasonable situations. */ appendStringInfo(buf, " %s", quote_identifier(rte->eref->aliasname)); @@ -4136,10 +4130,9 @@ get_from_clause_item(Node *jtnode, Query *query, deparse_context *context) else if (rte->rtekind == RTE_FUNCTION) { /* - * For a function RTE, always give an alias. - * This covers possible renaming of the function and/or - * instability of the FigureColname rules for things that - * aren't simple functions. + * For a function RTE, always give an alias. This covers possible + * renaming of the function and/or instability of the + * FigureColname rules for things that aren't simple functions. */ appendStringInfo(buf, " %s", quote_identifier(rte->eref->aliasname)); @@ -4175,7 +4168,7 @@ get_from_clause_item(Node *jtnode, Query *query, deparse_context *context) need_paren_on_right = PRETTY_PAREN(context) && !IsA(j->rarg, RangeTblRef) && - !(IsA(j->rarg, JoinExpr) && ((JoinExpr*) j->rarg)->alias != NULL); + !(IsA(j->rarg, JoinExpr) &&((JoinExpr *) j->rarg)->alias != NULL); if (!PRETTY_PAREN(context) || j->alias != NULL) appendStringInfoChar(buf, '('); @@ -4278,7 +4271,7 @@ get_from_clause_item(Node *jtnode, Query *query, deparse_context *context) if (col != list_head(j->using)) appendStringInfo(buf, ", "); appendStringInfoString(buf, - quote_identifier(strVal(lfirst(col)))); + quote_identifier(strVal(lfirst(col)))); } appendStringInfoChar(buf, ')'); } @@ -4415,8 +4408,7 @@ get_opclass_name(Oid opclass, Oid actual_datatype, opcrec = (Form_pg_opclass) GETSTRUCT(ht_opc); /* - * Special case for ARRAY_OPS: pretend it is default for any array - * type + * Special case for ARRAY_OPS: pretend it is default for any array type */ if (OidIsValid(actual_datatype)) { @@ -4476,19 +4468,19 @@ processIndirection(Node *node, deparse_context *context) format_type_be(fstore->resulttype)); /* - * Get the field name. Note we assume here that there's only - * one field being assigned to. This is okay in stored rules - * but could be wrong in executable target lists. Presently - * no problem since explain.c doesn't print plan targetlists, - * but someday may have to think of something ... + * Get the field name. Note we assume here that there's only one + * field being assigned to. This is okay in stored rules but + * could be wrong in executable target lists. Presently no + * problem since explain.c doesn't print plan targetlists, but + * someday may have to think of something ... */ fieldname = get_relid_attribute_name(typrelid, - linitial_int(fstore->fieldnums)); + linitial_int(fstore->fieldnums)); appendStringInfo(buf, ".%s", quote_identifier(fieldname)); /* - * We ignore arg since it should be an uninteresting reference - * to the target column or subcolumn. + * We ignore arg since it should be an uninteresting reference to + * the target column or subcolumn. */ node = (Node *) linitial(fstore->newvals); } @@ -4501,8 +4493,8 @@ processIndirection(Node *node, deparse_context *context) printSubscripts(aref, context); /* - * We ignore refexpr since it should be an uninteresting - * reference to the target column or subcolumn. + * We ignore refexpr since it should be an uninteresting reference + * to the target column or subcolumn. */ node = (Node *) aref->refassgnexpr; } @@ -4545,10 +4537,9 @@ const char * quote_identifier(const char *ident) { /* - * Can avoid quoting if ident starts with a lowercase letter or - * underscore and contains only lowercase letters, digits, and - * underscores, *and* is not any SQL keyword. Otherwise, supply - * quotes. + * Can avoid quoting if ident starts with a lowercase letter or underscore + * and contains only lowercase letters, digits, and underscores, *and* is + * not any SQL keyword. Otherwise, supply quotes. */ int nquotes = 0; bool safe; @@ -4557,8 +4548,8 @@ quote_identifier(const char *ident) char *optr; /* - * would like to use macros here, but they might yield - * unwanted locale-specific results... + * would like to use macros here, but they might yield unwanted + * locale-specific results... */ safe = ((ident[0] >= 'a' && ident[0] <= 'z') || ident[0] == '_'); @@ -4583,13 +4574,13 @@ quote_identifier(const char *ident) if (safe) { /* - * Check for keyword. This test is overly strong, since many of - * the "keywords" known to the parser are usable as column names, - * but the parser doesn't provide any easy way to test for whether - * an identifier is safe or not... so be safe not sorry. + * Check for keyword. This test is overly strong, since many of the + * "keywords" known to the parser are usable as column names, but the + * parser doesn't provide any easy way to test for whether an + * identifier is safe or not... so be safe not sorry. * - * Note: ScanKeywordLookup() does case-insensitive comparison, but - * that's fine, since we already know we have all-lower-case. + * Note: ScanKeywordLookup() does case-insensitive comparison, but that's + * fine, since we already know we have all-lower-case. */ if (ScanKeywordLookup(ident) != NULL) safe = false; @@ -4702,8 +4693,8 @@ generate_function_name(Oid funcid, int nargs, Oid *argtypes) /* * The idea here is to schema-qualify only if the parser would fail to - * resolve the correct function given the unqualified func name with - * the specified argtypes. + * resolve the correct function given the unqualified func name with the + * specified argtypes. */ p_result = func_get_detail(list_make1(makeString(proname)), NIL, nargs, argtypes, diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c index ccc8d0f448..95980ca1e0 100644 --- a/src/backend/utils/adt/selfuncs.c +++ b/src/backend/utils/adt/selfuncs.c @@ -15,7 +15,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.190 2005/10/11 17:27:14 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.191 2005/10/15 02:49:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -197,8 +197,8 @@ eqsel(PG_FUNCTION_ARGS) double selec; /* - * If expression is not variable = something or something = variable, - * then punt and return a default estimate. + * If expression is not variable = something or something = variable, then + * punt and return a default estimate. */ if (!get_restriction_variable(root, args, varRelid, &vardata, &other, &varonleft)) @@ -229,11 +229,11 @@ eqsel(PG_FUNCTION_ARGS) int i; /* - * Is the constant "=" to any of the column's most common - * values? (Although the given operator may not really be - * "=", we will assume that seeing whether it returns TRUE is - * an appropriate test. If you don't like this, maybe you - * shouldn't be using eqsel for your operator...) + * Is the constant "=" to any of the column's most common values? + * (Although the given operator may not really be "=", we will + * assume that seeing whether it returns TRUE is an appropriate + * test. If you don't like this, maybe you shouldn't be using + * eqsel for your operator...) */ if (get_attstatsslot(vardata.statsTuple, vardata.atttype, vardata.atttypmod, @@ -271,18 +271,18 @@ eqsel(PG_FUNCTION_ARGS) if (match) { /* - * Constant is "=" to this common value. We know - * selectivity exactly (or as exactly as VACUUM could - * calculate it, anyway). + * Constant is "=" to this common value. We know selectivity + * exactly (or as exactly as VACUUM could calculate it, + * anyway). */ selec = numbers[i]; } else { /* - * Comparison is against a constant that is neither NULL - * nor any of the common values. Its selectivity cannot - * be more than this: + * Comparison is against a constant that is neither NULL nor + * any of the common values. Its selectivity cannot be more + * than this: */ double sumcommon = 0.0; double otherdistinct; @@ -293,10 +293,10 @@ eqsel(PG_FUNCTION_ARGS) CLAMP_PROBABILITY(selec); /* - * and in fact it's probably a good deal less. We - * approximate that all the not-common values share this - * remaining fraction equally, so we divide by the number - * of other distinct values. + * and in fact it's probably a good deal less. We approximate + * that all the not-common values share this remaining + * fraction equally, so we divide by the number of other + * distinct values. */ otherdistinct = get_variable_numdistinct(&vardata) - nnumbers; @@ -304,8 +304,8 @@ eqsel(PG_FUNCTION_ARGS) selec /= otherdistinct; /* - * Another cross-check: selectivity shouldn't be estimated - * as more than the least common "most common value". + * Another cross-check: selectivity shouldn't be estimated as + * more than the least common "most common value". */ if (nnumbers > 0 && selec > numbers[nnumbers - 1]) selec = numbers[nnumbers - 1]; @@ -319,14 +319,14 @@ eqsel(PG_FUNCTION_ARGS) double ndistinct; /* - * Search is for a value that we do not know a priori, but we - * will assume it is not NULL. Estimate the selectivity as - * non-null fraction divided by number of distinct values, so - * that we get a result averaged over all possible values - * whether common or uncommon. (Essentially, we are assuming - * that the not-yet-known comparison value is equally likely - * to be any of the possible values, regardless of their - * frequency in the table. Is that a good idea?) + * Search is for a value that we do not know a priori, but we will + * assume it is not NULL. Estimate the selectivity as non-null + * fraction divided by number of distinct values, so that we get a + * result averaged over all possible values whether common or + * uncommon. (Essentially, we are assuming that the not-yet-known + * comparison value is equally likely to be any of the possible + * values, regardless of their frequency in the table. Is that a + * good idea?) */ selec = 1.0 - stats->stanullfrac; ndistinct = get_variable_numdistinct(&vardata); @@ -334,8 +334,8 @@ eqsel(PG_FUNCTION_ARGS) selec /= ndistinct; /* - * Cross-check: selectivity should never be estimated as more - * than the most common value's. + * Cross-check: selectivity should never be estimated as more than + * the most common value's. */ if (get_attstatsslot(vardata.statsTuple, vardata.atttype, vardata.atttypmod, @@ -352,10 +352,10 @@ eqsel(PG_FUNCTION_ARGS) else { /* - * No VACUUM ANALYZE stats available, so make a guess using - * estimated number of distinct values and assuming they are - * equally common. (The guess is unlikely to be very good, but we - * do know a few special cases.) + * No VACUUM ANALYZE stats available, so make a guess using estimated + * number of distinct values and assuming they are equally common. + * (The guess is unlikely to be very good, but we do know a few + * special cases.) */ selec = 1.0 / get_variable_numdistinct(&vardata); } @@ -386,17 +386,17 @@ neqsel(PG_FUNCTION_ARGS) float8 result; /* - * We want 1 - eqsel() where the equality operator is the one - * associated with this != operator, that is, its negator. + * We want 1 - eqsel() where the equality operator is the one associated + * with this != operator, that is, its negator. */ eqop = get_negator(operator); if (eqop) { result = DatumGetFloat8(DirectFunctionCall4(eqsel, PointerGetDatum(root), - ObjectIdGetDatum(eqop), + ObjectIdGetDatum(eqop), PointerGetDatum(args), - Int32GetDatum(varRelid))); + Int32GetDatum(varRelid))); } else { @@ -447,9 +447,9 @@ scalarineqsel(PlannerInfo *root, Oid operator, bool isgt, /* * If we have most-common-values info, add up the fractions of the MCV - * entries that satisfy MCV OP CONST. These fractions contribute - * directly to the result selectivity. Also add up the total fraction - * represented by MCV entries. + * entries that satisfy MCV OP CONST. These fractions contribute directly + * to the result selectivity. Also add up the total fraction represented + * by MCV entries. */ mcv_selec = 0.0; sumcommon = 0.0; @@ -473,17 +473,17 @@ scalarineqsel(PlannerInfo *root, Oid operator, bool isgt, } /* - * If there is a histogram, determine which bin the constant falls in, - * and compute the resulting contribution to selectivity. + * If there is a histogram, determine which bin the constant falls in, and + * compute the resulting contribution to selectivity. * * Someday, VACUUM might store more than one histogram per rel/att, - * corresponding to more than one possible sort ordering defined for - * the column type. However, to make that work we will need to figure - * out which staop to search for --- it's not necessarily the one we - * have at hand! (For example, we might have a '<=' operator rather - * than the '<' operator that will appear in staop.) For now, assume - * that whatever appears in pg_statistic is sorted the same way our - * operator sorts, or the reverse way if isgt is TRUE. + * corresponding to more than one possible sort ordering defined for the + * column type. However, to make that work we will need to figure out + * which staop to search for --- it's not necessarily the one we have at + * hand! (For example, we might have a '<=' operator rather than the '<' + * operator that will appear in staop.) For now, assume that whatever + * appears in pg_statistic is sorted the same way our operator sorts, or + * the reverse way if isgt is TRUE. */ hist_selec = 0.0; @@ -511,10 +511,9 @@ scalarineqsel(PlannerInfo *root, Oid operator, bool isgt, else { /* - * Scan to find proper location. This could be made - * faster by using a binary-search method, but it's - * probably not worth the trouble for typical histogram - * sizes. + * Scan to find proper location. This could be made faster by + * using a binary-search method, but it's probably not worth + * the trouble for typical histogram sizes. */ for (i = 1; i < nvalues; i++) { @@ -542,8 +541,8 @@ scalarineqsel(PlannerInfo *root, Oid operator, bool isgt, * We have values[i-1] < constant < values[i]. * * Convert the constant and the two nearest bin boundary - * values to a uniform comparison scale, and do a - * linear interpolation within this bin. + * values to a uniform comparison scale, and do a linear + * interpolation within this bin. */ if (convert_to_scalar(constval, consttype, &val, values[i - 1], values[i], @@ -564,10 +563,10 @@ scalarineqsel(PlannerInfo *root, Oid operator, bool isgt, binfrac = (val - low) / (high - low); /* - * Watch out for the possibility that we got a - * NaN or Infinity from the division. This - * can happen despite the previous checks, if - * for example "low" is -Infinity. + * Watch out for the possibility that we got a NaN + * or Infinity from the division. This can happen + * despite the previous checks, if for example + * "low" is -Infinity. */ if (isnan(binfrac) || binfrac < 0.0 || binfrac > 1.0) @@ -577,22 +576,20 @@ scalarineqsel(PlannerInfo *root, Oid operator, bool isgt, else { /* - * Ideally we'd produce an error here, on the - * grounds that the given operator shouldn't have - * scalarXXsel registered as its selectivity func - * unless we can deal with its operand types. But - * currently, all manner of stuff is invoking - * scalarXXsel, so give a default estimate until - * that can be fixed. + * Ideally we'd produce an error here, on the grounds + * that the given operator shouldn't have scalarXXsel + * registered as its selectivity func unless we can + * deal with its operand types. But currently, all + * manner of stuff is invoking scalarXXsel, so give a + * default estimate until that can be fixed. */ binfrac = 0.5; } /* - * Now, compute the overall selectivity across the - * values represented by the histogram. We have i-1 - * full bins and binfrac partial bin below the - * constant. + * Now, compute the overall selectivity across the values + * represented by the histogram. We have i-1 full bins + * and binfrac partial bin below the constant. */ histfrac = (double) (i - 1) + binfrac; histfrac /= (double) (nvalues - 1); @@ -608,9 +605,9 @@ scalarineqsel(PlannerInfo *root, Oid operator, bool isgt, hist_selec = isgt ? (1.0 - histfrac) : histfrac; /* - * The histogram boundaries are only approximate to begin - * with, and may well be out of date anyway. Therefore, don't - * believe extremely small or large selectivity estimates. + * The histogram boundaries are only approximate to begin with, + * and may well be out of date anyway. Therefore, don't believe + * extremely small or large selectivity estimates. */ if (hist_selec < 0.0001) hist_selec = 0.0001; @@ -623,8 +620,8 @@ scalarineqsel(PlannerInfo *root, Oid operator, bool isgt, /* * Now merge the results from the MCV and histogram calculations, - * realizing that the histogram covers only the non-null values that - * are not listed in MCV. + * realizing that the histogram covers only the non-null values that are + * not listed in MCV. */ selec = 1.0 - stats->stanullfrac - sumcommon; @@ -666,16 +663,15 @@ scalarltsel(PG_FUNCTION_ARGS) double selec; /* - * If expression is not variable op something or something op - * variable, then punt and return a default estimate. + * If expression is not variable op something or something op variable, + * then punt and return a default estimate. */ if (!get_restriction_variable(root, args, varRelid, &vardata, &other, &varonleft)) PG_RETURN_FLOAT8(DEFAULT_INEQ_SEL); /* - * Can't do anything useful if the something is not a constant, - * either. + * Can't do anything useful if the something is not a constant, either. */ if (!IsA(other, Const)) { @@ -684,8 +680,8 @@ scalarltsel(PG_FUNCTION_ARGS) } /* - * If the constant is NULL, assume operator is strict and return zero, - * ie, operator will never return TRUE. + * If the constant is NULL, assume operator is strict and return zero, ie, + * operator will never return TRUE. */ if (((Const *) other)->constisnull) { @@ -742,16 +738,15 @@ scalargtsel(PG_FUNCTION_ARGS) double selec; /* - * If expression is not variable op something or something op - * variable, then punt and return a default estimate. + * If expression is not variable op something or something op variable, + * then punt and return a default estimate. */ if (!get_restriction_variable(root, args, varRelid, &vardata, &other, &varonleft)) PG_RETURN_FLOAT8(DEFAULT_INEQ_SEL); /* - * Can't do anything useful if the something is not a constant, - * either. + * Can't do anything useful if the something is not a constant, either. */ if (!IsA(other, Const)) { @@ -760,8 +755,8 @@ scalargtsel(PG_FUNCTION_ARGS) } /* - * If the constant is NULL, assume operator is strict and return zero, - * ie, operator will never return TRUE. + * If the constant is NULL, assume operator is strict and return zero, ie, + * operator will never return TRUE. */ if (((Const *) other)->constisnull) { @@ -841,8 +836,8 @@ patternsel(PG_FUNCTION_ARGS, Pattern_Type ptype) variable = (Node *) linitial(args); /* - * If the constant is NULL, assume operator is strict and return zero, - * ie, operator will never return TRUE. + * If the constant is NULL, assume operator is strict and return zero, ie, + * operator will never return TRUE. */ if (((Const *) other)->constisnull) { @@ -853,10 +848,10 @@ patternsel(PG_FUNCTION_ARGS, Pattern_Type ptype) consttype = ((Const *) other)->consttype; /* - * The right-hand const is type text or bytea for all supported - * operators. We do not expect to see binary-compatible types here, - * since const-folding should have relabeled the const to exactly - * match the operator's declared type. + * The right-hand const is type text or bytea for all supported operators. + * We do not expect to see binary-compatible types here, since + * const-folding should have relabeled the const to exactly match the + * operator's declared type. */ if (consttype != TEXTOID && consttype != BYTEAOID) { @@ -865,15 +860,15 @@ patternsel(PG_FUNCTION_ARGS, Pattern_Type ptype) } /* - * Similarly, the exposed type of the left-hand side should be one - * of those we know. (Do not look at vardata.atttype, which might be - * something binary-compatible but different.) We can use it to choose + * Similarly, the exposed type of the left-hand side should be one of + * those we know. (Do not look at vardata.atttype, which might be + * something binary-compatible but different.) We can use it to choose * the index opclass from which we must draw the comparison operators. * * NOTE: It would be more correct to use the PATTERN opclasses than the - * simple ones, but at the moment ANALYZE will not generate statistics - * for the PATTERN operators. But our results are so approximate - * anyway that it probably hardly matters. + * simple ones, but at the moment ANALYZE will not generate statistics for + * the PATTERN operators. But our results are so approximate anyway that + * it probably hardly matters. */ vartype = vardata.vartype; @@ -904,8 +899,8 @@ patternsel(PG_FUNCTION_ARGS, Pattern_Type ptype) pstatus = pattern_fixed_prefix(patt, ptype, &prefix, &rest); /* - * If necessary, coerce the prefix constant to the right type. (The - * "rest" constant need not be changed.) + * If necessary, coerce the prefix constant to the right type. (The "rest" + * constant need not be changed.) */ if (prefix && prefix->consttype != vartype) { @@ -915,11 +910,11 @@ patternsel(PG_FUNCTION_ARGS, Pattern_Type ptype) { case TEXTOID: prefixstr = DatumGetCString(DirectFunctionCall1(textout, - prefix->constvalue)); + prefix->constvalue)); break; case BYTEAOID: prefixstr = DatumGetCString(DirectFunctionCall1(byteaout, - prefix->constvalue)); + prefix->constvalue)); break; default: elog(ERROR, "unrecognized consttype: %u", @@ -945,16 +940,15 @@ patternsel(PG_FUNCTION_ARGS, Pattern_Type ptype) eqargs = list_make2(variable, prefix); result = DatumGetFloat8(DirectFunctionCall4(eqsel, PointerGetDatum(root), - ObjectIdGetDatum(eqopr), - PointerGetDatum(eqargs), - Int32GetDatum(varRelid))); + ObjectIdGetDatum(eqopr), + PointerGetDatum(eqargs), + Int32GetDatum(varRelid))); } else { /* * Not exact-match pattern. We estimate selectivity of the fixed - * prefix and remainder of pattern separately, then combine the - * two. + * prefix and remainder of pattern separately, then combine the two. */ Selectivity prefixsel; Selectivity restsel; @@ -1113,8 +1107,8 @@ booltestsel(PlannerInfo *root, BoolTestType booltesttype, Node *arg, freq_true = 1.0 - numbers[0] - freq_null; /* - * Next derive frequency for false. Then use these as - * appropriate to derive frequency for each case. + * Next derive frequency for false. Then use these as appropriate + * to derive frequency for each case. */ freq_false = 1.0 - freq_true - freq_null; @@ -1157,10 +1151,9 @@ booltestsel(PlannerInfo *root, BoolTestType booltesttype, Node *arg, else { /* - * No most-common-value info available. Still have null - * fraction information, so use it for IS [NOT] UNKNOWN. - * Otherwise adjust for null fraction and assume an even split - * for boolean tests. + * No most-common-value info available. Still have null fraction + * information, so use it for IS [NOT] UNKNOWN. Otherwise adjust + * for null fraction and assume an even split for boolean tests. */ switch (booltesttype) { @@ -1174,8 +1167,8 @@ booltestsel(PlannerInfo *root, BoolTestType booltesttype, Node *arg, case IS_NOT_UNKNOWN: /* - * Select not unknown (not null) values. Calculate - * from freq_null. + * Select not unknown (not null) values. Calculate from + * freq_null. */ selec = 1.0 - freq_null; break; @@ -1198,8 +1191,8 @@ booltestsel(PlannerInfo *root, BoolTestType booltesttype, Node *arg, /* * If we can't get variable statistics for the argument, perhaps * clause_selectivity can do something with it. We ignore the - * possibility of a NULL value when using clause_selectivity, and - * just assume the value is either TRUE or FALSE. + * possibility of a NULL value when using clause_selectivity, and just + * assume the value is either TRUE or FALSE. */ switch (booltesttype) { @@ -1217,7 +1210,7 @@ booltestsel(PlannerInfo *root, BoolTestType booltesttype, Node *arg, case IS_FALSE: case IS_NOT_TRUE: selec = 1.0 - (double) clause_selectivity(root, arg, - varRelid, jointype); + varRelid, jointype); break; default: elog(ERROR, "unrecognized booltesttype: %d", @@ -1366,17 +1359,16 @@ eqjoinsel(PG_FUNCTION_ARGS) if (have_mcvs1 && have_mcvs2) { /* - * We have most-common-value lists for both relations. Run - * through the lists to see which MCVs actually join to each other - * with the given operator. This allows us to determine the exact - * join selectivity for the portion of the relations represented - * by the MCV lists. We still have to estimate for the remaining - * population, but in a skewed distribution this gives us a big - * leg up in accuracy. For motivation see the analysis in Y. - * Ioannidis and S. Christodoulakis, "On the propagation of errors - * in the size of join results", Technical Report 1018, Computer - * Science Dept., University of Wisconsin, Madison, March 1991 - * (available from ftp.cs.wisc.edu). + * We have most-common-value lists for both relations. Run through + * the lists to see which MCVs actually join to each other with the + * given operator. This allows us to determine the exact join + * selectivity for the portion of the relations represented by the MCV + * lists. We still have to estimate for the remaining population, but + * in a skewed distribution this gives us a big leg up in accuracy. + * For motivation see the analysis in Y. Ioannidis and S. + * Christodoulakis, "On the propagation of errors in the size of join + * results", Technical Report 1018, Computer Science Dept., University + * of Wisconsin, Madison, March 1991 (available from ftp.cs.wisc.edu). */ FmgrInfo eqproc; bool *hasmatch1; @@ -1400,20 +1392,20 @@ eqjoinsel(PG_FUNCTION_ARGS) hasmatch2 = (bool *) palloc0(nvalues2 * sizeof(bool)); /* - * If we are doing any variant of JOIN_IN, pretend all the values - * of the righthand relation are unique (ie, act as if it's been + * If we are doing any variant of JOIN_IN, pretend all the values of + * the righthand relation are unique (ie, act as if it's been * DISTINCT'd). * - * NOTE: it might seem that we should unique-ify the lefthand input - * when considering JOIN_REVERSE_IN. But this is not so, because - * the join clause we've been handed has not been commuted from - * the way the parser originally wrote it. We know that the - * unique side of the IN clause is *always* on the right. + * NOTE: it might seem that we should unique-ify the lefthand input when + * considering JOIN_REVERSE_IN. But this is not so, because the join + * clause we've been handed has not been commuted from the way the + * parser originally wrote it. We know that the unique side of the IN + * clause is *always* on the right. * * NOTE: it would be dangerous to try to be smart about JOIN_LEFT or * JOIN_RIGHT here, because we do not have enough information to - * determine which var is really on which side of the join. - * Perhaps someday we should pass in more information. + * determine which var is really on which side of the join. Perhaps + * someday we should pass in more information. */ if (jointype == JOIN_IN || jointype == JOIN_REVERSE_IN || @@ -1428,10 +1420,10 @@ eqjoinsel(PG_FUNCTION_ARGS) } /* - * Note we assume that each MCV will match at most one member of - * the other MCV list. If the operator isn't really equality, - * there could be multiple matches --- but we don't look for them, - * both for speed and because the math wouldn't add up... + * Note we assume that each MCV will match at most one member of the + * other MCV list. If the operator isn't really equality, there could + * be multiple matches --- but we don't look for them, both for speed + * and because the math wouldn't add up... */ matchprodfreq = 0.0; nmatches = 0; @@ -1480,8 +1472,8 @@ eqjoinsel(PG_FUNCTION_ARGS) pfree(hasmatch2); /* - * Compute total frequency of non-null values that are not in the - * MCV lists. + * Compute total frequency of non-null values that are not in the MCV + * lists. */ otherfreq1 = 1.0 - nullfrac1 - matchfreq1 - unmatchfreq1; otherfreq2 = 1.0 - nullfrac2 - matchfreq2 - unmatchfreq2; @@ -1491,10 +1483,10 @@ eqjoinsel(PG_FUNCTION_ARGS) /* * We can estimate the total selectivity from the point of view of * relation 1 as: the known selectivity for matched MCVs, plus - * unmatched MCVs that are assumed to match against random members - * of relation 2's non-MCV population, plus non-MCV values that - * are assumed to match against random members of relation 2's - * unmatched MCVs plus non-MCV values. + * unmatched MCVs that are assumed to match against random members of + * relation 2's non-MCV population, plus non-MCV values that are + * assumed to match against random members of relation 2's unmatched + * MCVs plus non-MCV values. */ totalsel1 = matchprodfreq; if (nd2 > nvalues2) @@ -1512,9 +1504,9 @@ eqjoinsel(PG_FUNCTION_ARGS) /* * Use the smaller of the two estimates. This can be justified in - * essentially the same terms as given below for the no-stats - * case: to a first approximation, we are estimating from the - * point of view of the relation with smaller nd. + * essentially the same terms as given below for the no-stats case: to + * a first approximation, we are estimating from the point of view of + * the relation with smaller nd. */ selec = (totalsel1 < totalsel2) ? totalsel1 : totalsel2; } @@ -1522,24 +1514,23 @@ eqjoinsel(PG_FUNCTION_ARGS) { /* * We do not have MCV lists for both sides. Estimate the join - * selectivity as MIN(1/nd1,1/nd2)*(1-nullfrac1)*(1-nullfrac2). - * This is plausible if we assume that the join operator is strict - * and the non-null values are about equally distributed: a given - * non-null tuple of rel1 will join to either zero or - * N2*(1-nullfrac2)/nd2 rows of rel2, so total join rows are at - * most N1*(1-nullfrac1)*N2*(1-nullfrac2)/nd2 giving a join - * selectivity of not more than (1-nullfrac1)*(1-nullfrac2)/nd2. - * By the same logic it is not more than - * (1-nullfrac1)*(1-nullfrac2)/nd1, so the expression with MIN() - * is an upper bound. Using the MIN() means we estimate from the - * point of view of the relation with smaller nd (since the larger - * nd is determining the MIN). It is reasonable to assume that - * most tuples in this rel will have join partners, so the bound - * is probably reasonably tight and should be taken as-is. + * selectivity as MIN(1/nd1,1/nd2)*(1-nullfrac1)*(1-nullfrac2). This + * is plausible if we assume that the join operator is strict and the + * non-null values are about equally distributed: a given non-null + * tuple of rel1 will join to either zero or N2*(1-nullfrac2)/nd2 rows + * of rel2, so total join rows are at most + * N1*(1-nullfrac1)*N2*(1-nullfrac2)/nd2 giving a join selectivity of + * not more than (1-nullfrac1)*(1-nullfrac2)/nd2. By the same logic it + * is not more than (1-nullfrac1)*(1-nullfrac2)/nd1, so the expression + * with MIN() is an upper bound. Using the MIN() means we estimate + * from the point of view of the relation with smaller nd (since the + * larger nd is determining the MIN). It is reasonable to assume that + * most tuples in this rel will have join partners, so the bound is + * probably reasonably tight and should be taken as-is. * * XXX Can we be smarter if we have an MCV list for just one side? It - * seems that if we assume equal distribution for the other side, - * we end up with the same answer anyway. + * seems that if we assume equal distribution for the other side, we + * end up with the same answer anyway. */ double nullfrac1 = stats1 ? stats1->stanullfrac : 0.0; double nullfrac2 = stats2 ? stats2->stanullfrac : 0.0; @@ -1588,9 +1579,9 @@ neqjoinsel(PG_FUNCTION_ARGS) { result = DatumGetFloat8(DirectFunctionCall4(eqjoinsel, PointerGetDatum(root), - ObjectIdGetDatum(eqop), + ObjectIdGetDatum(eqop), PointerGetDatum(args), - Int16GetDatum(jointype))); + Int16GetDatum(jointype))); } else { @@ -1812,10 +1803,10 @@ mergejoinscansel(PlannerInfo *root, Node *clause, *rightscan = selec; /* - * Only one of the two fractions can really be less than 1.0; believe - * the smaller estimate and reset the other one to exactly 1.0. If we - * get exactly equal estimates (as can easily happen with self-joins), - * believe neither. + * Only one of the two fractions can really be less than 1.0; believe the + * smaller estimate and reset the other one to exactly 1.0. If we get + * exactly equal estimates (as can easily happen with self-joins), believe + * neither. */ if (*leftscan > *rightscan) *leftscan = 1.0; @@ -1837,9 +1828,9 @@ fail: */ typedef struct { - Node *var; /* might be an expression, not just a Var */ - RelOptInfo *rel; /* relation it belongs to */ - double ndistinct; /* # distinct values */ + Node *var; /* might be an expression, not just a Var */ + RelOptInfo *rel; /* relation it belongs to */ + double ndistinct; /* # distinct values */ } GroupVarInfo; static List * @@ -1999,9 +1990,9 @@ estimate_num_groups(PlannerInfo *root, List *groupExprs, double input_rows) /* * If we find any variable-free GROUP BY item, then either it is a - * constant (and we can ignore it) or it contains a volatile - * function; in the latter case we punt and assume that each input - * row will yield a distinct group. + * constant (and we can ignore it) or it contains a volatile function; + * in the latter case we punt and assume that each input row will + * yield a distinct group. */ if (varshere == NIL) { @@ -2031,9 +2022,9 @@ estimate_num_groups(PlannerInfo *root, List *groupExprs, double input_rows) * Steps 3/4: group Vars by relation and estimate total numdistinct. * * For each iteration of the outer loop, we process the frontmost Var in - * varinfos, plus all other Vars in the same relation. We remove - * these Vars from the newvarinfos list for the next iteration. This - * is the easiest way to group Vars of same rel together. + * varinfos, plus all other Vars in the same relation. We remove these + * Vars from the newvarinfos list for the next iteration. This is the + * easiest way to group Vars of same rel together. */ numdistinct = 1.0; @@ -2075,11 +2066,11 @@ estimate_num_groups(PlannerInfo *root, List *groupExprs, double input_rows) if (rel->tuples > 0) { /* - * Clamp to size of rel, or size of rel / 10 if multiple Vars. - * The fudge factor is because the Vars are probably correlated - * but we don't know by how much. We should never clamp to less - * than the largest ndistinct value for any of the Vars, though, - * since there will surely be at least that many groups. + * Clamp to size of rel, or size of rel / 10 if multiple Vars. The + * fudge factor is because the Vars are probably correlated but we + * don't know by how much. We should never clamp to less than the + * largest ndistinct value for any of the Vars, though, since + * there will surely be at least that many groups. */ double clamp = rel->tuples; @@ -2179,8 +2170,8 @@ estimate_hash_bucketsize(PlannerInfo *root, Node *hashkey, double nbuckets) else { /* - * Believe a default ndistinct only if it came from stats. - * Otherwise punt and return 0.1, per comments above. + * Believe a default ndistinct only if it came from stats. Otherwise + * punt and return 0.1, per comments above. */ if (ndistinct == DEFAULT_NUM_DISTINCT) { @@ -2195,21 +2186,20 @@ estimate_hash_bucketsize(PlannerInfo *root, Node *hashkey, double nbuckets) avgfreq = (1.0 - stanullfrac) / ndistinct; /* - * Adjust ndistinct to account for restriction clauses. Observe we - * are assuming that the data distribution is affected uniformly by - * the restriction clauses! + * Adjust ndistinct to account for restriction clauses. Observe we are + * assuming that the data distribution is affected uniformly by the + * restriction clauses! * - * XXX Possibly better way, but much more expensive: multiply by - * selectivity of rel's restriction clauses that mention the target - * Var. + * XXX Possibly better way, but much more expensive: multiply by selectivity + * of rel's restriction clauses that mention the target Var. */ if (vardata.rel) ndistinct *= vardata.rel->rows / vardata.rel->tuples; /* - * Initial estimate of bucketsize fraction is 1/nbuckets as long as - * the number of buckets is less than the expected number of distinct - * values; otherwise it is 1/ndistinct. + * Initial estimate of bucketsize fraction is 1/nbuckets as long as the + * number of buckets is less than the expected number of distinct values; + * otherwise it is 1/ndistinct. */ if (ndistinct > nbuckets) estfract = 1.0 / nbuckets; @@ -2239,16 +2229,15 @@ estimate_hash_bucketsize(PlannerInfo *root, Node *hashkey, double nbuckets) } /* - * Adjust estimated bucketsize upward to account for skewed - * distribution. + * Adjust estimated bucketsize upward to account for skewed distribution. */ if (avgfreq > 0.0 && mcvfreq > avgfreq) estfract *= mcvfreq / avgfreq; /* * Clamp bucketsize to sane range (the above adjustment could easily - * produce an out-of-range result). We set the lower bound a little - * above zero, since zero isn't a very sane result. + * produce an out-of-range result). We set the lower bound a little above + * zero, since zero isn't a very sane result. */ if (estfract < 1.0e-6) estfract = 1.0e-6; @@ -2303,18 +2292,18 @@ convert_to_scalar(Datum value, Oid valuetypid, double *scaledvalue, double *scaledlobound, double *scaledhibound) { /* - * Both the valuetypid and the boundstypid should exactly match - * the declared input type(s) of the operator we are invoked for, - * so we just error out if either is not recognized. + * Both the valuetypid and the boundstypid should exactly match the + * declared input type(s) of the operator we are invoked for, so we just + * error out if either is not recognized. * - * XXX The histogram we are interpolating between points of could belong - * to a column that's only binary-compatible with the declared type. - * In essence we are assuming that the semantics of binary-compatible - * types are enough alike that we can use a histogram generated with one - * type's operators to estimate selectivity for the other's. This is - * outright wrong in some cases --- in particular signed versus unsigned + * XXX The histogram we are interpolating between points of could belong to a + * column that's only binary-compatible with the declared type. In essence + * we are assuming that the semantics of binary-compatible types are + * enough alike that we can use a histogram generated with one type's + * operators to estimate selectivity for the other's. This is outright + * wrong in some cases --- in particular signed versus unsigned * interpretation could trip us up. But it's useful enough in the - * majority of cases that we do it anyway. Should think about more + * majority of cases that we do it anyway. Should think about more * rigorous ways to do it. */ switch (valuetypid) @@ -2350,9 +2339,9 @@ convert_to_scalar(Datum value, Oid valuetypid, double *scaledvalue, case TEXTOID: case NAMEOID: { - char *valstr = convert_string_datum(value, valuetypid); - char *lostr = convert_string_datum(lobound, boundstypid); - char *histr = convert_string_datum(hibound, boundstypid); + char *valstr = convert_string_datum(value, valuetypid); + char *lostr = convert_string_datum(lobound, boundstypid); + char *histr = convert_string_datum(hibound, boundstypid); convert_string_to_scalar(valstr, scaledvalue, lostr, scaledlobound, @@ -2444,8 +2433,8 @@ convert_numeric_to_scalar(Datum value, Oid typid) } /* - * Can't get here unless someone tries to use scalarltsel/scalargtsel - * on an operator with one numeric and one non-numeric operand. + * Can't get here unless someone tries to use scalarltsel/scalargtsel on + * an operator with one numeric and one non-numeric operand. */ elog(ERROR, "unsupported type: %u", typid); return 0; @@ -2563,8 +2552,7 @@ convert_one_string_to_scalar(char *value, int rangelo, int rangehi) return 0.0; /* empty string has scalar value 0 */ /* - * Since base is at least 10, need not consider more than about 20 - * chars + * Since base is at least 10, need not consider more than about 20 chars */ if (slen > 20) slen = 20; @@ -2628,8 +2616,8 @@ convert_string_datum(Datum value, Oid typid) default: /* - * Can't get here unless someone tries to use scalarltsel on - * an operator with one string and one non-string operand. + * Can't get here unless someone tries to use scalarltsel on an + * operator with one string and one non-string operand. */ elog(ERROR, "unsupported type: %u", typid); return NULL; @@ -2642,16 +2630,16 @@ convert_string_datum(Datum value, Oid typid) size_t xfrmlen2; /* - * Note: originally we guessed at a suitable output buffer size, - * and only needed to call strxfrm twice if our guess was too - * small. However, it seems that some versions of Solaris have - * buggy strxfrm that can write past the specified buffer length - * in that scenario. So, do it the dumb way for portability. + * Note: originally we guessed at a suitable output buffer size, and + * only needed to call strxfrm twice if our guess was too small. + * However, it seems that some versions of Solaris have buggy strxfrm + * that can write past the specified buffer length in that scenario. + * So, do it the dumb way for portability. * - * Yet other systems (e.g., glibc) sometimes return a smaller value - * from the second call than the first; thus the Assert must be <= - * not == as you'd expect. Can't any of these people program - * their way out of a paper bag? + * Yet other systems (e.g., glibc) sometimes return a smaller value from + * the second call than the first; thus the Assert must be <= not == + * as you'd expect. Can't any of these people program their way out + * of a paper bag? */ xfrmlen = strxfrm(NULL, val, 0); xfrmstr = (char *) palloc(xfrmlen + 1); @@ -2780,16 +2768,16 @@ convert_timevalue_to_scalar(Datum value, Oid typid) Interval *interval = DatumGetIntervalP(value); /* - * Convert the month part of Interval to days using - * assumed average month length of 365.25/12.0 days. Not - * too accurate, but plenty good enough for our purposes. + * Convert the month part of Interval to days using assumed + * average month length of 365.25/12.0 days. Not too + * accurate, but plenty good enough for our purposes. */ #ifdef HAVE_INT64_TIMESTAMP - return interval->time + interval->day * (double)USECS_PER_DAY + - interval->month * ((DAYS_PER_YEAR / (double)MONTHS_PER_YEAR) * USECS_PER_DAY); + return interval->time + interval->day * (double) USECS_PER_DAY + + interval->month * ((DAYS_PER_YEAR / (double) MONTHS_PER_YEAR) * USECS_PER_DAY); #else return interval->time + interval->day * SECS_PER_DAY + - interval->month * ((DAYS_PER_YEAR / (double)MONTHS_PER_YEAR) * (double)SECS_PER_DAY); + interval->month * ((DAYS_PER_YEAR / (double) MONTHS_PER_YEAR) * (double) SECS_PER_DAY); #endif } case RELTIMEOID: @@ -2827,8 +2815,8 @@ convert_timevalue_to_scalar(Datum value, Oid typid) } /* - * Can't get here unless someone tries to use scalarltsel/scalargtsel - * on an operator with one timevalue and one non-timevalue operand. + * Can't get here unless someone tries to use scalarltsel/scalargtsel on + * an operator with one timevalue and one non-timevalue operand. */ elog(ERROR, "unsupported type: %u", typid); return 0; @@ -2875,8 +2863,8 @@ get_restriction_variable(PlannerInfo *root, List *args, int varRelid, right = (Node *) lsecond(args); /* - * Examine both sides. Note that when varRelid is nonzero, Vars of - * other relations will be treated as pseudoconstants. + * Examine both sides. Note that when varRelid is nonzero, Vars of other + * relations will be treated as pseudoconstants. */ examine_variable(root, left, varRelid, vardata); examine_variable(root, right, varRelid, &rdata); @@ -2995,18 +2983,18 @@ examine_variable(PlannerInfo *root, Node *node, int varRelid, { vardata->statsTuple = SearchSysCache(STATRELATT, ObjectIdGetDatum(relid), - Int16GetDatum(var->varattno), + Int16GetDatum(var->varattno), 0, 0); } else { /* - * XXX This means the Var comes from a JOIN or sub-SELECT. - * Later add code to dig down into the join etc and see if we - * can trace the variable to something with stats. (But - * beware of sub-SELECTs with DISTINCT/GROUP BY/etc. Perhaps - * there are no cases where this would really be useful, - * because we'd have flattened the subselect if it is??) + * XXX This means the Var comes from a JOIN or sub-SELECT. Later + * add code to dig down into the join etc and see if we can trace + * the variable to something with stats. (But beware of + * sub-SELECTs with DISTINCT/GROUP BY/etc. Perhaps there are no + * cases where this would really be useful, because we'd have + * flattened the subselect if it is??) */ } @@ -3031,9 +3019,9 @@ examine_variable(PlannerInfo *root, Node *node, int varRelid, if (varRelid == 0 || bms_is_member(varRelid, varnos)) { onerel = find_base_rel(root, - (varRelid ? varRelid : bms_singleton_member(varnos))); + (varRelid ? varRelid : bms_singleton_member(varnos))); vardata->rel = onerel; - node = basenode; /* strip any relabeling */ + node = basenode; /* strip any relabeling */ } /* else treat it as a constant */ break; @@ -3042,13 +3030,13 @@ examine_variable(PlannerInfo *root, Node *node, int varRelid, { /* treat it as a variable of a join relation */ vardata->rel = find_join_rel(root, varnos); - node = basenode; /* strip any relabeling */ + node = basenode; /* strip any relabeling */ } else if (bms_is_member(varRelid, varnos)) { /* ignore the vars belonging to other relations */ vardata->rel = find_base_rel(root, varRelid); - node = basenode; /* strip any relabeling */ + node = basenode; /* strip any relabeling */ /* note: no point in expressional-index search here */ } /* else treat it as a constant */ @@ -3064,13 +3052,13 @@ examine_variable(PlannerInfo *root, Node *node, int varRelid, if (onerel) { /* - * We have an expression in vars of a single relation. Try to - * match it to expressional index columns, in hopes of finding - * some statistics. + * We have an expression in vars of a single relation. Try to match + * it to expressional index columns, in hopes of finding some + * statistics. * - * XXX it's conceivable that there are multiple matches with - * different index opclasses; if so, we need to pick one that - * matches the operator we are estimating for. FIXME later. + * XXX it's conceivable that there are multiple matches with different + * index opclasses; if so, we need to pick one that matches the + * operator we are estimating for. FIXME later. */ ListCell *ilist; @@ -3105,8 +3093,8 @@ examine_variable(PlannerInfo *root, Node *node, int varRelid, if (equal(node, indexkey)) { /* - * Found a match ... is it a unique index? Tests - * here should match has_unique_index(). + * Found a match ... is it a unique index? Tests here + * should match has_unique_index(). */ if (index->unique && index->ncolumns == 1 && @@ -3114,8 +3102,8 @@ examine_variable(PlannerInfo *root, Node *node, int varRelid, vardata->isunique = true; /* Has it got stats? */ vardata->statsTuple = SearchSysCache(STATRELATT, - ObjectIdGetDatum(index->indexoid), - Int16GetDatum(pos + 1), + ObjectIdGetDatum(index->indexoid), + Int16GetDatum(pos + 1), 0, 0); if (vardata->statsTuple) break; @@ -3145,9 +3133,9 @@ get_variable_numdistinct(VariableStatData *vardata) double ntuples; /* - * Determine the stadistinct value to use. There are cases where we - * can get an estimate even without a pg_statistic entry, or can get a - * better value than is in pg_statistic. + * Determine the stadistinct value to use. There are cases where we can + * get an estimate even without a pg_statistic entry, or can get a better + * value than is in pg_statistic. */ if (HeapTupleIsValid(vardata->statsTuple)) { @@ -3162,16 +3150,15 @@ get_variable_numdistinct(VariableStatData *vardata) /* * Special-case boolean columns: presumably, two distinct values. * - * Are there any other datatypes we should wire in special estimates - * for? + * Are there any other datatypes we should wire in special estimates for? */ stadistinct = 2.0; } else { /* - * We don't keep statistics for system columns, but in some cases - * we can infer distinctness anyway. + * We don't keep statistics for system columns, but in some cases we + * can infer distinctness anyway. */ if (vardata->var && IsA(vardata->var, Var)) { @@ -3199,8 +3186,8 @@ get_variable_numdistinct(VariableStatData *vardata) /* * If there is a unique index for the variable, assume it is unique no - * matter what pg_statistic says (the statistics could be out of - * date). Can skip search if we already think it's unique. + * matter what pg_statistic says (the statistics could be out of date). + * Can skip search if we already think it's unique. */ if (stadistinct != -1.0) { @@ -3235,8 +3222,8 @@ get_variable_numdistinct(VariableStatData *vardata) return floor((-stadistinct * ntuples) + 0.5); /* - * With no data, estimate ndistinct = ntuples if the table is small, - * else use default. + * With no data, estimate ndistinct = ntuples if the table is small, else + * use default. */ if (ntuples < DEFAULT_NUM_DISTINCT) return ntuples; @@ -3276,12 +3263,10 @@ get_variable_maximum(PlannerInfo *root, VariableStatData *vardata, get_typlenbyval(vardata->atttype, &typLen, &typByVal); /* - * If there is a histogram, grab the last or first value as - * appropriate. + * If there is a histogram, grab the last or first value as appropriate. * - * If there is a histogram that is sorted with some other operator than - * the one we want, fail --- this suggests that there is data we can't - * use. + * If there is a histogram that is sorted with some other operator than the + * one we want, fail --- this suggests that there is data we can't use. */ if (get_attstatsslot(vardata->statsTuple, vardata->atttype, vardata->atttypmod, @@ -3327,9 +3312,9 @@ get_variable_maximum(PlannerInfo *root, VariableStatData *vardata, /* * If we have most-common-values info, look for a large MCV. This is - * needed even if we also have a histogram, since the histogram - * excludes the MCVs. However, usually the MCVs will not be the - * extreme values, so avoid unnecessary data copying. + * needed even if we also have a histogram, since the histogram excludes + * the MCVs. However, usually the MCVs will not be the extreme values, so + * avoid unnecessary data copying. */ if (get_attstatsslot(vardata->statsTuple, vardata->atttype, vardata->atttypmod, @@ -3411,7 +3396,7 @@ like_fixed_prefix(Const *patt_const, bool case_insensitive, if (typeid == BYTEAOID && case_insensitive) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("case insensitive matching not supported on type bytea"))); + errmsg("case insensitive matching not supported on type bytea"))); if (typeid != BYTEAOID) { @@ -3453,16 +3438,16 @@ like_fixed_prefix(Const *patt_const, bool case_insensitive, } /* - * XXX I suspect isalpha() is not an adequately locale-sensitive - * test for characters that can vary under case folding? + * XXX I suspect isalpha() is not an adequately locale-sensitive test + * for characters that can vary under case folding? */ if (case_insensitive && isalpha((unsigned char) patt[pos])) break; /* * NOTE: this code used to think that %% meant a literal %, but - * textlike() itself does not think that, and the SQL92 spec - * doesn't say any such thing either. + * textlike() itself does not think that, and the SQL92 spec doesn't + * say any such thing either. */ match[match_pos++] = patt[pos]; } @@ -3487,8 +3472,7 @@ like_fixed_prefix(Const *patt_const, bool case_insensitive, /* in LIKE, an empty pattern is an exact match! */ if (pos == pattlen) - return Pattern_Prefix_Exact; /* reached end of pattern, so - * exact */ + return Pattern_Prefix_Exact; /* reached end of pattern, so exact */ if (match_pos > 0) return Pattern_Prefix_Partial; @@ -3511,14 +3495,14 @@ regex_fixed_prefix(Const *patt_const, bool case_insensitive, Oid typeid = patt_const->consttype; /* - * Should be unnecessary, there are no bytea regex operators defined. - * As such, it should be noted that the rest of this function has *not* - * been made safe for binary (possibly NULL containing) strings. + * Should be unnecessary, there are no bytea regex operators defined. As + * such, it should be noted that the rest of this function has *not* been + * made safe for binary (possibly NULL containing) strings. */ if (typeid == BYTEAOID) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("regular-expression matching not supported on type bytea"))); + errmsg("regular-expression matching not supported on type bytea"))); /* the right-hand const is type text for all of these */ patt = DatumGetCString(DirectFunctionCall1(textout, patt_const->constvalue)); @@ -3535,8 +3519,8 @@ regex_fixed_prefix(Const *patt_const, bool case_insensitive, } /* - * If unquoted | is present at paren level 0 in pattern, then there - * are multiple alternatives for the start of the string. + * If unquoted | is present at paren level 0 in pattern, then there are + * multiple alternatives for the start of the string. */ paren_depth = 0; for (pos = 1; patt[pos]; pos++) @@ -3568,15 +3552,14 @@ regex_fixed_prefix(Const *patt_const, bool case_insensitive, prev_match_pos = match_pos = 0; /* note start at pos 1 to skip leading ^ */ - for (prev_pos = pos = 1; patt[pos]; ) + for (prev_pos = pos = 1; patt[pos];) { - int len; + int len; /* - * Check for characters that indicate multiple possible matches - * here. XXX I suspect isalpha() is not an adequately - * locale-sensitive test for characters that can vary under case - * folding? + * Check for characters that indicate multiple possible matches here. + * XXX I suspect isalpha() is not an adequately locale-sensitive test + * for characters that can vary under case folding? */ if (patt[pos] == '.' || patt[pos] == '(' || @@ -3586,8 +3569,8 @@ regex_fixed_prefix(Const *patt_const, bool case_insensitive, break; /* - * In AREs, backslash followed by alphanumeric is an escape, not - * a quoted character. Must treat it as having multiple possible + * In AREs, backslash followed by alphanumeric is an escape, not a + * quoted character. Must treat it as having multiple possible * matches. */ if (patt[pos] == '\\' && isalnum((unsigned char) patt[pos + 1])) @@ -3595,8 +3578,7 @@ regex_fixed_prefix(Const *patt_const, bool case_insensitive, /* * Check for quantifiers. Except for +, this means the preceding - * character is optional, so we must remove it from the prefix - * too! + * character is optional, so we must remove it from the prefix too! */ if (patt[pos] == '*' || patt[pos] == '?' || @@ -3716,8 +3698,8 @@ prefix_selectivity(PlannerInfo *root, Node *variable, /* Assume scalargtsel is appropriate for all supported types */ prefixsel = DatumGetFloat8(DirectFunctionCall4(scalargtsel, PointerGetDatum(root), - ObjectIdGetDatum(cmpopr), - PointerGetDatum(cmpargs), + ObjectIdGetDatum(cmpopr), + PointerGetDatum(cmpargs), Int32GetDatum(0))); /*------- @@ -3738,13 +3720,13 @@ prefix_selectivity(PlannerInfo *root, Node *variable, /* Assume scalarltsel is appropriate for all supported types */ topsel = DatumGetFloat8(DirectFunctionCall4(scalarltsel, PointerGetDatum(root), - ObjectIdGetDatum(cmpopr), - PointerGetDatum(cmpargs), + ObjectIdGetDatum(cmpopr), + PointerGetDatum(cmpargs), Int32GetDatum(0))); /* - * Merge the two selectivities in the same way as for a range - * query (see clauselist_selectivity()). + * Merge the two selectivities in the same way as for a range query + * (see clauselist_selectivity()). */ prefixsel = topsel + prefixsel - 1.0; @@ -3752,21 +3734,20 @@ prefix_selectivity(PlannerInfo *root, Node *variable, prefixsel += nulltestsel(root, IS_NULL, variable, 0); /* - * A zero or slightly negative prefixsel should be converted into - * a small positive value; we probably are dealing with a very - * tight range and got a bogus result due to roundoff errors. - * However, if prefixsel is very negative, then we probably have - * default selectivity estimates on one or both sides of the - * range. In that case, insert a not-so-wildly-optimistic default - * estimate. + * A zero or slightly negative prefixsel should be converted into a + * small positive value; we probably are dealing with a very tight + * range and got a bogus result due to roundoff errors. However, if + * prefixsel is very negative, then we probably have default + * selectivity estimates on one or both sides of the range. In that + * case, insert a not-so-wildly-optimistic default estimate. */ if (prefixsel <= 0.0) { if (prefixsel < -0.01) { /* - * No data available --- use a default estimate that is - * small, but not real small. + * No data available --- use a default estimate that is small, + * but not real small. */ prefixsel = 0.005; } @@ -3795,8 +3776,7 @@ prefix_selectivity(PlannerInfo *root, Node *variable, #define FIXED_CHAR_SEL 0.20 /* about 1/5 */ #define CHAR_RANGE_SEL 0.25 -#define ANY_CHAR_SEL 0.9 /* not 1, since it won't match - * end-of-string */ +#define ANY_CHAR_SEL 0.9 /* not 1, since it won't match end-of-string */ #define FULL_WILDCARD_SEL 5.0 #define PARTIAL_WILDCARD_SEL 2.0 @@ -3816,7 +3796,7 @@ like_selectivity(Const *patt_const, bool case_insensitive) if (typeid == BYTEAOID && case_insensitive) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("case insensitive matching not supported on type bytea"))); + errmsg("case insensitive matching not supported on type bytea"))); if (typeid != BYTEAOID) { @@ -3895,8 +3875,8 @@ regex_selectivity_sub(char *patt, int pattlen, bool case_insensitive) else if (patt[pos] == '|' && paren_depth == 0) { /* - * If unquoted | is present at paren level 0 in pattern, we - * have multiple alternatives; sum their probabilities. + * If unquoted | is present at paren level 0 in pattern, we have + * multiple alternatives; sum their probabilities. */ sel += regex_selectivity_sub(patt + (pos + 1), pattlen - (pos + 1), @@ -3970,14 +3950,14 @@ regex_selectivity(Const *patt_const, bool case_insensitive) Oid typeid = patt_const->consttype; /* - * Should be unnecessary, there are no bytea regex operators defined. - * As such, it should be noted that the rest of this function has *not* - * been made safe for binary (possibly NULL containing) strings. + * Should be unnecessary, there are no bytea regex operators defined. As + * such, it should be noted that the rest of this function has *not* been + * made safe for binary (possibly NULL containing) strings. */ if (typeid == BYTEAOID) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("regular-expression matching not supported on type bytea"))); + errmsg("regular-expression matching not supported on type bytea"))); /* the right-hand const is type text for all of these */ patt = DatumGetCString(DirectFunctionCall1(textout, patt_const->constvalue)); @@ -4062,7 +4042,7 @@ make_greater_string(const Const *str_const) if (datatype == NAMEOID) { workstr = DatumGetCString(DirectFunctionCall1(nameout, - str_const->constvalue)); + str_const->constvalue)); len = strlen(workstr); } else if (datatype == BYTEAOID) @@ -4084,7 +4064,7 @@ make_greater_string(const Const *str_const) else { workstr = DatumGetCString(DirectFunctionCall1(textout, - str_const->constvalue)); + str_const->constvalue)); len = strlen(workstr); } @@ -4120,8 +4100,8 @@ make_greater_string(const Const *str_const) *lastchar = savelastchar; /* - * Truncate off the last character, which might be more than 1 - * byte, depending on the character encoding. + * Truncate off the last character, which might be more than 1 byte, + * depending on the character encoding. */ if (datatype != BYTEAOID && pg_database_encoding_max_length() > 1) len = pg_mbcliplen(workstr, len, len - 1); @@ -4221,27 +4201,27 @@ genericcostestimate(PlannerInfo *root, List *selectivityQuals; /* - * If the index is partial, AND the index predicate with the - * explicitly given indexquals to produce a more accurate idea of the - * index selectivity. This may produce redundant clauses. We get rid - * of exact duplicates in the code below. We expect that most cases - * of partial redundancy (such as "x < 4" from the qual and "x < 5" - * from the predicate) will be recognized and handled correctly by - * clauselist_selectivity(). This assumption is somewhat fragile, - * since it depends on predicate_implied_by() and clauselist_selectivity() + * If the index is partial, AND the index predicate with the explicitly + * given indexquals to produce a more accurate idea of the index + * selectivity. This may produce redundant clauses. We get rid of exact + * duplicates in the code below. We expect that most cases of partial + * redundancy (such as "x < 4" from the qual and "x < 5" from the + * predicate) will be recognized and handled correctly by + * clauselist_selectivity(). This assumption is somewhat fragile, since + * it depends on predicate_implied_by() and clauselist_selectivity() * having similar capabilities, and there are certainly many cases where - * we will end up with a too-low selectivity estimate. This will bias the + * we will end up with a too-low selectivity estimate. This will bias the * system in favor of using partial indexes where possible, which is not * necessarily a bad thing. But it'd be nice to do better someday. * - * Note that index->indpred and indexQuals are both in implicit-AND form, - * so ANDing them together just takes merging the lists. However, - * eliminating duplicates is a bit trickier because indexQuals - * contains RestrictInfo nodes and the indpred does not. It is okay - * to pass a mixed list to clauselist_selectivity, but we have to work - * a bit to generate a list without logical duplicates. (We could - * just list_union indpred and strippedQuals, but then we'd not get - * caching of per-qual selectivity estimates.) + * Note that index->indpred and indexQuals are both in implicit-AND form, so + * ANDing them together just takes merging the lists. However, + * eliminating duplicates is a bit trickier because indexQuals contains + * RestrictInfo nodes and the indpred does not. It is okay to pass a + * mixed list to clauselist_selectivity, but we have to work a bit to + * generate a list without logical duplicates. (We could just list_union + * indpred and strippedQuals, but then we'd not get caching of per-qual + * selectivity estimates.) */ if (index->indpred != NIL) { @@ -4269,8 +4249,8 @@ genericcostestimate(PlannerInfo *root, numIndexTuples = *indexSelectivity * index->rel->tuples; /* - * We can bound the number of tuples by the index size in any case. - * Also, always estimate at least one tuple is touched, even when + * We can bound the number of tuples by the index size in any case. Also, + * always estimate at least one tuple is touched, even when * indexSelectivity estimate is tiny. */ if (numIndexTuples > index->tuples) @@ -4281,9 +4261,9 @@ genericcostestimate(PlannerInfo *root, /* * Estimate the number of index pages that will be retrieved. * - * For all currently-supported index types, the first page of the index - * is a metadata page, and we should figure on fetching that plus a - * pro-rated fraction of the remaining pages. + * For all currently-supported index types, the first page of the index is a + * metadata page, and we should figure on fetching that plus a pro-rated + * fraction of the remaining pages. */ if (index->pages > 1 && index->tuples > 0) { @@ -4304,15 +4284,15 @@ genericcostestimate(PlannerInfo *root, /* * CPU cost: any complex expressions in the indexquals will need to be - * evaluated once at the start of the scan to reduce them to runtime - * keys to pass to the index AM (see nodeIndexscan.c). We model the - * per-tuple CPU costs as cpu_index_tuple_cost plus one - * cpu_operator_cost per indexqual operator. + * evaluated once at the start of the scan to reduce them to runtime keys + * to pass to the index AM (see nodeIndexscan.c). We model the per-tuple + * CPU costs as cpu_index_tuple_cost plus one cpu_operator_cost per + * indexqual operator. * - * Note: this neglects the possible costs of rechecking lossy operators - * and OR-clause expressions. Detecting that that might be needed - * seems more expensive than it's worth, though, considering all the - * other inaccuracies here ... + * Note: this neglects the possible costs of rechecking lossy operators and + * OR-clause expressions. Detecting that that might be needed seems more + * expensive than it's worth, though, considering all the other + * inaccuracies here ... */ cost_qual_eval(&index_qual_cost, indexQuals); qual_op_cost = cpu_operator_cost * list_length(indexQuals); @@ -4351,15 +4331,14 @@ btcostestimate(PG_FUNCTION_ARGS) ListCell *l; /* - * For a btree scan, only leading '=' quals plus inequality quals - * for the immediately next attribute contribute to index selectivity - * (these are the "boundary quals" that determine the starting and - * stopping points of the index scan). Additional quals can suppress - * visits to the heap, so it's OK to count them in indexSelectivity, - * but they should not count for estimating numIndexTuples. So we must - * examine the given indexQuals to find out which ones count as boundary - * quals. We rely on the knowledge that they are given in index column - * order. + * For a btree scan, only leading '=' quals plus inequality quals for the + * immediately next attribute contribute to index selectivity (these are + * the "boundary quals" that determine the starting and stopping points of + * the index scan). Additional quals can suppress visits to the heap, so + * it's OK to count them in indexSelectivity, but they should not count + * for estimating numIndexTuples. So we must examine the given indexQuals + * to find out which ones count as boundary quals. We rely on the + * knowledge that they are given in index column order. */ indexBoundQuals = NIL; indexcol = 0; @@ -4367,9 +4346,9 @@ btcostestimate(PG_FUNCTION_ARGS) foreach(l, indexQuals) { RestrictInfo *rinfo = (RestrictInfo *) lfirst(l); - Expr *clause; - Oid clause_op; - int op_strategy; + Expr *clause; + Oid clause_op; + int op_strategy; Assert(IsA(rinfo, RestrictInfo)); clause = rinfo->clause; @@ -4409,15 +4388,15 @@ btcostestimate(PG_FUNCTION_ARGS) } op_strategy = get_op_opclass_strategy(clause_op, index->classlist[indexcol]); - Assert(op_strategy != 0); /* not a member of opclass?? */ + Assert(op_strategy != 0); /* not a member of opclass?? */ if (op_strategy == BTEqualStrategyNumber) eqQualHere = true; indexBoundQuals = lappend(indexBoundQuals, rinfo); } /* - * If index is unique and we found an '=' clause for each column, - * we can just assume numIndexTuples = 1 and skip the expensive + * If index is unique and we found an '=' clause for each column, we can + * just assume numIndexTuples = 1 and skip the expensive * clauselist_selectivity calculations. */ if (index->unique && indexcol == index->ncolumns - 1 && eqQualHere) @@ -4437,13 +4416,12 @@ btcostestimate(PG_FUNCTION_ARGS) indexSelectivity, indexCorrelation); /* - * If we can get an estimate of the first column's ordering - * correlation C from pg_statistic, estimate the index correlation as - * C for a single-column index, or C * 0.75 for multiple columns. - * (The idea here is that multiple columns dilute the importance of - * the first column's ordering, but don't negate it entirely. Before - * 8.0 we divided the correlation by the number of columns, but that - * seems too strong.) + * If we can get an estimate of the first column's ordering correlation C + * from pg_statistic, estimate the index correlation as C for a + * single-column index, or C * 0.75 for multiple columns. (The idea here + * is that multiple columns dilute the importance of the first column's + * ordering, but don't negate it entirely. Before 8.0 we divided the + * correlation by the number of columns, but that seems too strong.) */ if (index->indexkeys[0] != 0) { diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c index 73e7bb8ea8..d3090413c4 100644 --- a/src/backend/utils/adt/timestamp.c +++ b/src/backend/utils/adt/timestamp.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.154 2005/10/09 17:21:46 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.155 2005/10/15 02:49:30 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -116,7 +116,7 @@ timestamp_in(PG_FUNCTION_ARGS) case DTK_INVALID: ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("date/time value \"%s\" is no longer supported", str))); + errmsg("date/time value \"%s\" is no longer supported", str))); TIMESTAMP_NOEND(result); break; @@ -138,7 +138,7 @@ timestamp_in(PG_FUNCTION_ARGS) Datum timestamp_out(PG_FUNCTION_ARGS) { - Timestamp timestamp = PG_GETARG_TIMESTAMP(0); + Timestamp timestamp = PG_GETARG_TIMESTAMP(0); char *result; struct pg_tm tt, *tm = &tt; @@ -169,11 +169,12 @@ Datum timestamp_recv(PG_FUNCTION_ARGS) { StringInfo buf = (StringInfo) PG_GETARG_POINTER(0); + #ifdef NOT_USED Oid typelem = PG_GETARG_OID(1); #endif int32 typmod = PG_GETARG_INT32(2); - Timestamp timestamp; + Timestamp timestamp; struct pg_tm tt, *tm = &tt; fsec_t fsec; @@ -203,7 +204,7 @@ timestamp_recv(PG_FUNCTION_ARGS) Datum timestamp_send(PG_FUNCTION_ARGS) { - Timestamp timestamp = PG_GETARG_TIMESTAMP(0); + Timestamp timestamp = PG_GETARG_TIMESTAMP(0); StringInfoData buf; pq_begintypsend(&buf); @@ -223,7 +224,7 @@ timestamp_send(PG_FUNCTION_ARGS) Datum timestamp_scale(PG_FUNCTION_ARGS) { - Timestamp timestamp = PG_GETARG_TIMESTAMP(0); + Timestamp timestamp = PG_GETARG_TIMESTAMP(0); int32 typmod = PG_GETARG_INT32(1); Timestamp result; @@ -257,7 +258,6 @@ AdjustTimestampForTypmod(Timestamp *time, int32 typmod) INT64CONST(5), INT64CONST(0) }; - #else static const double TimestampScales[MAX_TIMESTAMP_PRECISION + 1] = { 1, @@ -276,21 +276,21 @@ AdjustTimestampForTypmod(Timestamp *time, int32 typmod) if (typmod < 0 || typmod > MAX_TIMESTAMP_PRECISION) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("timestamp(%d) precision must be between %d and %d", - typmod, 0, MAX_TIMESTAMP_PRECISION))); + errmsg("timestamp(%d) precision must be between %d and %d", + typmod, 0, MAX_TIMESTAMP_PRECISION))); /* - * Note: this round-to-nearest code is not completely consistent - * about rounding values that are exactly halfway between integral - * values. On most platforms, rint() will implement - * round-to-nearest-even, but the integer code always rounds up - * (away from zero). Is it worth trying to be consistent? + * Note: this round-to-nearest code is not completely consistent about + * rounding values that are exactly halfway between integral values. + * On most platforms, rint() will implement round-to-nearest-even, but + * the integer code always rounds up (away from zero). Is it worth + * trying to be consistent? */ #ifdef HAVE_INT64_TIMESTAMP if (*time >= INT64CONST(0)) { *time = ((*time + TimestampOffsets[typmod]) / TimestampScales[typmod]) * - TimestampScales[typmod]; + TimestampScales[typmod]; } else { @@ -298,7 +298,7 @@ AdjustTimestampForTypmod(Timestamp *time, int32 typmod) * TimestampScales[typmod]); } #else - *time = rint((double)*time * TimestampScales[typmod]) / TimestampScales[typmod]; + *time = rint((double) *time * TimestampScales[typmod]) / TimestampScales[typmod]; #endif } } @@ -359,7 +359,7 @@ timestamptz_in(PG_FUNCTION_ARGS) case DTK_INVALID: ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("date/time value \"%s\" is no longer supported", str))); + errmsg("date/time value \"%s\" is no longer supported", str))); TIMESTAMP_NOEND(result); break; @@ -413,6 +413,7 @@ Datum timestamptz_recv(PG_FUNCTION_ARGS) { StringInfo buf = (StringInfo) PG_GETARG_POINTER(0); + #ifdef NOT_USED Oid typelem = PG_GETARG_OID(1); #endif @@ -540,7 +541,7 @@ interval_in(PG_FUNCTION_ARGS) case DTK_INVALID: ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("date/time value \"%s\" is no longer supported", str))); + errmsg("date/time value \"%s\" is no longer supported", str))); break; default: @@ -583,6 +584,7 @@ Datum interval_recv(PG_FUNCTION_ARGS) { StringInfo buf = (StringInfo) PG_GETARG_POINTER(0); + #ifdef NOT_USED Oid typelem = PG_GETARG_OID(1); #endif @@ -643,6 +645,7 @@ interval_scale(PG_FUNCTION_ARGS) PG_RETURN_INTERVAL_P(result); } + /* * Adjust interval for specified precision, in both YEAR to SECOND * range and sub-second precision. @@ -670,7 +673,6 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod) INT64CONST(5), INT64CONST(0) }; - #else static const double IntervalScales[MAX_INTERVAL_PRECISION + 1] = { 1, @@ -684,8 +686,8 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod) #endif /* - * Unspecified range and precision? Then not necessary to adjust. - * Setting typmod to -1 is the convention for all types. + * Unspecified range and precision? Then not necessary to adjust. Setting + * typmod to -1 is the convention for all types. */ if (typmod != -1) { @@ -727,9 +729,9 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod) #ifdef HAVE_INT64_TIMESTAMP interval->time = (interval->time / USECS_PER_HOUR) * - USECS_PER_HOUR; + USECS_PER_HOUR; #else - interval->time = ((int)(interval->time / SECS_PER_HOUR)) * (double)SECS_PER_HOUR; + interval->time = ((int) (interval->time / SECS_PER_HOUR)) * (double) SECS_PER_HOUR; #endif } else if (range == INTERVAL_MASK(MINUTE)) @@ -747,10 +749,10 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod) hour = interval->time / USECS_PER_HOUR; interval->time -= hour * USECS_PER_HOUR; interval->time = (interval->time / USECS_PER_MINUTE) * - USECS_PER_MINUTE; + USECS_PER_MINUTE; #else - TMODULO(interval->time, hour, (double)SECS_PER_HOUR); - interval->time = ((int)(interval->time / SECS_PER_MINUTE)) * (double)SECS_PER_MINUTE; + TMODULO(interval->time, hour, (double) SECS_PER_HOUR); + interval->time = ((int) (interval->time / SECS_PER_MINUTE)) * (double) SECS_PER_MINUTE; #endif } else if (range == INTERVAL_MASK(SECOND)) @@ -768,7 +770,7 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod) minute = interval->time / USECS_PER_MINUTE; interval->time -= minute * USECS_PER_MINUTE; #else - TMODULO(interval->time, minute, (double)SECS_PER_MINUTE); + TMODULO(interval->time, minute, (double) SECS_PER_MINUTE); /* return subseconds too */ #endif } @@ -780,9 +782,9 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod) #ifdef HAVE_INT64_TIMESTAMP interval->time = (interval->time / USECS_PER_HOUR) * - USECS_PER_HOUR; + USECS_PER_HOUR; #else - interval->time = ((int) (interval->time / SECS_PER_HOUR)) * (double)SECS_PER_HOUR; + interval->time = ((int) (interval->time / SECS_PER_HOUR)) * (double) SECS_PER_HOUR; #endif } /* DAY TO MINUTE */ @@ -794,9 +796,9 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod) #ifdef HAVE_INT64_TIMESTAMP interval->time = (interval->time / USECS_PER_MINUTE) * - USECS_PER_MINUTE; + USECS_PER_MINUTE; #else - interval->time = ((int)(interval->time / SECS_PER_MINUTE)) * (double)SECS_PER_MINUTE; + interval->time = ((int) (interval->time / SECS_PER_MINUTE)) * (double) SECS_PER_MINUTE; #endif } /* DAY TO SECOND */ @@ -815,9 +817,9 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod) #ifdef HAVE_INT64_TIMESTAMP interval->time = (interval->time / USECS_PER_MINUTE) * - USECS_PER_MINUTE; + USECS_PER_MINUTE; #else - interval->time = ((int)(interval->time / SECS_PER_MINUTE)) * (double)SECS_PER_MINUTE; + interval->time = ((int) (interval->time / SECS_PER_MINUTE)) * (double) SECS_PER_MINUTE; #endif } /* HOUR TO SECOND */ @@ -835,7 +837,6 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod) { #ifdef HAVE_INT64_TIMESTAMP int64 hour; - #else double hour; #endif @@ -847,7 +848,7 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod) hour = interval->time / USECS_PER_HOUR; interval->time -= hour * USECS_PER_HOUR; #else - TMODULO(interval->time, hour, (double)SECS_PER_HOUR); + TMODULO(interval->time, hour, (double) SECS_PER_HOUR); #endif } else @@ -859,36 +860,35 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod) if (precision < 0 || precision > MAX_INTERVAL_PRECISION) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("interval(%d) precision must be between %d and %d", - precision, 0, MAX_INTERVAL_PRECISION))); + errmsg("interval(%d) precision must be between %d and %d", + precision, 0, MAX_INTERVAL_PRECISION))); /* - * Note: this round-to-nearest code is not completely - * consistent about rounding values that are exactly halfway - * between integral values. On most platforms, rint() will - * implement round-to-nearest-even, but the integer code - * always rounds up (away from zero). Is it worth trying to - * be consistent? + * Note: this round-to-nearest code is not completely consistent + * about rounding values that are exactly halfway between integral + * values. On most platforms, rint() will implement + * round-to-nearest-even, but the integer code always rounds up + * (away from zero). Is it worth trying to be consistent? */ #ifdef HAVE_INT64_TIMESTAMP if (interval->time >= INT64CONST(0)) { interval->time = ((interval->time + - IntervalOffsets[precision]) / - IntervalScales[precision]) * - IntervalScales[precision]; + IntervalOffsets[precision]) / + IntervalScales[precision]) * + IntervalScales[precision]; } else { interval->time = -(((-interval->time + - IntervalOffsets[precision]) / + IntervalOffsets[precision]) / IntervalScales[precision]) * - IntervalScales[precision]); + IntervalScales[precision]); } #else interval->time = rint(((double) interval->time) * - IntervalScales[precision]) / - IntervalScales[precision]; + IntervalScales[precision]) / + IntervalScales[precision]; #endif } } @@ -1016,16 +1016,16 @@ dt2time(Timestamp jd, int *hour, int *min, int *sec, fsec_t *fsec) * timezone) will be used. */ int -timestamp2tm(Timestamp dt, int *tzp, struct pg_tm *tm, fsec_t *fsec, char **tzn, pg_tz *attimezone) +timestamp2tm(Timestamp dt, int *tzp, struct pg_tm * tm, fsec_t *fsec, char **tzn, pg_tz *attimezone) { - Timestamp date; + Timestamp date; Timestamp time; pg_time_t utime; /* - * If HasCTZSet is true then we have a brute force time zone - * specified. Go ahead and rotate to the local time zone since we will - * later bypass any calls which adjust the tm fields. + * If HasCTZSet is true then we have a brute force time zone specified. Go + * ahead and rotate to the local time zone since we will later bypass any + * calls which adjust the tm fields. */ if (attimezone == NULL && HasCTZSet && tzp != NULL) { @@ -1057,7 +1057,7 @@ timestamp2tm(Timestamp dt, int *tzp, struct pg_tm *tm, fsec_t *fsec, char **tzn, dt2time(time, &tm->tm_hour, &tm->tm_min, &tm->tm_sec, fsec); #else time = dt; - TMODULO(time, date, (double)SECS_PER_DAY); + TMODULO(time, date, (double) SECS_PER_DAY); if (time < 0) { @@ -1082,7 +1082,7 @@ recalc_t: if (*fsec >= 1.0) { time = ceil(time); - if (time >= (double)SECS_PER_DAY) + if (time >= (double) SECS_PER_DAY) { time = 0; date += 1; @@ -1104,8 +1104,8 @@ recalc_t: } /* - * We have a brute force time zone per SQL99? Then use it without - * change since we have already rotated to the time zone. + * We have a brute force time zone per SQL99? Then use it without change + * since we have already rotated to the time zone. */ if (attimezone == NULL && HasCTZSet) { @@ -1119,14 +1119,14 @@ recalc_t: } /* - * If the time falls within the range of pg_time_t, use pg_localtime() - * to rotate to the local time zone. + * If the time falls within the range of pg_time_t, use pg_localtime() to + * rotate to the local time zone. * * First, convert to an integral timestamp, avoiding possibly * platform-specific roundoff-in-wrong-direction errors, and adjust to - * Unix epoch. Then see if we can convert to pg_time_t without loss. - * This coding avoids hardwiring any assumptions about the width of - * pg_time_t, so it should behave sanely on machines without int64. + * Unix epoch. Then see if we can convert to pg_time_t without loss. This + * coding avoids hardwiring any assumptions about the width of pg_time_t, + * so it should behave sanely on machines without int64. */ #ifdef HAVE_INT64_TIMESTAMP dt = (dt - *fsec) / USECS_PER_SEC + @@ -1139,7 +1139,7 @@ recalc_t: if ((Timestamp) utime == dt) { struct pg_tm *tx = pg_localtime(&utime, - attimezone ? attimezone : global_timezone); + attimezone ? attimezone : global_timezone); tm->tm_year = tx->tm_year + 1900; tm->tm_mon = tx->tm_mon + 1; @@ -1180,13 +1180,13 @@ recalc_t: * Returns -1 on failure (value out of range). */ int -tm2timestamp(struct pg_tm *tm, fsec_t fsec, int *tzp, Timestamp *result) +tm2timestamp(struct pg_tm * tm, fsec_t fsec, int *tzp, Timestamp *result) { #ifdef HAVE_INT64_TIMESTAMP - int date; + int date; int64 time; #else - double date, + double date, time; #endif @@ -1220,7 +1220,7 @@ tm2timestamp(struct pg_tm *tm, fsec_t fsec, int *tzp, Timestamp *result) * Convert a interval data type to a tm structure. */ int -interval2tm(Interval span, struct pg_tm *tm, fsec_t *fsec) +interval2tm(Interval span, struct pg_tm * tm, fsec_t *fsec) { #ifdef HAVE_INT64_TIMESTAMP int64 time; @@ -1242,8 +1242,8 @@ interval2tm(Interval span, struct pg_tm *tm, fsec_t *fsec) *fsec = time - (tm->tm_sec * USECS_PER_SEC); #else recalc: - TMODULO(time, tm->tm_hour, (double)SECS_PER_HOUR); - TMODULO(time, tm->tm_min, (double)SECS_PER_MINUTE); + TMODULO(time, tm->tm_hour, (double) SECS_PER_HOUR); + TMODULO(time, tm->tm_min, (double) SECS_PER_MINUTE); TMODULO(time, tm->tm_sec, 1.0); time = TSROUND(time); /* roundoff may need to propagate to higher-order fields */ @@ -1259,18 +1259,18 @@ recalc: } int -tm2interval(struct pg_tm *tm, fsec_t fsec, Interval *span) +tm2interval(struct pg_tm * tm, fsec_t fsec, Interval *span) { span->month = tm->tm_year * MONTHS_PER_YEAR + tm->tm_mon; - span->day = tm->tm_mday; + span->day = tm->tm_mday; #ifdef HAVE_INT64_TIMESTAMP span->time = (((((tm->tm_hour * INT64CONST(60)) + - tm->tm_min) * INT64CONST(60)) + - tm->tm_sec) * USECS_PER_SEC) + fsec; + tm->tm_min) * INT64CONST(60)) + + tm->tm_sec) * USECS_PER_SEC) + fsec; #else - span->time = (((tm->tm_hour * (double)MINS_PER_HOUR) + - tm->tm_min) * (double)SECS_PER_MINUTE) + - tm->tm_sec + fsec; + span->time = (((tm->tm_hour * (double) MINS_PER_HOUR) + + tm->tm_min) * (double) SECS_PER_MINUTE) + + tm->tm_sec + fsec; #endif return 0; @@ -1282,7 +1282,6 @@ time2t(const int hour, const int min, const int sec, const fsec_t fsec) { return (((((hour * MINS_PER_HOUR) + min) * SECS_PER_MINUTE) + sec) * USECS_PER_SEC) + fsec; } /* time2t() */ - #else static double time2t(const int hour, const int min, const int sec, const fsec_t fsec) @@ -1311,7 +1310,7 @@ dt2local(Timestamp dt, int tz) Datum timestamp_finite(PG_FUNCTION_ARGS) { - Timestamp timestamp = PG_GETARG_TIMESTAMP(0); + Timestamp timestamp = PG_GETARG_TIMESTAMP(0); PG_RETURN_BOOL(!TIMESTAMP_NOT_FINITE(timestamp)); } @@ -1328,7 +1327,7 @@ interval_finite(PG_FUNCTION_ARGS) *---------------------------------------------------------*/ void -GetEpochTime(struct pg_tm *tm) +GetEpochTime(struct pg_tm * tm) { struct pg_tm *t0; pg_time_t epoch = 0; @@ -1379,8 +1378,8 @@ timestamp_cmp_internal(Timestamp dt1, Timestamp dt2) * When using float representation, we have to be wary of NaNs. * * We consider all NANs to be equal and larger than any non-NAN. This is - * somewhat arbitrary; the important thing is to have a consistent - * sort order. + * somewhat arbitrary; the important thing is to have a consistent sort + * order. */ if (isnan(dt1)) { @@ -1667,10 +1666,10 @@ interval_cmp_internal(Interval *interval1, Interval *interval2) span2 += interval2->month * INT64CONST(30) * USECS_PER_DAY; span2 += interval2->day * INT64CONST(24) * USECS_PER_HOUR; #else - span1 += interval1->month * ((double)DAYS_PER_MONTH * SECS_PER_DAY); - span1 += interval1->day * ((double)HOURS_PER_DAY * SECS_PER_HOUR); - span2 += interval2->month * ((double)DAYS_PER_MONTH * SECS_PER_DAY); - span2 += interval2->day * ((double)HOURS_PER_DAY * SECS_PER_HOUR); + span1 += interval1->month * ((double) DAYS_PER_MONTH * SECS_PER_DAY); + span1 += interval1->day * ((double) HOURS_PER_DAY * SECS_PER_HOUR); + span2 += interval2->month * ((double) DAYS_PER_MONTH * SECS_PER_DAY); + span2 += interval2->day * ((double) HOURS_PER_DAY * SECS_PER_HOUR); #endif return ((span1 < span2) ? -1 : (span1 > span2) ? 1 : 0); @@ -1749,11 +1748,11 @@ interval_hash(PG_FUNCTION_ARGS) /* * Specify hash length as sizeof(double) + sizeof(int4), not as - * sizeof(Interval), so that any garbage pad bytes in the structure - * won't be included in the hash! + * sizeof(Interval), so that any garbage pad bytes in the structure won't + * be included in the hash! */ - return hash_any((unsigned char *) key, - sizeof(key->time) + sizeof(key->day) + sizeof(key->month)); + return hash_any((unsigned char *) key, + sizeof(key->time) + sizeof(key->day) + sizeof(key->month)); } /* overlaps_timestamp() --- implements the SQL92 OVERLAPS operator. @@ -1766,9 +1765,9 @@ Datum overlaps_timestamp(PG_FUNCTION_ARGS) { /* - * The arguments are Timestamps, but we leave them as generic Datums - * to avoid unnecessary conversions between value and reference forms - * --- not to mention possible dereferences of null pointers. + * The arguments are Timestamps, but we leave them as generic Datums to + * avoid unnecessary conversions between value and reference forms --- not + * to mention possible dereferences of null pointers. */ Datum ts1 = PG_GETARG_DATUM(0); Datum te1 = PG_GETARG_DATUM(1); @@ -1785,9 +1784,9 @@ overlaps_timestamp(PG_FUNCTION_ARGS) DatumGetBool(DirectFunctionCall2(timestamp_lt,t1,t2)) /* - * If both endpoints of interval 1 are null, the result is null - * (unknown). If just one endpoint is null, take ts1 as the non-null - * one. Otherwise, take ts1 as the lesser endpoint. + * If both endpoints of interval 1 are null, the result is null (unknown). + * If just one endpoint is null, take ts1 as the non-null one. Otherwise, + * take ts1 as the lesser endpoint. */ if (ts1IsNull) { @@ -1835,8 +1834,8 @@ overlaps_timestamp(PG_FUNCTION_ARGS) if (TIMESTAMP_GT(ts1, ts2)) { /* - * This case is ts1 < te2 OR te1 < te2, which may look redundant - * but in the presence of nulls it's not quite completely so. + * This case is ts1 < te2 OR te1 < te2, which may look redundant but + * in the presence of nulls it's not quite completely so. */ if (te2IsNull) PG_RETURN_NULL(); @@ -1846,8 +1845,8 @@ overlaps_timestamp(PG_FUNCTION_ARGS) PG_RETURN_NULL(); /* - * If te1 is not null then we had ts1 <= te1 above, and we just - * found ts1 >= te2, hence te1 >= te2. + * If te1 is not null then we had ts1 <= te1 above, and we just found + * ts1 >= te2, hence te1 >= te2. */ PG_RETURN_BOOL(false); } @@ -1862,8 +1861,8 @@ overlaps_timestamp(PG_FUNCTION_ARGS) PG_RETURN_NULL(); /* - * If te2 is not null then we had ts2 <= te2 above, and we just - * found ts2 >= te1, hence te2 >= te1. + * If te2 is not null then we had ts2 <= te2 above, and we just found + * ts2 >= te1, hence te2 >= te1. */ PG_RETURN_BOOL(false); } @@ -1871,8 +1870,7 @@ overlaps_timestamp(PG_FUNCTION_ARGS) { /* * For ts1 = ts2 the spec says te1 <> te2 OR te1 = te2, which is a - * rather silly way of saying "true if both are nonnull, else - * null". + * rather silly way of saying "true if both are nonnull, else null". */ if (te1IsNull || te2IsNull) PG_RETURN_NULL(); @@ -1938,13 +1936,13 @@ timestamp_mi(PG_FUNCTION_ARGS) result->day = 0; result = DatumGetIntervalP(DirectFunctionCall1(interval_justify_hours, - IntervalPGetDatum(result))); + IntervalPGetDatum(result))); PG_RETURN_INTERVAL_P(result); } /* interval_justify_hours() * Adjust interval so 'time' contains less than a whole day, and - * 'day' contains an integral number of days. This is useful for + * 'day' contains an integral number of days. This is useful for * situations (such as non-TZ) where '1 day' = '24 hours' is valid, * e.g. interval subtraction and division. The SQL standard requires * such conversion in these cases, but not the conversion of days to months. @@ -1952,8 +1950,8 @@ timestamp_mi(PG_FUNCTION_ARGS) Datum interval_justify_hours(PG_FUNCTION_ARGS) { - Interval *span = PG_GETARG_INTERVAL_P(0); - Interval *result; + Interval *span = PG_GETARG_INTERVAL_P(0); + Interval *result; result = (Interval *) palloc(sizeof(Interval)); result->month = span->month; @@ -1963,8 +1961,8 @@ interval_justify_hours(PG_FUNCTION_ARGS) result->time += span->day * USECS_PER_DAY; TMODULO(result->time, result->day, USECS_PER_DAY); #else - result->time += span->day * (double)SECS_PER_DAY; - TMODULO(result->time, result->day, (double)SECS_PER_DAY); + result->time += span->day * (double) SECS_PER_DAY; + TMODULO(result->time, result->day, (double) SECS_PER_DAY); #endif PG_RETURN_INTERVAL_P(result); @@ -1977,8 +1975,8 @@ interval_justify_hours(PG_FUNCTION_ARGS) Datum interval_justify_days(PG_FUNCTION_ARGS) { - Interval *span = PG_GETARG_INTERVAL_P(0); - Interval *result; + Interval *span = PG_GETARG_INTERVAL_P(0); + Interval *result; result = (Interval *) palloc(sizeof(Interval)); result->day = span->day; @@ -2003,7 +2001,7 @@ interval_justify_days(PG_FUNCTION_ARGS) Datum timestamp_pl_interval(PG_FUNCTION_ARGS) { - Timestamp timestamp = PG_GETARG_TIMESTAMP(0); + Timestamp timestamp = PG_GETARG_TIMESTAMP(0); Interval *span = PG_GETARG_INTERVAL_P(1); Timestamp result; @@ -2050,7 +2048,7 @@ timestamp_pl_interval(PG_FUNCTION_ARGS) *tm = &tt; fsec_t fsec; int julian; - + if (timestamp2tm(timestamp, NULL, tm, &fsec, NULL, NULL) != 0) ereport(ERROR, (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE), @@ -2076,7 +2074,7 @@ timestamp_pl_interval(PG_FUNCTION_ARGS) Datum timestamp_mi_interval(PG_FUNCTION_ARGS) { - Timestamp timestamp = PG_GETARG_TIMESTAMP(0); + Timestamp timestamp = PG_GETARG_TIMESTAMP(0); Interval *span = PG_GETARG_INTERVAL_P(1); Interval tspan; @@ -2277,7 +2275,9 @@ interval_mul(PG_FUNCTION_ARGS) { Interval *span = PG_GETARG_INTERVAL_P(0); float8 factor = PG_GETARG_FLOAT8(1); - double month_remainder, day_remainder, month_remainder_days; + double month_remainder, + day_remainder, + month_remainder_days; Interval *result; result = (Interval *) palloc(sizeof(Interval)); @@ -2303,7 +2303,7 @@ interval_mul(PG_FUNCTION_ARGS) #endif result = DatumGetIntervalP(DirectFunctionCall1(interval_justify_hours, - IntervalPGetDatum(result))); + IntervalPGetDatum(result))); PG_RETURN_INTERVAL_P(result); } @@ -2322,7 +2322,9 @@ interval_div(PG_FUNCTION_ARGS) { Interval *span = PG_GETARG_INTERVAL_P(0); float8 factor = PG_GETARG_FLOAT8(1); - double month_remainder, day_remainder, month_remainder_days; + double month_remainder, + day_remainder, + month_remainder_days; Interval *result; result = (Interval *) palloc(sizeof(Interval)); @@ -2354,7 +2356,7 @@ interval_div(PG_FUNCTION_ARGS) #endif result = DatumGetIntervalP(DirectFunctionCall1(interval_justify_hours, - IntervalPGetDatum(result))); + IntervalPGetDatum(result))); PG_RETURN_INTERVAL_P(result); } @@ -2386,10 +2388,10 @@ interval_accum(PG_FUNCTION_ARGS) elog(ERROR, "expected 2-element interval array"); /* - * XXX memcpy, instead of just extracting a pointer, to work around - * buggy array code: it won't ensure proper alignment of Interval - * objects on machines where double requires 8-byte alignment. That - * should be fixed, but in the meantime... + * XXX memcpy, instead of just extracting a pointer, to work around buggy + * array code: it won't ensure proper alignment of Interval objects on + * machines where double requires 8-byte alignment. That should be fixed, + * but in the meantime... * * Note: must use DatumGetPointer here, not DatumGetIntervalP, else some * compilers optimize into double-aligned load/store anyway. @@ -2398,8 +2400,8 @@ interval_accum(PG_FUNCTION_ARGS) memcpy((void *) &N, DatumGetPointer(transdatums[1]), sizeof(Interval)); newsum = DatumGetIntervalP(DirectFunctionCall2(interval_pl, - IntervalPGetDatum(&sumX), - IntervalPGetDatum(newval))); + IntervalPGetDatum(&sumX), + IntervalPGetDatum(newval))); N.time += 1; transdatums[0] = IntervalPGetDatum(newsum); @@ -2427,10 +2429,10 @@ interval_avg(PG_FUNCTION_ARGS) elog(ERROR, "expected 2-element interval array"); /* - * XXX memcpy, instead of just extracting a pointer, to work around - * buggy array code: it won't ensure proper alignment of Interval - * objects on machines where double requires 8-byte alignment. That - * should be fixed, but in the meantime... + * XXX memcpy, instead of just extracting a pointer, to work around buggy + * array code: it won't ensure proper alignment of Interval objects on + * machines where double requires 8-byte alignment. That should be fixed, + * but in the meantime... * * Note: must use DatumGetPointer here, not DatumGetIntervalP, else some * compilers optimize into double-aligned load/store anyway. @@ -2689,7 +2691,7 @@ Datum timestamp_text(PG_FUNCTION_ARGS) { /* Input is a Timestamp, but may as well leave it in Datum form */ - Datum timestamp = PG_GETARG_DATUM(0); + Datum timestamp = PG_GETARG_DATUM(0); text *result; char *str; int len; @@ -2728,7 +2730,7 @@ text_timestamp(PG_FUNCTION_ARGS) (errcode(ERRCODE_INVALID_DATETIME_FORMAT), errmsg("invalid input syntax for type timestamp: \"%s\"", DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(str)))))); + PointerGetDatum(str)))))); sp = VARDATA(str); dp = dstr; @@ -2750,7 +2752,7 @@ Datum timestamptz_text(PG_FUNCTION_ARGS) { /* Input is a Timestamp, but may as well leave it in Datum form */ - Datum timestamp = PG_GETARG_DATUM(0); + Datum timestamp = PG_GETARG_DATUM(0); text *result; char *str; int len; @@ -2788,7 +2790,7 @@ text_timestamptz(PG_FUNCTION_ARGS) (errcode(ERRCODE_INVALID_DATETIME_FORMAT), errmsg("invalid input syntax for type timestamp with time zone: \"%s\"", DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(str)))))); + PointerGetDatum(str)))))); sp = VARDATA(str); dp = dstr; @@ -2815,7 +2817,7 @@ interval_text(PG_FUNCTION_ARGS) int len; str = DatumGetCString(DirectFunctionCall1(interval_out, - IntervalPGetDatum(interval))); + IntervalPGetDatum(interval))); len = strlen(str) + VARHDRSZ; @@ -2849,7 +2851,7 @@ text_interval(PG_FUNCTION_ARGS) (errcode(ERRCODE_INVALID_DATETIME_FORMAT), errmsg("invalid input syntax for type interval: \"%s\"", DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(str)))))); + PointerGetDatum(str)))))); sp = VARDATA(str); dp = dstr; @@ -2870,7 +2872,7 @@ Datum timestamp_trunc(PG_FUNCTION_ARGS) { text *units = PG_GETARG_TEXT_P(0); - Timestamp timestamp = PG_GETARG_TIMESTAMP(1); + Timestamp timestamp = PG_GETARG_TIMESTAMP(1); Timestamp result; int type, val; @@ -2898,26 +2900,27 @@ timestamp_trunc(PG_FUNCTION_ARGS) switch (val) { case DTK_WEEK: - { - int woy; - - woy = date2isoweek(tm->tm_year, tm->tm_mon, tm->tm_mday); - /* - * If it is week 52/53 and the month is January, - * then the week must belong to the previous year. - * Also, some December dates belong to the next year. - */ - if (woy >= 52 && tm->tm_mon == 1) - --tm->tm_year; - if (woy <= 1 && tm->tm_mon == MONTHS_PER_YEAR) - ++tm->tm_year; - isoweek2date(woy, &(tm->tm_year), &(tm->tm_mon), &(tm->tm_mday)); - tm->tm_hour = 0; - tm->tm_min = 0; - tm->tm_sec = 0; - fsec = 0; - break; - } + { + int woy; + + woy = date2isoweek(tm->tm_year, tm->tm_mon, tm->tm_mday); + + /* + * If it is week 52/53 and the month is January, then the + * week must belong to the previous year. Also, some + * December dates belong to the next year. + */ + if (woy >= 52 && tm->tm_mon == 1) + --tm->tm_year; + if (woy <= 1 && tm->tm_mon == MONTHS_PER_YEAR) + ++tm->tm_year; + isoweek2date(woy, &(tm->tm_year), &(tm->tm_mon), &(tm->tm_mday)); + tm->tm_hour = 0; + tm->tm_min = 0; + tm->tm_sec = 0; + fsec = 0; + break; + } case DTK_MILLENNIUM: /* see comments in timestamptz_trunc */ if (tm->tm_year > 0) @@ -3032,34 +3035,35 @@ timestamptz_trunc(PG_FUNCTION_ARGS) switch (val) { case DTK_WEEK: - { - int woy; - - woy = date2isoweek(tm->tm_year, tm->tm_mon, tm->tm_mday); - /* - * If it is week 52/53 and the month is January, - * then the week must belong to the previous year. - * Also, some December dates belong to the next year. - */ - if (woy >= 52 && tm->tm_mon == 1) - --tm->tm_year; - if (woy <= 1 && tm->tm_mon == MONTHS_PER_YEAR) - ++tm->tm_year; - isoweek2date(woy, &(tm->tm_year), &(tm->tm_mon), &(tm->tm_mday)); - tm->tm_hour = 0; - tm->tm_min = 0; - tm->tm_sec = 0; - fsec = 0; - redotz = true; - break; - } + { + int woy; + + woy = date2isoweek(tm->tm_year, tm->tm_mon, tm->tm_mday); + + /* + * If it is week 52/53 and the month is January, then the + * week must belong to the previous year. Also, some + * December dates belong to the next year. + */ + if (woy >= 52 && tm->tm_mon == 1) + --tm->tm_year; + if (woy <= 1 && tm->tm_mon == MONTHS_PER_YEAR) + ++tm->tm_year; + isoweek2date(woy, &(tm->tm_year), &(tm->tm_mon), &(tm->tm_mday)); + tm->tm_hour = 0; + tm->tm_min = 0; + tm->tm_sec = 0; + fsec = 0; + redotz = true; + break; + } /* one may consider DTK_THOUSAND and DTK_HUNDRED... */ case DTK_MILLENNIUM: /* * truncating to the millennium? what is this supposed to - * mean? let us put the first year of the millennium... - * i.e. -1000, 1, 1001, 2001... + * mean? let us put the first year of the millennium... i.e. + * -1000, 1, 1001, 2001... */ if (tm->tm_year > 0) tm->tm_year = ((tm->tm_year + 999) / 1000) * 1000 - 999; @@ -3076,8 +3080,8 @@ timestamptz_trunc(PG_FUNCTION_ARGS) case DTK_DECADE: /* - * truncating to the decade? first year of the decade. - * must not be applied if year was truncated before! + * truncating to the decade? first year of the decade. must + * not be applied if year was truncated before! */ if (val != DTK_MILLENNIUM && val != DTK_CENTURY) { @@ -3126,8 +3130,8 @@ timestamptz_trunc(PG_FUNCTION_ARGS) default: ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("timestamp with time zone units \"%s\" not " - "supported", lowunits))); + errmsg("timestamp with time zone units \"%s\" not " + "supported", lowunits))); result = 0; } @@ -3143,8 +3147,8 @@ timestamptz_trunc(PG_FUNCTION_ARGS) { ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("timestamp with time zone units \"%s\" not recognized", - lowunits))); + errmsg("timestamp with time zone units \"%s\" not recognized", + lowunits))); result = 0; } @@ -3181,7 +3185,7 @@ interval_trunc(PG_FUNCTION_ARGS) { switch (val) { - /* fall through */ + /* fall through */ case DTK_MILLENNIUM: /* caution: C division may have negative remainder */ tm->tm_year = (tm->tm_year / 1000) * 1000; @@ -3241,7 +3245,7 @@ interval_trunc(PG_FUNCTION_ARGS) (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("interval units \"%s\" not recognized", DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(units)))))); + PointerGetDatum(units)))))); *result = *interval; } @@ -3263,7 +3267,7 @@ isoweek2date(int woy, int *year, int *mon, int *mday) if (!*year) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("cannot calculate week number without year information"))); + errmsg("cannot calculate week number without year information"))); /* fourth day of current year */ day4 = date2j(*year, 1, 4); @@ -3298,8 +3302,8 @@ date2isoweek(int year, int mon, int mday) day0 = j2day(day4 - 1); /* - * We need the first week containing a Thursday, otherwise this day - * falls into the previous year for purposes of counting weeks + * We need the first week containing a Thursday, otherwise this day falls + * into the previous year for purposes of counting weeks */ if (dayn < day4 - day0) { @@ -3312,8 +3316,8 @@ date2isoweek(int year, int mon, int mday) result = (dayn - (day4 - day0)) / 7 + 1; /* - * Sometimes the last few days in a year will fall into the first week - * of the next year, so check for this. + * Sometimes the last few days in a year will fall into the first week of + * the next year, so check for this. */ if (result >= 52) { @@ -3352,8 +3356,8 @@ date2isoyear(int year, int mon, int mday) day0 = j2day(day4 - 1); /* - * We need the first week containing a Thursday, otherwise this day - * falls into the previous year for purposes of counting weeks + * We need the first week containing a Thursday, otherwise this day falls + * into the previous year for purposes of counting weeks */ if (dayn < day4 - day0) { @@ -3368,8 +3372,8 @@ date2isoyear(int year, int mon, int mday) result = (dayn - (day4 - day0)) / 7 + 1; /* - * Sometimes the last few days in a year will fall into the first week - * of the next year, so check for this. + * Sometimes the last few days in a year will fall into the first week of + * the next year, so check for this. */ if (result >= 52) { @@ -3393,7 +3397,7 @@ Datum timestamp_part(PG_FUNCTION_ARGS) { text *units = PG_GETARG_TEXT_P(0); - Timestamp timestamp = PG_GETARG_TIMESTAMP(1); + Timestamp timestamp = PG_GETARG_TIMESTAMP(1); float8 result; int type, val; @@ -3484,9 +3488,9 @@ timestamp_part(PG_FUNCTION_ARGS) case DTK_DECADE: /* - * what is a decade wrt dates? let us assume that decade - * 199 is 1990 thru 1999... decade 0 starts on year 1 BC, - * and -1 is 11 BC thru 2 BC... + * what is a decade wrt dates? let us assume that decade 199 + * is 1990 thru 1999... decade 0 starts on year 1 BC, and -1 + * is 11 BC thru 2 BC... */ if (tm->tm_year >= 0) result = tm->tm_year / 10; @@ -3521,10 +3525,10 @@ timestamp_part(PG_FUNCTION_ARGS) result = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday); #ifdef HAVE_INT64_TIMESTAMP result += ((((tm->tm_hour * MINS_PER_HOUR) + tm->tm_min) * SECS_PER_MINUTE) + - tm->tm_sec + (fsec / 1000000.0)) / (double)SECS_PER_DAY; + tm->tm_sec + (fsec / 1000000.0)) / (double) SECS_PER_DAY; #else result += ((((tm->tm_hour * MINS_PER_HOUR) + tm->tm_min) * SECS_PER_MINUTE) + - tm->tm_sec + fsec) / (double)SECS_PER_DAY; + tm->tm_sec + fsec) / (double) SECS_PER_DAY; #endif break; @@ -3549,20 +3553,19 @@ timestamp_part(PG_FUNCTION_ARGS) TimestampTz timestamptz; /* - * convert to timestamptz to produce consistent - * results + * convert to timestamptz to produce consistent results */ if (timestamp2tm(timestamp, NULL, tm, &fsec, NULL, NULL) != 0) ereport(ERROR, - (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE), - errmsg("timestamp out of range"))); + (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE), + errmsg("timestamp out of range"))); tz = DetermineTimeZoneOffset(tm, global_timezone); if (tm2timestamp(tm, fsec, &tz, ×tamptz) != 0) ereport(ERROR, - (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE), - errmsg("timestamp out of range"))); + (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE), + errmsg("timestamp out of range"))); #ifdef HAVE_INT64_TIMESTAMP result = (timestamptz - SetEpochTimestamp()) / 1000000.0; @@ -3601,7 +3604,7 @@ timestamp_part(PG_FUNCTION_ARGS) { ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("timestamp units \"%s\" not recognized", lowunits))); + errmsg("timestamp units \"%s\" not recognized", lowunits))); result = 0; } @@ -3657,12 +3660,12 @@ timestamptz_part(PG_FUNCTION_ARGS) case DTK_TZ_MINUTE: result = -tz; result /= MINS_PER_HOUR; - FMODULO(result, dummy, (double)MINS_PER_HOUR); + FMODULO(result, dummy, (double) MINS_PER_HOUR); break; case DTK_TZ_HOUR: dummy = -tz; - FMODULO(dummy, result, (double)SECS_PER_HOUR); + FMODULO(dummy, result, (double) SECS_PER_HOUR); break; case DTK_MICROSEC: @@ -3749,18 +3752,18 @@ timestamptz_part(PG_FUNCTION_ARGS) result = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday); #ifdef HAVE_INT64_TIMESTAMP result += ((((tm->tm_hour * MINS_PER_HOUR) + tm->tm_min) * SECS_PER_MINUTE) + - tm->tm_sec + (fsec / 1000000.0)) / (double)SECS_PER_DAY; + tm->tm_sec + (fsec / 1000000.0)) / (double) SECS_PER_DAY; #else result += ((((tm->tm_hour * MINS_PER_HOUR) + tm->tm_min) * SECS_PER_MINUTE) + - tm->tm_sec + fsec) / (double)SECS_PER_DAY; + tm->tm_sec + fsec) / (double) SECS_PER_DAY; #endif break; default: ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("timestamp with time zone units \"%s\" not supported", - lowunits))); + errmsg("timestamp with time zone units \"%s\" not supported", + lowunits))); result = 0; } @@ -3771,7 +3774,7 @@ timestamptz_part(PG_FUNCTION_ARGS) { case DTK_EPOCH: #ifdef HAVE_INT64_TIMESTAMP - result = (timestamp - SetEpochTimestamp()) /1000000.0; + result = (timestamp - SetEpochTimestamp()) / 1000000.0; #else result = timestamp - SetEpochTimestamp(); #endif @@ -3797,8 +3800,8 @@ timestamptz_part(PG_FUNCTION_ARGS) default: ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("timestamp with time zone units \"%s\" not supported", - lowunits))); + errmsg("timestamp with time zone units \"%s\" not supported", + lowunits))); result = 0; } } @@ -3806,8 +3809,8 @@ timestamptz_part(PG_FUNCTION_ARGS) { ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("timestamp with time zone units \"%s\" not recognized", - lowunits))); + errmsg("timestamp with time zone units \"%s\" not recognized", + lowunits))); result = 0; } @@ -3913,8 +3916,8 @@ interval_part(PG_FUNCTION_ARGS) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("interval units \"%s\" not supported", - DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(units)))))); + DatumGetCString(DirectFunctionCall1(textout, + PointerGetDatum(units)))))); result = 0; } @@ -3933,7 +3936,7 @@ interval_part(PG_FUNCTION_ARGS) result = interval->time; #endif result += (DAYS_PER_YEAR * SECS_PER_DAY) * (interval->month / MONTHS_PER_YEAR); - result += ((double)DAYS_PER_MONTH * SECS_PER_DAY) * (interval->month % MONTHS_PER_YEAR); + result += ((double) DAYS_PER_MONTH * SECS_PER_DAY) * (interval->month % MONTHS_PER_YEAR); result += interval->day * SECS_PER_DAY; } else @@ -3942,7 +3945,7 @@ interval_part(PG_FUNCTION_ARGS) (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("interval units \"%s\" not recognized", DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(units)))))); + PointerGetDatum(units)))))); result = 0; } @@ -3950,9 +3953,9 @@ interval_part(PG_FUNCTION_ARGS) } -/* timestamp_zone() - * Encode timestamp type with specified time zone. - * This function is just timestamp2timestamptz() except instead of +/* timestamp_zone() + * Encode timestamp type with specified time zone. + * This function is just timestamp2timestamptz() except instead of * shifting to the global timezone, we shift to the specified timezone. * This is different from the other AT TIME ZONE cases because instead * of shifting to a _to_ a new time zone, it sets the time to _be_ the @@ -3963,20 +3966,20 @@ timestamp_zone(PG_FUNCTION_ARGS) { text *zone = PG_GETARG_TEXT_P(0); Timestamp timestamp = PG_GETARG_TIMESTAMP(1); - TimestampTz result; + TimestampTz result; int tz; - pg_tz *tzp; - char tzname[TZ_STRLEN_MAX + 1]; - int len; - + pg_tz *tzp; + char tzname[TZ_STRLEN_MAX + 1]; + int len; + if (TIMESTAMP_NOT_FINITE(timestamp)) PG_RETURN_TIMESTAMPTZ(timestamp); /* - * Look up the requested timezone. First we look in the timezone - * database (to handle cases like "America/New_York"), and if that - * fails, we look in the date token table (to handle cases like "EST"). - */ + * Look up the requested timezone. First we look in the timezone database + * (to handle cases like "America/New_York"), and if that fails, we look + * in the date token table (to handle cases like "EST"). + */ len = Min(VARSIZE(zone) - VARHDRSZ, TZ_STRLEN_MAX); memcpy(tzname, VARDATA(zone), len); tzname[len] = '\0'; @@ -3985,7 +3988,7 @@ timestamp_zone(PG_FUNCTION_ARGS) { /* Apply the timezone change */ struct pg_tm tm; - fsec_t fsec; + fsec_t fsec; if (timestamp2tm(timestamp, NULL, &tm, &fsec, NULL, tzp) != 0) ereport(ERROR, @@ -4032,7 +4035,7 @@ Datum timestamp_izone(PG_FUNCTION_ARGS) { Interval *zone = PG_GETARG_INTERVAL_P(0); - Timestamp timestamp = PG_GETARG_TIMESTAMP(1); + Timestamp timestamp = PG_GETARG_TIMESTAMP(1); TimestampTz result; int tz; @@ -4042,9 +4045,9 @@ timestamp_izone(PG_FUNCTION_ARGS) if (zone->month != 0) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("interval time zone \"%s\" must not specify month", - DatumGetCString(DirectFunctionCall1(interval_out, - PointerGetDatum(zone)))))); + errmsg("interval time zone \"%s\" must not specify month", + DatumGetCString(DirectFunctionCall1(interval_out, + PointerGetDatum(zone)))))); #ifdef HAVE_INT64_TIMESTAMP tz = zone->time / USECS_PER_SEC; @@ -4063,7 +4066,7 @@ timestamp_izone(PG_FUNCTION_ARGS) Datum timestamp_timestamptz(PG_FUNCTION_ARGS) { - Timestamp timestamp = PG_GETARG_TIMESTAMP(0); + Timestamp timestamp = PG_GETARG_TIMESTAMP(0); PG_RETURN_TIMESTAMPTZ(timestamp2timestamptz(timestamp)); } @@ -4139,17 +4142,17 @@ timestamptz_zone(PG_FUNCTION_ARGS) Timestamp result; int tz; pg_tz *tzp; - char tzname[TZ_STRLEN_MAX + 1]; - int len; + char tzname[TZ_STRLEN_MAX + 1]; + int len; if (TIMESTAMP_NOT_FINITE(timestamp)) PG_RETURN_TIMESTAMP(timestamp); /* - * Look up the requested timezone. First we look in the timezone - * database (to handle cases like "America/New_York"), and if that - * fails, we look in the date token table (to handle cases like "EST"). - */ + * Look up the requested timezone. First we look in the timezone database + * (to handle cases like "America/New_York"), and if that fails, we look + * in the date token table (to handle cases like "EST"). + */ len = Min(VARSIZE(zone) - VARHDRSZ, TZ_STRLEN_MAX); memcpy(tzname, VARDATA(zone), len); tzname[len] = '\0'; @@ -4158,7 +4161,7 @@ timestamptz_zone(PG_FUNCTION_ARGS) { /* Apply the timezone change */ struct pg_tm tm; - fsec_t fsec; + fsec_t fsec; if (timestamp2tm(timestamp, &tz, &tm, &fsec, NULL, tzp) != 0) ereport(ERROR, @@ -4215,9 +4218,9 @@ timestamptz_izone(PG_FUNCTION_ARGS) if (zone->month != 0) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("interval time zone \"%s\" must not specify month", - DatumGetCString(DirectFunctionCall1(interval_out, - PointerGetDatum(zone)))))); + errmsg("interval time zone \"%s\" must not specify month", + DatumGetCString(DirectFunctionCall1(interval_out, + PointerGetDatum(zone)))))); #ifdef HAVE_INT64_TIMESTAMP tz = -(zone->time / USECS_PER_SEC); diff --git a/src/backend/utils/adt/varbit.c b/src/backend/utils/adt/varbit.c index 370d3e8110..7dbbed16f6 100644 --- a/src/backend/utils/adt/varbit.c +++ b/src/backend/utils/adt/varbit.c @@ -9,7 +9,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/varbit.c,v 1.46 2005/09/24 17:53:16 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/varbit.c,v 1.47 2005/10/15 02:49:30 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -83,8 +83,8 @@ bit_in(PG_FUNCTION_ARGS) else { /* - * Otherwise it's binary. This allows things like cast('1001' as - * bit) to work transparently. + * Otherwise it's binary. This allows things like cast('1001' as bit) + * to work transparently. */ bit_not_hex = true; sp = input_string; @@ -98,16 +98,16 @@ bit_in(PG_FUNCTION_ARGS) bitlen = slen * 4; /* - * Sometimes atttypmod is not supplied. If it is supplied we need to - * make sure that the bitstring fits. + * Sometimes atttypmod is not supplied. If it is supplied we need to make + * sure that the bitstring fits. */ if (atttypmod <= 0) atttypmod = bitlen; else if (bitlen != atttypmod) ereport(ERROR, (errcode(ERRCODE_STRING_DATA_LENGTH_MISMATCH), - errmsg("bit string length %d does not match type bit(%d)", - bitlen, atttypmod))); + errmsg("bit string length %d does not match type bit(%d)", + bitlen, atttypmod))); len = VARBITTOTALLEN(atttypmod); /* set to 0 so that *r is always initialised and string is zero-padded */ @@ -204,8 +204,8 @@ bit_out(PG_FUNCTION_ARGS) } /* - * Go back one step if we printed a hex number that was not part of - * the bitstring anymore + * Go back one step if we printed a hex number that was not part of the + * bitstring anymore */ if (i > len) r--; @@ -222,6 +222,7 @@ Datum bit_recv(PG_FUNCTION_ARGS) { StringInfo buf = (StringInfo) PG_GETARG_POINTER(0); + #ifdef NOT_USED Oid typelem = PG_GETARG_OID(1); #endif @@ -239,14 +240,14 @@ bit_recv(PG_FUNCTION_ARGS) errmsg("invalid length in external bit string"))); /* - * Sometimes atttypmod is not supplied. If it is supplied we need to - * make sure that the bitstring fits. + * Sometimes atttypmod is not supplied. If it is supplied we need to make + * sure that the bitstring fits. */ if (atttypmod > 0 && bitlen != atttypmod) ereport(ERROR, (errcode(ERRCODE_STRING_DATA_LENGTH_MISMATCH), - errmsg("bit string length %d does not match type bit(%d)", - bitlen, atttypmod))); + errmsg("bit string length %d does not match type bit(%d)", + bitlen, atttypmod))); len = VARBITTOTALLEN(bitlen); result = (VarBit *) palloc(len); @@ -301,8 +302,8 @@ bit(PG_FUNCTION_ARGS) if (!isExplicit) ereport(ERROR, (errcode(ERRCODE_STRING_DATA_LENGTH_MISMATCH), - errmsg("bit string length %d does not match type bit(%d)", - VARBITLEN(arg), len))); + errmsg("bit string length %d does not match type bit(%d)", + VARBITLEN(arg), len))); rlen = VARBITTOTALLEN(len); /* set to 0 so that string is zero-padded */ @@ -314,9 +315,9 @@ bit(PG_FUNCTION_ARGS) Min(VARBITBYTES(result), VARBITBYTES(arg))); /* - * Make sure last byte is zero-padded if needed. This is useless but - * safe if source data was shorter than target length (we assume the - * last byte of the source data was itself correctly zero-padded). + * Make sure last byte is zero-padded if needed. This is useless but safe + * if source data was shorter than target length (we assume the last byte + * of the source data was itself correctly zero-padded). */ ipad = VARBITPAD(result); if (ipad > 0) @@ -378,8 +379,8 @@ varbit_in(PG_FUNCTION_ARGS) bitlen = slen * 4; /* - * Sometimes atttypmod is not supplied. If it is supplied we need to - * make sure that the bitstring fits. + * Sometimes atttypmod is not supplied. If it is supplied we need to make + * sure that the bitstring fits. */ if (atttypmod <= 0) atttypmod = bitlen; @@ -500,6 +501,7 @@ Datum varbit_recv(PG_FUNCTION_ARGS) { StringInfo buf = (StringInfo) PG_GETARG_POINTER(0); + #ifdef NOT_USED Oid typelem = PG_GETARG_OID(1); #endif @@ -517,8 +519,8 @@ varbit_recv(PG_FUNCTION_ARGS) errmsg("invalid length in external bit string"))); /* - * Sometimes atttypmod is not supplied. If it is supplied we need to - * make sure that the bitstring fits. + * Sometimes atttypmod is not supplied. If it is supplied we need to make + * sure that the bitstring fits. */ if (atttypmod > 0 && bitlen > atttypmod) ereport(ERROR, @@ -874,8 +876,8 @@ bitsubstr(PG_FUNCTION_ARGS) else { /* - * OK, we've got a true substring starting at position s1-1 and - * ending at position e1-1 + * OK, we've got a true substring starting at position s1-1 and ending + * at position e1-1 */ rbitlen = e1 - s1; len = VARBITTOTALLEN(rbitlen); diff --git a/src/backend/utils/adt/varchar.c b/src/backend/utils/adt/varchar.c index 84fcc97ccd..1377e7cc6d 100644 --- a/src/backend/utils/adt/varchar.c +++ b/src/backend/utils/adt/varchar.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/varchar.c,v 1.112 2005/07/29 12:59:15 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/varchar.c,v 1.113 2005/10/15 02:49:30 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -81,7 +81,7 @@ bpchar_input(const char *s, size_t len, int32 atttypmod) maxlen = len; else { - size_t charlen; /* number of CHARACTERS in the input */ + size_t charlen; /* number of CHARACTERS in the input */ maxlen = atttypmod - VARHDRSZ; charlen = pg_mbstrlen_with_len(s, len); @@ -106,16 +106,16 @@ bpchar_input(const char *s, size_t len, int32 atttypmod) } /* - * Now we set maxlen to the necessary byte length, not - * the number of CHARACTERS! + * Now we set maxlen to the necessary byte length, not the number + * of CHARACTERS! */ maxlen = len = mbmaxlen; } else { /* - * Now we set maxlen to the necessary byte length, not - * the number of CHARACTERS! + * Now we set maxlen to the necessary byte length, not the number + * of CHARACTERS! */ maxlen = len + (maxlen - charlen); } @@ -141,6 +141,7 @@ Datum bpcharin(PG_FUNCTION_ARGS) { char *s = PG_GETARG_CSTRING(0); + #ifdef NOT_USED Oid typelem = PG_GETARG_OID(1); #endif @@ -178,6 +179,7 @@ Datum bpcharrecv(PG_FUNCTION_ARGS) { StringInfo buf = (StringInfo) PG_GETARG_POINTER(0); + #ifdef NOT_USED Oid typelem = PG_GETARG_OID(1); #endif @@ -226,8 +228,8 @@ bpchar(PG_FUNCTION_ARGS) char *r; char *s; int i; - int charlen; /* number of characters in the input string - * + VARHDRSZ */ + int charlen; /* number of characters in the input string + + * VARHDRSZ */ /* No work if typmod is invalid */ if (maxlen < (int32) VARHDRSZ) @@ -254,24 +256,24 @@ bpchar(PG_FUNCTION_ARGS) for (i = maxmblen - VARHDRSZ; i < len - VARHDRSZ; i++) if (*(VARDATA(source) + i) != ' ') ereport(ERROR, - (errcode(ERRCODE_STRING_DATA_RIGHT_TRUNCATION), - errmsg("value too long for type character(%d)", - maxlen - VARHDRSZ))); + (errcode(ERRCODE_STRING_DATA_RIGHT_TRUNCATION), + errmsg("value too long for type character(%d)", + maxlen - VARHDRSZ))); } len = maxmblen; /* - * XXX: at this point, maxlen is the necessary byte - * length+VARHDRSZ, not the number of CHARACTERS! + * XXX: at this point, maxlen is the necessary byte length+VARHDRSZ, + * not the number of CHARACTERS! */ maxlen = len; } else { /* - * XXX: at this point, maxlen is the necessary byte - * length+VARHDRSZ, not the number of CHARACTERS! + * XXX: at this point, maxlen is the necessary byte length+VARHDRSZ, + * not the number of CHARACTERS! */ maxlen = len + (maxlen - charlen); } @@ -407,8 +409,8 @@ varchar_input(const char *s, size_t len, int32 atttypmod) if (s[j] != ' ') ereport(ERROR, (errcode(ERRCODE_STRING_DATA_RIGHT_TRUNCATION), - errmsg("value too long for type character varying(%d)", - (int) maxlen))); + errmsg("value too long for type character varying(%d)", + (int) maxlen))); } len = mbmaxlen; @@ -429,6 +431,7 @@ Datum varcharin(PG_FUNCTION_ARGS) { char *s = PG_GETARG_CSTRING(0); + #ifdef NOT_USED Oid typelem = PG_GETARG_OID(1); #endif @@ -466,11 +469,12 @@ Datum varcharrecv(PG_FUNCTION_ARGS) { StringInfo buf = (StringInfo) PG_GETARG_POINTER(0); + #ifdef NOT_USED Oid typelem = PG_GETARG_OID(1); #endif int32 atttypmod = PG_GETARG_INT32(2); - VarChar *result; + VarChar *result; char *str; int nbytes; @@ -531,8 +535,8 @@ varchar(PG_FUNCTION_ARGS) if (*(VARDATA(source) + i) != ' ') ereport(ERROR, (errcode(ERRCODE_STRING_DATA_RIGHT_TRUNCATION), - errmsg("value too long for type character varying(%d)", - maxlen - VARHDRSZ))); + errmsg("value too long for type character varying(%d)", + maxlen - VARHDRSZ))); } len = maxmblen + VARHDRSZ; diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c index dcd2b7ff42..07ba4dc684 100644 --- a/src/backend/utils/adt/varlena.c +++ b/src/backend/utils/adt/varlena.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.135 2005/09/24 17:53:16 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.136 2005/10/15 02:49:30 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -147,8 +147,7 @@ byteain(PG_FUNCTION_ARGS) else { /* - * We should never get here. The first pass should not allow - * it. + * We should never get here. The first pass should not allow it. */ ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), @@ -550,8 +549,8 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified) { S1 = Max(S, 1); - if (length_not_specified) /* special case - get length to - * end of string */ + if (length_not_specified) /* special case - get length to end of + * string */ L1 = -1; else { @@ -559,18 +558,18 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified) int E = S + length; /* - * A negative value for L is the only way for the end position - * to be before the start. SQL99 says to throw an error. + * A negative value for L is the only way for the end position to + * be before the start. SQL99 says to throw an error. */ if (E < S) ereport(ERROR, (errcode(ERRCODE_SUBSTRING_ERROR), - errmsg("negative substring length not allowed"))); + errmsg("negative substring length not allowed"))); /* - * A zero or negative value for the end position can happen if - * the start was negative or one. SQL99 says to return a - * zero-length string. + * A zero or negative value for the end position can happen if the + * start was negative or one. SQL99 says to return a zero-length + * string. */ if (E < 1) return PG_STR_GET_TEXT(""); @@ -579,9 +578,9 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified) } /* - * If the start position is past the end of the string, SQL99 says - * to return a zero-length string -- PG_GETARG_TEXT_P_SLICE() will - * do that for us. Convert to zero-based starting position + * If the start position is past the end of the string, SQL99 says to + * return a zero-length string -- PG_GETARG_TEXT_P_SLICE() will do + * that for us. Convert to zero-based starting position */ return DatumGetTextPSlice(str, S1 - 1, L1); } @@ -589,8 +588,8 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified) { /* * When encoding max length is > 1, we can't get LC without - * detoasting, so we'll grab a conservatively large slice now and - * go back later to do the right thing + * detoasting, so we'll grab a conservatively large slice now and go + * back later to do the right thing */ int32 slice_start; int32 slice_size; @@ -603,38 +602,38 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified) text *ret; /* - * if S is past the end of the string, the tuple toaster will - * return a zero-length string to us + * if S is past the end of the string, the tuple toaster will return a + * zero-length string to us */ S1 = Max(S, 1); /* - * We need to start at position zero because there is no way to - * know in advance which byte offset corresponds to the supplied - * start position. + * We need to start at position zero because there is no way to know + * in advance which byte offset corresponds to the supplied start + * position. */ slice_start = 0; - if (length_not_specified) /* special case - get length to - * end of string */ + if (length_not_specified) /* special case - get length to end of + * string */ slice_size = L1 = -1; else { int E = S + length; /* - * A negative value for L is the only way for the end position - * to be before the start. SQL99 says to throw an error. + * A negative value for L is the only way for the end position to + * be before the start. SQL99 says to throw an error. */ if (E < S) ereport(ERROR, (errcode(ERRCODE_SUBSTRING_ERROR), - errmsg("negative substring length not allowed"))); + errmsg("negative substring length not allowed"))); /* - * A zero or negative value for the end position can happen if - * the start was negative or one. SQL99 says to return a - * zero-length string. + * A zero or negative value for the end position can happen if the + * start was negative or one. SQL99 says to return a zero-length + * string. */ if (E < 1) return PG_STR_GET_TEXT(""); @@ -646,9 +645,8 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified) L1 = E - S1; /* - * Total slice size in bytes can't be any longer than the - * start position plus substring length times the encoding max - * length. + * Total slice size in bytes can't be any longer than the start + * position plus substring length times the encoding max length. */ slice_size = (S1 + L1) * eml; } @@ -662,16 +660,15 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified) slice_strlen = pg_mbstrlen_with_len(VARDATA(slice), VARSIZE(slice) - VARHDRSZ); /* - * Check that the start position wasn't > slice_strlen. If so, - * SQL99 says to return a zero-length string. + * Check that the start position wasn't > slice_strlen. If so, SQL99 + * says to return a zero-length string. */ if (S1 > slice_strlen) return PG_STR_GET_TEXT(""); /* - * Adjust L1 and E1 now that we know the slice string length. - * Again remember that S1 is one based, and slice_start is zero - * based. + * Adjust L1 and E1 now that we know the slice string length. Again + * remember that S1 is one based, and slice_start is zero based. */ if (L1 > -1) E1 = Min(S1 + L1, slice_start + 1 + slice_strlen); @@ -679,8 +676,7 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified) E1 = slice_start + 1 + slice_strlen; /* - * Find the start position in the slice; remember S1 is not zero - * based + * Find the start position in the slice; remember S1 is not zero based */ p = VARDATA(slice); for (i = 0; i < S1 - 1; i++) @@ -834,11 +830,10 @@ varstr_cmp(char *arg1, int len1, char *arg2, int len2) int result; /* - * Unfortunately, there is no strncoll(), so in the non-C locale case - * we have to do some memory copying. This turns out to be - * significantly slower, so we optimize the case where LC_COLLATE is - * C. We also try to optimize relatively-short strings by avoiding - * palloc/pfree overhead. + * Unfortunately, there is no strncoll(), so in the non-C locale case we + * have to do some memory copying. This turns out to be significantly + * slower, so we optimize the case where LC_COLLATE is C. We also try to + * optimize relatively-short strings by avoiding palloc/pfree overhead. */ if (lc_collate_is_c()) { @@ -859,11 +854,11 @@ varstr_cmp(char *arg1, int len1, char *arg2, int len2) /* Win32 does not have UTF-8, so we need to map to UTF-16 */ if (GetDatabaseEncoding() == PG_UTF8) { - int a1len; - int a2len; - int r; + int a1len; + int a2len; + int r; - if (len1 >= STACKBUFLEN/2) + if (len1 >= STACKBUFLEN / 2) { a1len = len1 * 2 + 2; a1p = palloc(a1len); @@ -873,7 +868,7 @@ varstr_cmp(char *arg1, int len1, char *arg2, int len2) a1len = STACKBUFLEN; a1p = a1buf; } - if (len2 >= STACKBUFLEN/2) + if (len2 >= STACKBUFLEN / 2) { a2len = len2 * 2 + 2; a2p = palloc(a2len); @@ -890,7 +885,7 @@ varstr_cmp(char *arg1, int len1, char *arg2, int len2) else { r = MultiByteToWideChar(CP_UTF8, 0, arg1, len1, - (LPWSTR) a1p, a1len/2); + (LPWSTR) a1p, a1len / 2); if (!r) ereport(ERROR, (errmsg("could not convert string to UTF16: %lu", @@ -903,7 +898,7 @@ varstr_cmp(char *arg1, int len1, char *arg2, int len2) else { r = MultiByteToWideChar(CP_UTF8, 0, arg2, len2, - (LPWSTR) a2p, a2len/2); + (LPWSTR) a2p, a2len / 2); if (!r) ereport(ERROR, (errmsg("could not convert string to UTF16: %lu", @@ -913,7 +908,8 @@ varstr_cmp(char *arg1, int len1, char *arg2, int len2) errno = 0; result = wcscoll((LPWSTR) a1p, (LPWSTR) a2p); - if (result == 2147483647) /* _NLSCMPERROR; missing from mingw headers */ + if (result == 2147483647) /* _NLSCMPERROR; missing from mingw + * headers */ ereport(ERROR, (errmsg("could not compare unicode strings: %d", errno))); @@ -925,7 +921,7 @@ varstr_cmp(char *arg1, int len1, char *arg2, int len2) return result; } -#endif /* WIN32 */ +#endif /* WIN32 */ if (len1 >= STACKBUFLEN) a1p = (char *) palloc(len1 + 1); @@ -1349,9 +1345,8 @@ bytea_substr(PG_FUNCTION_ARGS) if (fcinfo->nargs == 2) { /* - * Not passed a length - PG_GETARG_BYTEA_P_SLICE() grabs - * everything to the end of the string if we pass it a negative - * value for length. + * Not passed a length - PG_GETARG_BYTEA_P_SLICE() grabs everything to + * the end of the string if we pass it a negative value for length. */ L1 = -1; } @@ -1361,8 +1356,8 @@ bytea_substr(PG_FUNCTION_ARGS) int E = S + PG_GETARG_INT32(2); /* - * A negative value for L is the only way for the end position to - * be before the start. SQL99 says to throw an error. + * A negative value for L is the only way for the end position to be + * before the start. SQL99 says to throw an error. */ if (E < S) ereport(ERROR, @@ -1382,8 +1377,8 @@ bytea_substr(PG_FUNCTION_ARGS) /* * If the start position is past the end of the string, SQL99 says to - * return a zero-length string -- PG_GETARG_TEXT_P_SLICE() will do - * that for us. Convert to zero-based starting position + * return a zero-length string -- PG_GETARG_TEXT_P_SLICE() will do that + * for us. Convert to zero-based starting position */ PG_RETURN_BYTEA_P(PG_GETARG_BYTEA_P_SLICE(0, S1 - 1, L1)); } @@ -1686,7 +1681,7 @@ textToQualifiedNameList(text *textval) /* Convert to C string (handles possible detoasting). */ /* Note we rely on being able to modify rawname below. */ rawname = DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(textval))); + PointerGetDatum(textval))); if (!SplitIdentifierString(rawname, '.', &namelist)) ereport(ERROR, @@ -1788,14 +1783,13 @@ SplitIdentifierString(char *rawstring, char separator, return false; /* empty unquoted name not allowed */ /* - * Downcase the identifier, using same code as main lexer - * does. + * Downcase the identifier, using same code as main lexer does. * * XXX because we want to overwrite the input in-place, we cannot - * support a downcasing transformation that increases the - * string length. This is not a problem given the current - * implementation of downcase_truncate_identifier, but we'll - * probably have to do something about this someday. + * support a downcasing transformation that increases the string + * length. This is not a problem given the current implementation + * of downcase_truncate_identifier, but we'll probably have to do + * something about this someday. */ len = endp - curname; downname = downcase_truncate_identifier(curname, len, false); @@ -2083,12 +2077,14 @@ check_replace_text_has_escape_char(const text *replace_text) if (pg_database_encoding_max_length() == 1) { for (; p < p_end; p++) - if (*p == '\\') return true; + if (*p == '\\') + return true; } else { for (; p < p_end; p += pg_mblen(p)) - if (*p == '\\') return true; + if (*p == '\\') + return true; } return false; @@ -2100,7 +2096,7 @@ check_replace_text_has_escape_char(const text *replace_text) */ static void appendStringInfoRegexpSubstr(StringInfo str, text *replace_text, - regmatch_t *pmatch, text *src_text) + regmatch_t *pmatch, text *src_text) { const char *p = VARDATA(replace_text); const char *p_end = p + (VARSIZE(replace_text) - VARHDRSZ); @@ -2129,19 +2125,20 @@ appendStringInfoRegexpSubstr(StringInfo str, text *replace_text, } /* - * Copy the text when there is a text in the left of escape char - * or escape char is not found. + * Copy the text when there is a text in the left of escape char or + * escape char is not found. */ if (ch_cnt) { - text *append_text = text_substring(PointerGetDatum(replace_text), - substr_start, ch_cnt, false); + text *append_text = text_substring(PointerGetDatum(replace_text), + substr_start, ch_cnt, false); + appendStringInfoText(str, append_text); pfree(append_text); } substr_start += ch_cnt + 1; - if (p >= p_end) /* When escape char is not found. */ + if (p >= p_end) /* When escape char is not found. */ break; /* See the next character of escape char. */ @@ -2151,7 +2148,8 @@ appendStringInfoRegexpSubstr(StringInfo str, text *replace_text, if (*p >= '1' && *p <= '9') { /* Use the back reference of regexp. */ - int idx = *p - '0'; + int idx = *p - '0'; + so = pmatch[idx].rm_so; eo = pmatch[idx].rm_eo; p++; @@ -2169,8 +2167,9 @@ appendStringInfoRegexpSubstr(StringInfo str, text *replace_text, if (so != -1 && eo != -1) { /* Copy the text that is back reference of regexp. */ - text *append_text = text_substring(PointerGetDatum(src_text), - so + 1, (eo - so), false); + text *append_text = text_substring(PointerGetDatum(src_text), + so + 1, (eo - so), false); + appendStringInfoText(str, append_text); pfree(append_text); } @@ -2189,9 +2188,9 @@ replace_text_regexp(PG_FUNCTION_ARGS) text *ret_text; text *src_text = PG_GETARG_TEXT_P(0); int src_text_len = VARSIZE(src_text) - VARHDRSZ; - regex_t *re = (regex_t *)PG_GETARG_POINTER(1); + regex_t *re = (regex_t *) PG_GETARG_POINTER(1); text *replace_text = PG_GETARG_TEXT_P(2); - bool global = PG_GETARG_BOOL(3); + bool global = PG_GETARG_BOOL(3); StringInfo str = makeStringInfo(); int regexec_result; regmatch_t pmatch[REGEXP_REPLACE_BACKREF_CNT]; @@ -2214,33 +2213,34 @@ replace_text_regexp(PG_FUNCTION_ARGS) data, data_len, search_start, - NULL, /* no details */ + NULL, /* no details */ REGEXP_REPLACE_BACKREF_CNT, pmatch, 0); if (regexec_result != REG_OKAY && regexec_result != REG_NOMATCH) { - char errMsg[100]; + char errMsg[100]; /* re failed??? */ pg_regerror(regexec_result, re, errMsg, sizeof(errMsg)); ereport(ERROR, - (errcode(ERRCODE_INVALID_REGULAR_EXPRESSION), - errmsg("regular expression failed: %s", errMsg))); + (errcode(ERRCODE_INVALID_REGULAR_EXPRESSION), + errmsg("regular expression failed: %s", errMsg))); } if (regexec_result == REG_NOMATCH) break; - /* - * Copy the text when there is a text in the left of matched position. - */ + /* + * Copy the text when there is a text in the left of matched position. + */ if (pmatch[0].rm_so - data_pos > 0) { - text *left_text = text_substring(PointerGetDatum(src_text), - data_pos + 1, - pmatch[0].rm_so - data_pos, false); + text *left_text = text_substring(PointerGetDatum(src_text), + data_pos + 1, + pmatch[0].rm_so - data_pos, false); + appendStringInfoText(str, left_text); pfree(left_text); } @@ -2270,13 +2270,14 @@ replace_text_regexp(PG_FUNCTION_ARGS) } /* - * Copy the text when there is a text at the right of last matched - * or regexp is not matched. + * Copy the text when there is a text at the right of last matched or + * regexp is not matched. */ if (data_pos < data_len) { - text *right_text = text_substring(PointerGetDatum(src_text), - data_pos + 1, -1, true); + text *right_text = text_substring(PointerGetDatum(src_text), + data_pos + 1, -1, true); + appendStringInfoText(str, right_text); pfree(right_text); } @@ -2392,7 +2393,7 @@ text_to_array(PG_FUNCTION_ARGS) */ if (fldsep_len < 1) PG_RETURN_ARRAYTYPE_P(create_singleton_array(fcinfo, TEXTOID, - CStringGetDatum(inputstring), 1)); + CStringGetDatum(inputstring), 1)); /* start with end position holding the initial start position */ end_posn = 0; @@ -2409,17 +2410,17 @@ text_to_array(PG_FUNCTION_ARGS) if (fldnum == 1) { /* - * first element return one element, 1D, array using the - * input string + * first element return one element, 1D, array using the input + * string */ PG_RETURN_ARRAYTYPE_P(create_singleton_array(fcinfo, TEXTOID, - CStringGetDatum(inputstring), 1)); + CStringGetDatum(inputstring), 1)); } else { /* otherwise create array and exit */ PG_RETURN_ARRAYTYPE_P(makeArrayResult(astate, - CurrentMemoryContext)); + CurrentMemoryContext)); } } else if (start_posn == 0) @@ -2439,7 +2440,7 @@ text_to_array(PG_FUNCTION_ARGS) /* interior field requested */ result_text = text_substring(PointerGetDatum(inputstring), start_posn + fldsep_len, - end_posn - start_posn - fldsep_len, + end_posn - start_posn - fldsep_len, false); } @@ -2489,14 +2490,14 @@ array_to_text(PG_FUNCTION_ARGS) /* * We arrange to look up info about element type, including its output - * conversion proc, only once per series of calls, assuming the - * element type doesn't change underneath us. + * conversion proc, only once per series of calls, assuming the element + * type doesn't change underneath us. */ my_extra = (ArrayMetaState *) fcinfo->flinfo->fn_extra; if (my_extra == NULL) { fcinfo->flinfo->fn_extra = MemoryContextAlloc(fcinfo->flinfo->fn_mcxt, - sizeof(ArrayMetaState)); + sizeof(ArrayMetaState)); my_extra = (ArrayMetaState *) fcinfo->flinfo->fn_extra; my_extra->element_type = InvalidOid; } @@ -2504,8 +2505,7 @@ array_to_text(PG_FUNCTION_ARGS) if (my_extra->element_type != element_type) { /* - * Get info about element type, including its output conversion - * proc + * Get info about element type, including its output conversion proc */ get_type_io_data(element_type, IOFunc_output, &my_extra->typlen, &my_extra->typbyval, @@ -2606,7 +2606,7 @@ md5_text(PG_FUNCTION_ARGS) { text *in_text = PG_GETARG_TEXT_P(0); size_t len; - char hexsum[MD5_HASH_LEN + 1]; + char hexsum[MD5_HASH_LEN + 1]; text *result_text; /* Calculate the length of the buffer using varlena metadata */ @@ -2661,7 +2661,7 @@ pg_column_size(PG_FUNCTION_ARGS) if (fcinfo->flinfo->fn_extra == NULL) { /* Lookup the datatype of the supplied argument */ - Oid argtypeid = get_fn_expr_argtype(fcinfo->flinfo, 0); + Oid argtypeid = get_fn_expr_argtype(fcinfo->flinfo, 0); typlen = get_typlen(argtypeid); if (typlen == 0) /* should not happen */ diff --git a/src/backend/utils/cache/catcache.c b/src/backend/utils/cache/catcache.c index 2ffcee7769..918ab7c081 100644 --- a/src/backend/utils/cache/catcache.c +++ b/src/backend/utils/cache/catcache.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/cache/catcache.c,v 1.124 2005/09/24 22:54:39 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/cache/catcache.c,v 1.125 2005/10/15 02:49:30 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -35,7 +35,7 @@ #include "utils/syscache.h" -/* #define CACHEDEBUG */ /* turns DEBUG elogs on */ + /* #define CACHEDEBUG */ /* turns DEBUG elogs on */ /* * Constants related to size of the catcache. @@ -187,22 +187,22 @@ CatalogCacheComputeHashValue(CatCache *cache, int nkeys, ScanKey cur_skey) case 4: hashValue ^= DatumGetUInt32(DirectFunctionCall1(cache->cc_hashfunc[3], - cur_skey[3].sk_argument)) << 9; + cur_skey[3].sk_argument)) << 9; /* FALLTHROUGH */ case 3: hashValue ^= DatumGetUInt32(DirectFunctionCall1(cache->cc_hashfunc[2], - cur_skey[2].sk_argument)) << 6; + cur_skey[2].sk_argument)) << 6; /* FALLTHROUGH */ case 2: hashValue ^= DatumGetUInt32(DirectFunctionCall1(cache->cc_hashfunc[1], - cur_skey[1].sk_argument)) << 3; + cur_skey[1].sk_argument)) << 3; /* FALLTHROUGH */ case 1: hashValue ^= DatumGetUInt32(DirectFunctionCall1(cache->cc_hashfunc[0], - cur_skey[0].sk_argument)); + cur_skey[0].sk_argument)); break; default: elog(FATAL, "wrong number of hash keys: %d", nkeys); @@ -448,8 +448,8 @@ CatalogCacheIdInvalidate(int cacheId, /* * We don't bother to check whether the cache has finished - * initialization yet; if not, there will be no entries in it so - * no problem. + * initialization yet; if not, there will be no entries in it so no + * problem. */ /* @@ -522,15 +522,15 @@ void CreateCacheMemoryContext(void) { /* - * Purely for paranoia, check that context doesn't exist; caller - * probably did so already. + * Purely for paranoia, check that context doesn't exist; caller probably + * did so already. */ if (!CacheMemoryContext) CacheMemoryContext = AllocSetContextCreate(TopMemoryContext, "CacheMemoryContext", - ALLOCSET_DEFAULT_MINSIZE, - ALLOCSET_DEFAULT_INITSIZE, - ALLOCSET_DEFAULT_MAXSIZE); + ALLOCSET_DEFAULT_MINSIZE, + ALLOCSET_DEFAULT_INITSIZE, + ALLOCSET_DEFAULT_MAXSIZE); } @@ -768,7 +768,6 @@ do { \ cp->cc_reloid, cp->cc_indexoid, cp->id, \ cp->cc_nkeys, cp->cc_nbuckets); \ } while(0) - #else #define InitCatCache_DEBUG2 #endif @@ -786,8 +785,8 @@ InitCatCache(int id, int i; /* - * first switch to the cache context so our allocations do not vanish - * at the end of a transaction + * first switch to the cache context so our allocations do not vanish at + * the end of a transaction */ if (!CacheMemoryContext) CreateCacheMemoryContext(); @@ -878,7 +877,6 @@ do { \ i+1, cache->cc_nkeys, cache->cc_key[i]); \ } \ } while(0) - #else #define CatalogCacheInitializeCache_DEBUG1 #define CatalogCacheInitializeCache_DEBUG2 @@ -895,15 +893,15 @@ CatalogCacheInitializeCache(CatCache *cache) CatalogCacheInitializeCache_DEBUG1; /* - * Open the relation without locking --- we only need the tupdesc, - * which we assume will never change ... + * Open the relation without locking --- we only need the tupdesc, which + * we assume will never change ... */ relation = heap_open(cache->cc_reloid, NoLock); Assert(RelationIsValid(relation)); /* - * switch to the cache context so our allocations do not vanish at the - * end of a transaction + * switch to the cache context so our allocations do not vanish at the end + * of a transaction */ Assert(CacheMemoryContext != NULL); @@ -915,8 +913,8 @@ CatalogCacheInitializeCache(CatCache *cache) tupdesc = CreateTupleDescCopyConstr(RelationGetDescr(relation)); /* - * save the relation's name and relisshared flag, too (cc_relname - * is used only for debugging purposes) + * save the relation's name and relisshared flag, too (cc_relname is used + * only for debugging purposes) */ cache->cc_relname = pstrdup(RelationGetRelationName(relation)); cache->cc_relisshared = RelationGetForm(relation)->relisshared; @@ -957,8 +955,8 @@ CatalogCacheInitializeCache(CatCache *cache) cache->cc_isname[i] = (keytype == NAMEOID); /* - * Do equality-function lookup (we assume this won't need a - * catalog lookup for any supported type) + * Do equality-function lookup (we assume this won't need a catalog + * lookup for any supported type) */ fmgr_info_cxt(eqfunc, &cache->cc_skey[i].sk_func, @@ -1026,9 +1024,9 @@ IndexScanOK(CatCache *cache, ScanKey cur_skey) if (cache->id == INDEXRELID) { /* - * Since the OIDs of indexes aren't hardwired, it's painful to - * figure out which is which. Just force all pg_index searches to - * be heap scans while building the relcaches. + * Since the OIDs of indexes aren't hardwired, it's painful to figure + * out which is which. Just force all pg_index searches to be heap + * scans while building the relcaches. */ if (!criticalRelcachesBuilt) return false; @@ -1037,10 +1035,10 @@ IndexScanOK(CatCache *cache, ScanKey cur_skey) cache->id == AMNAME) { /* - * Always do heap scans in pg_am, because it's so small there's - * not much point in an indexscan anyway. We *must* do this when - * initially building critical relcache entries, but we might as - * well just always do it. + * Always do heap scans in pg_am, because it's so small there's not + * much point in an indexscan anyway. We *must* do this when + * initially building critical relcache entries, but we might as well + * just always do it. */ return false; } @@ -1146,18 +1144,18 @@ SearchCatCache(CatCache *cache, continue; /* - * we found a match in the cache: move it to the front of the - * global LRU list. We also move it to the front of the list for - * its hashbucket, in order to speed subsequent searches. (The - * most frequently accessed elements in any hashbucket will tend - * to be near the front of the hashbucket's list.) + * we found a match in the cache: move it to the front of the global + * LRU list. We also move it to the front of the list for its + * hashbucket, in order to speed subsequent searches. (The most + * frequently accessed elements in any hashbucket will tend to be near + * the front of the hashbucket's list.) */ DLMoveToFront(&ct->lrulist_elem); DLMoveToFront(&ct->cache_elem); /* - * If it's a positive entry, bump its refcount and return it. If - * it's negative, we can report failure to the caller. + * If it's a positive entry, bump its refcount and return it. If it's + * negative, we can report failure to the caller. */ if (!ct->negative) { @@ -1188,19 +1186,19 @@ SearchCatCache(CatCache *cache, } /* - * Tuple was not found in cache, so we have to try to retrieve it - * directly from the relation. If found, we will add it to the cache; - * if not found, we will add a negative cache entry instead. + * Tuple was not found in cache, so we have to try to retrieve it directly + * from the relation. If found, we will add it to the cache; if not + * found, we will add a negative cache entry instead. * - * NOTE: it is possible for recursive cache lookups to occur while - * reading the relation --- for example, due to shared-cache-inval - * messages being processed during heap_open(). This is OK. It's - * even possible for one of those lookups to find and enter the very - * same tuple we are trying to fetch here. If that happens, we will - * enter a second copy of the tuple into the cache. The first copy - * will never be referenced again, and will eventually age out of the - * cache, so there's no functional problem. This case is rare enough - * that it's not worth expending extra cycles to detect. + * NOTE: it is possible for recursive cache lookups to occur while reading + * the relation --- for example, due to shared-cache-inval messages being + * processed during heap_open(). This is OK. It's even possible for one + * of those lookups to find and enter the very same tuple we are trying to + * fetch here. If that happens, we will enter a second copy of the tuple + * into the cache. The first copy will never be referenced again, and + * will eventually age out of the cache, so there's no functional problem. + * This case is rare enough that it's not worth expending extra cycles to + * detect. */ relation = heap_open(cache->cc_reloid, AccessShareLock); @@ -1231,13 +1229,13 @@ SearchCatCache(CatCache *cache, /* * If tuple was not found, we need to build a negative cache entry - * containing a fake tuple. The fake tuple has the correct key - * columns, but nulls everywhere else. + * containing a fake tuple. The fake tuple has the correct key columns, + * but nulls everywhere else. * - * In bootstrap mode, we don't build negative entries, because the - * cache invalidation mechanism isn't alive and can't clear them - * if the tuple gets created later. (Bootstrap doesn't do UPDATEs, - * so it doesn't need cache inval for that.) + * In bootstrap mode, we don't build negative entries, because the cache + * invalidation mechanism isn't alive and can't clear them if the tuple + * gets created later. (Bootstrap doesn't do UPDATEs, so it doesn't need + * cache inval for that.) */ if (ct == NULL) { @@ -1256,8 +1254,8 @@ SearchCatCache(CatCache *cache, cache->cc_relname, hashIndex); /* - * We are not returning the negative entry to the caller, so leave - * its refcount zero. + * We are not returning the negative entry to the caller, so leave its + * refcount zero. */ return NULL; @@ -1331,7 +1329,7 @@ SearchCatCacheList(CatCache *cache, Dlelem *elt; CatCList *cl; CatCTup *ct; - List * volatile ctlist; + List *volatile ctlist; ListCell *ctlist_item; int nmembers; bool ordered; @@ -1362,8 +1360,8 @@ SearchCatCacheList(CatCache *cache, /* * compute a hash value of the given keys for faster search. We don't - * presently divide the CatCList items into buckets, but this still - * lets us skip non-matching items quickly most of the time. + * presently divide the CatCList items into buckets, but this still lets + * us skip non-matching items quickly most of the time. */ lHashValue = CatalogCacheComputeHashValue(cache, nkeys, cur_skey); @@ -1399,11 +1397,11 @@ SearchCatCacheList(CatCache *cache, /* * We found a matching list: mark it as touched since the last - * CatalogCacheCleanup() sweep. Also move the list to the front - * of the cache's list-of-lists, to speed subsequent searches. - * (We do not move the members to the fronts of their hashbucket - * lists, however, since there's no point in that unless they are - * searched for individually.) + * CatalogCacheCleanup() sweep. Also move the list to the front of + * the cache's list-of-lists, to speed subsequent searches. (We do not + * move the members to the fronts of their hashbucket lists, however, + * since there's no point in that unless they are searched for + * individually.) */ cl->touched = true; DLMoveToFront(&cl->cache_elem); @@ -1428,10 +1426,10 @@ SearchCatCacheList(CatCache *cache, * relation. For each matching tuple found in the relation, use an * existing cache entry if possible, else build a new one. * - * We have to bump the member refcounts temporarily to ensure they - * won't get dropped from the cache while loading other members. - * We use a PG_TRY block to ensure we can undo those refcounts if - * we get an error before we finish constructing the CatCList. + * We have to bump the member refcounts temporarily to ensure they won't get + * dropped from the cache while loading other members. We use a PG_TRY + * block to ensure we can undo those refcounts if we get an error before + * we finish constructing the CatCList. */ ResourceOwnerEnlargeCatCacheListRefs(CurrentResourceOwner); @@ -1473,13 +1471,13 @@ SearchCatCacheList(CatCache *cache, ct = (CatCTup *) DLE_VAL(elt); if (ct->dead || ct->negative) - continue; /* ignore dead and negative entries */ + continue; /* ignore dead and negative entries */ if (ct->hash_value != hashValue) - continue; /* quickly skip entry if wrong hash val */ + continue; /* quickly skip entry if wrong hash val */ if (!ItemPointerEquals(&(ct->tuple.t_self), &(ntp->t_self))) - continue; /* not same tuple */ + continue; /* not same tuple */ /* * Found a match, but can't use it if it belongs to another @@ -1526,9 +1524,9 @@ SearchCatCacheList(CatCache *cache, heap_freetuple(ntp); /* - * We are now past the last thing that could trigger an elog before - * we have finished building the CatCList and remembering it in the - * resource owner. So it's OK to fall out of the PG_TRY, and indeed + * We are now past the last thing that could trigger an elog before we + * have finished building the CatCList and remembering it in the + * resource owner. So it's OK to fall out of the PG_TRY, and indeed * we'd better do so before we start marking the members as belonging * to the list. */ @@ -1629,8 +1627,7 @@ CatalogCacheCreateEntry(CatCache *cache, HeapTuple ntp, MemoryContext oldcxt; /* - * Allocate CatCTup header in cache memory, and copy the tuple there - * too. + * Allocate CatCTup header in cache memory, and copy the tuple there too. */ oldcxt = MemoryContextSwitchTo(CacheMemoryContext); ct = (CatCTup *) palloc(sizeof(CatCTup)); @@ -1658,9 +1655,9 @@ CatalogCacheCreateEntry(CatCache *cache, HeapTuple ntp, CacheHdr->ch_ntup++; /* - * If we've exceeded the desired size of the caches, try to throw away - * the least recently used entry(s). NB: be careful not to throw away - * the newly-built entry... + * If we've exceeded the desired size of the caches, try to throw away the + * least recently used entry(s). NB: be careful not to throw away the + * newly-built entry... */ if (CacheHdr->ch_ntup > CacheHdr->ch_maxtup) CatalogCacheCleanup(ct); @@ -1684,22 +1681,22 @@ CatalogCacheCleanup(CatCTup *savect) *prevelt; /* - * Each time we have to do this, try to cut the cache size down to - * about 90% of the maximum. + * Each time we have to do this, try to cut the cache size down to about + * 90% of the maximum. */ tup_target = (CacheHdr->ch_maxtup * 9) / 10; /* - * Our strategy for managing CatCLists is that, each time we have to - * throw away some cache entries, we first move-to-front all the members - * of CatCLists that have been touched since the last cleanup sweep. - * Then we do strict LRU elimination by individual tuples, zapping a list - * if any of its members gets zapped. Before PostgreSQL 8.1, we moved - * members to front each time their owning list was touched, which was - * arguably more fair in balancing list members against standalone tuples - * --- but the overhead for large lists was horrendous. This scheme is - * more heavily biased towards preserving lists, but that is not - * necessarily bad either. + * Our strategy for managing CatCLists is that, each time we have to throw + * away some cache entries, we first move-to-front all the members of + * CatCLists that have been touched since the last cleanup sweep. Then we + * do strict LRU elimination by individual tuples, zapping a list if any + * of its members gets zapped. Before PostgreSQL 8.1, we moved members to + * front each time their owning list was touched, which was arguably more + * fair in balancing list members against standalone tuples --- but the + * overhead for large lists was horrendous. This scheme is more heavily + * biased towards preserving lists, but that is not necessarily bad + * either. */ for (ccp = CacheHdr->ch_caches; ccp; ccp = ccp->cc_next) { @@ -1710,7 +1707,7 @@ CatalogCacheCleanup(CatCTup *savect) Assert(cl->cl_magic == CL_MAGIC); if (cl->touched && !cl->dead) { - int i; + int i; for (i = 0; i < cl->n_members; i++) DLMoveToFront(&cl->members[i]->lrulist_elem); @@ -1775,9 +1772,9 @@ build_dummy_tuple(CatCache *cache, int nkeys, ScanKey skeys) if (attindex > 0) { /* - * Here we must be careful in case the caller passed a C - * string where a NAME is wanted: convert the given argument - * to a correctly padded NAME. Otherwise the memcpy() done in + * Here we must be careful in case the caller passed a C string + * where a NAME is wanted: convert the given argument to a + * correctly padded NAME. Otherwise the memcpy() done in * heap_formtuple could fall off the end of memory. */ if (cache->cc_isname[i]) @@ -1840,7 +1837,7 @@ build_dummy_tuple(CatCache *cache, int nkeys, ScanKey skeys) void PrepareToInvalidateCacheTuple(Relation relation, HeapTuple tuple, - void (*function) (int, uint32, ItemPointer, Oid)) + void (*function) (int, uint32, ItemPointer, Oid)) { CatCache *ccp; Oid reloid; diff --git a/src/backend/utils/cache/inval.c b/src/backend/utils/cache/inval.c index da0ffad16b..59250feac1 100644 --- a/src/backend/utils/cache/inval.c +++ b/src/backend/utils/cache/inval.c @@ -53,10 +53,10 @@ * * Also, whenever we see an operation on a pg_class or pg_attribute tuple, * we register a relcache flush operation for the relation described by that - * tuple. pg_class updates trigger an smgr flush operation as well. + * tuple. pg_class updates trigger an smgr flush operation as well. * * We keep the relcache and smgr flush requests in lists separate from the - * catcache tuple flush requests. This allows us to issue all the pending + * catcache tuple flush requests. This allows us to issue all the pending * catcache flushes before we issue relcache flushes, which saves us from * loading a catcache tuple during relcache load only to flush it again * right away. Also, we avoid queuing multiple relcache flush requests for @@ -80,7 +80,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/cache/inval.c,v 1.72 2005/06/17 22:32:46 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/cache/inval.c,v 1.73 2005/10/15 02:49:31 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -142,7 +142,7 @@ typedef struct TransInvalidationInfo struct TransInvalidationInfo *parent; /* Subtransaction nesting depth */ - int my_level; + int my_level; /* head of current-command event list */ InvalidationListHeader CurrentCmdInvalidMsgs; @@ -173,9 +173,9 @@ static struct CACHECALLBACK static int cache_callback_count = 0; /* info values for 2PC callback */ -#define TWOPHASE_INFO_MSG 0 /* SharedInvalidationMessage */ -#define TWOPHASE_INFO_FILE_BEFORE 1 /* relcache file inval */ -#define TWOPHASE_INFO_FILE_AFTER 2 /* relcache file inval */ +#define TWOPHASE_INFO_MSG 0 /* SharedInvalidationMessage */ +#define TWOPHASE_INFO_FILE_BEFORE 1 /* relcache file inval */ +#define TWOPHASE_INFO_FILE_AFTER 2 /* relcache file inval */ static void PersistInvalidationMessage(SharedInvalidationMessage *msg); @@ -208,7 +208,7 @@ AddInvalidationMessage(InvalidationChunk **listHdr, chunk = (InvalidationChunk *) MemoryContextAlloc(CurTransactionContext, sizeof(InvalidationChunk) + - (FIRSTCHUNKSIZE - 1) *sizeof(SharedInvalidationMessage)); + (FIRSTCHUNKSIZE - 1) *sizeof(SharedInvalidationMessage)); chunk->nitems = 0; chunk->maxitems = FIRSTCHUNKSIZE; chunk->next = *listHdr; @@ -222,7 +222,7 @@ AddInvalidationMessage(InvalidationChunk **listHdr, chunk = (InvalidationChunk *) MemoryContextAlloc(CurTransactionContext, sizeof(InvalidationChunk) + - (chunksize - 1) *sizeof(SharedInvalidationMessage)); + (chunksize - 1) *sizeof(SharedInvalidationMessage)); chunk->nitems = 0; chunk->maxitems = chunksize; chunk->next = *listHdr; @@ -316,7 +316,7 @@ AddRelcacheInvalidationMessage(InvalidationListHeader *hdr, ProcessMessageList(hdr->rclist, if (msg->rc.id == SHAREDINVALRELCACHE_ID && msg->rc.relId == relId) - return); + return); /* OK, add the item */ msg.rc.id = SHAREDINVALRELCACHE_ID; @@ -338,7 +338,7 @@ AddSmgrInvalidationMessage(InvalidationListHeader *hdr, ProcessMessageList(hdr->rclist, if (msg->sm.id == SHAREDINVALSMGR_ID && RelFileNodeEquals(msg->sm.rnode, rnode)) - return); + return); /* OK, add the item */ msg.sm.id = SHAREDINVALSMGR_ID; @@ -470,8 +470,8 @@ LocalExecuteInvalidationMessage(SharedInvalidationMessage *msg) else if (msg->id == SHAREDINVALSMGR_ID) { /* - * We could have smgr entries for relations of other databases, - * so no short-circuit test is possible here. + * We could have smgr entries for relations of other databases, so no + * short-circuit test is possible here. */ smgrclosenode(msg->sm.rnode); } @@ -523,17 +523,16 @@ PrepareForTupleInvalidation(Relation relation, HeapTuple tuple) return; /* - * We only need to worry about invalidation for tuples that are in - * system relations; user-relation tuples are never in catcaches and - * can't affect the relcache either. + * We only need to worry about invalidation for tuples that are in system + * relations; user-relation tuples are never in catcaches and can't affect + * the relcache either. */ if (!IsSystemRelation(relation)) return; /* - * TOAST tuples can likewise be ignored here. Note that TOAST tables - * are considered system relations so they are not filtered by the - * above test. + * TOAST tuples can likewise be ignored here. Note that TOAST tables are + * considered system relations so they are not filtered by the above test. */ if (IsToastRelation(relation)) return; @@ -561,16 +560,15 @@ PrepareForTupleInvalidation(Relation relation, HeapTuple tuple) databaseId = MyDatabaseId; /* - * We need to send out an smgr inval as well as a relcache inval. - * This is needed because other backends might possibly possess - * smgr cache but not relcache entries for the target relation. + * We need to send out an smgr inval as well as a relcache inval. This + * is needed because other backends might possibly possess smgr cache + * but not relcache entries for the target relation. * - * Note: during a pg_class row update that assigns a new - * relfilenode or reltablespace value, we will be called on both - * the old and new tuples, and thus will broadcast invalidation - * messages showing both the old and new RelFileNode values. This - * ensures that other backends will close smgr references to the - * old file. + * Note: during a pg_class row update that assigns a new relfilenode or + * reltablespace value, we will be called on both the old and new + * tuples, and thus will broadcast invalidation messages showing both + * the old and new RelFileNode values. This ensures that other + * backends will close smgr references to the old file. * * XXX possible future cleanup: it might be better to trigger smgr * flushes explicitly, rather than indirectly from pg_class updates. @@ -590,13 +588,12 @@ PrepareForTupleInvalidation(Relation relation, HeapTuple tuple) relationId = atttup->attrelid; /* - * KLUGE ALERT: we always send the relcache event with - * MyDatabaseId, even if the rel in question is shared (which we - * can't easily tell). This essentially means that only backends - * in this same database will react to the relcache flush request. - * This is in fact appropriate, since only those backends could - * see our pg_attribute change anyway. It looks a bit ugly - * though. + * KLUGE ALERT: we always send the relcache event with MyDatabaseId, + * even if the rel in question is shared (which we can't easily tell). + * This essentially means that only backends in this same database + * will react to the relcache flush request. This is in fact + * appropriate, since only those backends could see our pg_attribute + * change anyway. It looks a bit ugly though. */ databaseId = MyDatabaseId; } @@ -646,7 +643,7 @@ AtStart_Inval(void) /* * AtPrepare_Inval - * Save the inval lists state at 2PC transaction prepare. + * Save the inval lists state at 2PC transaction prepare. * * In this phase we just generate 2PC records for all the pending invalidation * work. @@ -658,8 +655,8 @@ AtPrepare_Inval(void) Assert(transInvalInfo != NULL && transInvalInfo->parent == NULL); /* - * Relcache init file invalidation requires processing both before - * and after we send the SI messages. + * Relcache init file invalidation requires processing both before and + * after we send the SI messages. */ if (transInvalInfo->RelcacheInitFileInval) RegisterTwoPhaseRecord(TWOPHASE_RM_INVAL_ID, TWOPHASE_INFO_FILE_BEFORE, @@ -678,7 +675,7 @@ AtPrepare_Inval(void) /* * PostPrepare_Inval - * Clean up after successful PREPARE. + * Clean up after successful PREPARE. * * Here, we want to act as though the transaction aborted, so that we will * undo any syscache changes it made, thereby bringing us into sync with the @@ -714,7 +711,7 @@ AtSubStart_Inval(void) /* * PersistInvalidationMessage - * Write an invalidation message to the 2PC state file. + * Write an invalidation message to the 2PC state file. */ static void PersistInvalidationMessage(SharedInvalidationMessage *msg) @@ -736,7 +733,7 @@ inval_twophase_postcommit(TransactionId xid, uint16 info, switch (info) { case TWOPHASE_INFO_MSG: - msg = (SharedInvalidationMessage *) recdata; + msg = (SharedInvalidationMessage *) recdata; Assert(len == sizeof(SharedInvalidationMessage)); SendSharedInvalidMessage(msg); break; @@ -786,15 +783,15 @@ AtEOXact_Inval(bool isCommit) Assert(transInvalInfo != NULL && transInvalInfo->parent == NULL); /* - * Relcache init file invalidation requires processing both before - * and after we send the SI messages. However, we need not do - * anything unless we committed. + * Relcache init file invalidation requires processing both before and + * after we send the SI messages. However, we need not do anything + * unless we committed. */ if (transInvalInfo->RelcacheInitFileInval) RelationCacheInitFileInvalidate(true); AppendInvalidationMessages(&transInvalInfo->PriorCmdInvalidMsgs, - &transInvalInfo->CurrentCmdInvalidMsgs); + &transInvalInfo->CurrentCmdInvalidMsgs); ProcessInvalidationMessages(&transInvalInfo->PriorCmdInvalidMsgs, SendSharedInvalidMessage); @@ -897,9 +894,9 @@ void CommandEndInvalidationMessages(void) { /* - * You might think this shouldn't be called outside any transaction, - * but bootstrap does it, and also ABORT issued when not in a - * transaction. So just quietly return if no state to work on. + * You might think this shouldn't be called outside any transaction, but + * bootstrap does it, and also ABORT issued when not in a transaction. So + * just quietly return if no state to work on. */ if (transInvalInfo == NULL) return; diff --git a/src/backend/utils/cache/lsyscache.c b/src/backend/utils/cache/lsyscache.c index ebb884dc25..096a3cb942 100644 --- a/src/backend/utils/cache/lsyscache.c +++ b/src/backend/utils/cache/lsyscache.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.128 2005/10/11 17:27:14 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.129 2005/10/15 02:49:31 momjian Exp $ * * NOTES * Eventually, the index information should go through here, too. @@ -149,10 +149,10 @@ get_op_hash_function(Oid opno) Oid opclass = InvalidOid; /* - * Search pg_amop to see if the target operator is registered as the - * "=" operator of any hash opclass. If the operator is registered in - * multiple opclasses, assume we can use the associated hash function - * from any one. + * Search pg_amop to see if the target operator is registered as the "=" + * operator of any hash opclass. If the operator is registered in + * multiple opclasses, assume we can use the associated hash function from + * any one. */ catlist = SearchSysCacheList(AMOPOPID, 1, ObjectIdGetDatum(opno), @@ -1223,9 +1223,9 @@ getTypeIOParam(HeapTuple typeTuple) Form_pg_type typeStruct = (Form_pg_type) GETSTRUCT(typeTuple); /* - * Array types get their typelem as parameter; everybody else gets - * their own type OID as parameter. (This is a change from 8.0, - * in which only composite types got their own OID as parameter.) + * Array types get their typelem as parameter; everybody else gets their + * own type OID as parameter. (This is a change from 8.0, in which only + * composite types got their own OID as parameter.) */ if (OidIsValid(typeStruct->typelem)) return typeStruct->typelem; @@ -1414,7 +1414,7 @@ get_typdefault(Oid typid) /* Convert C string to a value of the given type */ datum = OidFunctionCall3(type->typinput, CStringGetDatum(strDefaultVal), - ObjectIdGetDatum(getTypeIOParam(typeTuple)), + ObjectIdGetDatum(getTypeIOParam(typeTuple)), Int32GetDatum(-1)); /* Build a Const node containing the value */ expr = (Node *) makeConst(typid, @@ -1501,8 +1501,8 @@ get_typavgwidth(Oid typid, int32 typmod) { /* * For BPCHAR, the max width is also the only width. Otherwise we - * need to guess about the typical data width given the max. A - * sliding scale for percentage of max width seems reasonable. + * need to guess about the typical data width given the max. A sliding + * scale for percentage of max width seems reasonable. */ if (typid == BPCHAROID) return maxwidth; @@ -1513,8 +1513,8 @@ get_typavgwidth(Oid typid, int32 typmod) /* * Beyond 1000, assume we're looking at something like - * "varchar(10000)" where the limit isn't actually reached often, - * and use a fixed estimate. + * "varchar(10000)" where the limit isn't actually reached often, and + * use a fixed estimate. */ return 32 + (1000 - 32) / 2; } @@ -1905,9 +1905,9 @@ get_attstatsslot(HeapTuple statstuple, values, nvalues); /* - * If the element type is pass-by-reference, we now have a bunch - * of Datums that are pointers into the syscache value. Copy them - * to avoid problems if syscache decides to drop the entry. + * If the element type is pass-by-reference, we now have a bunch of + * Datums that are pointers into the syscache value. Copy them to + * avoid problems if syscache decides to drop the entry. */ if (!typeForm->typbyval) { @@ -1938,9 +1938,9 @@ get_attstatsslot(HeapTuple statstuple, statarray = DatumGetArrayTypeP(val); /* - * We expect the array to be a 1-D float4 array; verify that. We - * don't need to use deconstruct_array() since the array data is - * just going to look like a C array of float4 values. + * We expect the array to be a 1-D float4 array; verify that. We don't + * need to use deconstruct_array() since the array data is just going + * to look like a C array of float4 values. */ narrayelem = ARR_DIMS(statarray)[0]; if (ARR_NDIM(statarray) != 1 || narrayelem <= 0 || @@ -2038,7 +2038,7 @@ get_roleid(const char *rolname) Oid get_roleid_checked(const char *rolname) { - Oid roleid; + Oid roleid; roleid = get_roleid(rolname); if (!OidIsValid(roleid)) diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c index d74982dcb0..e877c1f828 100644 --- a/src/backend/utils/cache/relcache.c +++ b/src/backend/utils/cache/relcache.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.229 2005/09/16 04:13:18 neilc Exp $ + * $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.230 2005/10/15 02:49:31 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -192,7 +192,7 @@ static bool load_relcache_init_file(void); static void write_relcache_init_file(void); static void formrdesc(const char *relationName, Oid relationReltype, - bool hasoids, int natts, FormData_pg_attribute *att); + bool hasoids, int natts, FormData_pg_attribute *att); static HeapTuple ScanPgRelation(Oid targetRelId, bool indexOK); static Relation AllocateRelationDesc(Relation relation, Form_pg_class relp); @@ -241,9 +241,9 @@ ScanPgRelation(Oid targetRelId, bool indexOK) /* * Open pg_class and fetch a tuple. Force heap scan if we haven't yet - * built the critical relcache entries (this includes initdb and - * startup without a pg_internal.init file). The caller can also - * force a heap scan by setting indexOK == false. + * built the critical relcache entries (this includes initdb and startup + * without a pg_internal.init file). The caller can also force a heap + * scan by setting indexOK == false. */ pg_class_desc = heap_open(RelationRelationId, AccessShareLock); pg_class_scan = systable_beginscan(pg_class_desc, ClassOidIndexId, @@ -303,12 +303,11 @@ AllocateRelationDesc(Relation relation, Form_pg_class relp) /* * Copy the relation tuple form * - * We only allocate space for the fixed fields, ie, CLASS_TUPLE_SIZE. - * relacl is NOT stored in the relcache --- there'd be little point in - * it, since we don't copy the tuple's nullvalues bitmap and hence - * wouldn't know if the value is valid ... bottom line is that relacl - * *cannot* be retrieved from the relcache. Get it from the syscache - * if you need it. + * We only allocate space for the fixed fields, ie, CLASS_TUPLE_SIZE. relacl + * is NOT stored in the relcache --- there'd be little point in it, since + * we don't copy the tuple's nullvalues bitmap and hence wouldn't know if + * the value is valid ... bottom line is that relacl *cannot* be retrieved + * from the relcache. Get it from the syscache if you need it. */ relationForm = (Form_pg_class) palloc(CLASS_TUPLE_SIZE); @@ -355,8 +354,8 @@ RelationBuildTupleDesc(Relation relation) /* * Form a scan key that selects only user attributes (attnum > 0). - * (Eliminating system attribute rows at the index level is lots - * faster than fetching them.) + * (Eliminating system attribute rows at the index level is lots faster + * than fetching them.) */ ScanKeyInit(&skey[0], Anum_pg_attribute_attrelid, @@ -368,9 +367,9 @@ RelationBuildTupleDesc(Relation relation) Int16GetDatum(0)); /* - * Open pg_attribute and begin a scan. Force heap scan if we haven't - * yet built the critical relcache entries (this includes initdb and - * startup without a pg_internal.init file). + * Open pg_attribute and begin a scan. Force heap scan if we haven't yet + * built the critical relcache entries (this includes initdb and startup + * without a pg_internal.init file). */ pg_attribute_desc = heap_open(AttributeRelationId, AccessShareLock); pg_attribute_scan = systable_beginscan(pg_attribute_desc, @@ -445,9 +444,8 @@ RelationBuildTupleDesc(Relation relation) /* * However, we can easily set the attcacheoff value for the first - * attribute: it must be zero. This eliminates the need for special - * cases for attnum=1 that used to exist in fastgetattr() and - * index_getattr(). + * attribute: it must be zero. This eliminates the need for special cases + * for attnum=1 that used to exist in fastgetattr() and index_getattr(). */ if (relation->rd_rel->relnatts > 0) relation->rd_att->attrs[0]->attcacheoff = 0; @@ -477,7 +475,7 @@ RelationBuildTupleDesc(Relation relation) constr->num_check = relation->rd_rel->relchecks; constr->check = (ConstrCheck *) MemoryContextAllocZero(CacheMemoryContext, - constr->num_check * sizeof(ConstrCheck)); + constr->num_check * sizeof(ConstrCheck)); CheckConstraintFetch(relation); } else @@ -521,8 +519,8 @@ RelationBuildRuleLock(Relation relation) int maxlocks; /* - * Make the private context. Parameters are set on the assumption - * that it'll probably not contain much data. + * Make the private context. Parameters are set on the assumption that + * it'll probably not contain much data. */ rulescxt = AllocSetContextCreate(CacheMemoryContext, RelationGetRelationName(relation), @@ -532,8 +530,8 @@ RelationBuildRuleLock(Relation relation) relation->rd_rulescxt = rulescxt; /* - * allocate an array to hold the rewrite rules (the array is extended - * if necessary) + * allocate an array to hold the rewrite rules (the array is extended if + * necessary) */ maxlocks = 4; rules = (RewriteRule **) @@ -551,10 +549,10 @@ RelationBuildRuleLock(Relation relation) /* * open pg_rewrite and begin a scan * - * Note: since we scan the rules using RewriteRelRulenameIndexId, - * we will be reading the rules in name order, except possibly during - * emergency-recovery operations (ie, IsIgnoringSystemIndexes). This - * in turn ensures that rules will be fired in name order. + * Note: since we scan the rules using RewriteRelRulenameIndexId, we will be + * reading the rules in name order, except possibly during + * emergency-recovery operations (ie, IsIgnoringSystemIndexes). This in + * turn ensures that rules will be fired in name order. */ rewrite_desc = heap_open(RewriteRelationId, AccessShareLock); rewrite_tupdesc = RelationGetDescr(rewrite_desc); @@ -602,7 +600,7 @@ RelationBuildRuleLock(Relation relation) &isnull); Assert(!isnull); rule_evqual_str = DatumGetCString(DirectFunctionCall1(textout, - rule_evqual)); + rule_evqual)); oldcxt = MemoryContextSwitchTo(rulescxt); rule->qual = (Node *) stringToNode(rule_evqual_str); MemoryContextSwitchTo(oldcxt); @@ -647,8 +645,8 @@ equalRuleLocks(RuleLock *rlock1, RuleLock *rlock2) /* * As of 7.3 we assume the rule ordering is repeatable, because - * RelationBuildRuleLock should read 'em in a consistent order. So - * just compare corresponding slots. + * RelationBuildRuleLock should read 'em in a consistent order. So just + * compare corresponding slots. */ if (rlock1 != NULL) { @@ -717,8 +715,8 @@ RelationBuildDesc(Oid targetRelId, Relation oldrelation) relp = (Form_pg_class) GETSTRUCT(pg_class_tuple); /* - * allocate storage for the relation descriptor, and copy - * pg_class_tuple to relation->rd_rel. + * allocate storage for the relation descriptor, and copy pg_class_tuple + * to relation->rd_rel. */ relation = AllocateRelationDesc(oldrelation, relp); @@ -733,10 +731,9 @@ RelationBuildDesc(Oid targetRelId, Relation oldrelation) RelationGetRelid(relation) = relid; /* - * normal relations are not nailed into the cache; nor can a - * pre-existing relation be new. It could be temp though. (Actually, - * it could be new too, but it's okay to forget that fact if forced to - * flush the entry.) + * normal relations are not nailed into the cache; nor can a pre-existing + * relation be new. It could be temp though. (Actually, it could be new + * too, but it's okay to forget that fact if forced to flush the entry.) */ relation->rd_refcnt = 0; relation->rd_isnailed = false; @@ -834,9 +831,8 @@ RelationInitIndexAccessInfo(Relation relation) /* * Make a copy of the pg_index entry for the index. Since pg_index - * contains variable-length and possibly-null fields, we have to do - * this honestly rather than just treating it as a Form_pg_index - * struct. + * contains variable-length and possibly-null fields, we have to do this + * honestly rather than just treating it as a Form_pg_index struct. */ tuple = SearchSysCache(INDEXRELID, ObjectIdGetDatum(RelationGetRelid(relation)), @@ -851,9 +847,9 @@ RelationInitIndexAccessInfo(Relation relation) ReleaseSysCache(tuple); /* - * indclass cannot be referenced directly through the C struct, because - * it is after the variable-width indkey field. Therefore we extract - * the datum the hard way and provide a direct link in the relcache. + * indclass cannot be referenced directly through the C struct, because it + * is after the variable-width indkey field. Therefore we extract the + * datum the hard way and provide a direct link in the relcache. */ indclassDatum = fastgetattr(relation->rd_indextuple, Anum_pg_index_indclass, @@ -884,9 +880,9 @@ RelationInitIndexAccessInfo(Relation relation) amsupport = aform->amsupport; /* - * Make the private context to hold index access info. The reason we - * need a context, and not just a couple of pallocs, is so that we - * won't leak any subsidiary info attached to fmgr lookup records. + * Make the private context to hold index access info. The reason we need + * a context, and not just a couple of pallocs, is so that we won't leak + * any subsidiary info attached to fmgr lookup records. * * Context parameters are set on the assumption that it'll probably not * contain much data. @@ -931,7 +927,7 @@ RelationInitIndexAccessInfo(Relation relation) relation->rd_supportinfo = supportinfo; /* - * Fill the operator and support procedure OID arrays. (aminfo and + * Fill the operator and support procedure OID arrays. (aminfo and * supportinfo are left as zeroes, and are filled on-the-fly when used) */ IndexSupportInitialize(relation->rd_indclass, @@ -1070,17 +1066,17 @@ LookupOpclassInfo(Oid operatorClassOid, opcentry->supportProcs = NULL; /* - * To avoid infinite recursion during startup, force heap scans if - * we're looking up info for the opclasses used by the indexes we - * would like to reference here. + * To avoid infinite recursion during startup, force heap scans if we're + * looking up info for the opclasses used by the indexes we would like to + * reference here. */ indexOK = criticalRelcachesBuilt || (operatorClassOid != OID_BTREE_OPS_OID && operatorClassOid != INT2_BTREE_OPS_OID); /* - * Scan pg_amop to obtain operators for the opclass. We only fetch - * the default ones (those with subtype zero). + * Scan pg_amop to obtain operators for the opclass. We only fetch the + * default ones (those with subtype zero). */ if (numStrats > 0) { @@ -1113,8 +1109,8 @@ LookupOpclassInfo(Oid operatorClassOid, } /* - * Scan pg_amproc to obtain support procs for the opclass. We only - * fetch the default ones (those with subtype zero). + * Scan pg_amproc to obtain support procs for the opclass. We only fetch + * the default ones (those with subtype zero). */ if (numSupport > 0) { @@ -1193,8 +1189,8 @@ formrdesc(const char *relationName, Oid relationReltype, relation->rd_refcnt = 1; /* - * all entries built with this routine are nailed-in-cache; none are - * for new or temp relations. + * all entries built with this routine are nailed-in-cache; none are for + * new or temp relations. */ relation->rd_isnailed = true; relation->rd_createSubid = InvalidSubTransactionId; @@ -1203,9 +1199,9 @@ formrdesc(const char *relationName, Oid relationReltype, /* * initialize relation tuple form * - * The data we insert here is pretty incomplete/bogus, but it'll serve to - * get us launched. RelationCacheInitializePhase2() will read the - * real data from pg_class and replace what we've done here. + * The data we insert here is pretty incomplete/bogus, but it'll serve to get + * us launched. RelationCacheInitializePhase2() will read the real data + * from pg_class and replace what we've done here. */ relation->rd_rel = (Form_pg_class) palloc0(CLASS_TUPLE_SIZE); @@ -1214,10 +1210,9 @@ formrdesc(const char *relationName, Oid relationReltype, relation->rd_rel->reltype = relationReltype; /* - * It's important to distinguish between shared and non-shared - * relations, even at bootstrap time, to make sure we know where they - * are stored. At present, all relations that formrdesc is used for - * are not shared. + * It's important to distinguish between shared and non-shared relations, + * even at bootstrap time, to make sure we know where they are stored. At + * present, all relations that formrdesc is used for are not shared. */ relation->rd_rel->relisshared = false; @@ -1231,8 +1226,8 @@ formrdesc(const char *relationName, Oid relationReltype, * initialize attribute tuple form * * Unlike the case with the relation tuple, this data had better be right - * because it will never be replaced. The input values must be - * correctly defined by macros in src/include/catalog/ headers. + * because it will never be replaced. The input values must be correctly + * defined by macros in src/include/catalog/ headers. */ relation->rd_att = CreateTemplateTupleDesc(natts, hasoids); relation->rd_att->tdtypeid = relationReltype; @@ -1361,8 +1356,8 @@ RelationIdGetRelation(Oid relationId) return rd; /* - * no reldesc in the cache, so have RelationBuildDesc() build one and - * add it. + * no reldesc in the cache, so have RelationBuildDesc() build one and add + * it. */ rd = RelationBuildDesc(relationId, NULL); if (RelationIsValid(rd)) @@ -1454,11 +1449,12 @@ RelationReloadClassinfo(Relation relation) /* Should be called only for invalidated nailed indexes */ Assert(relation->rd_isnailed && !relation->rd_isvalid && relation->rd_rel->relkind == RELKIND_INDEX); + /* * Read the pg_class row * - * Don't try to use an indexscan of pg_class_oid_index to reload the - * info for pg_class_oid_index ... + * Don't try to use an indexscan of pg_class_oid_index to reload the info for + * pg_class_oid_index ... */ indexOK = (RelationGetRelid(relation) != ClassOidIndexId); pg_class_tuple = ScanPgRelation(RelationGetRelid(relation), indexOK); @@ -1492,25 +1488,25 @@ RelationClearRelation(Relation relation, bool rebuild) /* * Make sure smgr and lower levels close the relation's files, if they - * weren't closed already. If the relation is not getting deleted, - * the next smgr access should reopen the files automatically. This - * ensures that the low-level file access state is updated after, say, - * a vacuum truncation. + * weren't closed already. If the relation is not getting deleted, the + * next smgr access should reopen the files automatically. This ensures + * that the low-level file access state is updated after, say, a vacuum + * truncation. */ RelationCloseSmgr(relation); /* - * Never, never ever blow away a nailed-in system relation, because - * we'd be unable to recover. However, we must reset rd_targblock, in - * case we got called because of a relation cache flush that was - * triggered by VACUUM. + * Never, never ever blow away a nailed-in system relation, because we'd + * be unable to recover. However, we must reset rd_targblock, in case we + * got called because of a relation cache flush that was triggered by + * VACUUM. * - * If it's a nailed index, then we need to re-read the pg_class row to - * see if its relfilenode changed. We can't necessarily do that here, - * because we might be in a failed transaction. We assume it's okay - * to do it if there are open references to the relcache entry (cf - * notes for AtEOXact_RelationCache). Otherwise just mark the entry - * as possibly invalid, and it'll be fixed when next opened. + * If it's a nailed index, then we need to re-read the pg_class row to see if + * its relfilenode changed. We can't necessarily do that here, because we + * might be in a failed transaction. We assume it's okay to do it if + * there are open references to the relcache entry (cf notes for + * AtEOXact_RelationCache). Otherwise just mark the entry as possibly + * invalid, and it'll be fixed when next opened. */ if (relation->rd_isnailed) { @@ -1542,8 +1538,8 @@ RelationClearRelation(Relation relation, bool rebuild) * Free all the subsidiary data structures of the relcache entry. We * cannot free rd_att if we are trying to rebuild the entry, however, * because pointers to it may be cached in various places. The rule - * manager might also have pointers into the rewrite rules. So to - * begin with, we can only get rid of these fields: + * manager might also have pointers into the rewrite rules. So to begin + * with, we can only get rid of these fields: */ FreeTriggerDesc(relation->trigdesc); if (relation->rd_indextuple) @@ -1558,9 +1554,9 @@ RelationClearRelation(Relation relation, bool rebuild) /* * If we're really done with the relcache entry, blow it away. But if - * someone is still using it, reconstruct the whole deal without - * moving the physical RelationData record (so that the someone's - * pointer is still valid). + * someone is still using it, reconstruct the whole deal without moving + * the physical RelationData record (so that the someone's pointer is + * still valid). */ if (!rebuild) { @@ -1574,12 +1570,12 @@ RelationClearRelation(Relation relation, bool rebuild) else { /* - * When rebuilding an open relcache entry, must preserve ref count - * and rd_createSubid state. Also attempt to preserve the - * tupledesc and rewrite-rule substructures in place. + * When rebuilding an open relcache entry, must preserve ref count and + * rd_createSubid state. Also attempt to preserve the tupledesc and + * rewrite-rule substructures in place. * - * Note that this process does not touch CurrentResourceOwner; which - * is good because whatever ref counts the entry may have do not + * Note that this process does not touch CurrentResourceOwner; which is + * good because whatever ref counts the entry may have do not * necessarily belong to that resource owner. */ Oid save_relid = RelationGetRelid(relation); @@ -1773,8 +1769,8 @@ RelationCacheInvalidate(void) { /* * Add this entry to list of stuff to rebuild in second pass. - * pg_class_oid_index goes on the front of rebuildFirstList, - * other nailed indexes on the back, and everything else into + * pg_class_oid_index goes on the front of rebuildFirstList, other + * nailed indexes on the back, and everything else into * rebuildList (in no particular order). */ if (relation->rd_isnailed && @@ -1793,9 +1789,9 @@ RelationCacheInvalidate(void) rebuildList = list_concat(rebuildFirstList, rebuildList); /* - * Now zap any remaining smgr cache entries. This must happen before - * we start to rebuild entries, since that may involve catalog fetches - * which will re-open catalog files. + * Now zap any remaining smgr cache entries. This must happen before we + * start to rebuild entries, since that may involve catalog fetches which + * will re-open catalog files. */ smgrcloseall(); @@ -1832,13 +1828,13 @@ AtEOXact_RelationCache(bool isCommit) /* * To speed up transaction exit, we want to avoid scanning the relcache - * unless there is actually something for this routine to do. Other - * than the debug-only Assert checks, most transactions don't create - * any work for us to do here, so we keep a static flag that gets set - * if there is anything to do. (Currently, this means either a relation - * is created in the current xact, or an index list is forced.) For - * simplicity, the flag remains set till end of top-level transaction, - * even though we could clear it at subtransaction end in some cases. + * unless there is actually something for this routine to do. Other than + * the debug-only Assert checks, most transactions don't create any work + * for us to do here, so we keep a static flag that gets set if there is + * anything to do. (Currently, this means either a relation is created in + * the current xact, or an index list is forced.) For simplicity, the + * flag remains set till end of top-level transaction, even though we + * could clear it at subtransaction end in some cases. */ if (!need_eoxact_work #ifdef USE_ASSERT_CHECKING @@ -1857,10 +1853,9 @@ AtEOXact_RelationCache(bool isCommit) * The relcache entry's ref count should be back to its normal * not-in-a-transaction state: 0 unless it's nailed in cache. * - * In bootstrap mode, this is NOT true, so don't check it --- - * the bootstrap code expects relations to stay open across - * start/commit transaction calls. (That seems bogus, but it's - * not worth fixing.) + * In bootstrap mode, this is NOT true, so don't check it --- the + * bootstrap code expects relations to stay open across start/commit + * transaction calls. (That seems bogus, but it's not worth fixing.) */ #ifdef USE_ASSERT_CHECKING if (!IsBootstrapProcessingMode()) @@ -1939,8 +1934,8 @@ AtEOSubXact_RelationCache(bool isCommit, SubTransactionId mySubid, /* * Is it a relation created in the current subtransaction? * - * During subcommit, mark it as belonging to the parent, instead. - * During subabort, simply delete the relcache entry. + * During subcommit, mark it as belonging to the parent, instead. During + * subabort, simply delete the relcache entry. */ if (relation->rd_createSubid == mySubid) { @@ -2041,11 +2036,10 @@ RelationBuildLocalRelation(const char *relname, /* * create a new tuple descriptor from the one passed in. We do this - * partly to copy it into the cache context, and partly because the - * new relation can't have any defaults or constraints yet; they have - * to be added in later steps, because they require additions to - * multiple system catalogs. We can copy attnotnull constraints here, - * however. + * partly to copy it into the cache context, and partly because the new + * relation can't have any defaults or constraints yet; they have to be + * added in later steps, because they require additions to multiple system + * catalogs. We can copy attnotnull constraints here, however. */ rel->rd_att = CreateTupleDescCopy(tupDesc); has_not_null = false; @@ -2079,9 +2073,9 @@ RelationBuildLocalRelation(const char *relname, rel->rd_rel->relowner = BOOTSTRAP_SUPERUSERID; /* - * Insert relation physical and logical identifiers (OIDs) into the - * right places. Note that the physical ID (relfilenode) is initially - * the same as the logical ID (OID). + * Insert relation physical and logical identifiers (OIDs) into the right + * places. Note that the physical ID (relfilenode) is initially the same + * as the logical ID (OID). */ rel->rd_rel->relisshared = shared_relation; @@ -2157,8 +2151,8 @@ RelationCacheInitialize(void) /* * Try to load the relcache cache file. If successful, we're done for - * now. Otherwise, initialize the cache with pre-made descriptors for - * the critical "nailed-in" system catalogs. + * now. Otherwise, initialize the cache with pre-made descriptors for the + * critical "nailed-in" system catalogs. */ if (IsBootstrapProcessingMode() || !load_relcache_init_file()) @@ -2197,24 +2191,22 @@ RelationCacheInitializePhase2(void) return; /* - * If we didn't get the critical system indexes loaded into relcache, - * do so now. These are critical because the catcache depends on them - * for catcache fetches that are done during relcache load. Thus, we - * have an infinite-recursion problem. We can break the recursion by - * doing heapscans instead of indexscans at certain key spots. To - * avoid hobbling performance, we only want to do that until we have - * the critical indexes loaded into relcache. Thus, the flag - * criticalRelcachesBuilt is used to decide whether to do heapscan or - * indexscan at the key spots, and we set it true after we've loaded - * the critical indexes. + * If we didn't get the critical system indexes loaded into relcache, do + * so now. These are critical because the catcache depends on them for + * catcache fetches that are done during relcache load. Thus, we have an + * infinite-recursion problem. We can break the recursion by doing + * heapscans instead of indexscans at certain key spots. To avoid hobbling + * performance, we only want to do that until we have the critical indexes + * loaded into relcache. Thus, the flag criticalRelcachesBuilt is used to + * decide whether to do heapscan or indexscan at the key spots, and we set + * it true after we've loaded the critical indexes. * - * The critical indexes are marked as "nailed in cache", partly to make - * it easy for load_relcache_init_file to count them, but mainly - * because we cannot flush and rebuild them once we've set - * criticalRelcachesBuilt to true. (NOTE: perhaps it would be - * possible to reload them by temporarily setting - * criticalRelcachesBuilt to false again. For now, though, we just - * nail 'em in.) + * The critical indexes are marked as "nailed in cache", partly to make it + * easy for load_relcache_init_file to count them, but mainly because we + * cannot flush and rebuild them once we've set criticalRelcachesBuilt to + * true. (NOTE: perhaps it would be possible to reload them by + * temporarily setting criticalRelcachesBuilt to false again. For now, + * though, we just nail 'em in.) */ if (!criticalRelcachesBuilt) { @@ -2240,12 +2232,12 @@ RelationCacheInitializePhase2(void) } /* - * Now, scan all the relcache entries and update anything that might - * be wrong in the results from formrdesc or the relcache cache file. - * If we faked up relcache entries using formrdesc, then read the real - * pg_class rows and replace the fake entries with them. Also, if any - * of the relcache entries have rules or triggers, load that info the - * hard way since it isn't recorded in the cache file. + * Now, scan all the relcache entries and update anything that might be + * wrong in the results from formrdesc or the relcache cache file. If we + * faked up relcache entries using formrdesc, then read the real pg_class + * rows and replace the fake entries with them. Also, if any of the + * relcache entries have rules or triggers, load that info the hard way + * since it isn't recorded in the cache file. */ hash_seq_init(&status, RelationIdCache); @@ -2262,7 +2254,7 @@ RelationCacheInitializePhase2(void) Form_pg_class relp; htup = SearchSysCache(RELOID, - ObjectIdGetDatum(RelationGetRelid(relation)), + ObjectIdGetDatum(RelationGetRelid(relation)), 0, 0, 0); if (!HeapTupleIsValid(htup)) elog(FATAL, "cache lookup failed for relation %u", @@ -2311,11 +2303,10 @@ RelationCacheInitializePhase3(void) if (needNewCacheFile) { /* - * Force all the catcaches to finish initializing and thereby open - * the catalogs and indexes they use. This will preload the - * relcache with entries for all the most important system - * catalogs and indexes, so that the init file will be most useful - * for future backends. + * Force all the catcaches to finish initializing and thereby open the + * catalogs and indexes they use. This will preload the relcache with + * entries for all the most important system catalogs and indexes, so + * that the init file will be most useful for future backends. */ InitCatalogCachePhase2(); @@ -2349,7 +2340,7 @@ GetPgIndexDescriptor(void) oldcxt = MemoryContextSwitchTo(CacheMemoryContext); pgindexdesc = CreateTemplateTupleDesc(Natts_pg_index, false); - pgindexdesc->tdtypeid = RECORDOID; /* not right, but we don't care */ + pgindexdesc->tdtypeid = RECORDOID; /* not right, but we don't care */ pgindexdesc->tdtypmod = -1; for (i = 0; i < Natts_pg_index; i++) @@ -2405,7 +2396,7 @@ AttrDefaultFetch(Relation relation) continue; if (attrdef[i].adbin != NULL) elog(WARNING, "multiple attrdef records found for attr %s of rel %s", - NameStr(relation->rd_att->attrs[adform->adnum - 1]->attname), + NameStr(relation->rd_att->attrs[adform->adnum - 1]->attname), RelationGetRelationName(relation)); else found++; @@ -2415,12 +2406,12 @@ AttrDefaultFetch(Relation relation) adrel->rd_att, &isnull); if (isnull) elog(WARNING, "null adbin for attr %s of rel %s", - NameStr(relation->rd_att->attrs[adform->adnum - 1]->attname), + NameStr(relation->rd_att->attrs[adform->adnum - 1]->attname), RelationGetRelationName(relation)); else attrdef[i].adbin = MemoryContextStrdup(CacheMemoryContext, - DatumGetCString(DirectFunctionCall1(textout, - val))); + DatumGetCString(DirectFunctionCall1(textout, + val))); break; } @@ -2472,7 +2463,7 @@ CheckConstraintFetch(Relation relation) RelationGetRelationName(relation)); check[found].ccname = MemoryContextStrdup(CacheMemoryContext, - NameStr(conform->conname)); + NameStr(conform->conname)); /* Grab and test conbin is actually set */ val = fastgetattr(htup, @@ -2483,8 +2474,8 @@ CheckConstraintFetch(Relation relation) RelationGetRelationName(relation)); check[found].ccbin = MemoryContextStrdup(CacheMemoryContext, - DatumGetCString(DirectFunctionCall1(textout, - val))); + DatumGetCString(DirectFunctionCall1(textout, + val))); found++; } @@ -2514,7 +2505,7 @@ CheckConstraintFetch(Relation relation) * * Since shared cache inval causes the relcache's copy of the list to go away, * we return a copy of the list palloc'd in the caller's context. The caller - * may list_free() the returned list after scanning it. This is necessary + * may list_free() the returned list after scanning it. This is necessary * since the caller will typically be doing syscache lookups on the relevant * indexes, and syscache lookup could cause SI messages to be processed! * @@ -2539,10 +2530,10 @@ RelationGetIndexList(Relation relation) return list_copy(relation->rd_indexlist); /* - * We build the list we intend to return (in the caller's context) - * while doing the scan. After successfully completing the scan, we - * copy that list into the relcache entry. This avoids cache-context - * memory leakage if we get some sort of error partway through. + * We build the list we intend to return (in the caller's context) while + * doing the scan. After successfully completing the scan, we copy that + * list into the relcache entry. This avoids cache-context memory leakage + * if we get some sort of error partway through. */ result = NIL; oidIndex = InvalidOid; @@ -2662,9 +2653,9 @@ RelationGetOidIndex(Relation relation) List *ilist; /* - * If relation doesn't have OIDs at all, caller is probably confused. - * (We could just silently return InvalidOid, but it seems better to - * throw an assertion.) + * If relation doesn't have OIDs at all, caller is probably confused. (We + * could just silently return InvalidOid, but it seems better to throw an + * assertion.) */ Assert(relation->rd_rel->relhasoids); @@ -2707,10 +2698,9 @@ RelationGetIndexExpressions(Relation relation) return NIL; /* - * We build the tree we intend to return in the caller's context. - * After successfully completing the work, we copy it into the - * relcache entry. This avoids problems if we get some sort of error - * partway through. + * We build the tree we intend to return in the caller's context. After + * successfully completing the work, we copy it into the relcache entry. + * This avoids problems if we get some sort of error partway through. */ exprsDatum = heap_getattr(relation->rd_indextuple, Anum_pg_index_indexprs, @@ -2775,10 +2765,9 @@ RelationGetIndexPredicate(Relation relation) return NIL; /* - * We build the tree we intend to return in the caller's context. - * After successfully completing the work, we copy it into the - * relcache entry. This avoids problems if we get some sort of error - * partway through. + * We build the tree we intend to return in the caller's context. After + * successfully completing the work, we copy it into the relcache entry. + * This avoids problems if we get some sort of error partway through. */ predDatum = heap_getattr(relation->rd_indextuple, Anum_pg_index_indpred, @@ -2795,8 +2784,8 @@ RelationGetIndexPredicate(Relation relation) * will be comparing it to similarly-processed qual clauses, and may fail * to detect valid matches without this. This must match the processing * done to qual clauses in preprocess_expression()! (We can skip the - * stuff involving subqueries, however, since we don't allow any in - * index predicates.) + * stuff involving subqueries, however, since we don't allow any in index + * predicates.) */ result = (List *) eval_const_expressions((Node *) result); @@ -2897,9 +2886,9 @@ load_relcache_init_file(void) } /* - * Read the index relcache entries from the file. Note we will not - * enter any of them into the cache if the read fails partway through; - * this helps to guard against broken init files. + * Read the index relcache entries from the file. Note we will not enter + * any of them into the cache if the read fails partway through; this + * helps to guard against broken init files. */ max_rels = 100; rels = (Relation *) palloc(max_rels * sizeof(Relation)); @@ -3086,10 +3075,10 @@ load_relcache_init_file(void) /* * Rules and triggers are not saved (mainly because the internal - * format is complex and subject to change). They must be rebuilt - * if needed by RelationCacheInitializePhase2. This is not - * expected to be a big performance hit since few system catalogs - * have such. Ditto for index expressions and predicates. + * format is complex and subject to change). They must be rebuilt if + * needed by RelationCacheInitializePhase2. This is not expected to + * be a big performance hit since few system catalogs have such. + * Ditto for index expressions and predicates. */ rel->rd_rules = NULL; rel->rd_rulescxt = NULL; @@ -3114,17 +3103,17 @@ load_relcache_init_file(void) /* * Recompute lock and physical addressing info. This is needed in - * case the pg_internal.init file was copied from some other - * database by CREATE DATABASE. + * case the pg_internal.init file was copied from some other database + * by CREATE DATABASE. */ RelationInitLockInfo(rel); RelationInitPhysicalAddr(rel); } /* - * We reached the end of the init file without apparent problem. Did - * we get the right number of nailed items? (This is a useful - * crosscheck in case the set of critical rels or indexes changes.) + * We reached the end of the init file without apparent problem. Did we + * get the right number of nailed items? (This is a useful crosscheck in + * case the set of critical rels or indexes changes.) */ if (nailed_rels != NUM_CRITICAL_RELS || nailed_indexes != NUM_CRITICAL_INDEXES) @@ -3150,9 +3139,9 @@ load_relcache_init_file(void) return true; /* - * init file is broken, so do it the hard way. We don't bother trying - * to free the clutter we just allocated; it's not in the relcache so - * it won't hurt. + * init file is broken, so do it the hard way. We don't bother trying to + * free the clutter we just allocated; it's not in the relcache so it + * won't hurt. */ read_failed: pfree(rels); @@ -3180,8 +3169,8 @@ write_relcache_init_file(void) /* * We must write a temporary file and rename it into place. Otherwise, - * another backend starting at about the same time might crash trying - * to read the partially-complete file. + * another backend starting at about the same time might crash trying to + * read the partially-complete file. */ snprintf(tempfilename, sizeof(tempfilename), "%s/%s.%d", DatabasePath, RELCACHE_INIT_FILENAME, MyProcPid); @@ -3201,7 +3190,7 @@ write_relcache_init_file(void) (errcode_for_file_access(), errmsg("could not create relation-cache initialization file \"%s\": %m", tempfilename), - errdetail("Continuing anyway, but there's something wrong."))); + errdetail("Continuing anyway, but there's something wrong."))); return; } @@ -3308,11 +3297,11 @@ write_relcache_init_file(void) /* * Now we have to check whether the data we've so painstakingly - * accumulated is already obsolete due to someone else's - * just-committed catalog changes. If so, we just delete the temp - * file and leave it to the next backend to try again. (Our own - * relcache entries will be updated by SI message processing, but we - * can't be sure whether what we wrote out was up-to-date.) + * accumulated is already obsolete due to someone else's just-committed + * catalog changes. If so, we just delete the temp file and leave it to + * the next backend to try again. (Our own relcache entries will be + * updated by SI message processing, but we can't be sure whether what we + * wrote out was up-to-date.) * * This mustn't run concurrently with RelationCacheInitFileInvalidate, so * grab a serialization lock for the duration. @@ -3323,8 +3312,8 @@ write_relcache_init_file(void) AcceptInvalidationMessages(); /* - * If we have received any SI relcache invals since backend start, - * assume we may have written out-of-date data. + * If we have received any SI relcache invals since backend start, assume + * we may have written out-of-date data. */ if (relcacheInvalsReceived == 0L) { @@ -3332,10 +3321,10 @@ write_relcache_init_file(void) * OK, rename the temp file to its final name, deleting any * previously-existing init file. * - * Note: a failure here is possible under Cygwin, if some other - * backend is holding open an unlinked-but-not-yet-gone init file. - * So treat this as a noncritical failure; just remove the useless - * temp file on failure. + * Note: a failure here is possible under Cygwin, if some other backend + * is holding open an unlinked-but-not-yet-gone init file. So treat + * this as a noncritical failure; just remove the useless temp file on + * failure. */ if (rename(tempfilename, finalfilename) < 0) unlink(tempfilename); @@ -3401,11 +3390,10 @@ RelationCacheInitFileInvalidate(bool beforeSend) /* * We need to interlock this against write_relcache_init_file, to * guard against possibility that someone renames a new-but- - * already-obsolete init file into place just after we unlink. - * With the interlock, it's certain that write_relcache_init_file - * will notice our SI inval message before renaming into place, or - * else that we will execute second and successfully unlink the - * file. + * already-obsolete init file into place just after we unlink. With + * the interlock, it's certain that write_relcache_init_file will + * notice our SI inval message before renaming into place, or else + * that we will execute second and successfully unlink the file. */ LWLockAcquire(RelCacheInitLock, LW_EXCLUSIVE); unlink(initfilename); diff --git a/src/backend/utils/cache/syscache.c b/src/backend/utils/cache/syscache.c index cd24460857..1ee237fafd 100644 --- a/src/backend/utils/cache/syscache.c +++ b/src/backend/utils/cache/syscache.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/cache/syscache.c,v 1.100 2005/06/28 05:09:01 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/cache/syscache.c,v 1.101 2005/10/15 02:49:32 momjian Exp $ * * NOTES * These routines allow the parser/planner/executor to perform @@ -56,7 +56,7 @@ Add your entry to the cacheinfo[] array below. All cache lists are alphabetical, so add it in the proper place. Specify the relation - OID, index OID, number of keys, and key attribute numbers. If the + OID, index OID, number of keys, and key attribute numbers. If the relation contains tuples that are associated with a particular relation (for example, its attributes, rules, triggers, etc) then specify the attribute number that contains the OID of the associated relation. @@ -92,7 +92,7 @@ struct cachedesc }; static const struct cachedesc cacheinfo[] = { - {AggregateRelationId, /* AGGFNOID */ + {AggregateRelationId, /* AGGFNOID */ AggregateFnoidIndexId, 0, 1, @@ -102,7 +102,7 @@ static const struct cachedesc cacheinfo[] = { 0, 0 }}, - {AccessMethodRelationId, /* AMNAME */ + {AccessMethodRelationId, /* AMNAME */ AmNameIndexId, 0, 1, @@ -112,7 +112,7 @@ static const struct cachedesc cacheinfo[] = { 0, 0 }}, - {AccessMethodRelationId, /* AMOID */ + {AccessMethodRelationId, /* AMOID */ AmOidIndexId, 0, 1, @@ -152,7 +152,7 @@ static const struct cachedesc cacheinfo[] = { Anum_pg_amproc_amprocnum, 0 }}, - {AttributeRelationId, /* ATTNAME */ + {AttributeRelationId, /* ATTNAME */ AttributeRelidNameIndexId, Anum_pg_attribute_attrelid, 2, @@ -162,7 +162,7 @@ static const struct cachedesc cacheinfo[] = { 0, 0 }}, - {AttributeRelationId, /* ATTNUM */ + {AttributeRelationId, /* ATTNUM */ AttributeRelidNumIndexId, Anum_pg_attribute_attrelid, 2, @@ -172,7 +172,7 @@ static const struct cachedesc cacheinfo[] = { 0, 0 }}, - {AuthMemRelationId, /* AUTHMEMMEMROLE */ + {AuthMemRelationId, /* AUTHMEMMEMROLE */ AuthMemMemRoleIndexId, 0, 2, @@ -182,7 +182,7 @@ static const struct cachedesc cacheinfo[] = { 0, 0 }}, - {AuthMemRelationId, /* AUTHMEMROLEMEM */ + {AuthMemRelationId, /* AUTHMEMROLEMEM */ AuthMemRoleMemIndexId, 0, 2, @@ -192,7 +192,7 @@ static const struct cachedesc cacheinfo[] = { 0, 0 }}, - {AuthIdRelationId, /* AUTHNAME */ + {AuthIdRelationId, /* AUTHNAME */ AuthIdRolnameIndexId, 0, 1, @@ -202,7 +202,7 @@ static const struct cachedesc cacheinfo[] = { 0, 0 }}, - {AuthIdRelationId, /* AUTHOID */ + {AuthIdRelationId, /* AUTHOID */ AuthIdOidIndexId, 0, 1, @@ -213,7 +213,7 @@ static const struct cachedesc cacheinfo[] = { 0 }}, { - CastRelationId, /* CASTSOURCETARGET */ + CastRelationId, /* CASTSOURCETARGET */ CastSourceTargetIndexId, 0, 2, @@ -223,7 +223,7 @@ static const struct cachedesc cacheinfo[] = { 0, 0 }}, - {OperatorClassRelationId, /* CLAAMNAMENSP */ + {OperatorClassRelationId, /* CLAAMNAMENSP */ OpclassAmNameNspIndexId, 0, 3, @@ -233,7 +233,7 @@ static const struct cachedesc cacheinfo[] = { Anum_pg_opclass_opcnamespace, 0 }}, - {OperatorClassRelationId, /* CLAOID */ + {OperatorClassRelationId, /* CLAOID */ OpclassOidIndexId, 0, 1, @@ -243,7 +243,7 @@ static const struct cachedesc cacheinfo[] = { 0, 0 }}, - {ConversionRelationId, /* CONDEFAULT */ + {ConversionRelationId, /* CONDEFAULT */ ConversionDefaultIndexId, 0, 4, @@ -253,7 +253,7 @@ static const struct cachedesc cacheinfo[] = { Anum_pg_conversion_contoencoding, ObjectIdAttributeNumber, }}, - {ConversionRelationId, /* CONNAMENSP */ + {ConversionRelationId, /* CONNAMENSP */ ConversionNameNspIndexId, 0, 2, @@ -263,7 +263,7 @@ static const struct cachedesc cacheinfo[] = { 0, 0 }}, - {ConversionRelationId, /* CONOID */ + {ConversionRelationId, /* CONOID */ ConversionOidIndexId, 0, 1, @@ -273,7 +273,7 @@ static const struct cachedesc cacheinfo[] = { 0, 0 }}, - {IndexRelationId, /* INDEXRELID */ + {IndexRelationId, /* INDEXRELID */ IndexRelidIndexId, Anum_pg_index_indrelid, 1, @@ -283,7 +283,7 @@ static const struct cachedesc cacheinfo[] = { 0, 0 }}, - {InheritsRelationId, /* INHRELID */ + {InheritsRelationId, /* INHRELID */ InheritsRelidSeqnoIndexId, Anum_pg_inherits_inhrelid, 2, @@ -293,7 +293,7 @@ static const struct cachedesc cacheinfo[] = { 0, 0 }}, - {LanguageRelationId, /* LANGNAME */ + {LanguageRelationId, /* LANGNAME */ LanguageNameIndexId, 0, 1, @@ -303,7 +303,7 @@ static const struct cachedesc cacheinfo[] = { 0, 0 }}, - {LanguageRelationId, /* LANGOID */ + {LanguageRelationId, /* LANGOID */ LanguageOidIndexId, 0, 1, @@ -313,7 +313,7 @@ static const struct cachedesc cacheinfo[] = { 0, 0 }}, - {NamespaceRelationId, /* NAMESPACENAME */ + {NamespaceRelationId, /* NAMESPACENAME */ NamespaceNameIndexId, 0, 1, @@ -323,7 +323,7 @@ static const struct cachedesc cacheinfo[] = { 0, 0 }}, - {NamespaceRelationId, /* NAMESPACEOID */ + {NamespaceRelationId, /* NAMESPACEOID */ NamespaceOidIndexId, 0, 1, @@ -333,7 +333,7 @@ static const struct cachedesc cacheinfo[] = { 0, 0 }}, - {OperatorRelationId, /* OPERNAMENSP */ + {OperatorRelationId, /* OPERNAMENSP */ OperatorNameNspIndexId, 0, 4, @@ -343,7 +343,7 @@ static const struct cachedesc cacheinfo[] = { Anum_pg_operator_oprright, Anum_pg_operator_oprnamespace }}, - {OperatorRelationId, /* OPEROID */ + {OperatorRelationId, /* OPEROID */ OperatorOidIndexId, 0, 1, @@ -353,7 +353,7 @@ static const struct cachedesc cacheinfo[] = { 0, 0 }}, - {ProcedureRelationId, /* PROCNAMEARGSNSP */ + {ProcedureRelationId, /* PROCNAMEARGSNSP */ ProcedureNameArgsNspIndexId, 0, 3, @@ -363,7 +363,7 @@ static const struct cachedesc cacheinfo[] = { Anum_pg_proc_pronamespace, 0 }}, - {ProcedureRelationId, /* PROCOID */ + {ProcedureRelationId, /* PROCOID */ ProcedureOidIndexId, 0, 1, @@ -373,7 +373,7 @@ static const struct cachedesc cacheinfo[] = { 0, 0 }}, - {RelationRelationId, /* RELNAMENSP */ + {RelationRelationId, /* RELNAMENSP */ ClassNameNspIndexId, ObjectIdAttributeNumber, 2, @@ -383,7 +383,7 @@ static const struct cachedesc cacheinfo[] = { 0, 0 }}, - {RelationRelationId, /* RELOID */ + {RelationRelationId, /* RELOID */ ClassOidIndexId, ObjectIdAttributeNumber, 1, @@ -393,7 +393,7 @@ static const struct cachedesc cacheinfo[] = { 0, 0 }}, - {RewriteRelationId, /* RULERELNAME */ + {RewriteRelationId, /* RULERELNAME */ RewriteRelRulenameIndexId, Anum_pg_rewrite_ev_class, 2, @@ -403,7 +403,7 @@ static const struct cachedesc cacheinfo[] = { 0, 0 }}, - {StatisticRelationId, /* STATRELATT */ + {StatisticRelationId, /* STATRELATT */ StatisticRelidAttnumIndexId, Anum_pg_statistic_starelid, 2, @@ -413,7 +413,7 @@ static const struct cachedesc cacheinfo[] = { 0, 0 }}, - {TypeRelationId, /* TYPENAMENSP */ + {TypeRelationId, /* TYPENAMENSP */ TypeNameNspIndexId, Anum_pg_type_typrelid, 2, @@ -423,7 +423,7 @@ static const struct cachedesc cacheinfo[] = { 0, 0 }}, - {TypeRelationId, /* TYPEOID */ + {TypeRelationId, /* TYPEOID */ TypeOidIndexId, Anum_pg_type_typrelid, 1, @@ -435,7 +435,8 @@ static const struct cachedesc cacheinfo[] = { }} }; -static CatCache *SysCache[lengthof(cacheinfo)]; +static CatCache *SysCache[ + lengthof(cacheinfo)]; static int SysCacheSize = lengthof(cacheinfo); static bool CacheInitialized = false; @@ -697,10 +698,10 @@ SysCacheGetAttr(int cacheId, HeapTuple tup, bool *isNull) { /* - * We just need to get the TupleDesc out of the cache entry, and then - * we can apply heap_getattr(). We expect that the cache control data - * is currently valid --- if the caller recently fetched the tuple, - * then it should be. + * We just need to get the TupleDesc out of the cache entry, and then we + * can apply heap_getattr(). We expect that the cache control data is + * currently valid --- if the caller recently fetched the tuple, then it + * should be. */ if (cacheId < 0 || cacheId >= SysCacheSize) elog(ERROR, "invalid cache id: %d", cacheId); diff --git a/src/backend/utils/cache/typcache.c b/src/backend/utils/cache/typcache.c index b0b890516d..ff9cc97543 100644 --- a/src/backend/utils/cache/typcache.c +++ b/src/backend/utils/cache/typcache.c @@ -36,7 +36,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/cache/typcache.c,v 1.14 2005/05/29 04:23:06 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/cache/typcache.c,v 1.15 2005/10/15 02:49:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -135,9 +135,9 @@ lookup_type_cache(Oid type_id, int flags) if (typentry == NULL) { /* - * If we didn't find one, we want to make one. But first look up - * the pg_type row, just to make sure we don't make a cache entry - * for an invalid type OID. + * If we didn't find one, we want to make one. But first look up the + * pg_type row, just to make sure we don't make a cache entry for an + * invalid type OID. */ HeapTuple tp; Form_pg_type typtup; @@ -190,8 +190,8 @@ lookup_type_cache(Oid type_id, int flags) { /* * If we find a btree opclass where previously we only found a - * hash opclass, forget the hash equality operator so we can - * use the btree operator instead. + * hash opclass, forget the hash equality operator so we can use + * the btree operator instead. */ typentry->eq_opr = InvalidOid; typentry->eq_opr_finfo.fn_oid = InvalidOid; @@ -224,7 +224,7 @@ lookup_type_cache(Oid type_id, int flags) if (typentry->btree_opc != InvalidOid) typentry->gt_opr = get_opclass_member(typentry->btree_opc, InvalidOid, - BTGreaterStrategyNumber); + BTGreaterStrategyNumber); } if ((flags & (TYPECACHE_CMP_PROC | TYPECACHE_CMP_PROC_FINFO)) && typentry->cmp_proc == InvalidOid) @@ -238,9 +238,9 @@ lookup_type_cache(Oid type_id, int flags) /* * Set up fmgr lookup info as requested * - * Note: we tell fmgr the finfo structures live in CacheMemoryContext, - * which is not quite right (they're really in DynaHashContext) but - * this will do for our purposes. + * Note: we tell fmgr the finfo structures live in CacheMemoryContext, which + * is not quite right (they're really in DynaHashContext) but this will do + * for our purposes. */ if ((flags & TYPECACHE_EQ_OPR_FINFO) && typentry->eq_opr_finfo.fn_oid == InvalidOid && @@ -277,9 +277,9 @@ lookup_type_cache(Oid type_id, int flags) Assert(rel->rd_rel->reltype == typentry->type_id); /* - * Notice that we simply store a link to the relcache's tupdesc. - * Since we are relying on relcache to detect cache flush events, - * there's not a lot of point to maintaining an independent copy. + * Notice that we simply store a link to the relcache's tupdesc. Since + * we are relying on relcache to detect cache flush events, there's + * not a lot of point to maintaining an independent copy. */ typentry->tupDesc = RelationGetDescr(rel); @@ -316,12 +316,11 @@ lookup_default_opclass(Oid type_id, Oid am_id) * (either exactly or binary-compatibly, but prefer an exact match). * * We could find more than one binary-compatible match, in which case we - * require the user to specify which one he wants. If we find more - * than one exact match, then someone put bogus entries in pg_opclass. + * require the user to specify which one he wants. If we find more than + * one exact match, then someone put bogus entries in pg_opclass. * - * This is the same logic as GetDefaultOpClass() in indexcmds.c, except - * that we consider all opclasses, regardless of the current search - * path. + * This is the same logic as GetDefaultOpClass() in indexcmds.c, except that + * we consider all opclasses, regardless of the current search path. */ rel = heap_open(OperatorClassRelationId, AccessShareLock); @@ -361,8 +360,8 @@ lookup_default_opclass(Oid type_id, Oid am_id) if (nexact != 0) ereport(ERROR, (errcode(ERRCODE_DUPLICATE_OBJECT), - errmsg("there are multiple default operator classes for data type %s", - format_type_be(type_id)))); + errmsg("there are multiple default operator classes for data type %s", + format_type_be(type_id)))); if (ncompatible == 1) return compatibleOid; @@ -506,7 +505,7 @@ assign_record_type_typmod(TupleDesc tupDesc) int32 newlen = RecordCacheArrayLen * 2; RecordCacheArray = (TupleDesc *) repalloc(RecordCacheArray, - newlen * sizeof(TupleDesc)); + newlen * sizeof(TupleDesc)); RecordCacheArrayLen = newlen; } diff --git a/src/backend/utils/error/assert.c b/src/backend/utils/error/assert.c index 43205d07fd..d55c9d4f63 100644 --- a/src/backend/utils/error/assert.c +++ b/src/backend/utils/error/assert.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/error/assert.c,v 1.30 2004/12/31 22:01:27 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/utils/error/assert.c,v 1.31 2005/10/15 02:49:32 momjian Exp $ * * NOTE * This should eventually work with elog() @@ -42,8 +42,8 @@ ExceptionalCondition(char *conditionName, #ifdef SLEEP_ON_ASSERT /* - * It would be nice to use pg_usleep() here, but only does 2000 sec or - * 33 minutes, which seems too short. + * It would be nice to use pg_usleep() here, but only does 2000 sec or 33 + * minutes, which seems too short. */ sleep(1000000); #endif diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index d24242e840..b4f1000be8 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -25,7 +25,7 @@ * scenario of this sort is "out of memory"; and it's also the nastiest * to handle because we'd likely also run out of memory while trying to * report this error! Our escape hatch for this case is to reset the - * ErrorContext to empty before trying to process the inner error. Since + * ErrorContext to empty before trying to process the inner error. Since * ErrorContext is guaranteed to have at least 8K of space in it (see mcxt.c), * we should be able to process an "out of memory" message successfully. * Since we lose the prior error state due to the reset, we won't be able @@ -42,7 +42,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.164 2005/10/14 20:53:56 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.165 2005/10/15 02:49:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -188,8 +188,8 @@ errstart(int elevel, const char *filename, int lineno, /* * Now decide whether we need to process this report at all; if it's - * warning or less and not enabled for logging, just return FALSE - * without starting up any error logging machinery. + * warning or less and not enabled for logging, just return FALSE without + * starting up any error logging machinery. */ /* Determine whether message is enabled for server log output */ @@ -256,8 +256,8 @@ errstart(int elevel, const char *filename, int lineno, MemoryContextReset(ErrorContext); /* - * If we recurse more than once, the problem might be something - * broken in a context traceback routine. Abandon them too. + * If we recurse more than once, the problem might be something broken + * in a context traceback routine. Abandon them too. */ if (recursion_depth > 2) error_context_stack = NULL; @@ -316,15 +316,15 @@ errfinish(int dummy,...) CHECK_STACK_DEPTH(); /* - * Do processing in ErrorContext, which we hope has enough reserved - * space to report an error. + * Do processing in ErrorContext, which we hope has enough reserved space + * to report an error. */ oldcontext = MemoryContextSwitchTo(ErrorContext); /* * Call any context callback functions. Errors occurring in callback - * functions will be treated as recursive errors --- this ensures we - * will avoid infinite recursion (see errstart). + * functions will be treated as recursive errors --- this ensures we will + * avoid infinite recursion (see errstart). */ for (econtext = error_context_stack; econtext != NULL; @@ -333,34 +333,32 @@ errfinish(int dummy,...) /* * If ERROR (not more nor less) we pass it off to the current handler. - * Printing it and popping the stack is the responsibility of - * the handler. + * Printing it and popping the stack is the responsibility of the handler. */ if (elevel == ERROR) { /* - * We do some minimal cleanup before longjmp'ing so that handlers - * can execute in a reasonably sane state. + * We do some minimal cleanup before longjmp'ing so that handlers can + * execute in a reasonably sane state. */ /* This is just in case the error came while waiting for input */ ImmediateInterruptOK = false; /* - * Reset InterruptHoldoffCount in case we ereport'd from - * inside an interrupt holdoff section. (We assume here that - * no handler will itself be inside a holdoff section. If - * necessary, such a handler could save and restore - * InterruptHoldoffCount for itself, but this should make life - * easier for most.) + * Reset InterruptHoldoffCount in case we ereport'd from inside an + * interrupt holdoff section. (We assume here that no handler will + * itself be inside a holdoff section. If necessary, such a handler + * could save and restore InterruptHoldoffCount for itself, but this + * should make life easier for most.) */ InterruptHoldoffCount = 0; - CritSectionCount = 0; /* should be unnecessary, but... */ + CritSectionCount = 0; /* should be unnecessary, but... */ /* - * Note that we leave CurrentMemoryContext set to ErrorContext. - * The handler should reset it to something else soon. + * Note that we leave CurrentMemoryContext set to ErrorContext. The + * handler should reset it to something else soon. */ recursion_depth--; @@ -370,12 +368,11 @@ errfinish(int dummy,...) /* * If we are doing FATAL or PANIC, abort any old-style COPY OUT in * progress, so that we can report the message before dying. (Without - * this, pq_putmessage will refuse to send the message at all, which - * is what we want for NOTICE messages, but not for fatal exits.) This - * hack is necessary because of poor design of old-style copy - * protocol. Note we must do this even if client is fool enough to - * have set client_min_messages above FATAL, so don't look at - * output_to_client. + * this, pq_putmessage will refuse to send the message at all, which is + * what we want for NOTICE messages, but not for fatal exits.) This hack + * is necessary because of poor design of old-style copy protocol. Note + * we must do this even if client is fool enough to have set + * client_min_messages above FATAL, so don't look at output_to_client. */ if (elevel >= FATAL && whereToSendOutput == Remote) pq_endcopyout(true); @@ -412,28 +409,27 @@ errfinish(int dummy,...) ImmediateInterruptOK = false; /* - * If we just reported a startup failure, the client will - * disconnect on receiving it, so don't send any more to the - * client. + * If we just reported a startup failure, the client will disconnect + * on receiving it, so don't send any more to the client. */ if (PG_exception_stack == NULL && whereToSendOutput == Remote) whereToSendOutput = None; /* * fflush here is just to improve the odds that we get to see the - * error message, in case things are so hosed that proc_exit - * crashes. Any other code you might be tempted to add here - * should probably be in an on_proc_exit callback instead. + * error message, in case things are so hosed that proc_exit crashes. + * Any other code you might be tempted to add here should probably be + * in an on_proc_exit callback instead. */ fflush(stdout); fflush(stderr); /* - * If proc_exit is already running, we exit with nonzero exit code - * to indicate that something's pretty wrong. We also want to - * exit with nonzero exit code if not running under the postmaster - * (for example, if we are being run from the initdb script, we'd - * better return an error status). + * If proc_exit is already running, we exit with nonzero exit code to + * indicate that something's pretty wrong. We also want to exit with + * nonzero exit code if not running under the postmaster (for example, + * if we are being run from the initdb script, we'd better return an + * error status). */ proc_exit(proc_exit_inprogress || !IsUnderPostmaster); } @@ -441,8 +437,8 @@ errfinish(int dummy,...) if (elevel >= PANIC) { /* - * Serious crash time. Postmaster will observe nonzero process - * exit status and kill the other backends too. + * Serious crash time. Postmaster will observe nonzero process exit + * status and kill the other backends too. * * XXX: what if we are *in* the postmaster? abort() won't kill our * children... @@ -977,8 +973,8 @@ CopyErrorData(void) ErrorData *newedata; /* - * we don't increment recursion_depth because out-of-memory here does - * not indicate a problem within the error subsystem. + * we don't increment recursion_depth because out-of-memory here does not + * indicate a problem within the error subsystem. */ CHECK_STACK_DEPTH(); @@ -1037,9 +1033,9 @@ void FlushErrorState(void) { /* - * Reset stack to empty. The only case where it would be more than - * one deep is if we serviced an error that interrupted construction - * of another message. We assume control escaped out of that message + * Reset stack to empty. The only case where it would be more than one + * deep is if we serviced an error that interrupted construction of + * another message. We assume control escaped out of that message * construction and won't ever go back. */ errordata_stack_depth = -1; @@ -1117,7 +1113,7 @@ DebugFileOpen(void) 0666)) < 0) ereport(FATAL, (errcode_for_file_access(), - errmsg("could not open file \"%s\": %m", OutputFileName))); + errmsg("could not open file \"%s\": %m", OutputFileName))); istty = isatty(fd); close(fd); @@ -1131,17 +1127,17 @@ DebugFileOpen(void) OutputFileName))); /* - * If the file is a tty and we're running under the postmaster, - * try to send stdout there as well (if it isn't a tty then stderr - * will block out stdout, so we may as well let stdout go wherever - * it was going before). + * If the file is a tty and we're running under the postmaster, try to + * send stdout there as well (if it isn't a tty then stderr will block + * out stdout, so we may as well let stdout go wherever it was going + * before). */ if (istty && IsUnderPostmaster) if (!freopen(OutputFileName, "a", stdout)) ereport(FATAL, (errcode_for_file_access(), - errmsg("could not reopen file \"%s\" as stdout: %m", - OutputFileName))); + errmsg("could not reopen file \"%s\" as stdout: %m", + OutputFileName))); } } @@ -1156,13 +1152,13 @@ void set_syslog_parameters(const char *ident, int facility) { /* - * guc.c is likely to call us repeatedly with same parameters, so - * don't thrash the syslog connection unnecessarily. Also, we do not - * re-open the connection until needed, since this routine will get called - * whether or not Log_destination actually mentions syslog. + * guc.c is likely to call us repeatedly with same parameters, so don't + * thrash the syslog connection unnecessarily. Also, we do not re-open + * the connection until needed, since this routine will get called whether + * or not Log_destination actually mentions syslog. * - * Note that we make our own copy of the ident string rather than relying - * on guc.c's. This may be overly paranoid, but it ensures that we cannot + * Note that we make our own copy of the ident string rather than relying on + * guc.c's. This may be overly paranoid, but it ensures that we cannot * accidentally free a string that syslog is still using. */ if (syslog_ident == NULL || strcmp(syslog_ident, ident) != 0 || @@ -1212,13 +1208,12 @@ write_syslog(int level, const char *line) seq++; /* - * Our problem here is that many syslog implementations don't handle - * long messages in an acceptable manner. While this function doesn't - * help that fact, it does work around by splitting up messages into - * smaller pieces. + * Our problem here is that many syslog implementations don't handle long + * messages in an acceptable manner. While this function doesn't help that + * fact, it does work around by splitting up messages into smaller pieces. * - * We divide into multiple syslog() calls if message is too long - * or if the message contains embedded NewLine(s) '\n'. + * We divide into multiple syslog() calls if message is too long or if the + * message contains embedded NewLine(s) '\n'. */ len = strlen(line); if (len > PG_SYSLOG_LIMIT || strchr(line, '\n') != NULL) @@ -1290,7 +1285,7 @@ write_syslog(int level, const char *line) static void write_eventlog(int level, const char *line) { - int eventlevel = EVENTLOG_ERROR_TYPE; + int eventlevel = EVENTLOG_ERROR_TYPE; static HANDLE evtHandle = INVALID_HANDLE_VALUE; if (evtHandle == INVALID_HANDLE_VALUE) @@ -1356,9 +1351,9 @@ log_line_prefix(StringInfo buf) int i; /* - * This is one of the few places where we'd rather not inherit a - * static variable's value from the postmaster. But since we will, - * reset it when MyProcPid changes. + * This is one of the few places where we'd rather not inherit a static + * variable's value from the postmaster. But since we will, reset it when + * MyProcPid changes. */ if (log_my_pid != MyProcPid) { @@ -1412,8 +1407,8 @@ log_line_prefix(StringInfo buf) if (MyProcPort) { appendStringInfo(buf, "%lx.%x", - (long) (MyProcPort->session_start.tv_sec), - MyProcPid); + (long) (MyProcPort->session_start.tv_sec), + MyProcPid); } break; case 'p': @@ -1425,21 +1420,22 @@ log_line_prefix(StringInfo buf) case 'm': { /* - * Note: for %m, %t, and %s we deliberately use the - * C library's strftime/localtime, and not the - * equivalent functions from src/timezone. This - * ensures that all backends will report log entries - * in the same timezone, namely whatever C-library - * setting they inherit from the postmaster. If we - * used src/timezone then local settings of the - * TimeZone GUC variable would confuse the log. + * Note: for %m, %t, and %s we deliberately use the C + * library's strftime/localtime, and not the equivalent + * functions from src/timezone. This ensures that all + * backends will report log entries in the same timezone, + * namely whatever C-library setting they inherit from the + * postmaster. If we used src/timezone then local + * settings of the TimeZone GUC variable would confuse the + * log. */ - time_t stamp_time; - char strfbuf[128], msbuf[8]; + time_t stamp_time; + char strfbuf[128], + msbuf[8]; struct timeval tv; gettimeofday(&tv, NULL); - stamp_time = tv.tv_sec; + stamp_time = tv.tv_sec; strftime(strfbuf, sizeof(strfbuf), /* leave room for milliseconds... */ @@ -1452,8 +1448,8 @@ log_line_prefix(StringInfo buf) localtime(&stamp_time)); /* 'paste' milliseconds into place... */ - sprintf(msbuf, ".%03d", (int) (tv.tv_usec/1000)); - strncpy(strfbuf+19, msbuf, 4); + sprintf(msbuf, ".%03d", (int) (tv.tv_usec / 1000)); + strncpy(strfbuf + 19, msbuf, 4); appendStringInfoString(buf, strfbuf); } @@ -1535,7 +1531,7 @@ log_line_prefix(StringInfo buf) char * unpack_sql_state(int sql_state) { - static char buf[12]; + static char buf[12]; int i; for (i = 0; i < 5; i++) @@ -1629,8 +1625,7 @@ send_message_to_server_log(ErrorData *edata) } /* - * If the user wants the query that generated this error logged, do - * it. + * If the user wants the query that generated this error logged, do it. */ if (edata->elevel >= log_min_error_statement && debug_query_string != NULL) { @@ -1692,12 +1687,13 @@ send_message_to_server_log(ErrorData *edata) if ((Log_destination & LOG_DESTINATION_STDERR) || whereToSendOutput == Debug) { #ifdef WIN32 + /* * In a win32 service environment, there is no usable stderr. Capture * anything going there and write it to the eventlog instead. * - * If stderr redirection is active, it's ok to write to stderr - * because that's really a pipe to the syslogger process. + * If stderr redirection is active, it's ok to write to stderr because + * that's really a pipe to the syslogger process. */ if ((!Redirect_stderr || am_syslogger) && pgwin32_is_service()) write_eventlog(edata->elevel, buf.data); @@ -1847,12 +1843,12 @@ send_message_to_frontend(ErrorData *edata) pq_endmessage(&msgbuf); /* - * 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 ... + * 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 ... */ pq_flush(); } @@ -1887,9 +1883,9 @@ expand_fmt_string(const char *fmt, ErrorData *edata) if (*cp == 'm') { /* - * Replace %m by system error string. If there are any - * %'s in the string, we'd better double them so that - * vsnprintf won't misinterpret. + * Replace %m by system error string. If there are any %'s in + * the string, we'd better double them so that vsnprintf won't + * misinterpret. */ const char *cp2; @@ -1934,8 +1930,8 @@ useful_strerror(int errnum) str = strerror(errnum); /* - * Some strerror()s return an empty string for out-of-range errno. - * This is ANSI C spec compliant, but not exactly useful. + * Some strerror()s return an empty string for out-of-range errno. This is + * ANSI C spec compliant, but not exactly useful. */ if (str == NULL || *str == '\0') { diff --git a/src/backend/utils/fmgr/dfmgr.c b/src/backend/utils/fmgr/dfmgr.c index 3c33fbfa6f..2212f49fc4 100644 --- a/src/backend/utils/fmgr/dfmgr.c +++ b/src/backend/utils/fmgr/dfmgr.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.80 2005/05/11 01:26:02 neilc Exp $ + * $PostgreSQL: pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.81 2005/10/15 02:49:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -30,8 +30,8 @@ typedef struct df_files { struct df_files *next; /* List link */ dev_t device; /* Device file is on */ -#ifndef WIN32 /* ensures we never again depend on this - * under win32 */ +#ifndef WIN32 /* ensures we never again depend on this under + * win32 */ ino_t inode; /* Inode number of file */ #endif void *handle; /* a handle for pg_dl* functions */ @@ -200,8 +200,8 @@ load_file(char *filename) /* * 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. + * 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(fullname, &stat_buf) == -1) ereport(ERROR, @@ -209,8 +209,8 @@ load_file(char *filename) errmsg("could not access file \"%s\": %m", fullname))); /* - * We have to zap all entries in the list that match on either - * filename or inode, else load_external_function() won't do anything. + * We have to zap all entries in the list that match on either filename or + * inode, else load_external_function() won't do anything. */ prv = NULL; for (file_scanner = file_list; file_scanner != NULL; file_scanner = nxt) @@ -351,7 +351,7 @@ substitute_libpath_macro(const char *name) strncmp(name, "$libdir", strlen("$libdir")) != 0) ereport(ERROR, (errcode(ERRCODE_INVALID_NAME), - errmsg("invalid macro name in dynamic library path: %s", name))); + errmsg("invalid macro name in dynamic library path: %s", name))); ret = palloc(strlen(pkglib_path) + strlen(sep_ptr) + 1); diff --git a/src/backend/utils/fmgr/fmgr.c b/src/backend/utils/fmgr/fmgr.c index dd6134ccfd..4e5dcc3002 100644 --- a/src/backend/utils/fmgr/fmgr.c +++ b/src/backend/utils/fmgr/fmgr.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/fmgr/fmgr.c,v 1.96 2005/06/28 05:09:01 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/fmgr/fmgr.c,v 1.97 2005/10/15 02:49:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -41,9 +41,9 @@ * some warnings about int->pointer conversions... */ #if (defined(__mc68000__) || (defined(__m68k__))) && defined(__ELF__) -typedef int32 (*func_ptr) (); +typedef int32 (*func_ptr) (); #else -typedef char * (*func_ptr) (); +typedef char *(*func_ptr) (); #endif /* @@ -52,8 +52,8 @@ typedef char * (*func_ptr) (); typedef struct { func_ptr func; /* Address of the oldstyle function */ - bool arg_toastable[FUNC_MAX_ARGS]; /* is n'th arg of a - * toastable datatype? */ + bool arg_toastable[FUNC_MAX_ARGS]; /* is n'th arg of a toastable + * datatype? */ } Oldstyle_fnextra; /* @@ -95,8 +95,8 @@ fmgr_isbuiltin(Oid id) int high = fmgr_nbuiltins - 1; /* - * Loop invariant: low is the first index that could contain target - * entry, and high is the last index that could contain it. + * Loop invariant: low is the first index that could contain target entry, + * and high is the last index that could contain it. */ while (low <= high) { @@ -177,9 +177,9 @@ fmgr_info_cxt_security(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt, char *prosrc; /* - * fn_oid *must* be filled in last. Some code assumes that if fn_oid - * is valid, the whole struct is valid. Some FmgrInfo struct's do - * survive elogs. + * fn_oid *must* be filled in last. Some code assumes that if fn_oid is + * valid, the whole struct is valid. Some FmgrInfo struct's do survive + * elogs. */ finfo->fn_oid = InvalidOid; finfo->fn_extra = NULL; @@ -189,8 +189,7 @@ fmgr_info_cxt_security(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt, if ((fbp = fmgr_isbuiltin(functionId)) != 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_nargs = fbp->nargs; finfo->fn_strict = fbp->strict; @@ -227,11 +226,11 @@ fmgr_info_cxt_security(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt, /* * 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 can 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!) + * However, if the user has done a CREATE FUNCTION to create an + * alias for a builtin function, we can 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!) */ prosrcdatum = SysCacheGetAttr(PROCOID, procedureTuple, Anum_pg_proc_prosrc, &isnull); @@ -300,8 +299,7 @@ fmgr_info_C_lang(Oid functionId, FmgrInfo *finfo, HeapTuple procedureTuple) void *libraryhandle; /* - * Get prosrc and probin strings (link symbol and library - * filename) + * Get prosrc and probin strings (link symbol and library filename) */ prosrcattr = SysCacheGetAttr(PROCOID, procedureTuple, Anum_pg_proc_prosrc, &isnull); @@ -605,14 +603,13 @@ fmgr_oldstyle(PG_FUNCTION_ARGS) fnextra = (Oldstyle_fnextra *) fcinfo->flinfo->fn_extra; /* - * Result is NULL if any argument is NULL, but we still call the - * function (peculiar, but that's the way it worked before, and after - * all this is a backwards-compatibility wrapper). Note, however, - * that we'll never get here with NULL arguments if the function is - * marked strict. + * Result is NULL if any argument is NULL, but we still call the function + * (peculiar, but that's the way it worked before, and after all this is a + * backwards-compatibility wrapper). Note, however, that we'll never get + * here with NULL arguments if the function is marked strict. * - * We also need to detoast any TOAST-ed inputs, since it's unlikely that - * an old-style function knows about TOASTing. + * We also need to detoast any TOAST-ed inputs, since it's unlikely that an + * old-style function knows about TOASTing. */ isnull = false; for (i = 0; i < n_arguments; i++) @@ -634,9 +631,9 @@ fmgr_oldstyle(PG_FUNCTION_ARGS) case 1: /* - * nullvalue() used to use isNull to check if arg is NULL; - * perhaps there are other functions still out there that also - * rely on this undocumented hack? + * nullvalue() used to use isNull to check if arg is NULL; perhaps + * there are other functions still out there that also rely on + * this undocumented hack? */ returnValue = (*user_fn) (fcinfo->arg[0], &fcinfo->isnull); break; @@ -744,16 +741,16 @@ fmgr_oldstyle(PG_FUNCTION_ARGS) default: /* - * Increasing FUNC_MAX_ARGS doesn't automatically add cases to - * the above code, so mention the actual value in this error - * not FUNC_MAX_ARGS. You could add cases to the above if you - * needed to support old-style functions with many arguments, - * but making 'em be new-style is probably a better idea. + * Increasing FUNC_MAX_ARGS doesn't automatically add cases to the + * above code, so mention the actual value in this error not + * FUNC_MAX_ARGS. You could add cases to the above if you needed + * to support old-style functions with many arguments, but making + * 'em be new-style is probably a better idea. */ ereport(ERROR, (errcode(ERRCODE_TOO_MANY_ARGUMENTS), - errmsg("function %u has too many arguments (%d, maximum is %d)", - fcinfo->flinfo->fn_oid, n_arguments, 16))); + errmsg("function %u has too many arguments (%d, maximum is %d)", + fcinfo->flinfo->fn_oid, n_arguments, 16))); returnValue = NULL; /* keep compiler quiet */ break; } @@ -769,7 +766,7 @@ fmgr_oldstyle(PG_FUNCTION_ARGS) struct fmgr_security_definer_cache { FmgrInfo flinfo; - Oid userid; + Oid userid; }; /* @@ -785,8 +782,8 @@ fmgr_security_definer(PG_FUNCTION_ARGS) { Datum result; FmgrInfo *save_flinfo; - struct fmgr_security_definer_cache * volatile fcache; - Oid save_userid; + struct fmgr_security_definer_cache *volatile fcache; + Oid save_userid; HeapTuple tuple; if (!fcinfo->flinfo->fn_extra) @@ -1719,8 +1716,8 @@ fmgr(Oid procedureId,...) if (n_arguments > FUNC_MAX_ARGS) ereport(ERROR, (errcode(ERRCODE_TOO_MANY_ARGUMENTS), - errmsg("function %u has too many arguments (%d, maximum is %d)", - flinfo.fn_oid, n_arguments, FUNC_MAX_ARGS))); + errmsg("function %u has too many arguments (%d, maximum is %d)", + flinfo.fn_oid, n_arguments, FUNC_MAX_ARGS))); va_start(pvar, procedureId); for (i = 0; i < n_arguments; i++) fcinfo.arg[i] = (Datum) va_arg(pvar, char *); @@ -1760,10 +1757,10 @@ Int64GetDatum(int64 X) #else /* INT64_IS_BUSTED */ /* - * On a machine with no 64-bit-int C datatype, sizeof(int64) will not - * be 8, but we want Int64GetDatum to return an 8-byte object anyway, - * with zeroes in the unused bits. This is needed so that, for - * example, hash join of int8 will behave properly. + * On a machine with no 64-bit-int C datatype, sizeof(int64) will not be + * 8, but we want Int64GetDatum to return an 8-byte object anyway, with + * zeroes in the unused bits. This is needed so that, for example, hash + * join of int8 will behave properly. */ int64 *retval = (int64 *) palloc0(Max(sizeof(int64), 8)); @@ -1846,8 +1843,8 @@ get_fn_expr_rettype(FmgrInfo *flinfo) Node *expr; /* - * can't return anything useful if we have no FmgrInfo or if its - * fn_expr node has not been initialized + * can't return anything useful if we have no FmgrInfo or if its fn_expr + * node has not been initialized */ if (!flinfo || !flinfo->fn_expr) return InvalidOid; @@ -1866,8 +1863,8 @@ Oid get_fn_expr_argtype(FmgrInfo *flinfo, int argnum) { /* - * can't return anything useful if we have no FmgrInfo or if its - * fn_expr node has not been initialized + * can't return anything useful if we have no FmgrInfo or if its fn_expr + * node has not been initialized */ if (!flinfo || !flinfo->fn_expr) return InvalidOid; @@ -1909,8 +1906,8 @@ get_call_expr_argtype(Node *expr, int argnum) argtype = exprType((Node *) list_nth(args, argnum)); /* - * special hack for ScalarArrayOpExpr: what the underlying function - * will actually get passed is the element type of the array. + * special hack for ScalarArrayOpExpr: what the underlying function will + * actually get passed is the element type of the array. */ if (IsA(expr, ScalarArrayOpExpr) && argnum == 1) diff --git a/src/backend/utils/fmgr/funcapi.c b/src/backend/utils/fmgr/funcapi.c index 598168a70a..0a51f7ae0f 100644 --- a/src/backend/utils/fmgr/funcapi.c +++ b/src/backend/utils/fmgr/funcapi.c @@ -7,7 +7,7 @@ * Copyright (c) 2002-2005, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/fmgr/funcapi.c,v 1.25 2005/10/06 19:51:15 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/fmgr/funcapi.c,v 1.26 2005/10/15 02:49:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -29,13 +29,13 @@ static void shutdown_MultiFuncCall(Datum arg); static TypeFuncClass internal_get_result_type(Oid funcid, - Node *call_expr, - ReturnSetInfo *rsinfo, - Oid *resultTypeId, - TupleDesc *resultTupleDesc); + Node *call_expr, + ReturnSetInfo *rsinfo, + Oid *resultTypeId, + TupleDesc *resultTupleDesc); static bool resolve_polymorphic_tupdesc(TupleDesc tupdesc, - oidvector *declared_args, - Node *call_expr); + oidvector *declared_args, + Node *call_expr); static TypeFuncClass get_type_func_class(Oid typid); @@ -89,8 +89,8 @@ init_MultiFuncCall(PG_FUNCTION_ARGS) fcinfo->flinfo->fn_extra = retval; /* - * Ensure we will get shut down cleanly if the exprcontext is not - * run to completion. + * Ensure we will get shut down cleanly if the exprcontext is not run + * to completion. */ RegisterExprContextCallback(rsi->econtext, shutdown_MultiFuncCall, @@ -119,16 +119,16 @@ per_MultiFuncCall(PG_FUNCTION_ARGS) FuncCallContext *retval = (FuncCallContext *) fcinfo->flinfo->fn_extra; /* - * Clear the TupleTableSlot, if present. This is for safety's sake: - * the Slot will be in a long-lived context (it better be, if the + * Clear the TupleTableSlot, if present. This is for safety's sake: the + * Slot will be in a long-lived context (it better be, if the * FuncCallContext is pointing to it), but in most usage patterns the - * tuples stored in it will be in the function's per-tuple context. So - * at the beginning of each call, the Slot will hold a dangling - * pointer to an already-recycled tuple. We clear it out here. + * tuples stored in it will be in the function's per-tuple context. So at + * the beginning of each call, the Slot will hold a dangling pointer to an + * already-recycled tuple. We clear it out here. * * Note: use of retval->slot is obsolete as of 8.0, and we expect that it - * will always be NULL. This is just here for backwards compatibility - * in case someone creates a slot anyway. + * will always be NULL. This is just here for backwards compatibility in + * case someone creates a slot anyway. */ if (retval->slot != NULL) ExecClearTuple(retval->slot); @@ -168,8 +168,8 @@ shutdown_MultiFuncCall(Datum arg) flinfo->fn_extra = NULL; /* - * Caller is responsible to free up memory for individual struct - * elements other than att_in_funcinfo and elements. + * Caller is responsible to free up memory for individual struct elements + * other than att_in_funcinfo and elements. */ if (funcctx->attinmeta != NULL) pfree(funcctx->attinmeta); @@ -183,14 +183,14 @@ shutdown_MultiFuncCall(Datum arg) * Given a function's call info record, determine the kind of datatype * it is supposed to return. If resultTypeId isn't NULL, *resultTypeId * receives the actual datatype OID (this is mainly useful for scalar - * result types). If resultTupleDesc isn't NULL, *resultTupleDesc + * result types). If resultTupleDesc isn't NULL, *resultTupleDesc * receives a pointer to a TupleDesc when the result is of a composite * type, or NULL when it's a scalar result. NB: the tupledesc should * be copied if it is to be accessed over a long period. * * One hard case that this handles is resolution of actual rowtypes for * functions returning RECORD (from either the function's OUT parameter - * list, or a ReturnSetInfo context node). TYPEFUNC_RECORD is returned + * list, or a ReturnSetInfo context node). TYPEFUNC_RECORD is returned * only when we couldn't resolve the actual rowtype for lack of information. * * The other hard case that this handles is resolution of polymorphism. @@ -238,7 +238,7 @@ get_expr_result_type(Node *expr, else { /* handle as a generic expression; no chance to resolve RECORD */ - Oid typid = exprType(expr); + Oid typid = exprType(expr); if (resultTypeId) *resultTypeId = typid; @@ -273,7 +273,7 @@ get_func_result_type(Oid functionId, /* * internal_get_result_type -- workhorse code implementing all the above * - * funcid must always be supplied. call_expr and rsinfo can be NULL if not + * funcid must always be supplied. call_expr and rsinfo can be NULL if not * available. We will return TYPEFUNC_RECORD, and store NULL into * *resultTupleDesc, if we cannot deduce the complete result rowtype from * the available information. @@ -306,9 +306,9 @@ internal_get_result_type(Oid funcid, if (tupdesc) { /* - * It has OUT parameters, so it's basically like a regular - * composite type, except we have to be able to resolve any - * polymorphic OUT parameters. + * It has OUT parameters, so it's basically like a regular composite + * type, except we have to be able to resolve any polymorphic OUT + * parameters. */ if (resultTypeId) *resultTypeId = rettype; @@ -341,7 +341,7 @@ internal_get_result_type(Oid funcid, */ if (rettype == ANYARRAYOID || rettype == ANYELEMENTOID) { - Oid newrettype = exprType(call_expr); + Oid newrettype = exprType(call_expr); if (newrettype == InvalidOid) /* this probably should not happen */ ereport(ERROR, @@ -355,7 +355,7 @@ internal_get_result_type(Oid funcid, if (resultTypeId) *resultTypeId = rettype; if (resultTupleDesc) - *resultTupleDesc = NULL; /* default result */ + *resultTupleDesc = NULL; /* default result */ /* Classify the result type */ result = get_type_func_class(rettype); @@ -391,7 +391,7 @@ internal_get_result_type(Oid funcid, /* * Given the result tuple descriptor for a function with OUT parameters, * replace any polymorphic columns (ANYELEMENT/ANYARRAY) with correct data - * types deduced from the input arguments. Returns TRUE if able to deduce + * types deduced from the input arguments. Returns TRUE if able to deduce * all types, FALSE if not. */ static bool @@ -425,7 +425,7 @@ resolve_polymorphic_tupdesc(TupleDesc tupdesc, oidvector *declared_args, return true; /* - * Otherwise, extract actual datatype(s) from input arguments. (We assume + * Otherwise, extract actual datatype(s) from input arguments. (We assume * the parser already validated consistency of the arguments.) */ if (!call_expr) @@ -468,14 +468,14 @@ resolve_polymorphic_tupdesc(TupleDesc tupdesc, oidvector *declared_args, switch (tupdesc->attrs[i]->atttypid) { case ANYELEMENTOID: - TupleDescInitEntry(tupdesc, i+1, + TupleDescInitEntry(tupdesc, i + 1, NameStr(tupdesc->attrs[i]->attname), anyelement_type, -1, 0); break; case ANYARRAYOID: - TupleDescInitEntry(tupdesc, i+1, + TupleDescInitEntry(tupdesc, i + 1, NameStr(tupdesc->attrs[i]->attname), anyarray_type, -1, @@ -492,7 +492,7 @@ resolve_polymorphic_tupdesc(TupleDesc tupdesc, oidvector *declared_args, /* * Given the declared argument types and modes for a function, * replace any polymorphic types (ANYELEMENT/ANYARRAY) with correct data - * types deduced from the input arguments. Returns TRUE if able to deduce + * types deduced from the input arguments. Returns TRUE if able to deduce * all types, FALSE if not. This is the same logic as * resolve_polymorphic_tupdesc, but with a different argument representation. * @@ -513,7 +513,7 @@ resolve_polymorphic_argtypes(int numargs, Oid *argtypes, char *argmodes, inargno = 0; for (i = 0; i < numargs; i++) { - char argmode = argmodes ? argmodes[i] : PROARGMODE_IN; + char argmode = argmodes ? argmodes[i] : PROARGMODE_IN; switch (argtypes[i]) { @@ -612,10 +612,11 @@ get_type_func_class(Oid typid) case 'p': if (typid == RECORDOID) return TYPEFUNC_RECORD; + /* * We treat VOID and CSTRING as legitimate scalar datatypes, - * mostly for the convenience of the JDBC driver (which wants - * to be able to do "SELECT * FROM foo()" for all legitimately + * mostly for the convenience of the JDBC driver (which wants to + * be able to do "SELECT * FROM foo()" for all legitimately * user-callable functions). */ if (typid == VOIDOID || typid == CSTRINGOID) @@ -681,14 +682,14 @@ get_func_result_name(Oid functionId) * since the array data is just going to look like a C array of * values. */ - arr = DatumGetArrayTypeP(proargmodes); /* ensure not toasted */ + arr = DatumGetArrayTypeP(proargmodes); /* ensure not toasted */ numargs = ARR_DIMS(arr)[0]; if (ARR_NDIM(arr) != 1 || numargs < 0 || ARR_ELEMTYPE(arr) != CHAROID) elog(ERROR, "proargmodes is not a 1-D char array"); argmodes = (char *) ARR_DATA_PTR(arr); - arr = DatumGetArrayTypeP(proargnames); /* ensure not toasted */ + arr = DatumGetArrayTypeP(proargnames); /* ensure not toasted */ if (ARR_NDIM(arr) != 1 || ARR_DIMS(arr)[0] != numargs || ARR_ELEMTYPE(arr) != TEXTOID) @@ -769,7 +770,7 @@ build_function_result_tupdesc_t(HeapTuple procTuple) Anum_pg_proc_proargnames, &isnull); if (isnull) - proargnames = PointerGetDatum(NULL); /* just to be sure */ + proargnames = PointerGetDatum(NULL); /* just to be sure */ return build_function_result_tupdesc_d(proallargtypes, proargmodes, @@ -848,7 +849,7 @@ build_function_result_tupdesc_d(Datum proallargtypes, numoutargs = 0; for (i = 0; i < numargs; i++) { - char *pname; + char *pname; if (argmodes[i] == PROARGMODE_IN) continue; @@ -879,7 +880,7 @@ build_function_result_tupdesc_d(Datum proallargtypes, desc = CreateTemplateTupleDesc(numoutargs, false); for (i = 0; i < numoutargs; i++) { - TupleDescInitEntry(desc, i+1, + TupleDescInitEntry(desc, i + 1, outargnames[i], outargtypes[i], -1, @@ -986,7 +987,7 @@ TypeGetTupleDesc(Oid typeoid, List *colaliases) if (list_length(colaliases) != 1) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("number of aliases does not match number of columns"))); + errmsg("number of aliases does not match number of columns"))); /* OK, get the column alias */ attname = strVal(linitial(colaliases)); diff --git a/src/backend/utils/hash/dynahash.c b/src/backend/utils/hash/dynahash.c index 66be64a4e5..292673ac26 100644 --- a/src/backend/utils/hash/dynahash.c +++ b/src/backend/utils/hash/dynahash.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/hash/dynahash.c,v 1.64 2005/08/20 23:26:24 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/hash/dynahash.c,v 1.65 2005/10/15 02:49:33 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -115,14 +115,14 @@ hash_create(const char *tabname, long nelem, HASHCTL *info, int flags) HASHHDR *hctl; /* - * For shared hash tables, we have a local hash header (HTAB struct) - * that we allocate in TopMemoryContext; all else is in shared memory. + * For shared hash tables, we have a local hash header (HTAB struct) that + * we allocate in TopMemoryContext; all else is in shared memory. * - * For non-shared hash tables, everything including the hash header - * is in a memory context created specially for the hash table --- - * this makes hash_destroy very simple. The memory context is made - * a child of either a context specified by the caller, or - * TopMemoryContext if nothing is specified. + * For non-shared hash tables, everything including the hash header is in a + * memory context created specially for the hash table --- this makes + * hash_destroy very simple. The memory context is made a child of either + * a context specified by the caller, or TopMemoryContext if nothing is + * specified. */ if (flags & HASH_SHARED_MEM) { @@ -144,7 +144,7 @@ hash_create(const char *tabname, long nelem, HASHCTL *info, int flags) } /* Initialize the hash header, plus a copy of the table name */ - hashp = (HTAB *) DynaHashAlloc(sizeof(HTAB) + strlen(tabname) + 1); + hashp = (HTAB *) DynaHashAlloc(sizeof(HTAB) + strlen(tabname) +1); MemSet(hashp, 0, sizeof(HTAB)); hashp->tabname = (char *) (hashp + 1); @@ -156,10 +156,9 @@ hash_create(const char *tabname, long nelem, HASHCTL *info, int flags) hashp->hash = string_hash; /* default hash function */ /* - * If you don't specify a match function, it defaults to strncmp() if - * you used string_hash (either explicitly or by default) and to - * memcmp() otherwise. (Prior to PostgreSQL 7.4, memcmp() was always - * used.) + * If you don't specify a match function, it defaults to strncmp() if you + * used string_hash (either explicitly or by default) and to memcmp() + * otherwise. (Prior to PostgreSQL 7.4, memcmp() was always used.) */ if (flags & HASH_COMPARE) hashp->match = info->match; @@ -186,8 +185,8 @@ hash_create(const char *tabname, long nelem, HASHCTL *info, int flags) if (flags & HASH_SHARED_MEM) { /* - * ctl structure is preallocated for shared memory tables. Note - * that HASH_DIRSIZE and HASH_ALLOC had better be set as well. + * ctl structure is preallocated for shared memory tables. Note that + * HASH_DIRSIZE and HASH_ALLOC had better be set as well. */ hashp->hctl = info->hctl; hashp->dir = info->dir; @@ -243,8 +242,8 @@ hash_create(const char *tabname, long nelem, HASHCTL *info, int flags) } /* - * hash table now allocates space for key and data but you have to say - * how much space to allocate + * hash table now allocates space for key and data but you have to say how + * much space to allocate */ if (flags & HASH_ELEM) { @@ -318,8 +317,8 @@ init_htab(HTAB *hashp, long nelem) /* * 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 + * number of buckets. Allocate space for the next greater power of two + * number of buckets */ lnbuckets = (nelem - 1) / hctl->ffactor + 1; @@ -329,15 +328,14 @@ init_htab(HTAB *hashp, long 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) { @@ -418,7 +416,7 @@ hash_estimate_size(long num_entries, Size entrysize) size = add_size(size, mul_size(nDirEntries, sizeof(HASHSEGMENT))); /* segments */ size = add_size(size, mul_size(nSegments, - MAXALIGN(DEF_SEGSIZE * sizeof(HASHBUCKET)))); + MAXALIGN(DEF_SEGSIZE * sizeof(HASHBUCKET)))); /* elements --- allocated in groups of up to HASHELEMENT_ALLOC_MAX */ elementSize = MAXALIGN(sizeof(HASHELEMENT)) + MAXALIGN(entrysize); elementAllocCnt = Min(num_entries, HASHELEMENT_ALLOC_MAX); @@ -528,7 +526,7 @@ calc_bucket(HASHHDR *hctl, uint32 hash_val) * the result is a dangling pointer that shouldn't be dereferenced!) * * HASH_ENTER will normally ereport a generic "out of memory" error if - * it is unable to create a new entry. The HASH_ENTER_NULL operation is + * it is unable to create a new entry. The HASH_ENTER_NULL operation is * the same except it will return NULL if out of memory. Note that * HASH_ENTER_NULL cannot be used with the default palloc-based allocator, * since palloc internally ereports on out-of-memory. @@ -623,8 +621,8 @@ hash_search(HTAB *hashp, /* * better hope the caller is synchronizing access to this - * element, because someone else is going to reuse it the - * next time something is added to the table + * element, because someone else is going to reuse it the next + * time something is added to the table */ return (void *) ELEMENTKEY(currBucket); } @@ -680,9 +678,8 @@ hash_search(HTAB *hashp, if (++hctl->nentries / (long) (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); } @@ -731,7 +728,7 @@ hash_seq_search(HASH_SEQ_STATUS *status) { /* Continuing scan of curBucket... */ status->curEntry = curElem->link; - if (status->curEntry == NULL) /* end of this bucket */ + if (status->curEntry == NULL) /* end of this bucket */ ++status->curBucket; return (void *) ELEMENTKEY(curElem); } @@ -746,7 +743,7 @@ hash_seq_search(HASH_SEQ_STATUS *status) max_bucket = hctl->max_bucket; if (curBucket > max_bucket) - return NULL; /* search is done */ + return NULL; /* search is done */ /* * first find the right segment in the table directory. @@ -768,7 +765,7 @@ hash_seq_search(HASH_SEQ_STATUS *status) if (++curBucket > max_bucket) { status->curBucket = curBucket; - return NULL; /* search is done */ + return NULL; /* search is done */ } if (++segment_ndx >= ssize) { @@ -833,10 +830,9 @@ expand_table(HTAB *hashp) /* * *Before* changing masks, find old bucket corresponding to same hash - * values; values in that bucket may need to be relocated to new - * bucket. Note that new_bucket is certainly larger than low_mask at - * this point, so we can skip the first step of the regular hash mask - * calc. + * values; values in that bucket may need to be relocated to new bucket. + * Note that new_bucket is certainly larger than low_mask at this point, + * so we can skip the first step of the regular hash mask calc. */ old_bucket = (new_bucket & hctl->low_mask); @@ -850,10 +846,10 @@ expand_table(HTAB *hashp) } /* - * Relocate records to the new bucket. NOTE: because of the way the - * hash masking is done in calc_bucket, only one old bucket can need - * to be split at this point. With a different way of reducing the - * hash value, that might not be true! + * Relocate records to the new bucket. NOTE: because of the way the hash + * masking is done in calc_bucket, only one old bucket can need to be + * split at this point. With a different way of reducing the hash value, + * that might not be true! */ old_segnum = old_bucket >> hctl->sshift; old_segndx = MOD(old_bucket, hctl->ssize); diff --git a/src/backend/utils/hash/hashfn.c b/src/backend/utils/hash/hashfn.c index c596865816..43dac9daad 100644 --- a/src/backend/utils/hash/hashfn.c +++ b/src/backend/utils/hash/hashfn.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/hash/hashfn.c,v 1.24 2005/06/08 23:02:05 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/hash/hashfn.c,v 1.25 2005/10/15 02:49:33 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -64,7 +64,7 @@ uint32 bitmap_hash(const void *key, Size keysize) { Assert(keysize == sizeof(Bitmapset *)); - return bms_hash_value(*((const Bitmapset * const *) key)); + return bms_hash_value(*((const Bitmapset *const *) key)); } /* @@ -74,6 +74,6 @@ int bitmap_match(const void *key1, const void *key2, Size keysize) { Assert(keysize == sizeof(Bitmapset *)); - return !bms_equal(*((const Bitmapset * const *) key1), - *((const Bitmapset * const *) key2)); + return !bms_equal(*((const Bitmapset *const *) key1), + *((const Bitmapset *const *) key2)); } diff --git a/src/backend/utils/hash/pg_crc.c b/src/backend/utils/hash/pg_crc.c index 211da1aa72..2cfdff44e2 100644 --- a/src/backend/utils/hash/pg_crc.c +++ b/src/backend/utils/hash/pg_crc.c @@ -19,7 +19,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/hash/pg_crc.c,v 1.13 2005/06/02 05:55:29 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/hash/pg_crc.c,v 1.14 2005/10/15 02:49:33 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -378,7 +378,6 @@ const uint32 pg_crc64_table1[256] = { 0x5DEDC41A, 0x1F1D25F1, 0xD80C07CD, 0x9AFCE626 }; - #else /* int64 works */ const uint64 pg_crc64_table[256] = { @@ -511,7 +510,6 @@ const uint64 pg_crc64_table[256] = { UINT64CONST(0x5DEDC41A34BBEEB2), UINT64CONST(0x1F1D25F19D51D821), UINT64CONST(0xD80C07CD676F8394), UINT64CONST(0x9AFCE626CE85B507) }; - #endif /* INT64_IS_BUSTED */ -#endif /* PROVIDE_64BIT_CRC */ +#endif /* PROVIDE_64BIT_CRC */ diff --git a/src/backend/utils/init/flatfiles.c b/src/backend/utils/init/flatfiles.c index 7d9d2e6cb2..9906682c32 100644 --- a/src/backend/utils/init/flatfiles.c +++ b/src/backend/utils/init/flatfiles.c @@ -4,9 +4,9 @@ * Routines for maintaining "flat file" images of the shared catalogs. * * We use flat files so that the postmaster and not-yet-fully-started - * backends can look at the contents of pg_database, pg_authid, and - * pg_auth_members for authentication purposes. This module is - * responsible for keeping the flat-file images as nearly in sync with + * backends can look at the contents of pg_database, pg_authid, and + * pg_auth_members for authentication purposes. This module is + * responsible for keeping the flat-file images as nearly in sync with * database reality as possible. * * The tricky part of the write_xxx_file() routines in this module is that @@ -23,7 +23,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/utils/init/flatfiles.c,v 1.14 2005/08/11 21:11:46 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/init/flatfiles.c,v 1.15 2005/10/15 02:49:33 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -55,7 +55,7 @@ #define AUTH_FLAT_FILE "global/pg_auth" /* Info bits in a flatfiles 2PC record */ -#define FF_BIT_DATABASE 1 +#define FF_BIT_DATABASE 1 #define FF_BIT_AUTH 2 @@ -181,8 +181,8 @@ write_database_file(Relation drel) /* * Create a temporary filename to be renamed later. This prevents the - * backend from clobbering the flat file while the postmaster - * might be reading from it. + * backend from clobbering the flat file while the postmaster might be + * reading from it. */ filename = database_getflatfilename(); bufsize = strlen(filename) + 12; @@ -209,7 +209,7 @@ write_database_file(Relation drel) Oid datoid; Oid dattablespace; TransactionId datfrozenxid, - datvacuumxid; + datvacuumxid; datname = NameStr(dbform->datname); datoid = HeapTupleGetOid(tuple); @@ -219,7 +219,7 @@ write_database_file(Relation drel) /* * Identify the oldest datfrozenxid, ignoring databases that are not - * connectable (we assume they are safely frozen). This must match + * connectable (we assume they are safely frozen). This must match * the logic in vac_truncate_clog() in vacuum.c. */ if (dbform->datallowconn && @@ -262,8 +262,8 @@ write_database_file(Relation drel) tempname))); /* - * Rename the temp file to its final name, deleting the old flat file. - * We expect that rename(2) is an atomic action. + * Rename the temp file to its final name, deleting the old flat file. We + * expect that rename(2) is an atomic action. */ if (rename(tempname, filename)) ereport(ERROR, @@ -295,16 +295,18 @@ write_database_file(Relation drel) * and build data structures in-memory before writing the file. */ -typedef struct { +typedef struct +{ Oid roleid; bool rolcanlogin; - char* rolname; - char* rolpassword; - char* rolvaliduntil; - List* member_of; + char *rolname; + char *rolpassword; + char *rolvaliduntil; + List *member_of; } auth_entry; -typedef struct { +typedef struct +{ Oid roleid; Oid memberid; } authmem_entry; @@ -314,11 +316,13 @@ typedef struct { static int oid_compar(const void *a, const void *b) { - const auth_entry *a_auth = (const auth_entry*) a; - const auth_entry *b_auth = (const auth_entry*) b; + const auth_entry *a_auth = (const auth_entry *) a; + const auth_entry *b_auth = (const auth_entry *) b; - if (a_auth->roleid < b_auth->roleid) return -1; - if (a_auth->roleid > b_auth->roleid) return 1; + if (a_auth->roleid < b_auth->roleid) + return -1; + if (a_auth->roleid > b_auth->roleid) + return 1; return 0; } @@ -326,21 +330,23 @@ oid_compar(const void *a, const void *b) static int name_compar(const void *a, const void *b) { - const auth_entry *a_auth = (const auth_entry*) a; - const auth_entry *b_auth = (const auth_entry*) b; + const auth_entry *a_auth = (const auth_entry *) a; + const auth_entry *b_auth = (const auth_entry *) b; - return strcmp(a_auth->rolname,b_auth->rolname); + return strcmp(a_auth->rolname, b_auth->rolname); } /* qsort comparator for sorting authmem_entry array by memberid */ static int mem_compar(const void *a, const void *b) { - const authmem_entry *a_auth = (const authmem_entry*) a; - const authmem_entry *b_auth = (const authmem_entry*) b; + const authmem_entry *a_auth = (const authmem_entry *) a; + const authmem_entry *b_auth = (const authmem_entry *) b; - if (a_auth->memberid < b_auth->memberid) return -1; - if (a_auth->memberid > b_auth->memberid) return 1; + if (a_auth->memberid < b_auth->memberid) + return -1; + if (a_auth->memberid > b_auth->memberid) + return 1; return 0; } @@ -354,7 +360,7 @@ write_auth_file(Relation rel_authid, Relation rel_authmem) char *filename, *tempname; int bufsize; - BlockNumber totalblocks; + BlockNumber totalblocks; FILE *fp; mode_t oumask; HeapScanDesc scan; @@ -364,13 +370,13 @@ write_auth_file(Relation rel_authid, Relation rel_authmem) int curr_mem = 0; int total_mem = 0; int est_rows; - auth_entry *auth_info; + auth_entry *auth_info; authmem_entry *authmem_info; /* * Create a temporary filename to be renamed later. This prevents the - * backend from clobbering the flat file while the postmaster might - * be reading from it. + * backend from clobbering the flat file while the postmaster might be + * reading from it. */ filename = auth_getflatfilename(); bufsize = strlen(filename) + 12; @@ -387,29 +393,29 @@ write_auth_file(Relation rel_authid, Relation rel_authmem) tempname))); /* - * Read pg_authid and fill temporary data structures. Note we must - * read all roles, even those without rolcanlogin. + * Read pg_authid and fill temporary data structures. Note we must read + * all roles, even those without rolcanlogin. */ totalblocks = RelationGetNumberOfBlocks(rel_authid); totalblocks = totalblocks ? totalblocks : 1; - est_rows = totalblocks * (BLCKSZ / (sizeof(HeapTupleHeaderData)+sizeof(FormData_pg_authid))); - auth_info = (auth_entry*) palloc(est_rows*sizeof(auth_entry)); + est_rows = totalblocks * (BLCKSZ / (sizeof(HeapTupleHeaderData) + sizeof(FormData_pg_authid))); + auth_info = (auth_entry *) palloc(est_rows * sizeof(auth_entry)); scan = heap_beginscan(rel_authid, SnapshotNow, 0, NULL); while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL) { Form_pg_authid aform = (Form_pg_authid) GETSTRUCT(tuple); HeapTupleHeader tup = tuple->t_data; - char *tp; /* ptr to tuple data */ - long off; /* offset in tuple data */ + char *tp; /* ptr to tuple data */ + long off; /* offset in tuple data */ bits8 *bp = tup->t_bits; /* ptr to null bitmask in tuple */ Datum datum; if (curr_role >= est_rows) { est_rows *= 2; - auth_info = (auth_entry*) - repalloc(auth_info, est_rows*sizeof(auth_entry)); + auth_info = (auth_entry *) + repalloc(auth_info, est_rows * sizeof(auth_entry)); } auth_info[curr_role].roleid = HeapTupleGetOid(tuple); @@ -418,10 +424,10 @@ write_auth_file(Relation rel_authid, Relation rel_authmem) auth_info[curr_role].member_of = NIL; /* - * We can't use heap_getattr() here because during startup we will - * not have any tupdesc for pg_authid. Fortunately it's not too - * hard to work around this. rolpassword is the first possibly-null - * field so we can compute its offset directly. + * We can't use heap_getattr() here because during startup we will not + * have any tupdesc for pg_authid. Fortunately it's not too hard to + * work around this. rolpassword is the first possibly-null field so + * we can compute its offset directly. */ tp = (char *) tup + tup->t_hoff; off = offsetof(FormData_pg_authid, rolpassword); @@ -438,8 +444,8 @@ write_auth_file(Relation rel_authid, Relation rel_authmem) datum = PointerGetDatum(tp + off); /* - * The password probably shouldn't ever be out-of-line toasted; - * if it is, ignore it, since we can't handle that in startup mode. + * The password probably shouldn't ever be out-of-line toasted; if + * it is, ignore it, since we can't handle that in startup mode. */ if (VARATT_IS_EXTERNAL(DatumGetPointer(datum))) auth_info[curr_role].rolpassword = pstrdup(""); @@ -495,8 +501,8 @@ write_auth_file(Relation rel_authid, Relation rel_authmem) */ totalblocks = RelationGetNumberOfBlocks(rel_authmem); totalblocks = totalblocks ? totalblocks : 1; - est_rows = totalblocks * (BLCKSZ / (sizeof(HeapTupleHeaderData)+sizeof(FormData_pg_auth_members))); - authmem_info = (authmem_entry*) palloc(est_rows*sizeof(authmem_entry)); + est_rows = totalblocks * (BLCKSZ / (sizeof(HeapTupleHeaderData) + sizeof(FormData_pg_auth_members))); + authmem_info = (authmem_entry *) palloc(est_rows * sizeof(authmem_entry)); scan = heap_beginscan(rel_authmem, SnapshotNow, 0, NULL); while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL) @@ -506,8 +512,8 @@ write_auth_file(Relation rel_authid, Relation rel_authmem) if (curr_mem >= est_rows) { est_rows *= 2; - authmem_info = (authmem_entry*) - repalloc(authmem_info, est_rows*sizeof(authmem_entry)); + authmem_info = (authmem_entry *) + repalloc(authmem_info, est_rows * sizeof(authmem_entry)); } authmem_info[curr_mem].roleid = memform->roleid; @@ -518,8 +524,8 @@ write_auth_file(Relation rel_authid, Relation rel_authmem) heap_endscan(scan); /* - * Search for memberships. We can skip all this if pg_auth_members - * is empty. + * Search for memberships. We can skip all this if pg_auth_members is + * empty. */ if (total_mem > 0) { @@ -528,22 +534,23 @@ write_auth_file(Relation rel_authid, Relation rel_authmem) */ qsort(auth_info, total_roles, sizeof(auth_entry), oid_compar); qsort(authmem_info, total_mem, sizeof(authmem_entry), mem_compar); + /* * For each role, find what it belongs to. */ for (curr_role = 0; curr_role < total_roles; curr_role++) { - List *roles_list; - List *roles_names_list = NIL; - ListCell *mem; + List *roles_list; + List *roles_names_list = NIL; + ListCell *mem; /* We can skip this for non-login roles */ if (!auth_info[curr_role].rolcanlogin) continue; /* - * This search algorithm is the same as in is_member_of_role; - * we are just working with a different input data structure. + * This search algorithm is the same as in is_member_of_role; we + * are just working with a different input data structure. */ roles_list = list_make1_oid(auth_info[curr_role].roleid); @@ -551,17 +558,20 @@ write_auth_file(Relation rel_authid, Relation rel_authmem) { authmem_entry key; authmem_entry *found_mem; - int first_found, last_found, i; + int first_found, + last_found, + i; key.memberid = lfirst_oid(mem); found_mem = bsearch(&key, authmem_info, total_mem, sizeof(authmem_entry), mem_compar); if (!found_mem) continue; + /* - * bsearch found a match for us; but if there were - * multiple matches it could have found any one of them. - * Locate first and last match. + * bsearch found a match for us; but if there were multiple + * matches it could have found any one of them. Locate first + * and last match. */ first_found = last_found = (found_mem - authmem_info); while (first_found > 0 && @@ -570,30 +580,31 @@ write_auth_file(Relation rel_authid, Relation rel_authmem) while (last_found + 1 < total_mem && mem_compar(&key, &authmem_info[last_found + 1]) == 0) last_found++; + /* * Now add all the new roles to roles_list. */ for (i = first_found; i <= last_found; i++) roles_list = list_append_unique_oid(roles_list, - authmem_info[i].roleid); + authmem_info[i].roleid); } /* - * Convert list of role Oids to list of role names. - * We must do this before re-sorting auth_info. + * Convert list of role Oids to list of role names. We must do + * this before re-sorting auth_info. * - * We skip the first list element (curr_role itself) since there - * is no point in writing that a role is a member of itself. + * We skip the first list element (curr_role itself) since there is + * no point in writing that a role is a member of itself. */ for_each_cell(mem, lnext(list_head(roles_list))) { - auth_entry key_auth; + auth_entry key_auth; auth_entry *found_role; key_auth.roleid = lfirst_oid(mem); found_role = bsearch(&key_auth, auth_info, total_roles, sizeof(auth_entry), oid_compar); - if (found_role) /* paranoia */ + if (found_role) /* paranoia */ roles_names_list = lappend(roles_names_list, found_role->rolname); } @@ -613,7 +624,7 @@ write_auth_file(Relation rel_authid, Relation rel_authmem) if (arole->rolcanlogin) { - ListCell *mem; + ListCell *mem; fputs_quote(arole->rolname, fp); fputs(" ", fp); @@ -638,8 +649,8 @@ write_auth_file(Relation rel_authid, Relation rel_authmem) tempname))); /* - * Rename the temp file to its final name, deleting the old flat file. - * We expect that rename(2) is an atomic action. + * Rename the temp file to its final name, deleting the old flat file. We + * expect that rename(2) is an atomic action. */ if (rename(tempname, filename)) ereport(ERROR, @@ -671,11 +682,13 @@ BuildFlatFiles(bool database_only) { ResourceOwner owner; RelFileNode rnode; - Relation rel_db, rel_authid, rel_authmem; + Relation rel_db, + rel_authid, + rel_authmem; /* - * We don't have any hope of running a real relcache, but we can use - * the same fake-relcache facility that WAL replay uses. + * We don't have any hope of running a real relcache, but we can use the + * same fake-relcache facility that WAL replay uses. */ XLogInitRelationCache(); @@ -749,21 +762,21 @@ AtEOXact_UpdateFlatFiles(bool isCommit) } /* - * Advance command counter to be certain we see all effects of the - * current transaction. + * Advance command counter to be certain we see all effects of the current + * transaction. */ CommandCounterIncrement(); /* - * We use ExclusiveLock to ensure that only one backend writes the - * flat file(s) at a time. That's sufficient because it's okay to - * allow plain reads of the tables in parallel. There is some chance - * of a deadlock here (if we were triggered by a user update of one - * of the tables, which likely won't have gotten a strong enough lock), - * so get the locks we need before writing anything. + * We use ExclusiveLock to ensure that only one backend writes the flat + * file(s) at a time. That's sufficient because it's okay to allow plain + * reads of the tables in parallel. There is some chance of a deadlock + * here (if we were triggered by a user update of one of the tables, which + * likely won't have gotten a strong enough lock), so get the locks we + * need before writing anything. * - * For writing the auth file, it's sufficient to ExclusiveLock pg_authid; - * we take just regular AccessShareLock on pg_auth_members. + * For writing the auth file, it's sufficient to ExclusiveLock pg_authid; we + * take just regular AccessShareLock on pg_auth_members. */ if (database_file_update_subid != InvalidSubTransactionId) drel = heap_open(DatabaseRelationId, ExclusiveLock); @@ -863,7 +876,7 @@ AtEOSubXact_UpdateFlatFiles(bool isCommit, * or pg_auth_members via general-purpose INSERT/UPDATE/DELETE commands. * * It is sufficient for this to be a STATEMENT trigger since we don't - * care which individual rows changed. It doesn't much matter whether + * care which individual rows changed. It doesn't much matter whether * it's a BEFORE or AFTER trigger. */ Datum @@ -906,11 +919,11 @@ flatfile_twophase_postcommit(TransactionId xid, uint16 info, void *recdata, uint32 len) { /* - * Set flags to do the needed file updates at the end of my own - * current transaction. (XXX this has some issues if my own - * transaction later rolls back, or if there is any significant - * delay before I commit. OK for now because we disallow - * COMMIT PREPARED inside a transaction block.) + * Set flags to do the needed file updates at the end of my own current + * transaction. (XXX this has some issues if my own transaction later + * rolls back, or if there is any significant delay before I commit. OK + * for now because we disallow COMMIT PREPARED inside a transaction + * block.) */ if (info & FF_BIT_DATABASE) database_file_update_needed(); diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c index 148e260973..5c6f2f95d5 100644 --- a/src/backend/utils/init/miscinit.c +++ b/src/backend/utils/init/miscinit.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/init/miscinit.c,v 1.149 2005/08/17 22:14:33 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/init/miscinit.c,v 1.150 2005/10/15 02:49:33 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -37,7 +37,7 @@ #include "storage/ipc.h" #include "storage/pg_shmem.h" #include "storage/proc.h" -#include "storage/procarray.h" +#include "storage/procarray.h" #include "utils/builtins.h" #include "utils/guc.h" #include "utils/lsyscache.h" @@ -295,10 +295,10 @@ make_absolute_path(const char *path) * DEFINER functions, as well as locally in some specialized commands. * ---------------------------------------------------------------- */ -static Oid AuthenticatedUserId = InvalidOid; -static Oid SessionUserId = InvalidOid; -static Oid OuterUserId = InvalidOid; -static Oid CurrentUserId = InvalidOid; +static Oid AuthenticatedUserId = InvalidOid; +static Oid SessionUserId = InvalidOid; +static Oid OuterUserId = InvalidOid; +static Oid CurrentUserId = InvalidOid; /* We also have to remember the superuser state of some of these levels */ static bool AuthenticatedUserIsSuperuser = false; @@ -418,8 +418,8 @@ InitializeSessionUserId(const char *rolename) /* * These next checks are not enforced when in standalone mode, so that - * there is a way to recover from sillinesses like - * "UPDATE pg_authid SET rolcanlogin = false;". + * there is a way to recover from sillinesses like "UPDATE pg_authid SET + * rolcanlogin = false;". * * We do not enforce them for the autovacuum process either. */ @@ -433,15 +433,16 @@ InitializeSessionUserId(const char *rolename) (errcode(ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION), errmsg("role \"%s\" is not permitted to log in", rolename))); + /* * Check connection limit for this role. * * There is a race condition here --- we create our PGPROC before - * checking for other PGPROCs. If two backends did this at about the + * checking for other PGPROCs. If two backends did this at about the * same time, they might both think they were over the limit, while * ideally one should succeed and one fail. Getting that to work - * exactly seems more trouble than it is worth, however; instead - * we just document that the connection limit is approximate. + * exactly seems more trouble than it is worth, however; instead we + * just document that the connection limit is approximate. */ if (rform->rolconnlimit >= 0 && !AuthenticatedUserIsSuperuser && @@ -451,7 +452,7 @@ InitializeSessionUserId(const char *rolename) errmsg("too many connections for role \"%s\"", rolename))); } - + /* Record username and superuser status as GUC settings too */ SetConfigOption("session_authorization", rolename, PGC_BACKEND, PGC_S_OVERRIDE); @@ -460,9 +461,8 @@ InitializeSessionUserId(const char *rolename) PGC_INTERNAL, PGC_S_OVERRIDE); /* - * Set up user-specific configuration variables. This is a good place - * to do it so we don't have to read pg_authid twice during session - * startup. + * Set up user-specific configuration variables. This is a good place to + * do it so we don't have to read pg_authid twice during session startup. */ datum = SysCacheGetAttr(AUTHNAME, roleTup, Anum_pg_authid_rolconfig, &isnull); @@ -534,7 +534,7 @@ SetSessionAuthorization(Oid userid, bool is_superuser) !AuthenticatedUserIsSuperuser) ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), - errmsg("permission denied to set session authorization"))); + errmsg("permission denied to set session authorization"))); SetSessionUserId(userid, is_superuser); @@ -562,7 +562,7 @@ GetCurrentRoleId(void) * Change Role ID while running (SET ROLE) * * If roleid is InvalidOid, we are doing SET ROLE NONE: revert to the - * session user authorization. In this case the is_superuser argument + * session user authorization. In this case the is_superuser argument * is ignored. * * When roleid is not InvalidOid, the caller must have checked whether @@ -686,17 +686,17 @@ CreateLockFile(const char *filename, bool amPostmaster, pid_t my_pid = getpid(); /* - * We need a loop here because of race conditions. But don't loop - * forever (for example, a non-writable $PGDATA directory might cause - * a failure that won't go away). 100 tries seems like plenty. + * We need a loop here because of race conditions. But don't loop forever + * (for example, a non-writable $PGDATA directory might cause a failure + * that won't go away). 100 tries seems like plenty. */ for (ntries = 0;; ntries++) { /* * Try to create the lock file --- O_EXCL makes this atomic. * - * Think not to make the file protection weaker than 0600. See - * comments below. + * Think not to make the file protection weaker than 0600. See comments + * below. */ fd = open(filename, O_RDWR | O_CREAT | O_EXCL, 0600); if (fd >= 0) @@ -745,38 +745,38 @@ CreateLockFile(const char *filename, bool amPostmaster, /* * Check to see if the other process still exists * - * If the PID in the lockfile is our own PID or our parent's PID, - * then the file must be stale (probably left over from a previous - * system boot cycle). We need this test because of the likelihood - * that a reboot will assign exactly the same PID as we had in the - * previous reboot. Also, if there is just one more process launch - * in this reboot than in the previous one, the lockfile might mention - * our parent's PID. We can reject that since we'd never be launched - * directly by a competing postmaster. We can't detect grandparent - * processes unfortunately, but if the init script is written carefully - * then all but the immediate parent shell will be root-owned processes - * and so the kill test will fail with EPERM. + * If the PID in the lockfile is our own PID or our parent's PID, then + * the file must be stale (probably left over from a previous system + * boot cycle). We need this test because of the likelihood that a + * reboot will assign exactly the same PID as we had in the previous + * reboot. Also, if there is just one more process launch in this + * reboot than in the previous one, the lockfile might mention our + * parent's PID. We can reject that since we'd never be launched + * directly by a competing postmaster. We can't detect grandparent + * processes unfortunately, but if the init script is written + * carefully then all but the immediate parent shell will be + * root-owned processes and so the kill test will fail with EPERM. * * We can treat the EPERM-error case as okay because that error implies * that the existing process has a different userid than we do, which * means it cannot be a competing postmaster. A postmaster cannot * successfully attach to a data directory owned by a userid other - * than its own. (This is now checked directly in checkDataDir(), - * but has been true for a long time because of the restriction that - * the data directory isn't group- or world-accessible.) Also, - * since we create the lockfiles mode 600, we'd have failed above - * if the lockfile belonged to another userid --- which means that - * whatever process kill() is reporting about isn't the one that - * made the lockfile. (NOTE: this last consideration is the only - * one that keeps us from blowing away a Unix socket file belonging - * to an instance of Postgres being run by someone else, at least - * on machines where /tmp hasn't got a stickybit.) + * than its own. (This is now checked directly in checkDataDir(), but + * has been true for a long time because of the restriction that the + * data directory isn't group- or world-accessible.) Also, since we + * create the lockfiles mode 600, we'd have failed above if the + * lockfile belonged to another userid --- which means that whatever + * process kill() is reporting about isn't the one that made the + * lockfile. (NOTE: this last consideration is the only one that + * keeps us from blowing away a Unix socket file belonging to an + * instance of Postgres being run by someone else, at least on + * machines where /tmp hasn't got a stickybit.) * - * Windows hasn't got getppid(), but doesn't need it since it's not - * using real kill() either... + * Windows hasn't got getppid(), but doesn't need it since it's not using + * real kill() either... * - * Normally kill() will fail with ESRCH if the given PID doesn't - * exist. BeOS returns EINVAL for some silly reason, however. + * Normally kill() will fail with ESRCH if the given PID doesn't exist. + * BeOS returns EINVAL for some silly reason, however. */ if (other_pid != my_pid #ifndef WIN32 @@ -811,11 +811,11 @@ CreateLockFile(const char *filename, bool amPostmaster, } /* - * No, the creating process did not exist. However, it could be - * that the postmaster crashed (or more likely was kill -9'd by a - * clueless admin) but has left orphan backends behind. Check for - * this by looking to see if there is an associated shmem segment - * that is still in use. + * No, the creating process did not exist. However, it could be that + * the postmaster crashed (or more likely was kill -9'd by a clueless + * admin) but has left orphan backends behind. Check for this by + * looking to see if there is an associated shmem segment that is + * still in use. */ if (isDDLock) { @@ -833,23 +833,23 @@ CreateLockFile(const char *filename, bool amPostmaster, if (PGSharedMemoryIsInUse(id1, id2)) ereport(FATAL, (errcode(ERRCODE_LOCK_FILE_EXISTS), - errmsg("pre-existing shared memory block " - "(key %lu, ID %lu) is still in use", - id1, id2), - errhint("If you're sure there are no old " - "server processes still running, remove " - "the shared memory block with " - "the command \"ipcclean\", \"ipcrm\", " - "or just delete the file \"%s\".", - filename))); + errmsg("pre-existing shared memory block " + "(key %lu, ID %lu) is still in use", + id1, id2), + errhint("If you're sure there are no old " + "server processes still running, remove " + "the shared memory block with " + "the command \"ipcclean\", \"ipcrm\", " + "or just delete the file \"%s\".", + filename))); } } } /* - * Looks like nobody's home. Unlink the file and try again to - * create it. Need a loop because of possible race condition - * against other would-be creators. + * Looks like nobody's home. Unlink the file and try again to create + * it. Need a loop because of possible race condition against other + * would-be creators. */ if (unlink(filename) < 0) ereport(FATAL, @@ -857,7 +857,7 @@ CreateLockFile(const char *filename, bool amPostmaster, errmsg("could not remove old lock file \"%s\": %m", filename), errhint("The file seems accidentally left over, but " - "it could not be removed. Please remove the file " + "it could not be removed. Please remove the file " "by hand and try again."))); } @@ -878,7 +878,7 @@ CreateLockFile(const char *filename, bool amPostmaster, errno = save_errno ? save_errno : ENOSPC; ereport(FATAL, (errcode_for_file_access(), - errmsg("could not write lock file \"%s\": %m", filename))); + errmsg("could not write lock file \"%s\": %m", filename))); } if (close(fd)) { @@ -888,7 +888,7 @@ CreateLockFile(const char *filename, bool amPostmaster, errno = save_errno; ereport(FATAL, (errcode_for_file_access(), - errmsg("could not write lock file \"%s\": %m", filename))); + errmsg("could not write lock file \"%s\": %m", filename))); } /* @@ -939,10 +939,10 @@ TouchSocketLockFile(void) if (socketLockFile[0] != '\0') { /* - * utime() is POSIX standard, utimes() is a common alternative; if - * we have neither, fall back to actually reading the file (which - * only sets the access time not mod time, but that should be - * enough in most cases). In all paths, we ignore errors. + * utime() is POSIX standard, utimes() is a common alternative; if we + * have neither, fall back to actually reading the file (which only + * sets the access time not mod time, but that should be enough in + * most cases). In all paths, we ignore errors. */ #ifdef HAVE_UTIME utime(socketLockFile, NULL); @@ -1093,7 +1093,7 @@ ValidatePgVersion(const char *path) else ereport(FATAL, (errcode_for_file_access(), - errmsg("could not open file \"%s\": %m", full_path))); + errmsg("could not open file \"%s\": %m", full_path))); } ret = fscanf(file, "%ld.%ld", &file_major, &file_minor); @@ -1113,7 +1113,7 @@ ValidatePgVersion(const char *path) (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("database files are incompatible with server"), errdetail("The data directory was initialized by PostgreSQL version %ld.%ld, " - "which is not compatible with this version %s.", + "which is not compatible with this version %s.", file_major, file_minor, version_string))); } @@ -1149,7 +1149,7 @@ process_preload_libraries(char *preload_libraries_string) list_free(elemlist); ereport(LOG, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("invalid list syntax for parameter \"preload_libraries\""))); + errmsg("invalid list syntax for parameter \"preload_libraries\""))); return; } @@ -1164,9 +1164,8 @@ process_preload_libraries(char *preload_libraries_string) if (sep) { /* - * a colon separator implies there is an initialization - * function that we need to run in addition to loading the - * library + * a colon separator implies there is an initialization function + * that we need to run in addition to loading the library */ size_t filename_len = sep - tok; size_t funcname_len = strlen(tok) - filename_len - 1; diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c index 73fedbdd47..3c763e3929 100644 --- a/src/backend/utils/init/postinit.c +++ b/src/backend/utils/init/postinit.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/init/postinit.c,v 1.157 2005/08/11 21:11:46 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/init/postinit.c,v 1.158 2005/10/15 02:49:33 momjian Exp $ * * *------------------------------------------------------------------------- @@ -112,7 +112,7 @@ FindMyDatabase(const char *name, Oid *db_id, Oid *db_tablespace) * * Since FindMyDatabase cannot lock pg_database, the information it read * could be stale; for example we might have attached to a database that's in - * process of being destroyed by dropdb(). This routine is called after + * process of being destroyed by dropdb(). This routine is called after * we have all the locking and other infrastructure running --- now we can * check that we are really attached to a valid database. * @@ -134,14 +134,14 @@ static void ReverifyMyDatabase(const char *name) { Relation pgdbrel; - SysScanDesc pgdbscan; + SysScanDesc pgdbscan; ScanKeyData key; HeapTuple tup; Form_pg_database dbform; /* - * Because we grab RowShareLock here, we can be sure that dropdb() - * is not running in parallel with us (any more). + * Because we grab RowShareLock here, we can be sure that dropdb() is not + * running in parallel with us (any more). */ pgdbrel = heap_open(DatabaseRelationId, RowShareLock); @@ -161,17 +161,17 @@ ReverifyMyDatabase(const char *name) heap_close(pgdbrel, RowShareLock); /* - * The only real problem I could have created is to load dirty - * buffers for the dead database into shared buffer cache; if I - * did, some other backend will eventually try to write them and - * die in mdblindwrt. Flush any such pages to forestall trouble. + * The only real problem I could have created is to load dirty buffers + * for the dead database into shared buffer cache; if I did, some + * other backend will eventually try to write them and die in + * mdblindwrt. Flush any such pages to forestall trouble. */ DropBuffers(MyDatabaseId); /* Now I can commit hara-kiri with a clear conscience... */ ereport(FATAL, (errcode(ERRCODE_UNDEFINED_DATABASE), - errmsg("database \"%s\", OID %u, has disappeared from pg_database", - name, MyDatabaseId))); + errmsg("database \"%s\", OID %u, has disappeared from pg_database", + name, MyDatabaseId))); } dbform = (Form_pg_database) GETSTRUCT(tup); @@ -191,17 +191,18 @@ ReverifyMyDatabase(const char *name) if (!dbform->datallowconn) ereport(FATAL, (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), - errmsg("database \"%s\" is not currently accepting connections", - name))); + errmsg("database \"%s\" is not currently accepting connections", + name))); + /* * Check connection limit for this database. * * There is a race condition here --- we create our PGPROC before - * checking for other PGPROCs. If two backends did this at about the + * checking for other PGPROCs. If two backends did this at about the * same time, they might both think they were over the limit, while * ideally one should succeed and one fail. Getting that to work - * exactly seems more trouble than it is worth, however; instead - * we just document that the connection limit is approximate. + * exactly seems more trouble than it is worth, however; instead we + * just document that the connection limit is approximate. */ if (dbform->datconnlimit >= 0 && !superuser() && @@ -213,8 +214,8 @@ ReverifyMyDatabase(const char *name) } /* - * OK, we're golden. Next to-do item is to save the encoding - * info out of the pg_database tuple. + * OK, we're golden. Next to-do item is to save the encoding info out of + * the pg_database tuple. */ SetDatabaseEncoding(dbform->encoding); /* Record it as a GUC internal option, too */ @@ -264,8 +265,8 @@ InitCommunication(void) if (!IsUnderPostmaster) /* postmaster already did this */ { /* - * We're running a postgres bootstrap process or a standalone - * backend. Create private "shmem" and semaphores. + * We're running a postgres bootstrap process or a standalone backend. + * Create private "shmem" and semaphores. */ CreateSharedMemoryAndSemaphores(true, 0); } @@ -309,7 +310,7 @@ BaseInit(void) * The return value indicates whether the userID is a superuser. (That * can only be tested inside a transaction, so we want to do it during * the startup transaction rather than doing a separate one in postgres.c.) - * + * * Note: * Be very careful with the order of calls in the InitPostgres function. * -------------------------------- @@ -324,8 +325,8 @@ InitPostgres(const char *dbname, const char *username) /* * Set up the global variables holding database id and path. * - * We take a shortcut in the bootstrap case, otherwise we have to look up - * the db name in pg_database. + * We take a shortcut in the bootstrap case, otherwise we have to look up the + * db name in pg_database. */ if (bootstrap) { @@ -338,13 +339,12 @@ InitPostgres(const char *dbname, const char *username) char *fullpath; /* - * Formerly we validated DataDir here, but now that's done - * earlier. + * Formerly we validated DataDir here, but now that's done earlier. */ /* - * Find oid and tablespace of the database we're about to open. - * Since we're not yet up and running we have to use the hackish + * Find oid and tablespace of the database we're about to open. Since + * we're not yet up and running we have to use the hackish * FindMyDatabase. */ if (!FindMyDatabase(dbname, &MyDatabaseId, &MyDatabaseTableSpace)) @@ -364,8 +364,8 @@ InitPostgres(const char *dbname, const char *username) (errcode(ERRCODE_UNDEFINED_DATABASE), errmsg("database \"%s\" does not exist", dbname), - errdetail("The database subdirectory \"%s\" is missing.", - fullpath))); + errdetail("The database subdirectory \"%s\" is missing.", + fullpath))); else ereport(FATAL, (errcode_for_file_access(), @@ -383,17 +383,17 @@ InitPostgres(const char *dbname, const char *username) */ /* - * Set up my per-backend PGPROC struct in shared memory. (We need - * to know MyDatabaseId before we can do this, since it's entered into - * the PGPROC struct.) + * Set up my per-backend PGPROC struct in shared memory. (We need to + * know MyDatabaseId before we can do this, since it's entered into the + * PGPROC struct.) */ InitProcess(); /* * Initialize my entry in the shared-invalidation manager's array of - * per-backend data. (Formerly this came before InitProcess, but now - * it must happen after, because it uses MyProc.) Once I have done - * this, I am visible to other backends! + * per-backend data. (Formerly this came before InitProcess, but now it + * must happen after, because it uses MyProc.) Once I have done this, I + * am visible to other backends! * * Sets up MyBackendId, a unique backend identifier. */ @@ -410,22 +410,22 @@ InitPostgres(const char *dbname, const char *username) InitBufferPoolBackend(); /* - * Initialize local process's access to XLOG. In bootstrap case we - * may skip this since StartupXLOG() was run instead. + * Initialize local process's access to XLOG. In bootstrap case we may + * skip this since StartupXLOG() was run instead. */ if (!bootstrap) InitXLOGAccess(); /* - * Initialize the relation descriptor cache. This must create at - * least the minimum set of "nailed-in" cache entries. No catalog - * access happens here. + * Initialize the relation descriptor cache. This must create at least + * the minimum set of "nailed-in" cache entries. No catalog access + * happens here. */ RelationCacheInitialize(); /* - * Initialize all the system catalog caches. Note that no catalog - * access happens here; we only set up the cache structure. + * Initialize all the system catalog caches. Note that no catalog access + * happens here; we only set up the cache structure. */ InitCatalogCache(); @@ -433,14 +433,13 @@ InitPostgres(const char *dbname, const char *username) EnablePortalManager(); /* - * Set up process-exit callback to do pre-shutdown cleanup. This - * has to be after we've initialized all the low-level modules - * like the buffer manager, because during shutdown this has to - * run before the low-level modules start to close down. On the - * other hand, we want it in place before we begin our first - * transaction --- if we fail during the initialization transaction, - * as is entirely possible, we need the AbortTransaction call to - * clean up. + * Set up process-exit callback to do pre-shutdown cleanup. This has to + * be after we've initialized all the low-level modules like the buffer + * manager, because during shutdown this has to run before the low-level + * modules start to close down. On the other hand, we want it in place + * before we begin our first transaction --- if we fail during the + * initialization transaction, as is entirely possible, we need the + * AbortTransaction call to clean up. */ on_shmem_exit(ShutdownPostgres, 0); @@ -479,18 +478,18 @@ InitPostgres(const char *dbname, const char *username) } /* - * Unless we are bootstrapping, double-check that InitMyDatabaseInfo() - * got a correct result. We can't do this until all the - * database-access infrastructure is up. (Also, it wants to know if - * the user is a superuser, so the above stuff has to happen first.) + * Unless we are bootstrapping, double-check that InitMyDatabaseInfo() got + * a correct result. We can't do this until all the database-access + * infrastructure is up. (Also, it wants to know if the user is a + * superuser, so the above stuff has to happen first.) */ if (!bootstrap) ReverifyMyDatabase(dbname); /* * Final phase of relation cache startup: write a new cache file if - * necessary. This is done after ReverifyMyDatabase to avoid writing - * a cache file into a dead database. + * necessary. This is done after ReverifyMyDatabase to avoid writing a + * cache file into a dead database. */ RelationCacheInitializePhase3(); @@ -555,8 +554,8 @@ ShutdownPostgres(int code, Datum arg) AbortOutOfAnyTransaction(); /* - * User locks are not released by transaction end, so be sure to - * release them explicitly. + * User locks are not released by transaction end, so be sure to release + * them explicitly. */ #ifdef USER_LOCKS LockReleaseAll(USER_LOCKMETHOD, true); diff --git a/src/backend/utils/mb/conv.c b/src/backend/utils/mb/conv.c index 02082db5ef..a395384c93 100644 --- a/src/backend/utils/mb/conv.c +++ b/src/backend/utils/mb/conv.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/mb/conv.c,v 1.54 2005/09/24 17:53:17 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/mb/conv.c,v 1.55 2005/10/15 02:49:33 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -223,8 +223,8 @@ pg_mic2ascii(unsigned char *mic, unsigned char *p, int len) void latin2mic_with_table( unsigned char *l, /* local charset string (source) */ - unsigned char *p, /* pointer to store mule internal - * code (destination) */ + 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 */ @@ -265,8 +265,7 @@ latin2mic_with_table( */ void mic2latin_with_table( - unsigned char *mic, /* mule internal code - * (source) */ + unsigned char *mic, /* mule internal code (source) */ unsigned char *p, /* local code (destination) */ int len, /* length of p */ int lc, /* leading character */ @@ -380,8 +379,8 @@ UtfToLocal(unsigned char *utf, unsigned char *iso, { ereport(WARNING, (errcode(ERRCODE_UNTRANSLATABLE_CHARACTER), - errmsg("ignoring unconvertible UTF8 character 0x%04x", - iutf))); + errmsg("ignoring unconvertible UTF8 character 0x%04x", + iutf))); continue; } if (p->code & 0xff000000) diff --git a/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c b/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c index 277224103a..3b215b2c4f 100644 --- a/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c +++ b/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c,v 1.12 2005/09/24 17:53:18 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c,v 1.13 2005/10/15 02:49:34 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -462,7 +462,7 @@ euc_jp2sjis(unsigned char *euc, unsigned char *p, int len) while (euc_end >= euc && (c1 = *euc++)) { - if(c1 < 0x80) + if (c1 < 0x80) { /* should be ASCII */ *p++ = c1; @@ -487,7 +487,8 @@ euc_jp2sjis(unsigned char *euc, unsigned char *p, int len) } else { - int i, k2; + int i, + k2; /* IBM kanji */ for (i = 0;; i++) @@ -508,9 +509,9 @@ euc_jp2sjis(unsigned char *euc, unsigned char *p, int len) } } } - } + } else - { + { /* JIS X0208 kanji? */ c2 = *euc++; k = (c1 << 8) | (c2 & 0xff); @@ -543,7 +544,7 @@ sjis2euc_jp(unsigned char *sjis, unsigned char *p, int len) while (sjis_end >= sjis && (c1 = *sjis++)) { - if(c1 < 0x80) + if (c1 < 0x80) { /* should be ASCII */ *p++ = c1; @@ -643,4 +644,3 @@ sjis2euc_jp(unsigned char *sjis, unsigned char *p, int len) } *p = '\0'; } - diff --git a/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/big5.c b/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/big5.c index 4bdbfe9563..0447c2a9e7 100644 --- a/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/big5.c +++ b/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/big5.c @@ -7,7 +7,7 @@ * * 1999/1/15 Tatsuo Ishii * - * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/big5.c,v 1.5 2004/08/30 02:54:40 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/big5.c,v 1.6 2005/10/15 02:49:34 momjian Exp $ */ /* can be used in either frontend or backend */ @@ -19,7 +19,7 @@ typedef struct { unsigned short code, peer; -} codes_t; +} codes_t; /* map Big5 Level 1 to CNS 11643-1992 Plane 1 */ static codes_t big5Level1ToCnsPlane1[25] = { /* range */ @@ -205,7 +205,7 @@ static unsigned short b2c3[][2] = { }; static unsigned short BinarySearchRange - (codes_t *array, int high, unsigned short code) + (codes_t * array, int high, unsigned short code) { int low, mid, @@ -230,24 +230,24 @@ static unsigned short BinarySearchRange /* * 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. + * 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. + * 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) @@ -260,9 +260,8 @@ static unsigned short BinarySearchRange 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. + * 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)); diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/utf8_and_cyrillic.c b/src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/utf8_and_cyrillic.c index 3330f89d5d..efab622c94 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/utf8_and_cyrillic.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/utf8_and_cyrillic.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/utf8_and_cyrillic.c,v 1.11 2005/09/24 17:53:20 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/utf8_and_cyrillic.c,v 1.12 2005/10/15 02:49:34 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -75,7 +75,7 @@ koi8r_to_utf8(PG_FUNCTION_ARGS) Assert(len >= 0); LocalToUtf(src, dest, LUmapKOI8R, - sizeof(LUmapKOI8R) / sizeof(pg_local_to_utf), PG_KOI8R, len); + sizeof(LUmapKOI8R) / sizeof(pg_local_to_utf), PG_KOI8R, len); PG_RETURN_VOID(); } @@ -109,7 +109,7 @@ win1251_to_utf8(PG_FUNCTION_ARGS) Assert(len >= 0); LocalToUtf(src, dest, LUmapWIN1251, - sizeof(LUmapWIN1251) / sizeof(pg_local_to_utf), PG_WIN1251, len); + sizeof(LUmapWIN1251) / sizeof(pg_local_to_utf), PG_WIN1251, len); PG_RETURN_VOID(); } diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_euc_cn/utf8_and_euc_cn.c b/src/backend/utils/mb/conversion_procs/utf8_and_euc_cn/utf8_and_euc_cn.c index 29196cb4e8..9dcd87355a 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_euc_cn/utf8_and_euc_cn.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_euc_cn/utf8_and_euc_cn.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_cn/utf8_and_euc_cn.c,v 1.11 2005/09/24 17:53:21 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_cn/utf8_and_euc_cn.c,v 1.12 2005/10/15 02:49:34 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -45,7 +45,7 @@ euc_cn_to_utf8(PG_FUNCTION_ARGS) Assert(len >= 0); LocalToUtf(src, dest, LUmapEUC_CN, - sizeof(LUmapEUC_CN) / sizeof(pg_local_to_utf), PG_EUC_CN, len); + sizeof(LUmapEUC_CN) / sizeof(pg_local_to_utf), PG_EUC_CN, len); PG_RETURN_VOID(); } diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_euc_jp/utf8_and_euc_jp.c b/src/backend/utils/mb/conversion_procs/utf8_and_euc_jp/utf8_and_euc_jp.c index bbe849de90..4231bc08df 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_euc_jp/utf8_and_euc_jp.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_euc_jp/utf8_and_euc_jp.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_jp/utf8_and_euc_jp.c,v 1.11 2005/09/24 17:53:21 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_jp/utf8_and_euc_jp.c,v 1.12 2005/10/15 02:49:34 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -45,7 +45,7 @@ euc_jp_to_utf8(PG_FUNCTION_ARGS) Assert(len >= 0); LocalToUtf(src, dest, LUmapEUC_JP, - sizeof(LUmapEUC_JP) / sizeof(pg_local_to_utf), PG_EUC_JP, len); + sizeof(LUmapEUC_JP) / sizeof(pg_local_to_utf), PG_EUC_JP, len); PG_RETURN_VOID(); } diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/utf8_and_euc_kr.c b/src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/utf8_and_euc_kr.c index db1505ab62..b197b064ee 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/utf8_and_euc_kr.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/utf8_and_euc_kr.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/utf8_and_euc_kr.c,v 1.11 2005/09/24 17:53:22 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/utf8_and_euc_kr.c,v 1.12 2005/10/15 02:49:34 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -45,7 +45,7 @@ euc_kr_to_utf8(PG_FUNCTION_ARGS) Assert(len >= 0); LocalToUtf(src, dest, LUmapEUC_KR, - sizeof(LUmapEUC_KR) / sizeof(pg_local_to_utf), PG_EUC_KR, len); + sizeof(LUmapEUC_KR) / sizeof(pg_local_to_utf), PG_EUC_KR, len); PG_RETURN_VOID(); } diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_euc_tw/utf8_and_euc_tw.c b/src/backend/utils/mb/conversion_procs/utf8_and_euc_tw/utf8_and_euc_tw.c index cc05c64cc1..b2f7d465a7 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_euc_tw/utf8_and_euc_tw.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_euc_tw/utf8_and_euc_tw.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_tw/utf8_and_euc_tw.c,v 1.11 2005/09/24 17:53:22 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_tw/utf8_and_euc_tw.c,v 1.12 2005/10/15 02:49:34 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -45,7 +45,7 @@ euc_tw_to_utf8(PG_FUNCTION_ARGS) Assert(len >= 0); LocalToUtf(src, dest, LUmapEUC_TW, - sizeof(LUmapEUC_TW) / sizeof(pg_local_to_utf), PG_EUC_TW, len); + sizeof(LUmapEUC_TW) / sizeof(pg_local_to_utf), PG_EUC_TW, len); PG_RETURN_VOID(); } diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_gb18030/utf8_and_gb18030.c b/src/backend/utils/mb/conversion_procs/utf8_and_gb18030/utf8_and_gb18030.c index 37f207ec15..6cc235e732 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_gb18030/utf8_and_gb18030.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_gb18030/utf8_and_gb18030.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_gb18030/utf8_and_gb18030.c,v 1.11 2005/09/24 17:53:23 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_gb18030/utf8_and_gb18030.c,v 1.12 2005/10/15 02:49:34 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -45,7 +45,7 @@ gb18030_to_utf8(PG_FUNCTION_ARGS) Assert(len >= 0); LocalToUtf(src, dest, LUmapGB18030, - sizeof(LUmapGB18030) / sizeof(pg_local_to_utf), PG_GB18030, len); + sizeof(LUmapGB18030) / sizeof(pg_local_to_utf), PG_GB18030, len); PG_RETURN_VOID(); } diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c b/src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c index b6c56324ec..0038db58e6 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c,v 1.14 2005/09/24 17:53:23 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c,v 1.15 2005/10/15 02:49:35 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -65,7 +65,7 @@ typedef struct pg_utf_to_local *map2; /* from UTF8 map name */ int size1; /* size of map1 */ int size2; /* size of map2 */ -} pg_conv_map; +} pg_conv_map; static pg_conv_map maps[] = { {PG_SQL_ASCII}, /* SQL/ASCII */ diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_johab/utf8_and_johab.c b/src/backend/utils/mb/conversion_procs/utf8_and_johab/utf8_and_johab.c index 9e93be9c49..3de91947af 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_johab/utf8_and_johab.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_johab/utf8_and_johab.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_johab/utf8_and_johab.c,v 1.11 2005/09/24 17:53:24 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_johab/utf8_and_johab.c,v 1.12 2005/10/15 02:49:35 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -45,7 +45,7 @@ johab_to_utf8(PG_FUNCTION_ARGS) Assert(len >= 0); LocalToUtf(src, dest, LUmapJOHAB, - sizeof(LUmapJOHAB) / sizeof(pg_local_to_utf), PG_JOHAB, len); + sizeof(LUmapJOHAB) / sizeof(pg_local_to_utf), PG_JOHAB, len); PG_RETURN_VOID(); } diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_win1250/utf8_and_win1250.c b/src/backend/utils/mb/conversion_procs/utf8_and_win1250/utf8_and_win1250.c index cd79893ae8..6789ca7aaa 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_win1250/utf8_and_win1250.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_win1250/utf8_and_win1250.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win1250/utf8_and_win1250.c,v 1.12 2005/09/24 17:53:25 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win1250/utf8_and_win1250.c,v 1.13 2005/10/15 02:49:35 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -63,7 +63,7 @@ win1250_to_utf8(PG_FUNCTION_ARGS) Assert(len >= 0); LocalToUtf(src, dest, LUmapWIN1250, - sizeof(LUmapWIN1250) / sizeof(pg_local_to_utf), PG_WIN1250, len); + sizeof(LUmapWIN1250) / sizeof(pg_local_to_utf), PG_WIN1250, len); PG_RETURN_VOID(); } diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_win1252/utf8_and_win1252.c b/src/backend/utils/mb/conversion_procs/utf8_and_win1252/utf8_and_win1252.c index b7592b6c30..b4d2b2375a 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_win1252/utf8_and_win1252.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_win1252/utf8_and_win1252.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win1252/utf8_and_win1252.c,v 1.4 2005/09/24 17:53:25 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win1252/utf8_and_win1252.c,v 1.5 2005/10/15 02:49:35 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -63,7 +63,7 @@ win1252_to_utf8(PG_FUNCTION_ARGS) Assert(len >= 0); LocalToUtf(src, dest, LUmapWIN1252, - sizeof(LUmapWIN1252) / sizeof(pg_local_to_utf), PG_WIN1252, len); + sizeof(LUmapWIN1252) / sizeof(pg_local_to_utf), PG_WIN1252, len); PG_RETURN_VOID(); } diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_win1256/utf8_and_win1256.c b/src/backend/utils/mb/conversion_procs/utf8_and_win1256/utf8_and_win1256.c index a0036d80e6..d6b83d8f83 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_win1256/utf8_and_win1256.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_win1256/utf8_and_win1256.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win1256/utf8_and_win1256.c,v 1.12 2005/09/24 17:53:26 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win1256/utf8_and_win1256.c,v 1.13 2005/10/15 02:49:35 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -63,7 +63,7 @@ win1256_to_utf8(PG_FUNCTION_ARGS) Assert(len >= 0); LocalToUtf(src, dest, LUmapWIN1256, - sizeof(LUmapWIN1256) / sizeof(pg_local_to_utf), PG_WIN1256, len); + sizeof(LUmapWIN1256) / sizeof(pg_local_to_utf), PG_WIN1256, len); PG_RETURN_VOID(); } diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_win1258/utf8_and_win1258.c b/src/backend/utils/mb/conversion_procs/utf8_and_win1258/utf8_and_win1258.c index 3b74f81ba9..7cdcfd3c12 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_win1258/utf8_and_win1258.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_win1258/utf8_and_win1258.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win1258/utf8_and_win1258.c,v 1.2 2005/09/24 17:53:26 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win1258/utf8_and_win1258.c,v 1.3 2005/10/15 02:49:35 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -45,7 +45,7 @@ win1258_to_utf8(PG_FUNCTION_ARGS) Assert(len >= 0); LocalToUtf(src, dest, LUmapWIN1258, - sizeof(LUmapWIN1258) / sizeof(pg_local_to_utf), PG_WIN1258, len); + sizeof(LUmapWIN1258) / sizeof(pg_local_to_utf), PG_WIN1258, len); PG_RETURN_VOID(); } diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_win874/utf8_and_win874.c b/src/backend/utils/mb/conversion_procs/utf8_and_win874/utf8_and_win874.c index 48f30b2cad..7eda096a9b 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_win874/utf8_and_win874.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_win874/utf8_and_win874.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win874/utf8_and_win874.c,v 1.12 2005/09/24 17:53:26 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win874/utf8_and_win874.c,v 1.13 2005/10/15 02:49:35 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -63,7 +63,7 @@ win874_to_utf8(PG_FUNCTION_ARGS) Assert(len >= 0); LocalToUtf(src, dest, LUmapWIN874, - sizeof(LUmapWIN874) / sizeof(pg_local_to_utf), PG_WIN874, len); + sizeof(LUmapWIN874) / sizeof(pg_local_to_utf), PG_WIN874, len); PG_RETURN_VOID(); } diff --git a/src/backend/utils/mb/encnames.c b/src/backend/utils/mb/encnames.c index 5c0b15fd74..145343a881 100644 --- a/src/backend/utils/mb/encnames.c +++ b/src/backend/utils/mb/encnames.c @@ -2,7 +2,7 @@ * Encoding names and routines for work with it. All * in this file is shared bedween FE and BE. * - * $PostgreSQL: pgsql/src/backend/utils/mb/encnames.c,v 1.25 2005/03/14 18:31:20 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/mb/encnames.c,v 1.26 2005/10/15 02:49:33 momjian Exp $ */ #ifdef FRONTEND #include "postgres_fe.h" @@ -45,16 +45,16 @@ pg_encname pg_encname_tbl[] = }, /* Big5; Chinese for Taiwan multibyte set */ { "euccn", PG_EUC_CN - }, /* EUC-CN; Extended Unix Code for - * simplified Chinese */ + }, /* EUC-CN; Extended Unix Code for simplified + * Chinese */ { "eucjp", PG_EUC_JP - }, /* EUC-JP; Extended UNIX Code fixed Width - * for Japanese, standard OSF */ + }, /* EUC-JP; Extended UNIX Code fixed Width for + * Japanese, standard OSF */ { "euckr", PG_EUC_KR - }, /* EUC-KR; Extended Unix Code for Korean , - * KS X 1001 standard */ + }, /* EUC-KR; Extended Unix Code for Korean , KS + * X 1001 standard */ { "euctw", PG_EUC_TW }, /* EUC-TW; Extended Unix Code for @@ -111,8 +111,8 @@ pg_encname pg_encname_tbl[] = }, /* ISO-8859-9; RFC1345,KXS2 */ { "johab", PG_JOHAB - }, /* JOHAB; Extended Unix Code for - * simplified Chinese */ + }, /* JOHAB; Extended Unix Code for simplified + * Chinese */ { "koi8", PG_KOI8R }, /* _dirty_ alias for KOI8-R (backward @@ -185,8 +185,8 @@ pg_encname pg_encname_tbl[] = }, /* alias for WIN1258 */ { "win", PG_WIN1251 - }, /* _dirty_ alias for windows-1251 - * (backward compatibility) */ + }, /* _dirty_ alias for windows-1251 (backward + * compatibility) */ { "win1250", PG_WIN1250 }, /* alias for Windows-1250 */ diff --git a/src/backend/utils/mb/mbutils.c b/src/backend/utils/mb/mbutils.c index 8058fc8d27..f8dc7a3192 100644 --- a/src/backend/utils/mb/mbutils.c +++ b/src/backend/utils/mb/mbutils.c @@ -4,7 +4,7 @@ * (currently mule internal code (mic) is used) * Tatsuo Ishii * - * $PostgreSQL: pgsql/src/backend/utils/mb/mbutils.c,v 1.51 2005/09/24 17:53:17 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/mb/mbutils.c,v 1.52 2005/10/15 02:49:33 momjian Exp $ */ #include "postgres.h" @@ -107,12 +107,11 @@ SetClientEncoding(int encoding, bool doit) } /* - * If we're not inside a transaction then we can't do catalog lookups, - * so fail. After backend startup, this could only happen if we are + * If we're not inside a transaction then we can't do catalog lookups, so + * fail. After backend startup, this could only happen if we are * re-reading postgresql.conf due to SIGHUP --- so basically this just * constrains the ability to change client_encoding on the fly from - * postgresql.conf. Which would probably be a stupid thing to do - * anyway. + * postgresql.conf. Which would probably be a stupid thing to do anyway. */ if (!IsTransactionState()) return -1; @@ -136,8 +135,8 @@ SetClientEncoding(int encoding, bool doit) return 0; /* - * load the fmgr info into TopMemoryContext so that it survives - * outside transaction. + * load the fmgr info into TopMemoryContext so that it survives outside + * transaction. */ oldcontext = MemoryContextSwitchTo(TopMemoryContext); to_server = palloc(sizeof(FmgrInfo)); @@ -180,8 +179,8 @@ InitializeClientEncoding(void) if (SetClientEncoding(pending_client_encoding, true) < 0) { /* - * Oops, the requested conversion is not available. We couldn't - * fail before, but we can now. + * Oops, the requested conversion is not available. We couldn't fail + * before, but we can now. */ ereport(FATAL, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), @@ -256,8 +255,8 @@ pg_do_encoding_conversion(unsigned char *src, int len, } /* - * XXX we should avoid throwing errors in OidFunctionCall. Otherwise - * we are going into infinite loop! So we have to make sure that the + * XXX we should avoid throwing errors in OidFunctionCall. Otherwise we + * are going into infinite loop! So we have to make sure that the * function exists before calling OidFunctionCall. */ if (!SearchSysCacheExists(PROCOID, @@ -290,11 +289,11 @@ pg_convert(PG_FUNCTION_ARGS) Datum string = PG_GETARG_DATUM(0); Datum dest_encoding_name = PG_GETARG_DATUM(1); Datum src_encoding_name = DirectFunctionCall1( - namein, CStringGetDatum(DatabaseEncoding->name)); + namein, CStringGetDatum(DatabaseEncoding->name)); Datum result; result = DirectFunctionCall3( - pg_convert2, string, src_encoding_name, dest_encoding_name); + pg_convert2, string, src_encoding_name, dest_encoding_name); /* free memory allocated by namein */ pfree((void *) src_encoding_name); @@ -343,8 +342,7 @@ pg_convert2(PG_FUNCTION_ARGS) /* * build text data type structure. we cannot use textin() here, since - * textin assumes that input string encoding is same as database - * encoding. + * textin assumes that input string encoding is same as database encoding. */ len = strlen((char *) result) + VARHDRSZ; retval = palloc(len); @@ -502,7 +500,7 @@ pg_mbstrlen_with_len(const char *mbstr, int limit) while (limit > 0 && *mbstr) { - int l = pg_mblen(mbstr); + int l = pg_mblen(mbstr); limit -= l; mbstr += l; diff --git a/src/backend/utils/mb/wchar.c b/src/backend/utils/mb/wchar.c index 59116e2e81..e8866ba35c 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 multibyte streams. * Tatsuo Ishii - * $PostgreSQL: pgsql/src/backend/utils/mb/wchar.c,v 1.45 2005/09/24 17:53:17 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/mb/wchar.c,v 1.46 2005/10/15 02:49:33 momjian Exp $ * * WIN1250 client encoding updated by Pavel Behal * @@ -406,14 +406,14 @@ pg_utf_mblen(const unsigned char *s) len = 1; else if ((*s & 0xe0) == 0xc0) len = 2; - else if ((*s & 0xf0) == 0xe0) - len = 3; - else if ((*s & 0xf8) == 0xf0) - len = 4; - else if ((*s & 0xfc) == 0xf8) - len = 5; - else if ((*s & 0xfe) == 0xfc) - len = 6; + else if ((*s & 0xf0) == 0xe0) + len = 3; + else if ((*s & 0xf8) == 0xf0) + len = 4; + else if ((*s & 0xfc) == 0xf8) + len = 5; + else if ((*s & 0xfe) == 0xfc) + len = 6; return (len); } @@ -727,8 +727,8 @@ pg_wchar_tbl pg_wchar_table[] = { {pg_euckr2wchar_with_len, pg_euckr_mblen, pg_euckr_dsplen, 3}, /* 3; PG_EUC_KR */ {pg_euctw2wchar_with_len, pg_euctw_mblen, pg_euctw_dsplen, 3}, /* 4; PG_EUC_TW */ {pg_johab2wchar_with_len, pg_johab_mblen, pg_johab_dsplen, 3}, /* 5; PG_JOHAB */ - {pg_utf2wchar_with_len, pg_utf_mblen, pg_utf_dsplen, 4}, /* 6; PG_UTF8 */ - {pg_mule2wchar_with_len, pg_mule_mblen, pg_mule_dsplen, 3}, /* 7; PG_MULE_INTERNAL */ + {pg_utf2wchar_with_len, pg_utf_mblen, pg_utf_dsplen, 4}, /* 6; PG_UTF8 */ + {pg_mule2wchar_with_len, pg_mule_mblen, pg_mule_dsplen, 3}, /* 7; PG_MULE_INTERNAL */ {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, 1}, /* 8; PG_LATIN1 */ {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, 1}, /* 9; PG_LATIN2 */ {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, 1}, /* 10; PG_LATIN3 */ @@ -775,8 +775,8 @@ pg_encoding_mblen(int encoding, const char *mbstr) return ((encoding >= 0 && encoding < sizeof(pg_wchar_table) / sizeof(pg_wchar_tbl)) ? - ((*pg_wchar_table[encoding].mblen) ((const unsigned char *) mbstr)) : - ((*pg_wchar_table[PG_SQL_ASCII].mblen) ((const unsigned char *) mbstr))); + ((*pg_wchar_table[encoding].mblen) ((const unsigned char *) mbstr)) : + ((*pg_wchar_table[PG_SQL_ASCII].mblen) ((const unsigned char *) mbstr))); } /* @@ -789,8 +789,8 @@ pg_encoding_dsplen(int encoding, const char *mbstr) return ((encoding >= 0 && encoding < sizeof(pg_wchar_table) / sizeof(pg_wchar_tbl)) ? - ((*pg_wchar_table[encoding].dsplen) ((const unsigned char *) mbstr)) : - ((*pg_wchar_table[PG_SQL_ASCII].dsplen) ((const unsigned char *) mbstr))); + ((*pg_wchar_table[encoding].dsplen) ((const unsigned char *) mbstr)) : + ((*pg_wchar_table[PG_SQL_ASCII].dsplen) ((const unsigned char *) mbstr))); } /* @@ -806,28 +806,57 @@ pg_encoding_max_length(int encoding) #ifndef FRONTEND -bool pg_utf8_islegal(const unsigned char *source, int length) { - unsigned char a; - const unsigned char *srcptr = source+length; - switch (length) { - default: return false; - /* Everything else falls through when "true"... */ - case 4: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; - case 3: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; - case 2: if ((a = (*--srcptr)) > 0xBF) return false; - switch (*source) { - /* no fall-through in this inner switch */ - case 0xE0: if (a < 0xA0) return false; break; - case 0xED: if (a > 0x9F) return false; break; - case 0xF0: if (a < 0x90) return false; break; - case 0xF4: if (a > 0x8F) return false; break; - default: if (a < 0x80) return false; - } +bool +pg_utf8_islegal(const unsigned char *source, int length) +{ + unsigned char a; + const unsigned char *srcptr = source + length; - case 1: if (*source >= 0x80 && *source < 0xC2) return false; - } - if (*source > 0xF4) return false; - return true; + switch (length) + { + default: + return false; + /* Everything else falls through when "true"... */ + case 4: + if ((a = (*--srcptr)) < 0x80 || a > 0xBF) + return false; + case 3: + if ((a = (*--srcptr)) < 0x80 || a > 0xBF) + return false; + case 2: + if ((a = (*--srcptr)) > 0xBF) + return false; + switch (*source) + { + /* no fall-through in this inner switch */ + case 0xE0: + if (a < 0xA0) + return false; + break; + case 0xED: + if (a > 0x9F) + return false; + break; + case 0xF0: + if (a < 0x90) + return false; + break; + case 0xF4: + if (a > 0x8F) + return false; + break; + default: + if (a < 0x80) + return false; + } + + case 1: + if (*source >= 0x80 && *source < 0xC2) + return false; + } + if (*source > 0xF4) + return false; + return true; } @@ -855,11 +884,11 @@ pg_verifymbstr(const char *mbstr, int len, bool noError) while (len > 0 && *mbstr) { l = pg_mblen(mbstr); - + /* special UTF-8 check */ if (encoding == PG_UTF8) { - if(!pg_utf8_islegal((const unsigned char *) mbstr, l)) + if (!pg_utf8_islegal((const unsigned char *) mbstr, l)) { if (noError) return false; @@ -868,7 +897,9 @@ pg_verifymbstr(const char *mbstr, int len, bool noError) errmsg("invalid UNICODE byte sequence detected near byte 0x%02x", (unsigned char) *mbstr))); } - } else { + } + else + { for (i = 1; i < l; i++) { /* @@ -878,23 +909,23 @@ pg_verifymbstr(const char *mbstr, int len, bool noError) if (i >= len || (mbstr[i] & 0x80) == 0) { char buf[8 * 2 + 1]; - char *p = buf; - int j, - jlimit; + char *p = buf; + int j, + jlimit; if (noError) return false; jlimit = Min(l, len); - jlimit = Min(jlimit, 8); /* prevent buffer overrun */ + jlimit = Min(jlimit, 8); /* prevent buffer overrun */ for (j = 0; j < jlimit; j++) p += sprintf(p, "%02x", (unsigned char) mbstr[j]); ereport(ERROR, (errcode(ERRCODE_CHARACTER_NOT_IN_REPERTOIRE), - errmsg("invalid byte sequence for encoding \"%s\": 0x%s", - GetDatabaseEncodingName(), buf))); + errmsg("invalid byte sequence for encoding \"%s\": 0x%s", + GetDatabaseEncodingName(), buf))); } } } diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 1ba1ac31d3..3394fd77e3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -10,7 +10,7 @@ * Written by Peter Eisentraut . * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.292 2005/10/14 20:53:56 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.293 2005/10/15 02:49:36 momjian Exp $ * *-------------------------------------------------------------------- */ @@ -72,7 +72,7 @@ #define PG_KRB_SRVNAM "" #endif -#define CONFIG_FILENAME "postgresql.conf" +#define CONFIG_FILENAME "postgresql.conf" #define HBA_FILENAME "pg_hba.conf" #define IDENT_FILENAME "pg_ident.conf" @@ -94,9 +94,10 @@ extern DLLIMPORT bool check_function_bodies; extern int CommitDelay; extern int CommitSiblings; extern char *default_tablespace; -extern bool fullPageWrites; +extern bool fullPageWrites; + #ifdef TRACE_SORT -extern bool trace_sort; +extern bool trace_sort; #endif static const char *assign_log_destination(const char *value, @@ -106,9 +107,9 @@ static const char *assign_log_destination(const char *value, static int syslog_facility = LOG_LOCAL0; static const char *assign_syslog_facility(const char *facility, - bool doit, GucSource source); + bool doit, GucSource source); static const char *assign_syslog_ident(const char *ident, - bool doit, GucSource source); + bool doit, GucSource source); #endif static const char *assign_defaultxactisolevel(const char *newval, bool doit, @@ -157,8 +158,8 @@ bool Explain_pretty_print = true; bool log_parser_stats = false; bool log_planner_stats = false; bool log_executor_stats = false; -bool log_statement_stats = false; /* this is sort of all - * three above together */ +bool log_statement_stats = false; /* this is sort of all three + * above together */ bool log_btree_build_stats = false; bool SQL_inheritance = true; @@ -181,9 +182,9 @@ char *HbaFileName; char *IdentFileName; char *external_pid_file; -int tcp_keepalives_idle; -int tcp_keepalives_interval; -int tcp_keepalives_count; +int tcp_keepalives_idle; +int tcp_keepalives_interval; +int tcp_keepalives_count; /* * These variables are all dummies that don't do anything, except in some @@ -217,8 +218,8 @@ static int max_function_args; static int max_index_keys; static int max_identifier_length; static int block_size; -static bool integer_datetimes; -static bool standard_conforming_strings; +static bool integer_datetimes; +static bool standard_conforming_strings; /* should be static, but commands/variable.c needs to get at these */ char *role_string; @@ -501,7 +502,7 @@ static struct config_bool ConfigureNamesBool[] = {"fsync", PGC_SIGHUP, WAL_SETTINGS, gettext_noop("Forces synchronization of updates to disk."), gettext_noop("The server will use the fsync() system call in several places to make " - "sure that updates are physically written to disk. This insures " + "sure that updates are physically written to disk. This insures " "that a database cluster will recover to a consistent state after " "an operating system or hardware crash.") }, @@ -512,7 +513,7 @@ static struct config_bool ConfigureNamesBool[] = {"zero_damaged_pages", PGC_SUSET, DEVELOPER_OPTIONS, gettext_noop("Continues processing past damaged page headers."), gettext_noop("Detection of a damaged page header normally causes PostgreSQL to " - "report an error, aborting the current transaction. Setting " + "report an error, aborting the current transaction. Setting " "zero_damaged_pages to true causes the system to instead report a " "warning, zero out the damaged page, and continue processing. This " "behavior will destroy data, namely all the rows on the damaged page."), @@ -526,7 +527,7 @@ static struct config_bool ConfigureNamesBool[] = gettext_noop("Writes full pages to WAL when first modified after a checkpoint."), gettext_noop("A page write in process during an operating system crash might be " "only partially written to disk. During recovery, the row changes" - "stored in WAL are not enough to recover. This option writes " + "stored in WAL are not enough to recover. This option writes " "pages when first modified after a checkpoint to WAL so full recovery " "is possible.") }, @@ -537,7 +538,7 @@ static struct config_bool ConfigureNamesBool[] = {"silent_mode", PGC_POSTMASTER, LOGGING_WHEN, gettext_noop("Runs the server silently."), gettext_noop("If this parameter is set, the server will automatically run in the " - "background and any controlling terminals are dissociated.") + "background and any controlling terminals are dissociated.") }, &SilentMode, false, NULL, NULL @@ -693,7 +694,7 @@ static struct config_bool ConfigureNamesBool[] = {"stats_command_string", PGC_SUSET, STATS_COLLECTOR, gettext_noop("Collects statistics about executing commands."), gettext_noop("Enables the collection of statistics on the currently " - "executing command of each session, along with the time " + "executing command of each session, along with the time " "at which that command began execution.") }, &pgstat_collect_querystring, @@ -722,7 +723,7 @@ static struct config_bool ConfigureNamesBool[] = NULL }, &autovacuum_start_daemon, - false, NULL, NULL + false, NULL, NULL }, { @@ -779,8 +780,8 @@ static struct config_bool ConfigureNamesBool[] = gettext_noop("Logs the host name in the connection logs."), gettext_noop("By default, connection logs only show the IP address " "of the connecting host. If you want them to show the host name you " - "can turn this on, but depending on your host name resolution " - "setup it might impose a non-negligible performance penalty.") + "can turn this on, but depending on your host name resolution " + "setup it might impose a non-negligible performance penalty.") }, &log_hostname, false, NULL, NULL @@ -806,7 +807,7 @@ static struct config_bool ConfigureNamesBool[] = {"password_encryption", PGC_USERSET, CONN_AUTH_SECURITY, gettext_noop("Encrypt passwords."), gettext_noop("When a password is specified in CREATE USER or " - "ALTER USER without writing either ENCRYPTED or UNENCRYPTED, " + "ALTER USER without writing either ENCRYPTED or UNENCRYPTED, " "this parameter determines whether the password is to be encrypted.") }, &Password_encryption, @@ -816,9 +817,9 @@ static struct config_bool ConfigureNamesBool[] = {"transform_null_equals", PGC_USERSET, COMPAT_OPTIONS_CLIENT, gettext_noop("Treats \"expr=NULL\" as \"expr IS NULL\"."), gettext_noop("When turned on, expressions of the form expr = NULL " - "(or NULL = expr) are treated as expr IS NULL, that is, they " - "return true if expr evaluates to the null value, and false " - "otherwise. The correct behavior of expr = NULL is to always " + "(or NULL = expr) are treated as expr IS NULL, that is, they " + "return true if expr evaluates to the null value, and false " + "otherwise. The correct behavior of expr = NULL is to always " "return null (unknown).") }, &Transform_null_equals, @@ -979,7 +980,7 @@ static struct config_int ConfigureNamesInt[] = {"default_statistics_target", PGC_USERSET, QUERY_TUNING_OTHER, gettext_noop("Sets the default statistics target."), gettext_noop("This applies to table columns that have not had a " - "column-specific target set via ALTER TABLE SET STATISTICS.") + "column-specific target set via ALTER TABLE SET STATISTICS.") }, &default_statistics_target, 10, 1, 1000, NULL, NULL @@ -989,7 +990,7 @@ static struct config_int ConfigureNamesInt[] = gettext_noop("Sets the FROM-list size beyond which subqueries are not " "collapsed."), gettext_noop("The planner will merge subqueries into upper " - "queries if the resulting FROM list would have no more than " + "queries if the resulting FROM list would have no more than " "this many items.") }, &from_collapse_limit, @@ -1000,7 +1001,7 @@ static struct config_int ConfigureNamesInt[] = gettext_noop("Sets the FROM-list size beyond which JOIN constructs are not " "flattened."), gettext_noop("The planner will flatten explicit inner JOIN " - "constructs into lists of FROM items whenever a list of no more " + "constructs into lists of FROM items whenever a list of no more " "than this many items would result.") }, &join_collapse_limit, @@ -1052,12 +1053,12 @@ static struct config_int ConfigureNamesInt[] = * Note: There is some postprocessing done in PostmasterMain() to make * sure the buffers are at least twice the number of backends, so the * constraints here are partially unused. Similarly, the superuser - * reserved number is checked to ensure it is less than the max - * backends number. + * reserved number is checked to ensure it is less than the max backends + * number. * * MaxBackends is limited to INT_MAX/4 because some places compute - * 4*MaxBackends without any overflow check. Likewise we have to - * limit NBuffers to INT_MAX/2. + * 4*MaxBackends without any overflow check. Likewise we have to limit + * NBuffers to INT_MAX/2. */ { {"max_connections", PGC_POSTMASTER, CONN_AUTH_SETTINGS, @@ -1121,7 +1122,7 @@ static struct config_int ConfigureNamesInt[] = {"work_mem", PGC_USERSET, RESOURCES_MEM, gettext_noop("Sets the maximum memory to be used for query workspaces."), gettext_noop("This much memory may be used by each internal " - "sort operation and hash table before switching to " + "sort operation and hash table before switching to " "temporary disk files.") }, &work_mem, @@ -1278,7 +1279,7 @@ static struct config_int ConfigureNamesInt[] = {"max_locks_per_transaction", PGC_POSTMASTER, LOCK_MANAGEMENT, gettext_noop("Sets the maximum number of locks per transaction."), gettext_noop("The shared lock table is sized on the assumption that " - "at most max_locks_per_transaction * max_connections distinct " + "at most max_locks_per_transaction * max_connections distinct " "objects will need to be locked at any one time.") }, &max_locks_per_xact, @@ -1328,7 +1329,7 @@ static struct config_int ConfigureNamesInt[] = gettext_noop("Logs if filling of checkpoint segments happens more " "frequently than this (in seconds)."), gettext_noop("Write a message to the server log if checkpoints " - "caused by the filling of checkpoint segment files happens more " + "caused by the filling of checkpoint segment files happens more " "frequently than this number of seconds. Zero turns off the warning.") }, &CheckPointWarning, @@ -1368,7 +1369,7 @@ static struct config_int ConfigureNamesInt[] = {"extra_float_digits", PGC_USERSET, CLIENT_CONN_LOCALE, gettext_noop("Sets the number of digits displayed for floating-point values."), gettext_noop("This affects real, double precision, and geometric data types. " - "The parameter value is added to the standard number of digits " + "The parameter value is added to the standard number of digits " "(FLT_DIG or DBL_DIG as appropriate).") }, &extra_float_digits, @@ -1497,29 +1498,29 @@ static struct config_int ConfigureNamesInt[] = { {"tcp_keepalives_idle", PGC_USERSET, CLIENT_CONN_OTHER, - gettext_noop("Seconds between issuing TCP keepalives."), - gettext_noop("A value of 0 uses the system default."), - }, + gettext_noop("Seconds between issuing TCP keepalives."), + gettext_noop("A value of 0 uses the system default."), + }, &tcp_keepalives_idle, 0, 0, INT_MAX, assign_tcp_keepalives_idle, show_tcp_keepalives_idle }, { {"tcp_keepalives_interval", PGC_USERSET, CLIENT_CONN_OTHER, - gettext_noop("Seconds between TCP keepalive retransmits."), - gettext_noop("A value of 0 uses the system default."), - }, + gettext_noop("Seconds between TCP keepalive retransmits."), + gettext_noop("A value of 0 uses the system default."), + }, &tcp_keepalives_interval, 0, 0, INT_MAX, assign_tcp_keepalives_interval, show_tcp_keepalives_interval }, { {"tcp_keepalives_count", PGC_USERSET, CLIENT_CONN_OTHER, - gettext_noop("Maximum number of TCP keepalive retransmits."), - gettext_noop("This controls the number of consecutive keepalive retransmits that can be " - "lost before a connection is considered dead. A value of 0 uses the " - "system default."), - }, + gettext_noop("Maximum number of TCP keepalive retransmits."), + gettext_noop("This controls the number of consecutive keepalive retransmits that can be " + "lost before a connection is considered dead. A value of 0 uses the " + "system default."), + }, &tcp_keepalives_count, 0, 0, INT_MAX, assign_tcp_keepalives_count, show_tcp_keepalives_count }, @@ -1548,7 +1549,7 @@ static struct config_real ConfigureNamesReal[] = gettext_noop("Sets the planner's estimate of the cost of a nonsequentially " "fetched disk page."), gettext_noop("This is measured as a multiple of the cost of a " - "sequential page fetch. A higher value makes it more likely a " + "sequential page fetch. A higher value makes it more likely a " "sequential scan will be used, a lower value makes it more likely an " "index scan will be used.") }, @@ -1683,7 +1684,7 @@ static struct config_string ConfigureNamesString[] = {"log_min_messages", PGC_SUSET, LOGGING_WHEN, gettext_noop("Sets the message levels that are logged."), gettext_noop("Valid values are DEBUG5, DEBUG4, DEBUG3, DEBUG2, DEBUG1, " - "INFO, NOTICE, WARNING, ERROR, LOG, FATAL, and PANIC. Each level " + "INFO, NOTICE, WARNING, ERROR, LOG, FATAL, and PANIC. Each level " "includes all the levels that follow it.") }, &log_min_messages_str, @@ -2060,9 +2061,9 @@ static struct config_string ConfigureNamesString[] = { {"data_directory", PGC_POSTMASTER, FILE_LOCATIONS, - gettext_noop("Sets the server's data directory."), - NULL, - GUC_SUPERUSER_ONLY + gettext_noop("Sets the server's data directory."), + NULL, + GUC_SUPERUSER_ONLY }, &data_directory, NULL, NULL, NULL @@ -2070,9 +2071,9 @@ static struct config_string ConfigureNamesString[] = { {"config_file", PGC_POSTMASTER, FILE_LOCATIONS, - gettext_noop("Sets the server's main configuration file."), - NULL, - GUC_DISALLOW_IN_FILE | GUC_SUPERUSER_ONLY + gettext_noop("Sets the server's main configuration file."), + NULL, + GUC_DISALLOW_IN_FILE | GUC_SUPERUSER_ONLY }, &ConfigFileName, NULL, NULL, NULL @@ -2080,9 +2081,9 @@ static struct config_string ConfigureNamesString[] = { {"hba_file", PGC_POSTMASTER, FILE_LOCATIONS, - gettext_noop("Sets the server's \"hba\" configuration file"), - NULL, - GUC_SUPERUSER_ONLY + gettext_noop("Sets the server's \"hba\" configuration file"), + NULL, + GUC_SUPERUSER_ONLY }, &HbaFileName, NULL, NULL, NULL @@ -2090,9 +2091,9 @@ static struct config_string ConfigureNamesString[] = { {"ident_file", PGC_POSTMASTER, FILE_LOCATIONS, - gettext_noop("Sets the server's \"ident\" configuration file"), - NULL, - GUC_SUPERUSER_ONLY + gettext_noop("Sets the server's \"ident\" configuration file"), + NULL, + GUC_SUPERUSER_ONLY }, &IdentFileName, NULL, NULL, NULL @@ -2100,9 +2101,9 @@ static struct config_string ConfigureNamesString[] = { {"external_pid_file", PGC_POSTMASTER, FILE_LOCATIONS, - gettext_noop("Writes the postmaster PID to the specified file."), - NULL, - GUC_SUPERUSER_ONLY + gettext_noop("Writes the postmaster PID to the specified file."), + NULL, + GUC_SUPERUSER_ONLY }, &external_pid_file, NULL, assign_canonical_path, NULL @@ -2341,8 +2342,8 @@ static bool is_custom_class(const char *name, int dotPos) { /* - * assign_custom_variable_classes() has made sure no empty - * identifiers or whitespace exists in the variable + * assign_custom_variable_classes() has made sure no empty identifiers or + * whitespace exists in the variable */ bool result = false; const char *ccs = GetConfigOption("custom_variable_classes"); @@ -2472,21 +2473,21 @@ find_option(const char *name, int elevel) Assert(name); /* - * By equating const char ** with struct config_generic *, we are - * assuming the name field is first in config_generic. + * By equating const char ** with struct config_generic *, we are assuming + * the name field is first in config_generic. */ res = (struct config_generic **) bsearch((void *) &key, (void *) guc_variables, num_guc_variables, - sizeof(struct config_generic *), + sizeof(struct config_generic *), guc_var_compare); if (res) return *res; /* - * See if the name is an obsolete name for a variable. We assume that - * the set of supported old names is short enough that a brute-force - * search is the best way. + * See if the name is an obsolete name for a variable. We assume that the + * set of supported old names is short enough that a brute-force search is + * the best way. */ for (i = 0; map_old_guc_names[i] != NULL; i += 2) { @@ -2495,8 +2496,8 @@ find_option(const char *name, int elevel) } /* - * Check if the name is qualified, and if so, check if the qualifier - * maps to a custom variable class. + * Check if the name is qualified, and if so, check if the qualifier maps + * to a custom variable class. */ dot = strchr(name, GUC_QUALIFIER_SEPARATOR); if (dot != NULL && is_custom_class(name, dot - name)) @@ -2525,9 +2526,9 @@ static int guc_name_compare(const char *namea, const char *nameb) { /* - * The temptation to use strcasecmp() here must be resisted, because - * the array ordering has to remain stable across setlocale() calls. - * So, build our own with a simple ASCII-only downcasing. + * The temptation to use strcasecmp() here must be resisted, because the + * array ordering has to remain stable across setlocale() calls. So, build + * our own with a simple ASCII-only downcasing. */ while (*namea && *nameb) { @@ -2656,8 +2657,7 @@ InitializeGUCOptions(void) free(str); /* - * See notes in set_config_option about - * casting + * See notes in set_config_option about casting */ str = (char *) newstr; conf->reset_val = str; @@ -2683,8 +2683,8 @@ InitializeGUCOptions(void) PGC_POSTMASTER, PGC_S_OVERRIDE); /* - * For historical reasons, some GUC parameters can receive defaults - * from environment variables. Process those settings. + * For historical reasons, some GUC parameters can receive defaults from + * environment variables. Process those settings. */ env = getenv("PGPORT"); @@ -2727,9 +2727,9 @@ SelectConfigFiles(const char *userDoption, const char *progname) /* * Find the configuration file: if config_file was specified on the - * command line, use it, else use configdir/postgresql.conf. In any - * case ensure the result is an absolute path, so that it will be - * interpreted the same way by future backends. + * command line, use it, else use configdir/postgresql.conf. In any case + * ensure the result is an absolute path, so that it will be interpreted + * the same way by future backends. */ if (ConfigFileName) fname = make_absolute_path(ConfigFileName); @@ -2749,8 +2749,8 @@ SelectConfigFiles(const char *userDoption, const char *progname) } /* - * Set the ConfigFileName GUC variable to its final value, ensuring - * that it can't be overridden later. + * Set the ConfigFileName GUC variable to its final value, ensuring that + * it can't be overridden later. */ SetConfigOption("config_file", fname, PGC_POSTMASTER, PGC_S_OVERRIDE); free(fname); @@ -2771,8 +2771,8 @@ SelectConfigFiles(const char *userDoption, const char *progname) * If the data_directory GUC variable has been set, use that as DataDir; * otherwise use configdir if set; else punt. * - * Note: SetDataDir will copy and absolute-ize its argument, - * so we don't have to. + * Note: SetDataDir will copy and absolute-ize its argument, so we don't have + * to. */ if (data_directory) SetDataDir(data_directory); @@ -2792,9 +2792,9 @@ SelectConfigFiles(const char *userDoption, const char *progname) * Reflect the final DataDir value back into the data_directory GUC var. * (If you are wondering why we don't just make them a single variable, * it's because the EXEC_BACKEND case needs DataDir to be transmitted to - * child backends specially. XXX is that still true? Given that we - * now chdir to DataDir, EXEC_BACKEND can read the config file without - * knowing DataDir in advance.) + * child backends specially. XXX is that still true? Given that we now + * chdir to DataDir, EXEC_BACKEND can read the config file without knowing + * DataDir in advance.) */ SetConfigOption("data_directory", DataDir, PGC_POSTMASTER, PGC_S_OVERRIDE); @@ -2954,8 +2954,7 @@ ResetAllOptions(void) else if (newstr != str) { /* - * See notes in set_config_option about - * casting + * See notes in set_config_option about casting */ str = (char *) newstr; } @@ -3005,8 +3004,8 @@ push_old_value(struct config_generic * gconf) /* * We keep all the stack entries in TopTransactionContext so as to - * avoid allocation problems when a subtransaction back-fills - * stack entries for upper transaction levels. + * avoid allocation problems when a subtransaction back-fills stack + * entries for upper transaction levels. */ stack = (GucStack *) MemoryContextAlloc(TopTransactionContext, sizeof(GucStack)); @@ -3098,27 +3097,26 @@ AtEOXact_GUC(bool isCommit, bool isSubXact) Assert(stack->nest_level == my_level); /* - * We will pop the stack entry. Start by restoring outer xact - * status (since we may want to modify it below). Be careful to - * use my_status to reference the inner xact status below this - * point... + * We will pop the stack entry. Start by restoring outer xact status + * (since we may want to modify it below). Be careful to use + * my_status to reference the inner xact status below this point... */ gconf->status = stack->status; /* * We have two cases: * - * If commit and HAVE_TENTATIVE, set actual value to tentative (this - * is to override a SET LOCAL if one occurred later than SET). We - * keep the tentative value and propagate HAVE_TENTATIVE to the - * parent status, allowing the SET's effect to percolate up. (But - * if we're exiting the outermost transaction, we'll drop the - * HAVE_TENTATIVE bit below.) + * If commit and HAVE_TENTATIVE, set actual value to tentative (this is + * to override a SET LOCAL if one occurred later than SET). We keep + * the tentative value and propagate HAVE_TENTATIVE to the parent + * status, allowing the SET's effect to percolate up. (But if we're + * exiting the outermost transaction, we'll drop the HAVE_TENTATIVE + * bit below.) * * Otherwise, we have a transaction that aborted or executed only SET - * LOCAL (or no SET at all). In either case it should have no - * further effect, so restore both tentative and actual values - * from the stack entry. + * LOCAL (or no SET at all). In either case it should have no further + * effect, so restore both tentative and actual values from the stack + * entry. */ useTentative = isCommit && (my_status & GUC_HAVE_TENTATIVE) != 0; @@ -3150,7 +3148,7 @@ AtEOXact_GUC(bool isCommit, bool isSubXact) { if (conf->assign_hook) if (!(*conf->assign_hook) (newval, - true, PGC_S_OVERRIDE)) + true, PGC_S_OVERRIDE)) elog(LOG, "failed to commit %s", conf->gen.name); *conf->variable = newval; @@ -3183,7 +3181,7 @@ AtEOXact_GUC(bool isCommit, bool isSubXact) { if (conf->assign_hook) if (!(*conf->assign_hook) (newval, - true, PGC_S_OVERRIDE)) + true, PGC_S_OVERRIDE)) elog(LOG, "failed to commit %s", conf->gen.name); *conf->variable = newval; @@ -3216,7 +3214,7 @@ AtEOXact_GUC(bool isCommit, bool isSubXact) { if (conf->assign_hook) if (!(*conf->assign_hook) (newval, - true, PGC_S_OVERRIDE)) + true, PGC_S_OVERRIDE)) elog(LOG, "failed to commit %s", conf->gen.name); *conf->variable = newval; @@ -3253,7 +3251,7 @@ AtEOXact_GUC(bool isCommit, bool isSubXact) const char *newstr; newstr = (*conf->assign_hook) (newval, true, - PGC_S_OVERRIDE); + PGC_S_OVERRIDE); if (newstr == NULL) elog(LOG, "failed to commit %s", conf->gen.name); @@ -3263,8 +3261,7 @@ AtEOXact_GUC(bool isCommit, bool isSubXact) * If newval should now be freed, it'll be * taken care of below. * - * See notes in set_config_option about - * casting + * See notes in set_config_option about casting */ newval = (char *) newstr; } @@ -3291,8 +3288,8 @@ AtEOXact_GUC(bool isCommit, bool isSubXact) pfree(stack); /* - * If we're now out of all xact levels, forget TENTATIVE status - * bit; there's nothing tentative about the value anymore. + * If we're now out of all xact levels, forget TENTATIVE status bit; + * there's nothing tentative about the value anymore. */ if (!isSubXact) { @@ -3306,10 +3303,10 @@ AtEOXact_GUC(bool isCommit, bool isSubXact) } /* - * If we're now out of all xact levels, we can clear guc_dirty. (Note: - * we cannot reset guc_dirty when exiting a subtransaction, because we - * know that all outer transaction levels will have stacked values to - * deal with.) + * If we're now out of all xact levels, we can clear guc_dirty. (Note: we + * cannot reset guc_dirty when exiting a subtransaction, because we know + * that all outer transaction levels will have stacked values to deal + * with.) */ if (!isSubXact) guc_dirty = false; @@ -3326,8 +3323,8 @@ BeginReportingGUCOptions(void) int i; /* - * Don't do anything unless talking to an interactive frontend of - * protocol 3.0 or later. + * Don't do anything unless talking to an interactive frontend of protocol + * 3.0 or later. */ if (whereToSendOutput != Remote || PG_PROTOCOL_MAJOR(FrontendProtocol) < 3) @@ -3566,15 +3563,14 @@ set_config_option(const char *name, const char *value, { ereport(elevel, (errcode(ERRCODE_UNDEFINED_OBJECT), - errmsg("unrecognized configuration parameter \"%s\"", name))); + errmsg("unrecognized configuration parameter \"%s\"", name))); return false; } /* - * Check if the option can be set at this time. See guc.h for the - * precise rules. Note that we don't want to throw errors if we're in - * the SIGHUP context. In that case we just ignore the attempt and - * return true. + * Check if the option can be set at this time. See guc.h for the precise + * rules. Note that we don't want to throw errors if we're in the SIGHUP + * context. In that case we just ignore the attempt and return true. */ switch (record->context) { @@ -3613,22 +3609,22 @@ set_config_option(const char *name, const char *value, } /* - * Hmm, the idea of the SIGHUP context is "ought to be global, - * but can be changed after postmaster start". But there's - * nothing that prevents a crafty administrator from sending - * SIGHUP signals to individual backends only. + * Hmm, the idea of the SIGHUP context is "ought to be global, but + * can be changed after postmaster start". But there's nothing + * that prevents a crafty administrator from sending SIGHUP + * signals to individual backends only. */ break; case PGC_BACKEND: if (context == PGC_SIGHUP) { /* - * If a PGC_BACKEND parameter is changed in the config - * file, we want to accept the new value in the postmaster - * (whence it will propagate to subsequently-started - * backends), but ignore it in existing backends. This is - * a tad klugy, but necessary because we don't re-read the - * config file during backend start. + * If a PGC_BACKEND parameter is changed in the config file, + * we want to accept the new value in the postmaster (whence + * it will propagate to subsequently-started backends), but + * ignore it in existing backends. This is a tad klugy, but + * necessary because we don't re-read the config file during + * backend start. */ if (IsUnderPostmaster) return true; @@ -3647,8 +3643,8 @@ set_config_option(const char *name, const char *value, { ereport(elevel, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), - errmsg("permission denied to set parameter \"%s\"", - name))); + errmsg("permission denied to set parameter \"%s\"", + name))); return false; } break; @@ -3666,10 +3662,9 @@ set_config_option(const char *name, const char *value, /* * Ignore attempted set if overridden by previously processed setting. * However, if changeVal is false then plow ahead anyway since we are - * trying to find out if the value is potentially good, not actually - * use it. Also keep going if makeDefault is true, since we may want - * to set the reset/stacked values even if we can't set the variable - * itself. + * trying to find out if the value is potentially good, not actually use + * it. Also keep going if makeDefault is true, since we may want to set + * the reset/stacked values even if we can't set the variable itself. */ if (record->source > source) { @@ -3698,8 +3693,8 @@ set_config_option(const char *name, const char *value, { ereport(elevel, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("parameter \"%s\" requires a Boolean value", - name))); + errmsg("parameter \"%s\" requires a Boolean value", + name))); return false; } } @@ -3714,8 +3709,8 @@ set_config_option(const char *name, const char *value, { ereport(elevel, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("invalid value for parameter \"%s\": %d", - name, (int) newval))); + errmsg("invalid value for parameter \"%s\": %d", + name, (int) newval))); return false; } @@ -3774,8 +3769,8 @@ set_config_option(const char *name, const char *value, { ereport(elevel, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("parameter \"%s\" requires an integer value", - name))); + errmsg("parameter \"%s\" requires an integer value", + name))); return false; } if (newval < conf->min || newval > conf->max) @@ -3783,7 +3778,7 @@ set_config_option(const char *name, const char *value, ereport(elevel, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("%d is outside the valid range for parameter \"%s\" (%d .. %d)", - newval, name, conf->min, conf->max))); + newval, name, conf->min, conf->max))); return false; } } @@ -3798,8 +3793,8 @@ set_config_option(const char *name, const char *value, { ereport(elevel, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("invalid value for parameter \"%s\": %d", - name, newval))); + errmsg("invalid value for parameter \"%s\": %d", + name, newval))); return false; } @@ -3858,8 +3853,8 @@ set_config_option(const char *name, const char *value, { ereport(elevel, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("parameter \"%s\" requires a numeric value", - name))); + errmsg("parameter \"%s\" requires a numeric value", + name))); return false; } if (newval < conf->min || newval > conf->max) @@ -3867,7 +3862,7 @@ set_config_option(const char *name, const char *value, ereport(elevel, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("%g is outside the valid range for parameter \"%s\" (%g .. %g)", - newval, name, conf->min, conf->max))); + newval, name, conf->min, conf->max))); return false; } } @@ -3882,8 +3877,8 @@ set_config_option(const char *name, const char *value, { ereport(elevel, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("invalid value for parameter \"%s\": %g", - name, newval))); + errmsg("invalid value for parameter \"%s\": %g", + name, newval))); return false; } @@ -3945,9 +3940,8 @@ set_config_option(const char *name, const char *value, else if (conf->reset_val) { /* - * We could possibly avoid strdup here, but easier to - * make this case work the same as the normal - * assignment case. + * We could possibly avoid strdup here, but easier to make + * this case work the same as the normal assignment case. */ newval = guc_strdup(elevel, conf->reset_val); if (newval == NULL) @@ -3977,8 +3971,8 @@ set_config_option(const char *name, const char *value, free(newval); ereport(elevel, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("invalid value for parameter \"%s\": \"%s\"", - name, value ? value : ""))); + errmsg("invalid value for parameter \"%s\": \"%s\"", + name, value ? value : ""))); return false; } else if (hookresult != newval) @@ -3986,13 +3980,12 @@ set_config_option(const char *name, const char *value, free(newval); /* - * Having to cast away const here is annoying, but - * the alternative is to declare assign_hooks as - * returning char*, which would mean they'd have - * to cast away const, or as both taking and - * returning char*, which doesn't seem attractive - * either --- we don't want them to scribble on - * the passed str. + * Having to cast away const here is annoying, but the + * alternative is to declare assign_hooks as returning + * char*, which would mean they'd have to cast away + * const, or as both taking and returning char*, which + * doesn't seem attractive either --- we don't want + * them to scribble on the passed str. */ newval = (char *) hookresult; } @@ -4087,7 +4080,7 @@ GetConfigOption(const char *name) if (record == NULL) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), - errmsg("unrecognized configuration parameter \"%s\"", name))); + errmsg("unrecognized configuration parameter \"%s\"", name))); if ((record->flags & GUC_SUPERUSER_ONLY) && !superuser()) ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), @@ -4127,7 +4120,7 @@ GetConfigOptionResetString(const char *name) if (record == NULL) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), - errmsg("unrecognized configuration parameter \"%s\"", name))); + errmsg("unrecognized configuration parameter \"%s\"", name))); if ((record->flags & GUC_SUPERUSER_ONLY) && !superuser()) ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), @@ -4191,8 +4184,8 @@ flatten_set_variable_args(const char *name, List *args) ListCell *l; /* - * Fast path if just DEFAULT. We do not check the variable name in - * this case --- necessary for RESET ALL to work correctly. + * Fast path if just DEFAULT. We do not check the variable name in this + * case --- necessary for RESET ALL to work correctly. */ if (args == NIL) return NULL; @@ -4202,7 +4195,7 @@ flatten_set_variable_args(const char *name, List *args) if (record == NULL) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), - errmsg("unrecognized configuration parameter \"%s\"", name))); + errmsg("unrecognized configuration parameter \"%s\"", name))); flags = record->flags; @@ -4240,18 +4233,18 @@ flatten_set_variable_args(const char *name, List *args) if (arg->typename != NULL) { /* - * Must be a ConstInterval argument for TIME ZONE. - * Coerce to interval and back to normalize the value - * and account for any typmod. + * Must be a ConstInterval argument for TIME ZONE. Coerce + * to interval and back to normalize the value and account + * for any typmod. */ - Datum interval; + Datum interval; char *intervalout; interval = - DirectFunctionCall3(interval_in, - CStringGetDatum(val), - ObjectIdGetDatum(InvalidOid), - Int32GetDatum(arg->typename->typmod)); + DirectFunctionCall3(interval_in, + CStringGetDatum(val), + ObjectIdGetDatum(InvalidOid), + Int32GetDatum(arg->typename->typmod)); intervalout = DatumGetCString(DirectFunctionCall1(interval_out, @@ -4261,8 +4254,8 @@ flatten_set_variable_args(const char *name, List *args) else { /* - * Plain string literal or identifier. For quote - * mode, quote it if it's not a vanilla identifier. + * Plain string literal or identifier. For quote mode, + * quote it if it's not a vanilla identifier. */ if (flags & GUC_LIST_QUOTE) appendStringInfoString(&buf, quote_identifier(val)); @@ -4325,8 +4318,8 @@ set_config_by_name(PG_FUNCTION_ARGS) value = DatumGetCString(DirectFunctionCall1(textout, PG_GETARG_DATUM(1))); /* - * Get the desired state of is_local. Default to false if provided - * value is NULL + * Get the desired state of is_local. Default to false if provided value + * is NULL */ if (PG_ARGISNULL(2)) is_local = false; @@ -4359,11 +4352,11 @@ define_custom_variable(struct config_generic * variable) const char *value; struct config_string *pHolder; struct config_generic **res = (struct config_generic **) bsearch( - (void *) &nameAddr, - (void *) guc_variables, - num_guc_variables, - sizeof(struct config_generic *), - guc_var_compare); + (void *) &nameAddr, + (void *) guc_variables, + num_guc_variables, + sizeof(struct config_generic *), + guc_var_compare); if (res == NULL) { @@ -4388,8 +4381,7 @@ define_custom_variable(struct config_generic * variable) value = *pHolder->variable; /* - * Assign the string value stored in the placeholder to the real - * variable. + * Assign the string value stored in the placeholder to the real variable. * * XXX this is not really good enough --- it should be a nontransactional * assignment, since we don't want it to roll back if the current xact @@ -4656,7 +4648,7 @@ ShowAllGUCConfig(DestReceiver *dest) TEXTOID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber) 3, "description", TEXTOID, -1, 0); - + /* prepare for projection of tuples */ tstate = begin_tup_output_tupdesc(dest, tupdesc); @@ -4698,7 +4690,7 @@ GetConfigOptionByName(const char *name, const char **varname) if (record == NULL) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), - errmsg("unrecognized configuration parameter \"%s\"", name))); + errmsg("unrecognized configuration parameter \"%s\"", name))); if ((record->flags & GUC_SUPERUSER_ONLY) && !superuser()) ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), @@ -4814,8 +4806,7 @@ GetConfigOptionByNum(int varnum, const char **values, bool *noshow) default: { /* - * should never get here, but in case we do, set 'em to - * NULL + * should never get here, but in case we do, set 'em to NULL */ /* min_val */ @@ -4884,14 +4875,13 @@ show_all_settings(PG_FUNCTION_ARGS) funcctx = SRF_FIRSTCALL_INIT(); /* - * switch to memory context appropriate for multiple function - * calls + * switch to memory context appropriate for multiple function calls */ oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); /* - * need a tuple descriptor representing NUM_PG_SETTINGS_ATTS - * columns of the appropriate types + * need a tuple descriptor representing NUM_PG_SETTINGS_ATTS columns + * of the appropriate types */ tupdesc = CreateTemplateTupleDesc(NUM_PG_SETTINGS_ATTS, false); TupleDescInitEntry(tupdesc, (AttrNumber) 1, "name", @@ -4916,8 +4906,8 @@ show_all_settings(PG_FUNCTION_ARGS) TEXTOID, -1, 0); /* - * Generate attribute metadata needed later to produce tuples from - * raw C strings + * Generate attribute metadata needed later to produce tuples from raw + * C strings */ attinmeta = TupleDescGetAttInMetadata(tupdesc); funcctx->attinmeta = attinmeta; @@ -5144,8 +5134,8 @@ write_nondefault_variables(GucContext context) } /* - * Put new file in place. This could delay on Win32, but we don't - * hold any exclusive locks. + * Put new file in place. This could delay on Win32, but we don't hold + * any exclusive locks. */ rename(CONFIG_EXEC_PARAMS_NEW, CONFIG_EXEC_PARAMS); } @@ -5233,8 +5223,7 @@ read_nondefault_variables(void) FreeFile(fp); } - -#endif /* EXEC_BACKEND */ +#endif /* EXEC_BACKEND */ /* @@ -5317,15 +5306,15 @@ ProcessGUCArray(ArrayType *array, GucSource source) { ereport(WARNING, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("could not parse setting for parameter \"%s\"", name))); + errmsg("could not parse setting for parameter \"%s\"", name))); free(name); continue; } /* - * We process all these options at SUSET level. We assume that - * the right to insert an option into pg_database or pg_authid was - * checked when it was inserted. + * We process all these options at SUSET level. We assume that the + * right to insert an option into pg_database or pg_authid was checked + * when it was inserted. */ SetConfigOption(name, value, PGC_SUSET, source); @@ -5515,7 +5504,7 @@ assign_log_destination(const char *value, bool doit, GucSource source) if (source >= PGC_S_INTERACTIVE) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("invalid list syntax for parameter \"log_destination\""))); + errmsg("invalid list syntax for parameter \"log_destination\""))); return NULL; } @@ -5538,8 +5527,8 @@ assign_log_destination(const char *value, bool doit, GucSource source) if (source >= PGC_S_INTERACTIVE) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("unrecognized \"log_destination\" key word: \"%s\"", - tok))); + errmsg("unrecognized \"log_destination\" key word: \"%s\"", + tok))); pfree(rawstring); list_free(elemlist); return NULL; @@ -5560,7 +5549,7 @@ assign_log_destination(const char *value, bool doit, GucSource source) static const char * assign_syslog_facility(const char *facility, bool doit, GucSource source) { - int syslog_fac; + int syslog_fac; if (pg_strcasecmp(facility, "LOCAL0") == 0) syslog_fac = LOG_LOCAL0; @@ -5599,8 +5588,7 @@ assign_syslog_ident(const char *ident, bool doit, GucSource source) return ident; } - -#endif /* HAVE_SYSLOG */ +#endif /* HAVE_SYSLOG */ static const char * @@ -5690,8 +5678,8 @@ assign_msglvl(int *var, const char *newval, bool doit, GucSource source) } /* - * Client_min_messages always prints 'info', but we allow it as a - * value anyway. + * Client_min_messages always prints 'info', but we allow it as a value + * anyway. */ else if (pg_strcasecmp(newval, "info") == 0) { @@ -5784,8 +5772,8 @@ static const char * show_num_temp_buffers(void) { /* - * We show the GUC var until local buffers have been initialized, - * and NLocBuffer afterwards. + * We show the GUC var until local buffers have been initialized, and + * NLocBuffer afterwards. */ static char nbuf[32]; @@ -5801,7 +5789,7 @@ assign_phony_autocommit(bool newval, bool doit, GucSource source) if (doit && source >= PGC_S_INTERACTIVE) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("SET AUTOCOMMIT TO OFF is no longer supported"))); + errmsg("SET AUTOCOMMIT TO OFF is no longer supported"))); return false; } return true; @@ -5844,8 +5832,8 @@ assign_custom_variable_classes(const char *newval, bool doit, GucSource source) if (hasSpaceAfterToken || !isalnum(c)) { /* - * Syntax error due to token following space after token or - * non alpha numeric character + * Syntax error due to token following space after token or non + * alpha numeric character */ ereport(LOG, (errcode(ERRCODE_SYNTAX_ERROR), diff --git a/src/backend/utils/misc/pg_rusage.c b/src/backend/utils/misc/pg_rusage.c index a4a6d9e586..cf7bbb427c 100644 --- a/src/backend/utils/misc/pg_rusage.c +++ b/src/backend/utils/misc/pg_rusage.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/misc/pg_rusage.c,v 1.1 2005/10/03 22:52:23 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/misc/pg_rusage.c,v 1.2 2005/10/15 02:49:36 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -65,9 +65,9 @@ pg_rusage_show(const PGRUsage *ru0) snprintf(result, sizeof(result), "CPU %d.%02ds/%d.%02du sec elapsed %d.%02d sec", (int) (ru1.ru.ru_stime.tv_sec - ru0->ru.ru_stime.tv_sec), - (int) (ru1.ru.ru_stime.tv_usec - ru0->ru.ru_stime.tv_usec) / 10000, + (int) (ru1.ru.ru_stime.tv_usec - ru0->ru.ru_stime.tv_usec) / 10000, (int) (ru1.ru.ru_utime.tv_sec - ru0->ru.ru_utime.tv_sec), - (int) (ru1.ru.ru_utime.tv_usec - ru0->ru.ru_utime.tv_usec) / 10000, + (int) (ru1.ru.ru_utime.tv_usec - ru0->ru.ru_utime.tv_usec) / 10000, (int) (ru1.tv.tv_sec - ru0->tv.tv_sec), (int) (ru1.tv.tv_usec - ru0->tv.tv_usec) / 10000); diff --git a/src/backend/utils/misc/ps_status.c b/src/backend/utils/misc/ps_status.c index 1627cf49f7..af1421cd2f 100644 --- a/src/backend/utils/misc/ps_status.c +++ b/src/backend/utils/misc/ps_status.c @@ -5,7 +5,7 @@ * to contain some useful information. Mechanism differs wildly across * platforms. * - * $PostgreSQL: pgsql/src/backend/utils/misc/ps_status.c,v 1.24 2005/05/24 07:16:27 neilc Exp $ + * $PostgreSQL: pgsql/src/backend/utils/misc/ps_status.c,v 1.25 2005/10/15 02:49:36 momjian Exp $ * * Copyright (c) 2000-2005, PostgreSQL Global Development Group * various details abducted from various places @@ -85,7 +85,6 @@ extern char **environ; #define PS_BUFFER_SIZE 256 static char ps_buffer[PS_BUFFER_SIZE]; static const size_t ps_buffer_size = PS_BUFFER_SIZE; - #else /* PS_USE_CLOBBER_ARGV */ static char *ps_buffer; /* will point to argv area */ static size_t ps_buffer_size; /* space determined at run time */ @@ -98,20 +97,22 @@ static int save_argc; static char **save_argv; #ifdef WIN32 - /* - * Win32 does not support showing any changed arguments. To make it - * at all possible to track which backend is doing what, we create - * a named object that can be viewed with for example Process Explorer - */ + + /* + * Win32 does not support showing any changed arguments. To make it at all + * possible to track which backend is doing what, we create a named object + * that can be viewed with for example Process Explorer + */ static HANDLE ident_handle = INVALID_HANDLE_VALUE; -static void pgwin32_update_ident(char *ident) +static void +pgwin32_update_ident(char *ident) { - char name[PS_BUFFER_SIZE+32]; + char name[PS_BUFFER_SIZE + 32]; if (ident_handle != INVALID_HANDLE_VALUE) CloseHandle(ident_handle); - sprintf(name,"pgident: %s",ident); + sprintf(name, "pgident: %s", ident); ident_handle = CreateEvent(NULL, TRUE, @@ -130,7 +131,7 @@ static void pgwin32_update_ident(char *ident) * environment strings may be moved, so this should be called before any code * that might try to hang onto a getenv() result.) */ -char ** +char ** save_ps_display_args(int argc, char **argv) { save_argc = argc; @@ -139,8 +140,8 @@ save_ps_display_args(int argc, char **argv) #if defined(PS_USE_CLOBBER_ARGV) /* - * If we're going to overwrite the argv area, count the available - * space. Also move the environment to make additional room. + * If we're going to overwrite the argv area, count the available space. + * Also move the environment to make additional room. */ { char *end_of_area = NULL; @@ -193,12 +194,12 @@ save_ps_display_args(int argc, char **argv) * argument parsing purposes. * * (NB: do NOT think to remove the copying of argv[], even though - * postmaster.c finishes looking at argv[] long before we ever - * consider changing the ps display. On some platforms, getopt() - * keeps pointers into the argv array, and will get horribly confused - * when it is re-called to analyze a subprocess' argument string if - * the argv storage has been clobbered meanwhile. Other platforms - * have other dependencies on argv[]. + * postmaster.c finishes looking at argv[] long before we ever consider + * changing the ps display. On some platforms, getopt() keeps pointers + * into the argv array, and will get horribly confused when it is + * re-called to analyze a subprocess' argument string if the argv storage + * has been clobbered meanwhile. Other platforms have other dependencies + * on argv[]. */ { char **new_argv; @@ -220,8 +221,7 @@ save_ps_display_args(int argc, char **argv) argv = new_argv; } -#endif /* PS_USE_CHANGE_ARGV or - * PS_USE_CLOBBER_ARGV */ +#endif /* PS_USE_CHANGE_ARGV or PS_USE_CLOBBER_ARGV */ return argv; } @@ -278,8 +278,8 @@ init_ps_display(const char *username, const char *dbname, #ifdef PS_USE_SETPROCTITLE /* - * apparently setproctitle() already adds a `progname:' prefix to the - * ps line + * apparently setproctitle() already adds a `progname:' prefix to the ps + * line */ snprintf(ps_buffer, ps_buffer_size, "%s %s %s ", @@ -295,7 +295,6 @@ init_ps_display(const char *username, const char *dbname, #ifdef WIN32 pgwin32_update_ident(ps_buffer); #endif - #endif /* not PS_USE_NONE */ } @@ -360,7 +359,6 @@ set_ps_display(const char *activity) #ifdef WIN32 pgwin32_update_ident(ps_buffer); #endif - #endif /* not PS_USE_NONE */ } diff --git a/src/backend/utils/misc/superuser.c b/src/backend/utils/misc/superuser.c index c9c17cef70..6eba2fb935 100644 --- a/src/backend/utils/misc/superuser.c +++ b/src/backend/utils/misc/superuser.c @@ -14,7 +14,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/misc/superuser.c,v 1.33 2005/08/15 02:40:26 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/misc/superuser.c,v 1.34 2005/10/15 02:49:36 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -32,9 +32,9 @@ * the status of the last requested roleid. The cache can be flushed * at need by watching for cache update events on pg_authid. */ -static Oid last_roleid = InvalidOid; /* InvalidOid == cache not valid */ -static bool last_roleid_is_super = false; -static bool roleid_callback_registered = false; +static Oid last_roleid = InvalidOid; /* InvalidOid == cache not valid */ +static bool last_roleid_is_super = false; +static bool roleid_callback_registered = false; static void RoleidCallback(Datum arg, Oid relid); diff --git a/src/backend/utils/mmgr/aset.c b/src/backend/utils/mmgr/aset.c index 6c1b5f390d..70bcf778a1 100644 --- a/src/backend/utils/mmgr/aset.c +++ b/src/backend/utils/mmgr/aset.c @@ -11,7 +11,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/mmgr/aset.c,v 1.63 2005/09/01 18:15:42 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/mmgr/aset.c,v 1.64 2005/10/15 02:49:36 momjian Exp $ * * NOTE: * This is a new (Feb. 05, 1999) implementation of the allocation set @@ -140,8 +140,7 @@ typedef struct AllocSetContext /* Allocation parameters for this context: */ Size initBlockSize; /* initial block size */ Size maxBlockSize; /* maximum block size */ - AllocBlock keeper; /* if not NULL, keep this block over - * resets */ + AllocBlock keeper; /* if not NULL, keep this block over resets */ } AllocSetContext; typedef AllocSetContext *AllocSet; @@ -342,8 +341,8 @@ AllocSetContextCreate(MemoryContext parent, ereport(ERROR, (errcode(ERRCODE_OUT_OF_MEMORY), errmsg("out of memory"), - errdetail("Failed while creating memory context \"%s\".", - name))); + errdetail("Failed while creating memory context \"%s\".", + name))); } block->aset = context; block->freeptr = ((char *) block) + ALLOC_BLOCKHDRSZ; @@ -505,8 +504,8 @@ AllocSetAlloc(MemoryContext context, Size size) AssertArg(AllocSetIsValid(set)); /* - * If requested size exceeds maximum for chunks, allocate an entire - * block for this request. + * If requested size exceeds maximum for chunks, allocate an entire block + * for this request. */ if (size > ALLOC_CHUNK_LIMIT) { @@ -536,8 +535,8 @@ AllocSetAlloc(MemoryContext context, Size size) #endif /* - * Stick the new block underneath the active allocation block, so - * that we don't lose the use of the space remaining therein. + * Stick the new block underneath the active allocation block, so that + * we don't lose the use of the space remaining therein. */ if (set->blocks != NULL) { @@ -558,8 +557,7 @@ AllocSetAlloc(MemoryContext context, Size size) /* * Request is small enough to be treated as a chunk. Look in the - * corresponding free list to see if there is a free chunk we could - * reuse. + * corresponding free list to see if there is a free chunk we could reuse. */ fidx = AllocSetFreeIndex(size); priorfree = NULL; @@ -571,8 +569,8 @@ AllocSetAlloc(MemoryContext context, Size size) } /* - * If one is found, remove it from the free list, make it again a - * member of the alloc set and return its data address. + * If one is found, remove it from the free list, make it again a member + * of the alloc set and return its data address. */ if (chunk != NULL) { @@ -604,8 +602,8 @@ AllocSetAlloc(MemoryContext context, Size size) Assert(chunk_size >= size); /* - * If there is enough room in the active allocation block, we will put - * the chunk into that block. Else must start a new one. + * If there is enough room in the active allocation block, we will put the + * chunk into that block. Else must start a new one. */ if ((block = set->blocks) != NULL) { @@ -614,16 +612,16 @@ AllocSetAlloc(MemoryContext context, Size size) if (availspace < (chunk_size + ALLOC_CHUNKHDRSZ)) { /* - * The existing active (top) block does not have enough room - * for the requested allocation, but it might still have a - * useful amount of space in it. Once we push it down in the - * block list, we'll never try to allocate more space from it. - * So, before we do that, carve up its free space into chunks - * that we can put on the set's freelists. + * The existing active (top) block does not have enough room for + * the requested allocation, but it might still have a useful + * amount of space in it. Once we push it down in the block list, + * we'll never try to allocate more space from it. So, before we + * do that, carve up its free space into chunks that we can put on + * the set's freelists. * * Because we can only get here when there's less than - * ALLOC_CHUNK_LIMIT left in the block, this loop cannot - * iterate more than ALLOCSET_NUM_FREELISTS-1 times. + * ALLOC_CHUNK_LIMIT left in the block, this loop cannot iterate + * more than ALLOCSET_NUM_FREELISTS-1 times. */ while (availspace >= ((1 << ALLOC_MINBITS) + ALLOC_CHUNKHDRSZ)) { @@ -631,10 +629,9 @@ AllocSetAlloc(MemoryContext context, Size size) int a_fidx = AllocSetFreeIndex(availchunk); /* - * In most cases, we'll get back the index of the next - * larger freelist than the one we need to put this chunk - * on. The exception is when availchunk is exactly a - * power of 2. + * In most cases, we'll get back the index of the next larger + * freelist than the one we need to put this chunk on. The + * exception is when availchunk is exactly a power of 2. */ if (availchunk != (1 << (a_fidx + ALLOC_MINBITS))) { @@ -676,11 +673,11 @@ AllocSetAlloc(MemoryContext context, Size size) else { /* - * Use first power of 2 that is larger than previous block, - * but not more than the allowed limit. (We don't simply - * double the prior block size, because in some cases this - * could be a funny size, eg if very first allocation was for - * an odd-sized large chunk.) + * Use first power of 2 that is larger than previous block, but + * not more than the allowed limit. (We don't simply double the + * prior block size, because in some cases this could be a funny + * size, eg if very first allocation was for an odd-sized large + * chunk.) */ Size pblksize = set->blocks->endptr - ((char *) set->blocks); @@ -692,8 +689,8 @@ AllocSetAlloc(MemoryContext context, Size size) } /* - * If initBlockSize is less than ALLOC_CHUNK_LIMIT, we could need - * more space... but try to keep it a power of 2. + * If initBlockSize is less than ALLOC_CHUNK_LIMIT, we could need more + * space... but try to keep it a power of 2. */ required_size = chunk_size + ALLOC_BLOCKHDRSZ + ALLOC_CHUNKHDRSZ; while (blksize < required_size) @@ -703,9 +700,8 @@ AllocSetAlloc(MemoryContext context, Size size) 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... + * 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) { @@ -730,13 +726,13 @@ AllocSetAlloc(MemoryContext context, Size size) block->endptr = ((char *) block) + blksize; /* - * If this is the first block of the set, make it the "keeper" - * block. Formerly, a keeper block could only be created during - * context creation, but allowing it to happen here lets us have - * fast reset cycling even for contexts created with - * minContextSize = 0; that way we don't have to force space to be - * allocated in contexts that might never need any space. Don't - * mark an oversize block as a keeper, however. + * If this is the first block of the set, make it the "keeper" block. + * Formerly, a keeper block could only be created during context + * creation, but allowing it to happen here lets us have fast reset + * cycling even for contexts created with minContextSize = 0; that way + * we don't have to force space to be allocated in contexts that might + * never need any space. Don't mark an oversize block as a keeper, + * however. */ if (set->blocks == NULL && blksize == set->initBlockSize) { @@ -870,8 +866,8 @@ AllocSetRealloc(MemoryContext context, void *pointer, Size size) /* * Chunk sizes are aligned to power of 2 in AllocSetAlloc(). Maybe the - * allocated area already is >= the new size. (In particular, we - * always fall out here if the requested size is a decrease.) + * allocated area already is >= the new size. (In particular, we always + * fall out here if the requested size is a decrease.) */ if (oldsize >= size) { @@ -887,9 +883,9 @@ AllocSetRealloc(MemoryContext context, void *pointer, Size size) if (oldsize > ALLOC_CHUNK_LIMIT) { /* - * The chunk must been allocated as a single-chunk block. Find - * the containing block and use realloc() to make it bigger with - * minimum space wastage. + * The chunk must been allocated as a single-chunk block. Find the + * containing block and use realloc() to make it bigger with minimum + * space wastage. */ AllocBlock block = set->blocks; AllocBlock prevblock = NULL; @@ -944,15 +940,15 @@ AllocSetRealloc(MemoryContext context, void *pointer, Size size) else { /* - * Small-chunk case. If the chunk is the last one in its block, - * there might be enough free space after it that we can just - * enlarge the chunk in-place. It's relatively painful to find - * the containing block in the general case, but we can detect - * last-ness quite cheaply for the typical case where the chunk is - * in the active (topmost) allocation block. (At least with the - * regression tests and code as of 1/2001, realloc'ing the last - * chunk of a non-topmost block hardly ever happens, so it's not - * worth scanning the block list to catch that case.) + * Small-chunk case. If the chunk is the last one in its block, there + * might be enough free space after it that we can just enlarge the + * chunk in-place. It's relatively painful to find the containing + * block in the general case, but we can detect last-ness quite + * cheaply for the typical case where the chunk is in the active + * (topmost) allocation block. (At least with the regression tests + * and code as of 1/2001, realloc'ing the last chunk of a non-topmost + * block hardly ever happens, so it's not worth scanning the block + * list to catch that case.) * * NOTE: must be careful not to create a chunk of a size that * AllocSetAlloc would not create, else we'll get confused later. @@ -1031,10 +1027,10 @@ AllocSetIsEmpty(MemoryContext context) AllocSet set = (AllocSet) context; /* - * For now, we say "empty" only if the context is new or just reset. - * We could examine the freelists to determine if all space has been - * freed, but it's not really worth the trouble for present uses of - * this functionality. + * For now, we say "empty" only if the context is new or just reset. We + * could examine the freelists to determine if all space has been freed, + * but it's not really worth the trouble for present uses of this + * functionality. */ if (set->isReset) return true; @@ -1073,7 +1069,7 @@ AllocSetStats(MemoryContext context) } } fprintf(stderr, - "%s: %ld total in %ld blocks; %ld free (%ld chunks); %ld used\n", + "%s: %ld total in %ld blocks; %ld free (%ld chunks); %ld used\n", set->header.name, totalspace, nblocks, freespace, nchunks, totalspace - freespace); } @@ -1144,9 +1140,9 @@ AllocSetCheck(MemoryContext context) name, chunk, block); /* - * If chunk is allocated, check for correct aset pointer. (If - * it's free, the aset is the freelist pointer, which we can't - * check as easily...) + * If chunk is allocated, check for correct aset pointer. (If it's + * free, the aset is the freelist pointer, which we can't check as + * easily...) */ if (dsize > 0 && chunk->aset != (void *) set) elog(WARNING, "problem in alloc set %s: bogus aset link in block %p, chunk %p", diff --git a/src/backend/utils/mmgr/mcxt.c b/src/backend/utils/mmgr/mcxt.c index 6d68e30f7e..b653273022 100644 --- a/src/backend/utils/mmgr/mcxt.c +++ b/src/backend/utils/mmgr/mcxt.c @@ -14,7 +14,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/mmgr/mcxt.c,v 1.55 2005/05/14 23:16:29 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/mmgr/mcxt.c,v 1.56 2005/10/15 02:49:36 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -78,8 +78,8 @@ MemoryContextInit(void) AssertState(TopMemoryContext == NULL); /* - * Initialize TopMemoryContext as an AllocSetContext with slow growth - * rate --- we don't really expect much to be allocated in it. + * Initialize TopMemoryContext as an AllocSetContext with slow growth rate + * --- we don't really expect much to be allocated in it. * * (There is special-case code in MemoryContextCreate() for this call.) */ @@ -90,18 +90,18 @@ MemoryContextInit(void) 8 * 1024); /* - * Not having any other place to point CurrentMemoryContext, make it - * point to TopMemoryContext. Caller should change this soon! + * Not having any other place to point CurrentMemoryContext, make it point + * to TopMemoryContext. Caller should change this soon! */ CurrentMemoryContext = TopMemoryContext; /* - * Initialize ErrorContext as an AllocSetContext with slow growth rate - * --- we don't really expect much to be allocated in it. More to the - * point, require it to contain at least 8K at all times. This is the - * only case where retained memory in a context is *essential* --- we - * want to be sure ErrorContext still has some memory even if we've - * run out elsewhere! + * Initialize ErrorContext as an AllocSetContext with slow growth rate --- + * we don't really expect much to be allocated in it. More to the point, + * require it to contain at least 8K at all times. This is the only case + * where retained memory in a context is *essential* --- we want to be + * sure ErrorContext still has some memory even if we've run out + * elsewhere! */ ErrorContext = AllocSetContextCreate(TopMemoryContext, "ErrorContext", @@ -169,9 +169,9 @@ MemoryContextDelete(MemoryContext context) MemoryContextDeleteChildren(context); /* - * We delink the context from its parent before deleting it, so that - * if there's an error we won't have deleted/busted contexts still - * attached to the context tree. Better a leak than a crash. + * We delink the context from its parent before deleting it, so that if + * there's an error we won't have deleted/busted contexts still attached + * to the context tree. Better a leak than a crash. */ if (context->parent) { @@ -208,8 +208,8 @@ MemoryContextDeleteChildren(MemoryContext context) AssertArg(MemoryContextIsValid(context)); /* - * MemoryContextDelete will delink the child from me, so just iterate - * as long as there is a child. + * MemoryContextDelete will delink the child from me, so just iterate as + * long as there is a child. */ while (context->firstchild != NULL) MemoryContextDelete(context->firstchild); @@ -384,9 +384,9 @@ MemoryContextContains(MemoryContext context, void *pointer) ((char *) pointer - STANDARDCHUNKHEADERSIZE); /* - * If the context link doesn't match then we certainly have a - * non-member chunk. Also check for a reasonable-looking size as - * extra guard against being fooled by bogus pointers. + * If the context link doesn't match then we certainly have a non-member + * chunk. Also check for a reasonable-looking size as extra guard against + * being fooled by bogus pointers. */ if (header->context == context && AllocSizeIsValid(header->size)) return true; @@ -640,7 +640,6 @@ MemoryContextSwitchTo(MemoryContext context) CurrentMemoryContext = context; return old; } - #endif /* ! __GNUC__ */ /* diff --git a/src/backend/utils/mmgr/portalmem.c b/src/backend/utils/mmgr/portalmem.c index b55a343025..9866e12d68 100644 --- a/src/backend/utils/mmgr/portalmem.c +++ b/src/backend/utils/mmgr/portalmem.c @@ -12,7 +12,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/mmgr/portalmem.c,v 1.81 2005/06/17 22:32:47 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/mmgr/portalmem.c,v 1.82 2005/10/15 02:49:36 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -272,8 +272,8 @@ PortalCreateHoldStore(Portal portal) Assert(portal->holdStore == NULL); /* - * Create the memory context that is used for storage of the tuple - * set. Note this is NOT a child of the portal's heap memory. + * Create the memory context that is used for storage of the tuple set. + * Note this is NOT a child of the portal's heap memory. */ portal->holdContext = AllocSetContextCreate(PortalMemory, @@ -305,10 +305,10 @@ PortalDrop(Portal portal, bool isTopCommit) elog(ERROR, "cannot drop active portal"); /* - * Remove portal from hash table. Because we do this first, we will - * not come back to try to remove the portal again if there's any - * error in the subsequent steps. Better to leak a little memory than - * to get into an infinite error-recovery loop. + * Remove portal from hash table. Because we do this first, we will not + * come back to try to remove the portal again if there's any error in the + * subsequent steps. Better to leak a little memory than to get into an + * infinite error-recovery loop. */ PortalHashTableDelete(portal); @@ -317,27 +317,27 @@ PortalDrop(Portal portal, bool isTopCommit) (*portal->cleanup) (portal); /* - * Release any resources still attached to the portal. There are - * several cases being covered here: + * Release any resources still attached to the portal. There are several + * cases being covered here: * - * Top transaction commit (indicated by isTopCommit): normally we should - * do nothing here and let the regular end-of-transaction resource - * releasing mechanism handle these resources too. However, if we - * have a FAILED portal (eg, a cursor that got an error), we'd better - * clean up its resources to avoid resource-leakage warning messages. + * Top transaction commit (indicated by isTopCommit): normally we should do + * nothing here and let the regular end-of-transaction resource releasing + * mechanism handle these resources too. However, if we have a FAILED + * portal (eg, a cursor that got an error), we'd better clean up its + * resources to avoid resource-leakage warning messages. * - * Sub transaction commit: never comes here at all, since we don't kill - * any portals in AtSubCommit_Portals(). + * Sub transaction commit: never comes here at all, since we don't kill any + * portals in AtSubCommit_Portals(). * * Main or sub transaction abort: we will do nothing here because * portal->resowner was already set NULL; the resources were already * cleaned up in transaction abort. * - * Ordinary portal drop: must release resources. However, if the portal - * is not FAILED then we do not release its locks. The locks become - * the responsibility of the transaction's ResourceOwner (since it is - * the parent of the portal's owner) and will be released when the - * transaction eventually ends. + * Ordinary portal drop: must release resources. However, if the portal is + * not FAILED then we do not release its locks. The locks become the + * responsibility of the transaction's ResourceOwner (since it is the + * parent of the portal's owner) and will be released when the transaction + * eventually ends. */ if (portal->resowner && (!isTopCommit || portal->status == PORTAL_FAILED)) @@ -419,7 +419,7 @@ DropDependentPortals(MemoryContext queryContext) bool CommitHoldablePortals(void) { - bool result = false; + bool result = false; HASH_SEQ_STATUS status; PortalHashEnt *hentry; @@ -435,27 +435,26 @@ CommitHoldablePortals(void) portal->status == PORTAL_READY) { /* - * We are exiting the transaction that created a holdable - * cursor. Instead of dropping the portal, prepare it for - * access by later transactions. + * We are exiting the transaction that created a holdable cursor. + * Instead of dropping the portal, prepare it for access by later + * transactions. * - * Note that PersistHoldablePortal() must release all resources - * used by the portal that are local to the creating - * transaction. + * Note that PersistHoldablePortal() must release all resources used + * by the portal that are local to the creating transaction. */ PortalCreateHoldStore(portal); PersistHoldablePortal(portal); /* - * Any resources belonging to the portal will be released in - * the upcoming transaction-wide cleanup; the portal will no - * longer have its own resources. + * Any resources belonging to the portal will be released in the + * upcoming transaction-wide cleanup; the portal will no longer + * have its own resources. */ portal->resowner = NULL; /* - * Having successfully exported the holdable cursor, mark it - * as not belonging to this transaction. + * Having successfully exported the holdable cursor, mark it as + * not belonging to this transaction. */ portal->createSubid = InvalidSubTransactionId; @@ -480,7 +479,7 @@ CommitHoldablePortals(void) bool PrepareHoldablePortals(void) { - bool result = false; + bool result = false; HASH_SEQ_STATUS status; PortalHashEnt *hentry; @@ -496,8 +495,8 @@ PrepareHoldablePortals(void) portal->status == PORTAL_READY) { /* - * We are exiting the transaction that created a holdable - * cursor. Can't do PREPARE. + * We are exiting the transaction that created a holdable cursor. + * Can't do PREPARE. */ ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), @@ -527,8 +526,8 @@ AtCommit_Portals(void) Portal portal = hentry->portal; /* - * Do not touch active portals --- this can only happen in the - * case of a multi-transaction utility command, such as VACUUM. + * Do not touch active portals --- this can only happen in the case of + * a multi-transaction utility command, such as VACUUM. * * Note however that any resource owner attached to such a portal is * still going to go away, so don't leave a dangling pointer. @@ -579,8 +578,7 @@ AtAbort_Portals(void) portal->status = PORTAL_FAILED; /* - * Do nothing else to cursors held over from a previous - * transaction. + * Do nothing else to cursors held over from a previous transaction. */ if (portal->createSubid == InvalidSubTransactionId) continue; @@ -594,8 +592,8 @@ AtAbort_Portals(void) /* * Any resources belonging to the portal will be released in the - * upcoming transaction-wide cleanup; they will be gone before we - * run PortalDrop. + * upcoming transaction-wide cleanup; they will be gone before we run + * PortalDrop. */ portal->resowner = NULL; } @@ -686,11 +684,10 @@ AtSubAbort_Portals(SubTransactionId mySubid, continue; /* - * Force any active portals of my own transaction into FAILED - * state. This is mostly to ensure that a portal running a FETCH - * will go FAILED if the underlying cursor fails. (Note we do NOT - * want to do this to upper-level portals, since they may be able - * to continue.) + * Force any active portals of my own transaction into FAILED state. + * This is mostly to ensure that a portal running a FETCH will go + * FAILED if the underlying cursor fails. (Note we do NOT want to do + * this to upper-level portals, since they may be able to continue.) * * This is only needed to dodge the sanity check in PortalDrop. */ @@ -701,11 +698,11 @@ AtSubAbort_Portals(SubTransactionId mySubid, * If the portal is READY then allow it to survive into the parent * transaction; otherwise shut it down. * - * Currently, we can't actually support that because the portal's - * query might refer to objects created or changed in the failed - * subtransaction, leading to crashes if execution is resumed. - * So, even READY portals are deleted. It would be nice to detect - * whether the query actually depends on any such object, instead. + * Currently, we can't actually support that because the portal's query + * might refer to objects created or changed in the failed + * subtransaction, leading to crashes if execution is resumed. So, + * even READY portals are deleted. It would be nice to detect whether + * the query actually depends on any such object, instead. */ #ifdef NOT_USED if (portal->status == PORTAL_READY) @@ -725,9 +722,9 @@ AtSubAbort_Portals(SubTransactionId mySubid, } /* - * Any resources belonging to the portal will be released in - * the upcoming transaction-wide cleanup; they will be gone - * before we run PortalDrop. + * Any resources belonging to the portal will be released in the + * upcoming transaction-wide cleanup; they will be gone before we + * run PortalDrop. */ portal->resowner = NULL; } diff --git a/src/backend/utils/resowner/resowner.c b/src/backend/utils/resowner/resowner.c index 786652a757..97933de820 100644 --- a/src/backend/utils/resowner/resowner.c +++ b/src/backend/utils/resowner/resowner.c @@ -14,7 +14,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/resowner/resowner.c,v 1.13 2005/08/08 19:17:23 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/resowner/resowner.c,v 1.14 2005/10/15 02:49:36 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -108,7 +108,7 @@ ResourceOwnerCreate(ResourceOwner parent, const char *name) ResourceOwner owner; owner = (ResourceOwner) MemoryContextAllocZero(TopMemoryContext, - sizeof(ResourceOwnerData)); + sizeof(ResourceOwnerData)); owner->name = name; if (parent) @@ -185,9 +185,9 @@ ResourceOwnerReleaseInternal(ResourceOwner owner, ResourceOwnerReleaseInternal(child, phase, isCommit, isTopLevel); /* - * Make CurrentResourceOwner point to me, so that ReleaseBuffer etc - * don't get confused. We needn't PG_TRY here because the outermost - * level will fix it on error abort. + * Make CurrentResourceOwner point to me, so that ReleaseBuffer etc don't + * get confused. We needn't PG_TRY here because the outermost level will + * fix it on error abort. */ save = CurrentResourceOwner; CurrentResourceOwner = owner; @@ -195,16 +195,16 @@ ResourceOwnerReleaseInternal(ResourceOwner owner, if (phase == RESOURCE_RELEASE_BEFORE_LOCKS) { /* - * Release buffer pins. Note that ReleaseBuffer will - * remove the buffer entry from my list, so I just have to - * iterate till there are none. + * Release buffer pins. Note that ReleaseBuffer will remove the + * buffer entry from my list, so I just have to iterate till there are + * none. * - * During a commit, there shouldn't be any remaining pins --- - * that would indicate failure to clean up the executor correctly --- - * so issue warnings. In the abort case, just clean up quietly. + * During a commit, there shouldn't be any remaining pins --- that would + * indicate failure to clean up the executor correctly --- so issue + * warnings. In the abort case, just clean up quietly. * - * We are careful to do the releasing back-to-front, so as to - * avoid O(N^2) behavior in ResourceOwnerForgetBuffer(). + * We are careful to do the releasing back-to-front, so as to avoid + * O(N^2) behavior in ResourceOwnerForgetBuffer(). */ while (owner->nbuffers > 0) { @@ -214,12 +214,12 @@ ResourceOwnerReleaseInternal(ResourceOwner owner, } /* - * Release relcache references. Note that RelationClose will - * remove the relref entry from my list, so I just have to - * iterate till there are none. + * Release relcache references. Note that RelationClose will remove + * the relref entry from my list, so I just have to iterate till there + * are none. * - * As with buffer pins, warn if any are left at commit time, - * and release back-to-front for speed. + * As with buffer pins, warn if any are left at commit time, and release + * back-to-front for speed. */ while (owner->nrelrefs > 0) { @@ -233,9 +233,9 @@ ResourceOwnerReleaseInternal(ResourceOwner owner, if (isTopLevel) { /* - * For a top-level xact we are going to release all locks (or - * at least all non-session locks), so just do a single lmgr - * call at the top of the recursion. + * For a top-level xact we are going to release all locks (or at + * least all non-session locks), so just do a single lmgr call at + * the top of the recursion. */ if (owner == TopTransactionResourceOwner) ProcReleaseLocks(isCommit); @@ -244,8 +244,8 @@ ResourceOwnerReleaseInternal(ResourceOwner owner, { /* * Release locks retail. Note that if we are committing a - * subtransaction, we do NOT release its locks yet, but - * transfer them to the parent. + * subtransaction, we do NOT release its locks yet, but transfer + * them to the parent. */ Assert(owner->parent != NULL); if (isCommit) @@ -257,12 +257,12 @@ ResourceOwnerReleaseInternal(ResourceOwner owner, else if (phase == RESOURCE_RELEASE_AFTER_LOCKS) { /* - * Release catcache references. Note that ReleaseCatCache - * will remove the catref entry from my list, so I just have - * to iterate till there are none. Ditto for catcache lists. + * Release catcache references. Note that ReleaseCatCache will remove + * the catref entry from my list, so I just have to iterate till there + * are none. Ditto for catcache lists. * - * As with buffer pins, warn if any are left at commit time, - * and release back-to-front for speed. + * As with buffer pins, warn if any are left at commit time, and release + * back-to-front for speed. */ while (owner->ncatrefs > 0) { @@ -309,16 +309,16 @@ ResourceOwnerDelete(ResourceOwner owner) Assert(owner->nrelrefs == 0); /* - * Delete children. The recursive call will delink the child from me, - * so just iterate as long as there is a child. + * Delete children. The recursive call will delink the child from me, so + * just iterate as long as there is a child. */ while (owner->firstchild != NULL) ResourceOwnerDelete(owner->firstchild); /* * We delink the owner from its parent before deleting it, so that if - * there's an error we won't have deleted/busted owners still attached - * to the owner tree. Better a leak than a crash. + * there's an error we won't have deleted/busted owners still attached to + * the owner tree. Better a leak than a crash. */ ResourceOwnerNewParent(owner, NULL); @@ -502,8 +502,8 @@ ResourceOwnerForgetBuffer(ResourceOwner owner, Buffer buffer) /* * Scan back-to-front because it's more likely we are releasing a - * recently pinned buffer. This isn't always the case of course, - * but it's the way to bet. + * recently pinned buffer. This isn't always the case of course, but + * it's the way to bet. */ for (i = nb1; i >= 0; i--) { diff --git a/src/backend/utils/sort/logtape.c b/src/backend/utils/sort/logtape.c index e4066821de..b8c760f482 100644 --- a/src/backend/utils/sort/logtape.c +++ b/src/backend/utils/sort/logtape.c @@ -64,7 +64,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/sort/logtape.c,v 1.15 2004/12/31 22:02:52 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/utils/sort/logtape.c,v 1.16 2005/10/15 02:49:37 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -91,10 +91,9 @@ typedef struct IndirectBlock { int nextSlot; /* next pointer slot to write or read */ - struct IndirectBlock *nextup; /* parent indirect level, or NULL - * if top */ - long ptrs[BLOCKS_PER_INDIR_BLOCK]; /* indexes of contained - * blocks */ + struct IndirectBlock *nextup; /* parent indirect level, or NULL if + * top */ + long ptrs[BLOCKS_PER_INDIR_BLOCK]; /* indexes of contained blocks */ } IndirectBlock; /* @@ -107,24 +106,23 @@ typedef struct LogicalTape { IndirectBlock *indirect; /* bottom of my indirect-block hierarchy */ bool writing; /* T while in write phase */ - bool frozen; /* T if blocks should not be freed when - * read */ + bool frozen; /* T if blocks should not be freed when read */ bool dirty; /* does buffer need to be written? */ /* - * The total data volume in the logical tape is numFullBlocks * BLCKSZ - * + lastBlockBytes. BUT: we do not update lastBlockBytes during - * writing, only at completion of a write phase. + * The total data volume in the logical tape is numFullBlocks * BLCKSZ + + * lastBlockBytes. BUT: we do not update lastBlockBytes during writing, + * only at completion of a write phase. */ long numFullBlocks; /* number of complete blocks in log tape */ int lastBlockBytes; /* valid bytes in last (incomplete) block */ /* * Buffer for current data block. Note we don't bother to store the - * actual file block number of the data block (during the write phase - * it hasn't been assigned yet, and during read we don't care - * anymore). But we do need the relative block number so we can detect - * end-of-tape while reading. + * actual file block number of the data block (during the write phase it + * hasn't been assigned yet, and during read we don't care anymore). But + * we do need the relative block number so we can detect end-of-tape while + * reading. */ long curBlockNumber; /* this block's logical blk# within tape */ int pos; /* next read/write position in buffer */ @@ -144,20 +142,18 @@ struct LogicalTapeSet long nFileBlocks; /* # of blocks used in underlying file */ /* - * We store the numbers of recycled-and-available blocks in - * freeBlocks[]. When there are no such blocks, we extend the - * underlying file. Note that the block numbers in freeBlocks are - * always in *decreasing* order, so that removing the last entry gives - * us the lowest free block. + * We store the numbers of recycled-and-available blocks in freeBlocks[]. + * When there are no such blocks, we extend the underlying file. Note + * that the block numbers in freeBlocks are always in *decreasing* order, + * so that removing the last entry gives us the lowest free block. */ long *freeBlocks; /* resizable array */ int nFreeBlocks; /* # of currently free blocks */ - int freeBlocksLen; /* current allocated length of - * freeBlocks[] */ + int freeBlocksLen; /* current allocated length of freeBlocks[] */ /* - * tapes[] is declared size 1 since C wants a fixed size, but actually - * it is of length nTapes. + * tapes[] is declared size 1 since C wants a fixed size, but actually it + * is of length nTapes. */ int nTapes; /* # of logical tapes in set */ LogicalTape *tapes[1]; /* must be last in struct! */ @@ -232,9 +228,9 @@ static long ltsGetFreeBlock(LogicalTapeSet *lts) { /* - * If there are multiple free blocks, we select the one appearing last - * in freeBlocks[]. If there are none, assign the next block at the - * end of the file. + * If there are multiple free blocks, we select the one appearing last in + * freeBlocks[]. If there are none, assign the next block at the end of + * the file. */ if (lts->nFreeBlocks > 0) return lts->freeBlocks[--lts->nFreeBlocks]; @@ -258,14 +254,14 @@ ltsReleaseBlock(LogicalTapeSet *lts, long blocknum) { lts->freeBlocksLen *= 2; lts->freeBlocks = (long *) repalloc(lts->freeBlocks, - lts->freeBlocksLen * sizeof(long)); + lts->freeBlocksLen * sizeof(long)); } /* * Insert blocknum into array, preserving decreasing order (so that - * ltsGetFreeBlock returns the lowest available block number). This - * could get fairly slow if there were many free blocks, but we don't - * expect there to be very many at one time. + * ltsGetFreeBlock returns the lowest available block number). This could + * get fairly slow if there were many free blocks, but we don't expect + * there to be very many at one time. */ ndx = lts->nFreeBlocks++; ptr = lts->freeBlocks + ndx; @@ -293,8 +289,8 @@ ltsRecordBlockNum(LogicalTapeSet *lts, IndirectBlock *indirect, if (indirect->nextSlot >= BLOCKS_PER_INDIR_BLOCK) { /* - * This indirect block is full, so dump it out and recursively - * save its address in the next indirection level. Create a new + * This indirect block is full, so dump it out and recursively save + * its address in the next indirection level. Create a new * indirection level if there wasn't one before. */ long indirblock = ltsGetFreeBlock(lts); @@ -336,8 +332,8 @@ ltsRewindIndirectBlock(LogicalTapeSet *lts, indirect->ptrs[indirect->nextSlot] = -1L; /* - * If block is not topmost, write it out, and recurse to obtain - * address of first block in this hierarchy level. Read that one in. + * If block is not topmost, write it out, and recurse to obtain address of + * first block in this hierarchy level. Read that one in. */ if (indirect->nextup != NULL) { @@ -371,8 +367,8 @@ ltsRewindFrozenIndirectBlock(LogicalTapeSet *lts, IndirectBlock *indirect) { /* - * If block is not topmost, recurse to obtain address of first block - * in this hierarchy level. Read that one in. + * If block is not topmost, recurse to obtain address of first block in + * this hierarchy level. Read that one in. */ if (indirect->nextup != NULL) { @@ -448,8 +444,8 @@ ltsRecallPrevBlockNum(LogicalTapeSet *lts, ltsReadBlock(lts, indirblock, (void *) indirect->ptrs); /* - * The previous block would only have been written out if full, so - * we need not search it for a -1 sentinel. + * The previous block would only have been written out if full, so we + * need not search it for a -1 sentinel. */ indirect->nextSlot = BLOCKS_PER_INDIR_BLOCK + 1; } @@ -471,8 +467,8 @@ LogicalTapeSetCreate(int ntapes) int i; /* - * Create top-level struct. First LogicalTape pointer is already - * counted in sizeof(LogicalTapeSet). + * Create top-level struct. First LogicalTape pointer is already counted + * in sizeof(LogicalTapeSet). */ Assert(ntapes > 0); lts = (LogicalTapeSet *) palloc(sizeof(LogicalTapeSet) + @@ -617,8 +613,8 @@ LogicalTapeRewind(LogicalTapeSet *lts, int tapenum, bool forWrite) if (lt->writing) { /* - * Completion of a write phase. Flush last partial data - * block, flush any partial indirect blocks, rewind for normal + * Completion of a write phase. Flush last partial data block, + * flush any partial indirect blocks, rewind for normal * (destructive) read. */ if (lt->dirty) @@ -630,8 +626,8 @@ LogicalTapeRewind(LogicalTapeSet *lts, int tapenum, bool forWrite) else { /* - * This is only OK if tape is frozen; we rewind for (another) - * read pass. + * This is only OK if tape is frozen; we rewind for (another) read + * pass. */ Assert(lt->frozen); datablocknum = ltsRewindFrozenIndirectBlock(lts, lt->indirect); @@ -656,8 +652,8 @@ LogicalTapeRewind(LogicalTapeSet *lts, int tapenum, bool forWrite) * * NOTE: we assume the caller has read the tape to the end; otherwise * untouched data and indirect blocks will not have been freed. We - * could add more code to free any unread blocks, but in current - * usage of this module it'd be useless code. + * could add more code to free any unread blocks, but in current usage + * of this module it'd be useless code. */ IndirectBlock *ib, *nextib; @@ -757,8 +753,8 @@ LogicalTapeFreeze(LogicalTapeSet *lts, int tapenum) Assert(lt->writing); /* - * Completion of a write phase. Flush last partial data block, flush - * any partial indirect blocks, rewind for nondestructive read. + * Completion of a write phase. Flush last partial data block, flush any + * partial indirect blocks, rewind for nondestructive read. */ if (lt->dirty) ltsDumpBuffer(lts, lt); @@ -826,9 +822,9 @@ LogicalTapeBackspace(LogicalTapeSet *lts, int tapenum, size_t size) return false; /* a seek too far... */ /* - * OK, we need to back up nblocks blocks. This implementation would - * be pretty inefficient for long seeks, but we really aren't - * expecting that (a seek over one tuple is typical). + * OK, we need to back up nblocks blocks. This implementation would be + * pretty inefficient for long seeks, but we really aren't expecting that + * (a seek over one tuple is typical). */ while (nblocks-- > 0) { @@ -883,9 +879,9 @@ LogicalTapeSeek(LogicalTapeSet *lts, int tapenum, return false; /* - * OK, advance or back up to the target block. This implementation - * would be pretty inefficient for long seeks, but we really aren't - * expecting that (a seek over one tuple is typical). + * OK, advance or back up to the target block. This implementation would + * be pretty inefficient for long seeks, but we really aren't expecting + * that (a seek over one tuple is typical). */ while (lt->curBlockNumber > blocknum) { diff --git a/src/backend/utils/sort/tuplesort.c b/src/backend/utils/sort/tuplesort.c index 53f2b546f4..2007d7a694 100644 --- a/src/backend/utils/sort/tuplesort.c +++ b/src/backend/utils/sort/tuplesort.c @@ -78,7 +78,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/sort/tuplesort.c,v 1.51 2005/10/03 22:55:54 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/sort/tuplesort.c,v 1.52 2005/10/15 02:49:37 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -102,7 +102,7 @@ /* GUC variable */ #ifdef TRACE_SORT -bool trace_sort = false; +bool trace_sort = false; #endif @@ -112,8 +112,7 @@ bool trace_sort = false; */ typedef enum { - TSS_INITIAL, /* Loading tuples; still within memory - * limit */ + TSS_INITIAL, /* Loading tuples; still within memory limit */ TSS_BUILDRUNS, /* Loading tuples; writing to tape */ TSS_SORTEDINMEM, /* Sort completed entirely in memory */ TSS_SORTEDONTAPE, /* Sort completed, final run is on tape */ @@ -135,13 +134,12 @@ struct Tuplesortstate TupSortStatus status; /* enumerated value as shown above */ bool randomAccess; /* did caller request random access? */ long availMem; /* remaining memory available, in bytes */ - LogicalTapeSet *tapeset; /* logtape.c object for tapes in a temp - * file */ + LogicalTapeSet *tapeset; /* logtape.c object for tapes in a temp file */ /* - * These function pointers decouple the routines that must know what - * kind of tuple we are sorting from the routines that don't need to - * know it. They are set up by the tuplesort_begin_xxx routines. + * These function pointers decouple the routines that must know what kind + * of tuple we are sorting from the routines that don't need to know it. + * They are set up by the tuplesort_begin_xxx routines. * * Function to compare two tuples; result is per qsort() convention, ie: * @@ -150,83 +148,78 @@ struct Tuplesortstate int (*comparetup) (Tuplesortstate *state, const void *a, const void *b); /* - * Function to copy a supplied input tuple into palloc'd space. (NB: - * we assume that a single pfree() is enough to release the tuple - * later, so the representation must be "flat" in one palloc chunk.) - * state->availMem must be decreased by the amount of space used. + * Function to copy a supplied input tuple into palloc'd space. (NB: we + * assume that a single pfree() is enough to release the tuple later, so + * the representation must be "flat" in one palloc chunk.) state->availMem + * must be decreased by the amount of space used. */ void *(*copytup) (Tuplesortstate *state, void *tup); /* - * Function to write a stored tuple onto tape. The representation of - * the tuple on tape need not be the same as it is in memory; - * requirements on the tape representation are given below. After - * writing the tuple, pfree() it, and increase state->availMem by the - * amount of memory space thereby released. + * Function to write a stored tuple onto tape. The representation of the + * tuple on tape need not be the same as it is in memory; requirements on + * the tape representation are given below. After writing the tuple, + * pfree() it, and increase state->availMem by the amount of memory space + * thereby released. */ void (*writetup) (Tuplesortstate *state, int tapenum, void *tup); /* - * Function to read a stored tuple from tape back into memory. 'len' - * is the already-read length of the stored tuple. Create and return - * a palloc'd copy, and decrease state->availMem by the amount of - * memory space consumed. + * Function to read a stored tuple from tape back into memory. 'len' is + * the already-read length of the stored tuple. Create and return a + * palloc'd copy, and decrease state->availMem by the amount of memory + * space consumed. */ void *(*readtup) (Tuplesortstate *state, int tapenum, unsigned int len); /* - * This array holds pointers to tuples in sort memory. If we are in - * state INITIAL, the tuples are in no particular order; if we are in - * state SORTEDINMEM, the tuples are in final sorted order; in states - * BUILDRUNS and FINALMERGE, the tuples are organized in "heap" order - * per Algorithm H. (Note that memtupcount only counts the tuples - * that are part of the heap --- during merge passes, memtuples[] - * entries beyond TAPERANGE are never in the heap and are used to hold - * pre-read tuples.) In state SORTEDONTAPE, the array is not used. + * This array holds pointers to tuples in sort memory. If we are in state + * INITIAL, the tuples are in no particular order; if we are in state + * SORTEDINMEM, the tuples are in final sorted order; in states BUILDRUNS + * and FINALMERGE, the tuples are organized in "heap" order per Algorithm + * H. (Note that memtupcount only counts the tuples that are part of the + * heap --- during merge passes, memtuples[] entries beyond TAPERANGE are + * never in the heap and are used to hold pre-read tuples.) In state + * SORTEDONTAPE, the array is not used. */ void **memtuples; /* array of pointers to palloc'd tuples */ int memtupcount; /* number of tuples currently present */ int memtupsize; /* allocated length of memtuples array */ /* - * While building initial runs, this array holds the run number for - * each tuple in memtuples[]. During merge passes, we re-use it to - * hold the input tape number that each tuple in the heap was read - * from, or to hold the index of the next tuple pre-read from the same - * tape in the case of pre-read entries. This array is never - * allocated unless we need to use tapes. Whenever it is allocated, - * it has the same length as memtuples[]. + * While building initial runs, this array holds the run number for each + * tuple in memtuples[]. During merge passes, we re-use it to hold the + * input tape number that each tuple in the heap was read from, or to hold + * the index of the next tuple pre-read from the same tape in the case of + * pre-read entries. This array is never allocated unless we need to use + * tapes. Whenever it is allocated, it has the same length as + * memtuples[]. */ - int *memtupindex; /* index value associated with - * memtuples[i] */ + int *memtupindex; /* index value associated with memtuples[i] */ /* * While building initial runs, this is the current output run number - * (starting at 0). Afterwards, it is the number of initial runs we - * made. + * (starting at 0). Afterwards, it is the number of initial runs we made. */ int currentRun; /* - * These variables are only used during merge passes. mergeactive[i] - * is true if we are reading an input run from (actual) tape number i - * and have not yet exhausted that run. mergenext[i] is the memtuples - * index of the next pre-read tuple (next to be loaded into the heap) - * for tape i, or 0 if we are out of pre-read tuples. mergelast[i] - * similarly points to the last pre-read tuple from each tape. - * mergeavailmem[i] is the amount of unused space allocated for tape - * i. mergefreelist and mergefirstfree keep track of unused locations - * in the memtuples[] array. memtupindex[] links together pre-read - * tuples for each tape as well as recycled locations in - * mergefreelist. It is OK to use 0 as a null link in these lists, - * because memtuples[0] is part of the merge heap and is never a - * pre-read tuple. + * These variables are only used during merge passes. mergeactive[i] is + * true if we are reading an input run from (actual) tape number i and + * have not yet exhausted that run. mergenext[i] is the memtuples index + * of the next pre-read tuple (next to be loaded into the heap) for tape + * i, or 0 if we are out of pre-read tuples. mergelast[i] similarly + * points to the last pre-read tuple from each tape. mergeavailmem[i] is + * the amount of unused space allocated for tape i. mergefreelist and + * mergefirstfree keep track of unused locations in the memtuples[] array. + * memtupindex[] links together pre-read tuples for each tape as well as + * recycled locations in mergefreelist. It is OK to use 0 as a null link + * in these lists, because memtuples[0] is part of the merge heap and is + * never a pre-read tuple. */ bool mergeactive[MAXTAPES]; /* Active input run source? */ - int mergenext[MAXTAPES]; /* first preread tuple for each - * source */ - int mergelast[MAXTAPES]; /* last preread tuple for each - * source */ + int mergenext[MAXTAPES]; /* first preread tuple for each source */ + int mergelast[MAXTAPES]; /* last preread tuple for each source */ long mergeavailmem[MAXTAPES]; /* availMem for prereading * tapes */ long spacePerTape; /* actual per-tape target usage */ @@ -240,17 +233,15 @@ struct Tuplesortstate */ int Level; /* Knuth's l */ int destTape; /* current output tape (Knuth's j, less 1) */ - int tp_fib[MAXTAPES]; /* Target Fibonacci run counts - * (A[]) */ + int tp_fib[MAXTAPES]; /* Target Fibonacci run counts (A[]) */ int tp_runs[MAXTAPES]; /* # of real runs on each tape */ - int tp_dummy[MAXTAPES]; /* # of dummy runs for each tape - * (D[]) */ + int tp_dummy[MAXTAPES]; /* # of dummy runs for each tape (D[]) */ int tp_tapenum[MAXTAPES]; /* Actual tape numbers (TAPE[]) */ /* - * These variables are used after completion of sorting to keep track - * of the next tuple to return. (In the tape case, the tape's current - * read position is also critical state.) + * These variables are used after completion of sorting to keep track of + * the next tuple to return. (In the tape case, the tape's current read + * position is also critical state.) */ int result_tape; /* actual tape number of finished output */ int current; /* array index (only used if SORTEDINMEM) */ @@ -258,8 +249,7 @@ struct Tuplesortstate /* markpos_xxx holds marked position for mark and restore */ long markpos_block; /* tape block# (only used if SORTEDONTAPE) */ - int markpos_offset; /* saved "current", or offset in tape - * block */ + int markpos_offset; /* saved "current", or offset in tape block */ bool markpos_eof; /* saved "eof_reached" */ /* @@ -272,8 +262,8 @@ struct Tuplesortstate SortFunctionKind *sortFnKinds; /* - * These variables are specific to the IndexTuple case; they are set - * by tuplesort_begin_index and used only by the IndexTuple routines. + * These variables are specific to the IndexTuple case; they are set by + * tuplesort_begin_index and used only by the IndexTuple routines. */ Relation indexRel; ScanKey indexScanKey; @@ -458,8 +448,7 @@ tuplesort_begin_common(int workMem, bool randomAccess) /* Algorithm D variables will be initialized by inittapes, if needed */ - state->result_tape = -1; /* flag that result tape has not been - * formed */ + state->result_tape = -1; /* flag that result tape has not been formed */ return state; } @@ -505,8 +494,8 @@ tuplesort_begin_heap(TupleDesc tupDesc, &state->sortFnKinds[i]); /* - * We needn't fill in sk_strategy or sk_subtype since these - * scankeys will never be passed to an index. + * We needn't fill in sk_strategy or sk_subtype since these scankeys + * will never be passed to an index. */ ScanKeyInit(&state->scanKeys[i], attNums[i], @@ -606,8 +595,7 @@ tuplesort_end(Tuplesortstate *state) pfree(state->memtupindex); /* - * this stuff might better belong in a variant-specific shutdown - * routine + * this stuff might better belong in a variant-specific shutdown routine */ if (state->scanKeys) pfree(state->scanKeys); @@ -724,16 +712,16 @@ puttuple_common(Tuplesortstate *state, void *tuple) /* * Insert the copied tuple into the heap, with run number - * currentRun if it can go into the current run, else run - * number currentRun+1. The tuple can go into the current run - * if it is >= the first not-yet-output tuple. (Actually, it - * could go into the current run if it is >= the most recently - * output tuple ... but that would require keeping around the - * tuple we last output, and it's simplest to let writetup - * free each tuple as soon as it's written.) + * currentRun if it can go into the current run, else run number + * currentRun+1. The tuple can go into the current run if it is + * >= the first not-yet-output tuple. (Actually, it could go into + * the current run if it is >= the most recently output tuple ... + * but that would require keeping around the tuple we last output, + * and it's simplest to let writetup free each tuple as soon as + * it's written.) * - * Note there will always be at least one tuple in the heap at - * this point; see dumptuples. + * Note there will always be at least one tuple in the heap at this + * point; see dumptuples. */ Assert(state->memtupcount > 0); if (COMPARETUP(state, tuple, state->memtuples[0]) >= 0) @@ -742,8 +730,7 @@ puttuple_common(Tuplesortstate *state, void *tuple) tuplesort_heap_insert(state, tuple, state->currentRun + 1, true); /* - * If we are over the memory limit, dump tuples till we're - * under. + * If we are over the memory limit, dump tuples till we're under. */ dumptuples(state, false); break; @@ -770,8 +757,8 @@ tuplesort_performsort(Tuplesortstate *state) case TSS_INITIAL: /* - * We were able to accumulate all the tuples within the - * allowed amount of memory. Just qsort 'em and we're done. + * We were able to accumulate all the tuples within the allowed + * amount of memory. Just qsort 'em and we're done. */ if (state->memtupcount > 1) { @@ -788,10 +775,10 @@ tuplesort_performsort(Tuplesortstate *state) case TSS_BUILDRUNS: /* - * Finish tape-based sort. First, flush all tuples remaining - * in memory out to tape; then merge until we have a single - * remaining run (or, if !randomAccess, one run per tape). - * Note that mergeruns sets the correct state->status. + * Finish tape-based sort. First, flush all tuples remaining in + * memory out to tape; then merge until we have a single remaining + * run (or, if !randomAccess, one run per tape). Note that + * mergeruns sets the correct state->status. */ dumptuples(state, true); mergeruns(state); @@ -880,16 +867,15 @@ tuplesort_gettuple(Tuplesortstate *state, bool forward, /* * Backward. * - * if all tuples are fetched already then we return last tuple, - * else - tuple before last returned. + * if all tuples are fetched already then we return last tuple, else + * - tuple before last returned. */ if (state->eof_reached) { /* - * Seek position is pointing just past the zero tuplen at - * the end of file; back up to fetch last tuple's ending - * length word. If seek fails we must have a completely - * empty file. + * Seek position is pointing just past the zero tuplen at the + * end of file; back up to fetch last tuple's ending length + * word. If seek fails we must have a completely empty file. */ if (!LogicalTapeBackspace(state->tapeset, state->result_tape, @@ -900,9 +886,8 @@ tuplesort_gettuple(Tuplesortstate *state, bool forward, else { /* - * Back up and fetch previously-returned tuple's ending - * length word. If seek fails, assume we are at start of - * file. + * Back up and fetch previously-returned tuple's ending length + * word. If seek fails, assume we are at start of file. */ if (!LogicalTapeBackspace(state->tapeset, state->result_tape, @@ -915,17 +900,17 @@ tuplesort_gettuple(Tuplesortstate *state, bool forward, */ if (!LogicalTapeBackspace(state->tapeset, state->result_tape, - tuplen + 2 * sizeof(unsigned int))) + tuplen + 2 * sizeof(unsigned int))) { /* - * If that fails, presumably the prev tuple is the - * first in the file. Back up so that it becomes next - * to read in forward direction (not obviously right, - * but that is what in-memory case does). + * If that fails, presumably the prev tuple is the first + * in the file. Back up so that it becomes next to read + * in forward direction (not obviously right, but that is + * what in-memory case does). */ if (!LogicalTapeBackspace(state->tapeset, state->result_tape, - tuplen + sizeof(unsigned int))) + tuplen + sizeof(unsigned int))) elog(ERROR, "bogus tuple length in backward scan"); return NULL; } @@ -934,9 +919,9 @@ tuplesort_gettuple(Tuplesortstate *state, bool forward, tuplen = getlen(state, state->result_tape, false); /* - * Now we have the length of the prior tuple, back up and read - * it. Note: READTUP expects we are positioned after the - * initial length word of the tuple, so back up to that point. + * Now we have the length of the prior tuple, back up and read it. + * Note: READTUP expects we are positioned after the initial + * length word of the tuple, so back up to that point. */ if (!LogicalTapeBackspace(state->tapeset, state->result_tape, @@ -968,14 +953,12 @@ tuplesort_gettuple(Tuplesortstate *state, bool forward, if ((tupIndex = state->mergenext[srcTape]) == 0) { /* - * out of preloaded data on this tape, try to read - * more + * out of preloaded data on this tape, try to read more */ mergepreread(state); /* - * if still no data, we've reached end of run on this - * tape + * if still no data, we've reached end of run on this tape */ if ((tupIndex = state->mergenext[srcTape]) == 0) return tup; @@ -1062,12 +1045,12 @@ inittapes(Tuplesortstate *state) USEMEM(state, GetMemoryChunkSpace(state->memtupindex)); /* - * Convert the unsorted contents of memtuples[] into a heap. Each - * tuple is marked as belonging to run number zero. + * Convert the unsorted contents of memtuples[] into a heap. Each tuple is + * marked as belonging to run number zero. * * NOTE: we pass false for checkIndex since there's no point in comparing - * indexes in this step, even though we do intend the indexes to be - * part of the sort key... + * indexes in this step, even though we do intend the indexes to be part + * of the sort key... */ ntuples = state->memtupcount; state->memtupcount = 0; /* make the heap empty */ @@ -1150,8 +1133,8 @@ mergeruns(Tuplesortstate *state) /* * If we produced only one initial run (quite likely if the total data - * volume is between 1X and 2X workMem), we can just use that tape as - * the finished output, rather than doing a useless merge. + * volume is between 1X and 2X workMem), we can just use that tape as the + * finished output, rather than doing a useless merge. */ if (state->currentRun == 1) { @@ -1183,8 +1166,8 @@ mergeruns(Tuplesortstate *state) } /* - * If we don't have to produce a materialized sorted tape, - * quit as soon as we're down to one real/dummy run per tape. + * If we don't have to produce a materialized sorted tape, quit as + * soon as we're down to one real/dummy run per tape. */ if (!state->randomAccess && allOneRun) { @@ -1215,8 +1198,7 @@ mergeruns(Tuplesortstate *state) state->tp_runs[TAPERANGE - 1] = 0; /* - * reassign tape units per step D6; note we no longer care about - * A[] + * reassign tape units per step D6; note we no longer care about A[] */ svTape = state->tp_tapenum[TAPERANGE]; svDummy = state->tp_dummy[TAPERANGE]; @@ -1233,12 +1215,12 @@ mergeruns(Tuplesortstate *state) } /* - * Done. Knuth says that the result is on TAPE[1], but since we - * exited the loop without performing the last iteration of step D6, - * we have not rearranged the tape unit assignment, and therefore the - * result is on TAPE[T]. We need to do it this way so that we can - * freeze the final output tape while rewinding it. The last - * iteration of step D6 would be a waste of cycles anyway... + * Done. Knuth says that the result is on TAPE[1], but since we exited + * the loop without performing the last iteration of step D6, we have not + * rearranged the tape unit assignment, and therefore the result is on + * TAPE[T]. We need to do it this way so that we can freeze the final + * output tape while rewinding it. The last iteration of step D6 would be + * a waste of cycles anyway... */ state->result_tape = state->tp_tapenum[TAPERANGE]; LogicalTapeFreeze(state->tapeset, state->result_tape); @@ -1262,16 +1244,15 @@ mergeonerun(Tuplesortstate *state) spaceFreed; /* - * Start the merge by loading one tuple from each active source tape - * into the heap. We can also decrease the input run/dummy run - * counts. + * Start the merge by loading one tuple from each active source tape into + * the heap. We can also decrease the input run/dummy run counts. */ beginmerge(state); /* - * Execute merge by repeatedly extracting lowest tuple in heap, - * writing it out, and replacing it with next tuple from same tape (if - * there is another one). + * Execute merge by repeatedly extracting lowest tuple in heap, writing it + * out, and replacing it with next tuple from same tape (if there is + * another one). */ while (state->memtupcount > 0) { @@ -1304,8 +1285,8 @@ mergeonerun(Tuplesortstate *state) } /* - * When the heap empties, we're done. Write an end-of-run marker on - * the output tape, and increment its count of real runs. + * When the heap empties, we're done. Write an end-of-run marker on the + * output tape, and increment its count of real runs. */ markrunend(state, destTape); state->tp_runs[TAPERANGE]++; @@ -1341,8 +1322,7 @@ beginmerge(Tuplesortstate *state) memset(state->mergelast, 0, sizeof(state->mergelast)); memset(state->mergeavailmem, 0, sizeof(state->mergeavailmem)); state->mergefreelist = 0; /* nothing in the freelist */ - state->mergefirstfree = MAXTAPES; /* first slot available for - * preread */ + state->mergefirstfree = MAXTAPES; /* first slot available for preread */ /* Adjust run counts and mark the active tapes */ activeTapes = 0; @@ -1361,8 +1341,8 @@ beginmerge(Tuplesortstate *state) } /* - * Initialize space allocation to let each active input tape have an - * equal share of preread space. + * Initialize space allocation to let each active input tape have an equal + * share of preread space. */ Assert(activeTapes > 0); state->spacePerTape = state->availMem / activeTapes; @@ -1373,8 +1353,8 @@ beginmerge(Tuplesortstate *state) } /* - * Preread as many tuples as possible (and at least one) from each - * active tape + * Preread as many tuples as possible (and at least one) from each active + * tape */ mergepreread(state); @@ -1432,8 +1412,8 @@ mergepreread(Tuplesortstate *state) continue; /* - * Read tuples from this tape until it has used up its free - * memory, but ensure that we have at least one. + * Read tuples from this tape until it has used up its free memory, + * but ensure that we have at least one. */ priorAvail = state->availMem; state->availMem = state->mergeavailmem[srcTape]; @@ -1508,8 +1488,8 @@ dumptuples(Tuplesortstate *state, bool alltuples) (LACKMEM(state) && state->memtupcount > 1)) { /* - * Dump the heap's frontmost entry, and sift up to remove it from - * the heap. + * Dump the heap's frontmost entry, and sift up to remove it from the + * heap. */ Assert(state->memtupcount > 0); WRITETUP(state, state->tp_tapenum[state->destTape], @@ -1680,8 +1660,8 @@ tuplesort_heap_insert(Tuplesortstate *state, void *tuple, memtupindex = state->memtupindex; /* - * Sift-up the new entry, per Knuth 5.2.3 exercise 16. Note that Knuth - * is using 1-based array indexes, not 0-based. + * Sift-up the new entry, per Knuth 5.2.3 exercise 16. Note that Knuth is + * using 1-based array indexes, not 0-based. */ j = state->memtupcount++; while (j > 0) @@ -1805,12 +1785,12 @@ SelectSortFunction(Oid sortOperator, Oid opclass = InvalidOid; /* - * Search pg_amop to see if the target operator is registered as the - * "<" or ">" operator of any btree opclass. It's possible that it - * might be registered both ways (eg, if someone were to build a - * "reverse sort" opclass for some reason); prefer the "<" case if so. - * If the operator is registered the same way in multiple opclasses, - * assume we can use the associated comparator function from any one. + * Search pg_amop to see if the target operator is registered as the "<" + * or ">" operator of any btree opclass. It's possible that it might be + * registered both ways (eg, if someone were to build a "reverse sort" + * opclass for some reason); prefer the "<" case if so. If the operator is + * registered the same way in multiple opclasses, assume we can use the + * associated comparator function from any one. */ catlist = SearchSysCacheList(AMOPOPID, 1, ObjectIdGetDatum(sortOperator), @@ -1854,11 +1834,11 @@ SelectSortFunction(Oid sortOperator, } /* - * Can't find a comparator, so use the operator as-is. Decide whether - * it is forward or reverse sort by looking at its name (grotty, but - * this only matters for deciding which end NULLs should get sorted - * to). XXX possibly better idea: see whether its selectivity - * function is scalargtcmp? + * Can't find a comparator, so use the operator as-is. Decide whether it + * is forward or reverse sort by looking at its name (grotty, but this + * only matters for deciding which end NULLs should get sorted to). XXX + * possibly better idea: see whether its selectivity function is + * scalargtcmp? */ tuple = SearchSysCache(OPEROID, ObjectIdGetDatum(sortOperator), @@ -2142,15 +2122,15 @@ comparetup_index(Tuplesortstate *state, const void *a, const void *b) * If btree has asked us to enforce uniqueness, complain if two equal * tuples are detected (unless there was at least one NULL field). * - * It is sufficient to make the test here, because if two tuples are - * equal they *must* get compared at some stage of the sort --- - * otherwise the sort algorithm wouldn't have checked whether one must - * appear before the other. + * It is sufficient to make the test here, because if two tuples are equal + * they *must* get compared at some stage of the sort --- otherwise the + * sort algorithm wouldn't have checked whether one must appear before the + * other. * - * Some rather brain-dead implementations of qsort will sometimes call - * the comparison routine to compare a value to itself. (At this - * writing only QNX 4 is known to do such silly things.) Don't raise - * a bogus error in that case. + * Some rather brain-dead implementations of qsort will sometimes call the + * comparison routine to compare a value to itself. (At this writing only + * QNX 4 is known to do such silly things.) Don't raise a bogus error in + * that case. */ if (state->enforceUnique && !equal_hasnull && tuple1 != tuple2) ereport(ERROR, @@ -2159,10 +2139,10 @@ comparetup_index(Tuplesortstate *state, const void *a, const void *b) errdetail("Table contains duplicated values."))); /* - * If key values are equal, we sort on ItemPointer. This does not - * affect validity of the finished index, but it offers cheap - * insurance against performance problems with bad qsort - * implementations that have trouble with large numbers of equal keys. + * If key values are equal, we sort on ItemPointer. This does not affect + * validity of the finished index, but it offers cheap insurance against + * performance problems with bad qsort implementations that have trouble + * with large numbers of equal keys. */ { BlockNumber blk1 = ItemPointerGetBlockNumber(&tuple1->t_tid); diff --git a/src/backend/utils/sort/tuplestore.c b/src/backend/utils/sort/tuplestore.c index 1c00e06371..d409121418 100644 --- a/src/backend/utils/sort/tuplestore.c +++ b/src/backend/utils/sort/tuplestore.c @@ -36,7 +36,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/sort/tuplestore.c,v 1.22 2005/05/06 17:24:54 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/sort/tuplestore.c,v 1.23 2005/10/15 02:49:37 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -72,41 +72,41 @@ struct Tuplestorestate BufFile *myfile; /* underlying file, or NULL if none */ /* - * These function pointers decouple the routines that must know what - * kind of tuple we are handling from the routines that don't need to - * know it. They are set up by the tuplestore_begin_xxx routines. + * These function pointers decouple the routines that must know what kind + * of tuple we are handling from the routines that don't need to know it. + * They are set up by the tuplestore_begin_xxx routines. * - * (Although tuplestore.c currently only supports heap tuples, I've - * copied this part of tuplesort.c so that extension to other kinds of - * objects will be easy if it's ever needed.) + * (Although tuplestore.c currently only supports heap tuples, I've copied + * this part of tuplesort.c so that extension to other kinds of objects + * will be easy if it's ever needed.) * * Function to copy a supplied input tuple into palloc'd space. (NB: we - * assume that a single pfree() is enough to release the tuple later, - * so the representation must be "flat" in one palloc chunk.) - * state->availMem must be decreased by the amount of space used. + * assume that a single pfree() is enough to release the tuple later, so + * the representation must be "flat" in one palloc chunk.) state->availMem + * must be decreased by the amount of space used. */ void *(*copytup) (Tuplestorestate *state, void *tup); /* - * Function to write a stored tuple onto tape. The representation of - * the tuple on tape need not be the same as it is in memory; - * requirements on the tape representation are given below. After - * writing the tuple, pfree() it, and increase state->availMem by the - * amount of memory space thereby released. + * Function to write a stored tuple onto tape. The representation of the + * tuple on tape need not be the same as it is in memory; requirements on + * the tape representation are given below. After writing the tuple, + * pfree() it, and increase state->availMem by the amount of memory space + * thereby released. */ void (*writetup) (Tuplestorestate *state, void *tup); /* - * Function to read a stored tuple from tape back into memory. 'len' - * is the already-read length of the stored tuple. Create and return - * a palloc'd copy, and decrease state->availMem by the amount of - * memory space consumed. + * Function to read a stored tuple from tape back into memory. 'len' is + * the already-read length of the stored tuple. Create and return a + * palloc'd copy, and decrease state->availMem by the amount of memory + * space consumed. */ void *(*readtup) (Tuplestorestate *state, unsigned int len); /* - * This array holds pointers to tuples in memory if we are in state - * INMEM. In states WRITEFILE and READFILE it's not used. + * This array holds pointers to tuples in memory if we are in state INMEM. + * In states WRITEFILE and READFILE it's not used. */ void **memtuples; /* array of pointers to palloc'd tuples */ int memtupcount; /* number of tuples currently present */ @@ -115,17 +115,17 @@ struct Tuplestorestate /* * These variables are used to keep track of the current position. * - * In state WRITEFILE, the current file seek position is the write point, - * and the read position is remembered in readpos_xxx; in state - * READFILE, the current file seek position is the read point, and the - * write position is remembered in writepos_xxx. (The write position - * is the same as EOF, but since BufFileSeek doesn't currently - * implement SEEK_END, we have to remember it explicitly.) + * In state WRITEFILE, the current file seek position is the write point, and + * the read position is remembered in readpos_xxx; in state READFILE, the + * current file seek position is the read point, and the write position is + * remembered in writepos_xxx. (The write position is the same as EOF, + * but since BufFileSeek doesn't currently implement SEEK_END, we have to + * remember it explicitly.) * - * Special case: if we are in WRITEFILE state and eof_reached is true, - * then the read position is implicitly equal to the write position - * (and hence to the file seek position); this way we need not update - * the readpos_xxx variables on each write. + * Special case: if we are in WRITEFILE state and eof_reached is true, then + * the read position is implicitly equal to the write position (and hence + * to the file seek position); this way we need not update the readpos_xxx + * variables on each write. */ bool eof_reached; /* read reached EOF (always valid) */ int current; /* next array index (valid if INMEM) */ @@ -429,7 +429,7 @@ tuplestore_gettuple(Tuplestorestate *state, bool forward, &state->writepos_file, &state->writepos_offset); if (!state->eof_reached) if (BufFileSeek(state->myfile, - state->readpos_file, state->readpos_offset, + state->readpos_file, state->readpos_offset, SEEK_SET) != 0) elog(ERROR, "seek failed"); state->status = TSS_READFILE; @@ -454,11 +454,11 @@ tuplestore_gettuple(Tuplestorestate *state, bool forward, /* * Backward. * - * if all tuples are fetched already then we return last tuple, - * else - tuple before last returned. + * if all tuples are fetched already then we return last tuple, else + * - tuple before last returned. * - * Back up to fetch previously-returned tuple's ending length - * word. If seek fails, assume we are at start of file. + * Back up to fetch previously-returned tuple's ending length word. + * If seek fails, assume we are at start of file. */ if (BufFileSeek(state->myfile, 0, -(long) sizeof(unsigned int), SEEK_CUR) != 0) @@ -476,17 +476,17 @@ tuplestore_gettuple(Tuplestorestate *state, bool forward, * Back up to get ending length word of tuple before it. */ if (BufFileSeek(state->myfile, 0, - -(long) (tuplen + 2 * sizeof(unsigned int)), + -(long) (tuplen + 2 * sizeof(unsigned int)), SEEK_CUR) != 0) { /* - * If that fails, presumably the prev tuple is the - * first in the file. Back up so that it becomes next - * to read in forward direction (not obviously right, - * but that is what in-memory case does). + * If that fails, presumably the prev tuple is the first + * in the file. Back up so that it becomes next to read + * in forward direction (not obviously right, but that is + * what in-memory case does). */ if (BufFileSeek(state->myfile, 0, - -(long) (tuplen + sizeof(unsigned int)), + -(long) (tuplen + sizeof(unsigned int)), SEEK_CUR) != 0) elog(ERROR, "bogus tuple length in backward scan"); return NULL; @@ -495,9 +495,9 @@ tuplestore_gettuple(Tuplestorestate *state, bool forward, } /* - * Now we have the length of the prior tuple, back up and read - * it. Note: READTUP expects we are positioned after the - * initial length word of the tuple, so back up to that point. + * Now we have the length of the prior tuple, back up and read it. + * Note: READTUP expects we are positioned after the initial + * length word of the tuple, so back up to that point. */ if (BufFileSeek(state->myfile, 0, -(long) tuplen, diff --git a/src/backend/utils/time/tqual.c b/src/backend/utils/time/tqual.c index f8dcf43b64..fa6bd4a3c5 100644 --- a/src/backend/utils/time/tqual.c +++ b/src/backend/utils/time/tqual.c @@ -21,7 +21,7 @@ * TransactionIdDidCommit will both return true. If we check only * TransactionIdDidCommit, we could consider a tuple committed when a * later GetSnapshotData call will still think the originating transaction - * is in progress, which leads to application-level inconsistency. The + * is in progress, which leads to application-level inconsistency. The * upshot is that we gotta check TransactionIdIsInProgress first in all * code paths, except for a few cases where we are looking at * subtransactions of our own main transaction and so there can't be any @@ -32,7 +32,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/time/tqual.c,v 1.90 2005/08/20 00:39:57 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/time/tqual.c,v 1.91 2005/10/15 02:49:37 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -559,8 +559,7 @@ HeapTupleSatisfiesUpdate(HeapTupleHeader tuple, CommandId curcid, else if (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXmin(tuple))) { if (HeapTupleHeaderGetCmin(tuple) >= curcid) - return HeapTupleInvisible; /* inserted after scan - * started */ + return HeapTupleInvisible; /* inserted after scan started */ if (tuple->t_infomask & HEAP_XMAX_INVALID) /* xid invalid */ return HeapTupleMayBeUpdated; @@ -581,11 +580,9 @@ HeapTupleSatisfiesUpdate(HeapTupleHeader tuple, CommandId curcid, Assert(TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXmax(tuple))); if (HeapTupleHeaderGetCmax(tuple) >= curcid) - 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 (TransactionIdIsInProgress(HeapTupleHeaderGetXmin(tuple))) return HeapTupleInvisible; @@ -632,8 +629,7 @@ HeapTupleSatisfiesUpdate(HeapTupleHeader tuple, CommandId curcid, if (tuple->t_infomask & HEAP_IS_LOCKED) return HeapTupleMayBeUpdated; if (HeapTupleHeaderGetCmax(tuple) >= curcid) - return HeapTupleSelfUpdated; /* updated after scan - * started */ + return HeapTupleSelfUpdated; /* updated after scan started */ else return HeapTupleInvisible; /* updated before scan started */ } @@ -945,12 +941,12 @@ HeapTupleSatisfiesSnapshot(HeapTupleHeader tuple, Snapshot snapshot, * By here, the inserting transaction has committed - have to check * when... * - * Note that the provided snapshot contains only top-level XIDs, so we - * have to convert a subxact XID to its parent for comparison. - * However, we can make first-pass range checks with the given XID, - * because a subxact with XID < xmin has surely also got a parent with - * XID < xmin, while one with XID >= xmax must belong to a parent that - * was not yet committed at the time of this snapshot. + * Note that the provided snapshot contains only top-level XIDs, so we have + * to convert a subxact XID to its parent for comparison. However, we can + * make first-pass range checks with the given XID, because a subxact with + * XID < xmin has surely also got a parent with XID < xmin, while one with + * XID >= xmax must belong to a parent that was not yet committed at the + * time of this snapshot. */ if (TransactionIdFollowsOrEquals(HeapTupleHeaderGetXmin(tuple), snapshot->xmin)) @@ -1074,8 +1070,8 @@ HeapTupleSatisfiesVacuum(HeapTupleHeader tuple, TransactionId OldestXmin, /* * Has inserting transaction committed? * - * If the inserting transaction aborted, then the tuple was never visible - * to any other transaction, so we can delete it immediately. + * If the inserting transaction aborted, then the tuple was never visible to + * any other transaction, so we can delete it immediately. */ if (!(tuple->t_infomask & HEAP_XMIN_COMMITTED)) { @@ -1135,8 +1131,7 @@ HeapTupleSatisfiesVacuum(HeapTupleHeader tuple, TransactionId OldestXmin, else { /* - * Not in Progress, Not Committed, so either Aborted or - * crashed + * Not in Progress, Not Committed, so either Aborted or crashed */ tuple->t_infomask |= HEAP_XMIN_INVALID; SetBufferCommitInfoNeedsSave(buffer); @@ -1147,8 +1142,8 @@ HeapTupleSatisfiesVacuum(HeapTupleHeader tuple, TransactionId OldestXmin, } /* - * Okay, the inserter committed, so it was good at some point. Now - * what about the deleting transaction? + * Okay, the inserter committed, so it was good at some point. Now what + * about the deleting transaction? */ if (tuple->t_infomask & HEAP_XMAX_INVALID) return HEAPTUPLE_LIVE; @@ -1156,10 +1151,10 @@ HeapTupleSatisfiesVacuum(HeapTupleHeader tuple, TransactionId OldestXmin, if (tuple->t_infomask & HEAP_IS_LOCKED) { /* - * "Deleting" xact really only locked it, so the tuple - * is live in any case. However, we must make sure that either - * XMAX_COMMITTED or XMAX_INVALID gets set once the xact is gone; - * otherwise it is unsafe to recycle CLOG status after vacuuming. + * "Deleting" xact really only locked it, so the tuple is live in any + * case. However, we must make sure that either XMAX_COMMITTED or + * XMAX_INVALID gets set once the xact is gone; otherwise it is unsafe + * to recycle CLOG status after vacuuming. */ if (!(tuple->t_infomask & HEAP_XMAX_COMMITTED)) { @@ -1175,9 +1170,9 @@ HeapTupleSatisfiesVacuum(HeapTupleHeader tuple, TransactionId OldestXmin, } /* - * We don't really care whether xmax did commit, abort or - * crash. We know that xmax did lock the tuple, but - * it did not and will never actually update it. + * We don't really care whether xmax did commit, abort or crash. + * We know that xmax did lock the tuple, but it did not and will + * never actually update it. */ tuple->t_infomask |= HEAP_XMAX_INVALID; SetBufferCommitInfoNeedsSave(buffer); @@ -1204,8 +1199,7 @@ HeapTupleSatisfiesVacuum(HeapTupleHeader tuple, TransactionId OldestXmin, else { /* - * Not in Progress, Not Committed, so either Aborted or - * crashed + * Not in Progress, Not Committed, so either Aborted or crashed */ tuple->t_infomask |= HEAP_XMAX_INVALID; SetBufferCommitInfoNeedsSave(buffer); @@ -1223,10 +1217,10 @@ HeapTupleSatisfiesVacuum(HeapTupleHeader tuple, TransactionId OldestXmin, HeapTupleHeaderGetXmax(tuple))) { /* - * Inserter also deleted it, so it was never visible to anyone - * else. However, we can only remove it early if it's not an - * updated tuple; else its parent tuple is linking to it via t_ctid, - * and this tuple mustn't go away before the parent does. + * Inserter also deleted it, so it was never visible to anyone else. + * However, we can only remove it early if it's not an updated tuple; + * else its parent tuple is linking to it via t_ctid, and this tuple + * mustn't go away before the parent does. */ if (!(tuple->t_infomask & HEAP_UPDATED)) return HEAPTUPLE_DEAD; diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index f0d97f13f9..d79e4985a7 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -18,7 +18,7 @@ * to produce a new database. * * For largely-historical reasons, the template1 database is the one built - * by the basic bootstrap process. After it is complete, template0 and + * by the basic bootstrap process. After it is complete, template0 and * the default database, postgres, are made just by copying template1. * * To create template1, we run the postgres (backend) program in bootstrap @@ -42,7 +42,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * Portions taken from FreeBSD. * - * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.98 2005/08/28 22:21:46 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.99 2005/10/15 02:49:37 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -74,50 +74,50 @@ int optreset; /* * these values are passed in by makefile defines */ -static char *share_path = NULL; +static char *share_path = NULL; /* values to be obtained from arguments */ -static char *pg_data = ""; -static char *encoding = ""; -static char *locale = ""; -static char *lc_collate = ""; -static char *lc_ctype = ""; -static char *lc_monetary = ""; -static char *lc_numeric = ""; -static char *lc_time = ""; -static char *lc_messages = ""; -static char *username = ""; -static bool pwprompt = false; -static char *pwfilename = NULL; -static char *authmethod = ""; -static bool debug = false; -static bool noclean = false; -static bool show_setting = false; +static char *pg_data = ""; +static char *encoding = ""; +static char *locale = ""; +static char *lc_collate = ""; +static char *lc_ctype = ""; +static char *lc_monetary = ""; +static char *lc_numeric = ""; +static char *lc_time = ""; +static char *lc_messages = ""; +static char *username = ""; +static bool pwprompt = false; +static char *pwfilename = NULL; +static char *authmethod = ""; +static bool debug = false; +static bool noclean = false; +static bool show_setting = false; /* internal vars */ static const char *progname; -static char *encodingid = "0"; -static char *bki_file; -static char *desc_file; -static char *hba_file; -static char *ident_file; -static char *conf_file; -static char *conversion_file; -static char *info_schema_file; -static char *features_file; -static char *system_views_file; -static char *effective_user; -static bool made_new_pgdata = false; -static bool found_existing_pgdata = false; -static char infoversion[100]; -static bool caught_signal = false; -static bool output_failed = false; -static int output_errno = 0; +static char *encodingid = "0"; +static char *bki_file; +static char *desc_file; +static char *hba_file; +static char *ident_file; +static char *conf_file; +static char *conversion_file; +static char *info_schema_file; +static char *features_file; +static char *system_views_file; +static char *effective_user; +static bool made_new_pgdata = false; +static bool found_existing_pgdata = false; +static char infoversion[100]; +static bool caught_signal = false; +static bool output_failed = false; +static int output_errno = 0; /* defaults */ -static int n_connections = 10; -static int n_buffers = 50; +static int n_connections = 10; +static int n_buffers = 50; /* * Warning messages for authentication methods @@ -127,7 +127,7 @@ static int n_buffers = 50; "# any local user to connect as any PostgreSQL user, including the database\n" \ "# superuser. If you do not trust all your local users, use another\n" \ "# authentication method.\n" -static char *authwarning = NULL; +static char *authwarning = NULL; /* * Centralized knowledge of switches to pass to backend @@ -141,13 +141,14 @@ static const char *backend_options = "-F -O -c search_path=pg_catalog -c exit_on /* path to 'initdb' binary directory */ -static char bin_path[MAXPGPATH]; -static char backend_exec[MAXPGPATH]; +static char bin_path[MAXPGPATH]; +static char backend_exec[MAXPGPATH]; static void *pg_malloc(size_t size); static char *xstrdup(const char *s); static char **replace_token(char **lines, - const char *token, const char *replacement); + const char *token, const char *replacement); + #ifndef HAVE_UNIX_SOCKETS static char **filter_lines_with_token(char **lines, const char *token); #endif @@ -335,7 +336,9 @@ static char ** filter_lines_with_token(char **lines, const char *token) { int numlines = 1; - int i, src, dst; + int i, + src, + dst; char **result; for (i = 0; lines[i]; i++) @@ -458,7 +461,7 @@ writefile(char *path, char **lines) static FILE * popen_check(const char *command, const char *mode) { - FILE *cmdfd; + FILE *cmdfd; fflush(stdout); fflush(stderr); @@ -531,14 +534,13 @@ mkdir_p(char *path, mode_t omode) { /* * POSIX 1003.2: For each dir operand that does not name an - * existing directory, effects equivalent to those caused by - * the following command shall occcur: + * existing directory, effects equivalent to those caused by the + * following command shall occcur: * - * mkdir -p -m $(umask -S),u+wx $(dirname dir) && mkdir [-m mode] - * dir + * mkdir -p -m $(umask -S),u+wx $(dirname dir) && mkdir [-m mode] dir * - * We change the user's umask and then restore it, instead of - * doing chmod's. + * We change the user's umask and then restore it, instead of doing + * chmod's. */ oumask = umask(0); numask = oumask & ~(S_IWUSR | S_IXUSR); @@ -606,7 +608,7 @@ exit_nicely(void) { if (made_new_pgdata || found_existing_pgdata) fprintf(stderr, - _("%s: data directory \"%s\" not removed at user's request\n"), + _("%s: data directory \"%s\" not removed at user's request\n"), progname, pg_data); } @@ -640,7 +642,6 @@ get_id(void) exit(1); } #endif - #else /* the windows code */ struct passwd_win32 @@ -829,7 +830,7 @@ check_encodings_match(int pg_enc, const char *ctype) for (i = 0; encoding_match_list[i].system_enc_name; i++) { if (pg_enc == encoding_match_list[i].pg_enc_code - && pg_strcasecmp(sys, encoding_match_list[i].system_enc_name) == 0) + && pg_strcasecmp(sys, encoding_match_list[i].system_enc_name) == 0) { free(sys); return; @@ -839,11 +840,11 @@ check_encodings_match(int pg_enc, const char *ctype) fprintf(stderr, _("%s: warning: encoding mismatch\n"), progname); fprintf(stderr, - _("The encoding you selected (%s) and the encoding that the selected\n" - "locale uses (%s) are not known to match. This may lead to\n" - "misbehavior in various character string processing functions. To fix\n" - "this situation, rerun %s and either do not specify an encoding\n" - "explicitly, or choose a matching combination.\n"), + _("The encoding you selected (%s) and the encoding that the selected\n" + "locale uses (%s) are not known to match. This may lead to\n" + "misbehavior in various character string processing functions. To fix\n" + "this situation, rerun %s and either do not specify an encoding\n" + "explicitly, or choose a matching combination.\n"), pg_encoding_to_char(pg_enc), sys, progname); free(sys); @@ -944,9 +945,10 @@ check_data_dir(void) } #ifdef WIN32 + /* - * This fix is in mingw cvs (runtime/mingwex/dirent.c rev 1.4), but - * not in released version + * This fix is in mingw cvs (runtime/mingwex/dirent.c rev 1.4), but not in + * released version */ if (GetLastError() == ERROR_NO_MORE_FILES) errno = 0; @@ -969,7 +971,7 @@ mkdatadir(const char *subdir) char *path; path = pg_malloc(strlen(pg_data) + 2 + - (subdir == NULL ? 0 : strlen(subdir))); + (subdir == NULL ? 0 : strlen(subdir))); if (subdir != NULL) sprintf(path, "%s/%s", pg_data, subdir); @@ -1008,7 +1010,7 @@ check_input(char *path) { fprintf(stderr, _("%s: file \"%s\" does not exist\n" - "This means you have a corrupted installation or identified\n" + "This means you have a corrupted installation or identified\n" "the wrong directory with the invocation option -L.\n"), progname, path); exit(1); @@ -1205,28 +1207,30 @@ setup_config(void) conflines = readfile(hba_file); #ifndef HAVE_UNIX_SOCKETS - conflines = filter_lines_with_token(conflines,"@remove-line-for-nolocal@"); + conflines = filter_lines_with_token(conflines, "@remove-line-for-nolocal@"); #else - conflines = replace_token(conflines,"@remove-line-for-nolocal@",""); + conflines = replace_token(conflines, "@remove-line-for-nolocal@", ""); #endif #ifdef HAVE_IPV6 - /* + + /* * Probe to see if there is really any platform support for IPv6, and * comment out the relevant pg_hba line if not. This avoids runtime * warnings if getaddrinfo doesn't actually cope with IPv6. Particularly - * useful on Windows, where executables built on a machine with IPv6 - * may have to run on a machine without. + * useful on Windows, where executables built on a machine with IPv6 may + * have to run on a machine without. */ { struct addrinfo *gai_result; struct addrinfo hints; - int err = 0; + int err = 0; + #ifdef WIN32 /* need to call WSAStartup before calling getaddrinfo */ - WSADATA wsaData; + WSADATA wsaData; - err = WSAStartup(MAKEWORD(2,2), &wsaData); + err = WSAStartup(MAKEWORD(2, 2), &wsaData); #endif /* for best results, this code should match parse_hba() */ @@ -1245,12 +1249,12 @@ setup_config(void) "host all all ::1", "#host all all ::1"); } -#else /* !HAVE_IPV6 */ +#else /* !HAVE_IPV6 */ /* If we didn't compile IPV6 support at all, always comment it out */ conflines = replace_token(conflines, "host all all ::1", "#host all all ::1"); -#endif /* HAVE_IPV6 */ +#endif /* HAVE_IPV6 */ /* Replace default authentication methods */ conflines = replace_token(conflines, @@ -1259,7 +1263,7 @@ setup_config(void) conflines = replace_token(conflines, "@authcomment@", - strcmp(authmethod, "trust") ? "" : AUTHTRUST_WARNING); + strcmp(authmethod, "trust") ? "" : AUTHTRUST_WARNING); snprintf(path, sizeof(path), "%s/pg_hba.conf", pg_data); @@ -1311,9 +1315,9 @@ bootstrap_template1(char *short_version) if (strcmp(headerline, *bki_lines) != 0) { fprintf(stderr, - _("%s: input file \"%s\" does not belong to PostgreSQL %s\n" - "Check your installation or specify the correct path " - "using the option -L.\n"), + _("%s: input file \"%s\" does not belong to PostgreSQL %s\n" + "Check your installation or specify the correct path " + "using the option -L.\n"), progname, bki_file, PG_VERSION); exit_nicely(); } @@ -1325,8 +1329,8 @@ bootstrap_template1(char *short_version) /* * Pass correct LC_xxx environment to bootstrap. * - * The shell script arranged to restore the LC settings afterwards, but - * there doesn't seem to be any compelling reason to do that. + * The shell script arranged to restore the LC settings afterwards, but there + * doesn't seem to be any compelling reason to do that. */ snprintf(cmd, sizeof(cmd), "LC_COLLATE=%s", lc_collate); putenv(xstrdup(cmd)); @@ -1368,8 +1372,8 @@ setup_auth(void) char **line; static char *pg_authid_setup[] = { /* - * Create triggers to ensure manual updates to shared catalogs - * will be reflected into their "flat file" copies. + * Create triggers to ensure manual updates to shared catalogs will be + * reflected into their "flat file" copies. */ "CREATE TRIGGER pg_sync_pg_database " " AFTER INSERT OR UPDATE OR DELETE ON pg_database " @@ -1382,8 +1386,8 @@ setup_auth(void) " FOR EACH STATEMENT EXECUTE PROCEDURE flatfile_update_trigger();\n", /* - * The authid table shouldn't be readable except through views, - * to ensure passwords are not publicly visible. + * The authid table shouldn't be readable except through views, to + * ensure passwords are not publicly visible. */ "REVOKE ALL on pg_authid FROM public;\n", NULL @@ -1440,9 +1444,9 @@ get_set_pwd(void) * Read password from file * * Ideally this should insist that the file not be world-readable. - * However, this option is mainly intended for use on Windows - * where file permissions may not exist at all, so we'll skip the - * paranoia for now. + * However, this option is mainly intended for use on Windows where + * file permissions may not exist at all, so we'll skip the paranoia + * for now. */ FILE *pwf = fopen(pwfilename, "r"); char pwdbuf[MAXPGPATH]; @@ -1545,14 +1549,14 @@ setup_depend(void) char **line; static char *pg_depend_setup[] = { /* - * Make PIN entries in pg_depend for all objects made so far in - * the tables that the dependency code handles. This is overkill - * (the system doesn't really depend on having every last weird - * datatype, for instance) but generating only the minimum - * required set of dependencies seems hard. + * Make PIN entries in pg_depend for all objects made so far in the + * tables that the dependency code handles. This is overkill (the + * system doesn't really depend on having every last weird datatype, + * for instance) but generating only the minimum required set of + * dependencies seems hard. * - * Note that we deliberately do not pin the system views, which - * haven't been created yet. + * Note that we deliberately do not pin the system views, which haven't + * been created yet. * * First delete any already-made entries; PINs override all else, and * must be the only entries for their objects. @@ -1728,7 +1732,7 @@ setup_conversion(void) /* * Set up privileges * - * We mark most system catalogs as world-readable. We don't currently have + * We mark most system catalogs as world-readable. We don't currently have * to touch functions, languages, or databases, because their default * permissions are OK. * @@ -1815,8 +1819,7 @@ setup_schema(void) lines = readfile(info_schema_file); /* - * We use -N here to avoid backslashing stuff in - * information_schema.sql + * We use -N here to avoid backslashing stuff in information_schema.sql */ snprintf(cmd, sizeof(cmd), "\"%s\" %s -N template1 >%s", @@ -1907,8 +1910,8 @@ make_template0(void) /* * Explicitly revoke public create-schema and create-temp-table - * privileges in template1 and template0; else the latter would be - * on by default + * privileges in template1 and template0; else the latter would be on + * by default */ "REVOKE CREATE,TEMPORARY ON DATABASE template1 FROM public;\n", "REVOKE CREATE,TEMPORARY ON DATABASE template0 FROM public;\n", @@ -2034,9 +2037,10 @@ static char * escape_quotes(const char *src) { int len = strlen(src), - i, j; - char *result = pg_malloc(len * 2 + 1); - + i, + j; + char *result = pg_malloc(len * 2 + 1); + for (i = 0, j = 0; i < len; i++) { if (SQL_STR_DOUBLE(src[i])) @@ -2102,8 +2106,7 @@ setlocales(void) } /* - * override absent/invalid config settings from initdb's locale - * settings + * override absent/invalid config settings from initdb's locale settings */ if (strlen(lc_ctype) == 0 || !chklocale(lc_ctype)) @@ -2204,7 +2207,7 @@ main(int argc, char *argv[]) char *pgdenv; /* PGDATA value gotten from and sent to * environment */ char bin_dir[MAXPGPATH]; - char *pg_data_native; + char *pg_data_native; static const char *subdirs[] = { "global", "pg_xlog", @@ -2337,8 +2340,7 @@ main(int argc, char *argv[]) if (strcmp(authmethod, "md5") && strcmp(authmethod, "ident") && - strncmp(authmethod, "ident ", 6) && /* ident with space = - * param */ + strncmp(authmethod, "ident ", 6) && /* ident with space = param */ strcmp(authmethod, "trust") && #ifdef USE_PAM strcmp(authmethod, "pam") && @@ -2391,10 +2393,10 @@ main(int argc, char *argv[]) canonicalize_path(pg_data); /* - * we have to set PGDATA for postgres rather than pass it on the - * command line to avoid dumb quoting problems on Windows, and we - * would especially need quotes otherwise on Windows because paths - * there are most likely to have embedded spaces. + * we have to set PGDATA for postgres rather than pass it on the command + * line to avoid dumb quoting problems on Windows, and we would especially + * need quotes otherwise on Windows because paths there are most likely to + * have embedded spaces. */ pgdenv = pg_malloc(8 + strlen(pg_data)); sprintf(pgdenv, "PGDATA=%s", pg_data); @@ -2403,7 +2405,7 @@ main(int argc, char *argv[]) if ((ret = find_other_exec(argv[0], "postgres", PG_VERSIONSTR, backend_exec)) < 0) { - char full_path[MAXPGPATH]; + char full_path[MAXPGPATH]; if (find_my_exec(argv[0], full_path) < 0) StrNCpy(full_path, progname, MAXPGPATH); @@ -2557,8 +2559,7 @@ main(int argc, char *argv[]) umask(077); /* - * now we are starting to do real work, trap signals so we can clean - * up + * now we are starting to do real work, trap signals so we can clean up */ /* some of these are not valid on Windows */ @@ -2650,9 +2651,9 @@ main(int argc, char *argv[]) /* * Determine platform-specific config settings * - * Use reasonable values if kernel will let us, else scale back. Probe - * for max_connections first since it is subject to more constraints - * than shared_buffers. + * Use reasonable values if kernel will let us, else scale back. Probe for + * max_connections first since it is subject to more constraints than + * shared_buffers. */ set_null_conf(); @@ -2667,8 +2668,7 @@ main(int argc, char *argv[]) bootstrap_template1(short_version); /* - * Make the per-database PG_VERSION for template1 only after init'ing - * it + * Make the per-database PG_VERSION for template1 only after init'ing it */ set_short_version(short_version, "base/1"); @@ -2697,22 +2697,22 @@ main(int argc, char *argv[]) make_template0(); make_postgres(); - + if (authwarning != NULL) fprintf(stderr, "%s", authwarning); /* Get directory specification used to start this executable */ strcpy(bin_dir, argv[0]); get_parent_directory(bin_dir); - + printf(_("\nSuccess. You can now start the database server using:\n\n" " %s%s%spostmaster%s -D %s%s%s\n" "or\n" " %s%s%spg_ctl%s -D %s%s%s -l logfile start\n\n"), - QUOTE_PATH, bin_dir, (strlen(bin_dir) > 0) ? DIR_SEP : "", QUOTE_PATH, - QUOTE_PATH, pg_data_native, QUOTE_PATH, - QUOTE_PATH, bin_dir, (strlen(bin_dir) > 0) ? DIR_SEP : "", QUOTE_PATH, - QUOTE_PATH, pg_data_native, QUOTE_PATH); + QUOTE_PATH, bin_dir, (strlen(bin_dir) > 0) ? DIR_SEP : "", QUOTE_PATH, + QUOTE_PATH, pg_data_native, QUOTE_PATH, + QUOTE_PATH, bin_dir, (strlen(bin_dir) > 0) ? DIR_SEP : "", QUOTE_PATH, + QUOTE_PATH, pg_data_native, QUOTE_PATH); return 0; } diff --git a/src/bin/pg_config/pg_config.c b/src/bin/pg_config/pg_config.c index b5ea5265a9..9943ddf6f8 100644 --- a/src/bin/pg_config/pg_config.c +++ b/src/bin/pg_config/pg_config.c @@ -17,7 +17,7 @@ * * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/pg_config/pg_config.c,v 1.16 2005/10/13 17:58:44 tgl Exp $ + * $PostgreSQL: pgsql/src/bin/pg_config/pg_config.c,v 1.17 2005/10/15 02:49:37 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -27,7 +27,7 @@ #include "port.h" static const char *progname; -static char mypath[MAXPGPATH]; +static char mypath[MAXPGPATH]; /* @@ -37,7 +37,7 @@ static char mypath[MAXPGPATH]; * C:/Progra~1/ * * This can fail in 2 ways - if the path doesn't exist, or short names are - * disabled. In the first case, don't return any path. In the second case, + * disabled. In the first case, don't return any path. In the second case, * we leave the path in the long form. In this case, it does still seem to * fix elements containing spaces which is all we actually need. */ @@ -49,8 +49,9 @@ cleanup_path(char *path) if (GetShortPathName(path, path, MAXPGPATH - 1) == 0) { - /* Ignore ERROR_INVALID_PARAMETER as it almost certainly - * means that short names are disabled + /* + * Ignore ERROR_INVALID_PARAMETER as it almost certainly means that + * short names are disabled */ if (GetLastError() != ERROR_INVALID_PARAMETER) { @@ -78,8 +79,8 @@ cleanup_path(char *path) static void show_bindir(bool all) { - char path[MAXPGPATH]; - char *lastsep; + char path[MAXPGPATH]; + char *lastsep; if (all) printf("BINDIR = "); @@ -97,7 +98,7 @@ show_bindir(bool all) static void show_docdir(bool all) { - char path[MAXPGPATH]; + char path[MAXPGPATH]; if (all) printf("DOCDIR = "); @@ -109,7 +110,7 @@ show_docdir(bool all) static void show_includedir(bool all) { - char path[MAXPGPATH]; + char path[MAXPGPATH]; if (all) printf("INCLUDEDIR = "); @@ -121,7 +122,7 @@ show_includedir(bool all) static void show_pkgincludedir(bool all) { - char path[MAXPGPATH]; + char path[MAXPGPATH]; if (all) printf("PKGINCLUDEDIR = "); @@ -133,7 +134,7 @@ show_pkgincludedir(bool all) static void show_includedir_server(bool all) { - char path[MAXPGPATH]; + char path[MAXPGPATH]; if (all) printf("INCLUDEDIR-SERVER = "); @@ -145,7 +146,7 @@ show_includedir_server(bool all) static void show_libdir(bool all) { - char path[MAXPGPATH]; + char path[MAXPGPATH]; if (all) printf("LIBDIR = "); @@ -157,7 +158,7 @@ show_libdir(bool all) static void show_pkglibdir(bool all) { - char path[MAXPGPATH]; + char path[MAXPGPATH]; if (all) printf("PKGLIBDIR = "); @@ -169,7 +170,7 @@ show_pkglibdir(bool all) static void show_localedir(bool all) { - char path[MAXPGPATH]; + char path[MAXPGPATH]; if (all) printf("LOCALEDIR = "); @@ -181,7 +182,7 @@ show_localedir(bool all) static void show_mandir(bool all) { - char path[MAXPGPATH]; + char path[MAXPGPATH]; if (all) printf("MANDIR = "); @@ -193,7 +194,7 @@ show_mandir(bool all) static void show_sharedir(bool all) { - char path[MAXPGPATH]; + char path[MAXPGPATH]; if (all) printf("SHAREDIR = "); @@ -205,7 +206,7 @@ show_sharedir(bool all) static void show_sysconfdir(bool all) { - char path[MAXPGPATH]; + char path[MAXPGPATH]; if (all) printf("SYSCONFDIR = "); @@ -217,7 +218,7 @@ show_sysconfdir(bool all) static void show_pgxs(bool all) { - char path[MAXPGPATH]; + char path[MAXPGPATH]; if (all) printf("PGXS = "); @@ -376,28 +377,28 @@ typedef struct } InfoItem; static const InfoItem info_items[] = { - { "--bindir", show_bindir }, - { "--docdir", show_docdir }, - { "--includedir", show_includedir }, - { "--pkgincludedir", show_pkgincludedir }, - { "--includedir-server", show_includedir_server }, - { "--libdir", show_libdir }, - { "--pkglibdir", show_pkglibdir }, - { "--localedir", show_localedir }, - { "--mandir", show_mandir }, - { "--sharedir", show_sharedir }, - { "--sysconfdir", show_sysconfdir }, - { "--pgxs", show_pgxs }, - { "--configure", show_configure }, - { "--cc", show_cc }, - { "--cppflags", show_cppflags }, - { "--cflags", show_cflags }, - { "--cflags_sl", show_cflags_sl }, - { "--ldflags", show_ldflags }, - { "--ldflags_sl", show_ldflags_sl }, - { "--libs", show_libs }, - { "--version", show_version }, - { NULL, NULL } + {"--bindir", show_bindir}, + {"--docdir", show_docdir}, + {"--includedir", show_includedir}, + {"--pkgincludedir", show_pkgincludedir}, + {"--includedir-server", show_includedir_server}, + {"--libdir", show_libdir}, + {"--pkglibdir", show_pkglibdir}, + {"--localedir", show_localedir}, + {"--mandir", show_mandir}, + {"--sharedir", show_sharedir}, + {"--sysconfdir", show_sysconfdir}, + {"--pgxs", show_pgxs}, + {"--configure", show_configure}, + {"--cc", show_cc}, + {"--cppflags", show_cppflags}, + {"--cflags", show_cflags}, + {"--cflags_sl", show_cflags_sl}, + {"--ldflags", show_ldflags}, + {"--ldflags_sl", show_ldflags_sl}, + {"--libs", show_libs}, + {"--version", show_version}, + {NULL, NULL} }; diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c index c5573ee59e..4e9a9afa0e 100644 --- a/src/bin/pg_controldata/pg_controldata.c +++ b/src/bin/pg_controldata/pg_controldata.c @@ -6,7 +6,7 @@ * copyright (c) Oliver Elphick , 2001; * licence: BSD * - * $PostgreSQL: pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.26 2005/10/03 00:28:41 tgl Exp $ + * $PostgreSQL: pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.27 2005/10/15 02:49:37 momjian Exp $ */ #include "postgres.h" @@ -129,11 +129,11 @@ main(int argc, char *argv[]) if (!EQ_CRC32(crc, ControlFile.crc)) printf(_("WARNING: Calculated CRC checksum does not match value stored in file.\n" "Either the file is corrupt, or it has a different layout than this program\n" - "is expecting. The results below are untrustworthy.\n\n")); + "is expecting. The results below are untrustworthy.\n\n")); /* - * Use variable for format to suppress overly-anal-retentive gcc - * warning about %c + * Use variable for format to suppress overly-anal-retentive gcc warning + * about %c */ strftime(pgctime_str, sizeof(pgctime_str), strftime_fmt, localtime(&(ControlFile.time))); @@ -141,8 +141,8 @@ main(int argc, char *argv[]) localtime(&(ControlFile.checkPointCopy.time))); /* - * Format system_identifier separately to keep platform-dependent - * format code out of the translatable message string. + * Format system_identifier separately to keep platform-dependent format + * code out of the translatable message string. */ snprintf(sysident_str, sizeof(sysident_str), UINT64_FORMAT, ControlFile.system_identifier); @@ -157,7 +157,7 @@ main(int argc, char *argv[]) printf(_("Latest checkpoint location: %X/%X\n"), ControlFile.checkPoint.xlogid, ControlFile.checkPoint.xrecoff); printf(_("Prior checkpoint location: %X/%X\n"), - ControlFile.prevCheckPoint.xlogid, ControlFile.prevCheckPoint.xrecoff); + ControlFile.prevCheckPoint.xlogid, ControlFile.prevCheckPoint.xrecoff); printf(_("Latest checkpoint's REDO location: %X/%X\n"), ControlFile.checkPointCopy.redo.xlogid, ControlFile.checkPointCopy.redo.xrecoff); printf(_("Latest checkpoint's UNDO location: %X/%X\n"), diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index fe03b818e2..7c12a72c6d 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -4,7 +4,7 @@ * * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.60 2005/07/25 04:52:32 tgl Exp $ + * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.61 2005/10/15 02:49:38 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -326,22 +326,21 @@ static int start_postmaster(void) { /* - * Since there might be quotes to handle here, it is easier simply to - * pass everything to a shell to process them. + * Since there might be quotes to handle here, it is easier simply to pass + * everything to a shell to process them. */ char cmd[MAXPGPATH]; /* * Win32 needs START /B rather than "&". * - * Win32 has a problem with START and quoted executable names. You must - * add a "" as the title at the beginning so you can quote the - * executable name: + * Win32 has a problem with START and quoted executable names. You must add a + * "" as the title at the beginning so you can quote the executable name: * http://www.winnetmag.com/Article/ArticleID/14589/14589.html * http://dev.remotenetworktechnology.com/cmd/cmdfaq.htm */ if (log_file != NULL) -#ifndef WIN32 /* Cygwin doesn't have START */ +#ifndef WIN32 /* Cygwin doesn't have START */ snprintf(cmd, MAXPGPATH, "%s\"%s\" %s%s < \"%s\" >> \"%s\" 2>&1 &%s", SYSTEMQUOTE, postgres_path, pgdata_opt, post_opts, DEVNULL, log_file, SYSTEMQUOTE); @@ -351,7 +350,7 @@ start_postmaster(void) DEVNULL, log_file, SYSTEMQUOTE); #endif else -#ifndef WIN32 /* Cygwin doesn't have START */ +#ifndef WIN32 /* Cygwin doesn't have START */ snprintf(cmd, MAXPGPATH, "%s\"%s\" %s%s < \"%s\" 2>&1 &%s", SYSTEMQUOTE, postgres_path, pgdata_opt, post_opts, DEVNULL, SYSTEMQUOTE); @@ -544,11 +543,11 @@ do_start(void) if ((ret = find_other_exec(argv0, "postmaster", PM_VERSIONSTR, postmaster_path)) < 0) { - char full_path[MAXPGPATH]; - + char full_path[MAXPGPATH]; + if (find_my_exec(argv0, full_path) < 0) StrNCpy(full_path, progname, MAXPGPATH); - + if (ret == -1) write_stderr(_("The program \"postmaster\" is needed by %s " "but was not found in the\n" @@ -715,20 +714,20 @@ do_restart(void) print_msg(_("waiting for postmaster to shut down...")); - /* always wait for restart */ + /* always wait for restart */ for (cnt = 0; cnt < wait_seconds; cnt++) { if ((pid = get_pgpid()) != 0) { print_msg("."); - pg_usleep(1000000); /* 1 sec */ + pg_usleep(1000000); /* 1 sec */ } else break; } - if (pid != 0) /* pid file still exists */ + if (pid != 0) /* pid file still exists */ { print_msg(_(" failed\n")); @@ -792,12 +791,12 @@ postmaster_is_alive(pid_t pid) /* * Test to see if the process is still there. Note that we do not * consider an EPERM failure to mean that the process is still there; - * EPERM must mean that the given PID belongs to some other userid, - * and considering the permissions on $PGDATA, that means it's not - * the postmaster we are after. + * EPERM must mean that the given PID belongs to some other userid, and + * considering the permissions on $PGDATA, that means it's not the + * postmaster we are after. * * Don't believe that our own PID or parent shell's PID is the postmaster, - * either. (Windows hasn't got getppid(), though.) + * either. (Windows hasn't got getppid(), though.) */ if (pid == getpid()) return false; @@ -828,7 +827,8 @@ do_status(void) return; } } - else /* postmaster */ + else + /* postmaster */ { if (postmaster_is_alive((pid_t) pid)) { @@ -880,6 +880,7 @@ pgwin32_CommandLine(bool registration) { static char cmdLine[MAXPGPATH]; int ret; + #ifdef __CYGWIN__ char buf[MAXPGPATH]; #endif @@ -963,10 +964,10 @@ pgwin32_doRegister(void) } if ((hService = CreateService(hSCM, register_servicename, register_servicename, - SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, - SERVICE_AUTO_START, SERVICE_ERROR_NORMAL, + SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, + SERVICE_AUTO_START, SERVICE_ERROR_NORMAL, pgwin32_CommandLine(true), - NULL, NULL, "RPCSS\0", register_username, register_password)) == NULL) + NULL, NULL, "RPCSS\0", register_username, register_password)) == NULL) { CloseServiceHandle(hSCM); write_stderr(_("%s: could not register service \"%s\": error code %d\n"), progname, register_servicename, (int) GetLastError()); @@ -1036,9 +1037,9 @@ pgwin32_ServiceHandler(DWORD request) case SERVICE_CONTROL_SHUTDOWN: /* - * We only need a short wait hint here as it just needs to - * wait for the next checkpoint. They occur every 5 seconds - * during shutdown + * We only need a short wait hint here as it just needs to wait + * for the next checkpoint. They occur every 5 seconds during + * shutdown */ status.dwWaitHint = 10000; pgwin32_SetServiceStatus(SERVICE_STOP_PENDING); @@ -1294,9 +1295,8 @@ main(int argc, char **argv) set_pglocale_pgservice(argv[0], "pg_ctl"); /* - * save argv[0] so do_start() can look for the postmaster if - * necessary. we don't look for postmaster here because in many cases - * we won't need it. + * save argv[0] so do_start() can look for the postmaster if necessary. we + * don't look for postmaster here because in many cases we won't need it. */ argv0 = argv[0]; @@ -1337,9 +1337,9 @@ main(int argc, char **argv) /* * 'Action' can be before or after args so loop over both. Some - * getopt_long() implementations will reorder argv[] to place all - * flags first (GNU?), but we don't rely on it. Our /port version - * doesn't do that. + * getopt_long() implementations will reorder argv[] to place all flags + * first (GNU?), but we don't rely on it. Our /port version doesn't do + * that. */ optind = 1; @@ -1362,9 +1362,9 @@ main(int argc, char **argv) putenv(env_var); /* - * We could pass PGDATA just in an environment - * variable but we do -D too for clearer - * postmaster 'ps' display + * We could pass PGDATA just in an environment + * variable but we do -D too for clearer postmaster + * 'ps' display */ pgdata_opt = pg_malloc(strlen(pgdata_D) + 7); snprintf(pgdata_opt, strlen(pgdata_D) + 7, @@ -1397,7 +1397,7 @@ main(int argc, char **argv) if (strchr(optarg, '\\')) register_username = xstrdup(optarg); else - /* Prepend .\ for local accounts */ + /* Prepend .\ for local accounts */ { register_username = malloc(strlen(optarg) + 3); if (!register_username) diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 56f7665f5f..08497f3562 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -11,7 +11,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/bin/pg_dump/common.c,v 1.86 2005/06/27 02:17:47 tgl Exp $ + * $PostgreSQL: pgsql/src/bin/pg_dump/common.c,v 1.87 2005/10/15 02:49:38 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -292,8 +292,8 @@ flagInhAttrs(TableInfo *tblinfo, int numTables, { foundAttr = true; foundNotNull |= parent->notnull[inhAttrInd]; - if (attrDef != NULL) /* If we have a default, - * check parent */ + if (attrDef != NULL) /* If we have a default, check + * parent */ { AttrDefInfo *inhDef; @@ -302,15 +302,15 @@ flagInhAttrs(TableInfo *tblinfo, int numTables, { defaultsFound = true; defaultsMatch &= (strcmp(attrDef->adef_expr, - inhDef->adef_expr) == 0); + inhDef->adef_expr) == 0); } } } } /* - * Based on the scan of the parents, decide if we can rely on - * the inherited attr + * Based on the scan of the parents, decide if we can rely on the + * inherited attr */ if (foundAttr) /* Attr was inherited */ { @@ -330,8 +330,7 @@ flagInhAttrs(TableInfo *tblinfo, int numTables, } /* - * Clear it if NOT NULL and none of the parents were NOT - * NULL + * Clear it if NOT NULL and none of the parents were NOT NULL */ if (tbinfo->notnull[j] && !foundNotNull) { @@ -346,9 +345,9 @@ flagInhAttrs(TableInfo *tblinfo, int numTables, } /* - * Check for inherited CHECK constraints. We assume a constraint - * is inherited if its name matches the name of any constraint in - * the parent. Originally this code tried to compare the expression + * Check for inherited CHECK constraints. We assume a constraint is + * inherited if its name matches the name of any constraint in the + * parent. Originally this code tried to compare the expression * texts, but that can fail if the parent and child tables are in * different schemas, because reverse-listing of function calls may * produce different text (schema-qualified or not) depending on @@ -528,8 +527,8 @@ DOCatalogIdCompare(const void *p1, const void *p2) int cmpval; /* - * Compare OID first since it's usually unique, whereas there will - * only be a few distinct values of tableoid. + * Compare OID first since it's usually unique, whereas there will only be + * a few distinct values of tableoid. */ cmpval = oidcmp(obj1->catId.oid, obj2->catId.oid); if (cmpval == 0) diff --git a/src/bin/pg_dump/dumputils.c b/src/bin/pg_dump/dumputils.c index 267a8573ac..aa999173b2 100644 --- a/src/bin/pg_dump/dumputils.c +++ b/src/bin/pg_dump/dumputils.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/bin/pg_dump/dumputils.c,v 1.19 2005/07/02 17:01:51 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/pg_dump/dumputils.c,v 1.20 2005/10/15 02:49:38 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -49,8 +49,8 @@ fmtId(const char *rawid) id_return = createPQExpBuffer(); /* - * These checks need to match the identifier production in scan.l. - * Don't use islower() etc. + * These checks need to match the identifier production in scan.l. Don't + * use islower() etc. */ if (ScanKeywordLookup(rawid)) @@ -111,14 +111,14 @@ fmtId(const char *rawid) void appendStringLiteral(PQExpBuffer buf, const char *str, bool escapeAll) { - char ch; + char ch; const char *p; for (p = str; *p; p++) { ch = *p; if (ch == '\\' || - ((unsigned char)ch < (unsigned char)' ' && + ((unsigned char) ch < (unsigned char) ' ' && (escapeAll || (ch != '\t' && ch != '\n' && ch != '\v' && ch != '\f' && ch != '\r')))) @@ -127,7 +127,7 @@ appendStringLiteral(PQExpBuffer buf, const char *str, bool escapeAll) break; } } - + appendPQExpBufferChar(buf, '\''); for (p = str; *p; p++) { @@ -137,14 +137,13 @@ appendStringLiteral(PQExpBuffer buf, const char *str, bool escapeAll) appendPQExpBufferChar(buf, ch); appendPQExpBufferChar(buf, ch); } - else if ((unsigned char)ch < (unsigned char)' ' && + else if ((unsigned char) ch < (unsigned char) ' ' && (escapeAll || (ch != '\t' && ch != '\n' && ch != '\v' && ch != '\f' && ch != '\r'))) { /* - * generate octal escape for control chars other than - * whitespace + * generate octal escape for control chars other than whitespace */ appendPQExpBufferChar(buf, '\\'); appendPQExpBufferChar(buf, ((ch >> 6) & 3) + '0'); @@ -179,10 +178,9 @@ appendStringLiteralDQ(PQExpBuffer buf, const char *str, const char *dqprefix) appendPQExpBufferStr(delimBuf, dqprefix); /* - * Make sure we choose a delimiter which (without the trailing $) is - * not present in the string being quoted. We don't check with the - * trailing $ because a string ending in $foo must not be quoted with - * $foo$. + * Make sure we choose a delimiter which (without the trailing $) is not + * present in the string being quoted. We don't check with the trailing $ + * because a string ending in $foo must not be quoted with $foo$. */ while (strstr(str, delimBuf->data) != NULL) { @@ -260,15 +258,13 @@ parsePGArray(const char *atext, char ***itemarray, int *nitems) /* * We expect input in the form of "{item,item,item}" where any item is - * either raw data, or surrounded by double quotes (in which case - * embedded characters including backslashes and quotes are - * backslashed). + * either raw data, or surrounded by double quotes (in which case embedded + * characters including backslashes and quotes are backslashed). * - * We build the result as an array of pointers followed by the actual - * string data, all in one malloc block for convenience of - * deallocation. The worst-case storage need is not more than one - * pointer and one character for each input character (consider - * "{,,,,,,,,,,}"). + * We build the result as an array of pointers followed by the actual string + * data, all in one malloc block for convenience of deallocation. The + * worst-case storage need is not more than one pointer and one character + * for each input character (consider "{,,,,,,,,,,}"). */ *itemarray = NULL; *nitems = 0; @@ -374,12 +370,11 @@ buildACLCommands(const char *name, const char *type, privswgo = createPQExpBuffer(); /* - * At the end, these two will be pasted together to form the result. - * But the owner privileges need to go before the other ones to keep - * the dependencies valid. In recent versions this is normally the - * case, but in old versions they come after the PUBLIC privileges and - * that results in problems if we need to run REVOKE on the owner - * privileges. + * At the end, these two will be pasted together to form the result. But + * the owner privileges need to go before the other ones to keep the + * dependencies valid. In recent versions this is normally the case, but + * in old versions they come after the PUBLIC privileges and that results + * in problems if we need to run REVOKE on the owner privileges. */ firstsql = createPQExpBuffer(); secondsql = createPQExpBuffer(); @@ -450,7 +445,7 @@ buildACLCommands(const char *name, const char *type, else if (strncmp(grantee->data, "group ", strlen("group ")) == 0) appendPQExpBuffer(secondsql, "GROUP %s;\n", - fmtId(grantee->data + strlen("group "))); + fmtId(grantee->data + strlen("group "))); else appendPQExpBuffer(secondsql, "%s;\n", fmtId(grantee->data)); } @@ -463,7 +458,7 @@ buildACLCommands(const char *name, const char *type, else if (strncmp(grantee->data, "group ", strlen("group ")) == 0) appendPQExpBuffer(secondsql, "GROUP %s", - fmtId(grantee->data + strlen("group "))); + fmtId(grantee->data + strlen("group "))); else appendPQExpBuffer(secondsql, "%s", fmtId(grantee->data)); appendPQExpBuffer(secondsql, " WITH GRANT OPTION;\n"); @@ -477,8 +472,7 @@ buildACLCommands(const char *name, const char *type, } /* - * If we didn't find any owner privs, the owner must have revoked 'em - * all + * If we didn't find any owner privs, the owner must have revoked 'em all */ if (!found_owner_privs && owner) { @@ -638,8 +632,7 @@ copyAclUserName(PQExpBuffer output, char *input) while (*input && *input != '=') { /* - * If user name isn't quoted, then just add it to the output - * buffer + * If user name isn't quoted, then just add it to the output buffer */ if (*input != '"') appendPQExpBufferChar(output, *input++); @@ -654,8 +647,8 @@ copyAclUserName(PQExpBuffer output, char *input) return input; /* really a syntax error... */ /* - * Quoting convention is to escape " as "". Keep this - * code in sync with putid() in backend's acl.c. + * Quoting convention is to escape " as "". Keep this code in + * sync with putid() in backend's acl.c. */ if (*input == '"' && *(input + 1) == '"') input++; diff --git a/src/bin/pg_dump/pg_backup.h b/src/bin/pg_dump/pg_backup.h index 786d427160..41541b1c0b 100644 --- a/src/bin/pg_dump/pg_backup.h +++ b/src/bin/pg_dump/pg_backup.h @@ -15,7 +15,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup.h,v 1.36 2005/06/21 20:45:44 tgl Exp $ + * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup.h,v 1.37 2005/10/15 02:49:38 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -54,10 +54,10 @@ typedef enum _archiveFormat typedef struct _Archive { int verbose; - char *remoteVersionStr; /* server's version string */ - int remoteVersion; /* same in numeric form */ + char *remoteVersionStr; /* server's version string */ + int remoteVersion; /* same in numeric form */ - int minRemoteVersion; /* allowable range */ + int minRemoteVersion; /* allowable range */ int maxRemoteVersion; /* error handling */ @@ -72,10 +72,9 @@ typedef int (*DataDumperPtr) (Archive *AH, void *userArg); typedef struct _restoreOptions { int create; /* Issue commands to create the database */ - int noOwner; /* Don't try to match original object - * owner */ - int disable_triggers; /* disable triggers during - * data-only restore */ + int noOwner; /* Don't try to match original object owner */ + int disable_triggers; /* disable triggers during data-only + * restore */ int use_setsessauth;/* Use SET SESSION AUTHORIZATION commands * instead of OWNER TO */ char *superuser; /* Username to use as superuser */ @@ -114,8 +113,8 @@ typedef struct _restoreOptions bool limitToList; int compression; - int suppressDumpWarnings; /* Suppress output of WARNING - * entries to stderr */ + int suppressDumpWarnings; /* Suppress output of WARNING entries + * to stderr */ } RestoreOptions; /* diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c index 1818cf6288..54eb976920 100644 --- a/src/bin/pg_dump/pg_backup_archiver.c +++ b/src/bin/pg_dump/pg_backup_archiver.c @@ -15,7 +15,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.116 2005/09/28 13:11:26 petere Exp $ + * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.117 2005/10/15 02:49:38 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -45,7 +45,7 @@ static char *modulename = gettext_noop("archiver"); static ArchiveHandle *_allocAH(const char *FileSpec, const ArchiveFormat fmt, const int compression, ArchiveMode mode); static void _getObjectDescription(PQExpBuffer buf, TocEntry *te, - ArchiveHandle *AH); + ArchiveHandle *AH); static void _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isData, bool acl_pass); @@ -139,10 +139,9 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt) * Check for nonsensical option combinations. * * NB: create+dropSchema is useless because if you're creating the DB, - * there's no need to drop individual items in it. Moreover, if we - * tried to do that then we'd issue the drops in the database - * initially connected to, not the one we will create, which is very - * bad... + * there's no need to drop individual items in it. Moreover, if we tried + * to do that then we'd issue the drops in the database initially + * connected to, not the one we will create, which is very bad... */ if (ropt->create && ropt->dropSchema) die_horribly(AH, modulename, "-C and -c are incompatible options\n"); @@ -165,24 +164,24 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt) ropt->requirePassword, ropt->ignoreVersion); /* - * If we're talking to the DB directly, don't send comments since - * they obscure SQL when displaying errors + * If we're talking to the DB directly, don't send comments since they + * obscure SQL when displaying errors */ AH->noTocComments = 1; } /* - * Work out if we have an implied data-only restore. This can happen - * if the dump was data only or if the user has used a toc list to - * exclude all of the schema data. All we do is look for schema - * entries - if none are found then we set the dataOnly flag. + * Work out if we have an implied data-only restore. This can happen if + * the dump was data only or if the user has used a toc list to exclude + * all of the schema data. All we do is look for schema entries - if none + * are found then we set the dataOnly flag. * * We could scan for wanted TABLE entries, but that is not the same as * dataOnly. At this stage, it seems unnecessary (6-Mar-2001). */ if (!ropt->dataOnly) { - int impliedDataOnly = 1; + int impliedDataOnly = 1; for (te = AH->toc->next; te != AH->toc; te = te->next) { @@ -227,7 +226,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt) { AH->currentTE = te; - reqs = _tocEntryRequired(te, ropt, false /* needn't drop ACLs */); + reqs = _tocEntryRequired(te, ropt, false /* needn't drop ACLs */ ); if (((reqs & REQ_SCHEMA) != 0) && te->dropStmt) { /* We want the schema */ @@ -283,10 +282,9 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt) if ((reqs & REQ_DATA) != 0) { /* - * hadDumper will be set if there is genuine data component - * for this node. Otherwise, we need to check the defn field - * for statements that need to be executed in data-only - * restores. + * hadDumper will be set if there is genuine data component for + * this node. Otherwise, we need to check the defn field for + * statements that need to be executed in data-only restores. */ if (te->hadDumper) { @@ -322,15 +320,13 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt) te->tag); /* - * If we have a copy statement, use it. As of - * V1.3, these are separate to allow easy import - * from withing a database connection. Pre 1.3 - * archives can not use DB connections and are - * sent to output only. + * If we have a copy statement, use it. As of V1.3, + * these are separate to allow easy import from + * withing a database connection. Pre 1.3 archives can + * not use DB connections and are sent to output only. * - * For V1.3+, the table data MUST have a copy - * statement so that we can go into appropriate - * mode with libpq. + * For V1.3+, the table data MUST have a copy statement + * so that we can go into appropriate mode with libpq. */ if (te->copyStmt && strlen(te->copyStmt) > 0) ahprintf(AH, "%s", te->copyStmt); @@ -485,7 +481,7 @@ ArchiveEntry(Archive *AHX, CatalogId catalogId, DumpId dumpId, const char *tag, const char *namespace, - const char *tablespace, + const char *tablespace, const char *owner, bool withOids, const char *desc, const char *defn, const char *dropStmt, const char *copyStmt, @@ -808,9 +804,9 @@ archprintf(Archive *AH, const char *fmt,...) int cnt = -1; /* - * This is paranoid: deal with the possibility that vsnprintf is - * willing to ignore trailing null or returns > 0 even if string does - * not fit. It may be the case that it returns cnt = bufsize + * This is paranoid: deal with the possibility that vsnprintf is willing + * to ignore trailing null or returns > 0 even if string does not fit. It + * may be the case that it returns cnt = bufsize */ while (cnt < 0 || cnt >= (bSize - 1)) { @@ -918,13 +914,13 @@ ahprintf(ArchiveHandle *AH, const char *fmt,...) int cnt = -1; /* - * This is paranoid: deal with the possibility that vsnprintf is - * willing to ignore trailing null + * This is paranoid: deal with the possibility that vsnprintf is willing + * to ignore trailing null */ /* - * or returns > 0 even if string does not fit. It may be the case that - * it returns cnt = bufsize + * or returns > 0 even if string does not fit. It may be the case that it + * returns cnt = bufsize */ while (cnt < 0 || cnt >= (bSize - 1)) { @@ -980,13 +976,13 @@ dump_lo_buf(ArchiveHandle *AH) (unsigned long) AH->lo_buf_used, (unsigned long) res); if (res != AH->lo_buf_used) die_horribly(AH, modulename, - "could not write to large object (result: %lu, expected: %lu)\n", - (unsigned long) res, (unsigned long) AH->lo_buf_used); + "could not write to large object (result: %lu, expected: %lu)\n", + (unsigned long) res, (unsigned long) AH->lo_buf_used); } else { unsigned char *str; - size_t len; + size_t len; str = PQescapeBytea((const unsigned char *) AH->lo_buf, AH->lo_buf_used, &len); @@ -1017,7 +1013,7 @@ ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH) if (AH->writingBlob) { - size_t remaining = size * nmemb; + size_t remaining = size * nmemb; while (AH->lo_buf_used + remaining > AH->lo_buf_size) { @@ -1162,8 +1158,8 @@ warn_or_die_horribly(ArchiveHandle *AH, { write_msg(modulename, "Error from TOC entry %d; %u %u %s %s %s\n", AH->currentTE->dumpId, - AH->currentTE->catalogId.tableoid, AH->currentTE->catalogId.oid, - AH->currentTE->desc, AH->currentTE->tag, AH->currentTE->owner); + AH->currentTE->catalogId.tableoid, AH->currentTE->catalogId.oid, + AH->currentTE->desc, AH->currentTE->tag, AH->currentTE->owner); } AH->lastErrorStage = AH->stage; AH->lastErrorTE = AH->currentTE; @@ -1277,11 +1273,11 @@ ReadOffset(ArchiveHandle *AH, off_t *o) } /* - * Read the flag indicating the state of the data pointer. Check if - * valid and die if not. + * Read the flag indicating the state of the data pointer. Check if valid + * and die if not. * - * This used to be handled by a negative or zero pointer, now we use an - * extra byte specifically for the state. + * This used to be handled by a negative or zero pointer, now we use an extra + * byte specifically for the state. */ offsetFlg = (*AH->ReadBytePtr) (AH) & 0xFF; @@ -1320,11 +1316,11 @@ WriteInt(ArchiveHandle *AH, int i) int b; /* - * This is a bit yucky, but I don't want to make the binary format - * very dependent on representation, and not knowing much about it, I - * write out a sign byte. If you change this, don't forget to change - * the file version #, and modify readInt to read the new format AS - * WELL AS the old formats. + * This is a bit yucky, but I don't want to make the binary format very + * dependent on representation, and not knowing much about it, I write out + * a sign byte. If you change this, don't forget to change the file + * version #, and modify readInt to read the new format AS WELL AS the old + * formats. */ /* SIGN byte */ @@ -1513,8 +1509,8 @@ _discoverArchiveFormat(ArchiveHandle *AH) if (fseeko(fh, 0, SEEK_SET) != 0) { /* - * NOTE: Formats that use the lookahead buffer can unset this in - * their Init routine. + * NOTE: Formats that use the lookahead buffer can unset this in their + * Init routine. */ AH->readHeader = 1; } @@ -1570,15 +1566,15 @@ _allocAH(const char *FileSpec, const ArchiveFormat fmt, /* * Not used; maybe later.... * - * AH->workDir = strdup(FileSpec); for(i=strlen(FileSpec) ; i > 0 ; - * i--) if (AH->workDir[i-1] == '/') + * AH->workDir = strdup(FileSpec); for(i=strlen(FileSpec) ; i > 0 ; i--) + * if (AH->workDir[i-1] == '/') */ } else AH->fSpec = NULL; - AH->currUser = strdup(""); /* So it's valid, but we can free() it - * later if necessary */ + AH->currUser = strdup(""); /* So it's valid, but we can free() it later + * if necessary */ AH->currSchema = strdup(""); /* ditto */ AH->currWithOids = -1; /* force SET */ @@ -1601,8 +1597,8 @@ _allocAH(const char *FileSpec, const ArchiveFormat fmt, /* * On Windows, we need to use binary mode to read/write non-text archive - * formats. Force stdin/stdout into binary mode if that is what - * we are using. + * formats. Force stdin/stdout into binary mode if that is what we are + * using. */ #ifdef WIN32 if (fmt != archNull && @@ -1683,8 +1679,7 @@ WriteDataChunks(ArchiveHandle *AH) (*startPtr) (AH, te); /* - * printf("Dumper arg for %d is %x\n", te->id, - * te->dataDumperArg); + * printf("Dumper arg for %d is %x\n", te->id, te->dataDumperArg); */ /* @@ -1771,7 +1766,7 @@ ReadToc(ArchiveHandle *AH) /* Sanity check */ if (te->dumpId <= 0) die_horribly(AH, modulename, - "entry ID %d out of range -- perhaps a corrupt TOC\n", + "entry ID %d out of range -- perhaps a corrupt TOC\n", te->dumpId); te->hadDumper = ReadInt(AH); @@ -1890,7 +1885,7 @@ _tocEntryRequired(TocEntry *te, RestoreOptions *ropt, bool include_acls) /* If no namespace is specified, it means all. */ if (!te->namespace) return 0; - if(strcmp(ropt->schemaNames, te->namespace) != 0) + if (strcmp(ropt->schemaNames, te->namespace) != 0) return 0; } if ((strcmp(te->desc, "TABLE") == 0) || (strcmp(te->desc, "TABLE DATA") == 0)) @@ -1926,14 +1921,12 @@ _tocEntryRequired(TocEntry *te, RestoreOptions *ropt, bool include_acls) } /* - * Check if we had a dataDumper. Indicates if the entry is schema or - * data + * Check if we had a dataDumper. Indicates if the entry is schema or data */ if (!te->hadDumper) { /* - * Special Case: If 'SEQUENCE SET' then it is considered a data - * entry + * Special Case: If 'SEQUENCE SET' then it is considered a data entry */ if (strcmp(te->desc, "SEQUENCE SET") == 0) res = res & REQ_DATA; @@ -1942,8 +1935,8 @@ _tocEntryRequired(TocEntry *te, RestoreOptions *ropt, bool include_acls) } /* - * Special case: type with tag; this is obsolete - * and we always ignore it. + * Special case: type with tag; this is obsolete and we + * always ignore it. */ if ((strcmp(te->desc, "") == 0) && (strcmp(te->tag, "Max OID") == 0)) return 0; @@ -2095,8 +2088,8 @@ _reconnectToDB(ArchiveHandle *AH, const char *dbname) } /* - * NOTE: currUser keeps track of what the imaginary session user in - * our script is. It's now effectively reset to the original userID. + * NOTE: currUser keeps track of what the imaginary session user in our + * script is. It's now effectively reset to the original userID. */ if (AH->currUser) free(AH->currUser); @@ -2130,8 +2123,8 @@ _becomeUser(ArchiveHandle *AH, const char *user) _doSetSessionAuth(AH, user); /* - * NOTE: currUser keeps track of what the imaginary session user in - * our script is + * NOTE: currUser keeps track of what the imaginary session user in our + * script is */ if (AH->currUser) free(AH->currUser); @@ -2195,8 +2188,8 @@ _selectOutputSchema(ArchiveHandle *AH, const char *schemaName) if (!res || PQresultStatus(res) != PGRES_COMMAND_OK) warn_or_die_horribly(AH, modulename, - "could not set search_path to \"%s\": %s", - schemaName, PQerrorMessage(AH->connection)); + "could not set search_path to \"%s\": %s", + schemaName, PQerrorMessage(AH->connection)); PQclear(res); } @@ -2218,7 +2211,8 @@ static void _selectTablespace(ArchiveHandle *AH, const char *tablespace) { PQExpBuffer qry; - const char *want, *have; + const char *want, + *have; have = AH->currTablespace; want = tablespace; @@ -2250,7 +2244,7 @@ _selectTablespace(ArchiveHandle *AH, const char *tablespace) res = PQexec(AH->connection, qry->data); if (!res || PQresultStatus(res) != PGRES_COMMAND_OK) - warn_or_die_horribly(AH, modulename, + warn_or_die_horribly(AH, modulename, "could not set default_tablespace to %s: %s", fmtId(want), PQerrorMessage(AH->connection)); @@ -2292,17 +2286,17 @@ _getObjectDescription(PQExpBuffer buf, TocEntry *te, ArchiveHandle *AH) strcmp(type, "TYPE") == 0) { appendPQExpBuffer(buf, "%s ", type); - if (te->namespace && te->namespace[0]) /* is null pre-7.3 */ + if (te->namespace && te->namespace[0]) /* is null pre-7.3 */ appendPQExpBuffer(buf, "%s.", fmtId(te->namespace)); + /* - * Pre-7.3 pg_dump would sometimes (not always) put - * a fmtId'd name into te->tag for an index. - * This check is heuristic, so make its scope as - * narrow as possible. + * Pre-7.3 pg_dump would sometimes (not always) put a fmtId'd name + * into te->tag for an index. This check is heuristic, so make its + * scope as narrow as possible. */ if (AH->version < K_VERS_1_7 && te->tag[0] == '"' && - te->tag[strlen(te->tag)-1] == '"' && + te->tag[strlen(te->tag) - 1] == '"' && strcmp(type, "INDEX") == 0) appendPQExpBuffer(buf, "%s", te->tag); else @@ -2319,8 +2313,8 @@ _getObjectDescription(PQExpBuffer buf, TocEntry *te, ArchiveHandle *AH) } /* - * These object types require additional decoration. Fortunately, - * the information needed is exactly what's in the DROP command. + * These object types require additional decoration. Fortunately, the + * information needed is exactly what's in the DROP command. */ if (strcmp(type, "AGGREGATE") == 0 || strcmp(type, "FUNCTION") == 0 || @@ -2366,8 +2360,8 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat /* * Avoid dumping the public schema, as it will already be created ... - * unless we are using --clean mode, in which case it's been deleted - * and we'd better recreate it. + * unless we are using --clean mode, in which case it's been deleted and + * we'd better recreate it. */ if (!ropt->dropSchema && strcmp(te->desc, "SCHEMA") == 0 && strcmp(te->tag, "public") == 0) @@ -2411,11 +2405,11 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat pfx, te->tag, te->desc, te->namespace ? te->namespace : "-", te->owner); - if (te->tablespace) + if (te->tablespace) ahprintf(AH, "; Tablespace: %s", te->tablespace); ahprintf(AH, "\n"); - if (AH->PrintExtraTocPtr != NULL) + if (AH->PrintExtraTocPtr !=NULL) (*AH->PrintExtraTocPtr) (AH, te); ahprintf(AH, "--\n\n"); } @@ -2423,10 +2417,9 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat /* * Actually print the definition. * - * Really crude hack for suppressing AUTHORIZATION clause that old - * pg_dump versions put into CREATE SCHEMA. We have to do this when - * --no-owner mode is selected. This is ugly, but I see - * no other good way ... + * Really crude hack for suppressing AUTHORIZATION clause that old pg_dump + * versions put into CREATE SCHEMA. We have to do this when --no-owner + * mode is selected. This is ugly, but I see no other good way ... */ if (ropt->noOwner && strcmp(te->desc, "SCHEMA") == 0) { @@ -2489,8 +2482,7 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat /* * If it's an ACL entry, it might contain SET SESSION AUTHORIZATION - * commands, so we can no longer assume we know the current auth - * setting. + * commands, so we can no longer assume we know the current auth setting. */ if (strncmp(te->desc, "ACL", 3) == 0) { @@ -2643,8 +2635,8 @@ checkSeek(FILE *fp) else if (sizeof(off_t) > sizeof(long)) /* - * At this point, off_t is too large for long, so we return based - * on whether an off_t version of fseek is available. + * At this point, off_t is too large for long, so we return based on + * whether an off_t version of fseek is available. */ #ifdef HAVE_FSEEKO return true; diff --git a/src/bin/pg_dump/pg_backup_archiver.h b/src/bin/pg_dump/pg_backup_archiver.h index e7a05283d7..ce42974c6a 100644 --- a/src/bin/pg_dump/pg_backup_archiver.h +++ b/src/bin/pg_dump/pg_backup_archiver.h @@ -17,7 +17,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.67 2005/09/11 04:10:25 tgl Exp $ + * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.68 2005/10/15 02:49:38 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -179,10 +179,10 @@ typedef struct _archiveHandle char vrev; int version; /* Conveniently formatted version */ - char *archiveRemoteVersion; /* When reading an archive, - * the version of the dumped DB */ - char *archiveDumpVersion; /* When reading an archive, - * the version of the dumper */ + char *archiveRemoteVersion; /* When reading an archive, the + * version of the dumped DB */ + char *archiveDumpVersion; /* When reading an archive, the + * version of the dumper */ int debugLevel; /* Used for logging (currently only by * --verbose) */ @@ -200,14 +200,12 @@ typedef struct _archiveHandle * Fields used when discovering header. A format can always get the * previous read bytes from here... */ - int readHeader; /* Used if file header has been read - * already */ - char *lookahead; /* Buffer used when reading header to - * discover format */ + int readHeader; /* Used if file header has been read already */ + char *lookahead; /* Buffer used when reading header to discover + * format */ size_t lookaheadSize; /* Size of allocated buffer */ size_t lookaheadLen; /* Length of data in lookahead */ - off_t lookaheadPos; /* Current read position in lookahead - * buffer */ + off_t lookaheadPos; /* Current read position in lookahead buffer */ ArchiveEntryPtr ArchiveEntryPtr; /* Called for each metadata object */ StartDataPtr StartDataPtr; /* Called when table data is about to be @@ -221,8 +219,8 @@ typedef struct _archiveHandle ReadBufPtr ReadBufPtr; /* Read a buffer of input from the archive */ ClosePtr ClosePtr; /* Close the archive */ WriteExtraTocPtr WriteExtraTocPtr; /* Write extra TOC entry data - * associated with the current - * archive format */ + * associated with the current archive + * format */ ReadExtraTocPtr ReadExtraTocPtr; /* Read extr info associated with * archie format */ PrintExtraTocPtr PrintExtraTocPtr; /* Extra TOC info for format */ @@ -239,8 +237,8 @@ typedef struct _archiveHandle char *archdbname; /* DB name *read* from archive */ bool requirePassword; PGconn *connection; - int connectToDB; /* Flag to indicate if direct DB - * connection is required */ + int connectToDB; /* Flag to indicate if direct DB connection is + * required */ int pgCopyIn; /* Currently in libpq 'COPY IN' mode. */ PQExpBuffer pgCopyBuf; /* Left-over data from incomplete lines in * COPY IN */ @@ -263,13 +261,13 @@ typedef struct _archiveHandle ArchiveMode mode; /* File mode - r or w */ void *formatData; /* Header data specific to file format */ - RestoreOptions *ropt; /* Used to check restore options in - * ahwrite etc */ + RestoreOptions *ropt; /* Used to check restore options in ahwrite + * etc */ /* these vars track state to avoid sending redundant SET commands */ char *currUser; /* current username */ char *currSchema; /* current schema */ - char *currTablespace; /* current tablespace */ + char *currTablespace; /* current tablespace */ bool currWithOids; /* current default_with_oids setting */ void *lo_buf; @@ -289,8 +287,8 @@ typedef struct _tocEntry struct _tocEntry *next; CatalogId catalogId; DumpId dumpId; - bool hadDumper; /* Archiver was passed a dumper routine - * (used in restore) */ + bool hadDumper; /* Archiver was passed a dumper routine (used + * in restore) */ char *tag; /* index tag */ char *namespace; /* null or empty string if not in a schema */ char *tablespace; /* null if not in a tablespace; empty string diff --git a/src/bin/pg_dump/pg_backup_custom.c b/src/bin/pg_dump/pg_backup_custom.c index 115375c343..3edbb8f5c0 100644 --- a/src/bin/pg_dump/pg_backup_custom.c +++ b/src/bin/pg_dump/pg_backup_custom.c @@ -19,7 +19,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.32 2005/09/24 17:53:27 tgl Exp $ + * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.33 2005/10/15 02:49:38 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -151,10 +151,10 @@ InitArchiveFmt_Custom(ArchiveHandle *AH) /* * zlibOutSize is the buffer size we tell zlib it can output to. We - * actually allocate one extra byte because some routines want to - * append a trailing zero byte to the zlib output. The input buffer - * is expansible and is always of size ctx->inSize; zlibInSize is just - * the initial default size for it. + * actually allocate one extra byte because some routines want to append a + * trailing zero byte to the zlib output. The input buffer is expansible + * and is always of size ctx->inSize; zlibInSize is just the initial + * default size for it. */ ctx->zlibOut = (char *) malloc(zlibOutSize + 1); ctx->zlibIn = (char *) malloc(zlibInSize); @@ -258,8 +258,8 @@ _ReadExtraToc(ArchiveHandle *AH, TocEntry *te) ctx->dataState = ReadOffset(AH, &(ctx->dataPos)); /* - * Prior to V1.7 (pg7.3), we dumped the data size as an int now we - * don't dump it at all. + * Prior to V1.7 (pg7.3), we dumped the data size as an int now we don't + * dump it at all. */ if (AH->version < K_VERS_1_7) junk = ReadInt(AH); @@ -439,7 +439,7 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt) if ((TocIDRequired(AH, id, ropt) & REQ_DATA) != 0) die_horribly(AH, modulename, "Dumping a specific TOC data block out of order is not supported" - " without ID on this input stream (fseek required)\n"); + " without ID on this input stream (fseek required)\n"); switch (blkType) { @@ -541,7 +541,7 @@ _PrintData(ArchiveHandle *AH) cnt = fread(in, 1, blkLen, AH->FH); if (cnt != blkLen) die_horribly(AH, modulename, - "could not read data block -- expected %lu, got %lu\n", + "could not read data block -- expected %lu, got %lu\n", (unsigned long) blkLen, (unsigned long) cnt); ctx->filePos += blkLen; @@ -664,7 +664,7 @@ _skipData(ArchiveHandle *AH) cnt = fread(in, 1, blkLen, AH->FH); if (cnt != blkLen) die_horribly(AH, modulename, - "could not read data block -- expected %lu, got %lu\n", + "could not read data block -- expected %lu, got %lu\n", (unsigned long) blkLen, (unsigned long) cnt); ctx->filePos += blkLen; @@ -794,10 +794,9 @@ _CloseArchive(ArchiveHandle *AH) WriteDataChunks(AH); /* - * This is not an essential operation - it is really only needed - * if we expect to be doing seeks to read the data back - it may - * be ok to just use the existing self-consistent block - * formatting. + * This is not an essential operation - it is really only needed if we + * expect to be doing seeks to read the data back - it may be ok to + * just use the existing self-consistent block formatting. */ if (ctx->hasSeek) { @@ -882,7 +881,6 @@ _StartDataCompressor(ArchiveHandle *AH, TocEntry *te) if (deflateInit(zp, AH->compression) != Z_OK) die_horribly(AH, modulename, "could not initialize compression library: %s\n", zp->msg); } - #else AH->compression = 0; @@ -920,15 +918,14 @@ _DoDeflate(ArchiveHandle *AH, lclContext *ctx, int flush) ) { /* - * Extra paranoia: avoid zero-length chunks since a zero - * length chunk is the EOF marker. This should never happen - * but... + * Extra paranoia: avoid zero-length chunks since a zero length + * chunk is the EOF marker. This should never happen but... */ if (zp->avail_out < zlibOutSize) { /* - * printf("Wrote %lu byte deflated chunk\n", (unsigned - * long) (zlibOutSize - zp->avail_out)); + * printf("Wrote %lu byte deflated chunk\n", (unsigned long) + * (zlibOutSize - zp->avail_out)); */ WriteInt(AH, zlibOutSize - zp->avail_out); if (fwrite(out, 1, zlibOutSize - zp->avail_out, AH->FH) != (zlibOutSize - zp->avail_out)) diff --git a/src/bin/pg_dump/pg_backup_db.c b/src/bin/pg_dump/pg_backup_db.c index 2065f59a4d..a3f23b4cfd 100644 --- a/src/bin/pg_dump/pg_backup_db.c +++ b/src/bin/pg_dump/pg_backup_db.c @@ -5,7 +5,7 @@ * Implements the basic DB functions used by the archiver. * * IDENTIFICATION - * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.65 2005/09/11 04:10:25 tgl Exp $ + * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.66 2005/10/15 02:49:38 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -170,7 +170,7 @@ _connectDB(ArchiveHandle *AH, const char *reqdb, const char *requser) noPwd = (strcmp(PQerrorMessage(newConn), PQnoPasswordSupplied) == 0); badPwd = (strncmp(PQerrorMessage(newConn), - "Password authentication failed for user", 39) == 0); + "Password authentication failed for user", 39) == 0); if (noPwd || badPwd) { @@ -236,8 +236,8 @@ ConnectDatabase(Archive *AHX, AH->requirePassword = false; /* - * Start the connection. Loop until we have a password if requested - * by backend. + * Start the connection. Loop until we have a password if requested by + * backend. */ do { @@ -249,7 +249,7 @@ ConnectDatabase(Archive *AHX, die_horribly(AH, modulename, "failed to connect to database\n"); if (PQstatus(AH->connection) == CONNECTION_BAD && - strcmp(PQerrorMessage(AH->connection), PQnoPasswordSupplied) == 0 && + strcmp(PQerrorMessage(AH->connection), PQnoPasswordSupplied) == 0 && !feof(stdin)) { PQfinish(AH->connection); @@ -349,8 +349,8 @@ _sendCopyLine(ArchiveHandle *AH, char *qry, char *eos) } /* - * fprintf(stderr, "Found cr at %d, prev char was %c, next was - * %c\n", loc, qry[loc-1], qry[loc+1]); + * fprintf(stderr, "Found cr at %d, prev char was %c, next was %c\n", + * loc, qry[loc-1], qry[loc+1]); */ /* Count the number of preceding slashes */ @@ -361,8 +361,8 @@ _sendCopyLine(ArchiveHandle *AH, char *qry, char *eos) sPos = loc - sPos; /* - * If an odd number of preceding slashes, then \n was escaped so - * set the next search pos, and loop (if any left). + * If an odd number of preceding slashes, then \n was escaped so set + * the next search pos, and loop (if any left). */ if ((sPos & 1) == 1) { @@ -418,14 +418,14 @@ _sendSQLLine(ArchiveHandle *AH, char *qry, char *eos) { /* * The following is a mini state machine to assess the end of an SQL - * statement. It really only needs to parse good SQL, or at least - * that's the theory... End-of-statement is assumed to be an unquoted, + * statement. It really only needs to parse good SQL, or at least that's + * the theory... End-of-statement is assumed to be an unquoted, * un-commented semi-colon that's not within any parentheses. * * Note: the input can be split into bufferloads at arbitrary boundaries. * Therefore all state must be kept in AH->sqlparse, not in local - * variables of this routine. We assume that AH->sqlparse was - * filled with zeroes when created. + * variables of this routine. We assume that AH->sqlparse was filled with + * zeroes when created. */ for (; qry < eos; qry++) { @@ -435,18 +435,18 @@ _sendSQLLine(ArchiveHandle *AH, char *qry, char *eos) if (*qry == ';' && AH->sqlparse.braceDepth == 0) { /* - * We've found the end of a statement. Send it and - * reset the buffer. + * We've found the end of a statement. Send it and reset + * the buffer. */ - appendPQExpBufferChar(AH->sqlBuf, ';'); /* inessential */ + appendPQExpBufferChar(AH->sqlBuf, ';'); /* inessential */ ExecuteSqlCommand(AH, AH->sqlBuf, "could not execute query"); resetPQExpBuffer(AH->sqlBuf); AH->sqlparse.lastChar = '\0'; /* - * Remove any following newlines - so that - * embedded COPY commands don't get a starting newline. + * Remove any following newlines - so that embedded COPY + * commands don't get a starting newline. */ qry++; while (qry < eos && *qry == '\n') @@ -467,11 +467,11 @@ _sendSQLLine(ArchiveHandle *AH, char *qry, char *eos) { AH->sqlparse.state = SQL_IN_DOUBLE_QUOTE; } + /* * Look for dollar-quotes. We make the assumption that - * $-quotes will not have an ident character just - * before them in pg_dump output. XXX is this - * good enough? + * $-quotes will not have an ident character just before them + * in pg_dump output. XXX is this good enough? */ else if (*qry == '$' && !_isIdentChar(AH->sqlparse.lastChar)) { @@ -499,6 +499,7 @@ _sendSQLLine(ArchiveHandle *AH, char *qry, char *eos) break; case SQL_IN_EXT_COMMENT: + /* * This isn't fully correct, because we don't account for * nested slash-stars, but pg_dump never emits such. @@ -518,13 +519,14 @@ _sendSQLLine(ArchiveHandle *AH, char *qry, char *eos) break; case SQL_IN_E_QUOTE: + /* * Eventually we will need to handle '' specially, because * after E'...''... we should still be in E_QUOTE state. * - * XXX problem: how do we tell whether the dump was made - * by a version that thinks backslashes aren't special - * in non-E literals?? + * XXX problem: how do we tell whether the dump was made by a + * version that thinks backslashes aren't special in non-E + * literals?? */ if (*qry == '\'' && !AH->sqlparse.backSlash) AH->sqlparse.state = SQL_SCAN; @@ -556,12 +558,12 @@ _sendSQLLine(ArchiveHandle *AH, char *qry, char *eos) { /* * Ooops, we're not really in a dollar-tag. Valid tag - * chars do not include the various chars we look for - * in this state machine, so it's safe to just jump - * from this state back to SCAN. We have to back up - * the qry pointer so that the current character gets - * rescanned in SCAN state; and then "continue" so that - * the bottom-of-loop actions aren't done yet. + * chars do not include the various chars we look for in + * this state machine, so it's safe to just jump from this + * state back to SCAN. We have to back up the qry pointer + * so that the current character gets rescanned in SCAN + * state; and then "continue" so that the bottom-of-loop + * actions aren't done yet. */ AH->sqlparse.state = SQL_SCAN; qry--; @@ -570,12 +572,13 @@ _sendSQLLine(ArchiveHandle *AH, char *qry, char *eos) break; case SQL_IN_DOLLAR_QUOTE: + /* * If we are at a $, see whether what precedes it matches - * tagBuf. (Remember that the trailing $ of the tag was - * not added to tagBuf.) However, don't compare until we - * have enough data to be a possible match --- this is - * needed to avoid false match on '$a$a$...' + * tagBuf. (Remember that the trailing $ of the tag was not + * added to tagBuf.) However, don't compare until we have + * enough data to be a possible match --- this is needed to + * avoid false match on '$a$a$...' */ if (*qry == '$' && AH->sqlBuf->len >= AH->sqlparse.minTagEndPos && @@ -605,8 +608,8 @@ ExecuteSqlCommandBuf(ArchiveHandle *AH, void *qryv, size_t bufLen) char *eos = qry + bufLen; /* - * fprintf(stderr, "\n\n*****\n - * Buffer:\n\n%s\n*******************\n\n", qry); + * fprintf(stderr, "\n\n*****\n Buffer:\n\n%s\n*******************\n\n", + * qry); */ /* Could switch between command and COPY IN mode at each line */ @@ -653,8 +656,7 @@ _isIdentChar(unsigned char c) || (c >= '0' && c <= '9') || (c == '_') || (c == '$') - || (c >= (unsigned char) '\200') /* no need to check <= - * \377 */ + || (c >= (unsigned char) '\200') /* no need to check <= \377 */ ) return true; else @@ -668,8 +670,7 @@ _isDQChar(unsigned char c, bool atStart) || (c >= 'A' && c <= 'Z') || (c == '_') || (!atStart && c >= '0' && c <= '9') - || (c >= (unsigned char) '\200') /* no need to check <= - * \377 */ + || (c >= (unsigned char) '\200') /* no need to check <= \377 */ ) return true; else diff --git a/src/bin/pg_dump/pg_backup_files.c b/src/bin/pg_dump/pg_backup_files.c index 2f255c0c29..b36a1c8600 100644 --- a/src/bin/pg_dump/pg_backup_files.c +++ b/src/bin/pg_dump/pg_backup_files.c @@ -20,7 +20,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.26 2005/06/21 20:45:44 tgl Exp $ + * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.27 2005/10/15 02:49:38 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -469,7 +469,7 @@ _StartBlobs(ArchiveHandle *AH, TocEntry *te) if (ctx->blobToc == NULL) die_horribly(AH, modulename, - "could not open large object TOC for output: %s\n", strerror(errno)); + "could not open large object TOC for output: %s\n", strerror(errno)); } /* diff --git a/src/bin/pg_dump/pg_backup_null.c b/src/bin/pg_dump/pg_backup_null.c index 7e0b6ffe11..76eea19307 100644 --- a/src/bin/pg_dump/pg_backup_null.c +++ b/src/bin/pg_dump/pg_backup_null.c @@ -17,7 +17,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_null.c,v 1.15 2005/06/21 20:45:44 tgl Exp $ + * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_null.c,v 1.16 2005/10/15 02:49:38 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -100,7 +100,7 @@ _WriteBlobData(ArchiveHandle *AH, const void *data, size_t dLen) if (dLen > 0) { unsigned char *str; - size_t len; + size_t len; str = PQescapeBytea((const unsigned char *) data, dLen, &len); if (!str) @@ -161,6 +161,7 @@ static void _EndBlob(ArchiveHandle *AH, TocEntry *te, Oid oid) { AH->WriteDataPtr = _WriteData; + ahprintf(AH, "SELECT lo_close(0);\n\n"); } diff --git a/src/bin/pg_dump/pg_backup_tar.c b/src/bin/pg_dump/pg_backup_tar.c index 5b38d4615b..cbd9f66865 100644 --- a/src/bin/pg_dump/pg_backup_tar.c +++ b/src/bin/pg_dump/pg_backup_tar.c @@ -16,7 +16,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.48 2005/06/22 02:00:47 neilc Exp $ + * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.49 2005/10/15 02:49:38 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -54,7 +54,6 @@ static void _EndBlobs(ArchiveHandle *AH, TocEntry *te); #ifdef HAVE_LIBZ /* typedef gzFile ThingFile; */ typedef FILE ThingFile; - #else typedef FILE ThingFile; #endif @@ -180,13 +179,13 @@ InitArchiveFmt_Tar(ArchiveHandle *AH) if (ctx->tarFH == NULL) die_horribly(NULL, modulename, - "could not open TOC file for output: %s\n", strerror(errno)); + "could not open TOC file for output: %s\n", strerror(errno)); ctx->tarFHpos = 0; /* - * Make unbuffered since we will dup() it, and the buffers screw - * each other + * Make unbuffered since we will dup() it, and the buffers screw each + * other */ /* setvbuf(ctx->tarFH, NULL, _IONBF, 0); */ @@ -200,9 +199,9 @@ InitArchiveFmt_Tar(ArchiveHandle *AH) AH->compression = 0; /* - * We don't support compression because reading the files back is - * not possible since gzdopen uses buffered IO which totally - * screws file positioning. + * We don't support compression because reading the files back is not + * possible since gzdopen uses buffered IO which totally screws file + * positioning. */ if (AH->compression != 0) die_horribly(NULL, modulename, "compression not supported by tar output format\n"); @@ -220,8 +219,8 @@ InitArchiveFmt_Tar(ArchiveHandle *AH) die_horribly(NULL, modulename, "could not open TOC file for input: %s\n", strerror(errno)); /* - * Make unbuffered since we will dup() it, and the buffers screw - * each other + * Make unbuffered since we will dup() it, and the buffers screw each + * other */ /* setvbuf(ctx->tarFH, NULL, _IONBF, 0); */ @@ -336,8 +335,8 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode) tm = _tarPositionTo(AH, filename); if (!tm) /* Not found */ { - if (filename) /* Couldn't find the requested file. - * Future: DO SEEK(0) and retry. */ + if (filename) /* Couldn't find the requested file. Future: + * DO SEEK(0) and retry. */ die_horribly(AH, modulename, "could not find file %s in archive\n", filename); else /* Any file OK, non left, so return NULL */ @@ -351,7 +350,6 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode) else die_horribly(AH, modulename, "compression support is disabled in this format\n"); /* tm->zFH = gzdopen(dup(fileno(ctx->tarFH)), "rb"); */ - #else tm->nFH = ctx->tarFH; #endif @@ -378,7 +376,6 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode) } else tm->nFH = tm->tmpFH; - #else tm->nFH = tm->tmpFH; @@ -546,7 +543,7 @@ tarWrite(const void *buf, size_t len, TAR_MEMBER *th) if (res != len) die_horribly(th->AH, modulename, - "could not write to tar member (wrote %lu, attempted %lu)\n", + "could not write to tar member (wrote %lu, attempted %lu)\n", (unsigned long) res, (unsigned long) len); th->pos += res; @@ -630,8 +627,8 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt) tmpCopy[i] = pg_tolower((unsigned char) tmpCopy[i]); /* - * This is very nasty; we don't know if the archive used WITH - * OIDS, so we search the string for it in a paranoid sort of way. + * This is very nasty; we don't know if the archive used WITH OIDS, so + * we search the string for it in a paranoid sort of way. */ if (strncmp(tmpCopy, "copy ", 5) != 0) die_horribly(AH, modulename, @@ -784,16 +781,16 @@ _CloseArchive(ArchiveHandle *AH) WriteDataChunks(AH); /* - * Now this format wants to append a script which does a full - * restore if the files have been extracted. + * Now this format wants to append a script which does a full restore + * if the files have been extracted. */ th = tarOpen(AH, "restore.sql", 'w'); tarPrintf(AH, th, "create temporary table pgdump_restore_path(p text);\n"); tarPrintf(AH, th, "--\n" "-- NOTE:\n" "--\n" - "-- File paths need to be edited. Search for $$PATH$$ and\n" - "-- replace it with the path to the directory containing\n" + "-- File paths need to be edited. Search for $$PATH$$ and\n" + "-- replace it with the path to the directory containing\n" "-- the extracted data files.\n" "--\n" "-- Edit the following to match the path where the\n" @@ -826,7 +823,7 @@ _CloseArchive(ArchiveHandle *AH) { if (fputc(0, ctx->tarFH) == EOF) die_horribly(AH, modulename, - "could not write null block at end of tar archive\n"); + "could not write null block at end of tar archive\n"); } } @@ -942,13 +939,13 @@ tarPrintf(ArchiveHandle *AH, TAR_MEMBER *th, const char *fmt,...) int cnt = -1; /* - * This is paranoid: deal with the possibility that vsnprintf is - * willing to ignore trailing null + * This is paranoid: deal with the possibility that vsnprintf is willing + * to ignore trailing null */ /* - * or returns > 0 even if string does not fit. It may be the case that - * it returns cnt = bufsize + * or returns > 0 even if string does not fit. It may be the case that it + * returns cnt = bufsize */ while (cnt < 0 || cnt >= (bSize - 1)) { @@ -1019,9 +1016,10 @@ _tarAddFile(ArchiveHandle *AH, TAR_MEMBER *th) */ fseeko(tmp, 0, SEEK_END); th->fileLen = ftello(tmp); + /* - * Some compilers with throw a warning knowing this test can never be - * true because off_t can't exceed the compared maximum. + * Some compilers with throw a warning knowing this test can never be true + * because off_t can't exceed the compared maximum. */ if (th->fileLen > MAX_TAR_MEMBER_FILELEN) die_horribly(AH, modulename, "archive member too large for tar format\n"); @@ -1108,7 +1106,11 @@ _tarPositionTo(ArchiveHandle *AH, const char *filename) if (filename) die_horribly(AH, modulename, "could not find header for file %s in tar archive\n", filename); else - /* We're just scanning the archibe for the next file, so return null */ + + /* + * We're just scanning the archibe for the next file, so return + * null + */ { free(th); return NULL; @@ -1122,7 +1124,7 @@ _tarPositionTo(ArchiveHandle *AH, const char *filename) id = atoi(th->targetFile); if ((TocIDRequired(AH, id, AH->ropt) & REQ_DATA) != 0) die_horribly(AH, modulename, "dumping data out of order is not supported in this archive format: " - "%s is required, but comes before %s in the archive file.\n", + "%s is required, but comes before %s in the archive file.\n", th->targetFile, filename); /* Header doesn't match, so read to next header */ @@ -1168,7 +1170,7 @@ _tarGetHeader(ArchiveHandle *AH, TAR_MEMBER *th) snprintf(buf1, sizeof(buf1), INT64_FORMAT, (int64) ftello(ctx->tarFH)); snprintf(buf2, sizeof(buf2), INT64_FORMAT, (int64) ftello(ctx->tarFHpos)); die_horribly(AH, modulename, - "mismatch in actual vs. predicted file position (%s vs. %s)\n", + "mismatch in actual vs. predicted file position (%s vs. %s)\n", buf1, buf2); } #endif @@ -1191,8 +1193,8 @@ _tarGetHeader(ArchiveHandle *AH, TAR_MEMBER *th) sscanf(&h[148], "%8o", &sum); /* - * If the checksum failed, see if it is a null block. If so, - * silently continue to the next block. + * If the checksum failed, see if it is a null block. If so, silently + * continue to the next block. */ if (chk == sum) gotBlock = true; @@ -1301,12 +1303,12 @@ _tarWriteHeader(TAR_MEMBER *th) #if 0 /* User 32 */ - sprintf(&h[265], "%.31s", ""); /* How do I get username reliably? - * Do I need to? */ + sprintf(&h[265], "%.31s", ""); /* How do I get username reliably? Do + * I need to? */ /* Group 32 */ - sprintf(&h[297], "%.31s", ""); /* How do I get group reliably? Do - * I need to? */ + sprintf(&h[297], "%.31s", ""); /* How do I get group reliably? Do I + * need to? */ /* Maj Dev 8 */ sprintf(&h[329], "%6o ", 0); diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index c08999642f..895d156317 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -12,7 +12,7 @@ * by PostgreSQL * * IDENTIFICATION - * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.421 2005/09/21 19:58:02 tgl Exp $ + * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.422 2005/10/15 02:49:38 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -239,8 +239,8 @@ main(int argc, char **argv) {"version", no_argument, NULL, 'V'}, /* - * the following options don't have an equivalent short option - * letter, but are available as '-X long-name' + * the following options don't have an equivalent short option letter, + * but are available as '-X long-name' */ {"disable-dollar-quoting", no_argument, &disable_dollar_quoting, 1}, {"disable-triggers", no_argument, &disable_triggers, 1}, @@ -293,8 +293,7 @@ main(int argc, char **argv) /* this is now default, so just ignore the switch */ break; - case 'c': /* clean (i.e., drop) schema prior to - * create */ + case 'c': /* clean (i.e., drop) schema prior to create */ outputClean = 1; break; @@ -357,8 +356,7 @@ main(int argc, char **argv) outputBlobs = false; break; - case 'S': /* Username for superuser in plain text - * output */ + case 'S': /* Username for superuser in plain text output */ outputSuperuser = strdup(optarg); break; @@ -388,11 +386,11 @@ main(int argc, char **argv) break; /* - * Option letters were getting scarce, so I invented this - * new scheme: '-X feature' turns on some feature. Compare - * to the -f option in GCC. You should also add an - * equivalent GNU-style option --feature. Features that - * require arguments should use '-X feature=foo'. + * Option letters were getting scarce, so I invented this new + * scheme: '-X feature' turns on some feature. Compare to the + * -f option in GCC. You should also add an equivalent + * GNU-style option --feature. Features that require + * arguments should use '-X feature=foo'. */ case 'X': if (strcmp(optarg, "disable-dollar-quoting") == 0) @@ -507,8 +505,8 @@ main(int argc, char **argv) } /* - * Open the database using the Archiver, so it knows about it. Errors - * mean death. + * Open the database using the Archiver, so it knows about it. Errors mean + * death. */ g_conn = ConnectDatabase(g_fout, dbname, pghost, pgport, username, force_password, ignore_version); @@ -526,8 +524,9 @@ main(int argc, char **argv) /* Set the client encoding */ if (dumpencoding) { - char *cmd = malloc(strlen(dumpencoding) + 32); - sprintf(cmd,"SET client_encoding='%s'", dumpencoding); + char *cmd = malloc(strlen(dumpencoding) + 32); + + sprintf(cmd, "SET client_encoding='%s'", dumpencoding); do_sql_command(g_conn, cmd); free(cmd); } @@ -595,10 +594,9 @@ main(int argc, char **argv) * * In 7.3 or later, we can rely on dependency information to help us * determine a safe order, so the initial sort is mostly for cosmetic - * purposes: we sort by name to ensure that logically identical - * schemas will dump identically. Before 7.3 we don't have - * dependencies and we use OID ordering as an (unreliable) guide to - * creation order. + * purposes: we sort by name to ensure that logically identical schemas + * will dump identically. Before 7.3 we don't have dependencies and we + * use OID ordering as an (unreliable) guide to creation order. */ getDumpableObjects(&dobjs, &numObjs); @@ -610,8 +608,8 @@ main(int argc, char **argv) sortDumpableObjects(dobjs, numObjs); /* - * Create archive TOC entries for all the objects to be dumped, in a - * safe order. + * Create archive TOC entries for all the objects to be dumped, in a safe + * order. */ /* First the special encoding entry. */ @@ -646,8 +644,7 @@ main(int argc, char **argv) else ropt->compression = compressLevel; - ropt->suppressDumpWarnings = true; /* We've already shown - * them */ + ropt->suppressDumpWarnings = true; /* We've already shown them */ RestoreArchive(g_fout, ropt); } @@ -730,8 +727,8 @@ selectDumpableNamespace(NamespaceInfo *nsinfo) { /* * If a specific table is being dumped, do not dump any complete - * namespaces. If a specific namespace is being dumped, dump just - * that namespace. Otherwise, dump all non-system namespaces. + * namespaces. If a specific namespace is being dumped, dump just that + * namespace. Otherwise, dump all non-system namespaces. */ if (selectTableName != NULL) nsinfo->dump = false; @@ -758,8 +755,8 @@ selectDumpableTable(TableInfo *tbinfo) { /* * Always dump if dumping parent namespace; else, if a particular - * tablename has been specified, dump matching table name; else, do - * not dump. + * tablename has been specified, dump matching table name; else, do not + * dump. */ tbinfo->dump = false; if (tbinfo->dobj.namespace->dump) @@ -803,17 +800,17 @@ dumpTableData_copy(Archive *fout, void *dcontext) /* * Make sure we are in proper schema. We will qualify the table name - * below anyway (in case its name conflicts with a pg_catalog table); - * but this ensures reproducible results in case the table contains - * regproc, regclass, etc columns. + * below anyway (in case its name conflicts with a pg_catalog table); but + * this ensures reproducible results in case the table contains regproc, + * regclass, etc columns. */ selectSourceSchema(tbinfo->dobj.namespace->dobj.name); /* * If possible, specify the column list explicitly so that we have no - * possibility of retrieving data in the wrong column order. (The - * default column ordering of COPY will not be what we want in certain - * corner cases involving ADD COLUMN and inheritance.) + * possibility of retrieving data in the wrong column order. (The default + * column ordering of COPY will not be what we want in certain corner + * cases involving ADD COLUMN and inheritance.) */ if (g_fout->remoteVersion >= 70300) column_list = fmtCopyColumnList(tbinfo); @@ -823,15 +820,15 @@ dumpTableData_copy(Archive *fout, void *dcontext) if (oids && hasoids) { appendPQExpBuffer(q, "COPY %s %s WITH OIDS TO stdout;", - fmtQualifiedId(tbinfo->dobj.namespace->dobj.name, - classname), + fmtQualifiedId(tbinfo->dobj.namespace->dobj.name, + classname), column_list); } else { appendPQExpBuffer(q, "COPY %s %s TO stdout;", - fmtQualifiedId(tbinfo->dobj.namespace->dobj.name, - classname), + fmtQualifiedId(tbinfo->dobj.namespace->dobj.name, + classname), column_list); } res = PQexec(g_conn, q->data); @@ -868,42 +865,41 @@ dumpTableData_copy(Archive *fout, void *dcontext) /* * THROTTLE: * - * There was considerable discussion in late July, 2000 regarding - * slowing down pg_dump when backing up large tables. Users with - * both slow & fast (muti-processor) machines experienced - * performance degradation when doing a backup. + * There was considerable discussion in late July, 2000 regarding slowing + * down pg_dump when backing up large tables. Users with both slow & + * fast (muti-processor) machines experienced performance degradation + * when doing a backup. * - * Initial attempts based on sleeping for a number of ms for each ms - * of work were deemed too complex, then a simple 'sleep in each - * loop' implementation was suggested. The latter failed because - * the loop was too tight. Finally, the following was implemented: + * Initial attempts based on sleeping for a number of ms for each ms of + * work were deemed too complex, then a simple 'sleep in each loop' + * implementation was suggested. The latter failed because the loop + * was too tight. Finally, the following was implemented: * - * If throttle is non-zero, then See how long since the last sleep. - * Work out how long to sleep (based on ratio). If sleep is more - * than 100ms, then sleep reset timer EndIf EndIf + * If throttle is non-zero, then See how long since the last sleep. Work + * out how long to sleep (based on ratio). If sleep is more than + * 100ms, then sleep reset timer EndIf EndIf * - * where the throttle value was the number of ms to sleep per ms of - * work. The calculation was done in each loop. + * where the throttle value was the number of ms to sleep per ms of work. + * The calculation was done in each loop. * - * Most of the hard work is done in the backend, and this solution - * still did not work particularly well: on slow machines, the - * ratio was 50:1, and on medium paced machines, 1:1, and on fast - * multi-processor machines, it had little or no effect, for - * reasons that were unclear. + * Most of the hard work is done in the backend, and this solution still + * did not work particularly well: on slow machines, the ratio was + * 50:1, and on medium paced machines, 1:1, and on fast + * multi-processor machines, it had little or no effect, for reasons + * that were unclear. * * Further discussion ensued, and the proposal was dropped. * - * For those people who want this feature, it can be implemented - * using gettimeofday in each loop, calculating the time since - * last sleep, multiplying that by the sleep ratio, then if the - * result is more than a preset 'minimum sleep time' (say 100ms), - * call the 'select' function to sleep for a subsecond period ie. + * For those people who want this feature, it can be implemented using + * gettimeofday in each loop, calculating the time since last sleep, + * multiplying that by the sleep ratio, then if the result is more + * than a preset 'minimum sleep time' (say 100ms), call the 'select' + * function to sleep for a subsecond period ie. * * select(0, NULL, NULL, NULL, &tvi); * - * This will return after the interval specified in the structure - * tvi. Finally, call gettimeofday again to save the 'last sleep - * time'. + * This will return after the interval specified in the structure tvi. + * Finally, call gettimeofday again to save the 'last sleep time'. */ } archprintf(fout, "\\.\n\n\n"); @@ -936,9 +932,9 @@ dumpTableData_insert(Archive *fout, void *dcontext) /* * Make sure we are in proper schema. We will qualify the table name - * below anyway (in case its name conflicts with a pg_catalog table); - * but this ensures reproducible results in case the table contains - * regproc, regclass, etc columns. + * below anyway (in case its name conflicts with a pg_catalog table); but + * this ensures reproducible results in case the table contains regproc, + * regclass, etc columns. */ selectSourceSchema(tbinfo->dobj.namespace->dobj.name); @@ -946,15 +942,15 @@ dumpTableData_insert(Archive *fout, void *dcontext) { appendPQExpBuffer(q, "DECLARE _pg_dump_cursor CURSOR FOR " "SELECT * FROM ONLY %s", - fmtQualifiedId(tbinfo->dobj.namespace->dobj.name, - classname)); + fmtQualifiedId(tbinfo->dobj.namespace->dobj.name, + classname)); } else { appendPQExpBuffer(q, "DECLARE _pg_dump_cursor CURSOR FOR " "SELECT * FROM %s", - fmtQualifiedId(tbinfo->dobj.namespace->dobj.name, - classname)); + fmtQualifiedId(tbinfo->dobj.namespace->dobj.name, + classname)); } res = PQexec(g_conn, q->data); @@ -1013,16 +1009,15 @@ dumpTableData_insert(Archive *fout, void *dcontext) case NUMERICOID: { /* - * These types are printed without quotes - * unless they contain values that aren't - * accepted by the scanner unquoted (e.g., - * 'NaN'). Note that strtod() and friends - * might accept NaN, so we can't use that to - * test. + * These types are printed without quotes unless + * they contain values that aren't accepted by the + * scanner unquoted (e.g., 'NaN'). Note that + * strtod() and friends might accept NaN, so we + * can't use that to test. * - * In reality we only need to defend against - * infinity and NaN, so we need not get too - * crazy about pattern matching here. + * In reality we only need to defend against infinity + * and NaN, so we need not get too crazy about + * pattern matching here. */ const char *s = PQgetvalue(res, tuple, field); @@ -1092,7 +1087,7 @@ dumpTableData(Archive *fout, TableDataInfo *tdinfo) fmtId(tbinfo->dobj.name)); appendPQExpBuffer(copyBuf, "%s %sFROM stdin;\n", fmtCopyColumnList(tbinfo), - (tdinfo->oids && tbinfo->hasoids) ? "WITH OIDS " : ""); + (tdinfo->oids && tbinfo->hasoids) ? "WITH OIDS " : ""); copyStmt = copyBuf->data; } else @@ -1141,8 +1136,8 @@ getTableData(TableInfo *tblinfo, int numTables, bool oids) tdinfo->dobj.objType = DO_TABLE_DATA; /* - * Note: use tableoid 0 so that this object won't be mistaken - * for something that pg_depend entries apply to. + * Note: use tableoid 0 so that this object won't be mistaken for + * something that pg_depend entries apply to. */ tdinfo->dobj.catId.tableoid = 0; tdinfo->dobj.catId.oid = tblinfo[i].dobj.catId.oid; @@ -1279,7 +1274,7 @@ dumpDatabase(Archive *AH) dbDumpId, /* dump ID */ datname, /* Name */ NULL, /* Namespace */ - NULL, /* Tablespace */ + NULL, /* Tablespace */ dba, /* Owner */ false, /* with oids */ "DATABASE", /* Desc */ @@ -1508,8 +1503,8 @@ dumpBlobComments(Archive *AH, void *arg) /* Process the tuples, if any */ for (i = 0; i < PQntuples(res); i++) { - Oid blobOid; - char *comment; + Oid blobOid; + char *comment; /* ignore blobs without comments */ if (PQgetisnull(res, i, 1)) @@ -1558,8 +1553,8 @@ getNamespaces(int *numNamespaces) int i_nspacl; /* - * Before 7.3, there are no real namespaces; create two dummy entries, - * one for user stuff and one for system stuff. + * Before 7.3, there are no real namespaces; create two dummy entries, one + * for user stuff and one for system stuff. */ if (g_fout->remoteVersion < 70300) { @@ -1597,8 +1592,8 @@ getNamespaces(int *numNamespaces) selectSourceSchema("pg_catalog"); /* - * we fetch all namespaces including system ones, so that every object - * we read in can be linked to a containing namespace. + * we fetch all namespaces including system ones, so that every object we + * read in can be linked to a containing namespace. */ appendPQExpBuffer(query, "SELECT tableoid, oid, nspname, " "(%s nspowner) as rolname, " @@ -1734,8 +1729,8 @@ getTypes(int *numTypes) int i_typisdefined; /* - * we include even the built-in types because those may be used as - * array elements by user-defined types + * we include even the built-in types because those may be used as array + * elements by user-defined types * * we filter out the built-in types when we dump out the types * @@ -1751,7 +1746,7 @@ getTypes(int *numTypes) "typnamespace, " "(%s typowner) as rolname, " "typinput::oid as typinput, " - "typoutput::oid as typoutput, typelem, typrelid, " + "typoutput::oid as typoutput, typelem, typrelid, " "CASE WHEN typrelid = 0 THEN ' '::\"char\" " "ELSE (SELECT relkind FROM pg_class WHERE oid = typrelid) END as typrelkind, " "typtype, typisdefined " @@ -1764,7 +1759,7 @@ getTypes(int *numTypes) "0::oid as typnamespace, " "(%s typowner) as rolname, " "typinput::oid as typinput, " - "typoutput::oid as typoutput, typelem, typrelid, " + "typoutput::oid as typoutput, typelem, typrelid, " "CASE WHEN typrelid = 0 THEN ' '::\"char\" " "ELSE (SELECT relkind FROM pg_class WHERE oid = typrelid) END as typrelkind, " "typtype, typisdefined " @@ -1774,12 +1769,12 @@ getTypes(int *numTypes) else { appendPQExpBuffer(query, "SELECT " - "(SELECT oid FROM pg_class WHERE relname = 'pg_type') AS tableoid, " + "(SELECT oid FROM pg_class WHERE relname = 'pg_type') AS tableoid, " "oid, typname, " "0::oid as typnamespace, " "(%s typowner) as rolname, " "typinput::oid as typinput, " - "typoutput::oid as typoutput, typelem, typrelid, " + "typoutput::oid as typoutput, typelem, typrelid, " "CASE WHEN typrelid = 0 THEN ' '::\"char\" " "ELSE (SELECT relkind FROM pg_class WHERE oid = typrelid) END as typrelkind, " "typtype, typisdefined " @@ -1829,8 +1824,8 @@ getTypes(int *numTypes) /* * If it's a table's rowtype, use special type code to facilitate - * sorting into the desired order. (We don't want to consider it - * an ordinary type because that would bring the table up into the + * sorting into the desired order. (We don't want to consider it an + * ordinary type because that would bring the table up into the * datatype part of the dump order.) */ if (OidIsValid(tinfo[i].typrelid) && tinfo[i].typrelkind != 'c') @@ -1860,9 +1855,9 @@ getTypes(int *numTypes) /* * Make sure there are dependencies from the type to its input and - * output functions. (We don't worry about typsend, typreceive, - * or typanalyze since those are only valid in 7.4 and later, - * wherein the standard dependency mechanism will pick them up.) + * output functions. (We don't worry about typsend, typreceive, or + * typanalyze since those are only valid in 7.4 and later, wherein the + * standard dependency mechanism will pick them up.) */ funcInfo = findFuncByOid(tinfo[i].typinput); if (funcInfo) @@ -1970,7 +1965,7 @@ getOperators(int *numOprs) AssignDumpId(&oprinfo[i].dobj); oprinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_oprname)); oprinfo[i].dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_oprnamespace)), - oprinfo[i].dobj.catId.oid); + oprinfo[i].dobj.catId.oid); oprinfo[i].rolname = strdup(PQgetvalue(res, i, i_rolname)); oprinfo[i].oprcode = atooid(PQgetvalue(res, i, i_oprcode)); @@ -2050,7 +2045,7 @@ getConversions(int *numConversions) AssignDumpId(&convinfo[i].dobj); convinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_conname)); convinfo[i].dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_connamespace)), - convinfo[i].dobj.catId.oid); + convinfo[i].dobj.catId.oid); convinfo[i].rolname = strdup(PQgetvalue(res, i, i_rolname)); } @@ -2137,7 +2132,7 @@ getOpclasses(int *numOpclasses) AssignDumpId(&opcinfo[i].dobj); opcinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_opcname)); opcinfo[i].dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_opcnamespace)), - opcinfo[i].dobj.catId.oid); + opcinfo[i].dobj.catId.oid); opcinfo[i].rolname = strdup(PQgetvalue(res, i, i_rolname)); if (g_fout->remoteVersion >= 70300) @@ -2193,7 +2188,7 @@ getAggregates(int *numAggs) "FROM pg_proc " "WHERE proisagg " "AND pronamespace != " - "(select oid from pg_namespace where nspname = 'pg_catalog')", + "(select oid from pg_namespace where nspname = 'pg_catalog')", username_subquery); } else if (g_fout->remoteVersion >= 70100) @@ -2247,13 +2242,12 @@ getAggregates(int *numAggs) AssignDumpId(&agginfo[i].aggfn.dobj); agginfo[i].aggfn.dobj.name = strdup(PQgetvalue(res, i, i_aggname)); agginfo[i].aggfn.dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_aggnamespace)), - agginfo[i].aggfn.dobj.catId.oid); + agginfo[i].aggfn.dobj.catId.oid); agginfo[i].aggfn.rolname = strdup(PQgetvalue(res, i, i_rolname)); if (strlen(agginfo[i].aggfn.rolname) == 0) write_msg(NULL, "WARNING: owner of aggregate function \"%s\" appears to be invalid\n", agginfo[i].aggfn.dobj.name); - agginfo[i].aggfn.lang = InvalidOid; /* not currently - * interesting */ + agginfo[i].aggfn.lang = InvalidOid; /* not currently interesting */ agginfo[i].aggfn.nargs = 1; agginfo[i].aggfn.argtypes = (Oid *) malloc(sizeof(Oid)); agginfo[i].aggfn.argtypes[0] = atooid(PQgetvalue(res, i, i_aggbasetype)); @@ -2372,9 +2366,9 @@ getFuncs(int *numFuncs) finfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid)); AssignDumpId(&finfo[i].dobj); finfo[i].dobj.name = strdup(PQgetvalue(res, i, i_proname)); - finfo[i].dobj.namespace = + finfo[i].dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_pronamespace)), - finfo[i].dobj.catId.oid); + finfo[i].dobj.catId.oid); finfo[i].rolname = strdup(PQgetvalue(res, i, i_rolname)); finfo[i].lang = atooid(PQgetvalue(res, i, i_prolang)); finfo[i].prorettype = atooid(PQgetvalue(res, i, i_prorettype)); @@ -2390,8 +2384,8 @@ getFuncs(int *numFuncs) } if (strlen(finfo[i].rolname) == 0) - write_msg(NULL, - "WARNING: owner of function \"%s\" appears to be invalid\n", + write_msg(NULL, + "WARNING: owner of function \"%s\" appears to be invalid\n", finfo[i].dobj.name); } @@ -2441,22 +2435,21 @@ getTables(int *numTables) /* * Find all the tables (including views and sequences). * - * We include system catalogs, so that we can work if a user table is - * defined to inherit from a system catalog (pretty weird, but...) + * We include system catalogs, so that we can work if a user table is defined + * to inherit from a system catalog (pretty weird, but...) * * We ignore tables that are not type 'r' (ordinary relation), 'S' * (sequence), 'v' (view), or 'c' (composite type). * - * Composite-type table entries won't be dumped as such, but we have - * to make a DumpableObject for them so that we can track dependencies - * of the composite type (pg_depend entries for columns of the composite - * type link to the pg_class entry not the pg_type entry). + * Composite-type table entries won't be dumped as such, but we have to make + * a DumpableObject for them so that we can track dependencies of the + * composite type (pg_depend entries for columns of the composite type + * link to the pg_class entry not the pg_type entry). * - * Note: in this phase we should collect only a minimal amount of - * information about each table, basically just enough to decide if it - * is interesting. We must fetch all tables in this phase because - * otherwise we cannot correctly identify inherited columns, serial - * columns, etc. + * Note: in this phase we should collect only a minimal amount of information + * about each table, basically just enough to decide if it is interesting. + * We must fetch all tables in this phase because otherwise we cannot + * correctly identify inherited columns, serial columns, etc. */ if (g_fout->remoteVersion >= 80000) @@ -2477,9 +2470,9 @@ getTables(int *numTables) "from pg_class c " "left join pg_depend d on " "(c.relkind = '%c' and " - "d.classid = c.tableoid and d.objid = c.oid and " + "d.classid = c.tableoid and d.objid = c.oid and " "d.objsubid = 0 and " - "d.refclassid = c.tableoid and d.deptype = 'i') " + "d.refclassid = c.tableoid and d.deptype = 'i') " "where relkind in ('%c', '%c', '%c', '%c') " "order by c.oid", username_subquery, @@ -2505,9 +2498,9 @@ getTables(int *numTables) "from pg_class c " "left join pg_depend d on " "(c.relkind = '%c' and " - "d.classid = c.tableoid and d.objid = c.oid and " + "d.classid = c.tableoid and d.objid = c.oid and " "d.objsubid = 0 and " - "d.refclassid = c.tableoid and d.deptype = 'i') " + "d.refclassid = c.tableoid and d.deptype = 'i') " "where relkind in ('%c', '%c', '%c', '%c') " "order by c.oid", username_subquery, @@ -2518,7 +2511,7 @@ getTables(int *numTables) else if (g_fout->remoteVersion >= 70200) { appendPQExpBuffer(query, - "SELECT tableoid, oid, relname, relacl, relkind, " + "SELECT tableoid, oid, relname, relacl, relkind, " "0::oid as relnamespace, " "(%s relowner) as rolname, " "relchecks, reltriggers, " @@ -2536,7 +2529,7 @@ getTables(int *numTables) { /* all tables have oids in 7.1 */ appendPQExpBuffer(query, - "SELECT tableoid, oid, relname, relacl, relkind, " + "SELECT tableoid, oid, relname, relacl, relkind, " "0::oid as relnamespace, " "(%s relowner) as rolname, " "relchecks, reltriggers, " @@ -2554,16 +2547,16 @@ getTables(int *numTables) else { /* - * Before 7.1, view relkind was not set to 'v', so we must check - * if we have a view by looking for a rule in pg_rewrite. + * Before 7.1, view relkind was not set to 'v', so we must check if we + * have a view by looking for a rule in pg_rewrite. */ appendPQExpBuffer(query, "SELECT " - "(SELECT oid FROM pg_class WHERE relname = 'pg_class') AS tableoid, " + "(SELECT oid FROM pg_class WHERE relname = 'pg_class') AS tableoid, " "oid, relname, relacl, " "CASE WHEN relhasrules and relkind = 'r' " - " and EXISTS(SELECT rulename FROM pg_rewrite r WHERE " - " r.ev_class = c.oid AND r.ev_type = '1') " + " and EXISTS(SELECT rulename FROM pg_rewrite r WHERE " + " r.ev_class = c.oid AND r.ev_type = '1') " "THEN '%c'::\"char\" " "ELSE relkind END AS relkind," "0::oid as relnamespace, " @@ -2590,13 +2583,13 @@ getTables(int *numTables) *numTables = ntups; /* - * Extract data from result and lock dumpable tables. We do the - * locking before anything else, to minimize the window wherein a - * table could disappear under us. + * Extract data from result and lock dumpable tables. We do the locking + * before anything else, to minimize the window wherein a table could + * disappear under us. * - * Note that we have to save info about all tables here, even when - * dumping only one, because we don't yet know which tables might be - * inheritance ancestors of the target table. + * Note that we have to save info about all tables here, even when dumping + * only one, because we don't yet know which tables might be inheritance + * ancestors of the target table. */ tblinfo = (TableInfo *) calloc(ntups, sizeof(TableInfo)); @@ -2624,7 +2617,7 @@ getTables(int *numTables) AssignDumpId(&tblinfo[i].dobj); tblinfo[i].dobj.name = strdup(PQgetvalue(res, i, i_relname)); tblinfo[i].dobj.namespace = findNamespace(atooid(PQgetvalue(res, i, i_relnamespace)), - tblinfo[i].dobj.catId.oid); + tblinfo[i].dobj.catId.oid); tblinfo[i].rolname = strdup(PQgetvalue(res, i, i_rolname)); tblinfo[i].relacl = strdup(PQgetvalue(res, i, i_relacl)); tblinfo[i].relkind = *(PQgetvalue(res, i, i_relkind)); @@ -2649,8 +2642,8 @@ getTables(int *numTables) /* * Decide whether we want to dump this table. Sequences owned by - * serial columns are never dumpable on their own; we will - * transpose their owning table's dump flag to them below. + * serial columns are never dumpable on their own; we will transpose + * their owning table's dump flag to them below. */ if (tblinfo[i].relkind == RELKIND_COMPOSITE_TYPE) tblinfo[i].dump = false; @@ -2661,11 +2654,11 @@ getTables(int *numTables) tblinfo[i].interesting = tblinfo[i].dump; /* - * Read-lock target tables to make sure they aren't DROPPED or - * altered in schema before we get around to dumping them. + * Read-lock target tables to make sure they aren't DROPPED or altered + * in schema before we get around to dumping them. * - * Note that we don't explicitly lock parents of the target tables; - * we assume our lock on the child is enough to prevent schema + * Note that we don't explicitly lock parents of the target tables; we + * assume our lock on the child is enough to prevent schema * alterations to parent tables. * * NOTE: it'd be kinda nice to lock views and sequences too, not only @@ -2676,8 +2669,8 @@ getTables(int *numTables) resetPQExpBuffer(lockquery); appendPQExpBuffer(lockquery, "LOCK TABLE %s IN ACCESS SHARE MODE", - fmtQualifiedId(tblinfo[i].dobj.namespace->dobj.name, - tblinfo[i].dobj.name)); + fmtQualifiedId(tblinfo[i].dobj.namespace->dobj.name, + tblinfo[i].dobj.name)); do_sql_command(g_conn, lockquery->data); } @@ -2689,9 +2682,8 @@ getTables(int *numTables) /* * If the user is attempting to dump a specific table, check to ensure - * that the specified table actually exists. (This is a bit - * simplistic since we don't fully check the combination of -n and -t - * switches.) + * that the specified table actually exists. (This is a bit simplistic + * since we don't fully check the combination of -n and -t switches.) */ if (selectTableName) { @@ -2816,11 +2808,10 @@ getIndexes(TableInfo tblinfo[], int numTables) selectSourceSchema(tbinfo->dobj.namespace->dobj.name); /* - * The point of the messy-looking outer join is to find a - * constraint that is related by an internal dependency link to - * the index. If we find one, create a CONSTRAINT entry linked to - * the INDEX entry. We assume an index won't have more than one - * internal dependency. + * The point of the messy-looking outer join is to find a constraint + * that is related by an internal dependency link to the index. If we + * find one, create a CONSTRAINT entry linked to the INDEX entry. We + * assume an index won't have more than one internal dependency. */ resetPQExpBuffer(query); if (g_fout->remoteVersion >= 80000) @@ -2828,7 +2819,7 @@ getIndexes(TableInfo tblinfo[], int numTables) appendPQExpBuffer(query, "SELECT t.tableoid, t.oid, " "t.relname as indexname, " - "pg_catalog.pg_get_indexdef(i.indexrelid) as indexdef, " + "pg_catalog.pg_get_indexdef(i.indexrelid) as indexdef, " "t.relnatts as indnkeys, " "i.indkey, i.indisclustered, " "c.contype, c.conname, " @@ -2836,7 +2827,7 @@ getIndexes(TableInfo tblinfo[], int numTables) "c.oid as conoid, " "(SELECT spcname FROM pg_catalog.pg_tablespace s WHERE s.oid = t.reltablespace) as tablespace " "FROM pg_catalog.pg_index i " - "JOIN pg_catalog.pg_class t ON (t.oid = i.indexrelid) " + "JOIN pg_catalog.pg_class t ON (t.oid = i.indexrelid) " "LEFT JOIN pg_catalog.pg_depend d " "ON (d.classid = t.tableoid " "AND d.objid = t.oid " @@ -2853,7 +2844,7 @@ getIndexes(TableInfo tblinfo[], int numTables) appendPQExpBuffer(query, "SELECT t.tableoid, t.oid, " "t.relname as indexname, " - "pg_catalog.pg_get_indexdef(i.indexrelid) as indexdef, " + "pg_catalog.pg_get_indexdef(i.indexrelid) as indexdef, " "t.relnatts as indnkeys, " "i.indkey, i.indisclustered, " "c.contype, c.conname, " @@ -2861,7 +2852,7 @@ getIndexes(TableInfo tblinfo[], int numTables) "c.oid as conoid, " "NULL as tablespace " "FROM pg_catalog.pg_index i " - "JOIN pg_catalog.pg_class t ON (t.oid = i.indexrelid) " + "JOIN pg_catalog.pg_class t ON (t.oid = i.indexrelid) " "LEFT JOIN pg_catalog.pg_depend d " "ON (d.classid = t.tableoid " "AND d.objid = t.oid " @@ -2878,7 +2869,7 @@ getIndexes(TableInfo tblinfo[], int numTables) appendPQExpBuffer(query, "SELECT t.tableoid, t.oid, " "t.relname as indexname, " - "pg_get_indexdef(i.indexrelid) as indexdef, " + "pg_get_indexdef(i.indexrelid) as indexdef, " "t.relnatts as indnkeys, " "i.indkey, false as indisclustered, " "CASE WHEN i.indisprimary THEN 'p'::char " @@ -2900,7 +2891,7 @@ getIndexes(TableInfo tblinfo[], int numTables) "(SELECT oid FROM pg_class WHERE relname = 'pg_class') AS tableoid, " "t.oid, " "t.relname as indexname, " - "pg_get_indexdef(i.indexrelid) as indexdef, " + "pg_get_indexdef(i.indexrelid) as indexdef, " "t.relnatts as indnkeys, " "i.indkey, false as indisclustered, " "CASE WHEN i.indisprimary THEN 'p'::char " @@ -2955,11 +2946,11 @@ getIndexes(TableInfo tblinfo[], int numTables) /* * In pre-7.4 releases, indkeys may contain more entries than * indnkeys says (since indnkeys will be 1 for a functional - * index). We don't actually care about this case since we - * don't examine indkeys except for indexes associated with - * PRIMARY and UNIQUE constraints, which are never functional - * indexes. But we have to allocate enough space to keep - * parseOidArray from complaining. + * index). We don't actually care about this case since we don't + * examine indkeys except for indexes associated with PRIMARY and + * UNIQUE constraints, which are never functional indexes. But we + * have to allocate enough space to keep parseOidArray from + * complaining. */ indxinfo[j].indkeys = (Oid *) malloc(INDEX_MAX_KEYS * sizeof(Oid)); parseOidArray(PQgetvalue(res, j, i_indkey), @@ -3058,7 +3049,7 @@ getConstraints(TableInfo tblinfo[], int numTables) resetPQExpBuffer(query); appendPQExpBuffer(query, "SELECT tableoid, oid, conname, " - "pg_catalog.pg_get_constraintdef(oid) as condef " + "pg_catalog.pg_get_constraintdef(oid) as condef " "FROM pg_catalog.pg_constraint " "WHERE conrelid = '%u'::pg_catalog.oid " "AND contype = 'f'", @@ -3121,8 +3112,8 @@ getDomainConstraints(TypeInfo *tinfo) return; /* - * select appropriate schema to ensure names in constraint are - * properly qualified + * select appropriate schema to ensure names in constraint are properly + * qualified */ selectSourceSchema(tinfo->dobj.namespace->dobj.name); @@ -3130,7 +3121,7 @@ getDomainConstraints(TypeInfo *tinfo) if (g_fout->remoteVersion >= 70400) appendPQExpBuffer(query, "SELECT tableoid, oid, conname, " - "pg_catalog.pg_get_constraintdef(oid) AS consrc " + "pg_catalog.pg_get_constraintdef(oid) AS consrc " "FROM pg_catalog.pg_constraint " "WHERE contypid = '%u'::pg_catalog.oid " "ORDER BY conname", @@ -3269,10 +3260,10 @@ getRules(int *numRules) if (ruleinfo[i].ruletable) { /* - * If the table is a view, force its ON SELECT rule to be - * sorted before the view itself --- this ensures that any - * dependencies for the rule affect the table's positioning. - * Other rules are forced to appear after their table. + * If the table is a view, force its ON SELECT rule to be sorted + * before the view itself --- this ensures that any dependencies + * for the rule affect the table's positioning. Other rules are + * forced to appear after their table. */ if (ruleinfo[i].ruletable->relkind == RELKIND_VIEW && ruleinfo[i].ev_type == '1' && ruleinfo[i].is_instead) @@ -3343,8 +3334,7 @@ getTriggers(TableInfo tblinfo[], int numTables) tbinfo->dobj.name); /* - * select table schema to ensure regproc name is qualified if - * needed + * select table schema to ensure regproc name is qualified if needed */ selectSourceSchema(tbinfo->dobj.namespace->dobj.name); @@ -3352,16 +3342,15 @@ getTriggers(TableInfo tblinfo[], int numTables) if (g_fout->remoteVersion >= 70300) { /* - * We ignore triggers that are tied to a foreign-key - * constraint + * We ignore triggers that are tied to a foreign-key constraint */ appendPQExpBuffer(query, "SELECT tgname, " "tgfoid::pg_catalog.regproc as tgfname, " "tgtype, tgnargs, tgargs, tgenabled, " - "tgisconstraint, tgconstrname, tgdeferrable, " - "tgconstrrelid, tginitdeferred, tableoid, oid, " - "tgconstrrelid::pg_catalog.regclass as tgconstrrelname " + "tgisconstraint, tgconstrname, tgdeferrable, " + "tgconstrrelid, tginitdeferred, tableoid, oid, " + "tgconstrrelid::pg_catalog.regclass as tgconstrrelname " "from pg_catalog.pg_trigger t " "where tgrelid = '%u'::pg_catalog.oid " "and (not tgisconstraint " @@ -3374,11 +3363,11 @@ getTriggers(TableInfo tblinfo[], int numTables) else if (g_fout->remoteVersion >= 70100) { appendPQExpBuffer(query, - "SELECT tgname, tgfoid::regproc as tgfname, " + "SELECT tgname, tgfoid::regproc as tgfname, " "tgtype, tgnargs, tgargs, tgenabled, " - "tgisconstraint, tgconstrname, tgdeferrable, " - "tgconstrrelid, tginitdeferred, tableoid, oid, " - "(select relname from pg_class where oid = tgconstrrelid) " + "tgisconstraint, tgconstrname, tgdeferrable, " + "tgconstrrelid, tginitdeferred, tableoid, oid, " + "(select relname from pg_class where oid = tgconstrrelid) " " as tgconstrrelname " "from pg_trigger " "where tgrelid = '%u'::oid", @@ -3387,14 +3376,14 @@ getTriggers(TableInfo tblinfo[], int numTables) else { appendPQExpBuffer(query, - "SELECT tgname, tgfoid::regproc as tgfname, " + "SELECT tgname, tgfoid::regproc as tgfname, " "tgtype, tgnargs, tgargs, tgenabled, " - "tgisconstraint, tgconstrname, tgdeferrable, " + "tgisconstraint, tgconstrname, tgdeferrable, " "tgconstrrelid, tginitdeferred, " "(SELECT oid FROM pg_class WHERE relname = 'pg_trigger') AS tableoid, " "oid, " - "(select relname from pg_class where oid = tgconstrrelid) " + "(select relname from pg_class where oid = tgconstrrelid) " " as tgconstrrelname " "from pg_trigger " "where tgrelid = '%u'::oid", @@ -3624,7 +3613,7 @@ getCasts(int *numCasts) "FROM pg_type t1, pg_type t2, pg_proc p " "WHERE p.pronargs = 1 AND " "p.proargtypes[0] = t1.oid AND " - "p.prorettype = t2.oid AND p.proname = t2.typname " + "p.prorettype = t2.oid AND p.proname = t2.typname " "ORDER BY 3,4"); } @@ -3660,9 +3649,9 @@ getCasts(int *numCasts) castinfo[i].castcontext = *(PQgetvalue(res, i, i_castcontext)); /* - * Try to name cast as concatenation of typnames. This is only - * used for purposes of sorting. If we fail to find either type, - * the name will be an empty string. + * Try to name cast as concatenation of typnames. This is only used + * for purposes of sorting. If we fail to find either type, the name + * will be an empty string. */ initPQExpBuffer(&namebuf); sTypeInfo = findTypeByOid(castinfo[i].castsource); @@ -3751,12 +3740,11 @@ getTableAttrs(TableInfo *tblinfo, int numTables) /* find all the user attributes and their types */ /* - * we must read the attribute names in attribute number order! - * because we will use the attnum to index into the attnames array - * later. We actually ask to order by "attrelid, attnum" because - * (at least up to 7.3) the planner is not smart enough to realize - * it needn't re-sort the output of an indexscan on - * pg_attribute_relid_attnum_index. + * we must read the attribute names in attribute number order! because + * we will use the attnum to index into the attnames array later. We + * actually ask to order by "attrelid, attnum" because (at least up to + * 7.3) the planner is not smart enough to realize it needn't re-sort + * the output of an indexscan on pg_attribute_relid_attnum_index. */ if (g_verbose) write_msg(NULL, "finding the columns and types of table \"%s\"\n", @@ -3768,9 +3756,9 @@ getTableAttrs(TableInfo *tblinfo, int numTables) { /* need left join here to not fail on dropped columns ... */ appendPQExpBuffer(q, "SELECT a.attnum, a.attname, a.atttypmod, a.attstattarget, a.attstorage, t.typstorage, " - "a.attnotnull, a.atthasdef, a.attisdropped, a.attislocal, " - "pg_catalog.format_type(t.oid,a.atttypmod) as atttypname " - "from pg_catalog.pg_attribute a left join pg_catalog.pg_type t " + "a.attnotnull, a.atthasdef, a.attisdropped, a.attislocal, " + "pg_catalog.format_type(t.oid,a.atttypmod) as atttypname " + "from pg_catalog.pg_attribute a left join pg_catalog.pg_type t " "on a.atttypid = t.oid " "where a.attrelid = '%u'::pg_catalog.oid " "and a.attnum > 0::pg_catalog.int2 " @@ -3780,13 +3768,13 @@ getTableAttrs(TableInfo *tblinfo, int numTables) else if (g_fout->remoteVersion >= 70100) { /* - * attstattarget doesn't exist in 7.1. It does exist in 7.2, - * but we don't dump it because we can't tell whether it's - * been explicitly set or was just a default. + * attstattarget doesn't exist in 7.1. It does exist in 7.2, but + * we don't dump it because we can't tell whether it's been + * explicitly set or was just a default. */ appendPQExpBuffer(q, "SELECT a.attnum, a.attname, a.atttypmod, -1 as attstattarget, a.attstorage, t.typstorage, " "a.attnotnull, a.atthasdef, false as attisdropped, false as attislocal, " - "format_type(t.oid,a.atttypmod) as atttypname " + "format_type(t.oid,a.atttypmod) as atttypname " "from pg_attribute a left join pg_type t " "on a.atttypid = t.oid " "where a.attrelid = '%u'::oid " @@ -3886,7 +3874,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables) if (g_fout->remoteVersion >= 70300) { appendPQExpBuffer(q, "SELECT tableoid, oid, adnum, " - "pg_catalog.pg_get_expr(adbin, adrelid) AS adsrc " + "pg_catalog.pg_get_expr(adbin, adrelid) AS adsrc " "FROM pg_catalog.pg_attrdef " "WHERE adrelid = '%u'::pg_catalog.oid", tbinfo->dobj.catId.oid); @@ -3940,11 +3928,11 @@ getTableAttrs(TableInfo *tblinfo, int numTables) attrdefs[j].dobj.namespace = tbinfo->dobj.namespace; /* - * Defaults on a VIEW must always be dumped as separate - * ALTER TABLE commands. Defaults on regular tables are - * dumped as part of the CREATE TABLE if possible. To - * check if it's safe, we mark the default as needing to - * appear before the CREATE. + * Defaults on a VIEW must always be dumped as separate ALTER + * TABLE commands. Defaults on regular tables are dumped as + * part of the CREATE TABLE if possible. To check if it's + * safe, we mark the default as needing to appear before the + * CREATE. */ if (tbinfo->relkind == RELKIND_VIEW) { @@ -3987,7 +3975,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables) if (g_fout->remoteVersion >= 70400) { appendPQExpBuffer(q, "SELECT tableoid, oid, conname, " - "pg_catalog.pg_get_constraintdef(oid) AS consrc " + "pg_catalog.pg_get_constraintdef(oid) AS consrc " "FROM pg_catalog.pg_constraint " "WHERE conrelid = '%u'::pg_catalog.oid " " AND contype = 'c' " @@ -4068,11 +4056,12 @@ getTableAttrs(TableInfo *tblinfo, int numTables) constrs[j].conindex = 0; constrs[j].coninherited = false; constrs[j].separate = false; + /* - * Mark the constraint as needing to appear before the - * table --- this is so that any other dependencies of - * the constraint will be emitted before we try to create - * the table. + * Mark the constraint as needing to appear before the table + * --- this is so that any other dependencies of the + * constraint will be emitted before we try to create the + * table. */ addObjectDependency(&tbinfo->dobj, constrs[j].dobj.dumpId); @@ -4087,18 +4076,17 @@ getTableAttrs(TableInfo *tblinfo, int numTables) } /* - * Check to see if any columns are serial columns. Our first - * quick filter is that it must be integer or bigint with a - * default. If so, we scan to see if we found a sequence linked - * to this column. If we did, mark the column and sequence - * appropriately. + * Check to see if any columns are serial columns. Our first quick + * filter is that it must be integer or bigint with a default. If so, + * we scan to see if we found a sequence linked to this column. If we + * did, mark the column and sequence appropriately. */ for (j = 0; j < ntups; j++) { /* * Note assumption that format_type will show these types as - * exactly "integer" and "bigint" regardless of schema path. - * This is correct in 7.3 but needs to be watched. + * exactly "integer" and "bigint" regardless of schema path. This + * is correct in 7.3 but needs to be watched. */ if (strcmp(tbinfo->atttypnames[j], "integer") != 0 && strcmp(tbinfo->atttypnames[j], "bigint") != 0) @@ -4305,9 +4293,9 @@ findComments(Archive *fout, Oid classoid, Oid objoid, ncomments = collectComments(fout, &comments); /* - * Pre-7.2, pg_description does not contain classoid, so - * collectComments just stores a zero. If there's a collision on - * object OID, well, you get duplicate comments. + * Pre-7.2, pg_description does not contain classoid, so collectComments + * just stores a zero. If there's a collision on object OID, well, you + * get duplicate comments. */ if (fout->remoteVersion < 70200) classoid = 0; @@ -4341,8 +4329,8 @@ findComments(Archive *fout, Oid classoid, Oid objoid, /* * Now determine how many items match the object. The search loop - * invariant still holds: only items between low and high inclusive - * could match. + * invariant still holds: only items between low and high inclusive could + * match. */ nmatch = 1; while (middle > low) @@ -4560,7 +4548,7 @@ dumpNamespace(Archive *fout, NamespaceInfo *nspinfo) ArchiveEntry(fout, nspinfo->dobj.catId, nspinfo->dobj.dumpId, nspinfo->dobj.name, - NULL, NULL, + NULL, NULL, nspinfo->rolname, false, "SCHEMA", q->data, delq->data, NULL, nspinfo->dobj.dependencies, nspinfo->dobj.nDeps, @@ -4768,8 +4756,7 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo) typstorage = PQgetvalue(res, 0, PQfnumber(res, "typstorage")); /* - * DROP must be fully qualified in case same name appears in - * pg_catalog + * DROP must be fully qualified in case same name appears in pg_catalog */ appendPQExpBuffer(delq, "DROP TYPE %s.", fmtId(tinfo->dobj.namespace->dobj.name)); @@ -4895,7 +4882,7 @@ dumpDomain(Archive *fout, TypeInfo *tinfo) /* Fetch domain specific details */ /* We assume here that remoteVersion must be at least 70300 */ appendPQExpBuffer(query, "SELECT typnotnull, " - "pg_catalog.format_type(typbasetype, typtypmod) as typdefn, " + "pg_catalog.format_type(typbasetype, typtypmod) as typdefn, " "typdefault " "FROM pg_catalog.pg_type " "WHERE oid = '%u'::pg_catalog.oid", @@ -4942,14 +4929,13 @@ dumpDomain(Archive *fout, TypeInfo *tinfo) if (!domcheck->separate) appendPQExpBuffer(q, "\n\tCONSTRAINT %s %s", - fmtId(domcheck->dobj.name), domcheck->condef); + fmtId(domcheck->dobj.name), domcheck->condef); } appendPQExpBuffer(q, ";\n"); /* - * DROP must be fully qualified in case same name appears in - * pg_catalog + * DROP must be fully qualified in case same name appears in pg_catalog */ appendPQExpBuffer(delq, "DROP DOMAIN %s.", fmtId(tinfo->dobj.namespace->dobj.name)); @@ -5002,8 +4988,8 @@ dumpCompositeType(Archive *fout, TypeInfo *tinfo) /* We assume here that remoteVersion must be at least 70300 */ appendPQExpBuffer(query, "SELECT a.attname, " - "pg_catalog.format_type(a.atttypid, a.atttypmod) as atttypdefn " - "FROM pg_catalog.pg_type t, pg_catalog.pg_attribute a " + "pg_catalog.format_type(a.atttypid, a.atttypmod) as atttypdefn " + "FROM pg_catalog.pg_type t, pg_catalog.pg_attribute a " "WHERE t.oid = '%u'::pg_catalog.oid " "AND a.attrelid = t.typrelid " "AND NOT a.attisdropped " @@ -5042,8 +5028,7 @@ dumpCompositeType(Archive *fout, TypeInfo *tinfo) appendPQExpBuffer(q, "\n);\n"); /* - * DROP must be fully qualified in case same name appears in - * pg_catalog + * DROP must be fully qualified in case same name appears in pg_catalog */ appendPQExpBuffer(delq, "DROP TYPE %s.", fmtId(tinfo->dobj.namespace->dobj.name)); @@ -5084,7 +5069,7 @@ dumpCompositeType(Archive *fout, TypeInfo *tinfo) * * For some backwards compatibility with the older behavior, we forcibly * dump a PL if its handler function (and validator if any) are in a - * dumpable namespace. That case is not checked here. + * dumpable namespace. That case is not checked here. */ static bool shouldDumpProcLangs(void) @@ -5117,11 +5102,11 @@ dumpProcLang(Archive *fout, ProcLangInfo *plang) return; /* - * Try to find the support function(s). It is not an error if we - * don't find them --- if the functions are in the pg_catalog schema, - * as is standard in 8.1 and up, then we won't have loaded them. - * (In this case we will emit a parameterless CREATE LANGUAGE command, - * which will require PL template knowledge in the backend to reload.) + * Try to find the support function(s). It is not an error if we don't + * find them --- if the functions are in the pg_catalog schema, as is + * standard in 8.1 and up, then we won't have loaded them. (In this case + * we will emit a parameterless CREATE LANGUAGE command, which will + * require PL template knowledge in the backend to reload.) */ funcInfo = findFuncByOid(plang->lanplcallfoid); @@ -5137,8 +5122,8 @@ dumpProcLang(Archive *fout, ProcLangInfo *plang) /* * If the functions are dumpable then emit a traditional CREATE LANGUAGE - * with parameters. Otherwise, dump only if shouldDumpProcLangs() says - * to dump it. + * with parameters. Otherwise, dump only if shouldDumpProcLangs() says to + * dump it. */ useParams = (funcInfo != NULL && (validatorInfo != NULL || !OidIsValid(plang->lanvalidator))); @@ -5152,9 +5137,9 @@ dumpProcLang(Archive *fout, ProcLangInfo *plang) qlanname = strdup(fmtId(plang->dobj.name)); /* - * If dumping a HANDLER clause, treat the language as being in the - * handler function's schema; this avoids cluttering the HANDLER clause. - * Otherwise it doesn't really have a schema. + * If dumping a HANDLER clause, treat the language as being in the handler + * function's schema; this avoids cluttering the HANDLER clause. Otherwise + * it doesn't really have a schema. */ if (useParams) lanschema = funcInfo->dobj.namespace->dobj.name; @@ -5177,7 +5162,7 @@ dumpProcLang(Archive *fout, ProcLangInfo *plang) /* Cope with possibility that validator is in different schema */ if (validatorInfo->dobj.namespace != funcInfo->dobj.namespace) appendPQExpBuffer(defqry, "%s.", - fmtId(validatorInfo->dobj.namespace->dobj.name)); + fmtId(validatorInfo->dobj.namespace->dobj.name)); appendPQExpBuffer(defqry, "%s", fmtId(validatorInfo->dobj.name)); } @@ -5403,10 +5388,10 @@ dumpFunc(Archive *fout, FuncInfo *finfo) "null as proallargtypes, " "null as proargmodes, " "null as proargnames, " - "case when proiscachable then 'i' else 'v' end as provolatile, " + "case when proiscachable then 'i' else 'v' end as provolatile, " "proisstrict, " "'f'::boolean as prosecdef, " - "(SELECT lanname FROM pg_language WHERE oid = prolang) as lanname " + "(SELECT lanname FROM pg_language WHERE oid = prolang) as lanname " "FROM pg_proc " "WHERE oid = '%u'::oid", finfo->dobj.catId.oid); @@ -5418,10 +5403,10 @@ dumpFunc(Archive *fout, FuncInfo *finfo) "null as proallargtypes, " "null as proargmodes, " "null as proargnames, " - "case when proiscachable then 'i' else 'v' end as provolatile, " + "case when proiscachable then 'i' else 'v' end as provolatile, " "'f'::boolean as proisstrict, " "'f'::boolean as prosecdef, " - "(SELECT lanname FROM pg_language WHERE oid = prolang) as lanname " + "(SELECT lanname FROM pg_language WHERE oid = prolang) as lanname " "FROM pg_proc " "WHERE oid = '%u'::oid", finfo->dobj.catId.oid); @@ -5536,8 +5521,7 @@ dumpFunc(Archive *fout, FuncInfo *finfo) funcsig_tag = format_function_signature(finfo, false); /* - * DROP must be fully qualified in case same name appears in - * pg_catalog + * DROP must be fully qualified in case same name appears in pg_catalog */ appendPQExpBuffer(delqry, "DROP FUNCTION %s.%s;\n", fmtId(finfo->dobj.namespace->dobj.name), @@ -5640,9 +5624,9 @@ dumpCast(Archive *fout, CastInfo *cast) /* * As per discussion we dump casts if one or more of the underlying * objects (the conversion function and the two data types) are not - * builtin AND if all of the non-builtin objects namespaces are - * included in the dump. Builtin meaning, the namespace name does not - * start with "pg_". + * builtin AND if all of the non-builtin objects namespaces are included + * in the dump. Builtin meaning, the namespace name does not start with + * "pg_". */ sourceInfo = findTypeByOid(cast->castsource); targetInfo = findTypeByOid(cast->casttarget); @@ -5660,8 +5644,7 @@ dumpCast(Archive *fout, CastInfo *cast) return; /* - * Skip cast if function isn't from pg_ and that namespace is not - * dumped. + * Skip cast if function isn't from pg_ and that namespace is not dumped. */ if (funcInfo && strncmp(funcInfo->dobj.namespace->dobj.name, "pg_", 3) != 0 && @@ -5702,8 +5685,8 @@ dumpCast(Archive *fout, CastInfo *cast) else { /* - * Always qualify the function name, in case it is not in - * pg_catalog schema (format_function_signature won't qualify it). + * Always qualify the function name, in case it is not in pg_catalog + * schema (format_function_signature won't qualify it). */ appendPQExpBuffer(defqry, "WITH FUNCTION %s.", fmtId(funcInfo->dobj.namespace->dobj.name)); @@ -5827,9 +5810,9 @@ dumpOpr(Archive *fout, OprInfo *oprinfo) { appendPQExpBuffer(query, "SELECT oprkind, oprcode, " "CASE WHEN oprleft = 0 THEN '-' " - "ELSE format_type(oprleft, NULL) END as oprleft, " + "ELSE format_type(oprleft, NULL) END as oprleft, " "CASE WHEN oprright = 0 THEN '-' " - "ELSE format_type(oprright, NULL) END as oprright, " + "ELSE format_type(oprright, NULL) END as oprright, " "oprcom, oprnegate, oprrest, oprjoin, " "oprcanhash, oprlsortop, oprrsortop, " "0 as oprltcmpop, 0 as oprgtcmpop " @@ -5964,8 +5947,7 @@ dumpOpr(Archive *fout, OprInfo *oprinfo) appendPQExpBuffer(details, ",\n GTCMP = %s", name); /* - * DROP must be fully qualified in case same name appears in - * pg_catalog + * DROP must be fully qualified in case same name appears in pg_catalog */ appendPQExpBuffer(delq, "DROP OPERATOR %s.%s;\n", fmtId(oprinfo->dobj.namespace->dobj.name), @@ -5976,7 +5958,7 @@ dumpOpr(Archive *fout, OprInfo *oprinfo) ArchiveEntry(fout, oprinfo->dobj.catId, oprinfo->dobj.dumpId, oprinfo->dobj.name, - oprinfo->dobj.namespace->dobj.name, + oprinfo->dobj.namespace->dobj.name, NULL, oprinfo->rolname, false, "OPERATOR", q->data, delq->data, NULL, @@ -6146,7 +6128,7 @@ dumpOpclass(Archive *fout, OpclassInfo *opcinfo) appendPQExpBuffer(query, "SELECT opcintype::pg_catalog.regtype, " "opckeytype::pg_catalog.regtype, " "opcdefault, " - "(SELECT amname FROM pg_catalog.pg_am WHERE oid = opcamid) AS amname " + "(SELECT amname FROM pg_catalog.pg_am WHERE oid = opcamid) AS amname " "FROM pg_catalog.pg_opclass " "WHERE oid = '%u'::pg_catalog.oid", opcinfo->dobj.catId.oid); @@ -6175,8 +6157,7 @@ dumpOpclass(Archive *fout, OpclassInfo *opcinfo) amname = strdup(PQgetvalue(res, 0, i_amname)); /* - * DROP must be fully qualified in case same name appears in - * pg_catalog + * DROP must be fully qualified in case same name appears in pg_catalog */ appendPQExpBuffer(delq, "DROP OPERATOR CLASS %s", fmtId(opcinfo->dobj.namespace->dobj.name)); @@ -6285,7 +6266,7 @@ dumpOpclass(Archive *fout, OpclassInfo *opcinfo) ArchiveEntry(fout, opcinfo->dobj.catId, opcinfo->dobj.dumpId, opcinfo->dobj.name, - opcinfo->dobj.namespace->dobj.name, + opcinfo->dobj.namespace->dobj.name, NULL, opcinfo->rolname, false, "OPERATOR CLASS", q->data, delq->data, NULL, @@ -6346,8 +6327,8 @@ dumpConversion(Archive *fout, ConvInfo *convinfo) /* Get conversion-specific details */ appendPQExpBuffer(query, "SELECT conname, " - "pg_catalog.pg_encoding_to_char(conforencoding) AS conforencoding, " - "pg_catalog.pg_encoding_to_char(contoencoding) AS contoencoding, " + "pg_catalog.pg_encoding_to_char(conforencoding) AS conforencoding, " + "pg_catalog.pg_encoding_to_char(contoencoding) AS contoencoding, " "conproc, condefault " "FROM pg_catalog.pg_conversion c " "WHERE c.oid = '%u'::pg_catalog.oid", @@ -6378,8 +6359,7 @@ dumpConversion(Archive *fout, ConvInfo *convinfo) condefault = (PQgetvalue(res, 0, i_condefault)[0] == 't'); /* - * DROP must be fully qualified in case same name appears in - * pg_catalog + * DROP must be fully qualified in case same name appears in pg_catalog */ appendPQExpBuffer(delq, "DROP CONVERSION %s", fmtId(convinfo->dobj.namespace->dobj.name)); @@ -6397,8 +6377,8 @@ dumpConversion(Archive *fout, ConvInfo *convinfo) ArchiveEntry(fout, convinfo->dobj.catId, convinfo->dobj.dumpId, convinfo->dobj.name, - convinfo->dobj.namespace->dobj.name, - NULL, + convinfo->dobj.namespace->dobj.name, + NULL, convinfo->rolname, false, "CONVERSION", q->data, delq->data, NULL, convinfo->dobj.dependencies, convinfo->dobj.nDeps, @@ -6507,9 +6487,9 @@ dumpAgg(Archive *fout, AggInfo *agginfo) "aggsortop::pg_catalog.regoperator, " "agginitval, " "proargtypes[0] = 'pg_catalog.\"any\"'::pg_catalog.regtype as anybasetype, " - "proargtypes[0]::pg_catalog.regtype as fmtbasetype, " + "proargtypes[0]::pg_catalog.regtype as fmtbasetype, " "'t'::boolean as convertok " - "from pg_catalog.pg_aggregate a, pg_catalog.pg_proc p " + "from pg_catalog.pg_aggregate a, pg_catalog.pg_proc p " "where a.aggfnoid = p.oid " "and p.oid = '%u'::pg_catalog.oid", agginfo->aggfn.dobj.catId.oid); @@ -6521,9 +6501,9 @@ dumpAgg(Archive *fout, AggInfo *agginfo) "0 as aggsortop, " "agginitval, " "proargtypes[0] = 'pg_catalog.\"any\"'::pg_catalog.regtype as anybasetype, " - "proargtypes[0]::pg_catalog.regtype as fmtbasetype, " + "proargtypes[0]::pg_catalog.regtype as fmtbasetype, " "'t'::boolean as convertok " - "from pg_catalog.pg_aggregate a, pg_catalog.pg_proc p " + "from pg_catalog.pg_aggregate a, pg_catalog.pg_proc p " "where a.aggfnoid = p.oid " "and p.oid = '%u'::pg_catalog.oid", agginfo->aggfn.dobj.catId.oid); @@ -6531,12 +6511,12 @@ dumpAgg(Archive *fout, AggInfo *agginfo) else if (g_fout->remoteVersion >= 70100) { appendPQExpBuffer(query, "SELECT aggtransfn, aggfinalfn, " - "format_type(aggtranstype, NULL) as aggtranstype, " + "format_type(aggtranstype, NULL) as aggtranstype, " "0 as aggsortop, " "agginitval, " "aggbasetype = 0 as anybasetype, " "CASE WHEN aggbasetype = 0 THEN '-' " - "ELSE format_type(aggbasetype, NULL) END as fmtbasetype, " + "ELSE format_type(aggbasetype, NULL) END as fmtbasetype, " "'t'::boolean as convertok " "from pg_aggregate " "where oid = '%u'::oid", @@ -6649,8 +6629,7 @@ dumpAgg(Archive *fout, AggInfo *agginfo) } /* - * DROP must be fully qualified in case same name appears in - * pg_catalog + * DROP must be fully qualified in case same name appears in pg_catalog */ appendPQExpBuffer(delq, "DROP AGGREGATE %s.%s;\n", fmtId(agginfo->aggfn.dobj.namespace->dobj.name), @@ -6673,13 +6652,13 @@ dumpAgg(Archive *fout, AggInfo *agginfo) resetPQExpBuffer(q); appendPQExpBuffer(q, "AGGREGATE %s", aggsig); dumpComment(fout, q->data, - agginfo->aggfn.dobj.namespace->dobj.name, agginfo->aggfn.rolname, + agginfo->aggfn.dobj.namespace->dobj.name, agginfo->aggfn.rolname, agginfo->aggfn.dobj.catId, 0, agginfo->aggfn.dobj.dumpId); /* - * Since there is no GRANT ON AGGREGATE syntax, we have to make the - * ACL command look like a function's GRANT; in particular this - * affects the syntax for aggregates on ANY. + * Since there is no GRANT ON AGGREGATE syntax, we have to make the ACL + * command look like a function's GRANT; in particular this affects the + * syntax for aggregates on ANY. */ free(aggsig); free(aggsig_tag); @@ -6743,7 +6722,7 @@ dumpACL(Archive *fout, CatalogId objCatId, DumpId objDumpId, if (sql->len > 0) ArchiveEntry(fout, nilCatalogId, createDumpId(), tag, nspname, - NULL, + NULL, owner ? owner : "", false, "ACL", sql->data, "", NULL, &(objDumpId), 1, @@ -6915,8 +6894,8 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) } /* - * Default value --- suppress if inherited, serial, or to - * be printed separately. + * Default value --- suppress if inherited, serial, or to be + * printed separately. */ if (tbinfo->attrdefs[j] != NULL && !tbinfo->inhAttrDef[j] && @@ -6928,8 +6907,8 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) /* * Not Null constraint --- suppress if inherited * - * Note: we could suppress this for serial columns since - * SERIAL implies NOT NULL. We choose not to for forward + * Note: we could suppress this for serial columns since SERIAL + * implies NOT NULL. We choose not to for forward * compatibility, since there has been some talk of making * SERIAL not imply NOT NULL, in which case the explicit * specification would be needed. @@ -6974,7 +6953,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) appendPQExpBuffer(q, ", "); if (parentRel->dobj.namespace != tbinfo->dobj.namespace) appendPQExpBuffer(q, "%s.", - fmtId(parentRel->dobj.namespace->dobj.name)); + fmtId(parentRel->dobj.namespace->dobj.name)); appendPQExpBuffer(q, "%s", fmtId(parentRel->dobj.name)); } @@ -6987,9 +6966,9 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) for (j = 0; j < tbinfo->numatts; j++) { /* - * Dump per-column statistics information. We only issue an - * ALTER TABLE statement if the attstattarget entry for this - * column is non-negative (i.e. it's not the default value) + * Dump per-column statistics information. We only issue an ALTER + * TABLE statement if the attstattarget entry for this column is + * non-negative (i.e. it's not the default value) */ if (tbinfo->attstattarget[j] >= 0 && !tbinfo->attisdropped[j]) @@ -7004,8 +6983,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) /* * Dump per-column storage information. The statement is only - * dumped if the storage has been changed from the type's - * default. + * dumped if the storage has been changed from the type's default. */ if (!tbinfo->attisdropped[j] && tbinfo->attstorage[j] != tbinfo->typstorage[j]) { @@ -7028,8 +7006,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) } /* - * Only dump the statement if it's a storage type we - * recognize + * Only dump the statement if it's a storage type we recognize */ if (storage != NULL) { @@ -7047,9 +7024,9 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) ArchiveEntry(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId, tbinfo->dobj.name, tbinfo->dobj.namespace->dobj.name, - (tbinfo->relkind == RELKIND_VIEW) ? NULL : tbinfo->reltablespace, + (tbinfo->relkind == RELKIND_VIEW) ? NULL : tbinfo->reltablespace, tbinfo->rolname, - (strcmp(reltypename, "TABLE") == 0) ? tbinfo->hasoids : false, + (strcmp(reltypename, "TABLE") == 0) ? tbinfo->hasoids : false, reltypename, q->data, delq->data, NULL, tbinfo->dobj.dependencies, tbinfo->dobj.nDeps, NULL, NULL); @@ -7102,8 +7079,7 @@ dumpAttrDef(Archive *fout, AttrDefInfo *adinfo) adinfo->adef_expr); /* - * DROP must be fully qualified in case same name appears in - * pg_catalog + * DROP must be fully qualified in case same name appears in pg_catalog */ appendPQExpBuffer(delq, "ALTER TABLE %s.", fmtId(tbinfo->dobj.namespace->dobj.name)); @@ -7114,7 +7090,7 @@ dumpAttrDef(Archive *fout, AttrDefInfo *adinfo) ArchiveEntry(fout, adinfo->dobj.catId, adinfo->dobj.dumpId, tbinfo->attnames[adnum - 1], - tbinfo->dobj.namespace->dobj.name, + tbinfo->dobj.namespace->dobj.name, NULL, tbinfo->rolname, false, "DEFAULT", q->data, delq->data, NULL, @@ -7178,9 +7154,9 @@ dumpIndex(Archive *fout, IndxInfo *indxinfo) delq = createPQExpBuffer(); /* - * If there's an associated constraint, don't dump the index per se, - * but do dump any comment for it. (This is safe because dependency - * ordering will have ensured the constraint is emitted first.) + * If there's an associated constraint, don't dump the index per se, but + * do dump any comment for it. (This is safe because dependency ordering + * will have ensured the constraint is emitted first.) */ if (indxinfo->indexconstraint == 0) { @@ -7266,7 +7242,7 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo) fmtId(tbinfo->dobj.name)); appendPQExpBuffer(q, " ADD CONSTRAINT %s %s (", fmtId(coninfo->dobj.name), - coninfo->contype == 'p' ? "PRIMARY KEY" : "UNIQUE"); + coninfo->contype == 'p' ? "PRIMARY KEY" : "UNIQUE"); for (k = 0; k < indxinfo->indnkeys; k++) { @@ -7316,8 +7292,8 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo) else if (coninfo->contype == 'f') { /* - * XXX Potentially wrap in a 'SET CONSTRAINTS OFF' block so that - * the current table data is not processed + * XXX Potentially wrap in a 'SET CONSTRAINTS OFF' block so that the + * current table data is not processed */ appendPQExpBuffer(q, "ALTER TABLE ONLY %s\n", fmtId(tbinfo->dobj.name)); @@ -7450,7 +7426,7 @@ dumpTableConstraintComment(Archive *fout, ConstraintInfo *coninfo) tbinfo->dobj.namespace->dobj.name, tbinfo->rolname, coninfo->dobj.catId, 0, - coninfo->separate ? coninfo->dobj.dumpId : tbinfo->dobj.dumpId); + coninfo->separate ? coninfo->dobj.dumpId : tbinfo->dobj.dumpId); destroyPQExpBuffer(q); } @@ -7512,7 +7488,7 @@ findLastBuiltinOid_V70(void) res = PQexec(g_conn, "SELECT oid FROM pg_class WHERE relname = 'pg_indexes'"); check_sql_result(res, g_conn, - "SELECT oid FROM pg_class WHERE relname = 'pg_indexes'", + "SELECT oid FROM pg_class WHERE relname = 'pg_indexes'", PGRES_TUPLES_OK); ntups = PQntuples(res); if (ntups < 1) @@ -7554,12 +7530,12 @@ dumpSequence(Archive *fout, TableInfo *tbinfo) appendPQExpBuffer(query, "SELECT sequence_name, last_value, increment_by, " - "CASE WHEN increment_by > 0 AND max_value = %s THEN NULL " - " WHEN increment_by < 0 AND max_value = -1 THEN NULL " + "CASE WHEN increment_by > 0 AND max_value = %s THEN NULL " + " WHEN increment_by < 0 AND max_value = -1 THEN NULL " " ELSE max_value " "END AS max_value, " - "CASE WHEN increment_by > 0 AND min_value = 1 THEN NULL " - " WHEN increment_by < 0 AND min_value = %s THEN NULL " + "CASE WHEN increment_by > 0 AND min_value = 1 THEN NULL " + " WHEN increment_by < 0 AND min_value = %s THEN NULL " " ELSE min_value " "END AS min_value, " "cache_value, is_cycled, is_called from %s", @@ -7599,12 +7575,12 @@ dumpSequence(Archive *fout, TableInfo *tbinfo) /* * The logic we use for restoring sequences is as follows: * - * Add a basic CREATE SEQUENCE statement (use last_val for start if - * called is false, else use min_val for start_val). Skip this if the - * sequence came from a SERIAL column. + * Add a basic CREATE SEQUENCE statement (use last_val for start if called is + * false, else use min_val for start_val). Skip this if the sequence came + * from a SERIAL column. * - * Add a 'SETVAL(seq, last_val, iscalled)' at restore-time iff we load - * data. We do this for serial sequences too. + * Add a 'SETVAL(seq, last_val, iscalled)' at restore-time iff we load data. + * We do this for serial sequences too. */ if (!dataOnly && !OidIsValid(tbinfo->owning_tab)) @@ -7648,7 +7624,7 @@ dumpSequence(Archive *fout, TableInfo *tbinfo) ArchiveEntry(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId, tbinfo->dobj.name, - tbinfo->dobj.namespace->dobj.name, + tbinfo->dobj.namespace->dobj.name, NULL, tbinfo->rolname, false, "SEQUENCE", query->data, delqry->data, NULL, @@ -7664,11 +7640,10 @@ dumpSequence(Archive *fout, TableInfo *tbinfo) appendPQExpBuffer(query, "SELECT pg_catalog.setval("); /* - * If this is a SERIAL sequence, then use the - * pg_get_serial_sequence function to avoid hard-coding the - * sequence name. Note that this implicitly assumes that the - * sequence and its owning table are in the same schema, because - * we don't schema-qualify the reference. + * If this is a SERIAL sequence, then use the pg_get_serial_sequence + * function to avoid hard-coding the sequence name. Note that this + * implicitly assumes that the sequence and its owning table are in + * the same schema, because we don't schema-qualify the reference. */ if (OidIsValid(tbinfo->owning_tab) && (owning_tab = findTableByOid(tbinfo->owning_tab)) != NULL) @@ -7726,8 +7701,7 @@ dumpTrigger(Archive *fout, TriggerInfo *tginfo) delqry = createPQExpBuffer(); /* - * DROP must be fully qualified in case same name appears in - * pg_catalog + * DROP must be fully qualified in case same name appears in pg_catalog */ appendPQExpBuffer(delqry, "DROP TRIGGER %s ", fmtId(tginfo->dobj.name)); @@ -7814,7 +7788,8 @@ dumpTrigger(Archive *fout, TriggerInfo *tginfo) p = tginfo->tgargs; for (findx = 0; findx < tginfo->tgnargs; findx++) { - const char *s = p, *s2 = p; + const char *s = p, + *s2 = p; /* Set 'p' to end of arg string. marked by '\000' */ for (;;) @@ -7834,7 +7809,7 @@ dumpTrigger(Archive *fout, TriggerInfo *tginfo) p++; continue; } - if (p[0] == '0' && p[1] == '0' && p[2] == '0') /* is it '\000'? */ + if (p[0] == '0' && p[1] == '0' && p[2] == '0') /* is it '\000'? */ break; } p--; @@ -7953,8 +7928,7 @@ dumpRule(Archive *fout, RuleInfo *rinfo) printfPQExpBuffer(cmd, "%s\n", PQgetvalue(res, 0, 0)); /* - * DROP must be fully qualified in case same name appears in - * pg_catalog + * DROP must be fully qualified in case same name appears in pg_catalog */ appendPQExpBuffer(delcmd, "DROP RULE %s ", fmtId(rinfo->dobj.name)); @@ -8039,8 +8013,8 @@ getDependencies(void) /* * Since we ordered the SELECT by referencing ID, we can expect that - * multiple entries for the same object will appear together; this - * saves on searches. + * multiple entries for the same object will appear together; this saves + * on searches. */ dobj = NULL; @@ -8062,9 +8036,8 @@ getDependencies(void) dobj = findObjectByCatalogId(objId); /* - * Failure to find objects mentioned in pg_depend is not - * unexpected, since for example we don't collect info about TOAST - * tables. + * Failure to find objects mentioned in pg_depend is not unexpected, + * since for example we don't collect info about TOAST tables. */ if (dobj == NULL) { @@ -8088,16 +8061,17 @@ getDependencies(void) /* * Ordinarily, table rowtypes have implicit dependencies on their - * tables. However, for a composite type the implicit dependency - * goes the other way in pg_depend; which is the right thing for - * DROP but it doesn't produce the dependency ordering we need. - * So in that one case, we reverse the direction of the dependency. + * tables. However, for a composite type the implicit dependency goes + * the other way in pg_depend; which is the right thing for DROP but + * it doesn't produce the dependency ordering we need. So in that one + * case, we reverse the direction of the dependency. */ if (deptype == 'i' && dobj->objType == DO_TABLE && refdobj->objType == DO_TYPE) addObjectDependency(refdobj, dobj->dumpId); - else /* normal case */ + else + /* normal case */ addObjectDependency(dobj, refdobj->dumpId); } @@ -8276,8 +8250,8 @@ myFormatType(const char *typname, int32 typmod) } /* - * 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(typname, "char") == 0) appendPQExpBuffer(buf, "\"char\""); diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h index 1537fc3a39..a3d694d04f 100644 --- a/src/bin/pg_dump/pg_dump.h +++ b/src/bin/pg_dump/pg_dump.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.h,v 1.121 2005/09/05 23:50:49 tgl Exp $ + * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.h,v 1.122 2005/10/15 02:49:39 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -184,9 +184,8 @@ typedef struct _tableInfo bool dump; /* true if we want to dump it */ /* - * These fields are computed only if we decide the table is - * interesting (it's either a table to dump, or a direct parent of a - * dumpable table). + * These fields are computed only if we decide the table is interesting + * (it's either a table to dump, or a direct parent of a dumpable table). */ int numatts; /* number of attributes */ char **attnames; /* the attribute names */ @@ -200,9 +199,9 @@ typedef struct _tableInfo bool *attisserial; /* true if attr is serial or bigserial */ /* - * Note: we need to store per-attribute notnull, default, and - * constraint stuff for all interesting tables so that we can tell - * which constraints were inherited. + * Note: we need to store per-attribute notnull, default, and constraint + * stuff for all interesting tables so that we can tell which constraints + * were inherited. */ bool *notnull; /* Not null constraints on attributes */ struct _attrDefInfo **attrdefs; /* DEFAULT expressions */ diff --git a/src/bin/pg_dump/pg_dump_sort.c b/src/bin/pg_dump/pg_dump_sort.c index b3029988a4..7e91d9bb79 100644 --- a/src/bin/pg_dump/pg_dump_sort.c +++ b/src/bin/pg_dump/pg_dump_sort.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump_sort.c,v 1.10 2005/06/30 03:03:04 tgl Exp $ + * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump_sort.c,v 1.11 2005/10/15 02:49:39 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -128,8 +128,8 @@ DOTypeNameCompare(const void *p1, const void *p2) /* * Sort by namespace. Note that all objects of the same type should - * either have or not have a namespace link, so we needn't be fancy - * about cases where one link is null and the other not. + * either have or not have a namespace link, so we needn't be fancy about + * cases where one link is null and the other not. */ if (obj1->namespace && obj2->namespace) { @@ -248,17 +248,16 @@ TopoSort(DumpableObject **objs, k; /* - * This is basically the same algorithm shown for topological sorting - * in Knuth's Volume 1. However, we would like to minimize - * unnecessary rearrangement of the input ordering; that is, when we - * have a choice of which item to output next, we always want to take - * the one highest in the original list. Therefore, instead of - * maintaining an unordered linked list of items-ready-to-output as - * Knuth does, we maintain a heap of their item numbers, which we can - * use as a priority queue. This turns the algorithm from O(N) to O(N - * log N) because each insertion or removal of a heap item takes O(log - * N) time. However, that's still plenty fast enough for this - * application. + * This is basically the same algorithm shown for topological sorting in + * Knuth's Volume 1. However, we would like to minimize unnecessary + * rearrangement of the input ordering; that is, when we have a choice of + * which item to output next, we always want to take the one highest in + * the original list. Therefore, instead of maintaining an unordered + * linked list of items-ready-to-output as Knuth does, we maintain a heap + * of their item numbers, which we can use as a priority queue. This + * turns the algorithm from O(N) to O(N log N) because each insertion or + * removal of a heap item takes O(log N) time. However, that's still + * plenty fast enough for this application. */ *nOrdering = numObjs; /* for success return */ @@ -273,11 +272,11 @@ TopoSort(DumpableObject **objs, exit_horribly(NULL, modulename, "out of memory\n"); /* - * Scan the constraints, and for each item in the input, generate a - * count of the number of constraints that say it must be before - * something else. The count for the item with dumpId j is stored in - * beforeConstraints[j]. We also make a map showing the input-order - * index of the item with dumpId j. + * Scan the constraints, and for each item in the input, generate a count + * of the number of constraints that say it must be before something else. + * The count for the item with dumpId j is stored in beforeConstraints[j]. + * We also make a map showing the input-order index of the item with + * dumpId j. */ beforeConstraints = (int *) malloc((maxDumpId + 1) * sizeof(int)); if (beforeConstraints == NULL) @@ -303,16 +302,15 @@ TopoSort(DumpableObject **objs, } /* - * Now initialize the heap of items-ready-to-output by filling it with - * the indexes of items that already have beforeConstraints[id] == 0. + * Now initialize the heap of items-ready-to-output by filling it with the + * indexes of items that already have beforeConstraints[id] == 0. * - * The essential property of a heap is heap[(j-1)/2] >= heap[j] for each - * j in the range 1..heapLength-1 (note we are using 0-based - * subscripts here, while the discussion in Knuth assumes 1-based - * subscripts). So, if we simply enter the indexes into pendingHeap[] - * in decreasing order, we a-fortiori have the heap invariant - * satisfied at completion of this loop, and don't need to do any - * sift-up comparisons. + * The essential property of a heap is heap[(j-1)/2] >= heap[j] for each j in + * the range 1..heapLength-1 (note we are using 0-based subscripts here, + * while the discussion in Knuth assumes 1-based subscripts). So, if we + * simply enter the indexes into pendingHeap[] in decreasing order, we + * a-fortiori have the heap invariant satisfied at completion of this + * loop, and don't need to do any sift-up comparisons. */ heapLength = 0; for (i = numObjs; --i >= 0;) @@ -355,8 +353,8 @@ TopoSort(DumpableObject **objs, } /* - * If we failed, report the objects that couldn't be output; these are - * the ones with beforeConstraints[] still nonzero. + * If we failed, report the objects that couldn't be output; these are the + * ones with beforeConstraints[] still nonzero. */ if (i != 0) { @@ -389,8 +387,8 @@ addHeapElement(int val, int *heap, int heapLength) int j; /* - * Sift-up the new entry, per Knuth 5.2.3 exercise 16. Note that Knuth - * is using 1-based array indexes, not 0-based. + * Sift-up the new entry, per Knuth 5.2.3 exercise 16. Note that Knuth is + * using 1-based array indexes, not 0-based. */ j = heapLength; while (j > 0) @@ -464,22 +462,20 @@ findDependencyLoops(DumpableObject **objs, int nObjs, int totObjs) { /* * We use a workspace array, the initial part of which stores objects - * already processed, and the rest of which is used as temporary space - * to try to build a loop in. This is convenient because we do not - * care about loops involving already-processed objects (see notes - * above); we can easily reject such loops in findLoop() because of - * this representation. After we identify and process a loop, we can - * add it to the initial part of the workspace just by moving the - * boundary pointer. + * already processed, and the rest of which is used as temporary space to + * try to build a loop in. This is convenient because we do not care + * about loops involving already-processed objects (see notes above); we + * can easily reject such loops in findLoop() because of this + * representation. After we identify and process a loop, we can add it to + * the initial part of the workspace just by moving the boundary pointer. * - * When we determine that an object is not part of any interesting loop, - * we also add it to the initial part of the workspace. This is not - * necessary for correctness, but saves later invocations of - * findLoop() from uselessly chasing references to such an object. + * When we determine that an object is not part of any interesting loop, we + * also add it to the initial part of the workspace. This is not + * necessary for correctness, but saves later invocations of findLoop() + * from uselessly chasing references to such an object. * * We make the workspace large enough to hold all objects in the original - * universe. This is probably overkill, but it's provably enough - * space... + * universe. This is probably overkill, but it's provably enough space... */ DumpableObject **workspace; int initiallen; @@ -510,10 +506,10 @@ findDependencyLoops(DumpableObject **objs, int nObjs, int totObjs) else { /* - * Didn't find a loop, but add this object to workspace - * anyway, unless it's already present. We piggyback on the - * test that findLoop() already did: it won't have tentatively - * added obj to workspace if it's already present. + * Didn't find a loop, but add this object to workspace anyway, + * unless it's already present. We piggyback on the test that + * findLoop() already did: it won't have tentatively added obj to + * workspace if it's already present. */ if (workspace[initiallen] == obj) initiallen++; @@ -553,8 +549,8 @@ findLoop(DumpableObject *obj, int i; /* - * Reject if obj is already present in workspace. This test serves - * three purposes: it prevents us from finding loops that overlap + * Reject if obj is already present in workspace. This test serves three + * purposes: it prevents us from finding loops that overlap * previously-processed loops, it prevents us from going into infinite * recursion if we are given a startPoint object that links to a cycle * it's not a member of, and it guarantees that we can't overflow the @@ -572,8 +568,7 @@ findLoop(DumpableObject *obj, workspace[depth++] = obj; /* - * See if we've found a loop back to the desired startPoint; if so, - * done + * See if we've found a loop back to the desired startPoint; if so, done */ for (i = 0; i < obj->nDeps; i++) { @@ -630,10 +625,10 @@ repairTypeFuncLoop(DumpableObject *typeobj, DumpableObject *funcobj) addObjectDependency(funcobj, inputFuncInfo->dobj.dumpId); /* - * Make sure the input function's dependency on type gets removed too; - * if it hasn't been done yet, we'd end up with loops involving the - * type and two or more functions, which repairDependencyLoop() is not - * smart enough to handle. + * Make sure the input function's dependency on type gets removed too; if + * it hasn't been done yet, we'd end up with loops involving the type and + * two or more functions, which repairDependencyLoop() is not smart enough + * to handle. */ removeObjectDependency(&inputFuncInfo->dobj, typeobj->dumpId); } @@ -951,8 +946,8 @@ repairDependencyLoop(DumpableObject **loop, } /* - * If we can't find a principled way to break the loop, complain and - * break it in an arbitrary fashion. + * If we can't find a principled way to break the loop, complain and break + * it in an arbitrary fashion. */ write_msg(modulename, "WARNING: could not resolve dependency loop among these items:\n"); for (i = 0; i < nLoop; i++) diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c index 1c55d5e0c1..d74e42fba5 100644 --- a/src/bin/pg_dump/pg_dumpall.c +++ b/src/bin/pg_dump/pg_dumpall.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * - * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.68 2005/10/10 22:29:48 tgl Exp $ + * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.69 2005/10/15 02:49:39 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -55,21 +55,22 @@ static void dumpTimestamp(char *msg); static int runPgDump(const char *dbname); static PGconn *connectDatabase(const char *dbname, const char *pghost, const char *pgport, - const char *pguser, bool require_password, bool fail_on_error); + const char *pguser, bool require_password, bool fail_on_error); static PGresult *executeQuery(PGconn *conn, const char *query); static void executeCommand(PGconn *conn, const char *query); -static char pg_dump_bin[MAXPGPATH]; +static char pg_dump_bin[MAXPGPATH]; static PQExpBuffer pgdumpopts; -static bool output_clean = false; -static bool skip_acls = false; -static bool verbose = false; -static bool ignoreVersion = false; +static bool output_clean = false; +static bool skip_acls = false; +static bool verbose = false; +static bool ignoreVersion = false; + /* flags for -X long options */ -static int disable_dollar_quoting = 0; -static int disable_triggers = 0; -static int use_setsessauth = 0; -static int server_version; +static int disable_dollar_quoting = 0; +static int disable_triggers = 0; +static int use_setsessauth = 0; +static int server_version; int @@ -107,8 +108,8 @@ main(int argc, char *argv[]) {"no-acl", no_argument, NULL, 'x'}, /* - * the following options don't have an equivalent short option - * letter, but are available as '-X long-name' + * the following options don't have an equivalent short option letter, + * but are available as '-X long-name' */ {"disable-dollar-quoting", no_argument, &disable_dollar_quoting, 1}, {"disable-triggers", no_argument, &disable_triggers, 1}, @@ -140,7 +141,7 @@ main(int argc, char *argv[]) if ((ret = find_other_exec(argv[0], "pg_dump", PG_VERSIONSTR, pg_dump_bin)) < 0) { - char full_path[MAXPGPATH]; + char full_path[MAXPGPATH]; if (find_my_exec(argv[0], full_path) < 0) StrNCpy(full_path, progname, MAXPGPATH); @@ -190,7 +191,7 @@ main(int argc, char *argv[]) #ifndef WIN32 appendPQExpBuffer(pgdumpopts, " -h '%s'", pghost); #else - appendPQExpBuffer(pgdumpopts, " -h \"%s\"", pghost); + appendPQExpBuffer(pgdumpopts, " -h \"%s\"", pghost); #endif break; @@ -213,7 +214,7 @@ main(int argc, char *argv[]) #ifndef WIN32 appendPQExpBuffer(pgdumpopts, " -p '%s'", pgport); #else - appendPQExpBuffer(pgdumpopts, " -p \"%s\"", pgport); + appendPQExpBuffer(pgdumpopts, " -p \"%s\"", pgport); #endif break; @@ -226,7 +227,7 @@ main(int argc, char *argv[]) #ifndef WIN32 appendPQExpBuffer(pgdumpopts, " -S '%s'", optarg); #else - appendPQExpBuffer(pgdumpopts, " -S \"%s\"", optarg); + appendPQExpBuffer(pgdumpopts, " -S \"%s\"", optarg); #endif break; @@ -235,7 +236,7 @@ main(int argc, char *argv[]) #ifndef WIN32 appendPQExpBuffer(pgdumpopts, " -U '%s'", pguser); #else - appendPQExpBuffer(pgdumpopts, " -U \"%s\"", pguser); + appendPQExpBuffer(pgdumpopts, " -U \"%s\"", pguser); #endif break; @@ -473,9 +474,9 @@ dumpRoles(PGconn *conn) appendPQExpBuffer(buf, "DROP ROLE %s;\n", fmtId(rolename)); /* - * We dump CREATE ROLE followed by ALTER ROLE to ensure that the - * role will acquire the right properties even if it already exists. - * (The above DROP may therefore seem redundant, but it isn't really, + * We dump CREATE ROLE followed by ALTER ROLE to ensure that the role + * will acquire the right properties even if it already exists. (The + * above DROP may therefore seem redundant, but it isn't really, * because this technique doesn't get rid of role memberships.) */ appendPQExpBuffer(buf, "CREATE ROLE %s;\n", fmtId(rolename)); @@ -614,7 +615,7 @@ dumpGroups(PGconn *conn) int j; printfPQExpBuffer(buf, - "SELECT usename FROM pg_shadow WHERE usesysid = %s", + "SELECT usename FROM pg_shadow WHERE usesysid = %s", tok); res2 = executeQuery(conn, buf->data); @@ -729,7 +730,7 @@ dumpCreateDB(PGconn *conn) "pg_encoding_to_char(d.encoding), " "datistemplate, datacl, datconnlimit, " "(SELECT spcname FROM pg_tablespace t WHERE t.oid = d.dattablespace) AS dattablespace " - "FROM pg_database d LEFT JOIN pg_authid u ON (datdba = u.oid) " + "FROM pg_database d LEFT JOIN pg_authid u ON (datdba = u.oid) " "WHERE datallowconn ORDER BY 1"); else if (server_version >= 80000) res = executeQuery(conn, @@ -738,7 +739,7 @@ dumpCreateDB(PGconn *conn) "pg_encoding_to_char(d.encoding), " "datistemplate, datacl, -1 as datconnlimit, " "(SELECT spcname FROM pg_tablespace t WHERE t.oid = d.dattablespace) AS dattablespace " - "FROM pg_database d LEFT JOIN pg_shadow u ON (datdba = usesysid) " + "FROM pg_database d LEFT JOIN pg_shadow u ON (datdba = usesysid) " "WHERE datallowconn ORDER BY 1"); else if (server_version >= 70300) res = executeQuery(conn, @@ -747,13 +748,13 @@ dumpCreateDB(PGconn *conn) "pg_encoding_to_char(d.encoding), " "datistemplate, datacl, -1 as datconnlimit, " "'pg_default' AS dattablespace " - "FROM pg_database d LEFT JOIN pg_shadow u ON (datdba = usesysid) " + "FROM pg_database d LEFT JOIN pg_shadow u ON (datdba = usesysid) " "WHERE datallowconn ORDER BY 1"); else if (server_version >= 70100) res = executeQuery(conn, "SELECT datname, " "coalesce(" - "(select usename from pg_shadow where usesysid=datdba), " + "(select usename from pg_shadow where usesysid=datdba), " "(select usename from pg_shadow where usesysid=(select datdba from pg_database where datname='template0'))), " "pg_encoding_to_char(d.encoding), " "datistemplate, '' as datacl, -1 as datconnlimit, " @@ -763,12 +764,12 @@ dumpCreateDB(PGconn *conn) else { /* - * Note: 7.0 fails to cope with sub-select in COALESCE, so just - * deal with getting a NULL by not printing any OWNER clause. + * Note: 7.0 fails to cope with sub-select in COALESCE, so just deal + * with getting a NULL by not printing any OWNER clause. */ res = executeQuery(conn, "SELECT datname, " - "(select usename from pg_shadow where usesysid=datdba), " + "(select usename from pg_shadow where usesysid=datdba), " "pg_encoding_to_char(d.encoding), " "'f' as datistemplate, " "'' as datacl, -1 as datconnlimit, " @@ -953,8 +954,7 @@ makeAlterConfigCommand(const char *arrayitem, const char *type, const char *name appendPQExpBuffer(buf, "SET %s TO ", fmtId(mine)); /* - * Some GUC variable names are 'LIST' type and hence must not be - * quoted. + * Some GUC variable names are 'LIST' type and hence must not be quoted. */ if (pg_strcasecmp(mine, "DateStyle") == 0 || pg_strcasecmp(mine, "search_path") == 0) @@ -1019,8 +1019,8 @@ runPgDump(const char *dbname) /* * Win32 has to use double-quotes for args, rather than single quotes. - * Strangely enough, this is the only place we pass a database name on - * the command line, except "postgres" which doesn't need quoting. + * Strangely enough, this is the only place we pass a database name on the + * command line, except "postgres" which doesn't need quoting. */ #ifndef WIN32 appendPQExpBuffer(cmd, "%s\"%s\" %s -Fp '", SYSTEMQUOTE, pg_dump_bin, @@ -1087,8 +1087,8 @@ connectDatabase(const char *dbname, const char *pghost, const char *pgport, password = simple_prompt("Password: ", 100, false); /* - * Start the connection. Loop until we have a password if requested - * by backend. + * Start the connection. Loop until we have a password if requested by + * backend. */ do { @@ -1155,7 +1155,7 @@ connectDatabase(const char *dbname, const char *pghost, const char *pgport, } if (my_version != server_version - && (server_version < 70000 /* we can handle back to 7.0 */ + && (server_version < 70000 /* we can handle back to 7.0 */ || server_version > my_version)) { fprintf(stderr, _("server version: %s; %s version: %s\n"), @@ -1170,8 +1170,8 @@ connectDatabase(const char *dbname, const char *pghost, const char *pgport, } /* - * On 7.3 and later, make sure we are not fooled by non-system schemas - * in the search path. + * On 7.3 and later, make sure we are not fooled by non-system schemas in + * the search path. */ if (server_version >= 70300) executeCommand(conn, "SET search_path = pg_catalog"); diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c index 85eca07ee7..c40ee7bbec 100644 --- a/src/bin/pg_dump/pg_restore.c +++ b/src/bin/pg_dump/pg_restore.c @@ -34,7 +34,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/bin/pg_dump/pg_restore.c,v 1.72 2005/09/28 13:11:26 petere Exp $ + * $PostgreSQL: pgsql/src/bin/pg_dump/pg_restore.c,v 1.73 2005/10/15 02:49:39 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -113,8 +113,8 @@ main(int argc, char **argv) {"verbose", 0, NULL, 'v'}, /* - * the following options don't have an equivalent short option - * letter, but are available as '-X long-name' + * the following options don't have an equivalent short option letter, + * but are available as '-X long-name' */ {"use-set-session-authorization", no_argument, &use_setsessauth, 1}, {"disable-triggers", no_argument, &disable_triggers, 1}, @@ -150,8 +150,7 @@ main(int argc, char **argv) case 'a': /* Dump data only */ opts->dataOnly = 1; break; - case 'c': /* clean (i.e., drop) schema prior to - * create */ + case 'c': /* clean (i.e., drop) schema prior to create */ opts->dropSchema = 1; break; case 'C': @@ -331,8 +330,7 @@ main(int argc, char **argv) AH->verbose = opts->verbose; /* - * Whether to keep submitting sql commands as "pg_restore ... | psql - * ... " + * Whether to keep submitting sql commands as "pg_restore ... | psql ... " */ AH->exit_on_error = opts->exit_on_error; diff --git a/src/bin/pg_resetxlog/pg_resetxlog.c b/src/bin/pg_resetxlog/pg_resetxlog.c index 5ee0a2749a..d70b0bb95e 100644 --- a/src/bin/pg_resetxlog/pg_resetxlog.c +++ b/src/bin/pg_resetxlog/pg_resetxlog.c @@ -23,7 +23,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v 1.37 2005/10/03 00:28:42 tgl Exp $ + * $PostgreSQL: pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v 1.38 2005/10/15 02:49:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -73,7 +73,7 @@ main(int argc, char *argv[]) bool noupdate = false; TransactionId set_xid = 0; Oid set_oid = 0; - MultiXactId set_mxid = 0; + MultiXactId set_mxid = 0; MultiXactOffset set_mxoff = -1; uint32 minXlogTli = 0, minXlogId = 0, @@ -213,11 +213,11 @@ main(int argc, char *argv[]) exit(1); } - /* - * Don't allow pg_resetxlog to be run as root, to avoid - * overwriting the ownership of files in the data directory. We - * need only check for root -- any other user won't have - * sufficient permissions to modify files in the data directory. + /* + * Don't allow pg_resetxlog to be run as root, to avoid overwriting the + * ownership of files in the data directory. We need only check for root + * -- any other user won't have sufficient permissions to modify files in + * the data directory. */ #ifndef WIN32 #ifndef __BEOS__ /* no root check on BeOS */ @@ -243,8 +243,7 @@ main(int argc, char *argv[]) /* * Check for a postmaster lock file --- if there is one, refuse to - * proceed, on grounds we might be interfering with a live - * installation. + * proceed, on grounds we might be interfering with a live installation. */ snprintf(path, MAXPGPATH, "%s/postmaster.pid", DataDir); @@ -271,8 +270,8 @@ main(int argc, char *argv[]) GuessControlValues(); /* - * Adjust fields if required by switches. (Do this now so that - * printout, if any, includes these values.) + * Adjust fields if required by switches. (Do this now so that printout, + * if any, includes these values.) */ if (set_xid != 0) ControlFile.checkPointCopy.nextXid = set_xid; @@ -319,8 +318,8 @@ main(int argc, char *argv[]) if (ControlFile.state != DB_SHUTDOWNED && !force) { printf(_("The database server was not shut down cleanly.\n" - "Resetting the transaction log may cause data to be lost.\n" - "If you want to proceed anyway, use -f to force reset.\n")); + "Resetting the transaction log may cause data to be lost.\n" + "If you want to proceed anyway, use -f to force reset.\n")); exit(1); } @@ -353,9 +352,9 @@ ReadControlFile(void) if ((fd = open(XLOG_CONTROL_FILE, O_RDONLY)) < 0) { /* - * If pg_control is not there at all, or we can't read it, the - * odds are we've been handed a bad DataDir path, so give up. User - * can do "touch pg_control" to force us to proceed. + * If pg_control is not there at all, or we can't read it, the odds + * are we've been handed a bad DataDir path, so give up. User can do + * "touch pg_control" to force us to proceed. */ fprintf(stderr, _("%s: could not open file \"%s\" for reading: %s\n"), progname, XLOG_CONTROL_FILE, strerror(errno)); @@ -380,7 +379,7 @@ ReadControlFile(void) close(fd); if (len >= sizeof(ControlFileData) && - ((ControlFileData *) buffer)->pg_control_version == PG_CONTROL_VERSION) + ((ControlFileData *) buffer)->pg_control_version == PG_CONTROL_VERSION) { /* Check the CRC. */ INIT_CRC32(crc); @@ -431,8 +430,8 @@ GuessControlValues(void) ControlFile.catalog_version_no = CATALOG_VERSION_NO; /* - * Create a new unique installation identifier, since we can no longer - * use any old XLOG records. See notes in xlog.c about the algorithm. + * Create a new unique installation identifier, since we can no longer use + * any old XLOG records. See notes in xlog.c about the algorithm. */ gettimeofday(&tv, NULL); sysidentifier = ((uint64) tv.tv_sec) << 32; @@ -486,8 +485,8 @@ GuessControlValues(void) StrNCpy(ControlFile.lc_ctype, localeptr, LOCALE_NAME_BUFLEN); /* - * XXX eventually, should try to grovel through old XLOG to develop - * more accurate values for TimeLineID, nextXID, etc. + * XXX eventually, should try to grovel through old XLOG to develop more + * accurate values for TimeLineID, nextXID, etc. */ } @@ -509,8 +508,8 @@ PrintControlValues(bool guessed) printf(_("pg_control values:\n\n")); /* - * Format system_identifier separately to keep platform-dependent - * format code out of the translatable message string. + * Format system_identifier separately to keep platform-dependent format + * code out of the translatable message string. */ snprintf(sysident_str, sizeof(sysident_str), UINT64_FORMAT, ControlFile.system_identifier); @@ -587,11 +586,11 @@ RewriteControlFile(void) FIN_CRC32(ControlFile.crc); /* - * We write out BLCKSZ bytes into pg_control, zero-padding the excess - * over sizeof(ControlFileData). This reduces the odds of - * premature-EOF errors when reading pg_control. We'll still fail - * when we check the contents of the file, but hopefully with a more - * specific error than "couldn't read pg_control". + * We write out BLCKSZ bytes into pg_control, zero-padding the excess over + * sizeof(ControlFileData). This reduces the odds of premature-EOF errors + * when reading pg_control. We'll still fail when we check the contents + * of the file, but hopefully with a more specific error than "couldn't + * read pg_control". */ if (sizeof(ControlFileData) > BLCKSZ) { @@ -674,8 +673,8 @@ KillExistingXLOG(void) #ifdef WIN32 /* - * This fix is in mingw cvs (runtime/mingwex/dirent.c rev 1.4), but - * not in released version + * This fix is in mingw cvs (runtime/mingwex/dirent.c rev 1.4), but not in + * released version */ if (GetLastError() == ERROR_NO_MORE_FILES) errno = 0; diff --git a/src/bin/pgevent/pgevent.c b/src/bin/pgevent/pgevent.c index d91840f99f..6ad93e55fd 100644 --- a/src/bin/pgevent/pgevent.c +++ b/src/bin/pgevent/pgevent.c @@ -6,7 +6,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/bin/pgevent/pgevent.c,v 1.4 2004/09/27 19:16:01 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/pgevent/pgevent.c,v 1.5 2005/10/15 02:49:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -44,8 +44,8 @@ DllRegisterServer(void) } /* - * Add PostgreSQL source name as a subkey under the Application key in - * the EventLog registry key. + * Add PostgreSQL source name as a subkey under the Application key in the + * EventLog registry key. */ if (RegCreateKey(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\PostgreSQL", &key)) { @@ -91,8 +91,8 @@ STDAPI DllUnregisterServer(void) { /* - * Remove PostgreSQL source name as a subkey under the Application key - * in the EventLog registry key. + * Remove PostgreSQL source name as a subkey under the Application key in + * the EventLog registry key. */ if (RegDeleteKey(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\PostgreSQL")) diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index c9a9e966d2..d9f8dda595 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -3,12 +3,12 @@ * * Copyright (c) 2000-2005, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.153 2005/09/20 18:59:01 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.154 2005/10/15 02:49:40 momjian Exp $ */ #include "postgres_fe.h" #include "command.h" -#ifdef WIN32_CLIENT_ONLY /* needed for BCC */ +#ifdef WIN32_CLIENT_ONLY /* needed for BCC */ #undef mkdir #endif @@ -96,9 +96,9 @@ HandleSlashCmds(PsqlScanState scan_state, if (status == CMD_UNKNOWN && strlen(cmd) > 1) { /* - * If the command was not recognized, try to parse it as a - * one-letter command with immediately following argument (a - * still-supported, but no longer encouraged, syntax). + * If the command was not recognized, try to parse it as a one-letter + * command with immediately following argument (a still-supported, but + * no longer encouraged, syntax). */ char new_cmd[2]; @@ -205,13 +205,13 @@ exec_command(const char *cmd, opt2q; /* - * Ideally we should treat the arguments as SQL identifiers. But - * for backwards compatibility with 7.2 and older pg_dump files, - * we have to take unquoted arguments verbatim (don't downcase - * them). For now, double-quoted arguments may be stripped of - * double quotes (as if SQL identifiers). By 7.4 or so, pg_dump - * files can be expected to double-quote all mixed-case \connect - * arguments, and then we can get rid of OT_SQLIDHACK. + * Ideally we should treat the arguments as SQL identifiers. But for + * backwards compatibility with 7.2 and older pg_dump files, we have + * to take unquoted arguments verbatim (don't downcase them). For now, + * double-quoted arguments may be stripped of double quotes (as if SQL + * identifiers). By 7.4 or so, pg_dump files can be expected to + * double-quote all mixed-case \connect arguments, and then we can get + * rid of OT_SQLIDHACK. */ opt1 = psql_scan_slash_option(scan_state, OT_SQLIDHACK, &opt1q, true); @@ -284,7 +284,7 @@ exec_command(const char *cmd, else if (pg_strcasecmp(cmd, "copy") == 0) { char *opt = psql_scan_slash_option(scan_state, - OT_WHOLE_LINE, NULL, false); + OT_WHOLE_LINE, NULL, false); success = do_copy(opt); free(opt); @@ -377,8 +377,8 @@ exec_command(const char *cmd, /* - * \e or \edit -- edit the current query buffer (or a file and make it - * the query buffer + * \e or \edit -- edit the current query buffer (or a file and make it the + * query buffer */ else if (strcmp(cmd, "e") == 0 || strcmp(cmd, "edit") == 0) { @@ -416,7 +416,7 @@ exec_command(const char *cmd, fout = stdout; while ((value = psql_scan_slash_option(scan_state, - OT_NORMAL, "ed, false))) + OT_NORMAL, "ed, false))) { if (!quoted && strcmp(value, "-n") == 0) no_newline = true; @@ -438,7 +438,7 @@ exec_command(const char *cmd, else if (strcmp(cmd, "encoding") == 0) { char *encoding = psql_scan_slash_option(scan_state, - OT_NORMAL, NULL, false); + OT_NORMAL, NULL, false); if (!encoding) { @@ -466,7 +466,7 @@ exec_command(const char *cmd, else if (strcmp(cmd, "f") == 0) { char *fname = psql_scan_slash_option(scan_state, - OT_NORMAL, NULL, false); + OT_NORMAL, NULL, false); success = do_pset("fieldsep", fname, &pset.popt, quiet); free(fname); @@ -476,7 +476,7 @@ exec_command(const char *cmd, else if (strcmp(cmd, "g") == 0) { char *fname = psql_scan_slash_option(scan_state, - OT_FILEPIPE, NULL, false); + OT_FILEPIPE, NULL, false); if (!fname) pset.gfname = NULL; @@ -493,7 +493,7 @@ exec_command(const char *cmd, else if (strcmp(cmd, "h") == 0 || strcmp(cmd, "help") == 0) { char *opt = psql_scan_slash_option(scan_state, - OT_WHOLE_LINE, NULL, false); + OT_WHOLE_LINE, NULL, false); helpSQL(opt, pset.popt.topt.pager); free(opt); @@ -601,7 +601,7 @@ exec_command(const char *cmd, else if (strcmp(cmd, "o") == 0 || strcmp(cmd, "out") == 0) { char *fname = psql_scan_slash_option(scan_state, - OT_FILEPIPE, NULL, true); + OT_FILEPIPE, NULL, true); expand_tilde(&fname); success = setQFout(fname); @@ -732,7 +732,7 @@ exec_command(const char *cmd, else if (strcmp(cmd, "T") == 0) { char *value = psql_scan_slash_option(scan_state, - OT_NORMAL, NULL, false); + OT_NORMAL, NULL, false); success = do_pset("tableattr", value, &pset.popt, quiet); free(value); @@ -843,7 +843,7 @@ exec_command(const char *cmd, else if (strcmp(cmd, "z") == 0) { char *pattern = psql_scan_slash_option(scan_state, - OT_NORMAL, NULL, true); + OT_NORMAL, NULL, true); success = permissionsList(pattern); if (pattern) @@ -854,7 +854,7 @@ exec_command(const char *cmd, else if (strcmp(cmd, "!") == 0) { char *opt = psql_scan_slash_option(scan_state, - OT_WHOLE_LINE, NULL, false); + OT_WHOLE_LINE, NULL, false); success = do_shell(opt); free(opt); @@ -867,8 +867,7 @@ exec_command(const char *cmd, #if 0 /* - * These commands don't do anything. I just use them to test the - * parser. + * These commands don't do anything. I just use them to test the parser. */ else if (strcmp(cmd, "void") == 0 || strcmp(cmd, "#") == 0) { @@ -912,7 +911,7 @@ do_connect(const char *new_dbname, const char *new_user) const char *dbparam = NULL; const char *userparam = NULL; const char *pwparam = NULL; - char *password_prompt = NULL; + char *password_prompt = NULL; char *prompted_password = NULL; bool need_pass; bool success = false; @@ -932,13 +931,13 @@ do_connect(const char *new_dbname, const char *new_user) else userparam = new_user; - if (userparam == NULL) + if (userparam == NULL) password_prompt = strdup("Password: "); else { password_prompt = malloc(strlen("Password for user %s: ") - 2 + strlen(userparam) + 1); - sprintf(password_prompt,"Password for user %s: ", userparam); + sprintf(password_prompt, "Password for user %s: ", userparam); } /* need to prompt for password? */ @@ -946,8 +945,8 @@ do_connect(const char *new_dbname, const char *new_user) pwparam = prompted_password = simple_prompt(password_prompt, 100, false); /* - * Use old password (if any) if no new one given and we are - * reconnecting as same user + * Use old password (if any) if no new one given and we are reconnecting + * as same user */ if (!pwparam && oldconn && PQuser(oldconn) && userparam && strcmp(PQuser(oldconn), userparam) == 0) @@ -975,8 +974,8 @@ do_connect(const char *new_dbname, const char *new_user) free(password_prompt); /* - * If connection failed, try at least keep the old one. That's - * probably more convenient than just kicking you out of the program. + * If connection failed, try at least keep the old one. That's probably + * more convenient than just kicking you out of the program. */ if (!pset.db || PQstatus(pset.db) == CONNECTION_BAD) { @@ -995,8 +994,7 @@ do_connect(const char *new_dbname, const char *new_user) else { /* - * we don't want unpredictable things to happen in scripting - * mode + * we don't want unpredictable things to happen in scripting mode */ psql_error("\\connect: %s", PQerrorMessage(pset.db)); PQfinish(pset.db); @@ -1175,28 +1173,29 @@ do_edit(const char *filename_arg, PQExpBuffer query_buf) if (!tmpdir) tmpdir = "/tmp"; #else - char tmpdir[MAXPGPATH]; - int ret; + char tmpdir[MAXPGPATH]; + int ret; ret = GetTempPath(MAXPGPATH, tmpdir); if (ret == 0 || ret > MAXPGPATH) { psql_error("cannot locate temporary directory: %s", - !ret ? strerror(errno) : ""); + !ret ? strerror(errno) : ""); return false; } + /* - * No canonicalize_path() here. - * EDIT.EXE run from CMD.EXE prepends the current directory to the - * supplied path unless we use only backslashes, so we do that. + * No canonicalize_path() here. EDIT.EXE run from CMD.EXE prepends the + * current directory to the supplied path unless we use only + * backslashes, so we do that. */ #endif #ifndef WIN32 snprintf(fnametmp, sizeof(fnametmp), "%s%spsql.edit.%d", tmpdir, - "/", (int)getpid()); + "/", (int) getpid()); #else snprintf(fnametmp, sizeof(fnametmp), "%s%spsql.edit.%d", tmpdir, - "" /* trailing separator already present */, (int)getpid()); + "" /* trailing separator already present */ , (int) getpid()); #endif fname = (const char *) fnametmp; diff --git a/src/bin/psql/common.c b/src/bin/psql/common.c index 886bcde178..2999c169ef 100644 --- a/src/bin/psql/common.c +++ b/src/bin/psql/common.c @@ -3,7 +3,7 @@ * * Copyright (c) 2000-2005, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.107 2005/10/13 20:58:42 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.108 2005/10/15 02:49:40 momjian Exp $ */ #include "postgres_fe.h" #include "common.h" @@ -48,7 +48,6 @@ typedef struct timeval TimevalStruct; #define DIFF_MSEC(T, U) \ ((((int) ((T)->tv_sec - (U)->tv_sec)) * 1000000.0 + \ ((int) ((T)->tv_usec - (U)->tv_usec))) / 1000.0) - #else typedef struct _timeb TimevalStruct; @@ -188,7 +187,7 @@ setQFout(const char *fname) * */ void -psql_error(const char *fmt, ...) +psql_error(const char *fmt,...) { va_list ap; @@ -233,6 +232,7 @@ NoticeProcessor(void *arg, const char *message) * thread is using it. */ static PGcancel *cancelConn = NULL; + #ifdef WIN32 static CRITICAL_SECTION cancelConnLock; #endif @@ -248,7 +248,7 @@ void handle_sigint(SIGNAL_ARGS) { int save_errno = errno; - char errbuf[256]; + char errbuf[256]; /* Don't muck around if prompting for a password. */ if (prompt_state) @@ -268,13 +268,12 @@ handle_sigint(SIGNAL_ARGS) } errno = save_errno; /* just in case the write changed it */ } - -#else /* WIN32 */ +#else /* WIN32 */ static BOOL WINAPI consoleHandler(DWORD dwCtrlType) { - char errbuf[256]; + char errbuf[256]; if (dwCtrlType == CTRL_C_EVENT || dwCtrlType == CTRL_BREAK_EVENT) @@ -316,8 +315,7 @@ setup_cancel_handler(void) { SetConsoleCtrlHandler(consoleHandler, TRUE); } - -#endif /* WIN32 */ +#endif /* WIN32 */ /* ConnectionUp @@ -478,12 +476,12 @@ ReportSyntaxErrorPosition(const PGresult *result, const char *query) initPQExpBuffer(&msg); /* - * The returned cursor position is measured in logical characters. - * Each character might occupy multiple physical bytes in the string, - * and in some Far Eastern character sets it might take more than one - * screen column as well. We compute the starting byte offset and - * starting screen column of each logical character, and store these - * in qidx[] and scridx[] respectively. + * The returned cursor position is measured in logical characters. Each + * character might occupy multiple physical bytes in the string, and in + * some Far Eastern character sets it might take more than one screen + * column as well. We compute the starting byte offset and starting + * screen column of each logical character, and store these in qidx[] and + * scridx[] respectively. */ /* we need a safe allocation size... */ @@ -521,12 +519,12 @@ ReportSyntaxErrorPosition(const PGresult *result, const char *query) /* * Replace tabs with spaces in the writable copy. (Later we might - * want to think about coping with their variable screen width, - * but not today.) + * want to think about coping with their variable screen width, but + * not today.) * - * Extract line number and begin and end indexes of line containing - * error location. There will not be any newlines or carriage - * returns in the selected extract. + * Extract line number and begin and end indexes of line containing error + * location. There will not be any newlines or carriage returns in + * the selected extract. */ for (i = 0; i < clen; i++) { @@ -540,8 +538,8 @@ ReportSyntaxErrorPosition(const PGresult *result, const char *query) if (i < loc) { /* - * count lines before loc. Each \r or \n counts - * as a line except when \r \n appear together. + * count lines before loc. Each \r or \n counts as a + * line except when \r \n appear together. */ if (wquery[qidx[i]] == '\r' || i == 0 || @@ -568,9 +566,9 @@ ReportSyntaxErrorPosition(const PGresult *result, const char *query) if (scridx[iend] - scridx[ibeg] > DISPLAY_SIZE) { /* - * We first truncate right if it is enough. This code might - * be off a space or so on enforcing MIN_RIGHT_CUT if there's - * a wide character right there, but that should be okay. + * We first truncate right if it is enough. This code might be + * off a space or so on enforcing MIN_RIGHT_CUT if there's a wide + * character right there, but that should be okay. */ if (scridx[ibeg] + DISPLAY_SIZE >= scridx[loc] + MIN_RIGHT_CUT) { @@ -682,6 +680,7 @@ AcceptResult(const PGresult *result, const char *query) if (!OK) { const char *error = PQerrorMessage(pset.db); + if (strlen(error)) psql_error("%s", error); @@ -957,13 +956,15 @@ PrintQueryResults(PGresult *results) bool SendQuery(const char *query) { - PGresult *results; - TimevalStruct before, after; - bool OK, on_error_rollback_savepoint = false; + PGresult *results; + TimevalStruct before, + after; + bool OK, + on_error_rollback_savepoint = false; PGTransactionStatusType transaction_status; - static bool on_error_rollback_warning = false; + static bool on_error_rollback_warning = false; const char *rollback_str; - + if (!pset.db) { psql_error("You are currently not connected to a database.\n"); @@ -975,8 +976,8 @@ SendQuery(const char *query) char buf[3]; printf(_("***(Single step mode: verify command)*******************************************\n" - "%s\n" - "***(press return to proceed or enter x and return to cancel)********************\n"), + "%s\n" + "***(press return to proceed or enter x and return to cancel)********************\n"), query); fflush(stdout); if (fgets(buf, sizeof(buf), stdin) != NULL) @@ -1019,8 +1020,8 @@ SendQuery(const char *query) } if (transaction_status == PQTRANS_INTRANS && - (rollback_str = GetVariable(pset.vars, "ON_ERROR_ROLLBACK")) != NULL && - /* !off and !interactive is 'on' */ + (rollback_str = GetVariable(pset.vars, "ON_ERROR_ROLLBACK")) != NULL && + /* !off and !interactive is 'on' */ pg_strcasecmp(rollback_str, "off") != 0 && (pset.cur_cmd_interactive || pg_strcasecmp(rollback_str, "interactive") != 0)) @@ -1076,14 +1077,14 @@ SendQuery(const char *query) results = NULL; else { - /* - * Do nothing if they are messing with savepoints themselves: - * If the user did RELEASE or ROLLBACK, our savepoint is gone. - * If they issued a SAVEPOINT, releasing ours would remove theirs. + /* + * Do nothing if they are messing with savepoints themselves: If + * the user did RELEASE or ROLLBACK, our savepoint is gone. If + * they issued a SAVEPOINT, releasing ours would remove theirs. */ if (strcmp(PQcmdStatus(results), "SAVEPOINT") == 0 || strcmp(PQcmdStatus(results), "RELEASE") == 0 || - strcmp(PQcmdStatus(results), "ROLLBACK") ==0) + strcmp(PQcmdStatus(results), "ROLLBACK") == 0) results = NULL; else results = PQexec(pset.db, "RELEASE pg_psql_temporary_savepoint"); @@ -1126,19 +1127,19 @@ SendQuery(const char *query) static const char * skip_white_space(const char *query) { - int cnestlevel = 0; /* slash-star comment nest level */ + int cnestlevel = 0; /* slash-star comment nest level */ while (*query) { - int mblen = PQmblen(query, pset.encoding); + int mblen = PQmblen(query, pset.encoding); /* - * Note: we assume the encoding is a superset of ASCII, so that - * for example "query[0] == '/'" is meaningful. However, we do NOT - * assume that the second and subsequent bytes of a multibyte - * character couldn't look like ASCII characters; so it is critical - * to advance by mblen, not 1, whenever we haven't exactly identified - * the character we are skipping over. + * Note: we assume the encoding is a superset of ASCII, so that for + * example "query[0] == '/'" is meaningful. However, we do NOT assume + * that the second and subsequent bytes of a multibyte character + * couldn't look like ASCII characters; so it is critical to advance + * by mblen, not 1, whenever we haven't exactly identified the + * character we are skipping over. */ if (isspace((unsigned char) *query)) query += mblen; @@ -1155,9 +1156,10 @@ skip_white_space(const char *query) else if (cnestlevel == 0 && query[0] == '-' && query[1] == '-') { query += 2; + /* - * We have to skip to end of line since any slash-star inside - * the -- comment does NOT start a slash-star comment. + * We have to skip to end of line since any slash-star inside the + * -- comment does NOT start a slash-star comment. */ while (*query) { @@ -1204,12 +1206,12 @@ command_no_begin(const char *query) wordlen += PQmblen(&query[wordlen], pset.encoding); /* - * Transaction control commands. These should include every keyword - * that gives rise to a TransactionStmt in the backend grammar, except - * for the savepoint-related commands. + * Transaction control commands. These should include every keyword that + * gives rise to a TransactionStmt in the backend grammar, except for the + * savepoint-related commands. * - * (We assume that START must be START TRANSACTION, since there is - * presently no other "START foo" command.) + * (We assume that START must be START TRANSACTION, since there is presently + * no other "START foo" command.) */ if (wordlen == 5 && pg_strncasecmp(query, "abort", 5) == 0) return true; @@ -1240,12 +1242,12 @@ command_no_begin(const char *query) } /* - * Commands not allowed within transactions. The statements checked - * for here should be exactly those that call PreventTransactionChain() - * in the backend. + * Commands not allowed within transactions. The statements checked for + * here should be exactly those that call PreventTransactionChain() in the + * backend. * - * Note: we are a bit sloppy about CLUSTER, which is transactional in - * some variants but not others. + * Note: we are a bit sloppy about CLUSTER, which is transactional in some + * variants but not others. */ if (wordlen == 6 && pg_strncasecmp(query, "vacuum", 6) == 0) return true; @@ -1253,9 +1255,9 @@ command_no_begin(const char *query) return true; /* - * Note: these tests will match CREATE SYSTEM, DROP SYSTEM, and - * REINDEX TABLESPACE, which aren't really valid commands so we don't - * care much. The other six possible matches are correct. + * Note: these tests will match CREATE SYSTEM, DROP SYSTEM, and REINDEX + * TABLESPACE, which aren't really valid commands so we don't care much. + * The other six possible matches are correct. */ if ((wordlen == 6 && pg_strncasecmp(query, "create", 6) == 0) || (wordlen == 4 && pg_strncasecmp(query, "drop", 4) == 0) || @@ -1339,9 +1341,9 @@ expand_tilde(char **filename) return NULL; /* - * WIN32 doesn't use tilde expansion for file names. - * Also, it uses tilde for short versions of long file names, - * though the tilde is usually toward the end, not at the beginning. + * WIN32 doesn't use tilde expansion for file names. Also, it uses tilde + * for short versions of long file names, though the tilde is usually + * toward the end, not at the beginning. */ #ifndef WIN32 @@ -1367,7 +1369,7 @@ expand_tilde(char **filename) if (*(fn + 1) == '\0') get_home_path(home); /* ~ or ~/ only */ else if ((pw = getpwnam(fn + 1)) != NULL) - StrNCpy(home, pw->pw_dir, MAXPGPATH); /* ~user */ + StrNCpy(home, pw->pw_dir, MAXPGPATH); /* ~user */ *p = oldp; if (strlen(home) != 0) diff --git a/src/bin/psql/common.h b/src/bin/psql/common.h index e819a23409..413dcce0c1 100644 --- a/src/bin/psql/common.h +++ b/src/bin/psql/common.h @@ -3,7 +3,7 @@ * * Copyright (c) 2000-2005, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/common.h,v 1.44 2005/06/13 06:36:22 neilc Exp $ + * $PostgreSQL: pgsql/src/bin/psql/common.h,v 1.45 2005/10/15 02:49:40 momjian Exp $ */ #ifndef COMMON_H #define COMMON_H @@ -35,7 +35,7 @@ extern void *pg_calloc(size_t nmemb, size_t size); extern bool setQFout(const char *fname); extern void -psql_error(const char *fmt, ...) +psql_error(const char *fmt,...) /* This lets gcc check the format string for consistency. */ __attribute__((format(printf, 1, 2))); diff --git a/src/bin/psql/copy.c b/src/bin/psql/copy.c index 0ebe248b0c..bd1763c5ac 100644 --- a/src/bin/psql/copy.c +++ b/src/bin/psql/copy.c @@ -3,7 +3,7 @@ * * Copyright (c) 2000-2005, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.57 2005/05/07 02:22:49 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.58 2005/10/15 02:49:40 momjian Exp $ */ #include "postgres_fe.h" #include "copy.h" @@ -66,7 +66,7 @@ struct copy_options bool binary; bool oids; bool csv_mode; - bool header; + bool header; char *delim; char *null; char *quote; @@ -151,9 +151,8 @@ parse_slash_copy(const char *args) goto error; /* - * strtokx() will not have returned a multi-character token starting - * with '.', so we don't need strcmp() here. Likewise for '(', etc, - * below. + * strtokx() will not have returned a multi-character token starting with + * '.', so we don't need strcmp() here. Likewise for '(', etc, below. */ if (token[0] == '.') { @@ -272,8 +271,8 @@ parse_slash_copy(const char *args) if (token) { /* - * WITH is optional. Also, the backend will allow WITH followed - * by nothing, so we do too. + * WITH is optional. Also, the backend will allow WITH followed by + * nothing, so we do too. */ if (pg_strcasecmp(token, "with") == 0) token = strtokx(NULL, whitespace, NULL, NULL, @@ -672,7 +671,7 @@ handleCopyIn(PGconn *conn, FILE *copystream) { if (!QUIET()) puts(_("Enter data to be copied followed by a newline.\n" - "End with a backslash and a period on a line by itself.")); + "End with a backslash and a period on a line by itself.")); prompt = get_prompt(PROMPT_COPY); } else @@ -714,8 +713,8 @@ handleCopyIn(PGconn *conn, FILE *copystream) if (c == EOF && s == copybuf && firstload) { /* - * We are guessing a little bit as to the right - * line-ending here... + * We are guessing a little bit as to the right line-ending + * here... */ if (saw_cr) PQputline(conn, "\\.\r\n"); diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 9cd9858a71..d146b441f7 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,7 +3,7 @@ * * Copyright (c) 2000-2005, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.126 2005/10/04 19:01:18 petere Exp $ + * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.127 2005/10/15 02:49:40 momjian Exp $ */ #include "postgres_fe.h" #include "describe.h" @@ -37,8 +37,8 @@ static void processNamePattern(PQExpBuffer buf, const char *pattern, const char *schemavar, const char *namevar, const char *altnamevar, const char *visibilityrule); -static bool add_tablespace_footer(char relkind, Oid tablespace, char **footers, - int *count, PQExpBufferData buf, bool newline); +static bool add_tablespace_footer(char relkind, Oid tablespace, char **footers, + int *count, PQExpBufferData buf, bool newline); /*---------------- * Handlers for various slash commands displaying some sort of list @@ -62,20 +62,20 @@ describeAggregates(const char *pattern, bool verbose) initPQExpBuffer(&buf); /* - * There are two kinds of aggregates: ones that work on particular - * types and ones that work on all (denoted by input type = "any") + * There are two kinds of aggregates: ones that work on particular types + * and ones that work on all (denoted by input type = "any") */ printfPQExpBuffer(&buf, "SELECT n.nspname as \"%s\",\n" " p.proname AS \"%s\",\n" " CASE p.proargtypes[0]\n" - " WHEN 'pg_catalog.\"any\"'::pg_catalog.regtype\n" + " WHEN 'pg_catalog.\"any\"'::pg_catalog.regtype\n" " THEN CAST('%s' AS pg_catalog.text)\n" - " ELSE pg_catalog.format_type(p.proargtypes[0], NULL)\n" + " ELSE pg_catalog.format_type(p.proargtypes[0], NULL)\n" " END AS \"%s\",\n" - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" + " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" + " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.proisagg\n", _("Schema"), _("Name"), _("(all types)"), _("Data type"), _("Description")); @@ -121,7 +121,7 @@ describeTablespaces(const char *pattern, bool verbose) printfPQExpBuffer(&buf, "SELECT spcname AS \"%s\",\n" - " pg_catalog.pg_get_userbyid(spcowner) AS \"%s\",\n" + " pg_catalog.pg_get_userbyid(spcowner) AS \"%s\",\n" " spclocation AS \"%s\"", _("Name"), _("Owner"), _("Location")); @@ -170,9 +170,9 @@ describeFunctions(const char *pattern, bool verbose) "SELECT n.nspname as \"%s\",\n" " p.proname as \"%s\",\n" " CASE WHEN p.proretset THEN 'setof ' ELSE '' END ||\n" - " pg_catalog.format_type(p.prorettype, NULL) as \"%s\",\n" + " pg_catalog.format_type(p.prorettype, NULL) as \"%s\",\n" " pg_catalog.oidvectortypes(p.proargtypes) as \"%s\"", - _("Schema"), _("Name"), _("Result data type"), + _("Schema"), _("Name"), _("Result data type"), _("Argument data types")); if (verbose) @@ -180,7 +180,7 @@ describeFunctions(const char *pattern, bool verbose) ",\n r.rolname as \"%s\",\n" " l.lanname as \"%s\",\n" " p.prosrc as \"%s\",\n" - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"", + " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"", _("Owner"), _("Language"), _("Source code"), _("Description")); @@ -191,16 +191,15 @@ describeFunctions(const char *pattern, bool verbose) else appendPQExpBuffer(&buf, "\nFROM pg_catalog.pg_proc p" - "\n LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace" - "\n LEFT JOIN pg_catalog.pg_language l ON l.oid = p.prolang" - "\n LEFT JOIN pg_catalog.pg_roles r ON r.oid = p.proowner\n"); + "\n LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace" + "\n LEFT JOIN pg_catalog.pg_language l ON l.oid = p.prolang" + "\n LEFT JOIN pg_catalog.pg_roles r ON r.oid = p.proowner\n"); /* - * we skip in/out funcs by excluding functions that take or return - * cstring + * we skip in/out funcs by excluding functions that take or return cstring */ appendPQExpBuffer(&buf, - "WHERE p.prorettype <> 'pg_catalog.cstring'::pg_catalog.regtype\n" + "WHERE p.prorettype <> 'pg_catalog.cstring'::pg_catalog.regtype\n" " AND (p.proargtypes[0] IS NULL\n" " OR p.proargtypes[0] <> 'pg_catalog.cstring'::pg_catalog.regtype)\n" " AND NOT p.proisagg\n"); @@ -242,7 +241,7 @@ describeTypes(const char *pattern, bool verbose) printfPQExpBuffer(&buf, "SELECT n.nspname as \"%s\",\n" - " pg_catalog.format_type(t.oid, NULL) AS \"%s\",\n", + " pg_catalog.format_type(t.oid, NULL) AS \"%s\",\n", _("Schema"), _("Name")); if (verbose) appendPQExpBuffer(&buf, @@ -255,16 +254,15 @@ describeTypes(const char *pattern, bool verbose) " END AS \"%s\",\n", _("Internal name"), _("Size")); appendPQExpBuffer(&buf, - " pg_catalog.obj_description(t.oid, 'pg_type') as \"%s\"\n", + " pg_catalog.obj_description(t.oid, 'pg_type') as \"%s\"\n", _("Description")); appendPQExpBuffer(&buf, "FROM pg_catalog.pg_type t\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace\n"); + " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace\n"); /* * do not include array types (start with underscore); do not include - * complex types (typrelid!=0) unless they are standalone composite - * types + * complex types (typrelid!=0) unless they are standalone composite types */ appendPQExpBuffer(&buf, "WHERE (t.typrelid = 0 "); appendPQExpBuffer(&buf, "OR (SELECT c.relkind = 'c' FROM pg_catalog.pg_class c " @@ -311,11 +309,11 @@ describeOperators(const char *pattern) " o.oprname AS \"%s\",\n" " CASE WHEN o.oprkind='l' THEN NULL ELSE pg_catalog.format_type(o.oprleft, NULL) END AS \"%s\",\n" " CASE WHEN o.oprkind='r' THEN NULL ELSE pg_catalog.format_type(o.oprright, NULL) END AS \"%s\",\n" - " pg_catalog.format_type(o.oprresult, NULL) AS \"%s\",\n" - " coalesce(pg_catalog.obj_description(o.oid, 'pg_operator'),\n" - " pg_catalog.obj_description(o.oprcode, 'pg_proc')) AS \"%s\"\n" + " pg_catalog.format_type(o.oprresult, NULL) AS \"%s\",\n" + " coalesce(pg_catalog.obj_description(o.oid, 'pg_operator'),\n" + " pg_catalog.obj_description(o.oprcode, 'pg_proc')) AS \"%s\"\n" "FROM pg_catalog.pg_operator o\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = o.oprnamespace\n", + " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = o.oprnamespace\n", _("Schema"), _("Name"), _("Left arg type"), _("Right arg type"), _("Result type"), _("Description")); @@ -360,7 +358,7 @@ listAllDbs(bool verbose) " r.rolname as \"%s\"", _("Name"), _("Owner")); appendPQExpBuffer(&buf, - ",\n pg_catalog.pg_encoding_to_char(d.encoding) as \"%s\"", + ",\n pg_catalog.pg_encoding_to_char(d.encoding) as \"%s\"", _("Encoding")); if (verbose) appendPQExpBuffer(&buf, @@ -368,7 +366,7 @@ listAllDbs(bool verbose) _("Description")); appendPQExpBuffer(&buf, "\nFROM pg_catalog.pg_database d" - "\n LEFT JOIN pg_catalog.pg_roles r ON d.datdba = r.oid\n" + "\n LEFT JOIN pg_catalog.pg_roles r ON d.datdba = r.oid\n" "ORDER BY 1;"); res = PSQLexec(buf.data, false); @@ -400,8 +398,7 @@ permissionsList(const char *pattern) initPQExpBuffer(&buf); /* - * we ignore indexes and toast tables since they have no meaningful - * rights + * we ignore indexes and toast tables since they have no meaningful rights */ printfPQExpBuffer(&buf, "SELECT n.nspname as \"%s\",\n" @@ -409,19 +406,19 @@ permissionsList(const char *pattern) " CASE c.relkind WHEN 'r' THEN '%s' WHEN 'v' THEN '%s' WHEN 'S' THEN '%s' END as \"%s\",\n" " c.relacl as \"%s\"\n" "FROM pg_catalog.pg_class c\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n" + " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n" "WHERE c.relkind IN ('r', 'v', 'S')\n", _("Schema"), _("Name"), _("table"), _("view"), _("sequence"), _("Type"), _("Access privileges")); /* * Unless a schema pattern is specified, we suppress system and temp - * tables, since they normally aren't very interesting from a - * permissions point of view. You can see 'em by explicit request - * though, eg with \z pg_catalog.* + * tables, since they normally aren't very interesting from a permissions + * point of view. You can see 'em by explicit request though, eg with \z + * pg_catalog.* */ processNamePattern(&buf, pattern, true, false, "n.nspname", "c.relname", NULL, - "n.nspname !~ '^pg_' AND pg_catalog.pg_table_is_visible(c.oid)"); + "n.nspname !~ '^pg_' AND pg_catalog.pg_table_is_visible(c.oid)"); appendPQExpBuffer(&buf, "ORDER BY 1, 2;"); @@ -465,7 +462,7 @@ objectDescription(const char *pattern) appendPQExpBuffer(&buf, "SELECT DISTINCT tt.nspname AS \"%s\", tt.name AS \"%s\", tt.object AS \"%s\", d.description AS \"%s\"\n" "FROM (\n", - _("Schema"), _("Name"), _("Object"), _("Description")); + _("Schema"), _("Name"), _("Object"), _("Description")); /* Aggregate descriptions */ appendPQExpBuffer(&buf, @@ -474,7 +471,7 @@ objectDescription(const char *pattern) " CAST(p.proname AS pg_catalog.text) as name," " CAST('%s' AS pg_catalog.text) as object\n" " FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" + " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" " WHERE p.proisagg\n", _("aggregate")); processNamePattern(&buf, pattern, true, false, @@ -489,9 +486,9 @@ objectDescription(const char *pattern) " CAST(p.proname AS pg_catalog.text) as name," " CAST('%s' AS pg_catalog.text) as object\n" " FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" + " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - " WHERE p.prorettype <> 'pg_catalog.cstring'::pg_catalog.regtype\n" + " WHERE p.prorettype <> 'pg_catalog.cstring'::pg_catalog.regtype\n" " AND (p.proargtypes[0] IS NULL\n" " OR p.proargtypes[0] <> 'pg_catalog.cstring'::pg_catalog.regtype)\n" " AND NOT p.proisagg\n", @@ -508,7 +505,7 @@ objectDescription(const char *pattern) " CAST(o.oprname AS pg_catalog.text) as name," " CAST('%s' AS pg_catalog.text) as object\n" " FROM pg_catalog.pg_operator o\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = o.oprnamespace\n", + " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = o.oprnamespace\n", _("operator")); processNamePattern(&buf, pattern, false, false, "n.nspname", "o.oprname", NULL, @@ -522,10 +519,10 @@ objectDescription(const char *pattern) " pg_catalog.format_type(t.oid, NULL) as name," " CAST('%s' AS pg_catalog.text) as object\n" " FROM pg_catalog.pg_type t\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace\n", + " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace\n", _("data type")); processNamePattern(&buf, pattern, false, false, - "n.nspname", "pg_catalog.format_type(t.oid, NULL)", NULL, + "n.nspname", "pg_catalog.format_type(t.oid, NULL)", NULL, "pg_catalog.pg_type_is_visible(t.oid)"); /* Relation (tables, views, indexes, sequences) descriptions */ @@ -538,7 +535,7 @@ objectDescription(const char *pattern) " CASE c.relkind WHEN 'r' THEN '%s' WHEN 'v' THEN '%s' WHEN 'i' THEN '%s' WHEN 'S' THEN '%s' END" " AS pg_catalog.text) as object\n" " FROM pg_catalog.pg_class c\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n" + " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n" " WHERE c.relkind IN ('r', 'v', 'i', 'S')\n", _("table"), _("view"), _("index"), _("sequence")); processNamePattern(&buf, pattern, true, false, @@ -553,8 +550,8 @@ objectDescription(const char *pattern) " CAST(r.rulename AS pg_catalog.text) as name," " CAST('%s' AS pg_catalog.text) as object\n" " FROM pg_catalog.pg_rewrite r\n" - " JOIN pg_catalog.pg_class c ON c.oid = r.ev_class\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n" + " JOIN pg_catalog.pg_class c ON c.oid = r.ev_class\n" + " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n" " WHERE r.rulename != '_RETURN'\n", _("rule")); /* XXX not sure what to do about visibility rule here? */ @@ -570,8 +567,8 @@ objectDescription(const char *pattern) " CAST(t.tgname AS pg_catalog.text) as name," " CAST('%s' AS pg_catalog.text) as object\n" " FROM pg_catalog.pg_trigger t\n" - " JOIN pg_catalog.pg_class c ON c.oid = t.tgrelid\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n", + " JOIN pg_catalog.pg_class c ON c.oid = t.tgrelid\n" + " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n", _("trigger")); /* XXX not sure what to do about visibility rule here? */ processNamePattern(&buf, pattern, false, false, @@ -622,7 +619,7 @@ describeTableDetails(const char *pattern, bool verbose) " n.nspname,\n" " c.relname\n" "FROM pg_catalog.pg_class c\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n"); + " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n"); processNamePattern(&buf, pattern, false, false, "n.nspname", "c.relname", NULL, @@ -712,7 +709,7 @@ describeOneTableDetails(const char *schemaname, /* Get general table info */ printfPQExpBuffer(&buf, - "SELECT relhasindex, relkind, relchecks, reltriggers, relhasrules, \n" + "SELECT relhasindex, relkind, relchecks, reltriggers, relhasrules, \n" "relhasoids %s \n" "FROM pg_catalog.pg_class WHERE oid = '%s'", pset.sversion >= 80000 ? ", reltablespace" : "", @@ -886,7 +883,7 @@ describeOneTableDetails(const char *schemaname, break; default: printfPQExpBuffer(&title, _("?%c? \"%s.%s\""), - tableinfo.relkind, schemaname, relationname); + tableinfo.relkind, schemaname, relationname); break; } @@ -898,9 +895,9 @@ describeOneTableDetails(const char *schemaname, printfPQExpBuffer(&buf, "SELECT i.indisunique, i.indisprimary, i.indisclustered, a.amname, c2.relname,\n" - " pg_catalog.pg_get_expr(i.indpred, i.indrelid, true)\n" + " pg_catalog.pg_get_expr(i.indpred, i.indrelid, true)\n" "FROM pg_catalog.pg_index i, pg_catalog.pg_class c, pg_catalog.pg_class c2, pg_catalog.pg_am a\n" - "WHERE i.indexrelid = c.oid AND c.oid = '%s' AND c.relam = a.oid\n" + "WHERE i.indexrelid = c.oid AND c.oid = '%s' AND c.relam = a.oid\n" "AND i.indrelid = c2.oid", oid); @@ -962,7 +959,7 @@ describeOneTableDetails(const char *schemaname, printfPQExpBuffer(&buf, "SELECT r.rulename, trim(trailing ';' from pg_catalog.pg_get_ruledef(r.oid, true))\n" "FROM pg_catalog.pg_rewrite r\n" - "WHERE r.ev_class = '%s' AND r.rulename != '_RETURN' ORDER BY 1", + "WHERE r.ev_class = '%s' AND r.rulename != '_RETURN' ORDER BY 1", oid); result = PSQLexec(buf.data, false); if (!result) @@ -1023,10 +1020,10 @@ describeOneTableDetails(const char *schemaname, { printfPQExpBuffer(&buf, "SELECT c2.relname, i.indisprimary, i.indisunique, i.indisclustered, " - "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true), c2.reltablespace\n" + "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true), c2.reltablespace\n" "FROM pg_catalog.pg_class c, pg_catalog.pg_class c2, pg_catalog.pg_index i\n" "WHERE c.oid = '%s' AND c.oid = i.indrelid AND i.indexrelid = c2.oid\n" - "ORDER BY i.indisprimary DESC, i.indisunique DESC, c2.relname", + "ORDER BY i.indisprimary DESC, i.indisunique DESC, c2.relname", oid); result1 = PSQLexec(buf.data, false); if (!result1) @@ -1040,10 +1037,10 @@ describeOneTableDetails(const char *schemaname, { printfPQExpBuffer(&buf, "SELECT " - "pg_catalog.pg_get_constraintdef(r.oid, true), " + "pg_catalog.pg_get_constraintdef(r.oid, true), " "conname\n" "FROM pg_catalog.pg_constraint r\n" - "WHERE r.conrelid = '%s' AND r.contype = 'c' ORDER BY 1", + "WHERE r.conrelid = '%s' AND r.contype = 'c' ORDER BY 1", oid); result2 = PSQLexec(buf.data, false); if (!result2) @@ -1078,7 +1075,7 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.triggers) { printfPQExpBuffer(&buf, - "SELECT t.tgname, pg_catalog.pg_get_triggerdef(t.oid)\n" + "SELECT t.tgname, pg_catalog.pg_get_triggerdef(t.oid)\n" "FROM pg_catalog.pg_trigger t\n" "WHERE t.tgrelid = '%s' " "AND (not tgisconstraint " @@ -1105,9 +1102,9 @@ describeOneTableDetails(const char *schemaname, { printfPQExpBuffer(&buf, "SELECT conname,\n" - " pg_catalog.pg_get_constraintdef(oid, true) as condef\n" + " pg_catalog.pg_get_constraintdef(oid, true) as condef\n" "FROM pg_catalog.pg_constraint r\n" - "WHERE r.conrelid = '%s' AND r.contype = 'f' ORDER BY 1", + "WHERE r.conrelid = '%s' AND r.contype = 'f' ORDER BY 1", oid); result5 = PSQLexec(buf.data, false); if (!result5) @@ -1143,7 +1140,7 @@ describeOneTableDetails(const char *schemaname, { const char *indexdef; const char *usingpos; - PQExpBufferData tmpbuf; + PQExpBufferData tmpbuf; /* Output index name */ printfPQExpBuffer(&buf, _(" \"%s\""), @@ -1151,11 +1148,11 @@ describeOneTableDetails(const char *schemaname, /* Label as primary key or unique (but not both) */ appendPQExpBuffer(&buf, - strcmp(PQgetvalue(result1, i, 1), "t") == 0 + strcmp(PQgetvalue(result1, i, 1), "t") == 0 ? " PRIMARY KEY," : - (strcmp(PQgetvalue(result1, i, 2), "t") == 0 - ? " UNIQUE," - : "")); + (strcmp(PQgetvalue(result1, i, 2), "t") == 0 + ? " UNIQUE," + : "")); /* Everything after "USING" is echoed verbatim */ indexdef = PQgetvalue(result1, i, 4); usingpos = strstr(indexdef, " USING "); @@ -1170,9 +1167,9 @@ describeOneTableDetails(const char *schemaname, /* Print tablespace of the index on the same line */ count_footers += 1; initPQExpBuffer(&tmpbuf); - if (add_tablespace_footer('i', - atooid(PQgetvalue(result1, i, 5)), - footers, &count_footers, tmpbuf, false)) + if (add_tablespace_footer('i', + atooid(PQgetvalue(result1, i, 5)), + footers, &count_footers, tmpbuf, false)) { appendPQExpBuffer(&buf, ", "); appendPQExpBuffer(&buf, tmpbuf.data); @@ -1335,9 +1332,9 @@ error_return: } -/* - * Return true if the relation uses non default tablespace; - * otherwise return false +/* + * Return true if the relation uses non default tablespace; + * otherwise return false */ static bool add_tablespace_footer(char relkind, Oid tablespace, char **footers, @@ -1347,8 +1344,8 @@ add_tablespace_footer(char relkind, Oid tablespace, char **footers, if (relkind == 'r' || relkind == 'i') { /* - * We ignore the database default tablespace so that users not - * using tablespaces don't need to know about them. + * We ignore the database default tablespace so that users not using + * tablespaces don't need to know about them. */ if (tablespace != 0) { @@ -1362,9 +1359,9 @@ add_tablespace_footer(char relkind, Oid tablespace, char **footers, /* Should always be the case, but.... */ if (PQntuples(result1) > 0) { - printfPQExpBuffer(&buf, - newline?_("Tablespace: \"%s\""):_("tablespace \"%s\""), - PQgetvalue(result1, 0, 0)); + printfPQExpBuffer(&buf, + newline ? _("Tablespace: \"%s\"") : _("tablespace \"%s\""), + PQgetvalue(result1, 0, 0)); footers[(*count)++] = pg_strdup(buf.data); } @@ -1393,19 +1390,19 @@ describeRoles(const char *pattern) printfPQExpBuffer(&buf, "SELECT r.rolname AS \"%s\",\n" - " CASE WHEN r.rolsuper THEN '%s' ELSE '%s' END AS \"%s\",\n" - " CASE WHEN r.rolcreaterole THEN '%s' ELSE '%s' END AS \"%s\",\n" - " CASE WHEN r.rolcreatedb THEN '%s' ELSE '%s' END AS \"%s\",\n" - " CASE WHEN r.rolconnlimit < 0 THEN CAST('%s' AS pg_catalog.text)\n" + " CASE WHEN r.rolsuper THEN '%s' ELSE '%s' END AS \"%s\",\n" + " CASE WHEN r.rolcreaterole THEN '%s' ELSE '%s' END AS \"%s\",\n" + " CASE WHEN r.rolcreatedb THEN '%s' ELSE '%s' END AS \"%s\",\n" + " CASE WHEN r.rolconnlimit < 0 THEN CAST('%s' AS pg_catalog.text)\n" " ELSE CAST(r.rolconnlimit AS pg_catalog.text)\n" " END AS \"%s\", \n" " ARRAY(SELECT b.rolname FROM pg_catalog.pg_auth_members m JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid) WHERE m.member = r.oid) as \"%s\"\n" "FROM pg_catalog.pg_roles r\n", _("Role name"), - _("yes"),_("no"),_("Superuser"), - _("yes"),_("no"),_("Create role"), - _("yes"),_("no"),_("Create DB"), - _("no limit"),_("Connections"), + _("yes"), _("no"), _("Superuser"), + _("yes"), _("no"), _("Create role"), + _("yes"), _("no"), _("Create DB"), + _("no limit"), _("Connections"), _("Member of")); processNamePattern(&buf, pattern, false, false, @@ -1475,17 +1472,17 @@ listTables(const char *tabtypes, const char *pattern, bool verbose) if (verbose) appendPQExpBuffer(&buf, - ",\n pg_catalog.obj_description(c.oid, 'pg_class') as \"%s\"", + ",\n pg_catalog.obj_description(c.oid, 'pg_class') as \"%s\"", _("Description")); appendPQExpBuffer(&buf, "\nFROM pg_catalog.pg_class c" - "\n LEFT JOIN pg_catalog.pg_roles r ON r.oid = c.relowner" - "\n LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace"); + "\n LEFT JOIN pg_catalog.pg_roles r ON r.oid = c.relowner" + "\n LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace"); if (showIndexes) appendPQExpBuffer(&buf, - "\n LEFT JOIN pg_catalog.pg_index i ON i.indexrelid = c.oid" - "\n LEFT JOIN pg_catalog.pg_class c2 ON i.indrelid = c2.oid"); + "\n LEFT JOIN pg_catalog.pg_index i ON i.indexrelid = c.oid" + "\n LEFT JOIN pg_catalog.pg_class c2 ON i.indrelid = c2.oid"); appendPQExpBuffer(&buf, "\nWHERE c.relkind IN ("); if (showTables) @@ -1503,9 +1500,8 @@ listTables(const char *tabtypes, const char *pattern, bool verbose) /* * If showSystem is specified, show only system objects (those in - * pg_catalog). Otherwise, suppress system objects, including those - * in pg_catalog and pg_toast. (We don't want to hide temp tables - * though.) + * pg_catalog). Otherwise, suppress system objects, including those in + * pg_catalog and pg_toast. (We don't want to hide temp tables though.) */ if (showSystem) appendPQExpBuffer(&buf, " AND n.nspname = 'pg_catalog'\n"); @@ -1560,16 +1556,16 @@ listDomains(const char *pattern) printfPQExpBuffer(&buf, "SELECT n.nspname as \"%s\",\n" " t.typname as \"%s\",\n" - " pg_catalog.format_type(t.typbasetype, t.typtypmod) as \"%s\",\n" + " pg_catalog.format_type(t.typbasetype, t.typtypmod) as \"%s\",\n" " CASE WHEN t.typnotnull AND t.typdefault IS NOT NULL THEN 'not null default '||t.typdefault\n" - " WHEN t.typnotnull AND t.typdefault IS NULL THEN 'not null'\n" + " WHEN t.typnotnull AND t.typdefault IS NULL THEN 'not null'\n" " WHEN NOT t.typnotnull AND t.typdefault IS NOT NULL THEN 'default '||t.typdefault\n" " ELSE ''\n" " END as \"%s\",\n" - " pg_catalog.pg_get_constraintdef(r.oid, true) as \"%s\"\n" + " pg_catalog.pg_get_constraintdef(r.oid, true) as \"%s\"\n" "FROM pg_catalog.pg_type t\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace\n" - " LEFT JOIN pg_catalog.pg_constraint r ON t.oid = r.contypid\n" + " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace\n" + " LEFT JOIN pg_catalog.pg_constraint r ON t.oid = r.contypid\n" "WHERE t.typtype = 'd'\n", _("Schema"), _("Name"), @@ -1614,11 +1610,11 @@ listConversions(const char *pattern) printfPQExpBuffer(&buf, "SELECT n.nspname AS \"%s\",\n" " c.conname AS \"%s\",\n" - " pg_catalog.pg_encoding_to_char(c.conforencoding) AS \"%s\",\n" - " pg_catalog.pg_encoding_to_char(c.contoencoding) AS \"%s\",\n" + " pg_catalog.pg_encoding_to_char(c.conforencoding) AS \"%s\",\n" + " pg_catalog.pg_encoding_to_char(c.contoencoding) AS \"%s\",\n" " CASE WHEN c.condefault THEN '%s'\n" " ELSE '%s' END AS \"%s\"\n" - "FROM pg_catalog.pg_conversion c, pg_catalog.pg_namespace n\n" + "FROM pg_catalog.pg_conversion c, pg_catalog.pg_namespace n\n" "WHERE n.oid = c.connamespace\n", _("Schema"), _("Name"), @@ -1663,8 +1659,8 @@ listCasts(const char *pattern) initPQExpBuffer(&buf); /* NEED LEFT JOIN FOR BINARY CASTS */ printfPQExpBuffer(&buf, - "SELECT pg_catalog.format_type(castsource, NULL) AS \"%s\",\n" - " pg_catalog.format_type(casttarget, NULL) AS \"%s\",\n" + "SELECT pg_catalog.format_type(castsource, NULL) AS \"%s\",\n" + " pg_catalog.format_type(casttarget, NULL) AS \"%s\",\n" " CASE WHEN castfunc = 0 THEN '%s'\n" " ELSE p.proname\n" " END as \"%s\",\n" @@ -1672,7 +1668,7 @@ listCasts(const char *pattern) " WHEN c.castcontext = 'a' THEN '%s'\n" " ELSE '%s'\n" " END as \"%s\"\n" - "FROM pg_catalog.pg_cast c LEFT JOIN pg_catalog.pg_proc p\n" + "FROM pg_catalog.pg_cast c LEFT JOIN pg_catalog.pg_proc p\n" " ON c.castfunc = p.oid\n" "ORDER BY 1, 2", _("Source type"), @@ -1719,14 +1715,14 @@ listSchemas(const char *pattern, bool verbose) if (verbose) appendPQExpBuffer(&buf, ",\n n.nspacl as \"%s\"," - " pg_catalog.obj_description(n.oid, 'pg_namespace') as \"%s\"", + " pg_catalog.obj_description(n.oid, 'pg_namespace') as \"%s\"", _("Access privileges"), _("Description")); appendPQExpBuffer(&buf, - "\nFROM pg_catalog.pg_namespace n LEFT JOIN pg_catalog.pg_roles r\n" + "\nFROM pg_catalog.pg_namespace n LEFT JOIN pg_catalog.pg_roles r\n" " ON n.nspowner=r.oid\n" "WHERE (n.nspname !~ '^pg_temp_' OR\n" - " n.nspname = (pg_catalog.current_schemas(true))[1])\n"); /* temp schema is first */ + " n.nspname = (pg_catalog.current_schemas(true))[1])\n"); /* temp schema is first */ processNamePattern(&buf, pattern, true, false, NULL, "n.nspname", NULL, @@ -1796,9 +1792,9 @@ processNamePattern(PQExpBuffer buf, const char *pattern, initPQExpBuffer(&namebuf); /* - * Parse the pattern, converting quotes and lower-casing unquoted - * letters; we assume this was NOT done by scan_option. Also, adjust - * shell-style wildcard characters into regexp notation. + * Parse the pattern, converting quotes and lower-casing unquoted letters; + * we assume this was NOT done by scan_option. Also, adjust shell-style + * wildcard characters into regexp notation. */ inquotes = false; cp = pattern; @@ -1845,12 +1841,11 @@ processNamePattern(PQExpBuffer buf, const char *pattern, /* * Ordinary data character, transfer to pattern * - * Inside double quotes, or at all times if parsing an operator - * name, quote regexp special characters with a backslash to - * avoid regexp errors. Outside quotes, however, let them - * pass through as-is; this lets knowledgeable users build - * regexp expressions that are more powerful than shell-style - * patterns. + * Inside double quotes, or at all times if parsing an operator name, + * quote regexp special characters with a backslash to avoid + * regexp errors. Outside quotes, however, let them pass through + * as-is; this lets knowledgeable users build regexp expressions + * that are more powerful than shell-style patterns. */ if ((inquotes || force_escape) && strchr("|*+?()[]{}.^$\\", *cp)) diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c index 7d6cc7e4a0..879cdecd0e 100644 --- a/src/bin/psql/help.c +++ b/src/bin/psql/help.c @@ -3,7 +3,7 @@ * * Copyright (c) 2000-2005, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/help.c,v 1.105 2005/07/18 20:57:53 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/psql/help.c,v 1.106 2005/10/15 02:49:40 momjian Exp $ */ #include "postgres_fe.h" #include "common.h" @@ -138,7 +138,7 @@ usage(void) puts(_( "\nFor more information, type \"\\?\" (for internal commands) or \"\\help\"\n" - "(for SQL commands) from within psql, or consult the psql section in\n" + "(for SQL commands) from within psql, or consult the psql section in\n" "the PostgreSQL documentation.\n\n" "Report bugs to .")); } @@ -168,12 +168,12 @@ slashUsage(unsigned short int pager) /* if you add/remove a line here, change the row count above */ /* - * if this " is the start of the string then it ought to end there to - * fit in 80 columns >> " + * if this " is the start of the string then it ought to end there to fit + * in 80 columns >> " */ fprintf(output, _("General\n")); fprintf(output, _(" \\c[onnect] [DBNAME|- [USER]]\n" - " connect to new database (currently \"%s\")\n"), + " connect to new database (currently \"%s\")\n"), PQdb(pset.db)); fprintf(output, _(" \\cd [DIR] change the current working directory\n")); fprintf(output, _(" \\copyright show PostgreSQL usage and distribution terms\n")); @@ -205,13 +205,13 @@ slashUsage(unsigned short int pager) fprintf(output, _(" \\i FILE execute commands from file\n")); fprintf(output, _(" \\o [FILE] send all query results to file or |pipe\n")); fprintf(output, _(" \\qecho [STRING]\n" - " write string to query output stream (see \\o)\n")); + " write string to query output stream (see \\o)\n")); fprintf(output, "\n"); fprintf(output, _("Informational\n")); fprintf(output, _(" \\d [NAME] describe table, index, sequence, or view\n")); fprintf(output, _(" \\d{t|i|s|v|S} [PATTERN] (add \"+\" for more detail)\n" - " list tables/indexes/sequences/views/system tables\n")); + " list tables/indexes/sequences/views/system tables\n")); fprintf(output, _(" \\da [PATTERN] list aggregate functions\n")); fprintf(output, _(" \\db [PATTERN] list tablespaces (add \"+\" for more detail)\n")); fprintf(output, _(" \\dc [PATTERN] list conversions\n")); @@ -239,7 +239,7 @@ slashUsage(unsigned short int pager) fprintf(output, _(" \\pset NAME [VALUE]\n" " set table output option\n" " (NAME := {format|border|expanded|fieldsep|footer|null|\n" - " numericlocale|recordsep|tuples_only|title|tableattr|pager})\n")); + " numericlocale|recordsep|tuples_only|title|tableattr|pager})\n")); fprintf(output, _(" \\t show only rows (currently %s)\n"), ON(pset.popt.topt.tuples_only)); fprintf(output, _(" \\T [STRING] set HTML
tag attributes, or unset if none\n")); @@ -252,7 +252,7 @@ slashUsage(unsigned short int pager) fprintf(output, _(" \\lo_export LOBOID FILE\n" " \\lo_import FILE [COMMENT]\n" " \\lo_list\n" - " \\lo_unlink LOBOID large object operations\n")); + " \\lo_unlink LOBOID large object operations\n")); if (output != stdout) { @@ -291,7 +291,7 @@ helpSQL(const char *topic, unsigned short int pager) VALUE_OR_NULL(QL_HELP[i + items_per_column].cmd)); if (i + 2 * items_per_column < QL_HELP_COUNT) fprintf(output, "%-26s", - VALUE_OR_NULL(QL_HELP[i + 2 * items_per_column].cmd)); + VALUE_OR_NULL(QL_HELP[i + 2 * items_per_column].cmd)); fputc('\n', output); } /* Only close if we used the pager */ @@ -305,78 +305,82 @@ helpSQL(const char *topic, unsigned short int pager) } else { - int i,j,x=0; + int i, + j, + x = 0; bool help_found = false; FILE *output; - size_t len, wordlen; + size_t len, + wordlen; int nl_count = 0; char *ch; /* User gets two chances: exact match, then the first word */ - + /* First pass : strip trailing spaces and semicolons */ len = strlen(topic); while (topic[len - 1] == ' ' || topic[len - 1] == ';') - len--; + len--; - for (x=1; x<=3; x++) /* Three chances to guess that word... */ + for (x = 1; x <= 3; x++) /* Three chances to guess that word... */ { - if (x>1) /* Nothing on first pass - try the opening words */ + if (x > 1) /* Nothing on first pass - try the opening + * words */ + { + wordlen = j = 1; + while (topic[j] != ' ' && j++ < len) + wordlen++; + if (x == 2) { - wordlen=j=1; - while (topic[j] != ' ' && j++= len) /* Don't try again if the same word */ - { - output = PageOutput(nl_count, pager); - break; - } - len = wordlen; + j++; + while (topic[j] != ' ' && j++ <= len) + wordlen++; } + if (wordlen >= len) /* Don't try again if the same word */ + { + output = PageOutput(nl_count, pager); + break; + } + len = wordlen; + } - /* Count newlines for pager */ - for (i = 0; QL_HELP[i].cmd; i++) + /* Count newlines for pager */ + for (i = 0; QL_HELP[i].cmd; i++) + { + if (pg_strncasecmp(topic, QL_HELP[i].cmd, len) == 0 || + strcmp(topic, "*") == 0) { - if (pg_strncasecmp(topic, QL_HELP[i].cmd, len) == 0 || - strcmp(topic, "*") == 0) - { - nl_count += 5; - for (ch = QL_HELP[i].syntax; *ch != '\0'; ch++) - if (*ch == '\n') - nl_count++; - /* If we have an exact match, exit. Fixes \h SELECT */ - if (pg_strcasecmp(topic, QL_HELP[i].cmd) == 0) - break; - } - } - - output = PageOutput(nl_count, pager); - - for (i = 0; QL_HELP[i].cmd; i++) - { - if (pg_strncasecmp(topic, QL_HELP[i].cmd, len) == 0 || - strcmp(topic, "*") == 0) - { - help_found = true; - fprintf(output, _("Command: %s\n" - "Description: %s\n" - "Syntax:\n%s\n\n"), - QL_HELP[i].cmd, - _(QL_HELP[i].help), - _(QL_HELP[i].syntax)); - /* If we have an exact match, exit. Fixes \h SELECT */ - if (pg_strcasecmp(topic, QL_HELP[i].cmd) == 0) - break; - } - } - if (help_found) /* Don't keep trying if we got a match */ + nl_count += 5; + for (ch = QL_HELP[i].syntax; *ch != '\0'; ch++) + if (*ch == '\n') + nl_count++; + /* If we have an exact match, exit. Fixes \h SELECT */ + if (pg_strcasecmp(topic, QL_HELP[i].cmd) == 0) break; + } + } + + output = PageOutput(nl_count, pager); + + for (i = 0; QL_HELP[i].cmd; i++) + { + if (pg_strncasecmp(topic, QL_HELP[i].cmd, len) == 0 || + strcmp(topic, "*") == 0) + { + help_found = true; + fprintf(output, _("Command: %s\n" + "Description: %s\n" + "Syntax:\n%s\n\n"), + QL_HELP[i].cmd, + _(QL_HELP[i].help), + _(QL_HELP[i].syntax)); + /* If we have an exact match, exit. Fixes \h SELECT */ + if (pg_strcasecmp(topic, QL_HELP[i].cmd) == 0) + break; + } + } + if (help_found) /* Don't keep trying if we got a match */ + break; } if (!help_found) @@ -403,8 +407,8 @@ print_copyright(void) "Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group\n\n" "This software is based on Postgres95, formerly known as Postgres, which\n" "contains the following notice:\n\n" - "Portions Copyright(c) 1994, Regents of the University of California\n\n" - "Permission to use, copy, modify, and distribute this software and its\n" + "Portions Copyright(c) 1994, Regents of the University of California\n\n" + "Permission to use, copy, modify, and distribute this software and its\n" "documentation for any purpose, without fee, and without a written agreement\n" "is hereby granted, provided that the above copyright notice and this paragraph\n" "and the following two paragraphs appear in all copies.\n\n" diff --git a/src/bin/psql/input.c b/src/bin/psql/input.c index 2da977612c..4272fcb2e5 100644 --- a/src/bin/psql/input.c +++ b/src/bin/psql/input.c @@ -3,7 +3,7 @@ * * Copyright (c) 2000-2005, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/input.c,v 1.45 2005/06/10 15:40:41 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/psql/input.c,v 1.46 2005/10/15 02:49:40 momjian Exp $ */ #include "postgres_fe.h" @@ -24,7 +24,7 @@ #ifdef USE_READLINE static bool useReadline; static bool useHistory; -char *psql_history; +char *psql_history; enum histcontrol @@ -105,7 +105,7 @@ gets_interactive(const char *prompt) HC = GetHistControlConfig(); if (((HC & hctl_ignorespace) && s[0] == ' ') || - ((HC & hctl_ignoredups) && prev_hist && strcmp(s, prev_hist) == 0)) + ((HC & hctl_ignoredups) && prev_hist && strcmp(s, prev_hist) == 0)) { /* Ignore this line as far as history is concerned */ } @@ -221,7 +221,7 @@ saveHistory(char *fname) psql_error("could not save history to file \"%s\": %s\n", fname, strerror(errno)); } #else - psql_error("history is not supported by this installation\n"); + psql_error("history is not supported by this installation\n"); #endif return false; diff --git a/src/bin/psql/large_obj.c b/src/bin/psql/large_obj.c index 8bdcdc3682..b4c9027a63 100644 --- a/src/bin/psql/large_obj.c +++ b/src/bin/psql/large_obj.c @@ -3,7 +3,7 @@ * * Copyright (c) 2000-2005, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/large_obj.c,v 1.39 2005/07/02 17:01:52 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/psql/large_obj.c,v 1.40 2005/10/15 02:49:40 momjian Exp $ */ #include "postgres_fe.h" #include "large_obj.h" @@ -122,8 +122,8 @@ do_lo_export(const char *loid_arg, const char *filename_arg) status = lo_export(pset.db, atooid(loid_arg), filename_arg); if (status != 1) - { /* of course this status is documented - * nowhere :( */ + { /* of course this status is documented nowhere + * :( */ fputs(PQerrorMessage(pset.db), stderr); return fail_lo_xact("\\lo_export", own_transaction); } @@ -254,7 +254,7 @@ do_lo_list(void) snprintf(buf, sizeof(buf), "SELECT loid as \"ID\",\n" - " pg_catalog.obj_description(loid, 'pg_largeobject') as \"%s\"\n" + " pg_catalog.obj_description(loid, 'pg_largeobject') as \"%s\"\n" "FROM (SELECT DISTINCT loid FROM pg_catalog.pg_largeobject) x\n" "ORDER BY 1", _("Description")); diff --git a/src/bin/psql/mainloop.c b/src/bin/psql/mainloop.c index fad71c1120..775701a010 100644 --- a/src/bin/psql/mainloop.c +++ b/src/bin/psql/mainloop.c @@ -3,7 +3,7 @@ * * Copyright (c) 2000-2005, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/mainloop.c,v 1.67 2005/02/22 04:40:55 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/psql/mainloop.c,v 1.68 2005/10/15 02:49:40 momjian Exp $ */ #include "postgres_fe.h" #include "mainloop.h" @@ -35,8 +35,8 @@ MainLoop(FILE *source) { PsqlScanState scan_state; /* lexer working state */ PQExpBuffer query_buf; /* buffer for query being accumulated */ - PQExpBuffer previous_buf; /* if there isn't anything in the new - * buffer yet, use this one for \e, etc. */ + PQExpBuffer previous_buf; /* if there isn't anything in the new buffer + * yet, use this one for \e, etc. */ char *line; /* current line of input */ int added_nl_pos; bool success; @@ -117,12 +117,10 @@ MainLoop(FILE *source) } /* - * establish the control-C handler only after main_loop_jmp is - * ready + * establish the control-C handler only after main_loop_jmp is ready */ pqsignal(SIGINT, handle_sigint); /* control-C => cancel */ - -#else /* WIN32 */ +#else /* WIN32 */ setup_cancel_handler(); #endif @@ -156,9 +154,8 @@ MainLoop(FILE *source) line = gets_fromFile(source); /* - * query_buf holds query already accumulated. line is the - * malloc'd new line of input (note it must be freed before - * looping around!) + * query_buf holds query already accumulated. line is the malloc'd + * new line of input (note it must be freed before looping around!) */ /* No more input. Time to quit, or \i done */ @@ -225,8 +222,8 @@ MainLoop(FILE *source) prompt_status = prompt_tmp; /* - * Send command if semicolon found, or if end of line and - * we're in single-line mode. + * Send command if semicolon found, or if end of line and we're in + * single-line mode. */ if (scan_result == PSCAN_SEMICOLON || (scan_result == PSCAN_EOL && @@ -247,11 +244,10 @@ MainLoop(FILE *source) /* handle backslash command */ /* - * If we added a newline to query_buf, and nothing else - * has been inserted in query_buf by the lexer, then strip - * off the newline again. This avoids any change to - * query_buf when a line contains only a backslash - * command. + * If we added a newline to query_buf, and nothing else has + * been inserted in query_buf by the lexer, then strip off the + * newline again. This avoids any change to query_buf when a + * line contains only a backslash command. */ if (query_buf->len == added_nl_pos) query_buf->data[--query_buf->len] = '\0'; @@ -259,7 +255,7 @@ MainLoop(FILE *source) slashCmdStatus = HandleSlashCmds(scan_state, query_buf->len > 0 ? - query_buf : previous_buf); + query_buf : previous_buf); success = slashCmdStatus != CMD_ERROR; @@ -326,10 +322,10 @@ MainLoop(FILE *source) } /* - * Reset SIGINT handler because main_loop_jmp will be invalid as soon - * as we exit this routine. If there is an outer MainLoop instance, - * it will re-enable ^C catching as soon as it gets back to the top of - * its loop and resets main_loop_jmp to point to itself. + * Reset SIGINT handler because main_loop_jmp will be invalid as soon as + * we exit this routine. If there is an outer MainLoop instance, it will + * re-enable ^C catching as soon as it gets back to the top of its loop + * and resets main_loop_jmp to point to itself. */ #ifndef WIN32 pqsignal(SIGINT, SIG_DFL); diff --git a/src/bin/psql/mbprint.c b/src/bin/psql/mbprint.c index dd4bfca211..7bced92a6d 100644 --- a/src/bin/psql/mbprint.c +++ b/src/bin/psql/mbprint.c @@ -3,7 +3,7 @@ * * Copyright (c) 2000-2005, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/mbprint.c,v 1.17 2005/09/24 17:53:27 tgl Exp $ + * $PostgreSQL: pgsql/src/bin/psql/mbprint.c,v 1.18 2005/10/15 02:49:40 momjian Exp $ */ #include "postgres_fe.h" @@ -140,8 +140,7 @@ ucs_wcwidth(pg_wchar ucs) return 0; /* - * if we arrive here, ucs is not a combining or C0/C1 control - * character + * if we arrive here, ucs is not a combining or C0/C1 control character */ return 1 + @@ -217,10 +216,9 @@ utf_charcheck(const unsigned char *c) { /* * Unicode 3.1 compliant validation : for each category, it checks the - * combination of each byte to make sur it maps to a valid range. It - * also returns -1 for the following UCS values: ucs > 0x10ffff ucs & - * 0xfffe = 0xfffe 0xfdd0 < ucs < 0xfdef ucs & 0xdb00 = 0xd800 - * (surrogates) + * combination of each byte to make sur it maps to a valid range. It also + * returns -1 for the following UCS values: ucs > 0x10ffff ucs & 0xfffe = + * 0xfffe 0xfdd0 < ucs < 0xfdef ucs & 0xdb00 = 0xd800 (surrogates) */ if ((*c & 0x80) == 0) return 1; @@ -245,7 +243,7 @@ utf_charcheck(const unsigned char *c) /* check 0xfffe/0xffff, 0xfdd0..0xfedf range, surrogates */ if (((z == 0x0f) && (((yx & 0xffe) == 0xffe) || - (((yx & 0xf80) == 0xd80) && (lx >= 0x30) && (lx <= 0x4f)))) || + (((yx & 0xf80) == 0xd80) && (lx >= 0x30) && (lx <= 0x4f)))) || ((z == 0x0d) && ((yx & 0xb00) == 0x800))) return -1; return 3; @@ -318,8 +316,8 @@ pg_wcswidth(const char *pwcs, size_t len, int encoding) else { /* - * obviously, other encodings may want to fix this, but I don't - * know them myself, unfortunately. + * obviously, other encodings may want to fix this, but I don't know + * them myself, unfortunately. */ return len; } @@ -333,8 +331,8 @@ mbvalidate(char *pwcs, int encoding) else { /* - * other encodings needing validation should add their own - * routines here + * other encodings needing validation should add their own routines + * here */ } diff --git a/src/bin/psql/print.c b/src/bin/psql/print.c index 9c8000d7b7..3d2a1fa175 100644 --- a/src/bin/psql/print.c +++ b/src/bin/psql/print.c @@ -3,7 +3,7 @@ * * Copyright (c) 2000-2005, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.77 2005/10/04 19:01:18 petere Exp $ + * $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.78 2005/10/15 02:49:40 momjian Exp $ */ #include "postgres_fe.h" #include "common.h" @@ -52,11 +52,11 @@ pg_local_malloc(size_t size) static int integer_digits(const char *my_str) { - int frac_len; + int frac_len; if (my_str[0] == '-') my_str++; - + frac_len = strchr(my_str, '.') ? strlen(strchr(my_str, '.')) : 0; return strlen(my_str) - frac_len; @@ -66,17 +66,18 @@ integer_digits(const char *my_str) static int additional_numeric_locale_len(const char *my_str) { - int int_len = integer_digits(my_str), len = 0; - int groupdigits = atoi(grouping); + int int_len = integer_digits(my_str), + len = 0; + int groupdigits = atoi(grouping); if (int_len > 0) /* Don't count a leading separator */ len = (int_len / groupdigits - (int_len % groupdigits == 0)) * - strlen(thousands_sep); + strlen(thousands_sep); if (strchr(my_str, '.') != NULL) len += strlen(decimal_point) - strlen("."); - + return len; } @@ -89,23 +90,27 @@ strlen_with_numeric_locale(const char *my_str) static char * format_numeric_locale(const char *my_str) { - int i, j, int_len = integer_digits(my_str), leading_digits; - int groupdigits = atoi(grouping); - int new_str_start = 0; - char *new_str = new_str = pg_local_malloc( - strlen_with_numeric_locale(my_str) + 1); + int i, + j, + int_len = integer_digits(my_str), + leading_digits; + int groupdigits = atoi(grouping); + int new_str_start = 0; + char *new_str = new_str = pg_local_malloc( + strlen_with_numeric_locale(my_str) + 1); leading_digits = (int_len % groupdigits != 0) ? - int_len % groupdigits : groupdigits; + int_len % groupdigits : groupdigits; - if (my_str[0] == '-') /* skip over sign, affects grouping calculations */ + if (my_str[0] == '-') /* skip over sign, affects grouping + * calculations */ { new_str[0] = my_str[0]; my_str++; new_str_start = 1; } - for (i=0, j=new_str_start; ; i++, j++) + for (i = 0, j = new_str_start;; i++, j++) { /* Hit decimal point? */ if (my_str[i] == '.') @@ -123,7 +128,7 @@ format_numeric_locale(const char *my_str) new_str[j] = '\0'; break; } - + /* Add separator? */ if (i != 0 && (i - leading_digits) % groupdigits == 0) { @@ -133,7 +138,7 @@ format_numeric_locale(const char *my_str) new_str[j] = my_str[i]; } - + return new_str; } @@ -143,15 +148,15 @@ format_numeric_locale(const char *my_str) static void -print_unaligned_text(const char *title, const char *const *headers, - const char *const *cells, const char *const *footers, +print_unaligned_text(const char *title, const char *const * headers, + const char *const * cells, const char *const * footers, const char *opt_align, const char *opt_fieldsep, const char *opt_recordsep, bool opt_tuples_only, bool opt_numeric_locale, FILE *fout) { unsigned int col_count = 0; unsigned int i; - const char *const *ptr; + const char *const * ptr; bool need_recordsep = false; if (!opt_fieldsep) @@ -188,14 +193,14 @@ print_unaligned_text(const char *title, const char *const *headers, } if (opt_align[i % col_count] == 'r' && opt_numeric_locale) { - char *my_cell = format_numeric_locale(*ptr); + char *my_cell = format_numeric_locale(*ptr); fputs(my_cell, fout); free(my_cell); } else fputs(*ptr, fout); - + if ((i + 1) % col_count) fputs(opt_fieldsep, fout); else @@ -225,15 +230,15 @@ print_unaligned_text(const char *title, const char *const *headers, static void -print_unaligned_vertical(const char *title, const char *const *headers, - const char *const *cells, - const char *const *footers, const char *opt_align, +print_unaligned_vertical(const char *title, const char *const * headers, + const char *const * cells, + const char *const * footers, const char *opt_align, const char *opt_fieldsep, const char *opt_recordsep, - bool opt_tuples_only, bool opt_numeric_locale, FILE *fout) + bool opt_tuples_only, bool opt_numeric_locale, FILE *fout) { unsigned int col_count = 0; unsigned int i; - const char *const *ptr; + const char *const * ptr; if (!opt_fieldsep) opt_fieldsep = ""; @@ -262,7 +267,7 @@ print_unaligned_vertical(const char *title, const char *const *headers, fputs(opt_fieldsep, fout); if (opt_align[i % col_count] == 'r' && opt_numeric_locale) { - char *my_cell = format_numeric_locale(*ptr); + char *my_cell = format_numeric_locale(*ptr); fputs(my_cell, fout); free(my_cell); @@ -329,9 +334,9 @@ _print_horizontal_line(const unsigned int col_count, const unsigned int *widths, static void -print_aligned_text(const char *title, const char *const *headers, - const char *const *cells, const char *const *footers, - const char *opt_align, bool opt_tuples_only, bool opt_numeric_locale, +print_aligned_text(const char *title, const char *const * headers, + const char *const * cells, const char *const * footers, + const char *opt_align, bool opt_tuples_only, bool opt_numeric_locale, unsigned short int opt_border, int encoding, FILE *fout) { @@ -343,7 +348,7 @@ print_aligned_text(const char *title, const char *const *headers, tmp; unsigned int *widths, total_w; - const char *const *ptr; + const char *const * ptr; /* count columns */ for (ptr = headers; *ptr; ptr++) @@ -398,13 +403,13 @@ print_aligned_text(const char *title, const char *const *headers, for (i = 0, ptr = cells; *ptr; ptr++, i++) { - int add_numeric_locale_len; + int add_numeric_locale_len; if (opt_align[i % col_count] == 'r' && opt_numeric_locale) - add_numeric_locale_len = additional_numeric_locale_len(*ptr); - else - add_numeric_locale_len = 0; - + add_numeric_locale_len = additional_numeric_locale_len(*ptr); + else + add_numeric_locale_len = 0; + tmp = pg_wcswidth(*ptr, strlen(*ptr), encoding) + add_numeric_locale_len; if (tmp > widths[i % col_count]) widths[i % col_count] = tmp; @@ -485,9 +490,9 @@ print_aligned_text(const char *title, const char *const *headers, /* content */ if (opt_align[i % col_count] == 'r') { - if (opt_numeric_locale) - { - char *my_cell = format_numeric_locale(*ptr); + if (opt_numeric_locale) + { + char *my_cell = format_numeric_locale(*ptr); fprintf(fout, "%*s%s", widths[i % col_count] - cell_w[i], "", my_cell); free(my_cell); @@ -532,8 +537,7 @@ print_aligned_text(const char *title, const char *const *headers, #ifndef __MINGW32__ /* - * for some reason MinGW outputs an extra newline, so this supresses - * it + * for some reason MinGW outputs an extra newline, so this supresses it */ fputc('\n', fout); #endif @@ -547,15 +551,15 @@ print_aligned_text(const char *title, const char *const *headers, static void -print_aligned_vertical(const char *title, const char *const *headers, - const char *const *cells, const char *const *footers, +print_aligned_vertical(const char *title, const char *const * headers, + const char *const * cells, const char *const * footers, const char *opt_align, bool opt_tuples_only, bool opt_numeric_locale, unsigned short int opt_border, int encoding, FILE *fout) { unsigned int col_count = 0; unsigned int record = 1; - const char *const *ptr; + const char *const * ptr; unsigned int i, tmp = 0, hwidth = 0, @@ -613,11 +617,11 @@ print_aligned_vertical(const char *title, const char *const *headers, /* find longest data cell */ for (i = 0, ptr = cells; *ptr; ptr++, i++) { - int add_numeric_locale_len; + int add_numeric_locale_len; if (opt_align[i % col_count] == 'r' && opt_numeric_locale) add_numeric_locale_len = additional_numeric_locale_len(*ptr); - else + else add_numeric_locale_len = 0; tmp = pg_wcswidth(*ptr, strlen(*ptr), encoding) + add_numeric_locale_len; @@ -696,8 +700,8 @@ print_aligned_vertical(const char *title, const char *const *headers, if (opt_align[i % col_count] == 'r' && opt_numeric_locale) { - char *my_cell = format_numeric_locale(*ptr); - + char *my_cell = format_numeric_locale(*ptr); + if (opt_border < 2) fprintf(fout, "%s\n", my_cell); else @@ -746,8 +750,8 @@ void html_escaped_print(const char *in, FILE *fout) { const char *p; - bool leading_space = true; - + bool leading_space = true; + for (p = in; *p; p++) { switch (*p) @@ -788,15 +792,15 @@ html_escaped_print(const char *in, FILE *fout) static void -print_html_text(const char *title, const char *const *headers, - const char *const *cells, const char *const *footers, +print_html_text(const char *title, const char *const * headers, + const char *const * cells, const char *const * footers, const char *opt_align, bool opt_tuples_only, bool opt_numeric_locale, unsigned short int opt_border, const char *opt_table_attr, FILE *fout) { unsigned int col_count = 0; unsigned int i; - const char *const *ptr; + const char *const * ptr; fprintf(fout, "
", opt_align[(i) % col_count] == 'r' ? "right" : "left"); /* is string only whitespace? */ - if ((*ptr)[strspn(*ptr, " \t")] == '\0') + if ((*ptr)[strspn(*ptr, " \t")] == '\0') fputs("  ", fout); else if (opt_align[i % col_count] == 'r' && opt_numeric_locale) { - char *my_cell = format_numeric_locale(*ptr); + char *my_cell = format_numeric_locale(*ptr); - html_escaped_print(my_cell, fout); - free(my_cell); + html_escaped_print(my_cell, fout); + free(my_cell); } else html_escaped_print(*ptr, fout); @@ -873,16 +877,16 @@ print_html_text(const char *title, const char *const *headers, static void -print_html_vertical(const char *title, const char *const *headers, - const char *const *cells, const char *const *footers, - const char *opt_align, bool opt_tuples_only, - bool opt_numeric_locale, unsigned short int opt_border, - const char *opt_table_attr, FILE *fout) +print_html_vertical(const char *title, const char *const * headers, + const char *const * cells, const char *const * footers, + const char *opt_align, bool opt_tuples_only, + bool opt_numeric_locale, unsigned short int opt_border, + const char *opt_table_attr, FILE *fout) { unsigned int col_count = 0; unsigned int i; unsigned int record = 1; - const char *const *ptr; + const char *const * ptr; fprintf(fout, "
", opt_align[i % col_count] == 'r' ? "right" : "left"); /* is string only whitespace? */ - if ((*ptr)[strspn(*ptr, " \t")] == '\0') + if ((*ptr)[strspn(*ptr, " \t")] == '\0') fputs("  ", fout); else if (opt_align[i % col_count] == 'r' && opt_numeric_locale) { - char *my_cell = format_numeric_locale(*ptr); + char *my_cell = format_numeric_locale(*ptr); - html_escaped_print(my_cell, fout); - free(my_cell); + html_escaped_print(my_cell, fout); + free(my_cell); } else html_escaped_print(*ptr, fout); @@ -996,15 +1000,15 @@ latex_escaped_print(const char *in, FILE *fout) static void -print_latex_text(const char *title, const char *const *headers, - const char *const *cells, const char *const *footers, +print_latex_text(const char *title, const char *const * headers, + const char *const * cells, const char *const * footers, const char *opt_align, bool opt_tuples_only, bool opt_numeric_locale, unsigned short int opt_border, FILE *fout) { unsigned int col_count = 0; unsigned int i; - const char *const *ptr; + const char *const * ptr; /* print title */ @@ -1062,7 +1066,7 @@ print_latex_text(const char *title, const char *const *headers, { if (opt_numeric_locale) { - char *my_cell = format_numeric_locale(*ptr); + char *my_cell = format_numeric_locale(*ptr); latex_escaped_print(my_cell, fout); free(my_cell); @@ -1097,15 +1101,15 @@ print_latex_text(const char *title, const char *const *headers, static void -print_latex_vertical(const char *title, const char *const *headers, - const char *const *cells, const char *const *footers, - const char *opt_align, bool opt_tuples_only, - bool opt_numeric_locale, unsigned short int opt_border, - FILE *fout) +print_latex_vertical(const char *title, const char *const * headers, + const char *const * cells, const char *const * footers, + const char *opt_align, bool opt_tuples_only, + bool opt_numeric_locale, unsigned short int opt_border, + FILE *fout) { unsigned int col_count = 0; unsigned int i; - const char *const *ptr; + const char *const * ptr; unsigned int record = 1; (void) opt_align; /* currently unused parameter */ @@ -1173,7 +1177,7 @@ print_latex_vertical(const char *title, const char *const *headers, { if (opt_numeric_locale) { - char *my_cell = format_numeric_locale(*ptr); + char *my_cell = format_numeric_locale(*ptr); latex_escaped_print(my_cell, fout); free(my_cell); @@ -1212,15 +1216,15 @@ troff_ms_escaped_print(const char *in, FILE *fout) static void -print_troff_ms_text(const char *title, const char *const *headers, - const char *const *cells, const char *const *footers, - const char *opt_align, bool opt_tuples_only, - bool opt_numeric_locale, unsigned short int opt_border, - FILE *fout) +print_troff_ms_text(const char *title, const char *const * headers, + const char *const * cells, const char *const * footers, + const char *opt_align, bool opt_tuples_only, + bool opt_numeric_locale, unsigned short int opt_border, + FILE *fout) { unsigned int col_count = 0; unsigned int i; - const char *const *ptr; + const char *const * ptr; /* print title */ @@ -1271,7 +1275,7 @@ print_troff_ms_text(const char *title, const char *const *headers, { if (opt_numeric_locale) { - char *my_cell = format_numeric_locale(*ptr); + char *my_cell = format_numeric_locale(*ptr); troff_ms_escaped_print(my_cell, fout); free(my_cell); @@ -1303,17 +1307,17 @@ print_troff_ms_text(const char *title, const char *const *headers, static void -print_troff_ms_vertical(const char *title, const char *const *headers, - const char *const *cells, const char *const *footers, - const char *opt_align, bool opt_tuples_only, - bool opt_numeric_locale, unsigned short int opt_border, - FILE *fout) +print_troff_ms_vertical(const char *title, const char *const * headers, + const char *const * cells, const char *const * footers, + const char *opt_align, bool opt_tuples_only, + bool opt_numeric_locale, unsigned short int opt_border, + FILE *fout) { unsigned int col_count = 0; unsigned int i; - const char *const *ptr; + const char *const * ptr; unsigned int record = 1; - unsigned short current_format = 0; /* 0=none, 1=header, 2=body */ + unsigned short current_format = 0; /* 0=none, 1=header, 2=body */ (void) opt_align; /* currently unused parameter */ @@ -1333,8 +1337,8 @@ print_troff_ms_vertical(const char *title, const char *const *headers, fputs("center;\n", fout); /* basic format */ - if (opt_tuples_only) - fputs("c l;\n", fout); + if (opt_tuples_only) + fputs("c l;\n", fout); /* count columns */ for (ptr = headers; *ptr; ptr++) @@ -1381,7 +1385,7 @@ print_troff_ms_vertical(const char *title, const char *const *headers, fputc('\t', fout); if (opt_numeric_locale) { - char *my_cell = format_numeric_locale(*ptr); + char *my_cell = format_numeric_locale(*ptr); troff_ms_escaped_print(my_cell, fout); free(my_cell); @@ -1462,16 +1466,16 @@ PageOutput(int lines, unsigned short int pager) void printTable(const char *title, - const char *const *headers, - const char *const *cells, - const char *const *footers, + const char *const * headers, + const char *const * cells, + const char *const * footers, const char *align, const printTableOpt *opt, FILE *fout, FILE *flog) { const char *default_footer[] = {NULL}; unsigned short int border = opt->border; FILE *output; - bool use_expanded; + bool use_expanded; if (opt->format == PRINT_NOTHING) return; @@ -1483,9 +1487,9 @@ printTable(const char *title, border = 2; /* - * We only want to display the results in "expanded" format if - * this is a normal (user-submitted) query, not a table we're - * printing for a slash command. + * We only want to display the results in "expanded" format if this is a + * normal (user-submitted) query, not a table we're printing for a slash + * command. */ if (opt->expanded && opt->normal_query) use_expanded = true; @@ -1497,7 +1501,7 @@ printTable(const char *title, int col_count = 0, row_count = 0, lines; - const char *const *ptr; + const char *const * ptr; /* rough estimate of columns and rows */ if (headers) @@ -1532,16 +1536,16 @@ printTable(const char *title, if (use_expanded) print_unaligned_vertical(title, headers, cells, footers, align, opt->fieldSep, opt->recordSep, - opt->tuples_only, opt->numericLocale, output); + opt->tuples_only, opt->numericLocale, output); else print_unaligned_text(title, headers, cells, footers, align, opt->fieldSep, opt->recordSep, - opt->tuples_only, opt->numericLocale, output); + opt->tuples_only, opt->numericLocale, output); break; case PRINT_ALIGNED: if (use_expanded) print_aligned_vertical(title, headers, cells, footers, align, - opt->tuples_only, opt->numericLocale, border, + opt->tuples_only, opt->numericLocale, border, opt->encoding, output); else print_aligned_text(title, headers, cells, footers, align, @@ -1555,7 +1559,7 @@ printTable(const char *title, border, opt->tableAttr, output); else print_html_text(title, headers, cells, footers, - align, opt->tuples_only, opt->numericLocale, border, + align, opt->tuples_only, opt->numericLocale, border, opt->tableAttr, output); break; case PRINT_LATEX: @@ -1714,7 +1718,7 @@ setDecimalLocale(void) if (*extlconv->grouping && atoi(extlconv->grouping) > 0) grouping = strdup(extlconv->grouping); else - grouping = "3"; /* most common */ + grouping = "3"; /* most common */ if (*extlconv->thousands_sep) thousands_sep = strdup(extlconv->thousands_sep); else if (*decimal_point != ',') @@ -1722,5 +1726,3 @@ setDecimalLocale(void) else thousands_sep = "."; } - - diff --git a/src/bin/psql/print.h b/src/bin/psql/print.h index a5fd549aef..5b07bfd475 100644 --- a/src/bin/psql/print.h +++ b/src/bin/psql/print.h @@ -3,7 +3,7 @@ * * Copyright (c) 2000-2005, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/print.h,v 1.28 2005/07/18 20:57:53 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/psql/print.h,v 1.29 2005/10/15 02:49:40 momjian Exp $ */ #ifndef PRINT_H #define PRINT_H @@ -30,23 +30,21 @@ enum printFormat typedef struct _printTableOpt { enum printFormat format; /* one of the above */ - bool expanded; /* expanded/vertical output (if supported - * by output format) */ + bool expanded; /* expanded/vertical output (if supported by + * output format) */ unsigned short int pager; /* use pager for output (if to stdout and * stdout is a tty) 0=off 1=on 2=always */ bool tuples_only; /* don't output headers, row counts, etc. */ - unsigned short int border; /* Print a border around the table. - * 0=none, 1=dividing lines, 2=full */ + unsigned short int border; /* Print a border around the table. 0=none, + * 1=dividing lines, 2=full */ char *fieldSep; /* field separator for unaligned text mode */ - char *recordSep; /* record separator for unaligned text - * mode */ + char *recordSep; /* record separator for unaligned text mode */ bool numericLocale; /* locale-aware numeric units separator and - * decimal marker */ + * decimal marker */ char *tableAttr; /* attributes for HTML
*/ int encoding; /* character encoding */ - bool normal_query; /* are we presenting the results of a - * "normal" query, or a slash - * command? */ + bool normal_query; /* are we presenting the results of a "normal" + * query, or a slash command? */ } printTableOpt; @@ -74,8 +72,7 @@ typedef struct _printQueryOpt char *nullPrint; /* how to print null entities */ bool quote; /* quote all values as much as possible */ char *title; /* override title */ - char **footers; /* override footer (default is "(xx - * rows)") */ + char **footers; /* override footer (default is "(xx rows)") */ bool default_footer; /* print default footer if footers==NULL */ } printQueryOpt; @@ -84,10 +81,10 @@ typedef struct _printQueryOpt * * It calls the printTable above with all the things set straight. */ -void printQuery(const PGresult *result, const printQueryOpt *opt, - FILE *fout, FILE *flog); +void printQuery(const PGresult *result, const printQueryOpt *opt, + FILE *fout, FILE *flog); -void setDecimalLocale(void); +void setDecimalLocale(void); #ifndef __CYGWIN__ #define DEFAULT_PAGER "more" diff --git a/src/bin/psql/prompt.c b/src/bin/psql/prompt.c index 68cc52c08e..5b5d7196eb 100644 --- a/src/bin/psql/prompt.c +++ b/src/bin/psql/prompt.c @@ -3,7 +3,7 @@ * * Copyright (c) 2000-2005, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/prompt.c,v 1.39 2005/05/30 18:28:11 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/psql/prompt.c,v 1.40 2005/10/15 02:49:40 momjian Exp $ */ #include "postgres_fe.h" #include "prompt.h" @@ -175,7 +175,7 @@ get_prompt(promptStatus_t status) case '5': case '6': case '7': - *buf = (char) strtol(p, (char **)&p, 8); + *buf = (char) strtol(p, (char **) &p, 8); --p; break; case 'R': @@ -293,9 +293,8 @@ get_prompt(promptStatus_t status) /* * readline >=4.0 undocumented feature: non-printing - * characters in prompt strings must be marked as - * such, in order to properly display the line during - * editing. + * characters in prompt strings must be marked as such, in + * order to properly display the line during editing. */ buf[0] = '\001'; buf[1] = (*p == '[') ? RL_PROMPT_START_IGNORE : RL_PROMPT_END_IGNORE; diff --git a/src/bin/psql/settings.h b/src/bin/psql/settings.h index f4e78f407e..06da3194d1 100644 --- a/src/bin/psql/settings.h +++ b/src/bin/psql/settings.h @@ -3,7 +3,7 @@ * * Copyright (c) 2000-2005, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/settings.h,v 1.25 2005/06/14 02:57:41 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/psql/settings.h,v 1.26 2005/10/15 02:49:40 momjian Exp $ */ #ifndef SETTINGS_H #define SETTINGS_H @@ -39,10 +39,9 @@ typedef struct _psqlSettings char *gfname; /* one-shot file output argument for \g */ - bool notty; /* stdin or stdout is not a tty (as - * determined on startup) */ - bool getPassword; /* prompt the user for a username and - * password */ + bool notty; /* stdin or stdout is not a tty (as determined + * on startup) */ + bool getPassword; /* prompt the user for a username and password */ FILE *cur_cmd_source; /* describe the status of the current main * loop */ bool cur_cmd_interactive; @@ -56,7 +55,7 @@ typedef struct _psqlSettings bool timing; /* enable timing of all queries */ PGVerbosity verbosity; /* current error verbosity level */ - FILE *logfile; /* session log file handle */ + FILE *logfile; /* session log file handle */ } PsqlSettings; extern PsqlSettings pset; diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c index 89b136c8c0..5d027dd018 100644 --- a/src/bin/psql/startup.c +++ b/src/bin/psql/startup.c @@ -3,7 +3,7 @@ * * Copyright (c) 2000-2005, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.124 2005/10/04 19:01:18 petere Exp $ + * $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.125 2005/10/15 02:49:40 momjian Exp $ */ #include "postgres_fe.h" @@ -19,7 +19,7 @@ #include "getopt_long.h" #ifndef HAVE_INT_OPTRESET -int optreset; +int optreset; #endif #include @@ -107,7 +107,7 @@ main(int argc, char *argv[]) char *username = NULL; char *password = NULL; - char *password_prompt = NULL; + char *password_prompt = NULL; bool need_pass; set_pglocale_pgservice(argv[0], "psql"); @@ -180,9 +180,9 @@ main(int argc, char *argv[]) if (options.username) { /* - * The \001 is a hack to support the deprecated -u option which - * issues a username prompt. The recommended option is -U followed - * by the name on the command line. + * The \001 is a hack to support the deprecated -u option which issues + * a username prompt. The recommended option is -U followed by the + * name on the command line. */ if (strcmp(options.username, "\001") == 0) username = simple_prompt("User name: ", 100, true); @@ -207,7 +207,7 @@ main(int argc, char *argv[]) { need_pass = false; pset.db = PQsetdbLogin(options.host, options.port, NULL, NULL, - options.action == ACT_LIST_DB ? "postgres" : options.dbname, + options.action == ACT_LIST_DB ? "postgres" : options.dbname, username, password); if (PQstatus(pset.db) == CONNECTION_BAD && @@ -314,12 +314,12 @@ main(int argc, char *argv[]) if (!QUIET() && !pset.notty) { - int client_ver = parse_version(PG_VERSION); + int client_ver = parse_version(PG_VERSION); if (pset.sversion != client_ver) { const char *server_version; - char server_ver_str[16]; + char server_ver_str[16]; /* Try to get full text form, might include "devel" etc */ server_version = PQparameterStatus(pset.db, "server_version"); @@ -341,18 +341,18 @@ main(int argc, char *argv[]) pset.progname, PG_VERSION); printf(_("Type: \\copyright for distribution terms\n" - " \\h for help with SQL commands\n" - " \\? for help with psql commands\n" - " \\g or terminate with semicolon to execute query\n" - " \\q to quit\n\n")); + " \\h for help with SQL commands\n" + " \\? for help with psql commands\n" + " \\g or terminate with semicolon to execute query\n" + " \\q to quit\n\n")); if (pset.sversion / 100 != client_ver / 100) printf(_("WARNING: You are connected to a server with major version %d.%d,\n" "but your %s client is major version %d.%d. Some backslash commands,\n" "such as \\d, might not work properly.\n\n"), - pset.sversion / 10000, (pset.sversion / 100) % 100, - pset.progname, - client_ver / 10000, (client_ver / 100) % 100); + pset.sversion / 10000, (pset.sversion / 100) % 100, + pset.progname, + client_ver / 10000, (client_ver / 100) % 100); #ifdef USE_SSL printSSLInfo(); @@ -556,8 +556,8 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options) break; case 'u': pset.getPassword = true; - options->username = "\001"; /* hopefully nobody has - * that username */ + options->username = "\001"; /* hopefully nobody has that + * username */ /* this option is out */ used_old_u_option = true; break; @@ -630,8 +630,7 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options) } /* - * if we still have arguments, use it as the database name and - * username + * if we still have arguments, use it as the database name and username */ while (argc - optind >= 1) { @@ -691,9 +690,9 @@ process_psqlrc_file(char *filename) sprintf(psqlrc, "%s-%s", filename, PG_VERSION); if (access(psqlrc, R_OK) == 0) - (void)process_file(psqlrc); + (void) process_file(psqlrc); else if (access(filename, R_OK) == 0) - (void)process_file(filename); + (void) process_file(filename); free(psqlrc); } @@ -755,9 +754,9 @@ checkWin32Codepage(void) concp = GetConsoleCP(); if (wincp != concp) { - printf(_("Warning: Console code page (%u) differs from Windows code page (%u)\n" - " 8-bit characters may not work correctly. See psql reference\n" - " page \"Notes for Windows users\" for details.\n\n"), + printf(_("Warning: Console code page (%u) differs from Windows code page (%u)\n" + " 8-bit characters may not work correctly. See psql reference\n" + " page \"Notes for Windows users\" for details.\n\n"), concp, wincp); } } diff --git a/src/bin/psql/stringutils.c b/src/bin/psql/stringutils.c index 0087b1a623..b60033ccc8 100644 --- a/src/bin/psql/stringutils.c +++ b/src/bin/psql/stringutils.c @@ -3,7 +3,7 @@ * * Copyright (c) 2000-2005, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/stringutils.c,v 1.40 2005/01/01 05:43:08 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/psql/stringutils.c,v 1.41 2005/10/15 02:49:40 momjian Exp $ */ #include "postgres_fe.h" @@ -58,10 +58,10 @@ strtokx(const char *s, bool del_quotes, int encoding) { - static char *storage = NULL;/* store the local copy of the users - * string here */ - static char *string = NULL; /* pointer into storage where to continue - * on next call */ + static char *storage = NULL;/* store the local copy of the users string + * here */ + static char *string = NULL; /* pointer into storage where to continue on + * next call */ /* variously abused variables: */ unsigned int offset; @@ -74,8 +74,8 @@ strtokx(const char *s, /* * We may need extra space to insert delimiter nulls for adjacent - * tokens. 2X the space is a gross overestimate, but it's - * unlikely that this code will be used on huge strings anyway. + * tokens. 2X the space is a gross overestimate, but it's unlikely + * that this code will be used on huge strings anyway. */ storage = pg_malloc(2 * strlen(s) + 1); strcpy(storage, s); @@ -103,11 +103,11 @@ strtokx(const char *s, if (delim && strchr(delim, *start)) { /* - * If not at end of string, we need to insert a null to terminate - * the returned token. We can just overwrite the next character - * if it happens to be in the whitespace set ... otherwise move - * over the rest of the string to make room. (This is why we - * allocated extra space above). + * If not at end of string, we need to insert a null to terminate the + * returned token. We can just overwrite the next character if it + * happens to be in the whitespace set ... otherwise move over the + * rest of the string to make room. (This is why we allocated extra + * space above). */ p = start + 1; if (*p != '\0') @@ -146,8 +146,8 @@ strtokx(const char *s, } /* - * If not at end of string, we need to insert a null to terminate - * the returned token. See notes above. + * If not at end of string, we need to insert a null to terminate the + * returned token. See notes above. */ if (*p != '\0') { @@ -170,10 +170,9 @@ strtokx(const char *s, } /* - * Otherwise no quoting character. Scan till next whitespace, - * delimiter or quote. NB: at this point, *start is known not to be - * '\0', whitespace, delim, or quote, so we will consume at least one - * character. + * Otherwise no quoting character. Scan till next whitespace, delimiter + * or quote. NB: at this point, *start is known not to be '\0', + * whitespace, delim, or quote, so we will consume at least one character. */ offset = strcspn(start, whitespace); diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index 3a5fe0ab1f..27d7469b93 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -3,7 +3,7 @@ * * Copyright (c) 2000-2005, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.137 2005/08/14 18:49:30 tgl Exp $ + * $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.138 2005/10/15 02:49:40 momjian Exp $ */ /*---------------------------------------------------------------------- @@ -83,30 +83,28 @@ typedef struct SchemaQuery const char *catname; /* - * Selection condition --- only rows meeting this condition are - * candidates to display. If catname mentions multiple tables, - * include the necessary join condition here. For example, "c.relkind - * = 'r'". Write NULL (not an empty string) if not needed. + * Selection condition --- only rows meeting this condition are candidates + * to display. If catname mentions multiple tables, include the necessary + * join condition here. For example, "c.relkind = 'r'". Write NULL (not + * an empty string) if not needed. */ const char *selcondition; /* * Visibility condition --- which rows are visible without schema - * qualification? For example, - * "pg_catalog.pg_table_is_visible(c.oid)". + * qualification? For example, "pg_catalog.pg_table_is_visible(c.oid)". */ const char *viscondition; /* - * Namespace --- name of field to join to pg_namespace.oid. For - * example, "c.relnamespace". + * Namespace --- name of field to join to pg_namespace.oid. For example, + * "c.relnamespace". */ const char *namespace; /* - * Result --- the appropriately-quoted name to return, in the case of - * an unqualified name. For example, - * "pg_catalog.quote_ident(c.relname)". + * Result --- the appropriately-quoted name to return, in the case of an + * unqualified name. For example, "pg_catalog.quote_ident(c.relname)". */ const char *result; @@ -128,8 +126,7 @@ static int completion_max_records; * the completion callback functions. Ugly but there is no better way. */ static const char *completion_charp; /* to pass a string */ -static const char *const * completion_charpp; /* to pass a list of - * strings */ +static const char *const * completion_charpp; /* to pass a list of strings */ static const char *completion_info_charp; /* to pass a second string */ static const SchemaQuery *completion_squery; /* to pass a SchemaQuery */ @@ -433,9 +430,13 @@ typedef struct static const pgsql_thing_t words_after_create[] = { {"AGGREGATE", NULL, &Query_for_list_of_aggregates}, - {"CAST", NULL, NULL}, /* Casts have complex structures for - * names, so skip it */ - /* CREATE CONSTRAINT TRIGGER is not supported here because it is designed to be used only by pg_dump. */ + {"CAST", NULL, NULL}, /* Casts have complex structures for names, so + * skip it */ + + /* + * CREATE CONSTRAINT TRIGGER is not supported here because it is designed + * to be used only by pg_dump. + */ {"CONVERSION", "SELECT pg_catalog.quote_ident(conname) FROM pg_catalog.pg_conversion WHERE substring(pg_catalog.quote_ident(conname),1,%d)='%s'"}, {"DATABASE", Query_for_list_of_databases}, {"DOMAIN", NULL, &Query_for_list_of_domains}, @@ -443,8 +444,8 @@ static const pgsql_thing_t words_after_create[] = { {"GROUP", Query_for_list_of_roles}, {"LANGUAGE", Query_for_list_of_languages}, {"INDEX", NULL, &Query_for_list_of_indexes}, - {"OPERATOR", NULL, NULL}, /* Querying for this is probably not such - * a good idea. */ + {"OPERATOR", NULL, NULL}, /* Querying for this is probably not such a + * good idea. */ {"ROLE", Query_for_list_of_roles}, {"RULE", "SELECT pg_catalog.quote_ident(rulename) FROM pg_catalog.pg_rules WHERE substring(pg_catalog.quote_ident(rulename),1,%d)='%s'"}, {"SCHEMA", Query_for_list_of_schemas}, @@ -493,8 +494,8 @@ initialize_readline(void) completion_max_records = 1000; /* - * There is a variable rl_completion_query_items for this but - * apparently it's not defined everywhere. + * There is a variable rl_completion_query_items for this but apparently + * it's not defined everywhere. */ } @@ -550,9 +551,8 @@ psql_completion(char *text, int start, int end) /* * Scan the input line before our current position for the last four - * words. According to those we'll make some smart decisions on what - * the user is probably intending to type. TODO: Use strtokx() to do - * this. + * words. According to those we'll make some smart decisions on what the + * user is probably intending to type. TODO: Use strtokx() to do this. */ prev_wd = previous_word(start, 0); prev2_wd = previous_word(start, 1); @@ -580,8 +580,8 @@ psql_completion(char *text, int start, int end) /* ALTER */ /* - * complete with what you can alter (TABLE, GROUP, USER, ...) unless - * we're in ALTER TABLE sth ALTER + * complete with what you can alter (TABLE, GROUP, USER, ...) unless we're + * in ALTER TABLE sth ALTER */ else if (pg_strcasecmp(prev_wd, "ALTER") == 0 && pg_strcasecmp(prev3_wd, "TABLE") != 0) @@ -595,18 +595,18 @@ psql_completion(char *text, int start, int end) } /* ALTER AGGREGATE,FUNCTION */ else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 && - (pg_strcasecmp(prev2_wd, "AGGREGATE") == 0 || + (pg_strcasecmp(prev2_wd, "AGGREGATE") == 0 || pg_strcasecmp(prev2_wd, "FUNCTION") == 0)) { static const char *const list_ALTERAGG[] = - {"OWNER TO", "RENAME TO","SET SCHEMA", NULL}; + {"OWNER TO", "RENAME TO", "SET SCHEMA", NULL}; - COMPLETE_WITH_LIST(list_ALTERAGG); + COMPLETE_WITH_LIST(list_ALTERAGG); } /* ALTER CONVERSION,SCHEMA */ else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 && - (pg_strcasecmp(prev2_wd, "CONVERSION") == 0 || + (pg_strcasecmp(prev2_wd, "CONVERSION") == 0 || pg_strcasecmp(prev2_wd, "SCHEMA") == 0)) { static const char *const list_ALTERGEN[] = @@ -643,23 +643,23 @@ psql_completion(char *text, int start, int end) /* ALTER USER,ROLE */ else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 && (pg_strcasecmp(prev2_wd, "USER") == 0 || - pg_strcasecmp(prev2_wd, "ROLE") == 0)) + pg_strcasecmp(prev2_wd, "ROLE") == 0)) { static const char *const list_ALTERUSER[] = {"ENCRYPTED", "UNENCRYPTED", "CREATEDB", "NOCREATEDB", "CREATEUSER", - "NOCREATEUSER","CREATEROLE","NOCREATEROLE","INHERIT","NOINHERIT", - "LOGIN","NOLOGIN","CONNECTION LIMIT", "VALID UNTIL", "RENAME TO", - "SUPERUSER","NOSUPERUSER", "SET", "RESET", NULL}; + "NOCREATEUSER", "CREATEROLE", "NOCREATEROLE", "INHERIT", "NOINHERIT", + "LOGIN", "NOLOGIN", "CONNECTION LIMIT", "VALID UNTIL", "RENAME TO", + "SUPERUSER", "NOSUPERUSER", "SET", "RESET", NULL}; COMPLETE_WITH_LIST(list_ALTERUSER); } /* complete ALTER USER,ROLE ENCRYPTED,UNENCRYPTED with PASSWORD */ else if (pg_strcasecmp(prev4_wd, "ALTER") == 0 && - (pg_strcasecmp(prev3_wd, "ROLE") == 0 || pg_strcasecmp(prev3_wd, "USER") == 0) && - (pg_strcasecmp(prev_wd, "ENCRYPTED") == 0 || pg_strcasecmp(prev_wd, "UNENCRYPTED") == 0)) + (pg_strcasecmp(prev3_wd, "ROLE") == 0 || pg_strcasecmp(prev3_wd, "USER") == 0) && + (pg_strcasecmp(prev_wd, "ENCRYPTED") == 0 || pg_strcasecmp(prev_wd, "UNENCRYPTED") == 0)) { - COMPLETE_WITH_CONST("PASSWORD"); + COMPLETE_WITH_CONST("PASSWORD"); } /* ALTER DOMAIN */ else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 && @@ -694,21 +694,21 @@ psql_completion(char *text, int start, int end) else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 && pg_strcasecmp(prev2_wd, "SEQUENCE") == 0) { - static const char *const list_ALTERSEQUENCE[] = - {"INCREMENT", "MINVALUE", "MAXVALUE", "RESTART", "NO", "CACHE", "CYCLE", - "SET SCHEMA", NULL}; + static const char *const list_ALTERSEQUENCE[] = + {"INCREMENT", "MINVALUE", "MAXVALUE", "RESTART", "NO", "CACHE", "CYCLE", + "SET SCHEMA", NULL}; - COMPLETE_WITH_LIST(list_ALTERSEQUENCE); + COMPLETE_WITH_LIST(list_ALTERSEQUENCE); } /* ALTER SEQUENCE NO */ else if (pg_strcasecmp(prev4_wd, "ALTER") == 0 && pg_strcasecmp(prev3_wd, "SEQUENCE") == 0 && pg_strcasecmp(prev_wd, "NO") == 0) { - static const char *const list_ALTERSEQUENCE2[] = - {"MINVALUE", "MAXVALUE", "CYCLE", NULL}; + static const char *const list_ALTERSEQUENCE2[] = + {"MINVALUE", "MAXVALUE", "CYCLE", NULL}; - COMPLETE_WITH_LIST(list_ALTERSEQUENCE2); + COMPLETE_WITH_LIST(list_ALTERSEQUENCE2); } /* ALTER TRIGGER , add ON */ else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 && @@ -781,9 +781,9 @@ psql_completion(char *text, int start, int end) pg_strcasecmp(prev2_wd, "ALTER") == 0)) { /* DROP ... does not work well yet */ - static const char *const list_COLUMNALTER[] = + static const char *const list_COLUMNALTER[] = {"TYPE", "SET DEFAULT", "DROP DEFAULT", "SET NOT NULL", - "DROP NOT NULL", "SET STATISTICS", "SET STORAGE", NULL}; + "DROP NOT NULL", "SET STATISTICS", "SET STORAGE", NULL}; COMPLETE_WITH_LIST(list_COLUMNALTER); } @@ -802,7 +802,7 @@ psql_completion(char *text, int start, int end) pg_strcasecmp(prev_wd, "SET") == 0) { static const char *const list_TABLESET[] = - {"WITHOUT", "TABLESPACE","SCHEMA", NULL}; + {"WITHOUT", "TABLESPACE", "SCHEMA", NULL}; COMPLETE_WITH_LIST(list_TABLESET); } @@ -836,6 +836,7 @@ psql_completion(char *text, int start, int end) { static const char *const list_ALTERTYPE[] = {"OWNER TO", "SET SCHEMA", NULL}; + COMPLETE_WITH_LIST(list_ALTERTYPE); } /* complete ALTER GROUP */ @@ -869,9 +870,9 @@ psql_completion(char *text, int start, int end) {"WORK", "TRANSACTION", NULL}; COMPLETE_WITH_LIST(list_TRANS); - } + } /* COMMIT */ - else if(pg_strcasecmp(prev_wd, "COMMIT") == 0) + else if (pg_strcasecmp(prev_wd, "COMMIT") == 0) { static const char *const list_COMMIT[] = {"WORK", "TRANSACTION", "PREPARED", NULL}; @@ -904,8 +905,7 @@ psql_completion(char *text, int start, int end) COMPLETE_WITH_CONST("ON"); /* - * If we have CLUSTER ON, then add the correct tablename as - * well. + * If we have CLUSTER ON, then add the correct tablename as well. */ else if (pg_strcasecmp(prev3_wd, "CLUSTER") == 0 && pg_strcasecmp(prev_wd, "ON") == 0) @@ -923,7 +923,7 @@ psql_completion(char *text, int start, int end) static const char *const list_COMMENT[] = {"CAST", "CONVERSION", "DATABASE", "INDEX", "LANGUAGE", "RULE", "SCHEMA", "SEQUENCE", "TABLE", "TYPE", "VIEW", "COLUMN", "AGGREGATE", "FUNCTION", - "OPERATOR", "TRIGGER", "CONSTRAINT", "DOMAIN","LARGE OBJECT", NULL}; + "OPERATOR", "TRIGGER", "CONSTRAINT", "DOMAIN", "LARGE OBJECT", NULL}; COMPLETE_WITH_LIST(list_COMMENT); } @@ -946,12 +946,12 @@ psql_completion(char *text, int start, int end) else if (pg_strcasecmp(prev2_wd, "COPY") == 0 || pg_strcasecmp(prev2_wd, "\\copy") == 0 || pg_strcasecmp(prev2_wd, "BINARY") == 0) - { - static const char *const list_FROMTO[] = - {"FROM", "TO", NULL}; + { + static const char *const list_FROMTO[] = + {"FROM", "TO", NULL}; - COMPLETE_WITH_LIST(list_FROMTO); - } + COMPLETE_WITH_LIST(list_FROMTO); + } /* If we have COPY|BINARY FROM|TO, complete with filename */ else if ((pg_strcasecmp(prev3_wd, "COPY") == 0 || pg_strcasecmp(prev3_wd, "\\copy") == 0 || @@ -966,22 +966,22 @@ psql_completion(char *text, int start, int end) pg_strcasecmp(prev4_wd, "BINARY") == 0) && (pg_strcasecmp(prev2_wd, "FROM") == 0 || pg_strcasecmp(prev2_wd, "TO") == 0)) - { - static const char *const list_COPY[] = - {"BINARY", "OIDS", "DELIMITER", "NULL", "CSV", NULL}; + { + static const char *const list_COPY[] = + {"BINARY", "OIDS", "DELIMITER", "NULL", "CSV", NULL}; - COMPLETE_WITH_LIST(list_COPY); - } + COMPLETE_WITH_LIST(list_COPY); + } /* Handle COPY|BINARY FROM|TO filename CSV */ - else if (pg_strcasecmp(prev_wd, "CSV") == 0 && + else if (pg_strcasecmp(prev_wd, "CSV") == 0 && (pg_strcasecmp(prev3_wd, "FROM") == 0 || pg_strcasecmp(prev3_wd, "TO") == 0)) { - static const char *const list_CSV[] = - {"HEADER", "QUOTE", "ESCAPE", "FORCE QUOTE", NULL}; + static const char *const list_CSV[] = + {"HEADER", "QUOTE", "ESCAPE", "FORCE QUOTE", NULL}; - COMPLETE_WITH_LIST(list_CSV); + COMPLETE_WITH_LIST(list_CSV); } /* CREATE DATABASE */ @@ -990,7 +990,7 @@ psql_completion(char *text, int start, int end) { static const char *const list_DATABASE[] = {"OWNER", "TEMPLATE", "ENCODING", "TABLESPACE", "CONNECTION LIMIT", - NULL}; + NULL}; COMPLETE_WITH_LIST(list_DATABASE); } @@ -1011,8 +1011,8 @@ psql_completion(char *text, int start, int end) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL); /* - * Complete INDEX ON
with a list of table columns - * (which should really be in parens) + * Complete INDEX ON
with a list of table columns (which + * should really be in parens) */ else if (pg_strcasecmp(prev4_wd, "INDEX") == 0 && pg_strcasecmp(prev2_wd, "ON") == 0) @@ -1088,20 +1088,22 @@ psql_completion(char *text, int start, int end) /* CREATE TRIGGER */ /* complete CREATE TRIGGER with BEFORE,AFTER */ else if (pg_strcasecmp(prev3_wd, "CREATE") == 0 && - pg_strcasecmp(prev2_wd, "TRIGGER") == 0) + pg_strcasecmp(prev2_wd, "TRIGGER") == 0) { static const char *const list_CREATETRIGGER[] = - {"BEFORE", "AFTER", NULL}; - COMPLETE_WITH_LIST(list_CREATETRIGGER); + {"BEFORE", "AFTER", NULL}; + + COMPLETE_WITH_LIST(list_CREATETRIGGER); } /* complete CREATE TRIGGER BEFORE,AFTER sth with OR,ON */ else if (pg_strcasecmp(prev5_wd, "CREATE") == 0 && - pg_strcasecmp(prev4_wd, "TRIGGER") == 0 && - (pg_strcasecmp(prev2_wd, "BEFORE") == 0 || - pg_strcasecmp(prev2_wd, "AFTER") == 0)) + pg_strcasecmp(prev4_wd, "TRIGGER") == 0 && + (pg_strcasecmp(prev2_wd, "BEFORE") == 0 || + pg_strcasecmp(prev2_wd, "AFTER") == 0)) { static const char *const list_CREATETRIGGER2[] = - {"ON","OR",NULL}; + {"ON", "OR", NULL}; + COMPLETE_WITH_LIST(list_CREATETRIGGER2); } @@ -1111,29 +1113,35 @@ psql_completion(char *text, int start, int end) pg_strcasecmp(prev2_wd, "GROUP") == 0 || pg_strcasecmp(prev2_wd, "USER") == 0)) { static const char *const list_CREATEROLE[] = - {"ADMIN","CONNECTION LIMIT","CREATEDB","CREATEROLE","CREATEUSER", - "ENCRYPTED", "IN", "INHERIT", "LOGIN", "NOINHERIT", "NOLOGIN", "NOCREATEDB", - "NOCREATEROLE", "NOCREATEUSER", "NOSUPERUSER", "ROLE", "SUPERUSER", "SYSID", - "UNENCRYPTED",NULL}; - COMPLETE_WITH_LIST(list_CREATEROLE); + {"ADMIN", "CONNECTION LIMIT", "CREATEDB", "CREATEROLE", "CREATEUSER", + "ENCRYPTED", "IN", "INHERIT", "LOGIN", "NOINHERIT", "NOLOGIN", "NOCREATEDB", + "NOCREATEROLE", "NOCREATEUSER", "NOSUPERUSER", "ROLE", "SUPERUSER", "SYSID", + "UNENCRYPTED", NULL}; + + COMPLETE_WITH_LIST(list_CREATEROLE); } - /* complete CREATE ROLE,USER,GROUP ENCRYPTED,UNENCRYPTED with PASSWORD */ + + /* + * complete CREATE ROLE,USER,GROUP ENCRYPTED,UNENCRYPTED with + * PASSWORD + */ else if (pg_strcasecmp(prev4_wd, "CREATE") == 0 && - (pg_strcasecmp(prev3_wd, "ROLE") == 0 || - pg_strcasecmp(prev3_wd, "GROUP") == 0 || pg_strcasecmp(prev3_wd, "USER") == 0) && - (pg_strcasecmp(prev_wd, "ENCRYPTED") == 0 || pg_strcasecmp(prev_wd, "UNENCRYPTED") == 0)) + (pg_strcasecmp(prev3_wd, "ROLE") == 0 || + pg_strcasecmp(prev3_wd, "GROUP") == 0 || pg_strcasecmp(prev3_wd, "USER") == 0) && + (pg_strcasecmp(prev_wd, "ENCRYPTED") == 0 || pg_strcasecmp(prev_wd, "UNENCRYPTED") == 0)) { - COMPLETE_WITH_CONST("PASSWORD"); + COMPLETE_WITH_CONST("PASSWORD"); } /* complete CREATE ROLE,USER,GROUP IN with ROLE,GROUP */ else if (pg_strcasecmp(prev4_wd, "CREATE") == 0 && - (pg_strcasecmp(prev3_wd, "ROLE") == 0 || - pg_strcasecmp(prev3_wd, "GROUP") == 0 || pg_strcasecmp(prev3_wd, "USER") == 0) && - pg_strcasecmp(prev_wd, "IN") == 0) + (pg_strcasecmp(prev3_wd, "ROLE") == 0 || + pg_strcasecmp(prev3_wd, "GROUP") == 0 || pg_strcasecmp(prev3_wd, "USER") == 0) && + pg_strcasecmp(prev_wd, "IN") == 0) { static const char *const list_CREATEROLE3[] = - {"GROUP","ROLE",NULL}; - COMPLETE_WITH_LIST(list_CREATEROLE3); + {"GROUP", "ROLE", NULL}; + + COMPLETE_WITH_LIST(list_CREATEROLE3); } /* CREATE VIEW */ @@ -1150,20 +1158,23 @@ psql_completion(char *text, int start, int end) /* DECLARE */ else if (pg_strcasecmp(prev2_wd, "DECLARE") == 0) { - static const char *const list_DECLARE[] = - {"BINARY", "INSENSITIVE", "SCROLL", "NO SCROLL", "CURSOR", NULL}; - COMPLETE_WITH_LIST(list_DECLARE); + static const char *const list_DECLARE[] = + {"BINARY", "INSENSITIVE", "SCROLL", "NO SCROLL", "CURSOR", NULL}; + + COMPLETE_WITH_LIST(list_DECLARE); } else if (pg_strcasecmp(prev_wd, "CURSOR") == 0) { - static const char *const list_DECLARECURSOR[] = - {"WITH HOLD", "WITHOUT HOLD", "FOR", NULL}; - COMPLETE_WITH_LIST(list_DECLARECURSOR); + static const char *const list_DECLARECURSOR[] = + {"WITH HOLD", "WITHOUT HOLD", "FOR", NULL}; + + COMPLETE_WITH_LIST(list_DECLARECURSOR); } /* DELETE */ + /* * Complete DELETE with FROM (only if the word before that is not "ON" * (cf. rules) or "BEFORE" or "AFTER" (cf. triggers) or GRANT) @@ -1211,27 +1222,31 @@ psql_completion(char *text, int start, int end) pg_strcasecmp(prev3_wd, "AGGREGATE") == 0 && prev_wd[strlen(prev_wd) - 1] == ')')) { - static const char *const list_DROPCR[] = - {"CASCADE", "RESTRICT", NULL}; - COMPLETE_WITH_LIST(list_DROPCR); + static const char *const list_DROPCR[] = + {"CASCADE", "RESTRICT", NULL}; + + COMPLETE_WITH_LIST(list_DROPCR); } /* EXPLAIN */ + /* * Complete EXPLAIN [ANALYZE] [VERBOSE] with list of EXPLAIN-able commands */ else if (pg_strcasecmp(prev_wd, "EXPLAIN") == 0) { - static const char *const list_EXPLAIN[] = - {"SELECT","INSERT","DELETE","UPDATE","DECLARE","ANALYZE","VERBOSE",NULL}; - COMPLETE_WITH_LIST(list_EXPLAIN); + static const char *const list_EXPLAIN[] = + {"SELECT", "INSERT", "DELETE", "UPDATE", "DECLARE", "ANALYZE", "VERBOSE", NULL}; + + COMPLETE_WITH_LIST(list_EXPLAIN); } else if (pg_strcasecmp(prev2_wd, "EXPLAIN") == 0 && - pg_strcasecmp(prev_wd, "ANALYZE") == 0) + pg_strcasecmp(prev_wd, "ANALYZE") == 0) { - static const char *const list_EXPLAIN[] = - {"SELECT","INSERT","DELETE","UPDATE","DECLARE","VERBOSE",NULL}; - COMPLETE_WITH_LIST(list_EXPLAIN); + static const char *const list_EXPLAIN[] = + {"SELECT", "INSERT", "DELETE", "UPDATE", "DECLARE", "VERBOSE", NULL}; + + COMPLETE_WITH_LIST(list_EXPLAIN); } else if (pg_strcasecmp(prev_wd, "VERBOSE") == 0 && pg_strcasecmp(prev3_wd, "VACUUM") != 0 && @@ -1239,9 +1254,10 @@ psql_completion(char *text, int start, int end) (pg_strcasecmp(prev2_wd, "ANALYZE") == 0 || pg_strcasecmp(prev2_wd, "EXPLAIN") == 0)) { - static const char *const list_EXPLAIN[] = - {"SELECT","INSERT","DELETE","UPDATE","DECLARE",NULL}; - COMPLETE_WITH_LIST(list_EXPLAIN); + static const char *const list_EXPLAIN[] = + {"SELECT", "INSERT", "DELETE", "UPDATE", "DECLARE", NULL}; + + COMPLETE_WITH_LIST(list_EXPLAIN); } /* FETCH && MOVE */ @@ -1265,9 +1281,9 @@ psql_completion(char *text, int start, int end) } /* - * Complete FETCH with "FROM" or "IN". These are - * equivalent, but we may as well tab-complete both: perhaps some - * users prefer one variant or the other. + * Complete FETCH with "FROM" or "IN". These are equivalent, + * but we may as well tab-complete both: perhaps some users prefer one + * variant or the other. */ else if (pg_strcasecmp(prev3_wd, "FETCH") == 0 || pg_strcasecmp(prev3_wd, "MOVE") == 0) @@ -1295,15 +1311,15 @@ psql_completion(char *text, int start, int end) COMPLETE_WITH_CONST("ON"); /* - * Complete GRANT/REVOKE ON with a list of tables, views, - * sequences, and indexes + * Complete GRANT/REVOKE ON with a list of tables, views, sequences, + * and indexes * - * keywords DATABASE, FUNCTION, LANGUAGE, SCHEMA added to query result - * via UNION; seems to work intuitively + * keywords DATABASE, FUNCTION, LANGUAGE, SCHEMA added to query result via + * UNION; seems to work intuitively * - * Note: GRANT/REVOKE can get quite complex; tab-completion as - * implemented here will only work if the privilege list contains - * exactly one privilege + * Note: GRANT/REVOKE can get quite complex; tab-completion as implemented + * here will only work if the privilege list contains exactly one + * privilege */ else if ((pg_strcasecmp(prev3_wd, "GRANT") == 0 || pg_strcasecmp(prev3_wd, "REVOKE") == 0) && @@ -1564,7 +1580,7 @@ psql_completion(char *text, int start, int end) COMPLETE_WITH_LIST(constraint_list); } /* Complete SET ROLE */ - else if (pg_strcasecmp(prev2_wd, "SET") == 0 && + else if (pg_strcasecmp(prev2_wd, "SET") == 0 && pg_strcasecmp(prev_wd, "ROLE") == 0) COMPLETE_WITH_QUERY(Query_for_list_of_roles); /* Complete SET SESSION with AUTHORIZATION or CHARACTERISTICS... */ @@ -1589,14 +1605,14 @@ psql_completion(char *text, int start, int end) COMPLETE_WITH_CONST("TO"); /* Suggest possible variable values */ else if (pg_strcasecmp(prev3_wd, "SET") == 0 && - (pg_strcasecmp(prev_wd, "TO") == 0 || strcmp(prev_wd, "=") == 0)) + (pg_strcasecmp(prev_wd, "TO") == 0 || strcmp(prev_wd, "=") == 0)) { if (pg_strcasecmp(prev2_wd, "DateStyle") == 0) { static const char *const my_list[] = {"ISO", "SQL", "Postgres", "German", - "YMD", "DMY", "MDY", - "US", "European", "NonEuropean", + "YMD", "DMY", "MDY", + "US", "European", "NonEuropean", "DEFAULT", NULL}; COMPLETE_WITH_LIST(my_list); @@ -1638,16 +1654,16 @@ psql_completion(char *text, int start, int end) COMPLETE_WITH_CONST("SET"); /* - * If the previous word is SET (and it wasn't caught above as the - * _first_ word) the word before it was (hopefully) a table name and - * we'll now make a list of attributes. + * If the previous word is SET (and it wasn't caught above as the _first_ + * word) the word before it was (hopefully) a table name and we'll now + * make a list of attributes. */ else if (pg_strcasecmp(prev_wd, "SET") == 0) COMPLETE_WITH_ATTR(prev2_wd); /* UPDATE xx SET yy = */ else if (pg_strcasecmp(prev2_wd, "SET") == 0 && - pg_strcasecmp(prev4_wd, "UPDATE") == 0) + pg_strcasecmp(prev4_wd, "UPDATE") == 0) COMPLETE_WITH_CONST("="); /* @@ -1756,21 +1772,144 @@ psql_completion(char *text, int start, int end) COMPLETE_WITH_LIST(my_list); } else if (strcmp(prev_wd, "\\cd") == 0 || - strcmp(prev_wd, "\\e") == 0 || strcmp(prev_wd, "\\edit") == 0 || + strcmp(prev_wd, "\\e") == 0 || strcmp(prev_wd, "\\edit") == 0 || strcmp(prev_wd, "\\g") == 0 || - strcmp(prev_wd, "\\i") == 0 || strcmp(prev_wd, "\\include") == 0 || - strcmp(prev_wd, "\\o") == 0 || strcmp(prev_wd, "\\out") == 0 || + strcmp(prev_wd, "\\i") == 0 || strcmp(prev_wd, "\\include") == 0 || + strcmp(prev_wd, "\\o") == 0 || strcmp(prev_wd, "\\out") == 0 || strcmp(prev_wd, "\\s") == 0 || - strcmp(prev_wd, "\\w") == 0 || strcmp(prev_wd, "\\write") == 0 + strcmp(prev_wd, "\\w") == 0 || strcmp(prev_wd, "\\write") == 0 ) matches = completion_matches(text, filename_completion_function); - /* - * Finally, we look through the list of "things", such as TABLE, INDEX - * and check if that was the previous word. If so, execute the query - * to get a list of them. - */ + /* + * + * Fi + * n + * a + * l + * l + * y + * , + * + * we + * + * lo + * o + * k + * + * th + * r + * o + * u + * g + * h + * + * th + * e + * + * li + * s + * t + * + * of + * + * "t + * h + * i + * n + * g + * s + * " + * , + * + * su + * c + * h + * + * as + * + * TA + * B + * L + * E + * , + * + * IN + * D + * E + * X + * + * an + * d + * + * ch + * e + * c + * k + * + * if + * + * th + * a + * t + * + * wa + * s + * + * th + * e + * + * pr + * e + * v + * i + * o + * u + * s + * + * wo + * r + * d + * . + * + * If + * + * so + * , + * + * ex + * e + * c + * u + * t + * e + * + * th + * e + * + * qu + * e + * r + * y + * + * to + * + * ge + * t + * + * a + * li + * s + * t + * + * of + * + * th + * e + * m + * . + * */ else { int i; @@ -1789,30 +1928,236 @@ psql_completion(char *text, int start, int end) } } - /* - * If we still don't have anything to match we have to fabricate some - * sort of default list. If we were to just return NULL, readline - * automatically attempts filename completion, and that's usually no - * good. - */ - if (matches == NULL) - { - COMPLETE_WITH_CONST(""); + /* + * + * If + * + * we + * + * st + * i + * l + * l + * + * do + * n + * ' + * t + * + * ha + * v + * e + * + * an + * y + * t + * h + * i + * n + * g + * + * to + * + * ma + * t + * c + * h + * + * we + * + * ha + * v + * e + * + * to + * + * fa + * b + * r + * i + * c + * a + * t + * e + * + * so + * m + * e + * + * so + * r + * t + * + * of + * + * de + * f + * a + * u + * l + * t + * + * li + * s + * t + * . + * + * If + * + * we + * + * we + * r + * e + * + * to + * + * ju + * s + * t + * + * re + * t + * u + * r + * n + * + * NU + * L + * L + * , + * + * re + * a + * d + * l + * i + * n + * e + * + * au + * t + * o + * m + * a + * t + * i + * c + * a + * l + * l + * y + * + * at + * t + * e + * m + * p + * t + * s + * + * fi + * l + * e + * n + * a + * m + * e + * + * co + * m + * p + * l + * e + * t + * i + * o + * n + * , + * + * an + * d + * + * th + * a + * t + * ' + * s + * + * us + * u + * a + * l + * l + * y + * + * no + * + * go + * o + * d + * . + * */ + if (matches == NULL) + { + COMPLETE_WITH_CONST(""); #ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER - rl_completion_append_character = '\0'; + rl_completion_append_character = '\0'; #endif - } + } - /* free storage */ - free(prev_wd); - free(prev2_wd); - free(prev3_wd); - free(prev4_wd); - free(prev5_wd); + /* + * f + * r + * e + * e + * + * st + * o + * r + * a + * g + * e + * + */ + free(prev_wd); + free(prev2_wd); + free(prev3_wd); + free(prev4_wd); + free(prev5_wd); - /* Return our Grand List O' Matches */ - return matches; -} + /* + * R + * e + * t + * u + * r + * n + * + * ou + * r + * + * Gr + * a + * n + * d + * + * Li + * s + * t + * + * O' + * + * Ma + * t + * c + * h + * e + * s + * + */ + return matches; + } @@ -1832,43 +2177,152 @@ psql_completion(char *text, int start, int end) /* This one gives you one from a list of things you can put after CREATE or DROP as defined above. */ -static char * -create_command_generator(const char *text, int state) -{ - static int list_index, - string_length; - const char *name; + static char * + create_command_generator(const char *text, int state) + { + static int list_index, + string_length; + const char *name; - /* If this is the first time for this completion, init some values */ - if (state == 0) - { - list_index = 0; - string_length = strlen(text); - } + /* + * I + * f + * + * th + * i + * s + * + * is + * + * th + * e + * + * fi + * r + * s + * t + * + * ti + * m + * e + * + * fo + * r + * + * th + * i + * s + * + * co + * m + * p + * l + * e + * t + * i + * o + * n + * , + * + * in + * i + * t + * + * so + * m + * e + * + * va + * l + * u + * e + * s + * + */ + if (state == 0) + { + list_index = 0; + string_length = strlen(text); + } - /* find something that matches */ - while ((name = words_after_create[list_index++].name)) - if (pg_strncasecmp(name, text, string_length) == 0) - return pg_strdup(name); + /* + * f + * i + * n + * d + * + * so + * m + * e + * t + * h + * i + * n + * g + * + * th + * a + * t + * + * ma + * t + * c + * h + * e + * s + * + */ + while ((name = words_after_create[list_index++].name)) + if (pg_strncasecmp(name, text, string_length) == 0) + return pg_strdup(name); - /* if nothing matches, return NULL */ - return NULL; -} + /* + * i + * f + * + * no + * t + * h + * i + * n + * g + * + * ma + * t + * c + * h + * e + * s + * , + * + * re + * t + * u + * r + * n + * + * NU + * L + * L + * + */ + return NULL; + } /* The following two functions are wrappers for _complete_from_query */ -static char * -complete_from_query(const char *text, int state) -{ - return _complete_from_query(0, text, state); -} + static char * + complete_from_query(const char *text, int state) + { + return _complete_from_query(0, text, state); + } -static char * -complete_from_schema_query(const char *text, int state) -{ - return _complete_from_query(1, text, state); -} + static char * + complete_from_schema_query(const char *text, int state) + { + return _complete_from_query(1, text, state); + } /* This creates a list of matching things, according to a query pointed to @@ -1890,229 +2344,1308 @@ complete_from_schema_query(const char *text, int state) See top of file for examples of both kinds of query. */ -static char * -_complete_from_query(int is_schema_query, const char *text, int state) -{ - static int list_index, - string_length; - static PGresult *result = NULL; + static char * + _complete_from_query(int is_schema_query, const char *text, int state) + { + static int list_index, + string_length; + static PGresult *result = NULL; - /* - * If this is the first time for this completion, we fetch a list of - * our "things" from the backend. - */ - if (state == 0) - { - PQExpBufferData query_buffer; - char *e_text; - char *e_info_charp; + /* + * + * If + * + * th + * i + * s + * + * is + * + * th + * e + * + * fi + * r + * s + * t + * + * ti + * m + * e + * + * fo + * r + * + * th + * i + * s + * + * co + * m + * p + * l + * e + * t + * i + * o + * n + * , + * + * we + * + * fe + * t + * c + * h + * + * a + * li + * s + * t + * + * of + * + * ou + * r + * + * "t + * h + * i + * n + * g + * s + * " + * + * fr + * o + * m + * + * th + * e + * + * ba + * c + * k + * e + * n + * d + * . + * */ + if (state == 0) + { + PQExpBufferData query_buffer; + char *e_text; + char *e_info_charp; - list_index = 0; - string_length = strlen(text); + list_index = 0; + string_length = strlen(text); - /* Free any prior result */ - PQclear(result); - result = NULL; + /* + * F + * r + * e + * e + * + * an + * y + * + * pr + * i + * o + * r + * + * re + * s + * u + * l + * t + * + */ + PQclear(result); + result = NULL; - /* Set up suitably-escaped copies of textual inputs */ - e_text = pg_malloc(string_length * 2 + 1); - PQescapeString(e_text, text, string_length); + /* + * S + * e + * t + * + * up + * + * su + * i + * t + * a + * b + * l + * y + * - + * e + * s + * c + * a + * p + * e + * d + * + * co + * p + * i + * e + * s + * + * of + * + * te + * x + * t + * u + * a + * l + * + * in + * p + * u + * t + * s + * + */ + e_text = pg_malloc(string_length * 2 + 1); + PQescapeString(e_text, text, string_length); - if (completion_info_charp) - { - size_t charp_len; + if (completion_info_charp) + { + size_t charp_len; - charp_len = strlen(completion_info_charp); - e_info_charp = pg_malloc(charp_len * 2 + 1); - PQescapeString(e_info_charp, completion_info_charp, - charp_len); - } - else - e_info_charp = NULL; + charp_len = strlen(completion_info_charp); + e_info_charp = pg_malloc(charp_len * 2 + 1); + PQescapeString(e_info_charp, completion_info_charp, + charp_len); + } + else + e_info_charp = NULL; - initPQExpBuffer(&query_buffer); + initPQExpBuffer(&query_buffer); - if (is_schema_query) - { - /* completion_squery gives us the pieces to assemble */ - const char *qualresult = completion_squery->qualresult; + if (is_schema_query) + { + /* + * c + * o + * m + * p + * l + * e + * t + * i + * o + * n + * _ + * s + * q + * u + * e + * r + * y + * + * gi + * v + * e + * s + * + * us + * + * th + * e + * + * pi + * e + * c + * e + * s + * + * to + * + * as + * s + * e + * m + * b + * l + * e + * + */ + const char *qualresult = completion_squery->qualresult; - if (qualresult == NULL) - qualresult = completion_squery->result; + if (qualresult == NULL) + qualresult = completion_squery->result; - /* Get unqualified names matching the input-so-far */ - appendPQExpBuffer(&query_buffer, "SELECT %s FROM %s WHERE ", - completion_squery->result, - completion_squery->catname); - if (completion_squery->selcondition) - appendPQExpBuffer(&query_buffer, "%s AND ", - completion_squery->selcondition); - appendPQExpBuffer(&query_buffer, "substring(%s,1,%d)='%s'", - completion_squery->result, - string_length, e_text); - appendPQExpBuffer(&query_buffer, " AND %s", - completion_squery->viscondition); + /* + * G + * e + * t + * + * un + * q + * u + * a + * l + * i + * f + * i + * e + * d + * + * na + * m + * e + * s + * + * ma + * t + * c + * h + * i + * n + * g + * + * th + * e + * + * in + * p + * u + * t + * - + * s + * o + * - + * f + * a + * r + * + */ + appendPQExpBuffer(&query_buffer, "SELECT %s FROM %s WHERE ", + completion_squery->result, + completion_squery->catname); + if (completion_squery->selcondition) + appendPQExpBuffer(&query_buffer, "%s AND ", + completion_squery->selcondition); + appendPQExpBuffer(&query_buffer, "substring(%s,1,%d)='%s'", + completion_squery->result, + string_length, e_text); + appendPQExpBuffer(&query_buffer, " AND %s", + completion_squery->viscondition); - /* - * When fetching relation names, suppress system catalogs - * unless the input-so-far begins with "pg_". This is a - * compromise between not offering system catalogs for - * completion at all, and having them swamp the result when - * the input is just "p". - */ - if (strcmp(completion_squery->catname, - "pg_catalog.pg_class c") == 0 && - strncmp(text, "pg_", 3) !=0) - { - appendPQExpBuffer(&query_buffer, - " AND c.relnamespace <> (SELECT oid FROM" - " pg_catalog.pg_namespace WHERE nspname = 'pg_catalog')"); - } + /* + * + * Wh + * e + * n + * + * fe + * t + * c + * h + * i + * n + * g + * + * re + * l + * a + * t + * i + * o + * n + * + * na + * m + * e + * s + * , + * + * su + * p + * p + * r + * e + * s + * s + * + * sy + * s + * t + * e + * m + * + * ca + * t + * a + * l + * o + * g + * s + * + * un + * l + * e + * s + * s + * + * th + * e + * + * in + * p + * u + * t + * - + * s + * o + * - + * f + * a + * r + * + * be + * g + * i + * n + * s + * + * wi + * t + * h + * + * "p + * g + * _ + * " + * . + * + * Th + * i + * s + * + * is + * + * a + * co + * m + * p + * r + * o + * m + * i + * s + * e + * + * be + * t + * w + * e + * e + * n + * + * no + * t + * + * of + * f + * e + * r + * i + * n + * g + * + * sy + * s + * t + * e + * m + * + * ca + * t + * a + * l + * o + * g + * s + * + * fo + * r + * + * co + * m + * p + * l + * e + * t + * i + * o + * n + * + * at + * + * al + * l + * , + * + * an + * d + * + * ha + * v + * i + * n + * g + * + * th + * e + * m + * + * sw + * a + * m + * p + * + * th + * e + * + * re + * s + * u + * l + * t + * + * wh + * e + * n + * + * th + * e + * + * in + * p + * u + * t + * + * is + * + * ju + * s + * t + * + * "p + * " + * . + * */ + if (strcmp(completion_squery->catname, + "pg_catalog.pg_class c") == 0 && + strncmp(text, "pg_", 3) !=0) + { + appendPQExpBuffer(&query_buffer, + " AND c.relnamespace <> (SELECT oid FROM" + " pg_catalog.pg_namespace WHERE nspname = 'pg_catalog')"); + } - /* - * Add in matching schema names, but only if there is more - * than one potential match among schema names. - */ - appendPQExpBuffer(&query_buffer, "\nUNION\n" - "SELECT pg_catalog.quote_ident(n.nspname) || '.' " - "FROM pg_catalog.pg_namespace n " - "WHERE substring(pg_catalog.quote_ident(n.nspname) || '.',1,%d)='%s'", - string_length, e_text); - appendPQExpBuffer(&query_buffer, - " AND (SELECT pg_catalog.count(*)" - " FROM pg_catalog.pg_namespace" - " WHERE substring(pg_catalog.quote_ident(nspname) || '.',1,%d) =" - " substring('%s',1,pg_catalog.length(pg_catalog.quote_ident(nspname))+1)) > 1", - string_length, e_text); + /* + * + * Ad + * d + * + * in + * + * ma + * t + * c + * h + * i + * n + * g + * + * sc + * h + * e + * m + * a + * + * na + * m + * e + * s + * , + * + * bu + * t + * + * on + * l + * y + * + * if + * + * th + * e + * r + * e + * + * is + * + * mo + * r + * e + * + * th + * a + * n + * + * on + * e + * + * po + * t + * e + * n + * t + * i + * a + * l + * + * ma + * t + * c + * h + * + * am + * o + * n + * g + * + * sc + * h + * e + * m + * a + * + * na + * m + * e + * s + * . + * */ + appendPQExpBuffer(&query_buffer, "\nUNION\n" + "SELECT pg_catalog.quote_ident(n.nspname) || '.' " + "FROM pg_catalog.pg_namespace n " + "WHERE substring(pg_catalog.quote_ident(n.nspname) || '.',1,%d)='%s'", + string_length, e_text); + appendPQExpBuffer(&query_buffer, + " AND (SELECT pg_catalog.count(*)" + " FROM pg_catalog.pg_namespace" + " WHERE substring(pg_catalog.quote_ident(nspname) || '.',1,%d) =" + " substring('%s',1,pg_catalog.length(pg_catalog.quote_ident(nspname))+1)) > 1", + string_length, e_text); - /* - * Add in matching qualified names, but only if there is - * exactly one schema matching the input-so-far. - */ - appendPQExpBuffer(&query_buffer, "\nUNION\n" - "SELECT pg_catalog.quote_ident(n.nspname) || '.' || %s " - "FROM %s, pg_catalog.pg_namespace n " - "WHERE %s = n.oid AND ", - qualresult, - completion_squery->catname, - completion_squery->namespace); - if (completion_squery->selcondition) - appendPQExpBuffer(&query_buffer, "%s AND ", - completion_squery->selcondition); - appendPQExpBuffer(&query_buffer, "substring(pg_catalog.quote_ident(n.nspname) || '.' || %s,1,%d)='%s'", - qualresult, - string_length, e_text); + /* + * + * Ad + * d + * + * in + * + * ma + * t + * c + * h + * i + * n + * g + * + * qu + * a + * l + * i + * f + * i + * e + * d + * + * na + * m + * e + * s + * , + * + * bu + * t + * + * on + * l + * y + * + * if + * + * th + * e + * r + * e + * + * is + * + * ex + * a + * c + * t + * l + * y + * + * on + * e + * + * sc + * h + * e + * m + * a + * + * ma + * t + * c + * h + * i + * n + * g + * + * th + * e + * + * in + * p + * u + * t + * - + * s + * o + * - + * f + * a + * r + * . + * */ + appendPQExpBuffer(&query_buffer, "\nUNION\n" + "SELECT pg_catalog.quote_ident(n.nspname) || '.' || %s " + "FROM %s, pg_catalog.pg_namespace n " + "WHERE %s = n.oid AND ", + qualresult, + completion_squery->catname, + completion_squery->namespace); + if (completion_squery->selcondition) + appendPQExpBuffer(&query_buffer, "%s AND ", + completion_squery->selcondition); + appendPQExpBuffer(&query_buffer, "substring(pg_catalog.quote_ident(n.nspname) || '.' || %s,1,%d)='%s'", + qualresult, + string_length, e_text); - /* - * This condition exploits the single-matching-schema rule to - * speed up the query - */ - appendPQExpBuffer(&query_buffer, - " AND substring(pg_catalog.quote_ident(n.nspname) || '.',1,%d) =" - " substring('%s',1,pg_catalog.length(pg_catalog.quote_ident(n.nspname))+1)", - string_length, e_text); - appendPQExpBuffer(&query_buffer, - " AND (SELECT pg_catalog.count(*)" - " FROM pg_catalog.pg_namespace" - " WHERE substring(pg_catalog.quote_ident(nspname) || '.',1,%d) =" - " substring('%s',1,pg_catalog.length(pg_catalog.quote_ident(nspname))+1)) = 1", - string_length, e_text); + /* + * + * Th + * i + * s + * + * co + * n + * d + * i + * t + * i + * o + * n + * + * ex + * p + * l + * o + * i + * t + * s + * + * th + * e + * + * si + * n + * g + * l + * e + * - + * m + * a + * t + * c + * h + * i + * n + * g + * - + * s + * c + * h + * e + * m + * a + * + * ru + * l + * e + * + * to + * + * sp + * e + * e + * d + * + * up + * + * th + * e + * + * qu + * e + * r + * y + * */ + appendPQExpBuffer(&query_buffer, + " AND substring(pg_catalog.quote_ident(n.nspname) || '.',1,%d) =" + " substring('%s',1,pg_catalog.length(pg_catalog.quote_ident(n.nspname))+1)", + string_length, e_text); + appendPQExpBuffer(&query_buffer, + " AND (SELECT pg_catalog.count(*)" + " FROM pg_catalog.pg_namespace" + " WHERE substring(pg_catalog.quote_ident(nspname) || '.',1,%d) =" + " substring('%s',1,pg_catalog.length(pg_catalog.quote_ident(nspname))+1)) = 1", + string_length, e_text); - /* If an addon query was provided, use it */ - if (completion_charp) - appendPQExpBuffer(&query_buffer, "\n%s", completion_charp); - } - else - { - /* completion_charp is an sprintf-style format string */ - appendPQExpBuffer(&query_buffer, completion_charp, - string_length, e_text, e_info_charp); - } + /* + * I + * f + * + * an + * + * ad + * d + * o + * n + * + * qu + * e + * r + * y + * + * wa + * s + * + * pr + * o + * v + * i + * d + * e + * d + * , + * + * us + * e + * + * it + * + */ + if (completion_charp) + appendPQExpBuffer(&query_buffer, "\n%s", completion_charp); + } + else + { + /* + * c + * o + * m + * p + * l + * e + * t + * i + * o + * n + * _ + * c + * h + * a + * r + * p + * + * is + * + * an + * + * sp + * r + * i + * n + * t + * f + * - + * s + * t + * y + * l + * e + * + * fo + * r + * m + * a + * t + * + * st + * r + * i + * n + * g + * + */ + appendPQExpBuffer(&query_buffer, completion_charp, + string_length, e_text, e_info_charp); + } - /* Limit the number of records in the result */ - appendPQExpBuffer(&query_buffer, "\nLIMIT %d", - completion_max_records); + /* + * L + * i + * m + * i + * t + * + * th + * e + * + * nu + * m + * b + * e + * r + * + * of + * + * re + * c + * o + * r + * d + * s + * + * in + * + * th + * e + * + * re + * s + * u + * l + * t + * + */ + appendPQExpBuffer(&query_buffer, "\nLIMIT %d", + completion_max_records); - result = exec_query(query_buffer.data); + result = exec_query(query_buffer.data); - termPQExpBuffer(&query_buffer); - free(e_text); - if (e_info_charp) - free(e_info_charp); - } + termPQExpBuffer(&query_buffer); + free(e_text); + if (e_info_charp) + free(e_info_charp); + } - /* Find something that matches */ - if (result && PQresultStatus(result) == PGRES_TUPLES_OK) - { - const char *item; + /* + * F + * i + * n + * d + * + * so + * m + * e + * t + * h + * i + * n + * g + * + * th + * a + * t + * + * ma + * t + * c + * h + * e + * s + * + */ + if (result && PQresultStatus(result) == PGRES_TUPLES_OK) + { + const char *item; - while (list_index < PQntuples(result) && - (item = PQgetvalue(result, list_index++, 0))) - if (pg_strncasecmp(text, item, string_length) == 0) - return pg_strdup(item); - } + while (list_index < PQntuples(result) && + (item = PQgetvalue(result, list_index++, 0))) + if (pg_strncasecmp(text, item, string_length) == 0) + return pg_strdup(item); + } - /* If nothing matches, free the db structure and return null */ - PQclear(result); - result = NULL; - return NULL; -} + /* + * I + * f + * + * no + * t + * h + * i + * n + * g + * + * ma + * t + * c + * h + * e + * s + * , + * + * fr + * e + * e + * + * th + * e + * + * db + * + * st + * r + * u + * c + * t + * u + * r + * e + * + * an + * d + * + * re + * t + * u + * r + * n + * + * nu + * l + * l + * + */ + PQclear(result); + result = NULL; + return NULL; + } /* This function returns in order one of a fixed, NULL pointer terminated list of strings (if matching). This can be used if there are only a fixed number SQL words that can appear at certain spot. */ -static char * -complete_from_list(const char *text, int state) -{ - static int string_length, - list_index, - matches; - static bool casesensitive; - const char *item; + static char * + complete_from_list(const char *text, int state) + { + static int string_length, + list_index, + matches; + static bool casesensitive; + const char *item; - /* need to have a list */ - psql_assert(completion_charpp); + /* + * n + * e + * e + * d + * + * to + * + * ha + * v + * e + * + * a + * li + * s + * t + * + */ + psql_assert(completion_charpp); - /* Initialization */ - if (state == 0) - { - list_index = 0; - string_length = strlen(text); - casesensitive = true; - matches = 0; - } + /* + * I + * n + * i + * t + * i + * a + * l + * i + * z + * a + * t + * i + * o + * n + * + */ + if (state == 0) + { + list_index = 0; + string_length = strlen(text); + casesensitive = true; + matches = 0; + } - while ((item = completion_charpp[list_index++])) - { - /* First pass is case sensitive */ - if (casesensitive && strncmp(text, item, string_length) == 0) - { - matches++; - return pg_strdup(item); - } + while ((item = completion_charpp[list_index++])) + { + /* + * F + * i + * r + * s + * t + * + * pa + * s + * s + * + * is + * + * ca + * s + * e + * + * se + * n + * s + * i + * t + * i + * v + * e + * + */ + if (casesensitive && strncmp(text, item, string_length) == 0) + { + matches++; + return pg_strdup(item); + } - /* Second pass is case insensitive, don't bother counting matches */ - if (!casesensitive && pg_strncasecmp(text, item, string_length) == 0) - return pg_strdup(item); - } + /* + * S + * e + * c + * o + * n + * d + * + * pa + * s + * s + * + * is + * + * ca + * s + * e + * + * in + * s + * e + * n + * s + * i + * t + * i + * v + * e + * , + * + * do + * n + * ' + * t + * + * bo + * t + * h + * e + * r + * + * co + * u + * n + * t + * i + * n + * g + * + * ma + * t + * c + * h + * e + * s + * + */ + if (!casesensitive && pg_strncasecmp(text, item, string_length) == 0) + return pg_strdup(item); + } - /* - * No matches found. If we're not case insensitive already, lets - * switch to being case insensitive and try again - */ - if (casesensitive && matches == 0) - { - casesensitive = false; - list_index = 0; - state++; - return (complete_from_list(text, state)); - } + /* + * + * No + * + * ma + * t + * c + * h + * e + * s + * + * fo + * u + * n + * d + * . + * + * If + * + * we + * ' + * r + * e + * + * no + * t + * + * ca + * s + * e + * + * in + * s + * e + * n + * s + * i + * t + * i + * v + * e + * + * al + * r + * e + * a + * d + * y + * , + * + * le + * t + * s + * + * sw + * i + * t + * c + * h + * + * to + * + * be + * i + * n + * g + * + * ca + * s + * e + * + * in + * s + * e + * n + * s + * i + * t + * i + * v + * e + * + * an + * d + * + * tr + * y + * + * ag + * a + * i + * n + * */ + if (casesensitive && matches == 0) + { + casesensitive = false; + list_index = 0; + state++; + return (complete_from_list(text, state)); + } - /* If no more matches, return null. */ - return NULL; -} + /* + * I + * f + * + * no + * + * mo + * r + * e + * + * ma + * t + * c + * h + * e + * s + * , + * + * re + * t + * u + * r + * n + * + * nu + * l + * l + * . + * + */ + return NULL; + } /* This function returns one fixed string the first time even if it doesn't @@ -2121,18 +3654,19 @@ complete_from_list(const char *text, int state) will be overwritten. The string to be passed must be in completion_charp. */ -static char * -complete_from_const(const char *text, int state) -{ - (void) text; /* We don't care about what was entered - * already. */ + static char * + complete_from_const(const char *text, int state) + { + (void) text; /* We don't care about + * what was entered + * already. */ - psql_assert(completion_charp); - if (state == 0) - return pg_strdup(completion_charp); - else - return NULL; -} + psql_assert(completion_charp); + if (state == 0) + return pg_strdup(completion_charp); + else + return NULL; + } @@ -2143,28 +3677,28 @@ complete_from_const(const char *text, int state) * Execute a query and report any errors. This should be the preferred way of * talking to the database in this file. */ -static PGresult * -exec_query(const char *query) -{ - PGresult *result; + static PGresult * + exec_query(const char *query) + { + PGresult *result; - if (query == NULL || !pset.db || PQstatus(pset.db) != CONNECTION_OK) - return NULL; + if (query == NULL || !pset.db || PQstatus(pset.db) != CONNECTION_OK) + return NULL; - result = PQexec(pset.db, query); + result = PQexec(pset.db, query); - if (result != NULL && PQresultStatus(result) != PGRES_TUPLES_OK) - { + if (result != NULL && PQresultStatus(result) != PGRES_TUPLES_OK) + { #if 0 - psql_error("tab completion: %s failed - %s\n", - query, PQresStatus(PQresultStatus(result))); + psql_error("tab completion: %s failed - %s\n", + query, PQresStatus(PQresultStatus(result))); #endif - PQclear(result); - result = NULL; - } + PQclear(result); + result = NULL; + } - return result; -} + return result; + } @@ -2173,61 +3707,344 @@ exec_query(const char *query) * skip that many words; e.g. skip=1 finds the word before the * previous one. Return value is NULL or a malloc'ed string. */ -static char * -previous_word(int point, int skip) -{ - int i, - start = 0, - end = -1, - inquotes = 0; - char *s; + static char * + previous_word(int point, int skip) + { + int i, + start = 0, + end = -1, + inquotes = 0; + char *s; - while (skip-- >= 0) - { - /* first we look for a space before the current word */ - for (i = point; i >= 0; i--) - if (rl_line_buffer[i] == ' ') - break; + while (skip-- >= 0) + { + /* + * f + * i + * r + * s + * t + * + * we + * + * lo + * o + * k + * + * fo + * r + * + * a + * sp + * a + * c + * e + * + * be + * f + * o + * r + * e + * + * th + * e + * + * cu + * r + * r + * e + * n + * t + * + * wo + * r + * d + * + */ + for (i = point; i >= 0; i--) + if (rl_line_buffer[i] == ' ') + break; - /* now find the first non-space which then constitutes the end */ - for (; i >= 0; i--) - if (rl_line_buffer[i] != ' ') - { - end = i; - break; - } + /* + * n + * o + * w + * + * fi + * n + * d + * + * th + * e + * + * fi + * r + * s + * t + * + * no + * n + * - + * s + * p + * a + * c + * e + * + * wh + * i + * c + * h + * + * th + * e + * n + * + * co + * n + * s + * t + * i + * t + * u + * t + * e + * s + * + * th + * e + * + * en + * d + * + */ + for (; i >= 0; i--) + if (rl_line_buffer[i] != ' ') + { + end = i; + break; + } - /* - * If no end found we return null, because there is no word before - * the point - */ - if (end == -1) - return NULL; + /* + * + * If + * + * no + * + * en + * d + * + * fo + * u + * n + * d + * + * we + * + * re + * t + * u + * r + * n + * + * nu + * l + * l + * , + * + * be + * c + * a + * u + * s + * e + * + * th + * e + * r + * e + * + * is + * + * no + * + * wo + * r + * d + * + * be + * f + * o + * r + * e + * + * th + * e + * + * po + * i + * n + * t + * */ + if (end == -1) + return NULL; - /* - * Otherwise we now look for the start. The start is either the - * last character before any space going backwards from the end, - * or it's simply character 0 - */ - for (start = end; start > 0; start--) - { - if (rl_line_buffer[start] == '"') - inquotes = !inquotes; - if ((rl_line_buffer[start - 1] == ' ') && inquotes == 0) - break; - } + /* + * + * Ot + * h + * e + * r + * w + * i + * s + * e + * + * we + * + * no + * w + * + * lo + * o + * k + * + * fo + * r + * + * th + * e + * + * st + * a + * r + * t + * . + * + * Th + * e + * + * st + * a + * r + * t + * + * is + * + * ei + * t + * h + * e + * r + * + * th + * e + * + * la + * s + * t + * + * ch + * a + * r + * a + * c + * t + * e + * r + * + * be + * f + * o + * r + * e + * + * an + * y + * + * sp + * a + * c + * e + * + * go + * i + * n + * g + * + * ba + * c + * k + * w + * a + * r + * d + * s + * + * fr + * o + * m + * + * th + * e + * + * en + * d + * , + * + * or + * + * it + * ' + * s + * + * si + * m + * p + * l + * y + * + * ch + * a + * r + * a + * c + * t + * e + * r + * + * 0 + */ + for (start = end; start > 0; start--) + { + if (rl_line_buffer[start] == '"') + inquotes = !inquotes; + if ((rl_line_buffer[start - 1] == ' ') && inquotes == 0) + break; + } - point = start; - } + point = start; + } - /* make a copy */ - s = pg_malloc(end - start + 2); + /* + * m + * a + * k + * e + * + * a + * co + * p + * y + * + */ + s = pg_malloc(end - start + 2); - strncpy(s, &rl_line_buffer[start], end - start + 1); - s[end - start + 1] = '\0'; + strncpy(s, &rl_line_buffer[start], end - start + 1); + s[end - start + 1] = '\0'; - return s; -} + return s; + } @@ -2238,42 +4055,42 @@ previous_word(int point, int skip) * psql internal. Currently disabled because it is reported not to * cooperate with certain versions of readline. */ -static char * -quote_file_name(char *text, int match_type, char *quote_pointer) -{ - char *s; - size_t length; + static char * + quote_file_name(char *text, int match_type, char *quote_pointer) + { + char *s; + size_t length; - (void) quote_pointer; /* not used */ + (void) quote_pointer; /* not used */ - length = strlen(text) +(match_type == SINGLE_MATCH ? 3 : 2); - s = pg_malloc(length); - s[0] = '\''; - strcpy(s + 1, text); - if (match_type == SINGLE_MATCH) - s[length - 2] = '\''; - s[length - 1] = '\0'; - return s; -} + length = strlen(text) +(match_type == SINGLE_MATCH ? 3 : 2); + s = pg_malloc(length); + s[0] = '\''; + strcpy(s + 1, text); + if (match_type == SINGLE_MATCH) + s[length - 2] = '\''; + s[length - 1] = '\0'; + return s; + } -static char * -dequote_file_name(char *text, char quote_char) -{ - char *s; - size_t length; + static char * + dequote_file_name(char *text, char quote_char) + { + char *s; + size_t length; - if (!quote_char) - return pg_strdup(text); + if (!quote_char) + return pg_strdup(text); - length = strlen(text); - s = pg_malloc(length - 2 + 1); - strncpy(s, text +1, length - 2); - s[length] = '\0'; + length = strlen(text); + s = pg_malloc(length - 2 + 1); + strncpy(s, text +1, length - 2); + s[length] = '\0'; - return s; -} + return s; + } #endif /* 0 */ #endif /* USE_READLINE */ diff --git a/src/bin/psql/variables.c b/src/bin/psql/variables.c index 9763c2a9b2..3ee9701506 100644 --- a/src/bin/psql/variables.c +++ b/src/bin/psql/variables.c @@ -3,7 +3,7 @@ * * Copyright (c) 2000-2005, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/variables.c,v 1.21 2005/01/01 05:43:08 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/psql/variables.c,v 1.22 2005/10/15 02:49:41 momjian Exp $ */ #include "postgres_fe.h" #include "common.h" @@ -55,8 +55,8 @@ GetVariableBool(VariableSpace space, const char *name) return false; /* accept "off" or "OFF" as true */ /* - * for backwards compatibility, anything except "off" or "OFF" is - * taken as "true" + * for backwards compatibility, anything except "off" or "OFF" is taken as + * "true" */ return true; } diff --git a/src/bin/scripts/common.c b/src/bin/scripts/common.c index 7036ef1b1c..c450df3c6e 100644 --- a/src/bin/scripts/common.c +++ b/src/bin/scripts/common.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/bin/scripts/common.c,v 1.18 2005/08/15 21:02:26 tgl Exp $ + * $PostgreSQL: pgsql/src/bin/scripts/common.c,v 1.19 2005/10/15 02:49:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -20,7 +20,7 @@ #include "common.h" #ifndef HAVE_INT_OPTRESET -int optreset; +int optreset; #endif @@ -97,8 +97,8 @@ connectDatabase(const char *dbname, const char *pghost, const char *pgport, password = simple_prompt("Password: ", 100, false); /* - * Start the connection. Loop until we have a password if requested - * by backend. + * Start the connection. Loop until we have a password if requested by + * backend. */ do { diff --git a/src/bin/scripts/common.h b/src/bin/scripts/common.h index eac2674ea6..48b7214fde 100644 --- a/src/bin/scripts/common.h +++ b/src/bin/scripts/common.h @@ -4,7 +4,7 @@ * * Copyright (c) 2003-2005, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/scripts/common.h,v 1.11 2005/08/15 21:02:26 tgl Exp $ + * $PostgreSQL: pgsql/src/bin/scripts/common.h,v 1.12 2005/10/15 02:49:41 momjian Exp $ */ #ifndef COMMON_H #define COMMON_H @@ -14,7 +14,7 @@ #include "getopt_long.h" #ifndef HAVE_INT_OPTRESET -extern int optreset; +extern int optreset; #endif typedef void (*help_handler) (const char *progname); @@ -22,19 +22,19 @@ typedef void (*help_handler) (const char *progname); extern const char *get_user_name(const char *progname); extern void handle_help_version_opts(int argc, char *argv[], - const char *fixed_progname, - help_handler hlp); + const char *fixed_progname, + help_handler hlp); extern PGconn *connectDatabase(const char *dbname, const char *pghost, - const char *pgport, const char *pguser, - bool require_password, const char *progname); + const char *pgport, const char *pguser, + bool require_password, const char *progname); extern PGresult *executeQuery(PGconn *conn, const char *query, - const char *progname, bool echo); + const char *progname, bool echo); extern void executeCommand(PGconn *conn, const char *query, - const char *progname, bool echo); + const char *progname, bool echo); extern int check_yesno_response(const char *string); -#endif /* COMMON_H */ +#endif /* COMMON_H */ diff --git a/src/bin/scripts/createlang.c b/src/bin/scripts/createlang.c index 58e8a3703a..d66012a51a 100644 --- a/src/bin/scripts/createlang.c +++ b/src/bin/scripts/createlang.c @@ -5,7 +5,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/bin/scripts/createlang.c,v 1.20 2005/09/05 23:50:49 tgl Exp $ + * $PostgreSQL: pgsql/src/bin/scripts/createlang.c,v 1.21 2005/10/15 02:49:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -131,8 +131,8 @@ main(int argc, char *argv[]) progname); printfPQExpBuffer(&sql, "SELECT lanname as \"%s\", " - "(CASE WHEN lanpltrusted THEN '%s' ELSE '%s' END) as \"%s\" " - "FROM pg_catalog.pg_language WHERE lanispl;", + "(CASE WHEN lanpltrusted THEN '%s' ELSE '%s' END) as \"%s\" " + "FROM pg_catalog.pg_language WHERE lanispl;", _("Name"), _("yes"), _("no"), _("Trusted?")); result = executeQuery(conn, sql.data, progname, echo); @@ -163,15 +163,15 @@ main(int argc, char *argv[]) /* * Make sure the language isn't already installed */ - printfPQExpBuffer(&sql, - "SELECT oid FROM pg_catalog.pg_language WHERE lanname = '%s';", + printfPQExpBuffer(&sql, + "SELECT oid FROM pg_catalog.pg_language WHERE lanname = '%s';", langname); result = executeQuery(conn, sql.data, progname, echo); if (PQntuples(result) > 0) { PQfinish(conn); fprintf(stderr, - _("%s: language \"%s\" is already installed in database \"%s\"\n"), + _("%s: language \"%s\" is already installed in database \"%s\"\n"), progname, langname, dbname); /* separate exit status for "already installed" */ exit(2); diff --git a/src/bin/scripts/createuser.c b/src/bin/scripts/createuser.c index f3f906049c..a7de05a75d 100644 --- a/src/bin/scripts/createuser.c +++ b/src/bin/scripts/createuser.c @@ -5,7 +5,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/bin/scripts/createuser.c,v 1.20 2005/09/30 07:58:01 petere Exp $ + * $PostgreSQL: pgsql/src/bin/scripts/createuser.c,v 1.21 2005/10/15 02:49:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -313,7 +313,7 @@ help(const char *progname) printf(_(" -l, --login role can login (default)\n")); printf(_(" -L, --no-login role cannot login\n")); printf(_(" -i, --inherit role inherits privileges of roles it is a\n" - " member of (default)\n")); + " member of (default)\n")); printf(_(" -I, --no-inherit role does not inherit privileges\n")); printf(_(" -c, --connection-limit=N connection limit for role (default: no limit)\n")); printf(_(" -P, --pwprompt assign a password to new role\n")); @@ -329,6 +329,6 @@ help(const char *progname) printf(_(" -U, --username=USERNAME user name to connect as (not the one to create)\n")); printf(_(" -W, --password prompt for password to connect\n")); printf(_("\nIf one of -s, -S, -d, -D, -r, -R and ROLENAME is not specified, you will\n" - "be prompted interactively.\n")); + "be prompted interactively.\n")); printf(_("\nReport bugs to .\n")); } diff --git a/src/bin/scripts/droplang.c b/src/bin/scripts/droplang.c index 52eb06986e..f85c83b409 100644 --- a/src/bin/scripts/droplang.c +++ b/src/bin/scripts/droplang.c @@ -5,7 +5,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/bin/scripts/droplang.c,v 1.17 2005/08/15 21:02:26 tgl Exp $ + * $PostgreSQL: pgsql/src/bin/scripts/droplang.c,v 1.18 2005/10/15 02:49:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -137,12 +137,12 @@ main(int argc, char *argv[]) { printQueryOpt popt; - conn = connectDatabase(dbname, host, port, username, password, + conn = connectDatabase(dbname, host, port, username, password, progname); printfPQExpBuffer(&sql, "SELECT lanname as \"%s\", " - "(CASE WHEN lanpltrusted THEN '%s' ELSE '%s' END) as \"%s\" " - "FROM pg_catalog.pg_language WHERE lanispl;", + "(CASE WHEN lanpltrusted THEN '%s' ELSE '%s' END) as \"%s\" " + "FROM pg_catalog.pg_language WHERE lanispl;", _("Name"), _("yes"), _("no"), _("Trusted?")); result = executeQuery(conn, sql.data, progname, echo); @@ -159,9 +159,9 @@ main(int argc, char *argv[]) if (langname == NULL) { - fprintf(stderr, _("%s: missing required argument language name\n"), + fprintf(stderr, _("%s: missing required argument language name\n"), progname); - fprintf(stderr, _("Try \"%s --help\" for more information.\n"), + fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); exit(1); } @@ -173,18 +173,18 @@ main(int argc, char *argv[]) conn = connectDatabase(dbname, host, port, username, password, progname); /* - * Force schema search path to be just pg_catalog, so that we don't - * have to be paranoid about search paths below. + * Force schema search path to be just pg_catalog, so that we don't have + * to be paranoid about search paths below. */ executeCommand(conn, "SET search_path = pg_catalog;", progname, echo); /* - * Make sure the language is installed and find the OIDs of the - * handler and validator functions + * Make sure the language is installed and find the OIDs of the handler + * and validator functions */ printfPQExpBuffer(&sql, "SELECT lanplcallfoid, lanvalidator " - "FROM pg_language WHERE lanname = '%s' AND lanispl;", + "FROM pg_language WHERE lanname = '%s' AND lanispl;", langname); result = executeQuery(conn, sql.data, progname, echo); if (PQntuples(result) == 0) @@ -221,7 +221,7 @@ main(int argc, char *argv[]) * Check that the handler function isn't used by some other language */ printfPQExpBuffer(&sql, "SELECT count(*) FROM pg_language " - "WHERE lanplcallfoid = %u AND lanname <> '%s';", + "WHERE lanplcallfoid = %u AND lanname <> '%s';", lanplcallfoid, langname); result = executeQuery(conn, sql.data, progname, echo); if (strcmp(PQgetvalue(result, 0, 0), "0") == 0) @@ -237,7 +237,7 @@ main(int argc, char *argv[]) { printfPQExpBuffer(&sql, "SELECT proname, (SELECT nspname " "FROM pg_namespace ns WHERE ns.oid = pronamespace) " - "AS prons FROM pg_proc WHERE oid = %u;", + "AS prons FROM pg_proc WHERE oid = %u;", lanplcallfoid); result = executeQuery(conn, sql.data, progname, echo); handler = strdup(PQgetvalue(result, 0, 0)); @@ -256,7 +256,7 @@ main(int argc, char *argv[]) if (OidIsValid(lanvalidator)) { printfPQExpBuffer(&sql, "SELECT count(*) FROM pg_language " - "WHERE lanvalidator = %u AND lanname <> '%s';", + "WHERE lanvalidator = %u AND lanname <> '%s';", lanvalidator, langname); result = executeQuery(conn, sql.data, progname, echo); if (strcmp(PQgetvalue(result, 0, 0), "0") == 0) @@ -275,7 +275,7 @@ main(int argc, char *argv[]) { printfPQExpBuffer(&sql, "SELECT proname, (SELECT nspname " "FROM pg_namespace ns WHERE ns.oid = pronamespace) " - "AS prons FROM pg_proc WHERE oid = %u;", + "AS prons FROM pg_proc WHERE oid = %u;", lanvalidator); result = executeQuery(conn, sql.data, progname, echo); validator = strdup(PQgetvalue(result, 0, 0)); @@ -293,10 +293,10 @@ main(int argc, char *argv[]) */ printfPQExpBuffer(&sql, "DROP LANGUAGE \"%s\";\n", langname); if (!keephandler) - appendPQExpBuffer(&sql, "DROP FUNCTION \"%s\".\"%s\" ();\n", + appendPQExpBuffer(&sql, "DROP FUNCTION \"%s\".\"%s\" ();\n", handler_ns, handler); if (!keepvalidator) - appendPQExpBuffer(&sql, "DROP FUNCTION \"%s\".\"%s\" (oid);\n", + appendPQExpBuffer(&sql, "DROP FUNCTION \"%s\".\"%s\" (oid);\n", validator_ns, validator); if (echo) printf("%s", sql.data); diff --git a/src/bin/scripts/reindexdb.c b/src/bin/scripts/reindexdb.c index 5b4cbc79f5..b1cdb47ae3 100644 --- a/src/bin/scripts/reindexdb.c +++ b/src/bin/scripts/reindexdb.c @@ -4,7 +4,7 @@ * * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/scripts/reindexdb.c,v 1.3 2005/09/30 09:56:26 petere Exp $ + * $PostgreSQL: pgsql/src/bin/scripts/reindexdb.c,v 1.4 2005/10/15 02:49:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -15,19 +15,19 @@ static void reindex_one_database(const char *name, const char *dbname, - const char *type, const char *host, - const char *port, const char *username, - bool password, const char *progname, - bool echo, bool quiet); + const char *type, const char *host, + const char *port, const char *username, + bool password, const char *progname, + bool echo, bool quiet); static void reindex_all_databases(const char *host, const char *port, - const char *username, bool password, - const char *progname, bool echo, - bool quiet); + const char *username, bool password, + const char *progname, bool echo, + bool quiet); static void reindex_system_catalogs(const char *dbname, - const char *host, const char *port, - const char *username, bool password, - const char *progname, bool echo, - bool quiet); + const char *host, const char *port, + const char *username, bool password, + const char *progname, bool echo, + bool quiet); static void help(const char *progname); int @@ -48,22 +48,22 @@ main(int argc, char *argv[]) {NULL, 0, NULL, 0} }; - const char *progname; - int optindex; - int c; + const char *progname; + int optindex; + int c; - const char *dbname = NULL; - const char *host = NULL; - const char *port = NULL; - const char *username = NULL; + const char *dbname = NULL; + const char *host = NULL; + const char *port = NULL; + const char *username = NULL; bool password = false; bool syscatalog = false; bool alldb = false; bool echo = false; bool quiet = false; - const char *table = NULL; - const char *index = NULL; - + const char *table = NULL; + const char *index = NULL; + progname = get_progname(argv[0]); set_pglocale_pgservice(argv[0], "pgscripts"); @@ -150,7 +150,7 @@ main(int argc, char *argv[]) } reindex_all_databases(host, port, username, password, - progname, echo, quiet); + progname, echo, quiet); } else if (syscatalog) { @@ -176,7 +176,7 @@ main(int argc, char *argv[]) } reindex_system_catalogs(dbname, host, port, username, password, - progname, echo, quiet); + progname, echo, quiet); } else { @@ -192,14 +192,14 @@ main(int argc, char *argv[]) if (index) reindex_one_database(index, dbname, "INDEX", host, port, - username, password, progname, echo, quiet); + username, password, progname, echo, quiet); if (table) reindex_one_database(table, dbname, "TABLE", host, port, - username, password, progname, echo, quiet); + username, password, progname, echo, quiet); /* reindex database only if index or table is not specified */ if (index == NULL && table == NULL) reindex_one_database(dbname, dbname, "DATABASE", host, port, - username, password, progname, echo, quiet); + username, password, progname, echo, quiet); } exit(0); @@ -207,14 +207,14 @@ main(int argc, char *argv[]) static void reindex_one_database(const char *name, const char *dbname, const char *type, - const char *host, const char *port, const char *username, - bool password, const char *progname, bool echo, - bool quiet) + const char *host, const char *port, const char *username, + bool password, const char *progname, bool echo, + bool quiet) { - PQExpBufferData sql; + PQExpBufferData sql; - PGconn *conn; - PGresult *result; + PGconn *conn; + PGresult *result; initPQExpBuffer(&sql); @@ -228,7 +228,7 @@ reindex_one_database(const char *name, const char *dbname, const char *type, appendPQExpBuffer(&sql, ";\n"); conn = connectDatabase(dbname, host, port, username, password, progname); - + if (echo) printf("%s", sql.data); result = PQexec(conn, sql.data); @@ -261,12 +261,12 @@ reindex_one_database(const char *name, const char *dbname, const char *type, static void reindex_all_databases(const char *host, const char *port, - const char *username, bool password, - const char *progname, bool echo, bool quiet) + const char *username, bool password, + const char *progname, bool echo, bool quiet) { - PGconn *conn; - PGresult *result; - int i; + PGconn *conn; + PGresult *result; + int i; conn = connectDatabase("postgres", host, port, username, password, progname); result = executeQuery(conn, "SELECT datname FROM pg_database WHERE datallowconn;", progname, echo); @@ -274,13 +274,13 @@ reindex_all_databases(const char *host, const char *port, for (i = 0; i < PQntuples(result); i++) { - char *dbname = PQgetvalue(result, i, 0); + char *dbname = PQgetvalue(result, i, 0); if (!quiet) fprintf(stderr, _("%s: reindexing database \"%s\"\n"), progname, dbname); reindex_one_database(dbname, dbname, "DATABASE", host, port, username, - password, progname, echo, quiet); + password, progname, echo, quiet); } PQclear(result); @@ -288,20 +288,20 @@ reindex_all_databases(const char *host, const char *port, static void reindex_system_catalogs(const char *dbname, const char *host, const char *port, - const char *username, bool password, - const char *progname, bool echo, bool quiet) + const char *username, bool password, + const char *progname, bool echo, bool quiet) { - PQExpBufferData sql; + PQExpBufferData sql; - PGconn *conn; - PGresult *result; + PGconn *conn; + PGresult *result; initPQExpBuffer(&sql); appendPQExpBuffer(&sql, "REINDEX SYSTEM %s;\n", dbname); conn = connectDatabase(dbname, host, port, username, password, progname); - + if (echo) printf("%s", sql.data); result = PQexec(conn, sql.data); @@ -309,7 +309,7 @@ reindex_system_catalogs(const char *dbname, const char *host, const char *port, if (PQresultStatus(result) != PGRES_COMMAND_OK) { fprintf(stderr, _("%s: reindexing of system catalogs failed: %s"), - progname, PQerrorMessage(conn)); + progname, PQerrorMessage(conn)); PQfinish(conn); exit(1); } diff --git a/src/include/access/genam.h b/src/include/access/genam.h index 1ed42f8be6..acae7277a0 100644 --- a/src/include/access/genam.h +++ b/src/include/access/genam.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/genam.h,v 1.52 2005/06/13 23:14:48 tgl Exp $ + * $PostgreSQL: pgsql/src/include/access/genam.h,v 1.53 2005/10/15 02:49:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -82,8 +82,8 @@ extern IndexScanDesc index_beginscan(Relation heapRelation, Snapshot snapshot, int nkeys, ScanKey key); extern IndexScanDesc index_beginscan_multi(Relation indexRelation, - Snapshot snapshot, - int nkeys, ScanKey key); + Snapshot snapshot, + int nkeys, ScanKey key); extern void index_rescan(IndexScanDesc scan, ScanKey key); extern void index_endscan(IndexScanDesc scan); extern void index_markpos(IndexScanDesc scan); @@ -92,8 +92,8 @@ extern HeapTuple index_getnext(IndexScanDesc scan, ScanDirection direction); extern bool index_getnext_indexitem(IndexScanDesc scan, ScanDirection direction); extern bool index_getmulti(IndexScanDesc scan, - ItemPointer tids, int32 max_tids, - int32 *returned_tids); + ItemPointer tids, int32 max_tids, + int32 *returned_tids); extern IndexBulkDeleteResult *index_bulk_delete(Relation indexRelation, IndexBulkDeleteCallback callback, diff --git a/src/include/access/gist.h b/src/include/access/gist.h index 44fe84ee38..22c897959f 100644 --- a/src/include/access/gist.h +++ b/src/include/access/gist.h @@ -9,7 +9,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/gist.h,v 1.49 2005/06/30 17:52:14 teodor Exp $ + * $PostgreSQL: pgsql/src/include/access/gist.h,v 1.50 2005/10/15 02:49:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -45,11 +45,12 @@ typedef XLogRecPtr GistNSN; typedef struct GISTPageOpaqueData { - uint32 flags; /* 29 bits are unused for now */ - BlockNumber rightlink; + uint32 flags; /* 29 bits are unused for now */ + BlockNumber rightlink; - /* the only meaning - change this value if - page split. */ + /* + * the only meaning - change this value if page split. + */ GistNSN nsn; } GISTPageOpaqueData; @@ -99,19 +100,19 @@ typedef struct GISTENTRY bool leafkey; } GISTENTRY; -#define GistPageGetOpaque(page) ( (GISTPageOpaque) PageGetSpecialPointer(page) ) +#define GistPageGetOpaque(page) ( (GISTPageOpaque) PageGetSpecialPointer(page) ) #define GistPageIsLeaf(page) ( GistPageGetOpaque(page)->flags & F_LEAF) #define GIST_LEAF(entry) (GistPageIsLeaf((entry)->page)) #define GistPageSetLeaf(page) ( GistPageGetOpaque(page)->flags |= F_LEAF) -#define GistPageSetNonLeaf(page) ( GistPageGetOpaque(page)->flags &= ~F_LEAF) +#define GistPageSetNonLeaf(page) ( GistPageGetOpaque(page)->flags &= ~F_LEAF) -#define GistPageIsDeleted(page) ( GistPageGetOpaque(page)->flags & F_DELETED) +#define GistPageIsDeleted(page) ( GistPageGetOpaque(page)->flags & F_DELETED) #define GistPageSetDeleted(page) ( GistPageGetOpaque(page)->flags |= F_DELETED) -#define GistPageSetNonDeleted(page) ( GistPageGetOpaque(page)->flags &= ~F_DELETED) +#define GistPageSetNonDeleted(page) ( GistPageGetOpaque(page)->flags &= ~F_DELETED) -#define GistTuplesDeleted(page) ( GistPageGetOpaque(page)->flags & F_TUPLES_DELETED) -#define GistMarkTuplesDeleted(page) ( GistPageGetOpaque(page)->flags |= F_TUPLES_DELETED) +#define GistTuplesDeleted(page) ( GistPageGetOpaque(page)->flags & F_TUPLES_DELETED) +#define GistMarkTuplesDeleted(page) ( GistPageGetOpaque(page)->flags |= F_TUPLES_DELETED) #define GistClearTuplesDeleted(page) ( GistPageGetOpaque(page)->flags &= ~F_TUPLES_DELETED) /* diff --git a/src/include/access/gist_private.h b/src/include/access/gist_private.h index a14df2e377..1cfa5b92bc 100644 --- a/src/include/access/gist_private.h +++ b/src/include/access/gist_private.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/gist_private.h,v 1.7 2005/06/30 17:52:14 teodor Exp $ + * $PostgreSQL: pgsql/src/include/access/gist_private.h,v 1.8 2005/10/15 02:49:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -20,7 +20,7 @@ #include "access/xlogdefs.h" #include "fmgr.h" -#define GIST_UNLOCK BUFFER_LOCK_UNLOCK +#define GIST_UNLOCK BUFFER_LOCK_UNLOCK #define GIST_SHARE BUFFER_LOCK_SHARE #define GIST_EXCLUSIVE BUFFER_LOCK_EXCLUSIVE @@ -66,80 +66,83 @@ typedef struct GISTSTATE */ typedef struct GISTScanOpaqueData { - GISTSearchStack *stack; - GISTSearchStack *markstk; - uint16 flags; - GISTSTATE *giststate; - MemoryContext tempCxt; - Buffer curbuf; - Buffer markbuf; + GISTSearchStack *stack; + GISTSearchStack *markstk; + uint16 flags; + GISTSTATE *giststate; + MemoryContext tempCxt; + Buffer curbuf; + Buffer markbuf; } GISTScanOpaqueData; typedef GISTScanOpaqueData *GISTScanOpaque; /* XLog stuff */ -extern const XLogRecPtr XLogRecPtrForTemp; +extern const XLogRecPtr XLogRecPtrForTemp; -#define XLOG_GIST_ENTRY_UPDATE 0x00 -#define XLOG_GIST_ENTRY_DELETE 0x10 +#define XLOG_GIST_ENTRY_UPDATE 0x00 +#define XLOG_GIST_ENTRY_DELETE 0x10 #define XLOG_GIST_NEW_ROOT 0x20 -typedef struct gistxlogEntryUpdate { - RelFileNode node; - BlockNumber blkno; +typedef struct gistxlogEntryUpdate +{ + RelFileNode node; + BlockNumber blkno; uint16 ntodelete; - bool isemptypage; + bool isemptypage; - /* - * It used to identify completeness of insert. - * Sets to leaf itup - */ - ItemPointerData key; + /* + * It used to identify completeness of insert. Sets to leaf itup + */ + ItemPointerData key; - /* follow: - * 1. todelete OffsetNumbers - * 2. tuples to insert - */ + /* + * follow: 1. todelete OffsetNumbers 2. tuples to insert + */ } gistxlogEntryUpdate; #define XLOG_GIST_PAGE_SPLIT 0x30 -typedef struct gistxlogPageSplit { - RelFileNode node; - BlockNumber origblkno; /*splitted page*/ +typedef struct gistxlogPageSplit +{ + RelFileNode node; + BlockNumber origblkno; /* splitted page */ uint16 npage; /* see comments on gistxlogEntryUpdate */ - ItemPointerData key; - - /* follow: - * 1. gistxlogPage and array of IndexTupleData per page - */ + ItemPointerData key; + + /* + * follow: 1. gistxlogPage and array of IndexTupleData per page + */ } gistxlogPageSplit; #define XLOG_GIST_INSERT_COMPLETE 0x40 -typedef struct gistxlogPage { - BlockNumber blkno; - int num; -} gistxlogPage; +typedef struct gistxlogPage +{ + BlockNumber blkno; + int num; +} gistxlogPage; -#define XLOG_GIST_CREATE_INDEX 0x50 +#define XLOG_GIST_CREATE_INDEX 0x50 -typedef struct gistxlogInsertComplete { - RelFileNode node; +typedef struct gistxlogInsertComplete +{ + RelFileNode node; /* follows ItemPointerData key to clean */ } gistxlogInsertComplete; /* SplitedPageLayout - gistSplit function result */ -typedef struct SplitedPageLayout { - gistxlogPage block; - IndexTupleData *list; - int lenlist; - Buffer buffer; /* to write after all proceed */ +typedef struct SplitedPageLayout +{ + gistxlogPage block; + IndexTupleData *list; + int lenlist; + Buffer buffer; /* to write after all proceed */ - struct SplitedPageLayout *next; + struct SplitedPageLayout *next; } SplitedPageLayout; /* @@ -147,39 +150,42 @@ typedef struct SplitedPageLayout { * insertion */ -typedef struct GISTInsertStack { +typedef struct GISTInsertStack +{ /* current page */ - BlockNumber blkno; + BlockNumber blkno; Buffer buffer; Page page; - /* log sequence number from page->lsn to - recognize page update and compare it with page's nsn - to recognize page split*/ + /* + * log sequence number from page->lsn to recognize page update and + * compare it with page's nsn to recognize page split + */ GistNSN lsn; - + /* child's offset */ - OffsetNumber childoffnum; + OffsetNumber childoffnum; /* pointer to parent and child */ - struct GISTInsertStack *parent; - struct GISTInsertStack *child; + struct GISTInsertStack *parent; + struct GISTInsertStack *child; /* for gistFindPath */ - struct GISTInsertStack *next; + struct GISTInsertStack *next; } GISTInsertStack; #define XLogRecPtrIsInvalid( r ) ( (r).xlogid == 0 && (r).xrecoff == 0 ) -typedef struct { +typedef struct +{ Relation r; - IndexTuple *itup; /* in/out, points to compressed entry */ - int ituplen; /* length of itup */ - GISTInsertStack *stack; - bool needInsertComplete; + IndexTuple *itup; /* in/out, points to compressed entry */ + int ituplen; /* length of itup */ + GISTInsertStack *stack; + bool needInsertComplete; /* pointer to heap tuple */ - ItemPointerData key; + ItemPointerData key; } GISTInsertState; /* @@ -197,19 +203,19 @@ typedef struct { /* * When we update a relation on which we're doing a scan, we need to * check the scan and fix it if the update affected any of the pages - * it touches. Otherwise, we can miss records that we should see. + * it touches. Otherwise, we can miss records that we should see. * The only times we need to do this are for deletions and splits. See * the code in gistscan.c for how the scan is fixed. These two * constants tell us what sort of operation changed the index. */ #define GISTOP_DEL 0 -/* #define GISTOP_SPLIT 1 */ +/* #define GISTOP_SPLIT 1 */ #define ATTSIZE(datum, tupdesc, i, isnull) \ - ( \ - (isnull) ? 0 : \ - att_addlength(0, (tupdesc)->attrs[(i)-1]->attlen, (datum)) \ - ) + ( \ + (isnull) ? 0 : \ + att_addlength(0, (tupdesc)->attrs[(i)-1]->attlen, (datum)) \ + ) /* * mark tuples on inner pages during recovery @@ -230,11 +236,12 @@ extern void freeGISTstate(GISTSTATE *giststate); extern void gistmakedeal(GISTInsertState *state, GISTSTATE *giststate); extern void gistnewroot(Relation r, Buffer buffer, IndexTuple *itup, int len, ItemPointer key); -extern IndexTuple * gistSplit(Relation r, Buffer buffer, IndexTuple *itup, - int *len, SplitedPageLayout **dist, GISTSTATE *giststate); +extern IndexTuple *gistSplit(Relation r, Buffer buffer, IndexTuple *itup, + int *len, SplitedPageLayout **dist, GISTSTATE *giststate); + +extern GISTInsertStack *gistFindPath(Relation r, BlockNumber child, + Buffer (*myReadBuffer) (Relation, BlockNumber)); -extern GISTInsertStack* gistFindPath( Relation r, BlockNumber child, - Buffer (*myReadBuffer)(Relation, BlockNumber) ); /* gistxlog.c */ extern void gist_redo(XLogRecPtr lsn, XLogRecord *record); extern void gist_desc(char *buf, uint8 xl_info, char *rec); @@ -242,12 +249,12 @@ extern void gist_xlog_startup(void); extern void gist_xlog_cleanup(void); extern IndexTuple gist_form_invalid_tuple(BlockNumber blkno); -extern XLogRecData* formUpdateRdata(RelFileNode node, BlockNumber blkno, - OffsetNumber *todelete, int ntodelete, bool emptypage, - IndexTuple *itup, int ituplen, ItemPointer key); +extern XLogRecData *formUpdateRdata(RelFileNode node, BlockNumber blkno, + OffsetNumber *todelete, int ntodelete, bool emptypage, + IndexTuple *itup, int ituplen, ItemPointer key); -extern XLogRecData* formSplitRdata(RelFileNode node, BlockNumber blkno, - ItemPointer key, SplitedPageLayout *dist); +extern XLogRecData *formSplitRdata(RelFileNode node, BlockNumber blkno, + ItemPointer key, SplitedPageLayout *dist); extern XLogRecPtr gistxlogInsertCompletion(RelFileNode node, ItemPointerData *keys, int len); @@ -256,50 +263,50 @@ extern Datum gistgettuple(PG_FUNCTION_ARGS); extern Datum gistgetmulti(PG_FUNCTION_ARGS); /* gistutil.c */ -extern Buffer gistNewBuffer(Relation r); +extern Buffer gistNewBuffer(Relation r); extern OffsetNumber gistfillbuffer(Relation r, Page page, IndexTuple *itup, - int len, OffsetNumber off); + int len, OffsetNumber off); extern bool gistnospace(Page page, IndexTuple *itvec, int len); -extern IndexTuple * gistextractbuffer(Buffer buffer, int *len /* out */ ); -extern IndexTuple * gistjoinvector( - IndexTuple *itvec, int *len, - IndexTuple *additvec, int addlen); +extern IndexTuple *gistextractbuffer(Buffer buffer, int *len /* out */ ); +extern IndexTuple *gistjoinvector( + IndexTuple *itvec, int *len, + IndexTuple *additvec, int addlen); extern IndexTuple gistunion(Relation r, IndexTuple *itvec, - int len, GISTSTATE *giststate); + int len, GISTSTATE *giststate); extern IndexTuple gistgetadjusted(Relation r, - IndexTuple oldtup, - IndexTuple addtup, - GISTSTATE *giststate); + IndexTuple oldtup, + IndexTuple addtup, + GISTSTATE *giststate); extern int gistfindgroup(GISTSTATE *giststate, - GISTENTRY *valvec, GIST_SPLITVEC *spl); + GISTENTRY *valvec, GIST_SPLITVEC *spl); extern void gistadjsubkey(Relation r, - IndexTuple *itup, int len, - GIST_SPLITVEC *v, - GISTSTATE *giststate); + IndexTuple *itup, int len, + GIST_SPLITVEC *v, + GISTSTATE *giststate); extern IndexTuple gistFormTuple(GISTSTATE *giststate, - Relation r, Datum *attdata, int *datumsize, bool *isnull); + Relation r, Datum *attdata, int *datumsize, bool *isnull); extern OffsetNumber gistchoose(Relation r, Page p, - IndexTuple it, - GISTSTATE *giststate); + IndexTuple it, + GISTSTATE *giststate); extern void gistcentryinit(GISTSTATE *giststate, int nkey, - GISTENTRY *e, Datum k, - Relation r, Page pg, - OffsetNumber o, int b, bool l, bool isNull); + GISTENTRY *e, Datum k, + Relation r, Page pg, + OffsetNumber o, int b, bool l, bool isNull); extern void gistDeCompressAtt(GISTSTATE *giststate, Relation r, - IndexTuple tuple, Page p, OffsetNumber o, - GISTENTRY *attdata, bool *isnull); -extern void gistunionsubkey(Relation r, GISTSTATE *giststate, - IndexTuple *itvec, GIST_SPLITVEC *spl, bool isall); + IndexTuple tuple, Page p, OffsetNumber o, + GISTENTRY *attdata, bool *isnull); +extern void gistunionsubkey(Relation r, GISTSTATE *giststate, + IndexTuple *itvec, GIST_SPLITVEC *spl, bool isall); extern void GISTInitBuffer(Buffer b, uint32 f); extern void gistdentryinit(GISTSTATE *giststate, int nkey, GISTENTRY *e, Datum k, Relation r, Page pg, OffsetNumber o, int b, bool l, bool isNull); void gistUserPicksplit(Relation r, GistEntryVector *entryvec, GIST_SPLITVEC *v, - IndexTuple *itup, int len, GISTSTATE *giststate); + IndexTuple *itup, int len, GISTSTATE *giststate); /* gistvacuum.c */ extern Datum gistbulkdelete(PG_FUNCTION_ARGS); extern Datum gistvacuumcleanup(PG_FUNCTION_ARGS); -#endif /* GIST_PRIVATE_H */ +#endif /* GIST_PRIVATE_H */ diff --git a/src/include/access/hash.h b/src/include/access/hash.h index 1e40232b51..b433524f7c 100644 --- a/src/include/access/hash.h +++ b/src/include/access/hash.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/hash.h,v 1.62 2005/06/06 17:01:24 tgl Exp $ + * $PostgreSQL: pgsql/src/include/access/hash.h,v 1.63 2005/10/15 02:49:42 momjian Exp $ * * NOTES * modeled after Margo Seltzer's hash implementation for unix. @@ -58,11 +58,11 @@ typedef struct HashPageOpaqueData uint16 hasho_filler; /* available for future use */ /* - * We presently set hasho_filler to HASHO_FILL (0x1234); this is for - * the convenience of pg_filedump, which otherwise would have a hard - * time telling HashPageOpaqueData from BTPageOpaqueData. If we ever - * need that space for some other purpose, pg_filedump will have to - * find another way. + * We presently set hasho_filler to HASHO_FILL (0x1234); this is for the + * convenience of pg_filedump, which otherwise would have a hard time + * telling HashPageOpaqueData from BTPageOpaqueData. If we ever need that + * space for some other purpose, pg_filedump will have to find another + * way. */ } HashPageOpaqueData; @@ -89,10 +89,10 @@ typedef struct HashScanOpaqueData BlockNumber hashso_bucket_blkno; /* - * We also want to remember which buffers we're currently examining in - * the scan. We keep these buffers pinned (but not locked) across - * hashgettuple calls, in order to avoid doing a ReadBuffer() for - * every tuple in the index. + * We also want to remember which buffers we're currently examining in the + * scan. We keep these buffers pinned (but not locked) across hashgettuple + * calls, in order to avoid doing a ReadBuffer() for every tuple in the + * index. */ Buffer hashso_curbuf; Buffer hashso_mrkbuf; @@ -140,8 +140,8 @@ typedef struct HashMetaPageData double hashm_ntuples; /* number of tuples stored in the table */ uint16 hashm_ffactor; /* target fill factor (tuples/bucket) */ uint16 hashm_bsize; /* index page size (bytes) */ - uint16 hashm_bmsize; /* bitmap array size (bytes) - must be a - * power of 2 */ + uint16 hashm_bmsize; /* bitmap array size (bytes) - must be a power + * of 2 */ uint16 hashm_bmshift; /* log2(bitmap array size in BITS) */ uint32 hashm_maxbucket; /* ID of maximum bucket in use */ uint32 hashm_highmask; /* mask to modulo into entire table */ diff --git a/src/include/access/heapam.h b/src/include/access/heapam.h index 3221734a6f..cf4eb29bfc 100644 --- a/src/include/access/heapam.h +++ b/src/include/access/heapam.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/heapam.h,v 1.104 2005/08/20 00:39:59 tgl Exp $ + * $PostgreSQL: pgsql/src/include/access/heapam.h,v 1.105 2005/10/15 02:49:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -70,7 +70,6 @@ ) \ ) \ ) - #else /* defined(DISABLE_COMPLEX_MACRO) */ extern Datum fastgetattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, @@ -156,19 +155,19 @@ extern void heap_get_latest_tid(Relation relation, Snapshot snapshot, ItemPointer tid); extern void setLastTid(const ItemPointer tid); -extern Oid heap_insert(Relation relation, HeapTuple tup, CommandId cid, - bool use_wal, bool use_fsm); +extern Oid heap_insert(Relation relation, HeapTuple tup, CommandId cid, + bool use_wal, bool use_fsm); extern HTSU_Result heap_delete(Relation relation, ItemPointer tid, - ItemPointer ctid, TransactionId *update_xmax, - CommandId cid, Snapshot crosscheck, bool wait); + ItemPointer ctid, TransactionId *update_xmax, + CommandId cid, Snapshot crosscheck, bool wait); extern HTSU_Result heap_update(Relation relation, ItemPointer otid, - HeapTuple newtup, - ItemPointer ctid, TransactionId *update_xmax, - CommandId cid, Snapshot crosscheck, bool wait); + HeapTuple newtup, + ItemPointer ctid, TransactionId *update_xmax, + CommandId cid, Snapshot crosscheck, bool wait); extern HTSU_Result heap_lock_tuple(Relation relation, HeapTuple tuple, - Buffer *buffer, ItemPointer ctid, - TransactionId *update_xmax, CommandId cid, - LockTupleMode mode, bool nowait); + Buffer *buffer, ItemPointer ctid, + TransactionId *update_xmax, CommandId cid, + LockTupleMode mode, bool nowait); extern Oid simple_heap_insert(Relation relation, HeapTuple tup); extern void simple_heap_delete(Relation relation, ItemPointer tid); @@ -188,10 +187,10 @@ extern XLogRecPtr log_heap_move(Relation reln, Buffer oldbuf, /* in common/heaptuple.c */ extern Size heap_compute_data_size(TupleDesc tupleDesc, - Datum *values, bool *isnull); + Datum *values, bool *isnull); extern void heap_fill_tuple(TupleDesc tupleDesc, - Datum *values, bool *isnull, - char *data, uint16 *infomask, bits8 *bit); + Datum *values, bool *isnull, + char *data, uint16 *infomask, bits8 *bit); extern bool heap_attisnull(HeapTuple tup, int attnum); extern Datum nocachegetattr(HeapTuple tup, int attnum, TupleDesc att, bool *isnull); @@ -200,25 +199,25 @@ extern Datum heap_getsysattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, extern HeapTuple heap_copytuple(HeapTuple tuple); extern void heap_copytuple_with_tuple(HeapTuple src, HeapTuple dest); extern HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, - Datum *values, bool *isnull); + Datum *values, bool *isnull); extern HeapTuple heap_formtuple(TupleDesc tupleDescriptor, Datum *values, char *nulls); extern HeapTuple heap_modify_tuple(HeapTuple tuple, - TupleDesc tupleDesc, - Datum *replValues, - bool *replIsnull, - bool *doReplace); + TupleDesc tupleDesc, + Datum *replValues, + bool *replIsnull, + bool *doReplace); extern HeapTuple heap_modifytuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *replValues, char *replNulls, char *replActions); extern void heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc, - Datum *values, bool *isnull); + Datum *values, bool *isnull); extern void heap_deformtuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *values, char *nulls); extern void heap_freetuple(HeapTuple tuple); extern HeapTuple heap_addheader(int natts, bool withoid, - Size structlen, void *structure); + Size structlen, void *structure); #endif /* HEAPAM_H */ diff --git a/src/include/access/hio.h b/src/include/access/hio.h index e706fea4ca..715ad38b25 100644 --- a/src/include/access/hio.h +++ b/src/include/access/hio.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/hio.h,v 1.28 2005/06/20 18:37:01 tgl Exp $ + * $PostgreSQL: pgsql/src/include/access/hio.h,v 1.29 2005/10/15 02:49:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -19,6 +19,6 @@ extern void RelationPutHeapTuple(Relation relation, Buffer buffer, HeapTuple tuple); extern Buffer RelationGetBufferForTuple(Relation relation, Size len, - Buffer otherBuffer, bool use_fsm); + Buffer otherBuffer, bool use_fsm); #endif /* HIO_H */ diff --git a/src/include/access/htup.h b/src/include/access/htup.h index 6a78cd3a01..f6fbd8f04a 100644 --- a/src/include/access/htup.h +++ b/src/include/access/htup.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/htup.h,v 1.77 2005/09/02 19:02:20 tgl Exp $ + * $PostgreSQL: pgsql/src/include/access/htup.h,v 1.78 2005/10/15 02:49:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -81,7 +81,7 @@ * and Cmin simultaneously, so this is no longer possible. * * A word about t_ctid: whenever a new tuple is stored on disk, its t_ctid - * is initialized with its own TID (location). If the tuple is ever updated, + * is initialized with its own TID (location). If the tuple is ever updated, * its t_ctid is changed to point to the replacement version of the tuple. * Thus, a tuple is the latest version of its row iff XMAX is invalid or * t_ctid points to itself (in which case, if XMAX is valid, the tuple is @@ -161,15 +161,13 @@ typedef HeapTupleHeaderData *HeapTupleHeader; */ #define HEAP_HASNULL 0x0001 /* has null attribute(s) */ #define HEAP_HASVARWIDTH 0x0002 /* has variable-width attribute(s) */ -#define HEAP_HASEXTERNAL 0x0004 /* has external stored - * attribute(s) */ -#define HEAP_HASCOMPRESSED 0x0008 /* has compressed stored - * attribute(s) */ +#define HEAP_HASEXTERNAL 0x0004 /* has external stored attribute(s) */ +#define HEAP_HASCOMPRESSED 0x0008 /* has compressed stored attribute(s) */ #define HEAP_HASEXTENDED 0x000C /* the two above combined */ #define HEAP_HASOID 0x0010 /* has an object-id field */ /* 0x0020 is presently unused */ -#define HEAP_XMAX_EXCL_LOCK 0x0040 /* xmax is exclusive locker */ -#define HEAP_XMAX_SHARED_LOCK 0x0080 /* xmax is shared locker */ +#define HEAP_XMAX_EXCL_LOCK 0x0040 /* xmax is exclusive locker */ +#define HEAP_XMAX_SHARED_LOCK 0x0080 /* xmax is shared locker */ /* if either LOCK bit is set, xmax hasn't deleted the tuple, only locked it */ #define HEAP_IS_LOCKED (HEAP_XMAX_EXCL_LOCK | HEAP_XMAX_SHARED_LOCK) #define HEAP_XMIN_COMMITTED 0x0100 /* t_xmin committed */ @@ -178,10 +176,10 @@ typedef HeapTupleHeaderData *HeapTupleHeader; #define HEAP_XMAX_INVALID 0x0800 /* t_xmax invalid/aborted */ #define HEAP_XMAX_IS_MULTI 0x1000 /* t_xmax is a MultiXactId */ #define HEAP_UPDATED 0x2000 /* this is UPDATEd version of row */ -#define HEAP_MOVED_OFF 0x4000 /* moved to another place by - * VACUUM FULL */ -#define HEAP_MOVED_IN 0x8000 /* moved from another place by - * VACUUM FULL */ +#define HEAP_MOVED_OFF 0x4000 /* moved to another place by VACUUM + * FULL */ +#define HEAP_MOVED_IN 0x8000 /* moved from another place by VACUUM + * FULL */ #define HEAP_MOVED (HEAP_MOVED_OFF | HEAP_MOVED_IN) #define HEAP_XACT_MASK 0xFFC0 /* visibility-related bits */ @@ -371,7 +369,7 @@ do { \ * * Part of a palloc'd tuple: the HeapTupleData itself and the tuple * form a single palloc'd chunk. t_data points to the memory location * immediately following the HeapTupleData struct (at offset HEAPTUPLESIZE), - * and t_datamcxt is the containing context. This is used as the output + * and t_datamcxt is the containing context. This is used as the output * format of heap_form_tuple and related routines. * * * Separately allocated tuple: t_data points to a palloc'd chunk that diff --git a/src/include/access/itup.h b/src/include/access/itup.h index 614ab44036..050eea6aed 100644 --- a/src/include/access/itup.h +++ b/src/include/access/itup.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/itup.h,v 1.43 2005/03/27 18:38:27 tgl Exp $ + * $PostgreSQL: pgsql/src/include/access/itup.h,v 1.44 2005/10/15 02:49:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -22,7 +22,7 @@ /* * Index tuple header structure * - * All index tuples start with IndexTupleData. If the HasNulls bit is set, + * All index tuples start with IndexTupleData. If the HasNulls bit is set, * this is followed by an IndexAttributeBitMapData. The index attribute * values follow, beginning at a MAXALIGN boundary. * @@ -129,7 +129,7 @@ typedef IndexAttributeBitMapData *IndexAttributeBitMap; /* routines in indextuple.c */ extern IndexTuple index_form_tuple(TupleDesc tupleDescriptor, - Datum *values, bool *isnull); + Datum *values, bool *isnull); extern Datum nocache_index_getattr(IndexTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull); extern IndexTuple CopyIndexTuple(IndexTuple source); diff --git a/src/include/access/multixact.h b/src/include/access/multixact.h index 229f149406..02f2d601c5 100644 --- a/src/include/access/multixact.h +++ b/src/include/access/multixact.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/multixact.h,v 1.6 2005/08/20 23:26:29 tgl Exp $ + * $PostgreSQL: pgsql/src/include/access/multixact.h,v 1.7 2005/10/15 02:49:42 momjian Exp $ */ #ifndef MULTIXACT_H #define MULTIXACT_H @@ -29,10 +29,10 @@ typedef struct xl_multixact_create { - MultiXactId mid; /* new MultiXact's ID */ - MultiXactOffset moff; /* its starting offset in members file */ - int32 nxids; /* number of member XIDs */ - TransactionId xids[1]; /* VARIABLE LENGTH ARRAY */ + MultiXactId mid; /* new MultiXact's ID */ + MultiXactOffset moff; /* its starting offset in members file */ + int32 nxids; /* number of member XIDs */ + TransactionId xids[1]; /* VARIABLE LENGTH ARRAY */ } xl_multixact_create; #define MinSizeOfMultiXactCreate offsetof(xl_multixact_create, xids) @@ -44,7 +44,7 @@ extern bool MultiXactIdIsRunning(MultiXactId multi); extern void MultiXactIdWait(MultiXactId multi); extern bool ConditionalMultiXactIdWait(MultiXactId multi); extern void MultiXactIdSetOldestMember(void); -extern int GetMultiXactIdMembers(MultiXactId multi, TransactionId **xids); +extern int GetMultiXactIdMembers(MultiXactId multi, TransactionId **xids); extern void AtEOXact_MultiXact(void); @@ -54,13 +54,13 @@ extern void BootStrapMultiXact(void); extern void StartupMultiXact(void); extern void ShutdownMultiXact(void); extern void MultiXactGetCheckptMulti(bool is_shutdown, - MultiXactId *nextMulti, - MultiXactOffset *nextMultiOffset); + MultiXactId *nextMulti, + MultiXactOffset *nextMultiOffset); extern void CheckPointMultiXact(void); extern void MultiXactSetNextMXact(MultiXactId nextMulti, - MultiXactOffset nextMultiOffset); + MultiXactOffset nextMultiOffset); extern void MultiXactAdvanceNextMXact(MultiXactId minMulti, - MultiXactOffset minMultiOffset); + MultiXactOffset minMultiOffset); extern void multixact_redo(XLogRecPtr lsn, XLogRecord *record); extern void multixact_desc(char *buf, uint8 xl_info, char *rec); diff --git a/src/include/access/nbtree.h b/src/include/access/nbtree.h index f522cd2799..72f0a02f77 100644 --- a/src/include/access/nbtree.h +++ b/src/include/access/nbtree.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/nbtree.h,v 1.86 2005/06/06 17:01:24 tgl Exp $ + * $PostgreSQL: pgsql/src/include/access/nbtree.h,v 1.87 2005/10/15 02:49:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -193,8 +193,7 @@ typedef BTItemData *BTItem; #define XLOG_BTREE_SPLIT_R_ROOT 0x60 /* as above, new item on right */ #define XLOG_BTREE_DELETE 0x70 /* delete leaf btitem */ #define XLOG_BTREE_DELETE_PAGE 0x80 /* delete an entire page */ -#define XLOG_BTREE_DELETE_PAGE_META 0x90 /* same, plus update - * metapage */ +#define XLOG_BTREE_DELETE_PAGE_META 0x90 /* same, plus update metapage */ #define XLOG_BTREE_NEWROOT 0xA0 /* new root page */ #define XLOG_BTREE_NEWMETA 0xB0 /* update metadata page */ @@ -392,8 +391,8 @@ typedef struct BTScanOpaqueData /* these fields are set by _bt_preprocess_keys(): */ bool qual_ok; /* false if qual can never be satisfied */ int numberOfKeys; /* number of preprocessed scan keys */ - int numberOfRequiredKeys; /* number of keys that must be - * matched to continue the scan */ + int numberOfRequiredKeys; /* number of keys that must be matched + * to continue the scan */ ScanKey keyData; /* array of preprocessed scan keys */ } BTScanOpaqueData; diff --git a/src/include/access/relscan.h b/src/include/access/relscan.h index 2d95785bc8..88f4078d24 100644 --- a/src/include/access/relscan.h +++ b/src/include/access/relscan.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/relscan.h,v 1.40 2005/10/07 14:55:35 alvherre Exp $ + * $PostgreSQL: pgsql/src/include/access/relscan.h,v 1.41 2005/10/15 02:49:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -77,9 +77,9 @@ typedef struct IndexScanDescData /* * If keys_are_unique and got_tuple are both true, we stop calling the - * index AM; it is then necessary for index_getnext to keep track of - * the logical scan position for itself. It does that using - * unique_tuple_pos: -1 = before row, 0 = on row, +1 = after row. + * index AM; it is then necessary for index_getnext to keep track of the + * logical scan position for itself. It does that using unique_tuple_pos: + * -1 = before row, 0 = on row, +1 = after row. */ int unique_tuple_pos; /* logical position */ int unique_tuple_mark; /* logical marked position */ diff --git a/src/include/access/slru.h b/src/include/access/slru.h index 63e828a956..972a822795 100644 --- a/src/include/access/slru.h +++ b/src/include/access/slru.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/slru.h,v 1.13 2005/08/20 23:26:29 tgl Exp $ + * $PostgreSQL: pgsql/src/include/access/slru.h,v 1.14 2005/10/15 02:49:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -42,9 +42,9 @@ typedef struct SlruSharedData /* * Info for each buffer slot. Page number is undefined when status is - * EMPTY. lru_count is essentially the number of page switches since - * last use of this page; the page with highest lru_count is the best - * candidate to replace. + * EMPTY. lru_count is essentially the number of page switches since last + * use of this page; the page with highest lru_count is the best candidate + * to replace. */ char *page_buffer[NUM_SLRU_BUFFERS]; SlruPageStatus page_status[NUM_SLRU_BUFFERS]; @@ -53,9 +53,9 @@ typedef struct SlruSharedData LWLockId buffer_locks[NUM_SLRU_BUFFERS]; /* - * latest_page_number is the page number of the current end of the - * log; this is not critical data, since we use it only to avoid - * swapping out the latest page. + * latest_page_number is the page number of the current end of the log; + * this is not critical data, since we use it only to avoid swapping out + * the latest page. */ int latest_page_number; } SlruSharedData; @@ -71,21 +71,21 @@ typedef struct SlruCtlData SlruShared shared; /* - * This flag tells whether to fsync writes (true for pg_clog, false - * for pg_subtrans). + * This flag tells whether to fsync writes (true for pg_clog, false for + * pg_subtrans). */ bool do_fsync; /* - * Decide which of two page numbers is "older" for truncation - * purposes. We need to use comparison of TransactionIds here in order - * to do the right thing with wraparound XID arithmetic. + * Decide which of two page numbers is "older" for truncation purposes. We + * need to use comparison of TransactionIds here in order to do the right + * thing with wraparound XID arithmetic. */ bool (*PagePrecedes) (int, int); /* - * Dir is set during SimpleLruInit and does not change thereafter. - * Since it's always the same, it doesn't need to be in shared memory. + * Dir is set during SimpleLruInit and does not change thereafter. Since + * it's always the same, it doesn't need to be in shared memory. */ char Dir[64]; } SlruCtlData; diff --git a/src/include/access/transam.h b/src/include/access/transam.h index 51e54a9e05..55e3a5ecc2 100644 --- a/src/include/access/transam.h +++ b/src/include/access/transam.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/transam.h,v 1.55 2005/08/12 01:36:03 tgl Exp $ + * $PostgreSQL: pgsql/src/include/access/transam.h,v 1.56 2005/10/15 02:49:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -59,7 +59,7 @@ * using the OID generator. (We start the generator at 10000.) * * OIDs beginning at 16384 are assigned from the OID generator - * during normal multiuser operation. (We force the generator up to + * during normal multiuser operation. (We force the generator up to * 16384 as soon as we are in normal operation.) * * The choices of 10000 and 16384 are completely arbitrary, and can be moved @@ -87,9 +87,9 @@ typedef struct VariableCacheData Oid nextOid; /* next OID to assign */ uint32 oidCount; /* OIDs available before must do XLOG work */ TransactionId nextXid; /* next XID to assign */ - TransactionId xidWarnLimit; /* start complaining here */ - TransactionId xidStopLimit; /* refuse to advance nextXid beyond here */ - TransactionId xidWrapLimit; /* where the world ends */ + TransactionId xidWarnLimit; /* start complaining here */ + TransactionId xidStopLimit; /* refuse to advance nextXid beyond here */ + TransactionId xidWrapLimit; /* where the world ends */ NameData limit_datname; /* database that needs vacuumed first */ } VariableCacheData; @@ -124,7 +124,7 @@ extern bool TransactionIdFollowsOrEquals(TransactionId id1, TransactionId id2); extern TransactionId GetNewTransactionId(bool isSubXact); extern TransactionId ReadNewTransactionId(void); extern void SetTransactionIdLimit(TransactionId oldest_datfrozenxid, - Name oldest_datname); + Name oldest_datname); extern Oid GetNewObjectId(void); #endif /* TRAMSAM_H */ diff --git a/src/include/access/tupmacs.h b/src/include/access/tupmacs.h index d92d242cbd..2bde97105f 100644 --- a/src/include/access/tupmacs.h +++ b/src/include/access/tupmacs.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/tupmacs.h,v 1.28 2005/05/06 17:24:55 tgl Exp $ + * $PostgreSQL: pgsql/src/include/access/tupmacs.h,v 1.29 2005/10/15 02:49:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -66,7 +66,6 @@ : \ PointerGetDatum((char *) (T)) \ ) - #else /* SIZEOF_DATUM != 8 */ #define fetch_att(T,attbyval,attlen) \ @@ -159,7 +158,6 @@ break; \ } \ } while (0) - #else /* SIZEOF_DATUM != 8 */ #define store_att_byval(T,newdatum,attlen) \ diff --git a/src/include/access/twophase.h b/src/include/access/twophase.h index 18fc3f9171..14196e2ec3 100644 --- a/src/include/access/twophase.h +++ b/src/include/access/twophase.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/twophase.h,v 1.5 2005/08/20 23:26:29 tgl Exp $ + * $PostgreSQL: pgsql/src/include/access/twophase.h,v 1.6 2005/10/15 02:49:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -25,7 +25,7 @@ typedef struct GlobalTransactionData *GlobalTransaction; /* GUC variable */ -extern int max_prepared_xacts; +extern int max_prepared_xacts; extern Size TwoPhaseShmemSize(void); extern void TwoPhaseShmemInit(void); @@ -33,8 +33,8 @@ extern void TwoPhaseShmemInit(void); extern PGPROC *TwoPhaseGetDummyProc(TransactionId xid); extern GlobalTransaction MarkAsPreparing(TransactionId xid, const char *gid, - TimestampTz prepared_at, - Oid owner, Oid databaseid); + TimestampTz prepared_at, + Oid owner, Oid databaseid); extern void StartPrepare(GlobalTransaction gxact); extern void EndPrepare(GlobalTransaction gxact); diff --git a/src/include/access/twophase_rmgr.h b/src/include/access/twophase_rmgr.h index f15233ba2f..0196258782 100644 --- a/src/include/access/twophase_rmgr.h +++ b/src/include/access/twophase_rmgr.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/twophase_rmgr.h,v 1.1 2005/06/17 22:32:48 tgl Exp $ + * $PostgreSQL: pgsql/src/include/access/twophase_rmgr.h,v 1.2 2005/10/15 02:49:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -15,7 +15,7 @@ #define TWOPHASE_RMGR_H typedef void (*TwoPhaseCallback) (TransactionId xid, uint16 info, - void *recdata, uint32 len); + void *recdata, uint32 len); typedef uint8 TwoPhaseRmgrId; /* @@ -24,8 +24,8 @@ typedef uint8 TwoPhaseRmgrId; #define TWOPHASE_RM_END_ID 0 #define TWOPHASE_RM_LOCK_ID 1 #define TWOPHASE_RM_INVAL_ID 2 -#define TWOPHASE_RM_FLATFILES_ID 3 -#define TWOPHASE_RM_NOTIFY_ID 4 +#define TWOPHASE_RM_FLATFILES_ID 3 +#define TWOPHASE_RM_NOTIFY_ID 4 #define TWOPHASE_RM_MAX_ID TWOPHASE_RM_NOTIFY_ID extern const TwoPhaseCallback twophase_recover_callbacks[]; @@ -34,6 +34,6 @@ extern const TwoPhaseCallback twophase_postabort_callbacks[]; extern void RegisterTwoPhaseRecord(TwoPhaseRmgrId rmid, uint16 info, - const void *data, uint32 len); + const void *data, uint32 len); #endif /* TWOPHASE_RMGR_H */ diff --git a/src/include/access/xact.h b/src/include/access/xact.h index ae5722ecb4..a30a63dd79 100644 --- a/src/include/access/xact.h +++ b/src/include/access/xact.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/xact.h,v 1.78 2005/06/29 22:51:57 tgl Exp $ + * $PostgreSQL: pgsql/src/include/access/xact.h,v 1.79 2005/10/15 02:49:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -61,7 +61,7 @@ typedef enum } SubXactEvent; typedef void (*SubXactCallback) (SubXactEvent event, SubTransactionId mySubid, - SubTransactionId parentSubid, void *arg); + SubTransactionId parentSubid, void *arg); /* ---------------- diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index b5a4667c11..1785bf8198 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/xlog.h,v 1.68 2005/08/20 23:26:29 tgl Exp $ + * $PostgreSQL: pgsql/src/include/access/xlog.h,v 1.69 2005/10/15 02:49:42 momjian Exp $ */ #ifndef XLOG_H #define XLOG_H @@ -31,11 +31,11 @@ * where there can be zero to three backup blocks (as signaled by xl_info flag * bits). XLogRecord structs always start on MAXALIGN boundaries in the WAL * files, and we round up SizeOfXLogRecord so that the rmgr data is also - * guaranteed to begin on a MAXALIGN boundary. However, no padding is added + * guaranteed to begin on a MAXALIGN boundary. However, no padding is added * to align BkpBlock structs or backup block data. * * NOTE: xl_len counts only the rmgr data, not the XLogRecord header, - * and also not any backup blocks. xl_tot_len counts everything. Neither + * and also not any backup blocks. xl_tot_len counts everything. Neither * length field is rounded up to an alignment boundary. */ typedef struct XLogRecord @@ -69,8 +69,7 @@ typedef struct XLogRecord * record. (Could support 4 if we cared to dedicate all the xl_info bits for * this purpose; currently bit 0 of xl_info is unused and available.) */ -#define XLR_BKP_BLOCK_MASK 0x0E /* all info bits used for bkp - * blocks */ +#define XLR_BKP_BLOCK_MASK 0x0E /* all info bits used for bkp blocks */ #define XLR_MAX_BKP_BLOCKS 3 #define XLR_SET_BKP_BLOCK(iblk) (0x08 >> (iblk)) #define XLR_BKP_BLOCK_1 XLR_SET_BKP_BLOCK(0) /* 0x08 */ @@ -86,7 +85,7 @@ typedef struct XLogRecord /* Sync methods */ #define SYNC_METHOD_FSYNC 0 #define SYNC_METHOD_FDATASYNC 1 -#define SYNC_METHOD_OPEN 2 /* for O_SYNC and O_DSYNC */ +#define SYNC_METHOD_OPEN 2 /* for O_SYNC and O_DSYNC */ #define SYNC_METHOD_FSYNC_WRITETHROUGH 3 extern int sync_method; @@ -109,7 +108,7 @@ extern int sync_method; * value (ignoring InvalidBuffer) appearing in the rdata chain. * * When buffer is valid, caller must set buffer_std to indicate whether the - * page uses standard pd_lower/pd_upper header fields. If this is true, then + * page uses standard pd_lower/pd_upper header fields. If this is true, then * XLOG is allowed to omit the free space between pd_lower and pd_upper from * the backed-up page image. Note that even when buffer_std is false, the * page MUST have an LSN field as its first eight bytes! diff --git a/src/include/c.h b/src/include/c.h index b7a1e11268..2f21247b26 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -12,7 +12,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/c.h,v 1.189 2005/07/21 15:16:27 momjian Exp $ + * $PostgreSQL: pgsql/src/include/c.h,v 1.190 2005/10/15 02:49:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -55,8 +55,8 @@ #if !defined(WIN32) && !defined(__CYGWIN__) #include "pg_config_os.h" /* must be before any system header files */ #else -#if defined(_MSC_VER) || defined(__BORLANDC__) -#define WIN32_CLIENT_ONLY +#if defined(_MSC_VER) || defined(__BORLANDC__) +#define WIN32_CLIENT_ONLY #endif #endif #include "postgres_ext.h" @@ -84,7 +84,8 @@ /* We have to redefine some system functions after they are included above */ #include "pg_config_os.h" #else -#include "port/win32.h" /* We didn't run configure, but this is our port file */ +#include "port/win32.h" /* We didn't run configure, but this is our + * port file */ #endif #endif @@ -127,7 +128,6 @@ #define CppAsString(identifier) #identifier #define CppConcat(x, y) x##y - #else /* !HAVE_STRINGIZE */ #define CppAsString(identifier) "identifier" @@ -285,7 +285,6 @@ typedef long int int64; #ifndef HAVE_UINT64 typedef unsigned long int uint64; #endif - #elif defined(HAVE_LONG_LONG_INT_64) /* We have working support for "long long int", use that */ @@ -295,7 +294,6 @@ typedef long long int int64; #ifndef HAVE_UINT64 typedef unsigned long long int uint64; #endif - #else /* not HAVE_LONG_INT_64 and not * HAVE_LONG_LONG_INT_64 */ @@ -434,7 +432,7 @@ typedef struct varlena VarChar; /* var-length char, ie SQL varchar(n) */ /* * Specialized array types. These are physically laid out just the same * as regular arrays (so that the regular array subscripting code works - * with them). They exist as distinct types mostly for historical reasons: + * with them). They exist as distinct types mostly for historical reasons: * they have nonstandard I/O behavior which we don't want to change for fear * of breaking applications that look at the system catalogs. There is also * an implementation issue for oidvector: it's part of the primary key for diff --git a/src/include/catalog/catalog.h b/src/include/catalog/catalog.h index d30bc76359..ee1d012ced 100644 --- a/src/include/catalog/catalog.h +++ b/src/include/catalog/catalog.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/catalog.h,v 1.33 2005/08/12 01:36:04 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/catalog.h,v 1.34 2005/10/15 02:49:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -33,7 +33,7 @@ extern bool IsReservedName(const char *name); extern Oid GetNewOid(Relation relation); extern Oid GetNewOidWithIndex(Relation relation, Relation indexrel); -extern Oid GetNewRelFileNode(Oid reltablespace, bool relisshared, - Relation pg_class); +extern Oid GetNewRelFileNode(Oid reltablespace, bool relisshared, + Relation pg_class); #endif /* CATALOG_H */ diff --git a/src/include/catalog/dependency.h b/src/include/catalog/dependency.h index ab50817cb7..5c5e87c746 100644 --- a/src/include/catalog/dependency.h +++ b/src/include/catalog/dependency.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/dependency.h,v 1.16 2005/08/01 04:03:57 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/dependency.h,v 1.17 2005/10/15 02:49:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -109,13 +109,12 @@ typedef struct ObjectAddress { Oid classId; /* Class Id from pg_class */ Oid objectId; /* OID of the object */ - int32 objectSubId; /* Subitem within the object (column of - * table) */ + int32 objectSubId; /* Subitem within the object (column of table) */ } ObjectAddress; /* - * This enum covers all system catalogs whose OIDs can appear in + * This enum covers all system catalogs whose OIDs can appear in * pg_depend.classId or pg_shdepend.classId. */ typedef enum ObjectClass @@ -175,26 +174,26 @@ extern void recordMultipleDependencies(const ObjectAddress *depender, extern long deleteDependencyRecordsFor(Oid classId, Oid objectId); extern long changeDependencyFor(Oid classId, Oid objectId, - Oid refClassId, Oid oldRefObjectId, - Oid newRefObjectId); + Oid refClassId, Oid oldRefObjectId, + Oid newRefObjectId); /* in pg_shdepend.c */ extern void recordSharedDependencyOn(ObjectAddress *depender, - ObjectAddress *referenced, - SharedDependencyType deptype); + ObjectAddress *referenced, + SharedDependencyType deptype); extern void deleteSharedDependencyRecordsFor(Oid classId, Oid objectId); extern void recordDependencyOnOwner(Oid classId, Oid objectId, Oid owner); extern void changeDependencyOnOwner(Oid classId, Oid objectId, - Oid newOwnerId); + Oid newOwnerId); extern void updateAclDependencies(Oid classId, Oid objectId, - Oid ownerId, bool isGrant, - int noldmembers, Oid *oldmembers, - int nnewmembers, Oid *newmembers); + Oid ownerId, bool isGrant, + int noldmembers, Oid *oldmembers, + int nnewmembers, Oid *newmembers); extern char *checkSharedDependencies(Oid classId, Oid objectId); diff --git a/src/include/catalog/heap.h b/src/include/catalog/heap.h index 02845920b9..9cb4c5351a 100644 --- a/src/include/catalog/heap.h +++ b/src/include/catalog/heap.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/heap.h,v 1.75 2005/08/26 03:08:15 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/heap.h,v 1.76 2005/10/15 02:49:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -23,8 +23,7 @@ typedef struct RawColumnDefault { AttrNumber attnum; /* attribute to attach default to */ - Node *raw_default; /* default value (untransformed parse - * tree) */ + Node *raw_default; /* default value (untransformed parse tree) */ } RawColumnDefault; typedef struct CookedConstraint diff --git a/src/include/catalog/index.h b/src/include/catalog/index.h index 8076f84a46..7f4120109d 100644 --- a/src/include/catalog/index.h +++ b/src/include/catalog/index.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/index.h,v 1.63 2005/05/11 06:24:55 neilc Exp $ + * $PostgreSQL: pgsql/src/include/catalog/index.h,v 1.64 2005/10/15 02:49:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -23,11 +23,11 @@ /* Typedef for callback function for IndexBuildHeapScan */ typedef void (*IndexBuildCallback) (Relation index, - HeapTuple htup, - Datum *values, - bool *isnull, - bool tupleIsAlive, - void *state); + HeapTuple htup, + Datum *values, + bool *isnull, + bool tupleIsAlive, + void *state); extern Oid index_create(Oid heapRelationId, @@ -53,7 +53,7 @@ extern void FormIndexDatum(IndexInfo *indexInfo, bool *isnull); extern void IndexCloseAndUpdateStats(Relation heap, double heapTuples, - Relation index, double indexTuples); + Relation index, double indexTuples); extern void setRelhasindex(Oid relid, bool hasindex, bool isprimary, Oid reltoastidxid); diff --git a/src/include/catalog/indexing.h b/src/include/catalog/indexing.h index bb4ce868fb..6edbf23873 100644 --- a/src/include/catalog/indexing.h +++ b/src/include/catalog/indexing.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/indexing.h,v 1.91 2005/09/08 20:07:42 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/indexing.h,v 1.92 2005/10/15 02:49:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -57,164 +57,164 @@ extern void CatalogUpdateIndexes(Relation heapRel, HeapTuple heapTuple); * index name (much less the numeric OID). */ -DECLARE_UNIQUE_INDEX(pg_aggregate_fnoid_index,2650, on pg_aggregate using btree(aggfnoid oid_ops)); +DECLARE_UNIQUE_INDEX(pg_aggregate_fnoid_index, 2650, on pg_aggregate using btree(aggfnoid oid_ops)); #define AggregateFnoidIndexId 2650 -DECLARE_UNIQUE_INDEX(pg_am_name_index,2651, on pg_am using btree(amname name_ops)); +DECLARE_UNIQUE_INDEX(pg_am_name_index, 2651, on pg_am using btree(amname name_ops)); #define AmNameIndexId 2651 -DECLARE_UNIQUE_INDEX(pg_am_oid_index,2652, on pg_am using btree(oid oid_ops)); +DECLARE_UNIQUE_INDEX(pg_am_oid_index, 2652, on pg_am using btree(oid oid_ops)); #define AmOidIndexId 2652 -DECLARE_UNIQUE_INDEX(pg_amop_opc_strat_index,2653, on pg_amop using btree(amopclaid oid_ops, amopsubtype oid_ops, amopstrategy int2_ops)); +DECLARE_UNIQUE_INDEX(pg_amop_opc_strat_index, 2653, on pg_amop using btree(amopclaid oid_ops, amopsubtype oid_ops, amopstrategy int2_ops)); #define AccessMethodStrategyIndexId 2653 -DECLARE_UNIQUE_INDEX(pg_amop_opr_opc_index,2654, on pg_amop using btree(amopopr oid_ops, amopclaid oid_ops)); +DECLARE_UNIQUE_INDEX(pg_amop_opr_opc_index, 2654, on pg_amop using btree(amopopr oid_ops, amopclaid oid_ops)); #define AccessMethodOperatorIndexId 2654 -DECLARE_UNIQUE_INDEX(pg_amproc_opc_proc_index,2655, on pg_amproc using btree(amopclaid oid_ops, amprocsubtype oid_ops, amprocnum int2_ops)); +DECLARE_UNIQUE_INDEX(pg_amproc_opc_proc_index, 2655, on pg_amproc using btree(amopclaid oid_ops, amprocsubtype oid_ops, amprocnum int2_ops)); #define AccessMethodProcedureIndexId 2655 -DECLARE_UNIQUE_INDEX(pg_attrdef_adrelid_adnum_index,2656, on pg_attrdef using btree(adrelid oid_ops, adnum int2_ops)); -#define AttrDefaultIndexId 2656 -DECLARE_UNIQUE_INDEX(pg_attrdef_oid_index,2657, on pg_attrdef using btree(oid oid_ops)); +DECLARE_UNIQUE_INDEX(pg_attrdef_adrelid_adnum_index, 2656, on pg_attrdef using btree(adrelid oid_ops, adnum int2_ops)); +#define AttrDefaultIndexId 2656 +DECLARE_UNIQUE_INDEX(pg_attrdef_oid_index, 2657, on pg_attrdef using btree(oid oid_ops)); #define AttrDefaultOidIndexId 2657 -DECLARE_UNIQUE_INDEX(pg_attribute_relid_attnam_index,2658, on pg_attribute using btree(attrelid oid_ops, attname name_ops)); +DECLARE_UNIQUE_INDEX(pg_attribute_relid_attnam_index, 2658, on pg_attribute using btree(attrelid oid_ops, attname name_ops)); #define AttributeRelidNameIndexId 2658 -DECLARE_UNIQUE_INDEX(pg_attribute_relid_attnum_index,2659, on pg_attribute using btree(attrelid oid_ops, attnum int2_ops)); +DECLARE_UNIQUE_INDEX(pg_attribute_relid_attnum_index, 2659, on pg_attribute using btree(attrelid oid_ops, attnum int2_ops)); #define AttributeRelidNumIndexId 2659 -DECLARE_UNIQUE_INDEX(pg_authid_rolname_index,2676, on pg_authid using btree(rolname name_ops)); +DECLARE_UNIQUE_INDEX(pg_authid_rolname_index, 2676, on pg_authid using btree(rolname name_ops)); #define AuthIdRolnameIndexId 2676 -DECLARE_UNIQUE_INDEX(pg_authid_oid_index,2677, on pg_authid using btree(oid oid_ops)); +DECLARE_UNIQUE_INDEX(pg_authid_oid_index, 2677, on pg_authid using btree(oid oid_ops)); #define AuthIdOidIndexId 2677 -DECLARE_UNIQUE_INDEX(pg_auth_members_role_member_index,2694, on pg_auth_members using btree(roleid oid_ops, member oid_ops)); +DECLARE_UNIQUE_INDEX(pg_auth_members_role_member_index, 2694, on pg_auth_members using btree(roleid oid_ops, member oid_ops)); #define AuthMemRoleMemIndexId 2694 -DECLARE_UNIQUE_INDEX(pg_auth_members_member_role_index,2695, on pg_auth_members using btree(member oid_ops, roleid oid_ops)); +DECLARE_UNIQUE_INDEX(pg_auth_members_member_role_index, 2695, on pg_auth_members using btree(member oid_ops, roleid oid_ops)); #define AuthMemMemRoleIndexId 2695 -DECLARE_UNIQUE_INDEX(pg_autovacuum_vacrelid_index,1250, on pg_autovacuum using btree(vacrelid oid_ops)); +DECLARE_UNIQUE_INDEX(pg_autovacuum_vacrelid_index, 1250, on pg_autovacuum using btree(vacrelid oid_ops)); #define AutovacuumRelidIndexId 1250 -DECLARE_UNIQUE_INDEX(pg_cast_oid_index,2660, on pg_cast using btree(oid oid_ops)); -#define CastOidIndexId 2660 -DECLARE_UNIQUE_INDEX(pg_cast_source_target_index,2661, on pg_cast using btree(castsource oid_ops, casttarget oid_ops)); +DECLARE_UNIQUE_INDEX(pg_cast_oid_index, 2660, on pg_cast using btree(oid oid_ops)); +#define CastOidIndexId 2660 +DECLARE_UNIQUE_INDEX(pg_cast_source_target_index, 2661, on pg_cast using btree(castsource oid_ops, casttarget oid_ops)); #define CastSourceTargetIndexId 2661 -DECLARE_UNIQUE_INDEX(pg_class_oid_index,2662, on pg_class using btree(oid oid_ops)); +DECLARE_UNIQUE_INDEX(pg_class_oid_index, 2662, on pg_class using btree(oid oid_ops)); #define ClassOidIndexId 2662 -DECLARE_UNIQUE_INDEX(pg_class_relname_nsp_index,2663, on pg_class using btree(relname name_ops, relnamespace oid_ops)); +DECLARE_UNIQUE_INDEX(pg_class_relname_nsp_index, 2663, on pg_class using btree(relname name_ops, relnamespace oid_ops)); #define ClassNameNspIndexId 2663 /* This following index is not used for a cache and is not unique */ -DECLARE_INDEX(pg_constraint_conname_nsp_index,2664, on pg_constraint using btree(conname name_ops, connamespace oid_ops)); +DECLARE_INDEX(pg_constraint_conname_nsp_index, 2664, on pg_constraint using btree(conname name_ops, connamespace oid_ops)); #define ConstraintNameNspIndexId 2664 /* This following index is not used for a cache and is not unique */ -DECLARE_INDEX(pg_constraint_conrelid_index,2665, on pg_constraint using btree(conrelid oid_ops)); -#define ConstraintRelidIndexId 2665 +DECLARE_INDEX(pg_constraint_conrelid_index, 2665, on pg_constraint using btree(conrelid oid_ops)); +#define ConstraintRelidIndexId 2665 /* This following index is not used for a cache and is not unique */ -DECLARE_INDEX(pg_constraint_contypid_index,2666, on pg_constraint using btree(contypid oid_ops)); -#define ConstraintTypidIndexId 2666 -DECLARE_UNIQUE_INDEX(pg_constraint_oid_index,2667, on pg_constraint using btree(oid oid_ops)); +DECLARE_INDEX(pg_constraint_contypid_index, 2666, on pg_constraint using btree(contypid oid_ops)); +#define ConstraintTypidIndexId 2666 +DECLARE_UNIQUE_INDEX(pg_constraint_oid_index, 2667, on pg_constraint using btree(oid oid_ops)); #define ConstraintOidIndexId 2667 -DECLARE_UNIQUE_INDEX(pg_conversion_default_index,2668, on pg_conversion using btree(connamespace oid_ops, conforencoding int4_ops, contoencoding int4_ops, oid oid_ops)); +DECLARE_UNIQUE_INDEX(pg_conversion_default_index, 2668, on pg_conversion using btree(connamespace oid_ops, conforencoding int4_ops, contoencoding int4_ops, oid oid_ops)); #define ConversionDefaultIndexId 2668 -DECLARE_UNIQUE_INDEX(pg_conversion_name_nsp_index,2669, on pg_conversion using btree(conname name_ops, connamespace oid_ops)); +DECLARE_UNIQUE_INDEX(pg_conversion_name_nsp_index, 2669, on pg_conversion using btree(conname name_ops, connamespace oid_ops)); #define ConversionNameNspIndexId 2669 -DECLARE_UNIQUE_INDEX(pg_conversion_oid_index,2670, on pg_conversion using btree(oid oid_ops)); +DECLARE_UNIQUE_INDEX(pg_conversion_oid_index, 2670, on pg_conversion using btree(oid oid_ops)); #define ConversionOidIndexId 2670 -DECLARE_UNIQUE_INDEX(pg_database_datname_index,2671, on pg_database using btree(datname name_ops)); +DECLARE_UNIQUE_INDEX(pg_database_datname_index, 2671, on pg_database using btree(datname name_ops)); #define DatabaseNameIndexId 2671 -DECLARE_UNIQUE_INDEX(pg_database_oid_index,2672, on pg_database using btree(oid oid_ops)); -#define DatabaseOidIndexId 2672 +DECLARE_UNIQUE_INDEX(pg_database_oid_index, 2672, on pg_database using btree(oid oid_ops)); +#define DatabaseOidIndexId 2672 /* This following index is not used for a cache and is not unique */ -DECLARE_INDEX(pg_depend_depender_index,2673, on pg_depend using btree(classid oid_ops, objid oid_ops, objsubid int4_ops)); +DECLARE_INDEX(pg_depend_depender_index, 2673, on pg_depend using btree(classid oid_ops, objid oid_ops, objsubid int4_ops)); #define DependDependerIndexId 2673 /* This following index is not used for a cache and is not unique */ -DECLARE_INDEX(pg_depend_reference_index,2674, on pg_depend using btree(refclassid oid_ops, refobjid oid_ops, refobjsubid int4_ops)); -#define DependReferenceIndexId 2674 +DECLARE_INDEX(pg_depend_reference_index, 2674, on pg_depend using btree(refclassid oid_ops, refobjid oid_ops, refobjsubid int4_ops)); +#define DependReferenceIndexId 2674 -DECLARE_UNIQUE_INDEX(pg_description_o_c_o_index,2675, on pg_description using btree(objoid oid_ops, classoid oid_ops, objsubid int4_ops)); +DECLARE_UNIQUE_INDEX(pg_description_o_c_o_index, 2675, on pg_description using btree(objoid oid_ops, classoid oid_ops, objsubid int4_ops)); #define DescriptionObjIndexId 2675 /* This following index is not used for a cache and is not unique */ -DECLARE_INDEX(pg_index_indrelid_index,2678, on pg_index using btree(indrelid oid_ops)); +DECLARE_INDEX(pg_index_indrelid_index, 2678, on pg_index using btree(indrelid oid_ops)); #define IndexIndrelidIndexId 2678 -DECLARE_UNIQUE_INDEX(pg_index_indexrelid_index,2679, on pg_index using btree(indexrelid oid_ops)); +DECLARE_UNIQUE_INDEX(pg_index_indexrelid_index, 2679, on pg_index using btree(indexrelid oid_ops)); #define IndexRelidIndexId 2679 -DECLARE_UNIQUE_INDEX(pg_inherits_relid_seqno_index,2680, on pg_inherits using btree(inhrelid oid_ops, inhseqno int4_ops)); +DECLARE_UNIQUE_INDEX(pg_inherits_relid_seqno_index, 2680, on pg_inherits using btree(inhrelid oid_ops, inhseqno int4_ops)); #define InheritsRelidSeqnoIndexId 2680 -DECLARE_UNIQUE_INDEX(pg_language_name_index,2681, on pg_language using btree(lanname name_ops)); +DECLARE_UNIQUE_INDEX(pg_language_name_index, 2681, on pg_language using btree(lanname name_ops)); #define LanguageNameIndexId 2681 -DECLARE_UNIQUE_INDEX(pg_language_oid_index,2682, on pg_language using btree(oid oid_ops)); -#define LanguageOidIndexId 2682 +DECLARE_UNIQUE_INDEX(pg_language_oid_index, 2682, on pg_language using btree(oid oid_ops)); +#define LanguageOidIndexId 2682 -DECLARE_UNIQUE_INDEX(pg_largeobject_loid_pn_index,2683, on pg_largeobject using btree(loid oid_ops, pageno int4_ops)); +DECLARE_UNIQUE_INDEX(pg_largeobject_loid_pn_index, 2683, on pg_largeobject using btree(loid oid_ops, pageno int4_ops)); #define LargeObjectLOidPNIndexId 2683 -DECLARE_UNIQUE_INDEX(pg_namespace_nspname_index,2684, on pg_namespace using btree(nspname name_ops)); +DECLARE_UNIQUE_INDEX(pg_namespace_nspname_index, 2684, on pg_namespace using btree(nspname name_ops)); #define NamespaceNameIndexId 2684 -DECLARE_UNIQUE_INDEX(pg_namespace_oid_index,2685, on pg_namespace using btree(oid oid_ops)); +DECLARE_UNIQUE_INDEX(pg_namespace_oid_index, 2685, on pg_namespace using btree(oid oid_ops)); #define NamespaceOidIndexId 2685 -DECLARE_UNIQUE_INDEX(pg_opclass_am_name_nsp_index,2686, on pg_opclass using btree(opcamid oid_ops, opcname name_ops, opcnamespace oid_ops)); +DECLARE_UNIQUE_INDEX(pg_opclass_am_name_nsp_index, 2686, on pg_opclass using btree(opcamid oid_ops, opcname name_ops, opcnamespace oid_ops)); #define OpclassAmNameNspIndexId 2686 -DECLARE_UNIQUE_INDEX(pg_opclass_oid_index,2687, on pg_opclass using btree(oid oid_ops)); +DECLARE_UNIQUE_INDEX(pg_opclass_oid_index, 2687, on pg_opclass using btree(oid oid_ops)); #define OpclassOidIndexId 2687 -DECLARE_UNIQUE_INDEX(pg_operator_oid_index,2688, on pg_operator using btree(oid oid_ops)); -#define OperatorOidIndexId 2688 -DECLARE_UNIQUE_INDEX(pg_operator_oprname_l_r_n_index,2689, on pg_operator using btree(oprname name_ops, oprleft oid_ops, oprright oid_ops, oprnamespace oid_ops)); -#define OperatorNameNspIndexId 2689 +DECLARE_UNIQUE_INDEX(pg_operator_oid_index, 2688, on pg_operator using btree(oid oid_ops)); +#define OperatorOidIndexId 2688 +DECLARE_UNIQUE_INDEX(pg_operator_oprname_l_r_n_index, 2689, on pg_operator using btree(oprname name_ops, oprleft oid_ops, oprright oid_ops, oprnamespace oid_ops)); +#define OperatorNameNspIndexId 2689 -DECLARE_UNIQUE_INDEX(pg_pltemplate_name_index,1137, on pg_pltemplate using btree(tmplname name_ops)); +DECLARE_UNIQUE_INDEX(pg_pltemplate_name_index, 1137, on pg_pltemplate using btree(tmplname name_ops)); #define PLTemplateNameIndexId 1137 -DECLARE_UNIQUE_INDEX(pg_proc_oid_index,2690, on pg_proc using btree(oid oid_ops)); +DECLARE_UNIQUE_INDEX(pg_proc_oid_index, 2690, on pg_proc using btree(oid oid_ops)); #define ProcedureOidIndexId 2690 -DECLARE_UNIQUE_INDEX(pg_proc_proname_args_nsp_index,2691, on pg_proc using btree(proname name_ops, proargtypes oidvector_ops, pronamespace oid_ops)); +DECLARE_UNIQUE_INDEX(pg_proc_proname_args_nsp_index, 2691, on pg_proc using btree(proname name_ops, proargtypes oidvector_ops, pronamespace oid_ops)); #define ProcedureNameArgsNspIndexId 2691 -DECLARE_UNIQUE_INDEX(pg_rewrite_oid_index,2692, on pg_rewrite using btree(oid oid_ops)); +DECLARE_UNIQUE_INDEX(pg_rewrite_oid_index, 2692, on pg_rewrite using btree(oid oid_ops)); #define RewriteOidIndexId 2692 -DECLARE_UNIQUE_INDEX(pg_rewrite_rel_rulename_index,2693, on pg_rewrite using btree(ev_class oid_ops, rulename name_ops)); +DECLARE_UNIQUE_INDEX(pg_rewrite_rel_rulename_index, 2693, on pg_rewrite using btree(ev_class oid_ops, rulename name_ops)); #define RewriteRelRulenameIndexId 2693 /* This following index is not used for a cache and is not unique */ -DECLARE_INDEX(pg_shdepend_depender_index,1232, on pg_shdepend using btree(dbid oid_ops, classid oid_ops, objid oid_ops)); +DECLARE_INDEX(pg_shdepend_depender_index, 1232, on pg_shdepend using btree(dbid oid_ops, classid oid_ops, objid oid_ops)); #define SharedDependDependerIndexId 1232 /* This following index is not used for a cache and is not unique */ -DECLARE_INDEX(pg_shdepend_reference_index,1233, on pg_shdepend using btree(refclassid oid_ops, refobjid oid_ops)); +DECLARE_INDEX(pg_shdepend_reference_index, 1233, on pg_shdepend using btree(refclassid oid_ops, refobjid oid_ops)); #define SharedDependReferenceIndexId 1233 -DECLARE_UNIQUE_INDEX(pg_statistic_relid_att_index,2696, on pg_statistic using btree(starelid oid_ops, staattnum int2_ops)); +DECLARE_UNIQUE_INDEX(pg_statistic_relid_att_index, 2696, on pg_statistic using btree(starelid oid_ops, staattnum int2_ops)); #define StatisticRelidAttnumIndexId 2696 -DECLARE_UNIQUE_INDEX(pg_tablespace_oid_index,2697, on pg_tablespace using btree(oid oid_ops)); +DECLARE_UNIQUE_INDEX(pg_tablespace_oid_index, 2697, on pg_tablespace using btree(oid oid_ops)); #define TablespaceOidIndexId 2697 -DECLARE_UNIQUE_INDEX(pg_tablespace_spcname_index,2698, on pg_tablespace using btree(spcname name_ops)); +DECLARE_UNIQUE_INDEX(pg_tablespace_spcname_index, 2698, on pg_tablespace using btree(spcname name_ops)); #define TablespaceNameIndexId 2698 /* This following index is not used for a cache and is not unique */ -DECLARE_INDEX(pg_trigger_tgconstrname_index,2699, on pg_trigger using btree(tgconstrname name_ops)); +DECLARE_INDEX(pg_trigger_tgconstrname_index, 2699, on pg_trigger using btree(tgconstrname name_ops)); #define TriggerConstrNameIndexId 2699 /* This following index is not used for a cache and is not unique */ -DECLARE_INDEX(pg_trigger_tgconstrrelid_index,2700, on pg_trigger using btree(tgconstrrelid oid_ops)); +DECLARE_INDEX(pg_trigger_tgconstrrelid_index, 2700, on pg_trigger using btree(tgconstrrelid oid_ops)); #define TriggerConstrRelidIndexId 2700 -DECLARE_UNIQUE_INDEX(pg_trigger_tgrelid_tgname_index,2701, on pg_trigger using btree(tgrelid oid_ops, tgname name_ops)); +DECLARE_UNIQUE_INDEX(pg_trigger_tgrelid_tgname_index, 2701, on pg_trigger using btree(tgrelid oid_ops, tgname name_ops)); #define TriggerRelidNameIndexId 2701 -DECLARE_UNIQUE_INDEX(pg_trigger_oid_index,2702, on pg_trigger using btree(oid oid_ops)); +DECLARE_UNIQUE_INDEX(pg_trigger_oid_index, 2702, on pg_trigger using btree(oid oid_ops)); #define TriggerOidIndexId 2702 -DECLARE_UNIQUE_INDEX(pg_type_oid_index,2703, on pg_type using btree(oid oid_ops)); -#define TypeOidIndexId 2703 -DECLARE_UNIQUE_INDEX(pg_type_typname_nsp_index,2704, on pg_type using btree(typname name_ops, typnamespace oid_ops)); -#define TypeNameNspIndexId 2704 +DECLARE_UNIQUE_INDEX(pg_type_oid_index, 2703, on pg_type using btree(oid oid_ops)); +#define TypeOidIndexId 2703 +DECLARE_UNIQUE_INDEX(pg_type_typname_nsp_index, 2704, on pg_type using btree(typname name_ops, typnamespace oid_ops)); +#define TypeNameNspIndexId 2704 /* last step of initialization script: build the indexes declared above */ BUILD_INDICES diff --git a/src/include/catalog/namespace.h b/src/include/catalog/namespace.h index 060849e8ba..d3f0dc9809 100644 --- a/src/include/catalog/namespace.h +++ b/src/include/catalog/namespace.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/namespace.h,v 1.36 2005/08/01 04:03:57 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/namespace.h,v 1.37 2005/10/15 02:49:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -94,7 +94,7 @@ extern Oid FindDefaultConversionProc(int4 for_encoding, int4 to_encoding); extern void InitializeSearchPath(void); extern void AtEOXact_Namespace(bool isCommit); extern void AtEOSubXact_Namespace(bool isCommit, SubTransactionId mySubid, - SubTransactionId parentSubid); + SubTransactionId parentSubid); /* stuff for search_path GUC variable */ extern char *namespace_search_path; diff --git a/src/include/catalog/pg_aggregate.h b/src/include/catalog/pg_aggregate.h index 2e150137ee..9c577c38e2 100644 --- a/src/include/catalog/pg_aggregate.h +++ b/src/include/catalog/pg_aggregate.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_aggregate.h,v 1.51 2005/04/14 01:38:20 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_aggregate.h,v 1.52 2005/10/15 02:49:42 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -148,9 +148,9 @@ DATA(insert ( 2147 int8inc - 0 20 0 )); DATA(insert ( 2148 int8_accum numeric_variance 0 1231 "{0,0,0}" )); DATA(insert ( 2149 int4_accum numeric_variance 0 1231 "{0,0,0}" )); DATA(insert ( 2150 int2_accum numeric_variance 0 1231 "{0,0,0}" )); -DATA(insert ( 2151 float4_accum float8_variance 0 1022 "{0,0,0}" )); -DATA(insert ( 2152 float8_accum float8_variance 0 1022 "{0,0,0}" )); -DATA(insert ( 2153 numeric_accum numeric_variance 0 1231 "{0,0,0}" )); +DATA(insert ( 2151 float4_accum float8_variance 0 1022 "{0,0,0}" )); +DATA(insert ( 2152 float8_accum float8_variance 0 1022 "{0,0,0}" )); +DATA(insert ( 2153 numeric_accum numeric_variance 0 1231 "{0,0,0}" )); /* stddev */ DATA(insert ( 2154 int8_accum numeric_stddev 0 1231 "{0,0,0}" )); diff --git a/src/include/catalog/pg_am.h b/src/include/catalog/pg_am.h index 0f05c48c84..4f21202fa9 100644 --- a/src/include/catalog/pg_am.h +++ b/src/include/catalog/pg_am.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_am.h,v 1.37 2005/06/27 12:45:23 teodor Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_am.h,v 1.38 2005/10/15 02:49:42 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -34,18 +34,18 @@ * typedef struct FormData_pg_am * ---------------- */ -#define AccessMethodRelationId 2601 +#define AccessMethodRelationId 2601 CATALOG(pg_am,2601) { NameData amname; /* access method name */ - int2 amstrategies; /* total NUMBER of strategies (operators) - * by which we can traverse/search this AM */ - int2 amsupport; /* total NUMBER of support functions that - * this AM uses */ - int2 amorderstrategy;/* if this AM has a sort order, the - * strategy number of the sort operator. - * Zero if AM is not ordered. */ + int2 amstrategies; /* total NUMBER of strategies (operators) by + * which we can traverse/search this AM */ + int2 amsupport; /* total NUMBER of support functions that this + * AM uses */ + int2 amorderstrategy;/* if this AM has a sort order, the strategy + * number of the sort operator. Zero if AM is + * not ordered. */ bool amcanunique; /* does AM support UNIQUE indexes? */ bool amcanmulticol; /* does AM support multi-column indexes? */ bool amoptionalkey; /* can query omit key for the first column? */ diff --git a/src/include/catalog/pg_amop.h b/src/include/catalog/pg_amop.h index 35589750d1..09ea2d9856 100644 --- a/src/include/catalog/pg_amop.h +++ b/src/include/catalog/pg_amop.h @@ -23,7 +23,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_amop.h,v 1.65 2005/07/01 19:19:03 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_amop.h,v 1.66 2005/10/15 02:49:42 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -46,7 +46,7 @@ * typedef struct FormData_pg_amop * ---------------- */ -#define AccessMethodOperatorRelationId 2602 +#define AccessMethodOperatorRelationId 2602 CATALOG(pg_amop,2602) BKI_WITHOUT_OIDS { @@ -84,35 +84,35 @@ typedef FormData_pg_amop *Form_pg_amop; * rtree box_ops */ -DATA(insert ( 425 0 1 f 493 )); -DATA(insert ( 425 0 2 f 494 )); -DATA(insert ( 425 0 3 f 500 )); -DATA(insert ( 425 0 4 f 495 )); -DATA(insert ( 425 0 5 f 496 )); -DATA(insert ( 425 0 6 f 499 )); -DATA(insert ( 425 0 7 f 498 )); -DATA(insert ( 425 0 8 f 497 )); -DATA(insert ( 425 0 9 f 2571 )); -DATA(insert ( 425 0 10 f 2570 )); -DATA(insert ( 425 0 11 f 2573 )); -DATA(insert ( 425 0 12 f 2572 )); +DATA(insert ( 425 0 1 f 493 )); +DATA(insert ( 425 0 2 f 494 )); +DATA(insert ( 425 0 3 f 500 )); +DATA(insert ( 425 0 4 f 495 )); +DATA(insert ( 425 0 5 f 496 )); +DATA(insert ( 425 0 6 f 499 )); +DATA(insert ( 425 0 7 f 498 )); +DATA(insert ( 425 0 8 f 497 )); +DATA(insert ( 425 0 9 f 2571 )); +DATA(insert ( 425 0 10 f 2570 )); +DATA(insert ( 425 0 11 f 2573 )); +DATA(insert ( 425 0 12 f 2572 )); /* * rtree poly_ops (supports polygons) */ -DATA(insert ( 1993 0 1 f 485 )); -DATA(insert ( 1993 0 2 f 486 )); -DATA(insert ( 1993 0 3 f 492 )); -DATA(insert ( 1993 0 4 f 487 )); -DATA(insert ( 1993 0 5 f 488 )); -DATA(insert ( 1993 0 6 f 491 )); -DATA(insert ( 1993 0 7 f 490 )); -DATA(insert ( 1993 0 8 f 489 )); -DATA(insert ( 1993 0 9 f 2575 )); -DATA(insert ( 1993 0 10 f 2574 )); -DATA(insert ( 1993 0 11 f 2577 )); -DATA(insert ( 1993 0 12 f 2576 )); +DATA(insert ( 1993 0 1 f 485 )); +DATA(insert ( 1993 0 2 f 486 )); +DATA(insert ( 1993 0 3 f 492 )); +DATA(insert ( 1993 0 4 f 487 )); +DATA(insert ( 1993 0 5 f 488 )); +DATA(insert ( 1993 0 6 f 491 )); +DATA(insert ( 1993 0 7 f 490 )); +DATA(insert ( 1993 0 8 f 489 )); +DATA(insert ( 1993 0 9 f 2575 )); +DATA(insert ( 1993 0 10 f 2574 )); +DATA(insert ( 1993 0 11 f 2577 )); +DATA(insert ( 1993 0 12 f 2576 )); /* * btree int2_ops @@ -623,51 +623,51 @@ DATA(insert ( 2235 0 1 f 974 )); * gist box_ops */ -DATA(insert ( 2593 0 1 f 493 )); -DATA(insert ( 2593 0 2 f 494 )); -DATA(insert ( 2593 0 3 f 500 )); -DATA(insert ( 2593 0 4 f 495 )); -DATA(insert ( 2593 0 5 f 496 )); -DATA(insert ( 2593 0 6 f 499 )); -DATA(insert ( 2593 0 7 f 498 )); -DATA(insert ( 2593 0 8 f 497 )); -DATA(insert ( 2593 0 9 f 2571 )); -DATA(insert ( 2593 0 10 f 2570 )); -DATA(insert ( 2593 0 11 f 2573 )); -DATA(insert ( 2593 0 12 f 2572 )); +DATA(insert ( 2593 0 1 f 493 )); +DATA(insert ( 2593 0 2 f 494 )); +DATA(insert ( 2593 0 3 f 500 )); +DATA(insert ( 2593 0 4 f 495 )); +DATA(insert ( 2593 0 5 f 496 )); +DATA(insert ( 2593 0 6 f 499 )); +DATA(insert ( 2593 0 7 f 498 )); +DATA(insert ( 2593 0 8 f 497 )); +DATA(insert ( 2593 0 9 f 2571 )); +DATA(insert ( 2593 0 10 f 2570 )); +DATA(insert ( 2593 0 11 f 2573 )); +DATA(insert ( 2593 0 12 f 2572 )); /* * gist poly_ops (supports polygons) */ -DATA(insert ( 2594 0 1 t 485 )); -DATA(insert ( 2594 0 2 t 486 )); -DATA(insert ( 2594 0 3 t 492 )); -DATA(insert ( 2594 0 4 t 487 )); -DATA(insert ( 2594 0 5 t 488 )); -DATA(insert ( 2594 0 6 t 491 )); -DATA(insert ( 2594 0 7 t 490 )); -DATA(insert ( 2594 0 8 t 489 )); -DATA(insert ( 2594 0 9 t 2575 )); -DATA(insert ( 2594 0 10 t 2574 )); -DATA(insert ( 2594 0 11 t 2577 )); -DATA(insert ( 2594 0 12 t 2576 )); +DATA(insert ( 2594 0 1 t 485 )); +DATA(insert ( 2594 0 2 t 486 )); +DATA(insert ( 2594 0 3 t 492 )); +DATA(insert ( 2594 0 4 t 487 )); +DATA(insert ( 2594 0 5 t 488 )); +DATA(insert ( 2594 0 6 t 491 )); +DATA(insert ( 2594 0 7 t 490 )); +DATA(insert ( 2594 0 8 t 489 )); +DATA(insert ( 2594 0 9 t 2575 )); +DATA(insert ( 2594 0 10 t 2574 )); +DATA(insert ( 2594 0 11 t 2577 )); +DATA(insert ( 2594 0 12 t 2576 )); /* * gist circle_ops */ -DATA(insert ( 2595 0 1 t 1506 )); -DATA(insert ( 2595 0 2 t 1507 )); -DATA(insert ( 2595 0 3 t 1513 )); -DATA(insert ( 2595 0 4 t 1508 )); -DATA(insert ( 2595 0 5 t 1509 )); -DATA(insert ( 2595 0 6 t 1512 )); -DATA(insert ( 2595 0 7 t 1511 )); -DATA(insert ( 2595 0 8 t 1510 )); -DATA(insert ( 2595 0 9 t 2589 )); -DATA(insert ( 2595 0 10 t 1515 )); -DATA(insert ( 2595 0 11 t 1514 )); -DATA(insert ( 2595 0 12 t 2590 )); +DATA(insert ( 2595 0 1 t 1506 )); +DATA(insert ( 2595 0 2 t 1507 )); +DATA(insert ( 2595 0 3 t 1513 )); +DATA(insert ( 2595 0 4 t 1508 )); +DATA(insert ( 2595 0 5 t 1509 )); +DATA(insert ( 2595 0 6 t 1512 )); +DATA(insert ( 2595 0 7 t 1511 )); +DATA(insert ( 2595 0 8 t 1510 )); +DATA(insert ( 2595 0 9 t 2589 )); +DATA(insert ( 2595 0 10 t 1515 )); +DATA(insert ( 2595 0 11 t 1514 )); +DATA(insert ( 2595 0 12 t 2590 )); #endif /* PG_AMOP_H */ diff --git a/src/include/catalog/pg_attribute.h b/src/include/catalog/pg_attribute.h index bda89f4405..06d7eaedc2 100644 --- a/src/include/catalog/pg_attribute.h +++ b/src/include/catalog/pg_attribute.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_attribute.h,v 1.118 2005/06/28 05:09:04 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_attribute.h,v 1.119 2005/10/15 02:49:42 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -43,41 +43,40 @@ CATALOG(pg_attribute,1249) BKI_BOOTSTRAP BKI_WITHOUT_OIDS { - Oid attrelid; /* OID of relation containing this - * attribute */ + Oid attrelid; /* OID of relation containing this attribute */ NameData attname; /* name of attribute */ /* * atttypid is the OID of the instance in Catalog Class pg_type that - * defines the data type of this attribute (e.g. int4). Information - * in that instance is redundant with the attlen, attbyval, and - * attalign attributes of this instance, so they had better match or - * Postgres will fail. + * defines the data type of this attribute (e.g. int4). Information in + * that instance is redundant with the attlen, attbyval, and attalign + * attributes of this instance, so they had better match or Postgres will + * fail. */ Oid atttypid; /* - * attstattarget is the target number of statistics datapoints to - * collect during VACUUM ANALYZE of this column. A zero here - * indicates that we do not wish to collect any stats about this - * column. A "-1" here indicates that no value has been explicitly set - * for this column, so ANALYZE should use the default setting. + * attstattarget is the target number of statistics datapoints to collect + * during VACUUM ANALYZE of this column. A zero here indicates that we do + * not wish to collect any stats about this column. A "-1" here indicates + * that no value has been explicitly set for this column, so ANALYZE + * should use the default setting. */ int4 attstattarget; /* - * attlen is a copy of the typlen field from pg_type for this - * attribute. See atttypid comments above. + * attlen is a copy of the typlen field from pg_type for this attribute. + * See atttypid comments above. */ int2 attlen; /* * attnum is the "attribute number" for the attribute: A value that * uniquely identifies this attribute within its class. For user - * attributes, Attribute numbers are greater than 0 and not greater - * than the number of attributes in the class. I.e. if the Class - * pg_class says that Class XYZ has 10 attributes, then the user - * attribute numbers in Class pg_attribute must be 1-10. + * attributes, Attribute numbers are greater than 0 and not greater than + * the number of attributes in the class. I.e. if the Class pg_class says + * that Class XYZ has 10 attributes, then the user attribute numbers in + * Class pg_attribute must be 1-10. * * System attributes have attribute numbers less than 0 that are unique * within the class, but not constrained to any particular range. @@ -93,20 +92,19 @@ CATALOG(pg_attribute,1249) BKI_BOOTSTRAP BKI_WITHOUT_OIDS int4 attndims; /* - * fastgetattr() uses attcacheoff to cache byte offsets of attributes - * in heap tuples. The value actually stored in pg_attribute (-1) - * indicates no cached value. But when we copy these tuples into a - * tuple descriptor, we may then update attcacheoff in the copies. - * This speeds up the attribute walking process. + * fastgetattr() uses attcacheoff to cache byte offsets of attributes in + * heap tuples. The value actually stored in pg_attribute (-1) indicates + * no cached value. But when we copy these tuples into a tuple + * descriptor, we may then update attcacheoff in the copies. This speeds + * up the attribute walking process. */ int4 attcacheoff; /* - * atttypmod records type-specific data supplied at table creation - * time (for example, the max length of a varchar field). It is - * passed to type-specific input and output functions as the third - * argument. The value will generally be -1 for types that do not need - * typmod. + * atttypmod records type-specific data supplied at table creation time + * (for example, the max length of a varchar field). It is passed to + * type-specific input and output functions as the third argument. The + * value will generally be -1 for types that do not need typmod. */ int4 atttypmod; @@ -296,7 +294,7 @@ DATA(insert ( 1247 tableoid 26 0 4 -7 0 -1 -1 t p i t f f t 0)); { 1255, {"pronargs"}, 21, -1, 2, 10, 0, -1, -1, true, 'p', 's', true, false, false, true, 0 }, \ { 1255, {"prorettype"}, 26, -1, 4, 11, 0, -1, -1, true, 'p', 'i', true, false, false, true, 0 }, \ { 1255, {"proargtypes"}, 30, -1, -1, 12, 1, -1, -1, false, 'p', 'i', true, false, false, true, 0 }, \ -{ 1255, {"proallargtypes"}, 1028, -1, -1, 13, 1, -1, -1, false, 'x', 'i', false, false, false, true, 0 }, \ +{ 1255, {"proallargtypes"}, 1028, -1, -1, 13, 1, -1, -1, false, 'x', 'i', false, false, false, true, 0 }, \ { 1255, {"proargmodes"}, 1002, -1, -1, 14, 1, -1, -1, false, 'x', 'i', false, false, false, true, 0 }, \ { 1255, {"proargnames"}, 1009, -1, -1, 15, 1, -1, -1, false, 'x', 'i', false, false, false, true, 0 }, \ { 1255, {"prosrc"}, 25, -1, -1, 16, 0, -1, -1, false, 'x', 'i', false, false, false, true, 0 }, \ diff --git a/src/include/catalog/pg_authid.h b/src/include/catalog/pg_authid.h index bcdee017d1..082eb28024 100644 --- a/src/include/catalog/pg_authid.h +++ b/src/include/catalog/pg_authid.h @@ -10,7 +10,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_authid.h,v 1.3 2005/07/31 17:19:21 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_authid.h,v 1.4 2005/10/15 02:49:42 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -24,7 +24,7 @@ /* * The CATALOG definition has to refer to the type of rolvaliduntil as * "timestamptz" (lower case) so that bootstrap mode recognizes it. But - * the C header files define this type as TimestampTz. Since the field is + * the C header files define this type as TimestampTz. Since the field is * potentially-null and therefore can't be accessed directly from C code, * there is no particular need for the C struct definition to show the * field type as TimestampTz --- instead we just make it Datum. @@ -38,7 +38,7 @@ * typedef struct FormData_pg_authid * ---------------- */ -#define AuthIdRelationId 1260 +#define AuthIdRelationId 1260 CATALOG(pg_authid,1260) BKI_SHARED_RELATION { @@ -53,7 +53,7 @@ CATALOG(pg_authid,1260) BKI_SHARED_RELATION /* remaining fields may be null; use heap_getattr to read them! */ text rolpassword; /* password, if any */ - timestamptz rolvaliduntil; /* password expiration time, if any */ + timestamptz rolvaliduntil; /* password expiration time, if any */ text rolconfig[1]; /* GUC settings to apply at login */ } FormData_pg_authid; diff --git a/src/include/catalog/pg_autovacuum.h b/src/include/catalog/pg_autovacuum.h index 542668206a..048319187f 100644 --- a/src/include/catalog/pg_autovacuum.h +++ b/src/include/catalog/pg_autovacuum.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_autovacuum.h,v 1.2 2005/08/11 21:11:47 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_autovacuum.h,v 1.3 2005/10/15 02:49:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -25,17 +25,17 @@ * typedef struct FormData_pg_autovacuum * ---------------- */ -#define AutovacuumRelationId 1248 +#define AutovacuumRelationId 1248 CATALOG(pg_autovacuum,1248) BKI_WITHOUT_OIDS { - Oid vacrelid; /* OID of table */ - bool enabled; /* enabled for this table? */ + Oid vacrelid; /* OID of table */ + bool enabled; /* enabled for this table? */ int4 vac_base_thresh; /* base threshold value */ - float4 vac_scale_factor; /* reltuples scaling factor */ + float4 vac_scale_factor; /* reltuples scaling factor */ int4 anl_base_thresh; /* base threshold value */ - float4 anl_scale_factor; /* reltuples scaling factor */ - int4 vac_cost_delay; /* vacuum cost-based delay */ - int4 vac_cost_limit; /* vacuum cost limit */ + float4 anl_scale_factor; /* reltuples scaling factor */ + int4 vac_cost_delay; /* vacuum cost-based delay */ + int4 vac_cost_limit; /* vacuum cost limit */ } FormData_pg_autovacuum; /* ---------------- diff --git a/src/include/catalog/pg_cast.h b/src/include/catalog/pg_cast.h index 7f9e30a5b2..b355b1137e 100644 --- a/src/include/catalog/pg_cast.h +++ b/src/include/catalog/pg_cast.h @@ -10,7 +10,7 @@ * * Copyright (c) 2002-2005, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/include/catalog/pg_cast.h,v 1.22 2005/10/02 23:50:11 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_cast.h,v 1.23 2005/10/15 02:49:42 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -21,7 +21,7 @@ #ifndef PG_CAST_H #define PG_CAST_H -#define CastRelationId 2605 +#define CastRelationId 2605 CATALOG(pg_cast,2605) { @@ -44,11 +44,9 @@ typedef FormData_pg_cast *Form_pg_cast; typedef enum CoercionCodes { - COERCION_CODE_IMPLICIT = 'i', /* coercion in context of - * expression */ - COERCION_CODE_ASSIGNMENT = 'a', /* coercion in context of - * assignment */ - COERCION_CODE_EXPLICIT = 'e' /* explicit cast operation */ + COERCION_CODE_IMPLICIT = 'i', /* coercion in context of expression */ + COERCION_CODE_ASSIGNMENT = 'a', /* coercion in context of assignment */ + COERCION_CODE_EXPLICIT = 'e' /* explicit cast operation */ } CoercionCodes; @@ -107,8 +105,8 @@ DATA(insert ( 1700 700 1745 i )); DATA(insert ( 1700 701 1746 i )); /* Allow explicit coercions between int4 and bool */ -DATA(insert ( 23 16 2557 e )); -DATA(insert ( 16 23 2558 e )); +DATA(insert ( 23 16 2557 e )); +DATA(insert ( 16 23 2558 e )); /* * OID category: allow implicit conversion from any integral type (including @@ -116,7 +114,7 @@ DATA(insert ( 16 23 2558 e )); * from OID to int4 or int8. Similarly for each OID-alias type. Also allow * implicit coercions between OID and each OID-alias type, as well as * regproc<->regprocedure and regoper<->regoperator. (Other coercions - * between alias types must pass through OID.) Lastly, there is an implicit + * between alias types must pass through OID.) Lastly, there is an implicit * cast from text to regclass, which exists mainly to support legacy forms * of nextval() and related functions. */ diff --git a/src/include/catalog/pg_class.h b/src/include/catalog/pg_class.h index b6d8f556b4..c0fb63f80e 100644 --- a/src/include/catalog/pg_class.h +++ b/src/include/catalog/pg_class.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_class.h,v 1.89 2005/06/28 05:09:05 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_class.h,v 1.90 2005/10/15 02:49:42 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -40,7 +40,7 @@ * to get the relacl field ... and don't forget to check isNull. * ---------------- */ -#define RelationRelationId 1259 +#define RelationRelationId 1259 CATALOG(pg_class,1259) BKI_BOOTSTRAP { @@ -62,8 +62,8 @@ CATALOG(pg_class,1259) BKI_BOOTSTRAP /* * Class pg_attribute must contain exactly "relnatts" user attributes - * (with attnums ranging from 1 to relnatts) for this class. It may - * also contain entries with negative attnums for system attributes. + * (with attnums ranging from 1 to relnatts) for this class. It may also + * contain entries with negative attnums for system attributes. */ int2 relchecks; /* # of CHECK constraints for class */ int2 reltriggers; /* # of TRIGGERs */ diff --git a/src/include/catalog/pg_constraint.h b/src/include/catalog/pg_constraint.h index d0495ca0e5..71fb126638 100644 --- a/src/include/catalog/pg_constraint.h +++ b/src/include/catalog/pg_constraint.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_constraint.h,v 1.17 2005/08/01 04:03:57 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_constraint.h,v 1.18 2005/10/15 02:49:42 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -39,10 +39,10 @@ CATALOG(pg_constraint,2606) * conname + connamespace is deliberately not unique; we allow, for * example, the same name to be used for constraints of different * relations. This is partly for backwards compatibility with past - * Postgres practice, and partly because we don't want to have to - * obtain a global lock to generate a globally unique name for a - * nameless constraint. We associate a namespace with constraint - * names only for SQL92 compatibility. + * Postgres practice, and partly because we don't want to have to obtain a + * global lock to generate a globally unique name for a nameless + * constraint. We associate a namespace with constraint names only for + * SQL92 compatibility. */ NameData conname; /* name of this constraint */ Oid connamespace; /* OID of namespace containing constraint */ @@ -51,9 +51,9 @@ CATALOG(pg_constraint,2606) bool condeferred; /* deferred by default? */ /* - * conrelid and conkey are only meaningful if the constraint applies - * to a specific relation (this excludes domain constraints and - * assertions). Otherwise conrelid is 0 and conkey is NULL. + * conrelid and conkey are only meaningful if the constraint applies to a + * specific relation (this excludes domain constraints and assertions). + * Otherwise conrelid is 0 and conkey is NULL. */ Oid conrelid; /* relation this constraint constrains */ @@ -61,15 +61,14 @@ CATALOG(pg_constraint,2606) * contypid links to the pg_type row for a domain if this is a domain * constraint. Otherwise it's 0. * - * For SQL-style global ASSERTIONs, both conrelid and contypid would be - * zero. This is not presently supported, however. + * For SQL-style global ASSERTIONs, both conrelid and contypid would be zero. + * This is not presently supported, however. */ Oid contypid; /* domain this constraint constrains */ /* * These fields, plus confkey, are only meaningful for a foreign-key - * constraint. Otherwise confrelid is 0 and the char fields are - * spaces. + * constraint. Otherwise confrelid is 0 and the char fields are spaces. */ Oid confrelid; /* relation referenced by foreign key */ char confupdtype; /* foreign key's ON UPDATE action */ @@ -186,6 +185,6 @@ extern char *ChooseConstraintName(const char *name1, const char *name2, extern char *GetConstraintNameForTrigger(Oid triggerId); extern void AlterConstraintNamespaces(Oid ownerId, Oid oldNspId, - Oid newNspId, bool isType); + Oid newNspId, bool isType); #endif /* PG_CONSTRAINT_H */ diff --git a/src/include/catalog/pg_control.h b/src/include/catalog/pg_control.h index 158a4ee92b..847ad08b2e 100644 --- a/src/include/catalog/pg_control.h +++ b/src/include/catalog/pg_control.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_control.h,v 1.24 2005/10/03 00:28:43 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_control.h,v 1.25 2005/10/15 02:49:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -31,15 +31,14 @@ typedef struct CheckPoint { XLogRecPtr redo; /* next RecPtr available when we began to - * create CheckPoint (i.e. REDO start - * point) */ + * create CheckPoint (i.e. REDO start point) */ XLogRecPtr undo; /* first record of oldest in-progress - * transaction when we started (i.e. UNDO - * end point) */ + * transaction when we started (i.e. UNDO end + * point) */ TimeLineID ThisTimeLineID; /* current TLI */ TransactionId nextXid; /* next free XID */ Oid nextOid; /* next free OID */ - MultiXactId nextMulti; /* next free MultiXactId */ + MultiXactId nextMulti; /* next free MultiXactId */ MultiXactOffset nextMultiOffset; /* next free MultiXact offset */ time_t time; /* time stamp of checkpoint */ } CheckPoint; @@ -74,23 +73,23 @@ typedef enum DBState typedef struct ControlFileData { /* - * Unique system identifier --- to ensure we match up xlog files with - * the installation that produced them. + * Unique system identifier --- to ensure we match up xlog files with the + * installation that produced them. */ uint64 system_identifier; /* * Version identifier information. Keep these fields at the same offset, - * especially pg_control_version; they won't be real useful if they - * move around. (For historical reasons they must be 8 bytes into - * the file rather than immediately at the front.) + * especially pg_control_version; they won't be real useful if they move + * around. (For historical reasons they must be 8 bytes into the file + * rather than immediately at the front.) * * pg_control_version identifies the format of pg_control itself. * catalog_version_no identifies the format of the system catalogs. * - * There are additional version identifiers in individual files; for - * example, WAL logs contain per-page magic numbers that can serve as - * version cues for the WAL log. + * There are additional version identifiers in individual files; for example, + * WAL logs contain per-page magic numbers that can serve as version cues + * for the WAL log. */ uint32 pg_control_version; /* PG_CONTROL_VERSION */ uint32 catalog_version_no; /* see catversion.h */ @@ -108,13 +107,13 @@ typedef struct ControlFileData CheckPoint checkPointCopy; /* copy of last check point record */ /* - * This data is used to check for hardware-architecture compatibility - * of the database and the backend executable. We need not check - * endianness explicitly, since the pg_control version will surely - * look wrong to a machine of different endianness, but we do need - * to worry about MAXALIGN and floating-point format. (Note: storage - * layout nominally also depends on SHORTALIGN and INTALIGN, but in - * practice these are the same on all architectures of interest.) + * This data is used to check for hardware-architecture compatibility of + * the database and the backend executable. We need not check endianness + * explicitly, since the pg_control version will surely look wrong to a + * machine of different endianness, but we do need to worry about MAXALIGN + * and floating-point format. (Note: storage layout nominally also + * depends on SHORTALIGN and INTALIGN, but in practice these are the same + * on all architectures of interest.) * * Testing just one double value is not a very bulletproof test for * floating-point compatibility, but it will catch most cases. @@ -124,8 +123,8 @@ typedef struct ControlFileData #define FLOATFORMAT_VALUE 1234567.0 /* - * This data is used to make sure that configuration of this database - * is compatible with the backend executable. + * This data is used to make sure that configuration of this database is + * compatible with the backend executable. */ uint32 blcksz; /* block size for this DB */ uint32 relseg_size; /* blocks per segment of large relation */ diff --git a/src/include/catalog/pg_database.h b/src/include/catalog/pg_database.h index 5ad5737825..ae81c65c38 100644 --- a/src/include/catalog/pg_database.h +++ b/src/include/catalog/pg_database.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_database.h,v 1.37 2005/07/31 17:19:21 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_database.h,v 1.38 2005/10/15 02:49:42 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -31,7 +31,7 @@ * typedef struct FormData_pg_database * ---------------- */ -#define DatabaseRelationId 1262 +#define DatabaseRelationId 1262 CATALOG(pg_database,1262) BKI_SHARED_RELATION { diff --git a/src/include/catalog/pg_index.h b/src/include/catalog/pg_index.h index 2c2ec34846..732799c85c 100644 --- a/src/include/catalog/pg_index.h +++ b/src/include/catalog/pg_index.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_index.h,v 1.37 2005/04/14 01:38:20 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_index.h,v 1.38 2005/10/15 02:49:42 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -45,11 +45,11 @@ CATALOG(pg_index,2610) BKI_WITHOUT_OIDS /* VARIABLE LENGTH FIELDS: */ int2vector indkey; /* column numbers of indexed cols, or 0 */ oidvector indclass; /* opclass identifiers */ - text indexprs; /* expression trees for index attributes - * that are not simple column references; - * one for each zero entry in indkey[] */ - text indpred; /* expression tree for predicate, if a - * partial index; else NULL */ + text indexprs; /* expression trees for index attributes that + * are not simple column references; one for + * each zero entry in indkey[] */ + text indpred; /* expression tree for predicate, if a partial + * index; else NULL */ } FormData_pg_index; /* ---------------- diff --git a/src/include/catalog/pg_inherits.h b/src/include/catalog/pg_inherits.h index b1b2b0aa33..d296e215e8 100644 --- a/src/include/catalog/pg_inherits.h +++ b/src/include/catalog/pg_inherits.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_inherits.h,v 1.20 2005/04/14 01:38:20 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_inherits.h,v 1.21 2005/10/15 02:49:42 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -31,7 +31,7 @@ * typedef struct FormData_pg_inherits * ---------------- */ -#define InheritsRelationId 2611 +#define InheritsRelationId 2611 CATALOG(pg_inherits,2611) BKI_WITHOUT_OIDS { diff --git a/src/include/catalog/pg_language.h b/src/include/catalog/pg_language.h index 2254a5bc41..6bbbcd8bcc 100644 --- a/src/include/catalog/pg_language.h +++ b/src/include/catalog/pg_language.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_language.h,v 1.26 2005/04/14 01:38:20 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_language.h,v 1.27 2005/10/15 02:49:42 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -31,7 +31,7 @@ * typedef struct FormData_pg_language * ---------------- */ -#define LanguageRelationId 2612 +#define LanguageRelationId 2612 CATALOG(pg_language,2612) { diff --git a/src/include/catalog/pg_listener.h b/src/include/catalog/pg_listener.h index fedacf2b07..081501119d 100644 --- a/src/include/catalog/pg_listener.h +++ b/src/include/catalog/pg_listener.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_listener.h,v 1.19 2005/04/14 01:38:20 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_listener.h,v 1.20 2005/10/15 02:49:42 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -31,7 +31,7 @@ * cpp turns this into typedef struct FormData_pg_listener * ---------------------------------------------------------------- */ -#define ListenerRelationId 2614 +#define ListenerRelationId 2614 CATALOG(pg_listener,2614) BKI_WITHOUT_OIDS { diff --git a/src/include/catalog/pg_namespace.h b/src/include/catalog/pg_namespace.h index c460500578..0259165ffe 100644 --- a/src/include/catalog/pg_namespace.h +++ b/src/include/catalog/pg_namespace.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_namespace.h,v 1.18 2005/06/28 05:09:06 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_namespace.h,v 1.19 2005/10/15 02:49:42 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -82,6 +82,6 @@ DESCR("Standard public schema"); /* * prototypes for functions in pg_namespace.c */ -extern Oid NamespaceCreate(const char *nspName, Oid ownerId); +extern Oid NamespaceCreate(const char *nspName, Oid ownerId); #endif /* PG_NAMESPACE_H */ diff --git a/src/include/catalog/pg_operator.h b/src/include/catalog/pg_operator.h index ef04e960a7..678ed306f2 100644 --- a/src/include/catalog/pg_operator.h +++ b/src/include/catalog/pg_operator.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_operator.h,v 1.136 2005/07/01 19:19:03 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_operator.h,v 1.137 2005/10/15 02:49:42 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -36,7 +36,7 @@ * typedef struct FormData_pg_operator * ---------------- */ -#define OperatorRelationId 2617 +#define OperatorRelationId 2617 CATALOG(pg_operator,2617) { @@ -568,8 +568,8 @@ DATA(insert OID = 1510 ( "@" PGNSP PGUID b f 718 718 16 1511 0 0 0 0 0 DATA(insert OID = 1511 ( "~" PGNSP PGUID b f 718 718 16 1510 0 0 0 0 0 circle_contain contsel contjoinsel )); DATA(insert OID = 1512 ( "~=" PGNSP PGUID b f 718 718 16 1512 0 0 0 0 0 circle_same eqsel eqjoinsel )); DATA(insert OID = 1513 ( "&&" PGNSP PGUID b f 718 718 16 1513 0 0 0 0 0 circle_overlap areasel areajoinsel )); -DATA(insert OID = 1514 ( "|>>" PGNSP PGUID b f 718 718 16 0 0 0 0 0 0 circle_above positionsel positionjoinsel )); -DATA(insert OID = 1515 ( "<<|" PGNSP PGUID b f 718 718 16 0 0 0 0 0 0 circle_below positionsel positionjoinsel )); +DATA(insert OID = 1514 ( "|>>" PGNSP PGUID b f 718 718 16 0 0 0 0 0 0 circle_above positionsel positionjoinsel )); +DATA(insert OID = 1515 ( "<<|" PGNSP PGUID b f 718 718 16 0 0 0 0 0 0 circle_below positionsel positionjoinsel )); DATA(insert OID = 1516 ( "+" PGNSP PGUID b f 718 600 718 0 0 0 0 0 0 circle_add_pt - - )); DATA(insert OID = 1517 ( "-" PGNSP PGUID b f 718 600 718 0 0 0 0 0 0 circle_sub_pt - - )); @@ -866,16 +866,16 @@ DATA(insert OID = 2554 ( "+" PGNSP PGUID b f 1186 1184 1184 1327 0 0 0 0 0 i DATA(insert OID = 2555 ( "+" PGNSP PGUID b f 23 1082 1082 1100 0 0 0 0 0 integer_pl_date - - )); /* new operators for Y-direction rtree opclasses */ -DATA(insert OID = 2570 ( "<<|" PGNSP PGUID b f 603 603 16 0 0 0 0 0 0 box_below positionsel positionjoinsel )); -DATA(insert OID = 2571 ( "&<|" PGNSP PGUID b f 603 603 16 0 0 0 0 0 0 box_overbelow positionsel positionjoinsel )); -DATA(insert OID = 2572 ( "|&>" PGNSP PGUID b f 603 603 16 0 0 0 0 0 0 box_overabove positionsel positionjoinsel )); -DATA(insert OID = 2573 ( "|>>" PGNSP PGUID b f 603 603 16 0 0 0 0 0 0 box_above positionsel positionjoinsel )); -DATA(insert OID = 2574 ( "<<|" PGNSP PGUID b f 604 604 16 0 0 0 0 0 0 poly_below positionsel positionjoinsel )); -DATA(insert OID = 2575 ( "&<|" PGNSP PGUID b f 604 604 16 0 0 0 0 0 0 poly_overbelow positionsel positionjoinsel )); -DATA(insert OID = 2576 ( "|&>" PGNSP PGUID b f 604 604 16 0 0 0 0 0 0 poly_overabove positionsel positionjoinsel )); -DATA(insert OID = 2577 ( "|>>" PGNSP PGUID b f 604 604 16 0 0 0 0 0 0 poly_above positionsel positionjoinsel )); -DATA(insert OID = 2589 ( "&<|" PGNSP PGUID b f 718 718 16 0 0 0 0 0 0 circle_overbelow positionsel positionjoinsel )); -DATA(insert OID = 2590 ( "|&>" PGNSP PGUID b f 718 718 16 0 0 0 0 0 0 circle_overabove positionsel positionjoinsel )); +DATA(insert OID = 2570 ( "<<|" PGNSP PGUID b f 603 603 16 0 0 0 0 0 0 box_below positionsel positionjoinsel )); +DATA(insert OID = 2571 ( "&<|" PGNSP PGUID b f 603 603 16 0 0 0 0 0 0 box_overbelow positionsel positionjoinsel )); +DATA(insert OID = 2572 ( "|&>" PGNSP PGUID b f 603 603 16 0 0 0 0 0 0 box_overabove positionsel positionjoinsel )); +DATA(insert OID = 2573 ( "|>>" PGNSP PGUID b f 603 603 16 0 0 0 0 0 0 box_above positionsel positionjoinsel )); +DATA(insert OID = 2574 ( "<<|" PGNSP PGUID b f 604 604 16 0 0 0 0 0 0 poly_below positionsel positionjoinsel )); +DATA(insert OID = 2575 ( "&<|" PGNSP PGUID b f 604 604 16 0 0 0 0 0 0 poly_overbelow positionsel positionjoinsel )); +DATA(insert OID = 2576 ( "|&>" PGNSP PGUID b f 604 604 16 0 0 0 0 0 0 poly_overabove positionsel positionjoinsel )); +DATA(insert OID = 2577 ( "|>>" PGNSP PGUID b f 604 604 16 0 0 0 0 0 0 poly_above positionsel positionjoinsel )); +DATA(insert OID = 2589 ( "&<|" PGNSP PGUID b f 718 718 16 0 0 0 0 0 0 circle_overbelow positionsel positionjoinsel )); +DATA(insert OID = 2590 ( "|&>" PGNSP PGUID b f 718 718 16 0 0 0 0 0 0 circle_overabove positionsel positionjoinsel )); /* diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h index 8c7f5b438c..b63b2d4a8b 100644 --- a/src/include/catalog/pg_proc.h +++ b/src/include/catalog/pg_proc.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.386 2005/10/02 23:50:11 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.387 2005/10/15 02:49:42 momjian Exp $ * * NOTES * The script catalog/genbki.sh reads this file and generates .bki @@ -53,7 +53,7 @@ CATALOG(pg_proc,1255) BKI_BOOTSTRAP /* VARIABLE LENGTH FIELDS: */ oidvector proargtypes; /* parameter types (excludes OUT params) */ - Oid proallargtypes[1]; /* all param types (NULL if IN only) */ + Oid proallargtypes[1]; /* all param types (NULL if IN only) */ char proargmodes[1]; /* parameter modes (NULL if IN only) */ text proargnames[1]; /* parameter names (NULL if no names) */ text prosrc; /* procedure source text */ @@ -200,7 +200,7 @@ DATA(insert OID = 1254 ( textregexeq PGNSP PGUID 12 f f t f i 2 16 "25 25" _ DESCR("matches regex., case-sensitive"); DATA(insert OID = 1256 ( textregexne PGNSP PGUID 12 f f t f i 2 16 "25 25" _null_ _null_ _null_ textregexne - _null_ )); DESCR("does not match regex., case-sensitive"); -DATA(insert OID = 1257 ( textlen PGNSP PGUID 12 f f t f i 1 23 "25" _null_ _null_ _null_ textlen - _null_ )); +DATA(insert OID = 1257 ( textlen PGNSP PGUID 12 f f t f i 1 23 "25" _null_ _null_ _null_ textlen - _null_ )); DESCR("length"); DATA(insert OID = 1258 ( textcat PGNSP PGUID 12 f f t f i 2 25 "25 25" _null_ _null_ _null_ textcat - _null_ )); DESCR("concatenate"); @@ -234,11 +234,11 @@ DESCR("I/O"); DATA(insert OID = 110 ( unknownout PGNSP PGUID 12 f f t f i 1 2275 "705" _null_ _null_ _null_ unknownout - _null_ )); DESCR("I/O"); DATA(insert OID = 111 ( numeric_fac PGNSP PGUID 12 f f t f i 1 1700 "20" _null_ _null_ _null_ numeric_fac - _null_ )); -DATA(insert OID = 112 ( text PGNSP PGUID 12 f f t f i 1 25 "23" _null_ _null_ _null_ int4_text - _null_ )); +DATA(insert OID = 112 ( text PGNSP PGUID 12 f f t f i 1 25 "23" _null_ _null_ _null_ int4_text - _null_ )); DESCR("convert int4 to text"); -DATA(insert OID = 113 ( text PGNSP PGUID 12 f f t f i 1 25 "21" _null_ _null_ _null_ int2_text - _null_ )); +DATA(insert OID = 113 ( text PGNSP PGUID 12 f f t f i 1 25 "21" _null_ _null_ _null_ int2_text - _null_ )); DESCR("convert int2 to text"); -DATA(insert OID = 114 ( text PGNSP PGUID 12 f f t f i 1 25 "26" _null_ _null_ _null_ oid_text - _null_ )); +DATA(insert OID = 114 ( text PGNSP PGUID 12 f f t f i 1 25 "26" _null_ _null_ _null_ oid_text - _null_ )); DESCR("convert oid to text"); DATA(insert OID = 115 ( box_above_eq PGNSP PGUID 12 f f t f i 2 16 "603 603" _null_ _null_ _null_ box_above_eq - _null_ )); @@ -262,31 +262,31 @@ DATA(insert OID = 123 ( box_in PGNSP PGUID 12 f f t f i 1 603 "2275" _null DESCR("I/O"); DATA(insert OID = 124 ( box_out PGNSP PGUID 12 f f t f i 1 2275 "603" _null_ _null_ _null_ box_out - _null_ )); DESCR("I/O"); -DATA(insert OID = 125 ( box_overlap PGNSP PGUID 12 f f t f i 2 16 "603 603" _null_ _null_ _null_ box_overlap - _null_ )); +DATA(insert OID = 125 ( box_overlap PGNSP PGUID 12 f f t f i 2 16 "603 603" _null_ _null_ _null_ box_overlap - _null_ )); DESCR("overlaps"); -DATA(insert OID = 126 ( box_ge PGNSP PGUID 12 f f t f i 2 16 "603 603" _null_ _null_ _null_ box_ge - _null_ )); +DATA(insert OID = 126 ( box_ge PGNSP PGUID 12 f f t f i 2 16 "603 603" _null_ _null_ _null_ box_ge - _null_ )); DESCR("greater-than-or-equal by area"); -DATA(insert OID = 127 ( box_gt PGNSP PGUID 12 f f t f i 2 16 "603 603" _null_ _null_ _null_ box_gt - _null_ )); +DATA(insert OID = 127 ( box_gt PGNSP PGUID 12 f f t f i 2 16 "603 603" _null_ _null_ _null_ box_gt - _null_ )); DESCR("greater-than by area"); -DATA(insert OID = 128 ( box_eq PGNSP PGUID 12 f f t f i 2 16 "603 603" _null_ _null_ _null_ box_eq - _null_ )); +DATA(insert OID = 128 ( box_eq PGNSP PGUID 12 f f t f i 2 16 "603 603" _null_ _null_ _null_ box_eq - _null_ )); DESCR("equal by area"); -DATA(insert OID = 129 ( box_lt PGNSP PGUID 12 f f t f i 2 16 "603 603" _null_ _null_ _null_ box_lt - _null_ )); +DATA(insert OID = 129 ( box_lt PGNSP PGUID 12 f f t f i 2 16 "603 603" _null_ _null_ _null_ box_lt - _null_ )); DESCR("less-than by area"); -DATA(insert OID = 130 ( box_le PGNSP PGUID 12 f f t f i 2 16 "603 603" _null_ _null_ _null_ box_le - _null_ )); +DATA(insert OID = 130 ( box_le PGNSP PGUID 12 f f t f i 2 16 "603 603" _null_ _null_ _null_ box_le - _null_ )); DESCR("less-than-or-equal by area"); -DATA(insert OID = 131 ( point_above PGNSP PGUID 12 f f t f i 2 16 "600 600" _null_ _null_ _null_ point_above - _null_ )); +DATA(insert OID = 131 ( point_above PGNSP PGUID 12 f f t f i 2 16 "600 600" _null_ _null_ _null_ point_above - _null_ )); DESCR("is above"); -DATA(insert OID = 132 ( point_left PGNSP PGUID 12 f f t f i 2 16 "600 600" _null_ _null_ _null_ point_left - _null_ )); +DATA(insert OID = 132 ( point_left PGNSP PGUID 12 f f t f i 2 16 "600 600" _null_ _null_ _null_ point_left - _null_ )); DESCR("is left of"); -DATA(insert OID = 133 ( point_right PGNSP PGUID 12 f f t f i 2 16 "600 600" _null_ _null_ _null_ point_right - _null_ )); +DATA(insert OID = 133 ( point_right PGNSP PGUID 12 f f t f i 2 16 "600 600" _null_ _null_ _null_ point_right - _null_ )); DESCR("is right of"); -DATA(insert OID = 134 ( point_below PGNSP PGUID 12 f f t f i 2 16 "600 600" _null_ _null_ _null_ point_below - _null_ )); +DATA(insert OID = 134 ( point_below PGNSP PGUID 12 f f t f i 2 16 "600 600" _null_ _null_ _null_ point_below - _null_ )); DESCR("is below"); -DATA(insert OID = 135 ( point_eq PGNSP PGUID 12 f f t f i 2 16 "600 600" _null_ _null_ _null_ point_eq - _null_ )); +DATA(insert OID = 135 ( point_eq PGNSP PGUID 12 f f t f i 2 16 "600 600" _null_ _null_ _null_ point_eq - _null_ )); DESCR("same as?"); -DATA(insert OID = 136 ( on_pb PGNSP PGUID 12 f f t f i 2 16 "600 603" _null_ _null_ _null_ on_pb - _null_ )); +DATA(insert OID = 136 ( on_pb PGNSP PGUID 12 f f t f i 2 16 "600 603" _null_ _null_ _null_ on_pb - _null_ )); DESCR("point inside box?"); -DATA(insert OID = 137 ( on_ppath PGNSP PGUID 12 f f t f i 2 16 "600 602" _null_ _null_ _null_ on_ppath - _null_ )); +DATA(insert OID = 137 ( on_ppath PGNSP PGUID 12 f f t f i 2 16 "600 602" _null_ _null_ _null_ on_ppath - _null_ )); DESCR("point within closed path, or point on open path"); DATA(insert OID = 138 ( box_center PGNSP PGUID 12 f f t f i 1 600 "603" _null_ _null_ _null_ box_center - _null_ )); DESCR("center of"); @@ -380,31 +380,31 @@ DATA(insert OID = 184 ( oideq PGNSP PGUID 12 f f t f i 2 16 "26 26" _null_ DESCR("equal"); DATA(insert OID = 185 ( oidne PGNSP PGUID 12 f f t f i 2 16 "26 26" _null_ _null_ _null_ oidne - _null_ )); DESCR("not equal"); -DATA(insert OID = 186 ( box_same PGNSP PGUID 12 f f t f i 2 16 "603 603" _null_ _null_ _null_ box_same - _null_ )); +DATA(insert OID = 186 ( box_same PGNSP PGUID 12 f f t f i 2 16 "603 603" _null_ _null_ _null_ box_same - _null_ )); DESCR("same as?"); -DATA(insert OID = 187 ( box_contain PGNSP PGUID 12 f f t f i 2 16 "603 603" _null_ _null_ _null_ box_contain - _null_ )); +DATA(insert OID = 187 ( box_contain PGNSP PGUID 12 f f t f i 2 16 "603 603" _null_ _null_ _null_ box_contain - _null_ )); DESCR("contains?"); -DATA(insert OID = 188 ( box_left PGNSP PGUID 12 f f t f i 2 16 "603 603" _null_ _null_ _null_ box_left - _null_ )); +DATA(insert OID = 188 ( box_left PGNSP PGUID 12 f f t f i 2 16 "603 603" _null_ _null_ _null_ box_left - _null_ )); DESCR("is left of"); -DATA(insert OID = 189 ( box_overleft PGNSP PGUID 12 f f t f i 2 16 "603 603" _null_ _null_ _null_ box_overleft - _null_ )); +DATA(insert OID = 189 ( box_overleft PGNSP PGUID 12 f f t f i 2 16 "603 603" _null_ _null_ _null_ box_overleft - _null_ )); DESCR("overlaps or is left of"); -DATA(insert OID = 190 ( box_overright PGNSP PGUID 12 f f t f i 2 16 "603 603" _null_ _null_ _null_ box_overright - _null_ )); +DATA(insert OID = 190 ( box_overright PGNSP PGUID 12 f f t f i 2 16 "603 603" _null_ _null_ _null_ box_overright - _null_ )); DESCR("overlaps or is right of"); -DATA(insert OID = 191 ( box_right PGNSP PGUID 12 f f t f i 2 16 "603 603" _null_ _null_ _null_ box_right - _null_ )); +DATA(insert OID = 191 ( box_right PGNSP PGUID 12 f f t f i 2 16 "603 603" _null_ _null_ _null_ box_right - _null_ )); DESCR("is right of"); -DATA(insert OID = 192 ( box_contained PGNSP PGUID 12 f f t f i 2 16 "603 603" _null_ _null_ _null_ box_contained - _null_ )); +DATA(insert OID = 192 ( box_contained PGNSP PGUID 12 f f t f i 2 16 "603 603" _null_ _null_ _null_ box_contained - _null_ )); DESCR("contained in?"); DATA(insert OID = 193 ( rt_box_union PGNSP PGUID 12 f f t f i 2 603 "603 603" _null_ _null_ _null_ rt_box_union - _null_ )); DESCR("r-tree"); DATA(insert OID = 194 ( rt_box_inter PGNSP PGUID 12 f f t f i 2 2278 "603 603" _null_ _null_ _null_ rt_box_inter - _null_ )); DESCR("r-tree"); -DATA(insert OID = 195 ( rt_box_size PGNSP PGUID 12 f f t f i 2 2278 "603 2281" _null_ _null_ _null_ rt_box_size - _null_ )); +DATA(insert OID = 195 ( rt_box_size PGNSP PGUID 12 f f t f i 2 2278 "603 2281" _null_ _null_ _null_ rt_box_size - _null_ )); DESCR("r-tree"); DATA(insert OID = 197 ( rt_poly_union PGNSP PGUID 12 f f t f i 2 604 "604 604" _null_ _null_ _null_ rt_poly_union - _null_ )); DESCR("r-tree"); DATA(insert OID = 198 ( rt_poly_inter PGNSP PGUID 12 f f t f i 2 2278 "604 604" _null_ _null_ _null_ rt_poly_inter - _null_ )); DESCR("r-tree"); -DATA(insert OID = 199 ( rt_poly_size PGNSP PGUID 12 f f t f i 2 2278 "604 2281" _null_ _null_ _null_ rt_poly_size - _null_ )); +DATA(insert OID = 199 ( rt_poly_size PGNSP PGUID 12 f f t f i 2 2278 "604 2281" _null_ _null_ _null_ rt_poly_size - _null_ )); DESCR("r-tree"); /* OIDS 200 - 299 */ @@ -425,16 +425,16 @@ DATA(insert OID = 206 ( float4um PGNSP PGUID 12 f f t f i 1 700 "700" _null DESCR("negate"); DATA(insert OID = 207 ( float4abs PGNSP PGUID 12 f f t f i 1 700 "700" _null_ _null_ _null_ float4abs - _null_ )); DESCR("absolute value"); -DATA(insert OID = 208 ( float4_accum PGNSP PGUID 12 f f t f i 2 1022 "1022 700" _null_ _null_ _null_ float4_accum - _null_ )); +DATA(insert OID = 208 ( float4_accum PGNSP PGUID 12 f f t f i 2 1022 "1022 700" _null_ _null_ _null_ float4_accum - _null_ )); DESCR("aggregate transition function"); DATA(insert OID = 209 ( float4larger PGNSP PGUID 12 f f t f i 2 700 "700 700" _null_ _null_ _null_ float4larger - _null_ )); DESCR("larger of two"); DATA(insert OID = 211 ( float4smaller PGNSP PGUID 12 f f t f i 2 700 "700 700" _null_ _null_ _null_ float4smaller - _null_ )); DESCR("smaller of two"); -DATA(insert OID = 212 ( int4um PGNSP PGUID 12 f f t f i 1 23 "23" _null_ _null_ _null_ int4um - _null_ )); +DATA(insert OID = 212 ( int4um PGNSP PGUID 12 f f t f i 1 23 "23" _null_ _null_ _null_ int4um - _null_ )); DESCR("negate"); -DATA(insert OID = 213 ( int2um PGNSP PGUID 12 f f t f i 1 21 "21" _null_ _null_ _null_ int2um - _null_ )); +DATA(insert OID = 213 ( int2um PGNSP PGUID 12 f f t f i 1 21 "21" _null_ _null_ _null_ int2um - _null_ )); DESCR("negate"); DATA(insert OID = 214 ( float8in PGNSP PGUID 12 f f t f i 1 701 "2275" _null_ _null_ _null_ float8in - _null_ )); @@ -453,7 +453,7 @@ DATA(insert OID = 220 ( float8um PGNSP PGUID 12 f f t f i 1 701 "701" _null DESCR("negate"); DATA(insert OID = 221 ( float8abs PGNSP PGUID 12 f f t f i 1 701 "701" _null_ _null_ _null_ float8abs - _null_ )); DESCR("absolute value"); -DATA(insert OID = 222 ( float8_accum PGNSP PGUID 12 f f t f i 2 1022 "1022 701" _null_ _null_ _null_ float8_accum - _null_ )); +DATA(insert OID = 222 ( float8_accum PGNSP PGUID 12 f f t f i 2 1022 "1022 701" _null_ _null_ _null_ float8_accum - _null_ )); DESCR("aggregate transition function"); DATA(insert OID = 223 ( float8larger PGNSP PGUID 12 f f t f i 2 701 "701 701" _null_ _null_ _null_ float8larger - _null_ )); DESCR("larger of two"); @@ -516,53 +516,53 @@ DATA(insert OID = 246 ( tintervalin PGNSP PGUID 12 f f t f s 1 704 "2275" _n DESCR("I/O"); DATA(insert OID = 247 ( tintervalout PGNSP PGUID 12 f f t f s 1 2275 "704" _null_ _null_ _null_ tintervalout - _null_ )); DESCR("I/O"); -DATA(insert OID = 248 ( intinterval PGNSP PGUID 12 f f t f i 2 16 "702 704" _null_ _null_ _null_ intinterval - _null_ )); +DATA(insert OID = 248 ( intinterval PGNSP PGUID 12 f f t f i 2 16 "702 704" _null_ _null_ _null_ intinterval - _null_ )); DESCR("abstime in tinterval"); DATA(insert OID = 249 ( tintervalrel PGNSP PGUID 12 f f t f i 1 703 "704" _null_ _null_ _null_ tintervalrel - _null_ )); DESCR("tinterval to reltime"); DATA(insert OID = 250 ( timenow PGNSP PGUID 12 f f t f s 0 702 "" _null_ _null_ _null_ timenow - _null_ )); DESCR("Current date and time (abstime)"); -DATA(insert OID = 251 ( abstimeeq PGNSP PGUID 12 f f t f i 2 16 "702 702" _null_ _null_ _null_ abstimeeq - _null_ )); +DATA(insert OID = 251 ( abstimeeq PGNSP PGUID 12 f f t f i 2 16 "702 702" _null_ _null_ _null_ abstimeeq - _null_ )); DESCR("equal"); -DATA(insert OID = 252 ( abstimene PGNSP PGUID 12 f f t f i 2 16 "702 702" _null_ _null_ _null_ abstimene - _null_ )); +DATA(insert OID = 252 ( abstimene PGNSP PGUID 12 f f t f i 2 16 "702 702" _null_ _null_ _null_ abstimene - _null_ )); DESCR("not equal"); -DATA(insert OID = 253 ( abstimelt PGNSP PGUID 12 f f t f i 2 16 "702 702" _null_ _null_ _null_ abstimelt - _null_ )); +DATA(insert OID = 253 ( abstimelt PGNSP PGUID 12 f f t f i 2 16 "702 702" _null_ _null_ _null_ abstimelt - _null_ )); DESCR("less-than"); -DATA(insert OID = 254 ( abstimegt PGNSP PGUID 12 f f t f i 2 16 "702 702" _null_ _null_ _null_ abstimegt - _null_ )); +DATA(insert OID = 254 ( abstimegt PGNSP PGUID 12 f f t f i 2 16 "702 702" _null_ _null_ _null_ abstimegt - _null_ )); DESCR("greater-than"); -DATA(insert OID = 255 ( abstimele PGNSP PGUID 12 f f t f i 2 16 "702 702" _null_ _null_ _null_ abstimele - _null_ )); +DATA(insert OID = 255 ( abstimele PGNSP PGUID 12 f f t f i 2 16 "702 702" _null_ _null_ _null_ abstimele - _null_ )); DESCR("less-than-or-equal"); -DATA(insert OID = 256 ( abstimege PGNSP PGUID 12 f f t f i 2 16 "702 702" _null_ _null_ _null_ abstimege - _null_ )); +DATA(insert OID = 256 ( abstimege PGNSP PGUID 12 f f t f i 2 16 "702 702" _null_ _null_ _null_ abstimege - _null_ )); DESCR("greater-than-or-equal"); -DATA(insert OID = 257 ( reltimeeq PGNSP PGUID 12 f f t f i 2 16 "703 703" _null_ _null_ _null_ reltimeeq - _null_ )); +DATA(insert OID = 257 ( reltimeeq PGNSP PGUID 12 f f t f i 2 16 "703 703" _null_ _null_ _null_ reltimeeq - _null_ )); DESCR("equal"); -DATA(insert OID = 258 ( reltimene PGNSP PGUID 12 f f t f i 2 16 "703 703" _null_ _null_ _null_ reltimene - _null_ )); +DATA(insert OID = 258 ( reltimene PGNSP PGUID 12 f f t f i 2 16 "703 703" _null_ _null_ _null_ reltimene - _null_ )); DESCR("not equal"); -DATA(insert OID = 259 ( reltimelt PGNSP PGUID 12 f f t f i 2 16 "703 703" _null_ _null_ _null_ reltimelt - _null_ )); +DATA(insert OID = 259 ( reltimelt PGNSP PGUID 12 f f t f i 2 16 "703 703" _null_ _null_ _null_ reltimelt - _null_ )); DESCR("less-than"); -DATA(insert OID = 260 ( reltimegt PGNSP PGUID 12 f f t f i 2 16 "703 703" _null_ _null_ _null_ reltimegt - _null_ )); +DATA(insert OID = 260 ( reltimegt PGNSP PGUID 12 f f t f i 2 16 "703 703" _null_ _null_ _null_ reltimegt - _null_ )); DESCR("greater-than"); -DATA(insert OID = 261 ( reltimele PGNSP PGUID 12 f f t f i 2 16 "703 703" _null_ _null_ _null_ reltimele - _null_ )); +DATA(insert OID = 261 ( reltimele PGNSP PGUID 12 f f t f i 2 16 "703 703" _null_ _null_ _null_ reltimele - _null_ )); DESCR("less-than-or-equal"); -DATA(insert OID = 262 ( reltimege PGNSP PGUID 12 f f t f i 2 16 "703 703" _null_ _null_ _null_ reltimege - _null_ )); +DATA(insert OID = 262 ( reltimege PGNSP PGUID 12 f f t f i 2 16 "703 703" _null_ _null_ _null_ reltimege - _null_ )); DESCR("greater-than-or-equal"); -DATA(insert OID = 263 ( tintervalsame PGNSP PGUID 12 f f t f i 2 16 "704 704" _null_ _null_ _null_ tintervalsame - _null_ )); +DATA(insert OID = 263 ( tintervalsame PGNSP PGUID 12 f f t f i 2 16 "704 704" _null_ _null_ _null_ tintervalsame - _null_ )); DESCR("same as?"); -DATA(insert OID = 264 ( tintervalct PGNSP PGUID 12 f f t f i 2 16 "704 704" _null_ _null_ _null_ tintervalct - _null_ )); +DATA(insert OID = 264 ( tintervalct PGNSP PGUID 12 f f t f i 2 16 "704 704" _null_ _null_ _null_ tintervalct - _null_ )); DESCR("less-than"); -DATA(insert OID = 265 ( tintervalov PGNSP PGUID 12 f f t f i 2 16 "704 704" _null_ _null_ _null_ tintervalov - _null_ )); +DATA(insert OID = 265 ( tintervalov PGNSP PGUID 12 f f t f i 2 16 "704 704" _null_ _null_ _null_ tintervalov - _null_ )); DESCR("overlaps"); -DATA(insert OID = 266 ( tintervalleneq PGNSP PGUID 12 f f t f i 2 16 "704 703" _null_ _null_ _null_ tintervalleneq - _null_ )); +DATA(insert OID = 266 ( tintervalleneq PGNSP PGUID 12 f f t f i 2 16 "704 703" _null_ _null_ _null_ tintervalleneq - _null_ )); DESCR("length equal"); -DATA(insert OID = 267 ( tintervallenne PGNSP PGUID 12 f f t f i 2 16 "704 703" _null_ _null_ _null_ tintervallenne - _null_ )); +DATA(insert OID = 267 ( tintervallenne PGNSP PGUID 12 f f t f i 2 16 "704 703" _null_ _null_ _null_ tintervallenne - _null_ )); DESCR("length not equal to"); -DATA(insert OID = 268 ( tintervallenlt PGNSP PGUID 12 f f t f i 2 16 "704 703" _null_ _null_ _null_ tintervallenlt - _null_ )); +DATA(insert OID = 268 ( tintervallenlt PGNSP PGUID 12 f f t f i 2 16 "704 703" _null_ _null_ _null_ tintervallenlt - _null_ )); DESCR("length less-than"); -DATA(insert OID = 269 ( tintervallengt PGNSP PGUID 12 f f t f i 2 16 "704 703" _null_ _null_ _null_ tintervallengt - _null_ )); +DATA(insert OID = 269 ( tintervallengt PGNSP PGUID 12 f f t f i 2 16 "704 703" _null_ _null_ _null_ tintervallengt - _null_ )); DESCR("length greater-than"); -DATA(insert OID = 270 ( tintervallenle PGNSP PGUID 12 f f t f i 2 16 "704 703" _null_ _null_ _null_ tintervallenle - _null_ )); +DATA(insert OID = 270 ( tintervallenle PGNSP PGUID 12 f f t f i 2 16 "704 703" _null_ _null_ _null_ tintervallenle - _null_ )); DESCR("length less-than-or-equal"); -DATA(insert OID = 271 ( tintervallenge PGNSP PGUID 12 f f t f i 2 16 "704 703" _null_ _null_ _null_ tintervallenge - _null_ )); +DATA(insert OID = 271 ( tintervallenge PGNSP PGUID 12 f f t f i 2 16 "704 703" _null_ _null_ _null_ tintervallenge - _null_ )); DESCR("length greater-than-or-equal"); DATA(insert OID = 272 ( tintervalstart PGNSP PGUID 12 f f t f i 1 702 "704" _null_ _null_ _null_ tintervalstart - _null_ )); DESCR("start of interval"); @@ -570,12 +570,12 @@ DATA(insert OID = 273 ( tintervalend PGNSP PGUID 12 f f t f i 1 702 "704" _n DESCR("end of interval"); DATA(insert OID = 274 ( timeofday PGNSP PGUID 12 f f t f v 0 25 "" _null_ _null_ _null_ timeofday - _null_ )); DESCR("Current date and time - increments during transactions"); -DATA(insert OID = 275 ( isfinite PGNSP PGUID 12 f f t f i 1 16 "702" _null_ _null_ _null_ abstime_finite - _null_ )); +DATA(insert OID = 275 ( isfinite PGNSP PGUID 12 f f t f i 1 16 "702" _null_ _null_ _null_ abstime_finite - _null_ )); DESCR("finite abstime?"); -DATA(insert OID = 277 ( inter_sl PGNSP PGUID 12 f f t f i 2 16 "601 628" _null_ _null_ _null_ inter_sl - _null_ )); +DATA(insert OID = 277 ( inter_sl PGNSP PGUID 12 f f t f i 2 16 "601 628" _null_ _null_ _null_ inter_sl - _null_ )); DESCR("intersect?"); -DATA(insert OID = 278 ( inter_lb PGNSP PGUID 12 f f t f i 2 16 "628 603" _null_ _null_ _null_ inter_lb - _null_ )); +DATA(insert OID = 278 ( inter_lb PGNSP PGUID 12 f f t f i 2 16 "628 603" _null_ _null_ _null_ inter_lb - _null_ )); DESCR("intersect?"); DATA(insert OID = 279 ( float48mul PGNSP PGUID 12 f f t f i 2 701 "700 701" _null_ _null_ _null_ float48mul - _null_ )); @@ -595,58 +595,58 @@ DESCR("add"); DATA(insert OID = 286 ( float84mi PGNSP PGUID 12 f f t f i 2 701 "701 700" _null_ _null_ _null_ float84mi - _null_ )); DESCR("subtract"); -DATA(insert OID = 287 ( float4eq PGNSP PGUID 12 f f t f i 2 16 "700 700" _null_ _null_ _null_ float4eq - _null_ )); +DATA(insert OID = 287 ( float4eq PGNSP PGUID 12 f f t f i 2 16 "700 700" _null_ _null_ _null_ float4eq - _null_ )); DESCR("equal"); -DATA(insert OID = 288 ( float4ne PGNSP PGUID 12 f f t f i 2 16 "700 700" _null_ _null_ _null_ float4ne - _null_ )); +DATA(insert OID = 288 ( float4ne PGNSP PGUID 12 f f t f i 2 16 "700 700" _null_ _null_ _null_ float4ne - _null_ )); DESCR("not equal"); -DATA(insert OID = 289 ( float4lt PGNSP PGUID 12 f f t f i 2 16 "700 700" _null_ _null_ _null_ float4lt - _null_ )); +DATA(insert OID = 289 ( float4lt PGNSP PGUID 12 f f t f i 2 16 "700 700" _null_ _null_ _null_ float4lt - _null_ )); DESCR("less-than"); -DATA(insert OID = 290 ( float4le PGNSP PGUID 12 f f t f i 2 16 "700 700" _null_ _null_ _null_ float4le - _null_ )); +DATA(insert OID = 290 ( float4le PGNSP PGUID 12 f f t f i 2 16 "700 700" _null_ _null_ _null_ float4le - _null_ )); DESCR("less-than-or-equal"); -DATA(insert OID = 291 ( float4gt PGNSP PGUID 12 f f t f i 2 16 "700 700" _null_ _null_ _null_ float4gt - _null_ )); +DATA(insert OID = 291 ( float4gt PGNSP PGUID 12 f f t f i 2 16 "700 700" _null_ _null_ _null_ float4gt - _null_ )); DESCR("greater-than"); -DATA(insert OID = 292 ( float4ge PGNSP PGUID 12 f f t f i 2 16 "700 700" _null_ _null_ _null_ float4ge - _null_ )); +DATA(insert OID = 292 ( float4ge PGNSP PGUID 12 f f t f i 2 16 "700 700" _null_ _null_ _null_ float4ge - _null_ )); DESCR("greater-than-or-equal"); -DATA(insert OID = 293 ( float8eq PGNSP PGUID 12 f f t f i 2 16 "701 701" _null_ _null_ _null_ float8eq - _null_ )); +DATA(insert OID = 293 ( float8eq PGNSP PGUID 12 f f t f i 2 16 "701 701" _null_ _null_ _null_ float8eq - _null_ )); DESCR("equal"); -DATA(insert OID = 294 ( float8ne PGNSP PGUID 12 f f t f i 2 16 "701 701" _null_ _null_ _null_ float8ne - _null_ )); +DATA(insert OID = 294 ( float8ne PGNSP PGUID 12 f f t f i 2 16 "701 701" _null_ _null_ _null_ float8ne - _null_ )); DESCR("not equal"); -DATA(insert OID = 295 ( float8lt PGNSP PGUID 12 f f t f i 2 16 "701 701" _null_ _null_ _null_ float8lt - _null_ )); +DATA(insert OID = 295 ( float8lt PGNSP PGUID 12 f f t f i 2 16 "701 701" _null_ _null_ _null_ float8lt - _null_ )); DESCR("less-than"); -DATA(insert OID = 296 ( float8le PGNSP PGUID 12 f f t f i 2 16 "701 701" _null_ _null_ _null_ float8le - _null_ )); +DATA(insert OID = 296 ( float8le PGNSP PGUID 12 f f t f i 2 16 "701 701" _null_ _null_ _null_ float8le - _null_ )); DESCR("less-than-or-equal"); -DATA(insert OID = 297 ( float8gt PGNSP PGUID 12 f f t f i 2 16 "701 701" _null_ _null_ _null_ float8gt - _null_ )); +DATA(insert OID = 297 ( float8gt PGNSP PGUID 12 f f t f i 2 16 "701 701" _null_ _null_ _null_ float8gt - _null_ )); DESCR("greater-than"); -DATA(insert OID = 298 ( float8ge PGNSP PGUID 12 f f t f i 2 16 "701 701" _null_ _null_ _null_ float8ge - _null_ )); +DATA(insert OID = 298 ( float8ge PGNSP PGUID 12 f f t f i 2 16 "701 701" _null_ _null_ _null_ float8ge - _null_ )); DESCR("greater-than-or-equal"); -DATA(insert OID = 299 ( float48eq PGNSP PGUID 12 f f t f i 2 16 "700 701" _null_ _null_ _null_ float48eq - _null_ )); +DATA(insert OID = 299 ( float48eq PGNSP PGUID 12 f f t f i 2 16 "700 701" _null_ _null_ _null_ float48eq - _null_ )); DESCR("equal"); /* OIDS 300 - 399 */ -DATA(insert OID = 300 ( float48ne PGNSP PGUID 12 f f t f i 2 16 "700 701" _null_ _null_ _null_ float48ne - _null_ )); +DATA(insert OID = 300 ( float48ne PGNSP PGUID 12 f f t f i 2 16 "700 701" _null_ _null_ _null_ float48ne - _null_ )); DESCR("not equal"); -DATA(insert OID = 301 ( float48lt PGNSP PGUID 12 f f t f i 2 16 "700 701" _null_ _null_ _null_ float48lt - _null_ )); +DATA(insert OID = 301 ( float48lt PGNSP PGUID 12 f f t f i 2 16 "700 701" _null_ _null_ _null_ float48lt - _null_ )); DESCR("less-than"); -DATA(insert OID = 302 ( float48le PGNSP PGUID 12 f f t f i 2 16 "700 701" _null_ _null_ _null_ float48le - _null_ )); +DATA(insert OID = 302 ( float48le PGNSP PGUID 12 f f t f i 2 16 "700 701" _null_ _null_ _null_ float48le - _null_ )); DESCR("less-than-or-equal"); -DATA(insert OID = 303 ( float48gt PGNSP PGUID 12 f f t f i 2 16 "700 701" _null_ _null_ _null_ float48gt - _null_ )); +DATA(insert OID = 303 ( float48gt PGNSP PGUID 12 f f t f i 2 16 "700 701" _null_ _null_ _null_ float48gt - _null_ )); DESCR("greater-than"); -DATA(insert OID = 304 ( float48ge PGNSP PGUID 12 f f t f i 2 16 "700 701" _null_ _null_ _null_ float48ge - _null_ )); +DATA(insert OID = 304 ( float48ge PGNSP PGUID 12 f f t f i 2 16 "700 701" _null_ _null_ _null_ float48ge - _null_ )); DESCR("greater-than-or-equal"); -DATA(insert OID = 305 ( float84eq PGNSP PGUID 12 f f t f i 2 16 "701 700" _null_ _null_ _null_ float84eq - _null_ )); +DATA(insert OID = 305 ( float84eq PGNSP PGUID 12 f f t f i 2 16 "701 700" _null_ _null_ _null_ float84eq - _null_ )); DESCR("equal"); -DATA(insert OID = 306 ( float84ne PGNSP PGUID 12 f f t f i 2 16 "701 700" _null_ _null_ _null_ float84ne - _null_ )); +DATA(insert OID = 306 ( float84ne PGNSP PGUID 12 f f t f i 2 16 "701 700" _null_ _null_ _null_ float84ne - _null_ )); DESCR("not equal"); -DATA(insert OID = 307 ( float84lt PGNSP PGUID 12 f f t f i 2 16 "701 700" _null_ _null_ _null_ float84lt - _null_ )); +DATA(insert OID = 307 ( float84lt PGNSP PGUID 12 f f t f i 2 16 "701 700" _null_ _null_ _null_ float84lt - _null_ )); DESCR("less-than"); -DATA(insert OID = 308 ( float84le PGNSP PGUID 12 f f t f i 2 16 "701 700" _null_ _null_ _null_ float84le - _null_ )); +DATA(insert OID = 308 ( float84le PGNSP PGUID 12 f f t f i 2 16 "701 700" _null_ _null_ _null_ float84le - _null_ )); DESCR("less-than-or-equal"); -DATA(insert OID = 309 ( float84gt PGNSP PGUID 12 f f t f i 2 16 "701 700" _null_ _null_ _null_ float84gt - _null_ )); +DATA(insert OID = 309 ( float84gt PGNSP PGUID 12 f f t f i 2 16 "701 700" _null_ _null_ _null_ float84gt - _null_ )); DESCR("greater-than"); -DATA(insert OID = 310 ( float84ge PGNSP PGUID 12 f f t f i 2 16 "701 700" _null_ _null_ _null_ float84ge - _null_ )); +DATA(insert OID = 310 ( float84ge PGNSP PGUID 12 f f t f i 2 16 "701 700" _null_ _null_ _null_ float84ge - _null_ )); DESCR("greater-than-or-equal"); DATA(insert OID = 311 ( float8 PGNSP PGUID 12 f f t f i 1 701 "700" _null_ _null_ _null_ ftod - _null_ )); @@ -657,7 +657,7 @@ DATA(insert OID = 313 ( int4 PGNSP PGUID 12 f f t f i 1 23 "21" _null_ _ DESCR("convert int2 to int4"); DATA(insert OID = 314 ( int2 PGNSP PGUID 12 f f t f i 1 21 "23" _null_ _null_ _null_ i4toi2 - _null_ )); DESCR("convert int4 to int2"); -DATA(insert OID = 315 ( int2vectoreq PGNSP PGUID 12 f f t f i 2 16 "22 22" _null_ _null_ _null_ int2vectoreq - _null_ )); +DATA(insert OID = 315 ( int2vectoreq PGNSP PGUID 12 f f t f i 2 16 "22 22" _null_ _null_ _null_ int2vectoreq - _null_ )); DESCR("equal"); DATA(insert OID = 316 ( float8 PGNSP PGUID 12 f f t f i 1 701 "23" _null_ _null_ _null_ i4tod - _null_ )); DESCR("convert int4 to float8"); @@ -684,7 +684,7 @@ DATA(insert OID = 326 ( rtmarkpos PGNSP PGUID 12 f f t f v 1 2278 "2281" _n DESCR("r-tree(internal)"); DATA(insert OID = 327 ( rtrestrpos PGNSP PGUID 12 f f t f v 1 2278 "2281" _null_ _null_ _null_ rtrestrpos - _null_ )); DESCR("r-tree(internal)"); -DATA(insert OID = 328 ( rtrescan PGNSP PGUID 12 f f t f v 2 2278 "2281 2281" _null_ _null_ _null_ rtrescan - _null_ )); +DATA(insert OID = 328 ( rtrescan PGNSP PGUID 12 f f t f v 2 2278 "2281 2281" _null_ _null_ _null_ rtrescan - _null_ )); DESCR("r-tree(internal)"); DATA(insert OID = 321 ( rtbulkdelete PGNSP PGUID 12 f f t f v 3 2281 "2281 2281 2281" _null_ _null_ _null_ rtbulkdelete - _null_ )); DESCR("r-tree(internal)"); @@ -699,7 +699,7 @@ DATA(insert OID = 331 ( btinsert PGNSP PGUID 12 f f t f v 6 16 "2281 2281 2 DESCR("btree(internal)"); DATA(insert OID = 333 ( btbeginscan PGNSP PGUID 12 f f t f v 3 2281 "2281 2281 2281" _null_ _null_ _null_ btbeginscan - _null_ )); DESCR("btree(internal)"); -DATA(insert OID = 334 ( btrescan PGNSP PGUID 12 f f t f v 2 2278 "2281 2281" _null_ _null_ _null_ btrescan - _null_ )); +DATA(insert OID = 334 ( btrescan PGNSP PGUID 12 f f t f v 2 2278 "2281 2281" _null_ _null_ _null_ btrescan - _null_ )); DESCR("btree(internal)"); DATA(insert OID = 335 ( btendscan PGNSP PGUID 12 f f t f v 1 2278 "2281" _null_ _null_ _null_ btendscan - _null_ )); DESCR("btree(internal)"); @@ -716,21 +716,21 @@ DESCR("btree(internal)"); DATA(insert OID = 1268 ( btcostestimate PGNSP PGUID 12 f f t f v 7 2278 "2281 2281 2281 2281 2281 2281 2281" _null_ _null_ _null_ btcostestimate - _null_ )); DESCR("btree(internal)"); -DATA(insert OID = 339 ( poly_same PGNSP PGUID 12 f f t f i 2 16 "604 604" _null_ _null_ _null_ poly_same - _null_ )); +DATA(insert OID = 339 ( poly_same PGNSP PGUID 12 f f t f i 2 16 "604 604" _null_ _null_ _null_ poly_same - _null_ )); DESCR("same as?"); -DATA(insert OID = 340 ( poly_contain PGNSP PGUID 12 f f t f i 2 16 "604 604" _null_ _null_ _null_ poly_contain - _null_ )); +DATA(insert OID = 340 ( poly_contain PGNSP PGUID 12 f f t f i 2 16 "604 604" _null_ _null_ _null_ poly_contain - _null_ )); DESCR("contains?"); -DATA(insert OID = 341 ( poly_left PGNSP PGUID 12 f f t f i 2 16 "604 604" _null_ _null_ _null_ poly_left - _null_ )); +DATA(insert OID = 341 ( poly_left PGNSP PGUID 12 f f t f i 2 16 "604 604" _null_ _null_ _null_ poly_left - _null_ )); DESCR("is left of"); -DATA(insert OID = 342 ( poly_overleft PGNSP PGUID 12 f f t f i 2 16 "604 604" _null_ _null_ _null_ poly_overleft - _null_ )); +DATA(insert OID = 342 ( poly_overleft PGNSP PGUID 12 f f t f i 2 16 "604 604" _null_ _null_ _null_ poly_overleft - _null_ )); DESCR("overlaps or is left of"); -DATA(insert OID = 343 ( poly_overright PGNSP PGUID 12 f f t f i 2 16 "604 604" _null_ _null_ _null_ poly_overright - _null_ )); +DATA(insert OID = 343 ( poly_overright PGNSP PGUID 12 f f t f i 2 16 "604 604" _null_ _null_ _null_ poly_overright - _null_ )); DESCR("overlaps or is right of"); -DATA(insert OID = 344 ( poly_right PGNSP PGUID 12 f f t f i 2 16 "604 604" _null_ _null_ _null_ poly_right - _null_ )); +DATA(insert OID = 344 ( poly_right PGNSP PGUID 12 f f t f i 2 16 "604 604" _null_ _null_ _null_ poly_right - _null_ )); DESCR("is right of"); -DATA(insert OID = 345 ( poly_contained PGNSP PGUID 12 f f t f i 2 16 "604 604" _null_ _null_ _null_ poly_contained - _null_ )); +DATA(insert OID = 345 ( poly_contained PGNSP PGUID 12 f f t f i 2 16 "604 604" _null_ _null_ _null_ poly_contained - _null_ )); DESCR("contained in?"); -DATA(insert OID = 346 ( poly_overlap PGNSP PGUID 12 f f t f i 2 16 "604 604" _null_ _null_ _null_ poly_overlap - _null_ )); +DATA(insert OID = 346 ( poly_overlap PGNSP PGUID 12 f f t f i 2 16 "604 604" _null_ _null_ _null_ poly_overlap - _null_ )); DESCR("overlaps"); DATA(insert OID = 347 ( poly_in PGNSP PGUID 12 f f t f i 1 604 "2275" _null_ _null_ _null_ poly_in - _null_ )); DESCR("I/O"); @@ -743,15 +743,15 @@ DATA(insert OID = 351 ( btint4cmp PGNSP PGUID 12 f f t f i 2 23 "23 23" _nu DESCR("btree less-equal-greater"); DATA(insert OID = 842 ( btint8cmp PGNSP PGUID 12 f f t f i 2 23 "20 20" _null_ _null_ _null_ btint8cmp - _null_ )); DESCR("btree less-equal-greater"); -DATA(insert OID = 354 ( btfloat4cmp PGNSP PGUID 12 f f t f i 2 23 "700 700" _null_ _null_ _null_ btfloat4cmp - _null_ )); +DATA(insert OID = 354 ( btfloat4cmp PGNSP PGUID 12 f f t f i 2 23 "700 700" _null_ _null_ _null_ btfloat4cmp - _null_ )); DESCR("btree less-equal-greater"); -DATA(insert OID = 355 ( btfloat8cmp PGNSP PGUID 12 f f t f i 2 23 "701 701" _null_ _null_ _null_ btfloat8cmp - _null_ )); +DATA(insert OID = 355 ( btfloat8cmp PGNSP PGUID 12 f f t f i 2 23 "701 701" _null_ _null_ _null_ btfloat8cmp - _null_ )); DESCR("btree less-equal-greater"); DATA(insert OID = 356 ( btoidcmp PGNSP PGUID 12 f f t f i 2 23 "26 26" _null_ _null_ _null_ btoidcmp - _null_ )); DESCR("btree less-equal-greater"); DATA(insert OID = 404 ( btoidvectorcmp PGNSP PGUID 12 f f t f i 2 23 "30 30" _null_ _null_ _null_ btoidvectorcmp - _null_ )); DESCR("btree less-equal-greater"); -DATA(insert OID = 357 ( btabstimecmp PGNSP PGUID 12 f f t f i 2 23 "702 702" _null_ _null_ _null_ btabstimecmp - _null_ )); +DATA(insert OID = 357 ( btabstimecmp PGNSP PGUID 12 f f t f i 2 23 "702 702" _null_ _null_ _null_ btabstimecmp - _null_ )); DESCR("btree less-equal-greater"); DATA(insert OID = 358 ( btcharcmp PGNSP PGUID 12 f f t f i 2 23 "18 18" _null_ _null_ _null_ btcharcmp - _null_ )); DESCR("btree less-equal-greater"); @@ -759,11 +759,11 @@ DATA(insert OID = 359 ( btnamecmp PGNSP PGUID 12 f f t f i 2 23 "19 19" _nu DESCR("btree less-equal-greater"); DATA(insert OID = 360 ( bttextcmp PGNSP PGUID 12 f f t f i 2 23 "25 25" _null_ _null_ _null_ bttextcmp - _null_ )); DESCR("btree less-equal-greater"); -DATA(insert OID = 377 ( cash_cmp PGNSP PGUID 12 f f t f i 2 23 "790 790" _null_ _null_ _null_ cash_cmp - _null_ )); +DATA(insert OID = 377 ( cash_cmp PGNSP PGUID 12 f f t f i 2 23 "790 790" _null_ _null_ _null_ cash_cmp - _null_ )); DESCR("btree less-equal-greater"); -DATA(insert OID = 380 ( btreltimecmp PGNSP PGUID 12 f f t f i 2 23 "703 703" _null_ _null_ _null_ btreltimecmp - _null_ )); +DATA(insert OID = 380 ( btreltimecmp PGNSP PGUID 12 f f t f i 2 23 "703 703" _null_ _null_ _null_ btreltimecmp - _null_ )); DESCR("btree less-equal-greater"); -DATA(insert OID = 381 ( bttintervalcmp PGNSP PGUID 12 f f t f i 2 23 "704 704" _null_ _null_ _null_ bttintervalcmp - _null_ )); +DATA(insert OID = 381 ( bttintervalcmp PGNSP PGUID 12 f f t f i 2 23 "704 704" _null_ _null_ _null_ bttintervalcmp - _null_ )); DESCR("btree less-equal-greater"); DATA(insert OID = 382 ( btarraycmp PGNSP PGUID 12 f f t f i 2 23 "2277 2277" _null_ _null_ _null_ btarraycmp - _null_ )); DESCR("btree less-equal-greater"); @@ -784,15 +784,15 @@ DATA(insert OID = 367 ( close_pb PGNSP PGUID 12 f f t f i 2 600 "600 603" _ DESCR("closest point on box"); DATA(insert OID = 368 ( close_sb PGNSP PGUID 12 f f t f i 2 600 "601 603" _null_ _null_ _null_ close_sb - _null_ )); DESCR("closest point to line segment on box"); -DATA(insert OID = 369 ( on_ps PGNSP PGUID 12 f f t f i 2 16 "600 601" _null_ _null_ _null_ on_ps - _null_ )); +DATA(insert OID = 369 ( on_ps PGNSP PGUID 12 f f t f i 2 16 "600 601" _null_ _null_ _null_ on_ps - _null_ )); DESCR("point contained in segment?"); DATA(insert OID = 370 ( path_distance PGNSP PGUID 12 f f t f i 2 701 "602 602" _null_ _null_ _null_ path_distance - _null_ )); DESCR("distance between paths"); DATA(insert OID = 371 ( dist_ppath PGNSP PGUID 12 f f t f i 2 701 "600 602" _null_ _null_ _null_ dist_ppath - _null_ )); DESCR("distance between point and path"); -DATA(insert OID = 372 ( on_sb PGNSP PGUID 12 f f t f i 2 16 "601 603" _null_ _null_ _null_ on_sb - _null_ )); +DATA(insert OID = 372 ( on_sb PGNSP PGUID 12 f f t f i 2 16 "601 603" _null_ _null_ _null_ on_sb - _null_ )); DESCR("lseg contained in box?"); -DATA(insert OID = 373 ( inter_sb PGNSP PGUID 12 f f t f i 2 16 "601 603" _null_ _null_ _null_ inter_sb - _null_ )); +DATA(insert OID = 373 ( inter_sb PGNSP PGUID 12 f f t f i 2 16 "601 603" _null_ _null_ _null_ inter_sb - _null_ )); DESCR("intersect?"); /* OIDS 400 - 499 */ @@ -816,7 +816,7 @@ DATA(insert OID = 441 ( hashinsert PGNSP PGUID 12 f f t f v 6 16 "2281 2281 DESCR("hash(internal)"); DATA(insert OID = 443 ( hashbeginscan PGNSP PGUID 12 f f t f v 3 2281 "2281 2281 2281" _null_ _null_ _null_ hashbeginscan - _null_ )); DESCR("hash(internal)"); -DATA(insert OID = 444 ( hashrescan PGNSP PGUID 12 f f t f v 2 2278 "2281 2281" _null_ _null_ _null_ hashrescan - _null_ )); +DATA(insert OID = 444 ( hashrescan PGNSP PGUID 12 f f t f v 2 2278 "2281 2281" _null_ _null_ _null_ hashrescan - _null_ )); DESCR("hash(internal)"); DATA(insert OID = 445 ( hashendscan PGNSP PGUID 12 f f t f v 1 2278 "2281" _null_ _null_ _null_ hashendscan - _null_ )); DESCR("hash(internal)"); @@ -831,35 +831,35 @@ DESCR("hash(internal)"); DATA(insert OID = 438 ( hashcostestimate PGNSP PGUID 12 f f t f v 7 2278 "2281 2281 2281 2281 2281 2281 2281" _null_ _null_ _null_ hashcostestimate - _null_ )); DESCR("hash(internal)"); -DATA(insert OID = 449 ( hashint2 PGNSP PGUID 12 f f t f i 1 23 "21" _null_ _null_ _null_ hashint2 - _null_ )); +DATA(insert OID = 449 ( hashint2 PGNSP PGUID 12 f f t f i 1 23 "21" _null_ _null_ _null_ hashint2 - _null_ )); DESCR("hash"); -DATA(insert OID = 450 ( hashint4 PGNSP PGUID 12 f f t f i 1 23 "23" _null_ _null_ _null_ hashint4 - _null_ )); +DATA(insert OID = 450 ( hashint4 PGNSP PGUID 12 f f t f i 1 23 "23" _null_ _null_ _null_ hashint4 - _null_ )); DESCR("hash"); -DATA(insert OID = 949 ( hashint8 PGNSP PGUID 12 f f t f i 1 23 "20" _null_ _null_ _null_ hashint8 - _null_ )); +DATA(insert OID = 949 ( hashint8 PGNSP PGUID 12 f f t f i 1 23 "20" _null_ _null_ _null_ hashint8 - _null_ )); DESCR("hash"); -DATA(insert OID = 451 ( hashfloat4 PGNSP PGUID 12 f f t f i 1 23 "700" _null_ _null_ _null_ hashfloat4 - _null_ )); +DATA(insert OID = 451 ( hashfloat4 PGNSP PGUID 12 f f t f i 1 23 "700" _null_ _null_ _null_ hashfloat4 - _null_ )); DESCR("hash"); -DATA(insert OID = 452 ( hashfloat8 PGNSP PGUID 12 f f t f i 1 23 "701" _null_ _null_ _null_ hashfloat8 - _null_ )); +DATA(insert OID = 452 ( hashfloat8 PGNSP PGUID 12 f f t f i 1 23 "701" _null_ _null_ _null_ hashfloat8 - _null_ )); DESCR("hash"); -DATA(insert OID = 453 ( hashoid PGNSP PGUID 12 f f t f i 1 23 "26" _null_ _null_ _null_ hashoid - _null_ )); +DATA(insert OID = 453 ( hashoid PGNSP PGUID 12 f f t f i 1 23 "26" _null_ _null_ _null_ hashoid - _null_ )); DESCR("hash"); -DATA(insert OID = 454 ( hashchar PGNSP PGUID 12 f f t f i 1 23 "18" _null_ _null_ _null_ hashchar - _null_ )); +DATA(insert OID = 454 ( hashchar PGNSP PGUID 12 f f t f i 1 23 "18" _null_ _null_ _null_ hashchar - _null_ )); DESCR("hash"); -DATA(insert OID = 455 ( hashname PGNSP PGUID 12 f f t f i 1 23 "19" _null_ _null_ _null_ hashname - _null_ )); +DATA(insert OID = 455 ( hashname PGNSP PGUID 12 f f t f i 1 23 "19" _null_ _null_ _null_ hashname - _null_ )); DESCR("hash"); DATA(insert OID = 400 ( hashtext PGNSP PGUID 12 f f t f i 1 23 "25" _null_ _null_ _null_ hashtext - _null_ )); DESCR("hash"); DATA(insert OID = 456 ( hashvarlena PGNSP PGUID 12 f f t f i 1 23 "2281" _null_ _null_ _null_ hashvarlena - _null_ )); DESCR("hash any varlena type"); -DATA(insert OID = 457 ( hashoidvector PGNSP PGUID 12 f f t f i 1 23 "30" _null_ _null_ _null_ hashoidvector - _null_ )); +DATA(insert OID = 457 ( hashoidvector PGNSP PGUID 12 f f t f i 1 23 "30" _null_ _null_ _null_ hashoidvector - _null_ )); DESCR("hash"); DATA(insert OID = 329 ( hash_aclitem PGNSP PGUID 12 f f t f i 1 23 "1033" _null_ _null_ _null_ hash_aclitem - _null_ )); DESCR("hash"); -DATA(insert OID = 398 ( hashint2vector PGNSP PGUID 12 f f t f i 1 23 "22" _null_ _null_ _null_ hashint2vector - _null_ )); +DATA(insert OID = 398 ( hashint2vector PGNSP PGUID 12 f f t f i 1 23 "22" _null_ _null_ _null_ hashint2vector - _null_ )); DESCR("hash"); -DATA(insert OID = 399 ( hashmacaddr PGNSP PGUID 12 f f t f i 1 23 "829" _null_ _null_ _null_ hashmacaddr - _null_ )); +DATA(insert OID = 399 ( hashmacaddr PGNSP PGUID 12 f f t f i 1 23 "829" _null_ _null_ _null_ hashmacaddr - _null_ )); DESCR("hash"); -DATA(insert OID = 422 ( hashinet PGNSP PGUID 12 f f t f i 1 23 "869" _null_ _null_ _null_ hashinet - _null_ )); +DATA(insert OID = 422 ( hashinet PGNSP PGUID 12 f f t f i 1 23 "869" _null_ _null_ _null_ hashinet - _null_ )); DESCR("hash"); DATA(insert OID = 458 ( text_larger PGNSP PGUID 12 f f t f i 2 25 "25 25" _null_ _null_ _null_ text_larger - _null_ )); DESCR("larger of two"); @@ -870,7 +870,7 @@ DATA(insert OID = 460 ( int8in PGNSP PGUID 12 f f t f i 1 20 "2275" _null_ DESCR("I/O"); DATA(insert OID = 461 ( int8out PGNSP PGUID 12 f f t f i 1 2275 "20" _null_ _null_ _null_ int8out - _null_ )); DESCR("I/O"); -DATA(insert OID = 462 ( int8um PGNSP PGUID 12 f f t f i 1 20 "20" _null_ _null_ _null_ int8um - _null_ )); +DATA(insert OID = 462 ( int8um PGNSP PGUID 12 f f t f i 1 20 "20" _null_ _null_ _null_ int8um - _null_ )); DESCR("negate"); DATA(insert OID = 463 ( int8pl PGNSP PGUID 12 f f t f i 2 20 "20 20" _null_ _null_ _null_ int8pl - _null_ )); DESCR("add"); @@ -906,11 +906,11 @@ DESCR("less-than-or-equal"); DATA(insert OID = 479 ( int84ge PGNSP PGUID 12 f f t f i 2 16 "20 23" _null_ _null_ _null_ int84ge - _null_ )); DESCR("greater-than-or-equal"); -DATA(insert OID = 480 ( int4 PGNSP PGUID 12 f f t f i 1 23 "20" _null_ _null_ _null_ int84 - _null_ )); +DATA(insert OID = 480 ( int4 PGNSP PGUID 12 f f t f i 1 23 "20" _null_ _null_ _null_ int84 - _null_ )); DESCR("convert int8 to int4"); -DATA(insert OID = 481 ( int8 PGNSP PGUID 12 f f t f i 1 20 "23" _null_ _null_ _null_ int48 - _null_ )); +DATA(insert OID = 481 ( int8 PGNSP PGUID 12 f f t f i 1 20 "23" _null_ _null_ _null_ int48 - _null_ )); DESCR("convert int4 to int8"); -DATA(insert OID = 482 ( float8 PGNSP PGUID 12 f f t f i 1 701 "20" _null_ _null_ _null_ i8tod - _null_ )); +DATA(insert OID = 482 ( float8 PGNSP PGUID 12 f f t f i 1 701 "20" _null_ _null_ _null_ i8tod - _null_ )); DESCR("convert int8 to float8"); DATA(insert OID = 483 ( int8 PGNSP PGUID 12 f f t f i 1 20 "701" _null_ _null_ _null_ dtoi8 - _null_ )); DESCR("convert float8 to int8"); @@ -919,14 +919,14 @@ DESCR("convert float8 to int8"); /* OIDS 600 - 699 */ -DATA(insert OID = 652 ( float4 PGNSP PGUID 12 f f t f i 1 700 "20" _null_ _null_ _null_ i8tof - _null_ )); +DATA(insert OID = 652 ( float4 PGNSP PGUID 12 f f t f i 1 700 "20" _null_ _null_ _null_ i8tof - _null_ )); DESCR("convert int8 to float4"); DATA(insert OID = 653 ( int8 PGNSP PGUID 12 f f t f i 1 20 "700" _null_ _null_ _null_ ftoi8 - _null_ )); DESCR("convert float4 to int8"); -DATA(insert OID = 714 ( int2 PGNSP PGUID 12 f f t f i 1 21 "20" _null_ _null_ _null_ int82 - _null_ )); +DATA(insert OID = 714 ( int2 PGNSP PGUID 12 f f t f i 1 21 "20" _null_ _null_ _null_ int82 - _null_ )); DESCR("convert int8 to int2"); -DATA(insert OID = 754 ( int8 PGNSP PGUID 12 f f t f i 1 20 "21" _null_ _null_ _null_ int28 - _null_ )); +DATA(insert OID = 754 ( int8 PGNSP PGUID 12 f f t f i 1 20 "21" _null_ _null_ _null_ int28 - _null_ )); DESCR("convert int2 to int8"); DATA(insert OID = 1285 ( int4notin PGNSP PGUID 12 f f t f s 2 16 "23 25" _null_ _null_ _null_ int4notin - _null_ )); @@ -972,7 +972,7 @@ DESCR("less-than"); DATA(insert OID = 717 ( oidle PGNSP PGUID 12 f f t f i 2 16 "26 26" _null_ _null_ _null_ oidle - _null_ )); DESCR("less-than-or-equal"); -DATA(insert OID = 720 ( octet_length PGNSP PGUID 12 f f t f i 1 23 "17" _null_ _null_ _null_ byteaoctetlen - _null_ )); +DATA(insert OID = 720 ( octet_length PGNSP PGUID 12 f f t f i 1 23 "17" _null_ _null_ _null_ byteaoctetlen - _null_ )); DESCR("octet length"); DATA(insert OID = 721 ( get_byte PGNSP PGUID 12 f f t f i 2 23 "17 23" _null_ _null_ _null_ byteaGetByte - _null_ )); DESCR("get byte"); @@ -1024,7 +1024,7 @@ DATA(insert OID = 747 ( array_dims PGNSP PGUID 12 f f t f i 1 25 "2277" _nu DESCR("array dimensions"); DATA(insert OID = 750 ( array_in PGNSP PGUID 12 f f t f s 3 2277 "2275 26 23" _null_ _null_ _null_ array_in - _null_ )); DESCR("I/O"); -DATA(insert OID = 751 ( array_out PGNSP PGUID 12 f f t f s 1 2275 "2277" _null_ _null_ _null_ array_out - _null_ )); +DATA(insert OID = 751 ( array_out PGNSP PGUID 12 f f t f s 1 2275 "2277" _null_ _null_ _null_ array_out - _null_ )); DESCR("I/O"); DATA(insert OID = 2091 ( array_lower PGNSP PGUID 12 f f t f i 2 23 "2277 23" _null_ _null_ _null_ array_lower - _null_ )); DESCR("array lower dimension"); @@ -1051,17 +1051,17 @@ DATA(insert OID = 760 ( smgrin PGNSP PGUID 12 f f t f s 1 210 "2275" _null DESCR("I/O"); DATA(insert OID = 761 ( smgrout PGNSP PGUID 12 f f t f s 1 2275 "210" _null_ _null_ _null_ smgrout - _null_ )); DESCR("I/O"); -DATA(insert OID = 762 ( smgreq PGNSP PGUID 12 f f t f i 2 16 "210 210" _null_ _null_ _null_ smgreq - _null_ )); +DATA(insert OID = 762 ( smgreq PGNSP PGUID 12 f f t f i 2 16 "210 210" _null_ _null_ _null_ smgreq - _null_ )); DESCR("storage manager"); -DATA(insert OID = 763 ( smgrne PGNSP PGUID 12 f f t f i 2 16 "210 210" _null_ _null_ _null_ smgrne - _null_ )); +DATA(insert OID = 763 ( smgrne PGNSP PGUID 12 f f t f i 2 16 "210 210" _null_ _null_ _null_ smgrne - _null_ )); DESCR("storage manager"); -DATA(insert OID = 764 ( lo_import PGNSP PGUID 12 f f t f v 1 26 "25" _null_ _null_ _null_ lo_import - _null_ )); +DATA(insert OID = 764 ( lo_import PGNSP PGUID 12 f f t f v 1 26 "25" _null_ _null_ _null_ lo_import - _null_ )); DESCR("large object import"); DATA(insert OID = 765 ( lo_export PGNSP PGUID 12 f f t f v 2 23 "26 25" _null_ _null_ _null_ lo_export - _null_ )); DESCR("large object export"); -DATA(insert OID = 766 ( int4inc PGNSP PGUID 12 f f t f i 1 23 "23" _null_ _null_ _null_ int4inc - _null_ )); +DATA(insert OID = 766 ( int4inc PGNSP PGUID 12 f f t f i 1 23 "23" _null_ _null_ _null_ int4inc - _null_ )); DESCR("increment"); DATA(insert OID = 768 ( int4larger PGNSP PGUID 12 f f t f i 2 23 "23 23" _null_ _null_ _null_ int4larger - _null_ )); DESCR("larger of two"); @@ -1080,7 +1080,7 @@ DATA(insert OID = 775 ( gistinsert PGNSP PGUID 12 f f t f v 6 16 "2281 2281 DESCR("gist(internal)"); DATA(insert OID = 777 ( gistbeginscan PGNSP PGUID 12 f f t f v 3 2281 "2281 2281 2281" _null_ _null_ _null_ gistbeginscan - _null_ )); DESCR("gist(internal)"); -DATA(insert OID = 778 ( gistrescan PGNSP PGUID 12 f f t f v 2 2278 "2281 2281" _null_ _null_ _null_ gistrescan - _null_ )); +DATA(insert OID = 778 ( gistrescan PGNSP PGUID 12 f f t f v 2 2278 "2281 2281" _null_ _null_ _null_ gistrescan - _null_ )); DESCR("gist(internal)"); DATA(insert OID = 779 ( gistendscan PGNSP PGUID 12 f f t f v 1 2278 "2281" _null_ _null_ _null_ gistendscan - _null_ )); DESCR("gist(internal)"); @@ -1096,31 +1096,31 @@ DATA(insert OID = 2561 ( gistvacuumcleanup PGNSP PGUID 12 f f t f v 3 2281 "2 DATA(insert OID = 772 ( gistcostestimate PGNSP PGUID 12 f f t f v 7 2278 "2281 2281 2281 2281 2281 2281 2281" _null_ _null_ _null_ gistcostestimate - _null_ )); DESCR("gist(internal)"); -DATA(insert OID = 784 ( tintervaleq PGNSP PGUID 12 f f t f i 2 16 "704 704" _null_ _null_ _null_ tintervaleq - _null_ )); +DATA(insert OID = 784 ( tintervaleq PGNSP PGUID 12 f f t f i 2 16 "704 704" _null_ _null_ _null_ tintervaleq - _null_ )); DESCR("equal"); -DATA(insert OID = 785 ( tintervalne PGNSP PGUID 12 f f t f i 2 16 "704 704" _null_ _null_ _null_ tintervalne - _null_ )); +DATA(insert OID = 785 ( tintervalne PGNSP PGUID 12 f f t f i 2 16 "704 704" _null_ _null_ _null_ tintervalne - _null_ )); DESCR("not equal"); -DATA(insert OID = 786 ( tintervallt PGNSP PGUID 12 f f t f i 2 16 "704 704" _null_ _null_ _null_ tintervallt - _null_ )); +DATA(insert OID = 786 ( tintervallt PGNSP PGUID 12 f f t f i 2 16 "704 704" _null_ _null_ _null_ tintervallt - _null_ )); DESCR("less-than"); -DATA(insert OID = 787 ( tintervalgt PGNSP PGUID 12 f f t f i 2 16 "704 704" _null_ _null_ _null_ tintervalgt - _null_ )); +DATA(insert OID = 787 ( tintervalgt PGNSP PGUID 12 f f t f i 2 16 "704 704" _null_ _null_ _null_ tintervalgt - _null_ )); DESCR("greater-than"); -DATA(insert OID = 788 ( tintervalle PGNSP PGUID 12 f f t f i 2 16 "704 704" _null_ _null_ _null_ tintervalle - _null_ )); +DATA(insert OID = 788 ( tintervalle PGNSP PGUID 12 f f t f i 2 16 "704 704" _null_ _null_ _null_ tintervalle - _null_ )); DESCR("less-than-or-equal"); -DATA(insert OID = 789 ( tintervalge PGNSP PGUID 12 f f t f i 2 16 "704 704" _null_ _null_ _null_ tintervalge - _null_ )); +DATA(insert OID = 789 ( tintervalge PGNSP PGUID 12 f f t f i 2 16 "704 704" _null_ _null_ _null_ tintervalge - _null_ )); DESCR("greater-than-or-equal"); /* OIDS 800 - 899 */ -DATA(insert OID = 817 ( oid PGNSP PGUID 12 f f t f i 1 26 "25" _null_ _null_ _null_ text_oid - _null_ )); +DATA(insert OID = 817 ( oid PGNSP PGUID 12 f f t f i 1 26 "25" _null_ _null_ _null_ text_oid - _null_ )); DESCR("convert text to oid"); -DATA(insert OID = 818 ( int2 PGNSP PGUID 12 f f t f i 1 21 "25" _null_ _null_ _null_ text_int2 - _null_ )); +DATA(insert OID = 818 ( int2 PGNSP PGUID 12 f f t f i 1 21 "25" _null_ _null_ _null_ text_int2 - _null_ )); DESCR("convert text to int2"); -DATA(insert OID = 819 ( int4 PGNSP PGUID 12 f f t f i 1 23 "25" _null_ _null_ _null_ text_int4 - _null_ )); +DATA(insert OID = 819 ( int4 PGNSP PGUID 12 f f t f i 1 23 "25" _null_ _null_ _null_ text_int4 - _null_ )); DESCR("convert text to int4"); -DATA(insert OID = 838 ( float8 PGNSP PGUID 12 f f t f i 1 701 "25" _null_ _null_ _null_ text_float8 - _null_ )); +DATA(insert OID = 838 ( float8 PGNSP PGUID 12 f f t f i 1 701 "25" _null_ _null_ _null_ text_float8 - _null_ )); DESCR("convert text to float8"); -DATA(insert OID = 839 ( float4 PGNSP PGUID 12 f f t f i 1 700 "25" _null_ _null_ _null_ text_float4 - _null_ )); +DATA(insert OID = 839 ( float4 PGNSP PGUID 12 f f t f i 1 700 "25" _null_ _null_ _null_ text_float4 - _null_ )); DESCR("convert text to float4"); DATA(insert OID = 840 ( text PGNSP PGUID 12 f f t f i 1 25 "701" _null_ _null_ _null_ float8_text - _null_ )); DESCR("convert float8 to text"); @@ -1165,17 +1165,17 @@ DESCR("convert char to char()"); DATA(insert OID = 861 ( current_database PGNSP PGUID 12 f f t f i 0 19 "" _null_ _null_ _null_ current_database - _null_ )); DESCR("returns the current database"); -DATA(insert OID = 862 ( int4_mul_cash PGNSP PGUID 12 f f t f i 2 790 "23 790" _null_ _null_ _null_ int4_mul_cash - _null_ )); +DATA(insert OID = 862 ( int4_mul_cash PGNSP PGUID 12 f f t f i 2 790 "23 790" _null_ _null_ _null_ int4_mul_cash - _null_ )); DESCR("multiply"); -DATA(insert OID = 863 ( int2_mul_cash PGNSP PGUID 12 f f t f i 2 790 "21 790" _null_ _null_ _null_ int2_mul_cash - _null_ )); +DATA(insert OID = 863 ( int2_mul_cash PGNSP PGUID 12 f f t f i 2 790 "21 790" _null_ _null_ _null_ int2_mul_cash - _null_ )); DESCR("multiply"); -DATA(insert OID = 864 ( cash_mul_int4 PGNSP PGUID 12 f f t f i 2 790 "790 23" _null_ _null_ _null_ cash_mul_int4 - _null_ )); +DATA(insert OID = 864 ( cash_mul_int4 PGNSP PGUID 12 f f t f i 2 790 "790 23" _null_ _null_ _null_ cash_mul_int4 - _null_ )); DESCR("multiply"); -DATA(insert OID = 865 ( cash_div_int4 PGNSP PGUID 12 f f t f i 2 790 "790 23" _null_ _null_ _null_ cash_div_int4 - _null_ )); +DATA(insert OID = 865 ( cash_div_int4 PGNSP PGUID 12 f f t f i 2 790 "790 23" _null_ _null_ _null_ cash_div_int4 - _null_ )); DESCR("divide"); -DATA(insert OID = 866 ( cash_mul_int2 PGNSP PGUID 12 f f t f i 2 790 "790 21" _null_ _null_ _null_ cash_mul_int2 - _null_ )); +DATA(insert OID = 866 ( cash_mul_int2 PGNSP PGUID 12 f f t f i 2 790 "790 21" _null_ _null_ _null_ cash_mul_int2 - _null_ )); DESCR("multiply"); -DATA(insert OID = 867 ( cash_div_int2 PGNSP PGUID 12 f f t f i 2 790 "790 21" _null_ _null_ _null_ cash_div_int2 - _null_ )); +DATA(insert OID = 867 ( cash_div_int2 PGNSP PGUID 12 f f t f i 2 790 "790 21" _null_ _null_ _null_ cash_div_int2 - _null_ )); DESCR("divide"); DATA(insert OID = 886 ( cash_in PGNSP PGUID 12 f f t f i 1 790 "2275" _null_ _null_ _null_ cash_in - _null_ )); @@ -1227,19 +1227,19 @@ DESCR("modulus"); DATA(insert OID = 947 ( mod PGNSP PGUID 12 f f t f i 2 20 "20 20" _null_ _null_ _null_ int8mod - _null_ )); DESCR("modulus"); -DATA(insert OID = 944 ( char PGNSP PGUID 12 f f t f i 1 18 "25" _null_ _null_ _null_ text_char - _null_ )); +DATA(insert OID = 944 ( char PGNSP PGUID 12 f f t f i 1 18 "25" _null_ _null_ _null_ text_char - _null_ )); DESCR("convert text to char"); -DATA(insert OID = 946 ( text PGNSP PGUID 12 f f t f i 1 25 "18" _null_ _null_ _null_ char_text - _null_ )); +DATA(insert OID = 946 ( text PGNSP PGUID 12 f f t f i 1 25 "18" _null_ _null_ _null_ char_text - _null_ )); DESCR("convert char to text"); -DATA(insert OID = 950 ( istrue PGNSP PGUID 12 f f f f i 1 16 "16" _null_ _null_ _null_ istrue - _null_ )); +DATA(insert OID = 950 ( istrue PGNSP PGUID 12 f f f f i 1 16 "16" _null_ _null_ _null_ istrue - _null_ )); DESCR("bool is true (not false or unknown)"); -DATA(insert OID = 951 ( isfalse PGNSP PGUID 12 f f f f i 1 16 "16" _null_ _null_ _null_ isfalse - _null_ )); +DATA(insert OID = 951 ( isfalse PGNSP PGUID 12 f f f f i 1 16 "16" _null_ _null_ _null_ isfalse - _null_ )); DESCR("bool is false (not true or unknown)"); DATA(insert OID = 952 ( lo_open PGNSP PGUID 12 f f t f v 2 23 "26 23" _null_ _null_ _null_ lo_open - _null_ )); DESCR("large object open"); -DATA(insert OID = 953 ( lo_close PGNSP PGUID 12 f f t f v 1 23 "23" _null_ _null_ _null_ lo_close - _null_ )); +DATA(insert OID = 953 ( lo_close PGNSP PGUID 12 f f t f v 1 23 "23" _null_ _null_ _null_ lo_close - _null_ )); DESCR("large object close"); DATA(insert OID = 954 ( loread PGNSP PGUID 12 f f t f v 2 17 "23 23" _null_ _null_ _null_ loread - _null_ )); DESCR("large object read"); @@ -1247,11 +1247,11 @@ DATA(insert OID = 955 ( lowrite PGNSP PGUID 12 f f t f v 2 23 "23 17" _null DESCR("large object write"); DATA(insert OID = 956 ( lo_lseek PGNSP PGUID 12 f f t f v 3 23 "23 23 23" _null_ _null_ _null_ lo_lseek - _null_ )); DESCR("large object seek"); -DATA(insert OID = 957 ( lo_creat PGNSP PGUID 12 f f t f v 1 26 "23" _null_ _null_ _null_ lo_creat - _null_ )); +DATA(insert OID = 957 ( lo_creat PGNSP PGUID 12 f f t f v 1 26 "23" _null_ _null_ _null_ lo_creat - _null_ )); DESCR("large object create"); -DATA(insert OID = 715 ( lo_create PGNSP PGUID 12 f f t f v 1 26 "26" _null_ _null_ _null_ lo_create - _null_ )); +DATA(insert OID = 715 ( lo_create PGNSP PGUID 12 f f t f v 1 26 "26" _null_ _null_ _null_ lo_create - _null_ )); DESCR("large object create"); -DATA(insert OID = 958 ( lo_tell PGNSP PGUID 12 f f t f v 1 23 "23" _null_ _null_ _null_ lo_tell - _null_ )); +DATA(insert OID = 958 ( lo_tell PGNSP PGUID 12 f f t f v 1 23 "23" _null_ _null_ _null_ lo_tell - _null_ )); DESCR("large object position"); DATA(insert OID = 959 ( on_pl PGNSP PGUID 12 f f t f i 2 16 "600 628" _null_ _null_ _null_ on_pl - _null_ )); @@ -1265,7 +1265,7 @@ DESCR("closest point to line segment on line"); DATA(insert OID = 963 ( close_lb PGNSP PGUID 12 f f t f i 2 600 "628 603" _null_ _null_ _null_ close_lb - _null_ )); DESCR("closest point to line on box"); -DATA(insert OID = 964 ( lo_unlink PGNSP PGUID 12 f f t f v 1 23 "26" _null_ _null_ _null_ lo_unlink - _null_ )); +DATA(insert OID = 964 ( lo_unlink PGNSP PGUID 12 f f t f v 1 23 "26" _null_ _null_ _null_ lo_unlink - _null_ )); DESCR("large object unlink(delete)"); DATA(insert OID = 973 ( path_inter PGNSP PGUID 12 f f t f i 2 16 "602 602" _null_ _null_ _null_ path_inter - _null_ )); @@ -1284,23 +1284,23 @@ DATA(insert OID = 980 ( box_intersect PGNSP PGUID 12 f f t f i 2 603 "603 60 DESCR("box intersection (another box)"); DATA(insert OID = 981 ( diagonal PGNSP PGUID 12 f f t f i 1 601 "603" _null_ _null_ _null_ box_diagonal - _null_ )); DESCR("box diagonal"); -DATA(insert OID = 982 ( path_n_lt PGNSP PGUID 12 f f t f i 2 16 "602 602" _null_ _null_ _null_ path_n_lt - _null_ )); +DATA(insert OID = 982 ( path_n_lt PGNSP PGUID 12 f f t f i 2 16 "602 602" _null_ _null_ _null_ path_n_lt - _null_ )); DESCR("less-than"); -DATA(insert OID = 983 ( path_n_gt PGNSP PGUID 12 f f t f i 2 16 "602 602" _null_ _null_ _null_ path_n_gt - _null_ )); +DATA(insert OID = 983 ( path_n_gt PGNSP PGUID 12 f f t f i 2 16 "602 602" _null_ _null_ _null_ path_n_gt - _null_ )); DESCR("greater-than"); -DATA(insert OID = 984 ( path_n_eq PGNSP PGUID 12 f f t f i 2 16 "602 602" _null_ _null_ _null_ path_n_eq - _null_ )); +DATA(insert OID = 984 ( path_n_eq PGNSP PGUID 12 f f t f i 2 16 "602 602" _null_ _null_ _null_ path_n_eq - _null_ )); DESCR("equal"); -DATA(insert OID = 985 ( path_n_le PGNSP PGUID 12 f f t f i 2 16 "602 602" _null_ _null_ _null_ path_n_le - _null_ )); +DATA(insert OID = 985 ( path_n_le PGNSP PGUID 12 f f t f i 2 16 "602 602" _null_ _null_ _null_ path_n_le - _null_ )); DESCR("less-than-or-equal"); -DATA(insert OID = 986 ( path_n_ge PGNSP PGUID 12 f f t f i 2 16 "602 602" _null_ _null_ _null_ path_n_ge - _null_ )); +DATA(insert OID = 986 ( path_n_ge PGNSP PGUID 12 f f t f i 2 16 "602 602" _null_ _null_ _null_ path_n_ge - _null_ )); DESCR("greater-than-or-equal"); DATA(insert OID = 987 ( path_length PGNSP PGUID 12 f f t f i 1 701 "602" _null_ _null_ _null_ path_length - _null_ )); DESCR("sum of path segment lengths"); -DATA(insert OID = 988 ( point_ne PGNSP PGUID 12 f f t f i 2 16 "600 600" _null_ _null_ _null_ point_ne - _null_ )); +DATA(insert OID = 988 ( point_ne PGNSP PGUID 12 f f t f i 2 16 "600 600" _null_ _null_ _null_ point_ne - _null_ )); DESCR("not equal"); -DATA(insert OID = 989 ( point_vert PGNSP PGUID 12 f f t f i 2 16 "600 600" _null_ _null_ _null_ point_vert - _null_ )); +DATA(insert OID = 989 ( point_vert PGNSP PGUID 12 f f t f i 2 16 "600 600" _null_ _null_ _null_ point_vert - _null_ )); DESCR("vertically aligned?"); -DATA(insert OID = 990 ( point_horiz PGNSP PGUID 12 f f t f i 2 16 "600 600" _null_ _null_ _null_ point_horiz - _null_ )); +DATA(insert OID = 990 ( point_horiz PGNSP PGUID 12 f f t f i 2 16 "600 600" _null_ _null_ _null_ point_horiz - _null_ )); DESCR("horizontally aligned?"); DATA(insert OID = 991 ( point_distance PGNSP PGUID 12 f f t f i 2 701 "600 600" _null_ _null_ _null_ point_distance - _null_ )); DESCR("distance between"); @@ -1308,17 +1308,17 @@ DATA(insert OID = 992 ( slope PGNSP PGUID 12 f f t f i 2 701 "600 600" _nu DESCR("slope between points"); DATA(insert OID = 993 ( lseg PGNSP PGUID 12 f f t f i 2 601 "600 600" _null_ _null_ _null_ lseg_construct - _null_ )); DESCR("convert points to line segment"); -DATA(insert OID = 994 ( lseg_intersect PGNSP PGUID 12 f f t f i 2 16 "601 601" _null_ _null_ _null_ lseg_intersect - _null_ )); +DATA(insert OID = 994 ( lseg_intersect PGNSP PGUID 12 f f t f i 2 16 "601 601" _null_ _null_ _null_ lseg_intersect - _null_ )); DESCR("intersect?"); -DATA(insert OID = 995 ( lseg_parallel PGNSP PGUID 12 f f t f i 2 16 "601 601" _null_ _null_ _null_ lseg_parallel - _null_ )); +DATA(insert OID = 995 ( lseg_parallel PGNSP PGUID 12 f f t f i 2 16 "601 601" _null_ _null_ _null_ lseg_parallel - _null_ )); DESCR("parallel?"); -DATA(insert OID = 996 ( lseg_perp PGNSP PGUID 12 f f t f i 2 16 "601 601" _null_ _null_ _null_ lseg_perp - _null_ )); +DATA(insert OID = 996 ( lseg_perp PGNSP PGUID 12 f f t f i 2 16 "601 601" _null_ _null_ _null_ lseg_perp - _null_ )); DESCR("perpendicular?"); -DATA(insert OID = 997 ( lseg_vertical PGNSP PGUID 12 f f t f i 1 16 "601" _null_ _null_ _null_ lseg_vertical - _null_ )); +DATA(insert OID = 997 ( lseg_vertical PGNSP PGUID 12 f f t f i 1 16 "601" _null_ _null_ _null_ lseg_vertical - _null_ )); DESCR("vertical?"); -DATA(insert OID = 998 ( lseg_horizontal PGNSP PGUID 12 f f t f i 1 16 "601" _null_ _null_ _null_ lseg_horizontal - _null_ )); +DATA(insert OID = 998 ( lseg_horizontal PGNSP PGUID 12 f f t f i 1 16 "601" _null_ _null_ _null_ lseg_horizontal - _null_ )); DESCR("horizontal?"); -DATA(insert OID = 999 ( lseg_eq PGNSP PGUID 12 f f t f i 2 16 "601 601" _null_ _null_ _null_ lseg_eq - _null_ )); +DATA(insert OID = 999 ( lseg_eq PGNSP PGUID 12 f f t f i 2 16 "601 601" _null_ _null_ _null_ lseg_eq - _null_ )); DESCR("equal"); DATA(insert OID = 748 ( date PGNSP PGUID 12 f f t f s 1 1082 "25" _null_ _null_ _null_ text_date - _null_ )); @@ -1336,20 +1336,20 @@ DESCR("convert timetz to text"); /* OIDS 1000 - 1999 */ -DATA(insert OID = 1026 ( timezone PGNSP PGUID 12 f f t f i 2 1114 "1186 1184" _null_ _null_ _null_ timestamptz_izone - _null_ )); +DATA(insert OID = 1026 ( timezone PGNSP PGUID 12 f f t f i 2 1114 "1186 1184" _null_ _null_ _null_ timestamptz_izone - _null_ )); DESCR("adjust timestamp to new time zone"); DATA(insert OID = 1029 ( nullvalue PGNSP PGUID 12 f f f f i 1 16 "2276" _null_ _null_ _null_ nullvalue - _null_ )); DESCR("(internal)"); DATA(insert OID = 1030 ( nonnullvalue PGNSP PGUID 12 f f f f i 1 16 "2276" _null_ _null_ _null_ nonnullvalue - _null_ )); DESCR("(internal)"); -DATA(insert OID = 1031 ( aclitemin PGNSP PGUID 12 f f t f s 1 1033 "2275" _null_ _null_ _null_ aclitemin - _null_ )); +DATA(insert OID = 1031 ( aclitemin PGNSP PGUID 12 f f t f s 1 1033 "2275" _null_ _null_ _null_ aclitemin - _null_ )); DESCR("I/O"); -DATA(insert OID = 1032 ( aclitemout PGNSP PGUID 12 f f t f s 1 2275 "1033" _null_ _null_ _null_ aclitemout - _null_ )); +DATA(insert OID = 1032 ( aclitemout PGNSP PGUID 12 f f t f s 1 2275 "1033" _null_ _null_ _null_ aclitemout - _null_ )); DESCR("I/O"); -DATA(insert OID = 1035 ( aclinsert PGNSP PGUID 12 f f t f i 2 1034 "1034 1033" _null_ _null_ _null_ aclinsert - _null_ )); +DATA(insert OID = 1035 ( aclinsert PGNSP PGUID 12 f f t f i 2 1034 "1034 1033" _null_ _null_ _null_ aclinsert - _null_ )); DESCR("add/update ACL item"); -DATA(insert OID = 1036 ( aclremove PGNSP PGUID 12 f f t f i 2 1034 "1034 1033" _null_ _null_ _null_ aclremove - _null_ )); +DATA(insert OID = 1036 ( aclremove PGNSP PGUID 12 f f t f i 2 1034 "1034 1033" _null_ _null_ _null_ aclremove - _null_ )); DESCR("remove ACL item"); DATA(insert OID = 1037 ( aclcontains PGNSP PGUID 12 f f t f i 2 16 "1034 1033" _null_ _null_ _null_ aclcontains - _null_ )); DESCR("does ACL contain item?"); @@ -1377,7 +1377,7 @@ DATA(insert OID = 1052 ( bpcharge PGNSP PGUID 12 f f t f i 2 16 "1042 1042" DESCR("greater-than-or-equal"); DATA(insert OID = 1053 ( bpcharne PGNSP PGUID 12 f f t f i 2 16 "1042 1042" _null_ _null_ _null_ bpcharne - _null_ )); DESCR("not equal"); -DATA(insert OID = 1063 ( bpchar_larger PGNSP PGUID 12 f f t f i 2 1042 "1042 1042" _null_ _null_ _null_ bpchar_larger - _null_ )); +DATA(insert OID = 1063 ( bpchar_larger PGNSP PGUID 12 f f t f i 2 1042 "1042 1042" _null_ _null_ _null_ bpchar_larger - _null_ )); DESCR("larger of two"); DATA(insert OID = 1064 ( bpchar_smaller PGNSP PGUID 12 f f t f i 2 1042 "1042 1042" _null_ _null_ _null_ bpchar_smaller - _null_ )); DESCR("smaller of two"); @@ -1420,9 +1420,9 @@ DATA(insert OID = 1106 ( time_ne PGNSP PGUID 12 f f t f i 2 16 "1083 1083" DESCR("not equal"); DATA(insert OID = 1107 ( time_cmp PGNSP PGUID 12 f f t f i 2 23 "1083 1083" _null_ _null_ _null_ time_cmp - _null_ )); DESCR("less-equal-greater"); -DATA(insert OID = 1138 ( date_larger PGNSP PGUID 12 f f t f i 2 1082 "1082 1082" _null_ _null_ _null_ date_larger - _null_ )); +DATA(insert OID = 1138 ( date_larger PGNSP PGUID 12 f f t f i 2 1082 "1082 1082" _null_ _null_ _null_ date_larger - _null_ )); DESCR("larger of two"); -DATA(insert OID = 1139 ( date_smaller PGNSP PGUID 12 f f t f i 2 1082 "1082 1082" _null_ _null_ _null_ date_smaller - _null_ )); +DATA(insert OID = 1139 ( date_smaller PGNSP PGUID 12 f f t f i 2 1082 "1082 1082" _null_ _null_ _null_ date_smaller - _null_ )); DESCR("smaller of two"); DATA(insert OID = 1140 ( date_mi PGNSP PGUID 12 f f t f i 2 23 "1082 1082" _null_ _null_ _null_ date_mi - _null_ )); DESCR("subtract"); @@ -1462,7 +1462,7 @@ DATA(insert OID = 1156 ( timestamptz_ge PGNSP PGUID 12 f f t f i 2 16 "1184 1 DESCR("greater-than-or-equal"); DATA(insert OID = 1157 ( timestamptz_gt PGNSP PGUID 12 f f t f i 2 16 "1184 1184" _null_ _null_ _null_ timestamp_gt - _null_ )); DESCR("greater-than"); -DATA(insert OID = 1158 ( to_timestamp PGNSP PGUID 14 f f t f i 1 1184 "701" _null_ _null_ _null_ "select (''epoch''::timestamptz + $1 * ''1 second''::interval)" - _null_ )); +DATA(insert OID = 1158 ( to_timestamp PGNSP PGUID 14 f f t f i 1 1184 "701" _null_ _null_ _null_ "select (''epoch''::timestamptz + $1 * ''1 second''::interval)" - _null_ )); DESCR("convert UNIX epoch to timestamptz"); DATA(insert OID = 1159 ( timezone PGNSP PGUID 12 f f t f i 2 1114 "25 1184" _null_ _null_ _null_ timestamptz_zone - _null_ )); DESCR("adjust timestamp to new time zone"); @@ -1483,11 +1483,11 @@ DATA(insert OID = 1166 ( interval_ge PGNSP PGUID 12 f f t f i 2 16 "1186 118 DESCR("greater-than-or-equal"); DATA(insert OID = 1167 ( interval_gt PGNSP PGUID 12 f f t f i 2 16 "1186 1186" _null_ _null_ _null_ interval_gt - _null_ )); DESCR("greater-than"); -DATA(insert OID = 1168 ( interval_um PGNSP PGUID 12 f f t f i 1 1186 "1186" _null_ _null_ _null_ interval_um - _null_ )); +DATA(insert OID = 1168 ( interval_um PGNSP PGUID 12 f f t f i 1 1186 "1186" _null_ _null_ _null_ interval_um - _null_ )); DESCR("subtract"); -DATA(insert OID = 1169 ( interval_pl PGNSP PGUID 12 f f t f i 2 1186 "1186 1186" _null_ _null_ _null_ interval_pl - _null_ )); +DATA(insert OID = 1169 ( interval_pl PGNSP PGUID 12 f f t f i 2 1186 "1186 1186" _null_ _null_ _null_ interval_pl - _null_ )); DESCR("add"); -DATA(insert OID = 1170 ( interval_mi PGNSP PGUID 12 f f t f i 2 1186 "1186 1186" _null_ _null_ _null_ interval_mi - _null_ )); +DATA(insert OID = 1170 ( interval_mi PGNSP PGUID 12 f f t f i 2 1186 "1186 1186" _null_ _null_ _null_ interval_mi - _null_ )); DESCR("subtract"); DATA(insert OID = 1171 ( date_part PGNSP PGUID 12 f f t f s 2 701 "25 1184" _null_ _null_ _null_ timestamptz_part - _null_ )); DESCR("extract field from timestamp with time zone"); @@ -1495,42 +1495,42 @@ DATA(insert OID = 1172 ( date_part PGNSP PGUID 12 f f t f i 2 701 "25 1186 DESCR("extract field from interval"); DATA(insert OID = 1173 ( timestamptz PGNSP PGUID 12 f f t f i 1 1184 "702" _null_ _null_ _null_ abstime_timestamptz - _null_ )); DESCR("convert abstime to timestamp with time zone"); -DATA(insert OID = 1174 ( timestamptz PGNSP PGUID 12 f f t f s 1 1184 "1082" _null_ _null_ _null_ date_timestamptz - _null_ )); +DATA(insert OID = 1174 ( timestamptz PGNSP PGUID 12 f f t f s 1 1184 "1082" _null_ _null_ _null_ date_timestamptz - _null_ )); DESCR("convert date to timestamp with time zone"); -DATA(insert OID = 1175 ( justify_hours PGNSP PGUID 12 f f t f i 1 1186 "1186" _null_ _null_ _null_ interval_justify_hours - _null_ )); +DATA(insert OID = 1175 ( justify_hours PGNSP PGUID 12 f f t f i 1 1186 "1186" _null_ _null_ _null_ interval_justify_hours - _null_ )); DESCR("promote groups of 24 hours to numbers of days"); -DATA(insert OID = 1295 ( justify_days PGNSP PGUID 12 f f t f i 1 1186 "1186" _null_ _null_ _null_ interval_justify_days - _null_ )); +DATA(insert OID = 1295 ( justify_days PGNSP PGUID 12 f f t f i 1 1186 "1186" _null_ _null_ _null_ interval_justify_days - _null_ )); DESCR("promote groups of 30 days to numbers of months"); -DATA(insert OID = 1176 ( timestamptz PGNSP PGUID 14 f f t f s 2 1184 "1082 1083" _null_ _null_ _null_ "select cast(($1 + $2) as timestamp with time zone)" - _null_ )); +DATA(insert OID = 1176 ( timestamptz PGNSP PGUID 14 f f t f s 2 1184 "1082 1083" _null_ _null_ _null_ "select cast(($1 + $2) as timestamp with time zone)" - _null_ )); DESCR("convert date and time to timestamp with time zone"); DATA(insert OID = 1177 ( interval PGNSP PGUID 12 f f t f i 1 1186 "703" _null_ _null_ _null_ reltime_interval - _null_ )); DESCR("convert reltime to interval"); -DATA(insert OID = 1178 ( date PGNSP PGUID 12 f f t f s 1 1082 "1184" _null_ _null_ _null_ timestamptz_date - _null_ )); +DATA(insert OID = 1178 ( date PGNSP PGUID 12 f f t f s 1 1082 "1184" _null_ _null_ _null_ timestamptz_date - _null_ )); DESCR("convert timestamp with time zone to date"); DATA(insert OID = 1179 ( date PGNSP PGUID 12 f f t f s 1 1082 "702" _null_ _null_ _null_ abstime_date - _null_ )); DESCR("convert abstime to date"); -DATA(insert OID = 1180 ( abstime PGNSP PGUID 12 f f t f i 1 702 "1184" _null_ _null_ _null_ timestamptz_abstime - _null_ )); +DATA(insert OID = 1180 ( abstime PGNSP PGUID 12 f f t f i 1 702 "1184" _null_ _null_ _null_ timestamptz_abstime - _null_ )); DESCR("convert timestamp with time zone to abstime"); -DATA(insert OID = 1181 ( age PGNSP PGUID 12 f f t f s 1 23 "28" _null_ _null_ _null_ xid_age - _null_ )); +DATA(insert OID = 1181 ( age PGNSP PGUID 12 f f t f s 1 23 "28" _null_ _null_ _null_ xid_age - _null_ )); DESCR("age of a transaction ID, in transactions before current transaction"); -DATA(insert OID = 1188 ( timestamptz_mi PGNSP PGUID 12 f f t f i 2 1186 "1184 1184" _null_ _null_ _null_ timestamp_mi - _null_ )); +DATA(insert OID = 1188 ( timestamptz_mi PGNSP PGUID 12 f f t f i 2 1186 "1184 1184" _null_ _null_ _null_ timestamp_mi - _null_ )); DESCR("subtract"); -DATA(insert OID = 1189 ( timestamptz_pl_interval PGNSP PGUID 12 f f t f s 2 1184 "1184 1186" _null_ _null_ _null_ timestamptz_pl_interval - _null_ )); +DATA(insert OID = 1189 ( timestamptz_pl_interval PGNSP PGUID 12 f f t f s 2 1184 "1184 1186" _null_ _null_ _null_ timestamptz_pl_interval - _null_ )); DESCR("plus"); -DATA(insert OID = 1190 ( timestamptz_mi_interval PGNSP PGUID 12 f f t f s 2 1184 "1184 1186" _null_ _null_ _null_ timestamptz_mi_interval - _null_ )); +DATA(insert OID = 1190 ( timestamptz_mi_interval PGNSP PGUID 12 f f t f s 2 1184 "1184 1186" _null_ _null_ _null_ timestamptz_mi_interval - _null_ )); DESCR("minus"); DATA(insert OID = 1191 ( timestamptz PGNSP PGUID 12 f f t f s 1 1184 "25" _null_ _null_ _null_ text_timestamptz - _null_ )); DESCR("convert text to timestamp with time zone"); -DATA(insert OID = 1192 ( text PGNSP PGUID 12 f f t f s 1 25 "1184" _null_ _null_ _null_ timestamptz_text - _null_ )); +DATA(insert OID = 1192 ( text PGNSP PGUID 12 f f t f s 1 25 "1184" _null_ _null_ _null_ timestamptz_text - _null_ )); DESCR("convert timestamp with time zone to text"); -DATA(insert OID = 1193 ( text PGNSP PGUID 12 f f t f i 1 25 "1186" _null_ _null_ _null_ interval_text - _null_ )); +DATA(insert OID = 1193 ( text PGNSP PGUID 12 f f t f i 1 25 "1186" _null_ _null_ _null_ interval_text - _null_ )); DESCR("convert interval to text"); -DATA(insert OID = 1194 ( reltime PGNSP PGUID 12 f f t f i 1 703 "1186" _null_ _null_ _null_ interval_reltime - _null_ )); +DATA(insert OID = 1194 ( reltime PGNSP PGUID 12 f f t f i 1 703 "1186" _null_ _null_ _null_ interval_reltime - _null_ )); DESCR("convert interval to reltime"); -DATA(insert OID = 1195 ( timestamptz_smaller PGNSP PGUID 12 f f t f i 2 1184 "1184 1184" _null_ _null_ _null_ timestamp_smaller - _null_ )); +DATA(insert OID = 1195 ( timestamptz_smaller PGNSP PGUID 12 f f t f i 2 1184 "1184 1184" _null_ _null_ _null_ timestamp_smaller - _null_ )); DESCR("smaller of two"); -DATA(insert OID = 1196 ( timestamptz_larger PGNSP PGUID 12 f f t f i 2 1184 "1184 1184" _null_ _null_ _null_ timestamp_larger - _null_ )); +DATA(insert OID = 1196 ( timestamptz_larger PGNSP PGUID 12 f f t f i 2 1184 "1184 1184" _null_ _null_ _null_ timestamp_larger - _null_ )); DESCR("larger of two"); DATA(insert OID = 1197 ( interval_smaller PGNSP PGUID 12 f f t f i 2 1186 "1186 1186" _null_ _null_ _null_ interval_smaller - _null_ )); DESCR("smaller of two"); @@ -1544,9 +1544,9 @@ DESCR("date difference preserving months and years"); DATA(insert OID = 1200 ( interval PGNSP PGUID 12 f f t f i 2 1186 "1186 23" _null_ _null_ _null_ interval_scale - _null_ )); DESCR("adjust interval precision"); -DATA(insert OID = 1215 ( obj_description PGNSP PGUID 14 f f t f s 2 25 "26 19" _null_ _null_ _null_ "select description from pg_catalog.pg_description where objoid = $1 and classoid = (select oid from pg_catalog.pg_class where relname = $2 and relnamespace = PGNSP) and objsubid = 0" - _null_ )); +DATA(insert OID = 1215 ( obj_description PGNSP PGUID 14 f f t f s 2 25 "26 19" _null_ _null_ _null_ "select description from pg_catalog.pg_description where objoid = $1 and classoid = (select oid from pg_catalog.pg_class where relname = $2 and relnamespace = PGNSP) and objsubid = 0" - _null_ )); DESCR("get description for object id and catalog name"); -DATA(insert OID = 1216 ( col_description PGNSP PGUID 14 f f t f s 2 25 "26 23" _null_ _null_ _null_ "select description from pg_catalog.pg_description where objoid = $1 and classoid = ''pg_catalog.pg_class''::regclass and objsubid = $2" - _null_ )); +DATA(insert OID = 1216 ( col_description PGNSP PGUID 14 f f t f s 2 25 "26 23" _null_ _null_ _null_ "select description from pg_catalog.pg_description where objoid = $1 and classoid = ''pg_catalog.pg_class''::regclass and objsubid = $2" - _null_ )); DESCR("get description for table column"); DATA(insert OID = 1217 ( date_trunc PGNSP PGUID 12 f f t f s 2 1184 "25 1184" _null_ _null_ _null_ timestamptz_trunc - _null_ )); @@ -1554,9 +1554,9 @@ DESCR("truncate timestamp with time zone to specified units"); DATA(insert OID = 1218 ( date_trunc PGNSP PGUID 12 f f t f i 2 1186 "25 1186" _null_ _null_ _null_ interval_trunc - _null_ )); DESCR("truncate interval to specified units"); -DATA(insert OID = 1219 ( int8inc PGNSP PGUID 12 f f t f i 1 20 "20" _null_ _null_ _null_ int8inc - _null_ )); +DATA(insert OID = 1219 ( int8inc PGNSP PGUID 12 f f t f i 1 20 "20" _null_ _null_ _null_ int8inc - _null_ )); DESCR("increment"); -DATA(insert OID = 1230 ( int8abs PGNSP PGUID 12 f f t f i 1 20 "20" _null_ _null_ _null_ int8abs - _null_ )); +DATA(insert OID = 1230 ( int8abs PGNSP PGUID 12 f f t f i 1 20 "20" _null_ _null_ _null_ int8abs - _null_ )); DESCR("absolute value"); DATA(insert OID = 1236 ( int8larger PGNSP PGUID 12 f f t f i 2 20 "20 20" _null_ _null_ _null_ int8larger - _null_ )); @@ -1578,9 +1578,9 @@ DESCR("Calculate total disk space usage for the specified tablespace"); DATA(insert OID = 2323 ( pg_tablespace_size PGNSP PGUID 12 f f t f v 1 20 "19" _null_ _null_ _null_ pg_tablespace_size_name - _null_ )); DESCR("Calculate total disk space usage for the specified tablespace"); -DATA(insert OID = 1251 ( int4abs PGNSP PGUID 12 f f t f i 1 23 "23" _null_ _null_ _null_ int4abs - _null_ )); +DATA(insert OID = 1251 ( int4abs PGNSP PGUID 12 f f t f i 1 23 "23" _null_ _null_ _null_ int4abs - _null_ )); DESCR("absolute value"); -DATA(insert OID = 1253 ( int2abs PGNSP PGUID 12 f f t f i 1 21 "21" _null_ _null_ _null_ int2abs - _null_ )); +DATA(insert OID = 1253 ( int2abs PGNSP PGUID 12 f f t f i 1 21 "21" _null_ _null_ _null_ int2abs - _null_ )); DESCR("absolute value"); DATA(insert OID = 1263 ( interval PGNSP PGUID 12 f f t f s 1 1186 "25" _null_ _null_ _null_ text_interval - _null_ )); @@ -1589,9 +1589,9 @@ DESCR("convert text to interval"); DATA(insert OID = 2324 ( pg_database_size PGNSP PGUID 12 f f t f v 1 20 "26" _null_ _null_ _null_ pg_database_size_oid - _null_ )); DESCR("Calculate total disk space usage for the specified database"); -DATA(insert OID = 1271 ( overlaps PGNSP PGUID 12 f f f f i 4 16 "1266 1266 1266 1266" _null_ _null_ _null_ overlaps_timetz - _null_ )); +DATA(insert OID = 1271 ( overlaps PGNSP PGUID 12 f f f f i 4 16 "1266 1266 1266 1266" _null_ _null_ _null_ overlaps_timetz - _null_ )); DESCR("SQL92 interval comparison"); -DATA(insert OID = 1272 ( datetime_pl PGNSP PGUID 12 f f t f i 2 1114 "1082 1083" _null_ _null_ _null_ datetime_timestamp - _null_ )); +DATA(insert OID = 1272 ( datetime_pl PGNSP PGUID 12 f f t f i 2 1114 "1082 1083" _null_ _null_ _null_ datetime_timestamp - _null_ )); DESCR("convert date and time to timestamp"); DATA(insert OID = 1273 ( date_part PGNSP PGUID 12 f f t f i 2 701 "25 1266" _null_ _null_ _null_ timetz_part - _null_ )); DESCR("extract field from time with time zone"); @@ -1612,14 +1612,14 @@ DESCR("multiply"); DATA(insert OID = 1281 ( int48div PGNSP PGUID 12 f f t f i 2 20 "23 20" _null_ _null_ _null_ int48div - _null_ )); DESCR("divide"); -DATA(insert OID = 1287 ( oid PGNSP PGUID 12 f f t f i 1 26 "20" _null_ _null_ _null_ i8tooid - _null_ )); +DATA(insert OID = 1287 ( oid PGNSP PGUID 12 f f t f i 1 26 "20" _null_ _null_ _null_ i8tooid - _null_ )); DESCR("convert int8 to oid"); -DATA(insert OID = 1288 ( int8 PGNSP PGUID 12 f f t f i 1 20 "26" _null_ _null_ _null_ oidtoi8 - _null_ )); +DATA(insert OID = 1288 ( int8 PGNSP PGUID 12 f f t f i 1 20 "26" _null_ _null_ _null_ oidtoi8 - _null_ )); DESCR("convert oid to int8"); -DATA(insert OID = 1289 ( text PGNSP PGUID 12 f f t f i 1 25 "20" _null_ _null_ _null_ int8_text - _null_ )); +DATA(insert OID = 1289 ( text PGNSP PGUID 12 f f t f i 1 25 "20" _null_ _null_ _null_ int8_text - _null_ )); DESCR("convert int8 to text"); -DATA(insert OID = 1290 ( int8 PGNSP PGUID 12 f f t f i 1 20 "25" _null_ _null_ _null_ text_int8 - _null_ )); +DATA(insert OID = 1290 ( int8 PGNSP PGUID 12 f f t f i 1 20 "25" _null_ _null_ _null_ text_int8 - _null_ )); DESCR("convert text to int8"); DATA(insert OID = 1291 ( array_length_coerce PGNSP PGUID 12 f f t f s 3 2277 "2277 23 16" _null_ _null_ _null_ array_length_coerce - _null_ )); @@ -1635,13 +1635,13 @@ DESCR("latest tid of a tuple"); DATA(insert OID = 2168 ( pg_database_size PGNSP PGUID 12 f f t f v 1 20 "19" _null_ _null_ _null_ pg_database_size_name - _null_ )); DESCR("Calculate total disk space usage for the specified database"); -DATA(insert OID = 1296 ( timedate_pl PGNSP PGUID 14 f f t f i 2 1114 "1083 1082" _null_ _null_ _null_ "select ($2 + $1)" - _null_ )); +DATA(insert OID = 1296 ( timedate_pl PGNSP PGUID 14 f f t f i 2 1114 "1083 1082" _null_ _null_ _null_ "select ($2 + $1)" - _null_ )); DESCR("convert time and date to timestamp"); -DATA(insert OID = 1297 ( datetimetz_pl PGNSP PGUID 12 f f t f i 2 1184 "1082 1266" _null_ _null_ _null_ datetimetz_timestamptz - _null_ )); +DATA(insert OID = 1297 ( datetimetz_pl PGNSP PGUID 12 f f t f i 2 1184 "1082 1266" _null_ _null_ _null_ datetimetz_timestamptz - _null_ )); DESCR("convert date and time with time zone to timestamp with time zone"); -DATA(insert OID = 1298 ( timetzdate_pl PGNSP PGUID 14 f f t f i 2 1184 "1266 1082" _null_ _null_ _null_ "select ($2 + $1)" - _null_ )); +DATA(insert OID = 1298 ( timetzdate_pl PGNSP PGUID 14 f f t f i 2 1184 "1266 1082" _null_ _null_ _null_ "select ($2 + $1)" - _null_ )); DESCR("convert time with time zone and date to timestamp with time zone"); -DATA(insert OID = 1299 ( now PGNSP PGUID 12 f f t f s 0 1184 "" _null_ _null_ _null_ now - _null_ )); +DATA(insert OID = 1299 ( now PGNSP PGUID 12 f f t f s 0 1184 "" _null_ _null_ _null_ now - _null_ )); DESCR("current transaction time"); /* OIDS 1300 - 1399 */ @@ -1677,43 +1677,43 @@ DATA(insert OID = 1312 ( timestamp_in PGNSP PGUID 12 f f t f s 3 1114 "2275 2 DESCR("I/O"); DATA(insert OID = 1313 ( timestamp_out PGNSP PGUID 12 f f t f s 1 2275 "1114" _null_ _null_ _null_ timestamp_out - _null_ )); DESCR("I/O"); -DATA(insert OID = 1314 ( timestamptz_cmp PGNSP PGUID 12 f f t f i 2 23 "1184 1184" _null_ _null_ _null_ timestamp_cmp - _null_ )); +DATA(insert OID = 1314 ( timestamptz_cmp PGNSP PGUID 12 f f t f i 2 23 "1184 1184" _null_ _null_ _null_ timestamp_cmp - _null_ )); DESCR("less-equal-greater"); -DATA(insert OID = 1315 ( interval_cmp PGNSP PGUID 12 f f t f i 2 23 "1186 1186" _null_ _null_ _null_ interval_cmp - _null_ )); +DATA(insert OID = 1315 ( interval_cmp PGNSP PGUID 12 f f t f i 2 23 "1186 1186" _null_ _null_ _null_ interval_cmp - _null_ )); DESCR("less-equal-greater"); DATA(insert OID = 1316 ( time PGNSP PGUID 12 f f t f i 1 1083 "1114" _null_ _null_ _null_ timestamp_time - _null_ )); DESCR("convert timestamp to time"); DATA(insert OID = 1317 ( length PGNSP PGUID 12 f f t f i 1 23 "25" _null_ _null_ _null_ textlen - _null_ )); DESCR("length"); -DATA(insert OID = 1318 ( length PGNSP PGUID 12 f f t f i 1 23 "1042" _null_ _null_ _null_ bpcharlen - _null_ )); +DATA(insert OID = 1318 ( length PGNSP PGUID 12 f f t f i 1 23 "1042" _null_ _null_ _null_ bpcharlen - _null_ )); DESCR("character length"); -DATA(insert OID = 1319 ( xideqint4 PGNSP PGUID 12 f f t f i 2 16 "28 23" _null_ _null_ _null_ xideq - _null_ )); +DATA(insert OID = 1319 ( xideqint4 PGNSP PGUID 12 f f t f i 2 16 "28 23" _null_ _null_ _null_ xideq - _null_ )); DESCR("equal"); DATA(insert OID = 1326 ( interval_div PGNSP PGUID 12 f f t f i 2 1186 "1186 701" _null_ _null_ _null_ interval_div - _null_ )); DESCR("divide"); -DATA(insert OID = 1339 ( dlog10 PGNSP PGUID 12 f f t f i 1 701 "701" _null_ _null_ _null_ dlog10 - _null_ )); +DATA(insert OID = 1339 ( dlog10 PGNSP PGUID 12 f f t f i 1 701 "701" _null_ _null_ _null_ dlog10 - _null_ )); DESCR("base 10 logarithm"); -DATA(insert OID = 1340 ( log PGNSP PGUID 12 f f t f i 1 701 "701" _null_ _null_ _null_ dlog10 - _null_ )); +DATA(insert OID = 1340 ( log PGNSP PGUID 12 f f t f i 1 701 "701" _null_ _null_ _null_ dlog10 - _null_ )); DESCR("base 10 logarithm"); -DATA(insert OID = 1341 ( ln PGNSP PGUID 12 f f t f i 1 701 "701" _null_ _null_ _null_ dlog1 - _null_ )); +DATA(insert OID = 1341 ( ln PGNSP PGUID 12 f f t f i 1 701 "701" _null_ _null_ _null_ dlog1 - _null_ )); DESCR("natural logarithm"); -DATA(insert OID = 1342 ( round PGNSP PGUID 12 f f t f i 1 701 "701" _null_ _null_ _null_ dround - _null_ )); +DATA(insert OID = 1342 ( round PGNSP PGUID 12 f f t f i 1 701 "701" _null_ _null_ _null_ dround - _null_ )); DESCR("round to nearest integer"); -DATA(insert OID = 1343 ( trunc PGNSP PGUID 12 f f t f i 1 701 "701" _null_ _null_ _null_ dtrunc - _null_ )); +DATA(insert OID = 1343 ( trunc PGNSP PGUID 12 f f t f i 1 701 "701" _null_ _null_ _null_ dtrunc - _null_ )); DESCR("truncate to integer"); -DATA(insert OID = 1344 ( sqrt PGNSP PGUID 12 f f t f i 1 701 "701" _null_ _null_ _null_ dsqrt - _null_ )); +DATA(insert OID = 1344 ( sqrt PGNSP PGUID 12 f f t f i 1 701 "701" _null_ _null_ _null_ dsqrt - _null_ )); DESCR("square root"); -DATA(insert OID = 1345 ( cbrt PGNSP PGUID 12 f f t f i 1 701 "701" _null_ _null_ _null_ dcbrt - _null_ )); +DATA(insert OID = 1345 ( cbrt PGNSP PGUID 12 f f t f i 1 701 "701" _null_ _null_ _null_ dcbrt - _null_ )); DESCR("cube root"); -DATA(insert OID = 1346 ( pow PGNSP PGUID 12 f f t f i 2 701 "701 701" _null_ _null_ _null_ dpow - _null_ )); +DATA(insert OID = 1346 ( pow PGNSP PGUID 12 f f t f i 2 701 "701 701" _null_ _null_ _null_ dpow - _null_ )); DESCR("exponentiation"); -DATA(insert OID = 1368 ( power PGNSP PGUID 12 f f t f i 2 701 "701 701" _null_ _null_ _null_ dpow - _null_ )); +DATA(insert OID = 1368 ( power PGNSP PGUID 12 f f t f i 2 701 "701 701" _null_ _null_ _null_ dpow - _null_ )); DESCR("exponentiation"); -DATA(insert OID = 1347 ( exp PGNSP PGUID 12 f f t f i 1 701 "701" _null_ _null_ _null_ dexp - _null_ )); +DATA(insert OID = 1347 ( exp PGNSP PGUID 12 f f t f i 1 701 "701" _null_ _null_ _null_ dexp - _null_ )); DESCR("exponential"); /* @@ -1744,13 +1744,13 @@ DATA(insert OID = 1357 ( timetz_gt PGNSP PGUID 12 f f t f i 2 16 "1266 1266 DESCR("greater-than"); DATA(insert OID = 1358 ( timetz_cmp PGNSP PGUID 12 f f t f i 2 23 "1266 1266" _null_ _null_ _null_ timetz_cmp - _null_ )); DESCR("less-equal-greater"); -DATA(insert OID = 1359 ( timestamptz PGNSP PGUID 12 f f t f i 2 1184 "1082 1266" _null_ _null_ _null_ datetimetz_timestamptz - _null_ )); +DATA(insert OID = 1359 ( timestamptz PGNSP PGUID 12 f f t f i 2 1184 "1082 1266" _null_ _null_ _null_ datetimetz_timestamptz - _null_ )); DESCR("convert date and time with time zone to timestamp with time zone"); DATA(insert OID = 1364 ( time PGNSP PGUID 14 f f t f s 1 1083 "702" _null_ _null_ _null_ "select cast(cast($1 as timestamp without time zone) as time)" - _null_ )); DESCR("convert abstime to time"); -DATA(insert OID = 1367 ( character_length PGNSP PGUID 12 f f t f i 1 23 "1042" _null_ _null_ _null_ bpcharlen - _null_ )); +DATA(insert OID = 1367 ( character_length PGNSP PGUID 12 f f t f i 1 23 "1042" _null_ _null_ _null_ bpcharlen - _null_ )); DESCR("character length"); DATA(insert OID = 1369 ( character_length PGNSP PGUID 12 f f t f i 1 23 "25" _null_ _null_ _null_ textlen - _null_ )); DESCR("character length"); @@ -1763,21 +1763,21 @@ DESCR("character length"); DATA(insert OID = 1373 ( array_type_length_coerce PGNSP PGUID 12 f f t f s 3 2277 "2277 23 16" _null_ _null_ _null_ array_type_length_coerce - _null_ )); DESCR("coerce array to another type and adjust element typmod"); -DATA(insert OID = 1374 ( octet_length PGNSP PGUID 12 f f t f i 1 23 "25" _null_ _null_ _null_ textoctetlen - _null_ )); +DATA(insert OID = 1374 ( octet_length PGNSP PGUID 12 f f t f i 1 23 "25" _null_ _null_ _null_ textoctetlen - _null_ )); DESCR("octet length"); DATA(insert OID = 1375 ( octet_length PGNSP PGUID 12 f f t f i 1 23 "1042" _null_ _null_ _null_ bpcharoctetlen - _null_ )); DESCR("octet length"); -DATA(insert OID = 1377 ( time_larger PGNSP PGUID 12 f f t f i 2 1083 "1083 1083" _null_ _null_ _null_ time_larger - _null_ )); +DATA(insert OID = 1377 ( time_larger PGNSP PGUID 12 f f t f i 2 1083 "1083 1083" _null_ _null_ _null_ time_larger - _null_ )); DESCR("larger of two"); -DATA(insert OID = 1378 ( time_smaller PGNSP PGUID 12 f f t f i 2 1083 "1083 1083" _null_ _null_ _null_ time_smaller - _null_ )); +DATA(insert OID = 1378 ( time_smaller PGNSP PGUID 12 f f t f i 2 1083 "1083 1083" _null_ _null_ _null_ time_smaller - _null_ )); DESCR("smaller of two"); -DATA(insert OID = 1379 ( timetz_larger PGNSP PGUID 12 f f t f i 2 1266 "1266 1266" _null_ _null_ _null_ timetz_larger - _null_ )); +DATA(insert OID = 1379 ( timetz_larger PGNSP PGUID 12 f f t f i 2 1266 "1266 1266" _null_ _null_ _null_ timetz_larger - _null_ )); DESCR("larger of two"); -DATA(insert OID = 1380 ( timetz_smaller PGNSP PGUID 12 f f t f i 2 1266 "1266 1266" _null_ _null_ _null_ timetz_smaller - _null_ )); +DATA(insert OID = 1380 ( timetz_smaller PGNSP PGUID 12 f f t f i 2 1266 "1266 1266" _null_ _null_ _null_ timetz_smaller - _null_ )); DESCR("smaller of two"); -DATA(insert OID = 1381 ( char_length PGNSP PGUID 12 f f t f i 1 23 "25" _null_ _null_ _null_ textlen - _null_ )); +DATA(insert OID = 1381 ( char_length PGNSP PGUID 12 f f t f i 1 23 "25" _null_ _null_ _null_ textlen - _null_ )); DESCR("character length"); DATA(insert OID = 1382 ( date_part PGNSP PGUID 14 f f t f s 2 701 "25 702" _null_ _null_ _null_ "select pg_catalog.date_part($1, cast($2 as timestamp with time zone))" - _null_ )); @@ -1788,10 +1788,10 @@ DATA(insert OID = 1384 ( date_part PGNSP PGUID 14 f f t f i 2 701 "25 1082" DESCR("extract field from date"); DATA(insert OID = 1385 ( date_part PGNSP PGUID 12 f f t f i 2 701 "25 1083" _null_ _null_ _null_ time_part - _null_ )); DESCR("extract field from time"); -DATA(insert OID = 1386 ( age PGNSP PGUID 14 f f t f s 1 1186 "1184" _null_ _null_ _null_ "select pg_catalog.age(cast(current_date as timestamp with time zone), $1)" - _null_ )); +DATA(insert OID = 1386 ( age PGNSP PGUID 14 f f t f s 1 1186 "1184" _null_ _null_ _null_ "select pg_catalog.age(cast(current_date as timestamp with time zone), $1)" - _null_ )); DESCR("date difference from today preserving months and years"); -DATA(insert OID = 1388 ( timetz PGNSP PGUID 12 f f t f s 1 1266 "1184" _null_ _null_ _null_ timestamptz_timetz - _null_ )); +DATA(insert OID = 1388 ( timetz PGNSP PGUID 12 f f t f s 1 1266 "1184" _null_ _null_ _null_ timestamptz_timetz - _null_ )); DESCR("convert timestamptz to timetz"); DATA(insert OID = 1389 ( isfinite PGNSP PGUID 12 f f t f i 1 16 "1184" _null_ _null_ _null_ timestamp_finite - _null_ )); @@ -1806,11 +1806,11 @@ DATA(insert OID = 1394 ( abs PGNSP PGUID 12 f f t f i 1 700 "700" _null_ _ DESCR("absolute value"); DATA(insert OID = 1395 ( abs PGNSP PGUID 12 f f t f i 1 701 "701" _null_ _null_ _null_ float8abs - _null_ )); DESCR("absolute value"); -DATA(insert OID = 1396 ( abs PGNSP PGUID 12 f f t f i 1 20 "20" _null_ _null_ _null_ int8abs - _null_ )); +DATA(insert OID = 1396 ( abs PGNSP PGUID 12 f f t f i 1 20 "20" _null_ _null_ _null_ int8abs - _null_ )); DESCR("absolute value"); -DATA(insert OID = 1397 ( abs PGNSP PGUID 12 f f t f i 1 23 "23" _null_ _null_ _null_ int4abs - _null_ )); +DATA(insert OID = 1397 ( abs PGNSP PGUID 12 f f t f i 1 23 "23" _null_ _null_ _null_ int4abs - _null_ )); DESCR("absolute value"); -DATA(insert OID = 1398 ( abs PGNSP PGUID 12 f f t f i 1 21 "21" _null_ _null_ _null_ int2abs - _null_ )); +DATA(insert OID = 1398 ( abs PGNSP PGUID 12 f f t f i 1 21 "21" _null_ _null_ _null_ int2abs - _null_ )); DESCR("absolute value"); /* OIDS 1400 - 1499 */ @@ -1853,12 +1853,12 @@ DESCR("horizontal?"); DATA(insert OID = 1416 ( point PGNSP PGUID 12 f f t f i 1 600 "718" _null_ _null_ _null_ circle_center - _null_ )); DESCR("center of"); -DATA(insert OID = 1417 ( isnottrue PGNSP PGUID 12 f f f f i 1 16 "16" _null_ _null_ _null_ isnottrue - _null_ )); +DATA(insert OID = 1417 ( isnottrue PGNSP PGUID 12 f f f f i 1 16 "16" _null_ _null_ _null_ isnottrue - _null_ )); DESCR("bool is not true (ie, false or unknown)"); -DATA(insert OID = 1418 ( isnotfalse PGNSP PGUID 12 f f f f i 1 16 "16" _null_ _null_ _null_ isnotfalse - _null_ )); +DATA(insert OID = 1418 ( isnotfalse PGNSP PGUID 12 f f f f i 1 16 "16" _null_ _null_ _null_ isnotfalse - _null_ )); DESCR("bool is not false (ie, true or unknown)"); -DATA(insert OID = 1419 ( time PGNSP PGUID 12 f f t f i 1 1083 "1186" _null_ _null_ _null_ interval_time - _null_ )); +DATA(insert OID = 1419 ( time PGNSP PGUID 12 f f t f i 1 1083 "1186" _null_ _null_ _null_ interval_time - _null_ )); DESCR("convert interval to time"); DATA(insert OID = 1421 ( box PGNSP PGUID 12 f f t f i 2 603 "600 600" _null_ _null_ _null_ points_box - _null_ )); @@ -1926,9 +1926,9 @@ DESCR("convert box to polygon"); DATA(insert OID = 1449 ( polygon PGNSP PGUID 12 f f t f i 1 604 "602" _null_ _null_ _null_ path_poly - _null_ )); DESCR("convert path to polygon"); -DATA(insert OID = 1450 ( circle_in PGNSP PGUID 12 f f t f i 1 718 "2275" _null_ _null_ _null_ circle_in - _null_ )); +DATA(insert OID = 1450 ( circle_in PGNSP PGUID 12 f f t f i 1 718 "2275" _null_ _null_ _null_ circle_in - _null_ )); DESCR("I/O"); -DATA(insert OID = 1451 ( circle_out PGNSP PGUID 12 f f t f i 1 2275 "718" _null_ _null_ _null_ circle_out - _null_ )); +DATA(insert OID = 1451 ( circle_out PGNSP PGUID 12 f f t f i 1 2275 "718" _null_ _null_ _null_ circle_out - _null_ )); DESCR("I/O"); DATA(insert OID = 1452 ( circle_same PGNSP PGUID 12 f f t f i 2 16 "718 718" _null_ _null_ _null_ circle_same - _null_ )); DESCR("same as?"); @@ -2008,7 +2008,7 @@ DESCR("closest point to line on line segment"); DATA(insert OID = 1489 ( close_lseg PGNSP PGUID 12 f f t f i 2 600 "601 601" _null_ _null_ _null_ close_lseg - _null_ )); DESCR("closest point to line segment on line segment"); -DATA(insert OID = 1490 ( line_in PGNSP PGUID 12 f f t f i 1 628 "2275" _null_ _null_ _null_ line_in - _null_ )); +DATA(insert OID = 1490 ( line_in PGNSP PGUID 12 f f t f i 1 628 "2275" _null_ _null_ _null_ line_in - _null_ )); DESCR("I/O"); DATA(insert OID = 1491 ( line_out PGNSP PGUID 12 f f t f i 1 2275 "628" _null_ _null_ _null_ line_out - _null_ )); DESCR("I/O"); @@ -2060,16 +2060,16 @@ DESCR("number of points in polygon"); DATA(insert OID = 1564 ( bit_in PGNSP PGUID 12 f f t f i 3 1560 "2275 26 23" _null_ _null_ _null_ bit_in - _null_ )); DESCR("I/O"); -DATA(insert OID = 1565 ( bit_out PGNSP PGUID 12 f f t f i 1 2275 "1560" _null_ _null_ _null_ bit_out - _null_ )); +DATA(insert OID = 1565 ( bit_out PGNSP PGUID 12 f f t f i 1 2275 "1560" _null_ _null_ _null_ bit_out - _null_ )); DESCR("I/O"); -DATA(insert OID = 1569 ( like PGNSP PGUID 12 f f t f i 2 16 "25 25" _null_ _null_ _null_ textlike - _null_ )); +DATA(insert OID = 1569 ( like PGNSP PGUID 12 f f t f i 2 16 "25 25" _null_ _null_ _null_ textlike - _null_ )); DESCR("matches LIKE expression"); -DATA(insert OID = 1570 ( notlike PGNSP PGUID 12 f f t f i 2 16 "25 25" _null_ _null_ _null_ textnlike - _null_ )); +DATA(insert OID = 1570 ( notlike PGNSP PGUID 12 f f t f i 2 16 "25 25" _null_ _null_ _null_ textnlike - _null_ )); DESCR("does not match LIKE expression"); -DATA(insert OID = 1571 ( like PGNSP PGUID 12 f f t f i 2 16 "19 25" _null_ _null_ _null_ namelike - _null_ )); +DATA(insert OID = 1571 ( like PGNSP PGUID 12 f f t f i 2 16 "19 25" _null_ _null_ _null_ namelike - _null_ )); DESCR("matches LIKE expression"); -DATA(insert OID = 1572 ( notlike PGNSP PGUID 12 f f t f i 2 16 "19 25" _null_ _null_ _null_ namenlike - _null_ )); +DATA(insert OID = 1572 ( notlike PGNSP PGUID 12 f f t f i 2 16 "19 25" _null_ _null_ _null_ namenlike - _null_ )); DESCR("does not match LIKE expression"); @@ -2085,25 +2085,25 @@ DESCR("set sequence value and iscalled status"); DATA(insert OID = 1579 ( varbit_in PGNSP PGUID 12 f f t f i 3 1562 "2275 26 23" _null_ _null_ _null_ varbit_in - _null_ )); DESCR("I/O"); -DATA(insert OID = 1580 ( varbit_out PGNSP PGUID 12 f f t f i 1 2275 "1562" _null_ _null_ _null_ varbit_out - _null_ )); +DATA(insert OID = 1580 ( varbit_out PGNSP PGUID 12 f f t f i 1 2275 "1562" _null_ _null_ _null_ varbit_out - _null_ )); DESCR("I/O"); -DATA(insert OID = 1581 ( biteq PGNSP PGUID 12 f f t f i 2 16 "1560 1560" _null_ _null_ _null_ biteq - _null_ )); +DATA(insert OID = 1581 ( biteq PGNSP PGUID 12 f f t f i 2 16 "1560 1560" _null_ _null_ _null_ biteq - _null_ )); DESCR("equal"); -DATA(insert OID = 1582 ( bitne PGNSP PGUID 12 f f t f i 2 16 "1560 1560" _null_ _null_ _null_ bitne - _null_ )); +DATA(insert OID = 1582 ( bitne PGNSP PGUID 12 f f t f i 2 16 "1560 1560" _null_ _null_ _null_ bitne - _null_ )); DESCR("not equal"); -DATA(insert OID = 1592 ( bitge PGNSP PGUID 12 f f t f i 2 16 "1560 1560" _null_ _null_ _null_ bitge - _null_ )); +DATA(insert OID = 1592 ( bitge PGNSP PGUID 12 f f t f i 2 16 "1560 1560" _null_ _null_ _null_ bitge - _null_ )); DESCR("greater than or equal"); -DATA(insert OID = 1593 ( bitgt PGNSP PGUID 12 f f t f i 2 16 "1560 1560" _null_ _null_ _null_ bitgt - _null_ )); +DATA(insert OID = 1593 ( bitgt PGNSP PGUID 12 f f t f i 2 16 "1560 1560" _null_ _null_ _null_ bitgt - _null_ )); DESCR("greater than"); -DATA(insert OID = 1594 ( bitle PGNSP PGUID 12 f f t f i 2 16 "1560 1560" _null_ _null_ _null_ bitle - _null_ )); +DATA(insert OID = 1594 ( bitle PGNSP PGUID 12 f f t f i 2 16 "1560 1560" _null_ _null_ _null_ bitle - _null_ )); DESCR("less than or equal"); -DATA(insert OID = 1595 ( bitlt PGNSP PGUID 12 f f t f i 2 16 "1560 1560" _null_ _null_ _null_ bitlt - _null_ )); +DATA(insert OID = 1595 ( bitlt PGNSP PGUID 12 f f t f i 2 16 "1560 1560" _null_ _null_ _null_ bitlt - _null_ )); DESCR("less than"); -DATA(insert OID = 1596 ( bitcmp PGNSP PGUID 12 f f t f i 2 23 "1560 1560" _null_ _null_ _null_ bitcmp - _null_ )); +DATA(insert OID = 1596 ( bitcmp PGNSP PGUID 12 f f t f i 2 23 "1560 1560" _null_ _null_ _null_ bitcmp - _null_ )); DESCR("compare"); -DATA(insert OID = 1598 ( random PGNSP PGUID 12 f f t f v 0 701 "" _null_ _null_ _null_ drandom - _null_ )); +DATA(insert OID = 1598 ( random PGNSP PGUID 12 f f t f v 0 701 "" _null_ _null_ _null_ drandom - _null_ )); DESCR("random value"); DATA(insert OID = 1599 ( setseed PGNSP PGUID 12 f f t f v 1 23 "701" _null_ _null_ _null_ setseed - _null_ )); DESCR("set random seed"); @@ -2130,23 +2130,23 @@ DATA(insert OID = 1608 ( degrees PGNSP PGUID 12 f f t f i 1 701 "701" _null_ DESCR("radians to degrees"); DATA(insert OID = 1609 ( radians PGNSP PGUID 12 f f t f i 1 701 "701" _null_ _null_ _null_ radians - _null_ )); DESCR("degrees to radians"); -DATA(insert OID = 1610 ( pi PGNSP PGUID 12 f f t f i 0 701 "" _null_ _null_ _null_ dpi - _null_ )); +DATA(insert OID = 1610 ( pi PGNSP PGUID 12 f f t f i 0 701 "" _null_ _null_ _null_ dpi - _null_ )); DESCR("PI"); -DATA(insert OID = 1618 ( interval_mul PGNSP PGUID 12 f f t f i 2 1186 "1186 701" _null_ _null_ _null_ interval_mul - _null_ )); +DATA(insert OID = 1618 ( interval_mul PGNSP PGUID 12 f f t f i 2 1186 "1186 701" _null_ _null_ _null_ interval_mul - _null_ )); DESCR("multiply interval"); -DATA(insert OID = 1620 ( ascii PGNSP PGUID 12 f f t f i 1 23 "25" _null_ _null_ _null_ ascii - _null_ )); +DATA(insert OID = 1620 ( ascii PGNSP PGUID 12 f f t f i 1 23 "25" _null_ _null_ _null_ ascii - _null_ )); DESCR("convert first char to int4"); -DATA(insert OID = 1621 ( chr PGNSP PGUID 12 f f t f i 1 25 "23" _null_ _null_ _null_ chr - _null_ )); +DATA(insert OID = 1621 ( chr PGNSP PGUID 12 f f t f i 1 25 "23" _null_ _null_ _null_ chr - _null_ )); DESCR("convert int4 to char"); -DATA(insert OID = 1622 ( repeat PGNSP PGUID 12 f f t f i 2 25 "25 23" _null_ _null_ _null_ repeat - _null_ )); +DATA(insert OID = 1622 ( repeat PGNSP PGUID 12 f f t f i 2 25 "25 23" _null_ _null_ _null_ repeat - _null_ )); DESCR("replicate string int4 times"); DATA(insert OID = 1623 ( similar_escape PGNSP PGUID 12 f f f f i 2 25 "25 25" _null_ _null_ _null_ similar_escape - _null_ )); DESCR("convert SQL99 regexp pattern to POSIX style"); -DATA(insert OID = 1624 ( mul_d_interval PGNSP PGUID 12 f f t f i 2 1186 "701 1186" _null_ _null_ _null_ mul_d_interval - _null_ )); +DATA(insert OID = 1624 ( mul_d_interval PGNSP PGUID 12 f f t f i 2 1186 "701 1186" _null_ _null_ _null_ mul_d_interval - _null_ )); DATA(insert OID = 1631 ( bpcharlike PGNSP PGUID 12 f f t f i 2 16 "1042 25" _null_ _null_ _null_ textlike - _null_ )); DESCR("matches LIKE expression"); @@ -2157,9 +2157,9 @@ DATA(insert OID = 1633 ( texticlike PGNSP PGUID 12 f f t f i 2 16 "25 25" _nul DESCR("matches LIKE expression, case-insensitive"); DATA(insert OID = 1634 ( texticnlike PGNSP PGUID 12 f f t f i 2 16 "25 25" _null_ _null_ _null_ texticnlike - _null_ )); DESCR("does not match LIKE expression, case-insensitive"); -DATA(insert OID = 1635 ( nameiclike PGNSP PGUID 12 f f t f i 2 16 "19 25" _null_ _null_ _null_ nameiclike - _null_ )); +DATA(insert OID = 1635 ( nameiclike PGNSP PGUID 12 f f t f i 2 16 "19 25" _null_ _null_ _null_ nameiclike - _null_ )); DESCR("matches LIKE expression, case-insensitive"); -DATA(insert OID = 1636 ( nameicnlike PGNSP PGUID 12 f f t f i 2 16 "19 25" _null_ _null_ _null_ nameicnlike - _null_ )); +DATA(insert OID = 1636 ( nameicnlike PGNSP PGUID 12 f f t f i 2 16 "19 25" _null_ _null_ _null_ nameicnlike - _null_ )); DESCR("does not match LIKE expression, case-insensitive"); DATA(insert OID = 1637 ( like_escape PGNSP PGUID 12 f f t f i 2 25 "25 25" _null_ _null_ _null_ like_escape - _null_ )); DESCR("convert LIKE pattern to use backslash escapes"); @@ -2168,26 +2168,26 @@ DATA(insert OID = 1656 ( bpcharicregexeq PGNSP PGUID 12 f f t f i 2 16 "1042 2 DESCR("matches regex., case-insensitive"); DATA(insert OID = 1657 ( bpcharicregexne PGNSP PGUID 12 f f t f i 2 16 "1042 25" _null_ _null_ _null_ texticregexne - _null_ )); DESCR("does not match regex., case-insensitive"); -DATA(insert OID = 1658 ( bpcharregexeq PGNSP PGUID 12 f f t f i 2 16 "1042 25" _null_ _null_ _null_ textregexeq - _null_ )); +DATA(insert OID = 1658 ( bpcharregexeq PGNSP PGUID 12 f f t f i 2 16 "1042 25" _null_ _null_ _null_ textregexeq - _null_ )); DESCR("matches regex., case-sensitive"); -DATA(insert OID = 1659 ( bpcharregexne PGNSP PGUID 12 f f t f i 2 16 "1042 25" _null_ _null_ _null_ textregexne - _null_ )); +DATA(insert OID = 1659 ( bpcharregexne PGNSP PGUID 12 f f t f i 2 16 "1042 25" _null_ _null_ _null_ textregexne - _null_ )); DESCR("does not match regex., case-sensitive"); DATA(insert OID = 1660 ( bpchariclike PGNSP PGUID 12 f f t f i 2 16 "1042 25" _null_ _null_ _null_ texticlike - _null_ )); DESCR("matches LIKE expression, case-insensitive"); DATA(insert OID = 1661 ( bpcharicnlike PGNSP PGUID 12 f f t f i 2 16 "1042 25" _null_ _null_ _null_ texticnlike - _null_ )); DESCR("does not match LIKE expression, case-insensitive"); -DATA(insert OID = 1689 ( flatfile_update_trigger PGNSP PGUID 12 f f t f v 0 2279 "" _null_ _null_ _null_ flatfile_update_trigger - _null_ )); +DATA(insert OID = 1689 ( flatfile_update_trigger PGNSP PGUID 12 f f t f v 0 2279 "" _null_ _null_ _null_ flatfile_update_trigger - _null_ )); DESCR("update flat-file copy of a shared catalog"); /* Oracle Compatibility Related Functions - By Edmund Mergl */ DATA(insert OID = 868 ( strpos PGNSP PGUID 12 f f t f i 2 23 "25 25" _null_ _null_ _null_ textpos - _null_ )); DESCR("find position of substring"); -DATA(insert OID = 870 ( lower PGNSP PGUID 12 f f t f i 1 25 "25" _null_ _null_ _null_ lower - _null_ )); +DATA(insert OID = 870 ( lower PGNSP PGUID 12 f f t f i 1 25 "25" _null_ _null_ _null_ lower - _null_ )); DESCR("lowercase"); -DATA(insert OID = 871 ( upper PGNSP PGUID 12 f f t f i 1 25 "25" _null_ _null_ _null_ upper - _null_ )); +DATA(insert OID = 871 ( upper PGNSP PGUID 12 f f t f i 1 25 "25" _null_ _null_ _null_ upper - _null_ )); DESCR("uppercase"); -DATA(insert OID = 872 ( initcap PGNSP PGUID 12 f f t f i 1 25 "25" _null_ _null_ _null_ initcap - _null_ )); +DATA(insert OID = 872 ( initcap PGNSP PGUID 12 f f t f i 1 25 "25" _null_ _null_ _null_ initcap - _null_ )); DESCR("capitalize each word"); DATA(insert OID = 873 ( lpad PGNSP PGUID 12 f f t f i 3 25 "25 23 25" _null_ _null_ _null_ lpad - _null_ )); DESCR("left-pad string to length"); @@ -2205,15 +2205,15 @@ DATA(insert OID = 879 ( lpad PGNSP PGUID 14 f f t f i 2 25 "25 23" _null_ DESCR("left-pad string to length"); DATA(insert OID = 880 ( rpad PGNSP PGUID 14 f f t f i 2 25 "25 23" _null_ _null_ _null_ "select pg_catalog.rpad($1, $2, '' '')" - _null_ )); DESCR("right-pad string to length"); -DATA(insert OID = 881 ( ltrim PGNSP PGUID 12 f f t f i 1 25 "25" _null_ _null_ _null_ ltrim1 - _null_ )); +DATA(insert OID = 881 ( ltrim PGNSP PGUID 12 f f t f i 1 25 "25" _null_ _null_ _null_ ltrim1 - _null_ )); DESCR("trim spaces from left end of string"); -DATA(insert OID = 882 ( rtrim PGNSP PGUID 12 f f t f i 1 25 "25" _null_ _null_ _null_ rtrim1 - _null_ )); +DATA(insert OID = 882 ( rtrim PGNSP PGUID 12 f f t f i 1 25 "25" _null_ _null_ _null_ rtrim1 - _null_ )); DESCR("trim spaces from right end of string"); DATA(insert OID = 883 ( substr PGNSP PGUID 12 f f t f i 2 25 "25 23" _null_ _null_ _null_ text_substr_no_len - _null_ )); DESCR("return portion of string"); DATA(insert OID = 884 ( btrim PGNSP PGUID 12 f f t f i 2 25 "25 25" _null_ _null_ _null_ btrim - _null_ )); DESCR("trim selected characters from both ends of string"); -DATA(insert OID = 885 ( btrim PGNSP PGUID 12 f f t f i 1 25 "25" _null_ _null_ _null_ btrim1 - _null_ )); +DATA(insert OID = 885 ( btrim PGNSP PGUID 12 f f t f i 1 25 "25" _null_ _null_ _null_ btrim1 - _null_ )); DESCR("trim spaces from both ends of string"); DATA(insert OID = 936 ( substring PGNSP PGUID 12 f f t f i 3 25 "25 23 23" _null_ _null_ _null_ text_substr - _null_ )); @@ -2224,13 +2224,13 @@ DATA(insert OID = 2087 ( replace PGNSP PGUID 12 f f t f i 3 25 "25 25 25" _n DESCR("replace all occurrences of old_substr with new_substr in string"); DATA(insert OID = 2284 ( regexp_replace PGNSP PGUID 12 f f t f i 3 25 "25 25 25" _null_ _null_ _null_ textregexreplace_noopt - _null_ )); DESCR("replace text using regexp"); -DATA(insert OID = 2285 ( regexp_replace PGNSP PGUID 12 f f t f i 4 25 "25 25 25 25" _null_ _null_ _null_ textregexreplace - _null_ )); +DATA(insert OID = 2285 ( regexp_replace PGNSP PGUID 12 f f t f i 4 25 "25 25 25 25" _null_ _null_ _null_ textregexreplace - _null_ )); DESCR("replace text using regexp"); DATA(insert OID = 2088 ( split_part PGNSP PGUID 12 f f t f i 3 25 "25 25 23" _null_ _null_ _null_ split_text - _null_ )); DESCR("split string by field_sep and return field_num"); -DATA(insert OID = 2089 ( to_hex PGNSP PGUID 12 f f t f i 1 25 "23" _null_ _null_ _null_ to_hex32 - _null_ )); +DATA(insert OID = 2089 ( to_hex PGNSP PGUID 12 f f t f i 1 25 "23" _null_ _null_ _null_ to_hex32 - _null_ )); DESCR("convert int4 number to hex"); -DATA(insert OID = 2090 ( to_hex PGNSP PGUID 12 f f t f i 1 25 "20" _null_ _null_ _null_ to_hex64 - _null_ )); +DATA(insert OID = 2090 ( to_hex PGNSP PGUID 12 f f t f i 1 25 "20" _null_ _null_ _null_ to_hex64 - _null_ )); DESCR("convert int8 number to hex"); /* for character set encoding support */ @@ -2252,10 +2252,10 @@ DESCR("convert string with specified encoding names"); DATA(insert OID = 1619 ( convert_using PGNSP PGUID 12 f f t f s 2 25 "25 25" _null_ _null_ _null_ pg_convert_using - _null_ )); DESCR("convert string with specified conversion name"); -DATA(insert OID = 1264 ( pg_char_to_encoding PGNSP PGUID 12 f f t f s 1 23 "19" _null_ _null_ _null_ PG_char_to_encoding - _null_ )); +DATA(insert OID = 1264 ( pg_char_to_encoding PGNSP PGUID 12 f f t f s 1 23 "19" _null_ _null_ _null_ PG_char_to_encoding - _null_ )); DESCR("convert encoding name to encoding id"); -DATA(insert OID = 1597 ( pg_encoding_to_char PGNSP PGUID 12 f f t f s 1 19 "23" _null_ _null_ _null_ PG_encoding_to_char - _null_ )); +DATA(insert OID = 1597 ( pg_encoding_to_char PGNSP PGUID 12 f f t f s 1 19 "23" _null_ _null_ _null_ PG_encoding_to_char - _null_ )); DESCR("convert encoding id to encoding name"); DATA(insert OID = 1638 ( oidgt PGNSP PGUID 12 f f t f i 2 16 "26 26" _null_ _null_ _null_ oidgt - _null_ )); @@ -2264,65 +2264,65 @@ DATA(insert OID = 1639 ( oidge PGNSP PGUID 12 f f t f i 2 16 "26 26" _nul DESCR("greater-than-or-equal"); /* System-view support functions */ -DATA(insert OID = 1573 ( pg_get_ruledef PGNSP PGUID 12 f f t f s 1 25 "26" _null_ _null_ _null_ pg_get_ruledef - _null_ )); +DATA(insert OID = 1573 ( pg_get_ruledef PGNSP PGUID 12 f f t f s 1 25 "26" _null_ _null_ _null_ pg_get_ruledef - _null_ )); DESCR("source text of a rule"); -DATA(insert OID = 1640 ( pg_get_viewdef PGNSP PGUID 12 f f t f s 1 25 "25" _null_ _null_ _null_ pg_get_viewdef_name - _null_ )); +DATA(insert OID = 1640 ( pg_get_viewdef PGNSP PGUID 12 f f t f s 1 25 "25" _null_ _null_ _null_ pg_get_viewdef_name - _null_ )); DESCR("select statement of a view"); -DATA(insert OID = 1641 ( pg_get_viewdef PGNSP PGUID 12 f f t f s 1 25 "26" _null_ _null_ _null_ pg_get_viewdef - _null_ )); +DATA(insert OID = 1641 ( pg_get_viewdef PGNSP PGUID 12 f f t f s 1 25 "26" _null_ _null_ _null_ pg_get_viewdef - _null_ )); DESCR("select statement of a view"); -DATA(insert OID = 1642 ( pg_get_userbyid PGNSP PGUID 12 f f t f s 1 19 "26" _null_ _null_ _null_ pg_get_userbyid - _null_ )); +DATA(insert OID = 1642 ( pg_get_userbyid PGNSP PGUID 12 f f t f s 1 19 "26" _null_ _null_ _null_ pg_get_userbyid - _null_ )); DESCR("role name by OID (with fallback)"); -DATA(insert OID = 1643 ( pg_get_indexdef PGNSP PGUID 12 f f t f s 1 25 "26" _null_ _null_ _null_ pg_get_indexdef - _null_ )); +DATA(insert OID = 1643 ( pg_get_indexdef PGNSP PGUID 12 f f t f s 1 25 "26" _null_ _null_ _null_ pg_get_indexdef - _null_ )); DESCR("index description"); -DATA(insert OID = 1662 ( pg_get_triggerdef PGNSP PGUID 12 f f t f s 1 25 "26" _null_ _null_ _null_ pg_get_triggerdef - _null_ )); +DATA(insert OID = 1662 ( pg_get_triggerdef PGNSP PGUID 12 f f t f s 1 25 "26" _null_ _null_ _null_ pg_get_triggerdef - _null_ )); DESCR("trigger description"); -DATA(insert OID = 1387 ( pg_get_constraintdef PGNSP PGUID 12 f f t f s 1 25 "26" _null_ _null_ _null_ pg_get_constraintdef - _null_ )); +DATA(insert OID = 1387 ( pg_get_constraintdef PGNSP PGUID 12 f f t f s 1 25 "26" _null_ _null_ _null_ pg_get_constraintdef - _null_ )); DESCR("constraint description"); DATA(insert OID = 1716 ( pg_get_expr PGNSP PGUID 12 f f t f s 2 25 "25 26" _null_ _null_ _null_ pg_get_expr - _null_ )); DESCR("deparse an encoded expression"); -DATA(insert OID = 1665 ( pg_get_serial_sequence PGNSP PGUID 12 f f t f s 2 25 "25 25" _null_ _null_ _null_ pg_get_serial_sequence - _null_ )); +DATA(insert OID = 1665 ( pg_get_serial_sequence PGNSP PGUID 12 f f t f s 2 25 "25 25" _null_ _null_ _null_ pg_get_serial_sequence - _null_ )); DESCR("name of sequence for a serial column"); /* Generic referential integrity constraint triggers */ -DATA(insert OID = 1644 ( RI_FKey_check_ins PGNSP PGUID 12 f f t f v 0 2279 "" _null_ _null_ _null_ RI_FKey_check_ins - _null_ )); +DATA(insert OID = 1644 ( RI_FKey_check_ins PGNSP PGUID 12 f f t f v 0 2279 "" _null_ _null_ _null_ RI_FKey_check_ins - _null_ )); DESCR("referential integrity FOREIGN KEY ... REFERENCES"); -DATA(insert OID = 1645 ( RI_FKey_check_upd PGNSP PGUID 12 f f t f v 0 2279 "" _null_ _null_ _null_ RI_FKey_check_upd - _null_ )); +DATA(insert OID = 1645 ( RI_FKey_check_upd PGNSP PGUID 12 f f t f v 0 2279 "" _null_ _null_ _null_ RI_FKey_check_upd - _null_ )); DESCR("referential integrity FOREIGN KEY ... REFERENCES"); -DATA(insert OID = 1646 ( RI_FKey_cascade_del PGNSP PGUID 12 f f t f v 0 2279 "" _null_ _null_ _null_ RI_FKey_cascade_del - _null_ )); +DATA(insert OID = 1646 ( RI_FKey_cascade_del PGNSP PGUID 12 f f t f v 0 2279 "" _null_ _null_ _null_ RI_FKey_cascade_del - _null_ )); DESCR("referential integrity ON DELETE CASCADE"); -DATA(insert OID = 1647 ( RI_FKey_cascade_upd PGNSP PGUID 12 f f t f v 0 2279 "" _null_ _null_ _null_ RI_FKey_cascade_upd - _null_ )); +DATA(insert OID = 1647 ( RI_FKey_cascade_upd PGNSP PGUID 12 f f t f v 0 2279 "" _null_ _null_ _null_ RI_FKey_cascade_upd - _null_ )); DESCR("referential integrity ON UPDATE CASCADE"); -DATA(insert OID = 1648 ( RI_FKey_restrict_del PGNSP PGUID 12 f f t f v 0 2279 "" _null_ _null_ _null_ RI_FKey_restrict_del - _null_ )); +DATA(insert OID = 1648 ( RI_FKey_restrict_del PGNSP PGUID 12 f f t f v 0 2279 "" _null_ _null_ _null_ RI_FKey_restrict_del - _null_ )); DESCR("referential integrity ON DELETE RESTRICT"); -DATA(insert OID = 1649 ( RI_FKey_restrict_upd PGNSP PGUID 12 f f t f v 0 2279 "" _null_ _null_ _null_ RI_FKey_restrict_upd - _null_ )); +DATA(insert OID = 1649 ( RI_FKey_restrict_upd PGNSP PGUID 12 f f t f v 0 2279 "" _null_ _null_ _null_ RI_FKey_restrict_upd - _null_ )); DESCR("referential integrity ON UPDATE RESTRICT"); -DATA(insert OID = 1650 ( RI_FKey_setnull_del PGNSP PGUID 12 f f t f v 0 2279 "" _null_ _null_ _null_ RI_FKey_setnull_del - _null_ )); +DATA(insert OID = 1650 ( RI_FKey_setnull_del PGNSP PGUID 12 f f t f v 0 2279 "" _null_ _null_ _null_ RI_FKey_setnull_del - _null_ )); DESCR("referential integrity ON DELETE SET NULL"); -DATA(insert OID = 1651 ( RI_FKey_setnull_upd PGNSP PGUID 12 f f t f v 0 2279 "" _null_ _null_ _null_ RI_FKey_setnull_upd - _null_ )); +DATA(insert OID = 1651 ( RI_FKey_setnull_upd PGNSP PGUID 12 f f t f v 0 2279 "" _null_ _null_ _null_ RI_FKey_setnull_upd - _null_ )); DESCR("referential integrity ON UPDATE SET NULL"); DATA(insert OID = 1652 ( RI_FKey_setdefault_del PGNSP PGUID 12 f f t f v 0 2279 "" _null_ _null_ _null_ RI_FKey_setdefault_del - _null_ )); DESCR("referential integrity ON DELETE SET DEFAULT"); DATA(insert OID = 1653 ( RI_FKey_setdefault_upd PGNSP PGUID 12 f f t f v 0 2279 "" _null_ _null_ _null_ RI_FKey_setdefault_upd - _null_ )); DESCR("referential integrity ON UPDATE SET DEFAULT"); -DATA(insert OID = 1654 ( RI_FKey_noaction_del PGNSP PGUID 12 f f t f v 0 2279 "" _null_ _null_ _null_ RI_FKey_noaction_del - _null_ )); +DATA(insert OID = 1654 ( RI_FKey_noaction_del PGNSP PGUID 12 f f t f v 0 2279 "" _null_ _null_ _null_ RI_FKey_noaction_del - _null_ )); DESCR("referential integrity ON DELETE NO ACTION"); -DATA(insert OID = 1655 ( RI_FKey_noaction_upd PGNSP PGUID 12 f f t f v 0 2279 "" _null_ _null_ _null_ RI_FKey_noaction_upd - _null_ )); +DATA(insert OID = 1655 ( RI_FKey_noaction_upd PGNSP PGUID 12 f f t f v 0 2279 "" _null_ _null_ _null_ RI_FKey_noaction_upd - _null_ )); DESCR("referential integrity ON UPDATE NO ACTION"); -DATA(insert OID = 1666 ( varbiteq PGNSP PGUID 12 f f t f i 2 16 "1562 1562" _null_ _null_ _null_ biteq - _null_ )); +DATA(insert OID = 1666 ( varbiteq PGNSP PGUID 12 f f t f i 2 16 "1562 1562" _null_ _null_ _null_ biteq - _null_ )); DESCR("equal"); -DATA(insert OID = 1667 ( varbitne PGNSP PGUID 12 f f t f i 2 16 "1562 1562" _null_ _null_ _null_ bitne - _null_ )); +DATA(insert OID = 1667 ( varbitne PGNSP PGUID 12 f f t f i 2 16 "1562 1562" _null_ _null_ _null_ bitne - _null_ )); DESCR("not equal"); -DATA(insert OID = 1668 ( varbitge PGNSP PGUID 12 f f t f i 2 16 "1562 1562" _null_ _null_ _null_ bitge - _null_ )); +DATA(insert OID = 1668 ( varbitge PGNSP PGUID 12 f f t f i 2 16 "1562 1562" _null_ _null_ _null_ bitge - _null_ )); DESCR("greater than or equal"); -DATA(insert OID = 1669 ( varbitgt PGNSP PGUID 12 f f t f i 2 16 "1562 1562" _null_ _null_ _null_ bitgt - _null_ )); +DATA(insert OID = 1669 ( varbitgt PGNSP PGUID 12 f f t f i 2 16 "1562 1562" _null_ _null_ _null_ bitgt - _null_ )); DESCR("greater than"); -DATA(insert OID = 1670 ( varbitle PGNSP PGUID 12 f f t f i 2 16 "1562 1562" _null_ _null_ _null_ bitle - _null_ )); +DATA(insert OID = 1670 ( varbitle PGNSP PGUID 12 f f t f i 2 16 "1562 1562" _null_ _null_ _null_ bitle - _null_ )); DESCR("less than or equal"); -DATA(insert OID = 1671 ( varbitlt PGNSP PGUID 12 f f t f i 2 16 "1562 1562" _null_ _null_ _null_ bitlt - _null_ )); +DATA(insert OID = 1671 ( varbitlt PGNSP PGUID 12 f f t f i 2 16 "1562 1562" _null_ _null_ _null_ bitlt - _null_ )); DESCR("less than"); -DATA(insert OID = 1672 ( varbitcmp PGNSP PGUID 12 f f t f i 2 23 "1562 1562" _null_ _null_ _null_ bitcmp - _null_ )); +DATA(insert OID = 1672 ( varbitcmp PGNSP PGUID 12 f f t f i 2 23 "1562 1562" _null_ _null_ _null_ bitcmp - _null_ )); DESCR("compare"); DATA(insert OID = 1673 ( bitand PGNSP PGUID 12 f f t f i 2 1560 "1560 1560" _null_ _null_ _null_ bitand - _null_ )); @@ -2331,11 +2331,11 @@ DATA(insert OID = 1674 ( bitor PGNSP PGUID 12 f f t f i 2 1560 "1560 1560" _ DESCR("bitwise or"); DATA(insert OID = 1675 ( bitxor PGNSP PGUID 12 f f t f i 2 1560 "1560 1560" _null_ _null_ _null_ bitxor - _null_ )); DESCR("bitwise exclusive or"); -DATA(insert OID = 1676 ( bitnot PGNSP PGUID 12 f f t f i 1 1560 "1560" _null_ _null_ _null_ bitnot - _null_ )); +DATA(insert OID = 1676 ( bitnot PGNSP PGUID 12 f f t f i 1 1560 "1560" _null_ _null_ _null_ bitnot - _null_ )); DESCR("bitwise negation"); -DATA(insert OID = 1677 ( bitshiftleft PGNSP PGUID 12 f f t f i 2 1560 "1560 23" _null_ _null_ _null_ bitshiftleft - _null_ )); +DATA(insert OID = 1677 ( bitshiftleft PGNSP PGUID 12 f f t f i 2 1560 "1560 23" _null_ _null_ _null_ bitshiftleft - _null_ )); DESCR("bitwise left shift"); -DATA(insert OID = 1678 ( bitshiftright PGNSP PGUID 12 f f t f i 2 1560 "1560 23" _null_ _null_ _null_ bitshiftright - _null_ )); +DATA(insert OID = 1678 ( bitshiftright PGNSP PGUID 12 f f t f i 2 1560 "1560 23" _null_ _null_ _null_ bitshiftright - _null_ )); DESCR("bitwise right shift"); DATA(insert OID = 1679 ( bitcat PGNSP PGUID 12 f f t f i 2 1560 "1560 1560" _null_ _null_ _null_ bitcat - _null_ )); DESCR("bitwise concatenation"); @@ -2357,14 +2357,14 @@ DESCR("adjust varbit() to typmod length"); DATA(insert OID = 1698 ( position PGNSP PGUID 12 f f t f i 2 23 "1560 1560" _null_ _null_ _null_ bitposition - _null_ )); DESCR("return position of sub-bitstring"); -DATA(insert OID = 1699 ( substring PGNSP PGUID 14 f f t f i 2 1560 "1560 23" _null_ _null_ _null_ "select pg_catalog.substring($1, $2, -1)" - _null_ )); +DATA(insert OID = 1699 ( substring PGNSP PGUID 14 f f t f i 2 1560 "1560 23" _null_ _null_ _null_ "select pg_catalog.substring($1, $2, -1)" - _null_ )); DESCR("return portion of bitstring"); /* for mac type support */ -DATA(insert OID = 436 ( macaddr_in PGNSP PGUID 12 f f t f i 1 829 "2275" _null_ _null_ _null_ macaddr_in - _null_ )); +DATA(insert OID = 436 ( macaddr_in PGNSP PGUID 12 f f t f i 1 829 "2275" _null_ _null_ _null_ macaddr_in - _null_ )); DESCR("I/O"); -DATA(insert OID = 437 ( macaddr_out PGNSP PGUID 12 f f t f i 1 2275 "829" _null_ _null_ _null_ macaddr_out - _null_ )); +DATA(insert OID = 437 ( macaddr_out PGNSP PGUID 12 f f t f i 1 2275 "829" _null_ _null_ _null_ macaddr_out - _null_ )); DESCR("I/O"); DATA(insert OID = 752 ( text PGNSP PGUID 12 f f t f i 1 25 "829" _null_ _null_ _null_ macaddr_text - _null_ )); @@ -2390,15 +2390,15 @@ DATA(insert OID = 836 ( macaddr_cmp PGNSP PGUID 12 f f t f i 2 23 "829 829" _n DESCR("less-equal-greater"); /* for inet type support */ -DATA(insert OID = 910 ( inet_in PGNSP PGUID 12 f f t f i 1 869 "2275" _null_ _null_ _null_ inet_in - _null_ )); +DATA(insert OID = 910 ( inet_in PGNSP PGUID 12 f f t f i 1 869 "2275" _null_ _null_ _null_ inet_in - _null_ )); DESCR("I/O"); -DATA(insert OID = 911 ( inet_out PGNSP PGUID 12 f f t f i 1 2275 "869" _null_ _null_ _null_ inet_out - _null_ )); +DATA(insert OID = 911 ( inet_out PGNSP PGUID 12 f f t f i 1 2275 "869" _null_ _null_ _null_ inet_out - _null_ )); DESCR("I/O"); /* for cidr type support */ -DATA(insert OID = 1267 ( cidr_in PGNSP PGUID 12 f f t f i 1 650 "2275" _null_ _null_ _null_ cidr_in - _null_ )); +DATA(insert OID = 1267 ( cidr_in PGNSP PGUID 12 f f t f i 1 650 "2275" _null_ _null_ _null_ cidr_in - _null_ )); DESCR("I/O"); -DATA(insert OID = 1427 ( cidr_out PGNSP PGUID 12 f f t f i 1 2275 "650" _null_ _null_ _null_ cidr_out - _null_ )); +DATA(insert OID = 1427 ( cidr_out PGNSP PGUID 12 f f t f i 1 2275 "650" _null_ _null_ _null_ cidr_out - _null_ )); DESCR("I/O"); /* these are used for both inet and cidr */ @@ -2451,11 +2451,11 @@ DESCR("text to cidr"); DATA(insert OID = 1715 ( set_masklen PGNSP PGUID 12 f f t f i 2 869 "869 23" _null_ _null_ _null_ inet_set_masklen - _null_ )); DESCR("change the netmask of an inet"); -DATA(insert OID = 2196 ( inet_client_addr PGNSP PGUID 12 f f f f s 0 869 "" _null_ _null_ _null_ inet_client_addr - _null_ )); +DATA(insert OID = 2196 ( inet_client_addr PGNSP PGUID 12 f f f f s 0 869 "" _null_ _null_ _null_ inet_client_addr - _null_ )); DESCR("INET address of the client"); DATA(insert OID = 2197 ( inet_client_port PGNSP PGUID 12 f f f f s 0 23 "" _null_ _null_ _null_ inet_client_port - _null_ )); DESCR("client's port number for this connection"); -DATA(insert OID = 2198 ( inet_server_addr PGNSP PGUID 12 f f f f s 0 869 "" _null_ _null_ _null_ inet_server_addr - _null_ )); +DATA(insert OID = 2198 ( inet_server_addr PGNSP PGUID 12 f f f f s 0 869 "" _null_ _null_ _null_ inet_server_addr - _null_ )); DESCR("INET address of the server"); DATA(insert OID = 2199 ( inet_server_port PGNSP PGUID 12 f f f f s 0 23 "" _null_ _null_ _null_ inet_server_port - _null_ )); DESCR("server's port number for this connection"); @@ -2468,11 +2468,11 @@ DESCR("(internal)"); DATA(insert OID = 1690 ( time_mi_time PGNSP PGUID 12 f f t f i 2 1186 "1083 1083" _null_ _null_ _null_ time_mi_time - _null_ )); DESCR("minus"); -DATA(insert OID = 1691 ( boolle PGNSP PGUID 12 f f t f i 2 16 "16 16" _null_ _null_ _null_ boolle - _null_ )); +DATA(insert OID = 1691 ( boolle PGNSP PGUID 12 f f t f i 2 16 "16 16" _null_ _null_ _null_ boolle - _null_ )); DESCR("less-than-or-equal"); -DATA(insert OID = 1692 ( boolge PGNSP PGUID 12 f f t f i 2 16 "16 16" _null_ _null_ _null_ boolge - _null_ )); +DATA(insert OID = 1692 ( boolge PGNSP PGUID 12 f f t f i 2 16 "16 16" _null_ _null_ _null_ boolge - _null_ )); DESCR("greater-than-or-equal"); -DATA(insert OID = 1693 ( btboolcmp PGNSP PGUID 12 f f t f i 2 23 "16 16" _null_ _null_ _null_ btboolcmp - _null_ )); +DATA(insert OID = 1693 ( btboolcmp PGNSP PGUID 12 f f t f i 2 23 "16 16" _null_ _null_ _null_ btboolcmp - _null_ )); DESCR("btree less-equal-greater"); DATA(insert OID = 1696 ( timetz_hash PGNSP PGUID 12 f f t f i 1 23 "1266" _null_ _null_ _null_ timetz_hash - _null_ )); @@ -2484,41 +2484,41 @@ DESCR("hash"); /* OID's 1700 - 1799 NUMERIC data type */ DATA(insert OID = 1701 ( numeric_in PGNSP PGUID 12 f f t f i 3 1700 "2275 26 23" _null_ _null_ _null_ numeric_in - _null_ )); DESCR("I/O"); -DATA(insert OID = 1702 ( numeric_out PGNSP PGUID 12 f f t f i 1 2275 "1700" _null_ _null_ _null_ numeric_out - _null_ )); +DATA(insert OID = 1702 ( numeric_out PGNSP PGUID 12 f f t f i 1 2275 "1700" _null_ _null_ _null_ numeric_out - _null_ )); DESCR("I/O"); -DATA(insert OID = 1703 ( numeric PGNSP PGUID 12 f f t f i 2 1700 "1700 23" _null_ _null_ _null_ numeric - _null_ )); +DATA(insert OID = 1703 ( numeric PGNSP PGUID 12 f f t f i 2 1700 "1700 23" _null_ _null_ _null_ numeric - _null_ )); DESCR("adjust numeric to typmod precision/scale"); -DATA(insert OID = 1704 ( numeric_abs PGNSP PGUID 12 f f t f i 1 1700 "1700" _null_ _null_ _null_ numeric_abs - _null_ )); +DATA(insert OID = 1704 ( numeric_abs PGNSP PGUID 12 f f t f i 1 1700 "1700" _null_ _null_ _null_ numeric_abs - _null_ )); DESCR("absolute value"); -DATA(insert OID = 1705 ( abs PGNSP PGUID 12 f f t f i 1 1700 "1700" _null_ _null_ _null_ numeric_abs - _null_ )); +DATA(insert OID = 1705 ( abs PGNSP PGUID 12 f f t f i 1 1700 "1700" _null_ _null_ _null_ numeric_abs - _null_ )); DESCR("absolute value"); -DATA(insert OID = 1706 ( sign PGNSP PGUID 12 f f t f i 1 1700 "1700" _null_ _null_ _null_ numeric_sign - _null_ )); +DATA(insert OID = 1706 ( sign PGNSP PGUID 12 f f t f i 1 1700 "1700" _null_ _null_ _null_ numeric_sign - _null_ )); DESCR("sign of value"); -DATA(insert OID = 1707 ( round PGNSP PGUID 12 f f t f i 2 1700 "1700 23" _null_ _null_ _null_ numeric_round - _null_ )); +DATA(insert OID = 1707 ( round PGNSP PGUID 12 f f t f i 2 1700 "1700 23" _null_ _null_ _null_ numeric_round - _null_ )); DESCR("value rounded to 'scale'"); -DATA(insert OID = 1708 ( round PGNSP PGUID 14 f f t f i 1 1700 "1700" _null_ _null_ _null_ "select pg_catalog.round($1,0)" - _null_ )); +DATA(insert OID = 1708 ( round PGNSP PGUID 14 f f t f i 1 1700 "1700" _null_ _null_ _null_ "select pg_catalog.round($1,0)" - _null_ )); DESCR("value rounded to 'scale' of zero"); -DATA(insert OID = 1709 ( trunc PGNSP PGUID 12 f f t f i 2 1700 "1700 23" _null_ _null_ _null_ numeric_trunc - _null_ )); +DATA(insert OID = 1709 ( trunc PGNSP PGUID 12 f f t f i 2 1700 "1700 23" _null_ _null_ _null_ numeric_trunc - _null_ )); DESCR("value truncated to 'scale'"); -DATA(insert OID = 1710 ( trunc PGNSP PGUID 14 f f t f i 1 1700 "1700" _null_ _null_ _null_ "select pg_catalog.trunc($1,0)" - _null_ )); +DATA(insert OID = 1710 ( trunc PGNSP PGUID 14 f f t f i 1 1700 "1700" _null_ _null_ _null_ "select pg_catalog.trunc($1,0)" - _null_ )); DESCR("value truncated to 'scale' of zero"); -DATA(insert OID = 1711 ( ceil PGNSP PGUID 12 f f t f i 1 1700 "1700" _null_ _null_ _null_ numeric_ceil - _null_ )); +DATA(insert OID = 1711 ( ceil PGNSP PGUID 12 f f t f i 1 1700 "1700" _null_ _null_ _null_ numeric_ceil - _null_ )); DESCR("smallest integer >= value"); -DATA(insert OID = 2167 ( ceiling PGNSP PGUID 12 f f t f i 1 1700 "1700" _null_ _null_ _null_ numeric_ceil - _null_ )); +DATA(insert OID = 2167 ( ceiling PGNSP PGUID 12 f f t f i 1 1700 "1700" _null_ _null_ _null_ numeric_ceil - _null_ )); DESCR("smallest integer >= value"); -DATA(insert OID = 1712 ( floor PGNSP PGUID 12 f f t f i 1 1700 "1700" _null_ _null_ _null_ numeric_floor - _null_ )); +DATA(insert OID = 1712 ( floor PGNSP PGUID 12 f f t f i 1 1700 "1700" _null_ _null_ _null_ numeric_floor - _null_ )); DESCR("largest integer <= value"); -DATA(insert OID = 1718 ( numeric_eq PGNSP PGUID 12 f f t f i 2 16 "1700 1700" _null_ _null_ _null_ numeric_eq - _null_ )); +DATA(insert OID = 1718 ( numeric_eq PGNSP PGUID 12 f f t f i 2 16 "1700 1700" _null_ _null_ _null_ numeric_eq - _null_ )); DESCR("equal"); -DATA(insert OID = 1719 ( numeric_ne PGNSP PGUID 12 f f t f i 2 16 "1700 1700" _null_ _null_ _null_ numeric_ne - _null_ )); +DATA(insert OID = 1719 ( numeric_ne PGNSP PGUID 12 f f t f i 2 16 "1700 1700" _null_ _null_ _null_ numeric_ne - _null_ )); DESCR("not equal"); -DATA(insert OID = 1720 ( numeric_gt PGNSP PGUID 12 f f t f i 2 16 "1700 1700" _null_ _null_ _null_ numeric_gt - _null_ )); +DATA(insert OID = 1720 ( numeric_gt PGNSP PGUID 12 f f t f i 2 16 "1700 1700" _null_ _null_ _null_ numeric_gt - _null_ )); DESCR("greater-than"); -DATA(insert OID = 1721 ( numeric_ge PGNSP PGUID 12 f f t f i 2 16 "1700 1700" _null_ _null_ _null_ numeric_ge - _null_ )); +DATA(insert OID = 1721 ( numeric_ge PGNSP PGUID 12 f f t f i 2 16 "1700 1700" _null_ _null_ _null_ numeric_ge - _null_ )); DESCR("greater-than-or-equal"); -DATA(insert OID = 1722 ( numeric_lt PGNSP PGUID 12 f f t f i 2 16 "1700 1700" _null_ _null_ _null_ numeric_lt - _null_ )); +DATA(insert OID = 1722 ( numeric_lt PGNSP PGUID 12 f f t f i 2 16 "1700 1700" _null_ _null_ _null_ numeric_lt - _null_ )); DESCR("less-than"); -DATA(insert OID = 1723 ( numeric_le PGNSP PGUID 12 f f t f i 2 16 "1700 1700" _null_ _null_ _null_ numeric_le - _null_ )); +DATA(insert OID = 1723 ( numeric_le PGNSP PGUID 12 f f t f i 2 16 "1700 1700" _null_ _null_ _null_ numeric_le - _null_ )); DESCR("less-than-or-equal"); DATA(insert OID = 1724 ( numeric_add PGNSP PGUID 12 f f t f i 2 1700 "1700 1700" _null_ _null_ _null_ numeric_add - _null_ )); DESCR("add"); @@ -2532,17 +2532,17 @@ DATA(insert OID = 1728 ( mod PGNSP PGUID 12 f f t f i 2 1700 "1700 1700" _nu DESCR("modulus"); DATA(insert OID = 1729 ( numeric_mod PGNSP PGUID 12 f f t f i 2 1700 "1700 1700" _null_ _null_ _null_ numeric_mod - _null_ )); DESCR("modulus"); -DATA(insert OID = 1730 ( sqrt PGNSP PGUID 12 f f t f i 1 1700 "1700" _null_ _null_ _null_ numeric_sqrt - _null_ )); +DATA(insert OID = 1730 ( sqrt PGNSP PGUID 12 f f t f i 1 1700 "1700" _null_ _null_ _null_ numeric_sqrt - _null_ )); DESCR("square root"); -DATA(insert OID = 1731 ( numeric_sqrt PGNSP PGUID 12 f f t f i 1 1700 "1700" _null_ _null_ _null_ numeric_sqrt - _null_ )); +DATA(insert OID = 1731 ( numeric_sqrt PGNSP PGUID 12 f f t f i 1 1700 "1700" _null_ _null_ _null_ numeric_sqrt - _null_ )); DESCR("square root"); -DATA(insert OID = 1732 ( exp PGNSP PGUID 12 f f t f i 1 1700 "1700" _null_ _null_ _null_ numeric_exp - _null_ )); +DATA(insert OID = 1732 ( exp PGNSP PGUID 12 f f t f i 1 1700 "1700" _null_ _null_ _null_ numeric_exp - _null_ )); DESCR("e raised to the power of n"); -DATA(insert OID = 1733 ( numeric_exp PGNSP PGUID 12 f f t f i 1 1700 "1700" _null_ _null_ _null_ numeric_exp - _null_ )); +DATA(insert OID = 1733 ( numeric_exp PGNSP PGUID 12 f f t f i 1 1700 "1700" _null_ _null_ _null_ numeric_exp - _null_ )); DESCR("e raised to the power of n"); -DATA(insert OID = 1734 ( ln PGNSP PGUID 12 f f t f i 1 1700 "1700" _null_ _null_ _null_ numeric_ln - _null_ )); +DATA(insert OID = 1734 ( ln PGNSP PGUID 12 f f t f i 1 1700 "1700" _null_ _null_ _null_ numeric_ln - _null_ )); DESCR("natural logarithm of n"); -DATA(insert OID = 1735 ( numeric_ln PGNSP PGUID 12 f f t f i 1 1700 "1700" _null_ _null_ _null_ numeric_ln - _null_ )); +DATA(insert OID = 1735 ( numeric_ln PGNSP PGUID 12 f f t f i 1 1700 "1700" _null_ _null_ _null_ numeric_ln - _null_ )); DESCR("natural logarithm of n"); DATA(insert OID = 1736 ( log PGNSP PGUID 12 f f t f i 2 1700 "1700 1700" _null_ _null_ _null_ numeric_log - _null_ )); DESCR("logarithm base m of n"); @@ -2556,19 +2556,19 @@ DATA(insert OID = 1739 ( numeric_power PGNSP PGUID 12 f f t f i 2 1700 "1700 1 DESCR("m raised to the power of n"); DATA(insert OID = 1740 ( numeric PGNSP PGUID 12 f f t f i 1 1700 "23" _null_ _null_ _null_ int4_numeric - _null_ )); DESCR("(internal)"); -DATA(insert OID = 1741 ( log PGNSP PGUID 14 f f t f i 1 1700 "1700" _null_ _null_ _null_ "select pg_catalog.log(10, $1)" - _null_ )); +DATA(insert OID = 1741 ( log PGNSP PGUID 14 f f t f i 1 1700 "1700" _null_ _null_ _null_ "select pg_catalog.log(10, $1)" - _null_ )); DESCR("logarithm base 10 of n"); -DATA(insert OID = 1742 ( numeric PGNSP PGUID 12 f f t f i 1 1700 "700" _null_ _null_ _null_ float4_numeric - _null_ )); +DATA(insert OID = 1742 ( numeric PGNSP PGUID 12 f f t f i 1 1700 "700" _null_ _null_ _null_ float4_numeric - _null_ )); DESCR("(internal)"); -DATA(insert OID = 1743 ( numeric PGNSP PGUID 12 f f t f i 1 1700 "701" _null_ _null_ _null_ float8_numeric - _null_ )); +DATA(insert OID = 1743 ( numeric PGNSP PGUID 12 f f t f i 1 1700 "701" _null_ _null_ _null_ float8_numeric - _null_ )); DESCR("(internal)"); DATA(insert OID = 1744 ( int4 PGNSP PGUID 12 f f t f i 1 23 "1700" _null_ _null_ _null_ numeric_int4 - _null_ )); DESCR("(internal)"); -DATA(insert OID = 1745 ( float4 PGNSP PGUID 12 f f t f i 1 700 "1700" _null_ _null_ _null_ numeric_float4 - _null_ )); +DATA(insert OID = 1745 ( float4 PGNSP PGUID 12 f f t f i 1 700 "1700" _null_ _null_ _null_ numeric_float4 - _null_ )); DESCR("(internal)"); -DATA(insert OID = 1746 ( float8 PGNSP PGUID 12 f f t f i 1 701 "1700" _null_ _null_ _null_ numeric_float8 - _null_ )); +DATA(insert OID = 1746 ( float8 PGNSP PGUID 12 f f t f i 1 701 "1700" _null_ _null_ _null_ numeric_float8 - _null_ )); DESCR("(internal)"); -DATA(insert OID = 2170 ( width_bucket PGNSP PGUID 12 f f t f i 4 23 "1700 1700 1700 23" _null_ _null_ _null_ width_bucket_numeric - _null_ )); +DATA(insert OID = 2170 ( width_bucket PGNSP PGUID 12 f f t f i 4 23 "1700 1700 1700 23" _null_ _null_ _null_ width_bucket_numeric - _null_ )); DESCR("bucket number of operand in equidepth histogram"); DATA(insert OID = 1747 ( time_pl_interval PGNSP PGUID 12 f f t f i 2 1083 "1083 1186" _null_ _null_ _null_ time_pl_interval - _null_ )); @@ -2580,15 +2580,15 @@ DESCR("plus"); DATA(insert OID = 1750 ( timetz_mi_interval PGNSP PGUID 12 f f t f i 2 1266 "1266 1186" _null_ _null_ _null_ timetz_mi_interval - _null_ )); DESCR("minus"); -DATA(insert OID = 1764 ( numeric_inc PGNSP PGUID 12 f f t f i 1 1700 "1700" _null_ _null_ _null_ numeric_inc - _null_ )); +DATA(insert OID = 1764 ( numeric_inc PGNSP PGUID 12 f f t f i 1 1700 "1700" _null_ _null_ _null_ numeric_inc - _null_ )); DESCR("increment by one"); DATA(insert OID = 1766 ( numeric_smaller PGNSP PGUID 12 f f t f i 2 1700 "1700 1700" _null_ _null_ _null_ numeric_smaller - _null_ )); DESCR("smaller of two numbers"); DATA(insert OID = 1767 ( numeric_larger PGNSP PGUID 12 f f t f i 2 1700 "1700 1700" _null_ _null_ _null_ numeric_larger - _null_ )); DESCR("larger of two numbers"); -DATA(insert OID = 1769 ( numeric_cmp PGNSP PGUID 12 f f t f i 2 23 "1700 1700" _null_ _null_ _null_ numeric_cmp - _null_ )); +DATA(insert OID = 1769 ( numeric_cmp PGNSP PGUID 12 f f t f i 2 23 "1700 1700" _null_ _null_ _null_ numeric_cmp - _null_ )); DESCR("compare two numbers"); -DATA(insert OID = 1771 ( numeric_uminus PGNSP PGUID 12 f f t f i 1 1700 "1700" _null_ _null_ _null_ numeric_uminus - _null_ )); +DATA(insert OID = 1771 ( numeric_uminus PGNSP PGUID 12 f f t f i 1 1700 "1700" _null_ _null_ _null_ numeric_uminus - _null_ )); DESCR("negate"); DATA(insert OID = 1779 ( int8 PGNSP PGUID 12 f f t f i 1 20 "1700" _null_ _null_ _null_ numeric_int8 - _null_ )); DESCR("(internal)"); @@ -2604,9 +2604,9 @@ DATA(insert OID = 1770 ( to_char PGNSP PGUID 12 f f t f s 2 25 "1184 25" _null DESCR("format timestamp with time zone to text"); DATA(insert OID = 1772 ( to_char PGNSP PGUID 12 f f t f i 2 25 "1700 25" _null_ _null_ _null_ numeric_to_char - _null_ )); DESCR("format numeric to text"); -DATA(insert OID = 1773 ( to_char PGNSP PGUID 12 f f t f i 2 25 "23 25" _null_ _null_ _null_ int4_to_char - _null_ )); +DATA(insert OID = 1773 ( to_char PGNSP PGUID 12 f f t f i 2 25 "23 25" _null_ _null_ _null_ int4_to_char - _null_ )); DESCR("format int4 to text"); -DATA(insert OID = 1774 ( to_char PGNSP PGUID 12 f f t f i 2 25 "20 25" _null_ _null_ _null_ int8_to_char - _null_ )); +DATA(insert OID = 1774 ( to_char PGNSP PGUID 12 f f t f i 2 25 "20 25" _null_ _null_ _null_ int8_to_char - _null_ )); DESCR("format int8 to text"); DATA(insert OID = 1775 ( to_char PGNSP PGUID 12 f f t f i 2 25 "700 25" _null_ _null_ _null_ float4_to_char - _null_ )); DESCR("format float4 to text"); @@ -2680,7 +2680,7 @@ DATA(insert OID = 1831 ( float8_variance PGNSP PGUID 12 f f t f i 1 701 "1022" DESCR("VARIANCE aggregate final function"); DATA(insert OID = 1832 ( float8_stddev PGNSP PGUID 12 f f t f i 1 701 "1022" _null_ _null_ _null_ float8_stddev - _null_ )); DESCR("STDDEV aggregate final function"); -DATA(insert OID = 1833 ( numeric_accum PGNSP PGUID 12 f f t f i 2 1231 "1231 1700" _null_ _null_ _null_ numeric_accum - _null_ )); +DATA(insert OID = 1833 ( numeric_accum PGNSP PGUID 12 f f t f i 2 1231 "1231 1700" _null_ _null_ _null_ numeric_accum - _null_ )); DESCR("aggregate transition function"); DATA(insert OID = 1834 ( int2_accum PGNSP PGUID 12 f f t f i 2 1231 "1231 21" _null_ _null_ _null_ int2_accum - _null_ )); DESCR("aggregate transition function"); @@ -2688,11 +2688,11 @@ DATA(insert OID = 1835 ( int4_accum PGNSP PGUID 12 f f t f i 2 1231 "1231 23 DESCR("aggregate transition function"); DATA(insert OID = 1836 ( int8_accum PGNSP PGUID 12 f f t f i 2 1231 "1231 20" _null_ _null_ _null_ int8_accum - _null_ )); DESCR("aggregate transition function"); -DATA(insert OID = 1837 ( numeric_avg PGNSP PGUID 12 f f t f i 1 1700 "1231" _null_ _null_ _null_ numeric_avg - _null_ )); +DATA(insert OID = 1837 ( numeric_avg PGNSP PGUID 12 f f t f i 1 1700 "1231" _null_ _null_ _null_ numeric_avg - _null_ )); DESCR("AVG aggregate final function"); -DATA(insert OID = 1838 ( numeric_variance PGNSP PGUID 12 f f t f i 1 1700 "1231" _null_ _null_ _null_ numeric_variance - _null_ )); +DATA(insert OID = 1838 ( numeric_variance PGNSP PGUID 12 f f t f i 1 1700 "1231" _null_ _null_ _null_ numeric_variance - _null_ )); DESCR("VARIANCE aggregate final function"); -DATA(insert OID = 1839 ( numeric_stddev PGNSP PGUID 12 f f t f i 1 1700 "1231" _null_ _null_ _null_ numeric_stddev - _null_ )); +DATA(insert OID = 1839 ( numeric_stddev PGNSP PGUID 12 f f t f i 1 1700 "1231" _null_ _null_ _null_ numeric_stddev - _null_ )); DESCR("STDDEV aggregate final function"); DATA(insert OID = 1840 ( int2_sum PGNSP PGUID 12 f f f f i 2 20 "20 21" _null_ _null_ _null_ int2_sum - _null_ )); DESCR("SUM(int2) transition function"); @@ -2700,23 +2700,23 @@ DATA(insert OID = 1841 ( int4_sum PGNSP PGUID 12 f f f f i 2 20 "20 23" _nu DESCR("SUM(int4) transition function"); DATA(insert OID = 1842 ( int8_sum PGNSP PGUID 12 f f f f i 2 1700 "1700 20" _null_ _null_ _null_ int8_sum - _null_ )); DESCR("SUM(int8) transition function"); -DATA(insert OID = 1843 ( interval_accum PGNSP PGUID 12 f f t f i 2 1187 "1187 1186" _null_ _null_ _null_ interval_accum - _null_ )); +DATA(insert OID = 1843 ( interval_accum PGNSP PGUID 12 f f t f i 2 1187 "1187 1186" _null_ _null_ _null_ interval_accum - _null_ )); DESCR("aggregate transition function"); -DATA(insert OID = 1844 ( interval_avg PGNSP PGUID 12 f f t f i 1 1186 "1187" _null_ _null_ _null_ interval_avg - _null_ )); +DATA(insert OID = 1844 ( interval_avg PGNSP PGUID 12 f f t f i 1 1186 "1187" _null_ _null_ _null_ interval_avg - _null_ )); DESCR("AVG aggregate final function"); DATA(insert OID = 1962 ( int2_avg_accum PGNSP PGUID 12 f f t f i 2 1016 "1016 21" _null_ _null_ _null_ int2_avg_accum - _null_ )); DESCR("AVG(int2) transition function"); DATA(insert OID = 1963 ( int4_avg_accum PGNSP PGUID 12 f f t f i 2 1016 "1016 23" _null_ _null_ _null_ int4_avg_accum - _null_ )); DESCR("AVG(int4) transition function"); -DATA(insert OID = 1964 ( int8_avg PGNSP PGUID 12 f f t f i 1 1700 "1016" _null_ _null_ _null_ int8_avg - _null_ )); +DATA(insert OID = 1964 ( int8_avg PGNSP PGUID 12 f f t f i 1 1700 "1016" _null_ _null_ _null_ int8_avg - _null_ )); DESCR("AVG(int) aggregate final function"); /* To ASCII conversion */ DATA(insert OID = 1845 ( to_ascii PGNSP PGUID 12 f f t f i 1 25 "25" _null_ _null_ _null_ to_ascii_default - _null_ )); DESCR("encode text from DB encoding to ASCII text"); -DATA(insert OID = 1846 ( to_ascii PGNSP PGUID 12 f f t f i 2 25 "25 23" _null_ _null_ _null_ to_ascii_enc - _null_ )); +DATA(insert OID = 1846 ( to_ascii PGNSP PGUID 12 f f t f i 2 25 "25 23" _null_ _null_ _null_ to_ascii_enc - _null_ )); DESCR("encode text from encoding to ASCII text"); -DATA(insert OID = 1847 ( to_ascii PGNSP PGUID 12 f f t f i 2 25 "25 19" _null_ _null_ _null_ to_ascii_encname - _null_ )); +DATA(insert OID = 1847 ( to_ascii PGNSP PGUID 12 f f t f i 2 25 "25 19" _null_ _null_ _null_ to_ascii_encname - _null_ )); DESCR("encode text from encoding to ASCII text"); DATA(insert OID = 1848 ( interval_pl_time PGNSP PGUID 14 f f t f i 2 1083 "1186 1083" _null_ _null_ _null_ "select $2 + $1" - _null_ )); @@ -2754,7 +2754,7 @@ DATA(insert OID = 1893 ( int2or PGNSP PGUID 12 f f t f i 2 21 "21 21" _null DESCR("binary or"); DATA(insert OID = 1894 ( int2xor PGNSP PGUID 12 f f t f i 2 21 "21 21" _null_ _null_ _null_ int2xor - _null_ )); DESCR("binary xor"); -DATA(insert OID = 1895 ( int2not PGNSP PGUID 12 f f t f i 1 21 "21" _null_ _null_ _null_ int2not - _null_ )); +DATA(insert OID = 1895 ( int2not PGNSP PGUID 12 f f t f i 1 21 "21" _null_ _null_ _null_ int2not - _null_ )); DESCR("binary not"); DATA(insert OID = 1896 ( int2shl PGNSP PGUID 12 f f t f i 2 21 "21 23" _null_ _null_ _null_ int2shl - _null_ )); DESCR("binary shift left"); @@ -2767,7 +2767,7 @@ DATA(insert OID = 1899 ( int4or PGNSP PGUID 12 f f t f i 2 23 "23 23" _null DESCR("binary or"); DATA(insert OID = 1900 ( int4xor PGNSP PGUID 12 f f t f i 2 23 "23 23" _null_ _null_ _null_ int4xor - _null_ )); DESCR("binary xor"); -DATA(insert OID = 1901 ( int4not PGNSP PGUID 12 f f t f i 1 23 "23" _null_ _null_ _null_ int4not - _null_ )); +DATA(insert OID = 1901 ( int4not PGNSP PGUID 12 f f t f i 1 23 "23" _null_ _null_ _null_ int4not - _null_ )); DESCR("binary not"); DATA(insert OID = 1902 ( int4shl PGNSP PGUID 12 f f t f i 2 23 "23 23" _null_ _null_ _null_ int4shl - _null_ )); DESCR("binary shift left"); @@ -2780,7 +2780,7 @@ DATA(insert OID = 1905 ( int8or PGNSP PGUID 12 f f t f i 2 20 "20 20" _null DESCR("binary or"); DATA(insert OID = 1906 ( int8xor PGNSP PGUID 12 f f t f i 2 20 "20 20" _null_ _null_ _null_ int8xor - _null_ )); DESCR("binary xor"); -DATA(insert OID = 1907 ( int8not PGNSP PGUID 12 f f t f i 1 20 "20" _null_ _null_ _null_ int8not - _null_ )); +DATA(insert OID = 1907 ( int8not PGNSP PGUID 12 f f t f i 1 20 "20" _null_ _null_ _null_ int8not - _null_ )); DESCR("binary not"); DATA(insert OID = 1908 ( int8shl PGNSP PGUID 12 f f t f i 2 20 "20 23" _null_ _null_ _null_ int8shl - _null_ )); DESCR("binary shift left"); @@ -2797,7 +2797,7 @@ DATA(insert OID = 1913 ( float4up PGNSP PGUID 12 f f t f i 1 700 "700" _nul DESCR("unary plus"); DATA(insert OID = 1914 ( float8up PGNSP PGUID 12 f f t f i 1 701 "701" _null_ _null_ _null_ float8up - _null_ )); DESCR("unary plus"); -DATA(insert OID = 1915 ( numeric_uplus PGNSP PGUID 12 f f t f i 1 1700 "1700" _null_ _null_ _null_ numeric_uplus - _null_ )); +DATA(insert OID = 1915 ( numeric_uplus PGNSP PGUID 12 f f t f i 1 1700 "1700" _null_ _null_ _null_ numeric_uplus - _null_ )); DESCR("unary plus"); DATA(insert OID = 1922 ( has_table_privilege PGNSP PGUID 12 f f t f s 3 16 "19 25 25" _null_ _null_ _null_ has_table_privilege_name_name - _null_ )); @@ -2814,21 +2814,21 @@ DATA(insert OID = 1927 ( has_table_privilege PGNSP PGUID 12 f f t f s 2 16 DESCR("current user privilege on relation by rel oid"); -DATA(insert OID = 1928 ( pg_stat_get_numscans PGNSP PGUID 12 f f t f s 1 20 "26" _null_ _null_ _null_ pg_stat_get_numscans - _null_ )); +DATA(insert OID = 1928 ( pg_stat_get_numscans PGNSP PGUID 12 f f t f s 1 20 "26" _null_ _null_ _null_ pg_stat_get_numscans - _null_ )); DESCR("Statistics: Number of scans done for table/index"); -DATA(insert OID = 1929 ( pg_stat_get_tuples_returned PGNSP PGUID 12 f f t f s 1 20 "26" _null_ _null_ _null_ pg_stat_get_tuples_returned - _null_ )); +DATA(insert OID = 1929 ( pg_stat_get_tuples_returned PGNSP PGUID 12 f f t f s 1 20 "26" _null_ _null_ _null_ pg_stat_get_tuples_returned - _null_ )); DESCR("Statistics: Number of tuples read by seqscan"); -DATA(insert OID = 1930 ( pg_stat_get_tuples_fetched PGNSP PGUID 12 f f t f s 1 20 "26" _null_ _null_ _null_ pg_stat_get_tuples_fetched - _null_ )); +DATA(insert OID = 1930 ( pg_stat_get_tuples_fetched PGNSP PGUID 12 f f t f s 1 20 "26" _null_ _null_ _null_ pg_stat_get_tuples_fetched - _null_ )); DESCR("Statistics: Number of tuples fetched by idxscan"); -DATA(insert OID = 1931 ( pg_stat_get_tuples_inserted PGNSP PGUID 12 f f t f s 1 20 "26" _null_ _null_ _null_ pg_stat_get_tuples_inserted - _null_ )); +DATA(insert OID = 1931 ( pg_stat_get_tuples_inserted PGNSP PGUID 12 f f t f s 1 20 "26" _null_ _null_ _null_ pg_stat_get_tuples_inserted - _null_ )); DESCR("Statistics: Number of tuples inserted"); -DATA(insert OID = 1932 ( pg_stat_get_tuples_updated PGNSP PGUID 12 f f t f s 1 20 "26" _null_ _null_ _null_ pg_stat_get_tuples_updated - _null_ )); +DATA(insert OID = 1932 ( pg_stat_get_tuples_updated PGNSP PGUID 12 f f t f s 1 20 "26" _null_ _null_ _null_ pg_stat_get_tuples_updated - _null_ )); DESCR("Statistics: Number of tuples updated"); -DATA(insert OID = 1933 ( pg_stat_get_tuples_deleted PGNSP PGUID 12 f f t f s 1 20 "26" _null_ _null_ _null_ pg_stat_get_tuples_deleted - _null_ )); +DATA(insert OID = 1933 ( pg_stat_get_tuples_deleted PGNSP PGUID 12 f f t f s 1 20 "26" _null_ _null_ _null_ pg_stat_get_tuples_deleted - _null_ )); DESCR("Statistics: Number of tuples deleted"); -DATA(insert OID = 1934 ( pg_stat_get_blocks_fetched PGNSP PGUID 12 f f t f s 1 20 "26" _null_ _null_ _null_ pg_stat_get_blocks_fetched - _null_ )); +DATA(insert OID = 1934 ( pg_stat_get_blocks_fetched PGNSP PGUID 12 f f t f s 1 20 "26" _null_ _null_ _null_ pg_stat_get_blocks_fetched - _null_ )); DESCR("Statistics: Number of blocks fetched"); -DATA(insert OID = 1935 ( pg_stat_get_blocks_hit PGNSP PGUID 12 f f t f s 1 20 "26" _null_ _null_ _null_ pg_stat_get_blocks_hit - _null_ )); +DATA(insert OID = 1935 ( pg_stat_get_blocks_hit PGNSP PGUID 12 f f t f s 1 20 "26" _null_ _null_ _null_ pg_stat_get_blocks_hit - _null_ )); DESCR("Statistics: Number of blocks found in cache"); DATA(insert OID = 1936 ( pg_stat_get_backend_idset PGNSP PGUID 12 f f t t s 0 23 "" _null_ _null_ _null_ pg_stat_get_backend_idset - _null_ )); DESCR("Statistics: Currently active backend IDs"); @@ -2836,15 +2836,15 @@ DATA(insert OID = 2026 ( pg_backend_pid PGNSP PGUID 12 f f t f s 0 23 "" _nu DESCR("Statistics: Current backend PID"); DATA(insert OID = 2274 ( pg_stat_reset PGNSP PGUID 12 f f f f v 0 16 "" _null_ _null_ _null_ pg_stat_reset - _null_ )); DESCR("Statistics: Reset collected statistics"); -DATA(insert OID = 1937 ( pg_stat_get_backend_pid PGNSP PGUID 12 f f t f s 1 23 "23" _null_ _null_ _null_ pg_stat_get_backend_pid - _null_ )); +DATA(insert OID = 1937 ( pg_stat_get_backend_pid PGNSP PGUID 12 f f t f s 1 23 "23" _null_ _null_ _null_ pg_stat_get_backend_pid - _null_ )); DESCR("Statistics: PID of backend"); -DATA(insert OID = 1938 ( pg_stat_get_backend_dbid PGNSP PGUID 12 f f t f s 1 26 "23" _null_ _null_ _null_ pg_stat_get_backend_dbid - _null_ )); +DATA(insert OID = 1938 ( pg_stat_get_backend_dbid PGNSP PGUID 12 f f t f s 1 26 "23" _null_ _null_ _null_ pg_stat_get_backend_dbid - _null_ )); DESCR("Statistics: Database ID of backend"); -DATA(insert OID = 1939 ( pg_stat_get_backend_userid PGNSP PGUID 12 f f t f s 1 26 "23" _null_ _null_ _null_ pg_stat_get_backend_userid - _null_ )); +DATA(insert OID = 1939 ( pg_stat_get_backend_userid PGNSP PGUID 12 f f t f s 1 26 "23" _null_ _null_ _null_ pg_stat_get_backend_userid - _null_ )); DESCR("Statistics: User ID of backend"); -DATA(insert OID = 1940 ( pg_stat_get_backend_activity PGNSP PGUID 12 f f t f s 1 25 "23" _null_ _null_ _null_ pg_stat_get_backend_activity - _null_ )); +DATA(insert OID = 1940 ( pg_stat_get_backend_activity PGNSP PGUID 12 f f t f s 1 25 "23" _null_ _null_ _null_ pg_stat_get_backend_activity - _null_ )); DESCR("Statistics: Current query of backend"); -DATA(insert OID = 2094 ( pg_stat_get_backend_activity_start PGNSP PGUID 12 f f t f s 1 1184 "23" _null_ _null_ _null_ pg_stat_get_backend_activity_start - _null_)); +DATA(insert OID = 2094 ( pg_stat_get_backend_activity_start PGNSP PGUID 12 f f t f s 1 1184 "23" _null_ _null_ _null_ pg_stat_get_backend_activity_start - _null_)); DESCR("Statistics: Start time for current query of backend"); DATA(insert OID = 1391 ( pg_stat_get_backend_start PGNSP PGUID 12 f f t f s 1 1184 "23" _null_ _null_ _null_ pg_stat_get_backend_start - _null_)); DESCR("Statistics: Start time for current backend session"); @@ -2852,20 +2852,20 @@ DATA(insert OID = 1392 ( pg_stat_get_backend_client_addr PGNSP PGUID 12 f f t f DESCR("Statistics: Address of client connected to backend"); DATA(insert OID = 1393 ( pg_stat_get_backend_client_port PGNSP PGUID 12 f f t f s 1 23 "23" _null_ _null_ _null_ pg_stat_get_backend_client_port - _null_)); DESCR("Statistics: Port number of client connected to backend"); -DATA(insert OID = 1941 ( pg_stat_get_db_numbackends PGNSP PGUID 12 f f t f s 1 23 "26" _null_ _null_ _null_ pg_stat_get_db_numbackends - _null_ )); +DATA(insert OID = 1941 ( pg_stat_get_db_numbackends PGNSP PGUID 12 f f t f s 1 23 "26" _null_ _null_ _null_ pg_stat_get_db_numbackends - _null_ )); DESCR("Statistics: Number of backends in database"); -DATA(insert OID = 1942 ( pg_stat_get_db_xact_commit PGNSP PGUID 12 f f t f s 1 20 "26" _null_ _null_ _null_ pg_stat_get_db_xact_commit - _null_ )); +DATA(insert OID = 1942 ( pg_stat_get_db_xact_commit PGNSP PGUID 12 f f t f s 1 20 "26" _null_ _null_ _null_ pg_stat_get_db_xact_commit - _null_ )); DESCR("Statistics: Transactions committed"); -DATA(insert OID = 1943 ( pg_stat_get_db_xact_rollback PGNSP PGUID 12 f f t f s 1 20 "26" _null_ _null_ _null_ pg_stat_get_db_xact_rollback - _null_ )); +DATA(insert OID = 1943 ( pg_stat_get_db_xact_rollback PGNSP PGUID 12 f f t f s 1 20 "26" _null_ _null_ _null_ pg_stat_get_db_xact_rollback - _null_ )); DESCR("Statistics: Transactions rolled back"); -DATA(insert OID = 1944 ( pg_stat_get_db_blocks_fetched PGNSP PGUID 12 f f t f s 1 20 "26" _null_ _null_ _null_ pg_stat_get_db_blocks_fetched - _null_ )); +DATA(insert OID = 1944 ( pg_stat_get_db_blocks_fetched PGNSP PGUID 12 f f t f s 1 20 "26" _null_ _null_ _null_ pg_stat_get_db_blocks_fetched - _null_ )); DESCR("Statistics: Blocks fetched for database"); -DATA(insert OID = 1945 ( pg_stat_get_db_blocks_hit PGNSP PGUID 12 f f t f s 1 20 "26" _null_ _null_ _null_ pg_stat_get_db_blocks_hit - _null_ )); +DATA(insert OID = 1945 ( pg_stat_get_db_blocks_hit PGNSP PGUID 12 f f t f s 1 20 "26" _null_ _null_ _null_ pg_stat_get_db_blocks_hit - _null_ )); DESCR("Statistics: Blocks found in cache for database"); -DATA(insert OID = 1946 ( encode PGNSP PGUID 12 f f t f i 2 25 "17 25" _null_ _null_ _null_ binary_encode - _null_ )); +DATA(insert OID = 1946 ( encode PGNSP PGUID 12 f f t f i 2 25 "17 25" _null_ _null_ _null_ binary_encode - _null_ )); DESCR("Convert bytea value into some ascii-only text string"); -DATA(insert OID = 1947 ( decode PGNSP PGUID 12 f f t f i 2 17 "25 25" _null_ _null_ _null_ binary_decode - _null_ )); +DATA(insert OID = 1947 ( decode PGNSP PGUID 12 f f t f i 2 17 "25 25" _null_ _null_ _null_ binary_decode - _null_ )); DESCR("Convert ascii-encoded text string into bytea value"); DATA(insert OID = 1948 ( byteaeq PGNSP PGUID 12 f f t f i 2 16 "17 17" _null_ _null_ _null_ byteaeq - _null_ )); @@ -2908,7 +2908,7 @@ DATA(insert OID = 2008 ( notlike PGNSP PGUID 12 f f t f i 2 16 "17 17" _nul DESCR("does not match LIKE expression"); DATA(insert OID = 2009 ( like_escape PGNSP PGUID 12 f f t f i 2 17 "17 17" _null_ _null_ _null_ like_escape_bytea - _null_ )); DESCR("convert LIKE pattern to use backslash escapes"); -DATA(insert OID = 2010 ( length PGNSP PGUID 12 f f t f i 1 23 "17" _null_ _null_ _null_ byteaoctetlen - _null_ )); +DATA(insert OID = 2010 ( length PGNSP PGUID 12 f f t f i 1 23 "17" _null_ _null_ _null_ byteaoctetlen - _null_ )); DESCR("octet length"); DATA(insert OID = 2011 ( byteacat PGNSP PGUID 12 f f t f i 2 17 "17 17" _null_ _null_ _null_ byteacat - _null_ )); DESCR("concatenate"); @@ -2925,27 +2925,27 @@ DESCR("return position of substring"); DATA(insert OID = 2015 ( btrim PGNSP PGUID 12 f f t f i 2 17 "17 17" _null_ _null_ _null_ byteatrim - _null_ )); DESCR("trim both ends of string"); -DATA(insert OID = 2019 ( time PGNSP PGUID 12 f f t f s 1 1083 "1184" _null_ _null_ _null_ timestamptz_time - _null_ )); +DATA(insert OID = 2019 ( time PGNSP PGUID 12 f f t f s 1 1083 "1184" _null_ _null_ _null_ timestamptz_time - _null_ )); DESCR("convert timestamptz to time"); -DATA(insert OID = 2020 ( date_trunc PGNSP PGUID 12 f f t f i 2 1114 "25 1114" _null_ _null_ _null_ timestamp_trunc - _null_ )); +DATA(insert OID = 2020 ( date_trunc PGNSP PGUID 12 f f t f i 2 1114 "25 1114" _null_ _null_ _null_ timestamp_trunc - _null_ )); DESCR("truncate timestamp to specified units"); -DATA(insert OID = 2021 ( date_part PGNSP PGUID 12 f f t f i 2 701 "25 1114" _null_ _null_ _null_ timestamp_part - _null_ )); +DATA(insert OID = 2021 ( date_part PGNSP PGUID 12 f f t f i 2 701 "25 1114" _null_ _null_ _null_ timestamp_part - _null_ )); DESCR("extract field from timestamp"); DATA(insert OID = 2022 ( timestamp PGNSP PGUID 12 f f t f s 1 1114 "25" _null_ _null_ _null_ text_timestamp - _null_ )); DESCR("convert text to timestamp"); -DATA(insert OID = 2023 ( timestamp PGNSP PGUID 12 f f t f s 1 1114 "702" _null_ _null_ _null_ abstime_timestamp - _null_ )); +DATA(insert OID = 2023 ( timestamp PGNSP PGUID 12 f f t f s 1 1114 "702" _null_ _null_ _null_ abstime_timestamp - _null_ )); DESCR("convert abstime to timestamp"); -DATA(insert OID = 2024 ( timestamp PGNSP PGUID 12 f f t f i 1 1114 "1082" _null_ _null_ _null_ date_timestamp - _null_ )); +DATA(insert OID = 2024 ( timestamp PGNSP PGUID 12 f f t f i 1 1114 "1082" _null_ _null_ _null_ date_timestamp - _null_ )); DESCR("convert date to timestamp"); DATA(insert OID = 2025 ( timestamp PGNSP PGUID 12 f f t f i 2 1114 "1082 1083" _null_ _null_ _null_ datetime_timestamp - _null_ )); DESCR("convert date and time to timestamp"); -DATA(insert OID = 2027 ( timestamp PGNSP PGUID 12 f f t f s 1 1114 "1184" _null_ _null_ _null_ timestamptz_timestamp - _null_ )); +DATA(insert OID = 2027 ( timestamp PGNSP PGUID 12 f f t f s 1 1114 "1184" _null_ _null_ _null_ timestamptz_timestamp - _null_ )); DESCR("convert timestamp with time zone to timestamp"); -DATA(insert OID = 2028 ( timestamptz PGNSP PGUID 12 f f t f s 1 1184 "1114" _null_ _null_ _null_ timestamp_timestamptz - _null_ )); +DATA(insert OID = 2028 ( timestamptz PGNSP PGUID 12 f f t f s 1 1184 "1114" _null_ _null_ _null_ timestamp_timestamptz - _null_ )); DESCR("convert timestamp to timestamp with time zone"); -DATA(insert OID = 2029 ( date PGNSP PGUID 12 f f t f i 1 1082 "1114" _null_ _null_ _null_ timestamp_date - _null_ )); +DATA(insert OID = 2029 ( date PGNSP PGUID 12 f f t f i 1 1082 "1114" _null_ _null_ _null_ timestamp_date - _null_ )); DESCR("convert timestamp to date"); -DATA(insert OID = 2030 ( abstime PGNSP PGUID 12 f f t f s 1 702 "1114" _null_ _null_ _null_ timestamp_abstime - _null_ )); +DATA(insert OID = 2030 ( abstime PGNSP PGUID 12 f f t f s 1 702 "1114" _null_ _null_ _null_ timestamp_abstime - _null_ )); DESCR("convert timestamp to abstime"); DATA(insert OID = 2031 ( timestamp_mi PGNSP PGUID 12 f f t f i 2 1186 "1114 1114" _null_ _null_ _null_ timestamp_mi - _null_ )); DESCR("subtract"); @@ -2953,13 +2953,13 @@ DATA(insert OID = 2032 ( timestamp_pl_interval PGNSP PGUID 12 f f t f i 2 1114 DESCR("plus"); DATA(insert OID = 2033 ( timestamp_mi_interval PGNSP PGUID 12 f f t f i 2 1114 "1114 1186" _null_ _null_ _null_ timestamp_mi_interval - _null_ )); DESCR("minus"); -DATA(insert OID = 2034 ( text PGNSP PGUID 12 f f t f s 1 25 "1114" _null_ _null_ _null_ timestamp_text - _null_ )); +DATA(insert OID = 2034 ( text PGNSP PGUID 12 f f t f s 1 25 "1114" _null_ _null_ _null_ timestamp_text - _null_ )); DESCR("convert timestamp to text"); DATA(insert OID = 2035 ( timestamp_smaller PGNSP PGUID 12 f f t f i 2 1114 "1114 1114" _null_ _null_ _null_ timestamp_smaller - _null_ )); DESCR("smaller of two"); DATA(insert OID = 2036 ( timestamp_larger PGNSP PGUID 12 f f t f i 2 1114 "1114 1114" _null_ _null_ _null_ timestamp_larger - _null_ )); DESCR("larger of two"); -DATA(insert OID = 2037 ( timezone PGNSP PGUID 12 f f t f v 2 1266 "25 1266" _null_ _null_ _null_ timetz_zone - _null_ )); +DATA(insert OID = 2037 ( timezone PGNSP PGUID 12 f f t f v 2 1266 "25 1266" _null_ _null_ _null_ timetz_zone - _null_ )); DESCR("adjust time with time zone to new zone"); DATA(insert OID = 2038 ( timezone PGNSP PGUID 12 f f t f i 2 1266 "1186 1266" _null_ _null_ _null_ timetz_izone - _null_ )); DESCR("adjust time with time zone to new zone"); @@ -2971,34 +2971,34 @@ DATA(insert OID = 2043 ( overlaps PGNSP PGUID 14 f f f f i 4 16 "1114 1114 111 DESCR("SQL92 interval comparison"); DATA(insert OID = 2044 ( overlaps PGNSP PGUID 14 f f f f i 4 16 "1114 1186 1114 1114" _null_ _null_ _null_ "select ($1, ($1 + $2)) overlaps ($3, $4)" - _null_ )); DESCR("SQL92 interval comparison"); -DATA(insert OID = 2045 ( timestamp_cmp PGNSP PGUID 12 f f t f i 2 23 "1114 1114" _null_ _null_ _null_ timestamp_cmp - _null_ )); +DATA(insert OID = 2045 ( timestamp_cmp PGNSP PGUID 12 f f t f i 2 23 "1114 1114" _null_ _null_ _null_ timestamp_cmp - _null_ )); DESCR("less-equal-greater"); -DATA(insert OID = 2046 ( time PGNSP PGUID 12 f f t f i 1 1083 "1266" _null_ _null_ _null_ timetz_time - _null_ )); +DATA(insert OID = 2046 ( time PGNSP PGUID 12 f f t f i 1 1083 "1266" _null_ _null_ _null_ timetz_time - _null_ )); DESCR("convert time with time zone to time"); -DATA(insert OID = 2047 ( timetz PGNSP PGUID 12 f f t f s 1 1266 "1083" _null_ _null_ _null_ time_timetz - _null_ )); +DATA(insert OID = 2047 ( timetz PGNSP PGUID 12 f f t f s 1 1266 "1083" _null_ _null_ _null_ time_timetz - _null_ )); DESCR("convert time to timetz"); -DATA(insert OID = 2048 ( isfinite PGNSP PGUID 12 f f t f i 1 16 "1114" _null_ _null_ _null_ timestamp_finite - _null_ )); +DATA(insert OID = 2048 ( isfinite PGNSP PGUID 12 f f t f i 1 16 "1114" _null_ _null_ _null_ timestamp_finite - _null_ )); DESCR("finite timestamp?"); DATA(insert OID = 2049 ( to_char PGNSP PGUID 12 f f t f i 2 25 "1114 25" _null_ _null_ _null_ timestamp_to_char - _null_ )); DESCR("format timestamp to text"); -DATA(insert OID = 2052 ( timestamp_eq PGNSP PGUID 12 f f t f i 2 16 "1114 1114" _null_ _null_ _null_ timestamp_eq - _null_ )); +DATA(insert OID = 2052 ( timestamp_eq PGNSP PGUID 12 f f t f i 2 16 "1114 1114" _null_ _null_ _null_ timestamp_eq - _null_ )); DESCR("equal"); -DATA(insert OID = 2053 ( timestamp_ne PGNSP PGUID 12 f f t f i 2 16 "1114 1114" _null_ _null_ _null_ timestamp_ne - _null_ )); +DATA(insert OID = 2053 ( timestamp_ne PGNSP PGUID 12 f f t f i 2 16 "1114 1114" _null_ _null_ _null_ timestamp_ne - _null_ )); DESCR("not equal"); -DATA(insert OID = 2054 ( timestamp_lt PGNSP PGUID 12 f f t f i 2 16 "1114 1114" _null_ _null_ _null_ timestamp_lt - _null_ )); +DATA(insert OID = 2054 ( timestamp_lt PGNSP PGUID 12 f f t f i 2 16 "1114 1114" _null_ _null_ _null_ timestamp_lt - _null_ )); DESCR("less-than"); -DATA(insert OID = 2055 ( timestamp_le PGNSP PGUID 12 f f t f i 2 16 "1114 1114" _null_ _null_ _null_ timestamp_le - _null_ )); +DATA(insert OID = 2055 ( timestamp_le PGNSP PGUID 12 f f t f i 2 16 "1114 1114" _null_ _null_ _null_ timestamp_le - _null_ )); DESCR("less-than-or-equal"); -DATA(insert OID = 2056 ( timestamp_ge PGNSP PGUID 12 f f t f i 2 16 "1114 1114" _null_ _null_ _null_ timestamp_ge - _null_ )); +DATA(insert OID = 2056 ( timestamp_ge PGNSP PGUID 12 f f t f i 2 16 "1114 1114" _null_ _null_ _null_ timestamp_ge - _null_ )); DESCR("greater-than-or-equal"); -DATA(insert OID = 2057 ( timestamp_gt PGNSP PGUID 12 f f t f i 2 16 "1114 1114" _null_ _null_ _null_ timestamp_gt - _null_ )); +DATA(insert OID = 2057 ( timestamp_gt PGNSP PGUID 12 f f t f i 2 16 "1114 1114" _null_ _null_ _null_ timestamp_gt - _null_ )); DESCR("greater-than"); DATA(insert OID = 2058 ( age PGNSP PGUID 12 f f t f i 2 1186 "1114 1114" _null_ _null_ _null_ timestamp_age - _null_ )); DESCR("date difference preserving months and years"); -DATA(insert OID = 2059 ( age PGNSP PGUID 14 f f t f s 1 1186 "1114" _null_ _null_ _null_ "select pg_catalog.age(cast(current_date as timestamp without time zone), $1)" - _null_ )); +DATA(insert OID = 2059 ( age PGNSP PGUID 14 f f t f s 1 1186 "1114" _null_ _null_ _null_ "select pg_catalog.age(cast(current_date as timestamp without time zone), $1)" - _null_ )); DESCR("date difference from today preserving months and years"); -DATA(insert OID = 2069 ( timezone PGNSP PGUID 12 f f t f i 2 1184 "25 1114" _null_ _null_ _null_ timestamp_zone - _null_ )); +DATA(insert OID = 2069 ( timezone PGNSP PGUID 12 f f t f i 2 1184 "25 1114" _null_ _null_ _null_ timestamp_zone - _null_ )); DESCR("adjust timestamp to new time zone"); DATA(insert OID = 2070 ( timezone PGNSP PGUID 12 f f t f i 2 1184 "1186 1114" _null_ _null_ _null_ timestamp_izone - _null_ )); DESCR("adjust timestamp to new time zone"); @@ -3028,17 +3028,17 @@ DESCR("view system lock information"); DATA(insert OID = 1065 ( pg_prepared_xact PGNSP PGUID 12 f f t t v 0 2249 "" _null_ _null_ _null_ pg_prepared_xact - _null_ )); DESCR("view two-phase transactions"); -DATA(insert OID = 2079 ( pg_table_is_visible PGNSP PGUID 12 f f t f s 1 16 "26" _null_ _null_ _null_ pg_table_is_visible - _null_ )); +DATA(insert OID = 2079 ( pg_table_is_visible PGNSP PGUID 12 f f t f s 1 16 "26" _null_ _null_ _null_ pg_table_is_visible - _null_ )); DESCR("is table visible in search path?"); -DATA(insert OID = 2080 ( pg_type_is_visible PGNSP PGUID 12 f f t f s 1 16 "26" _null_ _null_ _null_ pg_type_is_visible - _null_ )); +DATA(insert OID = 2080 ( pg_type_is_visible PGNSP PGUID 12 f f t f s 1 16 "26" _null_ _null_ _null_ pg_type_is_visible - _null_ )); DESCR("is type visible in search path?"); -DATA(insert OID = 2081 ( pg_function_is_visible PGNSP PGUID 12 f f t f s 1 16 "26" _null_ _null_ _null_ pg_function_is_visible - _null_ )); +DATA(insert OID = 2081 ( pg_function_is_visible PGNSP PGUID 12 f f t f s 1 16 "26" _null_ _null_ _null_ pg_function_is_visible - _null_ )); DESCR("is function visible in search path?"); -DATA(insert OID = 2082 ( pg_operator_is_visible PGNSP PGUID 12 f f t f s 1 16 "26" _null_ _null_ _null_ pg_operator_is_visible - _null_ )); +DATA(insert OID = 2082 ( pg_operator_is_visible PGNSP PGUID 12 f f t f s 1 16 "26" _null_ _null_ _null_ pg_operator_is_visible - _null_ )); DESCR("is operator visible in search path?"); -DATA(insert OID = 2083 ( pg_opclass_is_visible PGNSP PGUID 12 f f t f s 1 16 "26" _null_ _null_ _null_ pg_opclass_is_visible - _null_ )); +DATA(insert OID = 2083 ( pg_opclass_is_visible PGNSP PGUID 12 f f t f s 1 16 "26" _null_ _null_ _null_ pg_opclass_is_visible - _null_ )); DESCR("is opclass visible in search path?"); -DATA(insert OID = 2093 ( pg_conversion_is_visible PGNSP PGUID 12 f f t f s 1 16 "26" _null_ _null_ _null_ pg_conversion_is_visible - _null_ )); +DATA(insert OID = 2093 ( pg_conversion_is_visible PGNSP PGUID 12 f f t f s 1 16 "26" _null_ _null_ _null_ pg_conversion_is_visible - _null_ )); DESCR("is conversion visible in search path?"); @@ -3049,75 +3049,75 @@ DESCR("Prepare for taking an online backup"); DATA(insert OID = 2173 ( pg_stop_backup PGNSP PGUID 12 f f t f v 0 25 "" _null_ _null_ _null_ pg_stop_backup - _null_ )); DESCR("Finish taking an online backup"); -DATA(insert OID = 2621 ( pg_reload_conf PGNSP PGUID 12 f f t f v 0 16 "" _null_ _null_ _null_ pg_reload_conf - _null_ )); +DATA(insert OID = 2621 ( pg_reload_conf PGNSP PGUID 12 f f t f v 0 16 "" _null_ _null_ _null_ pg_reload_conf - _null_ )); DESCR("Reload configuration files"); DATA(insert OID = 2622 ( pg_rotate_logfile PGNSP PGUID 12 f f t f v 0 16 "" _null_ _null_ _null_ pg_rotate_logfile - _null_ )); DESCR("Rotate log file"); -DATA(insert OID = 2623 ( pg_stat_file PGNSP PGUID 12 f f t f v 1 2249 "25" _null_ _null_ _null_ pg_stat_file - _null_ )); +DATA(insert OID = 2623 ( pg_stat_file PGNSP PGUID 12 f f t f v 1 2249 "25" _null_ _null_ _null_ pg_stat_file - _null_ )); DESCR("Return file information"); -DATA(insert OID = 2624 ( pg_read_file PGNSP PGUID 12 f f t f v 3 25 "25 20 20" _null_ _null_ _null_ pg_read_file - _null_ )); +DATA(insert OID = 2624 ( pg_read_file PGNSP PGUID 12 f f t f v 3 25 "25 20 20" _null_ _null_ _null_ pg_read_file - _null_ )); DESCR("Read text from a file"); -DATA(insert OID = 2625 ( pg_ls_dir PGNSP PGUID 12 f f t t v 1 25 "25" _null_ _null_ _null_ pg_ls_dir - _null_ )); +DATA(insert OID = 2625 ( pg_ls_dir PGNSP PGUID 12 f f t t v 1 25 "25" _null_ _null_ _null_ pg_ls_dir - _null_ )); DESCR("List all files in a directory"); - + /* Aggregates (moved here from pg_aggregate for 7.3) */ DATA(insert OID = 2100 ( avg PGNSP PGUID 12 t f f f i 1 1700 "20" _null_ _null_ _null_ aggregate_dummy - _null_ )); DATA(insert OID = 2101 ( avg PGNSP PGUID 12 t f f f i 1 1700 "23" _null_ _null_ _null_ aggregate_dummy - _null_ )); DATA(insert OID = 2102 ( avg PGNSP PGUID 12 t f f f i 1 1700 "21" _null_ _null_ _null_ aggregate_dummy - _null_ )); -DATA(insert OID = 2103 ( avg PGNSP PGUID 12 t f f f i 1 1700 "1700" _null_ _null_ _null_ aggregate_dummy - _null_ )); +DATA(insert OID = 2103 ( avg PGNSP PGUID 12 t f f f i 1 1700 "1700" _null_ _null_ _null_ aggregate_dummy - _null_ )); DATA(insert OID = 2104 ( avg PGNSP PGUID 12 t f f f i 1 701 "700" _null_ _null_ _null_ aggregate_dummy - _null_ )); DATA(insert OID = 2105 ( avg PGNSP PGUID 12 t f f f i 1 701 "701" _null_ _null_ _null_ aggregate_dummy - _null_ )); -DATA(insert OID = 2106 ( avg PGNSP PGUID 12 t f f f i 1 1186 "1186" _null_ _null_ _null_ aggregate_dummy - _null_ )); +DATA(insert OID = 2106 ( avg PGNSP PGUID 12 t f f f i 1 1186 "1186" _null_ _null_ _null_ aggregate_dummy - _null_ )); DATA(insert OID = 2107 ( sum PGNSP PGUID 12 t f f f i 1 1700 "20" _null_ _null_ _null_ aggregate_dummy - _null_ )); -DATA(insert OID = 2108 ( sum PGNSP PGUID 12 t f f f i 1 20 "23" _null_ _null_ _null_ aggregate_dummy - _null_ )); -DATA(insert OID = 2109 ( sum PGNSP PGUID 12 t f f f i 1 20 "21" _null_ _null_ _null_ aggregate_dummy - _null_ )); +DATA(insert OID = 2108 ( sum PGNSP PGUID 12 t f f f i 1 20 "23" _null_ _null_ _null_ aggregate_dummy - _null_ )); +DATA(insert OID = 2109 ( sum PGNSP PGUID 12 t f f f i 1 20 "21" _null_ _null_ _null_ aggregate_dummy - _null_ )); DATA(insert OID = 2110 ( sum PGNSP PGUID 12 t f f f i 1 700 "700" _null_ _null_ _null_ aggregate_dummy - _null_ )); DATA(insert OID = 2111 ( sum PGNSP PGUID 12 t f f f i 1 701 "701" _null_ _null_ _null_ aggregate_dummy - _null_ )); DATA(insert OID = 2112 ( sum PGNSP PGUID 12 t f f f i 1 790 "790" _null_ _null_ _null_ aggregate_dummy - _null_ )); -DATA(insert OID = 2113 ( sum PGNSP PGUID 12 t f f f i 1 1186 "1186" _null_ _null_ _null_ aggregate_dummy - _null_ )); -DATA(insert OID = 2114 ( sum PGNSP PGUID 12 t f f f i 1 1700 "1700" _null_ _null_ _null_ aggregate_dummy - _null_ )); +DATA(insert OID = 2113 ( sum PGNSP PGUID 12 t f f f i 1 1186 "1186" _null_ _null_ _null_ aggregate_dummy - _null_ )); +DATA(insert OID = 2114 ( sum PGNSP PGUID 12 t f f f i 1 1700 "1700" _null_ _null_ _null_ aggregate_dummy - _null_ )); -DATA(insert OID = 2115 ( max PGNSP PGUID 12 t f f f i 1 20 "20" _null_ _null_ _null_ aggregate_dummy - _null_ )); -DATA(insert OID = 2116 ( max PGNSP PGUID 12 t f f f i 1 23 "23" _null_ _null_ _null_ aggregate_dummy - _null_ )); -DATA(insert OID = 2117 ( max PGNSP PGUID 12 t f f f i 1 21 "21" _null_ _null_ _null_ aggregate_dummy - _null_ )); -DATA(insert OID = 2118 ( max PGNSP PGUID 12 t f f f i 1 26 "26" _null_ _null_ _null_ aggregate_dummy - _null_ )); +DATA(insert OID = 2115 ( max PGNSP PGUID 12 t f f f i 1 20 "20" _null_ _null_ _null_ aggregate_dummy - _null_ )); +DATA(insert OID = 2116 ( max PGNSP PGUID 12 t f f f i 1 23 "23" _null_ _null_ _null_ aggregate_dummy - _null_ )); +DATA(insert OID = 2117 ( max PGNSP PGUID 12 t f f f i 1 21 "21" _null_ _null_ _null_ aggregate_dummy - _null_ )); +DATA(insert OID = 2118 ( max PGNSP PGUID 12 t f f f i 1 26 "26" _null_ _null_ _null_ aggregate_dummy - _null_ )); DATA(insert OID = 2119 ( max PGNSP PGUID 12 t f f f i 1 700 "700" _null_ _null_ _null_ aggregate_dummy - _null_ )); DATA(insert OID = 2120 ( max PGNSP PGUID 12 t f f f i 1 701 "701" _null_ _null_ _null_ aggregate_dummy - _null_ )); DATA(insert OID = 2121 ( max PGNSP PGUID 12 t f f f i 1 702 "702" _null_ _null_ _null_ aggregate_dummy - _null_ )); -DATA(insert OID = 2122 ( max PGNSP PGUID 12 t f f f i 1 1082 "1082" _null_ _null_ _null_ aggregate_dummy - _null_ )); -DATA(insert OID = 2123 ( max PGNSP PGUID 12 t f f f i 1 1083 "1083" _null_ _null_ _null_ aggregate_dummy - _null_ )); -DATA(insert OID = 2124 ( max PGNSP PGUID 12 t f f f i 1 1266 "1266" _null_ _null_ _null_ aggregate_dummy - _null_ )); +DATA(insert OID = 2122 ( max PGNSP PGUID 12 t f f f i 1 1082 "1082" _null_ _null_ _null_ aggregate_dummy - _null_ )); +DATA(insert OID = 2123 ( max PGNSP PGUID 12 t f f f i 1 1083 "1083" _null_ _null_ _null_ aggregate_dummy - _null_ )); +DATA(insert OID = 2124 ( max PGNSP PGUID 12 t f f f i 1 1266 "1266" _null_ _null_ _null_ aggregate_dummy - _null_ )); DATA(insert OID = 2125 ( max PGNSP PGUID 12 t f f f i 1 790 "790" _null_ _null_ _null_ aggregate_dummy - _null_ )); -DATA(insert OID = 2126 ( max PGNSP PGUID 12 t f f f i 1 1114 "1114" _null_ _null_ _null_ aggregate_dummy - _null_ )); -DATA(insert OID = 2127 ( max PGNSP PGUID 12 t f f f i 1 1184 "1184" _null_ _null_ _null_ aggregate_dummy - _null_ )); -DATA(insert OID = 2128 ( max PGNSP PGUID 12 t f f f i 1 1186 "1186" _null_ _null_ _null_ aggregate_dummy - _null_ )); -DATA(insert OID = 2129 ( max PGNSP PGUID 12 t f f f i 1 25 "25" _null_ _null_ _null_ aggregate_dummy - _null_ )); -DATA(insert OID = 2130 ( max PGNSP PGUID 12 t f f f i 1 1700 "1700" _null_ _null_ _null_ aggregate_dummy - _null_ )); -DATA(insert OID = 2050 ( max PGNSP PGUID 12 t f f f i 1 2277 "2277" _null_ _null_ _null_ aggregate_dummy - _null_ )); -DATA(insert OID = 2244 ( max PGNSP PGUID 12 t f f f i 1 1042 "1042" _null_ _null_ _null_ aggregate_dummy - _null_ )); +DATA(insert OID = 2126 ( max PGNSP PGUID 12 t f f f i 1 1114 "1114" _null_ _null_ _null_ aggregate_dummy - _null_ )); +DATA(insert OID = 2127 ( max PGNSP PGUID 12 t f f f i 1 1184 "1184" _null_ _null_ _null_ aggregate_dummy - _null_ )); +DATA(insert OID = 2128 ( max PGNSP PGUID 12 t f f f i 1 1186 "1186" _null_ _null_ _null_ aggregate_dummy - _null_ )); +DATA(insert OID = 2129 ( max PGNSP PGUID 12 t f f f i 1 25 "25" _null_ _null_ _null_ aggregate_dummy - _null_ )); +DATA(insert OID = 2130 ( max PGNSP PGUID 12 t f f f i 1 1700 "1700" _null_ _null_ _null_ aggregate_dummy - _null_ )); +DATA(insert OID = 2050 ( max PGNSP PGUID 12 t f f f i 1 2277 "2277" _null_ _null_ _null_ aggregate_dummy - _null_ )); +DATA(insert OID = 2244 ( max PGNSP PGUID 12 t f f f i 1 1042 "1042" _null_ _null_ _null_ aggregate_dummy - _null_ )); -DATA(insert OID = 2131 ( min PGNSP PGUID 12 t f f f i 1 20 "20" _null_ _null_ _null_ aggregate_dummy - _null_ )); -DATA(insert OID = 2132 ( min PGNSP PGUID 12 t f f f i 1 23 "23" _null_ _null_ _null_ aggregate_dummy - _null_ )); -DATA(insert OID = 2133 ( min PGNSP PGUID 12 t f f f i 1 21 "21" _null_ _null_ _null_ aggregate_dummy - _null_ )); -DATA(insert OID = 2134 ( min PGNSP PGUID 12 t f f f i 1 26 "26" _null_ _null_ _null_ aggregate_dummy - _null_ )); +DATA(insert OID = 2131 ( min PGNSP PGUID 12 t f f f i 1 20 "20" _null_ _null_ _null_ aggregate_dummy - _null_ )); +DATA(insert OID = 2132 ( min PGNSP PGUID 12 t f f f i 1 23 "23" _null_ _null_ _null_ aggregate_dummy - _null_ )); +DATA(insert OID = 2133 ( min PGNSP PGUID 12 t f f f i 1 21 "21" _null_ _null_ _null_ aggregate_dummy - _null_ )); +DATA(insert OID = 2134 ( min PGNSP PGUID 12 t f f f i 1 26 "26" _null_ _null_ _null_ aggregate_dummy - _null_ )); DATA(insert OID = 2135 ( min PGNSP PGUID 12 t f f f i 1 700 "700" _null_ _null_ _null_ aggregate_dummy - _null_ )); DATA(insert OID = 2136 ( min PGNSP PGUID 12 t f f f i 1 701 "701" _null_ _null_ _null_ aggregate_dummy - _null_ )); DATA(insert OID = 2137 ( min PGNSP PGUID 12 t f f f i 1 702 "702" _null_ _null_ _null_ aggregate_dummy - _null_ )); -DATA(insert OID = 2138 ( min PGNSP PGUID 12 t f f f i 1 1082 "1082" _null_ _null_ _null_ aggregate_dummy - _null_ )); -DATA(insert OID = 2139 ( min PGNSP PGUID 12 t f f f i 1 1083 "1083" _null_ _null_ _null_ aggregate_dummy - _null_ )); -DATA(insert OID = 2140 ( min PGNSP PGUID 12 t f f f i 1 1266 "1266" _null_ _null_ _null_ aggregate_dummy - _null_ )); +DATA(insert OID = 2138 ( min PGNSP PGUID 12 t f f f i 1 1082 "1082" _null_ _null_ _null_ aggregate_dummy - _null_ )); +DATA(insert OID = 2139 ( min PGNSP PGUID 12 t f f f i 1 1083 "1083" _null_ _null_ _null_ aggregate_dummy - _null_ )); +DATA(insert OID = 2140 ( min PGNSP PGUID 12 t f f f i 1 1266 "1266" _null_ _null_ _null_ aggregate_dummy - _null_ )); DATA(insert OID = 2141 ( min PGNSP PGUID 12 t f f f i 1 790 "790" _null_ _null_ _null_ aggregate_dummy - _null_ )); -DATA(insert OID = 2142 ( min PGNSP PGUID 12 t f f f i 1 1114 "1114" _null_ _null_ _null_ aggregate_dummy - _null_ )); -DATA(insert OID = 2143 ( min PGNSP PGUID 12 t f f f i 1 1184 "1184" _null_ _null_ _null_ aggregate_dummy - _null_ )); -DATA(insert OID = 2144 ( min PGNSP PGUID 12 t f f f i 1 1186 "1186" _null_ _null_ _null_ aggregate_dummy - _null_ )); -DATA(insert OID = 2145 ( min PGNSP PGUID 12 t f f f i 1 25 "25" _null_ _null_ _null_ aggregate_dummy - _null_ )); -DATA(insert OID = 2146 ( min PGNSP PGUID 12 t f f f i 1 1700 "1700" _null_ _null_ _null_ aggregate_dummy - _null_ )); -DATA(insert OID = 2051 ( min PGNSP PGUID 12 t f f f i 1 2277 "2277" _null_ _null_ _null_ aggregate_dummy - _null_ )); -DATA(insert OID = 2245 ( min PGNSP PGUID 12 t f f f i 1 1042 "1042" _null_ _null_ _null_ aggregate_dummy - _null_ )); +DATA(insert OID = 2142 ( min PGNSP PGUID 12 t f f f i 1 1114 "1114" _null_ _null_ _null_ aggregate_dummy - _null_ )); +DATA(insert OID = 2143 ( min PGNSP PGUID 12 t f f f i 1 1184 "1184" _null_ _null_ _null_ aggregate_dummy - _null_ )); +DATA(insert OID = 2144 ( min PGNSP PGUID 12 t f f f i 1 1186 "1186" _null_ _null_ _null_ aggregate_dummy - _null_ )); +DATA(insert OID = 2145 ( min PGNSP PGUID 12 t f f f i 1 25 "25" _null_ _null_ _null_ aggregate_dummy - _null_ )); +DATA(insert OID = 2146 ( min PGNSP PGUID 12 t f f f i 1 1700 "1700" _null_ _null_ _null_ aggregate_dummy - _null_ )); +DATA(insert OID = 2051 ( min PGNSP PGUID 12 t f f f i 1 2277 "2277" _null_ _null_ _null_ aggregate_dummy - _null_ )); +DATA(insert OID = 2245 ( min PGNSP PGUID 12 t f f f i 1 1042 "1042" _null_ _null_ _null_ aggregate_dummy - _null_ )); DATA(insert OID = 2147 ( count PGNSP PGUID 12 t f f f i 1 20 "2276" _null_ _null_ _null_ aggregate_dummy - _null_ )); @@ -3126,14 +3126,14 @@ DATA(insert OID = 2149 ( variance PGNSP PGUID 12 t f f f i 1 1700 "23" _null_ DATA(insert OID = 2150 ( variance PGNSP PGUID 12 t f f f i 1 1700 "21" _null_ _null_ _null_ aggregate_dummy - _null_ )); DATA(insert OID = 2151 ( variance PGNSP PGUID 12 t f f f i 1 701 "700" _null_ _null_ _null_ aggregate_dummy - _null_ )); DATA(insert OID = 2152 ( variance PGNSP PGUID 12 t f f f i 1 701 "701" _null_ _null_ _null_ aggregate_dummy - _null_ )); -DATA(insert OID = 2153 ( variance PGNSP PGUID 12 t f f f i 1 1700 "1700" _null_ _null_ _null_ aggregate_dummy - _null_ )); +DATA(insert OID = 2153 ( variance PGNSP PGUID 12 t f f f i 1 1700 "1700" _null_ _null_ _null_ aggregate_dummy - _null_ )); DATA(insert OID = 2154 ( stddev PGNSP PGUID 12 t f f f i 1 1700 "20" _null_ _null_ _null_ aggregate_dummy - _null_ )); DATA(insert OID = 2155 ( stddev PGNSP PGUID 12 t f f f i 1 1700 "23" _null_ _null_ _null_ aggregate_dummy - _null_ )); DATA(insert OID = 2156 ( stddev PGNSP PGUID 12 t f f f i 1 1700 "21" _null_ _null_ _null_ aggregate_dummy - _null_ )); DATA(insert OID = 2157 ( stddev PGNSP PGUID 12 t f f f i 1 701 "700" _null_ _null_ _null_ aggregate_dummy - _null_ )); DATA(insert OID = 2158 ( stddev PGNSP PGUID 12 t f f f i 1 701 "701" _null_ _null_ _null_ aggregate_dummy - _null_ )); -DATA(insert OID = 2159 ( stddev PGNSP PGUID 12 t f f f i 1 1700 "1700" _null_ _null_ _null_ aggregate_dummy - _null_ )); +DATA(insert OID = 2159 ( stddev PGNSP PGUID 12 t f f f i 1 1700 "1700" _null_ _null_ _null_ aggregate_dummy - _null_ )); DATA(insert OID = 2160 ( text_pattern_lt PGNSP PGUID 12 f f t f i 2 16 "25 25" _null_ _null_ _null_ text_pattern_lt - _null_ )); DATA(insert OID = 2161 ( text_pattern_le PGNSP PGUID 12 f f t f i 2 16 "25 25" _null_ _null_ _null_ text_pattern_le - _null_ )); @@ -3170,34 +3170,34 @@ DATA(insert OID = 2194 ( btfloat48cmp PGNSP PGUID 12 f f t f i 2 23 "700 701" _ DATA(insert OID = 2195 ( btfloat84cmp PGNSP PGUID 12 f f t f i 2 23 "701 700" _null_ _null_ _null_ btfloat84cmp - _null_ )); -DATA(insert OID = 2212 ( regprocedurein PGNSP PGUID 12 f f t f s 1 2202 "2275" _null_ _null_ _null_ regprocedurein - _null_ )); +DATA(insert OID = 2212 ( regprocedurein PGNSP PGUID 12 f f t f s 1 2202 "2275" _null_ _null_ _null_ regprocedurein - _null_ )); DESCR("I/O"); -DATA(insert OID = 2213 ( regprocedureout PGNSP PGUID 12 f f t f s 1 2275 "2202" _null_ _null_ _null_ regprocedureout - _null_ )); +DATA(insert OID = 2213 ( regprocedureout PGNSP PGUID 12 f f t f s 1 2275 "2202" _null_ _null_ _null_ regprocedureout - _null_ )); DESCR("I/O"); -DATA(insert OID = 2214 ( regoperin PGNSP PGUID 12 f f t f s 1 2203 "2275" _null_ _null_ _null_ regoperin - _null_ )); +DATA(insert OID = 2214 ( regoperin PGNSP PGUID 12 f f t f s 1 2203 "2275" _null_ _null_ _null_ regoperin - _null_ )); DESCR("I/O"); -DATA(insert OID = 2215 ( regoperout PGNSP PGUID 12 f f t f s 1 2275 "2203" _null_ _null_ _null_ regoperout - _null_ )); +DATA(insert OID = 2215 ( regoperout PGNSP PGUID 12 f f t f s 1 2275 "2203" _null_ _null_ _null_ regoperout - _null_ )); DESCR("I/O"); -DATA(insert OID = 2216 ( regoperatorin PGNSP PGUID 12 f f t f s 1 2204 "2275" _null_ _null_ _null_ regoperatorin - _null_ )); +DATA(insert OID = 2216 ( regoperatorin PGNSP PGUID 12 f f t f s 1 2204 "2275" _null_ _null_ _null_ regoperatorin - _null_ )); DESCR("I/O"); -DATA(insert OID = 2217 ( regoperatorout PGNSP PGUID 12 f f t f s 1 2275 "2204" _null_ _null_ _null_ regoperatorout - _null_ )); +DATA(insert OID = 2217 ( regoperatorout PGNSP PGUID 12 f f t f s 1 2275 "2204" _null_ _null_ _null_ regoperatorout - _null_ )); DESCR("I/O"); -DATA(insert OID = 2218 ( regclassin PGNSP PGUID 12 f f t f s 1 2205 "2275" _null_ _null_ _null_ regclassin - _null_ )); +DATA(insert OID = 2218 ( regclassin PGNSP PGUID 12 f f t f s 1 2205 "2275" _null_ _null_ _null_ regclassin - _null_ )); DESCR("I/O"); -DATA(insert OID = 2219 ( regclassout PGNSP PGUID 12 f f t f s 1 2275 "2205" _null_ _null_ _null_ regclassout - _null_ )); +DATA(insert OID = 2219 ( regclassout PGNSP PGUID 12 f f t f s 1 2275 "2205" _null_ _null_ _null_ regclassout - _null_ )); DESCR("I/O"); -DATA(insert OID = 2220 ( regtypein PGNSP PGUID 12 f f t f s 1 2206 "2275" _null_ _null_ _null_ regtypein - _null_ )); +DATA(insert OID = 2220 ( regtypein PGNSP PGUID 12 f f t f s 1 2206 "2275" _null_ _null_ _null_ regtypein - _null_ )); DESCR("I/O"); -DATA(insert OID = 2221 ( regtypeout PGNSP PGUID 12 f f t f s 1 2275 "2206" _null_ _null_ _null_ regtypeout - _null_ )); +DATA(insert OID = 2221 ( regtypeout PGNSP PGUID 12 f f t f s 1 2275 "2206" _null_ _null_ _null_ regtypeout - _null_ )); DESCR("I/O"); DATA(insert OID = 1079 ( regclass PGNSP PGUID 12 f f t f s 1 2205 "25" _null_ _null_ _null_ text_regclass - _null_ )); DESCR("convert text to regclass"); DATA(insert OID = 2246 ( fmgr_internal_validator PGNSP PGUID 12 f f t f s 1 2278 "26" _null_ _null_ _null_ fmgr_internal_validator - _null_ )); DESCR("(internal)"); -DATA(insert OID = 2247 ( fmgr_c_validator PGNSP PGUID 12 f f t f s 1 2278 "26" _null_ _null_ _null_ fmgr_c_validator - _null_ )); +DATA(insert OID = 2247 ( fmgr_c_validator PGNSP PGUID 12 f f t f s 1 2278 "26" _null_ _null_ _null_ fmgr_c_validator - _null_ )); DESCR("(internal)"); -DATA(insert OID = 2248 ( fmgr_sql_validator PGNSP PGUID 12 f f t f s 1 2278 "26" _null_ _null_ _null_ fmgr_sql_validator - _null_ )); +DATA(insert OID = 2248 ( fmgr_sql_validator PGNSP PGUID 12 f f t f s 1 2278 "26" _null_ _null_ _null_ fmgr_sql_validator - _null_ )); DESCR("(internal)"); DATA(insert OID = 2250 ( has_database_privilege PGNSP PGUID 12 f f t f s 3 16 "19 25 25" _null_ _null_ _null_ has_database_privilege_name_name - _null_ )); @@ -3260,7 +3260,7 @@ DATA(insert OID = 2286 ( pg_total_relation_size PGNSP PGUID 12 f f t f v 1 20 " DESCR("Calculate total disk space usage for the specified table and associated indexes and toast tables"); DATA(insert OID = 2287 ( pg_total_relation_size PGNSP PGUID 12 f f t f v 1 20 "25" _null_ _null_ _null_ pg_total_relation_size_name - _null_ )); DESCR("Calculate total disk space usage for the specified table and associated indexes and toast tables"); -DATA(insert OID = 2288 ( pg_size_pretty PGNSP PGUID 12 f f t f v 1 25 "20" _null_ _null_ _null_ pg_size_pretty - _null_ )); +DATA(insert OID = 2288 ( pg_size_pretty PGNSP PGUID 12 f f t f v 1 25 "20" _null_ _null_ _null_ pg_size_pretty - _null_ )); DESCR("Convert a long int to a human readable text using size units"); DATA(insert OID = 2390 ( has_tablespace_privilege PGNSP PGUID 12 f f t f s 3 16 "19 25 25" _null_ _null_ _null_ has_tablespace_privilege_name_name - _null_ )); @@ -3291,49 +3291,49 @@ DESCR("current user privilege on role by role oid"); DATA(insert OID = 2290 ( record_in PGNSP PGUID 12 f f t f v 3 2249 "2275 26 23" _null_ _null_ _null_ record_in - _null_ )); DESCR("I/O"); -DATA(insert OID = 2291 ( record_out PGNSP PGUID 12 f f t f v 1 2275 "2249" _null_ _null_ _null_ record_out - _null_ )); +DATA(insert OID = 2291 ( record_out PGNSP PGUID 12 f f t f v 1 2275 "2249" _null_ _null_ _null_ record_out - _null_ )); DESCR("I/O"); -DATA(insert OID = 2292 ( cstring_in PGNSP PGUID 12 f f t f i 1 2275 "2275" _null_ _null_ _null_ cstring_in - _null_ )); +DATA(insert OID = 2292 ( cstring_in PGNSP PGUID 12 f f t f i 1 2275 "2275" _null_ _null_ _null_ cstring_in - _null_ )); DESCR("I/O"); -DATA(insert OID = 2293 ( cstring_out PGNSP PGUID 12 f f t f i 1 2275 "2275" _null_ _null_ _null_ cstring_out - _null_ )); +DATA(insert OID = 2293 ( cstring_out PGNSP PGUID 12 f f t f i 1 2275 "2275" _null_ _null_ _null_ cstring_out - _null_ )); DESCR("I/O"); -DATA(insert OID = 2294 ( any_in PGNSP PGUID 12 f f t f i 1 2276 "2275" _null_ _null_ _null_ any_in - _null_ )); +DATA(insert OID = 2294 ( any_in PGNSP PGUID 12 f f t f i 1 2276 "2275" _null_ _null_ _null_ any_in - _null_ )); DESCR("I/O"); -DATA(insert OID = 2295 ( any_out PGNSP PGUID 12 f f t f i 1 2275 "2276" _null_ _null_ _null_ any_out - _null_ )); +DATA(insert OID = 2295 ( any_out PGNSP PGUID 12 f f t f i 1 2275 "2276" _null_ _null_ _null_ any_out - _null_ )); DESCR("I/O"); -DATA(insert OID = 2296 ( anyarray_in PGNSP PGUID 12 f f t f i 1 2277 "2275" _null_ _null_ _null_ anyarray_in - _null_ )); +DATA(insert OID = 2296 ( anyarray_in PGNSP PGUID 12 f f t f i 1 2277 "2275" _null_ _null_ _null_ anyarray_in - _null_ )); DESCR("I/O"); -DATA(insert OID = 2297 ( anyarray_out PGNSP PGUID 12 f f t f s 1 2275 "2277" _null_ _null_ _null_ anyarray_out - _null_ )); +DATA(insert OID = 2297 ( anyarray_out PGNSP PGUID 12 f f t f s 1 2275 "2277" _null_ _null_ _null_ anyarray_out - _null_ )); DESCR("I/O"); -DATA(insert OID = 2298 ( void_in PGNSP PGUID 12 f f t f i 1 2278 "2275" _null_ _null_ _null_ void_in - _null_ )); +DATA(insert OID = 2298 ( void_in PGNSP PGUID 12 f f t f i 1 2278 "2275" _null_ _null_ _null_ void_in - _null_ )); DESCR("I/O"); -DATA(insert OID = 2299 ( void_out PGNSP PGUID 12 f f t f i 1 2275 "2278" _null_ _null_ _null_ void_out - _null_ )); +DATA(insert OID = 2299 ( void_out PGNSP PGUID 12 f f t f i 1 2275 "2278" _null_ _null_ _null_ void_out - _null_ )); DESCR("I/O"); -DATA(insert OID = 2300 ( trigger_in PGNSP PGUID 12 f f t f i 1 2279 "2275" _null_ _null_ _null_ trigger_in - _null_ )); +DATA(insert OID = 2300 ( trigger_in PGNSP PGUID 12 f f t f i 1 2279 "2275" _null_ _null_ _null_ trigger_in - _null_ )); DESCR("I/O"); -DATA(insert OID = 2301 ( trigger_out PGNSP PGUID 12 f f t f i 1 2275 "2279" _null_ _null_ _null_ trigger_out - _null_ )); +DATA(insert OID = 2301 ( trigger_out PGNSP PGUID 12 f f t f i 1 2275 "2279" _null_ _null_ _null_ trigger_out - _null_ )); DESCR("I/O"); -DATA(insert OID = 2302 ( language_handler_in PGNSP PGUID 12 f f t f i 1 2280 "2275" _null_ _null_ _null_ language_handler_in - _null_ )); +DATA(insert OID = 2302 ( language_handler_in PGNSP PGUID 12 f f t f i 1 2280 "2275" _null_ _null_ _null_ language_handler_in - _null_ )); DESCR("I/O"); -DATA(insert OID = 2303 ( language_handler_out PGNSP PGUID 12 f f t f i 1 2275 "2280" _null_ _null_ _null_ language_handler_out - _null_ )); +DATA(insert OID = 2303 ( language_handler_out PGNSP PGUID 12 f f t f i 1 2275 "2280" _null_ _null_ _null_ language_handler_out - _null_ )); DESCR("I/O"); -DATA(insert OID = 2304 ( internal_in PGNSP PGUID 12 f f t f i 1 2281 "2275" _null_ _null_ _null_ internal_in - _null_ )); +DATA(insert OID = 2304 ( internal_in PGNSP PGUID 12 f f t f i 1 2281 "2275" _null_ _null_ _null_ internal_in - _null_ )); DESCR("I/O"); -DATA(insert OID = 2305 ( internal_out PGNSP PGUID 12 f f t f i 1 2275 "2281" _null_ _null_ _null_ internal_out - _null_ )); +DATA(insert OID = 2305 ( internal_out PGNSP PGUID 12 f f t f i 1 2275 "2281" _null_ _null_ _null_ internal_out - _null_ )); DESCR("I/O"); -DATA(insert OID = 2306 ( opaque_in PGNSP PGUID 12 f f t f i 1 2282 "2275" _null_ _null_ _null_ opaque_in - _null_ )); +DATA(insert OID = 2306 ( opaque_in PGNSP PGUID 12 f f t f i 1 2282 "2275" _null_ _null_ _null_ opaque_in - _null_ )); DESCR("I/O"); -DATA(insert OID = 2307 ( opaque_out PGNSP PGUID 12 f f t f i 1 2275 "2282" _null_ _null_ _null_ opaque_out - _null_ )); +DATA(insert OID = 2307 ( opaque_out PGNSP PGUID 12 f f t f i 1 2275 "2282" _null_ _null_ _null_ opaque_out - _null_ )); DESCR("I/O"); -DATA(insert OID = 2312 ( anyelement_in PGNSP PGUID 12 f f t f i 1 2283 "2275" _null_ _null_ _null_ anyelement_in - _null_ )); +DATA(insert OID = 2312 ( anyelement_in PGNSP PGUID 12 f f t f i 1 2283 "2275" _null_ _null_ _null_ anyelement_in - _null_ )); DESCR("I/O"); -DATA(insert OID = 2313 ( anyelement_out PGNSP PGUID 12 f f t f i 1 2275 "2283" _null_ _null_ _null_ anyelement_out - _null_ )); +DATA(insert OID = 2313 ( anyelement_out PGNSP PGUID 12 f f t f i 1 2275 "2283" _null_ _null_ _null_ anyelement_out - _null_ )); DESCR("I/O"); /* cryptographic */ -DATA(insert OID = 2311 ( md5 PGNSP PGUID 12 f f t f i 1 25 "25" _null_ _null_ _null_ md5_text - _null_ )); +DATA(insert OID = 2311 ( md5 PGNSP PGUID 12 f f t f i 1 25 "25" _null_ _null_ _null_ md5_text - _null_ )); DESCR("calculates md5 hash"); -DATA(insert OID = 2321 ( md5 PGNSP PGUID 12 f f t f i 1 25 "17" _null_ _null_ _null_ md5_bytea - _null_ )); +DATA(insert OID = 2321 ( md5 PGNSP PGUID 12 f f t f i 1 25 "17" _null_ _null_ _null_ md5_bytea - _null_ )); DESCR("calculates md5 hash"); /* crosstype operations for date vs. timestamp and timestamptz */ @@ -3440,55 +3440,55 @@ DATA(insert OID = 2403 ( record_send PGNSP PGUID 12 f f t f v 1 17 "2249" _ DESCR("I/O"); DATA(insert OID = 2404 ( int2recv PGNSP PGUID 12 f f t f i 1 21 "2281" _null_ _null_ _null_ int2recv - _null_ )); DESCR("I/O"); -DATA(insert OID = 2405 ( int2send PGNSP PGUID 12 f f t f i 1 17 "21" _null_ _null_ _null_ int2send - _null_ )); +DATA(insert OID = 2405 ( int2send PGNSP PGUID 12 f f t f i 1 17 "21" _null_ _null_ _null_ int2send - _null_ )); DESCR("I/O"); DATA(insert OID = 2406 ( int4recv PGNSP PGUID 12 f f t f i 1 23 "2281" _null_ _null_ _null_ int4recv - _null_ )); DESCR("I/O"); -DATA(insert OID = 2407 ( int4send PGNSP PGUID 12 f f t f i 1 17 "23" _null_ _null_ _null_ int4send - _null_ )); +DATA(insert OID = 2407 ( int4send PGNSP PGUID 12 f f t f i 1 17 "23" _null_ _null_ _null_ int4send - _null_ )); DESCR("I/O"); DATA(insert OID = 2408 ( int8recv PGNSP PGUID 12 f f t f i 1 20 "2281" _null_ _null_ _null_ int8recv - _null_ )); DESCR("I/O"); -DATA(insert OID = 2409 ( int8send PGNSP PGUID 12 f f t f i 1 17 "20" _null_ _null_ _null_ int8send - _null_ )); +DATA(insert OID = 2409 ( int8send PGNSP PGUID 12 f f t f i 1 17 "20" _null_ _null_ _null_ int8send - _null_ )); DESCR("I/O"); DATA(insert OID = 2410 ( int2vectorrecv PGNSP PGUID 12 f f t f i 1 22 "2281" _null_ _null_ _null_ int2vectorrecv - _null_ )); DESCR("I/O"); -DATA(insert OID = 2411 ( int2vectorsend PGNSP PGUID 12 f f t f i 1 17 "22" _null_ _null_ _null_ int2vectorsend - _null_ )); +DATA(insert OID = 2411 ( int2vectorsend PGNSP PGUID 12 f f t f i 1 17 "22" _null_ _null_ _null_ int2vectorsend - _null_ )); DESCR("I/O"); DATA(insert OID = 2412 ( bytearecv PGNSP PGUID 12 f f t f i 1 17 "2281" _null_ _null_ _null_ bytearecv - _null_ )); DESCR("I/O"); -DATA(insert OID = 2413 ( byteasend PGNSP PGUID 12 f f t f i 1 17 "17" _null_ _null_ _null_ byteasend - _null_ )); +DATA(insert OID = 2413 ( byteasend PGNSP PGUID 12 f f t f i 1 17 "17" _null_ _null_ _null_ byteasend - _null_ )); DESCR("I/O"); DATA(insert OID = 2414 ( textrecv PGNSP PGUID 12 f f t f s 1 25 "2281" _null_ _null_ _null_ textrecv - _null_ )); DESCR("I/O"); -DATA(insert OID = 2415 ( textsend PGNSP PGUID 12 f f t f s 1 17 "25" _null_ _null_ _null_ textsend - _null_ )); +DATA(insert OID = 2415 ( textsend PGNSP PGUID 12 f f t f s 1 17 "25" _null_ _null_ _null_ textsend - _null_ )); DESCR("I/O"); DATA(insert OID = 2416 ( unknownrecv PGNSP PGUID 12 f f t f i 1 705 "2281" _null_ _null_ _null_ unknownrecv - _null_ )); DESCR("I/O"); -DATA(insert OID = 2417 ( unknownsend PGNSP PGUID 12 f f t f i 1 17 "705" _null_ _null_ _null_ unknownsend - _null_ )); +DATA(insert OID = 2417 ( unknownsend PGNSP PGUID 12 f f t f i 1 17 "705" _null_ _null_ _null_ unknownsend - _null_ )); DESCR("I/O"); DATA(insert OID = 2418 ( oidrecv PGNSP PGUID 12 f f t f i 1 26 "2281" _null_ _null_ _null_ oidrecv - _null_ )); DESCR("I/O"); -DATA(insert OID = 2419 ( oidsend PGNSP PGUID 12 f f t f i 1 17 "26" _null_ _null_ _null_ oidsend - _null_ )); +DATA(insert OID = 2419 ( oidsend PGNSP PGUID 12 f f t f i 1 17 "26" _null_ _null_ _null_ oidsend - _null_ )); DESCR("I/O"); DATA(insert OID = 2420 ( oidvectorrecv PGNSP PGUID 12 f f t f i 1 30 "2281" _null_ _null_ _null_ oidvectorrecv - _null_ )); DESCR("I/O"); -DATA(insert OID = 2421 ( oidvectorsend PGNSP PGUID 12 f f t f i 1 17 "30" _null_ _null_ _null_ oidvectorsend - _null_ )); +DATA(insert OID = 2421 ( oidvectorsend PGNSP PGUID 12 f f t f i 1 17 "30" _null_ _null_ _null_ oidvectorsend - _null_ )); DESCR("I/O"); DATA(insert OID = 2422 ( namerecv PGNSP PGUID 12 f f t f s 1 19 "2281" _null_ _null_ _null_ namerecv - _null_ )); DESCR("I/O"); -DATA(insert OID = 2423 ( namesend PGNSP PGUID 12 f f t f s 1 17 "19" _null_ _null_ _null_ namesend - _null_ )); +DATA(insert OID = 2423 ( namesend PGNSP PGUID 12 f f t f s 1 17 "19" _null_ _null_ _null_ namesend - _null_ )); DESCR("I/O"); DATA(insert OID = 2424 ( float4recv PGNSP PGUID 12 f f t f i 1 700 "2281" _null_ _null_ _null_ float4recv - _null_ )); DESCR("I/O"); -DATA(insert OID = 2425 ( float4send PGNSP PGUID 12 f f t f i 1 17 "700" _null_ _null_ _null_ float4send - _null_ )); +DATA(insert OID = 2425 ( float4send PGNSP PGUID 12 f f t f i 1 17 "700" _null_ _null_ _null_ float4send - _null_ )); DESCR("I/O"); DATA(insert OID = 2426 ( float8recv PGNSP PGUID 12 f f t f i 1 701 "2281" _null_ _null_ _null_ float8recv - _null_ )); DESCR("I/O"); -DATA(insert OID = 2427 ( float8send PGNSP PGUID 12 f f t f i 1 17 "701" _null_ _null_ _null_ float8send - _null_ )); +DATA(insert OID = 2427 ( float8send PGNSP PGUID 12 f f t f i 1 17 "701" _null_ _null_ _null_ float8send - _null_ )); DESCR("I/O"); DATA(insert OID = 2428 ( point_recv PGNSP PGUID 12 f f t f i 1 600 "2281" _null_ _null_ _null_ point_recv - _null_ )); DESCR("I/O"); -DATA(insert OID = 2429 ( point_send PGNSP PGUID 12 f f t f i 1 17 "600" _null_ _null_ _null_ point_send - _null_ )); +DATA(insert OID = 2429 ( point_send PGNSP PGUID 12 f f t f i 1 17 "600" _null_ _null_ _null_ point_send - _null_ )); DESCR("I/O"); DATA(insert OID = 2430 ( bpcharrecv PGNSP PGUID 12 f f t f s 3 1042 "2281 26 23" _null_ _null_ _null_ bpcharrecv - _null_ )); DESCR("I/O"); @@ -3500,45 +3500,45 @@ DATA(insert OID = 2433 ( varcharsend PGNSP PGUID 12 f f t f s 1 17 "1043" _ DESCR("I/O"); DATA(insert OID = 2434 ( charrecv PGNSP PGUID 12 f f t f i 1 18 "2281" _null_ _null_ _null_ charrecv - _null_ )); DESCR("I/O"); -DATA(insert OID = 2435 ( charsend PGNSP PGUID 12 f f t f i 1 17 "18" _null_ _null_ _null_ charsend - _null_ )); +DATA(insert OID = 2435 ( charsend PGNSP PGUID 12 f f t f i 1 17 "18" _null_ _null_ _null_ charsend - _null_ )); DESCR("I/O"); DATA(insert OID = 2436 ( boolrecv PGNSP PGUID 12 f f t f i 1 16 "2281" _null_ _null_ _null_ boolrecv - _null_ )); DESCR("I/O"); -DATA(insert OID = 2437 ( boolsend PGNSP PGUID 12 f f t f i 1 17 "16" _null_ _null_ _null_ boolsend - _null_ )); +DATA(insert OID = 2437 ( boolsend PGNSP PGUID 12 f f t f i 1 17 "16" _null_ _null_ _null_ boolsend - _null_ )); DESCR("I/O"); DATA(insert OID = 2438 ( tidrecv PGNSP PGUID 12 f f t f i 1 27 "2281" _null_ _null_ _null_ tidrecv - _null_ )); DESCR("I/O"); -DATA(insert OID = 2439 ( tidsend PGNSP PGUID 12 f f t f i 1 17 "27" _null_ _null_ _null_ tidsend - _null_ )); +DATA(insert OID = 2439 ( tidsend PGNSP PGUID 12 f f t f i 1 17 "27" _null_ _null_ _null_ tidsend - _null_ )); DESCR("I/O"); DATA(insert OID = 2440 ( xidrecv PGNSP PGUID 12 f f t f i 1 28 "2281" _null_ _null_ _null_ xidrecv - _null_ )); DESCR("I/O"); -DATA(insert OID = 2441 ( xidsend PGNSP PGUID 12 f f t f i 1 17 "28" _null_ _null_ _null_ xidsend - _null_ )); +DATA(insert OID = 2441 ( xidsend PGNSP PGUID 12 f f t f i 1 17 "28" _null_ _null_ _null_ xidsend - _null_ )); DESCR("I/O"); DATA(insert OID = 2442 ( cidrecv PGNSP PGUID 12 f f t f i 1 29 "2281" _null_ _null_ _null_ cidrecv - _null_ )); DESCR("I/O"); -DATA(insert OID = 2443 ( cidsend PGNSP PGUID 12 f f t f i 1 17 "29" _null_ _null_ _null_ cidsend - _null_ )); +DATA(insert OID = 2443 ( cidsend PGNSP PGUID 12 f f t f i 1 17 "29" _null_ _null_ _null_ cidsend - _null_ )); DESCR("I/O"); DATA(insert OID = 2444 ( regprocrecv PGNSP PGUID 12 f f t f i 1 24 "2281" _null_ _null_ _null_ regprocrecv - _null_ )); DESCR("I/O"); -DATA(insert OID = 2445 ( regprocsend PGNSP PGUID 12 f f t f i 1 17 "24" _null_ _null_ _null_ regprocsend - _null_ )); +DATA(insert OID = 2445 ( regprocsend PGNSP PGUID 12 f f t f i 1 17 "24" _null_ _null_ _null_ regprocsend - _null_ )); DESCR("I/O"); -DATA(insert OID = 2446 ( regprocedurerecv PGNSP PGUID 12 f f t f i 1 2202 "2281" _null_ _null_ _null_ regprocedurerecv - _null_ )); +DATA(insert OID = 2446 ( regprocedurerecv PGNSP PGUID 12 f f t f i 1 2202 "2281" _null_ _null_ _null_ regprocedurerecv - _null_ )); DESCR("I/O"); DATA(insert OID = 2447 ( regproceduresend PGNSP PGUID 12 f f t f i 1 17 "2202" _null_ _null_ _null_ regproceduresend - _null_ )); DESCR("I/O"); -DATA(insert OID = 2448 ( regoperrecv PGNSP PGUID 12 f f t f i 1 2203 "2281" _null_ _null_ _null_ regoperrecv - _null_ )); +DATA(insert OID = 2448 ( regoperrecv PGNSP PGUID 12 f f t f i 1 2203 "2281" _null_ _null_ _null_ regoperrecv - _null_ )); DESCR("I/O"); DATA(insert OID = 2449 ( regopersend PGNSP PGUID 12 f f t f i 1 17 "2203" _null_ _null_ _null_ regopersend - _null_ )); DESCR("I/O"); -DATA(insert OID = 2450 ( regoperatorrecv PGNSP PGUID 12 f f t f i 1 2204 "2281" _null_ _null_ _null_ regoperatorrecv - _null_ )); +DATA(insert OID = 2450 ( regoperatorrecv PGNSP PGUID 12 f f t f i 1 2204 "2281" _null_ _null_ _null_ regoperatorrecv - _null_ )); DESCR("I/O"); DATA(insert OID = 2451 ( regoperatorsend PGNSP PGUID 12 f f t f i 1 17 "2204" _null_ _null_ _null_ regoperatorsend - _null_ )); DESCR("I/O"); -DATA(insert OID = 2452 ( regclassrecv PGNSP PGUID 12 f f t f i 1 2205 "2281" _null_ _null_ _null_ regclassrecv - _null_ )); +DATA(insert OID = 2452 ( regclassrecv PGNSP PGUID 12 f f t f i 1 2205 "2281" _null_ _null_ _null_ regclassrecv - _null_ )); DESCR("I/O"); DATA(insert OID = 2453 ( regclasssend PGNSP PGUID 12 f f t f i 1 17 "2205" _null_ _null_ _null_ regclasssend - _null_ )); DESCR("I/O"); -DATA(insert OID = 2454 ( regtyperecv PGNSP PGUID 12 f f t f i 1 2206 "2281" _null_ _null_ _null_ regtyperecv - _null_ )); +DATA(insert OID = 2454 ( regtyperecv PGNSP PGUID 12 f f t f i 1 2206 "2281" _null_ _null_ _null_ regtyperecv - _null_ )); DESCR("I/O"); DATA(insert OID = 2455 ( regtypesend PGNSP PGUID 12 f f t f i 1 17 "2206" _null_ _null_ _null_ regtypesend - _null_ )); DESCR("I/O"); @@ -3556,17 +3556,17 @@ DATA(insert OID = 2461 ( numeric_send PGNSP PGUID 12 f f t f i 1 17 "1700" DESCR("I/O"); DATA(insert OID = 2462 ( abstimerecv PGNSP PGUID 12 f f t f i 1 702 "2281" _null_ _null_ _null_ abstimerecv - _null_ )); DESCR("I/O"); -DATA(insert OID = 2463 ( abstimesend PGNSP PGUID 12 f f t f i 1 17 "702" _null_ _null_ _null_ abstimesend - _null_ )); +DATA(insert OID = 2463 ( abstimesend PGNSP PGUID 12 f f t f i 1 17 "702" _null_ _null_ _null_ abstimesend - _null_ )); DESCR("I/O"); DATA(insert OID = 2464 ( reltimerecv PGNSP PGUID 12 f f t f i 1 703 "2281" _null_ _null_ _null_ reltimerecv - _null_ )); DESCR("I/O"); -DATA(insert OID = 2465 ( reltimesend PGNSP PGUID 12 f f t f i 1 17 "703" _null_ _null_ _null_ reltimesend - _null_ )); +DATA(insert OID = 2465 ( reltimesend PGNSP PGUID 12 f f t f i 1 17 "703" _null_ _null_ _null_ reltimesend - _null_ )); DESCR("I/O"); DATA(insert OID = 2466 ( tintervalrecv PGNSP PGUID 12 f f t f i 1 704 "2281" _null_ _null_ _null_ tintervalrecv - _null_ )); DESCR("I/O"); -DATA(insert OID = 2467 ( tintervalsend PGNSP PGUID 12 f f t f i 1 17 "704" _null_ _null_ _null_ tintervalsend - _null_ )); +DATA(insert OID = 2467 ( tintervalsend PGNSP PGUID 12 f f t f i 1 17 "704" _null_ _null_ _null_ tintervalsend - _null_ )); DESCR("I/O"); -DATA(insert OID = 2468 ( date_recv PGNSP PGUID 12 f f t f i 1 1082 "2281" _null_ _null_ _null_ date_recv - _null_ )); +DATA(insert OID = 2468 ( date_recv PGNSP PGUID 12 f f t f i 1 1082 "2281" _null_ _null_ _null_ date_recv - _null_ )); DESCR("I/O"); DATA(insert OID = 2469 ( date_send PGNSP PGUID 12 f f t f i 1 17 "1082" _null_ _null_ _null_ date_send - _null_ )); DESCR("I/O"); @@ -3592,49 +3592,49 @@ DATA(insert OID = 2479 ( interval_send PGNSP PGUID 12 f f t f i 1 17 "1186" DESCR("I/O"); DATA(insert OID = 2480 ( lseg_recv PGNSP PGUID 12 f f t f i 1 601 "2281" _null_ _null_ _null_ lseg_recv - _null_ )); DESCR("I/O"); -DATA(insert OID = 2481 ( lseg_send PGNSP PGUID 12 f f t f i 1 17 "601" _null_ _null_ _null_ lseg_send - _null_ )); +DATA(insert OID = 2481 ( lseg_send PGNSP PGUID 12 f f t f i 1 17 "601" _null_ _null_ _null_ lseg_send - _null_ )); DESCR("I/O"); DATA(insert OID = 2482 ( path_recv PGNSP PGUID 12 f f t f i 1 602 "2281" _null_ _null_ _null_ path_recv - _null_ )); DESCR("I/O"); -DATA(insert OID = 2483 ( path_send PGNSP PGUID 12 f f t f i 1 17 "602" _null_ _null_ _null_ path_send - _null_ )); +DATA(insert OID = 2483 ( path_send PGNSP PGUID 12 f f t f i 1 17 "602" _null_ _null_ _null_ path_send - _null_ )); DESCR("I/O"); DATA(insert OID = 2484 ( box_recv PGNSP PGUID 12 f f t f i 1 603 "2281" _null_ _null_ _null_ box_recv - _null_ )); DESCR("I/O"); -DATA(insert OID = 2485 ( box_send PGNSP PGUID 12 f f t f i 1 17 "603" _null_ _null_ _null_ box_send - _null_ )); +DATA(insert OID = 2485 ( box_send PGNSP PGUID 12 f f t f i 1 17 "603" _null_ _null_ _null_ box_send - _null_ )); DESCR("I/O"); DATA(insert OID = 2486 ( poly_recv PGNSP PGUID 12 f f t f i 1 604 "2281" _null_ _null_ _null_ poly_recv - _null_ )); DESCR("I/O"); -DATA(insert OID = 2487 ( poly_send PGNSP PGUID 12 f f t f i 1 17 "604" _null_ _null_ _null_ poly_send - _null_ )); +DATA(insert OID = 2487 ( poly_send PGNSP PGUID 12 f f t f i 1 17 "604" _null_ _null_ _null_ poly_send - _null_ )); DESCR("I/O"); DATA(insert OID = 2488 ( line_recv PGNSP PGUID 12 f f t f i 1 628 "2281" _null_ _null_ _null_ line_recv - _null_ )); DESCR("I/O"); -DATA(insert OID = 2489 ( line_send PGNSP PGUID 12 f f t f i 1 17 "628" _null_ _null_ _null_ line_send - _null_ )); +DATA(insert OID = 2489 ( line_send PGNSP PGUID 12 f f t f i 1 17 "628" _null_ _null_ _null_ line_send - _null_ )); DESCR("I/O"); DATA(insert OID = 2490 ( circle_recv PGNSP PGUID 12 f f t f i 1 718 "2281" _null_ _null_ _null_ circle_recv - _null_ )); DESCR("I/O"); -DATA(insert OID = 2491 ( circle_send PGNSP PGUID 12 f f t f i 1 17 "718" _null_ _null_ _null_ circle_send - _null_ )); +DATA(insert OID = 2491 ( circle_send PGNSP PGUID 12 f f t f i 1 17 "718" _null_ _null_ _null_ circle_send - _null_ )); DESCR("I/O"); DATA(insert OID = 2492 ( cash_recv PGNSP PGUID 12 f f t f i 1 790 "2281" _null_ _null_ _null_ cash_recv - _null_ )); DESCR("I/O"); -DATA(insert OID = 2493 ( cash_send PGNSP PGUID 12 f f t f i 1 17 "790" _null_ _null_ _null_ cash_send - _null_ )); +DATA(insert OID = 2493 ( cash_send PGNSP PGUID 12 f f t f i 1 17 "790" _null_ _null_ _null_ cash_send - _null_ )); DESCR("I/O"); DATA(insert OID = 2494 ( macaddr_recv PGNSP PGUID 12 f f t f i 1 829 "2281" _null_ _null_ _null_ macaddr_recv - _null_ )); DESCR("I/O"); -DATA(insert OID = 2495 ( macaddr_send PGNSP PGUID 12 f f t f i 1 17 "829" _null_ _null_ _null_ macaddr_send - _null_ )); +DATA(insert OID = 2495 ( macaddr_send PGNSP PGUID 12 f f t f i 1 17 "829" _null_ _null_ _null_ macaddr_send - _null_ )); DESCR("I/O"); DATA(insert OID = 2496 ( inet_recv PGNSP PGUID 12 f f t f i 1 869 "2281" _null_ _null_ _null_ inet_recv - _null_ )); DESCR("I/O"); -DATA(insert OID = 2497 ( inet_send PGNSP PGUID 12 f f t f i 1 17 "869" _null_ _null_ _null_ inet_send - _null_ )); +DATA(insert OID = 2497 ( inet_send PGNSP PGUID 12 f f t f i 1 17 "869" _null_ _null_ _null_ inet_send - _null_ )); DESCR("I/O"); DATA(insert OID = 2498 ( cidr_recv PGNSP PGUID 12 f f t f i 1 650 "2281" _null_ _null_ _null_ cidr_recv - _null_ )); DESCR("I/O"); -DATA(insert OID = 2499 ( cidr_send PGNSP PGUID 12 f f t f i 1 17 "650" _null_ _null_ _null_ cidr_send - _null_ )); +DATA(insert OID = 2499 ( cidr_send PGNSP PGUID 12 f f t f i 1 17 "650" _null_ _null_ _null_ cidr_send - _null_ )); DESCR("I/O"); -DATA(insert OID = 2500 ( cstring_recv PGNSP PGUID 12 f f t f s 1 2275 "2281" _null_ _null_ _null_ cstring_recv - _null_ )); +DATA(insert OID = 2500 ( cstring_recv PGNSP PGUID 12 f f t f s 1 2275 "2281" _null_ _null_ _null_ cstring_recv - _null_ )); DESCR("I/O"); DATA(insert OID = 2501 ( cstring_send PGNSP PGUID 12 f f t f s 1 17 "2275" _null_ _null_ _null_ cstring_send - _null_ )); DESCR("I/O"); -DATA(insert OID = 2502 ( anyarray_recv PGNSP PGUID 12 f f t f s 1 2277 "2281" _null_ _null_ _null_ anyarray_recv - _null_ )); +DATA(insert OID = 2502 ( anyarray_recv PGNSP PGUID 12 f f t f s 1 2277 "2281" _null_ _null_ _null_ anyarray_recv - _null_ )); DESCR("I/O"); DATA(insert OID = 2503 ( anyarray_send PGNSP PGUID 12 f f t f s 1 17 "2277" _null_ _null_ _null_ anyarray_send - _null_ )); DESCR("I/O"); @@ -3699,14 +3699,14 @@ DATA(insert OID = 2546 ( interval_pl_date PGNSP PGUID 14 f f t f i 2 1114 "118 DATA(insert OID = 2547 ( interval_pl_timetz PGNSP PGUID 14 f f t f i 2 1266 "1186 1266" _null_ _null_ _null_ "select $2 + $1" - _null_ )); DATA(insert OID = 2548 ( interval_pl_timestamp PGNSP PGUID 14 f f t f i 2 1114 "1186 1114" _null_ _null_ _null_ "select $2 + $1" - _null_ )); DATA(insert OID = 2549 ( interval_pl_timestamptz PGNSP PGUID 14 f f t f s 2 1184 "1186 1184" _null_ _null_ _null_ "select $2 + $1" - _null_ )); -DATA(insert OID = 2550 ( integer_pl_date PGNSP PGUID 14 f f t f i 2 1082 "23 1082" _null_ _null_ _null_ "select $2 + $1" - _null_ )); +DATA(insert OID = 2550 ( integer_pl_date PGNSP PGUID 14 f f t f i 2 1082 "23 1082" _null_ _null_ _null_ "select $2 + $1" - _null_ )); DATA(insert OID = 2556 ( pg_tablespace_databases PGNSP PGUID 12 f f t t s 1 26 "26" _null_ _null_ _null_ pg_tablespace_databases - _null_)); DESCR("returns database oids in a tablespace"); -DATA(insert OID = 2557 ( bool PGNSP PGUID 12 f f t f i 1 16 "23" _null_ _null_ _null_ int4_bool - _null_ )); +DATA(insert OID = 2557 ( bool PGNSP PGUID 12 f f t f i 1 16 "23" _null_ _null_ _null_ int4_bool - _null_ )); DESCR("convert int4 to boolean"); -DATA(insert OID = 2558 ( int4 PGNSP PGUID 12 f f t f i 1 23 "16" _null_ _null_ _null_ bool_int4 - _null_ )); +DATA(insert OID = 2558 ( int4 PGNSP PGUID 12 f f t f i 1 23 "16" _null_ _null_ _null_ bool_int4 - _null_ )); DESCR("convert boolean to int4"); DATA(insert OID = 2559 ( lastval PGNSP PGUID 12 f f t f v 0 20 "" _null_ _null_ _null_ lastval - _null_ )); DESCR("current value from last used sequence"); @@ -3720,21 +3720,21 @@ DATA(insert OID = 1269 ( pg_column_size PGNSP PGUID 12 f f t f s 1 23 "2276" DESCR("bytes required to store the value, perhaps with compression"); /* new functions for Y-direction rtree opclasses */ -DATA(insert OID = 2562 ( box_below PGNSP PGUID 12 f f t f i 2 16 "603 603" _null_ _null_ _null_ box_below - _null_ )); +DATA(insert OID = 2562 ( box_below PGNSP PGUID 12 f f t f i 2 16 "603 603" _null_ _null_ _null_ box_below - _null_ )); DESCR("is below"); -DATA(insert OID = 2563 ( box_overbelow PGNSP PGUID 12 f f t f i 2 16 "603 603" _null_ _null_ _null_ box_overbelow - _null_ )); +DATA(insert OID = 2563 ( box_overbelow PGNSP PGUID 12 f f t f i 2 16 "603 603" _null_ _null_ _null_ box_overbelow - _null_ )); DESCR("overlaps or is below"); -DATA(insert OID = 2564 ( box_overabove PGNSP PGUID 12 f f t f i 2 16 "603 603" _null_ _null_ _null_ box_overabove - _null_ )); +DATA(insert OID = 2564 ( box_overabove PGNSP PGUID 12 f f t f i 2 16 "603 603" _null_ _null_ _null_ box_overabove - _null_ )); DESCR("overlaps or is above"); -DATA(insert OID = 2565 ( box_above PGNSP PGUID 12 f f t f i 2 16 "603 603" _null_ _null_ _null_ box_above - _null_ )); +DATA(insert OID = 2565 ( box_above PGNSP PGUID 12 f f t f i 2 16 "603 603" _null_ _null_ _null_ box_above - _null_ )); DESCR("is above"); -DATA(insert OID = 2566 ( poly_below PGNSP PGUID 12 f f t f i 2 16 "604 604" _null_ _null_ _null_ poly_below - _null_ )); +DATA(insert OID = 2566 ( poly_below PGNSP PGUID 12 f f t f i 2 16 "604 604" _null_ _null_ _null_ poly_below - _null_ )); DESCR("is below"); -DATA(insert OID = 2567 ( poly_overbelow PGNSP PGUID 12 f f t f i 2 16 "604 604" _null_ _null_ _null_ poly_overbelow - _null_ )); +DATA(insert OID = 2567 ( poly_overbelow PGNSP PGUID 12 f f t f i 2 16 "604 604" _null_ _null_ _null_ poly_overbelow - _null_ )); DESCR("overlaps or is below"); -DATA(insert OID = 2568 ( poly_overabove PGNSP PGUID 12 f f t f i 2 16 "604 604" _null_ _null_ _null_ poly_overabove - _null_ )); +DATA(insert OID = 2568 ( poly_overabove PGNSP PGUID 12 f f t f i 2 16 "604 604" _null_ _null_ _null_ poly_overabove - _null_ )); DESCR("overlaps or is above"); -DATA(insert OID = 2569 ( poly_above PGNSP PGUID 12 f f t f i 2 16 "604 604" _null_ _null_ _null_ poly_above - _null_ )); +DATA(insert OID = 2569 ( poly_above PGNSP PGUID 12 f f t f i 2 16 "604 604" _null_ _null_ _null_ poly_above - _null_ )); DESCR("is above"); DATA(insert OID = 2587 ( circle_overbelow PGNSP PGUID 12 f f t f i 2 16 "718 718" _null_ _null_ _null_ circle_overbelow - _null_ )); DESCR("overlaps or is below"); @@ -3744,25 +3744,25 @@ DESCR("overlaps or is above"); /* support functions for GiST r-tree emulation */ DATA(insert OID = 2578 ( gist_box_consistent PGNSP PGUID 12 f f t f i 3 16 "2281 603 23" _null_ _null_ _null_ gist_box_consistent - _null_ )); DESCR("GiST support"); -DATA(insert OID = 2579 ( gist_box_compress PGNSP PGUID 12 f f t f i 1 2281 "2281" _null_ _null_ _null_ gist_box_compress - _null_ )); +DATA(insert OID = 2579 ( gist_box_compress PGNSP PGUID 12 f f t f i 1 2281 "2281" _null_ _null_ _null_ gist_box_compress - _null_ )); DESCR("GiST support"); -DATA(insert OID = 2580 ( gist_box_decompress PGNSP PGUID 12 f f t f i 1 2281 "2281" _null_ _null_ _null_ gist_box_decompress - _null_ )); +DATA(insert OID = 2580 ( gist_box_decompress PGNSP PGUID 12 f f t f i 1 2281 "2281" _null_ _null_ _null_ gist_box_decompress - _null_ )); DESCR("GiST support"); DATA(insert OID = 2581 ( gist_box_penalty PGNSP PGUID 12 f f t f i 3 2281 "2281 2281 2281" _null_ _null_ _null_ gist_box_penalty - _null_ )); DESCR("GiST support"); DATA(insert OID = 2582 ( gist_box_picksplit PGNSP PGUID 12 f f t f i 2 2281 "2281 2281" _null_ _null_ _null_ gist_box_picksplit - _null_ )); DESCR("GiST support"); -DATA(insert OID = 2583 ( gist_box_union PGNSP PGUID 12 f f t f i 2 603 "2281 2281" _null_ _null_ _null_ gist_box_union - _null_ )); +DATA(insert OID = 2583 ( gist_box_union PGNSP PGUID 12 f f t f i 2 603 "2281 2281" _null_ _null_ _null_ gist_box_union - _null_ )); DESCR("GiST support"); -DATA(insert OID = 2584 ( gist_box_same PGNSP PGUID 12 f f t f i 3 2281 "603 603 2281" _null_ _null_ _null_ gist_box_same - _null_ )); +DATA(insert OID = 2584 ( gist_box_same PGNSP PGUID 12 f f t f i 3 2281 "603 603 2281" _null_ _null_ _null_ gist_box_same - _null_ )); DESCR("GiST support"); DATA(insert OID = 2585 ( gist_poly_consistent PGNSP PGUID 12 f f t f i 3 16 "2281 604 23" _null_ _null_ _null_ gist_poly_consistent - _null_ )); DESCR("GiST support"); -DATA(insert OID = 2586 ( gist_poly_compress PGNSP PGUID 12 f f t f i 1 2281 "2281" _null_ _null_ _null_ gist_poly_compress - _null_ )); +DATA(insert OID = 2586 ( gist_poly_compress PGNSP PGUID 12 f f t f i 1 2281 "2281" _null_ _null_ _null_ gist_poly_compress - _null_ )); DESCR("GiST support"); DATA(insert OID = 2591 ( gist_circle_consistent PGNSP PGUID 12 f f t f i 3 16 "2281 718 23" _null_ _null_ _null_ gist_circle_consistent - _null_ )); DESCR("GiST support"); -DATA(insert OID = 2592 ( gist_circle_compress PGNSP PGUID 12 f f t f i 1 2281 "2281" _null_ _null_ _null_ gist_circle_compress - _null_ )); +DATA(insert OID = 2592 ( gist_circle_compress PGNSP PGUID 12 f f t f i 1 2281 "2281" _null_ _null_ _null_ gist_circle_compress - _null_ )); DESCR("GiST support"); @@ -3779,7 +3779,7 @@ DESCR("GiST support"); #define PROVOLATILE_VOLATILE 'v' /* can change even within a scan */ /* - * Symbolic values for proargmodes column. Note that these must agree with + * Symbolic values for proargmodes column. Note that these must agree with * the FunctionParameterMode enum in parsenodes.h; we declare them here to * be accessible from either header. */ diff --git a/src/include/catalog/pg_shdepend.h b/src/include/catalog/pg_shdepend.h index f3c905bd2f..de4f6eb0d4 100644 --- a/src/include/catalog/pg_shdepend.h +++ b/src/include/catalog/pg_shdepend.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_shdepend.h,v 1.1 2005/07/07 20:39:59 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_shdepend.h,v 1.2 2005/10/15 02:49:44 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -37,16 +37,16 @@ CATALOG(pg_shdepend,1214) BKI_SHARED_RELATION BKI_WITHOUT_OIDS /* * Identification of the dependent (referencing) object. * - * These fields are all zeroes for a DEPENDENCY_PIN entry. Also, - * dbid can be zero to denote a shared object. + * These fields are all zeroes for a DEPENDENCY_PIN entry. Also, dbid can be + * zero to denote a shared object. */ Oid dbid; /* OID of database containing object */ Oid classid; /* OID of table containing object */ Oid objid; /* OID of object itself */ /* - * Identification of the independent (referenced) object. This is - * always a shared object, so we need no database ID field. + * Identification of the independent (referenced) object. This is always + * a shared object, so we need no database ID field. */ Oid refclassid; /* OID of table containing object */ Oid refobjid; /* OID of object itself */ @@ -73,7 +73,7 @@ typedef FormData_pg_shdepend *Form_pg_shdepend; #define Anum_pg_shdepend_dbid 1 #define Anum_pg_shdepend_classid 2 #define Anum_pg_shdepend_objid 3 -#define Anum_pg_shdepend_refclassid 4 +#define Anum_pg_shdepend_refclassid 4 #define Anum_pg_shdepend_refobjid 5 #define Anum_pg_shdepend_deptype 6 diff --git a/src/include/catalog/pg_statistic.h b/src/include/catalog/pg_statistic.h index ded22c0329..6b46a5e2ef 100644 --- a/src/include/catalog/pg_statistic.h +++ b/src/include/catalog/pg_statistic.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_statistic.h,v 1.29 2005/04/14 01:38:21 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_statistic.h,v 1.30 2005/10/15 02:49:44 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -50,13 +50,13 @@ CATALOG(pg_statistic,2619) BKI_WITHOUT_OIDS /* * stawidth is the average width in bytes of non-null entries. For - * fixed-width datatypes this is of course the same as the typlen, but - * for var-width types it is more useful. Note that this is the - * average width of the data as actually stored, post-TOASTing (eg, - * for a moved-out-of-line value, only the size of the pointer object - * is counted). This is the appropriate definition for the primary - * use of the statistic, which is to estimate sizes of in-memory hash - * tables of tuples. + * fixed-width datatypes this is of course the same as the typlen, but for + * var-width types it is more useful. Note that this is the average width + * of the data as actually stored, post-TOASTing (eg, for a + * moved-out-of-line value, only the size of the pointer object is + * counted). This is the appropriate definition for the primary use of + * the statistic, which is to estimate sizes of in-memory hash tables of + * tuples. */ int4 stawidth; @@ -105,10 +105,10 @@ CATALOG(pg_statistic,2619) BKI_WITHOUT_OIDS Oid staop4; /* - * THE REST OF THESE ARE VARIABLE LENGTH FIELDS, and may even be - * absent (NULL). They cannot be accessed as C struct entries; you - * have to use the full field access machinery (heap_getattr) for - * them. We declare them here for the catalog machinery. + * THE REST OF THESE ARE VARIABLE LENGTH FIELDS, and may even be absent + * (NULL). They cannot be accessed as C struct entries; you have to use + * the full field access machinery (heap_getattr) for them. We declare + * them here for the catalog machinery. */ float4 stanumbers1[1]; @@ -118,8 +118,8 @@ CATALOG(pg_statistic,2619) BKI_WITHOUT_OIDS /* * Values in these arrays are values of the column's data type. We - * presently have to cheat quite a bit to allow polymorphic arrays of - * this kind, but perhaps someday it'll be a less bogus facility. + * presently have to cheat quite a bit to allow polymorphic arrays of this + * kind, but perhaps someday it'll be a less bogus facility. */ anyarray stavalues1; anyarray stavalues2; diff --git a/src/include/catalog/pg_type.h b/src/include/catalog/pg_type.h index 6e4092fd39..0e3dd006c4 100644 --- a/src/include/catalog/pg_type.h +++ b/src/include/catalog/pg_type.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_type.h,v 1.165 2005/08/12 01:36:04 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_type.h,v 1.166 2005/10/15 02:49:44 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -38,7 +38,7 @@ * See struct FormData_pg_attribute for details. * ---------------- */ -#define TypeRelationId 1247 +#define TypeRelationId 1247 CATALOG(pg_type,1247) BKI_BOOTSTRAP { @@ -56,28 +56,26 @@ CATALOG(pg_type,1247) BKI_BOOTSTRAP int2 typlen; /* - * typbyval determines whether internal Postgres routines pass a value - * of this type by value or by reference. typbyval had better be - * FALSE if the length is not 1, 2, or 4 (or 8 on 8-byte-Datum - * machines). 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. + * typbyval determines whether internal Postgres routines pass a value of + * this type by value or by reference. typbyval had better be FALSE if + * the length is not 1, 2, or 4 (or 8 on 8-byte-Datum machines). + * 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. */ bool typbyval; /* - * typtype is 'b' for a basic type, 'c' for a complex type (ie a - * table's rowtype), 'd' for a domain type, or 'p' for a pseudo type. + * typtype is 'b' for a basic type, 'c' for a complex type (ie a table's + * rowtype), 'd' for a domain type, or 'p' for a pseudo type. * - * If typtype is 'c', typrelid is the OID of the class' entry in - * pg_class. + * If typtype is 'c', typrelid is the OID of the class' entry in pg_class. */ char typtype; /* * If typisdefined is false, the entry is only a placeholder (forward - * reference). We know the type name, but not yet anything else about - * it. + * reference). We know the type name, but not yet anything else about it. */ bool typisdefined; @@ -87,11 +85,11 @@ CATALOG(pg_type,1247) BKI_BOOTSTRAP /* * If typelem is not 0 then it identifies another row in pg_type. The - * current type can then be subscripted like an array yielding values - * of type typelem. A non-zero typelem does not guarantee this type to - * be a "real" array type; some ordinary fixed-length types can also - * be subscripted (e.g., name, point). Variable-length types can *not* - * be turned into pseudo-arrays like that. Hence, the way to determine + * current type can then be subscripted like an array yielding values of + * type typelem. A non-zero typelem does not guarantee this type to be a + * "real" array type; some ordinary fixed-length types can also be + * subscripted (e.g., name, point). Variable-length types can *not* be + * turned into pseudo-arrays like that. Hence, the way to determine * whether a type is a "true" array type is if: * * typelem != 0 and typlen == -1. @@ -150,8 +148,8 @@ CATALOG(pg_type,1247) BKI_BOOTSTRAP /* * This flag represents a "NOT NULL" constraint against this datatype. * - * If true, the attnotnull column for a corresponding table column using - * this datatype will always enforce the NOT NULL constraint. + * If true, the attnotnull column for a corresponding table column using this + * datatype will always enforce the NOT NULL constraint. * * Used primarily for domain types. */ @@ -164,23 +162,23 @@ CATALOG(pg_type,1247) BKI_BOOTSTRAP Oid typbasetype; /* - * Domains use typtypmod to record the typmod to be applied to their - * base type (-1 if base type does not use a typmod). -1 if this type - * is not a domain. + * Domains use typtypmod to record the typmod to be applied to their base + * type (-1 if base type does not use a typmod). -1 if this type is not a + * domain. */ int4 typtypmod; /* - * typndims is the declared number of dimensions for an array domain - * type (i.e., typbasetype is an array type; the domain's typelem will - * match the base type's typelem). Otherwise zero. + * typndims is the declared number of dimensions for an array domain type + * (i.e., typbasetype is an array type; the domain's typelem will match + * the base type's typelem). Otherwise zero. */ int4 typndims; /* - * If typdefaultbin is not NULL, it is the nodeToString representation - * of a default expression for the type. Currently this is only used - * for domains. + * If typdefaultbin is not NULL, it is the nodeToString representation of + * a default expression for the type. Currently this is only used for + * domains. */ text typdefaultbin; /* VARIABLE LENGTH FIELD */ @@ -189,8 +187,8 @@ CATALOG(pg_type,1247) BKI_BOOTSTRAP * typdefaultbin is not NULL, typdefault must contain a human-readable * version of the default expression represented by typdefaultbin. If * typdefaultbin is NULL and typdefault is not, then typdefault is the - * external representation of the type's default value, which may be - * fed to the type's input converter to produce a constant. + * external representation of the type's default value, which may be fed + * to the type's input converter to produce a constant. */ text typdefault; /* VARIABLE LENGTH FIELD */ @@ -270,7 +268,7 @@ DATA(insert OID = 21 ( int2 PGNSP PGUID 2 t b t \054 0 0 int2in int2out int2 DESCR("-32 thousand to 32 thousand, 2-byte storage"); #define INT2OID 21 -DATA(insert OID = 22 ( int2vector PGNSP PGUID -1 f b t \054 0 21 int2vectorin int2vectorout int2vectorrecv int2vectorsend - i p f 0 -1 0 _null_ _null_ )); +DATA(insert OID = 22 ( int2vector PGNSP PGUID -1 f b t \054 0 21 int2vectorin int2vectorout int2vectorrecv int2vectorsend - i p f 0 -1 0 _null_ _null_ )); DESCR("array of int2, used in system tables"); #define INT2VECTOROID 22 @@ -302,7 +300,7 @@ DATA(insert OID = 29 ( cid PGNSP PGUID 4 t b t \054 0 0 cidin cidout cidrec DESCR("command identifier type, sequence in transaction id"); #define CIDOID 29 -DATA(insert OID = 30 ( oidvector PGNSP PGUID -1 f b t \054 0 26 oidvectorin oidvectorout oidvectorrecv oidvectorsend - i p f 0 -1 0 _null_ _null_ )); +DATA(insert OID = 30 ( oidvector PGNSP PGUID -1 f b t \054 0 26 oidvectorin oidvectorout oidvectorrecv oidvectorsend - i p f 0 -1 0 _null_ _null_ )); DESCR("array of oids, used in system tables"); #define OIDVECTOROID 30 diff --git a/src/include/commands/async.h b/src/include/commands/async.h index 7844043f54..05aeb86737 100644 --- a/src/include/commands/async.h +++ b/src/include/commands/async.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/commands/async.h,v 1.29 2005/10/06 21:30:39 neilc Exp $ + * $PostgreSQL: pgsql/src/include/commands/async.h,v 1.30 2005/10/15 02:49:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -40,6 +40,6 @@ extern void EnableNotifyInterrupt(void); extern bool DisableNotifyInterrupt(void); extern void notify_twophase_postcommit(TransactionId xid, uint16 info, - void *recdata, uint32 len); + void *recdata, uint32 len); #endif /* ASYNC_H */ diff --git a/src/include/commands/cluster.h b/src/include/commands/cluster.h index 382e2bcadf..bcafedc52a 100644 --- a/src/include/commands/cluster.h +++ b/src/include/commands/cluster.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994-5, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/commands/cluster.h,v 1.28 2005/05/10 13:16:26 momjian Exp $ + * $PostgreSQL: pgsql/src/include/commands/cluster.h,v 1.29 2005/10/15 02:49:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -20,7 +20,7 @@ extern void cluster(ClusterStmt *stmt); extern void check_index_is_clusterable(Relation OldHeap, Oid indexOid, - bool recheck); + bool recheck); extern void mark_index_clustered(Relation rel, Oid indexOid); extern Oid make_new_heap(Oid OIDOldHeap, const char *NewName, Oid NewTableSpace); diff --git a/src/include/commands/dbcommands.h b/src/include/commands/dbcommands.h index 7770ea9b97..9c629aff34 100644 --- a/src/include/commands/dbcommands.h +++ b/src/include/commands/dbcommands.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/commands/dbcommands.h,v 1.41 2005/07/31 17:19:21 tgl Exp $ + * $PostgreSQL: pgsql/src/include/commands/dbcommands.h,v 1.42 2005/10/15 02:49:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -27,14 +27,14 @@ typedef struct xl_dbase_create_rec_old Oid db_id; char src_path[1]; /* VARIABLE LENGTH STRING */ /* dst_path follows src_path */ -} xl_dbase_create_rec_old; +} xl_dbase_create_rec_old; typedef struct xl_dbase_drop_rec_old { /* Records dropping of a single subdirectory incl. contents */ Oid db_id; char dir_path[1]; /* VARIABLE LENGTH STRING */ -} xl_dbase_drop_rec_old; +} xl_dbase_drop_rec_old; typedef struct xl_dbase_create_rec { @@ -43,14 +43,14 @@ typedef struct xl_dbase_create_rec Oid tablespace_id; Oid src_db_id; Oid src_tablespace_id; -} xl_dbase_create_rec; +} xl_dbase_create_rec; typedef struct xl_dbase_drop_rec { /* Records dropping of a single subdirectory incl. contents */ Oid db_id; Oid tablespace_id; -} xl_dbase_drop_rec; +} xl_dbase_drop_rec; extern void createdb(const CreatedbStmt *stmt); extern void dropdb(const char *dbname); diff --git a/src/include/commands/defrem.h b/src/include/commands/defrem.h index a0f3dc67d6..ad7c6a178a 100644 --- a/src/include/commands/defrem.h +++ b/src/include/commands/defrem.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/commands/defrem.h,v 1.67 2005/08/01 04:03:58 tgl Exp $ + * $PostgreSQL: pgsql/src/include/commands/defrem.h,v 1.68 2005/10/15 02:49:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -37,7 +37,7 @@ extern void RemoveIndex(RangeVar *relation, DropBehavior behavior); extern void ReindexIndex(RangeVar *indexRelation); extern void ReindexTable(RangeVar *relation); extern void ReindexDatabase(const char *databaseName, - bool do_system, bool do_user); + bool do_system, bool do_user); extern char *makeObjectName(const char *name1, const char *name2, const char *label); extern char *ChooseRelationName(const char *name1, const char *name2, @@ -55,8 +55,8 @@ extern void AlterFunction(AlterFunctionStmt *stmt); extern void CreateCast(CreateCastStmt *stmt); extern void DropCast(DropCastStmt *stmt); extern void DropCastById(Oid castOid); -extern void AlterFunctionNamespace(List *name, List *argtypes, - const char *newschema); +extern void AlterFunctionNamespace(List *name, List *argtypes, + const char *newschema); /* commands/operatorcmds.c */ extern void DefineOperator(List *names, List *parameters); diff --git a/src/include/commands/tablecmds.h b/src/include/commands/tablecmds.h index 582720df3b..0774164844 100644 --- a/src/include/commands/tablecmds.h +++ b/src/include/commands/tablecmds.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/commands/tablecmds.h,v 1.23 2005/08/01 04:03:58 tgl Exp $ + * $PostgreSQL: pgsql/src/include/commands/tablecmds.h,v 1.24 2005/10/15 02:49:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -31,8 +31,8 @@ extern void AlterTableCreateToastTable(Oid relOid, bool silent); extern void AlterTableNamespace(RangeVar *relation, const char *newschema); extern void AlterRelationNamespaceInternal(Relation classRel, Oid relOid, - Oid oldNspOid, Oid newNspOid, - bool hasDependEntry); + Oid oldNspOid, Oid newNspOid, + bool hasDependEntry); extern void ExecuteTruncate(List *relations); @@ -51,7 +51,7 @@ extern void remove_on_commit_action(Oid relid); extern void PreCommit_on_commit_actions(void); extern void AtEOXact_on_commit_actions(bool isCommit); extern void AtEOSubXact_on_commit_actions(bool isCommit, - SubTransactionId mySubid, - SubTransactionId parentSubid); + SubTransactionId mySubid, + SubTransactionId parentSubid); #endif /* TABLECMDS_H */ diff --git a/src/include/commands/tablespace.h b/src/include/commands/tablespace.h index f6c83c952b..fab4f209f9 100644 --- a/src/include/commands/tablespace.h +++ b/src/include/commands/tablespace.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/commands/tablespace.h,v 1.10 2005/06/28 05:09:12 tgl Exp $ + * $PostgreSQL: pgsql/src/include/commands/tablespace.h,v 1.11 2005/10/15 02:49:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -25,12 +25,12 @@ typedef struct xl_tblspc_create_rec { Oid ts_id; char ts_path[1]; /* VARIABLE LENGTH STRING */ -} xl_tblspc_create_rec; +} xl_tblspc_create_rec; typedef struct xl_tblspc_drop_rec { Oid ts_id; -} xl_tblspc_drop_rec; +} xl_tblspc_drop_rec; extern void CreateTableSpace(CreateTableSpaceStmt *stmt); diff --git a/src/include/commands/trigger.h b/src/include/commands/trigger.h index 25c0019518..39325a1903 100644 --- a/src/include/commands/trigger.h +++ b/src/include/commands/trigger.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/commands/trigger.h,v 1.55 2005/08/23 22:40:40 tgl Exp $ + * $PostgreSQL: pgsql/src/include/commands/trigger.h,v 1.56 2005/10/15 02:49:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -95,8 +95,8 @@ typedef struct TriggerData #define RI_FK_RELNAME_ARGNO 1 #define RI_PK_RELNAME_ARGNO 2 #define RI_MATCH_TYPE_ARGNO 3 -#define RI_FIRST_ATTNAME_ARGNO 4 /* first attname pair - * starts here */ +#define RI_FIRST_ATTNAME_ARGNO 4 /* first attname pair starts + * here */ #define RI_KEYPAIR_FK_IDX 0 #define RI_KEYPAIR_PK_IDX 1 @@ -114,7 +114,7 @@ extern void RemoveTriggerById(Oid trigOid); extern void renametrig(Oid relid, const char *oldname, const char *newname); extern void EnableDisableTrigger(Relation rel, const char *tgname, - bool enable, bool skip_system); + bool enable, bool skip_system); extern void RelationBuildTriggers(Relation relation); @@ -172,9 +172,9 @@ extern void AfterTriggerSetState(ConstraintsSetStmt *stmt); * in utils/adt/ri_triggers.c */ extern bool RI_FKey_keyequal_upd_pk(Trigger *trigger, Relation pk_rel, - HeapTuple old_row, HeapTuple new_row); + HeapTuple old_row, HeapTuple new_row); extern bool RI_FKey_keyequal_upd_fk(Trigger *trigger, Relation fk_rel, - HeapTuple old_row, HeapTuple new_row); + HeapTuple old_row, HeapTuple new_row); extern bool RI_Initial_Check(FkConstraint *fkconstraint, Relation rel, Relation pkrel); @@ -183,6 +183,6 @@ extern bool RI_Initial_Check(FkConstraint *fkconstraint, #define RI_TRIGGER_FK 2 /* is a trigger on the FK relation */ #define RI_TRIGGER_NONE 0 /* is not an RI trigger function */ -extern int RI_FKey_trigger_type(Oid tgfoid); +extern int RI_FKey_trigger_type(Oid tgfoid); #endif /* TRIGGER_H */ diff --git a/src/include/commands/typecmds.h b/src/include/commands/typecmds.h index d53cf672a6..53632906a1 100644 --- a/src/include/commands/typecmds.h +++ b/src/include/commands/typecmds.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/commands/typecmds.h,v 1.13 2005/08/04 01:09:29 tgl Exp $ + * $PostgreSQL: pgsql/src/include/commands/typecmds.h,v 1.14 2005/10/15 02:49:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -38,6 +38,6 @@ extern void AlterTypeOwner(List *names, Oid newOwnerId); extern void AlterTypeOwnerInternal(Oid typeOid, Oid newOwnerId); extern void AlterTypeNamespace(List *names, const char *newschema); extern void AlterTypeNamespaceInternal(Oid typeOid, Oid nspOid, - bool errorOnTableType); + bool errorOnTableType); #endif /* TYPECMDS_H */ diff --git a/src/include/commands/vacuum.h b/src/include/commands/vacuum.h index db954fff2d..13418b018e 100644 --- a/src/include/commands/vacuum.h +++ b/src/include/commands/vacuum.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/commands/vacuum.h,v 1.61 2005/10/03 22:52:24 tgl Exp $ + * $PostgreSQL: pgsql/src/include/commands/vacuum.h,v 1.62 2005/10/15 02:49:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -59,8 +59,8 @@ typedef Datum (*AnalyzeAttrFetchFunc) (VacAttrStatsP stats, int rownum, typedef struct VacAttrStats { /* - * These fields are set up by the main ANALYZE code before invoking - * the type-specific typanalyze function. + * These fields are set up by the main ANALYZE code before invoking the + * type-specific typanalyze function. */ Form_pg_attribute attr; /* copy of pg_attribute row for column */ Form_pg_type attrtype; /* copy of pg_type row for column */ @@ -71,15 +71,15 @@ typedef struct VacAttrStats * returns FALSE. */ void (*compute_stats) (VacAttrStatsP stats, - AnalyzeAttrFetchFunc fetchfunc, + AnalyzeAttrFetchFunc fetchfunc, int samplerows, double totalrows); int minrows; /* Minimum # of rows wanted for stats */ void *extra_data; /* for extra type-specific data */ /* - * These fields are to be filled in by the compute_stats routine. - * (They are initialized to zero when the struct is created.) + * These fields are to be filled in by the compute_stats routine. (They + * are initialized to zero when the struct is created.) */ bool stats_valid; float4 stanullfrac; /* fraction of entries that are NULL */ @@ -112,7 +112,7 @@ extern DLLIMPORT int default_statistics_target; /* DLLIMPORT for PostGIS */ /* in commands/vacuum.c */ extern void vacuum(VacuumStmt *vacstmt, List *relids); extern void vac_open_indexes(Relation relation, LOCKMODE lockmode, - int *nindexes, Relation **Irel); + int *nindexes, Relation **Irel); extern void vac_close_indexes(int nindexes, Relation *Irel, LOCKMODE lockmode); extern void vac_update_relstats(Oid relid, BlockNumber num_pages, diff --git a/src/include/commands/variable.h b/src/include/commands/variable.h index 9814336325..4755dfba39 100644 --- a/src/include/commands/variable.h +++ b/src/include/commands/variable.h @@ -5,7 +5,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/commands/variable.h,v 1.26 2005/07/25 22:12:34 tgl Exp $ + * $PostgreSQL: pgsql/src/include/commands/variable.h,v 1.27 2005/10/15 02:49:44 momjian Exp $ */ #ifndef VARIABLE_H #define VARIABLE_H @@ -27,7 +27,7 @@ extern const char *show_random_seed(void); extern const char *assign_client_encoding(const char *value, bool doit, GucSource source); extern const char *assign_role(const char *value, - bool doit, GucSource source); + bool doit, GucSource source); extern const char *show_role(void); extern const char *assign_session_authorization(const char *value, bool doit, GucSource source); diff --git a/src/include/executor/execdebug.h b/src/include/executor/execdebug.h index 9a6969ecef..a4fc1c1016 100644 --- a/src/include/executor/execdebug.h +++ b/src/include/executor/execdebug.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/executor/execdebug.h,v 1.27 2005/05/13 21:20:16 tgl Exp $ + * $PostgreSQL: pgsql/src/include/executor/execdebug.h,v 1.28 2005/10/15 02:49:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -266,7 +266,6 @@ extern int NIndexTupleInserted; #define MJ_DEBUG_PROC_NODE(slot) \ MJ2_printf(" %s = ExecProcNode(...) returns %s\n", \ CppAsString(slot), NULL_OR_TUPLE(slot)) - #else #define MJ_nodeDisplay(l) diff --git a/src/include/executor/executor.h b/src/include/executor/executor.h index 6064ff2f4f..31228e114b 100644 --- a/src/include/executor/executor.h +++ b/src/include/executor/executor.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/executor/executor.h,v 1.119 2005/08/20 00:40:13 tgl Exp $ + * $PostgreSQL: pgsql/src/include/executor/executor.h,v 1.120 2005/10/15 02:49:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -40,17 +40,17 @@ extern bool ExecMayReturnRawTuples(PlanState *node); * prototypes from functions in execGrouping.c */ extern bool execTuplesMatch(TupleTableSlot *slot1, - TupleTableSlot *slot2, - int numCols, - AttrNumber *matchColIdx, - FmgrInfo *eqfunctions, - MemoryContext evalContext); + TupleTableSlot *slot2, + int numCols, + AttrNumber *matchColIdx, + FmgrInfo *eqfunctions, + MemoryContext evalContext); extern bool execTuplesUnequal(TupleTableSlot *slot1, - TupleTableSlot *slot2, - int numCols, - AttrNumber *matchColIdx, - FmgrInfo *eqfunctions, - MemoryContext evalContext); + TupleTableSlot *slot2, + int numCols, + AttrNumber *matchColIdx, + FmgrInfo *eqfunctions, + MemoryContext evalContext); extern FmgrInfo *execTuplesMatchPrepare(TupleDesc tupdesc, int numCols, AttrNumber *matchColIdx); @@ -75,12 +75,12 @@ extern TupleHashEntry LookupTupleHashEntry(TupleHashTable hashtable, extern JunkFilter *ExecInitJunkFilter(List *targetList, bool hasoid, TupleTableSlot *slot); extern JunkFilter *ExecInitJunkFilterConversion(List *targetList, - TupleDesc cleanTupType, - TupleTableSlot *slot); + TupleDesc cleanTupType, + TupleTableSlot *slot); extern bool ExecGetJunkAttribute(JunkFilter *junkfilter, TupleTableSlot *slot, char *attrName, Datum *value, bool *isNull); extern TupleTableSlot *ExecFilterJunk(JunkFilter *junkfilter, - TupleTableSlot *slot); + TupleTableSlot *slot); extern HeapTuple ExecRemoveJunk(JunkFilter *junkfilter, TupleTableSlot *slot); @@ -98,7 +98,7 @@ extern bool ExecContextForcesOids(PlanState *planstate, bool *hasoids); extern void ExecConstraints(ResultRelInfo *resultRelInfo, TupleTableSlot *slot, EState *estate); extern TupleTableSlot *EvalPlanQual(EState *estate, Index rti, - ItemPointer tid, TransactionId priorXmax); + ItemPointer tid, TransactionId priorXmax); /* * prototypes from functions in execProcnode.c diff --git a/src/include/executor/functions.h b/src/include/executor/functions.h index 88ca87fd86..ab959b8a3e 100644 --- a/src/include/executor/functions.h +++ b/src/include/executor/functions.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/executor/functions.h,v 1.25 2005/03/31 22:46:22 tgl Exp $ + * $PostgreSQL: pgsql/src/include/executor/functions.h,v 1.26 2005/10/15 02:49:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -21,7 +21,7 @@ extern Datum fmgr_sql(PG_FUNCTION_ARGS); extern bool check_sql_fn_retval(Oid func_id, Oid rettype, - List *queryTreeList, - JunkFilter **junkFilter); + List *queryTreeList, + JunkFilter **junkFilter); #endif /* FUNCTIONS_H */ diff --git a/src/include/executor/hashjoin.h b/src/include/executor/hashjoin.h index f5200831d7..abe0e5914d 100644 --- a/src/include/executor/hashjoin.h +++ b/src/include/executor/hashjoin.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/executor/hashjoin.h,v 1.36 2005/04/16 20:07:35 tgl Exp $ + * $PostgreSQL: pgsql/src/include/executor/hashjoin.h,v 1.37 2005/10/15 02:49:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -41,7 +41,7 @@ * If nbatch > 1 then tuples that don't belong in first batch get saved * into inner-batch temp files. The same statements apply for the * first scan of the outer relation, except we write tuples to outer-batch - * temp files. After finishing the first scan, we do the following for + * temp files. After finishing the first scan, we do the following for * each remaining 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. @@ -63,7 +63,7 @@ typedef struct HashJoinTupleData { - struct HashJoinTupleData *next; /* link to next tuple in same bucket */ + struct HashJoinTupleData *next; /* link to next tuple in same bucket */ uint32 hashvalue; /* tuple's hash code */ HeapTupleData htup; /* tuple header */ } HashJoinTupleData; @@ -86,21 +86,20 @@ typedef struct HashJoinTableData double totalTuples; /* # tuples obtained from inner plan */ /* - * These arrays are allocated for the life of the hash join, but - * only if nbatch > 1. A file is opened only when we first write - * a tuple into it (otherwise its pointer remains NULL). Note that - * the zero'th array elements never get used, since we will process - * rather than dump out any tuples of batch zero. + * These arrays are allocated for the life of the hash join, but only if + * nbatch > 1. A file is opened only when we first write a tuple into it + * (otherwise its pointer remains NULL). Note that the zero'th array + * elements never get used, since we will process rather than dump out any + * tuples of batch zero. */ BufFile **innerBatchFile; /* buffered virtual temp file per batch */ BufFile **outerBatchFile; /* buffered virtual temp file per batch */ /* - * Info about the datatype-specific hash functions for the datatypes - * being hashed. We assume that the inner and outer sides of each - * hashclause are the same type, or at least share the same hash - * function. This is an array of the same length as the number of hash - * keys. + * Info about the datatype-specific hash functions for the datatypes being + * hashed. We assume that the inner and outer sides of each hashclause + * are the same type, or at least share the same hash function. This is an + * array of the same length as the number of hash keys. */ FmgrInfo *hashfunctions; /* lookup data for hash functions */ diff --git a/src/include/executor/instrument.h b/src/include/executor/instrument.h index 47899fbcc2..3dad75e352 100644 --- a/src/include/executor/instrument.h +++ b/src/include/executor/instrument.h @@ -6,7 +6,7 @@ * * Copyright (c) 2001-2005, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/include/executor/instrument.h,v 1.11 2005/04/16 20:07:35 tgl Exp $ + * $PostgreSQL: pgsql/src/include/executor/instrument.h,v 1.12 2005/10/15 02:49:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -20,7 +20,7 @@ * gettimeofday() does not have sufficient resolution on Windows, * so we must use QueryPerformanceCounter() instead. These macros * also give some breathing room to use other high-precision-timing APIs - * on yet other platforms. (The macro-ization is not complete, however; + * on yet other platforms. (The macro-ization is not complete, however; * see subtraction code in instrument.c and explain.c.) */ #ifndef WIN32 @@ -32,8 +32,7 @@ typedef struct timeval instr_time; #define INSTR_TIME_SET_CURRENT(t) gettimeofday(&(t), NULL) #define INSTR_TIME_GET_DOUBLE(t) \ (((double) (t).tv_sec) + ((double) (t).tv_usec) / 1000000.0) - -#else /* WIN32 */ +#else /* WIN32 */ typedef LARGE_INTEGER instr_time; @@ -51,8 +50,7 @@ GetTimerFrequency(void) QueryPerformanceFrequency(&f); return (double) f.QuadPart; } - -#endif /* WIN32 */ +#endif /* WIN32 */ typedef struct Instrumentation diff --git a/src/include/executor/nodeHash.h b/src/include/executor/nodeHash.h index 678b2bd762..55715c8a60 100644 --- a/src/include/executor/nodeHash.h +++ b/src/include/executor/nodeHash.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/executor/nodeHash.h,v 1.37 2005/04/16 20:07:35 tgl Exp $ + * $PostgreSQL: pgsql/src/include/executor/nodeHash.h,v 1.38 2005/10/15 02:49:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -26,17 +26,17 @@ extern void ExecReScanHash(HashState *node, ExprContext *exprCtxt); extern HashJoinTable ExecHashTableCreate(Hash *node, List *hashOperators); extern void ExecHashTableDestroy(HashJoinTable hashtable); extern void ExecHashTableInsert(HashJoinTable hashtable, - HeapTuple tuple, - uint32 hashvalue); + HeapTuple tuple, + uint32 hashvalue); extern uint32 ExecHashGetHashValue(HashJoinTable hashtable, - ExprContext *econtext, - List *hashkeys); + ExprContext *econtext, + List *hashkeys); extern void ExecHashGetBucketAndBatch(HashJoinTable hashtable, - uint32 hashvalue, - int *bucketno, - int *batchno); + uint32 hashvalue, + int *bucketno, + int *batchno); extern HeapTuple ExecScanHashBucket(HashJoinState *hjstate, - ExprContext *econtext); + ExprContext *econtext); extern void ExecHashTableReset(HashJoinTable hashtable); extern void ExecChooseHashTableSize(double ntuples, int tupwidth, int *numbuckets, diff --git a/src/include/executor/nodeHashjoin.h b/src/include/executor/nodeHashjoin.h index 44e942317d..8590d6b189 100644 --- a/src/include/executor/nodeHashjoin.h +++ b/src/include/executor/nodeHashjoin.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/executor/nodeHashjoin.h,v 1.29 2005/03/06 22:15:05 tgl Exp $ + * $PostgreSQL: pgsql/src/include/executor/nodeHashjoin.h,v 1.30 2005/10/15 02:49:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -24,6 +24,6 @@ extern void ExecEndHashJoin(HashJoinState *node); extern void ExecReScanHashJoin(HashJoinState *node, ExprContext *exprCtxt); extern void ExecHashJoinSaveTuple(HeapTuple heapTuple, uint32 hashvalue, - BufFile **fileptr); + BufFile **fileptr); #endif /* NODEHASHJOIN_H */ diff --git a/src/include/executor/nodeIndexscan.h b/src/include/executor/nodeIndexscan.h index 69e7ea6ba9..7f280c892e 100644 --- a/src/include/executor/nodeIndexscan.h +++ b/src/include/executor/nodeIndexscan.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/executor/nodeIndexscan.h,v 1.23 2005/04/25 01:30:14 tgl Exp $ + * $PostgreSQL: pgsql/src/include/executor/nodeIndexscan.h,v 1.24 2005/10/15 02:49:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -30,8 +30,8 @@ extern bool ExecIndexBuildScanKeys(PlanState *planstate, List *quals, ExprState ***runtimeKeyInfo, ScanKey *scanKeys, int *numScanKeys); extern void ExecIndexEvalRuntimeKeys(ExprContext *econtext, - ExprState **run_keys, - ScanKey scan_keys, - int n_keys); + ExprState **run_keys, + ScanKey scan_keys, + int n_keys); #endif /* NODEINDEXSCAN_H */ diff --git a/src/include/executor/spi.h b/src/include/executor/spi.h index 23562c75e5..9f5e931640 100644 --- a/src/include/executor/spi.h +++ b/src/include/executor/spi.h @@ -2,7 +2,7 @@ * * spi.h * - * $PostgreSQL: pgsql/src/include/executor/spi.h,v 1.52 2005/05/02 00:37:06 neilc Exp $ + * $PostgreSQL: pgsql/src/include/executor/spi.h,v 1.53 2005/10/15 02:49:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -83,16 +83,16 @@ extern void SPI_push(void); extern void SPI_pop(void); extern void SPI_restore_connection(void); extern int SPI_execute(const char *src, bool read_only, long tcount); -extern int SPI_execute_plan(void *plan, Datum *Values, const char *Nulls, - bool read_only, long tcount); +extern int SPI_execute_plan(void *plan, Datum *Values, const char *Nulls, + bool read_only, long tcount); extern int SPI_exec(const char *src, long tcount); -extern int SPI_execp(void *plan, Datum *Values, const char *Nulls, - long tcount); -extern int SPI_execute_snapshot(void *plan, - Datum *Values, const char *Nulls, - Snapshot snapshot, - Snapshot crosscheck_snapshot, - bool read_only, long tcount); +extern int SPI_execp(void *plan, Datum *Values, const char *Nulls, + long tcount); +extern int SPI_execute_snapshot(void *plan, + Datum *Values, const char *Nulls, + Snapshot snapshot, + Snapshot crosscheck_snapshot, + bool read_only, long tcount); extern void *SPI_prepare(const char *src, int nargs, Oid *argtypes); extern void *SPI_saveplan(void *plan); extern int SPI_freeplan(void *plan); diff --git a/src/include/executor/spi_priv.h b/src/include/executor/spi_priv.h index a21bbc5e7c..267b3c5bd4 100644 --- a/src/include/executor/spi_priv.h +++ b/src/include/executor/spi_priv.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/executor/spi_priv.h,v 1.23 2005/10/01 18:43:19 tgl Exp $ + * $PostgreSQL: pgsql/src/include/executor/spi_priv.h,v 1.24 2005/10/15 02:49:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -26,7 +26,7 @@ typedef struct MemoryContext procCxt; /* procedure context */ MemoryContext execCxt; /* executor context */ MemoryContext savedcxt; - SubTransactionId connectSubid; /* ID of connecting subtransaction */ + SubTransactionId connectSubid; /* ID of connecting subtransaction */ } _SPI_connection; typedef struct diff --git a/src/include/executor/tuptable.h b/src/include/executor/tuptable.h index a5193683a2..882d377ed5 100644 --- a/src/include/executor/tuptable.h +++ b/src/include/executor/tuptable.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/executor/tuptable.h,v 1.28 2005/03/16 21:38:10 tgl Exp $ + * $PostgreSQL: pgsql/src/include/executor/tuptable.h,v 1.29 2005/10/15 02:49:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -37,17 +37,17 @@ * a lower plan node's output TupleTableSlot, or to a function result * constructed in a plan node's per-tuple econtext. It is the responsibility * of the generating plan node to be sure these resources are not released - * for as long as the virtual tuple needs to be valid. We only use virtual + * for as long as the virtual tuple needs to be valid. We only use virtual * tuples in the result slots of plan nodes --- tuples to be copied anywhere * else need to be "materialized" into physical tuples. Note also that a * virtual tuple does not have any "system columns". * * The Datum/isnull arrays of a TupleTableSlot serve double duty. When the - * slot contains a virtual tuple, they are the authoritative data. When the + * slot contains a virtual tuple, they are the authoritative data. When the * slot contains a physical tuple, the arrays contain data extracted from * the tuple. (In this state, any pass-by-reference Datums point into * the physical tuple.) The extracted information is built "lazily", - * ie, only as needed. This serves to avoid repeated extraction of data + * ie, only as needed. This serves to avoid repeated extraction of data * from the physical tuple. * * A TupleTableSlot can also be "empty", holding no valid data. This is @@ -70,7 +70,7 @@ * buffer page.) * * tts_nvalid indicates the number of valid columns in the tts_values/isnull - * arrays. When the slot is holding a "virtual" tuple this must be equal + * arrays. When the slot is holding a "virtual" tuple this must be equal * to the descriptor's natts. When the slot is holding a physical tuple * this is equal to the number of columns we have extracted (we always * extract columns from left to right, so there are no holes). @@ -85,8 +85,8 @@ typedef struct TupleTableSlot { NodeTag type; /* vestigial ... allows IsA tests */ - bool tts_isempty; /* true = slot is empty */ - bool tts_shouldFree; /* should pfree tuple? */ + bool tts_isempty; /* true = slot is empty */ + bool tts_shouldFree; /* should pfree tuple? */ bool tts_shouldFreeDesc; /* should pfree descriptor? */ bool tts_slow; /* saved state for slot_deform_tuple */ HeapTuple tts_tuple; /* physical tuple, or NULL if none */ @@ -137,7 +137,8 @@ extern HeapTuple ExecCopySlotTuple(TupleTableSlot *slot); extern HeapTuple ExecFetchSlotTuple(TupleTableSlot *slot); extern HeapTuple ExecMaterializeSlot(TupleTableSlot *slot); extern TupleTableSlot *ExecCopySlot(TupleTableSlot *dstslot, - TupleTableSlot *srcslot); + TupleTableSlot *srcslot); + /* in access/common/heaptuple.c */ extern Datum slot_getattr(TupleTableSlot *slot, int attnum, bool *isnull); extern void slot_getallattrs(TupleTableSlot *slot); diff --git a/src/include/fmgr.h b/src/include/fmgr.h index 1e60b45985..b7a85f15f5 100644 --- a/src/include/fmgr.h +++ b/src/include/fmgr.h @@ -11,7 +11,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/fmgr.h,v 1.39 2005/06/09 18:44:05 tgl Exp $ + * $PostgreSQL: pgsql/src/include/fmgr.h,v 1.40 2005/10/15 02:49:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -40,14 +40,11 @@ typedef Datum (*PGFunction) (FunctionCallInfo fcinfo); */ typedef struct FmgrInfo { - PGFunction fn_addr; /* pointer to function or handler to be - * called */ - Oid fn_oid; /* OID of function (NOT of handler, if - * any) */ + PGFunction fn_addr; /* pointer to function or handler to be called */ + Oid fn_oid; /* OID of function (NOT of handler, if any) */ short fn_nargs; /* 0..FUNC_MAX_ARGS, or -1 if variable arg * count */ - bool fn_strict; /* function is "strict" (NULL in => NULL - * out) */ + bool fn_strict; /* function is "strict" (NULL in => NULL out) */ bool fn_retset; /* function returns a set */ void *fn_extra; /* extra space for use by handler */ MemoryContext fn_mcxt; /* memory context to store fn_extra in */ @@ -62,8 +59,7 @@ typedef struct FunctionCallInfoData FmgrInfo *flinfo; /* ptr to lookup info used for this call */ fmNodePtr context; /* pass info about context of call */ fmNodePtr resultinfo; /* pass or return extra info about result */ - bool isnull; /* function must set true if result is - * NULL */ + bool isnull; /* function must set true if result is NULL */ short nargs; /* # arguments actually passed */ Datum arg[FUNC_MAX_ARGS]; /* Arguments passed to function */ bool argnull[FUNC_MAX_ARGS]; /* T if arg[i] is actually NULL */ @@ -91,7 +87,7 @@ extern void fmgr_info_copy(FmgrInfo *dstinfo, FmgrInfo *srcinfo, /* * This macro initializes all the fields of a FunctionCallInfoData except - * for the arg[] and argnull[] arrays. Performance testing has shown that + * for the arg[] and argnull[] arrays. Performance testing has shown that * the fastest way to set up argnull[] for small numbers of arguments is to * explicitly set each required element to false, so we don't try to zero * out the argnull[] array in the macro. @@ -290,8 +286,7 @@ extern struct varlena *pg_detoast_datum_slice(struct varlena * datum, typedef struct { - int api_version; /* specifies call convention version - * number */ + int api_version; /* specifies call convention version number */ /* More fields may be added later, for version numbers > 1. */ } Pg_finfo_record; diff --git a/src/include/funcapi.h b/src/include/funcapi.h index ddeec2930f..8357cdd6ed 100644 --- a/src/include/funcapi.h +++ b/src/include/funcapi.h @@ -9,7 +9,7 @@ * * Copyright (c) 2002-2005, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/include/funcapi.h,v 1.19 2005/10/06 19:51:15 tgl Exp $ + * $PostgreSQL: pgsql/src/include/funcapi.h,v 1.20 2005/10/15 02:49:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -67,9 +67,9 @@ typedef struct FuncCallContext /* * OPTIONAL maximum number of calls * - * max_calls is here for convenience only and setting it is optional. If - * not set, you must provide alternative means to know when the - * function is done. + * max_calls is here for convenience only and setting it is optional. If not + * set, you must provide alternative means to know when the function is + * done. */ uint32 max_calls; @@ -84,40 +84,38 @@ typedef struct FuncCallContext /* * OPTIONAL pointer to miscellaneous user-provided context information * - * user_fctx is for use as a pointer to your own struct to retain - * arbitrary context information between calls of your function. + * user_fctx is for use as a pointer to your own struct to retain arbitrary + * context information between calls of your function. */ void *user_fctx; /* * OPTIONAL pointer to struct containing attribute type input metadata * - * attinmeta is for use when returning tuples (i.e. composite data types) - * and is not used when returning base data types. It is only needed - * if you intend to use BuildTupleFromCStrings() to create the return - * tuple. + * attinmeta is for use when returning tuples (i.e. composite data types) and + * is not used when returning base data types. It is only needed if you + * intend to use BuildTupleFromCStrings() to create the return tuple. */ AttInMetadata *attinmeta; /* - * memory context used for structures that must live for multiple - * calls + * memory context used for structures that must live for multiple calls * - * multi_call_memory_ctx is set by SRF_FIRSTCALL_INIT() for you, and used - * by SRF_RETURN_DONE() for cleanup. It is the most appropriate memory - * context for any memory that is to be reused across multiple calls - * of the SRF. + * multi_call_memory_ctx is set by SRF_FIRSTCALL_INIT() for you, and used by + * SRF_RETURN_DONE() for cleanup. It is the most appropriate memory + * context for any memory that is to be reused across multiple calls of + * the SRF. */ MemoryContext multi_call_memory_ctx; /* * OPTIONAL pointer to struct containing tuple description * - * tuple_desc is for use when returning tuples (i.e. composite data - * types) and is only needed if you are going to build the tuples with - * heap_formtuple() rather than with BuildTupleFromCStrings(). Note - * that the TupleDesc pointer stored here should usually have been run - * through BlessTupleDesc() first. + * tuple_desc is for use when returning tuples (i.e. composite data types) + * and is only needed if you are going to build the tuples with + * heap_formtuple() rather than with BuildTupleFromCStrings(). Note that + * the TupleDesc pointer stored here should usually have been run through + * BlessTupleDesc() first. */ TupleDesc tuple_desc; @@ -128,23 +126,23 @@ typedef struct FuncCallContext * * External declarations: * get_call_result_type: - * Given a function's call info record, determine the kind of datatype - * it is supposed to return. If resultTypeId isn't NULL, *resultTypeId - * receives the actual datatype OID (this is mainly useful for scalar - * result types). If resultTupleDesc isn't NULL, *resultTupleDesc - * receives a pointer to a TupleDesc when the result is of a composite - * type, or NULL when it's a scalar result or the rowtype could not be - * determined. NB: the tupledesc should be copied if it is to be - * accessed over a long period. + * Given a function's call info record, determine the kind of datatype + * it is supposed to return. If resultTypeId isn't NULL, *resultTypeId + * receives the actual datatype OID (this is mainly useful for scalar + * result types). If resultTupleDesc isn't NULL, *resultTupleDesc + * receives a pointer to a TupleDesc when the result is of a composite + * type, or NULL when it's a scalar result or the rowtype could not be + * determined. NB: the tupledesc should be copied if it is to be + * accessed over a long period. * get_expr_result_type: - * Given an expression node, return the same info as for - * get_call_result_type. Note: the cases in which rowtypes cannot be - * determined are different from the cases for get_call_result_type. + * Given an expression node, return the same info as for + * get_call_result_type. Note: the cases in which rowtypes cannot be + * determined are different from the cases for get_call_result_type. * get_func_result_type: - * Given only a function's OID, return the same info as for - * get_call_result_type. Note: the cases in which rowtypes cannot be - * determined are different from the cases for get_call_result_type. - * Do *not* use this if you can use one of the others. + * Given only a function's OID, return the same info as for + * get_call_result_type. Note: the cases in which rowtypes cannot be + * determined are different from the cases for get_call_result_type. + * Do *not* use this if you can use one of the others. *---------- */ @@ -158,24 +156,24 @@ typedef enum TypeFuncClass } TypeFuncClass; extern TypeFuncClass get_call_result_type(FunctionCallInfo fcinfo, - Oid *resultTypeId, - TupleDesc *resultTupleDesc); + Oid *resultTypeId, + TupleDesc *resultTupleDesc); extern TypeFuncClass get_expr_result_type(Node *expr, - Oid *resultTypeId, - TupleDesc *resultTupleDesc); + Oid *resultTypeId, + TupleDesc *resultTupleDesc); extern TypeFuncClass get_func_result_type(Oid functionId, - Oid *resultTypeId, - TupleDesc *resultTupleDesc); + Oid *resultTypeId, + TupleDesc *resultTupleDesc); extern char *get_func_result_name(Oid functionId); extern bool resolve_polymorphic_argtypes(int numargs, Oid *argtypes, - char *argmodes, - Node *call_expr); + char *argmodes, + Node *call_expr); extern TupleDesc build_function_result_tupdesc_d(Datum proallargtypes, - Datum proargmodes, - Datum proargnames); + Datum proargmodes, + Datum proargnames); extern TupleDesc build_function_result_tupdesc_t(HeapTuple procTuple); diff --git a/src/include/getaddrinfo.h b/src/include/getaddrinfo.h index 3561aac091..f0a3a82020 100644 --- a/src/include/getaddrinfo.h +++ b/src/include/getaddrinfo.h @@ -15,7 +15,7 @@ * * Copyright (c) 2003-2005, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/include/getaddrinfo.h,v 1.16 2005/08/25 17:50:59 tgl Exp $ + * $PostgreSQL: pgsql/src/include/getaddrinfo.h,v 1.17 2005/10/15 02:49:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -41,7 +41,7 @@ #define EAI_SERVICE (-8) #define EAI_MEMORY (-10) #define EAI_SYSTEM (-11) -#else /* WIN32 */ +#else /* WIN32 */ #define EAI_AGAIN WSATRY_AGAIN #define EAI_BADFLAGS WSAEINVAL #define EAI_FAIL WSANO_RECOVERY @@ -50,9 +50,9 @@ #define EAI_NODATA WSANO_DATA #define EAI_NONAME WSAHOST_NOT_FOUND #define EAI_SERVICE WSATYPE_NOT_FOUND -#define EAI_SOCKTYPE WSAESOCKTNOSUPPORT -#endif /* !WIN32 */ -#endif /* !EAI_FAIL */ +#define EAI_SOCKTYPE WSAESOCKTNOSUPPORT +#endif /* !WIN32 */ +#endif /* !EAI_FAIL */ #ifndef AI_PASSIVE #define AI_PASSIVE 0x0001 diff --git a/src/include/lib/dllist.h b/src/include/lib/dllist.h index d6813caab2..b0194e91bf 100644 --- a/src/include/lib/dllist.h +++ b/src/include/lib/dllist.h @@ -34,7 +34,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/lib/dllist.h,v 1.24 2004/12/31 22:03:31 pgsql Exp $ + * $PostgreSQL: pgsql/src/include/lib/dllist.h,v 1.25 2005/10/15 02:49:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -61,8 +61,8 @@ typedef struct Dllist extern Dllist *DLNewList(void); /* allocate and initialize a list header */ extern void DLInitList(Dllist *list); /* init a header alloced by caller */ -extern void DLFreeList(Dllist *list); /* free up a list and all the - * nodes in it */ +extern void DLFreeList(Dllist *list); /* free up a list and all the nodes in + * it */ extern Dlelem *DLNewElem(void *val); extern void DLInitElem(Dlelem *e, void *val); extern void DLFreeElem(Dlelem *e); diff --git a/src/include/libpq/auth.h b/src/include/libpq/auth.h index 9f93b7fdf8..95002d0977 100644 --- a/src/include/libpq/auth.h +++ b/src/include/libpq/auth.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/libpq/auth.h,v 1.29 2005/06/27 02:04:25 neilc Exp $ + * $PostgreSQL: pgsql/src/include/libpq/auth.h,v 1.30 2005/10/15 02:49:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -23,7 +23,7 @@ extern void ClientAuthentication(Port *port); -#define PG_KRB5_VERSION "PGVER5.1" /* at most KRB_SENDAUTH_VLEN chars */ +#define PG_KRB5_VERSION "PGVER5.1" /* at most KRB_SENDAUTH_VLEN chars */ extern char *pg_krb_server_keyfile; extern char *pg_krb_srvnam; diff --git a/src/include/libpq/be-fsstubs.h b/src/include/libpq/be-fsstubs.h index 1307293b25..117768fd8c 100644 --- a/src/include/libpq/be-fsstubs.h +++ b/src/include/libpq/be-fsstubs.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/libpq/be-fsstubs.h,v 1.24 2005/06/13 02:26:51 tgl Exp $ + * $PostgreSQL: pgsql/src/include/libpq/be-fsstubs.h,v 1.25 2005/10/15 02:49:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -48,6 +48,6 @@ extern int lo_write(int fd, char *buf, int len); */ extern void AtEOXact_LargeObject(bool isCommit); extern void AtEOSubXact_LargeObject(bool isCommit, SubTransactionId mySubid, - SubTransactionId parentSubid); + SubTransactionId parentSubid); #endif /* BE_FSSTUBS_H */ diff --git a/src/include/libpq/hba.h b/src/include/libpq/hba.h index 3809498114..5251db1c05 100644 --- a/src/include/libpq/hba.h +++ b/src/include/libpq/hba.h @@ -4,7 +4,7 @@ * Interface to hba.c * * - * $PostgreSQL: pgsql/src/include/libpq/hba.h,v 1.40 2005/08/11 21:11:48 tgl Exp $ + * $PostgreSQL: pgsql/src/include/libpq/hba.h,v 1.41 2005/10/15 02:49:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -36,8 +36,8 @@ extern void load_ident(void); extern void load_role(void); extern int hba_getauthmethod(hbaPort *port); extern int authident(hbaPort *port); -extern bool read_pg_database_line(FILE *fp, char *dbname, Oid *dboid, - Oid *dbtablespace, TransactionId *dbfrozenxid, - TransactionId *dbvacuumxid); +extern bool read_pg_database_line(FILE *fp, char *dbname, Oid *dboid, + Oid *dbtablespace, TransactionId *dbfrozenxid, + TransactionId *dbvacuumxid); -#endif /* HBA_H */ +#endif /* HBA_H */ diff --git a/src/include/libpq/libpq-be.h b/src/include/libpq/libpq-be.h index b7d8e36582..465abdbd38 100644 --- a/src/include/libpq/libpq-be.h +++ b/src/include/libpq/libpq-be.h @@ -11,7 +11,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/libpq/libpq-be.h,v 1.51 2005/09/12 02:26:33 tgl Exp $ + * $PostgreSQL: pgsql/src/include/libpq/libpq-be.h,v 1.52 2005/10/15 02:49:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -58,10 +58,9 @@ typedef struct Port CAC_state canAcceptConnections; /* postmaster connection status */ /* - * Information that needs to be saved from the startup packet and - * passed into backend execution. "char *" fields are NULL if not - * set. guc_options points to a List of alternating option names and - * values. + * Information that needs to be saved from the startup packet and passed + * into backend execution. "char *" fields are NULL if not set. + * guc_options points to a List of alternating option names and values. */ char *database_name; char *user_name; @@ -77,10 +76,9 @@ typedef struct Port char cryptSalt[2]; /* Password salt */ /* - * Information that really has no business at all being in struct - * Port, but since it gets used by elog.c in the same way as - * database_name and other members of this struct, we may as well keep - * it here. + * Information that really has no business at all being in struct Port, + * but since it gets used by elog.c in the same way as database_name and + * other members of this struct, we may as well keep it here. */ const char *commandTag; /* current command tag */ struct timeval session_start; /* for session duration logging */ @@ -88,17 +86,16 @@ typedef struct Port /* * TCP keepalive settings. * - * default values are 0 if AF_UNIX or not yet known; - * current values are 0 if AF_UNIX or using the default. - * Also, -1 in a default value means we were unable to find out the - * default (getsockopt failed). + * default values are 0 if AF_UNIX or not yet known; current values are 0 if + * AF_UNIX or using the default. Also, -1 in a default value means we were + * unable to find out the default (getsockopt failed). */ - int default_keepalives_idle; - int default_keepalives_interval; - int default_keepalives_count; - int keepalives_idle; - int keepalives_interval; - int keepalives_count; + int default_keepalives_idle; + int default_keepalives_interval; + int default_keepalives_count; + int keepalives_idle; + int keepalives_interval; + int keepalives_count; /* * SSL structures @@ -117,12 +114,12 @@ extern ProtocolVersion FrontendProtocol; /* TCP keepalives configuration. These are no-ops on an AF_UNIX socket. */ -extern int pq_getkeepalivesidle(Port *port); -extern int pq_getkeepalivesinterval(Port *port); -extern int pq_getkeepalivescount(Port *port); +extern int pq_getkeepalivesidle(Port *port); +extern int pq_getkeepalivesinterval(Port *port); +extern int pq_getkeepalivescount(Port *port); -extern int pq_setkeepalivesidle(int idle, Port *port); -extern int pq_setkeepalivesinterval(int interval, Port *port); -extern int pq_setkeepalivescount(int count, Port *port); +extern int pq_setkeepalivesidle(int idle, Port *port); +extern int pq_setkeepalivesinterval(int interval, Port *port); +extern int pq_setkeepalivescount(int count, Port *port); #endif /* LIBPQ_BE_H */ diff --git a/src/include/libpq/libpq.h b/src/include/libpq/libpq.h index ed19e91c33..4514be24dc 100644 --- a/src/include/libpq/libpq.h +++ b/src/include/libpq/libpq.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/libpq/libpq.h,v 1.64 2004/12/31 22:03:32 pgsql Exp $ + * $PostgreSQL: pgsql/src/include/libpq/libpq.h,v 1.65 2005/10/15 02:49:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -46,7 +46,7 @@ typedef struct * prototypes for functions in pqcomm.c */ extern int StreamServerPort(int family, char *hostName, - unsigned short portNumber, char *unixSocketName, int ListenSocket[], + unsigned short portNumber, char *unixSocketName, int ListenSocket[], int MaxListen); extern int StreamConnection(int server_fd, Port *port); extern void StreamClose(int sock); diff --git a/src/include/libpq/pqcomm.h b/src/include/libpq/pqcomm.h index 830237d001..c2c62a4a19 100644 --- a/src/include/libpq/pqcomm.h +++ b/src/include/libpq/pqcomm.h @@ -9,7 +9,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/libpq/pqcomm.h,v 1.97 2005/06/27 02:04:26 neilc Exp $ + * $PostgreSQL: pgsql/src/include/libpq/pqcomm.h,v 1.98 2005/10/15 02:49:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -46,7 +46,6 @@ #define ss_len __ss_len #define HAVE_STRUCT_SOCKADDR_STORAGE_SS_LEN 1 #endif - #else /* !HAVE_STRUCT_SOCKADDR_STORAGE */ /* Define a struct sockaddr_storage if we don't have one. */ @@ -183,8 +182,7 @@ typedef uint32 AuthRequest; typedef struct CancelRequestPacket { /* Note that each field is stored in network byte order! */ - MsgType cancelRequestCode; /* code to identify a cancel - * request */ + MsgType cancelRequestCode; /* code to identify a cancel request */ uint32 backendPID; /* PID of client's backend */ uint32 cancelAuthCode; /* secret key to authorize cancel */ } CancelRequestPacket; diff --git a/src/include/mb/pg_wchar.h b/src/include/mb/pg_wchar.h index c926330dd7..cf4b2cd2c4 100644 --- a/src/include/mb/pg_wchar.h +++ b/src/include/mb/pg_wchar.h @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/include/mb/pg_wchar.h,v 1.62 2005/09/24 17:53:27 tgl Exp $ */ +/* $PostgreSQL: pgsql/src/include/mb/pg_wchar.h,v 1.63 2005/10/15 02:49:45 momjian Exp $ */ #ifndef PG_WCHAR_H #define PG_WCHAR_H @@ -92,36 +92,34 @@ typedef unsigned int pg_wchar; #define LC_CNS11643_1 0x95 /* CNS 11643-1992 Plane 1 */ #define LC_CNS11643_2 0x96 /* CNS 11643-1992 Plane 2 */ /* #define FREE 0x97 free (unused) */ -#define LC_BIG5_1 0x98 /* Plane 1 Chinese traditional (not - * supported) */ -#define LC_BIG5_2 0x99 /* Plane 1 Chinese traditional (not - * supported) */ +#define LC_BIG5_1 0x98 /* Plane 1 Chinese traditional (not supported) */ +#define LC_BIG5_2 0x99 /* Plane 1 Chinese traditional (not supported) */ /* * Private single byte encodings (0xa0-0xef) */ #define LC_SISHENG 0xa0 /* Chinese SiSheng characters for * PinYin/ZhuYin (not supported) */ -#define LC_IPA 0xa1 /* IPA (International Phonetic - * Association) (not supported) */ +#define LC_IPA 0xa1 /* IPA (International Phonetic Association) + * (not supported) */ #define LC_VISCII_LOWER 0xa2 /* Vietnamese VISCII1.1 lower-case (not * supported) */ #define LC_VISCII_UPPER 0xa3 /* Vietnamese VISCII1.1 upper-case (not * supported) */ #define LC_ARABIC_DIGIT 0xa4 /* Arabic digit (not supported) */ #define LC_ARABIC_1_COLUMN 0xa5 /* Arabic 1-column (not supported) */ -#define LC_ASCII_RIGHT_TO_LEFT 0xa6 /* ASCII (left half of ISO8859-1) - * with right-to-left direction - * (not supported) */ -#define LC_LAO 0xa7 /* Lao characters (ISO10646 0E80..0EDF) - * (not supported) */ +#define LC_ASCII_RIGHT_TO_LEFT 0xa6 /* ASCII (left half of ISO8859-1) with + * right-to-left direction (not + * supported) */ +#define LC_LAO 0xa7 /* Lao characters (ISO10646 0E80..0EDF) (not + * supported) */ #define LC_ARABIC_2_COLUMN 0xa8 /* Arabic 1-column (not supported) */ /* * Private multibyte encodings (0xf0-0xff) */ -#define LC_INDIAN_1_COLUMN 0xf0/* Indian charset for 1-column width - * glypps (not supported) */ +#define LC_INDIAN_1_COLUMN 0xf0/* Indian charset for 1-column width glypps + * (not supported) */ #define LC_TIBETAN_1_COLUMN 0xf1 /* Tibetan 1 column glyph (not supported) */ #define LC_ETHIOPIC 0xf5 /* Ethiopic characters (not supported) */ #define LC_CNS11643_3 0xf6 /* CNS 11643-1992 Plane 3 */ @@ -129,8 +127,8 @@ typedef unsigned int pg_wchar; #define LC_CNS11643_5 0xf8 /* CNS 11643-1992 Plane 5 */ #define LC_CNS11643_6 0xf9 /* CNS 11643-1992 Plane 6 */ #define LC_CNS11643_7 0xfa /* CNS 11643-1992 Plane 7 */ -#define LC_INDIAN_2_COLUMN 0xfb/* Indian charset for 2-column width - * glypps (not supported) */ +#define LC_INDIAN_2_COLUMN 0xfb/* Indian charset for 2-column width glypps + * (not supported) */ #define LC_TIBETAN 0xfc /* Tibetan (not supported) */ /* #define FREE 0xfd free (unused) */ /* #define FREE 0xfe free (unused) */ @@ -255,8 +253,8 @@ typedef struct mb2wchar_with_len_converter mb2wchar_with_len; /* convert a multibyte * string to a wchar */ mblen_converter mblen; /* returns the length of a multibyte char */ - mbdisplaylen_converter dsplen; /* returns the lenghth of a - * display length */ + mbdisplaylen_converter dsplen; /* returns the lenghth of a display + * length */ int maxmblen; /* max bytes for a char in this charset */ } pg_wchar_tbl; diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h index 04cab28e39..a2a802cacc 100644 --- a/src/include/miscadmin.h +++ b/src/include/miscadmin.h @@ -13,7 +13,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/miscadmin.h,v 1.179 2005/08/17 22:14:34 tgl Exp $ + * $PostgreSQL: pgsql/src/include/miscadmin.h,v 1.180 2005/10/15 02:49:41 momjian Exp $ * * NOTES * some of the information in this file should be moved to other files. @@ -83,7 +83,6 @@ do { \ if (InterruptPending) \ ProcessInterrupts(); \ } while(0) - #else /* WIN32 */ #define CHECK_FOR_INTERRUPTS() \ @@ -229,15 +228,15 @@ extern char *DatabasePath; extern void SetDatabasePath(const char *path); extern char *GetUserNameFromId(Oid roleid); -extern Oid GetUserId(void); +extern Oid GetUserId(void); extern void SetUserId(Oid userid); -extern Oid GetOuterUserId(void); -extern Oid GetSessionUserId(void); +extern Oid GetOuterUserId(void); +extern Oid GetSessionUserId(void); extern void InitializeSessionUserId(const char *rolename); extern void InitializeSessionUserIdStandalone(void); extern void AtAbort_UserId(void); extern void SetSessionAuthorization(Oid userid, bool is_superuser); -extern Oid GetCurrentRoleId(void); +extern Oid GetCurrentRoleId(void); extern void SetCurrentRoleId(Oid roleid, bool is_superuser); extern void SetDataDir(const char *dir); @@ -246,7 +245,7 @@ extern char *make_absolute_path(const char *path); /* in utils/misc/superuser.c */ extern bool superuser(void); /* current user is superuser */ -extern bool superuser_arg(Oid roleid); /* given user is superuser */ +extern bool superuser_arg(Oid roleid); /* given user is superuser */ /***************************************************************************** diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h index 5e68eae527..8b06e2897d 100644 --- a/src/include/nodes/execnodes.h +++ b/src/include/nodes/execnodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/nodes/execnodes.h,v 1.138 2005/09/25 19:37:35 tgl Exp $ + * $PostgreSQL: pgsql/src/include/nodes/execnodes.h,v 1.139 2005/10/15 02:49:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -180,7 +180,7 @@ typedef struct ReturnSetInfo * ExecProject() evaluates the tlist, forms a tuple, and stores it * in the given slot. Note that the result will be a "virtual" tuple * unless ExecMaterializeSlot() is then called to force it to be - * converted to a physical tuple. The slot must have a tupledesc + * converted to a physical tuple. The slot must have a tupledesc * that matches the output of the tlist! * * The planner very often produces tlists that consist entirely of @@ -301,8 +301,7 @@ typedef struct EState /* Info about target table for insert/update/delete queries: */ ResultRelInfo *es_result_relations; /* array of ResultRelInfos */ int es_num_result_relations; /* length of array */ - ResultRelInfo *es_result_relation_info; /* currently active array - * elt */ + ResultRelInfo *es_result_relation_info; /* currently active array elt */ JunkFilter *es_junkFilter; /* currently active junk filter */ Relation es_into_relation_descriptor; /* for SELECT INTO */ @@ -330,17 +329,15 @@ typedef struct EState List *es_exprcontexts; /* List of ExprContexts within EState */ /* - * this ExprContext is for per-output-tuple operations, such as - * constraint checks and index-value computations. It will be reset - * for each output tuple. Note that it will be created only if - * needed. + * this ExprContext is for per-output-tuple operations, such as constraint + * checks and index-value computations. It will be reset for each output + * tuple. Note that it will be created only if needed. */ ExprContext *es_per_tuple_exprcontext; /* Below is to re-evaluate plan qual in READ COMMITTED mode */ Plan *es_topPlan; /* link to top of plan tree */ - struct evalPlanQual *es_evalPlanQual; /* chain of PlanQual - * states */ + struct evalPlanQual *es_evalPlanQual; /* chain of PlanQual states */ bool *es_evTupleNull; /* local array of EPQ status */ HeapTuple *es_evTuple; /* shared array of EPQ substitute tuples */ bool es_useEvalPlan; /* evaluating EPQ tuples? */ @@ -483,40 +480,39 @@ typedef struct FuncExprState List *args; /* states of argument expressions */ /* - * Function manager's lookup info for the target function. If - * func.fn_oid is InvalidOid, we haven't initialized it yet. + * Function manager's lookup info for the target function. If func.fn_oid + * is InvalidOid, we haven't initialized it yet. */ FmgrInfo func; /* - * We also need to store argument values across calls when evaluating - * a function-returning-set. + * We also need to store argument values across calls when evaluating a + * function-returning-set. * - * setArgsValid is true when we are evaluating a set-valued function and - * we are in the middle of a call series; we want to pass the same - * argument values to the function again (and again, until it returns + * setArgsValid is true when we are evaluating a set-valued function and we + * are in the middle of a call series; we want to pass the same argument + * values to the function again (and again, until it returns * ExprEndResult). */ bool setArgsValid; /* * Flag to remember whether we found a set-valued argument to the - * function. This causes the function result to be a set as well. - * Valid only when setArgsValid is true. + * function. This causes the function result to be a set as well. Valid + * only when setArgsValid is true. */ bool setHasSetArg; /* some argument returns a set */ /* * Flag to remember whether we have registered a shutdown callback for * this FuncExprState. We do so only if setArgsValid has been true at - * least once (since all the callback is for is to clear - * setArgsValid). + * least once (since all the callback is for is to clear setArgsValid). */ bool shutdown_reg; /* a shutdown callback is registered */ /* - * Current argument data for a set-valued function; contains valid - * data only if setArgsValid is true. + * Current argument data for a set-valued function; contains valid data + * only if setArgsValid is true. */ FunctionCallInfoData setArgs; } FuncExprState; @@ -740,25 +736,24 @@ typedef struct PlanState Plan *plan; /* associated Plan node */ - EState *state; /* at execution time, state's of - * individual nodes point to one EState - * for the whole top-level plan */ + EState *state; /* at execution time, state's of individual + * nodes point to one EState for the whole + * top-level plan */ struct Instrumentation *instrument; /* Optional runtime stats for this * plan node */ /* - * Common structural data for all Plan types. These links to - * subsidiary state trees parallel links in the associated plan tree - * (except for the subPlan list, which does not exist in the plan - * tree). + * Common structural data for all Plan types. These links to subsidiary + * state trees parallel links in the associated plan tree (except for the + * subPlan list, which does not exist in the plan tree). */ List *targetlist; /* target list to be computed at this node */ List *qual; /* implicitly-ANDed qual conditions */ struct PlanState *lefttree; /* input plan tree(s) */ struct PlanState *righttree; - List *initPlan; /* Init SubPlanState nodes (un-correlated - * expr subselects) */ + List *initPlan; /* Init SubPlanState nodes (un-correlated expr + * subselects) */ List *subPlan; /* SubPlanState nodes in my expressions */ /* @@ -1065,7 +1060,7 @@ typedef struct MergeJoinState { JoinState js; /* its first field is NodeTag */ int mj_NumClauses; - MergeJoinClause mj_Clauses; /* array of length mj_NumClauses */ + MergeJoinClause mj_Clauses; /* array of length mj_NumClauses */ int mj_JoinState; bool mj_FillOuter; bool mj_FillInner; diff --git a/src/include/nodes/makefuncs.h b/src/include/nodes/makefuncs.h index 52444d258b..9fb10ee660 100644 --- a/src/include/nodes/makefuncs.h +++ b/src/include/nodes/makefuncs.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/nodes/makefuncs.h,v 1.52 2005/04/06 16:34:07 tgl Exp $ + * $PostgreSQL: pgsql/src/include/nodes/makefuncs.h,v 1.53 2005/10/15 02:49:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -30,9 +30,9 @@ extern Var *makeVar(Index varno, Index varlevelsup); extern TargetEntry *makeTargetEntry(Expr *expr, - AttrNumber resno, - char *resname, - bool resjunk); + AttrNumber resno, + char *resname, + bool resjunk); extern TargetEntry *flatCopyTargetEntry(TargetEntry *src_tle); diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h index bc98075712..327e4301ff 100644 --- a/src/include/nodes/nodes.h +++ b/src/include/nodes/nodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/nodes/nodes.h,v 1.175 2005/08/01 20:31:15 tgl Exp $ + * $PostgreSQL: pgsql/src/include/nodes/nodes.h,v 1.176 2005/10/15 02:49:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -141,8 +141,8 @@ typedef enum NodeTag /* * TAGS FOR EXPRESSION STATE NODES (execnodes.h) * - * These correspond (not always one-for-one) to primitive nodes derived - * from Expr. + * These correspond (not always one-for-one) to primitive nodes derived from + * Expr. */ T_ExprState = 400, T_GenericExprState, @@ -322,8 +322,8 @@ typedef enum NodeTag * * These are objects that aren't part of parse/plan/execute node tree * structures, but we give them NodeTags anyway for identification - * purposes (usually because they are involved in APIs where we want - * to pass multiple object types through the same pointer). + * purposes (usually because they are involved in APIs where we want to + * pass multiple object types through the same pointer). */ T_TriggerData = 900, /* in commands/trigger.h */ T_ReturnSetInfo, /* in nodes/execnodes.h */ @@ -406,8 +406,7 @@ extern bool equal(void *a, void *b); * These could have gone into plannodes.h or some such, but many files * depend on them... */ -typedef double Selectivity; /* fraction of tuples a qualifier will - * pass */ +typedef double Selectivity; /* fraction of tuples a qualifier will pass */ typedef double Cost; /* execution cost (in page-access units) */ @@ -425,8 +424,8 @@ typedef enum CmdType CMD_UPDATE, /* update stmt (formerly replace) */ CMD_INSERT, /* insert stmt (formerly append) */ CMD_DELETE, - CMD_UTILITY, /* cmds like create, destroy, copy, - * vacuum, etc. */ + CMD_UTILITY, /* cmds like create, destroy, copy, vacuum, + * etc. */ CMD_NOTHING /* dummy command for instead nothing rules * with qual */ } CmdType; @@ -449,22 +448,20 @@ typedef enum JoinType */ JOIN_INNER, /* matching tuple pairs only */ JOIN_LEFT, /* pairs + unmatched outer tuples */ - JOIN_FULL, /* pairs + unmatched outer + unmatched - * inner */ + JOIN_FULL, /* pairs + unmatched outer + unmatched inner */ JOIN_RIGHT, /* pairs + unmatched inner tuples */ /* - * SQL92 considers UNION JOIN to be a kind of join, so list it here - * for parser convenience, even though it's not implemented like a - * join in the executor. (The planner must convert it to an Append - * plan.) + * SQL92 considers UNION JOIN to be a kind of join, so list it here for + * parser convenience, even though it's not implemented like a join in the + * executor. (The planner must convert it to an Append plan.) */ JOIN_UNION, /* * These are used for queries like WHERE foo IN (SELECT bar FROM ...). - * Only JOIN_IN is actually implemented in the executor; the others - * are defined for internal use in the planner. + * Only JOIN_IN is actually implemented in the executor; the others are + * defined for internal use in the planner. */ JOIN_IN, /* at most one result per outer row */ JOIN_REVERSE_IN, /* at most one result per inner row */ diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h index 70c6743ac1..766076b7d6 100644 --- a/src/include/nodes/parsenodes.h +++ b/src/include/nodes/parsenodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.290 2005/08/23 22:40:47 tgl Exp $ + * $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.291 2005/10/15 02:49:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -87,14 +87,13 @@ typedef struct Query bool hasSubLinks; /* has subquery SubLink */ List *rtable; /* list of range table entries */ - FromExpr *jointree; /* table join tree (FROM and WHERE - * clauses) */ + FromExpr *jointree; /* table join tree (FROM and WHERE clauses) */ List *rowMarks; /* integer list of RT indexes of relations * that are selected FOR UPDATE/SHARE */ - bool forUpdate; /* true if rowMarks are FOR UPDATE, - * false if they are FOR SHARE */ + bool forUpdate; /* true if rowMarks are FOR UPDATE, false if + * they are FOR SHARE */ bool rowNoWait; /* FOR UPDATE/SHARE NOWAIT option */ List *targetList; /* target list (of TargetEntry) */ @@ -110,16 +109,16 @@ typedef struct Query Node *limitOffset; /* # of result tuples to skip */ Node *limitCount; /* # of result tuples to return */ - Node *setOperations; /* set-operation tree if this is top level - * of a UNION/INTERSECT/EXCEPT query */ + Node *setOperations; /* set-operation tree if this is top level of + * a UNION/INTERSECT/EXCEPT query */ /* * If the resultRelation turns out to be the parent of an inheritance - * tree, the planner will add all the child tables to the rtable and - * store a list of the rtindexes of all the result relations here. - * This is done at plan time, not parse time, since we don't want to - * commit to the exact set of child tables at parse time. This field - * ought to go in some sort of TopPlan plan node, not in the Query. + * tree, the planner will add all the child tables to the rtable and store + * a list of the rtindexes of all the result relations here. This is done + * at plan time, not parse time, since we don't want to commit to the + * exact set of child tables at parse time. This field ought to go in + * some sort of TopPlan plan node, not in the Query. */ List *resultRelations; /* integer list of RT indexes, or NIL */ } Query; @@ -305,8 +304,7 @@ typedef struct ResTarget NodeTag type; char *name; /* column name or NULL */ List *indirection; /* subscripts and field names, or NIL */ - Node *val; /* the value expression to compute or - * assign */ + Node *val; /* the value expression to compute or assign */ } ResTarget; /* @@ -373,8 +371,7 @@ typedef struct ColumnDef int inhcount; /* number of times column is inherited */ bool is_local; /* column has local (non-inherited) def'n */ bool is_not_null; /* NOT NULL constraint specified? */ - Node *raw_default; /* default value (untransformed parse - * tree) */ + Node *raw_default; /* default value (untransformed parse tree) */ char *cooked_default; /* nodeToString representation */ List *constraints; /* other constraints on column */ RangeVar *support; /* supporting relation, if any */ @@ -419,7 +416,7 @@ typedef struct DefElem /* * LockingClause - raw representation of FOR UPDATE/SHARE options * - * Note: lockedRels == NIL means "all relations in query". Otherwise it + * Note: lockedRels == NIL means "all relations in query". Otherwise it * is a list of String nodes giving relation eref names. */ typedef struct LockingClause @@ -470,7 +467,7 @@ typedef struct LockingClause * a stored rule might contain entries for columns dropped since the rule * was created. (This is only possible for columns not actually referenced * in the rule.) When loading a stored rule, we replace the joinaliasvars - * items for any such columns with NULL Consts. (We can't simply delete + * items for any such columns with NULL Consts. (We can't simply delete * them from the joinaliasvars list, because that would affect the attnums * of Vars referencing the rest of the list.) * @@ -513,9 +510,9 @@ typedef struct RangeTblEntry RTEKind rtekind; /* see above */ /* - * XXX the fields applicable to only some rte kinds should be merged - * into a union. I didn't do this yet because the diffs would impact - * a lot of code that is being actively worked on. FIXME later. + * XXX the fields applicable to only some rte kinds should be merged into + * a union. I didn't do this yet because the diffs would impact a lot of + * code that is being actively worked on. FIXME later. */ /* @@ -538,14 +535,13 @@ typedef struct RangeTblEntry /* * Fields valid for a join RTE (else NULL/zero): * - * joinaliasvars is a list of Vars or COALESCE expressions corresponding - * to the columns of the join result. An alias Var referencing column - * K of the join result can be replaced by the K'th element of - * joinaliasvars --- but to simplify the task of reverse-listing - * aliases correctly, we do not do that until planning time. In a Query - * loaded from a stored rule, it is also possible for joinaliasvars - * items to be NULL Consts, denoting columns dropped since the rule was - * made. + * joinaliasvars is a list of Vars or COALESCE expressions corresponding to + * the columns of the join result. An alias Var referencing column K of + * the join result can be replaced by the K'th element of joinaliasvars + * --- but to simplify the task of reverse-listing aliases correctly, we + * do not do that until planning time. In a Query loaded from a stored + * rule, it is also possible for joinaliasvars items to be NULL Consts, + * denoting columns dropped since the rule was made. */ JoinType jointype; /* type of join */ List *joinaliasvars; /* list of alias-var expansions */ @@ -610,8 +606,8 @@ typedef struct InsertStmt /* * An INSERT statement has *either* VALUES or SELECT, never both. If - * VALUES, a targetList is supplied (empty for DEFAULT VALUES). If - * SELECT, a complete SelectStmt (or set-operation tree) is supplied. + * VALUES, a targetList is supplied (empty for DEFAULT VALUES). If SELECT, + * a complete SelectStmt (or set-operation tree) is supplied. */ List *targetList; /* the target list (of ResTarget) */ Node *selectStmt; /* the source SELECT */ @@ -667,9 +663,9 @@ typedef enum ContainsOids { MUST_HAVE_OIDS, /* WITH OIDS explicitely specified */ MUST_NOT_HAVE_OIDS, /* WITHOUT OIDS explicitely specified */ - DEFAULT_OIDS /* neither specified; use the default, - * which is the value of the - * default_with_oids GUC var */ + DEFAULT_OIDS /* neither specified; use the default, which + * is the value of the default_with_oids GUC + * var */ } ContainsOids; typedef struct SelectStmt @@ -683,8 +679,7 @@ typedef struct SelectStmt * else... */ List *distinctClause; /* NULL, list of DISTINCT ON exprs, or - * lcons(NIL,NIL) for all (SELECT - * DISTINCT) */ + * lcons(NIL,NIL) for all (SELECT DISTINCT) */ RangeVar *into; /* target table (for select into table) */ List *intoColNames; /* column names for into table */ ContainsOids intoHasOids; /* should target table have OIDs? */ @@ -701,7 +696,7 @@ typedef struct SelectStmt List *sortClause; /* sort clause (a list of SortBy's) */ Node *limitOffset; /* # of result tuples to skip */ Node *limitCount; /* # of result tuples to return */ - LockingClause *lockingClause; /* FOR UPDATE/FOR SHARE */ + LockingClause *lockingClause; /* FOR UPDATE/FOR SHARE */ /* * These fields are used only in upper-level SelectStmts. @@ -829,8 +824,8 @@ typedef enum AlterTableType AT_ProcessedConstraint, /* pre-processed add constraint (local in * parser/analyze.c) */ AT_DropConstraint, /* drop constraint */ - AT_DropConstraintQuietly, /* drop constraint, no error/warning - * (local in commands/tablecmds.c) */ + AT_DropConstraintQuietly, /* drop constraint, no error/warning (local in + * commands/tablecmds.c) */ AT_AlterColumnType, /* alter column type */ AT_ToastTable, /* create toast table */ AT_ChangeOwner, /* change owner */ @@ -903,9 +898,8 @@ typedef struct GrantStmt NodeTag type; bool is_grant; /* true = GRANT, false = REVOKE */ GrantObjectType objtype; /* kind of object being operated on */ - List *objects; /* list of RangeVar nodes, FuncWithArgs - * nodes, or plain names (as Value - * strings) */ + List *objects; /* list of RangeVar nodes, FuncWithArgs nodes, + * or plain names (as Value strings) */ List *privileges; /* list of privilege names (as Strings) */ /* privileges == NIL denotes "all privileges" */ List *grantees; /* list of PrivGrantee nodes */ @@ -964,8 +958,8 @@ typedef struct CopyStmt { NodeTag type; RangeVar *relation; /* the relation to copy */ - List *attlist; /* List of column names (as Strings), or - * NIL for all columns */ + List *attlist; /* List of column names (as Strings), or NIL + * for all columns */ bool is_from; /* TO or FROM */ char *filename; /* if NULL, use stdin/stdout */ List *options; /* List of DefElem nodes */ @@ -1027,8 +1021,7 @@ typedef struct CreateStmt typedef enum ConstrType /* types of constraints */ { - CONSTR_NULL, /* not SQL92, but a lot of people expect - * it */ + CONSTR_NULL, /* not SQL92, but a lot of people expect it */ CONSTR_NOTNULL, CONSTR_DEFAULT, CONSTR_CHECK, @@ -1048,8 +1041,7 @@ typedef struct Constraint char *name; /* name, or NULL if unnamed */ Node *raw_expr; /* expr, as untransformed parse tree */ char *cooked_expr; /* expr, as nodeToString representation */ - List *keys; /* String nodes naming referenced - * column(s) */ + List *keys; /* String nodes naming referenced column(s) */ char *indexspace; /* index tablespace for PKEY/UNIQUE * constraints; NULL for default */ } Constraint; @@ -1146,8 +1138,7 @@ typedef struct CreatePLangStmt NodeTag type; char *plname; /* PL name */ List *plhandler; /* PL call handler function (qual. name) */ - List *plvalidator; /* optional validator function (qual. - * name) */ + List *plvalidator; /* optional validator function (qual. name) */ bool pltrusted; /* PL is trusted */ } CreatePLangStmt; @@ -1397,9 +1388,8 @@ typedef struct IndexStmt char *tableSpace; /* tablespace, or NULL to use parent's */ List *indexParams; /* a list of IndexElem */ Node *whereClause; /* qualification (partial-index predicate) */ - List *rangetable; /* range table for qual and/or - * expressions, filled in by - * transformStmt() */ + List *rangetable; /* range table for qual and/or expressions, + * filled in by transformStmt() */ bool unique; /* is index unique? */ bool primary; /* is index on primary key? */ bool isconstraint; /* is it from a CONSTRAINT clause? */ @@ -1433,7 +1423,7 @@ typedef struct FunctionParameter NodeTag type; char *name; /* parameter name, or NULL if not given */ TypeName *argType; /* TypeName for parameter type */ - FunctionParameterMode mode; /* IN/OUT/INOUT */ + FunctionParameterMode mode; /* IN/OUT/INOUT */ } FunctionParameter; typedef struct AlterFunctionStmt @@ -1513,13 +1503,13 @@ typedef struct RenameStmt */ typedef struct AlterObjectSchemaStmt { - NodeTag type; - ObjectType objectType; /* OBJECT_TABLE, OBJECT_TYPE, etc */ + NodeTag type; + ObjectType objectType; /* OBJECT_TABLE, OBJECT_TYPE, etc */ RangeVar *relation; /* in case it's a table */ List *object; /* in case it's some other object */ List *objarg; /* argument types, if applicable */ char *addname; /* additional name if needed */ - char *newschema; /* the new schema */ + char *newschema; /* the new schema */ } AlterObjectSchemaStmt; /* ---------------------- @@ -1529,7 +1519,7 @@ typedef struct AlterObjectSchemaStmt typedef struct AlterOwnerStmt { NodeTag type; - ObjectType objectType; /* OBJECT_TABLE, OBJECT_TYPE, etc */ + ObjectType objectType; /* OBJECT_TABLE, OBJECT_TYPE, etc */ RangeVar *relation; /* in case it's a table */ List *object; /* in case it's some other object */ List *objarg; /* argument types, if applicable */ @@ -1607,7 +1597,7 @@ typedef struct TransactionStmt NodeTag type; TransactionStmtKind kind; /* see above */ List *options; /* for BEGIN/START and savepoint commands */ - char *gid; /* for two-phase-commit related commands */ + char *gid; /* for two-phase-commit related commands */ } TransactionStmt; /* ---------------------- @@ -1801,8 +1791,7 @@ typedef struct ConstraintsSetStmt typedef struct ReindexStmt { NodeTag type; - ObjectType kind; /* OBJECT_INDEX, OBJECT_TABLE, - * OBJECT_DATABASE */ + ObjectType kind; /* OBJECT_INDEX, OBJECT_TABLE, OBJECT_DATABASE */ RangeVar *relation; /* Table or index to reindex */ const char *name; /* name of database to reindex */ bool do_system; /* include system tables in database case */ diff --git a/src/include/nodes/pg_list.h b/src/include/nodes/pg_list.h index 564745e9a5..3c419ff72b 100644 --- a/src/include/nodes/pg_list.h +++ b/src/include/nodes/pg_list.h @@ -30,7 +30,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/nodes/pg_list.h,v 1.52 2005/07/28 20:26:22 tgl Exp $ + * $PostgreSQL: pgsql/src/include/nodes/pg_list.h,v 1.53 2005/10/15 02:49:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -93,7 +93,6 @@ list_length(List *l) { return l ? l->length : 0; } - #else extern ListCell *list_head(List *l); diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h index 6e2e01166c..4a0ff51afd 100644 --- a/src/include/nodes/plannodes.h +++ b/src/include/nodes/plannodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/nodes/plannodes.h,v 1.79 2005/04/25 01:30:14 tgl Exp $ + * $PostgreSQL: pgsql/src/include/nodes/plannodes.h,v 1.80 2005/10/15 02:49:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -43,10 +43,8 @@ typedef struct Plan /* * estimated execution costs for plan (see costsize.c for more info) */ - Cost startup_cost; /* cost expended before fetching any - * tuples */ - Cost total_cost; /* total cost (assuming all tuples - * fetched) */ + Cost startup_cost; /* cost expended before fetching any tuples */ + Cost total_cost; /* total cost (assuming all tuples fetched) */ /* * planner's estimate of result size of this plan step @@ -67,13 +65,13 @@ typedef struct Plan /* * Information for management of parameter-change-driven rescanning * - * extParam includes the paramIDs of all external PARAM_EXEC params - * affecting this plan node or its children. setParam params from the - * node's initPlans are not included, but their extParams are. + * extParam includes the paramIDs of all external PARAM_EXEC params affecting + * this plan node or its children. setParam params from the node's + * initPlans are not included, but their extParams are. * - * allParam includes all the extParam paramIDs, plus the IDs of local - * params that affect the node (i.e., the setParams of its initplans). - * These are _all_ the PARAM_EXEC params that affect this node. + * allParam includes all the extParam paramIDs, plus the IDs of local params + * that affect the node (i.e., the setParams of its initplans). These are + * _all_ the PARAM_EXEC params that affect this node. */ Bitmapset *extParam; Bitmapset *allParam; @@ -83,9 +81,9 @@ typedef struct Plan * resultRelation from Query there and get rid of Query itself from * Executor. Some other stuff like below could be put there, too. */ - int nParamExec; /* Number of them in entire query. This is - * to get Executor know about how many - * PARAM_EXEC there are in query plan. */ + int nParamExec; /* Number of them in entire query. This is to + * get Executor know about how many PARAM_EXEC + * there are in query plan. */ } Plan; /* ---------------- @@ -138,7 +136,7 @@ typedef struct Append * BitmapAnd node - * Generate the intersection of the results of sub-plans. * - * The subplans must be of types that yield tuple bitmaps. The targetlist + * The subplans must be of types that yield tuple bitmaps. The targetlist * and qual fields of the plan are unused and are always NIL. * ---------------- */ @@ -152,7 +150,7 @@ typedef struct BitmapAnd * BitmapOr node - * Generate the union of the results of sub-plans. * - * The subplans must be of types that yield tuple bitmaps. The targetlist + * The subplans must be of types that yield tuple bitmaps. The targetlist * and qual fields of the plan are unused and are always NIL. * ---------------- */ @@ -186,15 +184,15 @@ typedef Scan SeqScan; * in the same form it appeared in the query WHERE condition. Each should * be of the form (indexkey OP comparisonval) or (comparisonval OP indexkey). * The indexkey is a Var or expression referencing column(s) of the index's - * base table. The comparisonval might be any expression, but it won't use + * base table. The comparisonval might be any expression, but it won't use * any columns of the base table. * * indexqual has the same form, but the expressions have been commuted if * necessary to put the indexkeys on the left, and the indexkeys are replaced * by Var nodes identifying the index columns (varattno is the index column * position, not the base table's column, even though varno is for the base - * table). This is a bit hokey ... would be cleaner to use a special-purpose - * node type that could not be mistaken for a regular Var. But it will do + * table). This is a bit hokey ... would be cleaner to use a special-purpose + * node type that could not be mistaken for a regular Var. But it will do * for now. * * indexstrategy and indexsubtype are lists corresponding one-to-one with @@ -205,11 +203,11 @@ typedef Scan SeqScan; typedef struct IndexScan { Scan scan; - Oid indexid; /* OID of index to scan */ - List *indexqual; /* list of index quals (OpExprs) */ - List *indexqualorig; /* the same in original form */ - List *indexstrategy; /* integer list of strategy numbers */ - List *indexsubtype; /* OID list of strategy subtypes */ + Oid indexid; /* OID of index to scan */ + List *indexqual; /* list of index quals (OpExprs) */ + List *indexqualorig; /* the same in original form */ + List *indexstrategy; /* integer list of strategy numbers */ + List *indexsubtype; /* OID list of strategy subtypes */ ScanDirection indexorderdir; /* forward or backward or don't care */ } IndexScan; @@ -217,7 +215,7 @@ typedef struct IndexScan * bitmap index scan node * * BitmapIndexScan delivers a bitmap of potential tuple locations; - * it does not access the heap itself. The bitmap is used by an + * it does not access the heap itself. The bitmap is used by an * ancestor BitmapHeapScan node, possibly after passing through * intermediate BitmapAnd and/or BitmapOr nodes to combine it with * the results of other BitmapIndexScans. @@ -233,11 +231,11 @@ typedef struct IndexScan typedef struct BitmapIndexScan { Scan scan; - Oid indexid; /* OID of index to scan */ - List *indexqual; /* list of index quals (OpExprs) */ - List *indexqualorig; /* the same in original form */ - List *indexstrategy; /* integer list of strategy numbers */ - List *indexsubtype; /* OID list of strategy subtypes */ + Oid indexid; /* OID of index to scan */ + List *indexqual; /* list of index quals (OpExprs) */ + List *indexqualorig; /* the same in original form */ + List *indexstrategy; /* integer list of strategy numbers */ + List *indexsubtype; /* OID list of strategy subtypes */ } BitmapIndexScan; /* ---------------- @@ -252,7 +250,7 @@ typedef struct BitmapIndexScan typedef struct BitmapHeapScan { Scan scan; - List *bitmapqualorig; /* index quals, in standard expr form */ + List *bitmapqualorig; /* index quals, in standard expr form */ } BitmapHeapScan; /* ---------------- @@ -424,8 +422,7 @@ typedef struct Agg typedef struct Unique { Plan plan; - int numCols; /* number of columns to check for - * uniqueness */ + int numCols; /* number of columns to check for uniqueness */ AttrNumber *uniqColIdx; /* indexes into the target list */ } Unique; diff --git a/src/include/nodes/primnodes.h b/src/include/nodes/primnodes.h index 279b79738e..1cdd64b26e 100644 --- a/src/include/nodes/primnodes.h +++ b/src/include/nodes/primnodes.h @@ -10,7 +10,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/nodes/primnodes.h,v 1.108 2005/06/26 22:05:41 tgl Exp $ + * $PostgreSQL: pgsql/src/include/nodes/primnodes.h,v 1.109 2005/10/15 02:49:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -64,8 +64,8 @@ typedef struct RangeVar char *catalogname; /* the catalog (database) name, or NULL */ char *schemaname; /* the schema name, or NULL */ char *relname; /* the relation/sequence name */ - InhOption inhOpt; /* expand rel by inheritance? recursively - * act on children? */ + InhOption inhOpt; /* expand rel by inheritance? recursively act + * on children? */ bool istemp; /* is this a temp relation/sequence? */ Alias *alias; /* table alias & optional column aliases */ } RangeVar; @@ -110,19 +110,17 @@ typedef struct Expr typedef struct Var { Expr xpr; - Index varno; /* index of this var's relation in the - * range table (could also be INNER or - * OUTER) */ - AttrNumber varattno; /* attribute number of this var, or zero - * for all */ - Oid vartype; /* pg_type tuple OID for the type of this - * var */ + Index varno; /* index of this var's relation in the range + * table (could also be INNER or OUTER) */ + AttrNumber varattno; /* attribute number of this var, or zero for + * all */ + Oid vartype; /* pg_type tuple OID for the type of this var */ int32 vartypmod; /* pg_attribute typmod value */ Index varlevelsup; /* - * for subquery variables referencing outer relations; 0 in a normal - * var, >0 means N levels up + * for subquery variables referencing outer relations; 0 in a normal var, + * >0 means N levels up */ Index varnoold; /* original value of varno, for debugging */ AttrNumber varoattno; /* original value of varattno */ @@ -139,11 +137,10 @@ typedef struct Const Datum constvalue; /* the constant's value */ bool constisnull; /* whether the constant is null (if true, * constvalue is undefined) */ - bool constbyval; /* whether this datatype is passed by - * value. If true, then all the - * information is stored in the Datum. If - * false, then the Datum contains a - * pointer to the information. */ + bool constbyval; /* whether this datatype is passed by value. + * If true, then all the information is stored + * in the Datum. If false, then the Datum + * contains a pointer to the information. */ } Const; /* ---------------- @@ -214,14 +211,14 @@ typedef struct ArrayRef * operation */ Oid refarraytype; /* type of the array proper */ Oid refelemtype; /* type of the array elements */ - List *refupperindexpr;/* expressions that evaluate to upper - * array indexes */ - List *reflowerindexpr;/* expressions that evaluate to lower - * array indexes */ - Expr *refexpr; /* the expression that evaluates to an - * array value */ - Expr *refassgnexpr; /* expression for the source value, or - * NULL if fetch */ + List *refupperindexpr;/* expressions that evaluate to upper array + * indexes */ + List *reflowerindexpr;/* expressions that evaluate to lower array + * indexes */ + Expr *refexpr; /* the expression that evaluates to an array + * value */ + Expr *refassgnexpr; /* expression for the source value, or NULL if + * fetch */ } ArrayRef; /* @@ -390,10 +387,9 @@ typedef struct SubLink { Expr xpr; SubLinkType subLinkType; /* EXISTS, ALL, ANY, MULTIEXPR, EXPR */ - bool useOr; /* TRUE to combine column results with - * "OR" not "AND" */ - List *lefthand; /* list of outer-query expressions on the - * left */ + bool useOr; /* TRUE to combine column results with "OR" + * not "AND" */ + List *lefthand; /* list of outer-query expressions on the left */ List *operName; /* originally specified operator name */ List *operOids; /* OIDs of actual combining operators */ Node *subselect; /* subselect as Query* or parsetree */ @@ -431,8 +427,8 @@ typedef struct SubPlan Expr xpr; /* Fields copied from original SubLink: */ SubLinkType subLinkType; /* EXISTS, ALL, ANY, MULTIEXPR, EXPR */ - bool useOr; /* TRUE to combine column results with - * "OR" not "AND" */ + bool useOr; /* TRUE to combine column results with "OR" + * not "AND" */ /* The combining operators, transformed to executable expressions: */ List *exprs; /* list of OpExpr expression trees */ List *paramIds; /* IDs of Params embedded in the above */ @@ -440,22 +436,21 @@ typedef struct SubPlan /* The subselect, transformed to a Plan: */ struct Plan *plan; /* subselect plan itself */ int plan_id; /* dummy thing because of we haven't equal - * funcs for plan nodes... actually, we - * could put *plan itself somewhere else - * (TopPlan node ?)... */ + * funcs for plan nodes... actually, we could + * put *plan itself somewhere else (TopPlan + * node ?)... */ List *rtable; /* range table for subselect */ /* Information about execution strategy: */ - bool useHashTable; /* TRUE to store subselect output in a - * hash table (implies we are doing "IN") */ - bool unknownEqFalse; /* TRUE if it's okay to return FALSE when - * the spec result is UNKNOWN; this allows - * much simpler handling of null values */ + bool useHashTable; /* TRUE to store subselect output in a hash + * table (implies we are doing "IN") */ + bool unknownEqFalse; /* TRUE if it's okay to return FALSE when the + * spec result is UNKNOWN; this allows much + * simpler handling of null values */ /* Information for passing params into and out of the subselect: */ /* setParam and parParam are lists of integers (param IDs) */ List *setParam; /* initplan subqueries have to set these * Params for parent plan */ - List *parParam; /* indices of input Params from parent - * plan */ + List *parParam; /* indices of input Params from parent plan */ List *args; /* exprs to pass as parParam values */ } SubPlan; @@ -639,10 +634,10 @@ typedef struct RowExpr Oid row_typeid; /* RECORDOID or a composite type's ID */ /* - * Note: we deliberately do NOT store a typmod. Although a typmod - * will be associated with specific RECORD types at runtime, it will - * differ for different backends, and so cannot safely be stored in - * stored parsetrees. We must assume typmod -1 for a RowExpr node. + * Note: we deliberately do NOT store a typmod. Although a typmod will be + * associated with specific RECORD types at runtime, it will differ for + * different backends, and so cannot safely be stored in stored + * parsetrees. We must assume typmod -1 for a RowExpr node. */ CoercionForm row_format; /* how to display this node */ } RowExpr; @@ -837,8 +832,8 @@ typedef struct TargetEntry * clause */ Oid resorigtbl; /* OID of column's source table */ AttrNumber resorigcol; /* column's number in source table */ - bool resjunk; /* set to true to eliminate the attribute - * from final target list */ + bool resjunk; /* set to true to eliminate the attribute from + * final target list */ } TargetEntry; diff --git a/src/include/nodes/relation.h b/src/include/nodes/relation.h index 3b23bfbeb4..01aa96d717 100644 --- a/src/include/nodes/relation.h +++ b/src/include/nodes/relation.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/nodes/relation.h,v 1.118 2005/08/27 22:13:43 tgl Exp $ + * $PostgreSQL: pgsql/src/include/nodes/relation.h,v 1.119 2005/10/15 02:49:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -52,7 +52,7 @@ typedef struct QualCost * * This struct is conventionally called "root" in all the planner routines. * It holds links to all of the planner's working state, in addition to the - * original Query. Note that at present the planner extensively manipulates + * original Query. Note that at present the planner extensively manipulates * the passed-in Query data structure; someday that should stop. *---------- */ @@ -64,47 +64,48 @@ typedef struct PlannerInfo /* * base_rel_array holds pointers to "base rels" and "other rels" (see - * comments for RelOptInfo for more info). It is indexed by rangetable - * index (so entry 0 is always wasted). Entries can be NULL when - * an RTE does not correspond to a base relation. Note that the array - * may be enlarged on-the-fly. + * comments for RelOptInfo for more info). It is indexed by rangetable + * index (so entry 0 is always wasted). Entries can be NULL when an RTE + * does not correspond to a base relation. Note that the array may be + * enlarged on-the-fly. */ - struct RelOptInfo **base_rel_array; /* All one-relation RelOptInfos */ + struct RelOptInfo **base_rel_array; /* All one-relation RelOptInfos */ int base_rel_array_size; /* current allocated array len */ /* * join_rel_list is a list of all join-relation RelOptInfos we have - * considered in this planning run. For small problems we just scan - * the list to do lookups, but when there are many join relations we - * build a hash table for faster lookups. The hash table is present - * and valid when join_rel_hash is not NULL. Note that we still maintain - * the list even when using the hash table for lookups; this simplifies - * life for GEQO. + * considered in this planning run. For small problems we just scan the + * list to do lookups, but when there are many join relations we build a + * hash table for faster lookups. The hash table is present and valid + * when join_rel_hash is not NULL. Note that we still maintain the list + * even when using the hash table for lookups; this simplifies life for + * GEQO. */ List *join_rel_list; /* list of join-relation RelOptInfos */ - struct HTAB *join_rel_hash; /* optional hashtable for join relations */ + struct HTAB *join_rel_hash; /* optional hashtable for join relations */ - List *equi_key_list; /* list of lists of equijoined - * PathKeyItems */ + List *equi_key_list; /* list of lists of equijoined PathKeyItems */ - List *left_join_clauses; /* list of RestrictInfos for outer join - * clauses w/nonnullable var on left */ + List *left_join_clauses; /* list of RestrictInfos for outer + * join clauses w/nonnullable var on + * left */ - List *right_join_clauses; /* list of RestrictInfos for outer join - * clauses w/nonnullable var on right */ + List *right_join_clauses; /* list of RestrictInfos for outer + * join clauses w/nonnullable var on + * right */ - List *full_join_clauses; /* list of RestrictInfos for full outer - * join clauses */ + List *full_join_clauses; /* list of RestrictInfos for full + * outer join clauses */ List *in_info_list; /* list of InClauseInfos */ - List *query_pathkeys; /* desired pathkeys for query_planner(), - * and actual pathkeys afterwards */ + List *query_pathkeys; /* desired pathkeys for query_planner(), and + * actual pathkeys afterwards */ List *group_pathkeys; /* groupClause pathkeys, if any */ List *sort_pathkeys; /* sortClause pathkeys, if any */ - double tuple_fraction; /* tuple_fraction passed to query_planner */ + double tuple_fraction; /* tuple_fraction passed to query_planner */ bool hasJoinRTEs; /* true if any RTEs are RTE_JOIN kind */ bool hasOuterJoins; /* true if any RTEs are outer joins */ @@ -268,13 +269,13 @@ typedef struct RelOptInfo Relids *attr_needed; /* array indexed [min_attr .. max_attr] */ int32 *attr_widths; /* array indexed [min_attr .. max_attr] */ List *indexlist; - BlockNumber pages; + BlockNumber pages; double tuples; struct Plan *subplan; /* if subquery */ /* used by various scans and joins: */ - List *baserestrictinfo; /* RestrictInfo structures (if - * base rel) */ + List *baserestrictinfo; /* RestrictInfo structures (if base + * rel) */ QualCost baserestrictcost; /* cost of evaluating the above */ Relids outerjoinset; /* set of base relids */ List *joininfo; /* RestrictInfo structures for join clauses @@ -287,10 +288,9 @@ typedef struct RelOptInfo /* * Inner indexscans are not in the main pathlist because they are not - * usable except in specific join contexts. We use the - * index_inner_paths list just to avoid recomputing the best inner - * indexscan repeatedly for similar outer relations. See comments for - * InnerIndexscanInfo. + * usable except in specific join contexts. We use the index_inner_paths + * list just to avoid recomputing the best inner indexscan repeatedly for + * similar outer relations. See comments for InnerIndexscanInfo. */ } RelOptInfo; @@ -323,7 +323,7 @@ typedef struct IndexOptInfo RelOptInfo *rel; /* back-link to index's table */ /* statistics from pg_class */ - BlockNumber pages; /* number of disk pages in index */ + BlockNumber pages; /* number of disk pages in index */ double tuples; /* number of index tuples in index */ /* index descriptor information */ @@ -335,8 +335,7 @@ typedef struct IndexOptInfo RegProcedure amcostestimate; /* OID of the access method's cost fcn */ - List *indexprs; /* expressions for non-simple index - * columns */ + List *indexprs; /* expressions for non-simple index columns */ List *indpred; /* predicate if a partial index, else NIL */ bool predOK; /* true if predicate matches query */ @@ -365,9 +364,9 @@ typedef struct PathKeyItem Oid sortop; /* the ordering operator ('<' op) */ /* - * key typically points to a Var node, ie a relation attribute, but it - * can also point to an arbitrary expression representing the value - * indexed by an index expression. + * key typically points to a Var node, ie a relation attribute, but it can + * also point to an arbitrary expression representing the value indexed by + * an index expression. */ } PathKeyItem; @@ -390,10 +389,8 @@ typedef struct Path RelOptInfo *parent; /* the relation this path can build */ /* estimated execution costs for path (see costsize.c for more info) */ - Cost startup_cost; /* cost expended before fetching any - * tuples */ - Cost total_cost; /* total cost (assuming all tuples - * fetched) */ + Cost startup_cost; /* cost expended before fetching any tuples */ + Cost total_cost; /* total cost (assuming all tuples fetched) */ List *pathkeys; /* sort ordering of path's output */ /* pathkeys is a List of Lists of PathKeyItem nodes; see above */ @@ -459,11 +456,11 @@ typedef struct IndexPath * * The individual indexscans are represented by IndexPath nodes, and any * logic on top of them is represented by a tree of BitmapAndPath and - * BitmapOrPath nodes. Notice that we can use the same IndexPath node both + * BitmapOrPath nodes. Notice that we can use the same IndexPath node both * to represent a regular IndexScan plan, and as the child of a BitmapHeapPath * that represents scanning the same index using a BitmapIndexScan. The * startup_cost and total_cost figures of an IndexPath always represent the - * costs to use it as a regular IndexScan. The costs of a BitmapIndexScan + * costs to use it as a regular IndexScan. The costs of a BitmapIndexScan * can be computed using the IndexPath's indextotalcost and indexselectivity. * * BitmapHeapPaths can be nestloop inner indexscans. The isjoininner and @@ -486,7 +483,7 @@ typedef struct BitmapHeapPath typedef struct BitmapAndPath { Path path; - List *bitmapquals; /* IndexPaths and BitmapOrPaths */ + List *bitmapquals; /* IndexPaths and BitmapOrPaths */ Selectivity bitmapselectivity; } BitmapAndPath; @@ -499,7 +496,7 @@ typedef struct BitmapAndPath typedef struct BitmapOrPath { Path path; - List *bitmapquals; /* IndexPaths and BitmapAndPaths */ + List *bitmapquals; /* IndexPaths and BitmapAndPaths */ Selectivity bitmapselectivity; } BitmapOrPath; @@ -638,8 +635,7 @@ typedef JoinPath NestPath; typedef struct MergePath { JoinPath jpath; - List *path_mergeclauses; /* join clauses to be used for - * merge */ + List *path_mergeclauses; /* join clauses to be used for merge */ List *outersortkeys; /* keys for explicit sort, if any */ List *innersortkeys; /* keys for explicit sort, if any */ } MergePath; @@ -712,7 +708,7 @@ typedef struct HashPath * that appeared higher in the tree and were pushed down to the join rel * because they used no other rels. That's what the is_pushed_down flag is * for; it tells us that a qual came from a point above the join of the - * set of base rels listed in required_relids. A clause that originally came + * set of base rels listed in required_relids. A clause that originally came * from WHERE will *always* have its is_pushed_down flag set; a clause that * came from an INNER JOIN condition, but doesn't use all the rels being * joined, will also have is_pushed_down set because it will get attached to @@ -745,11 +741,11 @@ typedef struct RestrictInfo bool is_pushed_down; /* TRUE if clause was pushed down in level */ /* - * This flag is set true if the clause looks potentially useful as a - * merge or hash join clause, that is if it is a binary opclause with - * nonoverlapping sets of relids referenced in the left and right - * sides. (Whether the operator is actually merge or hash joinable - * isn't checked, however.) + * This flag is set true if the clause looks potentially useful as a merge + * or hash join clause, that is if it is a binary opclause with + * nonoverlapping sets of relids referenced in the left and right sides. + * (Whether the operator is actually merge or hash joinable isn't checked, + * however.) */ bool can_join; @@ -843,8 +839,8 @@ typedef struct InClauseInfo List *sub_targetlist; /* targetlist of original RHS subquery */ /* - * Note: sub_targetlist is just a list of Vars or expressions; it does - * not contain TargetEntry nodes. + * Note: sub_targetlist is just a list of Vars or expressions; it does not + * contain TargetEntry nodes. */ } InClauseInfo; diff --git a/src/include/nodes/tidbitmap.h b/src/include/nodes/tidbitmap.h index ea5673e6f2..5b8c010e51 100644 --- a/src/include/nodes/tidbitmap.h +++ b/src/include/nodes/tidbitmap.h @@ -15,7 +15,7 @@ * * Copyright (c) 2003-2005, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/include/nodes/tidbitmap.h,v 1.2 2005/08/28 22:47:20 tgl Exp $ + * $PostgreSQL: pgsql/src/include/nodes/tidbitmap.h,v 1.3 2005/10/15 02:49:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -26,7 +26,7 @@ /* - * Actual bitmap representation is private to tidbitmap.c. Callers can + * Actual bitmap representation is private to tidbitmap.c. Callers can * do IsA(x, TIDBitmap) on it, but nothing else. */ typedef struct TIDBitmap TIDBitmap; @@ -34,7 +34,7 @@ typedef struct TIDBitmap TIDBitmap; /* Result structure for tbm_iterate */ typedef struct { - BlockNumber blockno; /* page number containing tuples */ + BlockNumber blockno; /* page number containing tuples */ int ntuples; /* -1 indicates lossy result */ OffsetNumber offsets[1]; /* VARIABLE LENGTH ARRAY */ } TBMIterateResult; /* VARIABLE LENGTH STRUCT */ diff --git a/src/include/optimizer/clauses.h b/src/include/optimizer/clauses.h index ae5ab79f98..bf00f2cc97 100644 --- a/src/include/optimizer/clauses.h +++ b/src/include/optimizer/clauses.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/optimizer/clauses.h,v 1.79 2005/05/22 22:30:20 tgl Exp $ + * $PostgreSQL: pgsql/src/include/optimizer/clauses.h,v 1.80 2005/10/15 02:49:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -23,7 +23,7 @@ typedef struct { - int numAggs; /* total number of aggregate calls */ + int numAggs; /* total number of aggregate calls */ int numDistinctAggs; /* number that use DISTINCT */ Size transitionSpace; /* for pass-by-ref transition data */ } AggClauseCounts; @@ -87,18 +87,18 @@ extern Node *expression_tree_mutator(Node *node, Node *(*mutator) (), #define QTW_DONT_COPY_QUERY 0x04 /* do not copy top Query */ extern bool query_tree_walker(Query *query, bool (*walker) (), - void *context, int flags); + void *context, int flags); extern Query *query_tree_mutator(Query *query, Node *(*mutator) (), - void *context, int flags); + void *context, int flags); extern bool range_table_walker(List *rtable, bool (*walker) (), - void *context, int flags); + void *context, int flags); extern List *range_table_mutator(List *rtable, Node *(*mutator) (), - void *context, int flags); + void *context, int flags); extern bool query_or_expression_tree_walker(Node *node, bool (*walker) (), - void *context, int flags); + void *context, int flags); extern Node *query_or_expression_tree_mutator(Node *node, Node *(*mutator) (), - void *context, int flags); + void *context, int flags); #endif /* CLAUSES_H */ diff --git a/src/include/optimizer/cost.h b/src/include/optimizer/cost.h index 4162b632fc..eeec6b1f1b 100644 --- a/src/include/optimizer/cost.h +++ b/src/include/optimizer/cost.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/optimizer/cost.h,v 1.70 2005/08/22 17:35:03 momjian Exp $ + * $PostgreSQL: pgsql/src/include/optimizer/cost.h,v 1.71 2005/10/15 02:49:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -56,7 +56,7 @@ extern void cost_seqscan(Path *path, PlannerInfo *root, RelOptInfo *baserel); extern void cost_index(IndexPath *path, PlannerInfo *root, IndexOptInfo *index, List *indexQuals, bool is_injoin); extern void cost_bitmap_heap_scan(Path *path, PlannerInfo *root, RelOptInfo *baserel, - Path *bitmapqual, bool is_injoin); + Path *bitmapqual, bool is_injoin); extern void cost_bitmap_and_node(BitmapAndPath *path, PlannerInfo *root); extern void cost_bitmap_or_node(BitmapOrPath *path, PlannerInfo *root); extern void cost_bitmap_tree_node(Path *path, Cost *cost, Selectivity *selec); diff --git a/src/include/optimizer/geqo.h b/src/include/optimizer/geqo.h index b67fc1aa49..504f815e95 100644 --- a/src/include/optimizer/geqo.h +++ b/src/include/optimizer/geqo.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/optimizer/geqo.h,v 1.39 2005/06/05 22:32:58 tgl Exp $ + * $PostgreSQL: pgsql/src/include/optimizer/geqo.h,v 1.40 2005/10/15 02:49:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -48,8 +48,7 @@ * * If you change these, update backend/utils/misc/postgresql.sample.conf */ -extern int Geqo_effort; /* 1 .. 10, knob for adjustment of - * defaults */ +extern int Geqo_effort; /* 1 .. 10, knob for adjustment of defaults */ #define DEFAULT_GEQO_EFFORT 5 #define MIN_GEQO_EFFORT 1 @@ -79,7 +78,7 @@ typedef struct /* routines in geqo_main.c */ extern RelOptInfo *geqo(PlannerInfo *root, - int number_of_rels, List *initial_rels); + int number_of_rels, List *initial_rels); /* routines in geqo_eval.c */ extern Cost geqo_eval(Gene *tour, int num_gene, GeqoEvalData *evaldata); diff --git a/src/include/optimizer/pathnode.h b/src/include/optimizer/pathnode.h index 009ada29da..473043cbad 100644 --- a/src/include/optimizer/pathnode.h +++ b/src/include/optimizer/pathnode.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/optimizer/pathnode.h,v 1.61 2005/06/05 22:32:58 tgl Exp $ + * $PostgreSQL: pgsql/src/include/optimizer/pathnode.h,v 1.62 2005/10/15 02:49:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -35,15 +35,15 @@ extern IndexPath *create_index_path(PlannerInfo *root, ScanDirection indexscandir, bool isjoininner); extern BitmapHeapPath *create_bitmap_heap_path(PlannerInfo *root, - RelOptInfo *rel, - Path *bitmapqual, - bool isjoininner); + RelOptInfo *rel, + Path *bitmapqual, + bool isjoininner); extern BitmapAndPath *create_bitmap_and_path(PlannerInfo *root, - RelOptInfo *rel, - List *bitmapquals); + RelOptInfo *rel, + List *bitmapquals); extern BitmapOrPath *create_bitmap_or_path(PlannerInfo *root, - RelOptInfo *rel, - List *bitmapquals); + RelOptInfo *rel, + List *bitmapquals); extern TidPath *create_tidscan_path(PlannerInfo *root, RelOptInfo *rel, List *tideval); extern AppendPath *create_append_path(RelOptInfo *rel, List *subpaths); diff --git a/src/include/optimizer/paths.h b/src/include/optimizer/paths.h index 7c8108b000..4020f4bf49 100644 --- a/src/include/optimizer/paths.h +++ b/src/include/optimizer/paths.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/optimizer/paths.h,v 1.87 2005/08/27 22:13:44 tgl Exp $ + * $PostgreSQL: pgsql/src/include/optimizer/paths.h,v 1.88 2005/10/15 02:49:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -42,13 +42,13 @@ extern List *generate_bitmap_or_paths(PlannerInfo *root, RelOptInfo *rel, extern Path *best_inner_indexscan(PlannerInfo *root, RelOptInfo *rel, Relids outer_relids, JoinType jointype); extern List *group_clauses_by_indexkey(IndexOptInfo *index, - List *clauses, List *outer_clauses, - Relids outer_relids, - bool *found_clause); + List *clauses, List *outer_clauses, + Relids outer_relids, + bool *found_clause); extern bool match_index_to_operand(Node *operand, int indexcol, IndexOptInfo *index); extern List *expand_indexqual_conditions(IndexOptInfo *index, - List *clausegroups); + List *clausegroups); extern void check_partial_indexes(PlannerInfo *root, RelOptInfo *rel); extern List *flatten_clausegroups_list(List *clausegroups); @@ -110,7 +110,7 @@ extern Path *get_cheapest_fractional_path_for_pathkeys(List *paths, extern List *build_index_pathkeys(PlannerInfo *root, IndexOptInfo *index, ScanDirection scandir); extern List *convert_subquery_pathkeys(PlannerInfo *root, RelOptInfo *rel, - List *subquery_pathkeys); + List *subquery_pathkeys); extern List *build_join_pathkeys(PlannerInfo *root, RelOptInfo *joinrel, JoinType jointype, diff --git a/src/include/optimizer/planmain.h b/src/include/optimizer/planmain.h index 59b925f8b7..0e78933f79 100644 --- a/src/include/optimizer/planmain.h +++ b/src/include/optimizer/planmain.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/optimizer/planmain.h,v 1.89 2005/09/28 21:17:02 tgl Exp $ + * $PostgreSQL: pgsql/src/include/optimizer/planmain.h,v 1.90 2005/10/15 02:49:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -21,15 +21,15 @@ * prototypes for plan/planmain.c */ extern void query_planner(PlannerInfo *root, List *tlist, - double tuple_fraction, - Path **cheapest_path, Path **sorted_path, - double *num_groups); + double tuple_fraction, + Path **cheapest_path, Path **sorted_path, + double *num_groups); /* * prototypes for plan/planagg.c */ extern Plan *optimize_minmax_aggregates(PlannerInfo *root, List *tlist, - Path *best_path); + Path *best_path); /* * prototypes for plan/createplan.c @@ -56,7 +56,7 @@ extern Material *make_material(Plan *lefttree); extern Plan *materialize_finished_plan(Plan *subplan); extern Unique *make_unique(Plan *lefttree, List *distinctList); extern Limit *make_limit(Plan *lefttree, Node *limitOffset, Node *limitCount, - int offset_est, int count_est); + int offset_est, int count_est); extern SetOp *make_setop(SetOpCmd cmd, Plan *lefttree, List *distinctList, AttrNumber flagColIdx); extern Result *make_result(List *tlist, Node *resconstantqual, Plan *subplan); @@ -68,7 +68,7 @@ extern bool is_projection_capable_plan(Plan *plan); extern void add_base_rels_to_query(PlannerInfo *root, Node *jtnode); extern void build_base_rel_tlists(PlannerInfo *root, List *final_tlist); extern Relids distribute_quals_to_rels(PlannerInfo *root, Node *jtnode, - bool below_outer_join); + bool below_outer_join); extern void process_implied_equality(PlannerInfo *root, Node *item1, Node *item2, Oid sortop1, Oid sortop2, diff --git a/src/include/optimizer/planner.h b/src/include/optimizer/planner.h index 37091c9f57..f1467e3956 100644 --- a/src/include/optimizer/planner.h +++ b/src/include/optimizer/planner.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/optimizer/planner.h,v 1.33 2005/06/05 22:32:58 tgl Exp $ + * $PostgreSQL: pgsql/src/include/optimizer/planner.h,v 1.34 2005/10/15 02:49:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -24,6 +24,6 @@ extern ParamListInfo PlannerBoundParamList; /* current boundParams */ extern Plan *planner(Query *parse, bool isCursor, int cursorOptions, ParamListInfo boundParams); extern Plan *subquery_planner(Query *parse, double tuple_fraction, - List **subquery_pathkeys); + List **subquery_pathkeys); #endif /* PLANNER_H */ diff --git a/src/include/optimizer/predtest.h b/src/include/optimizer/predtest.h index 0fc0d0f447..16e555e43c 100644 --- a/src/include/optimizer/predtest.h +++ b/src/include/optimizer/predtest.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/optimizer/predtest.h,v 1.2 2005/07/23 21:05:48 tgl Exp $ + * $PostgreSQL: pgsql/src/include/optimizer/predtest.h,v 1.3 2005/10/15 02:49:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -18,8 +18,8 @@ extern bool predicate_implied_by(List *predicate_list, - List *restrictinfo_list); + List *restrictinfo_list); extern bool predicate_refuted_by(List *predicate_list, - List *restrictinfo_list); + List *restrictinfo_list); #endif /* PREDTEST_H */ diff --git a/src/include/optimizer/prep.h b/src/include/optimizer/prep.h index 35907e6e72..c26e6491f3 100644 --- a/src/include/optimizer/prep.h +++ b/src/include/optimizer/prep.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/optimizer/prep.h,v 1.51 2005/06/10 02:21:05 tgl Exp $ + * $PostgreSQL: pgsql/src/include/optimizer/prep.h,v 1.52 2005/10/15 02:49:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -46,7 +46,7 @@ extern List *preprocess_targetlist(PlannerInfo *root, List *tlist); * prototypes for prepunion.c */ extern Plan *plan_set_operations(PlannerInfo *root, double tuple_fraction, - List **sortClauses); + List **sortClauses); extern List *find_all_inheritors(Oid parentrel); diff --git a/src/include/optimizer/restrictinfo.h b/src/include/optimizer/restrictinfo.h index 527c5f500a..0715df59d6 100644 --- a/src/include/optimizer/restrictinfo.h +++ b/src/include/optimizer/restrictinfo.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/optimizer/restrictinfo.h,v 1.33 2005/07/28 20:26:22 tgl Exp $ + * $PostgreSQL: pgsql/src/include/optimizer/restrictinfo.h,v 1.34 2005/10/15 02:49:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -18,11 +18,11 @@ extern RestrictInfo *make_restrictinfo(Expr *clause, - bool is_pushed_down, - Relids required_relids); + bool is_pushed_down, + Relids required_relids); extern List *make_restrictinfo_from_bitmapqual(Path *bitmapqual, - bool is_pushed_down, - bool include_predicates); + bool is_pushed_down, + bool include_predicates); extern bool restriction_is_or_clause(RestrictInfo *restrictinfo); extern List *get_actual_clauses(List *restrictinfo_list); extern void get_actual_join_clauses(List *restrictinfo_list, diff --git a/src/include/optimizer/subselect.h b/src/include/optimizer/subselect.h index ccad3cd91b..9affa54b33 100644 --- a/src/include/optimizer/subselect.h +++ b/src/include/optimizer/subselect.h @@ -5,7 +5,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/optimizer/subselect.h,v 1.25 2005/06/05 22:32:58 tgl Exp $ + * $PostgreSQL: pgsql/src/include/optimizer/subselect.h,v 1.26 2005/10/15 02:49:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -26,6 +26,6 @@ extern Node *SS_replace_correlation_vars(Node *expr); extern Node *SS_process_sublinks(Node *expr, bool isQual); extern void SS_finalize_plan(Plan *plan, List *rtable); extern Param *SS_make_initplan_from_plan(PlannerInfo *root, Plan *plan, - Oid resulttype, int32 resulttypmod); + Oid resulttype, int32 resulttypmod); #endif /* SUBSELECT_H */ diff --git a/src/include/parser/parse_node.h b/src/include/parser/parse_node.h index c864f5714f..03ffe140ab 100644 --- a/src/include/parser/parse_node.h +++ b/src/include/parser/parse_node.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/parser/parse_node.h,v 1.45 2005/08/01 20:31:16 tgl Exp $ + * $PostgreSQL: pgsql/src/include/parser/parse_node.h,v 1.46 2005/10/15 02:49:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -56,14 +56,13 @@ typedef struct ParseState List *p_rtable; /* range table so far */ List *p_joinlist; /* join items so far (will become FromExpr * node's fromlist) */ - List *p_relnamespace; /* current namespace for relations */ - List *p_varnamespace; /* current namespace for columns */ + List *p_relnamespace; /* current namespace for relations */ + List *p_varnamespace; /* current namespace for columns */ Oid *p_paramtypes; /* OIDs of types for $n parameter symbols */ int p_numparams; /* allocated size of p_paramtypes[] */ int p_next_resno; /* next targetlist resno to assign */ LockingClause *p_locking_clause; /* FOR UPDATE/FOR SHARE info */ - Node *p_value_substitute; /* what to replace VALUE with, - * if any */ + Node *p_value_substitute; /* what to replace VALUE with, if any */ bool p_variableparams; bool p_hasAggs; bool p_hasSubLinks; diff --git a/src/include/parser/parse_target.h b/src/include/parser/parse_target.h index 35c2a41baf..9bd6c6e1ba 100644 --- a/src/include/parser/parse_target.h +++ b/src/include/parser/parse_target.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/parser/parse_target.h,v 1.36 2005/05/31 01:03:23 tgl Exp $ + * $PostgreSQL: pgsql/src/include/parser/parse_target.h,v 1.37 2005/10/15 02:49:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -28,7 +28,7 @@ extern void updateTargetListEntry(ParseState *pstate, TargetEntry *tle, extern List *checkInsertTargets(ParseState *pstate, List *cols, List **attrnos); extern TupleDesc expandRecordVariable(ParseState *pstate, Var *var, - int levelsup); + int levelsup); extern char *FigureColname(Node *node); #endif /* PARSE_TARGET_H */ diff --git a/src/include/parser/parsetree.h b/src/include/parser/parsetree.h index c1997bb787..45b46b2983 100644 --- a/src/include/parser/parsetree.h +++ b/src/include/parser/parsetree.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/parser/parsetree.h,v 1.30 2005/06/03 23:05:30 tgl Exp $ + * $PostgreSQL: pgsql/src/include/parser/parsetree.h,v 1.31 2005/10/15 02:49:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -60,7 +60,7 @@ extern void get_rte_attribute_type(RangeTblEntry *rte, AttrNumber attnum, * get_rte_attribute_type will fail on such an attr) */ extern bool get_rte_attribute_is_dropped(RangeTblEntry *rte, - AttrNumber attnum); + AttrNumber attnum); /* ---------------- diff --git a/src/include/pgstat.h b/src/include/pgstat.h index 35ac29208f..cba5acb303 100644 --- a/src/include/pgstat.h +++ b/src/include/pgstat.h @@ -5,7 +5,7 @@ * * Copyright (c) 2001-2005, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/include/pgstat.h,v 1.37 2005/10/06 02:29:19 tgl Exp $ + * $PostgreSQL: pgsql/src/include/pgstat.h,v 1.38 2005/10/15 02:49:41 momjian Exp $ * ---------- */ #ifndef PGSTAT_H @@ -54,7 +54,7 @@ typedef int64 PgStat_Counter; */ typedef struct PgStat_MsgHdr { - StatMsgType m_type; + StatMsgType m_type; int m_size; int m_backendid; int m_procpid; @@ -113,10 +113,10 @@ typedef struct PgStat_MsgDummy */ typedef struct PgStat_MsgBestart { - PgStat_MsgHdr m_hdr; - Oid m_databaseid; - Oid m_userid; - SockAddr m_clientaddr; + PgStat_MsgHdr m_hdr; + Oid m_databaseid; + Oid m_userid; + SockAddr m_clientaddr; } PgStat_MsgBestart; /* ---------- @@ -130,19 +130,19 @@ typedef struct PgStat_MsgBeterm /* ---------- * PgStat_MsgAutovacStart Sent by the autovacuum daemon to signal - * that a database is going to be processed + * that a database is going to be processed * ---------- */ typedef struct PgStat_MsgAutovacStart { PgStat_MsgHdr m_hdr; Oid m_databaseid; - TimestampTz m_start_time; + TimestampTz m_start_time; } PgStat_MsgAutovacStart; /* ---------- * PgStat_MsgVacuum Sent by the backend or autovacuum daemon - * after VACUUM or VACUUM ANALYZE + * after VACUUM or VACUUM ANALYZE * ---------- */ typedef struct PgStat_MsgVacuum @@ -156,7 +156,7 @@ typedef struct PgStat_MsgVacuum /* ---------- * PgStat_MsgAnalyze Sent by the backend or autovacuum daemon - * after ANALYZE + * after ANALYZE * ---------- */ typedef struct PgStat_MsgAnalyze @@ -164,8 +164,8 @@ typedef struct PgStat_MsgAnalyze PgStat_MsgHdr m_hdr; Oid m_databaseid; Oid m_tableoid; - PgStat_Counter m_live_tuples; - PgStat_Counter m_dead_tuples; + PgStat_Counter m_live_tuples; + PgStat_Counter m_dead_tuples; } PgStat_MsgAnalyze; @@ -287,7 +287,7 @@ typedef struct PgStat_StatDBEntry PgStat_Counter n_blocks_fetched; PgStat_Counter n_blocks_hit; int destroy; - TimestampTz last_autovac_time; + TimestampTz last_autovac_time; } PgStat_StatDBEntry; @@ -299,20 +299,19 @@ typedef struct PgStat_StatBeEntry { /* An entry is non-empty iff procpid > 0 */ int procpid; - TimestampTz start_timestamp; - TimestampTz activity_start_timestamp; + TimestampTz start_timestamp; + TimestampTz activity_start_timestamp; char activity[PGSTAT_ACTIVITY_SIZE]; /* - * The following fields are initialized by the BESTART message. If - * we have received messages from a backend before we have - * received its BESTART, these fields will be uninitialized: - * userid and databaseid will be InvalidOid, and clientaddr will - * be undefined. + * The following fields are initialized by the BESTART message. If we have + * received messages from a backend before we have received its BESTART, + * these fields will be uninitialized: userid and databaseid will be + * InvalidOid, and clientaddr will be undefined. */ Oid userid; Oid databaseid; - SockAddr clientaddr; + SockAddr clientaddr; } PgStat_StatBeEntry; @@ -397,10 +396,10 @@ extern void pgstat_report_activity(const char *what); extern void pgstat_report_tabstat(void); extern void pgstat_report_autovac(Oid dboid); extern void pgstat_report_vacuum(Oid tableoid, bool shared, - bool analyze, PgStat_Counter tuples); + bool analyze, PgStat_Counter tuples); extern void pgstat_report_analyze(Oid tableoid, bool shared, - PgStat_Counter livetuples, - PgStat_Counter deadtuples); + PgStat_Counter livetuples, + PgStat_Counter deadtuples); extern int pgstat_vacuum_tabstat(void); extern void pgstat_reset_counters(void); diff --git a/src/include/pgtime.h b/src/include/pgtime.h index 95f2139393..dda479490f 100644 --- a/src/include/pgtime.h +++ b/src/include/pgtime.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/include/pgtime.h,v 1.10 2005/09/09 02:31:49 tgl Exp $ + * $PostgreSQL: pgsql/src/include/pgtime.h,v 1.11 2005/10/15 02:49:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -41,15 +41,15 @@ typedef struct pg_tz pg_tz; extern struct pg_tm *pg_localtime(const pg_time_t *timep, const pg_tz *tz); extern struct pg_tm *pg_gmtime(const pg_time_t *timep); -extern int pg_next_dst_boundary(const pg_time_t *timep, - long int *before_gmtoff, - int *before_isdst, - pg_time_t *boundary, - long int *after_gmtoff, - int *after_isdst, - const pg_tz *tz); +extern int pg_next_dst_boundary(const pg_time_t *timep, + long int *before_gmtoff, + int *before_isdst, + pg_time_t *boundary, + long int *after_gmtoff, + int *after_isdst, + const pg_tz *tz); extern size_t pg_strftime(char *s, size_t max, const char *format, - const struct pg_tm *tm); + const struct pg_tm * tm); extern void pg_timezone_initialize(void); extern pg_tz *pg_tzset(const char *tzname); diff --git a/src/include/port.h b/src/include/port.h index a95ac4a85e..a61abe719f 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/port.h,v 1.83 2005/09/27 17:39:34 tgl Exp $ + * $PostgreSQL: pgsql/src/include/port.h,v 1.84 2005/10/15 02:49:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -29,7 +29,7 @@ extern char *first_dir_separator(const char *filename); extern char *last_dir_separator(const char *filename); extern char *first_path_separator(const char *pathlist); extern void join_path_components(char *ret_path, - const char *head, const char *tail); + const char *head, const char *tail); extern void canonicalize_path(char *path); extern void make_native_path(char *path); extern bool path_contains_parent_reference(const char *path); @@ -113,17 +113,21 @@ extern unsigned char pg_toupper(unsigned char ch); extern unsigned char pg_tolower(unsigned char ch); #ifdef USE_SNPRINTF -extern int pg_vsnprintf(char *str, size_t count, const char *fmt, va_list args); -extern int pg_snprintf(char *str, size_t count, const char *fmt,...) +extern int pg_vsnprintf(char *str, size_t count, const char *fmt, va_list args); +extern int +pg_snprintf(char *str, size_t count, const char *fmt,...) /* This extension allows gcc to check the format string */ __attribute__((format(printf, 3, 4))); -extern int pg_sprintf(char *str, const char *fmt,...) +extern int +pg_sprintf(char *str, const char *fmt,...) /* This extension allows gcc to check the format string */ __attribute__((format(printf, 2, 3))); -extern int pg_fprintf(FILE *stream, const char *fmt,...) +extern int +pg_fprintf(FILE *stream, const char *fmt,...) /* This extension allows gcc to check the format string */ __attribute__((format(printf, 2, 3))); -extern int pg_printf(const char *fmt,...) +extern int +pg_printf(const char *fmt,...) /* This extension allows gcc to check the format string */ __attribute__((format(printf, 1, 2))); @@ -133,7 +137,7 @@ __attribute__((format(printf, 1, 2))); * know anything about pg_printf. */ #ifdef __GNUC__ -#define vsnprintf(...) pg_vsnprintf(__VA_ARGS__) +#define vsnprintf(...) pg_vsnprintf(__VA_ARGS__) #define snprintf(...) pg_snprintf(__VA_ARGS__) #define sprintf(...) pg_sprintf(__VA_ARGS__) #define fprintf(...) pg_fprintf(__VA_ARGS__) @@ -189,6 +193,7 @@ extern int pclose_check(FILE *stream); */ extern int pgrename(const char *from, const char *to); extern int pgunlink(const char *path); + /* Include this first so later includes don't see these defines */ #ifdef WIN32_CLIENT_ONLY #include @@ -201,14 +206,14 @@ extern int pgunlink(const char *path); * Cygwin has its own symlinks which work on Win95/98/ME where * junction points don't, so use it instead. We have no way of * knowing what type of system Cygwin binaries will be run on. - * Note: Some CYGWIN includes might #define WIN32. + * Note: Some CYGWIN includes might #define WIN32. */ #if defined(WIN32) && !defined(__CYGWIN__) extern int pgsymlink(const char *oldpath, const char *newpath); + #define symlink(oldpath, newpath) pgsymlink(oldpath, newpath) #endif - -#endif /* defined(WIN32) || defined(__CYGWIN__) */ +#endif /* defined(WIN32) || defined(__CYGWIN__) */ extern void copydir(char *fromdir, char *todir, bool recurse); @@ -235,15 +240,14 @@ extern void srand48(long seed); /* Last parameter not used */ extern int gettimeofday(struct timeval * tp, struct timezone * tzp); - -#else /* !WIN32 */ +#else /* !WIN32 */ /* * Win32 requires a special close for sockets and pipes, while on Unix * close() does them all. */ #define closesocket close -#endif /* WIN32 */ +#endif /* WIN32 */ /* * Default "extern" declarations or macro substitutes for library routines. diff --git a/src/include/port/darwin.h b/src/include/port/darwin.h index 0a802e5abb..2b7600bebe 100644 --- a/src/include/port/darwin.h +++ b/src/include/port/darwin.h @@ -1,4 +1,3 @@ #define __darwin__ 1 #define HAVE_FSYNC_WRITETHROUGH - diff --git a/src/include/port/hpux.h b/src/include/port/hpux.h index 949ae23124..e96c5324a3 100644 --- a/src/include/port/hpux.h +++ b/src/include/port/hpux.h @@ -13,14 +13,12 @@ #ifndef BYTE_ORDER #define BYTE_ORDER BIG_ENDIAN #endif - #elif defined(__ia64) /* HPUX runs IA64 in big-endian mode */ #ifndef BYTE_ORDER #define BYTE_ORDER BIG_ENDIAN #endif - #else #error unrecognized CPU type for HP-UX diff --git a/src/include/port/ultrix4.h b/src/include/port/ultrix4.h index 4600dd36bd..c199afcbea 100644 --- a/src/include/port/ultrix4.h +++ b/src/include/port/ultrix4.h @@ -23,8 +23,7 @@ * warning-free compilation. */ -#include /* Declare various types, e.g. size_t, - * fd_set */ +#include /* Declare various types, e.g. size_t, fd_set */ extern int fp_class_d(double); extern long random(void); diff --git a/src/include/port/win32.h b/src/include/port/win32.h index 1617bc104d..44c449443a 100644 --- a/src/include/port/win32.h +++ b/src/include/port/win32.h @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/include/port/win32.h,v 1.46 2005/06/16 17:53:54 momjian Exp $ */ +/* $PostgreSQL: pgsql/src/include/port/win32.h,v 1.47 2005/10/15 02:49:45 momjian Exp $ */ /* undefine and redefine after #include */ #undef mkdir @@ -39,7 +39,6 @@ #else /* not BUILDING_DLL */ #define DLLIMPORT __declspec (dllimport) #endif - #elif defined(WIN32_CLIENT_ONLY) #if defined(_DLL) @@ -47,7 +46,6 @@ #else /* not _DLL */ #define DLLIMPORT __declspec (dllimport) #endif - #else /* not CYGWIN, not MSVC, not MingW */ #define DLLIMPORT @@ -134,8 +132,7 @@ int semop(int semId, struct sembuf * sops, int flag); #define SIGHUP 1 #define SIGQUIT 3 #define SIGTRAP 5 -#define SIGABRT 22 /* Set to match W32 value -- not UNIX - * value */ +#define SIGABRT 22 /* Set to match W32 value -- not UNIX value */ #define SIGKILL 9 #define SIGPIPE 13 #define SIGALRM 14 @@ -187,7 +184,7 @@ typedef int pid_t; /* * Supplement to . */ -#define lstat(path, sb) stat((path), (sb)) +#define lstat(path, sb) stat((path), (sb)) /* * Supplement to . @@ -247,7 +244,7 @@ int pgwin32_recv(SOCKET s, char *buf, int len, int flags); int pgwin32_send(SOCKET s, char *buf, int len, int flags); const char *pgwin32_socket_strerror(int err); -int pgwin32_waitforsinglesocket(SOCKET s, int what); +int pgwin32_waitforsinglesocket(SOCKET s, int what); /* in backend/port/win32/security.c */ extern int pgwin32_is_admin(void); diff --git a/src/include/port/win32/sys/socket.h b/src/include/port/win32/sys/socket.h index c9798060d6..d594901f8c 100644 --- a/src/include/port/win32/sys/socket.h +++ b/src/include/port/win32/sys/socket.h @@ -14,7 +14,7 @@ #ifdef PGERROR #define ERROR PGERROR -/* +/* * we can't use the windows gai_strerror{AW} functions because * they are defined inline in the MS header files. So we'll use our * own diff --git a/src/include/postmaster/autovacuum.h b/src/include/postmaster/autovacuum.h index 620a528f1b..716f6dbf3b 100644 --- a/src/include/postmaster/autovacuum.h +++ b/src/include/postmaster/autovacuum.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/postmaster/autovacuum.h,v 1.2 2005/08/11 21:11:50 tgl Exp $ + * $PostgreSQL: pgsql/src/include/postmaster/autovacuum.h,v 1.3 2005/10/15 02:49:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -15,14 +15,14 @@ #define AUTOVACUUM_H /* GUC variables */ -extern bool autovacuum_start_daemon; -extern int autovacuum_naptime; -extern int autovacuum_vac_thresh; -extern double autovacuum_vac_scale; -extern int autovacuum_anl_thresh; -extern double autovacuum_anl_scale; -extern int autovacuum_vac_cost_delay; -extern int autovacuum_vac_cost_limit; +extern bool autovacuum_start_daemon; +extern int autovacuum_naptime; +extern int autovacuum_vac_thresh; +extern double autovacuum_vac_scale; +extern int autovacuum_anl_thresh; +extern double autovacuum_anl_scale; +extern int autovacuum_vac_cost_delay; +extern int autovacuum_vac_cost_limit; /* Status inquiry functions */ extern bool AutoVacuumingActive(void); @@ -30,11 +30,11 @@ extern bool IsAutoVacuumProcess(void); /* Functions to start autovacuum process, called from postmaster */ extern void autovac_init(void); -extern int autovac_start(void); +extern int autovac_start(void); extern void autovac_stopped(void); #ifdef EXEC_BACKEND extern void AutoVacMain(int argc, char *argv[]); #endif -#endif /* AUTOVACUUM_H */ +#endif /* AUTOVACUUM_H */ diff --git a/src/include/postmaster/fork_process.h b/src/include/postmaster/fork_process.h index c089630034..59f4ff7af4 100644 --- a/src/include/postmaster/fork_process.h +++ b/src/include/postmaster/fork_process.h @@ -5,7 +5,7 @@ * * Copyright (c) 1996-2005, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/include/postmaster/fork_process.h,v 1.2 2005/03/13 23:32:26 tgl Exp $ + * $PostgreSQL: pgsql/src/include/postmaster/fork_process.h,v 1.3 2005/10/15 02:49:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -14,4 +14,4 @@ extern pid_t fork_process(void); -#endif /* FORK_PROCESS_H */ +#endif /* FORK_PROCESS_H */ diff --git a/src/include/postmaster/syslogger.h b/src/include/postmaster/syslogger.h index 078cad5605..6a8c2b7126 100644 --- a/src/include/postmaster/syslogger.h +++ b/src/include/postmaster/syslogger.h @@ -5,7 +5,7 @@ * * Copyright (c) 2004-2005, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/include/postmaster/syslogger.h,v 1.4 2005/01/01 20:44:29 tgl Exp $ + * $PostgreSQL: pgsql/src/include/postmaster/syslogger.h,v 1.5 2005/10/15 02:49:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -24,7 +24,6 @@ extern bool am_syslogger; #ifndef WIN32 extern int syslogPipe[2]; - #else extern HANDLE syslogPipe[2]; #endif diff --git a/src/include/regex/regcustom.h b/src/include/regex/regcustom.h index 9b0c691de0..f3b92570e6 100644 --- a/src/include/regex/regcustom.h +++ b/src/include/regex/regcustom.h @@ -25,7 +25,7 @@ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $PostgreSQL: pgsql/src/include/regex/regcustom.h,v 1.4 2004/05/07 00:24:58 tgl Exp $ + * $PostgreSQL: pgsql/src/include/regex/regcustom.h,v 1.5 2005/10/15 02:49:46 momjian Exp $ */ /* headers if any */ @@ -46,13 +46,10 @@ /* internal character type and related */ typedef pg_wchar chr; /* the type itself */ typedef unsigned uchr; /* unsigned type that will hold a chr */ -typedef int celt; /* type to hold chr, MCCE number, or - * NOCELT */ +typedef int celt; /* type to hold chr, MCCE number, or NOCELT */ -#define NOCELT (-1) /* celt value which is not valid chr or - * MCCE */ -#define CHR(c) ((unsigned char) (c)) /* turn char literal into chr - * literal */ +#define NOCELT (-1) /* celt value which is not valid chr or MCCE */ +#define CHR(c) ((unsigned char) (c)) /* turn char literal into chr literal */ #define DIGITVAL(c) ((c)-'0') /* turn chr digit into its value */ #define CHRBITS 32 /* bits in a chr; must not use sizeof */ #define CHR_MIN 0x00000000 /* smallest and largest chr; the value */ diff --git a/src/include/regex/regex.h b/src/include/regex/regex.h index 37c0609763..9cda1c23eb 100644 --- a/src/include/regex/regex.h +++ b/src/include/regex/regex.h @@ -29,7 +29,7 @@ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $PostgreSQL: pgsql/src/include/regex/regex.h,v 1.27 2005/07/10 04:54:32 momjian Exp $ + * $PostgreSQL: pgsql/src/include/regex/regex.h,v 1.28 2005/10/15 02:49:46 momjian Exp $ */ /* @@ -109,8 +109,7 @@ typedef struct #define REG_NLANCH 000200 /* ^ matches after \n, $ before */ #define REG_NEWLINE 000300 /* newlines are line terminators */ #define REG_PEND 000400 /* ugh -- backward-compatibility hack */ -#define REG_EXPECT 001000 /* report details on partial/limited - * matches */ +#define REG_EXPECT 001000 /* report details on partial/limited matches */ #define REG_BOSONLY 002000 /* temporary kludge for BOS-only matches */ #define REG_DUMP 004000 /* none of your business :-) */ #define REG_FAKE 010000 /* none of your business :-) */ @@ -150,8 +149,7 @@ typedef struct #define REG_BADRPT 13 /* quantifier operand invalid */ #define REG_ASSERT 15 /* "can't happen" -- you found a bug */ #define REG_INVARG 16 /* invalid argument to regex function */ -#define REG_MIXED 17 /* character widths of regex and string - * differ */ +#define REG_MIXED 17 /* character widths of regex and string differ */ #define REG_BADOPT 18 /* invalid embedded option */ /* two specials for debugging and testing */ #define REG_ATOI 101 /* convert error-code name to number */ diff --git a/src/include/regex/regguts.h b/src/include/regex/regguts.h index 1fb1e748a2..18712b4090 100644 --- a/src/include/regex/regguts.h +++ b/src/include/regex/regguts.h @@ -27,7 +27,7 @@ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $PostgreSQL: pgsql/src/include/regex/regguts.h,v 1.4 2005/05/25 21:40:42 momjian Exp $ + * $PostgreSQL: pgsql/src/include/regex/regguts.h,v 1.5 2005/10/15 02:49:46 momjian Exp $ */ @@ -134,8 +134,7 @@ #ifndef BYTBITS #define BYTBITS 8 /* bits in a byt */ #endif -#define BYTTAB (1<buf_hdr_lock) #define UnlockBufHdr(bufHdr) \ SpinLockRelease(&(bufHdr)->buf_hdr_lock) #define LockBufHdr_NoHoldoff(bufHdr) \ SpinLockAcquire_NoHoldoff(&(bufHdr)->buf_hdr_lock) -#define UnlockBufHdr_NoHoldoff(bufHdr) \ +#define UnlockBufHdr_NoHoldoff(bufHdr) \ SpinLockRelease_NoHoldoff(&(bufHdr)->buf_hdr_lock) @@ -191,7 +188,7 @@ extern Size StrategyShmemSize(void); extern void StrategyInitialize(bool init); /* buf_table.c */ -extern Size BufTableShmemSize(int size); +extern Size BufTableShmemSize(int size); extern void InitBufTable(int size); extern int BufTableLookup(BufferTag *tagPtr); extern int BufTableInsert(BufferTag *tagPtr, int buf_id); diff --git a/src/include/storage/bufmgr.h b/src/include/storage/bufmgr.h index 63def4a2e2..afe323314b 100644 --- a/src/include/storage/bufmgr.h +++ b/src/include/storage/bufmgr.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/storage/bufmgr.h,v 1.96 2005/08/20 23:26:33 tgl Exp $ + * $PostgreSQL: pgsql/src/include/storage/bufmgr.h,v 1.97 2005/10/15 02:49:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -153,7 +153,7 @@ extern void LockBufferForCleanup(Buffer buffer); extern void AbortBufferIO(void); extern void BufmgrCommit(void); -extern void BufferSync(void); +extern void BufferSync(void); extern void BgBufferSync(void); extern void AtProcExit_LocalBuffers(void); diff --git a/src/include/storage/fd.h b/src/include/storage/fd.h index 5a25e51879..5b1ebe743b 100644 --- a/src/include/storage/fd.h +++ b/src/include/storage/fd.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/storage/fd.h,v 1.53 2005/08/08 03:12:16 tgl Exp $ + * $PostgreSQL: pgsql/src/include/storage/fd.h,v 1.54 2005/10/15 02:49:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -88,7 +88,7 @@ extern void set_max_safe_fds(void); extern void closeAllVfds(void); extern void AtEOXact_Files(void); extern void AtEOSubXact_Files(bool isCommit, SubTransactionId mySubid, - SubTransactionId parentSubid); + SubTransactionId parentSubid); extern void RemovePgTempFiles(void); extern int pg_fsync(int fd); extern int pg_fsync_no_writethrough(int fd); diff --git a/src/include/storage/itemptr.h b/src/include/storage/itemptr.h index 75cddd8429..8705644f7b 100644 --- a/src/include/storage/itemptr.h +++ b/src/include/storage/itemptr.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/storage/itemptr.h,v 1.26 2004/12/31 22:03:42 pgsql Exp $ + * $PostgreSQL: pgsql/src/include/storage/itemptr.h,v 1.27 2005/10/15 02:49:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -41,8 +41,7 @@ typedef struct ItemPointerData } #ifdef __arm__ -__attribute__((packed)) /* Appropriate whack upside the head for - * ARM */ +__attribute__((packed)) /* Appropriate whack upside the head for ARM */ #endif ItemPointerData; diff --git a/src/include/storage/lmgr.h b/src/include/storage/lmgr.h index 72504ee2ab..730060a348 100644 --- a/src/include/storage/lmgr.h +++ b/src/include/storage/lmgr.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/storage/lmgr.h,v 1.51 2005/08/01 20:31:16 tgl Exp $ + * $PostgreSQL: pgsql/src/include/storage/lmgr.h,v 1.52 2005/10/15 02:49:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -28,13 +28,12 @@ #define RowExclusiveLock 3 /* INSERT, UPDATE, DELETE */ #define ShareUpdateExclusiveLock 4 /* VACUUM (non-FULL) */ #define ShareLock 5 /* CREATE INDEX */ -#define ShareRowExclusiveLock 6 /* like EXCLUSIVE MODE, but allows - * ROW SHARE */ +#define ShareRowExclusiveLock 6 /* like EXCLUSIVE MODE, but allows ROW + * SHARE */ #define ExclusiveLock 7 /* blocks ROW SHARE/SELECT...FOR * UPDATE */ #define AccessExclusiveLock 8 /* ALTER TABLE, DROP TABLE, VACUUM - * FULL, and unqualified LOCK - * TABLE */ + * FULL, and unqualified LOCK TABLE */ /* * Note: all lock mode numbers must be less than lock.h's MAX_LOCKMODES, @@ -50,7 +49,7 @@ extern bool ConditionalLockRelation(Relation relation, LOCKMODE lockmode); extern void UnlockRelation(Relation relation, LOCKMODE lockmode); extern void LockRelationForSession(LockRelId *relid, bool istemprel, - LOCKMODE lockmode); + LOCKMODE lockmode); extern void UnlockRelationForSession(LockRelId *relid, LOCKMODE lockmode); /* Lock a relation for extension */ @@ -65,7 +64,7 @@ extern void UnlockPage(Relation relation, BlockNumber blkno, LOCKMODE lockmode); /* Lock a tuple (see heap_lock_tuple before assuming you understand this) */ extern void LockTuple(Relation relation, ItemPointer tid, LOCKMODE lockmode); extern bool ConditionalLockTuple(Relation relation, ItemPointer tid, - LOCKMODE lockmode); + LOCKMODE lockmode); extern void UnlockTuple(Relation relation, ItemPointer tid, LOCKMODE lockmode); /* Lock an XID (used to wait for a transaction to finish) */ @@ -76,14 +75,14 @@ extern bool ConditionalXactLockTableWait(TransactionId xid); /* Lock a general object (other than a relation) of the current database */ extern void LockDatabaseObject(Oid classid, Oid objid, uint16 objsubid, - LOCKMODE lockmode); + LOCKMODE lockmode); extern void UnlockDatabaseObject(Oid classid, Oid objid, uint16 objsubid, - LOCKMODE lockmode); + LOCKMODE lockmode); /* Lock a shared-across-databases object (other than a relation) */ extern void LockSharedObject(Oid classid, Oid objid, uint16 objsubid, - LOCKMODE lockmode); + LOCKMODE lockmode); extern void UnlockSharedObject(Oid classid, Oid objid, uint16 objsubid, - LOCKMODE lockmode); + LOCKMODE lockmode); #endif /* LMGR_H */ diff --git a/src/include/storage/lock.h b/src/include/storage/lock.h index 6610b1381b..e6b9e94b65 100644 --- a/src/include/storage/lock.h +++ b/src/include/storage/lock.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/storage/lock.h,v 1.90 2005/08/20 23:26:33 tgl Exp $ + * $PostgreSQL: pgsql/src/include/storage/lock.h,v 1.91 2005/10/15 02:49:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -122,6 +122,7 @@ typedef enum LockTagType /* ID info for a transaction is its TransactionId */ LOCKTAG_OBJECT, /* non-relation database object */ /* ID info for an object is DB OID + CLASS OID + OBJECT OID + SUBID */ + /* * Note: object ID has same representation as in pg_depend and * pg_description, but notice that we are constraining SUBID to 16 bits. @@ -137,23 +138,23 @@ typedef enum LockTagType * to widen Oid, BlockNumber, or TransactionId to more than 32 bits. * * We include lockmethodid in the locktag so that a single hash table in - * shared memory can store locks of different lockmethods. For largely + * shared memory can store locks of different lockmethods. For largely * historical reasons, it's passed to the lock.c routines as a separate * argument and then stored into the locktag. */ typedef struct LOCKTAG { - uint32 locktag_field1; /* a 32-bit ID field */ - uint32 locktag_field2; /* a 32-bit ID field */ - uint32 locktag_field3; /* a 32-bit ID field */ - uint16 locktag_field4; /* a 16-bit ID field */ - uint8 locktag_type; /* see enum LockTagType */ + uint32 locktag_field1; /* a 32-bit ID field */ + uint32 locktag_field2; /* a 32-bit ID field */ + uint32 locktag_field3; /* a 32-bit ID field */ + uint16 locktag_field4; /* a 16-bit ID field */ + uint8 locktag_type; /* see enum LockTagType */ uint8 locktag_lockmethodid; /* lockmethod indicator */ } LOCKTAG; /* * These macros define how we map logical IDs of lockable objects into - * the physical fields of LOCKTAG. Use these to set up LOCKTAG values, + * the physical fields of LOCKTAG. Use these to set up LOCKTAG values, * rather than accessing the fields directly. Note multiple eval of target! */ #define SET_LOCKTAG_RELATION(locktag,dboid,reloid) \ @@ -225,11 +226,9 @@ typedef struct LOCK /* data */ LOCKMASK grantMask; /* bitmask for lock types already granted */ LOCKMASK waitMask; /* bitmask for lock types awaited */ - SHM_QUEUE procLocks; /* list of PROCLOCK objects assoc. with - * lock */ + SHM_QUEUE procLocks; /* list of PROCLOCK objects assoc. with lock */ PROC_QUEUE waitProcs; /* list of PGPROC objects waiting on lock */ - int requested[MAX_LOCKMODES]; /* counts of requested - * locks */ + int requested[MAX_LOCKMODES]; /* counts of requested locks */ int nRequested; /* total of requested[] array */ int granted[MAX_LOCKMODES]; /* counts of granted locks */ int nGranted; /* total of granted[] array */ @@ -250,7 +249,7 @@ typedef struct LOCK * * Internally to a backend, it is possible for the same lock to be held * for different purposes: the backend tracks transaction locks separately - * from session locks. However, this is not reflected in the shared-memory + * from session locks. However, this is not reflected in the shared-memory * state: we only track which backend(s) hold the lock. This is OK since a * backend can never block itself. * @@ -261,7 +260,7 @@ typedef struct LOCK * as soon as convenient. * * releaseMask is workspace for LockReleaseAll(): it shows the locks due - * to be released during the current call. This must only be examined or + * to be released during the current call. This must only be examined or * set by the backend owning the PROCLOCK. * * Each PROCLOCK object is linked into lists for both the associated LOCK @@ -373,13 +372,13 @@ extern LOCKMETHODID LockMethodTableInit(const char *tabName, int numModes); extern LOCKMETHODID LockMethodTableRename(LOCKMETHODID lockmethodid); extern LockAcquireResult LockAcquire(LOCKMETHODID lockmethodid, - LOCKTAG *locktag, - bool isTempObject, - LOCKMODE lockmode, - bool sessionLock, - bool dontWait); + LOCKTAG *locktag, + bool isTempObject, + LOCKMODE lockmode, + bool sessionLock, + bool dontWait); extern bool LockRelease(LOCKMETHODID lockmethodid, LOCKTAG *locktag, - LOCKMODE lockmode, bool sessionLock); + LOCKMODE lockmode, bool sessionLock); extern void LockReleaseAll(LOCKMETHODID lockmethodid, bool allLocks); extern void LockReleaseCurrentOwner(void); extern void LockReassignCurrentOwner(void); @@ -403,11 +402,11 @@ extern LockData *GetLockStatusData(void); extern const char *GetLockmodeName(LOCKMODE mode); extern void lock_twophase_recover(TransactionId xid, uint16 info, - void *recdata, uint32 len); + void *recdata, uint32 len); extern void lock_twophase_postcommit(TransactionId xid, uint16 info, - void *recdata, uint32 len); + void *recdata, uint32 len); extern void lock_twophase_postabort(TransactionId xid, uint16 info, - void *recdata, uint32 len); + void *recdata, uint32 len); #ifdef LOCK_DEBUG extern void DumpLocks(PGPROC *proc); diff --git a/src/include/storage/lwlock.h b/src/include/storage/lwlock.h index 98d1d40ad5..4291e0b2e7 100644 --- a/src/include/storage/lwlock.h +++ b/src/include/storage/lwlock.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/storage/lwlock.h,v 1.22 2005/08/20 23:26:34 tgl Exp $ + * $PostgreSQL: pgsql/src/include/storage/lwlock.h,v 1.23 2005/10/15 02:49:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -47,8 +47,7 @@ typedef enum LWLockId BgWriterCommLock, TwoPhaseStateLock, - NumFixedLWLocks, /* must be last except for - * MaxDynamicLWLock */ + NumFixedLWLocks, /* must be last except for MaxDynamicLWLock */ MaxDynamicLWLock = 1000000000 } LWLockId; diff --git a/src/include/storage/pg_shmem.h b/src/include/storage/pg_shmem.h index c034e19ce4..4dd91e8540 100644 --- a/src/include/storage/pg_shmem.h +++ b/src/include/storage/pg_shmem.h @@ -17,7 +17,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/storage/pg_shmem.h,v 1.15 2005/08/20 23:26:34 tgl Exp $ + * $PostgreSQL: pgsql/src/include/storage/pg_shmem.h,v 1.16 2005/10/15 02:49:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -46,7 +46,7 @@ extern void PGSharedMemoryReAttach(void); #endif extern PGShmemHeader *PGSharedMemoryCreate(Size size, bool makePrivate, - int port); + int port); extern bool PGSharedMemoryIsInUse(unsigned long id1, unsigned long id2); extern void PGSharedMemoryDetach(void); diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index b915f78035..4cba391048 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/storage/proc.h,v 1.83 2005/10/11 20:41:32 tgl Exp $ + * $PostgreSQL: pgsql/src/include/storage/proc.h,v 1.84 2005/10/15 02:49:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -65,9 +65,9 @@ struct PGPROC TransactionId xid; /* transaction currently being executed by * this proc */ - TransactionId xmin; /* minimal running XID as it was when we - * were starting our xact: vacuum must not - * remove tuples deleted by xid >= xmin ! */ + TransactionId xmin; /* minimal running XID as it was when we were + * starting our xact: vacuum must not remove + * tuples deleted by xid >= xmin ! */ int pid; /* This backend's process id, or 0 */ Oid databaseId; /* OID of database this backend is using */ @@ -83,11 +83,11 @@ struct PGPROC LOCK *waitLock; /* Lock object we're sleeping on ... */ PROCLOCK *waitProcLock; /* Per-holder info for awaited lock */ LOCKMODE waitLockMode; /* type of lock we're waiting for */ - LOCKMASK heldLocks; /* bitmask for lock types already held on - * this lock object by this backend */ + LOCKMASK heldLocks; /* bitmask for lock types already held on this + * lock object by this backend */ - SHM_QUEUE procLocks; /* list of PROCLOCK objects for locks held - * or awaited by this backend */ + SHM_QUEUE procLocks; /* list of PROCLOCK objects for locks held or + * awaited by this backend */ struct XidCache subxids; /* cache for subtransaction XIDs */ }; diff --git a/src/include/storage/procarray.h b/src/include/storage/procarray.h index 1c010ff5b0..68c615afc6 100644 --- a/src/include/storage/procarray.h +++ b/src/include/storage/procarray.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/storage/procarray.h,v 1.5 2005/08/20 23:26:34 tgl Exp $ + * $PostgreSQL: pgsql/src/include/storage/procarray.h,v 1.6 2005/10/15 02:49:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -27,7 +27,7 @@ extern bool TransactionIdIsActive(TransactionId xid); extern TransactionId GetOldestXmin(bool allDbs); extern PGPROC *BackendPidGetProc(int pid); -extern int BackendXidGetPid(TransactionId xid); +extern int BackendXidGetPid(TransactionId xid); extern bool IsBackendPid(int pid); extern bool DatabaseHasActiveBackends(Oid databaseId, bool ignoreMyself); diff --git a/src/include/storage/sinval.h b/src/include/storage/sinval.h index 2fe0cce836..b4845f8a89 100644 --- a/src/include/storage/sinval.h +++ b/src/include/storage/sinval.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/storage/sinval.h,v 1.42 2005/08/20 23:26:35 tgl Exp $ + * $PostgreSQL: pgsql/src/include/storage/sinval.h,v 1.43 2005/10/15 02:49:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -23,9 +23,9 @@ * invalidates an entry in a catcache, one that invalidates a relcache entry, * and one that invalidates an smgr cache entry. More types could be added * if needed. The message type is identified by the first "int16" field of - * the message struct. Zero or positive means a catcache inval message (and + * the message struct. Zero or positive means a catcache inval message (and * also serves as the catcache ID field). -1 means a relcache inval message. - * -2 means an smgr inval message. Other negative values are available to + * -2 means an smgr inval message. Other negative values are available to * identify other inval message types. * * Catcache inval events are initially driven by detecting tuple inserts, @@ -89,7 +89,7 @@ extern void InitBackendSharedInvalidationState(void); extern void SendSharedInvalidMessage(SharedInvalidationMessage *msg); extern void ReceiveSharedInvalidMessages( - void (*invalFunction) (SharedInvalidationMessage *msg), + void (*invalFunction) (SharedInvalidationMessage *msg), void (*resetFunction) (void)); /* signal handler for catchup events (SIGUSR1) */ diff --git a/src/include/storage/sinvaladt.h b/src/include/storage/sinvaladt.h index 7d1f5f4685..c02bee016d 100644 --- a/src/include/storage/sinvaladt.h +++ b/src/include/storage/sinvaladt.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/storage/sinvaladt.h,v 1.39 2005/08/20 23:26:35 tgl Exp $ + * $PostgreSQL: pgsql/src/include/storage/sinvaladt.h,v 1.40 2005/10/15 02:49:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -81,8 +81,7 @@ typedef struct SISeg */ int minMsgNum; /* oldest message still needed */ int maxMsgNum; /* next message number to be assigned */ - int lastBackend; /* index of last active procState entry, - * +1 */ + int lastBackend; /* index of last active procState entry, +1 */ int maxBackends; /* size of procState array */ int freeBackends; /* number of empty procState slots */ @@ -94,8 +93,8 @@ typedef struct SISeg /* * Per-backend state info. * - * We declare procState as 1 entry because C wants a fixed-size array, - * but actually it is maxBackends entries long. + * We declare procState as 1 entry because C wants a fixed-size array, but + * actually it is maxBackends entries long. */ ProcState procState[1]; /* reflects the invalidation state */ } SISeg; diff --git a/src/include/storage/smgr.h b/src/include/storage/smgr.h index ab3c39fd1c..910d49565c 100644 --- a/src/include/storage/smgr.h +++ b/src/include/storage/smgr.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/storage/smgr.h,v 1.52 2005/06/17 22:32:50 tgl Exp $ + * $PostgreSQL: pgsql/src/include/storage/smgr.h,v 1.53 2005/10/15 02:49:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -30,7 +30,7 @@ * * An SMgrRelation may have an "owner", which is just a pointer to it from * somewhere else; smgr.c will clear this pointer if the SMgrRelation is - * closed. We use this to avoid dangling pointers from relcache to smgr + * closed. We use this to avoid dangling pointers from relcache to smgr * without having to make the smgr explicitly aware of relcache. There * can't be more than one "owner" pointer per SMgrRelation, but that's * all we need. diff --git a/src/include/tcop/dest.h b/src/include/tcop/dest.h index 3efb1924c5..410020f265 100644 --- a/src/include/tcop/dest.h +++ b/src/include/tcop/dest.h @@ -54,7 +54,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/tcop/dest.h,v 1.46 2005/03/16 21:38:10 tgl Exp $ + * $PostgreSQL: pgsql/src/include/tcop/dest.h,v 1.47 2005/10/15 02:49:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -102,7 +102,7 @@ struct _DestReceiver { /* Called for each tuple to be output: */ void (*receiveSlot) (TupleTableSlot *slot, - DestReceiver *self); + DestReceiver *self); /* Per-executor-run initialization and shutdown: */ void (*rStartup) (DestReceiver *self, int operation, diff --git a/src/include/tcop/pquery.h b/src/include/tcop/pquery.h index da2d29aea8..856fb29615 100644 --- a/src/include/tcop/pquery.h +++ b/src/include/tcop/pquery.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/tcop/pquery.h,v 1.35 2005/06/22 17:45:46 tgl Exp $ + * $PostgreSQL: pgsql/src/include/tcop/pquery.h,v 1.36 2005/10/15 02:49:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -25,7 +25,7 @@ extern PortalStrategy ChoosePortalStrategy(List *parseTrees); extern List *FetchPortalTargetList(Portal portal); extern void PortalStart(Portal portal, ParamListInfo params, - Snapshot snapshot); + Snapshot snapshot); extern void PortalSetResultFormat(Portal portal, int nFormats, int16 *formats); diff --git a/src/include/tcop/tcopprot.h b/src/include/tcop/tcopprot.h index 93b703c929..1f03f546c8 100644 --- a/src/include/tcop/tcopprot.h +++ b/src/include/tcop/tcopprot.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/tcop/tcopprot.h,v 1.77 2005/08/11 21:11:50 tgl Exp $ + * $PostgreSQL: pgsql/src/include/tcop/tcopprot.h,v 1.78 2005/10/15 02:49:46 momjian Exp $ * * OLD COMMENTS * This file was created so that other c files could get the two @@ -66,6 +66,6 @@ extern int PostgresMain(int argc, char *argv[], const char *username); extern void ResetUsage(void); extern void ShowUsage(const char *title); extern void set_debug_options(int debug_flag, - GucContext context, GucSource source); + GucContext context, GucSource source); #endif /* TCOPPROT_H */ diff --git a/src/include/utils/acl.h b/src/include/utils/acl.h index 9fd551f28c..c02cc34218 100644 --- a/src/include/utils/acl.h +++ b/src/include/utils/acl.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/acl.h,v 1.84 2005/10/10 18:49:04 tgl Exp $ + * $PostgreSQL: pgsql/src/include/utils/acl.h,v 1.85 2005/10/15 02:49:46 momjian Exp $ * * NOTES * An ACL array is simply an array of AclItems, representing the union @@ -79,7 +79,7 @@ typedef struct AclItem /* * Definitions for convenient access to Acl (array of AclItem) and IdList - * (array of Oid). These are standard PostgreSQL arrays, but are restricted + * (array of Oid). These are standard PostgreSQL arrays, but are restricted * to have one dimension. We also ignore the lower bound when reading, * and set it to one when writing. * @@ -208,7 +208,7 @@ extern Acl *aclnewowner(const Acl *old_acl, Oid oldOwnerId, Oid newOwnerId); extern AclMode aclmask(const Acl *acl, Oid roleid, Oid ownerId, AclMode mask, AclMaskHow how); -extern int aclmembers(const Acl *acl, Oid **roleids); +extern int aclmembers(const Acl *acl, Oid **roleids); extern bool has_privs_of_role(Oid member, Oid role); extern bool is_member_of_role(Oid member, Oid role); @@ -216,8 +216,8 @@ extern bool is_admin_of_role(Oid member, Oid role); extern void check_is_member_of_role(Oid member, Oid role); extern void select_best_grantor(Oid roleId, AclMode privileges, - const Acl *acl, Oid ownerId, - Oid *grantorId, AclMode *grantOptions); + const Acl *acl, Oid ownerId, + Oid *grantorId, AclMode *grantOptions); extern void initialize_acl(void); diff --git a/src/include/utils/array.h b/src/include/utils/array.h index 92ff21bb64..1e8be02606 100644 --- a/src/include/utils/array.h +++ b/src/include/utils/array.h @@ -10,7 +10,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/array.h,v 1.54 2005/03/29 00:17:18 tgl Exp $ + * $PostgreSQL: pgsql/src/include/utils/array.h,v 1.55 2005/10/15 02:49:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -162,7 +162,7 @@ extern ArrayType *array_set_slice(ArrayType *array, int nSubscripts, bool *isNull); extern Datum array_map(FunctionCallInfo fcinfo, Oid inpType, Oid retType, - ArrayMapState *amstate); + ArrayMapState *amstate); extern ArrayType *construct_array(Datum *elems, int nelems, Oid elmtype, diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h index 50855daf8d..469d993d04 100644 --- a/src/include/utils/builtins.h +++ b/src/include/utils/builtins.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/builtins.h,v 1.265 2005/10/02 23:50:13 tgl Exp $ + * $PostgreSQL: pgsql/src/include/utils/builtins.h,v 1.266 2005/10/15 02:49:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -752,7 +752,7 @@ extern Datum numeric_in(PG_FUNCTION_ARGS); extern Datum numeric_out(PG_FUNCTION_ARGS); extern Datum numeric_recv(PG_FUNCTION_ARGS); extern Datum numeric_send(PG_FUNCTION_ARGS); -extern Datum numeric (PG_FUNCTION_ARGS); +extern Datum numeric(PG_FUNCTION_ARGS); extern Datum numeric_abs(PG_FUNCTION_ARGS); extern Datum numeric_uminus(PG_FUNCTION_ARGS); extern Datum numeric_uplus(PG_FUNCTION_ARGS); diff --git a/src/include/utils/catcache.h b/src/include/utils/catcache.h index 62637f3ec9..6fb358b813 100644 --- a/src/include/utils/catcache.h +++ b/src/include/utils/catcache.h @@ -13,7 +13,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/catcache.h,v 1.55 2005/08/13 22:18:07 tgl Exp $ + * $PostgreSQL: pgsql/src/include/utils/catcache.h,v 1.56 2005/10/15 02:49:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -56,9 +56,8 @@ typedef struct catcache long cc_newloads; /* # of successful loads of new entry */ /* - * cc_searches - (cc_hits + cc_neg_hits + cc_newloads) is number of - * failed searches, each of which will result in loading a negative - * entry + * cc_searches - (cc_hits + cc_neg_hits + cc_newloads) is number of failed + * searches, each of which will result in loading a negative entry */ long cc_invals; /* # of entries invalidated from cache */ long cc_discards; /* # of entries discarded due to overflow */ @@ -77,18 +76,18 @@ typedef struct catctup /* * Each tuple in a cache is a member of two Dllists: one lists all the - * elements in all the caches in LRU order, and the other lists just - * the elements in one hashbucket of one cache, also in LRU order. + * elements in all the caches in LRU order, and the other lists just the + * elements in one hashbucket of one cache, also in LRU order. */ Dlelem lrulist_elem; /* list member of global LRU list */ Dlelem cache_elem; /* list member of per-bucket list */ /* * The tuple may also be a member of at most one CatCList. (If a single - * catcache is list-searched with varying numbers of keys, we may have - * to make multiple entries for the same tuple because of this - * restriction. Currently, that's not expected to be common, so we - * accept the potential inefficiency.) + * catcache is list-searched with varying numbers of keys, we may have to + * make multiple entries for the same tuple because of this restriction. + * Currently, that's not expected to be common, so we accept the potential + * inefficiency.) */ struct catclist *c_list; /* containing CatCList, or NULL if none */ @@ -96,13 +95,13 @@ typedef struct catctup * A tuple marked "dead" must not be returned by subsequent searches. * However, it won't be physically deleted from the cache until its * refcount goes to zero. (If it's a member of a CatCList, the list's - * refcount must go to zero, too; also, remember to mark the list dead - * at the same time the tuple is marked.) + * refcount must go to zero, too; also, remember to mark the list dead at + * the same time the tuple is marked.) * - * A negative cache entry is an assertion that there is no tuple matching - * a particular key. This is just as useful as a normal entry so far - * as avoiding catalog searches is concerned. Management of positive - * and negative entries is identical. + * A negative cache entry is an assertion that there is no tuple matching a + * particular key. This is just as useful as a normal entry so far as + * avoiding catalog searches is concerned. Management of positive and + * negative entries is identical. */ int refcount; /* number of active references */ bool dead; /* dead but not yet removed? */ @@ -119,26 +118,26 @@ typedef struct catclist CatCache *my_cache; /* link to owning catcache */ /* - * A CatCList describes the result of a partial search, ie, a search - * using only the first K key columns of an N-key cache. We form the - * keys used into a tuple (with other attributes NULL) to represent - * the stored key set. The CatCList object contains links to cache - * entries for all the table rows satisfying the partial key. (Note: - * none of these will be negative cache entries.) + * A CatCList describes the result of a partial search, ie, a search using + * only the first K key columns of an N-key cache. We form the keys used + * into a tuple (with other attributes NULL) to represent the stored key + * set. The CatCList object contains links to cache entries for all the + * table rows satisfying the partial key. (Note: none of these will be + * negative cache entries.) * - * A CatCList is only a member of a per-cache list; we do not do separate - * LRU management for CatCLists. See CatalogCacheCleanup() for the - * details of the management algorithm. + * A CatCList is only a member of a per-cache list; we do not do separate LRU + * management for CatCLists. See CatalogCacheCleanup() for the details of + * the management algorithm. * - * A list marked "dead" must not be returned by subsequent searches. - * However, it won't be physically deleted from the cache until its - * refcount goes to zero. (A list should be marked dead if any of its - * member entries are dead.) + * A list marked "dead" must not be returned by subsequent searches. However, + * it won't be physically deleted from the cache until its refcount goes + * to zero. (A list should be marked dead if any of its member entries + * are dead.) * * If "ordered" is true then the member tuples appear in the order of the - * cache's underlying index. This will be true in normal operation, - * but might not be true during bootstrap or recovery operations. - * (namespace.c is able to save some cycles when it is true.) + * cache's underlying index. This will be true in normal operation, but + * might not be true during bootstrap or recovery operations. (namespace.c + * is able to save some cycles when it is true.) */ Dlelem cache_elem; /* list member of per-catcache list */ int refcount; /* number of active references */ @@ -189,7 +188,7 @@ extern void CatalogCacheIdInvalidate(int cacheId, uint32 hashValue, ItemPointer pointer); extern void PrepareToInvalidateCacheTuple(Relation relation, HeapTuple tuple, - void (*function) (int, uint32, ItemPointer, Oid)); + void (*function) (int, uint32, ItemPointer, Oid)); extern void PrintCatCacheLeakWarning(HeapTuple tuple); extern void PrintCatCacheListLeakWarning(CatCList *list); diff --git a/src/include/utils/date.h b/src/include/utils/date.h index 869e2ade29..e7985e820e 100644 --- a/src/include/utils/date.h +++ b/src/include/utils/date.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/date.h,v 1.31 2005/10/09 17:21:47 tgl Exp $ + * $PostgreSQL: pgsql/src/include/utils/date.h,v 1.32 2005/10/15 02:49:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -21,7 +21,6 @@ typedef int32 DateADT; #ifdef HAVE_INT64_TIMESTAMP typedef int64 TimeADT; - #else typedef float8 TimeADT; #endif @@ -29,11 +28,9 @@ typedef float8 TimeADT; typedef struct { #ifdef HAVE_INT64_TIMESTAMP - int64 time; /* all time units other than months and - * years */ + int64 time; /* all time units other than months and years */ #else - double time; /* all time units other than months and - * years */ + double time; /* all time units other than months and years */ #endif int32 zone; /* numeric time zone, in seconds */ } TimeTzADT; @@ -55,7 +52,6 @@ typedef struct #define DateADTGetDatum(X) Int32GetDatum(X) #define TimeADTGetDatum(X) Int64GetDatum(X) #define TimeTzADTPGetDatum(X) PointerGetDatum(X) - #else #define MAX_TIME_PRECISION 10 @@ -71,8 +67,7 @@ typedef struct #define DateADTGetDatum(X) Int32GetDatum(X) #define TimeADTGetDatum(X) Float8GetDatum(X) #define TimeTzADTPGetDatum(X) PointerGetDatum(X) - -#endif /* HAVE_INT64_TIMESTAMP */ +#endif /* HAVE_INT64_TIMESTAMP */ #define PG_GETARG_DATEADT(n) DatumGetDateADT(PG_GETARG_DATUM(n)) #define PG_GETARG_TIMEADT(n) DatumGetTimeADT(PG_GETARG_DATUM(n)) diff --git a/src/include/utils/datetime.h b/src/include/utils/datetime.h index 572a9852f7..48b158e050 100644 --- a/src/include/utils/datetime.h +++ b/src/include/utils/datetime.h @@ -9,7 +9,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/datetime.h,v 1.56 2005/07/23 14:25:34 momjian Exp $ + * $PostgreSQL: pgsql/src/include/utils/datetime.h,v 1.57 2005/10/15 02:49:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -175,10 +175,10 @@ #define DTK_DATE_M (DTK_M(YEAR) | DTK_M(MONTH) | DTK_M(DAY)) #define DTK_TIME_M (DTK_M(HOUR) | DTK_M(MINUTE) | DTK_M(SECOND)) -#define MAXDATELEN 51 /* maximum possible length of an input - * date string (not counting tr. null) */ -#define MAXDATEFIELDS 25 /* maximum possible number of fields in a - * date string */ +#define MAXDATELEN 51 /* maximum possible length of an input date + * string (not counting tr. null) */ +#define MAXDATEFIELDS 25 /* maximum possible number of fields in a date + * string */ #define TOKMAXLEN 10 /* only this many chars are stored in * datetktbl */ @@ -271,8 +271,8 @@ extern const int day_tab[2][13]; #define DTERR_TZDISP_OVERFLOW (-5) -extern void GetCurrentDateTime(struct pg_tm *tm); -extern void GetCurrentTimeUsec(struct pg_tm *tm, fsec_t *fsec, int *tzp); +extern void GetCurrentDateTime(struct pg_tm * tm); +extern void GetCurrentTimeUsec(struct pg_tm * tm, fsec_t *fsec, int *tzp); extern void j2date(int jd, int *year, int *month, int *day); extern int date2j(int year, int month, int day); @@ -281,22 +281,22 @@ extern int ParseDateTime(const char *timestr, char *workbuf, size_t buflen, int maxfields, int *numfields); extern int DecodeDateTime(char **field, int *ftype, int nf, int *dtype, - struct pg_tm *tm, fsec_t *fsec, int *tzp); + struct pg_tm * tm, fsec_t *fsec, int *tzp); extern int DecodeTimeOnly(char **field, int *ftype, int nf, int *dtype, - struct pg_tm *tm, fsec_t *fsec, int *tzp); + struct pg_tm * tm, fsec_t *fsec, int *tzp); extern int DecodeInterval(char **field, int *ftype, int nf, int *dtype, - struct pg_tm *tm, fsec_t *fsec); + struct pg_tm * tm, fsec_t *fsec); extern void DateTimeParseError(int dterr, const char *str, const char *datatype); -extern int DetermineTimeZoneOffset(struct pg_tm *tm, pg_tz *tzp); +extern int DetermineTimeZoneOffset(struct pg_tm * tm, pg_tz *tzp); -extern int EncodeDateOnly(struct pg_tm *tm, int style, char *str); -extern int EncodeTimeOnly(struct pg_tm *tm, fsec_t fsec, int *tzp, int style, char *str); -extern int EncodeDateTime(struct pg_tm *tm, fsec_t fsec, int *tzp, char **tzn, int style, char *str); -extern int EncodeInterval(struct pg_tm *tm, fsec_t fsec, int style, char *str); +extern int EncodeDateOnly(struct pg_tm * tm, int style, char *str); +extern int EncodeTimeOnly(struct pg_tm * tm, fsec_t fsec, int *tzp, int style, char *str); +extern int EncodeDateTime(struct pg_tm * tm, fsec_t fsec, int *tzp, char **tzn, int style, char *str); +extern int EncodeInterval(struct pg_tm * tm, fsec_t fsec, int style, char *str); extern int DecodeSpecial(int field, char *lowtoken, int *val); extern int DecodeUnits(int field, char *lowtoken, int *val); diff --git a/src/include/utils/elog.h b/src/include/utils/elog.h index 264dfcc142..06b91f05af 100644 --- a/src/include/utils/elog.h +++ b/src/include/utils/elog.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/elog.h,v 1.80 2005/10/14 20:53:56 tgl Exp $ + * $PostgreSQL: pgsql/src/include/utils/elog.h,v 1.81 2005/10/15 02:49:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -23,23 +23,22 @@ #define DEBUG3 12 #define DEBUG2 13 #define DEBUG1 14 /* used by GUC debug_* variables */ -#define LOG 15 /* Server operational messages; sent only - * to server log by default. */ -#define COMMERROR 16 /* Client communication problems; same as - * LOG for server reporting, but never - * sent to client. */ -#define INFO 17 /* Informative messages that are always - * sent to client; is not affected by +#define LOG 15 /* Server operational messages; sent only to + * server log by default. */ +#define COMMERROR 16 /* Client communication problems; same as LOG + * for server reporting, but never sent to + * client. */ +#define INFO 17 /* Informative messages that are always sent + * to client; is not affected by * client_min_messages */ #define NOTICE 18 /* Helpful messages to users about query - * operation; sent to client and server - * log by default. */ -#define WARNING 19 /* Warnings. NOTICE is for expected - * messages like implicit sequence - * creation by SERIAL. WARNING is for - * unexpected messages. */ -#define ERROR 20 /* user error - abort transaction; return - * to known state */ + * operation; sent to client and server log + * by default. */ +#define WARNING 19 /* Warnings. NOTICE is for expected messages + * like implicit sequence creation by SERIAL. + * WARNING is for unexpected messages. */ +#define ERROR 20 /* user error - abort transaction; return to + * known state */ /* Save ERROR value in PGERROR so it can be restored when Win32 includes * modify it. We have to use a constant rather than ERROR because macros * are expanded only when referenced outside macros. @@ -283,6 +282,7 @@ extern int Log_destination; /* Other exported functions */ extern void DebugFileOpen(void); extern char *unpack_sql_state(int sql_state); + #ifdef HAVE_SYSLOG extern void set_syslog_parameters(const char *ident, int facility); #endif diff --git a/src/include/utils/flatfiles.h b/src/include/utils/flatfiles.h index 5faf35db57..6b6a7cec86 100644 --- a/src/include/utils/flatfiles.h +++ b/src/include/utils/flatfiles.h @@ -4,7 +4,7 @@ * Routines for maintaining "flat file" images of the shared catalogs. * * - * $PostgreSQL: pgsql/src/include/utils/flatfiles.h,v 1.5 2005/06/28 05:09:13 tgl Exp $ + * $PostgreSQL: pgsql/src/include/utils/flatfiles.h,v 1.6 2005/10/15 02:49:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -24,12 +24,12 @@ extern void BuildFlatFiles(bool database_only); extern void AtPrepare_UpdateFlatFiles(void); extern void AtEOXact_UpdateFlatFiles(bool isCommit); extern void AtEOSubXact_UpdateFlatFiles(bool isCommit, - SubTransactionId mySubid, - SubTransactionId parentSubid); + SubTransactionId mySubid, + SubTransactionId parentSubid); extern Datum flatfile_update_trigger(PG_FUNCTION_ARGS); extern void flatfile_twophase_postcommit(TransactionId xid, uint16 info, - void *recdata, uint32 len); + void *recdata, uint32 len); #endif /* FLATFILES_H */ diff --git a/src/include/utils/fmgrtab.h b/src/include/utils/fmgrtab.h index 1ed1018adb..0a2e05b581 100644 --- a/src/include/utils/fmgrtab.h +++ b/src/include/utils/fmgrtab.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/fmgrtab.h,v 1.24 2004/12/31 22:03:46 pgsql Exp $ + * $PostgreSQL: pgsql/src/include/utils/fmgrtab.h,v 1.25 2005/10/15 02:49:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -26,8 +26,7 @@ typedef struct { Oid foid; /* OID of the function */ const char *funcName; /* C name of the function */ - short nargs; /* 0..FUNC_MAX_ARGS, or -1 if variable - * count */ + short nargs; /* 0..FUNC_MAX_ARGS, or -1 if variable count */ bool strict; /* T if function is "strict" */ bool retset; /* T if function returns a set */ PGFunction func; /* pointer to compiled function */ diff --git a/src/include/utils/guc.h b/src/include/utils/guc.h index 00399bd488..fdfd5dbeb7 100644 --- a/src/include/utils/guc.h +++ b/src/include/utils/guc.h @@ -7,7 +7,7 @@ * Copyright (c) 2000-2005, PostgreSQL Global Development Group * Written by Peter Eisentraut . * - * $PostgreSQL: pgsql/src/include/utils/guc.h,v 1.62 2005/07/30 15:17:26 momjian Exp $ + * $PostgreSQL: pgsql/src/include/utils/guc.h,v 1.63 2005/10/15 02:49:46 momjian Exp $ *-------------------------------------------------------------------- */ #ifndef GUC_H @@ -134,9 +134,9 @@ extern char *HbaFileName; extern char *IdentFileName; extern char *external_pid_file; -extern int tcp_keepalives_idle; -extern int tcp_keepalives_interval; -extern int tcp_keepalives_count; +extern int tcp_keepalives_idle; +extern int tcp_keepalives_interval; +extern int tcp_keepalives_count; extern void SetConfigOption(const char *name, const char *value, GucContext context, GucSource source); @@ -227,7 +227,7 @@ extern bool ClearDateCache(bool newval, bool doit, GucSource source); /* in commands/tablespace.c */ extern const char *assign_default_tablespace(const char *newval, - bool doit, GucSource source); + bool doit, GucSource source); /* in utils/adt/regexp.c */ extern const char *assign_regex_flavor(const char *value, diff --git a/src/include/utils/hsearch.h b/src/include/utils/hsearch.h index 0821610b9b..eda390ae8f 100644 --- a/src/include/utils/hsearch.h +++ b/src/include/utils/hsearch.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/hsearch.h,v 1.40 2005/08/20 23:26:37 tgl Exp $ + * $PostgreSQL: pgsql/src/include/utils/hsearch.h,v 1.41 2005/10/15 02:49:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -27,10 +27,10 @@ typedef uint32 (*HashValueFunc) (const void *key, Size keysize); * as key comparison functions.) */ typedef int (*HashCompareFunc) (const void *key1, const void *key2, - Size keysize); + Size keysize); /* - * Key copying functions must have this signature. The return value is not + * Key copying functions must have this signature. The return value is not * used. (The definition is set up to allow memcpy() and strncpy() to be * used directly.) */ @@ -95,8 +95,7 @@ typedef struct HASHHDR long nsegs; /* Number of allocated segments */ Size keysize; /* hash key length in bytes */ Size entrysize; /* total user element size in bytes */ - long max_dsize; /* 'dsize' limit if directory is fixed - * size */ + long max_dsize; /* 'dsize' limit if directory is fixed size */ int nelem_alloc; /* number of entries to allocate at once */ HASHELEMENT *freeList; /* linked list of free elements */ #ifdef HASH_STATISTICS @@ -117,8 +116,7 @@ typedef struct HTAB HashCompareFunc match; /* key comparison function */ HashCopyFunc keycopy; /* key copying function */ HashAllocFunc alloc; /* memory allocator */ - MemoryContext hcxt; /* memory context if default allocator - * used */ + MemoryContext hcxt; /* memory context if default allocator used */ char *tabname; /* table name (for error messages) */ bool isshared; /* true if table is in shared memory */ } HTAB; @@ -129,8 +127,7 @@ typedef struct HASHCTL { long ssize; /* Segment Size */ long dsize; /* (initial) Directory Size */ - long max_dsize; /* limit to dsize if directory size is - * limited */ + long max_dsize; /* limit to dsize if directory size is limited */ long ffactor; /* Fill factor */ Size keysize; /* hash key length in bytes */ Size entrysize; /* total user element size in bytes */ diff --git a/src/include/utils/inval.h b/src/include/utils/inval.h index 372d34a22c..d2f3a21070 100644 --- a/src/include/utils/inval.h +++ b/src/include/utils/inval.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/inval.h,v 1.36 2005/06/17 22:32:50 tgl Exp $ + * $PostgreSQL: pgsql/src/include/utils/inval.h,v 1.37 2005/10/15 02:49:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -52,6 +52,6 @@ extern void CacheRegisterRelcacheCallback(CacheCallbackFunction func, Datum arg); extern void inval_twophase_postcommit(TransactionId xid, uint16 info, - void *recdata, uint32 len); + void *recdata, uint32 len); #endif /* INVAL_H */ diff --git a/src/include/utils/lsyscache.h b/src/include/utils/lsyscache.h index dfd785d5d1..bc3d0b4430 100644 --- a/src/include/utils/lsyscache.h +++ b/src/include/utils/lsyscache.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/lsyscache.h,v 1.100 2005/06/28 05:09:13 tgl Exp $ + * $PostgreSQL: pgsql/src/include/utils/lsyscache.h,v 1.101 2005/10/15 02:49:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -104,8 +104,8 @@ extern void free_attstatsslot(Oid atttype, Datum *values, int nvalues, float4 *numbers, int nnumbers); extern char *get_namespace_name(Oid nspid); -extern Oid get_roleid(const char *rolname); -extern Oid get_roleid_checked(const char *rolname); +extern Oid get_roleid(const char *rolname); +extern Oid get_roleid_checked(const char *rolname); #define is_array_type(typid) (get_element_type(typid) != InvalidOid) diff --git a/src/include/utils/nabstime.h b/src/include/utils/nabstime.h index 4c7577c3db..305e522857 100644 --- a/src/include/utils/nabstime.h +++ b/src/include/utils/nabstime.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/nabstime.h,v 1.47 2005/07/22 03:46:34 momjian Exp $ + * $PostgreSQL: pgsql/src/include/utils/nabstime.h,v 1.48 2005/10/15 02:49:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -162,6 +162,6 @@ extern Datum timeofday(PG_FUNCTION_ARGS); /* non-fmgr-callable support routines */ extern AbsoluteTime GetCurrentAbsoluteTime(void); -extern void abstime2tm(AbsoluteTime time, int *tzp, struct pg_tm *tm, char **tzn); +extern void abstime2tm(AbsoluteTime time, int *tzp, struct pg_tm * tm, char **tzn); #endif /* NABSTIME_H */ diff --git a/src/include/utils/palloc.h b/src/include/utils/palloc.h index f1bbfa2cda..249f7ff7cf 100644 --- a/src/include/utils/palloc.h +++ b/src/include/utils/palloc.h @@ -21,7 +21,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/palloc.h,v 1.33 2005/02/18 21:52:34 tgl Exp $ + * $PostgreSQL: pgsql/src/include/utils/palloc.h,v 1.34 2005/10/15 02:49:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -80,14 +80,13 @@ static __inline__ MemoryContext MemoryContextSwitchTo(MemoryContext context) { MemoryContext old = CurrentMemoryContext; + CurrentMemoryContext = context; return old; } - #else extern MemoryContext MemoryContextSwitchTo(MemoryContext context); - #endif /* __GNUC__ */ /* diff --git a/src/include/utils/pg_crc.h b/src/include/utils/pg_crc.h index 5bf9ed7633..e1efc3cf9e 100644 --- a/src/include/utils/pg_crc.h +++ b/src/include/utils/pg_crc.h @@ -17,7 +17,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/pg_crc.h,v 1.13 2005/06/02 05:55:29 tgl Exp $ + * $PostgreSQL: pgsql/src/include/utils/pg_crc.h,v 1.14 2005/10/15 02:49:46 momjian Exp $ */ #ifndef PG_CRC_H #define PG_CRC_H @@ -76,7 +76,7 @@ typedef struct pg_crc64 { uint32 crc0; uint32 crc1; -} pg_crc64; +} pg_crc64; /* Initialize a CRC accumulator */ #define INIT_CRC64(crc) ((crc).crc0 = 0xffffffff, (crc).crc1 = 0xffffffff) @@ -108,13 +108,12 @@ do { \ /* Constant table for CRC calculation */ extern const uint32 pg_crc64_table0[]; extern const uint32 pg_crc64_table1[]; - #else /* int64 works */ typedef struct pg_crc64 { uint64 crc0; -} pg_crc64; +} pg_crc64; /* Initialize a CRC accumulator */ #define INIT_CRC64(crc) ((crc).crc0 = UINT64CONST(0xffffffffffffffff)) @@ -143,7 +142,6 @@ do { \ /* Constant table for CRC calculation */ extern const uint64 pg_crc64_table[]; #endif /* INT64_IS_BUSTED */ - -#endif /* PROVIDE_64BIT_CRC */ +#endif /* PROVIDE_64BIT_CRC */ #endif /* PG_CRC_H */ diff --git a/src/include/utils/portal.h b/src/include/utils/portal.h index 33de53eee8..758592525f 100644 --- a/src/include/utils/portal.h +++ b/src/include/utils/portal.h @@ -39,7 +39,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/portal.h,v 1.56 2005/06/17 22:32:50 tgl Exp $ + * $PostgreSQL: pgsql/src/include/utils/portal.h,v 1.57 2005/10/15 02:49:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -106,10 +106,11 @@ typedef struct PortalData MemoryContext heap; /* subsidiary memory for portal */ ResourceOwner resowner; /* resources owned by portal */ void (*cleanup) (Portal portal); /* cleanup hook */ - SubTransactionId createSubid; /* the ID of the creating subxact */ + SubTransactionId createSubid; /* the ID of the creating subxact */ + /* - * if createSubid is InvalidSubTransactionId, the portal is held over - * from a previous transaction + * if createSubid is InvalidSubTransactionId, the portal is held over from + * a previous transaction */ /* The query or queries the portal will execute */ @@ -120,11 +121,11 @@ typedef struct PortalData MemoryContext queryContext; /* where the above trees live */ /* - * Note: queryContext effectively identifies which prepared statement - * the portal depends on, if any. The queryContext is *not* owned by - * the portal and is not to be deleted by portal destruction. (But - * for a cursor it is the same as "heap", and that context is deleted - * by portal destruction.) + * Note: queryContext effectively identifies which prepared statement the + * portal depends on, if any. The queryContext is *not* owned by the + * portal and is not to be deleted by portal destruction. (But for a + * cursor it is the same as "heap", and that context is deleted by portal + * destruction.) */ ParamListInfo portalParams; /* params to pass to query */ @@ -145,21 +146,21 @@ typedef struct PortalData int16 *formats; /* a format code for each column */ /* - * Where we store tuples for a held cursor or a PORTAL_UTIL_SELECT - * query. (A cursor held past the end of its transaction no longer has - * any active executor state.) + * Where we store tuples for a held cursor or a PORTAL_UTIL_SELECT query. + * (A cursor held past the end of its transaction no longer has any active + * executor state.) */ Tuplestorestate *holdStore; /* store for holdable cursors */ MemoryContext holdContext; /* memory containing holdStore */ /* * atStart, atEnd and portalPos indicate the current cursor position. - * portalPos is zero before the first row, N after fetching N'th row - * of query. After we run off the end, portalPos = # of rows in - * query, and atEnd is true. If portalPos overflows, set posOverflow - * (this causes us to stop relying on its value for navigation). Note - * that atStart implies portalPos == 0, but not the reverse (portalPos - * could have overflowed). + * portalPos is zero before the first row, N after fetching N'th row of + * query. After we run off the end, portalPos = # of rows in query, and + * atEnd is true. If portalPos overflows, set posOverflow (this causes us + * to stop relying on its value for navigation). Note that atStart + * implies portalPos == 0, but not the reverse (portalPos could have + * overflowed). */ bool atStart; bool atEnd; @@ -188,11 +189,11 @@ extern void AtCommit_Portals(void); extern void AtAbort_Portals(void); extern void AtCleanup_Portals(void); extern void AtSubCommit_Portals(SubTransactionId mySubid, - SubTransactionId parentSubid, - ResourceOwner parentXactOwner); + SubTransactionId parentSubid, + ResourceOwner parentXactOwner); extern void AtSubAbort_Portals(SubTransactionId mySubid, - SubTransactionId parentSubid, - ResourceOwner parentXactOwner); + SubTransactionId parentSubid, + ResourceOwner parentXactOwner); extern void AtSubCleanup_Portals(SubTransactionId mySubid); extern Portal CreatePortal(const char *name, bool allowDup, bool dupSilent); extern Portal CreateNewPortal(void); diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h index 73893fcf55..17344ab0bf 100644 --- a/src/include/utils/rel.h +++ b/src/include/utils/rel.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/rel.h,v 1.86 2005/10/06 02:29:21 tgl Exp $ + * $PostgreSQL: pgsql/src/include/utils/rel.h,v 1.87 2005/10/15 02:49:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -67,9 +67,9 @@ typedef struct Trigger typedef struct TriggerDesc { /* - * Index data to identify which triggers are which. Since each - * trigger can appear in more than one class, for each class we - * provide a list of integer indexes into the triggers array. + * Index data to identify which triggers are which. Since each trigger + * can appear in more than one class, for each class we provide a list of + * integer indexes into the triggers array. */ #define TRIGGER_NUM_EVENT_CLASSES 3 @@ -133,16 +133,15 @@ typedef struct RelationData bool rd_istemp; /* rel uses the local buffer mgr */ bool rd_isnailed; /* rel is nailed in cache */ bool rd_isvalid; /* relcache entry is valid */ - char rd_indexvalid; /* state of rd_indexlist: 0 = not valid, - * 1 = valid, 2 = temporarily forced */ + char rd_indexvalid; /* state of rd_indexlist: 0 = not valid, 1 = + * valid, 2 = temporarily forced */ SubTransactionId rd_createSubid; /* rel was created in current xact */ /* * rd_createSubid is the ID of the highest subtransaction the rel has - * survived into; or zero if the rel was not created in the current - * top transaction. This should be relied on only for optimization - * purposes; it is possible for new-ness to be "forgotten" (eg, after - * CLUSTER). + * survived into; or zero if the rel was not created in the current top + * transaction. This should be relied on only for optimization purposes; + * it is possible for new-ness to be "forgotten" (eg, after CLUSTER). */ Form_pg_class rd_rel; /* RELATION tuple */ TupleDesc rd_att; /* tuple descriptor */ @@ -166,14 +165,14 @@ typedef struct RelationData * * Note: only default operators and support procs for each opclass are * cached, namely those with subtype zero. The arrays are indexed by - * strategy or support number, which is a sufficient identifier given - * that restriction. + * strategy or support number, which is a sufficient identifier given that + * restriction. */ MemoryContext rd_indexcxt; /* private memory cxt for this stuff */ RelationAmInfo *rd_aminfo; /* lookup info for funcs found in pg_am */ Oid *rd_operator; /* OIDs of index operators */ RegProcedure *rd_support; /* OIDs of support procedures */ - FmgrInfo *rd_supportinfo; /* lookup info for support procedures */ + FmgrInfo *rd_supportinfo; /* lookup info for support procedures */ List *rd_indexprs; /* index expression trees, if any */ List *rd_indpred; /* index predicate tree, if any */ diff --git a/src/include/utils/relcache.h b/src/include/utils/relcache.h index aadf14c479..1111e897f1 100644 --- a/src/include/utils/relcache.h +++ b/src/include/utils/relcache.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/relcache.h,v 1.51 2005/08/12 01:36:05 tgl Exp $ + * $PostgreSQL: pgsql/src/include/utils/relcache.h,v 1.52 2005/10/15 02:49:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -35,7 +35,7 @@ extern List *RelationGetIndexExpressions(Relation relation); extern List *RelationGetIndexPredicate(Relation relation); extern void RelationSetIndexList(Relation relation, - List *indexIds, Oid oidIndex); + List *indexIds, Oid oidIndex); extern void RelationInitIndexAccessInfo(Relation relation); @@ -67,7 +67,7 @@ extern void RelationCacheInvalidate(void); extern void AtEOXact_RelationCache(bool isCommit); extern void AtEOSubXact_RelationCache(bool isCommit, SubTransactionId mySubid, - SubTransactionId parentSubid); + SubTransactionId parentSubid); /* * Routines to help manage rebuilding of relcache init file diff --git a/src/include/utils/selfuncs.h b/src/include/utils/selfuncs.h index e54c11df36..ba91b0b402 100644 --- a/src/include/utils/selfuncs.h +++ b/src/include/utils/selfuncs.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/selfuncs.h,v 1.23 2005/06/05 22:32:58 tgl Exp $ + * $PostgreSQL: pgsql/src/include/utils/selfuncs.h,v 1.24 2005/10/15 02:49:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -36,7 +36,7 @@ #define DEFAULT_INEQ_SEL 0.3333333333333333 /* default selectivity estimate for range inequalities "A > b AND A < c" */ -#define DEFAULT_RANGE_INEQ_SEL 0.005 +#define DEFAULT_RANGE_INEQ_SEL 0.005 /* default selectivity estimate for pattern-match operators such as LIKE */ #define DEFAULT_MATCH_SEL 0.005 diff --git a/src/include/utils/syscache.h b/src/include/utils/syscache.h index 8a30e08e18..4d1d8cd9ef 100644 --- a/src/include/utils/syscache.h +++ b/src/include/utils/syscache.h @@ -9,7 +9,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/syscache.h,v 1.60 2005/06/28 05:09:13 tgl Exp $ + * $PostgreSQL: pgsql/src/include/utils/syscache.h,v 1.61 2005/10/15 02:49:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -54,7 +54,7 @@ #define NAMESPACEOID 23 #define OPERNAMENSP 24 #define OPEROID 25 -#define PROCNAMEARGSNSP 26 +#define PROCNAMEARGSNSP 26 #define PROCOID 27 #define RELNAMENSP 28 #define RELOID 29 diff --git a/src/include/utils/timestamp.h b/src/include/utils/timestamp.h index dc218f3b28..f5fa5f0d37 100644 --- a/src/include/utils/timestamp.h +++ b/src/include/utils/timestamp.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/timestamp.h,v 1.56 2005/10/09 17:21:47 tgl Exp $ + * $PostgreSQL: pgsql/src/include/utils/timestamp.h,v 1.57 2005/10/15 02:49:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -36,7 +36,6 @@ #ifdef HAVE_INT64_TIMESTAMP typedef int64 Timestamp; typedef int64 TimestampTz; - #else typedef double Timestamp; typedef double TimestampTz; @@ -45,15 +44,14 @@ typedef double TimestampTz; typedef struct { #ifdef HAVE_INT64_TIMESTAMP - int64 time; /* all time units other than days, - * months and years */ + int64 time; /* all time units other than days, months and + * years */ #else - double time; /* all time units other than days, - * months and years */ + double time; /* all time units other than days, months and + * years */ #endif - int32 day; /* days, after time for alignment */ - int32 month; /* months and years, after time for - * alignment */ + int32 day; /* days, after time for alignment */ + int32 month; /* months and years, after time for alignment */ } Interval; @@ -62,12 +60,12 @@ typedef struct /* in both timestamp.h and ecpg/dt.h */ #define DAYS_PER_YEAR 365.25 /* assumes leap year every four years */ -#define MONTHS_PER_YEAR 12 +#define MONTHS_PER_YEAR 12 /* * DAYS_PER_MONTH is very imprecise. The more accurate value is * 365.2425/12 = 30.436875, or '30 days 10:29:06'. Right now we only * return an integral number of days, but someday perhaps we should - * also return a 'time' value to be used as well. ISO 8601 suggests + * also return a 'time' value to be used as well. ISO 8601 suggests * 30 days. */ #define DAYS_PER_MONTH 30 /* assumes exactly 30 days per month */ @@ -80,7 +78,7 @@ typedef struct */ #define SECS_PER_YEAR (36525 * 864) /* avoid floating-point computation */ #define SECS_PER_DAY 86400 -#define SECS_PER_HOUR 3600 +#define SECS_PER_HOUR 3600 #define SECS_PER_MINUTE 60 #define MINS_PER_HOUR 60 @@ -118,7 +116,6 @@ typedef struct #define DT_NOBEGIN (-INT64CONST(0x7fffffffffffffff) - 1) #define DT_NOEND (INT64CONST(0x7fffffffffffffff)) - #else #define DatumGetTimestamp(X) ((Timestamp) DatumGetFloat8(X)) @@ -158,7 +155,6 @@ typedef struct #ifdef HAVE_INT64_TIMESTAMP typedef int32 fsec_t; - #else typedef double fsec_t; @@ -167,7 +163,6 @@ typedef double fsec_t; /* note: this is also used for rounding off intervals */ #define TS_PREC_INV 1000000.0 #define TSROUND(j) (rint(((double) (j)) * TS_PREC_INV) / TS_PREC_INV) - #endif #define TIMESTAMP_MASK(b) (1 << (b)) @@ -297,16 +292,16 @@ extern TimestampTz GetCurrentTimestamp(void); extern TimestampTz time_t_to_timestamptz(time_t tm); -extern int tm2timestamp(struct pg_tm *tm, fsec_t fsec, int *tzp, Timestamp *dt); -extern int timestamp2tm(Timestamp dt, int *tzp, struct pg_tm *tm, +extern int tm2timestamp(struct pg_tm * tm, fsec_t fsec, int *tzp, Timestamp *dt); +extern int timestamp2tm(Timestamp dt, int *tzp, struct pg_tm * tm, fsec_t *fsec, char **tzn, pg_tz *attimezone); extern void dt2time(Timestamp dt, int *hour, int *min, int *sec, fsec_t *fsec); -extern int interval2tm(Interval span, struct pg_tm *tm, fsec_t *fsec); -extern int tm2interval(struct pg_tm *tm, fsec_t fsec, Interval *span); +extern int interval2tm(Interval span, struct pg_tm * tm, fsec_t *fsec); +extern int tm2interval(struct pg_tm * tm, fsec_t fsec, Interval *span); extern Timestamp SetEpochTimestamp(void); -extern void GetEpochTime(struct pg_tm *tm); +extern void GetEpochTime(struct pg_tm * tm); extern int timestamp_cmp_internal(Timestamp dt1, Timestamp dt2); diff --git a/src/include/utils/tqual.h b/src/include/utils/tqual.h index fa530ed977..bfd51cb72e 100644 --- a/src/include/utils/tqual.h +++ b/src/include/utils/tqual.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/tqual.h,v 1.58 2005/08/20 00:40:32 tgl Exp $ + * $PostgreSQL: pgsql/src/include/utils/tqual.h,v 1.59 2005/10/15 02:49:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -47,7 +47,7 @@ typedef struct SnapshotData typedef SnapshotData *Snapshot; /* Special snapshot values: */ -#define InvalidSnapshot ((Snapshot) 0x0) /* same as NULL */ +#define InvalidSnapshot ((Snapshot) 0x0) /* same as NULL */ #define SnapshotNow ((Snapshot) 0x1) #define SnapshotSelf ((Snapshot) 0x2) #define SnapshotAny ((Snapshot) 0x3) @@ -111,7 +111,7 @@ typedef enum HEAPTUPLE_DEAD, /* tuple is dead and deletable */ HEAPTUPLE_LIVE, /* tuple is live (committed, no deleter) */ HEAPTUPLE_RECENTLY_DEAD, /* tuple is dead, but not deletable yet */ - HEAPTUPLE_INSERT_IN_PROGRESS, /* inserting xact is still in progress */ + HEAPTUPLE_INSERT_IN_PROGRESS, /* inserting xact is still in progress */ HEAPTUPLE_DELETE_IN_PROGRESS /* deleting xact is still in progress */ } HTSV_Result; diff --git a/src/include/utils/typcache.h b/src/include/utils/typcache.h index 615c36331c..64fe33d81d 100644 --- a/src/include/utils/typcache.h +++ b/src/include/utils/typcache.h @@ -9,7 +9,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/typcache.h,v 1.7 2004/12/31 22:03:46 pgsql Exp $ + * $PostgreSQL: pgsql/src/include/utils/typcache.h,v 1.8 2005/10/15 02:49:47 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -35,8 +35,8 @@ typedef struct TypeCacheEntry /* * Information obtained from opclass entries * - * These will be InvalidOid if no match could be found, or if the - * information hasn't yet been requested. + * These will be InvalidOid if no match could be found, or if the information + * hasn't yet been requested. */ Oid btree_opc; /* OID of the default btree opclass */ Oid hash_opc; /* OID of the default hash opclass */ @@ -48,9 +48,9 @@ typedef struct TypeCacheEntry /* * Pre-set-up fmgr call info for the equality operator and the btree * comparison function. These are kept in the type cache to avoid - * problems with memory leaks in repeated calls to array_eq and - * array_cmp. There is not currently a need to maintain call info for - * the lt_opr or gt_opr. + * problems with memory leaks in repeated calls to array_eq and array_cmp. + * There is not currently a need to maintain call info for the lt_opr or + * gt_opr. */ FmgrInfo eq_opr_finfo; FmgrInfo cmp_proc_finfo; diff --git a/src/interfaces/ecpg/compatlib/informix.c b/src/interfaces/ecpg/compatlib/informix.c index 8acfc1ecf0..d0e884f93b 100644 --- a/src/interfaces/ecpg/compatlib/informix.c +++ b/src/interfaces/ecpg/compatlib/informix.c @@ -15,7 +15,7 @@ char *ECPGalloc(long, int); static int -deccall2(decimal *arg1, decimal *arg2, int (*ptr) (numeric *, numeric *)) +deccall2(decimal * arg1, decimal * arg2, int (*ptr) (numeric *, numeric *)) { numeric *a1, *a2; @@ -53,7 +53,7 @@ deccall2(decimal *arg1, decimal *arg2, int (*ptr) (numeric *, numeric *)) } static int -deccall3(decimal *arg1, decimal *arg2, decimal *result, int (*ptr) (numeric *, numeric *, numeric *)) +deccall3(decimal * arg1, decimal * arg2, decimal * result, int (*ptr) (numeric *, numeric *, numeric *)) { numeric *a1, *a2, @@ -118,7 +118,7 @@ deccall3(decimal *arg1, decimal *arg2, decimal *result, int (*ptr) (numeric *, n /* we start with the numeric functions */ int -decadd(decimal *arg1, decimal *arg2, decimal *sum) +decadd(decimal * arg1, decimal * arg2, decimal * sum) { deccall3(arg1, arg2, sum, PGTYPESnumeric_add); @@ -131,13 +131,13 @@ decadd(decimal *arg1, decimal *arg2, decimal *sum) } int -deccmp(decimal *arg1, decimal *arg2) +deccmp(decimal * arg1, decimal * arg2) { return (deccall2(arg1, arg2, PGTYPESnumeric_cmp)); } void -deccopy(decimal *src, decimal *target) +deccopy(decimal * src, decimal * target) { memcpy(target, src, sizeof(decimal)); } @@ -162,11 +162,10 @@ ecpg_strndup(const char *str, size_t len) } int -deccvasc(char *cp, int len, decimal *np) +deccvasc(char *cp, int len, decimal * np) { - char *str = ecpg_strndup(cp, len); /* decimal_in always - * converts the complete - * string */ + char *str = ecpg_strndup(cp, len); /* decimal_in always converts + * the complete string */ int ret = 0; numeric *result; @@ -208,7 +207,7 @@ deccvasc(char *cp, int len, decimal *np) } int -deccvdbl(double dbl, decimal *np) +deccvdbl(double dbl, decimal * np) { numeric *nres = PGTYPESnumeric_new(); int result = 1; @@ -229,7 +228,7 @@ deccvdbl(double dbl, decimal *np) } int -deccvint(int in, decimal *np) +deccvint(int in, decimal * np) { numeric *nres = PGTYPESnumeric_new(); int result = 1; @@ -250,7 +249,7 @@ deccvint(int in, decimal *np) } int -deccvlong(long lng, decimal *np) +deccvlong(long lng, decimal * np) { numeric *nres = PGTYPESnumeric_new(); int result = 1; @@ -271,7 +270,7 @@ deccvlong(long lng, decimal *np) } int -decdiv(decimal *n1, decimal *n2, decimal *result) +decdiv(decimal * n1, decimal * n2, decimal * result) { int i; @@ -296,7 +295,7 @@ decdiv(decimal *n1, decimal *n2, decimal *result) } int -decmul(decimal *n1, decimal *n2, decimal *result) +decmul(decimal * n1, decimal * n2, decimal * result) { int i; @@ -317,7 +316,7 @@ decmul(decimal *n1, decimal *n2, decimal *result) } int -decsub(decimal *n1, decimal *n2, decimal *result) +decsub(decimal * n1, decimal * n2, decimal * result) { int i; @@ -338,7 +337,7 @@ decsub(decimal *n1, decimal *n2, decimal *result) } int -dectoasc(decimal *np, char *cp, int len, int right) +dectoasc(decimal * np, char *cp, int len, int right) { char *str; numeric *nres = PGTYPESnumeric_new(); @@ -373,7 +372,7 @@ dectoasc(decimal *np, char *cp, int len, int right) } int -dectodbl(decimal *np, double *dblp) +dectodbl(decimal * np, double *dblp) { numeric *nres = PGTYPESnumeric_new(); int i; @@ -391,7 +390,7 @@ dectodbl(decimal *np, double *dblp) } int -dectoint(decimal *np, int *ip) +dectoint(decimal * np, int *ip) { int ret; numeric *nres = PGTYPESnumeric_new(); @@ -411,7 +410,7 @@ dectoint(decimal *np, int *ip) } int -dectolong(decimal *np, long *lngp) +dectolong(decimal * np, long *lngp) { int ret; numeric *nres = PGTYPESnumeric_new();; @@ -453,7 +452,7 @@ rdatestr(date d, char *str) * */ int -rstrdate(char *str, date *d) +rstrdate(char *str, date * d) { date dat; char strbuf[10]; @@ -511,7 +510,7 @@ rstrdate(char *str, date *d) } void -rtoday(date *d) +rtoday(date * d) { PGTYPESdate_today(d); return; @@ -530,7 +529,7 @@ rjulmdy(date d, short mdy[3]) } int -rdefmtdate(date *d, char *fmt, char *str) +rdefmtdate(date * d, char *fmt, char *str) { /* TODO: take care of DBCENTURY environment variable */ /* PGSQL functions allow all centuries */ @@ -567,7 +566,7 @@ rfmtdate(date d, char *fmt, char *str) } int -rmdyjul(short mdy[3], date *d) +rmdyjul(short mdy[3], date * d) { int mdy_int[3]; @@ -587,13 +586,13 @@ rdayofweek(date d) /* And the datetime stuff */ void -dtcurrent(timestamp *ts) +dtcurrent(timestamp * ts) { PGTYPEStimestamp_current(ts); } int -dtcvasc(char *str, timestamp *ts) +dtcvasc(char *str, timestamp * ts) { timestamp ts_tmp; int i; @@ -616,13 +615,13 @@ dtcvasc(char *str, timestamp *ts) } int -dtsub(timestamp *ts1, timestamp *ts2, interval *iv) +dtsub(timestamp * ts1, timestamp * ts2, interval * iv) { return PGTYPEStimestamp_sub(ts1, ts2, iv); } int -dttoasc(timestamp *ts, char *output) +dttoasc(timestamp * ts, char *output) { char *asctime = PGTYPEStimestamp_to_asc(*ts); @@ -632,13 +631,13 @@ dttoasc(timestamp *ts, char *output) } int -dttofmtasc(timestamp *ts, char *output, int str_len, char *fmtstr) +dttofmtasc(timestamp * ts, char *output, int str_len, char *fmtstr) { return PGTYPEStimestamp_fmt_asc(ts, output, str_len, fmtstr); } int -intoasc(interval *i, char *str) +intoasc(interval * i, char *str) { str = PGTYPESinterval_to_asc(i); @@ -963,7 +962,7 @@ rtypwidth(int sqltype, int sqllen) } int -dtcvfmtasc(char *inbuf, char *fmtstr, timestamp *dtvalue) +dtcvfmtasc(char *inbuf, char *fmtstr, timestamp * dtvalue) { return PGTYPEStimestamp_defmt_asc(inbuf, fmtstr, dtvalue); } diff --git a/src/interfaces/ecpg/ecpglib/connect.c b/src/interfaces/ecpg/ecpglib/connect.c index 56706fb8ef..94d2f42ec1 100644 --- a/src/interfaces/ecpg/ecpglib/connect.c +++ b/src/interfaces/ecpg/ecpglib/connect.c @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.25 2005/04/14 10:08:57 meskes Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.26 2005/10/15 02:49:47 momjian Exp $ */ #define POSTGRES_ECPG_INTERNAL #include "postgres_fe.h" @@ -16,7 +16,6 @@ static pthread_mutex_t connections_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_key_t actual_connection_key; static pthread_once_t actual_connection_key_once = PTHREAD_ONCE_INIT; - #endif static struct connection *actual_connection = NULL; static struct connection *all_connections = NULL; @@ -38,10 +37,13 @@ ecpg_get_connection_nr(const char *connection_name) { #ifdef ENABLE_THREAD_SAFETY ret = pthread_getspecific(actual_connection_key); - /* if no connection in TSD for this thread, get the global default connection - * and hope the user knows what they're doing (i.e. using their own mutex to - * protect that connection from concurrent accesses */ - if(NULL == ret) + + /* + * if no connection in TSD for this thread, get the global default + * connection and hope the user knows what they're doing (i.e. using + * their own mutex to protect that connection from concurrent accesses + */ + if (NULL == ret) { ECPGlog("no TSD connection, going for global\n"); ret = actual_connection; @@ -76,13 +78,16 @@ ECPGget_connection(const char *connection_name) { #ifdef ENABLE_THREAD_SAFETY ret = pthread_getspecific(actual_connection_key); - /* if no connection in TSD for this thread, get the global default connection - * and hope the user knows what they're doing (i.e. using their own mutex to - * protect that connection from concurrent accesses */ - if(NULL == ret) + + /* + * if no connection in TSD for this thread, get the global default + * connection and hope the user knows what they're doing (i.e. using + * their own mutex to protect that connection from concurrent accesses + */ + if (NULL == ret) { ECPGlog("no TSD connection here either, using global\n"); - ret = actual_connection; + ret = actual_connection; } else ECPGlog("got TSD connection\n"); @@ -275,8 +280,8 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p /* * Informix uses an environment variable DBPATH that overrides the - * connection parameters given here. We do the same with PG_DBPATH - * as the syntax is different. + * connection parameters given here. We do the same with PG_DBPATH as + * the syntax is different. */ envname = getenv("PG_DBPATH"); if (envname) @@ -294,20 +299,20 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p connection_name = "DEFAULT"; if (dbname != NULL) - { + { /* get the detail information out of dbname */ if (strchr(dbname, '@') != NULL) { /* old style: dbname[@server][:port] */ tmp = strrchr(dbname, ':'); - if (tmp != NULL) /* port number given */ + if (tmp != NULL) /* port number given */ { port = strdup(tmp + 1); *tmp = '\0'; } tmp = strrchr(dbname, '@'); - if (tmp != NULL) /* host name given */ + if (tmp != NULL) /* host name given */ { host = strdup(tmp + 1); *tmp = '\0'; diff --git a/src/interfaces/ecpg/ecpglib/data.c b/src/interfaces/ecpg/ecpglib/data.c index 252fbae355..90111db4da 100644 --- a/src/interfaces/ecpg/ecpglib/data.c +++ b/src/interfaces/ecpg/ecpglib/data.c @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.28 2005/08/24 10:34:19 meskes Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.29 2005/10/15 02:49:47 momjian Exp $ */ #define POSTGRES_ECPG_INTERNAL #include "postgres_fe.h" @@ -53,8 +53,8 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno, /* We will have to decode the value */ /* - * check for null value and set indicator accordingly, i.e. -1 if NULL - * and 0 if not + * check for null value and set indicator accordingly, i.e. -1 if NULL and + * 0 if not */ if (PQgetisnull(results, act_tuple, act_field)) value_for_indicator = -1; @@ -85,8 +85,8 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno, if (force_indicator == false) { /* - * Informix has an additional way to specify NULLs - * note that this uses special values to denote NULL + * Informix has an additional way to specify NULLs note + * that this uses special values to denote NULL */ ECPGset_noind_null(type, var + offset * act_tuple); } @@ -424,8 +424,8 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno, if (INFORMIX_MODE(compat)) { /* - * Informix wants its own NULL value here - * instead of an error + * Informix wants its own NULL value here instead + * of an error */ ECPGset_noind_null(ECPGt_numeric, nres); } @@ -471,8 +471,8 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno, if (INFORMIX_MODE(compat)) { /* - * Informix wants its own NULL value here - * instead of an error + * Informix wants its own NULL value here instead + * of an error */ ECPGset_noind_null(ECPGt_interval, ires); } @@ -514,8 +514,8 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno, if (INFORMIX_MODE(compat)) { /* - * Informix wants its own NULL value here - * instead of an error + * Informix wants its own NULL value here instead + * of an error */ ECPGset_noind_null(ECPGt_date, &ddres); } @@ -556,8 +556,8 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno, if (INFORMIX_MODE(compat)) { /* - * Informix wants its own NULL value here - * instead of an error + * Informix wants its own NULL value here instead + * of an error */ ECPGset_noind_null(ECPGt_timestamp, &tres); } diff --git a/src/interfaces/ecpg/ecpglib/error.c b/src/interfaces/ecpg/ecpglib/error.c index 0b819518d7..582a2cb357 100644 --- a/src/interfaces/ecpg/ecpglib/error.c +++ b/src/interfaces/ecpg/ecpglib/error.c @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/error.c,v 1.10 2003/11/29 19:52:08 pgsql Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/error.c,v 1.11 2005/10/15 02:49:47 momjian Exp $ */ #define POSTGRES_ECPG_INTERNAL #include "postgres_fe.h" @@ -49,7 +49,7 @@ ECPGraise(int line, int code, const char *sqlstate, const char *str) case ECPG_INT_FORMAT: snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc), - "Not correctly formatted int type: %s line %d.", str, line); + "Not correctly formatted int type: %s line %d.", str, line); break; case ECPG_UINT_FORMAT: @@ -64,7 +64,7 @@ ECPGraise(int line, int code, const char *sqlstate, const char *str) case ECPG_CONVERT_BOOL: snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc), - "Unable to convert %s to bool on line %d.", str, line); + "Unable to convert %s to bool on line %d.", str, line); break; case ECPG_EMPTY: @@ -84,12 +84,12 @@ ECPGraise(int line, int code, const char *sqlstate, const char *str) case ECPG_DATA_NOT_ARRAY: snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc), - "Data read from backend is not an array in line %d.", line); + "Data read from backend is not an array in line %d.", line); break; case ECPG_ARRAY_INSERT: snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc), - "Trying to insert an array of variables in line %d.", line); + "Trying to insert an array of variables in line %d.", line); break; case ECPG_NO_CONN: @@ -129,7 +129,7 @@ ECPGraise(int line, int code, const char *sqlstate, const char *str) case ECPG_VAR_NOT_CHAR: snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc), - "Variable is not a character type in line %d.", line); + "Variable is not a character type in line %d.", line); break; case ECPG_TRANS: @@ -139,7 +139,7 @@ ECPGraise(int line, int code, const char *sqlstate, const char *str) case ECPG_CONNECT: snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc), - "Could not connect to database %s in line %d.", str, line); + "Could not connect to database %s in line %d.", str, line); break; default: @@ -192,7 +192,7 @@ ECPGraise_backend(int line, PGresult *result, PGconn *conn, int compat) sqlca->sqlcode = ECPG_PGSQL; ECPGlog("raising sqlstate %.*s in line %d, '%s'.\n", - sizeof(sqlca->sqlstate), sqlca->sqlstate, line, sqlca->sqlerrm.sqlerrmc); + sizeof(sqlca->sqlstate), sqlca->sqlstate, line, sqlca->sqlerrm.sqlerrmc); /* free all memory we have allocated for the user */ ECPGfree_auto_mem(); diff --git a/src/interfaces/ecpg/ecpglib/execute.c b/src/interfaces/ecpg/ecpglib/execute.c index f8e32530d7..ac870f0cc8 100644 --- a/src/interfaces/ecpg/ecpglib/execute.c +++ b/src/interfaces/ecpg/ecpglib/execute.c @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.42 2005/07/04 19:05:45 momjian Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.43 2005/10/15 02:49:47 momjian Exp $ */ /* * The aim is to get a simpler inteface to the database routines. @@ -110,8 +110,7 @@ ECPGget_variable(va_list APREF, enum ECPGttype type, struct variable * var, bool var->ind_value = var->ind_pointer; /* - * negative values are used to indicate an array without given - * bounds + * negative values are used to indicate an array without given bounds */ /* reset to zero for us */ if (var->ind_arrsize < 0) @@ -120,6 +119,7 @@ ECPGget_variable(va_list APREF, enum ECPGttype type, struct variable * var, bool var->ind_varcharsize = 0; } } + #undef APREF /* @@ -267,9 +267,8 @@ ECPGis_type_an_array(int type, const struct statement * stmt, const struct varia if ((stmt->connection->cache_head) == NULL) { /* - * Text like types are not an array for ecpg, but postgres counts - * them as an array. This define reminds you to not 'correct' - * these values. + * Text like types are not an array for ecpg, but postgres counts them + * as an array. This define reminds you to not 'correct' these values. */ #define not_an_array_in_ecpg ECPG_ARRAY_NONE @@ -464,7 +463,7 @@ ECPGstore_result(const PGresult *results, int act_field, int len = strlen(PQgetvalue(results, act_tuple, act_field)) + 1; if (!ECPGget_data(results, act_tuple, act_field, stmt->lineno, - var->type, var->ind_type, current_data_location, + var->type, var->ind_type, current_data_location, var->ind_value, len, 0, var->ind_offset, isarray, stmt->compat, stmt->force_indicator)) status = false; else @@ -499,8 +498,8 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia char *newcopy = NULL; /* - * arrays are not possible unless the attribute is an array too FIXME: - * we do not know if the attribute is an array here + * arrays are not possible unless the attribute is an array too FIXME: we + * do not know if the attribute is an array here */ #if 0 if (var->arrsize > 1 &&...) @@ -772,8 +771,7 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia sprintf(mallocedval + strlen(mallocedval), "%c,", (((char *) var->value)[element]) ? 't' : 'f'); /* - * this is necessary since sizeof(C++'s - * bool)==sizeof(int) + * this is necessary since sizeof(C++'s bool)==sizeof(int) */ else if (var->offset == sizeof(int)) for (element = 0; element < var->arrsize; element++) @@ -1064,10 +1062,9 @@ ECPGexecute(struct statement * stmt) copiedquery = ECPGstrdup(stmt->command, stmt->lineno); /* - * Now, if the type is one of the fill in types then we take the - * argument and enter that in the string at the first %s position. - * Then if there are any more fill in types we fill in at the next and - * so on. + * Now, if the type is one of the fill in types then we take the argument + * and enter that in the string at the first %s position. Then if there + * are any more fill in types we fill in at the next and so on. */ var = stmt->inlist; @@ -1082,14 +1079,14 @@ ECPGexecute(struct statement * stmt) tobeinserted = NULL; /* - * A descriptor is a special case since it contains many variables - * but is listed only once. + * A descriptor is a special case since it contains many variables but + * is listed only once. */ if (var->type == ECPGt_descriptor) { /* - * We create an additional variable list here, so the same - * logic applies. + * We create an additional variable list here, so the same logic + * applies. */ struct variable desc_inlist; struct descriptor *desc; @@ -1156,8 +1153,8 @@ ECPGexecute(struct statement * stmt) if (tobeinserted) { /* - * Now tobeinserted points to an area that is to be inserted - * at the first %s + * Now tobeinserted points to an area that is to be inserted at + * the first %s */ if (!(newcopy = (char *) ECPGalloc(strlen(copiedquery) + strlen(tobeinserted) + 1, stmt->lineno))) return false; @@ -1166,8 +1163,8 @@ ECPGexecute(struct statement * stmt) if ((p = next_insert(newcopy + hostvarl)) == NULL) { /* - * We have an argument but we dont have the matched up - * string in the string + * We have an argument but we dont have the matched up string + * in the string */ ECPGraise(stmt->lineno, ECPG_TOO_MANY_ARGUMENTS, ECPG_SQLSTATE_USING_CLAUSE_DOES_NOT_MATCH_PARAMETERS, NULL); return false; @@ -1178,8 +1175,8 @@ ECPGexecute(struct statement * stmt) hostvarl = strlen(newcopy); /* - * The strange thing in the second argument is the rest of - * the string from the old string + * The strange thing in the second argument is the rest of the + * string from the old string */ strcat(newcopy, copiedquery @@ -1188,9 +1185,9 @@ ECPGexecute(struct statement * stmt) } /* - * Now everything is safely copied to the newcopy. Lets free - * the oldcopy and let the copiedquery get the var->value from - * the newcopy. + * Now everything is safely copied to the newcopy. Lets free the + * oldcopy and let the copiedquery get the var->value from the + * newcopy. */ if (malloced) { diff --git a/src/interfaces/ecpg/ecpglib/extern.h b/src/interfaces/ecpg/ecpglib/extern.h index a342231809..cde99c9f3e 100644 --- a/src/interfaces/ecpg/ecpglib/extern.h +++ b/src/interfaces/ecpg/ecpglib/extern.h @@ -125,8 +125,9 @@ PGresult **ECPGdescriptor_lvalue(int line, const char *descriptor); bool ECPGstore_result(const PGresult *results, int act_field, const struct statement * stmt, struct variable * var); bool ECPGstore_input(const int, const bool, const struct variable *, const char **, bool *); + #if defined(__GNUC__) && (defined (__powerpc__) || defined(__amd64__) || defined(__x86_64__)) - // work around a gcc/ABI bug with va_lists on ppc+amd64 + /* work around a gcc/ABI bug with va_lists on ppc+amd64 */ void ECPGget_variable(va_list, enum ECPGttype, struct variable *, bool); #else void ECPGget_variable(va_list *, enum ECPGttype, struct variable *, bool); diff --git a/src/interfaces/ecpg/ecpglib/memory.c b/src/interfaces/ecpg/ecpglib/memory.c index 97c8500b95..49d3c29d1e 100644 --- a/src/interfaces/ecpg/ecpglib/memory.c +++ b/src/interfaces/ecpg/ecpglib/memory.c @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/memory.c,v 1.6 2004/12/30 09:36:37 meskes Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/memory.c,v 1.7 2005/10/15 02:49:47 momjian Exp $ */ #define POSTGRES_ECPG_INTERNAL #include "postgres_fe.h" @@ -50,7 +50,7 @@ ECPGstrdup(const char *string, int lineno) if (string == NULL) return NULL; - + new = strdup(string); if (!new) { diff --git a/src/interfaces/ecpg/ecpglib/misc.c b/src/interfaces/ecpg/ecpglib/misc.c index a5619a69bf..ff38bfab79 100644 --- a/src/interfaces/ecpg/ecpglib/misc.c +++ b/src/interfaces/ecpg/ecpglib/misc.c @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.25 2005/09/12 11:57:53 meskes Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.26 2005/10/15 02:49:47 momjian Exp $ */ #define POSTGRES_ECPG_INTERNAL #include "postgres_fe.h" @@ -58,7 +58,6 @@ static struct sqlca_t sqlca_init = #ifdef ENABLE_THREAD_SAFETY static pthread_key_t sqlca_key; static pthread_once_t sqlca_key_once = PTHREAD_ONCE_INIT; - #else static struct sqlca_t sqlca = { @@ -122,8 +121,7 @@ static void ecpg_sqlca_key_destructor(void *arg) { if (arg != NULL) - free(arg); /* sqlca structure allocated in - * ECPGget_sqlca */ + free(arg); /* sqlca structure allocated in ECPGget_sqlca */ } static void @@ -186,10 +184,11 @@ ECPGtrans(int lineno, const char *connection_name, const char *transaction) /* if we have no connection we just simulate the command */ if (con && con->connection) { - /* If we got a transaction command but have no open transaction, - * we have to start one, unless we are in autocommit, where the - * developers have to take care themselves. - * However, if the command is a begin statement, we just execute it once. + /* + * If we got a transaction command but have no open transaction, we + * have to start one, unless we are in autocommit, where the + * developers have to take care themselves. However, if the command is + * a begin statement, we just execute it once. */ if (con->committed && !con->autocommit && strncmp(transaction, "begin", 5) != 0 && strncmp(transaction, "start", 5) != 0) { @@ -201,7 +200,7 @@ ECPGtrans(int lineno, const char *connection_name, const char *transaction) } PQclear(res); } - + res = PQexec(con->connection, transaction); if (res == NULL || PQresultStatus(res) != PGRES_COMMAND_OK) { @@ -257,7 +256,7 @@ ECPGlog(const char *format,...) return; } - sprintf(f, "[%d]: %s", (int)getpid(), format); + sprintf(f, "[%d]: %s", (int) getpid(), format); va_start(ap, format); vfprintf(debugstream, f, ap); diff --git a/src/interfaces/ecpg/ecpglib/prepare.c b/src/interfaces/ecpg/ecpglib/prepare.c index b6e79c6bbb..cd57c41914 100644 --- a/src/interfaces/ecpg/ecpglib/prepare.c +++ b/src/interfaces/ecpg/ecpglib/prepare.c @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.13 2004/10/05 10:48:37 meskes Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.14 2005/10/15 02:49:47 momjian Exp $ */ #define POSTGRES_ECPG_INTERNAL #include "postgres_fe.h" @@ -46,9 +46,9 @@ replace_variables(char *text) if (!string && *ptr == ':') { - if (ptr[1]==':') - ptr+=2; /* skip '::' */ - else + if (ptr[1] == ':') + ptr += 2; /* skip '::' */ + else { *ptr = '?'; for (++ptr; *ptr && isvarchar(*ptr); ptr++) @@ -120,8 +120,8 @@ ECPGdeallocate(int lineno, int c, char *name) if (INFORMIX_MODE(compat)) { /* - * Just ignore all errors since we do not know the list of cursors - * we are allowed to free. We have to trust the software. + * Just ignore all errors since we do not know the list of cursors we + * are allowed to free. We have to trust the software. */ return true; } diff --git a/src/interfaces/ecpg/include/ecpgtype.h b/src/interfaces/ecpg/include/ecpgtype.h index 3d544029b7..6f521718a3 100644 --- a/src/interfaces/ecpg/include/ecpgtype.h +++ b/src/interfaces/ecpg/include/ecpgtype.h @@ -44,10 +44,10 @@ enum ECPGttype ECPGt_bool, ECPGt_float, ECPGt_double, ECPGt_varchar, ECPGt_varchar2, - ECPGt_numeric, /* this is a decimal that stores its - * digits in a malloced array */ - ECPGt_decimal, /* this is a decimal that stores its - * digits in a fixed array */ + ECPGt_numeric, /* this is a decimal that stores its digits in + * a malloced array */ + ECPGt_decimal, /* this is a decimal that stores its digits in + * a fixed array */ ECPGt_date, ECPGt_timestamp, ECPGt_interval, diff --git a/src/interfaces/ecpg/include/pgtypes_interval.h b/src/interfaces/ecpg/include/pgtypes_interval.h index fba723f40d..2abaf60b1d 100644 --- a/src/interfaces/ecpg/include/pgtypes_interval.h +++ b/src/interfaces/ecpg/include/pgtypes_interval.h @@ -4,15 +4,12 @@ typedef struct { #ifdef HAVE_INT64_TIMESTAMP - int64 time; /* all time units other than months and - * years */ + int64 time; /* all time units other than months and years */ #else - double time; /* all time units other than months and - * years */ + double time; /* all time units other than months and years */ #endif - long month; /* months and years, after time for - * alignment */ -} interval; + long month; /* months and years, after time for alignment */ +} interval; #ifdef __cplusplus extern "C" diff --git a/src/interfaces/ecpg/include/pgtypes_numeric.h b/src/interfaces/ecpg/include/pgtypes_numeric.h index 70856728cd..8d391db123 100644 --- a/src/interfaces/ecpg/include/pgtypes_numeric.h +++ b/src/interfaces/ecpg/include/pgtypes_numeric.h @@ -14,35 +14,31 @@ typedef unsigned char NumericDigit; typedef struct { - int ndigits; /* number of digits in digits[] - can be - * 0! */ + int ndigits; /* number of digits in digits[] - can be 0! */ int weight; /* weight of first digit */ int rscale; /* result scale */ int dscale; /* display scale */ - int sign; /* NUMERIC_POS, NUMERIC_NEG, or - * NUMERIC_NAN */ + int sign; /* NUMERIC_POS, NUMERIC_NEG, or NUMERIC_NAN */ NumericDigit *buf; /* start of alloc'd space for digits[] */ NumericDigit *digits; /* decimal digits */ -} numeric; +} numeric; typedef struct { - int ndigits; /* number of digits in digits[] - can be - * 0! */ + int ndigits; /* number of digits in digits[] - can be 0! */ int weight; /* weight of first digit */ int rscale; /* result scale */ int dscale; /* display scale */ - int sign; /* NUMERIC_POS, NUMERIC_NEG, or - * NUMERIC_NAN */ + int sign; /* NUMERIC_POS, NUMERIC_NEG, or NUMERIC_NAN */ NumericDigit digits[DECSIZE]; /* decimal digits */ -} decimal; +} decimal; #ifdef __cplusplus extern "C" { #endif -numeric *PGTYPESnumeric_new(void); + numeric * PGTYPESnumeric_new(void); void PGTYPESnumeric_free(numeric *); numeric *PGTYPESnumeric_from_asc(char *, char **); char *PGTYPESnumeric_to_asc(numeric *, int); diff --git a/src/interfaces/ecpg/include/pgtypes_timestamp.h b/src/interfaces/ecpg/include/pgtypes_timestamp.h index 8b3bf941e7..3965fa48bd 100644 --- a/src/interfaces/ecpg/include/pgtypes_timestamp.h +++ b/src/interfaces/ecpg/include/pgtypes_timestamp.h @@ -6,7 +6,6 @@ #ifdef HAVE_INT64_TIMESTAMP typedef int64 timestamp; typedef int64 TimestampTz; - #else typedef double timestamp; typedef double TimestampTz; @@ -23,8 +22,8 @@ extern int PGTYPEStimestamp_sub(timestamp *, timestamp *, interval *); extern int PGTYPEStimestamp_fmt_asc(timestamp *, char *, int, char *); extern void PGTYPEStimestamp_current(timestamp *); extern int PGTYPEStimestamp_defmt_asc(char *, char *, timestamp *); -extern int PGTYPEStimestamp_add_interval(timestamp *tin, interval *span, timestamp *tout); -extern int PGTYPEStimestamp_sub_interval(timestamp *tin, interval *span, timestamp *tout); +extern int PGTYPEStimestamp_add_interval(timestamp * tin, interval * span, timestamp * tout); +extern int PGTYPEStimestamp_sub_interval(timestamp * tin, interval * span, timestamp * tout); #ifdef __cplusplus } diff --git a/src/interfaces/ecpg/pgtypeslib/common.c b/src/interfaces/ecpg/pgtypeslib/common.c index 903013a2e3..1e3dee39e9 100644 --- a/src/interfaces/ecpg/pgtypeslib/common.c +++ b/src/interfaces/ecpg/pgtypeslib/common.c @@ -41,8 +41,7 @@ pgtypes_fmt_replace(union un_fmt_comb replace_val, int replace_type, char **outp if (i + 1 <= *pstr_len) { /* - * copy over i + 1 bytes, that includes the tailing - * terminator + * copy over i + 1 bytes, that includes the tailing terminator */ strncpy(*output, replace_val.str_val, i + 1); *pstr_len -= i; diff --git a/src/interfaces/ecpg/pgtypeslib/datetime.c b/src/interfaces/ecpg/pgtypeslib/datetime.c index 1d8a85d7a8..5cb0dca012 100644 --- a/src/interfaces/ecpg/pgtypeslib/datetime.c +++ b/src/interfaces/ecpg/pgtypeslib/datetime.c @@ -25,7 +25,7 @@ PGTYPESdate_from_timestamp(timestamp dt) dDate = (dt / USECS_PER_DAY); #else /* Seconds to days */ - dDate = (dt / (double)SECS_PER_DAY); + dDate = (dt / (double) SECS_PER_DAY); #endif return dDate; @@ -58,7 +58,7 @@ PGTYPESdate_from_asc(char *str, char **endptr) } if (ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf, ptr) != 0 || - DecodeDateTime(field, ftype, nf, &dtype, tm, &fsec, &tzp, EuroDates) != 0) + DecodeDateTime(field, ftype, nf, &dtype, tm, &fsec, &tzp, EuroDates) != 0) { errno = PGTYPES_DATE_BAD_DATE; return INT_MIN; @@ -111,7 +111,7 @@ PGTYPESdate_julmdy(date jd, int *mdy) } void -PGTYPESdate_mdyjul(int *mdy, date *jdate) +PGTYPESdate_mdyjul(int *mdy, date * jdate) { /* month is mdy[0] */ /* day is mdy[1] */ @@ -131,7 +131,7 @@ PGTYPESdate_dayofweek(date dDate) } void -PGTYPESdate_today(date *d) +PGTYPESdate_today(date * d) { struct tm ts; @@ -143,8 +143,7 @@ PGTYPESdate_today(date *d) #define PGTYPES_DATE_NUM_MAX_DIGITS 20 /* should suffice for most * years... */ -#define PGTYPES_FMTDATE_DAY_DIGITS_LZ 1 /* LZ means "leading - * zeroes" */ +#define PGTYPES_FMTDATE_DAY_DIGITS_LZ 1 /* LZ means "leading zeroes" */ #define PGTYPES_FMTDATE_DOW_LITERAL_SHORT 2 #define PGTYPES_FMTDATE_MONTH_DIGITS_LZ 3 #define PGTYPES_FMTDATE_MONTH_LITERAL_SHORT 4 @@ -161,8 +160,8 @@ PGTYPESdate_fmt_asc(date dDate, char *fmtstring, char *outbuf) } mapping[] = { /* - * format items have to be sorted according to their length, since - * the first pattern that matches gets replaced by its value + * format items have to be sorted according to their length, since the + * first pattern that matches gets replaced by its value */ { "ddd", PGTYPES_FMTDATE_DOW_LITERAL_SHORT @@ -290,8 +289,7 @@ PGTYPESdate_fmt_asc(date dDate, char *fmtstring, char *outbuf) /* * doesn't happen (we set replace_type to - * PGTYPES_TYPE_STRING_CONSTANT in case of an error - * above) + * PGTYPES_TYPE_STRING_CONSTANT in case of an error above) */ break; } @@ -316,11 +314,11 @@ PGTYPESdate_fmt_asc(date dDate, char *fmtstring, char *outbuf) #define PGTYPES_DATE_MONTH_MAXLENGTH 20 /* probably even less :-) */ int -PGTYPESdate_defmt_asc(date *d, char *fmt, char *str) +PGTYPESdate_defmt_asc(date * d, char *fmt, char *str) { /* - * token[2] = { 4,6 } means that token 2 starts at position 4 and ends - * at (including) position 6 + * token[2] = { 4,6 } means that token 2 starts at position 4 and ends at + * (including) position 6 */ int token[3][2]; int token_values[3] = {-1, -1, -1}; @@ -334,7 +332,7 @@ PGTYPESdate_defmt_asc(date *d, char *fmt, char *str) char *str_copy; struct tm tm; - tm.tm_year = tm.tm_mon = tm.tm_mday = 0; /* keep compiler quiet */ + tm.tm_year = tm.tm_mon = tm.tm_mday = 0; /* keep compiler quiet */ if (!d || !str || !fmt) { @@ -427,8 +425,8 @@ PGTYPESdate_defmt_asc(date *d, char *fmt, char *str) /* okay, this really is the special case */ /* - * as long as the string, one additional byte for the terminator - * and 2 for the delimiters between the 3 fiedls + * as long as the string, one additional byte for the terminator and 2 + * for the delimiters between the 3 fiedls */ str_copy = pgtypes_alloc(strlen(str) + 1 + 2); if (!str_copy) @@ -465,9 +463,9 @@ PGTYPESdate_defmt_asc(date *d, char *fmt, char *str) target_pos = 0; /* - * XXX: Here we could calculate the positions of the tokens and - * save the for loop down there where we again check with - * isdigit() for digits. + * XXX: Here we could calculate the positions of the tokens and save + * the for loop down there where we again check with isdigit() for + * digits. */ for (i = 0; i < 3; i++) { @@ -521,8 +519,8 @@ PGTYPESdate_defmt_asc(date *d, char *fmt, char *str) } /* - * we're at the end of the input string, but maybe we are still - * reading a number... + * we're at the end of the input string, but maybe we are still reading a + * number... */ if (reading_digit) { @@ -534,8 +532,8 @@ PGTYPESdate_defmt_asc(date *d, char *fmt, char *str) if (token_count < 2) { /* - * not all tokens found, no way to find 2 missing tokens with - * string matches + * not all tokens found, no way to find 2 missing tokens with string + * matches */ free(str_copy); errno = PGTYPES_DATE_ERR_ENOTDMY; @@ -546,8 +544,7 @@ PGTYPESdate_defmt_asc(date *d, char *fmt, char *str) { /* * not all tokens found but we may find another one with string - * matches by testing for the months names and months - * abbreviations + * matches by testing for the months names and months abbreviations */ char *month_lower_tmp = pgtypes_alloc(PGTYPES_DATE_MONTH_MAXLENGTH); char *start_pos; @@ -579,8 +576,8 @@ PGTYPESdate_defmt_asc(date *d, char *fmt, char *str) offset = start_pos - str_copy; /* - * sort the new token into the numeric tokens, shift them - * if necessary + * sort the new token into the numeric tokens, shift them if + * necessary */ if (offset < token[0][0]) { @@ -602,8 +599,8 @@ PGTYPESdate_defmt_asc(date *d, char *fmt, char *str) token[token_count][1] = offset + strlen(month_lower_tmp) - 1; /* - * the value is the index of the month in the array of - * months + 1 (January is month 0) + * the value is the index of the month in the array of months + * + 1 (January is month 0) */ token_values[token_count] = i + 1; found = 1; @@ -611,9 +608,9 @@ PGTYPESdate_defmt_asc(date *d, char *fmt, char *str) } /* - * evil[tm] hack: if we read the pgtypes_date_months and - * haven't found a match, reset list to point to - * pgtypes_date_months_short and reset the counter variable i + * evil[tm] hack: if we read the pgtypes_date_months and haven't + * found a match, reset list to point to pgtypes_date_months_short + * and reset the counter variable i */ if (list == pgtypes_date_months) { @@ -636,13 +633,12 @@ PGTYPESdate_defmt_asc(date *d, char *fmt, char *str) * here we found a month. token[token_count] and * token_values[token_count] reflect the month's details. * - * only the month can be specified with a literal. Here we can do a - * quick check if the month is at the right position according to - * the format string because we can check if the token that we - * expect to be the month is at the position of the only token - * that already has a value. If we wouldn't check here we could - * say "December 4 1990" with a fmt string of "dd mm yy" for 12 - * April 1990. + * only the month can be specified with a literal. Here we can do a quick + * check if the month is at the right position according to the format + * string because we can check if the token that we expect to be the + * month is at the position of the only token that already has a + * value. If we wouldn't check here we could say "December 4 1990" + * with a fmt string of "dd mm yy" for 12 April 1990. */ if (fmt_token_order[token_count] != 'm') { diff --git a/src/interfaces/ecpg/pgtypeslib/dt.h b/src/interfaces/ecpg/pgtypeslib/dt.h index d7ca2d5bf2..f8eefa93f4 100644 --- a/src/interfaces/ecpg/pgtypeslib/dt.h +++ b/src/interfaces/ecpg/pgtypeslib/dt.h @@ -8,7 +8,6 @@ #ifdef HAVE_INT64_TIMESTAMP typedef int32 fsec_t; - #else typedef double fsec_t; @@ -17,7 +16,6 @@ typedef double fsec_t; /* note: this is also used for rounding off intervals */ #define TS_PREC_INV 1000000.0 #define TSROUND(j) (rint(((double) (j)) * TS_PREC_INV) / TS_PREC_INV) - #endif #define USE_POSTGRES_DATES 0 @@ -168,10 +166,10 @@ typedef double fsec_t; #define DTK_DATE_M (DTK_M(YEAR) | DTK_M(MONTH) | DTK_M(DAY)) #define DTK_TIME_M (DTK_M(HOUR) | DTK_M(MINUTE) | DTK_M(SECOND)) -#define MAXDATELEN 51 /* maximum possible length of an input - * date string (not counting tr. null) */ -#define MAXDATEFIELDS 25 /* maximum possible number of fields in a - * date string */ +#define MAXDATELEN 51 /* maximum possible length of an input date + * string (not counting tr. null) */ +#define MAXDATEFIELDS 25 /* maximum possible number of fields in a date + * string */ #define TOKMAXLEN 10 /* only this many chars are stored in * datetktbl */ @@ -221,12 +219,12 @@ do { \ /* in both timestamp.h and ecpg/dt.h */ #define DAYS_PER_YEAR 365.25 /* assumes leap year every four years */ -#define MONTHS_PER_YEAR 12 +#define MONTHS_PER_YEAR 12 /* * DAYS_PER_MONTH is very imprecise. The more accurate value is * 365.2425/12 = 30.436875, or '30 days 10:29:06'. Right now we only * return an integral number of days, but someday perhaps we should - * also return a 'time' value to be used as well. ISO 8601 suggests + * also return a 'time' value to be used as well. ISO 8601 suggests * 30 days. */ #define DAYS_PER_MONTH 30 /* assumes exactly 30 days per month */ @@ -239,7 +237,7 @@ do { \ */ #define SECS_PER_YEAR (36525 * 864) /* avoid floating-point computation */ #define SECS_PER_DAY 86400 -#define SECS_PER_HOUR 3600 +#define SECS_PER_HOUR 3600 #define SECS_PER_MINUTE 60 #define MINS_PER_HOUR 60 @@ -291,7 +289,6 @@ do { \ #define DT_NOBEGIN (-INT64CONST(0x7fffffffffffffff) - 1) #define DT_NOEND (INT64CONST(0x7fffffffffffffff)) - #else #ifdef HUGE_VAL @@ -311,15 +308,15 @@ do { \ int DecodeTimeOnly(char **field, int *ftype, int nf, int *dtype, - struct tm *tm, fsec_t *fsec, int *tzp); + struct tm * tm, fsec_t *fsec, int *tzp); int DecodeInterval(char **field, int *ftype, int nf, int *dtype, - struct tm *tm, fsec_t *fsec); + struct tm * tm, fsec_t *fsec); -int EncodeTimeOnly(struct tm *tm, fsec_t fsec, int *tzp, int style, char *str); -int EncodeDateTime(struct tm *tm, fsec_t fsec, int *tzp, char **tzn, int style, char *str, bool); -int EncodeInterval(struct tm *tm, fsec_t fsec, int style, char *str); +int EncodeTimeOnly(struct tm * tm, fsec_t fsec, int *tzp, int style, char *str); +int EncodeDateTime(struct tm * tm, fsec_t fsec, int *tzp, char **tzn, int style, char *str, bool); +int EncodeInterval(struct tm * tm, fsec_t fsec, int style, char *str); int tm2timestamp(struct tm *, fsec_t, int *, timestamp *); @@ -339,6 +336,6 @@ extern char *pgtypes_date_weekdays_short[]; extern char *pgtypes_date_months[]; extern char *months[]; extern char *days[]; -extern int day_tab[2][13]; +extern int day_tab[2][13]; #endif /* DT_H */ diff --git a/src/interfaces/ecpg/pgtypeslib/dt_common.c b/src/interfaces/ecpg/pgtypeslib/dt_common.c index b5939c243e..bd10e2dbd0 100644 --- a/src/interfaces/ecpg/pgtypeslib/dt_common.c +++ b/src/interfaces/ecpg/pgtypeslib/dt_common.c @@ -8,7 +8,7 @@ #include "dt.h" #include "pgtypes_timestamp.h" -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}}; @@ -240,8 +240,7 @@ static datetkn datetktbl[] = { {"lhdt", DTZ, POS(44)}, /* Lord Howe Daylight Time, Australia */ {"lhst", TZ, POS(42)}, /* Lord Howe Standard Time, Australia */ {"ligt", TZ, POS(40)}, /* From Melbourne, Australia */ - {"lint", TZ, POS(56)}, /* Line Islands Time (Kiribati; +14 - * hours!) */ + {"lint", TZ, POS(56)}, /* Line Islands Time (Kiribati; +14 hours!) */ {"lkt", TZ, POS(24)}, /* Lanka Time */ {"m", UNITS, DTK_MONTH}, /* "month" for ISO input */ {"magst", DTZ, POS(48)}, /* Magadan Summer Time */ @@ -686,7 +685,7 @@ DecodeSpecial(int field, char *lowtoken, int *val) * Encode date as local time. */ int -EncodeDateOnly(struct tm *tm, int style, char *str, bool EuroDates) +EncodeDateOnly(struct tm * tm, int style, char *str, bool EuroDates) { if (tm->tm_mon < 1 || tm->tm_mon > MONTHS_PER_YEAR) return -1; @@ -700,7 +699,7 @@ EncodeDateOnly(struct tm *tm, int style, char *str, bool EuroDates) tm->tm_year, tm->tm_mon, tm->tm_mday); else sprintf(str, "%04d-%02d-%02d %s", - -(tm->tm_year - 1), tm->tm_mon, tm->tm_mday, "BC"); + -(tm->tm_year - 1), tm->tm_mon, tm->tm_mday, "BC"); break; case USE_SQL_DATES: @@ -766,7 +765,7 @@ TrimTrailingZeros(char *str) * European - dd/mm/yyyy */ int -EncodeDateTime(struct tm *tm, fsec_t fsec, int *tzp, char **tzn, int style, char *str, bool EuroDates) +EncodeDateTime(struct tm * tm, fsec_t fsec, int *tzp, char **tzn, int style, char *str, bool EuroDates) { int day, hour, @@ -778,15 +777,15 @@ EncodeDateTime(struct tm *tm, fsec_t fsec, int *tzp, char **tzn, int style, char /* Compatible with ISO-8601 date formats */ sprintf(str, "%04d-%02d-%02d %02d:%02d", - (tm->tm_year > 0) ? tm->tm_year : -(tm->tm_year - 1), + (tm->tm_year > 0) ? tm->tm_year : -(tm->tm_year - 1), tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min); /* - * Print fractional seconds if any. The field widths here - * should be at least equal to MAX_TIMESTAMP_PRECISION. + * Print fractional seconds if any. The field widths here should + * be at least equal to MAX_TIMESTAMP_PRECISION. * - * In float mode, don't print fractional seconds before 1 AD, - * since it's unlikely there's any precision left ... + * In float mode, don't print fractional seconds before 1 AD, since + * it's unlikely there's any precision left ... */ #ifdef HAVE_INT64_TIMESTAMP if (fsec != 0) @@ -806,10 +805,10 @@ EncodeDateTime(struct tm *tm, fsec_t fsec, int *tzp, char **tzn, int style, char sprintf(str + strlen(str), " BC"); /* - * tzp == NULL indicates that we don't want *any* time zone - * info in the output string. *tzn != NULL indicates that we - * have alpha time zone info available. tm_isdst != -1 - * indicates that we have a valid time zone translation. + * tzp == NULL indicates that we don't want *any* time zone info + * in the output string. *tzn != NULL indicates that we have alpha + * time zone info available. tm_isdst != -1 indicates that we have + * a valid time zone translation. */ if (tzp != NULL && tm->tm_isdst >= 0) { @@ -828,15 +827,15 @@ EncodeDateTime(struct tm *tm, fsec_t fsec, int *tzp, char **tzn, int style, char sprintf(str, "%02d/%02d", tm->tm_mon, tm->tm_mday); sprintf(str + 5, "/%04d %02d:%02d", - (tm->tm_year > 0) ? tm->tm_year : -(tm->tm_year - 1), + (tm->tm_year > 0) ? tm->tm_year : -(tm->tm_year - 1), tm->tm_hour, tm->tm_min); /* - * Print fractional seconds if any. The field widths here - * should be at least equal to MAX_TIMESTAMP_PRECISION. + * Print fractional seconds if any. The field widths here should + * be at least equal to MAX_TIMESTAMP_PRECISION. * - * In float mode, don't print fractional seconds before 1 AD, - * since it's unlikely there's any precision left ... + * In float mode, don't print fractional seconds before 1 AD, since + * it's unlikely there's any precision left ... */ #ifdef HAVE_INT64_TIMESTAMP if (fsec != 0) @@ -874,15 +873,15 @@ EncodeDateTime(struct tm *tm, fsec_t fsec, int *tzp, char **tzn, int style, char sprintf(str, "%02d.%02d", tm->tm_mday, tm->tm_mon); sprintf(str + 5, ".%04d %02d:%02d", - (tm->tm_year > 0) ? tm->tm_year : -(tm->tm_year - 1), + (tm->tm_year > 0) ? tm->tm_year : -(tm->tm_year - 1), tm->tm_hour, tm->tm_min); /* - * Print fractional seconds if any. The field widths here - * should be at least equal to MAX_TIMESTAMP_PRECISION. + * Print fractional seconds if any. The field widths here should + * be at least equal to MAX_TIMESTAMP_PRECISION. * - * In float mode, don't print fractional seconds before 1 AD, - * since it's unlikely there's any precision left ... + * In float mode, don't print fractional seconds before 1 AD, since + * it's unlikely there's any precision left ... */ #ifdef HAVE_INT64_TIMESTAMP if (fsec != 0) @@ -932,11 +931,11 @@ EncodeDateTime(struct tm *tm, fsec_t fsec, int *tzp, char **tzn, int style, char sprintf(str + 10, " %02d:%02d", tm->tm_hour, tm->tm_min); /* - * Print fractional seconds if any. The field widths here - * should be at least equal to MAX_TIMESTAMP_PRECISION. + * Print fractional seconds if any. The field widths here should + * be at least equal to MAX_TIMESTAMP_PRECISION. * - * In float mode, don't print fractional seconds before 1 AD, - * since it's unlikely there's any precision left ... + * In float mode, don't print fractional seconds before 1 AD, since + * it's unlikely there's any precision left ... */ #ifdef HAVE_INT64_TIMESTAMP if (fsec != 0) @@ -953,7 +952,7 @@ EncodeDateTime(struct tm *tm, fsec_t fsec, int *tzp, char **tzn, int style, char sprintf(str + strlen(str), ":%02d", tm->tm_sec); sprintf(str + strlen(str), " %04d", - (tm->tm_year > 0) ? tm->tm_year : -(tm->tm_year - 1)); + (tm->tm_year > 0) ? tm->tm_year : -(tm->tm_year - 1)); if (tm->tm_year <= 0) sprintf(str + strlen(str), " BC"); @@ -965,10 +964,9 @@ EncodeDateTime(struct tm *tm, fsec_t fsec, int *tzp, char **tzn, int style, char { /* * We have a time zone, but no string version. Use the - * numeric form, but be sure to include a leading - * space to avoid formatting something which would be - * rejected by the date/time parser later. - thomas - * 2001-10-19 + * numeric form, but be sure to include a leading space to + * avoid formatting something which would be rejected by + * the date/time parser later. - thomas 2001-10-19 */ hour = -(*tzp / SECS_PER_HOUR); min = (abs(*tzp) / MINS_PER_HOUR) % MINS_PER_HOUR; @@ -982,7 +980,7 @@ EncodeDateTime(struct tm *tm, fsec_t fsec, int *tzp, char **tzn, int style, char } /* EncodeDateTime() */ void -GetEpochTime(struct tm *tm) +GetEpochTime(struct tm * tm) { struct tm *t0; time_t epoch = 0; @@ -1004,7 +1002,7 @@ GetEpochTime(struct tm *tm) } /* GetEpochTime() */ static void -abstime2tm(AbsoluteTime _time, int *tzp, struct tm *tm, char **tzn) +abstime2tm(AbsoluteTime _time, int *tzp, struct tm * tm, char **tzn) { time_t time = (time_t) _time; struct tm *tx; @@ -1035,15 +1033,13 @@ abstime2tm(AbsoluteTime _time, int *tzp, struct tm *tm, char **tzn) *tzp = -tm->tm_gmtoff; /* tm_gmtoff is Sun/DEC-ism */ /* - * XXX FreeBSD man pages indicate that this should work - tgl - * 97/04/23 + * XXX FreeBSD man pages indicate that this should work - tgl 97/04/23 */ if (tzn != NULL) { /* - * Copy no more than MAXTZLEN bytes of timezone to tzn, in - * case it contains an error message, which doesn't fit in the - * buffer + * Copy no more than MAXTZLEN bytes of timezone to tzn, in case it + * contains an error message, which doesn't fit in the buffer */ StrNCpy(*tzn, tm->tm_zone, MAXTZLEN + 1); if (strlen(tm->tm_zone) > MAXTZLEN) @@ -1060,9 +1056,8 @@ abstime2tm(AbsoluteTime _time, int *tzp, struct tm *tm, char **tzn) if (tzn != NULL) { /* - * Copy no more than MAXTZLEN bytes of timezone to tzn, in - * case it contains an error message, which doesn't fit in the - * buffer + * Copy no more than MAXTZLEN bytes of timezone to tzn, in case it + * contains an error message, which doesn't fit in the buffer */ StrNCpy(*tzn, TZNAME_GLOBAL[tm->tm_isdst], MAXTZLEN + 1); if (strlen(TZNAME_GLOBAL[tm->tm_isdst]) > MAXTZLEN) @@ -1085,7 +1080,7 @@ abstime2tm(AbsoluteTime _time, int *tzp, struct tm *tm, char **tzn) } void -GetCurrentDateTime(struct tm *tm) +GetCurrentDateTime(struct tm * tm) { int tz; @@ -1104,7 +1099,7 @@ GetCurrentDateTime(struct tm *tm) * the *only* call of mktime() in the backend. */ static int -DetermineLocalTimeZone(struct tm *tm) +DetermineLocalTimeZone(struct tm * tm) { int tz; @@ -1113,10 +1108,9 @@ DetermineLocalTimeZone(struct tm *tm) #if defined(HAVE_TM_ZONE) || defined(HAVE_INT_TIMEZONE) /* - * Some buggy mktime() implementations may change the - * year/month/day when given a time right at a DST boundary. To - * prevent corruption of the caller's data, give mktime() a - * copy... + * Some buggy mktime() implementations may change the year/month/day + * when given a time right at a DST boundary. To prevent corruption + * of the caller's data, give mktime() a copy... */ struct tm tt, *tmp = &tt; @@ -1129,7 +1123,7 @@ DetermineLocalTimeZone(struct tm *tm) /* indicate timezone unknown */ tmp->tm_isdst = -1; - if (mktime(tmp) != (time_t)-1 && tmp->tm_isdst >= 0) + if (mktime(tmp) != (time_t) -1 && tmp->tm_isdst >= 0) { /* mktime() succeeded, trust its result */ tm->tm_isdst = tmp->tm_isdst; @@ -1165,8 +1159,8 @@ DetermineLocalTimeZone(struct tm *tm) mytime = (time_t) mysec; /* - * Use localtime to convert that time_t to broken-down time, - * and reassemble to get a representation of local time. + * Use localtime to convert that time_t to broken-down time, and + * reassemble to get a representation of local time. */ tmp = localtime(&mytime); day = (date2j(tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday) - @@ -1180,21 +1174,20 @@ DetermineLocalTimeZone(struct tm *tm) delta1 = mysec - locsec; /* - * However, if that GMT time and the local time we are - * actually interested in are on opposite sides of a - * daylight-savings-time transition, then this is not the time - * offset we want. So, adjust the time_t to be what we think - * the GMT time corresponding to our target local time is, and - * repeat the localtime() call and delta calculation. We may - * have to do it twice before we have a trustworthy delta. + * However, if that GMT time and the local time we are actually + * interested in are on opposite sides of a daylight-savings-time + * transition, then this is not the time offset we want. So, + * adjust the time_t to be what we think the GMT time + * corresponding to our target local time is, and repeat the + * localtime() call and delta calculation. We may have to do it + * twice before we have a trustworthy delta. * - * Note: think not to put a loop here, since if we've been given - * an "impossible" local time (in the gap during a - * spring-forward transition) we'd never get out of the loop. - * Twice is enough to give the behavior we want, which is that - * "impossible" times are taken as standard time, while at a - * fall-back boundary ambiguous times are also taken as - * standard. + * Note: think not to put a loop here, since if we've been given an + * "impossible" local time (in the gap during a spring-forward + * transition) we'd never get out of the loop. Twice is enough to + * give the behavior we want, which is that "impossible" times are + * taken as standard time, while at a fall-back boundary ambiguous + * times are also taken as standard. */ mysec += delta1; mytime = (time_t) mysec; @@ -1268,13 +1261,13 @@ dt2time(double jd, int *hour, int *min, int *sec, fsec_t *fsec) */ static int DecodeNumberField(int len, char *str, int fmask, -int *tmask, struct tm *tm, fsec_t *fsec, int *is2digits, bool EuroDates) + int *tmask, struct tm * tm, fsec_t *fsec, int *is2digits, bool EuroDates) { char *cp; /* - * Have a decimal point? Then this is a date or something with a - * seconds field... + * Have a decimal point? Then this is a date or something with a seconds + * field... */ if ((cp = strchr(str, '.')) != NULL) { @@ -1375,7 +1368,7 @@ int *tmask, struct tm *tm, fsec_t *fsec, int *is2digits, bool EuroDates) */ static int DecodeNumber(int flen, char *str, int fmask, -int *tmask, struct tm *tm, fsec_t *fsec, int *is2digits, bool EuroDates) + int *tmask, struct tm * tm, fsec_t *fsec, int *is2digits, bool EuroDates) { int val; char *cp; @@ -1389,12 +1382,12 @@ int *tmask, struct tm *tm, fsec_t *fsec, int *is2digits, bool EuroDates) if (*cp == '.') { /* - * More than two digits? Then could be a date or a run-together - * time: 2001.360 20011225 040506.789 + * More than two digits? Then could be a date or a run-together time: + * 2001.360 20011225 040506.789 */ if (cp - str > 2) return DecodeNumberField(flen, str, (fmask | DTK_DATE_M), - tmask, tm, fsec, is2digits, EuroDates); + tmask, tm, fsec, is2digits, EuroDates); *fsec = strtod(cp, &cp); if (*cp != '\0') @@ -1443,8 +1436,8 @@ int *tmask, struct tm *tm, fsec_t *fsec, int *is2digits, bool EuroDates) } /* no year and EuroDates enabled? then could be day */ else if ((EuroDates || (fmask & DTK_M(MONTH))) && - !(fmask & DTK_M(YEAR)) && !(fmask & DTK_M(DAY)) && - val >= 1 && val <= 31) + !(fmask & DTK_M(YEAR)) && !(fmask & DTK_M(DAY)) && + val >= 1 && val <= 31) { *tmask = DTK_M(DAY); tm->tm_mday = val; @@ -1461,8 +1454,8 @@ int *tmask, struct tm *tm, fsec_t *fsec, int *is2digits, bool EuroDates) } /* - * Check for 2 or 4 or more digits, but currently we reach here only - * if two digits. - thomas 2000-03-28 + * Check for 2 or 4 or more digits, but currently we reach here only if + * two digits. - thomas 2000-03-28 */ else if (!(fmask & DTK_M(YEAR)) && (flen >= 4 || flen == 2)) { @@ -1483,7 +1476,7 @@ int *tmask, struct tm *tm, fsec_t *fsec, int *is2digits, bool EuroDates) * Insist on a complete set of fields. */ static int -DecodeDate(char *str, int fmask, int *tmask, struct tm *tm, bool EuroDates) +DecodeDate(char *str, int fmask, int *tmask, struct tm * tm, bool EuroDates) { fsec_t fsec; @@ -1612,7 +1605,7 @@ DecodeDate(char *str, int fmask, int *tmask, struct tm *tm, bool EuroDates) * can be used to represent time spans. */ static int -DecodeTime(char *str, int fmask, int *tmask, struct tm *tm, fsec_t *fsec) +DecodeTime(char *str, int fmask, int *tmask, struct tm * tm, fsec_t *fsec) { char *cp; @@ -1642,9 +1635,8 @@ DecodeTime(char *str, int fmask, int *tmask, struct tm *tm, fsec_t *fsec) char fstr[MAXDATELEN + 1]; /* - * OK, we have at most six digits to work with. Let's - * construct a string and then do the conversion to an - * integer. + * OK, we have at most six digits to work with. Let's construct a + * string and then do the conversion to an integer. */ strncpy(fstr, (cp + 1), 7); strcpy(fstr + strlen(fstr), "000000"); @@ -1777,7 +1769,7 @@ DecodePosixTimezone(char *str, int *tzp) */ int ParseDateTime(char *timestr, char *lowstr, - char **field, int *ftype, int maxfields, int *numfields, char **endstr) + char **field, int *ftype, int maxfields, int *numfields, char **endstr) { int nf = 0; char *lp = lowstr; @@ -1819,8 +1811,8 @@ ParseDateTime(char *timestr, char *lowstr, *lp++ = *(*endstr)++; /* - * insist that the delimiters match to get a - * three-field date. + * insist that the delimiters match to get a three-field + * date. */ if (*(*endstr) == *dp) { @@ -1839,8 +1831,8 @@ ParseDateTime(char *timestr, char *lowstr, } /* - * otherwise, number only and will determine year, month, day, - * or concatenated fields later... + * otherwise, number only and will determine year, month, day, or + * concatenated fields later... */ else ftype[nf] = DTK_NUMBER; @@ -1856,8 +1848,7 @@ ParseDateTime(char *timestr, char *lowstr, } /* - * text? then date string, month, day of week, special, or - * timezone + * text? then date string, month, day of week, special, or timezone */ else if (isalpha((unsigned char) *(*endstr))) { @@ -1867,8 +1858,8 @@ ParseDateTime(char *timestr, char *lowstr, *lp++ = pg_tolower((unsigned char) *(*endstr)++); /* - * Full date string with leading text month? Could also be a - * POSIX time zone... + * Full date string with leading text month? Could also be a POSIX + * time zone... */ if (*(*endstr) == '-' || *(*endstr) == '/' || *(*endstr) == '.') { @@ -1960,13 +1951,12 @@ ParseDateTime(char *timestr, char *lowstr, */ int DecodeDateTime(char **field, int *ftype, int nf, - int *dtype, struct tm *tm, fsec_t *fsec, int *tzp, bool EuroDates) + int *dtype, struct tm * tm, fsec_t *fsec, int *tzp, bool EuroDates) { int fmask = 0, tmask, type; - int ptype = 0; /* "prefix type" for ISO y2001m02d04 - * format */ + int ptype = 0; /* "prefix type" for ISO y2001m02d04 format */ int i; int val; int mer = HR24; @@ -2046,8 +2036,8 @@ DecodeDateTime(char **field, int *ftype, int nf, /* * Starts with a digit but we already have a time - * field? Then we are in trouble with a date and - * time already... + * field? Then we are in trouble with a date and time + * already... */ if ((fmask & DTK_TIME_M) == DTK_TIME_M) return -1; @@ -2061,11 +2051,11 @@ DecodeDateTime(char **field, int *ftype, int nf, *cp = '\0'; /* - * Then read the rest of the field as a - * concatenated time + * Then read the rest of the field as a concatenated + * time */ if ((ftype[i] = DecodeNumberField(strlen(field[i]), field[i], fmask, - &tmask, tm, fsec, &is2digits, EuroDates)) < 0) + &tmask, tm, fsec, &is2digits, EuroDates)) < 0) return -1; /* @@ -2096,8 +2086,8 @@ DecodeDateTime(char **field, int *ftype, int nf, * DecodeTime() */ /* test for > 24:00:00 */ - if (tm->tm_hour > 24 || - (tm->tm_hour == 24 && (tm->tm_min > 0 || tm->tm_sec > 0))) + if (tm->tm_hour > 24 || + (tm->tm_hour == 24 && (tm->tm_min > 0 || tm->tm_sec > 0))) return -1; break; @@ -2112,9 +2102,8 @@ DecodeDateTime(char **field, int *ftype, int nf, return -1; /* - * Already have a time zone? Then maybe this is the - * second field of a POSIX time: EST+3 (equivalent to - * PST) + * Already have a time zone? Then maybe this is the second + * field of a POSIX time: EST+3 (equivalent to PST) */ if (i > 0 && (fmask & DTK_M(TZ)) != 0 && ftype[i - 1] == DTK_TZ && @@ -2254,7 +2243,7 @@ DecodeDateTime(char **field, int *ftype, int nf, case DTK_TIME: /* previous field was "t" for ISO time */ if ((ftype[i] = DecodeNumberField(strlen(field[i]), field[i], (fmask | DTK_DATE_M), - &tmask, tm, fsec, &is2digits, EuroDates)) < 0) + &tmask, tm, fsec, &is2digits, EuroDates)) < 0) return -1; if (tmask != DTK_TIME_M) @@ -2287,23 +2276,23 @@ DecodeDateTime(char **field, int *ftype, int nf, else if (cp != NULL && flen - strlen(cp) > 2) { /* - * Interpret as a concatenated date or time Set - * the type field to allow decoding other fields - * later. Example: 20011223 or 040506 + * Interpret as a concatenated date or time Set the + * type field to allow decoding other fields later. + * Example: 20011223 or 040506 */ if ((ftype[i] = DecodeNumberField(flen, field[i], fmask, - &tmask, tm, fsec, &is2digits, EuroDates)) < 0) + &tmask, tm, fsec, &is2digits, EuroDates)) < 0) return -1; } else if (flen > 4) { if ((ftype[i] = DecodeNumberField(flen, field[i], fmask, - &tmask, tm, fsec, &is2digits, EuroDates)) < 0) + &tmask, tm, fsec, &is2digits, EuroDates)) < 0) return -1; } /* otherwise it is a single date/time field... */ else if (DecodeNumber(flen, field[i], fmask, - &tmask, tm, fsec, &is2digits, EuroDates) != 0) + &tmask, tm, fsec, &is2digits, EuroDates) != 0) return -1; } break; @@ -2376,8 +2365,8 @@ DecodeDateTime(char **field, int *ftype, int nf, case MONTH: /* - * already have a (numeric) month? then see if we - * can substitute... + * 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) @@ -2392,8 +2381,8 @@ DecodeDateTime(char **field, int *ftype, int nf, 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; @@ -2405,8 +2394,8 @@ DecodeDateTime(char **field, int *ftype, int nf, case DTZ: /* - * set mask for TZ here _or_ check for DTZ later - * when getting default timezone + * set mask for TZ here _or_ check for DTZ later when + * getting default timezone */ tmask |= DTK_M(TZ); tm->tm_isdst = 1; @@ -2447,9 +2436,8 @@ DecodeDateTime(char **field, int *ftype, int nf, case ISOTIME: /* - * This is a filler field "t" indicating that the - * next field is time. Try to verify that this is - * sensible. + * This is a filler field "t" indicating that the next + * field is time. Try to verify that this is sensible. */ tmask = 0; @@ -2465,8 +2453,8 @@ DecodeDateTime(char **field, int *ftype, int nf, ***/ if (i >= nf - 1 || (ftype[i + 1] != DTK_NUMBER && - ftype[i + 1] != DTK_TIME && - ftype[i + 1] != DTK_DATE)) + ftype[i + 1] != DTK_TIME && + ftype[i + 1] != DTK_DATE)) return -1; ptype = val; @@ -2516,8 +2504,8 @@ DecodeDateTime(char **field, int *ftype, int nf, 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; @@ -2526,8 +2514,8 @@ DecodeDateTime(char **field, int *ftype, int nf, if ((fmask & DTK_DATE_M) == DTK_DATE_M && 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; @@ -2554,14 +2542,12 @@ find_end_token(char *str, char *fmt) * functions gets called as find_end_token("28the day12the hour", "the * day%hthehour") * - * fmt points to "the day%hthehour", next_percent points to %hthehour and - * we have to find a match for everything between these positions - * ("the day"). We look for "the day" in str and know that the pattern - * we are about to scan ends where this string starts (right after the - * "28") + * fmt points to "the day%hthehour", next_percent points to %hthehour and we + * have to find a match for everything between these positions ("the + * day"). We look for "the day" in str and know that the pattern we are + * about to scan ends where this string starts (right after the "28") * - * At the end, *fmt is '\0' and *str isn't. end_position then is - * unchanged. + * At the end, *fmt is '\0' and *str isn't. end_position then is unchanged. */ char *end_position = NULL; char *next_percent, @@ -2580,10 +2566,10 @@ find_end_token(char *str, char *fmt) while (fmt[scan_offset] == '%' && fmt[scan_offset + 1]) { /* - * there is no delimiter, skip to the next delimiter if we're - * reading a number and then something that is not a number - * "9:15pm", we might be able to recover with the strtol end - * pointer. Go for the next percent sign + * there is no delimiter, skip to the next delimiter if we're reading + * a number and then something that is not a number "9:15pm", we might + * be able to recover with the strtol end pointer. Go for the next + * percent sign */ scan_offset += 2; } @@ -2591,10 +2577,10 @@ find_end_token(char *str, char *fmt) if (next_percent) { /* - * we don't want to allocate extra memory, so we temporarily set - * the '%' sign to '\0' and call strstr However since we allow - * whitespace to float around everything, we have to shorten the - * pattern until we reach a non-whitespace character + * we don't want to allocate extra memory, so we temporarily set the + * '%' sign to '\0' and call strstr However since we allow whitespace + * to float around everything, we have to shorten the pattern until we + * reach a non-whitespace character */ subst_location = next_percent; @@ -2604,16 +2590,16 @@ find_end_token(char *str, char *fmt) *subst_location = '\0'; /* - * the haystack is the str and the needle is the original fmt but - * it ends at the position where the next percent sign would be + * the haystack is the str and the needle is the original fmt but it + * ends at the position where the next percent sign would be */ /* - * There is one special case. Imagine: str = " 2", fmt = "%d - * %...", since we want to allow blanks as "dynamic" padding we - * have to accept this. Now, we are called with a fmt of " %..." - * and look for " " in str. We find it at the first position and - * never read the 2... + * There is one special case. Imagine: str = " 2", fmt = "%d %...", + * since we want to allow blanks as "dynamic" padding we have to + * accept this. Now, we are called with a fmt of " %..." and look for + * " " in str. We find it at the first position and never read the + * 2... */ while (*str == ' ') str++; @@ -2623,8 +2609,8 @@ find_end_token(char *str, char *fmt) else { /* - * there is no other percent sign. So everything up to the end has - * to match. + * there is no other percent sign. So everything up to the end has to + * match. */ end_position = str + strlen(str); } @@ -2641,8 +2627,8 @@ find_end_token(char *str, char *fmt) * * and have set fmt to " " because overwrote the % sign with a NULL * - * In this case where we would have to match a space but can't find - * it, set end_position to the end of the string + * In this case where we would have to match a space but can't find it, + * set end_position to the end of the string */ if ((fmt + scan_offset)[0] == ' ' && fmt + scan_offset + 1 == subst_location) end_position = str + strlen(str); @@ -2654,8 +2640,8 @@ static int pgtypes_defmt_scan(union un_fmt_comb * scan_val, int scan_type, char **pstr, char *pfmt) { /* - * scan everything between pstr and pstr_end. This is not including - * the last character so we might set it to '\0' for the parsing + * scan everything between pstr and pstr_end. This is not including the + * last character so we might set it to '\0' for the parsing */ char last_char; @@ -2679,8 +2665,8 @@ pgtypes_defmt_scan(union un_fmt_comb * scan_val, int scan_type, char **pstr, cha case PGTYPES_TYPE_UINT: /* - * numbers may be blank-padded, this is the only deviation - * from the fmt-string we accept + * numbers may be blank-padded, this is the only deviation from + * the fmt-string we accept */ while (**pstr == ' ') (*pstr)++; @@ -2716,7 +2702,7 @@ int PGTYPEStimestamp_defmt_scan(char **, char *, timestamp *, int *, int *, int int *, int *, int *, int *); int -PGTYPEStimestamp_defmt_scan(char **str, char *fmt, timestamp *d, +PGTYPEStimestamp_defmt_scan(char **str, char *fmt, timestamp * d, int *year, int *month, int *day, int *hour, int *minute, int *second, int *tz) @@ -2764,15 +2750,15 @@ PGTYPEStimestamp_defmt_scan(char **str, char *fmt, timestamp *d, pfmt++; /* - * we parse the day and see if it is a week day but we do - * not check if the week day really matches the date + * we parse the day and see if it is a week day but we do not + * check if the week day really matches the date */ err = 1; j = 0; while (pgtypes_date_weekdays_short[j]) { if (strncmp(pgtypes_date_weekdays_short[j], pstr, - strlen(pgtypes_date_weekdays_short[j])) == 0) + strlen(pgtypes_date_weekdays_short[j])) == 0) { /* found it */ err = 0; @@ -2854,8 +2840,8 @@ PGTYPEStimestamp_defmt_scan(char **str, char *fmt, timestamp *d, case 'D': /* - * we have to concatenate the strings in order to be able - * to find the end of the substitution + * we have to concatenate the strings in order to be able to + * find the end of the substitution */ pfmt++; tmp = pgtypes_alloc(strlen("%m/%d/%y") + strlen(pstr) + 1); @@ -2908,8 +2894,8 @@ PGTYPEStimestamp_defmt_scan(char **str, char *fmt, timestamp *d, /* * XXX what should we do with that? We could say that it's - * sufficient if we have the year and the day within the - * year to get at least a specific day. + * sufficient if we have the year and the day within the year + * to get at least a specific day. */ break; case 'M': @@ -3097,8 +3083,8 @@ PGTYPEStimestamp_defmt_scan(char **str, char *fmt, timestamp *d, err = pgtypes_defmt_scan(&scan_val, scan_type, &pstr, pfmt); /* - * XXX use DecodeSpecial instead ? - it's declared static - * but the arrays as well. :-( + * XXX use DecodeSpecial instead ? - it's declared static but + * the arrays as well. :-( */ for (j = 0; !err && j < szdatetktbl; j++) { @@ -3106,8 +3092,8 @@ PGTYPEStimestamp_defmt_scan(char **str, char *fmt, timestamp *d, { /* * tz calculates the offset for the seconds, the - * timezone value of the datetktbl table is in - * quarter hours + * timezone value of the datetktbl table is in quarter + * hours */ *tz = -15 * MINS_PER_HOUR * datetktbl[j].value; break; @@ -3163,7 +3149,7 @@ PGTYPEStimestamp_defmt_scan(char **str, char *fmt, timestamp *d, err = 1; *minute = 0; } - if (*hour > 24 || /* test for > 24:00:00 */ + if (*hour > 24 || /* test for > 24:00:00 */ (*hour == 24 && (*minute > 0 || *second > 0))) { err = 1; diff --git a/src/interfaces/ecpg/pgtypeslib/extern.h b/src/interfaces/ecpg/pgtypeslib/extern.h index 3475992d28..689a3e8955 100644 --- a/src/interfaces/ecpg/pgtypeslib/extern.h +++ b/src/interfaces/ecpg/pgtypeslib/extern.h @@ -12,10 +12,10 @@ #define PGTYPES_TYPE_DOUBLE_NF 4 /* no fractional part */ #define PGTYPES_TYPE_INT64 5 #define PGTYPES_TYPE_UINT 6 -#define PGTYPES_TYPE_UINT_2_LZ 7 /* 2 digits, pad with - * leading zero */ -#define PGTYPES_TYPE_UINT_2_LS 8 /* 2 digits, pad with - * leading space */ +#define PGTYPES_TYPE_UINT_2_LZ 7 /* 2 digits, pad with leading + * zero */ +#define PGTYPES_TYPE_UINT_2_LS 8 /* 2 digits, pad with leading + * space */ #define PGTYPES_TYPE_UINT_3_LZ 9 #define PGTYPES_TYPE_UINT_4_LZ 10 #define PGTYPES_TYPE_UINT_LONG 11 diff --git a/src/interfaces/ecpg/pgtypeslib/interval.c b/src/interfaces/ecpg/pgtypeslib/interval.c index 93a9d3b45e..fd915bb3dd 100644 --- a/src/interfaces/ecpg/pgtypeslib/interval.c +++ b/src/interfaces/ecpg/pgtypeslib/interval.c @@ -33,7 +33,7 @@ TrimTrailingZeros(char *str) * can be used to represent time spans. */ static int -DecodeTime(char *str, int fmask, int *tmask, struct tm *tm, fsec_t *fsec) +DecodeTime(char *str, int fmask, int *tmask, struct tm * tm, fsec_t *fsec) { char *cp; @@ -63,9 +63,8 @@ DecodeTime(char *str, int fmask, int *tmask, struct tm *tm, fsec_t *fsec) char fstr[MAXDATELEN + 1]; /* - * OK, we have at most six digits to work with. Let's - * construct a string and then do the conversion to an - * integer. + * OK, we have at most six digits to work with. Let's construct a + * string and then do the conversion to an integer. */ strncpy(fstr, (cp + 1), 7); strcpy(fstr + strlen(fstr), "000000"); @@ -107,7 +106,7 @@ DecodeTime(char *str, int fmask, int *tmask, struct tm *tm, fsec_t *fsec) * preceding an hh:mm:ss field. - thomas 1998-04-30 */ int -DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct tm *tm, fsec_t *fsec) +DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct tm * tm, fsec_t *fsec) { int is_before = FALSE; @@ -149,9 +148,9 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct tm *tm, fsec */ /* - * A single signed number ends up here, but will be - * rejected by DecodeTime(). So, work this out to drop - * through to DTK_NUMBER, which *can* tolerate this. + * A single signed number ends up here, but will be rejected + * by DecodeTime(). So, work this out to drop through to + * DTK_NUMBER, which *can* tolerate this. */ cp = field[i] + 1; while (*cp != '\0' && *cp != ':' && *cp != '.') @@ -169,8 +168,8 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct tm *tm, fsec /* * Set the next type to be a day, if units are not - * specified. This handles the case of '1 +02:03' - * since we are reading right to left. + * specified. This handles the case of '1 +02:03' since we + * are reading right to left. */ type = DTK_DAY; tmask = DTK_M(TZ); @@ -445,7 +444,7 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct tm *tm, fsec * - thomas 1998-04-30 */ int -EncodeInterval(struct tm *tm, fsec_t fsec, int style, char *str) +EncodeInterval(struct tm * tm, fsec_t fsec, int style, char *str) { int is_before = FALSE; int is_nonzero = FALSE; @@ -453,9 +452,8 @@ EncodeInterval(struct tm *tm, fsec_t fsec, int style, char *str) /* * The sign of year and month are guaranteed to match, since they are - * stored internally as "month". But we'll need to check for is_before - * and is_nonzero when determining the signs of hour/minute/seconds - * fields. + * stored internally as "month". But we'll need to check for is_before and + * is_nonzero when determining the signs of hour/minute/seconds fields. */ switch (style) { @@ -493,7 +491,7 @@ EncodeInterval(struct tm *tm, fsec_t fsec, int style, char *str) tm->tm_sec != 0 || fsec != 0) { int minus = tm->tm_hour < 0 || tm->tm_min < 0 || - tm->tm_sec < 0 || fsec < 0; + tm->tm_sec < 0 || fsec < 0; sprintf(cp, "%s%s%02d:%02d", (is_nonzero ? " " : ""), (minus ? "-" : (is_before ? "+" : "")), @@ -511,7 +509,7 @@ EncodeInterval(struct tm *tm, fsec_t fsec, int style, char *str) sprintf(cp, ".%06d", Abs(fsec)); #else fsec += tm->tm_sec; - sprintf(cp, ":%012.9f", fabs(fsec)); + sprintf(cp, ":%012.9f", fabs(fsec)); #endif TrimTrailingZeros(cp); cp += strlen(cp); @@ -670,7 +668,7 @@ EncodeInterval(struct tm *tm, fsec_t fsec, int style, char *str) * Convert a interval data type to a tm structure. */ static int -interval2tm(interval span, struct tm *tm, fsec_t *fsec) +interval2tm(interval span, struct tm * tm, fsec_t *fsec) { #ifdef HAVE_INT64_TIMESTAMP int64 time; @@ -703,9 +701,9 @@ interval2tm(interval span, struct tm *tm, fsec_t *fsec) *fsec = time - (tm->tm_sec * USECS_PER_SEC); #else recalc: - TMODULO(time, tm->tm_mday, (double)SECS_PER_DAY); - TMODULO(time, tm->tm_hour, (double)SECS_PER_HOUR); - TMODULO(time, tm->tm_min, (double)SECS_PER_MINUTE); + TMODULO(time, tm->tm_mday, (double) SECS_PER_DAY); + TMODULO(time, tm->tm_hour, (double) SECS_PER_HOUR); + TMODULO(time, tm->tm_min, (double) SECS_PER_MINUTE); TMODULO(time, tm->tm_sec, 1.0); time = TSROUND(time); /* roundoff may need to propagate to higher-order fields */ @@ -721,19 +719,19 @@ recalc: } /* interval2tm() */ static int -tm2interval(struct tm *tm, fsec_t fsec, interval *span) +tm2interval(struct tm * tm, fsec_t fsec, interval * span) { span->month = tm->tm_year * MONTHS_PER_YEAR + tm->tm_mon; #ifdef HAVE_INT64_TIMESTAMP span->time = (((((((tm->tm_mday * INT64CONST(24)) + - tm->tm_hour) * INT64CONST(60)) + - tm->tm_min) * INT64CONST(60)) + - tm->tm_sec) * USECS_PER_SEC) + fsec; + tm->tm_hour) * INT64CONST(60)) + + tm->tm_min) * INT64CONST(60)) + + tm->tm_sec) * USECS_PER_SEC) + fsec; #else - span->time = (((((tm->tm_mday * (double)HOURS_PER_DAY) + - tm->tm_hour) * (double)MINS_PER_HOUR) + - tm->tm_min) * (double)SECS_PER_MINUTE) + - tm->tm_sec + fsec; + span->time = (((((tm->tm_mday * (double) HOURS_PER_DAY) + + tm->tm_hour) * (double) MINS_PER_HOUR) + + tm->tm_min) * (double) SECS_PER_MINUTE) + + tm->tm_sec + fsec; #endif return 0; @@ -797,7 +795,7 @@ PGTYPESinterval_from_asc(char *str, char **endptr) } char * -PGTYPESinterval_to_asc(interval *span) +PGTYPESinterval_to_asc(interval * span) { struct tm tt, *tm = &tt; @@ -821,7 +819,7 @@ PGTYPESinterval_to_asc(interval *span) } int -PGTYPESinterval_copy(interval *intvlsrc, interval *intrcldest) +PGTYPESinterval_copy(interval * intvlsrc, interval * intrcldest) { intrcldest->time = intvlsrc->time; intrcldest->month = intvlsrc->month; diff --git a/src/interfaces/ecpg/pgtypeslib/numeric.c b/src/interfaces/ecpg/pgtypeslib/numeric.c index e0a954ccad..575d6d0c97 100644 --- a/src/interfaces/ecpg/pgtypeslib/numeric.c +++ b/src/interfaces/ecpg/pgtypeslib/numeric.c @@ -28,7 +28,7 @@ * ---------- */ static int -apply_typmod(numeric *var, long typmod) +apply_typmod(numeric * var, long typmod) { int precision; int scale; @@ -71,10 +71,10 @@ apply_typmod(numeric *var, long typmod) /* * Check for overflow - note we can't do this before rounding, because - * rounding could raise the weight. Also note that the var's weight - * could be inflated by leading zeroes, which will be stripped before - * storage but perhaps might not have been yet. In any case, we must - * recognize a true zero, whose weight doesn't mean anything. + * rounding could raise the weight. Also note that the var's weight could + * be inflated by leading zeroes, which will be stripped before storage + * but perhaps might not have been yet. In any case, we must recognize a + * true zero, whose weight doesn't mean anything. */ if (var->weight >= maxweight) { @@ -108,7 +108,7 @@ apply_typmod(numeric *var, long typmod) * ---------- */ static int -alloc_var(numeric *var, int ndigits) +alloc_var(numeric * var, int ndigits) { digitbuf_free(var->buf); var->buf = digitbuf_alloc(ndigits + 1); @@ -141,7 +141,7 @@ PGTYPESnumeric_new(void) * ---------- */ static int -set_var_from_str(char *str, char **ptr, numeric *dest) +set_var_from_str(char *str, char **ptr, numeric * dest) { bool have_dp = FALSE; int i = 0; @@ -271,7 +271,7 @@ set_var_from_str(char *str, char **ptr, numeric *dest) * ---------- */ static char * -get_str_from_var(numeric *var, int dscale) +get_str_from_var(numeric * var, int dscale) { char *str; char *cp; @@ -334,8 +334,7 @@ get_str_from_var(numeric *var, int dscale) } /* - * If requested, output a decimal point and all the digits that follow - * it. + * If requested, output a decimal point and all the digits that follow it. */ if (dscale > 0) { @@ -385,7 +384,7 @@ PGTYPESnumeric_from_asc(char *str, char **endptr) } char * -PGTYPESnumeric_to_asc(numeric *num, int dscale) +PGTYPESnumeric_to_asc(numeric * num, int dscale) { if (dscale < 0) dscale = num->dscale; @@ -401,7 +400,7 @@ PGTYPESnumeric_to_asc(numeric *num, int dscale) * ---------- */ static void -zero_var(numeric *var) +zero_var(numeric * var) { digitbuf_free(var->buf); var->buf = NULL; @@ -412,7 +411,7 @@ zero_var(numeric *var) } void -PGTYPESnumeric_free(numeric *var) +PGTYPESnumeric_free(numeric * var) { digitbuf_free(var->buf); free(var); @@ -428,7 +427,7 @@ PGTYPESnumeric_free(numeric *var) * ---------- */ static int -cmp_abs(numeric *var1, numeric *var2) +cmp_abs(numeric * var1, numeric * var2) { int i1 = 0; int i2 = 0; @@ -486,7 +485,7 @@ cmp_abs(numeric *var1, numeric *var2) * ---------- */ static int -add_abs(numeric *var1, numeric *var2, numeric *result) +add_abs(numeric * var1, numeric * var2, numeric * result) { NumericDigit *res_buf; NumericDigit *res_digits; @@ -574,7 +573,7 @@ add_abs(numeric *var1, numeric *var2, numeric *result) * ---------- */ static int -sub_abs(numeric *var1, numeric *var2, numeric *result) +sub_abs(numeric * var1, numeric * var2, numeric * result) { NumericDigit *res_buf; NumericDigit *res_digits; @@ -658,7 +657,7 @@ sub_abs(numeric *var1, numeric *var2, numeric *result) * ---------- */ int -PGTYPESnumeric_add(numeric *var1, numeric *var2, numeric *result) +PGTYPESnumeric_add(numeric * var1, numeric * var2, numeric * result) { /* * Decide on the signs of the two variables what to do @@ -677,8 +676,7 @@ PGTYPESnumeric_add(numeric *var1, numeric *var2, numeric *result) else { /* - * var1 is positive, var2 is negative Must compare absolute - * values + * var1 is positive, var2 is negative Must compare absolute values */ switch (cmp_abs(var1, var2)) { @@ -787,7 +785,7 @@ PGTYPESnumeric_add(numeric *var1, numeric *var2, numeric *result) * ---------- */ int -PGTYPESnumeric_sub(numeric *var1, numeric *var2, numeric *result) +PGTYPESnumeric_sub(numeric * var1, numeric * var2, numeric * result) { /* * Decide on the signs of the two variables what to do @@ -918,7 +916,7 @@ PGTYPESnumeric_sub(numeric *var1, numeric *var2, numeric *result) * ---------- */ int -PGTYPESnumeric_mul(numeric *var1, numeric *var2, numeric *result) +PGTYPESnumeric_mul(numeric * var1, numeric * var2, numeric * result) { NumericDigit *res_buf; NumericDigit *res_digits; @@ -1009,7 +1007,7 @@ PGTYPESnumeric_mul(numeric *var1, numeric *var2, numeric *result) * Note that this must be called before div_var. */ static int -select_div_scale(numeric *var1, numeric *var2, int *rscale) +select_div_scale(numeric * var1, numeric * var2, int *rscale) { int weight1, weight2, @@ -1021,8 +1019,8 @@ select_div_scale(numeric *var1, numeric *var2, int *rscale) int res_rscale; /* - * The result scale of a division isn't specified in any SQL standard. - * For PostgreSQL we select a display scale that will give at least + * The result scale of a division isn't specified in any SQL standard. For + * PostgreSQL we select a display scale that will give at least * NUMERIC_MIN_SIG_DIGITS significant digits, so that numeric gives a * result no less accurate than float8; but use a scale not less than * either input's display scale. @@ -1076,7 +1074,7 @@ select_div_scale(numeric *var1, numeric *var2, int *rscale) } int -PGTYPESnumeric_div(numeric *var1, numeric *var2, numeric *result) +PGTYPESnumeric_div(numeric * var1, numeric * var2, numeric * result) { NumericDigit *res_digits; int res_ndigits; @@ -1165,9 +1163,9 @@ PGTYPESnumeric_div(numeric *var1, numeric *var2, numeric *result) memcpy(dividend.digits, var1->digits, var1->ndigits); /* - * Setup the result. Do the allocation in a temporary buffer - * first, so we don't free result->buf unless we have successfully - * allocated a buffer to replace it with. + * Setup the result. Do the allocation in a temporary buffer first, so we + * don't free result->buf unless we have successfully allocated a buffer + * to replace it with. */ tmp_buf = digitbuf_alloc(res_ndigits + 2); if (tmp_buf == NULL) @@ -1284,9 +1282,10 @@ PGTYPESnumeric_div(numeric *var1, numeric *var2, numeric *result) result->sign = NUMERIC_POS; result->dscale = res_dscale; - err = 0; /* if we've made it this far, return success */ + err = 0; /* if we've made it this far, return success */ done: + /* * Tidy up */ @@ -1304,7 +1303,7 @@ done: int -PGTYPESnumeric_cmp(numeric *var1, numeric *var2) +PGTYPESnumeric_cmp(numeric * var1, numeric * var2) { /* use cmp_abs function to calculate the result */ @@ -1317,8 +1316,7 @@ PGTYPESnumeric_cmp(numeric *var1, numeric *var2) if (var1->sign == NUMERIC_NEG && var2->sign == NUMERIC_NEG) { /* - * instead of inverting the result, we invert the paramter - * ordering + * instead of inverting the result, we invert the paramter ordering */ return cmp_abs(var2, var1); } @@ -1335,7 +1333,7 @@ PGTYPESnumeric_cmp(numeric *var1, numeric *var2) } int -PGTYPESnumeric_from_int(signed int int_val, numeric *var) +PGTYPESnumeric_from_int(signed int int_val, numeric * var) { /* implicit conversion */ signed long int long_int = int_val; @@ -1344,14 +1342,14 @@ PGTYPESnumeric_from_int(signed int int_val, numeric *var) } int -PGTYPESnumeric_from_long(signed long int long_val, numeric *var) +PGTYPESnumeric_from_long(signed long int long_val, numeric * var) { /* calculate the size of the long int number */ /* a number n needs log_10 n digits */ /* - * however we multiply by 10 each time and compare instead of - * calculating the logarithm + * however we multiply by 10 each time and compare instead of calculating + * the logarithm */ int size = 0; @@ -1405,8 +1403,8 @@ PGTYPESnumeric_from_long(signed long int long_val, numeric *var) /* * we can abandon if abs_long_val reaches 0, because the memory is - * initialized properly and filled with '0', so converting 10000 - * in only one step is no problem + * initialized properly and filled with '0', so converting 10000 in + * only one step is no problem */ } while (abs_long_val > 0); @@ -1414,7 +1412,7 @@ PGTYPESnumeric_from_long(signed long int long_val, numeric *var) } int -PGTYPESnumeric_copy(numeric *src, numeric *dst) +PGTYPESnumeric_copy(numeric * src, numeric * dst) { int i; @@ -1437,7 +1435,7 @@ PGTYPESnumeric_copy(numeric *src, numeric *dst) } int -PGTYPESnumeric_from_double(double d, numeric *dst) +PGTYPESnumeric_from_double(double d, numeric * dst) { char buffer[100]; numeric *tmp; @@ -1454,7 +1452,7 @@ PGTYPESnumeric_from_double(double d, numeric *dst) } static int -numericvar_to_double_no_overflow(numeric *var, double *dp) +numericvar_to_double_no_overflow(numeric * var, double *dp) { char *tmp; double val; @@ -1478,7 +1476,7 @@ numericvar_to_double_no_overflow(numeric *var, double *dp) } int -PGTYPESnumeric_to_double(numeric *nv, double *dp) +PGTYPESnumeric_to_double(numeric * nv, double *dp) { double tmp; int i; @@ -1490,7 +1488,7 @@ PGTYPESnumeric_to_double(numeric *nv, double *dp) } int -PGTYPESnumeric_to_int(numeric *nv, int *ip) +PGTYPESnumeric_to_int(numeric * nv, int *ip) { long l; int i; @@ -1509,7 +1507,7 @@ PGTYPESnumeric_to_int(numeric *nv, int *ip) } int -PGTYPESnumeric_to_long(numeric *nv, long *lp) +PGTYPESnumeric_to_long(numeric * nv, long *lp) { int i; long l = 0; @@ -1537,7 +1535,7 @@ PGTYPESnumeric_to_long(numeric *nv, long *lp) } int -PGTYPESnumeric_to_decimal(numeric *src, decimal *dst) +PGTYPESnumeric_to_decimal(numeric * src, decimal * dst) { int i; @@ -1560,7 +1558,7 @@ PGTYPESnumeric_to_decimal(numeric *src, decimal *dst) } int -PGTYPESnumeric_from_decimal(decimal *src, numeric *dst) +PGTYPESnumeric_from_decimal(decimal * src, numeric * dst) { int i; diff --git a/src/interfaces/ecpg/pgtypeslib/timestamp.c b/src/interfaces/ecpg/pgtypeslib/timestamp.c index ad40a2903c..ecff91c781 100644 --- a/src/interfaces/ecpg/pgtypeslib/timestamp.c +++ b/src/interfaces/ecpg/pgtypeslib/timestamp.c @@ -24,7 +24,6 @@ time2t(const int hour, const int min, const int sec, const fsec_t fsec) { return (((((hour * MINS_PER_HOUR) + min) * SECS_PER_MINUTE) + sec) * USECS_PER_SEC) + fsec; } /* time2t() */ - #else static double time2t(const int hour, const int min, const int sec, const fsec_t fsec) @@ -52,12 +51,11 @@ dt2local(timestamp dt, int tz) * Returns -1 on failure (overflow). */ int -tm2timestamp(struct tm *tm, fsec_t fsec, int *tzp, timestamp *result) +tm2timestamp(struct tm * tm, fsec_t fsec, int *tzp, timestamp * result) { #ifdef HAVE_INT64_TIMESTAMP int dDate; int64 time; - #else double dDate, time; @@ -141,7 +139,7 @@ dt2time(timestamp jd, int *hour, int *min, int *sec, fsec_t *fsec) * local time zone. If out of this range, leave as GMT. - tgl 97/05/27 */ static int -timestamp2tm(timestamp dt, int *tzp, struct tm *tm, fsec_t *fsec, char **tzn) +timestamp2tm(timestamp dt, int *tzp, struct tm * tm, fsec_t *fsec, char **tzn) { #ifdef HAVE_INT64_TIMESTAMP int64 dDate, @@ -181,7 +179,7 @@ timestamp2tm(timestamp dt, int *tzp, struct tm *tm, fsec_t *fsec, char **tzn) dt2time(time, &tm->tm_hour, &tm->tm_min, &tm->tm_sec, fsec); #else time = dt; - TMODULO(time, dDate, (double)SECS_PER_DAY); + TMODULO(time, dDate, (double) SECS_PER_DAY); if (time < 0) { @@ -206,7 +204,7 @@ recalc_t: if (*fsec >= 1.0) { time = ceil(time); - if (time >= (double)SECS_PER_DAY) + if (time >= (double) SECS_PER_DAY) { time = 0; dDate += 1; @@ -244,7 +242,7 @@ recalc_t: tm->tm_gmtoff = tx->tm_gmtoff; tm->tm_zone = tx->tm_zone; - *tzp = -tm->tm_gmtoff; /* tm_gmtoff is Sun/DEC-ism */ + *tzp = -tm->tm_gmtoff; /* tm_gmtoff is Sun/DEC-ism */ if (tzn != NULL) *tzn = (char *) tm->tm_zone; #elif defined(HAVE_INT_TIMEZONE) @@ -252,7 +250,6 @@ recalc_t: if (tzn != NULL) *tzn = TZNAME_GLOBAL[(tm->tm_isdst > 0)]; #endif - #else /* not (HAVE_TM_ZONE || HAVE_INT_TIMEZONE) */ *tzp = 0; /* Mark this as *no* time zone available */ @@ -367,8 +364,8 @@ PGTYPEStimestamp_from_asc(char *str, char **endptr) /* AdjustTimestampForTypmod(&result, typmod); */ /* - * Since it's difficult to test for noresult, make sure errno is 0 if - * no error occured. + * Since it's difficult to test for noresult, make sure errno is 0 if no + * error occured. */ errno = 0; return result; @@ -382,8 +379,8 @@ PGTYPEStimestamp_to_asc(timestamp tstamp) char buf[MAXDATELEN + 1]; char *tzn = NULL; fsec_t fsec; - int DateStyle = 1; /* this defaults to ISO_DATES, shall we - * make it an option? */ + int DateStyle = 1; /* this defaults to ISO_DATES, shall we make + * it an option? */ if (TIMESTAMP_NOT_FINITE(tstamp)) EncodeSpecialTimestamp(tstamp, buf); @@ -398,7 +395,7 @@ PGTYPEStimestamp_to_asc(timestamp tstamp) } void -PGTYPEStimestamp_current(timestamp *ts) +PGTYPEStimestamp_current(timestamp * ts) { struct tm tm; @@ -408,7 +405,7 @@ PGTYPEStimestamp_current(timestamp *ts) } static int -dttofmtasc_replace(timestamp *ts, date dDate, int dow, struct tm *tm, +dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm, char *output, int *pstr_len, char *fmtstr) { union un_fmt_comb replace_val; @@ -457,8 +454,7 @@ dttofmtasc_replace(timestamp *ts, date dDate, int dow, struct tm *tm, case 'D': /* - * ts, dDate, dow, tm is information about the - * timestamp + * ts, dDate, dow, tm is information about the timestamp * * q is the start of the current output buffer * @@ -518,8 +514,8 @@ dttofmtasc_replace(timestamp *ts, date dDate, int dow, struct tm *tm, case 'g': /* XXX: fall back to strftime */ { - char *fmt = "%g"; /* Keep compiler quiet - * about 2-digit year */ + char *fmt = "%g"; /* Keep compiler quiet about + * 2-digit year */ tm->tm_mon -= 1; i = strftime(q, *pstr_len, fmt, tm); @@ -671,8 +667,8 @@ dttofmtasc_replace(timestamp *ts, date dDate, int dow, struct tm *tm, case 'x': /* XXX: fall back to strftime */ { - char *fmt = "%x"; /* Keep compiler quiet - * about 2-digit year */ + char *fmt = "%x"; /* Keep compiler quiet about + * 2-digit year */ tm->tm_mon -= 1; i = strftime(q, *pstr_len, fmt, tm); @@ -798,7 +794,7 @@ dttofmtasc_replace(timestamp *ts, date dDate, int dow, struct tm *tm, int -PGTYPEStimestamp_fmt_asc(timestamp *ts, char *output, int str_len, char *fmtstr) +PGTYPEStimestamp_fmt_asc(timestamp * ts, char *output, int str_len, char *fmtstr) { struct tm tm; fsec_t fsec; @@ -813,7 +809,7 @@ PGTYPEStimestamp_fmt_asc(timestamp *ts, char *output, int str_len, char *fmtstr) } int -PGTYPEStimestamp_sub(timestamp *ts1, timestamp *ts2, interval *iv) +PGTYPEStimestamp_sub(timestamp * ts1, timestamp * ts2, interval * iv) { if (TIMESTAMP_NOT_FINITE(*ts1) || TIMESTAMP_NOT_FINITE(*ts2)) return PGTYPES_TS_ERR_EINFTIME; @@ -826,7 +822,7 @@ PGTYPEStimestamp_sub(timestamp *ts1, timestamp *ts2, interval *iv) } int -PGTYPEStimestamp_defmt_asc(char *str, char *fmt, timestamp *d) +PGTYPEStimestamp_defmt_asc(char *str, char *fmt, timestamp * d) { int year, month, @@ -870,83 +866,82 @@ PGTYPEStimestamp_defmt_asc(char *str, char *fmt, timestamp *d) /* * add an interval to a time stamp * -* *tout = tin + span +* *tout = tin + span * -* returns 0 if successful -* returns -1 if it fails +* returns 0 if successful +* returns -1 if it fails * */ - + int -PGTYPEStimestamp_add_interval(timestamp *tin, interval *span, timestamp *tout) +PGTYPEStimestamp_add_interval(timestamp * tin, interval * span, timestamp * tout) { - - - if (TIMESTAMP_NOT_FINITE(*tin)) - *tout = *tin; - - - else - { - if (span->month != 0) - { - struct tm tt, - *tm = &tt; - fsec_t fsec; - - - if (timestamp2tm(*tin, NULL, tm, &fsec, NULL) !=0) - return -1; - tm->tm_mon += span->month; - if (tm->tm_mon > MONTHS_PER_YEAR) - { - tm->tm_year += (tm->tm_mon - 1) / MONTHS_PER_YEAR; - tm->tm_mon = (tm->tm_mon - 1) % MONTHS_PER_YEAR + 1; - } - else if (tm->tm_mon < 1) - { - tm->tm_year += tm->tm_mon / MONTHS_PER_YEAR - 1; - tm->tm_mon = tm->tm_mon % MONTHS_PER_YEAR + MONTHS_PER_YEAR; - } - - - /* adjust for end of month boundary problems... */ - if (tm->tm_mday > day_tab[isleap(tm->tm_year)][tm->tm_mon - 1]) - tm->tm_mday = (day_tab[isleap(tm->tm_year)][tm->tm_mon - 1]); - - - if (tm2timestamp(tm, fsec, NULL, tin) !=0) - return -1; - } - - - *tin +=span->time; - *tout = *tin; - } - return 0; - + + + if (TIMESTAMP_NOT_FINITE(*tin)) + *tout = *tin; + + + else + { + if (span->month != 0) + { + struct tm tt, + *tm = &tt; + fsec_t fsec; + + + if (timestamp2tm(*tin, NULL, tm, &fsec, NULL) != 0) + return -1; + tm->tm_mon += span->month; + if (tm->tm_mon > MONTHS_PER_YEAR) + { + tm->tm_year += (tm->tm_mon - 1) / MONTHS_PER_YEAR; + tm->tm_mon = (tm->tm_mon - 1) % MONTHS_PER_YEAR + 1; + } + else if (tm->tm_mon < 1) + { + tm->tm_year += tm->tm_mon / MONTHS_PER_YEAR - 1; + tm->tm_mon = tm->tm_mon % MONTHS_PER_YEAR + MONTHS_PER_YEAR; + } + + + /* adjust for end of month boundary problems... */ + if (tm->tm_mday > day_tab[isleap(tm->tm_year)][tm->tm_mon - 1]) + tm->tm_mday = (day_tab[isleap(tm->tm_year)][tm->tm_mon - 1]); + + + if (tm2timestamp(tm, fsec, NULL, tin) != 0) + return -1; + } + + + *tin += span->time; + *tout = *tin; + } + return 0; + } - - + + /* * subtract an interval from a time stamp * -* *tout = tin - span +* *tout = tin - span * -* returns 0 if successful -* returns -1 if it fails +* returns 0 if successful +* returns -1 if it fails * */ - -int -PGTYPEStimestamp_sub_interval(timestamp *tin, interval *span, timestamp *tout) -{ - interval tspan; - - tspan.month = -span->month; - tspan.time = -span->time; - - - return PGTYPEStimestamp_add_interval(tin, &tspan, tout ); -} +int +PGTYPEStimestamp_sub_interval(timestamp * tin, interval * span, timestamp * tout) +{ + interval tspan; + + tspan.month = -span->month; + tspan.time = -span->time; + + + return PGTYPEStimestamp_add_interval(tin, &tspan, tout); +} diff --git a/src/interfaces/ecpg/preproc/ecpg.c b/src/interfaces/ecpg/preproc/ecpg.c index 761c35fb2d..41625fa758 100644 --- a/src/interfaces/ecpg/preproc/ecpg.c +++ b/src/interfaces/ecpg/preproc/ecpg.c @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.92 2005/08/29 01:32:00 tgl Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.93 2005/10/15 02:49:47 momjian Exp $ */ /* New main for ecpg, the PostgreSQL embedded SQL precompiler. */ /* (C) Michael Meskes Feb 5th, 1998 */ @@ -43,7 +43,7 @@ help(const char *progname) printf(" -c automatically generate C code from embedded SQL code;\n" " currently this works for EXEC SQL TYPE\n"); printf(" -C MODE set compatibility mode;\n" - " MODE may be one of \"INFORMIX\", \"INFORMIX_SE\"\n"); + " MODE may be one of \"INFORMIX\", \"INFORMIX_SE\"\n"); #ifdef YYDEBUG printf(" -d generate parser debug output\n"); #endif @@ -431,8 +431,8 @@ main(int argc, char *const argv[]) if (!(ptr->opened)) { /* - * Does not really make sense to declare a cursor - * but not open it + * Does not really make sense to declare a cursor but + * not open it */ snprintf(errortext, sizeof(errortext), "cursor \"%s\" has been declared but not opened\n", ptr->name); mmerror(PARSE_ERROR, ET_WARNING, errortext); diff --git a/src/interfaces/ecpg/preproc/ecpg_keywords.c b/src/interfaces/ecpg/preproc/ecpg_keywords.c index 6594ada2d2..cd4f8668a7 100644 --- a/src/interfaces/ecpg/preproc/ecpg_keywords.c +++ b/src/interfaces/ecpg/preproc/ecpg_keywords.c @@ -4,7 +4,7 @@ * lexical token lookup for reserved words in postgres embedded SQL * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg_keywords.c,v 1.30 2004/09/27 09:59:17 meskes Exp $ + * $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg_keywords.c,v 1.31 2005/10/15 02:49:47 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -63,8 +63,8 @@ static ScanKeyword ScanKeywords[] = { {"section", SQL_SECTION}, {"short", SQL_SHORT}, {"signed", SQL_SIGNED}, - {"sql", SQL_SQL}, /* strange thing, used for into sql - * descriptor MYDESC; */ + {"sql", SQL_SQL}, /* strange thing, used for into sql descriptor + * MYDESC; */ {"sqlerror", SQL_SQLERROR}, {"sqlprint", SQL_SQLPRINT}, {"sqlwarning", SQL_SQLWARNING}, @@ -103,12 +103,12 @@ ScanECPGKeywordLookup(char *text) return NULL; /* - * Apply an ASCII-only downcasing. We must not use tolower() since it - * may produce the wrong translation in some locales (eg, Turkish), - * and we don't trust isupper() very much either. In an ASCII-based - * encoding the tests against A and Z are sufficient, but we also - * check isupper() so that we will work correctly under EBCDIC. The - * actual case conversion step should work for either ASCII or EBCDIC. + * Apply an ASCII-only downcasing. We must not use tolower() since it may + * produce the wrong translation in some locales (eg, Turkish), and we + * don't trust isupper() very much either. In an ASCII-based encoding the + * tests against A and Z are sufficient, but we also check isupper() so + * that we will work correctly under EBCDIC. The actual case conversion + * step should work for either ASCII or EBCDIC. */ for (i = 0; i < len; i++) { diff --git a/src/interfaces/ecpg/preproc/keywords.c b/src/interfaces/ecpg/preproc/keywords.c index 08f960a600..06d9596790 100644 --- a/src/interfaces/ecpg/preproc/keywords.c +++ b/src/interfaces/ecpg/preproc/keywords.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/keywords.c,v 1.69 2005/10/04 13:28:21 meskes Exp $ + * $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/keywords.c,v 1.70 2005/10/15 02:49:47 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -43,322 +43,322 @@ static ScanKeyword ScanKeywords[] = { {"analyze", ANALYZE}, {"and", AND}, {"any", ANY}, - {"array", ARRAY}, - {"as", AS}, - {"asc", ASC}, - {"assertion", ASSERTION}, - {"assignment", ASSIGNMENT}, - {"asymmetric", ASYMMETRIC}, - {"at", AT}, - {"authorization", AUTHORIZATION}, - {"backward", BACKWARD}, - {"before", BEFORE}, - {"begin", BEGIN_P}, - {"between", BETWEEN}, - {"bigint", BIGINT}, - {"binary", BINARY}, - {"bit", BIT}, - {"boolean", BOOLEAN_P}, - {"both", BOTH}, - {"by", BY}, - {"cache", CACHE}, - {"called", CALLED}, - {"cascade", CASCADE}, - {"case", CASE}, - {"cast", CAST}, - {"chain", CHAIN}, - {"char", CHAR_P}, - {"character", CHARACTER}, - {"characteristics", CHARACTERISTICS}, - {"check", CHECK}, - {"checkpoint", CHECKPOINT}, - {"class", CLASS}, - {"close", CLOSE}, - {"cluster", CLUSTER}, - {"coalesce", COALESCE}, - {"collate", COLLATE}, - {"column", COLUMN}, - {"comment", COMMENT}, - {"commit", COMMIT}, - {"committed", COMMITTED}, - {"connection", CONNECTION}, - {"constraint", CONSTRAINT}, - {"constraints", CONSTRAINTS}, - {"conversion", CONVERSION_P}, - {"convert", CONVERT}, - {"copy", COPY}, - {"create", CREATE}, - {"createdb", CREATEDB}, - {"createrole", CREATEROLE}, - {"createuser", CREATEUSER}, - {"cross", CROSS}, - {"csv", CSV}, - {"current_date", CURRENT_DATE}, - {"current_role", CURRENT_ROLE}, - {"current_time", CURRENT_TIME}, - {"current_timestamp", CURRENT_TIMESTAMP}, - {"cursor", CURSOR}, - {"cycle", CYCLE}, - {"database", DATABASE}, - {"day", DAY_P}, - {"deallocate", DEALLOCATE}, - {"dec", DEC}, - {"decimal", DECIMAL_P}, - {"declare", DECLARE}, - {"default", DEFAULT}, - {"defaults", DEFAULTS}, - {"deferrable", DEFERRABLE}, - {"deferred", DEFERRED}, - {"definer", DEFINER}, - {"delete", DELETE_P}, - {"delimiter", DELIMITER}, - {"delimiters", DELIMITERS}, - {"desc", DESC}, - {"disable", DISABLE_P}, - {"distinct", DISTINCT}, - {"do", DO}, - {"domain", DOMAIN_P}, - {"double", DOUBLE_P}, - {"drop", DROP}, - {"each", EACH}, - {"else", ELSE}, - {"enable", ENABLE_P}, - {"encoding", ENCODING}, - {"encrypted", ENCRYPTED}, - {"end", END_P}, - {"escape", ESCAPE}, - {"except", EXCEPT}, - {"excluding", EXCLUDING}, - {"exclusive", EXCLUSIVE}, - {"execute", EXECUTE}, - {"exists", EXISTS}, - {"explain", EXPLAIN}, - {"external", EXTERNAL}, - {"extract", EXTRACT}, - {"false", FALSE_P}, - {"fetch", FETCH}, - {"first", FIRST_P}, - {"float", FLOAT_P}, - {"for", FOR}, - {"force", FORCE}, - {"foreign", FOREIGN}, - {"forward", FORWARD}, - {"freeze", FREEZE}, - {"from", FROM}, - {"full", FULL}, - {"function", FUNCTION}, - {"get", GET}, - {"global", GLOBAL}, - {"grant", GRANT}, - {"granted", GRANTED}, - {"greatest", GREATEST}, - {"group", GROUP_P}, - {"handler", HANDLER}, - {"having", HAVING}, - {"header", HEADER}, - {"hold", HOLD}, - {"hour", HOUR_P}, - {"ilike", ILIKE}, - {"immediate", IMMEDIATE}, - {"immutable", IMMUTABLE}, - {"implicit", IMPLICIT_P}, - {"in", IN_P}, - {"including", INCLUDING}, - {"increment", INCREMENT}, - {"index", INDEX}, - {"inherit", INHERIT}, - {"inherits", INHERITS}, - {"initially", INITIALLY}, - {"inner", INNER_P}, - {"inout", INOUT}, - {"input", INPUT_P}, - {"insensitive", INSENSITIVE}, - {"insert", INSERT}, - {"instead", INSTEAD}, - {"int", INT_P}, - {"integer", INTEGER}, - {"intersect", INTERSECT}, - {"interval", INTERVAL}, - {"into", INTO}, - {"invoker", INVOKER}, - {"is", IS}, - {"isnull", ISNULL}, - {"isolation", ISOLATION}, - {"join", JOIN}, - {"key", KEY}, - {"lancompiler", LANCOMPILER}, - {"language", LANGUAGE}, - {"large", LARGE_P}, - {"last", LAST_P}, - {"leading", LEADING}, - {"least", LEAST}, - {"left", LEFT}, - {"level", LEVEL}, - {"like", LIKE}, - {"limit", LIMIT}, - {"listen", LISTEN}, - {"load", LOAD}, - {"local", LOCAL}, - {"location", LOCATION}, - {"lock", LOCK_P}, - {"login", LOGIN_P}, - {"match", MATCH}, - {"maxvalue", MAXVALUE}, - {"minute", MINUTE_P}, - {"minvalue", MINVALUE}, - {"mode", MODE}, - {"month", MONTH_P}, - {"move", MOVE}, - {"names", NAMES}, - {"national", NATIONAL}, - {"natural", NATURAL}, - {"nchar", NCHAR}, - {"new", NEW}, - {"next", NEXT}, - {"no", NO}, - {"nocreatedb", NOCREATEDB}, - {"nocreaterole", NOCREATEROLE}, - {"nocreateuser", NOCREATEUSER}, - {"noinherit", NOINHERIT}, - {"nologin", NOLOGIN_P}, - {"none", NONE}, - {"nosuperuser", NOSUPERUSER}, - {"not", NOT}, - {"nothing", NOTHING}, - {"notify", NOTIFY}, - {"notnull", NOTNULL}, - {"nowait", NOWAIT}, - {"null", NULL_P}, - {"nullif", NULLIF}, - {"numeric", NUMERIC}, - {"object", OBJECT_P}, - {"of", OF}, - {"off", OFF}, - {"offset", OFFSET}, - {"oids", OIDS}, - {"old", OLD}, - {"on", ON}, - {"only", ONLY}, - {"operator", OPERATOR}, - {"option", OPTION}, - {"or", OR}, - {"order", ORDER}, - {"out", OUT_P}, - {"outer", OUTER_P}, - {"overlaps", OVERLAPS}, - {"owner", OWNER}, - {"partial", PARTIAL}, - {"password", PASSWORD}, - {"position", POSITION}, - {"precision", PRECISION}, - {"prepare", PREPARE}, - {"prepared", PREPARED}, - {"preserve", PRESERVE}, - {"primary", PRIMARY}, - {"prior", PRIOR}, - {"privileges", PRIVILEGES}, - {"procedural", PROCEDURAL}, - {"procedure", PROCEDURE}, - {"quote", QUOTE}, - {"read", READ}, - {"real", REAL}, - {"recheck", RECHECK}, - {"references", REFERENCES}, - {"reindex", REINDEX}, - {"relative", RELATIVE_P}, - {"release", RELEASE}, - {"rename", RENAME}, - {"repeatable", REPEATABLE}, - {"replace", REPLACE}, - {"reset", RESET}, - {"restart", RESTART}, - {"restrict", RESTRICT}, - {"returns", RETURNS}, - {"revoke", REVOKE}, - {"right", RIGHT}, - {"role", ROLE}, - {"rollback", ROLLBACK}, - {"row", ROW}, - {"rows", ROWS}, - {"rule", RULE}, - {"savepoint", SAVEPOINT}, - {"schema", SCHEMA}, - {"scroll", SCROLL}, - {"second", SECOND_P}, - {"security", SECURITY}, - {"select", SELECT}, - {"sequence", SEQUENCE}, - {"serializable", SERIALIZABLE}, - {"session", SESSION}, - {"session_user", SESSION_USER}, - {"set", SET}, - {"setof", SETOF}, - {"share", SHARE}, - {"show", SHOW}, - {"similar", SIMILAR}, - {"simple", SIMPLE}, - {"smallint", SMALLINT}, - {"some", SOME}, - {"stable", STABLE}, - {"start", START}, - {"statement", STATEMENT}, - {"statistics", STATISTICS}, - {"stdin", STDIN}, - {"stdout", STDOUT}, - {"storage", STORAGE}, - {"strict", STRICT_P}, - {"substring", SUBSTRING}, - {"superuser", SUPERUSER_P}, - {"symmetric", SYMMETRIC}, - {"sysid", SYSID}, - {"system", SYSTEM_P}, - {"table", TABLE}, - {"tablespace", TABLESPACE}, - {"temp", TEMP}, - {"template", TEMPLATE}, - {"temporary", TEMPORARY}, - {"then", THEN}, - {"time", TIME}, - {"timestamp", TIMESTAMP}, - {"to", TO}, - {"toast", TOAST}, - {"trailing", TRAILING}, - {"transaction", TRANSACTION}, - {"treat", TREAT}, - {"trigger", TRIGGER}, - {"trim", TRIM}, - {"true", TRUE_P}, - {"truncate", TRUNCATE}, - {"trusted", TRUSTED}, - {"type", TYPE_P}, - {"uncommitted", UNCOMMITTED}, - {"unencrypted", UNENCRYPTED}, - {"union", UNION}, - {"unique", UNIQUE}, - {"unknown", UNKNOWN}, - {"unlisten", UNLISTEN}, - {"until", UNTIL}, - {"update", UPDATE}, - {"user", USER}, - {"using", USING}, - {"vacuum", VACUUM}, - {"valid", VALID}, - {"validator", VALIDATOR}, - {"values", VALUES}, - {"varchar", VARCHAR}, - {"varying", VARYING}, - {"verbose", VERBOSE}, - {"view", VIEW}, - {"volatile", VOLATILE}, - {"when", WHEN}, - {"where", WHERE}, - {"with", WITH}, - {"without", WITHOUT}, - {"work", WORK}, - {"write", WRITE}, - {"year", YEAR_P}, - {"zone", ZONE}, - }; + {"array", ARRAY}, + {"as", AS}, + {"asc", ASC}, + {"assertion", ASSERTION}, + {"assignment", ASSIGNMENT}, + {"asymmetric", ASYMMETRIC}, + {"at", AT}, + {"authorization", AUTHORIZATION}, + {"backward", BACKWARD}, + {"before", BEFORE}, + {"begin", BEGIN_P}, + {"between", BETWEEN}, + {"bigint", BIGINT}, + {"binary", BINARY}, + {"bit", BIT}, + {"boolean", BOOLEAN_P}, + {"both", BOTH}, + {"by", BY}, + {"cache", CACHE}, + {"called", CALLED}, + {"cascade", CASCADE}, + {"case", CASE}, + {"cast", CAST}, + {"chain", CHAIN}, + {"char", CHAR_P}, + {"character", CHARACTER}, + {"characteristics", CHARACTERISTICS}, + {"check", CHECK}, + {"checkpoint", CHECKPOINT}, + {"class", CLASS}, + {"close", CLOSE}, + {"cluster", CLUSTER}, + {"coalesce", COALESCE}, + {"collate", COLLATE}, + {"column", COLUMN}, + {"comment", COMMENT}, + {"commit", COMMIT}, + {"committed", COMMITTED}, + {"connection", CONNECTION}, + {"constraint", CONSTRAINT}, + {"constraints", CONSTRAINTS}, + {"conversion", CONVERSION_P}, + {"convert", CONVERT}, + {"copy", COPY}, + {"create", CREATE}, + {"createdb", CREATEDB}, + {"createrole", CREATEROLE}, + {"createuser", CREATEUSER}, + {"cross", CROSS}, + {"csv", CSV}, + {"current_date", CURRENT_DATE}, + {"current_role", CURRENT_ROLE}, + {"current_time", CURRENT_TIME}, + {"current_timestamp", CURRENT_TIMESTAMP}, + {"cursor", CURSOR}, + {"cycle", CYCLE}, + {"database", DATABASE}, + {"day", DAY_P}, + {"deallocate", DEALLOCATE}, + {"dec", DEC}, + {"decimal", DECIMAL_P}, + {"declare", DECLARE}, + {"default", DEFAULT}, + {"defaults", DEFAULTS}, + {"deferrable", DEFERRABLE}, + {"deferred", DEFERRED}, + {"definer", DEFINER}, + {"delete", DELETE_P}, + {"delimiter", DELIMITER}, + {"delimiters", DELIMITERS}, + {"desc", DESC}, + {"disable", DISABLE_P}, + {"distinct", DISTINCT}, + {"do", DO}, + {"domain", DOMAIN_P}, + {"double", DOUBLE_P}, + {"drop", DROP}, + {"each", EACH}, + {"else", ELSE}, + {"enable", ENABLE_P}, + {"encoding", ENCODING}, + {"encrypted", ENCRYPTED}, + {"end", END_P}, + {"escape", ESCAPE}, + {"except", EXCEPT}, + {"excluding", EXCLUDING}, + {"exclusive", EXCLUSIVE}, + {"execute", EXECUTE}, + {"exists", EXISTS}, + {"explain", EXPLAIN}, + {"external", EXTERNAL}, + {"extract", EXTRACT}, + {"false", FALSE_P}, + {"fetch", FETCH}, + {"first", FIRST_P}, + {"float", FLOAT_P}, + {"for", FOR}, + {"force", FORCE}, + {"foreign", FOREIGN}, + {"forward", FORWARD}, + {"freeze", FREEZE}, + {"from", FROM}, + {"full", FULL}, + {"function", FUNCTION}, + {"get", GET}, + {"global", GLOBAL}, + {"grant", GRANT}, + {"granted", GRANTED}, + {"greatest", GREATEST}, + {"group", GROUP_P}, + {"handler", HANDLER}, + {"having", HAVING}, + {"header", HEADER}, + {"hold", HOLD}, + {"hour", HOUR_P}, + {"ilike", ILIKE}, + {"immediate", IMMEDIATE}, + {"immutable", IMMUTABLE}, + {"implicit", IMPLICIT_P}, + {"in", IN_P}, + {"including", INCLUDING}, + {"increment", INCREMENT}, + {"index", INDEX}, + {"inherit", INHERIT}, + {"inherits", INHERITS}, + {"initially", INITIALLY}, + {"inner", INNER_P}, + {"inout", INOUT}, + {"input", INPUT_P}, + {"insensitive", INSENSITIVE}, + {"insert", INSERT}, + {"instead", INSTEAD}, + {"int", INT_P}, + {"integer", INTEGER}, + {"intersect", INTERSECT}, + {"interval", INTERVAL}, + {"into", INTO}, + {"invoker", INVOKER}, + {"is", IS}, + {"isnull", ISNULL}, + {"isolation", ISOLATION}, + {"join", JOIN}, + {"key", KEY}, + {"lancompiler", LANCOMPILER}, + {"language", LANGUAGE}, + {"large", LARGE_P}, + {"last", LAST_P}, + {"leading", LEADING}, + {"least", LEAST}, + {"left", LEFT}, + {"level", LEVEL}, + {"like", LIKE}, + {"limit", LIMIT}, + {"listen", LISTEN}, + {"load", LOAD}, + {"local", LOCAL}, + {"location", LOCATION}, + {"lock", LOCK_P}, + {"login", LOGIN_P}, + {"match", MATCH}, + {"maxvalue", MAXVALUE}, + {"minute", MINUTE_P}, + {"minvalue", MINVALUE}, + {"mode", MODE}, + {"month", MONTH_P}, + {"move", MOVE}, + {"names", NAMES}, + {"national", NATIONAL}, + {"natural", NATURAL}, + {"nchar", NCHAR}, + {"new", NEW}, + {"next", NEXT}, + {"no", NO}, + {"nocreatedb", NOCREATEDB}, + {"nocreaterole", NOCREATEROLE}, + {"nocreateuser", NOCREATEUSER}, + {"noinherit", NOINHERIT}, + {"nologin", NOLOGIN_P}, + {"none", NONE}, + {"nosuperuser", NOSUPERUSER}, + {"not", NOT}, + {"nothing", NOTHING}, + {"notify", NOTIFY}, + {"notnull", NOTNULL}, + {"nowait", NOWAIT}, + {"null", NULL_P}, + {"nullif", NULLIF}, + {"numeric", NUMERIC}, + {"object", OBJECT_P}, + {"of", OF}, + {"off", OFF}, + {"offset", OFFSET}, + {"oids", OIDS}, + {"old", OLD}, + {"on", ON}, + {"only", ONLY}, + {"operator", OPERATOR}, + {"option", OPTION}, + {"or", OR}, + {"order", ORDER}, + {"out", OUT_P}, + {"outer", OUTER_P}, + {"overlaps", OVERLAPS}, + {"owner", OWNER}, + {"partial", PARTIAL}, + {"password", PASSWORD}, + {"position", POSITION}, + {"precision", PRECISION}, + {"prepare", PREPARE}, + {"prepared", PREPARED}, + {"preserve", PRESERVE}, + {"primary", PRIMARY}, + {"prior", PRIOR}, + {"privileges", PRIVILEGES}, + {"procedural", PROCEDURAL}, + {"procedure", PROCEDURE}, + {"quote", QUOTE}, + {"read", READ}, + {"real", REAL}, + {"recheck", RECHECK}, + {"references", REFERENCES}, + {"reindex", REINDEX}, + {"relative", RELATIVE_P}, + {"release", RELEASE}, + {"rename", RENAME}, + {"repeatable", REPEATABLE}, + {"replace", REPLACE}, + {"reset", RESET}, + {"restart", RESTART}, + {"restrict", RESTRICT}, + {"returns", RETURNS}, + {"revoke", REVOKE}, + {"right", RIGHT}, + {"role", ROLE}, + {"rollback", ROLLBACK}, + {"row", ROW}, + {"rows", ROWS}, + {"rule", RULE}, + {"savepoint", SAVEPOINT}, + {"schema", SCHEMA}, + {"scroll", SCROLL}, + {"second", SECOND_P}, + {"security", SECURITY}, + {"select", SELECT}, + {"sequence", SEQUENCE}, + {"serializable", SERIALIZABLE}, + {"session", SESSION}, + {"session_user", SESSION_USER}, + {"set", SET}, + {"setof", SETOF}, + {"share", SHARE}, + {"show", SHOW}, + {"similar", SIMILAR}, + {"simple", SIMPLE}, + {"smallint", SMALLINT}, + {"some", SOME}, + {"stable", STABLE}, + {"start", START}, + {"statement", STATEMENT}, + {"statistics", STATISTICS}, + {"stdin", STDIN}, + {"stdout", STDOUT}, + {"storage", STORAGE}, + {"strict", STRICT_P}, + {"substring", SUBSTRING}, + {"superuser", SUPERUSER_P}, + {"symmetric", SYMMETRIC}, + {"sysid", SYSID}, + {"system", SYSTEM_P}, + {"table", TABLE}, + {"tablespace", TABLESPACE}, + {"temp", TEMP}, + {"template", TEMPLATE}, + {"temporary", TEMPORARY}, + {"then", THEN}, + {"time", TIME}, + {"timestamp", TIMESTAMP}, + {"to", TO}, + {"toast", TOAST}, + {"trailing", TRAILING}, + {"transaction", TRANSACTION}, + {"treat", TREAT}, + {"trigger", TRIGGER}, + {"trim", TRIM}, + {"true", TRUE_P}, + {"truncate", TRUNCATE}, + {"trusted", TRUSTED}, + {"type", TYPE_P}, + {"uncommitted", UNCOMMITTED}, + {"unencrypted", UNENCRYPTED}, + {"union", UNION}, + {"unique", UNIQUE}, + {"unknown", UNKNOWN}, + {"unlisten", UNLISTEN}, + {"until", UNTIL}, + {"update", UPDATE}, + {"user", USER}, + {"using", USING}, + {"vacuum", VACUUM}, + {"valid", VALID}, + {"validator", VALIDATOR}, + {"values", VALUES}, + {"varchar", VARCHAR}, + {"varying", VARYING}, + {"verbose", VERBOSE}, + {"view", VIEW}, + {"volatile", VOLATILE}, + {"when", WHEN}, + {"where", WHERE}, + {"with", WITH}, + {"without", WITHOUT}, + {"work", WORK}, + {"write", WRITE}, + {"year", YEAR_P}, + {"zone", ZONE}, +}; /* * ScanKeywordLookup - see if a given word is a keyword @@ -372,54 +372,53 @@ static ScanKeyword ScanKeywords[] = { * keywords are to be matched in this way even though non-keyword identifiers * receive a different case-normalization mapping. */ - ScanKeyword * - ScanKeywordLookup(char *text) - { - int len, - i; - char word[NAMEDATALEN]; - ScanKeyword *low; - ScanKeyword *high; - - len = strlen(text); - /* We assume all keywords are shorter than NAMEDATALEN. */ - if (len >= NAMEDATALEN) - return NULL; - - /* - * Apply an ASCII-only downcasing. We must not use tolower() - * since it may produce the wrong translation in some locales (eg, - * Turkish). - */ - for (i = 0; i < len; i++) - { - char ch = text[i]; - - if (ch >= 'A' && ch <= 'Z') - ch += 'a' - 'A'; - word[i] = ch; - } - word[len] = '\0'; - - /* - * Now do a binary search using plain strcmp() comparison. - */ - low = &ScanKeywords[0]; - high = endof(ScanKeywords) - 1; - while (low <= high) - { - ScanKeyword *middle; - int difference; - - middle = low + (high - low) / 2; - difference = strcmp(middle->name, word); - if (difference == 0) - return middle; - else if (difference < 0) - low = middle + 1; - else - high = middle - 1; - } +ScanKeyword * +ScanKeywordLookup(char *text) +{ + int len, + i; + char word[NAMEDATALEN]; + ScanKeyword *low; + ScanKeyword *high; + len = strlen(text); + /* We assume all keywords are shorter than NAMEDATALEN. */ + if (len >= NAMEDATALEN) return NULL; + + /* + * Apply an ASCII-only downcasing. We must not use tolower() since it may + * produce the wrong translation in some locales (eg, Turkish). + */ + for (i = 0; i < len; i++) + { + char ch = text[i]; + + if (ch >= 'A' && ch <= 'Z') + ch += 'a' - 'A'; + word[i] = ch; } + word[len] = '\0'; + + /* + * Now do a binary search using plain strcmp() comparison. + */ + low = &ScanKeywords[0]; + high = endof(ScanKeywords) - 1; + while (low <= high) + { + ScanKeyword *middle; + int difference; + + middle = low + (high - low) / 2; + difference = strcmp(middle->name, word); + if (difference == 0) + return middle; + else if (difference < 0) + low = middle + 1; + else + high = middle - 1; + } + + return NULL; +} diff --git a/src/interfaces/ecpg/preproc/type.c b/src/interfaces/ecpg/preproc/type.c index acd2faf83d..392120cf10 100644 --- a/src/interfaces/ecpg/preproc/type.c +++ b/src/interfaces/ecpg/preproc/type.c @@ -173,8 +173,7 @@ get_type(enum ECPGttype type) 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; case ECPGt_const: /* constant string quoted */ @@ -257,7 +256,7 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type, ECPGdump_a_simple(o, name, type->u.element->type, - type->u.element->size, type->size, NULL, prefix); + type->u.element->size, type->size, NULL, prefix); if (ind_type != NULL) { @@ -358,7 +357,7 @@ ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype type, */ if ((atoi(varcharsize) > 1 || (atoi(arrsize) > 0) || - (atoi(varcharsize) == 0 && strcmp(varcharsize, "0") != 0) || + (atoi(varcharsize) == 0 && strcmp(varcharsize, "0") != 0) || (atoi(arrsize) == 0 && strcmp(arrsize, "0") != 0)) && siz == NULL) sprintf(variable, "(%s%s)", prefix ? prefix : "", name); @@ -386,8 +385,7 @@ ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype type, case ECPGt_date: /* - * we have to use a pointer and translate the variable - * type + * we have to use a pointer and translate the variable type */ sprintf(variable, "&(%s%s)", prefix ? prefix : "", name); sprintf(offset, "sizeof(date)"); @@ -395,8 +393,7 @@ ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype type, case ECPGt_timestamp: /* - * we have to use a pointer and translate the variable - * type + * we have to use a pointer and translate the variable type */ sprintf(variable, "&(%s%s)", prefix ? prefix : "", name); sprintf(offset, "sizeof(timestamp)"); @@ -445,9 +442,8 @@ static void ECPGdump_a_struct(FILE *o, const char *name, const char *ind_name, char *arrsiz, struct ECPGtype * type, struct ECPGtype * ind_type, const char *offsetarg, const char *prefix, const char *ind_prefix) { /* - * If offset is NULL, then this is the first recursive level. If not - * then we are in a struct in a struct and the offset is used as - * offset. + * If offset is NULL, then this is the first recursive level. If not then + * we are in a struct in a struct and the offset is used as offset. */ struct ECPGstruct_member *p, *ind_p = NULL; diff --git a/src/interfaces/ecpg/preproc/type.h b/src/interfaces/ecpg/preproc/type.h index 1a5471fe15..020e6b4fde 100644 --- a/src/interfaces/ecpg/preproc/type.h +++ b/src/interfaces/ecpg/preproc/type.h @@ -14,15 +14,14 @@ struct ECPGstruct_member struct ECPGtype { enum ECPGttype type; - char *size; /* For array it is the number of elements. - * For varchar it is the maxsize of the - * area. */ - char *struct_sizeof; /* For a struct this is the sizeof() type - * as string */ + char *size; /* For array it is the number of elements. For + * varchar it is the maxsize of the area. */ + char *struct_sizeof; /* For a struct this is the sizeof() type as + * string */ union { - struct ECPGtype *element; /* For an array this is the type - * of the element */ + struct ECPGtype *element; /* For an array this is the type of + * the element */ struct ECPGstruct_member *members; /* A pointer to a list of * members. */ } u; diff --git a/src/interfaces/ecpg/preproc/variable.c b/src/interfaces/ecpg/preproc/variable.c index e26dc02985..9372bfa6b7 100644 --- a/src/interfaces/ecpg/preproc/variable.c +++ b/src/interfaces/ecpg/preproc/variable.c @@ -58,8 +58,8 @@ find_struct_member(char *name, char *str, struct ECPGstruct_member * members, in int count; /* - * We don't care about what's inside the array braces - * so just eat up the character + * We don't care about what's inside the array braces so + * just eat up the character */ for (count = 1, end = next + 1; count; end++) { @@ -81,8 +81,8 @@ find_struct_member(char *name, char *str, struct ECPGstruct_member * members, in switch (*end) { - case '\0': /* found the end, but this time it has to - * be an array element */ + case '\0': /* found the end, but this time it has to be + * an array element */ if (members->type->type != ECPGt_array) mmerror(PARSE_ERROR, ET_FATAL, "incorrectly formed variable %s", name); @@ -198,8 +198,8 @@ find_variable(char *name) if (*next == '[') { /* - * We don't care about what's inside the array braces so just - * eat up the characters + * We don't care about what's inside the array braces so just eat + * up the characters */ for (count = 1, end = next + 1; count; end++) { @@ -410,8 +410,8 @@ dump_variables(struct arguments * list, int mode) return; /* - * The list is build up from the beginning so lets first dump the end - * of the list: + * The list is build up from the beginning so lets first dump the end of + * the list: */ dump_variables(list->next, mode); @@ -550,8 +550,8 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty if (atoi(*length) < 0) { /* - * make sure we return length = -1 for arrays without - * given bounds + * make sure we return length = -1 for arrays without given + * bounds */ if (atoi(*dimension) < 0 && !type_definition) diff --git a/src/interfaces/libpq/fe-auth.c b/src/interfaces/libpq/fe-auth.c index 4075aad614..4b15ff643d 100644 --- a/src/interfaces/libpq/fe-auth.c +++ b/src/interfaces/libpq/fe-auth.c @@ -10,7 +10,7 @@ * exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes). * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.104 2005/10/08 19:32:58 tgl Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.105 2005/10/15 02:49:48 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -64,7 +64,8 @@ */ #define STARTUP_MSG 7 /* Initialise a connection */ -#define STARTUP_KRB4_MSG 10 /* krb4 session follows. Not supported any more. */ +#define STARTUP_KRB4_MSG 10 /* krb4 session follows. Not supported any + * more. */ #define STARTUP_KRB5_MSG 11 /* krb5 session follows */ #define STARTUP_PASSWORD_MSG 14 /* Password follows */ @@ -139,7 +140,7 @@ pg_an_to_ln(char *aname) if ((p = strchr(aname, '/')) || (p = strchr(aname, '@'))) *p = '\0'; #ifdef WIN32 - for (p = aname; *p ; p++) + for (p = aname; *p; p++) *p = pg_tolower(*p); #endif @@ -265,9 +266,9 @@ pg_krb5_sendauth(char *PQerrormsg, int sock, const char *hostname, const char *s } /* - * libpq uses a non-blocking socket. But kerberos needs a blocking - * socket, and we have to block somehow to do mutual authentication - * anyway. So we temporarily make it blocking. + * libpq uses a non-blocking socket. But kerberos needs a blocking socket, + * and we have to block somehow to do mutual authentication anyway. So we + * temporarily make it blocking. */ if (!pg_set_block(sock)) { @@ -291,11 +292,11 @@ pg_krb5_sendauth(char *PQerrormsg, int sock, const char *hostname, const char *s { #if defined(HAVE_KRB5_ERROR_TEXT_DATA) snprintf(PQerrormsg, PQERRORMSG_LENGTH, - libpq_gettext("Kerberos 5 authentication rejected: %*s\n"), + libpq_gettext("Kerberos 5 authentication rejected: %*s\n"), (int) err_ret->text.length, err_ret->text.data); #elif defined(HAVE_KRB5_ERROR_E_DATA) snprintf(PQerrormsg, PQERRORMSG_LENGTH, - libpq_gettext("Kerberos 5 authentication rejected: %*s\n"), + libpq_gettext("Kerberos 5 authentication rejected: %*s\n"), (int) err_ret->e_data->length, (const char *) err_ret->e_data->data); #else @@ -321,7 +322,7 @@ pg_krb5_sendauth(char *PQerrormsg, int sock, const char *hostname, const char *s char sebuf[256]; snprintf(PQerrormsg, PQERRORMSG_LENGTH, - libpq_gettext("could not restore non-blocking mode on socket: %s\n"), + libpq_gettext("could not restore non-blocking mode on socket: %s\n"), pqStrerror(errno, sebuf, sizeof(sebuf))); ret = STATUS_ERROR; } @@ -355,8 +356,8 @@ pg_local_sendauth(char *PQerrormsg, PGconn *conn) #endif /* - * The backend doesn't care what we send here, but it wants exactly - * one character to force recvmsg() to block and wait for us. + * The backend doesn't care what we send here, but it wants exactly one + * character to force recvmsg() to block and wait for us. */ buf = '\0'; iov.iov_base = &buf; @@ -388,7 +389,7 @@ pg_local_sendauth(char *PQerrormsg, PGconn *conn) return STATUS_OK; #else snprintf(PQerrormsg, PQERRORMSG_LENGTH, - libpq_gettext("SCM_CRED authentication method not supported\n")); + libpq_gettext("SCM_CRED authentication method not supported\n")); return STATUS_ERROR; #endif } @@ -473,7 +474,7 @@ fe_sendauth(AuthRequest areq, PGconn *conn, const char *hostname, case AUTH_REQ_KRB4: snprintf(PQerrormsg, PQERRORMSG_LENGTH, - libpq_gettext("Kerberos 4 authentication not supported\n")); + libpq_gettext("Kerberos 4 authentication not supported\n")); return STATUS_ERROR; case AUTH_REQ_KRB5: @@ -490,7 +491,7 @@ fe_sendauth(AuthRequest areq, PGconn *conn, const char *hostname, break; #else snprintf(PQerrormsg, PQERRORMSG_LENGTH, - libpq_gettext("Kerberos 5 authentication not supported\n")); + libpq_gettext("Kerberos 5 authentication not supported\n")); return STATUS_ERROR; #endif @@ -506,7 +507,7 @@ fe_sendauth(AuthRequest areq, PGconn *conn, const char *hostname, if (pg_password_sendauth(conn, password, areq) != STATUS_OK) { (void) snprintf(PQerrormsg, PQERRORMSG_LENGTH, - "fe_sendauth: error sending password authentication\n"); + "fe_sendauth: error sending password authentication\n"); return STATUS_ERROR; } break; @@ -518,7 +519,7 @@ fe_sendauth(AuthRequest areq, PGconn *conn, const char *hostname, default: snprintf(PQerrormsg, PQERRORMSG_LENGTH, - libpq_gettext("authentication method %u not supported\n"), areq); + libpq_gettext("authentication method %u not supported\n"), areq); return STATUS_ERROR; } @@ -587,6 +588,7 @@ fe_getauthname(char *PQerrormsg) const char *name = NULL; char *authn; MsgType authsvc; + #ifdef WIN32 char username[128]; DWORD namesize = sizeof(username) - 1; @@ -623,7 +625,7 @@ fe_getauthname(char *PQerrormsg) if (authsvc != STARTUP_MSG && authsvc != STARTUP_KRB5_MSG) snprintf(PQerrormsg, PQERRORMSG_LENGTH, - libpq_gettext("fe_getauthname: invalid authentication system: %d\n"), + libpq_gettext("fe_getauthname: invalid authentication system: %d\n"), authsvc); authn = name ? strdup(name) : NULL; diff --git a/src/interfaces/libpq/fe-auth.h b/src/interfaces/libpq/fe-auth.h index 024107564b..0e015711ec 100644 --- a/src/interfaces/libpq/fe-auth.h +++ b/src/interfaces/libpq/fe-auth.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.h,v 1.21 2005/06/27 02:04:26 neilc Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.h,v 1.22 2005/10/15 02:49:48 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -39,6 +39,6 @@ extern MsgType fe_getauthsvc(char *PQerrormsg); extern void fe_setauthsvc(const char *name, char *PQerrormsg); extern char *fe_getauthname(char *PQerrormsg); -#define PG_KRB5_VERSION "PGVER5.1" /* at most KRB_SENDAUTH_VLEN chars */ +#define PG_KRB5_VERSION "PGVER5.1" /* at most KRB_SENDAUTH_VLEN chars */ #endif /* FE_AUTH_H */ diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index 012631a135..f9f3246f50 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.321 2005/09/26 17:49:09 petere Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.322 2005/10/15 02:49:48 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -116,9 +116,9 @@ */ static const PQconninfoOption PQconninfoOptions[] = { /* - * "authtype" is no longer used, so mark it "don't show". We keep it - * in the array so as not to reject conninfo strings from old apps - * that might still try to set it. + * "authtype" is no longer used, so mark it "don't show". We keep it in + * the array so as not to reject conninfo strings from old apps that might + * still try to set it. */ {"authtype", "PGAUTHTYPE", DefaultAuthtype, NULL, "Database-Authtype", "D", 20}, @@ -168,8 +168,8 @@ static const PQconninfoOption PQconninfoOptions[] = { #endif /* - * "sslmode" option is allowed even without client SSL support because - * the client can still handle SSL modes "disable" and "allow". + * "sslmode" option is allowed even without client SSL support because the + * client can still handle SSL modes "disable" and "allow". */ {"sslmode", "PGSSLMODE", DefaultSSLMode, NULL, "SSL-Mode", "", 8}, /* sizeof("disable") == 8 */ @@ -177,7 +177,7 @@ static const PQconninfoOption PQconninfoOptions[] = { #ifdef KRB5 /* Kerberos authentication supports specifying the service name */ {"krbsrvname", "PGKRBSRVNAME", PG_KRB_SRVNAM, NULL, - "Kerberos-service-name", "", 20}, + "Kerberos-service-name", "", 20}, #endif /* Terminating entry --- MUST BE LAST */ @@ -370,8 +370,8 @@ connectOptions1(PGconn *conn, const char *conninfo) /* * Move option values into conn structure * - * Don't put anything cute here --- intelligence should be in - * connectOptions2 ... + * Don't put anything cute here --- intelligence should be in connectOptions2 + * ... * * XXX: probably worth checking strdup() return value here... */ @@ -476,7 +476,7 @@ connectOptions2(PGconn *conn) { conn->status = CONNECTION_BAD; printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("invalid sslmode value: \"%s\"\n"), + libpq_gettext("invalid sslmode value: \"%s\"\n"), conn->sslmode); return false; } @@ -488,8 +488,8 @@ connectOptions2(PGconn *conn) case 'p': /* "prefer" */ /* - * warn user that an SSL connection will never be - * negotiated since SSL was not compiled in? + * warn user that an SSL connection will never be negotiated + * since SSL was not compiled in? */ break; @@ -655,8 +655,8 @@ connectNoDelay(PGconn *conn) char sebuf[256]; printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not set socket to TCP no delay mode: %s\n"), - SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf))); + libpq_gettext("could not set socket to TCP no delay mode: %s\n"), + SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf))); return 0; } #endif @@ -686,9 +686,9 @@ connectFailureMessage(PGconn *conn, int errorno) NI_NUMERICSERV); printfPQExpBuffer(&conn->errorMessage, libpq_gettext( - "could not connect to server: %s\n" - "\tIs the server running locally and accepting\n" - "\tconnections on Unix domain socket \"%s\"?\n" + "could not connect to server: %s\n" + "\tIs the server running locally and accepting\n" + "\tconnections on Unix domain socket \"%s\"?\n" ), SOCK_STRERROR(errorno, sebuf, sizeof(sebuf)), service); @@ -698,9 +698,9 @@ connectFailureMessage(PGconn *conn, int errorno) { printfPQExpBuffer(&conn->errorMessage, libpq_gettext( - "could not connect to server: %s\n" - "\tIs the server running on host \"%s\" and accepting\n" - "\tTCP/IP connections on port %s?\n" + "could not connect to server: %s\n" + "\tIs the server running on host \"%s\" and accepting\n" + "\tTCP/IP connections on port %s?\n" ), SOCK_STRERROR(errorno, sebuf, sizeof(sebuf)), conn->pghostaddr @@ -815,12 +815,11 @@ connectDBStart(PGconn *conn) conn->status = CONNECTION_NEEDED; /* - * The code for processing CONNECTION_NEEDED state is in - * PQconnectPoll(), so that it can easily be re-executed if needed - * again during the asynchronous startup process. However, we must - * run it once here, because callers expect a success return from this - * routine to mean that we are in PGRES_POLLING_WRITING connection - * state. + * The code for processing CONNECTION_NEEDED state is in PQconnectPoll(), + * so that it can easily be re-executed if needed again during the + * asynchronous startup process. However, we must run it once here, + * because callers expect a success return from this routine to mean that + * we are in PGRES_POLLING_WRITING connection state. */ if (PQconnectPoll(conn) == PGRES_POLLING_WRITING) return 1; @@ -863,8 +862,7 @@ connectDBComplete(PGconn *conn) if (timeout > 0) { /* - * Rounding could cause connection to fail; need at least 2 - * secs + * Rounding could cause connection to fail; need at least 2 secs */ if (timeout < 2) timeout = 2; @@ -877,8 +875,7 @@ connectDBComplete(PGconn *conn) { /* * Wait, if necessary. Note that the initial state (just after - * PQconnectStart) is to wait for the socket to select for - * writing. + * PQconnectStart) is to wait for the socket to select for writing. */ switch (flag) { @@ -954,8 +951,8 @@ PQconnectPoll(PGconn *conn) switch (conn->status) { /* - * We really shouldn't have been polled in these two cases, - * but we can handle it. + * We really shouldn't have been polled in these two cases, but we + * can handle it. */ case CONNECTION_BAD: return PGRES_POLLING_FAILED; @@ -995,24 +992,24 @@ PQconnectPoll(PGconn *conn) printfPQExpBuffer(&conn->errorMessage, libpq_gettext( "invalid connection state, " - "probably indicative of memory corruption\n" + "probably indicative of memory corruption\n" )); goto error_return; } -keep_going: /* We will come back to here until there - * is nothing left to do. */ +keep_going: /* We will come back to here until there is + * nothing left to do. */ switch (conn->status) { case CONNECTION_NEEDED: { /* * Try to initiate a connection to one of the addresses - * returned by getaddrinfo_all(). conn->addr_cur is the - * next one to try. We fail when we run out of addresses - * (reporting the error returned for the *last* - * alternative, which may not be what users expect :-(). + * returned by getaddrinfo_all(). conn->addr_cur is the next + * one to try. We fail when we run out of addresses + * (reporting the error returned for the *last* alternative, + * which may not be what users expect :-(). */ while (conn->addr_cur != NULL) { @@ -1028,8 +1025,8 @@ keep_going: /* We will come back to here until there if (conn->sock < 0) { /* - * ignore socket() failure if we have more - * addresses to try + * ignore socket() failure if we have more addresses + * to try */ if (addr_cur->ai_next != NULL) { @@ -1037,15 +1034,15 @@ keep_going: /* We will come back to here until there continue; } printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not create socket: %s\n"), - SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf))); + libpq_gettext("could not create socket: %s\n"), + SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf))); break; } /* - * Select socket options: no delay of outgoing data - * for TCP sockets, nonblock mode, close-on-exec. - * Fail if any of this fails. + * Select socket options: no delay of outgoing data for + * TCP sockets, nonblock mode, close-on-exec. Fail if any + * of this fails. */ if (!IS_AF_UNIX(addr_cur->ai_family)) { @@ -1061,7 +1058,7 @@ keep_going: /* We will come back to here until there { printfPQExpBuffer(&conn->errorMessage, libpq_gettext("could not set socket to non-blocking mode: %s\n"), - SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf))); + SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf))); closesocket(conn->sock); conn->sock = -1; conn->addr_cur = addr_cur->ai_next; @@ -1073,18 +1070,17 @@ keep_going: /* We will come back to here until there { printfPQExpBuffer(&conn->errorMessage, libpq_gettext("could not set socket to close-on-exec mode: %s\n"), - SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf))); + SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf))); closesocket(conn->sock); conn->sock = -1; conn->addr_cur = addr_cur->ai_next; continue; } -#endif /* F_SETFD */ +#endif /* F_SETFD */ /* - * Start/make connection. This should not block, - * since we are in nonblock mode. If it does, well, - * too bad. + * Start/make connection. This should not block, since we + * are in nonblock mode. If it does, well, too bad. */ if (connect(conn->sock, addr_cur->ai_addr, addr_cur->ai_addrlen) < 0) @@ -1095,9 +1091,9 @@ keep_going: /* We will come back to here until there SOCK_ERRNO == 0) { /* - * This is fine - we're in non-blocking mode, - * and the connection is in progress. Tell - * caller to wait for write-ready on socket. + * This is fine - we're in non-blocking mode, and + * the connection is in progress. Tell caller to + * wait for write-ready on socket. */ conn->status = CONNECTION_STARTED; return PGRES_POLLING_WRITING; @@ -1107,20 +1103,19 @@ keep_going: /* We will come back to here until there else { /* - * Hm, we're connected already --- seems the - * "nonblock connection" wasn't. Advance the - * state machine and go do the next stuff. + * Hm, we're connected already --- seems the "nonblock + * connection" wasn't. Advance the state machine and + * go do the next stuff. */ conn->status = CONNECTION_STARTED; goto keep_going; } /* - * This connection failed --- set up error report, - * then close socket (do it this way in case close() - * affects the value of errno...). We will ignore the - * connect() failure and keep going if there are more - * addresses. + * This connection failed --- set up error report, then + * close socket (do it this way in case close() affects + * the value of errno...). We will ignore the connect() + * failure and keep going if there are more addresses. */ connectFailureMessage(conn, SOCK_ERRNO); if (conn->sock >= 0) @@ -1136,8 +1131,8 @@ keep_going: /* We will come back to here until there } /* loop over addresses */ /* - * Ooops, no more addresses. An appropriate error message - * is already set up, so just set the right status. + * Ooops, no more addresses. An appropriate error message is + * already set up, so just set the right status. */ goto error_return; } @@ -1148,8 +1143,8 @@ keep_going: /* We will come back to here until there ACCEPT_TYPE_ARG3 optlen = sizeof(optval); /* - * Write ready, since we've made it here, so the - * connection has been made ... or has failed. + * Write ready, since we've made it here, so the connection + * has been made ... or has failed. */ /* @@ -1161,23 +1156,22 @@ keep_going: /* We will come back to here until there (char *) &optval, &optlen) == -1) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not get socket error status: %s\n"), - SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf))); + libpq_gettext("could not get socket error status: %s\n"), + SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf))); goto error_return; } else if (optval != 0) { /* - * When using a nonblocking connect, we will typically - * see connect failures at this point, so provide a - * friendly error message. + * When using a nonblocking connect, we will typically see + * connect failures at this point, so provide a friendly + * error message. */ connectFailureMessage(conn, optval); /* - * If more addresses remain, keep trying, just as in - * the case where connect() returned failure - * immediately. + * If more addresses remain, keep trying, just as in the + * case where connect() returned failure immediately. */ if (conn->addr_cur->ai_next != NULL) { @@ -1201,7 +1195,7 @@ keep_going: /* We will come back to here until there { printfPQExpBuffer(&conn->errorMessage, libpq_gettext("could not get client address from socket: %s\n"), - SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf))); + SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf))); goto error_return; } @@ -1220,9 +1214,8 @@ keep_going: /* We will come back to here until there #ifdef USE_SSL /* - * If SSL is enabled and we haven't already got it - * running, request it instead of sending the startup - * message. + * If SSL is enabled and we haven't already got it running, + * request it instead of sending the startup message. */ if (IS_AF_UNIX(conn->raddr.addr.ss_family)) { @@ -1237,16 +1230,15 @@ keep_going: /* We will come back to here until there /* * Send the SSL request packet. * - * Theoretically, this could block, but it really - * shouldn't since we only got here if the socket is - * write-ready. + * Theoretically, this could block, but it really shouldn't + * since we only got here if the socket is write-ready. */ pv = htonl(NEGOTIATE_SSL_CODE); if (pqPacketSend(conn, 0, &pv, sizeof(pv)) != STATUS_OK) { printfPQExpBuffer(&conn->errorMessage, libpq_gettext("could not send SSL negotiation packet: %s\n"), - SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf))); + SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf))); goto error_return; } /* Ok, wait for response */ @@ -1260,10 +1252,10 @@ keep_going: /* We will come back to here until there */ if (PG_PROTOCOL_MAJOR(conn->pversion) >= 3) startpacket = pqBuildStartupPacket3(conn, &packetlen, - EnvironmentOptions); + EnvironmentOptions); else startpacket = pqBuildStartupPacket2(conn, &packetlen, - EnvironmentOptions); + EnvironmentOptions); if (!startpacket) { printfPQExpBuffer(&conn->errorMessage, @@ -1274,14 +1266,14 @@ keep_going: /* We will come back to here until there /* * Send the startup packet. * - * Theoretically, this could block, but it really shouldn't - * since we only got here if the socket is write-ready. + * Theoretically, this could block, but it really shouldn't since + * we only got here if the socket is write-ready. */ if (pqPacketSend(conn, 0, startpacket, packetlen) != STATUS_OK) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not send startup packet: %s\n"), - SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf))); + libpq_gettext("could not send startup packet: %s\n"), + SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf))); free(startpacket); goto error_return; } @@ -1302,15 +1294,15 @@ keep_going: /* We will come back to here until there PostgresPollingStatusType pollres; /* - * On first time through, get the postmaster's response to - * our SSL negotiation packet. + * On first time through, get the postmaster's response to our + * SSL negotiation packet. */ if (conn->ssl == NULL) { /* * We use pqReadData here since it has the logic to - * distinguish no-data-yet from connection closure. - * Since conn->ssl isn't set, a plain recv() will occur. + * distinguish no-data-yet from connection closure. Since + * conn->ssl isn't set, a plain recv() will occur. */ char SSLok; int rdresult; @@ -1402,8 +1394,8 @@ keep_going: /* We will come back to here until there } /* - * Handle authentication exchange: wait for postmaster - * messages and respond as necessary. + * Handle authentication exchange: wait for postmaster messages + * and respond as necessary. */ case CONNECTION_AWAITING_RESPONSE: { @@ -1413,9 +1405,9 @@ keep_going: /* We will come back to here until there AuthRequest areq; /* - * Scan the message from current point (note that if we - * find the message is incomplete, we will return without - * advancing inStart, and resume here next time). + * Scan the message from current point (note that if we find + * the message is incomplete, we will return without advancing + * inStart, and resume here next time). */ conn->inCursor = conn->inStart; @@ -1435,8 +1427,8 @@ keep_going: /* We will come back to here until there { printfPQExpBuffer(&conn->errorMessage, libpq_gettext( - "expected authentication request from " - "server, but received %c\n"), + "expected authentication request from " + "server, but received %c\n"), beresp); goto error_return; } @@ -1458,17 +1450,17 @@ keep_going: /* We will come back to here until there /* * Try to validate message length before using it. - * Authentication requests can't be very large. Errors - * can be a little larger, but not huge. If we see a - * large apparent length in an error, it means we're - * really talking to a pre-3.0-protocol server; cope. + * Authentication requests can't be very large. Errors can be + * a little larger, but not huge. If we see a large apparent + * length in an error, it means we're really talking to a + * pre-3.0-protocol server; cope. */ if (beresp == 'R' && (msgLength < 8 || msgLength > 100)) { printfPQExpBuffer(&conn->errorMessage, libpq_gettext( - "expected authentication request from " - "server, but received %c\n"), + "expected authentication request from " + "server, but received %c\n"), beresp); goto error_return; } @@ -1486,9 +1478,8 @@ keep_going: /* We will come back to here until there conn->inStart = conn->inCursor; /* - * The postmaster typically won't end its message with - * a newline, so add one to conform to libpq - * conventions. + * The postmaster typically won't end its message with a + * newline, so add one to conform to libpq conventions. */ appendPQExpBufferChar(&conn->errorMessage, '\n'); @@ -1513,16 +1504,16 @@ keep_going: /* We will come back to here until there /* * Can't process if message body isn't all here yet. * - * (In protocol 2.0 case, we are assuming messages carry at - * least 4 bytes of data.) + * (In protocol 2.0 case, we are assuming messages carry at least + * 4 bytes of data.) */ msgLength -= 4; avail = conn->inEnd - conn->inCursor; if (avail < msgLength) { /* - * Before returning, try to enlarge the input buffer - * if needed to hold the whole message; see notes in + * Before returning, try to enlarge the input buffer if + * needed to hold the whole message; see notes in * pqParseInput3. */ if (pqCheckInBufferSpace(conn->inCursor + msgLength, conn)) @@ -1557,8 +1548,7 @@ keep_going: /* We will come back to here until there /* * if sslmode is "allow" and we haven't tried an SSL - * connection already, then retry with an SSL - * connection + * connection already, then retry with an SSL connection */ if (conn->sslmode[0] == 'a' /* "allow" */ && conn->ssl == NULL @@ -1575,8 +1565,8 @@ keep_going: /* We will come back to here until there } /* - * if sslmode is "prefer" and we're in an SSL - * connection, then do a non-SSL retry + * if sslmode is "prefer" and we're in an SSL connection, + * then do a non-SSL retry */ if (conn->sslmode[0] == 'p' /* "prefer" */ && conn->ssl @@ -1626,21 +1616,20 @@ keep_going: /* We will come back to here until there } /* - * OK, we successfully read the message; mark data - * consumed + * OK, we successfully read the message; mark data consumed */ conn->inStart = conn->inCursor; /* Respond to the request if necessary. */ /* - * Note that conn->pghost must be non-NULL if we are going - * to avoid the Kerberos code doing a hostname look-up. + * Note that conn->pghost must be non-NULL if we are going to + * avoid the Kerberos code doing a hostname look-up. */ /* - * XXX fe-auth.c has not been fixed to support - * PQExpBuffers, so: + * XXX fe-auth.c has not been fixed to support PQExpBuffers, + * so: */ if (fe_sendauth(areq, conn, conn->pghost, conn->pgpass, conn->errorMessage.data) != STATUS_OK) @@ -1651,10 +1640,9 @@ keep_going: /* We will come back to here until there conn->errorMessage.len = strlen(conn->errorMessage.data); /* - * Just make sure that any data sent by fe_sendauth is - * flushed out. Although this theoretically could block, - * it really shouldn't since we don't send large auth - * responses. + * Just make sure that any data sent by fe_sendauth is flushed + * out. Although this theoretically could block, it really + * shouldn't since we don't send large auth responses. */ if (pqFlush(conn)) goto error_return; @@ -1680,14 +1668,14 @@ keep_going: /* We will come back to here until there { /* * Now we expect to hear from the backend. A ReadyForQuery - * message indicates that startup is successful, but we - * might also get an Error message indicating failure. - * (Notice messages indicating nonfatal warnings are also - * allowed by the protocol, as are ParameterStatus and - * BackendKeyData messages.) Easiest way to handle this is - * to let PQgetResult() read the messages. We just have to - * fake it out about the state of the connection, by - * setting asyncStatus = PGASYNC_BUSY (done above). + * message indicates that startup is successful, but we might + * also get an Error message indicating failure. (Notice + * messages indicating nonfatal warnings are also allowed by + * the protocol, as are ParameterStatus and BackendKeyData + * messages.) Easiest way to handle this is to let + * PQgetResult() read the messages. We just have to fake it + * out about the state of the connection, by setting + * asyncStatus = PGASYNC_BUSY (done above). */ if (PQisBusy(conn)) @@ -1706,11 +1694,10 @@ keep_going: /* We will come back to here until there libpq_gettext("unexpected message from server during startup\n")); /* - * if the resultStatus is FATAL, then - * conn->errorMessage already has a copy of the error; - * needn't copy it back. But add a newline if it's not - * there already, since postmaster error messages may - * not have one. + * if the resultStatus is FATAL, then conn->errorMessage + * already has a copy of the error; needn't copy it back. + * But add a newline if it's not there already, since + * postmaster error messages may not have one. */ if (conn->errorMessage.len <= 0 || conn->errorMessage.data[conn->errorMessage.len - 1] != '\n') @@ -1741,8 +1728,7 @@ keep_going: /* We will come back to here until there case CONNECTION_SETENV: /* - * Do post-connection housekeeping (only needed in protocol - * 2.0). + * Do post-connection housekeeping (only needed in protocol 2.0). * * We pretend that the connection is OK for the duration of these * queries. @@ -1773,8 +1759,8 @@ keep_going: /* We will come back to here until there default: printfPQExpBuffer(&conn->errorMessage, libpq_gettext( - "invalid connection state %c, " - "probably indicative of memory corruption\n" + "invalid connection state %c, " + "probably indicative of memory corruption\n" ), conn->status); goto error_return; @@ -1785,11 +1771,11 @@ keep_going: /* We will come back to here until there error_return: /* - * We used to close the socket at this point, but that makes it - * awkward for those above us if they wish to remove this socket from - * their own records (an fd_set for example). We'll just have this - * socket closed when PQfinish is called (which is compulsory even - * after an error, since the connection structure must be freed). + * We used to close the socket at this point, but that makes it awkward + * for those above us if they wish to remove this socket from their own + * records (an fd_set for example). We'll just have this socket closed + * when PQfinish is called (which is compulsory even after an error, since + * the connection structure must be freed). */ conn->status = CONNECTION_BAD; return PGRES_POLLING_FAILED; @@ -1806,11 +1792,11 @@ makeEmptyPGconn(void) PGconn *conn; #ifdef WIN32 + /* - * Make sure socket support is up and running. - * Even though this is done in libpqdll.c, that is only for MSVC and - * BCC builds and doesn't work for static builds at all, so we have - * to do it in the main code too. + * Make sure socket support is up and running. Even though this is done in + * libpqdll.c, that is only for MSVC and BCC builds and doesn't work for + * static builds at all, so we have to do it in the main code too. */ WSADATA wsaData; @@ -1841,15 +1827,15 @@ makeEmptyPGconn(void) #endif /* - * We try to send at least 8K at a time, which is the usual size of - * pipe buffers on Unix systems. That way, when we are sending a - * large amount of data, we avoid incurring extra kernel context swaps - * for partial bufferloads. The output buffer is initially made 16K - * in size, and we try to dump it after accumulating 8K. + * We try to send at least 8K at a time, which is the usual size of pipe + * buffers on Unix systems. That way, when we are sending a large amount + * of data, we avoid incurring extra kernel context swaps for partial + * bufferloads. The output buffer is initially made 16K in size, and we + * try to dump it after accumulating 8K. * - * With the same goal of minimizing context swaps, the input buffer will - * be enlarged anytime it has less than 8K free, so we initially - * allocate twice that. + * With the same goal of minimizing context swaps, the input buffer will be + * enlarged anytime it has less than 8K free, so we initially allocate + * twice that. */ conn->inBufSize = 16 * 1024; conn->inBuffer = (char *) malloc(conn->inBufSize); @@ -1928,7 +1914,7 @@ freePGconn(PGconn *conn) notify = conn->notifyHead; while (notify != NULL) { - PGnotify *prev = notify; + PGnotify *prev = notify; notify = notify->next; free(prev); @@ -1980,9 +1966,9 @@ closePGconn(PGconn *conn) } /* - * must reset the blocking status so a possible reconnect will work - * don't call PQsetnonblocking() because it will fail if it's unable - * to flush the connection. + * must reset the blocking status so a possible reconnect will work don't + * call PQsetnonblocking() because it will fail if it's unable to flush + * the connection. */ conn->nonblocking = FALSE; @@ -2005,7 +1991,7 @@ closePGconn(PGconn *conn) notify = conn->notifyHead; while (notify != NULL) { - PGnotify *prev = notify; + PGnotify *prev = notify; notify = notify->next; free(prev); @@ -2104,7 +2090,7 @@ PQresetPoll(PGconn *conn) PGcancel * PQgetCancel(PGconn *conn) { - PGcancel *cancel; + PGcancel *cancel; if (!conn) return NULL; @@ -2159,7 +2145,7 @@ internal_cancel(SockAddr *raddr, int be_pid, int be_key, int save_errno = SOCK_ERRNO; int tmpsock = -1; char sebuf[256]; - int maxlen; + int maxlen; struct { uint32 packetlen; @@ -2167,8 +2153,8 @@ internal_cancel(SockAddr *raddr, int be_pid, int be_key, } crp; /* - * We need to open a temporary connection to the postmaster. Do - * this with only kernel calls. + * We need to open a temporary connection to the postmaster. Do this with + * only kernel calls. */ if ((tmpsock = socket(raddr->addr.ss_family, SOCK_STREAM, 0)) < 0) { @@ -2208,12 +2194,11 @@ retry4: } /* - * Wait for the postmaster to close the connection, which indicates - * that it's processed the request. Without this delay, we might - * issue another command only to find that our cancel zaps that - * command instead of the one we thought we were canceling. Note we - * don't actually expect this read to obtain any data, we are just - * waiting for EOF to be signaled. + * Wait for the postmaster to close the connection, which indicates that + * it's processed the request. Without this delay, we might issue another + * command only to find that our cancel zaps that command instead of the + * one we thought we were canceling. Note we don't actually expect this + * read to obtain any data, we are just waiting for EOF to be signaled. */ retry5: if (recv(tmpsock, (char *) &crp, 1, 0) < 0) @@ -2230,9 +2215,10 @@ retry5: return TRUE; cancel_errReturn: + /* - * Make sure we don't overflow the error buffer. Leave space for - * the \n at the end, and for the terminating zero. + * Make sure we don't overflow the error buffer. Leave space for the \n at + * the end, and for the terminating zero. */ maxlen = errbufsize - strlen(errbuf) - 2; if (maxlen >= 0) @@ -2253,7 +2239,7 @@ cancel_errReturn: * Returns TRUE if able to send the cancel request, FALSE if not. * * On failure, an error message is stored in *errbuf, which must be of size - * errbufsize (recommended size is 256 bytes). *errbuf is not changed on + * errbufsize (recommended size is 256 bytes). *errbuf is not changed on * success return. */ int @@ -2284,7 +2270,7 @@ PQcancel(PGcancel *cancel, char *errbuf, int errbufsize) int PQrequestCancel(PGconn *conn) { - int r; + int r; /* Check we have an open connection */ if (!conn) @@ -2362,9 +2348,9 @@ parseServiceInfo(PQconninfoOption *options, PQExpBuffer errorMessage) i; /* - * We have to special-case the environment variable PGSERVICE here, - * since this is and should be called before inserting environment - * defaults for other connection options. + * We have to special-case the environment variable PGSERVICE here, since + * this is and should be called before inserting environment defaults for + * other connection options. */ if (service == NULL) service = getenv("PGSERVICE"); @@ -2398,7 +2384,7 @@ parseServiceInfo(PQconninfoOption *options, PQExpBuffer errorMessage) { fclose(f); printfPQExpBuffer(errorMessage, - libpq_gettext("ERROR: line %d too long in service file \"%s\"\n"), + libpq_gettext("ERROR: line %d too long in service file \"%s\"\n"), linenr, serviceFile); return 2; @@ -2437,8 +2423,8 @@ parseServiceInfo(PQconninfoOption *options, PQExpBuffer errorMessage) if (group_found) { /* - * Finally, we are in the right group and can parse - * the line + * Finally, we are in the right group and can parse the + * line */ char *key, *val; @@ -2458,8 +2444,8 @@ parseServiceInfo(PQconninfoOption *options, PQExpBuffer errorMessage) *val++ = '\0'; /* - * Set the parameter --- but don't override any - * previous explicit setting. + * Set the parameter --- but don't override any previous + * explicit setting. */ found_keyword = false; for (i = 0; options[i].keyword; i++) @@ -2638,8 +2624,7 @@ conninfo_parse(const char *conninfo, PQExpBuffer errorMessage) } /* - * Now we have the name and the value. Search for the param - * record. + * Now we have the name and the value. Search for the param record. */ for (option = options; option->keyword != NULL; option++) { @@ -2649,7 +2634,7 @@ conninfo_parse(const char *conninfo, PQExpBuffer errorMessage) if (option->keyword == NULL) { printfPQExpBuffer(errorMessage, - libpq_gettext("invalid connection option \"%s\"\n"), + libpq_gettext("invalid connection option \"%s\"\n"), pname); PQconninfoFree(options); free(buf); @@ -2676,8 +2661,8 @@ conninfo_parse(const char *conninfo, PQExpBuffer errorMessage) free(buf); /* - * If there's a service spec, use it to obtain any - * not-explicitly-given parameters. + * If there's a service spec, use it to obtain any not-explicitly-given + * parameters. */ if (parseServiceInfo(options, errorMessage)) { @@ -2686,8 +2671,8 @@ conninfo_parse(const char *conninfo, PQExpBuffer errorMessage) } /* - * Get the fallback resources for parameters not specified in the - * conninfo string nor the service. + * Get the fallback resources for parameters not specified in the conninfo + * string nor the service. */ for (option = options; option->keyword != NULL; option++) { @@ -3100,7 +3085,7 @@ PasswordFromFile(char *hostname, char *port, char *dbname, char *username) FILE *fp; char pgpassfile[MAXPGPATH]; struct stat stat_buf; - char *passfile_env; + char *passfile_env; #define LINELEN NAMEDATALEN*5 char buf[LINELEN]; @@ -3138,7 +3123,7 @@ PasswordFromFile(char *hostname, char *port, char *dbname, char *username) if (!S_ISREG(stat_buf.st_mode)) { fprintf(stderr, - libpq_gettext("WARNING: password file \"%s\" is not a plain file\n"), + libpq_gettext("WARNING: password file \"%s\" is not a plain file\n"), pgpassfile); free(pgpassfile); return NULL; @@ -3212,7 +3197,6 @@ pqGetHomeDirectory(char *buf, int bufsize) return false; StrNCpy(buf, pwd->pw_dir, bufsize); return true; - #else char tmppath[MAX_PATH]; @@ -3235,7 +3219,6 @@ default_threadlock(int acquire) #ifdef ENABLE_THREAD_SAFETY #ifndef WIN32 static pthread_mutex_t singlethread_lock = PTHREAD_MUTEX_INITIALIZER; - #else static pthread_mutex_t singlethread_lock = NULL; static long mutex_initlock = 0; diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c index 0835b263bd..84637072bc 100644 --- a/src/interfaces/libpq/fe-exec.c +++ b/src/interfaces/libpq/fe-exec.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.175 2005/09/24 17:53:28 tgl Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.176 2005/10/15 02:49:48 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -30,7 +30,7 @@ #endif /* keep this in same order as ExecStatusType in libpq-fe.h */ -char *const pgresStatus[] = { +char *const pgresStatus[] = { "PGRES_EMPTY_QUERY", "PGRES_COMMAND_OK", "PGRES_TUPLES_OK", @@ -209,8 +209,8 @@ pqResultAlloc(PGresult *res, size_t nBytes, bool isBinary) return res->null_field; /* - * If alignment is needed, round up the current position to an - * alignment boundary. + * If alignment is needed, round up the current position to an alignment + * boundary. */ if (isBinary) { @@ -234,10 +234,9 @@ pqResultAlloc(PGresult *res, size_t nBytes, bool isBinary) /* * 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. + * 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) { @@ -393,8 +392,8 @@ void pqSaveErrorResult(PGconn *conn) { /* - * If no old async result, just let PQmakeEmptyPGresult make one. - * Likewise if old result is not an error message. + * If no old async result, just let PQmakeEmptyPGresult make one. Likewise + * if old result is not an error message. */ if (conn->result == NULL || conn->result->resultStatus != PGRES_FATAL_ERROR || @@ -423,9 +422,9 @@ pqPrepareAsyncResult(PGconn *conn) PGresult *res; /* - * 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 */ @@ -435,8 +434,8 @@ pqPrepareAsyncResult(PGconn *conn) else { /* - * Make sure PQerrorMessage agrees with result; it could be - * different if we have concatenated messages. + * Make sure PQerrorMessage agrees with result; it could be different + * if we have concatenated messages. */ resetPQExpBuffer(&conn->errorMessage); appendPQExpBufferStr(&conn->errorMessage, @@ -455,7 +454,7 @@ pqPrepareAsyncResult(PGconn *conn) * a trailing newline, and should not be more than one line). */ void -pqInternalNotice(const PGNoticeHooks *hooks, const char *fmt, ...) +pqInternalNotice(const PGNoticeHooks * hooks, const char *fmt,...) { char msgBuf[1024]; va_list args; @@ -484,8 +483,8 @@ pqInternalNotice(const PGNoticeHooks *hooks, const char *fmt, ...) /* XXX should provide a SQLSTATE too? */ /* - * Result text is always just the primary message + newline. If we - * can't allocate it, don't bother invoking the receiver. + * Result text is always just the primary message + newline. If we can't + * allocate it, don't bother invoking the receiver. */ res->errMsg = (char *) pqResultAlloc(res, strlen(msgBuf) + 2, FALSE); if (res->errMsg) @@ -506,20 +505,20 @@ pqInternalNotice(const PGNoticeHooks *hooks, const char *fmt, ...) * Returns TRUE if OK, FALSE if not enough memory to add the row */ int -pqAddTuple(PGresult *res, PGresAttValue *tup) +pqAddTuple(PGresult *res, PGresAttValue * tup) { if (res->ntups >= res->tupArrSize) { /* * Try to grow the array. * - * We can use realloc because shallow copying of the structure is - * okay. Note that the first time through, res->tuples is NULL. - * 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. + * We can use realloc because shallow copying of the structure is okay. + * Note that the first time through, res->tuples is NULL. 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. */ int newSize = (res->tupArrSize > 0) ? res->tupArrSize * 2 : 128; PGresAttValue **newTuples; @@ -595,7 +594,7 @@ pqSaveParameterStatus(PGconn *conn, const char *name, const char *value) * Store new info as a single malloc block */ pstatus = (pgParameterStatus *) malloc(sizeof(pgParameterStatus) + - strlen(name) +strlen(value) + 2); + strlen(name) + strlen(value) + 2); if (pstatus) { char *ptr; @@ -611,8 +610,8 @@ pqSaveParameterStatus(PGconn *conn, const char *name, const char *value) } /* - * Special hacks: remember client_encoding as a numeric value, and - * convert server version to a numeric form as well. + * Special hacks: remember client_encoding as a numeric value, and convert + * server version to a numeric form as well. */ if (strcmp(name, "client_encoding") == 0) conn->client_encoding = pg_char_to_encoding(value); @@ -653,7 +652,7 @@ PQsendQuery(PGconn *conn, const char *query) if (!query) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("command string is a null pointer\n")); + libpq_gettext("command string is a null pointer\n")); return 0; } @@ -670,9 +669,8 @@ PQsendQuery(PGconn *conn, const char *query) conn->queryclass = PGQUERY_SIMPLE; /* - * Give the data a push. In nonblock mode, don't complain if we're - * unable to send it all; PQgetResult() will do any additional - * flushing needed. + * Give the data a push. In nonblock mode, don't complain if we're unable + * to send it all; PQgetResult() will do any additional flushing needed. */ if (pqFlush(conn) < 0) { @@ -705,7 +703,7 @@ PQsendQueryParams(PGconn *conn, if (!command) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("command string is a null pointer\n")); + libpq_gettext("command string is a null pointer\n")); return 0; } @@ -722,10 +720,10 @@ PQsendQueryParams(PGconn *conn, /* * PQsendPrepare - * Submit a Parse message, but don't wait for it to finish + * Submit a Parse message, but don't wait for it to finish * * Returns: 1 if successfully submitted - * 0 if error (conn->errorMessage is set) + * 0 if error (conn->errorMessage is set) */ int PQsendPrepare(PGconn *conn, @@ -738,14 +736,14 @@ PQsendPrepare(PGconn *conn, if (!stmtName) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("statement name is a null pointer\n")); + libpq_gettext("statement name is a null pointer\n")); return 0; } if (!query) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("command string is a null pointer\n")); + libpq_gettext("command string is a null pointer\n")); return 0; } @@ -753,7 +751,7 @@ PQsendPrepare(PGconn *conn, if (PG_PROTOCOL_MAJOR(conn->pversion) < 3) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("function requires at least protocol version 3.0\n")); + libpq_gettext("function requires at least protocol version 3.0\n")); return 0; } @@ -765,7 +763,7 @@ PQsendPrepare(PGconn *conn, if (nParams > 0 && paramTypes) { - int i; + int i; if (pqPutInt(nParams, 2, conn) < 0) goto sendFailed; @@ -792,9 +790,8 @@ PQsendPrepare(PGconn *conn, conn->queryclass = PGQUERY_PREPARE; /* - * Give the data a push. In nonblock mode, don't complain if we're - * unable to send it all; PQgetResult() will do any additional - * flushing needed. + * Give the data a push. In nonblock mode, don't complain if we're unable + * to send it all; PQgetResult() will do any additional flushing needed. */ if (pqFlush(conn) < 0) goto sendFailed; @@ -828,7 +825,7 @@ PQsendQueryPrepared(PGconn *conn, if (!stmtName) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("statement name is a null pointer\n")); + libpq_gettext("statement name is a null pointer\n")); return 0; } @@ -866,7 +863,7 @@ PQsendQueryStart(PGconn *conn) if (conn->asyncStatus != PGASYNC_IDLE) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("another command is already in progress\n")); + libpq_gettext("another command is already in progress\n")); return false; } @@ -902,13 +899,13 @@ PQsendQueryGuts(PGconn *conn, if (PG_PROTOCOL_MAJOR(conn->pversion) < 3) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("function requires at least protocol version 3.0\n")); + libpq_gettext("function requires at least protocol version 3.0\n")); return 0; } /* - * We will send Parse (if needed), Bind, Describe Portal, Execute, - * Sync, using specified statement name and the unnamed portal. + * We will send Parse (if needed), Bind, Describe Portal, Execute, Sync, + * using specified statement name and the unnamed portal. */ if (command) @@ -1022,9 +1019,8 @@ PQsendQueryGuts(PGconn *conn, conn->queryclass = PGQUERY_EXTENDED; /* - * Give the data a push. In nonblock mode, don't complain if we're - * unable to send it all; PQgetResult() will do any additional - * flushing needed. + * Give the data a push. In nonblock mode, don't complain if we're unable + * to send it all; PQgetResult() will do any additional flushing needed. */ if (pqFlush(conn) < 0) goto sendFailed; @@ -1051,8 +1047,8 @@ pqHandleSendFailure(PGconn *conn) { /* * Accept any available input data, ignoring errors. Note that if - * pqReadData decides the backend has closed the channel, it will - * close our side of the socket --- that's just what we want here. + * pqReadData decides the backend has closed the channel, it will close + * our side of the socket --- that's just what we want here. */ while (pqReadData(conn) > 0) /* loop until no more data readable */ ; @@ -1076,9 +1072,9 @@ PQconsumeInput(PGconn *conn) return 0; /* - * for non-blocking connections try to flush the send-queue, otherwise - * we may never get a response for something that may not have already - * been sent because it's in our write buffer! + * for non-blocking connections try to flush the send-queue, otherwise we + * may never get a response for something that may not have already been + * sent because it's in our write buffer! */ if (pqIsnonblocking(conn)) { @@ -1087,10 +1083,10 @@ PQconsumeInput(PGconn *conn) } /* - * Load more data, if available. We do this no matter what state we - * are in, since we are probably getting called because the - * application wants to get rid of a read-select condition. Note that - * we will NOT block waiting for more input. + * Load more data, if available. We do this no matter what state we are + * in, since we are probably getting called because the application wants + * to get rid of a read-select condition. Note that we will NOT block + * waiting for more input. */ if (pqReadData(conn) < 0) return 0; @@ -1157,8 +1153,8 @@ PQgetResult(PGconn *conn) int flushResult; /* - * If data remains unsent, send it. Else we might be waiting for - * the result of a command the backend hasn't even got yet. + * If data remains unsent, send it. Else we might be waiting for the + * result of a command the backend hasn't even got yet. */ while ((flushResult = pqFlush(conn)) > 0) { @@ -1212,7 +1208,7 @@ PQgetResult(PGconn *conn) break; default: printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("unexpected asyncStatus: %d\n"), + libpq_gettext("unexpected asyncStatus: %d\n"), (int) conn->asyncStatus); res = PQmakeEmptyPGresult(conn, PGRES_FATAL_ERROR); break; @@ -1268,7 +1264,7 @@ PQexecParams(PGconn *conn, /* * PQprepare - * Creates a prepared statement by issuing a v3.0 parse message. + * Creates a prepared statement by issuing a v3.0 parse message. * * If the query was not even sent, return NULL; conn->errorMessage is set to * a relevant message. @@ -1324,9 +1320,8 @@ PQexecStart(PGconn *conn) return false; /* - * Silently discard any prior query result that application didn't - * eat. This is probably poor design, but it's here for backward - * compatibility. + * Silently discard any prior query result that application didn't eat. + * This is probably poor design, but it's here for backward compatibility. */ while ((result = PQgetResult(conn)) != NULL) { @@ -1339,7 +1334,7 @@ PQexecStart(PGconn *conn) { /* In protocol 3, we can get out of a COPY IN state */ if (PQputCopyEnd(conn, - libpq_gettext("COPY terminated by new PQexec")) < 0) + libpq_gettext("COPY terminated by new PQexec")) < 0) return false; /* keep waiting to swallow the copy's failure message */ } @@ -1347,7 +1342,7 @@ PQexecStart(PGconn *conn) { /* In older protocols we have to punt */ printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("COPY IN state must be terminated first\n")); + libpq_gettext("COPY IN state must be terminated first\n")); return false; } } @@ -1356,9 +1351,9 @@ PQexecStart(PGconn *conn) if (PG_PROTOCOL_MAJOR(conn->pversion) >= 3) { /* - * In protocol 3, we can get out of a COPY OUT state: we - * just switch back to BUSY and allow the remaining COPY - * data to be dropped on the floor. + * In protocol 3, we can get out of a COPY OUT state: we just + * switch back to BUSY and allow the remaining COPY data to be + * dropped on the floor. */ conn->asyncStatus = PGASYNC_BUSY; /* keep waiting to swallow the copy's completion message */ @@ -1367,7 +1362,7 @@ PQexecStart(PGconn *conn) { /* In older protocols we have to punt */ printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("COPY OUT state must be terminated first\n")); + libpq_gettext("COPY OUT state must be terminated first\n")); return false; } } @@ -1390,9 +1385,9 @@ PQexecFinish(PGconn *conn) PGresult *lastResult; /* - * For backwards compatibility, return the last result if there are - * more than one --- but merge error messages if we get more than one - * error result. + * For backwards compatibility, return the last result if there are more + * than one --- but merge error messages if we get more than one error + * result. * * We have to stop if we see copy in/out, however. We will resume parsing * after application performs the data transfer. @@ -1412,8 +1407,7 @@ PQexecFinish(PGconn *conn) result = lastResult; /* - * Make sure PQerrorMessage agrees with concatenated - * result + * Make sure PQerrorMessage agrees with concatenated result */ resetPQExpBuffer(&conn->errorMessage); appendPQExpBufferStr(&conn->errorMessage, result->errMsg); @@ -1494,11 +1488,11 @@ PQputCopyData(PGconn *conn, const char *buffer, int nbytes) if (nbytes > 0) { /* - * Try to flush any previously sent data in preference to growing - * the output buffer. If we can't enlarge the buffer enough to - * hold the data, return 0 in the nonblock case, else hard error. - * (For simplicity, always assume 5 bytes of overhead even in - * protocol 2.0 case.) + * Try to flush any previously sent data in preference to growing the + * output buffer. If we can't enlarge the buffer enough to hold the + * data, return 0 in the nonblock case, else hard error. (For + * simplicity, always assume 5 bytes of overhead even in protocol 2.0 + * case.) */ if ((conn->outBufSize - conn->outCount - 5) < nbytes) { @@ -1569,8 +1563,8 @@ PQputCopyEnd(PGconn *conn, const char *errormsg) } /* - * If we sent the COPY command in extended-query mode, we must - * issue a Sync as well. + * If we sent the COPY command in extended-query mode, we must issue a + * Sync as well. */ if (conn->queryclass != PGQUERY_SIMPLE) { @@ -1982,8 +1976,8 @@ PQfnumber(const PGresult *res, const char *field_name) return -1; /* - * Note: it is correct to reject a zero-length input string; the - * proper input to match a zero-length field name would be "". + * Note: it is correct to reject a zero-length input string; the proper + * input to match a zero-length field name would be "". */ if (field_name == NULL || field_name[0] == '\0' || @@ -1992,8 +1986,8 @@ PQfnumber(const PGresult *res, const char *field_name) /* * Note: this code will not reject partially quoted strings, eg - * foo"BAR"foo will become fooBARfoo when it probably ought to be an - * error condition. + * foo"BAR"foo will become fooBARfoo when it probably ought to be an error + * condition. */ field_case = strdup(field_name); if (field_case == NULL) @@ -2156,11 +2150,11 @@ PQoidValue(const PGresult *res) char *endptr = NULL; unsigned long result; - if (!res || - !res->cmdStatus || - strncmp(res->cmdStatus, "INSERT ", 7) != 0 || - res->cmdStatus[7] < '0' || - res->cmdStatus[7] > '9') + if (!res || + !res->cmdStatus || + strncmp(res->cmdStatus, "INSERT ", 7) != 0 || + res->cmdStatus[7] < '0' || + res->cmdStatus[7] > '9') return InvalidOid; result = strtoul(res->cmdStatus + 7, &endptr, 10); @@ -2280,11 +2274,10 @@ PQsetnonblocking(PGconn *conn, int arg) return (0); /* - * to guarantee constancy for flushing/query/result-polling behavior - * we need to flush the send queue at this point in order to guarantee - * proper behavior. this is ok because either they are making a - * transition _from_ or _to_ blocking mode, either way we can block - * them. + * to guarantee constancy for flushing/query/result-polling behavior we + * need to flush the send queue at this point in order to guarantee proper + * behavior. this is ok because either they are making a transition _from_ + * or _to_ blocking mode, either way we can block them. */ /* if we are going from blocking to non-blocking flush here */ if (pqFlush(conn)) @@ -2519,9 +2512,9 @@ PQunescapeBytea(const unsigned char *strtext, size_t *retbuflen) /* * Note: if we see '\' followed by something that isn't a * recognized escape sequence, we loop around having done - * nothing except advance i. Therefore the something will - * be emitted as ordinary data on the next cycle. Corner - * case: '\' at end of string will just be discarded. + * nothing except advance i. Therefore the something will be + * emitted as ordinary data on the next cycle. Corner case: + * '\' at end of string will just be discarded. */ break; @@ -2530,8 +2523,7 @@ PQunescapeBytea(const unsigned char *strtext, size_t *retbuflen) break; } } - buflen = j; /* buflen is the length of the dequoted - * data */ + buflen = j; /* buflen is the length of the dequoted data */ /* Shrink the buffer to be no larger than necessary */ /* +1 avoids unportable behavior when buflen==0 */ diff --git a/src/interfaces/libpq/fe-lobj.c b/src/interfaces/libpq/fe-lobj.c index 665efe90bc..6745849c51 100644 --- a/src/interfaces/libpq/fe-lobj.c +++ b/src/interfaces/libpq/fe-lobj.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/libpq/fe-lobj.c,v 1.53 2005/06/13 02:26:53 tgl Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-lobj.c,v 1.54 2005/10/15 02:49:48 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -328,7 +328,7 @@ lo_create(PGconn *conn, Oid lobjId) if (conn->lobjfuncs->fn_lo_create == 0) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("cannot determine OID of function lo_create\n")); + libpq_gettext("cannot determine OID of function lo_create\n")); return InvalidOid; } @@ -453,8 +453,8 @@ lo_import(PGconn *conn, const char *filename) char sebuf[256]; printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not open file \"%s\": %s\n"), - filename, pqStrerror(errno, sebuf, sizeof(sebuf))); + libpq_gettext("could not open file \"%s\": %s\n"), + filename, pqStrerror(errno, sebuf, sizeof(sebuf))); return InvalidOid; } @@ -465,7 +465,7 @@ lo_import(PGconn *conn, const char *filename) if (lobjOid == InvalidOid) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not create large object for file \"%s\"\n"), + libpq_gettext("could not create large object for file \"%s\"\n"), filename); (void) close(fd); return InvalidOid; @@ -475,7 +475,7 @@ lo_import(PGconn *conn, const char *filename) if (lobj == -1) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not open large object %u\n"), + libpq_gettext("could not open large object %u\n"), lobjOid); (void) close(fd); return InvalidOid; @@ -490,7 +490,7 @@ lo_import(PGconn *conn, const char *filename) if (tmp < nbytes) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("error while reading file \"%s\"\n"), + libpq_gettext("error while reading file \"%s\"\n"), filename); (void) close(fd); (void) lo_close(conn, lobj); @@ -525,7 +525,7 @@ lo_export(PGconn *conn, Oid lobjId, const char *filename) if (lobj == -1) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not open large object %u\n"), lobjId); + libpq_gettext("could not open large object %u\n"), lobjId); return -1; } @@ -538,8 +538,8 @@ lo_export(PGconn *conn, Oid lobjId, const char *filename) char sebuf[256]; printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not open file \"%s\": %s\n"), - filename, pqStrerror(errno, sebuf, sizeof(sebuf))); + libpq_gettext("could not open file \"%s\": %s\n"), + filename, pqStrerror(errno, sebuf, sizeof(sebuf))); (void) lo_close(conn, lobj); return -1; } @@ -553,7 +553,7 @@ lo_export(PGconn *conn, Oid lobjId, const char *filename) if (tmp < nbytes) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("error while writing to file \"%s\"\n"), + libpq_gettext("error while writing to file \"%s\"\n"), filename); (void) lo_close(conn, lobj); (void) close(fd); @@ -566,7 +566,7 @@ lo_export(PGconn *conn, Oid lobjId, const char *filename) if (close(fd)) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("error while writing to file \"%s\"\n"), + libpq_gettext("error while writing to file \"%s\"\n"), filename); return -1; } @@ -605,9 +605,8 @@ lo_initialize(PGconn *conn) MemSet((char *) lobjfuncs, 0, sizeof(PGlobjfuncs)); /* - * Execute the query to get all the functions at once. In 7.3 and - * later we need to be schema-safe. lo_create only exists in 8.1 - * and up. + * Execute the query to get all the functions at once. In 7.3 and later + * we need to be schema-safe. lo_create only exists in 8.1 and up. */ if (conn->sversion >= 70300) query = "select proname, oid from pg_catalog.pg_proc " @@ -680,62 +679,62 @@ lo_initialize(PGconn *conn) PQclear(res); /* - * Finally check that we really got all large object interface - * functions --- except lo_create, which may not exist. + * Finally check that we really got all large object interface functions + * --- except lo_create, which may not exist. */ if (lobjfuncs->fn_lo_open == 0) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("cannot determine OID of function lo_open\n")); + libpq_gettext("cannot determine OID of function lo_open\n")); free(lobjfuncs); return -1; } if (lobjfuncs->fn_lo_close == 0) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("cannot determine OID of function lo_close\n")); + libpq_gettext("cannot determine OID of function lo_close\n")); free(lobjfuncs); return -1; } if (lobjfuncs->fn_lo_creat == 0) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("cannot determine OID of function lo_creat\n")); + libpq_gettext("cannot determine OID of function lo_creat\n")); free(lobjfuncs); return -1; } if (lobjfuncs->fn_lo_unlink == 0) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("cannot determine OID of function lo_unlink\n")); + libpq_gettext("cannot determine OID of function lo_unlink\n")); free(lobjfuncs); return -1; } if (lobjfuncs->fn_lo_lseek == 0) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("cannot determine OID of function lo_lseek\n")); + libpq_gettext("cannot determine OID of function lo_lseek\n")); free(lobjfuncs); return -1; } if (lobjfuncs->fn_lo_tell == 0) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("cannot determine OID of function lo_tell\n")); + libpq_gettext("cannot determine OID of function lo_tell\n")); free(lobjfuncs); return -1; } if (lobjfuncs->fn_lo_read == 0) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("cannot determine OID of function loread\n")); + libpq_gettext("cannot determine OID of function loread\n")); free(lobjfuncs); return -1; } if (lobjfuncs->fn_lo_write == 0) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("cannot determine OID of function lowrite\n")); + libpq_gettext("cannot determine OID of function lowrite\n")); free(lobjfuncs); return -1; } diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c index 2eff7e4fe2..c78d8b3c66 100644 --- a/src/interfaces/libpq/fe-misc.c +++ b/src/interfaces/libpq/fe-misc.c @@ -23,7 +23,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/libpq/fe-misc.c,v 1.121 2005/09/26 17:49:09 petere Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-misc.c,v 1.122 2005/10/15 02:49:48 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -226,7 +226,7 @@ pqGetInt(int *result, size_t bytes, PGconn *conn) break; default: pqInternalNotice(&conn->noticeHooks, - "integer of size %lu not supported by pqGetInt", + "integer of size %lu not supported by pqGetInt", (unsigned long) bytes); return EOF; } @@ -262,7 +262,7 @@ pqPutInt(int value, size_t bytes, PGconn *conn) break; default: pqInternalNotice(&conn->noticeHooks, - "integer of size %lu not supported by pqPutInt", + "integer of size %lu not supported by pqPutInt", (unsigned long) bytes); return EOF; } @@ -289,9 +289,9 @@ pqCheckOutBufferSpace(int bytes_needed, PGconn *conn) return 0; /* - * If we need to enlarge the buffer, we first try to double it in - * size; if that doesn't work, enlarge in multiples of 8K. This - * avoids thrashing the malloc pool by repeated small enlargements. + * If we need to enlarge the buffer, we first try to double it in size; if + * that doesn't work, enlarge in multiples of 8K. This avoids thrashing + * the malloc pool by repeated small enlargements. * * Note: tests for newsize > 0 are to catch integer overflow. */ @@ -352,9 +352,9 @@ pqCheckInBufferSpace(int bytes_needed, PGconn *conn) return 0; /* - * If we need to enlarge the buffer, we first try to double it in - * size; if that doesn't work, enlarge in multiples of 8K. This - * avoids thrashing the malloc pool by repeated small enlargements. + * If we need to enlarge the buffer, we first try to double it in size; if + * that doesn't work, enlarge in multiples of 8K. This avoids thrashing + * the malloc pool by repeated small enlargements. * * Note: tests for newsize > 0 are to catch integer overflow. */ @@ -565,20 +565,19 @@ pqReadData(PGconn *conn) } /* - * If the buffer is fairly full, enlarge it. We need to be able to - * enlarge the buffer in case a single message exceeds the initial - * buffer size. We enlarge before filling the buffer entirely so as - * to avoid asking the kernel for a partial packet. The magic constant - * here should be large enough for a TCP packet or Unix pipe - * bufferload. 8K is the usual pipe buffer size, so... + * If the buffer is fairly full, enlarge it. We need to be able to enlarge + * the buffer in case a single message exceeds the initial buffer size. + * We enlarge before filling the buffer entirely so as to avoid asking the + * kernel for a partial packet. The magic constant here should be large + * enough for a TCP packet or Unix pipe bufferload. 8K is the usual pipe + * buffer size, so... */ if (conn->inBufSize - conn->inEnd < 8192) { if (pqCheckInBufferSpace(conn->inEnd + 8192, conn)) { /* - * We don't insist that the enlarge worked, but we need some - * room + * We don't insist that the enlarge worked, but we need some room */ if (conn->inBufSize - conn->inEnd < 100) return -1; /* errorMessage already set */ @@ -608,8 +607,8 @@ retry3: goto definitelyFailed; #endif printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not receive data from server: %s\n"), - SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf))); + libpq_gettext("could not receive data from server: %s\n"), + SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf))); return -1; } if (nread > 0) @@ -617,17 +616,16 @@ retry3: conn->inEnd += nread; /* - * Hack to deal with the fact that some kernels will only give us - * back 1 packet per recv() call, even if we asked for more and - * there is more available. If it looks like we are reading a - * long message, loop back to recv() again immediately, until we - * run out of data or buffer space. Without this, the - * block-and-restart behavior of libpq's higher levels leads to - * O(N^2) performance on long messages. + * Hack to deal with the fact that some kernels will only give us back + * 1 packet per recv() call, even if we asked for more and there is + * more available. If it looks like we are reading a long message, + * loop back to recv() again immediately, until we run out of data or + * buffer space. Without this, the block-and-restart behavior of + * libpq's higher levels leads to O(N^2) performance on long messages. * - * Since we left-justified the data above, conn->inEnd gives the - * amount of data already read in the current message. We - * consider the message "long" once we have acquired 32k ... + * Since we left-justified the data above, conn->inEnd gives the amount + * of data already read in the current message. We consider the + * message "long" once we have acquired 32k ... */ if (conn->inEnd > 32768 && (conn->inBufSize - conn->inEnd) >= 8192) @@ -642,18 +640,18 @@ retry3: return 1; /* got a zero read after successful tries */ /* - * A return value of 0 could mean just that no data is now available, - * or it could mean EOF --- that is, the server has closed the - * connection. Since we have the socket in nonblock mode, the only way - * to tell the difference is to see if select() is saying that the - * file is ready. Grumble. Fortunately, we don't expect this path to - * be taken much, since in normal practice we should not be trying to - * read data unless the file selected for reading already. + * A return value of 0 could mean just that no data is now available, or + * it could mean EOF --- that is, the server has closed the connection. + * Since we have the socket in nonblock mode, the only way to tell the + * difference is to see if select() is saying that the file is ready. + * Grumble. Fortunately, we don't expect this path to be taken much, + * since in normal practice we should not be trying to read data unless + * the file selected for reading already. * - * In SSL mode it's even worse: SSL_read() could say WANT_READ and then - * data could arrive before we make the pqReadReady() test. So we - * must play dumb and assume there is more data, relying on the SSL - * layer to detect true EOF. + * In SSL mode it's even worse: SSL_read() could say WANT_READ and then data + * could arrive before we make the pqReadReady() test. So we must play + * dumb and assume there is more data, relying on the SSL layer to detect + * true EOF. */ #ifdef USE_SSL @@ -699,8 +697,8 @@ retry4: goto definitelyFailed; #endif printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not receive data from server: %s\n"), - SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf))); + libpq_gettext("could not receive data from server: %s\n"), + SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf))); return -1; } if (nread > 0) @@ -710,15 +708,15 @@ retry4: } /* - * OK, we are getting a zero read even though select() says ready. - * This means the connection has been closed. Cope. + * OK, we are getting a zero read even though select() says ready. This + * means the connection has been closed. Cope. */ definitelyFailed: printfPQExpBuffer(&conn->errorMessage, libpq_gettext( - "server closed the connection unexpectedly\n" - "\tThis probably means the server terminated abnormally\n" - "\tbefore or while processing the request.\n")); + "server closed the connection unexpectedly\n" + "\tThis probably means the server terminated abnormally\n" + "\tbefore or while processing the request.\n")); conn->status = CONNECTION_BAD; /* No more connection to backend */ pqsecure_close(conn); closesocket(conn->sock); @@ -761,9 +759,9 @@ pqSendSome(PGconn *conn, int len) if (sent < 0) { /* - * Anything except EAGAIN/EWOULDBLOCK/EINTR is trouble. If - * it's EPIPE or ECONNRESET, assume we've lost the backend - * connection permanently. + * Anything except EAGAIN/EWOULDBLOCK/EINTR is trouble. If it's + * EPIPE or ECONNRESET, assume we've lost the backend connection + * permanently. */ switch (SOCK_ERRNO) { @@ -784,25 +782,25 @@ pqSendSome(PGconn *conn, int len) #endif printfPQExpBuffer(&conn->errorMessage, libpq_gettext( - "server closed the connection unexpectedly\n" - "\tThis probably means the server terminated abnormally\n" - "\tbefore or while processing the request.\n")); + "server closed the connection unexpectedly\n" + "\tThis probably means the server terminated abnormally\n" + "\tbefore or while processing the request.\n")); /* - * We used to close the socket here, but that's a bad - * idea since there might be unread data waiting - * (typically, a NOTICE message from the backend - * telling us it's committing hara-kiri...). Leave - * the socket open until pqReadData finds no more data - * can be read. But abandon attempt to send data. + * We used to close the socket here, but that's a bad idea + * since there might be unread data waiting (typically, a + * NOTICE message from the backend telling us it's + * committing hara-kiri...). Leave the socket open until + * pqReadData finds no more data can be read. But abandon + * attempt to send data. */ conn->outCount = 0; return -1; default: printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not send data to server: %s\n"), - SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf))); + libpq_gettext("could not send data to server: %s\n"), + SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf))); /* We don't assume it's a fatal error... */ conn->outCount = 0; return -1; @@ -831,16 +829,15 @@ pqSendSome(PGconn *conn, int len) /* * There are scenarios in which we can't send data because the - * communications channel is full, but we cannot expect the - * server to clear the channel eventually because it's blocked - * trying to send data to us. (This can happen when we are - * sending a large amount of COPY data, and the server has - * generated lots of NOTICE responses.) To avoid a deadlock - * situation, we must be prepared to accept and buffer - * incoming data before we try again. Furthermore, it is - * possible that such incoming data might not arrive until - * after we've gone to sleep. Therefore, we wait for either - * read ready or write ready. + * communications channel is full, but we cannot expect the server + * to clear the channel eventually because it's blocked trying to + * send data to us. (This can happen when we are sending a large + * amount of COPY data, and the server has generated lots of + * NOTICE responses.) To avoid a deadlock situation, we must be + * prepared to accept and buffer incoming data before we try + * again. Furthermore, it is possible that such incoming data + * might not arrive until after we've gone to sleep. Therefore, + * we wait for either read ready or write ready. */ if (pqReadData(conn) < 0) { @@ -990,7 +987,7 @@ pqSocketCheck(PGconn *conn, int forRead, int forWrite, time_t end_time) printfPQExpBuffer(&conn->errorMessage, libpq_gettext("select() failed: %s\n"), - SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf))); + SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf))); } return result; @@ -1040,7 +1037,6 @@ pqSocketPoll(int sock, int forRead, int forWrite, time_t end_time) } return poll(&input_fd, 1, timeout_ms); - #else /* !HAVE_POLL */ fd_set input_mask; @@ -1134,9 +1130,9 @@ libpq_gettext(const char *msgid) { /* dgettext() preserves errno, but bindtextdomain() doesn't */ #ifdef WIN32 - int save_errno = GetLastError(); + int save_errno = GetLastError(); #else - int save_errno = errno; + int save_errno = errno; #endif const char *ldir; diff --git a/src/interfaces/libpq/fe-print.c b/src/interfaces/libpq/fe-print.c index a83004328c..f49859020b 100644 --- a/src/interfaces/libpq/fe-print.c +++ b/src/interfaces/libpq/fe-print.c @@ -10,7 +10,7 @@ * didn't really belong there. * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/libpq/fe-print.c,v 1.63 2005/08/23 21:02:03 momjian Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-print.c,v 1.64 2005/10/15 02:49:48 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -45,7 +45,7 @@ static void do_field(const PQprintOpt *po, const PGresult *res, unsigned char *fieldNotNum, int *fieldMax, const int fieldMaxLen, FILE *fout); static char *do_header(FILE *fout, const PQprintOpt *po, const int nFields, - int *fieldMax, const char **fieldNames, unsigned char *fieldNotNum, + int *fieldMax, const char **fieldNames, unsigned char *fieldNotNum, const int fs_len, const PGresult *res); static void output_row(FILE *fout, const PQprintOpt *po, const int nFields, char **fields, unsigned char *fieldNotNum, int *fieldMax, char *border, @@ -88,6 +88,7 @@ PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po) int total_line_length = 0; int usePipe = 0; char *pagerenv; + #if defined(ENABLE_THREAD_SAFETY) && !defined(WIN32) sigset_t osigset; bool sigpipe_masked = false; @@ -99,7 +100,6 @@ PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po) #ifdef TIOCGWINSZ struct winsize screen_size; - #else struct winsize { @@ -156,8 +156,8 @@ PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po) ) { /* - * If we think there'll be more than one screen of output, try - * to pipe to the pager program. + * If we think there'll be more than one screen of output, try to + * pipe to the pager program. */ #ifdef TIOCGWINSZ if (ioctl(fileno(stdout), TIOCGWINSZ, &screen_size) == -1 || @@ -195,8 +195,8 @@ PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po) sigpipe_masked = true; #else oldsigpipehandler = pqsignal(SIGPIPE, SIG_IGN); -#endif /* ENABLE_THREAD_SAFETY */ -#endif /* WIN32 */ +#endif /* ENABLE_THREAD_SAFETY */ +#endif /* WIN32 */ } else fout = stdout; @@ -256,7 +256,7 @@ PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po) { if (po->html3) fprintf(fout, - "
\n", + "
%d
\n", po->tableOpt ? po->tableOpt : "", i); else fprintf(fout, libpq_gettext("-- RECORD %d --\n"), i); @@ -276,7 +276,7 @@ PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po) { if (po->caption) fprintf(fout, - "
%d
\n", + "
%s
\n", po->tableOpt ? po->tableOpt : "", po->caption); else @@ -284,7 +284,7 @@ PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po) "
%s
\n", - po->tableOpt ? po->tableOpt : "", nTups, nFields); + po->tableOpt ? po->tableOpt : "", nTups, nFields); } else fprintf(fout, "
" "Retrieved %d rows * %d fields" "
", po->tableOpt ? po->tableOpt : ""); @@ -311,15 +311,15 @@ PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po) _pclose(fout); #else pclose(fout); - + #ifdef ENABLE_THREAD_SAFETY /* we can't easily verify if EPIPE occurred, so say it did */ if (sigpipe_masked) pq_reset_sigpipe(&osigset, sigpipe_pending, true); #else pqsignal(SIGPIPE, oldsigpipehandler); -#endif /* ENABLE_THREAD_SAFETY */ -#endif /* WIN32 */ +#endif /* ENABLE_THREAD_SAFETY */ +#endif /* WIN32 */ } if (po->html3 && !po->expanded) fputs("
\n", fout); @@ -380,9 +380,9 @@ do_field(const PQprintOpt *po, const PGresult *res, } /* - * 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 is still not bulletproof but it handles most cases. + * 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 + * is still not bulletproof but it handles most cases. */ if (*pval == 'E' || *pval == 'e' || !(ch >= '0' && ch <= '9')) @@ -547,7 +547,7 @@ output_row(FILE *fout, const PQprintOpt *po, const int nFields, char **fields, if (po->html3) fprintf(fout, "%s", - fieldNotNum[field_index] ? "left" : "right", p ? p : ""); + fieldNotNum[field_index] ? "left" : "right", p ? p : ""); else { fprintf(fout, @@ -678,8 +678,7 @@ PQprintTuples(const PGresult *res, FILE *fout, /* output stream */ int PrintAttNames, /* print attribute names or not */ int TerseOutput, /* delimiter bars or not? */ - int colWidth /* width of column, if 0, use variable - * width */ + int colWidth /* width of column, if 0, use variable width */ ) { int nFields; diff --git a/src/interfaces/libpq/fe-protocol2.c b/src/interfaces/libpq/fe-protocol2.c index b5753dba44..8e3614ac07 100644 --- a/src/interfaces/libpq/fe-protocol2.c +++ b/src/interfaces/libpq/fe-protocol2.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/libpq/fe-protocol2.c,v 1.18 2005/06/12 00:00:21 neilc Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-protocol2.c,v 1.19 2005/10/15 02:49:48 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -89,7 +89,7 @@ pqSetenvPoll(PGconn *conn) printfPQExpBuffer(&conn->errorMessage, libpq_gettext( "invalid setenv state %c, " - "probably indicative of memory corruption\n" + "probably indicative of memory corruption\n" ), conn->setenv_state); goto error_return; @@ -104,8 +104,8 @@ pqSetenvPoll(PGconn *conn) { /* * Send SET commands for stuff directed by Environment - * Options. Note: we assume that SET commands won't - * start transaction blocks, even in a 7.3 server with + * Options. Note: we assume that SET commands won't start + * transaction blocks, even in a 7.3 server with * autocommit off. */ char setQuery[100]; /* note length limit in @@ -125,7 +125,7 @@ pqSetenvPoll(PGconn *conn) conn->next_eo->pgName, val); #ifdef CONNECTDEBUG fprintf(stderr, - "Use environment variable %s to send %s\n", + "Use environment variable %s to send %s\n", conn->next_eo->envName, setQuery); #endif if (!PQsendQuery(conn, setQuery)) @@ -173,9 +173,9 @@ pqSetenvPoll(PGconn *conn) case SETENV_STATE_QUERY1_SEND: { /* - * Issue query to get information we need. Here we - * must use begin/commit in case autocommit is off by - * default in a 7.3 server. + * Issue query to get information we need. Here we must + * use begin/commit in case autocommit is off by default + * in a 7.3 server. * * Note: version() exists in all protocol-2.0-supporting * backends. In 7.3 it would be safer to write @@ -227,8 +227,8 @@ pqSetenvPoll(PGconn *conn) val += 11; /* - * strip off platform part (scribbles on - * result, naughty naughty) + * strip off platform part (scribbles on result, + * naughty naughty) */ ptr = strchr(val, ' '); if (ptr) @@ -254,11 +254,11 @@ pqSetenvPoll(PGconn *conn) const char *query; /* - * pg_client_encoding does not exist in pre-7.2 - * servers. So we need to be prepared for an error - * here. Do *not* start a transaction block, except - * in 7.3 servers where we need to prevent - * autocommit-off from starting a transaction anyway. + * pg_client_encoding does not exist in pre-7.2 servers. + * So we need to be prepared for an error here. Do *not* + * start a transaction block, except in 7.3 servers where + * we need to prevent autocommit-off from starting a + * transaction anyway. */ if (conn->sversion >= 70300 && conn->sversion < 70400) @@ -295,16 +295,15 @@ pqSetenvPoll(PGconn *conn) { /* Extract client encoding and save it */ val = PQgetvalue(res, 0, 0); - if (val && *val) /* null should not happen, - * but */ + if (val && *val) /* null should not happen, but */ pqSaveParameterStatus(conn, "client_encoding", val); } else { /* - * Error: presumably function not available, - * so use PGCLIENTENCODING or SQL_ASCII as the + * Error: presumably function not available, so + * use PGCLIENTENCODING or SQL_ASCII as the * fallback. */ val = getenv("PGCLIENTENCODING"); @@ -331,7 +330,7 @@ pqSetenvPoll(PGconn *conn) default: printfPQExpBuffer(&conn->errorMessage, libpq_gettext("invalid state %c, " - "probably indicative of memory corruption\n"), + "probably indicative of memory corruption\n"), conn->setenv_state); goto error_return; } @@ -361,11 +360,10 @@ pqParseInput2(PGconn *conn) for (;;) { /* - * Quit if in COPY_OUT state: we expect raw data from the server - * until PQendcopy is called. Don't try to parse it according to - * the normal protocol. (This is bogus. The data lines ought to - * be part of the protocol and have identifying leading - * characters.) + * Quit if in COPY_OUT state: we expect raw data from the server until + * PQendcopy is called. Don't try to parse it according to the normal + * protocol. (This is bogus. The data lines ought to be part of the + * protocol and have identifying leading characters.) */ if (conn->asyncStatus == PGASYNC_COPY_OUT) return; @@ -381,9 +379,9 @@ pqParseInput2(PGconn *conn) * NOTIFY and NOTICE messages can happen in any state besides COPY * OUT; always process them right away. * - * Most other messages should only be processed while in BUSY state. - * (In particular, in READY state we hold off further parsing - * until the application collects the current PGresult.) + * Most other messages should only be processed while in BUSY state. (In + * particular, in READY state we hold off further parsing until the + * application collects the current PGresult.) * * However, if the state is IDLE then we got trouble; we need to deal * with the unexpected message somehow. @@ -407,10 +405,10 @@ pqParseInput2(PGconn *conn) /* * Unexpected message in IDLE state; need to recover somehow. * ERROR messages are displayed using the notice processor; - * anything else is just dropped on the floor after displaying - * a suitable warning notice. (An ERROR is very possibly the - * backend telling us why it is about to close the connection, - * so we don't want to just discard it...) + * anything else is just dropped on the floor after displaying a + * suitable warning notice. (An ERROR is very possibly the + * backend telling us why it is about to close the connection, so + * we don't want to just discard it...) */ if (id == 'E') { @@ -420,7 +418,7 @@ pqParseInput2(PGconn *conn) else { pqInternalNotice(&conn->noticeHooks, - "message type 0x%02x arrived from server while idle", + "message type 0x%02x arrived from server while idle", id); /* Discard the unexpected message; good idea?? */ conn->inStart = conn->inEnd; @@ -440,7 +438,7 @@ pqParseInput2(PGconn *conn) if (conn->result == NULL) { conn->result = PQmakeEmptyPGresult(conn, - PGRES_COMMAND_OK); + PGRES_COMMAND_OK); if (!conn->result) return; } @@ -467,15 +465,15 @@ pqParseInput2(PGconn *conn) id); 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 */ /* - * This is expected only during backend startup, but - * it's just as easy to handle it as part of the main - * loop. Save the data and continue processing. + * This is expected only during backend startup, but it's + * just as easy to handle it as part of the main loop. + * Save the data and continue processing. */ if (pqGetInt(&(conn->be_pid), 4, conn)) return; @@ -487,8 +485,7 @@ pqParseInput2(PGconn *conn) return; /* We pretty much ignore this message type... */ break; - case 'T': /* row descriptions (start of query - * results) */ + case 'T': /* row descriptions (start of query results) */ if (conn->result == NULL) { /* First 'T' in a query sequence */ @@ -499,10 +496,10 @@ pqParseInput2(PGconn *conn) { /* * A new 'T' message is treated as the start of - * another PGresult. (It is not clear that this - * is really possible with the current backend.) - * We stop parsing until the application accepts - * the current result. + * another PGresult. (It is not clear that this is + * really possible with the current backend.) We stop + * parsing until the application accepts the current + * result. */ conn->asyncStatus = PGASYNC_READY; return; @@ -679,8 +676,8 @@ getAnotherTuple(PGconn *conn, bool binary) MemSet(conn->curTuple, 0, nfields * sizeof(PGresAttValue)); /* - * If it's binary, fix the column format indicators. We assume - * the backend will consistently send either B or D, not a mix. + * If it's binary, fix the column format indicators. We assume the + * backend will consistently send either B or D, not a mix. */ if (binary) { @@ -765,16 +762,16 @@ outOfMemory: /* Replace partially constructed result with an error result */ /* - * we do NOT use pqSaveErrorResult() here, because of the likelihood - * that there's not enough memory to concatenate messages... + * we do NOT use pqSaveErrorResult() here, because of the likelihood that + * there's not enough memory to concatenate messages... */ pqClearAsyncResult(conn); printfPQExpBuffer(&conn->errorMessage, libpq_gettext("out of memory for query result\n")); /* - * XXX: if PQmakeEmptyPGresult() fails, there's probably not much - * we can do to recover... + * XXX: if PQmakeEmptyPGresult() fails, there's probably not much we can + * do to recover... */ conn->result = PQmakeEmptyPGresult(conn, PGRES_FATAL_ERROR); conn->asyncStatus = PGASYNC_READY; @@ -805,8 +802,8 @@ pqGetErrorNotice2(PGconn *conn, bool isError) /* * Since the message might be pretty long, we create a temporary - * PQExpBuffer rather than using conn->workBuffer. workBuffer is - * intended for stuff that is expected to be short. + * PQExpBuffer rather than using conn->workBuffer. workBuffer is intended + * for stuff that is expected to be short. */ initPQExpBuffer(&workBuf); if (pqGets(&workBuf, conn)) @@ -826,12 +823,12 @@ pqGetErrorNotice2(PGconn *conn, bool isError) goto failure; /* - * Break the message into fields. We can't do very much here, but we - * can split the severity code off, and remove trailing newlines. - * Also, we use the heuristic that the primary message extends only to - * the first newline --- anything after that is detail message. (In - * some cases it'd be better classed as hint, but we can hardly be - * expected to guess that here.) + * Break the message into fields. We can't do very much here, but we can + * split the severity code off, and remove trailing newlines. Also, we use + * the heuristic that the primary message extends only to the first + * newline --- anything after that is detail message. (In some cases it'd + * be better classed as hint, but we can hardly be expected to guess that + * here.) */ while (workBuf.len > 0 && workBuf.data[workBuf.len - 1] == '\n') workBuf.data[--workBuf.len] = '\0'; @@ -867,8 +864,8 @@ pqGetErrorNotice2(PGconn *conn, bool isError) /* * Either save error as current async result, or just emit the notice. - * Also, if it's an error and we were in a transaction block, assume - * the server has now gone to error-in-transaction state. + * Also, if it's an error and we were in a transaction block, assume the + * server has now gone to error-in-transaction state. */ if (isError) { @@ -922,8 +919,8 @@ checkXactStatus(PGconn *conn, const char *cmdTag) /* * Normally we get into INERROR state by detecting an Error message. - * However, if we see one of these tags then we know for sure the - * server is in abort state ... + * However, if we see one of these tags then we know for sure the server + * is in abort state ... */ else if (strcmp(cmdTag, "*ABORT STATE*") == 0) /* pre-7.3 only */ conn->xactStatus = PQTRANS_INERROR; @@ -949,9 +946,9 @@ getNotify(PGconn *conn) return EOF; /* - * Store the relation name right after the PQnotify structure so it - * can all be freed at once. We don't use NAMEDATALEN because we - * don't want to tie this interface to a specific server name length. + * Store the relation name right after the PQnotify structure so it can + * all be freed at once. We don't use NAMEDATALEN because we don't want + * to tie this interface to a specific server name length. */ nmlen = strlen(conn->workBuffer.data); newNotify = (PGnotify *) malloc(sizeof(PGnotify) + nmlen + 1); @@ -1011,8 +1008,8 @@ pqGetCopyData2(PGconn *conn, char **buffer, int async) msgLength = conn->inCursor - conn->inStart; /* - * If it's the end-of-data marker, consume it, exit COPY_OUT mode, - * and let caller read status with PQgetResult(). + * If it's the end-of-data marker, consume it, exit COPY_OUT mode, and + * let caller read status with PQgetResult(). */ if (msgLength == 3 && strncmp(&conn->inBuffer[conn->inStart], "\\.\n", 3) == 0) @@ -1069,8 +1066,8 @@ pqGetline2(PGconn *conn, char *s, int maxlen) } /* - * Since this is a purely synchronous routine, we don't bother to - * maintain conn->inCursor; there is no need to back up. + * Since this is a purely synchronous routine, we don't bother to maintain + * conn->inCursor; there is no need to back up. */ while (maxlen > 1) { @@ -1116,11 +1113,11 @@ pqGetlineAsync2(PGconn *conn, char *buffer, int bufsize) 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; @@ -1146,12 +1143,11 @@ pqGetlineAsync2(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. + * 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) { @@ -1180,8 +1176,8 @@ pqEndcopy2(PGconn *conn) } /* - * make sure no data is waiting to be sent, abort if we are - * non-blocking and the flush fails + * make sure no data is waiting to be sent, abort if we are non-blocking + * and the flush fails */ if (pqFlush(conn) && pqIsnonblocking(conn)) return (1); @@ -1208,8 +1204,8 @@ pqEndcopy2(PGconn *conn) * Trouble. For backwards-compatibility reasons, we issue the error * message as if it were a notice (would be nice to get rid of this * silliness, but too many apps probably don't handle errors from - * PQendcopy reasonably). Note that the app can still obtain the - * error status from the PGconn object. + * PQendcopy reasonably). Note that the app can still obtain the error + * status from the PGconn object. */ if (conn->errorMessage.len > 0) { @@ -1225,17 +1221,17 @@ pqEndcopy2(PGconn *conn) PQclear(result); /* - * The worst case is that we've lost sync with the backend entirely - * due to application screwup of the copy in/out protocol. To recover, - * reset the connection (talk about using a sledgehammer...) + * The worst case is that we've lost sync with the backend entirely due to + * application screwup of the copy in/out protocol. To recover, reset the + * connection (talk about using a sledgehammer...) */ pqInternalNotice(&conn->noticeHooks, - "lost synchronization with server, resetting connection"); + "lost synchronization with server, resetting connection"); /* * Users doing non-blocking connections need to handle the reset - * themselves, they'll need to check the connection status if we - * return an error. + * themselves, they'll need to check the connection status if we return an + * error. */ if (pqIsnonblocking(conn)) PQresetStart(conn); @@ -1317,8 +1313,7 @@ pqFunctionCall2(PGconn *conn, Oid fnid, } /* - * Scan the message. If we run out of data, loop around to try - * again. + * Scan the message. If we run out of data, loop around to try again. */ conn->inCursor = conn->inStart; needInput = true; @@ -1328,8 +1323,8 @@ pqFunctionCall2(PGconn *conn, Oid fnid, /* * We should see V or E response to the command, but might get N - * and/or A notices first. We also need to swallow the final Z - * before returning. + * and/or A notices first. We also need to swallow the final Z before + * returning. */ switch (id) { @@ -1365,7 +1360,7 @@ pqFunctionCall2(PGconn *conn, Oid fnid, { /* The backend violates the protocol. */ printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("protocol error: id=0x%x\n"), + libpq_gettext("protocol error: id=0x%x\n"), id); pqSaveErrorResult(conn); conn->inStart = conn->inCursor; @@ -1397,7 +1392,7 @@ pqFunctionCall2(PGconn *conn, Oid fnid, default: /* The backend violates the protocol. */ printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("protocol error: id=0x%x\n"), + libpq_gettext("protocol error: id=0x%x\n"), id); pqSaveErrorResult(conn); conn->inStart = conn->inCursor; @@ -1425,7 +1420,7 @@ pqFunctionCall2(PGconn *conn, Oid fnid, */ char * pqBuildStartupPacket2(PGconn *conn, int *packetlen, - const PQEnvironmentOption *options) + const PQEnvironmentOption * options) { StartupPacket *startpacket; diff --git a/src/interfaces/libpq/fe-protocol3.c b/src/interfaces/libpq/fe-protocol3.c index 273159f430..d3af5ad447 100644 --- a/src/interfaces/libpq/fe-protocol3.c +++ b/src/interfaces/libpq/fe-protocol3.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/libpq/fe-protocol3.c,v 1.21 2005/06/12 00:00:21 neilc Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-protocol3.c,v 1.22 2005/10/15 02:49:48 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -51,8 +51,8 @@ static int getParameterStatus(PGconn *conn); static int getNotify(PGconn *conn); static int getCopyStart(PGconn *conn, ExecStatusType copytype); static int getReadyForQuery(PGconn *conn); -static int build_startup_packet(const PGconn *conn, char *packet, - const PQEnvironmentOption *options); +static int build_startup_packet(const PGconn *conn, char *packet, + const PQEnvironmentOption * options); /* @@ -73,8 +73,8 @@ pqParseInput3(PGconn *conn) for (;;) { /* - * Try to read a message. First get the type code and length. - * Return if not enough data. + * Try to read a message. First get the type code and length. Return + * if not enough data. */ conn->inCursor = conn->inStart; if (pqGetc(&id, conn)) @@ -83,9 +83,9 @@ pqParseInput3(PGconn *conn) return; /* - * Try to validate message type/length here. A length less than 4 - * is definitely broken. Large lengths should only be believed - * for a few message types. + * Try to validate message type/length here. A length less than 4 is + * definitely broken. Large lengths should only be believed for a few + * message types. */ if (msgLength < 4) { @@ -106,20 +106,20 @@ pqParseInput3(PGconn *conn) if (avail < msgLength) { /* - * Before returning, enlarge the input buffer if needed to - * hold the whole message. This is better than leaving it to - * pqReadData because we can avoid multiple cycles of - * realloc() when the message is large; also, we can implement - * a reasonable recovery strategy if we are unable to make the - * buffer big enough. + * Before returning, enlarge the input buffer if needed to hold + * the whole message. This is better than leaving it to + * pqReadData because we can avoid multiple cycles of realloc() + * when the message is large; also, we can implement a reasonable + * recovery strategy if we are unable to make the buffer big + * enough. */ if (pqCheckInBufferSpace(conn->inCursor + msgLength, conn)) { /* - * XXX add some better recovery code... plan is to skip - * over the message using its length, then report an - * error. For the moment, just treat this like loss of - * sync (which indeed it might be!) + * XXX add some better recovery code... plan is to skip over + * the message using its length, then report an error. For the + * moment, just treat this like loss of sync (which indeed it + * might be!) */ handleSyncLoss(conn, id, msgLength); } @@ -127,20 +127,20 @@ pqParseInput3(PGconn *conn) } /* - * NOTIFY and NOTICE messages can happen in any state; always - * process them right away. + * NOTIFY and NOTICE messages can happen in any state; always process + * them right away. * - * Most other messages should only be processed while in BUSY state. - * (In particular, in READY state we hold off further parsing - * until the application collects the current PGresult.) + * Most other messages should only be processed while in BUSY state. (In + * particular, in READY state we hold off further parsing until the + * application collects the current PGresult.) * * However, if the state is IDLE then we got trouble; we need to deal * with the unexpected message somehow. * - * ParameterStatus ('S') messages are a special case: in IDLE state - * we must process 'em (this case could happen if a new value was - * adopted from config file due to SIGHUP), but otherwise we hold - * off until BUSY state. + * ParameterStatus ('S') messages are a special case: in IDLE state we + * must process 'em (this case could happen if a new value was adopted + * from config file due to SIGHUP), but otherwise we hold off until + * BUSY state. */ if (id == 'A') { @@ -163,9 +163,9 @@ pqParseInput3(PGconn *conn) * ERROR messages are displayed using the notice processor; * ParameterStatus is handled normally; anything else is just * dropped on the floor after displaying a suitable warning - * notice. (An ERROR is very possibly the backend telling us - * why it is about to close the connection, so we don't want - * to just discard it...) + * notice. (An ERROR is very possibly the backend telling us why + * it is about to close the connection, so we don't want to just + * discard it...) */ if (id == 'E') { @@ -180,7 +180,7 @@ pqParseInput3(PGconn *conn) else { pqInternalNotice(&conn->noticeHooks, - "message type 0x%02x arrived from server while idle", + "message type 0x%02x arrived from server while idle", id); /* Discard the unexpected message */ conn->inCursor += msgLength; @@ -199,7 +199,7 @@ pqParseInput3(PGconn *conn) if (conn->result == NULL) { conn->result = PQmakeEmptyPGresult(conn, - PGRES_COMMAND_OK); + PGRES_COMMAND_OK); if (!conn->result) return; } @@ -221,7 +221,7 @@ pqParseInput3(PGconn *conn) if (conn->result == NULL) { conn->result = PQmakeEmptyPGresult(conn, - PGRES_EMPTY_QUERY); + PGRES_EMPTY_QUERY); if (!conn->result) return; } @@ -234,7 +234,7 @@ pqParseInput3(PGconn *conn) if (conn->result == NULL) { conn->result = PQmakeEmptyPGresult(conn, - PGRES_COMMAND_OK); + PGRES_COMMAND_OK); if (!conn->result) return; } @@ -252,9 +252,9 @@ pqParseInput3(PGconn *conn) case 'K': /* secret key data from the backend */ /* - * This is expected only during backend startup, but - * it's just as easy to handle it as part of the main - * loop. Save the data and continue processing. + * This is expected only during backend startup, but it's + * just as easy to handle it as part of the main loop. + * Save the data and continue processing. */ if (pqGetInt(&(conn->be_pid), 4, conn)) return; @@ -272,10 +272,10 @@ pqParseInput3(PGconn *conn) { /* * A new 'T' message is treated as the start of - * another PGresult. (It is not clear that this - * is really possible with the current backend.) - * We stop parsing until the application accepts - * the current result. + * another PGresult. (It is not clear that this is + * really possible with the current backend.) We stop + * parsing until the application accepts the current + * result. */ conn->asyncStatus = PGASYNC_READY; return; @@ -285,13 +285,13 @@ pqParseInput3(PGconn *conn) /* * NoData indicates that we will not be seeing a - * RowDescription message because the statement or - * portal inquired about doesn't return rows. Set up a - * COMMAND_OK result, instead of TUPLES_OK. + * RowDescription message because the statement or portal + * inquired about doesn't return rows. Set up a COMMAND_OK + * result, instead of TUPLES_OK. */ if (conn->result == NULL) conn->result = PQmakeEmptyPGresult(conn, - PGRES_COMMAND_OK); + PGRES_COMMAND_OK); break; case 'D': /* Data Row */ if (conn->result != NULL && @@ -302,12 +302,11 @@ pqParseInput3(PGconn *conn) return; } else if (conn->result != NULL && - conn->result->resultStatus == PGRES_FATAL_ERROR) + conn->result->resultStatus == PGRES_FATAL_ERROR) { /* - * We've already choked for some reason. Just - * discard tuples till we get to the end of the - * query. + * We've already choked for some reason. Just discard + * tuples till we get to the end of the query. */ conn->inCursor += msgLength; } @@ -335,19 +334,19 @@ pqParseInput3(PGconn *conn) case 'd': /* Copy Data */ /* - * If we see Copy Data, just silently drop it. This - * would only occur if application exits COPY OUT mode - * too early. + * If we see Copy Data, just silently drop it. This would + * only occur if application exits COPY OUT mode too + * early. */ conn->inCursor += msgLength; break; case 'c': /* Copy Done */ /* - * If we see Copy Done, just silently drop it. This - * is the normal case during PQendcopy. We will keep - * swallowing data, expecting to see command-complete - * for the COPY command. + * If we see Copy Done, just silently drop it. This is + * the normal case during PQendcopy. We will keep + * swallowing data, expecting to see command-complete for + * the COPY command. */ break; default: @@ -395,7 +394,7 @@ handleSyncLoss(PGconn *conn, char id, int msgLength) { printfPQExpBuffer(&conn->errorMessage, libpq_gettext( - "lost synchronization with server: got message type \"%c\", length %d\n"), + "lost synchronization with server: got message type \"%c\", length %d\n"), id, msgLength); /* build an error result holding the error message */ pqSaveErrorResult(conn); @@ -618,16 +617,16 @@ pqGetErrorNotice3(PGconn *conn, bool isError) /* * Since the fields might be pretty long, we create a temporary - * PQExpBuffer rather than using conn->workBuffer. workBuffer is - * intended for stuff that is expected to be short. We shouldn't use + * PQExpBuffer rather than using conn->workBuffer. workBuffer is intended + * for stuff that is expected to be short. We shouldn't use * conn->errorMessage either, since this might be only a notice. */ initPQExpBuffer(&workBuf); /* * Make a PGresult to hold the accumulated fields. We temporarily lie - * about the result status, so that PQmakeEmptyPGresult doesn't - * uselessly copy conn->errorMessage. + * about the result status, so that PQmakeEmptyPGresult doesn't uselessly + * copy conn->errorMessage. */ res = PQmakeEmptyPGresult(conn, PGRES_EMPTY_QUERY); if (!res) @@ -808,9 +807,9 @@ getNotify(PGconn *conn) } /* - * Store the strings right after the PQnotify structure so it can all - * be freed at once. We don't use NAMEDATALEN because we don't want - * to tie this interface to a specific server name length. + * Store the strings right after the PQnotify structure so it can all be + * freed at once. We don't use NAMEDATALEN because we don't want to tie + * this interface to a specific server name length. */ nmlen = strlen(svname); extralen = strlen(conn->workBuffer.data); @@ -940,9 +939,9 @@ pqGetCopyData3(PGconn *conn, char **buffer, int async) for (;;) { /* - * Do we have the next input message? To make life simpler for - * async callers, we keep returning 0 until the next message is - * fully available, even if it is not Copy Data. + * Do we have the next input message? To make life simpler for async + * callers, we keep returning 0 until the next message is fully + * available, even if it is not Copy Data. */ conn->inCursor = conn->inStart; if (pqGetc(&id, conn)) @@ -1017,7 +1016,7 @@ pqGetline3(PGconn *conn, char *s, int maxlen) conn->copy_is_binary) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("PQgetline: not doing text COPY OUT\n")); + libpq_gettext("PQgetline: not doing text COPY OUT\n")); *s = '\0'; return EOF; } @@ -1070,9 +1069,8 @@ pqGetlineAsync3(PGconn *conn, char *buffer, int bufsize) /* * Recognize the next input message. To make life simpler for async - * callers, we keep returning 0 until the next message is fully - * available even if it is not Copy Data. This should keep PQendcopy - * from blocking. + * callers, we keep returning 0 until the next message is fully available + * even if it is not Copy Data. This should keep PQendcopy from blocking. */ conn->inCursor = conn->inStart; if (pqGetc(&id, conn)) @@ -1084,8 +1082,8 @@ pqGetlineAsync3(PGconn *conn, char *buffer, int bufsize) return 0; /* - * Cannot proceed unless it's a Copy Data message. Anything else - * means end of copy mode. + * Cannot proceed unless it's a Copy Data message. Anything else means + * end of copy mode. */ if (id != 'd') return -1; @@ -1144,8 +1142,8 @@ pqEndcopy3(PGconn *conn) return 1; /* - * If we sent the COPY command in extended-query mode, we must - * issue a Sync as well. + * If we sent the COPY command in extended-query mode, we must issue a + * Sync as well. */ if (conn->queryclass != PGQUERY_SIMPLE) { @@ -1156,8 +1154,8 @@ pqEndcopy3(PGconn *conn) } /* - * make sure no data is waiting to be sent, abort if we are - * non-blocking and the flush fails + * make sure no data is waiting to be sent, abort if we are non-blocking + * and the flush fails */ if (pqFlush(conn) && pqIsnonblocking(conn)) return (1); @@ -1167,12 +1165,11 @@ pqEndcopy3(PGconn *conn) resetPQExpBuffer(&conn->errorMessage); /* - * Non blocking connections may have to abort at this point. If - * everyone played the game there should be no problem, but in error - * scenarios the expected messages may not have arrived yet. (We are - * assuming that the backend's packetizing will ensure that - * CommandComplete arrives along with the CopyDone; are there corner - * cases where that doesn't happen?) + * Non blocking connections may have to abort at this point. If everyone + * played the game there should be no problem, but in error scenarios the + * expected messages may not have arrived yet. (We are assuming that the + * backend's packetizing will ensure that CommandComplete arrives along + * with the CopyDone; are there corner cases where that doesn't happen?) */ if (pqIsnonblocking(conn) && PQisBusy(conn)) return (1); @@ -1191,8 +1188,8 @@ pqEndcopy3(PGconn *conn) * Trouble. For backwards-compatibility reasons, we issue the error * message as if it were a notice (would be nice to get rid of this * silliness, but too many apps probably don't handle errors from - * PQendcopy reasonably). Note that the app can still obtain the - * error status from the PGconn object. + * PQendcopy reasonably). Note that the app can still obtain the error + * status from the PGconn object. */ if (conn->errorMessage.len > 0) { @@ -1293,8 +1290,7 @@ pqFunctionCall3(PGconn *conn, Oid fnid, } /* - * Scan the message. If we run out of data, loop around to try - * again. + * Scan the message. If we run out of data, loop around to try again. */ needInput = true; @@ -1305,9 +1301,9 @@ pqFunctionCall3(PGconn *conn, Oid fnid, continue; /* - * Try to validate message type/length here. A length less than 4 - * is definitely broken. Large lengths should only be believed - * for a few message types. + * Try to validate message type/length here. A length less than 4 is + * definitely broken. Large lengths should only be believed for a few + * message types. */ if (msgLength < 4) { @@ -1328,16 +1324,16 @@ pqFunctionCall3(PGconn *conn, Oid fnid, if (avail < msgLength) { /* - * Before looping, enlarge the input buffer if needed to hold - * the whole message. See notes in parseInput. + * Before looping, enlarge the input buffer if needed to hold the + * whole message. See notes in parseInput. */ if (pqCheckInBufferSpace(conn->inCursor + msgLength, conn)) { /* - * XXX add some better recovery code... plan is to skip - * over the message using its length, then report an - * error. For the moment, just treat this like loss of - * sync (which indeed it might be!) + * XXX add some better recovery code... plan is to skip over + * the message using its length, then report an error. For the + * moment, just treat this like loss of sync (which indeed it + * might be!) */ handleSyncLoss(conn, id, msgLength); break; @@ -1347,8 +1343,8 @@ pqFunctionCall3(PGconn *conn, Oid fnid, /* * We should see V or E response to the command, but might get N - * and/or A notices first. We also need to swallow the final Z - * before returning. + * and/or A notices first. We also need to swallow the final Z before + * returning. */ switch (id) { @@ -1404,7 +1400,7 @@ pqFunctionCall3(PGconn *conn, Oid fnid, default: /* The backend violates the protocol. */ printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("protocol error: id=0x%x\n"), + libpq_gettext("protocol error: id=0x%x\n"), id); pqSaveErrorResult(conn); /* trust the specified message length as what to skip */ @@ -1434,7 +1430,7 @@ pqFunctionCall3(PGconn *conn, Oid fnid, */ char * pqBuildStartupPacket3(PGconn *conn, int *packetlen, - const PQEnvironmentOption *options) + const PQEnvironmentOption * options) { char *startpacket; @@ -1457,7 +1453,7 @@ pqBuildStartupPacket3(PGconn *conn, int *packetlen, */ static int build_startup_packet(const PGconn *conn, char *packet, - const PQEnvironmentOption *options) + const PQEnvironmentOption * options) { int packet_len = 0; const PQEnvironmentOption *next_eo; diff --git a/src/interfaces/libpq/fe-secure.c b/src/interfaces/libpq/fe-secure.c index 4ef11616ae..316ea4ac26 100644 --- a/src/interfaces/libpq/fe-secure.c +++ b/src/interfaces/libpq/fe-secure.c @@ -11,7 +11,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/libpq/fe-secure.c,v 1.71 2005/08/28 16:37:48 momjian Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-secure.c,v 1.72 2005/10/15 02:49:48 momjian Exp $ * * NOTES * [ Most of these notes are wrong/obsolete, but perhaps not all ] @@ -274,15 +274,16 @@ pqsecure_open_client(PGconn *conn) char *err = SSLerrmessage(); printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not establish SSL connection: %s\n"), + libpq_gettext("could not establish SSL connection: %s\n"), err); SSLerrfree(err); close_SSL(conn); return PGRES_POLLING_FAILED; } + /* - * Initialize errorMessage to empty. This allows open_client_SSL() - * to detect whether client_cert_cb() has stored a message. + * Initialize errorMessage to empty. This allows open_client_SSL() to + * detect whether client_cert_cb() has stored a message. */ resetPQExpBuffer(&conn->errorMessage); } @@ -332,11 +333,10 @@ rloop: case SSL_ERROR_WANT_WRITE: /* - * Returning 0 here would cause caller to wait for - * read-ready, which is not correct since what SSL wants - * is wait for write-ready. The former could get us stuck - * in an infinite wait, so don't risk it; busy-loop - * instead. + * Returning 0 here would cause caller to wait for read-ready, + * which is not correct since what SSL wants is wait for + * write-ready. The former could get us stuck in an infinite + * wait, so don't risk it; busy-loop instead. */ goto rloop; case SSL_ERROR_SYSCALL: @@ -345,12 +345,12 @@ rloop: if (n == -1) printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("SSL SYSCALL error: %s\n"), - SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf))); + libpq_gettext("SSL SYSCALL error: %s\n"), + SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf))); else { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("SSL SYSCALL error: EOF detected\n")); + libpq_gettext("SSL SYSCALL error: EOF detected\n")); SOCK_ERRNO_SET(ECONNRESET); n = -1; @@ -362,7 +362,7 @@ rloop: char *err = SSLerrmessage(); printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("SSL error: %s\n"), err); + libpq_gettext("SSL error: %s\n"), err); SSLerrfree(err); } /* fall through */ @@ -372,7 +372,7 @@ rloop: break; default: printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("unrecognized SSL error code: %d\n"), + libpq_gettext("unrecognized SSL error code: %d\n"), err); n = -1; break; @@ -392,21 +392,21 @@ ssize_t pqsecure_write(PGconn *conn, const void *ptr, size_t len) { ssize_t n; - -#ifndef WIN32 + +#ifndef WIN32 #ifdef ENABLE_THREAD_SAFETY sigset_t osigmask; bool sigpipe_pending; bool got_epipe = false; - + if (pq_block_sigpipe(&osigmask, &sigpipe_pending) < 0) return -1; #else pqsigfunc oldsighandler = pqsignal(SIGPIPE, SIG_IGN); -#endif /* ENABLE_THREAD_SAFETY */ -#endif /* WIN32 */ - +#endif /* ENABLE_THREAD_SAFETY */ +#endif /* WIN32 */ + #ifdef USE_SSL if (conn->ssl) { @@ -422,8 +422,8 @@ pqsecure_write(PGconn *conn, const void *ptr, size_t len) /* * Returning 0 here causes caller to wait for write-ready, - * which is not really the right thing, but it's the best - * we can do. + * which is not really the right thing, but it's the best we + * can do. */ n = 0; break; @@ -441,13 +441,13 @@ pqsecure_write(PGconn *conn, const void *ptr, size_t len) got_epipe = true; #endif printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("SSL SYSCALL error: %s\n"), - SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf))); + libpq_gettext("SSL SYSCALL error: %s\n"), + SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf))); } else { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("SSL SYSCALL error: EOF detected\n")); + libpq_gettext("SSL SYSCALL error: EOF detected\n")); SOCK_ERRNO_SET(ECONNRESET); n = -1; } @@ -458,7 +458,7 @@ pqsecure_write(PGconn *conn, const void *ptr, size_t len) char *err = SSLerrmessage(); printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("SSL error: %s\n"), err); + libpq_gettext("SSL error: %s\n"), err); SSLerrfree(err); } /* fall through */ @@ -468,7 +468,7 @@ pqsecure_write(PGconn *conn, const void *ptr, size_t len) break; default: printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("unrecognized SSL error code: %d\n"), + libpq_gettext("unrecognized SSL error code: %d\n"), err); n = -1; break; @@ -483,14 +483,14 @@ pqsecure_write(PGconn *conn, const void *ptr, size_t len) got_epipe = true; #endif } - + #ifndef WIN32 #ifdef ENABLE_THREAD_SAFETY pq_reset_sigpipe(&osigmask, sigpipe_pending, got_epipe); #else pqsignal(SIGPIPE, oldsighandler); -#endif /* ENABLE_THREAD_SAFETY */ -#endif /* WIN32 */ +#endif /* ENABLE_THREAD_SAFETY */ +#endif /* WIN32 */ return n; } @@ -539,7 +539,7 @@ verify_peer(PGconn *conn) printfPQExpBuffer(&conn->errorMessage, libpq_gettext("error querying socket: %s\n"), - SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf))); + SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf))); return -1; } @@ -553,10 +553,9 @@ verify_peer(PGconn *conn) int herrno = 0; /* - * Currently, pqGethostbyname() is used only on platforms that - * don't have getaddrinfo(). If you enable this function, you - * should convert the pqGethostbyname() function call to use - * getaddrinfo(). + * Currently, pqGethostbyname() is used only on platforms that don't + * have getaddrinfo(). If you enable this function, you should + * convert the pqGethostbyname() function call to use getaddrinfo(). */ pqGethostbyname(conn->peer_cn, &hpstr, buf, sizeof(buf), &h, &herrno); @@ -566,7 +565,7 @@ verify_peer(PGconn *conn) if (h == NULL) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not get information about host \"%s\": %s\n"), + libpq_gettext("could not get information about host \"%s\": %s\n"), conn->peer_cn, hstrerror(h_errno)); return -1; } @@ -608,19 +607,19 @@ verify_peer(PGconn *conn) printfPQExpBuffer(&conn->errorMessage, libpq_gettext( "server common name \"%s\" does not resolve to %ld.%ld.%ld.%ld\n"), - conn->peer_cn, (l >> 24) % 0x100, (l >> 16) % 0x100, + conn->peer_cn, (l >> 24) % 0x100, (l >> 16) % 0x100, (l >> 8) % 0x100, l % 0x100); break; default: printfPQExpBuffer(&conn->errorMessage, libpq_gettext( - "server common name \"%s\" does not resolve to peer address\n"), + "server common name \"%s\" does not resolve to peer address\n"), conn->peer_cn); } return -1; } -#endif /* NOT_USED */ +#endif /* NOT_USED */ /* * Load precomputed DH parameters. @@ -774,6 +773,7 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey) { char homedir[MAXPGPATH]; struct stat buf; + #ifndef WIN32 struct stat buf2; #endif @@ -786,7 +786,7 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey) if (!pqGetHomeDirectory(homedir, sizeof(homedir))) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not get user information\n")); + libpq_gettext("could not get user information\n")); return 0; } @@ -795,7 +795,7 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey) if ((fp = fopen(fnbuf, "r")) == NULL) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not open certificate file \"%s\": %s\n"), + libpq_gettext("could not open certificate file \"%s\": %s\n"), fnbuf, pqStrerror(errno, sebuf, sizeof(sebuf))); return 0; } @@ -804,7 +804,7 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey) char *err = SSLerrmessage(); printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not read certificate file \"%s\": %s\n"), + libpq_gettext("could not read certificate file \"%s\": %s\n"), fnbuf, err); SSLerrfree(err); fclose(fp); @@ -817,7 +817,7 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey) if (stat(fnbuf, &buf) == -1) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("certificate present, but not private key file \"%s\"\n"), + libpq_gettext("certificate present, but not private key file \"%s\"\n"), fnbuf); return 0; } @@ -826,7 +826,7 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey) buf.st_uid != geteuid()) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("private key file \"%s\" has wrong permissions\n"), + libpq_gettext("private key file \"%s\" has wrong permissions\n"), fnbuf); return 0; } @@ -834,7 +834,7 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey) if ((fp = fopen(fnbuf, "r")) == NULL) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not open private key file \"%s\": %s\n"), + libpq_gettext("could not open private key file \"%s\": %s\n"), fnbuf, pqStrerror(errno, sebuf, sizeof(sebuf))); return 0; } @@ -852,7 +852,7 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey) char *err = SSLerrmessage(); printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not read private key file \"%s\": %s\n"), + libpq_gettext("could not read private key file \"%s\": %s\n"), fnbuf, err); SSLerrfree(err); fclose(fp); @@ -866,7 +866,7 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey) char *err = SSLerrmessage(); printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("certificate does not match private key file \"%s\": %s\n"), + libpq_gettext("certificate does not match private key file \"%s\": %s\n"), fnbuf, err); SSLerrfree(err); return 0; @@ -881,9 +881,9 @@ static unsigned long pq_threadidcallback(void) { /* - * This is not starndard-compliant. pthread_self() returns - * pthread_t, and shouldn't be cast to unsigned long, but - * CRYPTO_set_id_callback requires it, so we have to do it. + * This is not starndard-compliant. pthread_self() returns pthread_t, and + * shouldn't be cast to unsigned long, but CRYPTO_set_id_callback requires + * it, so we have to do it. */ return (unsigned long) pthread_self(); } @@ -898,7 +898,6 @@ pq_lockingcallback(int mode, int n, const char *file, int line) else pthread_mutex_unlock(&pq_lockarray[n]); } - #endif /* ENABLE_THREAD_SAFETY */ static int @@ -907,7 +906,6 @@ init_ssl_system(PGconn *conn) #ifdef ENABLE_THREAD_SAFETY #ifndef WIN32 static pthread_mutex_t init_mutex = PTHREAD_MUTEX_INITIALIZER; - #else static pthread_mutex_t init_mutex = NULL; static long mutex_initlock = 0; @@ -954,7 +952,7 @@ init_ssl_system(PGconn *conn) char *err = SSLerrmessage(); printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not create SSL context: %s\n"), + libpq_gettext("could not create SSL context: %s\n"), err); SSLerrfree(err); #ifdef ENABLE_THREAD_SAFETY @@ -1037,7 +1035,7 @@ open_client_SSL(PGconn *conn) r = SSL_connect(conn->ssl); if (r <= 0) { - int err = SSL_get_error(conn->ssl, r); + int err = SSL_get_error(conn->ssl, r); switch (err) { @@ -1053,11 +1051,11 @@ open_client_SSL(PGconn *conn) if (r == -1) printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("SSL SYSCALL error: %s\n"), - SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf))); + libpq_gettext("SSL SYSCALL error: %s\n"), + SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf))); else printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("SSL SYSCALL error: EOF detected\n")); + libpq_gettext("SSL SYSCALL error: EOF detected\n")); close_SSL(conn); return PGRES_POLLING_FAILED; } @@ -1068,7 +1066,7 @@ open_client_SSL(PGconn *conn) * these will be detected by client_cert_cb() which is * called from SSL_connect(). We want to return that * error message and not the rather unhelpful error that - * OpenSSL itself returns. So check to see if an error + * OpenSSL itself returns. So check to see if an error * message was already stored. */ if (conn->errorMessage.len == 0) @@ -1086,7 +1084,7 @@ open_client_SSL(PGconn *conn) default: printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("unrecognized SSL error code: %d\n"), + libpq_gettext("unrecognized SSL error code: %d\n"), err); close_SSL(conn); return PGRES_POLLING_FAILED; @@ -1106,7 +1104,7 @@ open_client_SSL(PGconn *conn) if (r != X509_V_OK) { printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("certificate could not be validated: %s\n"), + libpq_gettext("certificate could not be validated: %s\n"), X509_verify_cert_error_string(r)); close_SSL(conn); return PGRES_POLLING_FAILED; @@ -1120,7 +1118,7 @@ open_client_SSL(PGconn *conn) char *err = SSLerrmessage(); printfPQExpBuffer(&conn->errorMessage, - libpq_gettext("certificate could not be obtained: %s\n"), + libpq_gettext("certificate could not be obtained: %s\n"), err); SSLerrfree(err); close_SSL(conn); @@ -1142,8 +1140,8 @@ open_client_SSL(PGconn *conn) /* * this is necessary to eliminate man-in-the-middle attacks and - * impersonations where the attacker somehow learned the server's - * private key + * impersonations where the attacker somehow learned the server's private + * key */ if (verify_peer(conn) == -1) { @@ -1231,29 +1229,27 @@ PQgetssl(PGconn *conn) return NULL; return conn->ssl; } - -#else /* !USE_SSL */ +#else /* !USE_SSL */ void * PQgetssl(PGconn *conn) { return NULL; } - #endif /* USE_SSL */ #if defined(ENABLE_THREAD_SAFETY) && !defined(WIN32) /* - * Block SIGPIPE for this thread. This prevents send()/write() from exiting + * Block SIGPIPE for this thread. This prevents send()/write() from exiting * the application. */ int pq_block_sigpipe(sigset_t *osigset, bool *sigpipe_pending) { - sigset_t sigpipe_sigset; - sigset_t sigset; - + sigset_t sigpipe_sigset; + sigset_t sigset; + sigemptyset(&sigpipe_sigset); sigaddset(&sigpipe_sigset, SIGPIPE); @@ -1268,7 +1264,7 @@ pq_block_sigpipe(sigset_t *osigset, bool *sigpipe_pending) /* Is there a pending SIGPIPE? */ if (sigpending(&sigset) != 0) return -1; - + if (sigismember(&sigset, SIGPIPE)) *sigpipe_pending = true; else @@ -1276,15 +1272,15 @@ pq_block_sigpipe(sigset_t *osigset, bool *sigpipe_pending) } else *sigpipe_pending = false; - + return 0; } - + /* * Discard any pending SIGPIPE and reset the signal mask. * * Note: we are effectively assuming here that the C library doesn't queue - * up multiple SIGPIPE events. If it did, then we'd accidentally leave + * up multiple SIGPIPE events. If it did, then we'd accidentally leave * ours in the queue when an event was already pending and we got another. * As long as it doesn't queue multiple events, we're OK because the caller * can't tell the difference. @@ -1295,15 +1291,15 @@ pq_block_sigpipe(sigset_t *osigset, bool *sigpipe_pending) * gotten one, pass got_epipe = TRUE. * * We do not want this to change errno, since if it did that could lose - * the error code from a preceding send(). We essentially assume that if + * the error code from a preceding send(). We essentially assume that if * we were able to do pq_block_sigpipe(), this can't fail. */ void pq_reset_sigpipe(sigset_t *osigset, bool sigpipe_pending, bool got_epipe) { - int save_errno = SOCK_ERRNO; - int signo; - sigset_t sigset; + int save_errno = SOCK_ERRNO; + int signo; + sigset_t sigset; /* Clear SIGPIPE only if none was pending */ if (got_epipe && !sigpipe_pending) @@ -1311,19 +1307,19 @@ pq_reset_sigpipe(sigset_t *osigset, bool sigpipe_pending, bool got_epipe) if (sigpending(&sigset) == 0 && sigismember(&sigset, SIGPIPE)) { - sigset_t sigpipe_sigset; - + sigset_t sigpipe_sigset; + sigemptyset(&sigpipe_sigset); sigaddset(&sigpipe_sigset, SIGPIPE); sigwait(&sigpipe_sigset, &signo); } } - + /* Restore saved block mask */ pthread_sigmask(SIG_SETMASK, osigset, NULL); SOCK_ERRNO_SET(save_errno); } -#endif /* ENABLE_THREAD_SAFETY */ +#endif /* ENABLE_THREAD_SAFETY */ diff --git a/src/interfaces/libpq/libpq-fe.h b/src/interfaces/libpq/libpq-fe.h index f68bc0d658..a26721e9f6 100644 --- a/src/interfaces/libpq/libpq-fe.h +++ b/src/interfaces/libpq/libpq-fe.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/interfaces/libpq/libpq-fe.h,v 1.119 2005/09/24 17:53:28 tgl Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/libpq-fe.h,v 1.120 2005/10/15 02:49:48 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -39,16 +39,16 @@ typedef enum { /* * Although it is okay to add to this list, values which become unused - * should never be removed, nor should constants be redefined - that - * would break compatibility with existing code. + * should never be removed, nor should constants be redefined - that would + * break compatibility with existing code. */ CONNECTION_OK, CONNECTION_BAD, /* Non-blocking mode only below here */ /* - * The existence of these should never be relied upon - they should - * only be used for user feedback or similar purposes. + * The existence of these should never be relied upon - they should only + * be used for user feedback or similar purposes. */ CONNECTION_STARTED, /* Waiting for connection to be made. */ CONNECTION_MADE, /* Connection OK; waiting to send. */ @@ -78,12 +78,12 @@ typedef enum * 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 */ + * 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 */ - PGRES_BAD_RESPONSE, /* an unexpected response was recv'd from - * the backend */ + PGRES_BAD_RESPONSE, /* an unexpected response was recv'd from the + * backend */ PGRES_NONFATAL_ERROR, /* notice or warning message */ PGRES_FATAL_ERROR /* query failed */ } ExecStatusType; @@ -146,8 +146,7 @@ typedef char pqbool; typedef struct _PQprintOpt { - pqbool header; /* print output field headings and row - * count */ + pqbool header; /* print output field headings and row count */ pqbool align; /* fill align the fields */ pqbool standard; /* old brain dead format */ pqbool html3; /* output html tables */ @@ -156,8 +155,8 @@ typedef struct _PQprintOpt char *fieldSep; /* field separator */ char *tableOpt; /* insert to HTML */ char *caption; /* HTML
*/ - char **fieldName; /* null terminated array of replacement - * field names */ + char **fieldName; /* null terminated array of replacement field + * names */ } PQprintOpt; /* ---------------- @@ -175,11 +174,11 @@ typedef struct _PQconninfoOption char *compiled; /* Fallback compiled in default value */ char *val; /* Option's current value, or NULL */ 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 - * option - don't show by default */ + 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 option - don't show + * by default */ int dispsize; /* Field size in characters for dialog */ } PQconninfoOption; @@ -321,8 +320,8 @@ extern PGresult *PQexecParams(PGconn *conn, const int *paramFormats, int resultFormat); extern PGresult *PQprepare(PGconn *conn, const char *stmtName, - const char *query, int nParams, - const Oid *paramTypes); + const char *query, int nParams, + const Oid *paramTypes); extern PGresult *PQexecPrepared(PGconn *conn, const char *stmtName, int nParams, @@ -342,8 +341,8 @@ extern int PQsendQueryParams(PGconn *conn, const int *paramFormats, int resultFormat); extern int PQsendPrepare(PGconn *conn, const char *stmtName, - const char *query, int nParams, - const Oid *paramTypes); + const char *query, int nParams, + const Oid *paramTypes); extern int PQsendQueryPrepared(PGconn *conn, const char *stmtName, int nParams, @@ -467,8 +466,7 @@ PQprintTuples(const PGresult *res, FILE *fout, /* output stream */ int printAttName, /* print attribute names */ int terseOutput, /* delimiter bars */ - int width); /* width of column, if 0, use variable - * width */ + int width); /* width of column, if 0, use variable width */ /* === in fe-lobj.c === */ diff --git a/src/interfaces/libpq/libpq-int.h b/src/interfaces/libpq/libpq-int.h index 3eb66dea2d..d2ee44753b 100644 --- a/src/interfaces/libpq/libpq-int.h +++ b/src/interfaces/libpq/libpq-int.h @@ -12,7 +12,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/interfaces/libpq/libpq-int.h,v 1.107 2005/08/23 21:02:03 momjian Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/libpq-int.h,v 1.108 2005/10/15 02:49:49 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -39,8 +39,8 @@ #endif #ifdef WIN32_CLIENT_ONLY -typedef int ssize_t; /* ssize_t doesn't exist in VC (at least - * not VC6) */ +typedef int ssize_t; /* ssize_t doesn't exist in VC (at least not + * VC6) */ #endif /* include stuff common to fe and be */ @@ -92,7 +92,7 @@ typedef struct pgresAttDesc Oid typid; /* type id */ int typlen; /* type size */ int atttypmod; /* type-specific modifier info */ -} PGresAttDesc; +} PGresAttDesc; /* * Data for a single attribute of a single tuple @@ -117,9 +117,8 @@ typedef struct pgresAttDesc typedef struct pgresAttValue { int len; /* length in bytes of the value */ - char *value; /* actual value, plus terminating zero - * byte */ -} PGresAttValue; + char *value; /* actual value, plus terminating zero byte */ +} PGresAttValue; /* Typedef for message-field list entries */ typedef struct pgMessageField @@ -127,7 +126,7 @@ typedef struct pgMessageField struct pgMessageField *next; /* list link */ char code; /* field code */ char contents[1]; /* field value (VARIABLE LENGTH) */ -} PGMessageField; +} PGMessageField; /* Fields needed for notice handling */ typedef struct @@ -136,7 +135,7 @@ typedef struct void *noticeRecArg; PQnoticeProcessor noticeProc; /* notice message processor */ void *noticeProcArg; -} PGNoticeHooks; +} PGNoticeHooks; struct pg_result { @@ -147,22 +146,21 @@ struct pg_result * PGresAttValue's */ int tupArrSize; /* allocated size of tuples array */ ExecStatusType resultStatus; - char cmdStatus[CMDSTATUS_LEN]; /* cmd status from the - * query */ + char cmdStatus[CMDSTATUS_LEN]; /* cmd status from the query */ int binary; /* binary tuple values if binary == 1, * otherwise text */ /* - * These fields are copied from the originating PGconn, so that - * operations on the PGresult don't have to reference the PGconn. + * These fields are copied from the originating PGconn, so that operations + * on the PGresult don't have to reference the PGconn. */ PGNoticeHooks noticeHooks; int client_encoding; /* encoding id */ /* * Error information (all NULL if not an error result). errMsg is the - * "overall" error message returned by PQresultErrorMessage. If we - * have per-field info then it is stored in a linked list. + * "overall" error message returned by PQresultErrorMessage. If we have + * per-field info then it is stored in a linked list. */ char *errMsg; /* error message, or NULL if no error */ PGMessageField *errFields; /* message broken into fields */ @@ -171,8 +169,8 @@ struct pg_result char null_field[1]; /* - * Space management information. Note that attDescs and error stuff, - * if not null, point into allocated blocks. But tuples points to a + * Space management information. Note that attDescs and error stuff, 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 */ @@ -188,7 +186,7 @@ typedef enum 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; +} PGAsyncStatusType; /* PGQueryClass tracks which query protocol we are now executing */ typedef enum @@ -196,7 +194,7 @@ typedef enum PGQUERY_SIMPLE, /* simple Query protocol (PQexec) */ PGQUERY_EXTENDED, /* full Extended protocol (PQexecParams) */ PGQUERY_PREPARE /* Parse only (PQprepare) */ -} PGQueryClass; +} PGQueryClass; /* PGSetenvStatusType defines the state of the PQSetenv state machine */ /* (this is used only for 2.0-protocol connections) */ @@ -209,14 +207,14 @@ typedef enum SETENV_STATE_QUERY2_SEND, /* About to send a status query */ SETENV_STATE_QUERY2_WAIT, /* Waiting for query to complete */ SETENV_STATE_IDLE -} PGSetenvStatusType; +} PGSetenvStatusType; /* Typedef for the EnvironmentOptions[] array */ typedef struct PQEnvironmentOption { const char *envName, /* name of an environment variable */ *pgName; /* name of corresponding SET variable */ -} PQEnvironmentOption; +} PQEnvironmentOption; /* Typedef for parameter-status list entries */ typedef struct pgParameterStatus @@ -225,7 +223,7 @@ typedef struct pgParameterStatus char *name; /* parameter name */ char *value; /* parameter value */ /* Note: name and value are stored in same malloc block as struct is */ -} pgParameterStatus; +} pgParameterStatus; /* large-object-access data ... allocated only if large-object code is used. */ typedef struct pgLobjfuncs @@ -239,7 +237,7 @@ typedef struct pgLobjfuncs 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; +} PGlobjfuncs; /* * PGconn stores all the state data associated with a single connection @@ -248,16 +246,15 @@ typedef struct pgLobjfuncs struct pg_conn { /* Saved values of connection options */ - char *pghost; /* the machine on which the server is - * running */ - char *pghostaddr; /* the IPv4 address of the machine on - * which the server is running, in IPv4 - * numbers-and-dots notation. Takes - * precedence over above. */ + char *pghost; /* the machine on which the server is running */ + char *pghostaddr; /* the IPv4 address of the machine on which + * the server is running, in IPv4 + * numbers-and-dots notation. Takes precedence + * over above. */ char *pgport; /* the server's communication port */ - char *pgunixsocket; /* the Unix-domain socket that the server - * is listening on; if NULL, uses a - * default constructed from pgport */ + char *pgunixsocket; /* the Unix-domain socket that the server is + * listening on; if NULL, uses a default + * constructed from pgport */ char *pgtty; /* tty on which the backend messages is * displayed (OBSOLETE, NOT USED) */ char *connect_timeout; /* connection timeout (numeric string) */ @@ -267,7 +264,7 @@ struct pg_conn char *pgpass; char *sslmode; /* SSL mode (require,prefer,allow,disable) */ #ifdef KRB5 - char *krbsrvname; /* Kerberos service name */ + char *krbsrvname; /* Kerberos service name */ #endif /* Optional file to write trace info to */ @@ -282,11 +279,11 @@ struct pg_conn PGTransactionStatusType xactStatus; /* note: xactStatus never changes to ACTIVE */ PGQueryClass queryclass; - bool nonblocking; /* whether this connection is using - * nonblock sending semantics */ + bool nonblocking; /* whether this connection is using nonblock + * sending semantics */ char copy_is_binary; /* 1 = copy binary, 0 = copy text */ - int copy_already_done; /* # bytes already returned in - * COPY OUT */ + int copy_already_done; /* # bytes already returned in COPY + * OUT */ PGnotify *notifyHead; /* oldest unreported Notify msg */ PGnotify *notifyTail; /* newest unreported Notify msg */ @@ -312,17 +309,14 @@ struct pg_conn pgParameterStatus *pstatus; /* ParameterStatus data */ int client_encoding; /* encoding id */ PGVerbosity verbosity; /* error/notice message verbosity */ - PGlobjfuncs *lobjfuncs; /* private state for large-object access - * fns */ + 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 inStart; /* offset to first unconsumed data in buffer */ int inCursor; /* next byte to tentatively consume */ - int inEnd; /* offset to first position after avail - * data */ + int inEnd; /* offset to first position after avail data */ /* Buffer for data not yet sent to backend */ char *outBuffer; /* currently allocated buffer */ @@ -330,8 +324,8 @@ struct pg_conn int outCount; /* number of chars waiting in buffer */ /* State for constructing messages in outBuffer */ - int outMsgStart; /* offset to msg start (length word); if - * -1, msg has no length word */ + int outMsgStart; /* offset to msg start (length word); if -1, + * msg has no length word */ int outMsgEnd; /* offset to msg end (so far) */ /* Status for asynchronous result construction */ @@ -408,10 +402,10 @@ extern void pqClearAsyncResult(PGconn *conn); extern void pqSaveErrorResult(PGconn *conn); extern PGresult *pqPrepareAsyncResult(PGconn *conn); extern void -pqInternalNotice(const PGNoticeHooks *hooks, const char *fmt, ...) +pqInternalNotice(const PGNoticeHooks * hooks, const char *fmt,...) /* This lets gcc check the format string for consistency. */ __attribute__((format(printf, 2, 3))); -extern int pqAddTuple(PGresult *res, PGresAttValue *tup); +extern int pqAddTuple(PGresult *res, PGresAttValue * tup); extern void pqSaveMessageField(PGresult *res, char code, const char *value); extern void pqSaveParameterStatus(PGconn *conn, const char *name, @@ -423,7 +417,7 @@ extern void pqHandleSendFailure(PGconn *conn); extern PostgresPollingStatusType pqSetenvPoll(PGconn *conn); extern char *pqBuildStartupPacket2(PGconn *conn, int *packetlen, - const PQEnvironmentOption *options); + const PQEnvironmentOption * options); extern void pqParseInput2(PGconn *conn); extern int pqGetCopyData2(PGconn *conn, char **buffer, int async); extern int pqGetline2(PGconn *conn, char *s, int maxlen); @@ -437,7 +431,7 @@ extern PGresult *pqFunctionCall2(PGconn *conn, Oid fnid, /* === in fe-protocol3.c === */ extern char *pqBuildStartupPacket3(PGconn *conn, int *packetlen, - const PQEnvironmentOption *options); + const PQEnvironmentOption * options); extern void pqParseInput3(PGconn *conn); extern int pqGetErrorNotice3(PGconn *conn, bool isError); extern int pqGetCopyData3(PGconn *conn, char **buffer, int async); @@ -452,8 +446,8 @@ extern PGresult *pqFunctionCall3(PGconn *conn, Oid fnid, /* === in fe-misc.c === */ /* - * "Get" and "Put" routines return 0 if successful, EOF if not. Note that - * for Get, EOF merely means the buffer is exhausted, not that there is + * "Get" and "Put" routines return 0 if successful, EOF if not. Note that for + * Get, EOF merely means the buffer is exhausted, not that there is * necessarily any error. */ extern int pqCheckOutBufferSpace(int bytes_needed, PGconn *conn); @@ -488,7 +482,7 @@ extern ssize_t pqsecure_write(PGconn *, const void *ptr, size_t len); #if defined(ENABLE_THREAD_SAFETY) && !defined(WIN32) extern int pq_block_sigpipe(sigset_t *osigset, bool *sigpipe_pending); extern void pq_reset_sigpipe(sigset_t *osigset, bool sigpipe_pending, - bool got_epipe); + bool got_epipe); #endif /* @@ -501,7 +495,6 @@ extern void pq_reset_sigpipe(sigset_t *osigset, bool sigpipe_pending, extern char * libpq_gettext(const char *msgid) __attribute__((format_arg(1))); - #else #define libpq_gettext(x) (x) #endif diff --git a/src/interfaces/libpq/pqexpbuffer.c b/src/interfaces/libpq/pqexpbuffer.c index 279faeba23..b28adc434b 100644 --- a/src/interfaces/libpq/pqexpbuffer.c +++ b/src/interfaces/libpq/pqexpbuffer.c @@ -17,7 +17,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/interfaces/libpq/pqexpbuffer.c,v 1.20 2004/12/31 22:03:50 pgsql Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/pqexpbuffer.c,v 1.21 2005/10/15 02:49:49 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -135,9 +135,9 @@ enlargePQExpBuffer(PQExpBuffer str, size_t needed) char *newdata; /* - * Guard against ridiculous "needed" values, which can occur if we're - * fed bogus data. Without this, we can get an overflow or infinite - * loop in the following. + * Guard against ridiculous "needed" values, which can occur if we're fed + * bogus data. Without this, we can get an overflow or infinite loop in + * the following. */ if (needed >= ((size_t) INT_MAX - str->len)) return 0; @@ -150,19 +150,18 @@ enlargePQExpBuffer(PQExpBuffer str, size_t needed) return 1; /* 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 = (str->maxlen > 0) ? (2 * str->maxlen) : 64; while (needed > newlen) newlen = 2 * newlen; /* - * Clamp to INT_MAX in case we went past it. Note we are assuming - * here that INT_MAX <= UINT_MAX/2, else the above loop could - * overflow. We will still have newlen >= needed. + * Clamp to INT_MAX in case we went past it. Note we are assuming here + * that INT_MAX <= UINT_MAX/2, else the above loop could overflow. We + * will still have newlen >= needed. */ if (newlen > (size_t) INT_MAX) newlen = (size_t) INT_MAX; @@ -197,8 +196,8 @@ printfPQExpBuffer(PQExpBuffer str, const char *fmt,...) { /* * Try to format the given string into the available space; but if - * there's hardly any space, don't bother trying, just fall - * through to enlarge the buffer first. + * there's hardly any space, don't bother trying, just fall through to + * enlarge the buffer first. */ if (str->maxlen > str->len + 16) { @@ -245,8 +244,8 @@ appendPQExpBuffer(PQExpBuffer str, const char *fmt,...) { /* * Try to format the given string into the available space; but if - * there's hardly any space, don't bother trying, just fall - * through to enlarge the buffer first. + * there's hardly any space, don't bother trying, just fall through to + * enlarge the buffer first. */ if (str->maxlen > str->len + 16) { @@ -321,8 +320,8 @@ appendBinaryPQExpBuffer(PQExpBuffer str, const char *data, size_t datalen) str->len += datalen; /* - * Keep a trailing null in place, even though it's probably useless - * for binary data... + * Keep a trailing null in place, even though it's probably useless for + * binary data... */ str->data[str->len] = '\0'; } diff --git a/src/interfaces/libpq/pthread-win32.h b/src/interfaces/libpq/pthread-win32.h index 4109c89871..c30eaeb291 100644 --- a/src/interfaces/libpq/pthread-win32.h +++ b/src/interfaces/libpq/pthread-win32.h @@ -5,13 +5,15 @@ typedef ULONG pthread_key_t; typedef HANDLE pthread_mutex_t; typedef int pthread_once_t; -DWORD pthread_self(); +DWORD pthread_self(); -void pthread_setspecific(pthread_key_t, void*); -void* pthread_getspecific(pthread_key_t); +void pthread_setspecific(pthread_key_t, void *); +void *pthread_getspecific(pthread_key_t); -void pthread_mutex_init(pthread_mutex_t *, void *attr); -void pthread_mutex_lock(pthread_mutex_t*); // blocking -void pthread_mutex_unlock(pthread_mutex_t*); +void pthread_mutex_init(pthread_mutex_t *, void *attr); +void pthread_mutex_lock(pthread_mutex_t *); + +//blocking +void pthread_mutex_unlock(pthread_mutex_t *); #endif diff --git a/src/interfaces/libpq/win32.c b/src/interfaces/libpq/win32.c index bd48b2d2cd..dbca603e0d 100644 --- a/src/interfaces/libpq/win32.c +++ b/src/interfaces/libpq/win32.c @@ -290,7 +290,7 @@ winsock_strerror(int err, char *strerrbuf, size_t buflen) dlls[i].handle = (void *) LoadLibraryEx( dlls[i].dll_name, 0, - LOAD_LIBRARY_AS_DATAFILE); + LOAD_LIBRARY_AS_DATAFILE); } if (dlls[i].dll_name && !dlls[i].handle) @@ -303,7 +303,7 @@ winsock_strerror(int err, char *strerrbuf, size_t buflen) success = 0 != FormatMessage( flags, dlls[i].handle, err, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), strerrbuf, buflen - 64, 0 ); diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c index 5f9246187c..5bd2943dd5 100644 --- a/src/pl/plperl/plperl.c +++ b/src/pl/plperl/plperl.c @@ -33,7 +33,7 @@ * ENHANCEMENTS, OR MODIFICATIONS. * * IDENTIFICATION - * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.92 2005/08/24 19:06:28 tgl Exp $ + * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.93 2005/10/15 02:49:49 momjian Exp $ * **********************************************************************/ @@ -82,15 +82,15 @@ typedef struct plperl_proc_desc bool lanpltrusted; bool fn_retistuple; /* true, if function returns tuple */ bool fn_retisset; /* true, if function returns set */ - bool fn_retisarray; /* true if function returns array */ + bool fn_retisarray; /* true if function returns array */ Oid result_oid; /* Oid of result type */ - FmgrInfo result_in_func; /* I/O function and arg for result type */ + FmgrInfo result_in_func; /* I/O function and arg for result type */ Oid result_typioparam; int nargs; FmgrInfo arg_out_func[FUNC_MAX_ARGS]; bool arg_is_rowtype[FUNC_MAX_ARGS]; SV *reference; -} plperl_proc_desc; +} plperl_proc_desc; /********************************************************************** @@ -131,7 +131,7 @@ static SV *plperl_hash_from_tuple(HeapTuple tuple, TupleDesc tupdesc); static void plperl_init_shared_libs(pTHX); static HV *plperl_spi_execute_fetch_result(SPITupleTable *, int, int); -void plperl_return_next(SV *); +void plperl_return_next(SV *); /* * This routine is a crock, and so is everyplace that calls it. The problem @@ -160,12 +160,12 @@ plperl_init(void) return; DefineCustomBoolVariable( - "plperl.use_strict", - "If true, will compile trusted and untrusted perl code in strict mode", - NULL, - &plperl_use_strict, - PGC_USERSET, - NULL, NULL); + "plperl.use_strict", + "If true, will compile trusted and untrusted perl code in strict mode", + NULL, + &plperl_use_strict, + PGC_USERSET, + NULL, NULL); EmitWarningsOnPlaceholders("plperl"); @@ -240,7 +240,7 @@ plperl_init_all(void) "$PLContainer->deny('require');" \ "sub ::mk_strict_safefunc {" \ " my $ret = $PLContainer->reval(qq[sub { BEGIN { strict->import(); } $_[0] $_[1] }]); " \ - " $@ =~ s/\\(eval \\d+\\) //g if $@; return $ret; }" + " $@ =~ s/\\(eval \\d+\\) //g if $@; return $ret; }" #define SAFE_BAD \ "use vars qw($PLContainer); $PLContainer = new Safe('PLPerl');" \ @@ -257,7 +257,7 @@ plperl_init_all(void) static void plperl_init_interp(void) { - static char *embedding[3] = { + static char *embedding[3] = { "", "-e", PERLBOOT }; @@ -288,7 +288,7 @@ plperl_safe_init(void) * assume that floating-point comparisons are exact, so use a slightly * smaller comparison value. */ - if (safe_version < 2.0899 ) + if (safe_version < 2.0899) { /* not safe, so disallow all trusted funcs */ eval_pv(SAFE_BAD, FALSE); @@ -308,10 +308,10 @@ plperl_safe_init(void) static char * strip_trailing_ws(const char *msg) { - char *res = pstrdup(msg); - int len = strlen(res); + char *res = pstrdup(msg); + int len = strlen(res); - while (len > 0 && isspace((unsigned char) res[len-1])) + while (len > 0 && isspace((unsigned char) res[len - 1])) res[--len] = '\0'; return res; } @@ -320,7 +320,7 @@ strip_trailing_ws(const char *msg) /* Build a tuple from a hash. */ static HeapTuple -plperl_build_tuple_result(HV *perlhash, AttInMetadata *attinmeta) +plperl_build_tuple_result(HV * perlhash, AttInMetadata *attinmeta) { TupleDesc td = attinmeta->tupdesc; char **values; @@ -334,7 +334,7 @@ plperl_build_tuple_result(HV *perlhash, AttInMetadata *attinmeta) hv_iterinit(perlhash); while ((val = hv_iternextsv(perlhash, &key, &klen))) { - int attn = SPI_fnumber(td, key); + int attn = SPI_fnumber(td, key); if (attn <= 0 || td->attrs[attn - 1]->attisdropped) ereport(ERROR, @@ -354,29 +354,30 @@ plperl_build_tuple_result(HV *perlhash, AttInMetadata *attinmeta) /* * convert perl array to postgres string representation */ -static SV* -plperl_convert_to_pg_array(SV *src) +static SV * +plperl_convert_to_pg_array(SV * src) { - SV* rv; - int count; - dSP ; + SV *rv; + int count; - PUSHMARK(SP) ; + dSP; + + PUSHMARK(SP); XPUSHs(src); - PUTBACK ; + PUTBACK; count = call_pv("::_plperl_to_pg_array", G_SCALAR); - SPAGAIN ; + SPAGAIN; if (count != 1) elog(ERROR, "unexpected _plperl_to_pg_array failure"); rv = POPs; - - PUTBACK ; - return rv; + PUTBACK; + + return rv; } @@ -400,10 +401,10 @@ plperl_trigger_build_args(FunctionCallInfo fcinfo) tupdesc = tdata->tg_relation->rd_att; relid = DatumGetCString( - DirectFunctionCall1(oidout, - ObjectIdGetDatum(tdata->tg_relation->rd_id) - ) - ); + DirectFunctionCall1(oidout, + ObjectIdGetDatum(tdata->tg_relation->rd_id) + ) + ); hv_store(hv, "name", 4, newSVpv(tdata->tg_trigger->tgname, 0), 0); hv_store(hv, "relid", 5, newSVpv(relid, 0), 0); @@ -445,10 +446,11 @@ plperl_trigger_build_args(FunctionCallInfo fcinfo) if (tdata->tg_trigger->tgnargs > 0) { - AV *av = newAV(); - for (i=0; i < tdata->tg_trigger->tgnargs; i++) + AV *av = newAV(); + + for (i = 0; i < tdata->tg_trigger->tgnargs; i++) av_push(av, newSVpv(tdata->tg_trigger->tgargs[i], 0)); - hv_store(hv, "args", 4, newRV_noinc((SV *)av), 0); + hv_store(hv, "args", 4, newRV_noinc((SV *) av), 0); } hv_store(hv, "relname", 7, @@ -470,14 +472,14 @@ plperl_trigger_build_args(FunctionCallInfo fcinfo) level = "UNKNOWN"; hv_store(hv, "level", 5, newSVpv(level, 0), 0); - return newRV_noinc((SV*)hv); + return newRV_noinc((SV *) hv); } /* Set up the new tuple returned from a trigger. */ static HeapTuple -plperl_modify_tuple(HV *hvTD, TriggerData *tdata, HeapTuple otup) +plperl_modify_tuple(HV * hvTD, TriggerData *tdata, HeapTuple otup) { SV **svp; HV *hvNew; @@ -531,8 +533,8 @@ plperl_modify_tuple(HV *hvTD, TriggerData *tdata, HeapTuple otup) &typinput, &typioparam); fmgr_info(typinput, &finfo); modvalues[slotsused] = FunctionCall3(&finfo, - CStringGetDatum(SvPV(val, PL_na)), - ObjectIdGetDatum(typioparam), + CStringGetDatum(SvPV(val, PL_na)), + ObjectIdGetDatum(typioparam), Int32GetDatum(tupdesc->attrs[attn - 1]->atttypmod)); modnulls[slotsused] = ' '; } @@ -571,11 +573,11 @@ PG_FUNCTION_INFO_V1(plperl_call_handler); Datum plperl_call_handler(PG_FUNCTION_ARGS) { - Datum retval; + Datum retval; plperl_proc_desc *save_prodesc; FunctionCallInfo save_caller_info; Tuplestorestate *save_tuple_store; - TupleDesc save_tuple_desc; + TupleDesc save_tuple_desc; plperl_init_all(); @@ -657,7 +659,7 @@ plperl_create_sub(char *s, bool trusted) dSP; SV *subref; int count; - char *compile_sub; + char *compile_sub; if (trusted && !plperl_safe_init_done) { @@ -674,8 +676,8 @@ plperl_create_sub(char *s, bool trusted) /* * G_KEEPERR seems to be needed here, else we don't recognize compile - * errors properly. Perhaps it's because there's another level of - * eval inside mksafefunc? + * errors properly. Perhaps it's because there's another level of eval + * inside mksafefunc? */ if (trusted && plperl_use_strict) @@ -746,8 +748,8 @@ plperl_create_sub(char *s, bool trusted) * **********************************************************************/ -EXTERN_C void boot_DynaLoader(pTHX_ CV *cv); -EXTERN_C void boot_SPI(pTHX_ CV *cv); +EXTERN_C void boot_DynaLoader(pTHX_ CV * cv); +EXTERN_C void boot_SPI(pTHX_ CV * cv); static void plperl_init_shared_libs(pTHX) @@ -760,20 +762,20 @@ plperl_init_shared_libs(pTHX) static SV * -plperl_call_perl_func(plperl_proc_desc *desc, FunctionCallInfo fcinfo) +plperl_call_perl_func(plperl_proc_desc * desc, FunctionCallInfo fcinfo) { dSP; SV *retval; int i; int count; - SV *sv; + SV *sv; ENTER; SAVETMPS; PUSHMARK(SP); - XPUSHs(&PL_sv_undef); /* no trigger data */ + XPUSHs(&PL_sv_undef); /* no trigger data */ for (i = 0; i < desc->nargs; i++) { @@ -808,7 +810,8 @@ plperl_call_perl_func(plperl_proc_desc *desc, FunctionCallInfo fcinfo) fcinfo->arg[i])); sv = newSVpv(tmp, 0); #if PERL_BCDVERSION >= 0x5006000L - if (GetDatabaseEncoding() == PG_UTF8) SvUTF8_on(sv); + if (GetDatabaseEncoding() == PG_UTF8) + SvUTF8_on(sv); #endif XPUSHs(sv_2mortal(sv)); pfree(tmp); @@ -852,8 +855,8 @@ plperl_call_perl_func(plperl_proc_desc *desc, FunctionCallInfo fcinfo) static SV * -plperl_call_perl_trigger_func(plperl_proc_desc *desc, FunctionCallInfo fcinfo, - SV *td) +plperl_call_perl_trigger_func(plperl_proc_desc * desc, FunctionCallInfo fcinfo, + SV * td) { dSP; SV *retval; @@ -915,7 +918,7 @@ plperl_func_handler(PG_FUNCTION_ARGS) SV *perlret; Datum retval; ReturnSetInfo *rsi; - SV* array_ret = NULL; + SV *array_ret = NULL; if (SPI_connect() != SPI_OK_CONNECT) elog(ERROR, "could not connect to SPI manager"); @@ -927,7 +930,7 @@ plperl_func_handler(PG_FUNCTION_ARGS) plperl_current_tuple_store = 0; plperl_current_tuple_desc = 0; - rsi = (ReturnSetInfo *)fcinfo->resultinfo; + rsi = (ReturnSetInfo *) fcinfo->resultinfo; if (prodesc->fn_retisset) { @@ -956,17 +959,18 @@ plperl_func_handler(PG_FUNCTION_ARGS) { /* * If the Perl function returned an arrayref, we pretend that it - * called return_next() for each element of the array, to handle - * old SRFs that didn't know about return_next(). Any other sort - * of return value is an error. + * called return_next() for each element of the array, to handle old + * SRFs that didn't know about return_next(). Any other sort of return + * value is an error. */ if (SvTYPE(perlret) == SVt_RV && SvTYPE(SvRV(perlret)) == SVt_PVAV) { - int i = 0; - SV **svp = 0; - AV *rav = (AV *)SvRV(perlret); - while ((svp = av_fetch(rav, i, FALSE)) != NULL) + int i = 0; + SV **svp = 0; + AV *rav = (AV *) SvRV(perlret); + + while ((svp = av_fetch(rav, i, FALSE)) != NULL) { plperl_return_next(*svp); i++; @@ -981,12 +985,12 @@ plperl_func_handler(PG_FUNCTION_ARGS) } rsi->returnMode = SFRM_Materialize; - if (plperl_current_tuple_store) + if (plperl_current_tuple_store) { rsi->setResult = plperl_current_tuple_store; rsi->setDesc = plperl_current_tuple_desc; } - retval = (Datum)0; + retval = (Datum) 0; } else if (SvTYPE(perlret) == SVt_NULL) { @@ -994,14 +998,14 @@ plperl_func_handler(PG_FUNCTION_ARGS) if (rsi && IsA(rsi, ReturnSetInfo)) rsi->isDone = ExprEndResult; fcinfo->isnull = true; - retval = (Datum)0; + retval = (Datum) 0; } else if (prodesc->fn_retistuple) { /* Return a perl hash converted to a Datum */ - TupleDesc td; + TupleDesc td; AttInMetadata *attinmeta; - HeapTuple tup; + HeapTuple tup; if (!SvOK(perlret) || SvTYPE(perlret) != SVt_RV || SvTYPE(SvRV(perlret)) != SVt_PVHV) @@ -1022,21 +1026,21 @@ plperl_func_handler(PG_FUNCTION_ARGS) } attinmeta = TupleDescGetAttInMetadata(td); - tup = plperl_build_tuple_result((HV *)SvRV(perlret), attinmeta); + tup = plperl_build_tuple_result((HV *) SvRV(perlret), attinmeta); retval = HeapTupleGetDatum(tup); } else { - /* Return a perl string converted to a Datum */ - char *val; - - if (prodesc->fn_retisarray && SvROK(perlret) && + /* Return a perl string converted to a Datum */ + char *val; + + if (prodesc->fn_retisarray && SvROK(perlret) && SvTYPE(SvRV(perlret)) == SVt_PVAV) - { - array_ret = plperl_convert_to_pg_array(perlret); - SvREFCNT_dec(perlret); - perlret = array_ret; - } + { + array_ret = plperl_convert_to_pg_array(perlret); + SvREFCNT_dec(perlret); + perlret = array_ret; + } val = SvPV(perlret, PL_na); @@ -1047,7 +1051,7 @@ plperl_func_handler(PG_FUNCTION_ARGS) } if (array_ret == NULL) - SvREFCNT_dec(perlret); + SvREFCNT_dec(perlret); return retval; } @@ -1096,7 +1100,7 @@ plperl_trigger_handler(PG_FUNCTION_ARGS) else if (TRIGGER_FIRED_BY_DELETE(trigdata->tg_event)) retval = (Datum) trigdata->tg_trigtuple; else - retval = (Datum) 0; /* can this happen? */ + retval = (Datum) 0; /* can this happen? */ } else { @@ -1121,7 +1125,7 @@ plperl_trigger_handler(PG_FUNCTION_ARGS) { ereport(WARNING, (errcode(ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED), - errmsg("ignoring modified tuple in DELETE trigger"))); + errmsg("ignoring modified tuple in DELETE trigger"))); trv = NULL; } } @@ -1153,7 +1157,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger) int proname_len; plperl_proc_desc *prodesc = NULL; int i; - SV **svp; + SV **svp; /* We'll need the pg_proc tuple in any case... */ procTup = SearchSysCache(PROCOID, @@ -1189,7 +1193,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger) * function's pg_proc entry without changing its OID. ************************************************************/ uptodate = (prodesc->fn_xmin == HeapTupleHeaderGetXmin(procTup->t_data) && - prodesc->fn_cmin == HeapTupleHeaderGetCmin(procTup->t_data)); + prodesc->fn_cmin == HeapTupleHeaderGetCmin(procTup->t_data)); if (!uptodate) { @@ -1257,7 +1261,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger) if (!is_trigger) { typeTup = SearchSysCache(TYPEOID, - ObjectIdGetDatum(procStruct->prorettype), + ObjectIdGetDatum(procStruct->prorettype), 0, 0, 0); if (!HeapTupleIsValid(typeTup)) { @@ -1289,8 +1293,8 @@ compile_plperl_function(Oid fn_oid, bool is_trigger) free(prodesc); ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("plperl functions cannot return type %s", - format_type_be(procStruct->prorettype)))); + errmsg("plperl functions cannot return type %s", + format_type_be(procStruct->prorettype)))); } } @@ -1299,8 +1303,8 @@ compile_plperl_function(Oid fn_oid, bool is_trigger) prodesc->fn_retistuple = (typeStruct->typtype == 'c' || procStruct->prorettype == RECORDOID); - prodesc->fn_retisarray = - (typeStruct->typlen == -1 && typeStruct->typelem) ; + prodesc->fn_retisarray = + (typeStruct->typlen == -1 && typeStruct->typelem); perm_fmgr_info(typeStruct->typinput, &(prodesc->result_in_func)); prodesc->result_typioparam = getTypeIOParam(typeTup); @@ -1318,7 +1322,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger) for (i = 0; i < prodesc->nargs; i++) { typeTup = SearchSysCache(TYPEOID, - ObjectIdGetDatum(procStruct->proargtypes.values[i]), + ObjectIdGetDatum(procStruct->proargtypes.values[i]), 0, 0, 0); if (!HeapTupleIsValid(typeTup)) { @@ -1336,8 +1340,8 @@ compile_plperl_function(Oid fn_oid, bool is_trigger) free(prodesc); ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("plperl functions cannot take type %s", - format_type_be(procStruct->proargtypes.values[i])))); + errmsg("plperl functions cannot take type %s", + format_type_be(procStruct->proargtypes.values[i])))); } if (typeStruct->typtype == 'c') @@ -1370,7 +1374,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger) ************************************************************/ prodesc->reference = plperl_create_sub(proc_source, prodesc->lanpltrusted); pfree(proc_source); - if (!prodesc->reference) /* can this happen? */ + if (!prodesc->reference) /* can this happen? */ { free(prodesc->proname); free(prodesc); @@ -1407,7 +1411,7 @@ plperl_hash_from_tuple(HeapTuple tuple, TupleDesc tupdesc) Oid typoutput; bool typisvarlena; int namelen; - SV *sv; + SV *sv; if (tupdesc->attrs[i]->attisdropped) continue; @@ -1416,7 +1420,8 @@ plperl_hash_from_tuple(HeapTuple tuple, TupleDesc tupdesc) namelen = strlen(attname); attr = heap_getattr(tuple, i + 1, tupdesc, &isnull); - if (isnull) { + if (isnull) + { /* Store (attname => undef) and move on. */ hv_store(hv, attname, namelen, newSV(0), 0); continue; @@ -1449,8 +1454,8 @@ plperl_spi_exec(char *query, int limit) HV *ret_hv; /* - * Execute the query inside a sub-transaction, so we can cope with - * errors sanely + * Execute the query inside a sub-transaction, so we can cope with errors + * sanely */ MemoryContext oldcontext = CurrentMemoryContext; ResourceOwner oldowner = CurrentResourceOwner; @@ -1472,9 +1477,10 @@ plperl_spi_exec(char *query, int limit) ReleaseCurrentSubTransaction(); MemoryContextSwitchTo(oldcontext); CurrentResourceOwner = oldowner; + /* - * AtEOSubXact_SPI() should not have popped any SPI context, - * but just in case it did, make sure we remain connected. + * AtEOSubXact_SPI() should not have popped any SPI context, but just + * in case it did, make sure we remain connected. */ SPI_restore_connection(); } @@ -1493,9 +1499,9 @@ plperl_spi_exec(char *query, int limit) CurrentResourceOwner = oldowner; /* - * If AtEOSubXact_SPI() popped any SPI context of the subxact, - * it will have left us in a disconnected state. We need this - * hack to return to connected state. + * If AtEOSubXact_SPI() popped any SPI context of the subxact, it will + * have left us in a disconnected state. We need this hack to return + * to connected state. */ SPI_restore_connection(); @@ -1547,14 +1553,14 @@ plperl_spi_execute_fetch_result(SPITupleTable *tuptable, int processed, void -plperl_return_next(SV *sv) +plperl_return_next(SV * sv) { plperl_proc_desc *prodesc = plperl_current_prodesc; FunctionCallInfo fcinfo = plperl_current_caller_info; - ReturnSetInfo *rsi = (ReturnSetInfo *)fcinfo->resultinfo; + ReturnSetInfo *rsi = (ReturnSetInfo *) fcinfo->resultinfo; MemoryContext cxt; - HeapTuple tuple; - TupleDesc tupdesc; + HeapTuple tuple; + TupleDesc tupdesc; if (!sv) return; @@ -1578,7 +1584,7 @@ plperl_return_next(SV *sv) cxt = MemoryContextSwitchTo(rsi->econtext->ecxt_per_query_memory); if (!plperl_current_tuple_store) - plperl_current_tuple_store = + plperl_current_tuple_store = tuplestore_begin_heap(true, false, work_mem); if (prodesc->fn_retistuple) @@ -1589,26 +1595,28 @@ plperl_return_next(SV *sv) rettype = get_call_result_type(fcinfo, NULL, &tupdesc); tupdesc = CreateTupleDescCopy(tupdesc); attinmeta = TupleDescGetAttInMetadata(tupdesc); - tuple = plperl_build_tuple_result((HV *)SvRV(sv), attinmeta); + tuple = plperl_build_tuple_result((HV *) SvRV(sv), attinmeta); } else { - Datum ret; - bool isNull; + Datum ret; + bool isNull; tupdesc = CreateTupleDescCopy(rsi->expectedDesc); if (SvOK(sv) && SvTYPE(sv) != SVt_NULL) { - char *val = SvPV(sv, PL_na); + char *val = SvPV(sv, PL_na); + ret = FunctionCall3(&prodesc->result_in_func, PointerGetDatum(val), ObjectIdGetDatum(prodesc->result_typioparam), Int32GetDatum(-1)); isNull = false; } - else { - ret = (Datum)0; + else + { + ret = (Datum) 0; isNull = true; } @@ -1627,7 +1635,7 @@ plperl_return_next(SV *sv) SV * plperl_spi_query(char *query) { - SV *cursor; + SV *cursor; MemoryContext oldcontext = CurrentMemoryContext; ResourceOwner oldowner = CurrentResourceOwner; @@ -1637,8 +1645,8 @@ plperl_spi_query(char *query) PG_TRY(); { - void *plan; - Portal portal = NULL; + void *plan; + Portal portal = NULL; plan = SPI_prepare(query, 0, NULL); if (plan) @@ -1678,14 +1686,15 @@ plperl_spi_query(char *query) SV * plperl_spi_fetchrow(char *cursor) { - SV *row = newSV(0); - Portal p = SPI_cursor_find(cursor); + SV *row = newSV(0); + Portal p = SPI_cursor_find(cursor); if (!p) return row; SPI_cursor_fetch(p, true, 1); - if (SPI_processed == 0) { + if (SPI_processed == 0) + { SPI_cursor_close(p); return row; } diff --git a/src/pl/plperl/ppport.h b/src/pl/plperl/ppport.h index 592908f27f..d9c64deabf 100644 --- a/src/pl/plperl/ppport.h +++ b/src/pl/plperl/ppport.h @@ -344,14 +344,13 @@ typedef NVTYPE NV; #else #if defined(USE_THREADS) static SV * -newRV_noinc(SV *sv) +newRV_noinc(SV * sv) { SV *nsv = (SV *) newRV(sv); SvREFCNT_dec(sv); return nsv; } - #else #define newRV_noinc(sv) \ (PL_Sv=(SV*)newRV(sv), SvREFCNT_dec(sv), (SV*)PL_Sv) @@ -367,7 +366,7 @@ newRV_noinc(SV *sv) #if defined(NEED_newCONSTSUB) static #else -extern void newCONSTSUB(HV *stash, char *name, SV *sv); +extern void newCONSTSUB(HV * stash, char *name, SV * sv); #endif #if defined(NEED_newCONSTSUB) || defined(NEED_newCONSTSUB_GLOBAL) @@ -404,8 +403,8 @@ SV *sv; #endif newSVOP(OP_CONST, 0, newSVpv(name, 0)), - newSVOP(OP_CONST, 0, &PL_sv_no), /* SvPV(&PL_sv_no) == "" - * -- GMB */ + newSVOP(OP_CONST, 0, &PL_sv_no), /* SvPV(&PL_sv_no) == "" -- + * GMB */ newSTATEOP(0, Nullch, newSVOP(OP_CONST, 0, sv)) ); @@ -484,7 +483,6 @@ SV *sv; #define aMY_CXT my_cxtp #define aMY_CXT_ aMY_CXT, #define _aMY_CXT ,aMY_CXT - #else /* single interpreter */ #define START_MY_CXT static my_cxt_t my_cxt; @@ -545,7 +543,7 @@ SV *sv; ((SvFLAGS(sv) & (SVf_POK|SVf_UTF8)) == (SVf_POK) \ ? ((lp = SvCUR(sv)), SvPVX(sv)) : my_sv_2pvbyte(aTHX_ sv, &lp)) static char * -my_sv_2pvbyte(pTHX_ register SV *sv, STRLEN *lp) +my_sv_2pvbyte(pTHX_ register SV * sv, STRLEN * lp) { sv_utf8_downgrade(sv, 0); return SvPV(sv, *lp); @@ -560,7 +558,7 @@ my_sv_2pvbyte(pTHX_ register SV *sv, STRLEN *lp) ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? SvPVX(sv) : sv_2pv_nolen(sv)) static char * -sv_2pv_nolen(pTHX_ register SV *sv) +sv_2pv_nolen(pTHX_ register SV * sv) { STRLEN n_a; diff --git a/src/pl/plperl/spi_internal.h b/src/pl/plperl/spi_internal.h index 5c511fce47..4d2c407ee1 100644 --- a/src/pl/plperl/spi_internal.h +++ b/src/pl/plperl/spi_internal.h @@ -17,6 +17,6 @@ int spi_ERROR(void); /* this is actually in plperl.c */ HV *plperl_spi_exec(char *, int); -void plperl_return_next(SV *); -SV *plperl_spi_query(char *); -SV *plperl_spi_fetchrow(char *); +void plperl_return_next(SV *); +SV *plperl_spi_query(char *); +SV *plperl_spi_fetchrow(char *); diff --git a/src/pl/plpgsql/src/pl_comp.c b/src/pl/plpgsql/src/pl_comp.c index 1f1d03b879..2c84899519 100644 --- a/src/pl/plpgsql/src/pl_comp.c +++ b/src/pl/plpgsql/src/pl_comp.c @@ -3,7 +3,7 @@ * procedural language * * IDENTIFICATION - * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.93 2005/09/24 22:54:44 tgl Exp $ + * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.94 2005/10/15 02:49:49 momjian Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -95,7 +95,7 @@ typedef struct plpgsql_hashent { PLpgSQL_func_hashkey key; PLpgSQL_function *function; -} plpgsql_HashEnt; +} plpgsql_HashEnt; #define FUNCS_PER_USER 128 /* initial table size */ @@ -107,7 +107,7 @@ typedef struct { const char *label; int sqlerrstate; -} ExceptionLabelMap; +} ExceptionLabelMap; static const ExceptionLabelMap exception_label_map[] = { #include "plerrcodes.h" @@ -121,27 +121,27 @@ static const ExceptionLabelMap exception_label_map[] = { */ static PLpgSQL_function *do_compile(FunctionCallInfo fcinfo, HeapTuple procTup, - PLpgSQL_func_hashkey *hashkey, + PLpgSQL_func_hashkey * hashkey, bool forValidator); -static int fetchArgInfo(HeapTuple procTup, - Oid **p_argtypes, char ***p_argnames, - char **p_argmodes); +static int fetchArgInfo(HeapTuple procTup, + Oid **p_argtypes, char ***p_argnames, + char **p_argmodes); static PLpgSQL_row *build_row_from_class(Oid classOid); -static PLpgSQL_row *build_row_from_vars(PLpgSQL_variable **vars, int numvars); +static PLpgSQL_row *build_row_from_vars(PLpgSQL_variable ** vars, int numvars); static PLpgSQL_type *build_datatype(HeapTuple typeTup, int32 typmod); static void compute_function_hashkey(FunctionCallInfo fcinfo, Form_pg_proc procStruct, - PLpgSQL_func_hashkey *hashkey, + PLpgSQL_func_hashkey * hashkey, bool forValidator); static void plpgsql_resolve_polymorphic_argtypes(int numargs, Oid *argtypes, char *argmodes, Node *call_expr, bool forValidator, const char *proname); -static PLpgSQL_function *plpgsql_HashTableLookup(PLpgSQL_func_hashkey *func_key); -static void plpgsql_HashTableInsert(PLpgSQL_function *function, - PLpgSQL_func_hashkey *func_key); -static void plpgsql_HashTableDelete(PLpgSQL_function *function); -static void delete_function(PLpgSQL_function *func); +static PLpgSQL_function *plpgsql_HashTableLookup(PLpgSQL_func_hashkey * func_key); +static void plpgsql_HashTableInsert(PLpgSQL_function * function, + PLpgSQL_func_hashkey * func_key); +static void plpgsql_HashTableDelete(PLpgSQL_function * function); +static void delete_function(PLpgSQL_function * func); /* ---------- * plpgsql_compile Make an execution tree for a PL/pgSQL function. @@ -174,8 +174,8 @@ plpgsql_compile(FunctionCallInfo fcinfo, bool forValidator) procStruct = (Form_pg_proc) GETSTRUCT(procTup); /* - * See if there's already a cache entry for the current FmgrInfo. If - * not, try to find one in the hash table. + * See if there's already a cache entry for the current FmgrInfo. If not, + * try to find one in the hash table. */ function = (PLpgSQL_function *) fcinfo->flinfo->fn_extra; @@ -193,7 +193,7 @@ plpgsql_compile(FunctionCallInfo fcinfo, bool forValidator) { /* We have a compiled function, but is it still valid? */ if (!(function->fn_xmin == HeapTupleHeaderGetXmin(procTup->t_data) && - function->fn_cmin == HeapTupleHeaderGetCmin(procTup->t_data))) + function->fn_cmin == HeapTupleHeaderGetCmin(procTup->t_data))) { /* Nope, drop the function and associated storage */ delete_function(function); @@ -202,14 +202,13 @@ plpgsql_compile(FunctionCallInfo fcinfo, bool forValidator) } /* - * If the function wasn't found or was out-of-date, we have to compile - * it + * If the function wasn't found or was out-of-date, we have to compile it */ if (!function) { /* - * Calculate hashkey if we didn't already; we'll need it to store - * the completed function. + * Calculate hashkey if we didn't already; we'll need it to store the + * completed function. */ if (!hashkey_valid) compute_function_hashkey(fcinfo, procStruct, &hashkey, @@ -253,7 +252,7 @@ plpgsql_compile(FunctionCallInfo fcinfo, bool forValidator) static PLpgSQL_function * do_compile(FunctionCallInfo fcinfo, HeapTuple procTup, - PLpgSQL_func_hashkey *hashkey, + PLpgSQL_func_hashkey * hashkey, bool forValidator) { Form_pg_proc procStruct = (Form_pg_proc) GETSTRUCT(procTup); @@ -281,9 +280,9 @@ do_compile(FunctionCallInfo fcinfo, MemoryContext func_cxt; /* - * Setup the scanner input and error info. We assume that this - * function cannot be invoked recursively, so there's no need to save - * and restore the static variables used here. + * Setup the scanner input and error info. We assume that this function + * cannot be invoked recursively, so there's no need to save and restore + * the static variables used here. */ prosrcdatum = SysCacheGetAttr(PROCOID, procTup, Anum_pg_proc_prosrc, &isnull); @@ -317,17 +316,16 @@ do_compile(FunctionCallInfo fcinfo, datums_last = 0; /* - * Do extra syntax checks when validating the function - * definition. We skip this when actually compiling functions for - * execution, for performance reasons. + * Do extra syntax checks when validating the function definition. We skip + * this when actually compiling functions for execution, for performance + * reasons. */ plpgsql_check_syntax = forValidator; /* - * Create the new function node. We allocate the function and all - * of its compile-time storage (e.g. parse tree) in its own memory - * context. This allows us to reclaim the function's storage - * cleanly. + * Create the new function node. We allocate the function and all of its + * compile-time storage (e.g. parse tree) in its own memory context. This + * allows us to reclaim the function's storage cleanly. */ func_cxt = AllocSetContextCreate(TopMemoryContext, "PL/PgSQL function context", @@ -344,18 +342,19 @@ do_compile(FunctionCallInfo fcinfo, function->fn_cmin = HeapTupleHeaderGetCmin(procTup->t_data); function->fn_functype = functype; function->fn_cxt = func_cxt; - function->out_param_varno = -1; /* set up for no OUT param */ + function->out_param_varno = -1; /* set up for no OUT param */ switch (functype) { case T_FUNCTION: + /* - * Fetch info about the procedure's parameters. Allocations - * aren't needed permanently, so make them in tmp cxt. + * Fetch info about the procedure's parameters. Allocations aren't + * needed permanently, so make them in tmp cxt. * - * We also need to resolve any polymorphic input or output - * argument types. In validation mode we won't be able to, - * so we arbitrarily assume we are dealing with integers. + * We also need to resolve any polymorphic input or output argument + * types. In validation mode we won't be able to, so we + * arbitrarily assume we are dealing with integers. */ MemoryContextSwitchTo(compile_tmp_cxt); @@ -396,8 +395,8 @@ do_compile(FunctionCallInfo fcinfo, argdtype->ttype != PLPGSQL_TTYPE_ROW) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("plpgsql functions cannot take type %s", - format_type_be(argtypeid)))); + errmsg("plpgsql functions cannot take type %s", + format_type_be(argtypeid)))); /* Build variable and add to datum list */ argvariable = plpgsql_build_variable(buf, 0, @@ -433,8 +432,8 @@ do_compile(FunctionCallInfo fcinfo, /* * If there's just one OUT parameter, out_param_varno points - * directly to it. If there's more than one, build a row - * that holds all of them. + * directly to it. If there's more than one, build a row that + * holds all of them. */ if (num_out_args == 1) function->out_param_varno = out_arg_variables[0]->dno; @@ -448,14 +447,14 @@ do_compile(FunctionCallInfo fcinfo, } /* - * Check for a polymorphic returntype. If found, use the - * actual returntype type from the caller's FuncExpr node, if - * we have one. (In validation mode we arbitrarily assume we - * are dealing with integers.) + * Check for a polymorphic returntype. If found, use the actual + * returntype type from the caller's FuncExpr node, if we have + * one. (In validation mode we arbitrarily assume we are dealing + * with integers.) * - * Note: errcode is FEATURE_NOT_SUPPORTED because it should - * always work; if it doesn't we're in some context that fails - * to make the info available. + * Note: errcode is FEATURE_NOT_SUPPORTED because it should always + * work; if it doesn't we're in some context that fails to make + * the info available. */ rettypeid = procStruct->prorettype; if (rettypeid == ANYARRAYOID || rettypeid == ANYELEMENTOID) @@ -473,9 +472,9 @@ do_compile(FunctionCallInfo fcinfo, if (!OidIsValid(rettypeid)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("could not determine actual return type " - "for polymorphic function \"%s\"", - plpgsql_error_funcname))); + errmsg("could not determine actual return type " + "for polymorphic function \"%s\"", + plpgsql_error_funcname))); } } @@ -509,8 +508,8 @@ do_compile(FunctionCallInfo fcinfo, else ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("plpgsql functions cannot return type %s", - format_type_be(rettypeid)))); + errmsg("plpgsql functions cannot return type %s", + format_type_be(rettypeid)))); } if (typeStruct->typrelid != InvalidOid || @@ -533,7 +532,7 @@ do_compile(FunctionCallInfo fcinfo, num_out_args == 0) { (void) plpgsql_build_variable("$0", 0, - build_datatype(typeTup, -1), + build_datatype(typeTup, -1), true); } } @@ -551,7 +550,7 @@ do_compile(FunctionCallInfo fcinfo, if (procStruct->pronargs != 0) ereport(ERROR, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), - errmsg("trigger functions cannot have declared arguments"), + errmsg("trigger functions cannot have declared arguments"), errhint("You probably want to use TG_NARGS and TG_ARGV instead."))); /* Add the record for referencing NEW */ @@ -578,43 +577,43 @@ do_compile(FunctionCallInfo fcinfo, /* Add the variable tg_name */ var = plpgsql_build_variable("tg_name", 0, - plpgsql_build_datatype(NAMEOID, -1), + plpgsql_build_datatype(NAMEOID, -1), true); function->tg_name_varno = var->dno; /* Add the variable tg_when */ var = plpgsql_build_variable("tg_when", 0, - plpgsql_build_datatype(TEXTOID, -1), + plpgsql_build_datatype(TEXTOID, -1), true); function->tg_when_varno = var->dno; /* Add the variable tg_level */ var = plpgsql_build_variable("tg_level", 0, - plpgsql_build_datatype(TEXTOID, -1), + plpgsql_build_datatype(TEXTOID, -1), true); function->tg_level_varno = var->dno; /* Add the variable tg_op */ var = plpgsql_build_variable("tg_op", 0, - plpgsql_build_datatype(TEXTOID, -1), + plpgsql_build_datatype(TEXTOID, -1), true); function->tg_op_varno = var->dno; /* Add the variable tg_relid */ var = plpgsql_build_variable("tg_relid", 0, - plpgsql_build_datatype(OIDOID, -1), + plpgsql_build_datatype(OIDOID, -1), true); function->tg_relid_varno = var->dno; /* Add the variable tg_relname */ var = plpgsql_build_variable("tg_relname", 0, - plpgsql_build_datatype(NAMEOID, -1), + plpgsql_build_datatype(NAMEOID, -1), true); function->tg_relname_varno = var->dno; /* Add the variable tg_nargs */ var = plpgsql_build_variable("tg_nargs", 0, - plpgsql_build_datatype(INT4OID, -1), + plpgsql_build_datatype(INT4OID, -1), true); function->tg_nargs_varno = var->dno; @@ -654,11 +653,11 @@ do_compile(FunctionCallInfo fcinfo, /* * If it has OUT parameters or returns VOID or returns a set, we allow - * control to fall off the end without an explicit RETURN statement. - * The easiest way to implement this is to add a RETURN statement to the - * end of the statement list during parsing. However, if the outer block - * has an EXCEPTION clause, we need to make a new outer block, since the - * added RETURN shouldn't act like it is inside the EXCEPTION clause. + * control to fall off the end without an explicit RETURN statement. The + * easiest way to implement this is to add a RETURN statement to the end + * of the statement list during parsing. However, if the outer block has + * an EXCEPTION clause, we need to make a new outer block, since the added + * RETURN shouldn't act like it is inside the EXCEPTION clause. */ if (num_out_args > 0 || function->fn_rettype == VOIDOID || function->fn_retset) @@ -668,8 +667,8 @@ do_compile(FunctionCallInfo fcinfo, PLpgSQL_stmt_block *new; new = palloc0(sizeof(PLpgSQL_stmt_block)); - new->cmd_type = PLPGSQL_STMT_BLOCK; - new->body = list_make1(function->action); + new->cmd_type = PLPGSQL_STMT_BLOCK; + new->body = list_make1(function->action); function->action = new; } @@ -734,15 +733,15 @@ plpgsql_compile_error_callback(void *arg) if (arg) { /* - * Try to convert syntax error position to reference text of - * original CREATE FUNCTION command. + * Try to convert syntax error position to reference text of original + * CREATE FUNCTION command. */ if (function_parse_error_transpose((const char *) arg)) return; /* - * Done if a syntax error position was reported; otherwise we have - * to fall back to a "near line N" report. + * Done if a syntax error position was reported; otherwise we have to + * fall back to a "near line N" report. */ } @@ -784,7 +783,7 @@ fetchArgInfo(HeapTuple procTup, Oid **p_argtypes, char ***p_argnames, * deconstruct_array() since the array data is just going to look like * a C array of values. */ - arr = DatumGetArrayTypeP(proallargtypes); /* ensure not toasted */ + arr = DatumGetArrayTypeP(proallargtypes); /* ensure not toasted */ numargs = ARR_DIMS(arr)[0]; if (ARR_NDIM(arr) != 1 || numargs < 0 || @@ -816,7 +815,7 @@ fetchArgInfo(HeapTuple procTup, Oid **p_argtypes, char ***p_argnames, deconstruct_array(DatumGetArrayTypeP(proargnames), TEXTOID, -1, false, 'i', &elems, &nelems); - if (nelems != numargs) /* should not happen */ + if (nelems != numargs) /* should not happen */ elog(ERROR, "proargnames must have the same number of elements as the function has arguments"); *p_argnames = (char **) palloc(sizeof(char *) * numargs); for (i = 0; i < numargs; i++) @@ -868,7 +867,7 @@ plpgsql_parse_word(char *word) { if (strcmp(cp[0], "tg_argv") == 0) { - bool save_spacescanned = plpgsql_SpaceScanned; + bool save_spacescanned = plpgsql_SpaceScanned; PLpgSQL_trigarg *trigarg; trigarg = palloc0(sizeof(PLpgSQL_trigarg)); @@ -918,8 +917,8 @@ plpgsql_parse_word(char *word) } /* - * Nothing found - up to now it's a word without any special meaning - * for us. + * Nothing found - up to now it's a word without any special meaning for + * us. */ pfree(cp[0]); return T_WORD; @@ -988,8 +987,8 @@ plpgsql_parse_dblword(char *word) case PLPGSQL_NSTYPE_REC: { /* - * First word is a record name, so second word must be a - * field in this record. + * First word is a record name, so second word must be a field + * in this record. */ PLpgSQL_recfield *new; @@ -1010,8 +1009,8 @@ plpgsql_parse_dblword(char *word) case PLPGSQL_NSTYPE_ROW: { /* - * First word is a row name, so second word must be a - * field in this row. + * First word is a row name, so second word must be a field in + * this row. */ PLpgSQL_row *row; int i; @@ -1094,8 +1093,8 @@ plpgsql_parse_tripword(char *word) case PLPGSQL_NSTYPE_REC: { /* - * This word is a record name, so third word must be a - * field in this record. + * This word is a record name, so third word must be a field + * in this record. */ PLpgSQL_recfield *new; @@ -1118,8 +1117,8 @@ plpgsql_parse_tripword(char *word) case PLPGSQL_NSTYPE_ROW: { /* - * This word is a row name, so third word must be a field - * in this row. + * This word is a row name, so third word must be a field in + * this row. */ PLpgSQL_row *row; int i; @@ -1180,8 +1179,8 @@ plpgsql_parse_wordtype(char *word) pfree(cp[1]); /* - * Do a lookup on the compiler's namestack. But ensure it moves up to - * the toplevel. + * Do a lookup on the compiler's namestack. But ensure it moves up to the + * toplevel. */ old_nsstate = plpgsql_ns_setlocal(false); nse = plpgsql_ns_lookup(cp[0], NULL); @@ -1204,8 +1203,8 @@ plpgsql_parse_wordtype(char *word) } /* - * Word wasn't found on the namestack. Try to find a data type with - * that name, but ignore pg_type entries that are in fact class types. + * Word wasn't found on the namestack. Try to find a data type with that + * name, but ignore pg_type entries that are in fact class types. */ typeOid = LookupTypeName(makeTypeName(cp[0])); if (OidIsValid(typeOid)) @@ -1236,8 +1235,8 @@ plpgsql_parse_wordtype(char *word) } /* - * Nothing found - up to now it's a word without any special meaning - * for us. + * Nothing found - up to now it's a word without any special meaning for + * us. */ pfree(cp[0]); return T_ERROR; @@ -1281,8 +1280,8 @@ plpgsql_parse_dblwordtype(char *word) nse = plpgsql_ns_lookup(cp[0], NULL); /* - * If this is a label lookup the second word in that label's - * namestack level + * If this is a label lookup the second word in that label's namestack + * level */ if (nse != NULL) { @@ -1341,8 +1340,8 @@ plpgsql_parse_dblwordtype(char *word) elog(ERROR, "cache lookup failed for type %u", attrStruct->atttypid); /* - * Found that - build a compiler type struct in the caller's cxt - * and return it + * Found that - build a compiler type struct in the caller's cxt and + * return it */ MemoryContextSwitchTo(oldCxt); plpgsql_yylval.dtype = build_datatype(typetup, attrStruct->atttypmod); @@ -1383,7 +1382,7 @@ plpgsql_parse_tripwordtype(char *word) int i; RangeVar *relvar; MemoryContext oldCxt; - int result = T_ERROR; + int result = T_ERROR; /* Avoid memory leaks in the long-term function context */ oldCxt = MemoryContextSwitchTo(compile_tmp_cxt); @@ -1410,7 +1409,7 @@ plpgsql_parse_tripwordtype(char *word) cp[1][qualified_att_len - i - 1] = '\0'; relvar = makeRangeVarFromNameList(stringToQualifiedNameList(cp[0], - "plpgsql_parse_tripwordtype")); + "plpgsql_parse_tripwordtype")); classOid = RangeVarGetRelid(relvar, true); if (!OidIsValid(classOid)) goto done; @@ -1447,8 +1446,8 @@ plpgsql_parse_tripwordtype(char *word) elog(ERROR, "cache lookup failed for type %u", attrStruct->atttypid); /* - * Found that - build a compiler type struct in the caller's cxt - * and return it + * Found that - build a compiler type struct in the caller's cxt and + * return it */ MemoryContextSwitchTo(oldCxt); plpgsql_yylval.dtype = build_datatype(typetup, attrStruct->atttypmod); @@ -1555,11 +1554,11 @@ plpgsql_parse_dblwordrowtype(char *word) * * The returned struct may be a PLpgSQL_var, PLpgSQL_row, or * PLpgSQL_rec depending on the given datatype, and is allocated via - * palloc. The struct is automatically added to the current datum + * palloc. The struct is automatically added to the current datum * array, and optionally to the current namespace. */ PLpgSQL_variable * -plpgsql_build_variable(const char *refname, int lineno, PLpgSQL_type *dtype, +plpgsql_build_variable(const char *refname, int lineno, PLpgSQL_type * dtype, bool add2namespace) { PLpgSQL_variable *result; @@ -1613,8 +1612,7 @@ plpgsql_build_variable(const char *refname, int lineno, PLpgSQL_type *dtype, case PLPGSQL_TTYPE_REC: { /* - * "record" type -- build a variable-contents record - * variable + * "record" type -- build a variable-contents record variable */ PLpgSQL_rec *rec; @@ -1636,7 +1634,7 @@ plpgsql_build_variable(const char *refname, int lineno, PLpgSQL_type *dtype, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("variable \"%s\" has pseudo-type %s", refname, format_type_be(dtype->typoid)))); - result = NULL; /* keep compiler quiet */ + result = NULL; /* keep compiler quiet */ break; default: elog(ERROR, "unrecognized ttype: %d", dtype->ttype); @@ -1676,8 +1674,8 @@ build_row_from_class(Oid classOid) errmsg("relation \"%s\" is not a table", relname))); /* - * Create a row datum entry and all the required variables that it - * will point to. + * Create a row datum entry and all the required variables that it will + * point to. */ row = palloc0(sizeof(PLpgSQL_row)); row->dtype = PLPGSQL_DTYPE_ROW; @@ -1707,16 +1705,16 @@ build_row_from_class(Oid classOid) /* * Create the internal variable for the field * - * We know if the table definitions contain a default value or if - * the field is declared in the table as NOT NULL. But it's - * possible to create a table field as NOT NULL without a - * default value and that would lead to problems later when - * initializing the variables due to entering a block at - * execution time. Thus we ignore this information for now. + * We know if the table definitions contain a default value or if the + * field is declared in the table as NOT NULL. But it's possible + * to create a table field as NOT NULL without a default value and + * that would lead to problems later when initializing the + * variables due to entering a block at execution time. Thus we + * ignore this information for now. */ var = plpgsql_build_variable(refname, 0, - plpgsql_build_datatype(attrStruct->atttypid, - attrStruct->atttypmod), + plpgsql_build_datatype(attrStruct->atttypid, + attrStruct->atttypmod), false); /* Add the variable to the row */ @@ -1740,7 +1738,7 @@ build_row_from_class(Oid classOid) * Build a row-variable data structure given the component variables. */ static PLpgSQL_row * -build_row_from_vars(PLpgSQL_variable **vars, int numvars) +build_row_from_vars(PLpgSQL_variable ** vars, int numvars) { PLpgSQL_row *row; int i; @@ -1755,8 +1753,8 @@ build_row_from_vars(PLpgSQL_variable **vars, int numvars) for (i = 0; i < numvars; i++) { PLpgSQL_variable *var = vars[i]; - Oid typoid = RECORDOID; - int32 typmod = -1; + Oid typoid = RECORDOID; + int32 typmod = -1; switch (var->dtype) { @@ -1783,7 +1781,7 @@ build_row_from_vars(PLpgSQL_variable **vars, int numvars) row->fieldnames[i] = var->refname; row->varnos[i] = var->dno; - TupleDescInitEntry(row->rowtupdesc, i+1, + TupleDescInitEntry(row->rowtupdesc, i + 1, var->refname, typoid, typmod, 0); @@ -1899,8 +1897,8 @@ plpgsql_parse_err_condition(char *condname) PLpgSQL_condition *prev; /* - * XXX Eventually we will want to look for user-defined exception - * names here. + * XXX Eventually we will want to look for user-defined exception names + * here. */ /* @@ -1944,7 +1942,7 @@ plpgsql_parse_err_condition(char *condname) * ---------- */ void -plpgsql_adddatum(PLpgSQL_datum *new) +plpgsql_adddatum(PLpgSQL_datum * new) { if (plpgsql_nDatums == datums_alloc) { @@ -2020,7 +2018,7 @@ plpgsql_add_initdatums(int **varnos) static void compute_function_hashkey(FunctionCallInfo fcinfo, Form_pg_proc procStruct, - PLpgSQL_func_hashkey *hashkey, + PLpgSQL_func_hashkey * hashkey, bool forValidator) { /* Make sure any unused bytes of the struct are zero */ @@ -2030,9 +2028,9 @@ compute_function_hashkey(FunctionCallInfo fcinfo, hashkey->funcOid = fcinfo->flinfo->fn_oid; /* - * if trigger, get relation OID. In validation mode we do not know - * what relation is intended to be used, so we leave trigrelOid zero; - * the hash entry built in this case will never really be used. + * if trigger, get relation OID. In validation mode we do not know what + * relation is intended to be used, so we leave trigrelOid zero; the hash + * entry built in this case will never really be used. */ if (CALLED_AS_TRIGGER(fcinfo) && !forValidator) { @@ -2103,7 +2101,7 @@ plpgsql_resolve_polymorphic_argtypes(int numargs, } static void -delete_function(PLpgSQL_function *func) +delete_function(PLpgSQL_function * func) { /* remove function from hash table */ plpgsql_HashTableDelete(func); @@ -2112,8 +2110,8 @@ delete_function(PLpgSQL_function *func) MemoryContextDelete(func->fn_cxt); /* - * Caller should be sure not to use passed-in pointer, as it now - * points to pfree'd storage + * Caller should be sure not to use passed-in pointer, as it now points to + * pfree'd storage */ } @@ -2137,7 +2135,7 @@ plpgsql_HashTableInit(void) } static PLpgSQL_function * -plpgsql_HashTableLookup(PLpgSQL_func_hashkey *func_key) +plpgsql_HashTableLookup(PLpgSQL_func_hashkey * func_key) { plpgsql_HashEnt *hentry; @@ -2152,8 +2150,8 @@ plpgsql_HashTableLookup(PLpgSQL_func_hashkey *func_key) } static void -plpgsql_HashTableInsert(PLpgSQL_function *function, - PLpgSQL_func_hashkey *func_key) +plpgsql_HashTableInsert(PLpgSQL_function * function, + PLpgSQL_func_hashkey * func_key) { plpgsql_HashEnt *hentry; bool found; @@ -2171,12 +2169,12 @@ plpgsql_HashTableInsert(PLpgSQL_function *function, } static void -plpgsql_HashTableDelete(PLpgSQL_function *function) +plpgsql_HashTableDelete(PLpgSQL_function * function) { plpgsql_HashEnt *hentry; hentry = (plpgsql_HashEnt *) hash_search(plpgsql_HashTable, - (void *) function->fn_hashkey, + (void *) function->fn_hashkey, HASH_REMOVE, NULL); if (hentry == NULL) diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c index 6238aef0eb..721b1014fd 100644 --- a/src/pl/plpgsql/src/pl_exec.c +++ b/src/pl/plpgsql/src/pl_exec.c @@ -3,7 +3,7 @@ * procedural language * * IDENTIFICATION - * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.152 2005/09/13 16:16:17 tgl Exp $ + * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.153 2005/10/15 02:49:49 momjian Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -75,97 +75,97 @@ static PLpgSQL_expr *active_simple_exprs = NULL; * Local function forward declarations ************************************************************/ static void plpgsql_exec_error_callback(void *arg); -static PLpgSQL_datum *copy_plpgsql_datum(PLpgSQL_datum *datum); +static PLpgSQL_datum *copy_plpgsql_datum(PLpgSQL_datum * datum); -static int exec_stmt_block(PLpgSQL_execstate *estate, - PLpgSQL_stmt_block *block); -static int exec_stmts(PLpgSQL_execstate *estate, - List *stmts); -static int exec_stmt(PLpgSQL_execstate *estate, - PLpgSQL_stmt *stmt); -static int exec_stmt_assign(PLpgSQL_execstate *estate, - PLpgSQL_stmt_assign *stmt); -static int exec_stmt_perform(PLpgSQL_execstate *estate, - PLpgSQL_stmt_perform *stmt); -static int exec_stmt_getdiag(PLpgSQL_execstate *estate, - PLpgSQL_stmt_getdiag *stmt); -static int exec_stmt_if(PLpgSQL_execstate *estate, - PLpgSQL_stmt_if *stmt); -static int exec_stmt_loop(PLpgSQL_execstate *estate, - PLpgSQL_stmt_loop *stmt); -static int exec_stmt_while(PLpgSQL_execstate *estate, - PLpgSQL_stmt_while *stmt); -static int exec_stmt_fori(PLpgSQL_execstate *estate, - PLpgSQL_stmt_fori *stmt); -static int exec_stmt_fors(PLpgSQL_execstate *estate, - PLpgSQL_stmt_fors *stmt); -static int exec_stmt_select(PLpgSQL_execstate *estate, - PLpgSQL_stmt_select *stmt); -static int exec_stmt_open(PLpgSQL_execstate *estate, - PLpgSQL_stmt_open *stmt); -static int exec_stmt_fetch(PLpgSQL_execstate *estate, - PLpgSQL_stmt_fetch *stmt); -static int exec_stmt_close(PLpgSQL_execstate *estate, - PLpgSQL_stmt_close *stmt); -static int exec_stmt_exit(PLpgSQL_execstate *estate, - PLpgSQL_stmt_exit *stmt); -static int exec_stmt_return(PLpgSQL_execstate *estate, - PLpgSQL_stmt_return *stmt); -static int exec_stmt_return_next(PLpgSQL_execstate *estate, - PLpgSQL_stmt_return_next *stmt); -static int exec_stmt_raise(PLpgSQL_execstate *estate, - PLpgSQL_stmt_raise *stmt); -static int exec_stmt_execsql(PLpgSQL_execstate *estate, - PLpgSQL_stmt_execsql *stmt); -static int exec_stmt_dynexecute(PLpgSQL_execstate *estate, - PLpgSQL_stmt_dynexecute *stmt); -static int exec_stmt_dynfors(PLpgSQL_execstate *estate, - PLpgSQL_stmt_dynfors *stmt); +static int exec_stmt_block(PLpgSQL_execstate * estate, + PLpgSQL_stmt_block * block); +static int exec_stmts(PLpgSQL_execstate * estate, + List *stmts); +static int exec_stmt(PLpgSQL_execstate * estate, + PLpgSQL_stmt * stmt); +static int exec_stmt_assign(PLpgSQL_execstate * estate, + PLpgSQL_stmt_assign * stmt); +static int exec_stmt_perform(PLpgSQL_execstate * estate, + PLpgSQL_stmt_perform * stmt); +static int exec_stmt_getdiag(PLpgSQL_execstate * estate, + PLpgSQL_stmt_getdiag * stmt); +static int exec_stmt_if(PLpgSQL_execstate * estate, + PLpgSQL_stmt_if * stmt); +static int exec_stmt_loop(PLpgSQL_execstate * estate, + PLpgSQL_stmt_loop * stmt); +static int exec_stmt_while(PLpgSQL_execstate * estate, + PLpgSQL_stmt_while * stmt); +static int exec_stmt_fori(PLpgSQL_execstate * estate, + PLpgSQL_stmt_fori * stmt); +static int exec_stmt_fors(PLpgSQL_execstate * estate, + PLpgSQL_stmt_fors * stmt); +static int exec_stmt_select(PLpgSQL_execstate * estate, + PLpgSQL_stmt_select * stmt); +static int exec_stmt_open(PLpgSQL_execstate * estate, + PLpgSQL_stmt_open * stmt); +static int exec_stmt_fetch(PLpgSQL_execstate * estate, + PLpgSQL_stmt_fetch * stmt); +static int exec_stmt_close(PLpgSQL_execstate * estate, + PLpgSQL_stmt_close * stmt); +static int exec_stmt_exit(PLpgSQL_execstate * estate, + PLpgSQL_stmt_exit * stmt); +static int exec_stmt_return(PLpgSQL_execstate * estate, + PLpgSQL_stmt_return * stmt); +static int exec_stmt_return_next(PLpgSQL_execstate * estate, + PLpgSQL_stmt_return_next * stmt); +static int exec_stmt_raise(PLpgSQL_execstate * estate, + PLpgSQL_stmt_raise * stmt); +static int exec_stmt_execsql(PLpgSQL_execstate * estate, + PLpgSQL_stmt_execsql * stmt); +static int exec_stmt_dynexecute(PLpgSQL_execstate * estate, + PLpgSQL_stmt_dynexecute * stmt); +static int exec_stmt_dynfors(PLpgSQL_execstate * estate, + PLpgSQL_stmt_dynfors * stmt); -static void plpgsql_estate_setup(PLpgSQL_execstate *estate, - PLpgSQL_function *func, +static void plpgsql_estate_setup(PLpgSQL_execstate * estate, + PLpgSQL_function * func, ReturnSetInfo *rsi); -static void exec_eval_cleanup(PLpgSQL_execstate *estate); +static void exec_eval_cleanup(PLpgSQL_execstate * estate); -static void exec_prepare_plan(PLpgSQL_execstate *estate, - PLpgSQL_expr *expr); +static void exec_prepare_plan(PLpgSQL_execstate * estate, + PLpgSQL_expr * expr); static bool exec_simple_check_node(Node *node); -static void exec_simple_check_plan(PLpgSQL_expr *expr); -static Datum exec_eval_simple_expr(PLpgSQL_execstate *estate, - PLpgSQL_expr *expr, +static void exec_simple_check_plan(PLpgSQL_expr * expr); +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, - PLpgSQL_expr *expr); -static void exec_assign_value(PLpgSQL_execstate *estate, - PLpgSQL_datum *target, +static void exec_assign_expr(PLpgSQL_execstate * estate, + PLpgSQL_datum * target, + PLpgSQL_expr * expr); +static void exec_assign_value(PLpgSQL_execstate * estate, + PLpgSQL_datum * target, Datum value, Oid valtype, bool *isNull); -static void exec_eval_datum(PLpgSQL_execstate *estate, - PLpgSQL_datum *datum, +static void exec_eval_datum(PLpgSQL_execstate * estate, + PLpgSQL_datum * datum, Oid expectedtypeid, Oid *typeid, Datum *value, bool *isnull); -static int exec_eval_integer(PLpgSQL_execstate *estate, - PLpgSQL_expr *expr, +static int exec_eval_integer(PLpgSQL_execstate * estate, + PLpgSQL_expr * expr, bool *isNull); -static bool exec_eval_boolean(PLpgSQL_execstate *estate, - PLpgSQL_expr *expr, +static bool exec_eval_boolean(PLpgSQL_execstate * estate, + PLpgSQL_expr * expr, bool *isNull); -static Datum exec_eval_expr(PLpgSQL_execstate *estate, - PLpgSQL_expr *expr, +static Datum exec_eval_expr(PLpgSQL_execstate * estate, + PLpgSQL_expr * expr, bool *isNull, Oid *rettype); -static int exec_run_select(PLpgSQL_execstate *estate, - PLpgSQL_expr *expr, long maxtuples, Portal *portalP); -static void exec_move_row(PLpgSQL_execstate *estate, - PLpgSQL_rec *rec, - PLpgSQL_row *row, +static int exec_run_select(PLpgSQL_execstate * estate, + PLpgSQL_expr * expr, long maxtuples, Portal *portalP); +static void exec_move_row(PLpgSQL_execstate * estate, + PLpgSQL_rec * rec, + PLpgSQL_row * row, HeapTuple tup, TupleDesc tupdesc); -static HeapTuple make_tuple_from_row(PLpgSQL_execstate *estate, - PLpgSQL_row *row, +static HeapTuple make_tuple_from_row(PLpgSQL_execstate * estate, + PLpgSQL_row * row, TupleDesc tupdesc); static char *convert_value_to_string(Datum value, Oid valtype); static Datum exec_cast_value(Datum value, Oid valtype, @@ -177,10 +177,10 @@ static Datum exec_cast_value(Datum value, Oid valtype, static Datum exec_simple_cast_value(Datum value, Oid valtype, Oid reqtype, int32 reqtypmod, bool isnull); -static void exec_init_tuple_store(PLpgSQL_execstate *estate); +static void exec_init_tuple_store(PLpgSQL_execstate * estate); static bool compatible_tupdesc(TupleDesc td1, TupleDesc td2); -static void exec_set_found(PLpgSQL_execstate *estate, bool state); -static void free_var(PLpgSQL_var *var); +static void exec_set_found(PLpgSQL_execstate * estate, bool state); +static void free_var(PLpgSQL_var * var); /* ---------- @@ -189,7 +189,7 @@ static void free_var(PLpgSQL_var *var); * ---------- */ Datum -plpgsql_exec_function(PLpgSQL_function *func, FunctionCallInfo fcinfo) +plpgsql_exec_function(PLpgSQL_function * func, FunctionCallInfo fcinfo) { PLpgSQL_execstate estate; ErrorContextCallback plerrcontext; @@ -290,8 +290,8 @@ plpgsql_exec_function(PLpgSQL_function *func, FunctionCallInfo fcinfo) estate.err_text = NULL; /* - * Provide a more helpful message if a CONTINUE has been used - * outside a loop. + * Provide a more helpful message if a CONTINUE has been used outside + * a loop. */ if (rc == PLPGSQL_RC_CONTINUE) ereport(ERROR, @@ -299,8 +299,8 @@ plpgsql_exec_function(PLpgSQL_function *func, FunctionCallInfo fcinfo) errmsg("CONTINUE cannot be used outside a loop"))); else ereport(ERROR, - (errcode(ERRCODE_S_R_E_FUNCTION_EXECUTED_NO_RETURN_STATEMENT), - errmsg("control reached end of function without RETURN"))); + (errcode(ERRCODE_S_R_E_FUNCTION_EXECUTED_NO_RETURN_STATEMENT), + errmsg("control reached end of function without RETURN"))); } /* @@ -399,7 +399,7 @@ plpgsql_exec_function(PLpgSQL_function *func, FunctionCallInfo fcinfo) * ---------- */ HeapTuple -plpgsql_exec_trigger(PLpgSQL_function *func, +plpgsql_exec_trigger(PLpgSQL_function * func, TriggerData *trigdata) { PLpgSQL_execstate estate; @@ -493,7 +493,7 @@ plpgsql_exec_trigger(PLpgSQL_function *func, var = (PLpgSQL_var *) (estate.datums[func->tg_name_varno]); var->value = DirectFunctionCall1(namein, - CStringGetDatum(trigdata->tg_trigger->tgname)); + CStringGetDatum(trigdata->tg_trigger->tgname)); var->isnull = false; var->freeval = true; @@ -524,7 +524,7 @@ plpgsql_exec_trigger(PLpgSQL_function *func, var = (PLpgSQL_var *) (estate.datums[func->tg_relname_varno]); var->value = DirectFunctionCall1(namein, - CStringGetDatum(RelationGetRelationName(trigdata->tg_relation))); + CStringGetDatum(RelationGetRelationName(trigdata->tg_relation))); var->isnull = false; var->freeval = true; @@ -534,8 +534,8 @@ plpgsql_exec_trigger(PLpgSQL_function *func, var->freeval = false; /* - * Store the trigger argument values into the special execution - * state variables + * Store the trigger argument values into the special execution state + * variables */ estate.err_text = gettext_noop("while storing call arguments into local variables"); estate.trig_nargs = trigdata->tg_trigger->tgnargs; @@ -546,7 +546,7 @@ plpgsql_exec_trigger(PLpgSQL_function *func, estate.trig_argv = palloc(sizeof(Datum) * estate.trig_nargs); for (i = 0; i < trigdata->tg_trigger->tgnargs; i++) estate.trig_argv[i] = DirectFunctionCall1(textin, - CStringGetDatum(trigdata->tg_trigger->tgargs[i])); + CStringGetDatum(trigdata->tg_trigger->tgargs[i])); } /* @@ -566,8 +566,8 @@ plpgsql_exec_trigger(PLpgSQL_function *func, estate.err_text = NULL; /* - * Provide a more helpful message if a CONTINUE has been used - * outside a loop. + * Provide a more helpful message if a CONTINUE has been used outside + * a loop. */ if (rc == PLPGSQL_RC_CONTINUE) ereport(ERROR, @@ -575,8 +575,8 @@ plpgsql_exec_trigger(PLpgSQL_function *func, errmsg("CONTINUE cannot be used outside a loop"))); else ereport(ERROR, - (errcode(ERRCODE_S_R_E_FUNCTION_EXECUTED_NO_RETURN_STATEMENT), - errmsg("control reached end of trigger procedure without RETURN"))); + (errcode(ERRCODE_S_R_E_FUNCTION_EXECUTED_NO_RETURN_STATEMENT), + errmsg("control reached end of trigger procedure without RETURN"))); } if (estate.retisset) @@ -585,14 +585,14 @@ plpgsql_exec_trigger(PLpgSQL_function *func, errmsg("trigger procedure cannot return a set"))); /* - * Check that the returned tuple structure has the same attributes, - * the relation that fired the trigger has. A per-statement trigger - * always needs to return NULL, so we ignore any return value the - * function itself produces (XXX: is this a good idea?) + * Check that the returned tuple structure has the same attributes, the + * relation that fired the trigger has. A per-statement trigger always + * needs to return NULL, so we ignore any return value the function itself + * produces (XXX: is this a good idea?) * * XXX This way it is possible, that the trigger returns a tuple where - * attributes don't have the correct atttypmod's length. It's up to - * the trigger's programmer to ensure that this doesn't happen. Jan + * attributes don't have the correct atttypmod's length. It's up to the + * trigger's programmer to ensure that this doesn't happen. Jan */ if (estate.retisnull || TRIGGER_FIRED_FOR_STATEMENT(trigdata->tg_event)) rettup = NULL; @@ -652,10 +652,10 @@ plpgsql_exec_error_callback(void *arg) else if (estate->err_text != NULL) { /* - * We don't expend the cycles to run gettext() on err_text unless - * we actually need it. Therefore, places that set up err_text - * should use gettext_noop() to ensure the strings get recorded in - * the message dictionary. + * We don't expend the cycles to run gettext() on err_text unless we + * actually need it. Therefore, places that set up err_text should + * use gettext_noop() to ensure the strings get recorded in the + * message dictionary. */ /* @@ -677,48 +677,49 @@ plpgsql_exec_error_callback(void *arg) * ---------- */ static PLpgSQL_datum * -copy_plpgsql_datum(PLpgSQL_datum *datum) +copy_plpgsql_datum(PLpgSQL_datum * datum) { PLpgSQL_datum *result; switch (datum->dtype) { case PLPGSQL_DTYPE_VAR: - { - PLpgSQL_var *new = palloc(sizeof(PLpgSQL_var)); + { + PLpgSQL_var *new = palloc(sizeof(PLpgSQL_var)); - memcpy(new, datum, sizeof(PLpgSQL_var)); - /* Ensure the value is null (possibly not needed?) */ - new->value = 0; - new->isnull = true; - new->freeval = false; + memcpy(new, datum, sizeof(PLpgSQL_var)); + /* Ensure the value is null (possibly not needed?) */ + new->value = 0; + new->isnull = true; + new->freeval = false; - result = (PLpgSQL_datum *) new; - } - break; + result = (PLpgSQL_datum *) new; + } + break; case PLPGSQL_DTYPE_REC: - { - PLpgSQL_rec *new = palloc(sizeof(PLpgSQL_rec)); + { + PLpgSQL_rec *new = palloc(sizeof(PLpgSQL_rec)); - memcpy(new, datum, sizeof(PLpgSQL_rec)); - /* Ensure the value is null (possibly not needed?) */ - new->tup = NULL; - new->tupdesc = NULL; - new->freetup = false; - new->freetupdesc = false; + memcpy(new, datum, sizeof(PLpgSQL_rec)); + /* Ensure the value is null (possibly not needed?) */ + new->tup = NULL; + new->tupdesc = NULL; + new->freetup = false; + new->freetupdesc = false; - result = (PLpgSQL_datum *) new; - } - break; + result = (PLpgSQL_datum *) new; + } + break; case PLPGSQL_DTYPE_ROW: case PLPGSQL_DTYPE_RECFIELD: case PLPGSQL_DTYPE_ARRAYELEM: case PLPGSQL_DTYPE_TRIGARG: + /* - * These datum records are read-only at runtime, so no need - * to copy them + * These datum records are read-only at runtime, so no need to + * copy them */ result = datum; break; @@ -734,7 +735,7 @@ copy_plpgsql_datum(PLpgSQL_datum *datum) static bool -exception_matches_conditions(ErrorData *edata, PLpgSQL_condition *cond) +exception_matches_conditions(ErrorData *edata, PLpgSQL_condition * cond) { for (; cond != NULL; cond = cond->next) { @@ -766,7 +767,7 @@ exception_matches_conditions(ErrorData *edata, PLpgSQL_condition *cond) * ---------- */ static int -exec_stmt_block(PLpgSQL_execstate *estate, PLpgSQL_stmt_block *block) +exec_stmt_block(PLpgSQL_execstate * estate, PLpgSQL_stmt_block * block) { volatile int rc = -1; int i; @@ -794,9 +795,9 @@ exec_stmt_block(PLpgSQL_execstate *estate, PLpgSQL_stmt_block *block) var->isnull = true; if (var->notnull) ereport(ERROR, - (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), - errmsg("variable \"%s\" declared NOT NULL cannot default to NULL", - var->refname))); + (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), + errmsg("variable \"%s\" declared NOT NULL cannot default to NULL", + var->refname))); } else { @@ -836,8 +837,7 @@ exec_stmt_block(PLpgSQL_execstate *estate, PLpgSQL_stmt_block *block) if (block->exceptions) { /* - * Execute the statements in the block's body inside a - * sub-transaction + * Execute the statements in the block's body inside a sub-transaction */ MemoryContext oldcontext = CurrentMemoryContext; ResourceOwner oldowner = CurrentResourceOwner; @@ -856,15 +856,15 @@ exec_stmt_block(PLpgSQL_execstate *estate, PLpgSQL_stmt_block *block) CurrentResourceOwner = oldowner; /* - * AtEOSubXact_SPI() should not have popped any SPI context, - * but just in case it did, make sure we remain connected. + * AtEOSubXact_SPI() should not have popped any SPI context, but + * just in case it did, make sure we remain connected. */ SPI_restore_connection(); } PG_CATCH(); { - ErrorData *edata; - ListCell *e; + ErrorData *edata; + ListCell *e; /* Save error info */ MemoryContextSwitchTo(oldcontext); @@ -877,24 +877,23 @@ exec_stmt_block(PLpgSQL_execstate *estate, PLpgSQL_stmt_block *block) CurrentResourceOwner = oldowner; /* - * If AtEOSubXact_SPI() popped any SPI context of the subxact, - * it will have left us in a disconnected state. We need this - * hack to return to connected state. + * If AtEOSubXact_SPI() popped any SPI context of the subxact, it + * will have left us in a disconnected state. We need this hack + * to return to connected state. */ SPI_restore_connection(); /* Look for a matching exception handler */ - foreach (e, block->exceptions->exc_list) + foreach(e, block->exceptions->exc_list) { PLpgSQL_exception *exception = (PLpgSQL_exception *) lfirst(e); if (exception_matches_conditions(edata, exception->conditions)) { /* - * Initialize the magic SQLSTATE and SQLERRM - * variables for the exception block. We needn't - * do this until we have found a matching - * exception. + * Initialize the magic SQLSTATE and SQLERRM variables for + * the exception block. We needn't do this until we have + * found a matching exception. */ PLpgSQL_var *state_var; PLpgSQL_var *errm_var; @@ -902,14 +901,14 @@ exec_stmt_block(PLpgSQL_execstate *estate, PLpgSQL_stmt_block *block) state_var = (PLpgSQL_var *) estate->datums[block->exceptions->sqlstate_varno]; state_var->value = DirectFunctionCall1(textin, - CStringGetDatum(unpack_sql_state(edata->sqlerrcode))); + CStringGetDatum(unpack_sql_state(edata->sqlerrcode))); state_var->freeval = true; state_var->isnull = false; errm_var = (PLpgSQL_var *) estate->datums[block->exceptions->sqlerrm_varno]; errm_var->value = DirectFunctionCall1(textin, - CStringGetDatum(edata->message)); + CStringGetDatum(edata->message)); errm_var->freeval = true; errm_var->isnull = false; @@ -956,7 +955,7 @@ exec_stmt_block(PLpgSQL_execstate *estate, PLpgSQL_stmt_block *block) return PLPGSQL_RC_EXIT; estate->exitlabel = NULL; return PLPGSQL_RC_OK; - + default: elog(ERROR, "unrecognized rc: %d", rc); } @@ -971,14 +970,15 @@ exec_stmt_block(PLpgSQL_execstate *estate, PLpgSQL_stmt_block *block) * ---------- */ static int -exec_stmts(PLpgSQL_execstate *estate, List *stmts) +exec_stmts(PLpgSQL_execstate * estate, List *stmts) { ListCell *s; - foreach (s, stmts) + foreach(s, stmts) { PLpgSQL_stmt *stmt = (PLpgSQL_stmt *) lfirst(s); - int rc = exec_stmt(estate, stmt); + int rc = exec_stmt(estate, stmt); + if (rc != PLPGSQL_RC_OK) return rc; } @@ -993,7 +993,7 @@ exec_stmts(PLpgSQL_execstate *estate, List *stmts) * ---------- */ static int -exec_stmt(PLpgSQL_execstate *estate, PLpgSQL_stmt *stmt) +exec_stmt(PLpgSQL_execstate * estate, PLpgSQL_stmt * stmt) { PLpgSQL_stmt *save_estmt; int rc = -1; @@ -1102,7 +1102,7 @@ exec_stmt(PLpgSQL_execstate *estate, PLpgSQL_stmt *stmt) * ---------- */ static int -exec_stmt_assign(PLpgSQL_execstate *estate, PLpgSQL_stmt_assign *stmt) +exec_stmt_assign(PLpgSQL_execstate * estate, PLpgSQL_stmt_assign * stmt) { Assert(stmt->varno >= 0); @@ -1118,7 +1118,7 @@ exec_stmt_assign(PLpgSQL_execstate *estate, PLpgSQL_stmt_assign *stmt) * ---------- */ static int -exec_stmt_perform(PLpgSQL_execstate *estate, PLpgSQL_stmt_perform *stmt) +exec_stmt_perform(PLpgSQL_execstate * estate, PLpgSQL_stmt_perform * stmt) { PLpgSQL_expr *expr = stmt->expr; @@ -1135,15 +1135,15 @@ exec_stmt_perform(PLpgSQL_execstate *estate, PLpgSQL_stmt_perform *stmt) * ---------- */ static int -exec_stmt_getdiag(PLpgSQL_execstate *estate, PLpgSQL_stmt_getdiag *stmt) +exec_stmt_getdiag(PLpgSQL_execstate * estate, PLpgSQL_stmt_getdiag * stmt) { - ListCell *lc; + ListCell *lc; - foreach (lc, stmt->diag_items) + foreach(lc, stmt->diag_items) { - PLpgSQL_diag_item *diag_item = (PLpgSQL_diag_item *) lfirst(lc); - PLpgSQL_datum *var; - bool isnull = false; + PLpgSQL_diag_item *diag_item = (PLpgSQL_diag_item *) lfirst(lc); + PLpgSQL_datum *var; + bool isnull = false; if (diag_item->target <= 0) continue; @@ -1185,7 +1185,7 @@ exec_stmt_getdiag(PLpgSQL_execstate *estate, PLpgSQL_stmt_getdiag *stmt) * ---------- */ static int -exec_stmt_if(PLpgSQL_execstate *estate, PLpgSQL_stmt_if *stmt) +exec_stmt_if(PLpgSQL_execstate * estate, PLpgSQL_stmt_if * stmt) { bool value; bool isnull; @@ -1214,11 +1214,11 @@ exec_stmt_if(PLpgSQL_execstate *estate, PLpgSQL_stmt_if *stmt) * ---------- */ static int -exec_stmt_loop(PLpgSQL_execstate *estate, PLpgSQL_stmt_loop *stmt) +exec_stmt_loop(PLpgSQL_execstate * estate, PLpgSQL_stmt_loop * stmt) { for (;;) { - int rc = exec_stmts(estate, stmt->body); + int rc = exec_stmts(estate, stmt->body); switch (rc) { @@ -1234,7 +1234,7 @@ exec_stmt_loop(PLpgSQL_execstate *estate, PLpgSQL_stmt_loop *stmt) return PLPGSQL_RC_EXIT; estate->exitlabel = NULL; return PLPGSQL_RC_OK; - + case PLPGSQL_RC_CONTINUE: if (estate->exitlabel == NULL) /* anonymous continue, so re-run the loop */ @@ -1267,7 +1267,7 @@ exec_stmt_loop(PLpgSQL_execstate *estate, PLpgSQL_stmt_loop *stmt) * ---------- */ static int -exec_stmt_while(PLpgSQL_execstate *estate, PLpgSQL_stmt_while *stmt) +exec_stmt_while(PLpgSQL_execstate * estate, PLpgSQL_stmt_while * stmt) { for (;;) { @@ -1330,7 +1330,7 @@ exec_stmt_while(PLpgSQL_execstate *estate, PLpgSQL_stmt_while *stmt) * ---------- */ static int -exec_stmt_fori(PLpgSQL_execstate *estate, PLpgSQL_stmt_fori *stmt) +exec_stmt_fori(PLpgSQL_execstate * estate, PLpgSQL_stmt_fori * stmt) { PLpgSQL_var *var; Datum value; @@ -1413,9 +1413,9 @@ exec_stmt_fori(PLpgSQL_execstate *estate, PLpgSQL_stmt_fori *stmt) } /* - * otherwise, this is a labelled exit that does not match - * the current statement's label, if any: return RC_EXIT - * so that the EXIT continues to propagate up the stack. + * otherwise, this is a labelled exit that does not match the + * current statement's label, if any: return RC_EXIT so that the + * EXIT continues to propagate up the stack. */ break; @@ -1435,12 +1435,11 @@ exec_stmt_fori(PLpgSQL_execstate *estate, PLpgSQL_stmt_fori *stmt) else { /* - * otherwise, this is a named continue that does not - * match the current statement's label, if any: return - * RC_CONTINUE so that the CONTINUE will propagate up - * the stack. + * otherwise, this is a named continue that does not match the + * current statement's label, if any: return RC_CONTINUE so + * that the CONTINUE will propagate up the stack. */ - break; + break; } } @@ -1455,9 +1454,9 @@ exec_stmt_fori(PLpgSQL_execstate *estate, PLpgSQL_stmt_fori *stmt) /* * Set the FOUND variable to indicate the result of executing the loop - * (namely, whether we looped one or more times). This must be set - * here so that it does not interfere with the value of the FOUND - * variable inside the loop processing itself. + * (namely, whether we looped one or more times). This must be set here so + * that it does not interfere with the value of the FOUND variable inside + * the loop processing itself. */ exec_set_found(estate, found); @@ -1473,7 +1472,7 @@ exec_stmt_fori(PLpgSQL_execstate *estate, PLpgSQL_stmt_fori *stmt) * ---------- */ static int -exec_stmt_fors(PLpgSQL_execstate *estate, PLpgSQL_stmt_fors *stmt) +exec_stmt_fors(PLpgSQL_execstate * estate, PLpgSQL_stmt_fors * stmt) { PLpgSQL_rec *rec = NULL; PLpgSQL_row *row = NULL; @@ -1505,8 +1504,8 @@ exec_stmt_fors(PLpgSQL_execstate *estate, PLpgSQL_stmt_fors *stmt) n = SPI_processed; /* - * If the query didn't return any rows, set the target to NULL and - * return with FOUND = false. + * If the query didn't return any rows, set the target to NULL and return + * with FOUND = false. */ if (n == 0) exec_move_row(estate, rec, row, NULL, tuptab->tupdesc); @@ -1545,10 +1544,9 @@ exec_stmt_fors(PLpgSQL_execstate *estate, PLpgSQL_stmt_fors *stmt) } /* - * otherwise, we processed a labelled exit that does - * not match the current statement's label, if any: - * return RC_EXIT so that the EXIT continues to - * recurse upward. + * otherwise, we processed a labelled exit that does not + * match the current statement's label, if any: return + * RC_EXIT so that the EXIT continues to recurse upward. */ } else if (rc == PLPGSQL_RC_CONTINUE) @@ -1569,16 +1567,16 @@ exec_stmt_fors(PLpgSQL_execstate *estate, PLpgSQL_stmt_fors *stmt) } /* - * otherwise, we processed a named continue - * that does not match the current statement's - * label, if any: return RC_CONTINUE so that the - * CONTINUE will propagate up the stack. + * otherwise, we processed a named continue that does not + * match the current statement's label, if any: return + * RC_CONTINUE so that the CONTINUE will propagate up the + * stack. */ } /* - * We're aborting the loop, so cleanup and set FOUND. - * (This code should match the code after the loop.) + * We're aborting the loop, so cleanup and set FOUND. (This + * code should match the code after the loop.) */ SPI_freetuptable(tuptab); SPI_cursor_close(portal); @@ -1610,9 +1608,9 @@ exec_stmt_fors(PLpgSQL_execstate *estate, PLpgSQL_stmt_fors *stmt) /* * Set the FOUND variable to indicate the result of executing the loop - * (namely, whether we looped one or more times). This must be set - * here so that it does not interfere with the value of the FOUND - * variable inside the loop processing itself. + * (namely, whether we looped one or more times). This must be set here so + * that it does not interfere with the value of the FOUND variable inside + * the loop processing itself. */ exec_set_found(estate, found); @@ -1626,7 +1624,7 @@ exec_stmt_fors(PLpgSQL_execstate *estate, PLpgSQL_stmt_fors *stmt) * ---------- */ static int -exec_stmt_select(PLpgSQL_execstate *estate, PLpgSQL_stmt_select *stmt) +exec_stmt_select(PLpgSQL_execstate * estate, PLpgSQL_stmt_select * stmt) { PLpgSQL_rec *rec = NULL; PLpgSQL_row *row = NULL; @@ -1656,8 +1654,7 @@ exec_stmt_select(PLpgSQL_execstate *estate, PLpgSQL_stmt_select *stmt) n = estate->eval_processed; /* - * If the query didn't return any rows, set the target to NULL and - * return. + * If the query didn't return any rows, set the target to NULL and return. */ if (n == 0) { @@ -1685,7 +1682,7 @@ exec_stmt_select(PLpgSQL_execstate *estate, PLpgSQL_stmt_select *stmt) * ---------- */ static int -exec_stmt_exit(PLpgSQL_execstate *estate, PLpgSQL_stmt_exit *stmt) +exec_stmt_exit(PLpgSQL_execstate * estate, PLpgSQL_stmt_exit * stmt) { /* * If the exit / continue has a condition, evaluate it @@ -1715,12 +1712,12 @@ exec_stmt_exit(PLpgSQL_execstate *estate, PLpgSQL_stmt_exit *stmt) * ---------- */ static int -exec_stmt_return(PLpgSQL_execstate *estate, PLpgSQL_stmt_return *stmt) +exec_stmt_return(PLpgSQL_execstate * estate, PLpgSQL_stmt_return * stmt) { /* * If processing a set-returning PL/PgSQL function, the final RETURN - * indicates that the function is finished producing tuples. The rest - * of the work will be done at the top level. + * indicates that the function is finished producing tuples. The rest of + * the work will be done at the top level. */ if (estate->retisset) return PLPGSQL_RC_RETURN; @@ -1737,41 +1734,41 @@ exec_stmt_return(PLpgSQL_execstate *estate, PLpgSQL_stmt_return *stmt) switch (retvar->dtype) { case PLPGSQL_DTYPE_VAR: - { - PLpgSQL_var *var = (PLpgSQL_var *) retvar; + { + PLpgSQL_var *var = (PLpgSQL_var *) retvar; - estate->retval = var->value; - estate->retisnull = var->isnull; - estate->rettype = var->datatype->typoid; - } - break; + estate->retval = var->value; + estate->retisnull = var->isnull; + estate->rettype = var->datatype->typoid; + } + break; case PLPGSQL_DTYPE_REC: - { - PLpgSQL_rec *rec = (PLpgSQL_rec *) retvar; - - if (HeapTupleIsValid(rec->tup)) { - estate->retval = (Datum) rec->tup; - estate->rettupdesc = rec->tupdesc; - estate->retisnull = false; + PLpgSQL_rec *rec = (PLpgSQL_rec *) retvar; + + if (HeapTupleIsValid(rec->tup)) + { + estate->retval = (Datum) rec->tup; + estate->rettupdesc = rec->tupdesc; + estate->retisnull = false; + } } - } - break; + break; case PLPGSQL_DTYPE_ROW: - { - PLpgSQL_row *row = (PLpgSQL_row *) retvar; + { + PLpgSQL_row *row = (PLpgSQL_row *) retvar; - Assert(row->rowtupdesc); - estate->retval = (Datum) make_tuple_from_row(estate, row, - row->rowtupdesc); - if (estate->retval == (Datum) NULL) /* should not happen */ - elog(ERROR, "row not compatible with its own tupdesc"); - estate->rettupdesc = row->rowtupdesc; - estate->retisnull = false; - } - break; + Assert(row->rowtupdesc); + estate->retval = (Datum) make_tuple_from_row(estate, row, + row->rowtupdesc); + if (estate->retval == (Datum) NULL) /* should not happen */ + elog(ERROR, "row not compatible with its own tupdesc"); + estate->rettupdesc = row->rowtupdesc; + estate->retisnull = false; + } + break; default: elog(ERROR, "unrecognized dtype: %d", retvar->dtype); @@ -1806,8 +1803,8 @@ exec_stmt_return(PLpgSQL_execstate *estate, PLpgSQL_stmt_return *stmt) /* * Special hack for function returning VOID: instead of NULL, return a * non-null VOID value. This is of dubious importance but is kept for - * backwards compatibility. Note that the only other way to get here - * is to have written "RETURN NULL" in a function returning tuple. + * backwards compatibility. Note that the only other way to get here is + * to have written "RETURN NULL" in a function returning tuple. */ if (estate->fn_rettype == VOIDOID) { @@ -1826,8 +1823,8 @@ exec_stmt_return(PLpgSQL_execstate *estate, PLpgSQL_stmt_return *stmt) * ---------- */ static int -exec_stmt_return_next(PLpgSQL_execstate *estate, - PLpgSQL_stmt_return_next *stmt) +exec_stmt_return_next(PLpgSQL_execstate * estate, + PLpgSQL_stmt_return_next * stmt) { TupleDesc tupdesc; int natts; @@ -1837,7 +1834,7 @@ exec_stmt_return_next(PLpgSQL_execstate *estate, if (!estate->retisset) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("cannot use RETURN NEXT in a non-SETOF function"))); + errmsg("cannot use RETURN NEXT in a non-SETOF function"))); if (estate->tuple_store == NULL) exec_init_tuple_store(estate); @@ -1853,59 +1850,59 @@ exec_stmt_return_next(PLpgSQL_execstate *estate, switch (retvar->dtype) { case PLPGSQL_DTYPE_VAR: - { - PLpgSQL_var *var = (PLpgSQL_var *) retvar; - Datum retval = var->value; - bool isNull = var->isnull; + { + PLpgSQL_var *var = (PLpgSQL_var *) retvar; + Datum retval = var->value; + bool isNull = var->isnull; - if (natts != 1) - ereport(ERROR, - (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("wrong result type supplied in RETURN NEXT"))); + if (natts != 1) + ereport(ERROR, + (errcode(ERRCODE_DATATYPE_MISMATCH), + errmsg("wrong result type supplied in RETURN NEXT"))); - /* coerce type if needed */ - retval = exec_simple_cast_value(retval, - var->datatype->typoid, - tupdesc->attrs[0]->atttypid, + /* coerce type if needed */ + retval = exec_simple_cast_value(retval, + var->datatype->typoid, + tupdesc->attrs[0]->atttypid, tupdesc->attrs[0]->atttypmod, - isNull); + isNull); - tuple = heap_form_tuple(tupdesc, &retval, &isNull); + tuple = heap_form_tuple(tupdesc, &retval, &isNull); - free_tuple = true; - } - break; + free_tuple = true; + } + break; case PLPGSQL_DTYPE_REC: - { - PLpgSQL_rec *rec = (PLpgSQL_rec *) retvar; + { + PLpgSQL_rec *rec = (PLpgSQL_rec *) retvar; - if (!HeapTupleIsValid(rec->tup)) - ereport(ERROR, - (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), - errmsg("record \"%s\" is not assigned yet", - rec->refname), - errdetail("The tuple structure of a not-yet-assigned record is indeterminate."))); - if (!compatible_tupdesc(tupdesc, rec->tupdesc)) - ereport(ERROR, - (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("wrong record type supplied in RETURN NEXT"))); - tuple = rec->tup; - } - break; + if (!HeapTupleIsValid(rec->tup)) + ereport(ERROR, + (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), + errmsg("record \"%s\" is not assigned yet", + rec->refname), + errdetail("The tuple structure of a not-yet-assigned record is indeterminate."))); + if (!compatible_tupdesc(tupdesc, rec->tupdesc)) + ereport(ERROR, + (errcode(ERRCODE_DATATYPE_MISMATCH), + errmsg("wrong record type supplied in RETURN NEXT"))); + tuple = rec->tup; + } + break; case PLPGSQL_DTYPE_ROW: - { - PLpgSQL_row *row = (PLpgSQL_row *) retvar; + { + PLpgSQL_row *row = (PLpgSQL_row *) retvar; - tuple = make_tuple_from_row(estate, row, tupdesc); - if (tuple == NULL) - ereport(ERROR, - (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("wrong record type supplied in RETURN NEXT"))); - free_tuple = true; - } - break; + tuple = make_tuple_from_row(estate, row, tupdesc); + if (tuple == NULL) + ereport(ERROR, + (errcode(ERRCODE_DATATYPE_MISMATCH), + errmsg("wrong record type supplied in RETURN NEXT"))); + free_tuple = true; + } + break; default: elog(ERROR, "unrecognized dtype: %d", retvar->dtype); @@ -1922,7 +1919,7 @@ exec_stmt_return_next(PLpgSQL_execstate *estate, if (natts != 1) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("wrong result type supplied in RETURN NEXT"))); + errmsg("wrong result type supplied in RETURN NEXT"))); retval = exec_eval_expr(estate, stmt->expr, @@ -1966,7 +1963,7 @@ exec_stmt_return_next(PLpgSQL_execstate *estate, } static void -exec_init_tuple_store(PLpgSQL_execstate *estate) +exec_init_tuple_store(PLpgSQL_execstate * estate) { ReturnSetInfo *rsi = estate->rsi; MemoryContext oldcxt; @@ -1995,7 +1992,7 @@ exec_init_tuple_store(PLpgSQL_execstate *estate) * ---------- */ static int -exec_stmt_raise(PLpgSQL_execstate *estate, PLpgSQL_stmt_raise *stmt) +exec_stmt_raise(PLpgSQL_execstate * estate, PLpgSQL_stmt_raise * stmt) { char *cp; PLpgSQL_dstring ds; @@ -2030,7 +2027,7 @@ exec_stmt_raise(PLpgSQL_execstate *estate, PLpgSQL_stmt_raise *stmt) errmsg("too few parameters specified for RAISE"))); paramvalue = exec_eval_expr(estate, - (PLpgSQL_expr *) lfirst(current_param), + (PLpgSQL_expr *) lfirst(current_param), ¶misnull, ¶mtypeid); @@ -2048,8 +2045,8 @@ exec_stmt_raise(PLpgSQL_execstate *estate, PLpgSQL_stmt_raise *stmt) } /* - * If more parameters were specified than were required to process - * the format string, throw an error + * If more parameters were specified than were required to process the + * format string, throw an error */ if (current_param != NULL) ereport(ERROR, @@ -2062,8 +2059,8 @@ exec_stmt_raise(PLpgSQL_execstate *estate, PLpgSQL_stmt_raise *stmt) estate->err_text = raise_skip_msg; /* suppress traceback of raise */ ereport(stmt->elog_level, - ((stmt->elog_level >= ERROR) ? errcode(ERRCODE_RAISE_EXCEPTION) : 0, - errmsg_internal("%s", plpgsql_dstring_get(&ds)))); + ((stmt->elog_level >= ERROR) ? errcode(ERRCODE_RAISE_EXCEPTION) : 0, + errmsg_internal("%s", plpgsql_dstring_get(&ds)))); estate->err_text = NULL; /* un-suppress... */ @@ -2078,8 +2075,8 @@ exec_stmt_raise(PLpgSQL_execstate *estate, PLpgSQL_stmt_raise *stmt) * ---------- */ static void -plpgsql_estate_setup(PLpgSQL_execstate *estate, - PLpgSQL_function *func, +plpgsql_estate_setup(PLpgSQL_execstate * estate, + PLpgSQL_function * func, ReturnSetInfo *rsi) { estate->retval = (Datum) 0; @@ -2116,9 +2113,9 @@ plpgsql_estate_setup(PLpgSQL_execstate *estate, estate->err_text = NULL; /* - * Create an EState for evaluation of simple expressions, if there's - * not one already in the current transaction. The EState is made a - * child of TopTransactionContext so it will have the right lifespan. + * Create an EState for evaluation of simple expressions, if there's not + * one already in the current transaction. The EState is made a child of + * TopTransactionContext so it will have the right lifespan. */ if (simple_eval_estate == NULL) { @@ -2130,8 +2127,8 @@ plpgsql_estate_setup(PLpgSQL_execstate *estate, } /* - * Create an expression context for simple expressions. - * This must be a child of simple_eval_estate. + * Create an expression context for simple expressions. This must be a + * child of simple_eval_estate. */ estate->eval_econtext = CreateExprContext(simple_eval_estate); } @@ -2144,7 +2141,7 @@ plpgsql_estate_setup(PLpgSQL_execstate *estate, * ---------- */ static void -exec_eval_cleanup(PLpgSQL_execstate *estate) +exec_eval_cleanup(PLpgSQL_execstate * estate) { /* Clear result of a full SPI_execute */ if (estate->eval_tuptable != NULL) @@ -2162,8 +2159,8 @@ exec_eval_cleanup(PLpgSQL_execstate *estate) * ---------- */ static void -exec_prepare_plan(PLpgSQL_execstate *estate, - PLpgSQL_expr *expr) +exec_prepare_plan(PLpgSQL_execstate * estate, + PLpgSQL_expr * expr) { int i; _SPI_plan *spi_plan; @@ -2198,16 +2195,16 @@ exec_prepare_plan(PLpgSQL_execstate *estate, case SPI_ERROR_COPY: ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot COPY to/from client in PL/pgSQL"))); + errmsg("cannot COPY to/from client in PL/pgSQL"))); case SPI_ERROR_CURSOR: ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot manipulate cursors directly in PL/pgSQL"), - errhint("Use PL/pgSQL's cursor features instead."))); + errmsg("cannot manipulate cursors directly in PL/pgSQL"), + errhint("Use PL/pgSQL's cursor features instead."))); case SPI_ERROR_TRANSACTION: ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot begin/end transactions in PL/pgSQL"), + errmsg("cannot begin/end transactions in PL/pgSQL"), errhint("Use a BEGIN block with an EXCEPTION clause instead."))); default: elog(ERROR, "SPI_prepare failed for \"%s\": %s", @@ -2231,8 +2228,8 @@ exec_prepare_plan(PLpgSQL_execstate *estate, * ---------- */ static int -exec_stmt_execsql(PLpgSQL_execstate *estate, - PLpgSQL_stmt_execsql *stmt) +exec_stmt_execsql(PLpgSQL_execstate * estate, + PLpgSQL_stmt_execsql * stmt) { int i; Datum *values; @@ -2282,9 +2279,9 @@ exec_stmt_execsql(PLpgSQL_execstate *estate, case SPI_OK_UPDATE: /* - * If the INSERT, DELETE, or UPDATE query affected at least - * one tuple, set the magic 'FOUND' variable to true. This - * conforms with the behavior of PL/SQL. + * If the INSERT, DELETE, or UPDATE query affected at least one + * tuple, set the magic 'FOUND' variable to true. This conforms + * with the behavior of PL/SQL. */ exec_set_found(estate, (SPI_processed != 0)); break; @@ -2292,7 +2289,7 @@ exec_stmt_execsql(PLpgSQL_execstate *estate, case SPI_OK_SELECT: ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("SELECT query has no destination for result data"), + errmsg("SELECT query has no destination for result data"), errhint("If you want to discard the results, use PERFORM instead."))); default: @@ -2323,8 +2320,8 @@ exec_stmt_execsql(PLpgSQL_execstate *estate, * ---------- */ static int -exec_stmt_dynexecute(PLpgSQL_execstate *estate, - PLpgSQL_stmt_dynexecute *stmt) +exec_stmt_dynexecute(PLpgSQL_execstate * estate, + PLpgSQL_stmt_dynexecute * stmt) { Datum query; bool isnull = false; @@ -2340,8 +2337,8 @@ exec_stmt_dynexecute(PLpgSQL_execstate *estate, row = (PLpgSQL_row *) (estate->datums[stmt->row->rowno]); /* - * First we evaluate the string expression after the EXECUTE keyword. - * It's result is the querystring we have to execute. + * First we evaluate the string expression after the EXECUTE keyword. It's + * result is the querystring we have to execute. */ query = exec_eval_expr(estate, stmt->query, &isnull, &restype); if (isnull) @@ -2356,8 +2353,8 @@ exec_stmt_dynexecute(PLpgSQL_execstate *estate, /* * Call SPI_execute() without preparing a saved plan. The returncode can - * be any standard OK. Note that while a SELECT is allowed, its - * results will be discarded unless an INTO clause is specified. + * be any standard OK. Note that while a SELECT is allowed, its results + * will be discarded unless an INTO clause is specified. */ exec_res = SPI_execute(querystr, estate->readonly_func, 0); @@ -2398,14 +2395,13 @@ exec_stmt_dynexecute(PLpgSQL_execstate *estate, case SPI_OK_SELINTO: /* - * We want to disallow SELECT INTO for now, because its - * behavior is not consistent with SELECT INTO in a normal - * plpgsql context. (We need to reimplement EXECUTE to parse - * the string as a plpgsql command, not just feed it to - * SPI_execute.) However, CREATE AS should be allowed ... and - * since it produces the same parsetree as SELECT INTO, - * there's no way to tell the difference except to look at the - * source text. Wotta kluge! + * We want to disallow SELECT INTO for now, because its behavior + * is not consistent with SELECT INTO in a normal plpgsql context. + * (We need to reimplement EXECUTE to parse the string as a + * plpgsql command, not just feed it to SPI_execute.) However, + * CREATE AS should be allowed ... and since it produces the same + * parsetree as SELECT INTO, there's no way to tell the difference + * except to look at the source text. Wotta kluge! */ { char *ptr; @@ -2428,13 +2424,13 @@ exec_stmt_dynexecute(PLpgSQL_execstate *estate, case SPI_ERROR_CURSOR: ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot manipulate cursors directly in PL/pgSQL"), + errmsg("cannot manipulate cursors directly in PL/pgSQL"), errhint("Use PL/pgSQL's cursor features instead."))); case SPI_ERROR_TRANSACTION: ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("cannot begin/end transactions in PL/pgSQL"), - errhint("Use a BEGIN block with an EXCEPTION clause instead."))); + errhint("Use a BEGIN block with an EXCEPTION clause instead."))); default: elog(ERROR, "SPI_execute failed executing query \"%s\": %s", @@ -2462,7 +2458,7 @@ exec_stmt_dynexecute(PLpgSQL_execstate *estate, * ---------- */ static int -exec_stmt_dynfors(PLpgSQL_execstate *estate, PLpgSQL_stmt_dynfors *stmt) +exec_stmt_dynfors(PLpgSQL_execstate * estate, PLpgSQL_stmt_dynfors * stmt) { Datum query; bool isnull; @@ -2487,8 +2483,8 @@ exec_stmt_dynfors(PLpgSQL_execstate *estate, PLpgSQL_stmt_dynfors *stmt) elog(ERROR, "unsupported target"); /* - * Evaluate the string expression after the EXECUTE keyword. It's - * result is the querystring we have to execute. + * Evaluate the string expression after the EXECUTE keyword. It's result + * is the querystring we have to execute. */ query = exec_eval_expr(estate, stmt->query, &isnull, &restype); if (isnull) @@ -2524,8 +2520,8 @@ exec_stmt_dynfors(PLpgSQL_execstate *estate, PLpgSQL_stmt_dynfors *stmt) n = SPI_processed; /* - * If the query didn't return any rows, set the target to NULL and - * return with FOUND = false. + * If the query didn't return any rows, set the target to NULL and return + * with FOUND = false. */ if (n == 0) exec_move_row(estate, rec, row, NULL, tuptab->tupdesc); @@ -2541,7 +2537,7 @@ exec_stmt_dynfors(PLpgSQL_execstate *estate, PLpgSQL_stmt_dynfors *stmt) for (i = 0; i < n; i++) { - int rc; + int rc; /* * Assign the tuple to the target @@ -2569,10 +2565,9 @@ exec_stmt_dynfors(PLpgSQL_execstate *estate, PLpgSQL_stmt_dynfors *stmt) } /* - * otherwise, we processed a labelled exit that does - * not match the current statement's label, if any: - * return RC_EXIT so that the EXIT continues to - * recurse upward. + * otherwise, we processed a labelled exit that does not + * match the current statement's label, if any: return + * RC_EXIT so that the EXIT continues to recurse upward. */ } else if (rc == PLPGSQL_RC_CONTINUE) @@ -2589,15 +2584,15 @@ exec_stmt_dynfors(PLpgSQL_execstate *estate, PLpgSQL_stmt_dynfors *stmt) } /* - * otherwise, we process a labelled continue that - * does not match the current statement's label, - * so propagate RC_CONTINUE upward in the stack. + * otherwise, we process a labelled continue that does not + * match the current statement's label, so propagate + * RC_CONTINUE upward in the stack. */ } /* - * We're aborting the loop, so cleanup and set FOUND. - * (This code should match the code after the loop.) + * We're aborting the loop, so cleanup and set FOUND. (This + * code should match the code after the loop.) */ SPI_freetuptable(tuptab); SPI_cursor_close(portal); @@ -2629,9 +2624,9 @@ exec_stmt_dynfors(PLpgSQL_execstate *estate, PLpgSQL_stmt_dynfors *stmt) /* * Set the FOUND variable to indicate the result of executing the loop - * (namely, whether we looped one or more times). This must be set - * here so that it does not interfere with the value of the FOUND - * variable inside the loop processing itself. + * (namely, whether we looped one or more times). This must be set here so + * that it does not interfere with the value of the FOUND variable inside + * the loop processing itself. */ exec_set_found(estate, found); @@ -2644,7 +2639,7 @@ exec_stmt_dynfors(PLpgSQL_execstate *estate, PLpgSQL_stmt_dynfors *stmt) * ---------- */ static int -exec_stmt_open(PLpgSQL_execstate *estate, PLpgSQL_stmt_open *stmt) +exec_stmt_open(PLpgSQL_execstate * estate, PLpgSQL_stmt_open * stmt) { PLpgSQL_var *curvar = NULL; char *curname = NULL; @@ -2765,7 +2760,7 @@ exec_stmt_open(PLpgSQL_execstate *estate, PLpgSQL_stmt_open *stmt) if (curvar->cursor_explicit_argrow < 0) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("arguments given for cursor without arguments"))); + errmsg("arguments given for cursor without arguments"))); memset(&set_args, 0, sizeof(set_args)); set_args.cmd_type = PLPGSQL_STMT_SELECT; @@ -2846,7 +2841,7 @@ exec_stmt_open(PLpgSQL_execstate *estate, PLpgSQL_stmt_open *stmt) * ---------- */ static int -exec_stmt_fetch(PLpgSQL_execstate *estate, PLpgSQL_stmt_fetch *stmt) +exec_stmt_fetch(PLpgSQL_execstate * estate, PLpgSQL_stmt_fetch * stmt) { PLpgSQL_var *curvar = NULL; PLpgSQL_rec *rec = NULL; @@ -2864,7 +2859,7 @@ exec_stmt_fetch(PLpgSQL_execstate *estate, PLpgSQL_stmt_fetch *stmt) if (curvar->isnull) ereport(ERROR, (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), - errmsg("cursor variable \"%s\" is NULL", curvar->refname))); + errmsg("cursor variable \"%s\" is NULL", curvar->refname))); curname = DatumGetCString(DirectFunctionCall1(textout, curvar->value)); portal = SPI_cursor_find(curname); @@ -2919,7 +2914,7 @@ exec_stmt_fetch(PLpgSQL_execstate *estate, PLpgSQL_stmt_fetch *stmt) * ---------- */ static int -exec_stmt_close(PLpgSQL_execstate *estate, PLpgSQL_stmt_close *stmt) +exec_stmt_close(PLpgSQL_execstate * estate, PLpgSQL_stmt_close * stmt) { PLpgSQL_var *curvar = NULL; Portal portal; @@ -2933,7 +2928,7 @@ exec_stmt_close(PLpgSQL_execstate *estate, PLpgSQL_stmt_close *stmt) if (curvar->isnull) ereport(ERROR, (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), - errmsg("cursor variable \"%s\" is NULL", curvar->refname))); + errmsg("cursor variable \"%s\" is NULL", curvar->refname))); curname = DatumGetCString(DirectFunctionCall1(textout, curvar->value)); portal = SPI_cursor_find(curname); @@ -2959,8 +2954,8 @@ exec_stmt_close(PLpgSQL_execstate *estate, PLpgSQL_stmt_close *stmt) * ---------- */ static void -exec_assign_expr(PLpgSQL_execstate *estate, PLpgSQL_datum *target, - PLpgSQL_expr *expr) +exec_assign_expr(PLpgSQL_execstate * estate, PLpgSQL_datum * target, + PLpgSQL_expr * expr) { Datum value; Oid valtype; @@ -2977,8 +2972,8 @@ exec_assign_expr(PLpgSQL_execstate *estate, PLpgSQL_datum *target, * ---------- */ static void -exec_assign_value(PLpgSQL_execstate *estate, - PLpgSQL_datum *target, +exec_assign_value(PLpgSQL_execstate * estate, + PLpgSQL_datum * target, Datum value, Oid valtype, bool *isNull) { switch (target->dtype) @@ -3005,10 +3000,10 @@ exec_assign_value(PLpgSQL_execstate *estate, /* * If type is by-reference, make sure we have a freshly - * palloc'd copy; the originally passed value may not live - * as long as the variable! But we don't need to re-copy - * if exec_cast_value performed a conversion; its output - * must already be palloc'd. + * palloc'd copy; the originally passed value may not live as + * long as the variable! But we don't need to re-copy if + * exec_cast_value performed a conversion; its output must + * already be palloc'd. */ if (!var->datatype->typbyval && !*isNull) { @@ -3019,10 +3014,10 @@ exec_assign_value(PLpgSQL_execstate *estate, } /* - * Now free the old value. (We can't do this any earlier - * because of the possibility that we are assigning the - * var's old value to it, eg "foo := foo". We could optimize - * out the assignment altogether in such cases, but it's too + * Now free the old value. (We can't do this any earlier + * because of the possibility that we are assigning the var's + * old value to it, eg "foo := foo". We could optimize out + * the assignment altogether in such cases, but it's too * infrequent to be worth testing for.) */ free_var(var); @@ -3139,16 +3134,16 @@ exec_assign_value(PLpgSQL_execstate *estate, rec = (PLpgSQL_rec *) (estate->datums[recfield->recparentno]); /* - * Check that there is already a tuple in the record. We - * need that because records don't have any predefined - * field structure. + * Check that there is already a tuple in the record. We need + * that because records don't have any predefined field + * structure. */ if (!HeapTupleIsValid(rec->tup)) ereport(ERROR, - (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), - errmsg("record \"%s\" is not assigned yet", - rec->refname), - errdetail("The tuple structure of a not-yet-assigned record is indeterminate."))); + (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), + errmsg("record \"%s\" is not assigned yet", + rec->refname), + errdetail("The tuple structure of a not-yet-assigned record is indeterminate."))); /* * Get the number of the records field to change and the @@ -3164,9 +3159,9 @@ exec_assign_value(PLpgSQL_execstate *estate, natts = rec->tupdesc->natts; /* - * Set up values/datums arrays for heap_formtuple. For - * all the attributes except the one we want to replace, - * use the value that's in the old tuple. + * Set up values/datums arrays for heap_formtuple. For all + * the attributes except the one we want to replace, use the + * value that's in the old tuple. */ values = palloc(sizeof(Datum) * natts); nulls = palloc(natts); @@ -3184,8 +3179,8 @@ exec_assign_value(PLpgSQL_execstate *estate, } /* - * Now insert the new value, being careful to cast it to - * the right type. + * Now insert the new value, being careful to cast it to the + * right type. */ atttype = SPI_gettypeid(rec->tupdesc, fno + 1); atttypmod = rec->tupdesc->attrs[fno]->atttypmod; @@ -3201,8 +3196,8 @@ exec_assign_value(PLpgSQL_execstate *estate, nulls[fno] = ' '; /* - * Avoid leaking the result of exec_simple_cast_value, if - * it performed a conversion to a pass-by-ref type. + * Avoid leaking the result of exec_simple_cast_value, if it + * performed a conversion to a pass-by-ref type. */ if (!attisnull && values[fno] != value && !get_typbyval(atttype)) mustfree = DatumGetPointer(values[fno]); @@ -3251,12 +3246,12 @@ exec_assign_value(PLpgSQL_execstate *estate, /* * Target is an element of an array * - * To handle constructs like x[1][2] := something, we have to - * be prepared to deal with a chain of arrayelem datums. - * Chase back to find the base array datum, and save the - * subscript expressions as we go. (We are scanning right - * to left here, but want to evaluate the subscripts - * left-to-right to minimize surprises.) + * To handle constructs like x[1][2] := something, we have to be + * prepared to deal with a chain of arrayelem datums. Chase + * back to find the base array datum, and save the subscript + * expressions as we go. (We are scanning right to left here, + * but want to evaluate the subscripts left-to-right to + * minimize surprises.) */ nsubscripts = 0; do @@ -3274,13 +3269,13 @@ exec_assign_value(PLpgSQL_execstate *estate, /* Fetch current value of array datum */ exec_eval_datum(estate, target, InvalidOid, - &arraytypeid, &oldarraydatum, &oldarrayisnull); + &arraytypeid, &oldarraydatum, &oldarrayisnull); arrayelemtypeid = get_element_type(arraytypeid); if (!OidIsValid(arrayelemtypeid)) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("subscripted object is not an array"))); + errmsg("subscripted object is not an array"))); get_typlenbyvalalign(arrayelemtypeid, &elemtyplen, @@ -3289,8 +3284,7 @@ exec_assign_value(PLpgSQL_execstate *estate, arraytyplen = get_typlen(arraytypeid); /* - * Evaluate the subscripts, switch into left-to-right - * order + * Evaluate the subscripts, switch into left-to-right order */ havenullsubscript = false; for (i = 0; i < nsubscripts; i++) @@ -3313,12 +3307,12 @@ exec_assign_value(PLpgSQL_execstate *estate, return; /* - * If the original array is null, cons up an empty array - * so that the assignment can proceed; we'll end with a + * If the original array is null, cons up an empty array so + * that the assignment can proceed; we'll end with a * one-element array containing just the assigned-to - * subscript. This only works for varlena arrays, though; - * for fixed-length array types we skip the assignment. - * Again, this corresponds to the current behavior of + * subscript. This only works for varlena arrays, though; for + * fixed-length array types we skip the assignment. Again, + * this corresponds to the current behavior of * ExecEvalArrayRef(). */ if (oldarrayisnull) @@ -3363,8 +3357,8 @@ exec_assign_value(PLpgSQL_execstate *estate, arraytypeid, isNull); /* - * Avoid leaking the result of exec_simple_cast_value, if - * it performed a conversion to a pass-by-ref type. + * Avoid leaking the result of exec_simple_cast_value, if it + * performed a conversion to a pass-by-ref type. */ if (!*isNull && coerced_value != value && !elemtypbyval) pfree(DatumGetPointer(coerced_value)); @@ -3391,13 +3385,13 @@ exec_assign_value(PLpgSQL_execstate *estate, * At present this doesn't handle PLpgSQL_expr or PLpgSQL_arrayelem datums. * * NOTE: caller must not modify the returned value, since it points right - * at the stored value in the case of pass-by-reference datatypes. In some + * at the stored value in the case of pass-by-reference datatypes. In some * cases we have to palloc a return value, and in such cases we put it into * the estate's short-term memory context. */ static void -exec_eval_datum(PLpgSQL_execstate *estate, - PLpgSQL_datum *datum, +exec_eval_datum(PLpgSQL_execstate * estate, + PLpgSQL_datum * datum, Oid expectedtypeid, Oid *typeid, Datum *value, @@ -3454,19 +3448,18 @@ exec_eval_datum(PLpgSQL_execstate *estate, if (!HeapTupleIsValid(rec->tup)) ereport(ERROR, - (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), - errmsg("record \"%s\" is not assigned yet", - rec->refname), - errdetail("The tuple structure of a not-yet-assigned record is indeterminate."))); + (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), + errmsg("record \"%s\" is not assigned yet", + rec->refname), + errdetail("The tuple structure of a not-yet-assigned record is indeterminate."))); Assert(rec->tupdesc != NULL); /* Make sure we have a valid type/typmod setting */ BlessTupleDesc(rec->tupdesc); /* - * In a trigger, the NEW and OLD parameters are likely to - * be on-disk tuples that don't have the desired Datum - * fields. Copy the tuple body and insert the right - * values. + * In a trigger, the NEW and OLD parameters are likely to be + * on-disk tuples that don't have the desired Datum fields. + * Copy the tuple body and insert the right values. */ oldcontext = MemoryContextSwitchTo(estate->eval_econtext->ecxt_per_tuple_memory); heap_copytuple_with_tuple(rec->tup, &worktup); @@ -3494,10 +3487,10 @@ exec_eval_datum(PLpgSQL_execstate *estate, rec = (PLpgSQL_rec *) (estate->datums[recfield->recparentno]); if (!HeapTupleIsValid(rec->tup)) ereport(ERROR, - (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), - errmsg("record \"%s\" is not assigned yet", - rec->refname), - errdetail("The tuple structure of a not-yet-assigned record is indeterminate."))); + (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), + errmsg("record \"%s\" is not assigned yet", + rec->refname), + errdetail("The tuple structure of a not-yet-assigned record is indeterminate."))); fno = SPI_fnumber(rec->tupdesc, recfield->fieldname); if (fno == SPI_ERROR_NOATTRIBUTE) ereport(ERROR, @@ -3555,8 +3548,8 @@ exec_eval_datum(PLpgSQL_execstate *estate, * ---------- */ static int -exec_eval_integer(PLpgSQL_execstate *estate, - PLpgSQL_expr *expr, +exec_eval_integer(PLpgSQL_execstate * estate, + PLpgSQL_expr * expr, bool *isNull) { Datum exprdatum; @@ -3577,8 +3570,8 @@ exec_eval_integer(PLpgSQL_execstate *estate, * ---------- */ static bool -exec_eval_boolean(PLpgSQL_execstate *estate, - PLpgSQL_expr *expr, +exec_eval_boolean(PLpgSQL_execstate * estate, + PLpgSQL_expr * expr, bool *isNull) { Datum exprdatum; @@ -3599,8 +3592,8 @@ exec_eval_boolean(PLpgSQL_execstate *estate, * ---------- */ static Datum -exec_eval_expr(PLpgSQL_execstate *estate, - PLpgSQL_expr *expr, +exec_eval_expr(PLpgSQL_execstate * estate, + PLpgSQL_expr * expr, bool *isNull, Oid *rettype) { @@ -3623,7 +3616,7 @@ exec_eval_expr(PLpgSQL_execstate *estate, if (rc != SPI_OK_SELECT) ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), - errmsg("query \"%s\" did not return data", expr->query))); + errmsg("query \"%s\" did not return data", expr->query))); /* * If there are no rows selected, the result is NULL. @@ -3662,8 +3655,8 @@ exec_eval_expr(PLpgSQL_execstate *estate, * ---------- */ static int -exec_run_select(PLpgSQL_execstate *estate, - PLpgSQL_expr *expr, long maxtuples, Portal *portalP) +exec_run_select(PLpgSQL_execstate * estate, + PLpgSQL_expr * expr, long maxtuples, Portal *portalP) { int i; Datum *values; @@ -3744,8 +3737,8 @@ exec_run_select(PLpgSQL_execstate *estate, * ---------- */ static Datum -exec_eval_simple_expr(PLpgSQL_execstate *estate, - PLpgSQL_expr *expr, +exec_eval_simple_expr(PLpgSQL_execstate * estate, + PLpgSQL_expr * expr, bool *isNull, Oid *rettype) { @@ -3761,8 +3754,8 @@ exec_eval_simple_expr(PLpgSQL_execstate *estate, *rettype = expr->expr_simple_type; /* - * Prepare the expression for execution, if it's not been done already - * in the current transaction. + * Prepare the expression for execution, if it's not been done already in + * the current transaction. */ if (expr->expr_simple_state == NULL) { @@ -3776,14 +3769,14 @@ exec_eval_simple_expr(PLpgSQL_execstate *estate, /* * Param list can live in econtext's temporary memory context. * - * XXX think about avoiding repeated palloc's for param lists? Beware - * however that this routine is re-entrant: exec_eval_datum() can call - * it back for subscript evaluation, and so there can be a need to - * have more than one active param list. + * XXX think about avoiding repeated palloc's for param lists? Beware however + * that this routine is re-entrant: exec_eval_datum() can call it back for + * subscript evaluation, and so there can be a need to have more than one + * active param list. */ paramLI = (ParamListInfo) MemoryContextAlloc(econtext->ecxt_per_tuple_memory, - (expr->nparams + 1) * sizeof(ParamListInfoData)); + (expr->nparams + 1) * sizeof(ParamListInfoData)); /* * Put the parameter values into the parameter list entries. @@ -3806,10 +3799,10 @@ exec_eval_simple_expr(PLpgSQL_execstate *estate, econtext->ecxt_param_list_info = paramLI; /* - * We have to do some of the things SPI_execute_plan would do, - * in particular advance the snapshot if we are in a non-read-only - * function. Without this, stable functions within the expression - * would fail to see updates made so far by our own function. + * We have to do some of the things SPI_execute_plan would do, in + * particular advance the snapshot if we are in a non-read-only function. + * Without this, stable functions within the expression would fail to see + * updates made so far by our own function. */ SPI_push(); saveActiveSnapshot = ActiveSnapshot; @@ -3857,9 +3850,9 @@ exec_eval_simple_expr(PLpgSQL_execstate *estate, * ---------- */ static void -exec_move_row(PLpgSQL_execstate *estate, - PLpgSQL_rec *rec, - PLpgSQL_row *row, +exec_move_row(PLpgSQL_execstate * estate, + PLpgSQL_rec * rec, + PLpgSQL_row * row, HeapTuple tup, TupleDesc tupdesc) { /* @@ -3923,16 +3916,16 @@ exec_move_row(PLpgSQL_execstate *estate, * Row is a bit more complicated in that we assign the individual * attributes of the tuple to the variables the row points to. * - * NOTE: this code used to demand row->nfields == tup->t_data->t_natts, - * but that's wrong. The tuple might have more fields than we - * expected if it's from an inheritance-child table of the current - * table, or it might have fewer if the table has had columns added by - * ALTER TABLE. Ignore extra columns and assume NULL for missing - * columns, the same as heap_getattr would do. We also have to skip - * over dropped columns in either the source or destination. + * NOTE: this code used to demand row->nfields == tup->t_data->t_natts, but + * that's wrong. The tuple might have more fields than we expected if + * it's from an inheritance-child table of the current table, or it might + * have fewer if the table has had columns added by ALTER TABLE. Ignore + * extra columns and assume NULL for missing columns, the same as + * heap_getattr would do. We also have to skip over dropped columns in + * either the source or destination. * - * If we have no tuple data at all, we'll assign NULL to all columns of - * the row variable. + * If we have no tuple data at all, we'll assign NULL to all columns of the + * row variable. */ if (row != NULL) { @@ -3991,8 +3984,8 @@ exec_move_row(PLpgSQL_execstate *estate, * ---------- */ static HeapTuple -make_tuple_from_row(PLpgSQL_execstate *estate, - PLpgSQL_row *row, +make_tuple_from_row(PLpgSQL_execstate * estate, + PLpgSQL_row * row, TupleDesc tupdesc) { int natts = tupdesc->natts; @@ -4066,8 +4059,8 @@ exec_cast_value(Datum value, Oid valtype, if (!isnull) { /* - * If the type of the queries return value isn't that of the - * variable, convert it. + * If the type of the queries return value isn't that of the variable, + * convert it. */ if (valtype != reqtype || reqtypmod != -1) { @@ -4358,7 +4351,7 @@ exec_simple_check_node(Node *node) * ---------- */ static void -exec_simple_check_plan(PLpgSQL_expr *expr) +exec_simple_check_plan(PLpgSQL_expr * expr) { _SPI_plan *spi_plan = (_SPI_plan *) expr->plan; Plan *plan; @@ -4367,8 +4360,8 @@ exec_simple_check_plan(PLpgSQL_expr *expr) expr->expr_simple_expr = NULL; /* - * 1. We can only evaluate queries that resulted in one single - * execution plan + * 1. We can only evaluate queries that resulted in one single execution + * plan */ if (list_length(spi_plan->ptlist) != 1) return; @@ -4445,7 +4438,7 @@ compatible_tupdesc(TupleDesc td1, TupleDesc td2) * ---------- */ static void -exec_set_found(PLpgSQL_execstate *estate, bool state) +exec_set_found(PLpgSQL_execstate * estate, bool state) { PLpgSQL_var *var; @@ -4481,10 +4474,10 @@ plpgsql_xact_cb(XactEvent event, void *arg) active_simple_exprs = NULL; /* - * If we are doing a clean transaction shutdown, free the - * EState (so that any remaining resources will be released - * correctly). In an abort, we expect the regular abort - * recovery procedures to release everything of interest. + * If we are doing a clean transaction shutdown, free the EState (so that + * any remaining resources will be released correctly). In an abort, we + * expect the regular abort recovery procedures to release everything of + * interest. */ if (event == XACT_EVENT_COMMIT && simple_eval_estate) FreeExecutorState(simple_eval_estate); @@ -4492,7 +4485,7 @@ plpgsql_xact_cb(XactEvent event, void *arg) } static void -free_var(PLpgSQL_var *var) +free_var(PLpgSQL_var * var) { if (var->freeval) { diff --git a/src/pl/plpgsql/src/pl_funcs.c b/src/pl/plpgsql/src/pl_funcs.c index 03280c94b1..dd12a061f3 100644 --- a/src/pl/plpgsql/src/pl_funcs.c +++ b/src/pl/plpgsql/src/pl_funcs.c @@ -3,7 +3,7 @@ * procedural language * * IDENTIFICATION - * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_funcs.c,v 1.45 2005/06/22 01:35:02 neilc Exp $ + * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_funcs.c,v 1.46 2005/10/15 02:49:50 momjian Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -56,7 +56,7 @@ static bool ns_localmode = false; * ---------- */ void -plpgsql_dstring_init(PLpgSQL_dstring *ds) +plpgsql_dstring_init(PLpgSQL_dstring * ds) { ds->value = palloc(ds->alloc = 512); ds->used = 1; @@ -69,13 +69,13 @@ plpgsql_dstring_init(PLpgSQL_dstring *ds) * ---------- */ void -plpgsql_dstring_free(PLpgSQL_dstring *ds) +plpgsql_dstring_free(PLpgSQL_dstring * ds) { pfree(ds->value); } static void -plpgsql_dstring_expand(PLpgSQL_dstring *ds, int needed) +plpgsql_dstring_expand(PLpgSQL_dstring * ds, int needed) { /* Don't allow truncating the string */ Assert(needed > ds->alloc); @@ -94,7 +94,7 @@ plpgsql_dstring_expand(PLpgSQL_dstring *ds, int needed) * ---------- */ void -plpgsql_dstring_append(PLpgSQL_dstring *ds, const char *str) +plpgsql_dstring_append(PLpgSQL_dstring * ds, const char *str) { int len = strlen(str); int needed = ds->used + len; @@ -113,7 +113,7 @@ plpgsql_dstring_append(PLpgSQL_dstring *ds, const char *str) * ---------- */ void -plpgsql_dstring_append_char(PLpgSQL_dstring *ds, char c) +plpgsql_dstring_append_char(PLpgSQL_dstring * ds, char c) { if (ds->used == ds->alloc) plpgsql_dstring_expand(ds, ds->used + 1); @@ -129,7 +129,7 @@ plpgsql_dstring_append_char(PLpgSQL_dstring *ds, char c) * ---------- */ char * -plpgsql_dstring_get(PLpgSQL_dstring *ds) +plpgsql_dstring_get(PLpgSQL_dstring * ds) { return ds->value; } @@ -229,7 +229,7 @@ plpgsql_ns_additem(int itemtype, int itemno, const char *name) { ns->items_alloc *= 2; ns->items = repalloc(ns->items, - sizeof(PLpgSQL_nsitem *) * ns->items_alloc); + sizeof(PLpgSQL_nsitem *) * ns->items_alloc); } } @@ -310,8 +310,8 @@ plpgsql_ns_rename(char *oldname, char *newname) int i; /* - * Lookup name in the namestack; do the lookup in the current - * namespace only. + * Lookup name in the namestack; do the lookup in the current namespace + * only. */ for (ns = ns_current; ns != NULL; ns = ns->upper) { @@ -416,8 +416,8 @@ plpgsql_convert_ident(const char *s, char **output, int numidents) else ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("qualified identifier cannot be used here: %s", - sstart))); + errmsg("qualified identifier cannot be used here: %s", + sstart))); /* If not done, skip whitespace, dot, whitespace */ if (*s) @@ -443,7 +443,7 @@ plpgsql_convert_ident(const char *s, char **output, int numidents) * Statement type as a string, for use in error messages etc. */ const char * -plpgsql_stmt_typename(PLpgSQL_stmt *stmt) +plpgsql_stmt_typename(PLpgSQL_stmt * stmt) { switch (stmt->cmd_type) { @@ -499,28 +499,28 @@ plpgsql_stmt_typename(PLpgSQL_stmt *stmt) static int dump_indent; static void dump_ind(); -static void dump_stmt(PLpgSQL_stmt *stmt); -static void dump_block(PLpgSQL_stmt_block *block); -static void dump_assign(PLpgSQL_stmt_assign *stmt); -static void dump_if(PLpgSQL_stmt_if *stmt); -static void dump_loop(PLpgSQL_stmt_loop *stmt); -static void dump_while(PLpgSQL_stmt_while *stmt); -static void dump_fori(PLpgSQL_stmt_fori *stmt); -static void dump_fors(PLpgSQL_stmt_fors *stmt); -static void dump_select(PLpgSQL_stmt_select *stmt); -static void dump_exit(PLpgSQL_stmt_exit *stmt); -static void dump_return(PLpgSQL_stmt_return *stmt); -static void dump_return_next(PLpgSQL_stmt_return_next *stmt); -static void dump_raise(PLpgSQL_stmt_raise *stmt); -static void dump_execsql(PLpgSQL_stmt_execsql *stmt); -static void dump_dynexecute(PLpgSQL_stmt_dynexecute *stmt); -static void dump_dynfors(PLpgSQL_stmt_dynfors *stmt); -static void dump_getdiag(PLpgSQL_stmt_getdiag *stmt); -static void dump_open(PLpgSQL_stmt_open *stmt); -static void dump_fetch(PLpgSQL_stmt_fetch *stmt); -static void dump_close(PLpgSQL_stmt_close *stmt); -static void dump_perform(PLpgSQL_stmt_perform *stmt); -static void dump_expr(PLpgSQL_expr *expr); +static void dump_stmt(PLpgSQL_stmt * stmt); +static void dump_block(PLpgSQL_stmt_block * block); +static void dump_assign(PLpgSQL_stmt_assign * stmt); +static void dump_if(PLpgSQL_stmt_if * stmt); +static void dump_loop(PLpgSQL_stmt_loop * stmt); +static void dump_while(PLpgSQL_stmt_while * stmt); +static void dump_fori(PLpgSQL_stmt_fori * stmt); +static void dump_fors(PLpgSQL_stmt_fors * stmt); +static void dump_select(PLpgSQL_stmt_select * stmt); +static void dump_exit(PLpgSQL_stmt_exit * stmt); +static void dump_return(PLpgSQL_stmt_return * stmt); +static void dump_return_next(PLpgSQL_stmt_return_next * stmt); +static void dump_raise(PLpgSQL_stmt_raise * stmt); +static void dump_execsql(PLpgSQL_stmt_execsql * stmt); +static void dump_dynexecute(PLpgSQL_stmt_dynexecute * stmt); +static void dump_dynfors(PLpgSQL_stmt_dynfors * stmt); +static void dump_getdiag(PLpgSQL_stmt_getdiag * stmt); +static void dump_open(PLpgSQL_stmt_open * stmt); +static void dump_fetch(PLpgSQL_stmt_fetch * stmt); +static void dump_close(PLpgSQL_stmt_close * stmt); +static void dump_perform(PLpgSQL_stmt_perform * stmt); +static void dump_expr(PLpgSQL_expr * expr); static void @@ -533,7 +533,7 @@ dump_ind(void) } static void -dump_stmt(PLpgSQL_stmt *stmt) +dump_stmt(PLpgSQL_stmt * stmt) { printf("%3d:", stmt->lineno); switch (stmt->cmd_type) @@ -607,16 +607,16 @@ dump_stmt(PLpgSQL_stmt *stmt) static void dump_stmts(List *stmts) { - ListCell *s; + ListCell *s; dump_indent += 2; - foreach (s, stmts) + foreach(s, stmts) dump_stmt((PLpgSQL_stmt *) lfirst(s)); dump_indent -= 2; } static void -dump_block(PLpgSQL_stmt_block *block) +dump_block(PLpgSQL_stmt_block * block) { char *name; @@ -632,9 +632,9 @@ dump_block(PLpgSQL_stmt_block *block) if (block->exceptions) { - ListCell *e; + ListCell *e; - foreach (e, block->exceptions->exc_list) + foreach(e, block->exceptions->exc_list) { PLpgSQL_exception *exc = (PLpgSQL_exception *) lfirst(e); PLpgSQL_condition *cond; @@ -657,7 +657,7 @@ dump_block(PLpgSQL_stmt_block *block) } static void -dump_assign(PLpgSQL_stmt_assign *stmt) +dump_assign(PLpgSQL_stmt_assign * stmt) { dump_ind(); printf("ASSIGN var %d := ", stmt->varno); @@ -666,7 +666,7 @@ dump_assign(PLpgSQL_stmt_assign *stmt) } static void -dump_if(PLpgSQL_stmt_if *stmt) +dump_if(PLpgSQL_stmt_if * stmt) { dump_ind(); printf("IF "); @@ -687,7 +687,7 @@ dump_if(PLpgSQL_stmt_if *stmt) } static void -dump_loop(PLpgSQL_stmt_loop *stmt) +dump_loop(PLpgSQL_stmt_loop * stmt) { dump_ind(); printf("LOOP\n"); @@ -699,7 +699,7 @@ dump_loop(PLpgSQL_stmt_loop *stmt) } static void -dump_while(PLpgSQL_stmt_while *stmt) +dump_while(PLpgSQL_stmt_while * stmt) { dump_ind(); printf("WHILE "); @@ -713,7 +713,7 @@ dump_while(PLpgSQL_stmt_while *stmt) } static void -dump_fori(PLpgSQL_stmt_fori *stmt) +dump_fori(PLpgSQL_stmt_fori * stmt) { dump_ind(); printf("FORI %s %s\n", stmt->var->refname, (stmt->reverse) ? "REVERSE" : "NORMAL"); @@ -736,7 +736,7 @@ dump_fori(PLpgSQL_stmt_fori *stmt) } static void -dump_fors(PLpgSQL_stmt_fors *stmt) +dump_fors(PLpgSQL_stmt_fors * stmt) { dump_ind(); printf("FORS %s ", (stmt->rec != NULL) ? stmt->rec->refname : stmt->row->refname); @@ -750,7 +750,7 @@ dump_fors(PLpgSQL_stmt_fors *stmt) } static void -dump_select(PLpgSQL_stmt_select *stmt) +dump_select(PLpgSQL_stmt_select * stmt) { dump_ind(); printf("SELECT "); @@ -773,7 +773,7 @@ dump_select(PLpgSQL_stmt_select *stmt) } static void -dump_open(PLpgSQL_stmt_open *stmt) +dump_open(PLpgSQL_stmt_open * stmt) { dump_ind(); printf("OPEN curvar=%d\n", stmt->curvar); @@ -805,7 +805,7 @@ dump_open(PLpgSQL_stmt_open *stmt) } static void -dump_fetch(PLpgSQL_stmt_fetch *stmt) +dump_fetch(PLpgSQL_stmt_fetch * stmt) { dump_ind(); printf("FETCH curvar=%d\n", stmt->curvar); @@ -826,14 +826,14 @@ dump_fetch(PLpgSQL_stmt_fetch *stmt) } static void -dump_close(PLpgSQL_stmt_close *stmt) +dump_close(PLpgSQL_stmt_close * stmt) { dump_ind(); printf("CLOSE curvar=%d\n", stmt->curvar); } static void -dump_perform(PLpgSQL_stmt_perform *stmt) +dump_perform(PLpgSQL_stmt_perform * stmt) { dump_ind(); printf("PERFORM expr = "); @@ -842,7 +842,7 @@ dump_perform(PLpgSQL_stmt_perform *stmt) } static void -dump_exit(PLpgSQL_stmt_exit *stmt) +dump_exit(PLpgSQL_stmt_exit * stmt) { dump_ind(); printf("%s label='%s'", @@ -856,7 +856,7 @@ dump_exit(PLpgSQL_stmt_exit *stmt) } static void -dump_return(PLpgSQL_stmt_return *stmt) +dump_return(PLpgSQL_stmt_return * stmt) { dump_ind(); printf("RETURN "); @@ -870,7 +870,7 @@ dump_return(PLpgSQL_stmt_return *stmt) } static void -dump_return_next(PLpgSQL_stmt_return_next *stmt) +dump_return_next(PLpgSQL_stmt_return_next * stmt) { dump_ind(); printf("RETURN NEXT "); @@ -884,15 +884,15 @@ dump_return_next(PLpgSQL_stmt_return_next *stmt) } static void -dump_raise(PLpgSQL_stmt_raise *stmt) +dump_raise(PLpgSQL_stmt_raise * stmt) { - ListCell *lc; - int i = 0; + ListCell *lc; + int i = 0; dump_ind(); printf("RAISE '%s'\n", stmt->message); dump_indent += 2; - foreach (lc, stmt->params) + foreach(lc, stmt->params) { dump_ind(); printf(" parameter %d: ", i++); @@ -903,7 +903,7 @@ dump_raise(PLpgSQL_stmt_raise *stmt) } static void -dump_execsql(PLpgSQL_stmt_execsql *stmt) +dump_execsql(PLpgSQL_stmt_execsql * stmt) { dump_ind(); printf("EXECSQL "); @@ -912,7 +912,7 @@ dump_execsql(PLpgSQL_stmt_execsql *stmt) } static void -dump_dynexecute(PLpgSQL_stmt_dynexecute *stmt) +dump_dynexecute(PLpgSQL_stmt_dynexecute * stmt) { dump_ind(); printf("EXECUTE "); @@ -934,7 +934,7 @@ dump_dynexecute(PLpgSQL_stmt_dynexecute *stmt) } static void -dump_dynfors(PLpgSQL_stmt_dynfors *stmt) +dump_dynfors(PLpgSQL_stmt_dynfors * stmt) { dump_ind(); printf("FORS %s EXECUTE ", (stmt->rec != NULL) ? stmt->rec->refname : stmt->row->refname); @@ -948,13 +948,13 @@ dump_dynfors(PLpgSQL_stmt_dynfors *stmt) } static void -dump_getdiag(PLpgSQL_stmt_getdiag *stmt) +dump_getdiag(PLpgSQL_stmt_getdiag * stmt) { - ListCell *lc; + ListCell *lc; dump_ind(); printf("GET DIAGNOSTICS "); - foreach (lc, stmt->diag_items) + foreach(lc, stmt->diag_items) { PLpgSQL_diag_item *diag_item = (PLpgSQL_diag_item *) lfirst(lc); @@ -982,7 +982,7 @@ dump_getdiag(PLpgSQL_stmt_getdiag *stmt) } static void -dump_expr(PLpgSQL_expr *expr) +dump_expr(PLpgSQL_expr * expr) { int i; @@ -1002,7 +1002,7 @@ dump_expr(PLpgSQL_expr *expr) } void -plpgsql_dumptree(PLpgSQL_function *func) +plpgsql_dumptree(PLpgSQL_function * func) { int i; PLpgSQL_datum *d; diff --git a/src/pl/plpgsql/src/pl_handler.c b/src/pl/plpgsql/src/pl_handler.c index c20efe7739..69d128e869 100644 --- a/src/pl/plpgsql/src/pl_handler.c +++ b/src/pl/plpgsql/src/pl_handler.c @@ -3,7 +3,7 @@ * procedural language * * IDENTIFICATION - * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_handler.c,v 1.25 2005/03/29 00:17:23 tgl Exp $ + * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_handler.c,v 1.26 2005/10/15 02:49:50 momjian Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -47,7 +47,7 @@ extern DLLIMPORT bool check_function_bodies; -static bool plpgsql_firstcall = true; +static bool plpgsql_firstcall = true; static void plpgsql_init_all(void); @@ -118,7 +118,7 @@ plpgsql_call_handler(PG_FUNCTION_ARGS) */ if (CALLED_AS_TRIGGER(fcinfo)) retval = PointerGetDatum(plpgsql_exec_trigger(func, - (TriggerData *) fcinfo->context)); + (TriggerData *) fcinfo->context)); else retval = plpgsql_exec_function(func, fcinfo); @@ -198,7 +198,7 @@ plpgsql_validator(PG_FUNCTION_ARGS) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("plpgsql functions cannot take type %s", - format_type_be(proc->proargtypes.values[i])))); + format_type_be(proc->proargtypes.values[i])))); } } diff --git a/src/pl/plpgsql/src/plpgsql.h b/src/pl/plpgsql/src/plpgsql.h index 3615b3bf06..38b1aa1329 100644 --- a/src/pl/plpgsql/src/plpgsql.h +++ b/src/pl/plpgsql/src/plpgsql.h @@ -3,7 +3,7 @@ * procedural language * * IDENTIFICATION - * $PostgreSQL: pgsql/src/pl/plpgsql/src/plpgsql.h,v 1.64 2005/06/22 01:35:02 neilc Exp $ + * $PostgreSQL: pgsql/src/pl/plpgsql/src/plpgsql.h,v 1.65 2005/10/15 02:49:50 momjian Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -150,7 +150,7 @@ typedef struct int alloc; int used; /* Including NUL terminator */ char *value; -} PLpgSQL_dstring; +} PLpgSQL_dstring; typedef struct @@ -164,7 +164,7 @@ typedef struct Oid typioparam; FmgrInfo typinput; /* lookup info for typinput function */ int32 atttypmod; /* typmod (taken from someplace else) */ -} PLpgSQL_type; +} PLpgSQL_type; /* @@ -176,7 +176,7 @@ typedef struct { /* Generic datum array item */ int dtype; int dno; -} PLpgSQL_datum; +} PLpgSQL_datum; /* * The variants PLpgSQL_var, PLpgSQL_row, and PLpgSQL_rec share these @@ -188,7 +188,7 @@ typedef struct int dno; char *refname; int lineno; -} PLpgSQL_variable; +} PLpgSQL_variable; typedef struct PLpgSQL_expr { /* SQL Query to plan and execute */ @@ -206,7 +206,7 @@ typedef struct PLpgSQL_expr /* params to pass to expr */ int nparams; int params[1]; /* VARIABLE SIZE ARRAY ... must be last */ -} PLpgSQL_expr; +} PLpgSQL_expr; typedef struct @@ -226,7 +226,7 @@ typedef struct Datum value; bool isnull; bool freeval; -} PLpgSQL_var; +} PLpgSQL_var; typedef struct @@ -248,7 +248,7 @@ typedef struct int nfields; char **fieldnames; int *varnos; -} PLpgSQL_row; +} PLpgSQL_row; typedef struct @@ -262,7 +262,7 @@ typedef struct TupleDesc tupdesc; bool freetup; bool freetupdesc; -} PLpgSQL_rec; +} PLpgSQL_rec; typedef struct @@ -271,7 +271,7 @@ typedef struct int rfno; char *fieldname; int recparentno; /* dno of parent record */ -} PLpgSQL_recfield; +} PLpgSQL_recfield; typedef struct @@ -280,7 +280,7 @@ typedef struct int dno; PLpgSQL_expr *subscript; int arrayparentno; /* dno of parent array variable */ -} PLpgSQL_arrayelem; +} PLpgSQL_arrayelem; typedef struct @@ -288,7 +288,7 @@ typedef struct int dtype; int dno; PLpgSQL_expr *argnum; -} PLpgSQL_trigarg; +} PLpgSQL_trigarg; typedef struct @@ -296,7 +296,7 @@ typedef struct int itemtype; int itemno; char name[1]; -} PLpgSQL_nsitem; +} PLpgSQL_nsitem; /* XXX: consider adapting this to use List */ @@ -306,14 +306,14 @@ typedef struct PLpgSQL_ns int items_used; PLpgSQL_nsitem **items; struct PLpgSQL_ns *upper; -} PLpgSQL_ns; +} PLpgSQL_ns; typedef struct { /* Generic execution node */ int cmd_type; int lineno; -} PLpgSQL_stmt; +} PLpgSQL_stmt; typedef struct PLpgSQL_condition @@ -321,21 +321,21 @@ typedef struct PLpgSQL_condition int sqlerrstate; /* SQLSTATE code */ char *condname; /* condition name (for debugging) */ struct PLpgSQL_condition *next; -} PLpgSQL_condition; +} PLpgSQL_condition; typedef struct { int sqlstate_varno; int sqlerrm_varno; List *exc_list; /* List of WHEN clauses */ -} PLpgSQL_exception_block; +} PLpgSQL_exception_block; typedef struct { /* One EXCEPTION ... WHEN clause */ int lineno; PLpgSQL_condition *conditions; List *action; /* List of statements */ -} PLpgSQL_exception; +} PLpgSQL_exception; typedef struct @@ -347,7 +347,7 @@ typedef struct int n_initvars; int *initvarnos; PLpgSQL_exception_block *exceptions; -} PLpgSQL_stmt_block; +} PLpgSQL_stmt_block; typedef struct @@ -356,27 +356,27 @@ typedef struct int lineno; int varno; PLpgSQL_expr *expr; -} PLpgSQL_stmt_assign; +} PLpgSQL_stmt_assign; typedef struct { /* PERFORM statement */ int cmd_type; int lineno; PLpgSQL_expr *expr; -} PLpgSQL_stmt_perform; +} PLpgSQL_stmt_perform; typedef struct { /* Get Diagnostics item */ int kind; /* id for diagnostic value desired */ int target; /* where to assign it */ -} PLpgSQL_diag_item; +} PLpgSQL_diag_item; typedef struct { /* Get Diagnostics statement */ int cmd_type; int lineno; List *diag_items; /* List of PLpgSQL_diag_item */ -} PLpgSQL_stmt_getdiag; +} PLpgSQL_stmt_getdiag; typedef struct @@ -386,7 +386,7 @@ typedef struct PLpgSQL_expr *cond; List *true_body; /* List of statements */ List *false_body; /* List of statements */ -} PLpgSQL_stmt_if; +} PLpgSQL_stmt_if; typedef struct @@ -395,7 +395,7 @@ typedef struct int lineno; char *label; List *body; /* List of statements */ -} PLpgSQL_stmt_loop; +} PLpgSQL_stmt_loop; typedef struct @@ -405,7 +405,7 @@ typedef struct char *label; PLpgSQL_expr *cond; List *body; /* List of statements */ -} PLpgSQL_stmt_while; +} PLpgSQL_stmt_while; typedef struct @@ -418,7 +418,7 @@ typedef struct PLpgSQL_expr *upper; int reverse; List *body; /* List of statements */ -} PLpgSQL_stmt_fori; +} PLpgSQL_stmt_fori; typedef struct @@ -430,7 +430,7 @@ typedef struct PLpgSQL_row *row; PLpgSQL_expr *query; List *body; /* List of statements */ -} PLpgSQL_stmt_fors; +} PLpgSQL_stmt_fors; typedef struct @@ -442,7 +442,7 @@ typedef struct PLpgSQL_row *row; PLpgSQL_expr *query; List *body; /* List of statements */ -} PLpgSQL_stmt_dynfors; +} PLpgSQL_stmt_dynfors; typedef struct @@ -452,7 +452,7 @@ typedef struct PLpgSQL_rec *rec; PLpgSQL_row *row; PLpgSQL_expr *query; -} PLpgSQL_stmt_select; +} PLpgSQL_stmt_select; typedef struct @@ -464,7 +464,7 @@ typedef struct PLpgSQL_expr *argquery; PLpgSQL_expr *query; PLpgSQL_expr *dynquery; -} PLpgSQL_stmt_open; +} PLpgSQL_stmt_open; typedef struct @@ -474,7 +474,7 @@ typedef struct PLpgSQL_rec *rec; PLpgSQL_row *row; int curvar; -} PLpgSQL_stmt_fetch; +} PLpgSQL_stmt_fetch; typedef struct @@ -482,7 +482,7 @@ typedef struct int cmd_type; int lineno; int curvar; -} PLpgSQL_stmt_close; +} PLpgSQL_stmt_close; typedef struct @@ -492,7 +492,7 @@ typedef struct bool is_exit; /* Is this an exit or a continue? */ char *label; PLpgSQL_expr *cond; -} PLpgSQL_stmt_exit; +} PLpgSQL_stmt_exit; typedef struct @@ -501,7 +501,7 @@ typedef struct int lineno; PLpgSQL_expr *expr; int retvarno; -} PLpgSQL_stmt_return; +} PLpgSQL_stmt_return; typedef struct { /* RETURN NEXT statement */ @@ -509,7 +509,7 @@ typedef struct int lineno; PLpgSQL_expr *expr; int retvarno; -} PLpgSQL_stmt_return_next; +} PLpgSQL_stmt_return_next; typedef struct { /* RAISE statement */ @@ -518,7 +518,7 @@ typedef struct int elog_level; char *message; List *params; /* list of expressions */ -} PLpgSQL_stmt_raise; +} PLpgSQL_stmt_raise; typedef struct @@ -526,17 +526,17 @@ typedef struct int cmd_type; int lineno; PLpgSQL_expr *sqlstmt; -} PLpgSQL_stmt_execsql; +} PLpgSQL_stmt_execsql; typedef struct { /* Dynamic SQL string to execute */ int cmd_type; int lineno; - PLpgSQL_rec *rec; /* INTO record or row variable */ + PLpgSQL_rec *rec; /* INTO record or row variable */ PLpgSQL_row *row; PLpgSQL_expr *query; -} PLpgSQL_stmt_dynexecute; +} PLpgSQL_stmt_dynexecute; typedef struct PLpgSQL_func_hashkey @@ -544,20 +544,19 @@ typedef struct PLpgSQL_func_hashkey Oid funcOid; /* - * For a trigger function, the OID of the relation triggered on is - * part of the hashkey --- we want to compile the trigger separately - * for each relation it is used with, in case the rowtype is - * different. Zero if not called as a trigger. + * For a trigger function, the OID of the relation triggered on is part of + * the hashkey --- we want to compile the trigger separately for each + * relation it is used with, in case the rowtype is different. Zero if + * not called as a trigger. */ Oid trigrelOid; /* - * We include actual argument types in the hash key to support - * polymorphic PLpgSQL functions. Be careful that extra positions are - * zeroed! + * We include actual argument types in the hash key to support polymorphic + * PLpgSQL functions. Be careful that extra positions are zeroed! */ Oid argtypes[FUNC_MAX_ARGS]; -} PLpgSQL_func_hashkey; +} PLpgSQL_func_hashkey; typedef struct PLpgSQL_function @@ -596,7 +595,7 @@ typedef struct PLpgSQL_function int ndatums; PLpgSQL_datum **datums; PLpgSQL_stmt_block *action; -} PLpgSQL_function; +} PLpgSQL_function; typedef struct @@ -612,8 +611,8 @@ typedef struct bool readonly_func; TupleDesc rettupdesc; - char *exitlabel; /* the "target" label of the current - * EXIT or CONTINUE stmt, if any */ + char *exitlabel; /* the "target" label of the current EXIT or + * CONTINUE stmt, if any */ Tuplestorestate *tuple_store; /* SRFs accumulate results here */ MemoryContext tuple_store_cxt; @@ -636,15 +635,15 @@ typedef struct PLpgSQL_function *err_func; /* current func */ PLpgSQL_stmt *err_stmt; /* current stmt */ const char *err_text; /* additional state info */ -} PLpgSQL_execstate; +} PLpgSQL_execstate; /********************************************************************** * Global variable declarations **********************************************************************/ -extern bool plpgsql_DumpExecTree; -extern bool plpgsql_SpaceScanned; +extern bool plpgsql_DumpExecTree; +extern bool plpgsql_SpaceScanned; extern int plpgsql_nDatums; extern PLpgSQL_datum **plpgsql_Datums; @@ -657,7 +656,7 @@ extern char *plpgsql_base_yytext; #define plpgsql_yytext plpgsql_base_yytext extern PLpgSQL_function *plpgsql_curr_compile; -extern bool plpgsql_check_syntax; +extern bool plpgsql_check_syntax; extern MemoryContext compile_tmp_cxt; /********************************************************************** @@ -681,10 +680,10 @@ extern int plpgsql_parse_dblwordrowtype(char *word); extern PLpgSQL_type *plpgsql_parse_datatype(const char *string); extern PLpgSQL_type *plpgsql_build_datatype(Oid typeOid, int32 typmod); extern PLpgSQL_variable *plpgsql_build_variable(const char *refname, int lineno, - PLpgSQL_type *dtype, + PLpgSQL_type * dtype, bool add2namespace); extern PLpgSQL_condition *plpgsql_parse_err_condition(char *condname); -extern void plpgsql_adddatum(PLpgSQL_datum *new); +extern void plpgsql_adddatum(PLpgSQL_datum * new); extern int plpgsql_add_initdatums(int **varnos); extern void plpgsql_HashTableInit(void); extern void plpgsql_compile_error_callback(void *arg); @@ -701,9 +700,9 @@ extern Datum plpgsql_validator(PG_FUNCTION_ARGS); * Functions in pl_exec.c * ---------- */ -extern Datum plpgsql_exec_function(PLpgSQL_function *func, +extern Datum plpgsql_exec_function(PLpgSQL_function * func, FunctionCallInfo fcinfo); -extern HeapTuple plpgsql_exec_trigger(PLpgSQL_function *func, +extern HeapTuple plpgsql_exec_trigger(PLpgSQL_function * func, TriggerData *trigdata); extern void plpgsql_xact_cb(XactEvent event, void *arg); @@ -711,11 +710,11 @@ extern void plpgsql_xact_cb(XactEvent event, void *arg); * Functions for the dynamic string handling in pl_funcs.c * ---------- */ -extern void plpgsql_dstring_init(PLpgSQL_dstring *ds); -extern void plpgsql_dstring_free(PLpgSQL_dstring *ds); -extern void plpgsql_dstring_append(PLpgSQL_dstring *ds, const char *str); -extern void plpgsql_dstring_append_char(PLpgSQL_dstring *ds, char c); -extern char *plpgsql_dstring_get(PLpgSQL_dstring *ds); +extern void plpgsql_dstring_init(PLpgSQL_dstring * ds); +extern void plpgsql_dstring_free(PLpgSQL_dstring * ds); +extern void plpgsql_dstring_append(PLpgSQL_dstring * ds, const char *str); +extern void plpgsql_dstring_append_char(PLpgSQL_dstring * ds, char c); +extern char *plpgsql_dstring_get(PLpgSQL_dstring * ds); /* ---------- * Functions for the namestack handling in pl_funcs.c @@ -734,8 +733,8 @@ extern void plpgsql_ns_rename(char *oldname, char *newname); * ---------- */ extern void plpgsql_convert_ident(const char *s, char **output, int numidents); -extern const char *plpgsql_stmt_typename(PLpgSQL_stmt *stmt); -extern void plpgsql_dumptree(PLpgSQL_function *func); +extern const char *plpgsql_stmt_typename(PLpgSQL_stmt * stmt); +extern void plpgsql_dumptree(PLpgSQL_function * func); /* ---------- * Externs in gram.y and scan.l diff --git a/src/pl/plpython/plpython.c b/src/pl/plpython/plpython.c index b1d47c7782..eff1d695cd 100644 --- a/src/pl/plpython/plpython.c +++ b/src/pl/plpython/plpython.c @@ -29,7 +29,7 @@ * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. * * IDENTIFICATION - * $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.65 2005/07/10 04:56:55 momjian Exp $ + * $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.66 2005/10/15 02:49:50 momjian Exp $ * ********************************************************************* */ @@ -118,8 +118,8 @@ typedef struct PLyTypeInfo int is_rowtype; /* - * is_rowtype can be: -1 not known yet (initial state) 0 scalar - * datatype 1 rowtype 2 rowtype, but I/O functions not set up yet + * is_rowtype can be: -1 not known yet (initial state) 0 scalar datatype + * 1 rowtype 2 rowtype, but I/O functions not set up yet */ } PLyTypeInfo; @@ -133,8 +133,8 @@ typedef struct PLyProcedure TransactionId fn_xmin; CommandId fn_cmin; bool fn_readonly; - PLyTypeInfo result; /* also used to store info for trigger - * tuple type */ + PLyTypeInfo result; /* also used to store info for trigger tuple + * type */ PLyTypeInfo args[FUNC_MAX_ARGS]; int nargs; PyObject *code; /* compiled procedure code */ @@ -340,7 +340,7 @@ plpython_call_handler(PG_FUNCTION_ARGS) HeapTuple trv; proc = PLy_procedure_get(fcinfo, - RelationGetRelid(tdata->tg_relation)); + RelationGetRelid(tdata->tg_relation)); PLy_curr_procedure = proc; trv = PLy_trigger_handler(fcinfo, proc); retval = PointerGetDatum(trv); @@ -430,8 +430,8 @@ PLy_trigger_handler(FunctionCallInfo fcinfo, PLyProcedure * proc) { /* * hmmm, perhaps they only read the pltcl page, not a - * surprising thing since i've written no documentation, - * so accept a belated OK + * surprising thing since i've written no documentation, so + * accept a belated OK */ elog(ERROR, "expected return to be \"SKIP\" or \"MODIFY\""); } @@ -523,8 +523,8 @@ PLy_modify_tuple(PLyProcedure * proc, PyObject * pltd, TriggerData *tdata, modvalues[i] = FunctionCall3(&proc->result.out.r.atts[atti].typfunc, CStringGetDatum(src), - ObjectIdGetDatum(proc->result.out.r.atts[atti].typioparam), - Int32GetDatum(tupdesc->attrs[atti]->atttypmod)); + ObjectIdGetDatum(proc->result.out.r.atts[atti].typioparam), + Int32GetDatum(tupdesc->attrs[atti]->atttypmod)); modnulls[i] = ' '; Py_DECREF(plstr); @@ -600,7 +600,7 @@ PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure * proc, HeapTuple * Py_DECREF(pltname); stroid = DatumGetCString(DirectFunctionCall1(oidout, - ObjectIdGetDatum(tdata->tg_relation->rd_id))); + ObjectIdGetDatum(tdata->tg_relation->rd_id))); pltrelid = PyString_FromString(stroid); PyDict_SetItemString(pltdata, "relid", pltrelid); Py_DECREF(pltrelid); @@ -756,10 +756,10 @@ PLy_function_handler(FunctionCallInfo fcinfo, PLyProcedure * proc) Assert(!PLy_error_in_progress); /* - * Disconnect from SPI manager and then create the return values - * datum (if the input function does a palloc for it this must not - * be allocated in the SPI memory context because SPI_finish would - * free it). + * Disconnect from SPI manager and then create the return values datum + * (if the input function does a palloc for it this must not be + * allocated in the SPI memory context because SPI_finish would free + * it). */ if (SPI_finish() != SPI_OK_FINISH) elog(ERROR, "SPI_finish failed"); @@ -781,7 +781,7 @@ PLy_function_handler(FunctionCallInfo fcinfo, PLyProcedure * proc) plrv_sc = PyString_AsString(plrv_so); rv = FunctionCall3(&proc->result.out.d.typfunc, PointerGetDatum(plrv_sc), - ObjectIdGetDatum(proc->result.out.d.typioparam), + ObjectIdGetDatum(proc->result.out.d.typioparam), Int32GetDatum(-1)); } @@ -813,8 +813,8 @@ PLy_procedure_call(PLyProcedure * proc, char *kargs, PyObject * vargs) proc->globals, proc->globals); /* - * If there was an error in a PG callback, propagate that no matter - * what Python claims about its success. + * If there was an error in a PG callback, propagate that no matter what + * Python claims about its success. */ if (PLy_error_in_progress) { @@ -885,7 +885,7 @@ PLy_function_build_args(FunctionCallInfo fcinfo, PLyProcedure * proc) dt = FunctionCall3(&(proc->args[i].in.d.typfunc), fcinfo->arg[i], - ObjectIdGetDatum(proc->args[i].in.d.typioparam), + ObjectIdGetDatum(proc->args[i].in.d.typioparam), Int32GetDatum(-1)); ct = DatumGetCString(dt); arg = (proc->args[i].in.d.func) (ct); @@ -1025,8 +1025,8 @@ PLy_procedure_create(FunctionCallInfo fcinfo, Oid tgreloid, PG_TRY(); { /* - * get information required for output conversion of the return - * value, but only if this isn't a trigger. + * get information required for output conversion of the return value, + * but only if this isn't a trigger. */ if (!CALLED_AS_TRIGGER(fcinfo)) { @@ -1034,7 +1034,7 @@ PLy_procedure_create(FunctionCallInfo fcinfo, Oid tgreloid, Form_pg_type rvTypeStruct; rvTypeTup = SearchSysCache(TYPEOID, - ObjectIdGetDatum(procStruct->prorettype), + ObjectIdGetDatum(procStruct->prorettype), 0, 0, 0); if (!HeapTupleIsValid(rvTypeTup)) elog(ERROR, "cache lookup failed for type %u", @@ -1051,14 +1051,14 @@ PLy_procedure_create(FunctionCallInfo fcinfo, Oid tgreloid, else ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("plpython functions cannot return type %s", - format_type_be(procStruct->prorettype)))); + errmsg("plpython functions cannot return type %s", + format_type_be(procStruct->prorettype)))); } if (rvTypeStruct->typtype == 'c') ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("plpython functions cannot return tuples yet"))); + errmsg("plpython functions cannot return tuples yet"))); else PLy_output_datum_func(&proc->result, rvTypeTup); @@ -1077,8 +1077,8 @@ PLy_procedure_create(FunctionCallInfo fcinfo, Oid tgreloid, } /* - * now get information required for input conversion of the - * procedures arguments. + * now get information required for input conversion of the procedures + * arguments. */ proc->nargs = fcinfo->nargs; for (i = 0; i < fcinfo->nargs; i++) @@ -1087,7 +1087,7 @@ PLy_procedure_create(FunctionCallInfo fcinfo, Oid tgreloid, Form_pg_type argTypeStruct; argTypeTup = SearchSysCache(TYPEOID, - ObjectIdGetDatum(procStruct->proargtypes.values[i]), + ObjectIdGetDatum(procStruct->proargtypes.values[i]), 0, 0, 0); if (!HeapTupleIsValid(argTypeTup)) elog(ERROR, "cache lookup failed for type %u", @@ -1099,15 +1099,14 @@ PLy_procedure_create(FunctionCallInfo fcinfo, Oid tgreloid, ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("plpython functions cannot take type %s", - format_type_be(procStruct->proargtypes.values[i])))); + format_type_be(procStruct->proargtypes.values[i])))); if (argTypeStruct->typtype != 'c') PLy_input_datum_func(&(proc->args[i]), procStruct->proargtypes.values[i], argTypeTup); else - proc->args[i].is_rowtype = 2; /* still need to set I/O - * funcs */ + proc->args[i].is_rowtype = 2; /* still need to set I/O funcs */ ReleaseSysCache(argTypeTup); } @@ -1152,8 +1151,8 @@ PLy_procedure_compile(PLyProcedure * proc, const char *src) proc->globals = PyDict_Copy(PLy_interp_globals); /* - * SD is private preserved data between calls GD is global data shared - * by all functions + * SD is private preserved data between calls GD is global data shared by + * all functions */ proc->statics = PyDict_New(); PyDict_SetItemString(proc->globals, "SD", proc->statics); @@ -1279,7 +1278,7 @@ PLy_input_tuple_funcs(PLyTypeInfo * arg, TupleDesc desc) continue; typeTup = SearchSysCache(TYPEOID, - ObjectIdGetDatum(desc->attrs[i]->atttypid), + ObjectIdGetDatum(desc->attrs[i]->atttypid), 0, 0, 0); if (!HeapTupleIsValid(typeTup)) elog(ERROR, "cache lookup failed for type %u", @@ -1313,7 +1312,7 @@ PLy_output_tuple_funcs(PLyTypeInfo * arg, TupleDesc desc) continue; typeTup = SearchSysCache(TYPEOID, - ObjectIdGetDatum(desc->attrs[i]->atttypid), + ObjectIdGetDatum(desc->attrs[i]->atttypid), 0, 0, 0); if (!HeapTupleIsValid(typeTup)) elog(ERROR, "cache lookup failed for type %u", @@ -1492,8 +1491,8 @@ PLyDict_FromTuple(PLyTypeInfo * info, HeapTuple tuple, TupleDesc desc) { vdat = FunctionCall3(&info->in.r.atts[i].typfunc, vattr, - ObjectIdGetDatum(info->in.r.atts[i].typioparam), - Int32GetDatum(desc->attrs[i]->atttypmod)); + ObjectIdGetDatum(info->in.r.atts[i].typioparam), + Int32GetDatum(desc->attrs[i]->atttypmod)); vsrc = DatumGetCString(vdat); /* @@ -1864,7 +1863,7 @@ PLy_spi_prepare(PyObject * self, PyObject * args) if ((list) && (!PySequence_Check(list))) { PyErr_SetString(PLy_exc_spi_error, - "Second argument in plpy.prepare() must be a sequence"); + "Second argument in plpy.prepare() must be a sequence"); return NULL; } @@ -1889,8 +1888,8 @@ PLy_spi_prepare(PyObject * self, PyObject * args) /* * the other loop might throw an exception, if PLyTypeInfo - * member isn't properly initialized the Py_DECREF(plan) - * will go boom + * member isn't properly initialized the Py_DECREF(plan) will + * go boom */ for (i = 0; i < nargs; i++) { @@ -1910,8 +1909,7 @@ PLy_spi_prepare(PyObject * self, PyObject * args) sptr = PyString_AsString(optr); /* - * XXX should extend this to allow qualified type - * names + * XXX should extend this to allow qualified type names */ typeTup = typenameType(makeTypeName(sptr)); Py_DECREF(optr); @@ -2023,6 +2021,7 @@ PLy_spi_execute_plan(PyObject * ob, PyObject * list, long limit) char *sv; PyObject *so = PyObject_Str(list); + if (!so) PLy_elog(ERROR, "function \"%s\" could not execute plan", PLy_procedure_name(PLy_curr_procedure)); @@ -2061,7 +2060,7 @@ PLy_spi_execute_plan(PyObject * ob, PyObject * list, long limit) plan->values[i] = FunctionCall3(&(plan->args[i].out.d.typfunc), CStringGetDatum(sv), - ObjectIdGetDatum(plan->args[i].out.d.typioparam), + ObjectIdGetDatum(plan->args[i].out.d.typioparam), Int32GetDatum(-1)); Py_DECREF(so); @@ -2210,7 +2209,7 @@ PLy_spi_execute_fetch_result(SPITupleTable *tuptable, int rows, int status) for (i = 0; i < rows; i++) { PyObject *row = PLyDict_FromTuple(&args, tuptable->vals[i], - tuptable->tupdesc); + tuptable->tupdesc); PyList_SetItem(result->rows, i, row); } @@ -2226,7 +2225,7 @@ PLy_spi_execute_fetch_result(SPITupleTable *tuptable, int rows, int status) FlushErrorState(); if (!PyErr_Occurred()) PyErr_SetString(PLy_exc_error, - "Unknown error in PLy_spi_execute_fetch_result"); + "Unknown error in PLy_spi_execute_fetch_result"); Py_DECREF(result); PLy_typeinfo_dealloc(&args); return NULL; @@ -2428,8 +2427,7 @@ PLy_output(volatile int level, PyObject * self, PyObject * args) Py_XDECREF(so); /* - * return a legal object so the interpreter will continue on its merry - * way + * return a legal object so the interpreter will continue on its merry way */ Py_INCREF(Py_None); return Py_None; @@ -2541,10 +2539,10 @@ PLy_traceback(int *xlevel) vstr = "Unknown"; /* - * I'm not sure what to do if eob is NULL here -- we can't call - * PLy_elog because that function calls us, so we could end up - * with infinite recursion. I'm not even sure if eob could be - * NULL here -- would an Assert() be more appropriate? + * I'm not sure what to do if eob is NULL here -- we can't call PLy_elog + * because that function calls us, so we could end up with infinite + * recursion. I'm not even sure if eob could be NULL here -- would an + * Assert() be more appropriate? */ estr = eob ? PyString_AsString(eob) : "Unknown Exception"; xstr = PLy_printf("%s: %s", estr, vstr); diff --git a/src/pl/tcl/pltcl.c b/src/pl/tcl/pltcl.c index 98cc0cf832..fe4e9f030e 100644 --- a/src/pl/tcl/pltcl.c +++ b/src/pl/tcl/pltcl.c @@ -31,7 +31,7 @@ * ENHANCEMENTS, OR MODIFICATIONS. * * IDENTIFICATION - * $PostgreSQL: pgsql/src/pl/tcl/pltcl.c,v 1.97 2005/05/06 17:24:55 tgl Exp $ + * $PostgreSQL: pgsql/src/pl/tcl/pltcl.c,v 1.98 2005/10/15 02:49:50 momjian Exp $ * **********************************************************************/ @@ -88,14 +88,12 @@ utf_e2u(unsigned char *src) pfree(_pltcl_utf_dst); } while (0) #define UTF_U2E(x) (_pltcl_utf_dst=utf_u2e(_pltcl_utf_src=(x))) #define UTF_E2U(x) (_pltcl_utf_dst=utf_e2u(_pltcl_utf_src=(x))) - #else /* !PLTCL_UTF */ #define UTF_BEGIN #define UTF_END #define UTF_U2E(x) (x) #define UTF_E2U(x) (x) - #endif /* PLTCL_UTF */ @@ -114,7 +112,7 @@ typedef struct pltcl_proc_desc int nargs; FmgrInfo arg_out_func[FUNC_MAX_ARGS]; bool arg_is_rowtype[FUNC_MAX_ARGS]; -} pltcl_proc_desc; +} pltcl_proc_desc; /********************************************************************** @@ -128,7 +126,7 @@ typedef struct pltcl_query_desc Oid *argtypes; FmgrInfo *arginfuncs; Oid *argtypioparams; -} pltcl_query_desc; +} pltcl_query_desc; /********************************************************************** @@ -151,9 +149,9 @@ static pltcl_proc_desc *pltcl_current_prodesc = NULL; * Forward declarations **********************************************************************/ static void pltcl_init_all(void); -static void pltcl_init_interp(Tcl_Interp *interp); +static void pltcl_init_interp(Tcl_Interp * interp); -static void pltcl_init_load_unknown(Tcl_Interp *interp); +static void pltcl_init_load_unknown(Tcl_Interp * interp); Datum pltcl_call_handler(PG_FUNCTION_ARGS); Datum pltclu_call_handler(PG_FUNCTION_ARGS); @@ -165,34 +163,34 @@ static HeapTuple pltcl_trigger_handler(PG_FUNCTION_ARGS); static pltcl_proc_desc *compile_pltcl_function(Oid fn_oid, Oid tgreloid); -static int pltcl_elog(ClientData cdata, Tcl_Interp *interp, +static int pltcl_elog(ClientData cdata, Tcl_Interp * interp, int argc, CONST84 char *argv[]); -static int pltcl_quote(ClientData cdata, Tcl_Interp *interp, +static int pltcl_quote(ClientData cdata, Tcl_Interp * interp, int argc, CONST84 char *argv[]); -static int pltcl_argisnull(ClientData cdata, Tcl_Interp *interp, +static int pltcl_argisnull(ClientData cdata, Tcl_Interp * interp, int argc, CONST84 char *argv[]); -static int pltcl_returnnull(ClientData cdata, Tcl_Interp *interp, +static int pltcl_returnnull(ClientData cdata, Tcl_Interp * interp, int argc, CONST84 char *argv[]); -static int pltcl_SPI_execute(ClientData cdata, Tcl_Interp *interp, - int argc, CONST84 char *argv[]); -static int pltcl_process_SPI_result(Tcl_Interp *interp, - CONST84 char *arrayname, - CONST84 char *loop_body, - int spi_rc, - SPITupleTable *tuptable, - int ntuples); -static int pltcl_SPI_prepare(ClientData cdata, Tcl_Interp *interp, +static int pltcl_SPI_execute(ClientData cdata, Tcl_Interp * interp, int argc, CONST84 char *argv[]); -static int pltcl_SPI_execute_plan(ClientData cdata, Tcl_Interp *interp, - int argc, CONST84 char *argv[]); -static int pltcl_SPI_lastoid(ClientData cdata, Tcl_Interp *interp, +static int pltcl_process_SPI_result(Tcl_Interp * interp, + CONST84 char *arrayname, + CONST84 char *loop_body, + int spi_rc, + SPITupleTable *tuptable, + int ntuples); +static int pltcl_SPI_prepare(ClientData cdata, Tcl_Interp * interp, + int argc, CONST84 char *argv[]); +static int pltcl_SPI_execute_plan(ClientData cdata, Tcl_Interp * interp, + int argc, CONST84 char *argv[]); +static int pltcl_SPI_lastoid(ClientData cdata, Tcl_Interp * interp, int argc, CONST84 char *argv[]); -static void pltcl_set_tuple_values(Tcl_Interp *interp, CONST84 char *arrayname, +static void pltcl_set_tuple_values(Tcl_Interp * interp, CONST84 char *arrayname, int tupno, HeapTuple tuple, TupleDesc tupdesc); static void pltcl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc, - Tcl_DString *retval); + Tcl_DString * retval); /* @@ -298,7 +296,7 @@ pltcl_init_all(void) * pltcl_init_interp() - initialize a Tcl interpreter **********************************************************************/ static void -pltcl_init_interp(Tcl_Interp *interp) +pltcl_init_interp(Tcl_Interp * interp) { /************************************************************ * Install the commands for SPI support in the interpreter @@ -328,7 +326,7 @@ pltcl_init_interp(Tcl_Interp *interp) * table pltcl_modules (if it exists) **********************************************************************/ static void -pltcl_init_load_unknown(Tcl_Interp *interp) +pltcl_init_load_unknown(Tcl_Interp * interp) { int spi_rc; int tcl_rc; @@ -429,8 +427,8 @@ pltcl_call_handler(PG_FUNCTION_ARGS) PG_TRY(); { /* - * Determine if called as function or trigger and - * call appropriate subhandler + * Determine if called as function or trigger and call appropriate + * subhandler */ if (CALLED_AS_TRIGGER(fcinfo)) { @@ -615,7 +613,7 @@ pltcl_func_handler(PG_FUNCTION_ARGS) UTF_BEGIN; retval = FunctionCall3(&prodesc->result_in_func, PointerGetDatum(UTF_U2E(interp->result)), - ObjectIdGetDatum(prodesc->result_typioparam), + ObjectIdGetDatum(prodesc->result_typioparam), Int32GetDatum(-1)); UTF_END; } @@ -653,7 +651,7 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS) /* Find or compile the function */ prodesc = compile_pltcl_function(fcinfo->flinfo->fn_oid, - RelationGetRelid(trigdata->tg_relation)); + RelationGetRelid(trigdata->tg_relation)); pltcl_current_prodesc = prodesc; @@ -681,7 +679,7 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS) /* The oid of the trigger relation for argument TG_relid */ stroid = DatumGetCString(DirectFunctionCall1(oidout, - ObjectIdGetDatum(trigdata->tg_relation->rd_id))); + ObjectIdGetDatum(trigdata->tg_relation->rd_id))); Tcl_DStringAppendElement(&tcl_cmd, stroid); pfree(stroid); @@ -693,7 +691,7 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS) Tcl_DStringAppendElement(&tcl_trigtup, ""); else Tcl_DStringAppendElement(&tcl_trigtup, - NameStr(tupdesc->attrs[i]->attname)); + NameStr(tupdesc->attrs[i]->attname)); } Tcl_DStringAppendElement(&tcl_cmd, Tcl_DStringValue(&tcl_trigtup)); Tcl_DStringFree(&tcl_trigtup); @@ -717,8 +715,8 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS) tupdesc, &tcl_trigtup); /* - * Now the command part of the event for TG_op and data for - * NEW and OLD + * Now the command part of the event for TG_op and data for NEW + * and OLD */ if (TRIGGER_FIRED_BY_INSERT(trigdata->tg_event)) { @@ -887,7 +885,7 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS) * for the input function ************************************************************/ typeTup = SearchSysCache(TYPEOID, - ObjectIdGetDatum(tupdesc->attrs[attnum - 1]->atttypid), + ObjectIdGetDatum(tupdesc->attrs[attnum - 1]->atttypid), 0, 0, 0); if (!HeapTupleIsValid(typeTup)) elog(ERROR, "cache lookup failed for type %u", @@ -906,7 +904,7 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS) FunctionCall3(&finfo, CStringGetDatum(UTF_U2E(ret_value)), ObjectIdGetDatum(typioparam), - Int32GetDatum(tupdesc->attrs[attnum - 1]->atttypmod)); + Int32GetDatum(tupdesc->attrs[attnum - 1]->atttypmod)); UTF_END; } @@ -988,7 +986,7 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid) prodesc = (pltcl_proc_desc *) Tcl_GetHashValue(hashent); uptodate = (prodesc->fn_xmin == HeapTupleHeaderGetXmin(procTup->t_data) && - prodesc->fn_cmin == HeapTupleHeaderGetCmin(procTup->t_data)); + prodesc->fn_cmin == HeapTupleHeaderGetCmin(procTup->t_data)); if (!uptodate) { @@ -1065,7 +1063,7 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid) if (!is_trigger) { typeTup = SearchSysCache(TYPEOID, - ObjectIdGetDatum(procStruct->prorettype), + ObjectIdGetDatum(procStruct->prorettype), 0, 0, 0); if (!HeapTupleIsValid(typeTup)) { @@ -1095,8 +1093,8 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid) free(prodesc); ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("pltcl functions cannot return type %s", - format_type_be(procStruct->prorettype)))); + errmsg("pltcl functions cannot return type %s", + format_type_be(procStruct->prorettype)))); } } @@ -1106,7 +1104,7 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid) free(prodesc); ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("pltcl functions cannot return tuples yet"))); + errmsg("pltcl functions cannot return tuples yet"))); } perm_fmgr_info(typeStruct->typinput, &(prodesc->result_in_func)); @@ -1126,7 +1124,7 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid) for (i = 0; i < prodesc->nargs; i++) { typeTup = SearchSysCache(TYPEOID, - ObjectIdGetDatum(procStruct->proargtypes.values[i]), + ObjectIdGetDatum(procStruct->proargtypes.values[i]), 0, 0, 0); if (!HeapTupleIsValid(typeTup)) { @@ -1145,7 +1143,7 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("pltcl functions cannot take type %s", - format_type_be(procStruct->proargtypes.values[i])))); + format_type_be(procStruct->proargtypes.values[i])))); } if (typeStruct->typtype == 'c') @@ -1272,7 +1270,7 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid) * pltcl_elog() - elog() support for PLTcl **********************************************************************/ static int -pltcl_elog(ClientData cdata, Tcl_Interp *interp, +pltcl_elog(ClientData cdata, Tcl_Interp * interp, int argc, CONST84 char *argv[]) { volatile int level; @@ -1344,7 +1342,7 @@ pltcl_elog(ClientData cdata, Tcl_Interp *interp, * be used in SPI_execute query strings **********************************************************************/ static int -pltcl_quote(ClientData cdata, Tcl_Interp *interp, +pltcl_quote(ClientData cdata, Tcl_Interp * interp, int argc, CONST84 char *argv[]) { char *tmp; @@ -1397,7 +1395,7 @@ pltcl_quote(ClientData cdata, Tcl_Interp *interp, * pltcl_argisnull() - determine if a specific argument is NULL **********************************************************************/ static int -pltcl_argisnull(ClientData cdata, Tcl_Interp *interp, +pltcl_argisnull(ClientData cdata, Tcl_Interp * interp, int argc, CONST84 char *argv[]) { int argno; @@ -1454,7 +1452,7 @@ pltcl_argisnull(ClientData cdata, Tcl_Interp *interp, * pltcl_returnnull() - Cause a NULL return from a function **********************************************************************/ static int -pltcl_returnnull(ClientData cdata, Tcl_Interp *interp, +pltcl_returnnull(ClientData cdata, Tcl_Interp * interp, int argc, CONST84 char *argv[]) { FunctionCallInfo fcinfo = pltcl_current_fcinfo; @@ -1530,14 +1528,14 @@ pltcl_subtrans_commit(MemoryContext oldcontext, ResourceOwner oldowner) CurrentResourceOwner = oldowner; /* - * AtEOSubXact_SPI() should not have popped any SPI context, - * but just in case it did, make sure we remain connected. + * AtEOSubXact_SPI() should not have popped any SPI context, but just in + * case it did, make sure we remain connected. */ SPI_restore_connection(); } static void -pltcl_subtrans_abort(Tcl_Interp *interp, +pltcl_subtrans_abort(Tcl_Interp * interp, MemoryContext oldcontext, ResourceOwner oldowner) { ErrorData *edata; @@ -1553,9 +1551,9 @@ pltcl_subtrans_abort(Tcl_Interp *interp, CurrentResourceOwner = oldowner; /* - * If AtEOSubXact_SPI() popped any SPI context of the subxact, - * it will have left us in a disconnected state. We need this - * hack to return to connected state. + * If AtEOSubXact_SPI() popped any SPI context of the subxact, it will + * have left us in a disconnected state. We need this hack to return to + * connected state. */ SPI_restore_connection(); @@ -1570,7 +1568,7 @@ pltcl_subtrans_abort(Tcl_Interp *interp, * for the Tcl interpreter **********************************************************************/ static int -pltcl_SPI_execute(ClientData cdata, Tcl_Interp *interp, +pltcl_SPI_execute(ClientData cdata, Tcl_Interp * interp, int argc, CONST84 char *argv[]) { int my_rc; @@ -1673,7 +1671,7 @@ pltcl_SPI_execute(ClientData cdata, Tcl_Interp *interp, * Shared code between pltcl_SPI_execute and pltcl_SPI_execute_plan */ static int -pltcl_process_SPI_result(Tcl_Interp *interp, +pltcl_process_SPI_result(Tcl_Interp * interp, CONST84 char *arrayname, CONST84 char *loop_body, int spi_rc, @@ -1702,6 +1700,7 @@ pltcl_process_SPI_result(Tcl_Interp *interp, break; case SPI_OK_SELECT: + /* * Process the tuples we got */ @@ -1711,8 +1710,8 @@ pltcl_process_SPI_result(Tcl_Interp *interp, if (loop_body == NULL) { /* - * If there is no loop body given, just set the variables - * from the first tuple (if any) + * If there is no loop body given, just set the variables from + * the first tuple (if any) */ if (ntuples > 0) pltcl_set_tuple_values(interp, arrayname, 0, @@ -1721,8 +1720,8 @@ pltcl_process_SPI_result(Tcl_Interp *interp, else { /* - * There is a loop body - process all tuples and evaluate - * the body on each + * There is a loop body - process all tuples and evaluate the + * body on each */ for (i = 0; i < ntuples; i++) { @@ -1776,7 +1775,7 @@ pltcl_process_SPI_result(Tcl_Interp *interp, * and not save the plan currently. **********************************************************************/ static int -pltcl_SPI_prepare(ClientData cdata, Tcl_Interp *interp, +pltcl_SPI_prepare(ClientData cdata, Tcl_Interp * interp, int argc, CONST84 char *argv[]) { int nargs; @@ -1921,7 +1920,7 @@ pltcl_SPI_prepare(ClientData cdata, Tcl_Interp *interp, * pltcl_SPI_execute_plan() - Execute a prepared plan **********************************************************************/ static int -pltcl_SPI_execute_plan(ClientData cdata, Tcl_Interp *interp, +pltcl_SPI_execute_plan(ClientData cdata, Tcl_Interp * interp, int argc, CONST84 char *argv[]) { int my_rc; @@ -2017,7 +2016,7 @@ pltcl_SPI_execute_plan(ClientData cdata, Tcl_Interp *interp, if (strlen(nulls) != qdesc->nargs) { Tcl_SetResult(interp, - "length of nulls string doesn't match # of arguments", + "length of nulls string doesn't match # of arguments", TCL_VOLATILE); return TCL_ERROR; } @@ -2047,7 +2046,7 @@ pltcl_SPI_execute_plan(ClientData cdata, Tcl_Interp *interp, if (callnargs != qdesc->nargs) { Tcl_SetResult(interp, - "argument list length doesn't match # of arguments for query", + "argument list length doesn't match # of arguments for query", TCL_VOLATILE); ckfree((char *) callargs); return TCL_ERROR; @@ -2141,7 +2140,7 @@ pltcl_SPI_execute_plan(ClientData cdata, Tcl_Interp *interp, * be used after insert queries **********************************************************************/ static int -pltcl_SPI_lastoid(ClientData cdata, Tcl_Interp *interp, +pltcl_SPI_lastoid(ClientData cdata, Tcl_Interp * interp, int argc, CONST84 char *argv[]) { char buf[64]; @@ -2157,7 +2156,7 @@ pltcl_SPI_lastoid(ClientData cdata, Tcl_Interp *interp, * of a given tuple **********************************************************************/ static void -pltcl_set_tuple_values(Tcl_Interp *interp, CONST84 char *arrayname, +pltcl_set_tuple_values(Tcl_Interp * interp, CONST84 char *arrayname, int tupno, HeapTuple tuple, TupleDesc tupdesc) { int i; @@ -2212,7 +2211,7 @@ pltcl_set_tuple_values(Tcl_Interp *interp, CONST84 char *arrayname, * for the output function ************************************************************/ typeTup = SearchSysCache(TYPEOID, - ObjectIdGetDatum(tupdesc->attrs[i]->atttypid), + ObjectIdGetDatum(tupdesc->attrs[i]->atttypid), 0, 0, 0); if (!HeapTupleIsValid(typeTup)) elog(ERROR, "cache lookup failed for type %u", @@ -2250,7 +2249,7 @@ pltcl_set_tuple_values(Tcl_Interp *interp, CONST84 char *arrayname, **********************************************************************/ static void pltcl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc, - Tcl_DString *retval) + Tcl_DString * retval) { int i; char *outputstr; @@ -2282,7 +2281,7 @@ pltcl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc, * for the output function ************************************************************/ typeTup = SearchSysCache(TYPEOID, - ObjectIdGetDatum(tupdesc->attrs[i]->atttypid), + ObjectIdGetDatum(tupdesc->attrs[i]->atttypid), 0, 0, 0); if (!HeapTupleIsValid(typeTup)) elog(ERROR, "cache lookup failed for type %u", diff --git a/src/port/copydir.c b/src/port/copydir.c index a5cd967ed7..b2f9070046 100644 --- a/src/port/copydir.c +++ b/src/port/copydir.c @@ -11,7 +11,7 @@ * as a service. * * IDENTIFICATION - * $PostgreSQL: pgsql/src/port/copydir.c,v 1.14 2005/09/03 15:55:00 tgl Exp $ + * $PostgreSQL: pgsql/src/port/copydir.c,v 1.15 2005/10/15 02:49:50 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -66,11 +66,11 @@ copydir(char *fromdir, char *todir, bool recurse) while ((xlde = ReadDir(xldir, fromdir)) != NULL) { - struct stat fst; + struct stat fst; - if (strcmp(xlde->d_name, ".") == 0 || + if (strcmp(xlde->d_name, ".") == 0 || strcmp(xlde->d_name, "..") == 0) - continue; + continue; snprintf(fromfile, MAXPGPATH, "%s/%s", fromdir, xlde->d_name); snprintf(tofile, MAXPGPATH, "%s/%s", todir, xlde->d_name); diff --git a/src/port/crypt.c b/src/port/crypt.c index 5488fe60ce..d3c01d2f38 100644 --- a/src/port/crypt.c +++ b/src/port/crypt.c @@ -11,18 +11,18 @@ * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) @@ -35,7 +35,6 @@ #if defined(LIBC_SCCS) && !defined(lint) #if 0 static char sccsid[] = "@(#)crypt.c 8.1.1.1 (Berkeley) 8/18/93"; - #else __RCSID("$NetBSD: crypt.c,v 1.18 2001/03/01 14:37:35 wiz Exp $"); #endif @@ -330,7 +329,7 @@ int chars_in; /* ===== (mostly) Standard DES Tables ==================== */ -static const unsigned char IP[] = { /* initial permutation */ +static const unsigned char IP[] = { /* initial permutation */ 58, 50, 42, 34, 26, 18, 10, 2, 60, 52, 44, 36, 28, 20, 12, 4, 62, 54, 46, 38, 30, 22, 14, 6, @@ -383,7 +382,7 @@ static const unsigned char PC2[] = { /* permuted choice table 2 */ 0, 0, 46, 42, 50, 36, 29, 32, }; -static const unsigned char S[8][64] = { /* 48->32 bit substitution tables */ +static const unsigned char S[8][64] = { /* 48->32 bit substitution tables */ /* S[1] */ {14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7, 0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8, @@ -437,7 +436,7 @@ static const unsigned char P32Tr[] = { /* 32-bit permutation function */ 22, 11, 4, 25, }; -static const unsigned char CIFP[] = { /* compressed/interleaved permutation */ +static const unsigned char CIFP[] = { /* compressed/interleaved permutation */ 1, 2, 3, 4, 17, 18, 19, 20, 5, 6, 7, 8, 21, 22, 23, 24, 9, 10, 11, 12, 25, 26, 27, 28, @@ -449,7 +448,7 @@ static const unsigned char CIFP[] = { /* compressed/interleaved permutation */ 45, 46, 47, 48, 61, 62, 63, 64, }; -static const unsigned char itoa64[] = /* 0..63 => ascii-64 */ +static const unsigned char itoa64[] = /* 0..63 => ascii-64 */ "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; @@ -523,8 +522,7 @@ const char *setting; key++; keyblock.b[i] = t; } - if (des_setkey((char *) keyblock.b)) /* also initializes - * "a64toi" */ + if (des_setkey((char *) keyblock.b)) /* also initializes "a64toi" */ return (NULL); encp = &cryptresult[0]; @@ -816,6 +814,7 @@ init_des() int tableno; static unsigned char perm[64], tmp32[32]; /* "static" for speed */ + /* static volatile long init_start = 0; not used */ /* diff --git a/src/port/dirmod.c b/src/port/dirmod.c index 48f0914224..d79b9f2fb5 100644 --- a/src/port/dirmod.c +++ b/src/port/dirmod.c @@ -10,7 +10,7 @@ * Win32 (NT, Win2k, XP). replace() doesn't work on Win95/98/Me. * * IDENTIFICATION - * $PostgreSQL: pgsql/src/port/dirmod.c,v 1.40 2005/09/18 09:48:24 petere Exp $ + * $PostgreSQL: pgsql/src/port/dirmod.c,v 1.41 2005/10/15 02:49:51 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -53,8 +53,7 @@ #define palloc(sz) pgport_palloc(sz) #define pstrdup(str) pgport_pstrdup(str) #endif - -#else /* FRONTEND */ +#else /* FRONTEND */ /* * In frontend, fake palloc behavior with these @@ -104,8 +103,7 @@ fe_repalloc(void *pointer, Size size) } return res; } - -#endif /* FRONTEND */ +#endif /* FRONTEND */ #if defined(WIN32) || defined(__CYGWIN__) @@ -119,9 +117,9 @@ pgrename(const char *from, const char *to) int loops = 0; /* - * We need these loops because even though PostgreSQL uses flags - * that allow rename while the file is open, other applications - * might have these files open without those flags. + * We need these loops because even though PostgreSQL uses flags that + * allow rename while the file is open, other applications might have + * these files open without those flags. */ #if defined(WIN32) && !defined(__CYGWIN__) while (!MoveFileEx(from, to, MOVEFILE_REPLACE_EXISTING)) @@ -169,9 +167,9 @@ pgunlink(const char *path) int loops = 0; /* - * We need these loops because even though PostgreSQL uses flags - * that allow unlink while the file is open, other applications - * might have these files open without those flags. + * We need these loops because even though PostgreSQL uses flags that + * allow unlink while the file is open, other applications might have + * these files open without those flags. */ while (unlink(path)) { @@ -200,7 +198,7 @@ pgunlink(const char *path) } -#ifdef WIN32 /* Cygwin has its own symlinks */ +#ifdef WIN32 /* Cygwin has its own symlinks */ /* * pgsymlink support: @@ -244,7 +242,7 @@ pgsymlink(const char *oldpath, const char *newpath) CreateDirectory(newpath, 0); dirhandle = CreateFile(newpath, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, - FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, 0); + FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, 0); if (dirhandle == INVALID_HANDLE_VALUE) return -1; @@ -270,13 +268,13 @@ pgsymlink(const char *oldpath, const char *newpath) reparseBuf->PathBuffer, MAX_PATH); /* - * FSCTL_SET_REPARSE_POINT is coded differently depending on SDK - * version; we use our own definition + * FSCTL_SET_REPARSE_POINT is coded differently depending on SDK version; + * we use our own definition */ if (!DeviceIoControl(dirhandle, - CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 41, METHOD_BUFFERED, FILE_ANY_ACCESS), + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 41, METHOD_BUFFERED, FILE_ANY_ACCESS), reparseBuf, - reparseBuf->ReparseDataLength + REPARSE_JUNCTION_DATA_BUFFER_HEADER_SIZE, + reparseBuf->ReparseDataLength + REPARSE_JUNCTION_DATA_BUFFER_HEADER_SIZE, 0, 0, &len, 0)) { LPSTR msg; @@ -306,10 +304,8 @@ pgsymlink(const char *oldpath, const char *newpath) return 0; } - -#endif /* WIN32 */ - -#endif /* defined(WIN32) || defined(__CYGWIN__) */ +#endif /* WIN32 */ +#endif /* defined(WIN32) || defined(__CYGWIN__) */ /* We undefined this above, so we redefine it */ @@ -321,7 +317,7 @@ pgsymlink(const char *oldpath, const char *newpath) /* * fnames * - * return a list of the names of objects in the argument directory + * return a list of the names of objects in the argument directory */ static char ** fnames(char *path) @@ -351,7 +347,7 @@ fnames(char *path) { if (strcmp(file->d_name, ".") != 0 && strcmp(file->d_name, "..") != 0) { - if (numnames+1 >= fnsize) + if (numnames + 1 >= fnsize) { fnsize *= 2; filenames = (char **) repalloc(filenames, @@ -364,8 +360,8 @@ fnames(char *path) #ifdef WIN32 /* - * This fix is in mingw cvs (runtime/mingwex/dirent.c rev 1.4), but - * not in released version + * This fix is in mingw cvs (runtime/mingwex/dirent.c rev 1.4), but not in + * released version */ if (GetLastError() == ERROR_NO_MORE_FILES) errno = 0; @@ -423,8 +419,8 @@ rmtree(char *path, bool rmtopdir) struct stat statbuf; /* - * we copy all the names out of the directory before we start - * modifying it. + * we copy all the names out of the directory before we start modifying + * it. */ filenames = fnames(path); diff --git a/src/port/exec.c b/src/port/exec.c index 8220536c03..e754b18215 100644 --- a/src/port/exec.c +++ b/src/port/exec.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/port/exec.c,v 1.38 2005/02/22 04:43:16 momjian Exp $ + * $PostgreSQL: pgsql/src/port/exec.c,v 1.39 2005/10/15 02:49:51 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -75,7 +75,6 @@ validate_exec(const char *path) struct passwd *pwp; int i; int in_grp = 0; - #else char path_exe[MAXPGPATH + sizeof(".exe") - 1]; #endif @@ -96,8 +95,8 @@ validate_exec(const char *path) /* * Ensure that the file exists and is a regular file. * - * XXX if you have a broken system where stat() looks at the symlink - * instead of the underlying file, you lose. + * XXX if you have a broken system where stat() looks at the symlink instead + * of the underlying file, you lose. */ if (stat(path, &buf) < 0) return -1; @@ -222,8 +221,8 @@ find_my_exec(const char *argv0, char *retpath) #endif /* - * Since no explicit path was supplied, the user must have - * been relying on PATH. We'll search the same PATH. + * Since no explicit path was supplied, the user must have been relying on + * PATH. We'll search the same PATH. */ if ((path = getenv("PATH")) && *path) { @@ -254,7 +253,7 @@ find_my_exec(const char *argv0, char *retpath) switch (validate_exec(retpath)) { - case 0: /* found ok */ + case 0: /* found ok */ return resolve_symlinks(retpath); case -1: /* wasn't even a candidate, keep looking */ break; @@ -292,16 +291,16 @@ resolve_symlinks(char *path) char *fname; /* - * To resolve a symlink properly, we have to chdir into its directory - * and then chdir to where the symlink points; otherwise we may fail to + * To resolve a symlink properly, we have to chdir into its directory and + * then chdir to where the symlink points; otherwise we may fail to * resolve relative links correctly (consider cases involving mount * points, for example). After following the final symlink, we use * getcwd() to figure out where the heck we're at. * - * One might think we could skip all this if path doesn't point to a - * symlink to start with, but that's wrong. We also want to get rid - * of any directory symlinks that are present in the given path. - * We expect getcwd() to give us an accurate, symlink-free path. + * One might think we could skip all this if path doesn't point to a symlink + * to start with, but that's wrong. We also want to get rid of any + * directory symlinks that are present in the given path. We expect + * getcwd() to give us an accurate, symlink-free path. */ if (!getcwd(orig_wd, MAXPGPATH)) { @@ -312,8 +311,8 @@ resolve_symlinks(char *path) for (;;) { - char *lsep; - int rllen; + char *lsep; + int rllen; lsep = last_dir_separator(path); if (lsep) @@ -360,8 +359,7 @@ resolve_symlinks(char *path) log_error(_("could not change directory to \"%s\""), orig_wd); return -1; } - -#endif /* HAVE_READLINK */ +#endif /* HAVE_READLINK */ return 0; } @@ -435,8 +433,7 @@ pipe_read_line(char *cmd, char *line, int maxsize) return NULL; return line; - -#else /* WIN32 */ +#else /* WIN32 */ SECURITY_ATTRIBUTES sattr; HANDLE childstdoutrd, @@ -488,31 +485,31 @@ pipe_read_line(char *cmd, char *line, int maxsize) &pi)) { /* Successfully started the process */ - char *lineptr; + char *lineptr; ZeroMemory(line, maxsize); /* Try to read at least one line from the pipe */ /* This may require more than one wait/read attempt */ - for (lineptr = line; lineptr < line+maxsize-1; ) + for (lineptr = line; lineptr < line + maxsize - 1;) { DWORD bytesread = 0; /* Let's see if we can read */ if (WaitForSingleObject(childstdoutrddup, 10000) != WAIT_OBJECT_0) - break; /* Timeout, but perhaps we got a line already */ + break; /* Timeout, but perhaps we got a line already */ - if (!ReadFile(childstdoutrddup, lineptr, maxsize-(lineptr-line), + if (!ReadFile(childstdoutrddup, lineptr, maxsize - (lineptr - line), &bytesread, NULL)) - break; /* Error, but perhaps we got a line already */ + break; /* Error, but perhaps we got a line already */ lineptr += strlen(lineptr); if (!bytesread) - break; /* EOF */ + break; /* EOF */ if (strchr(line, '\n')) - break; /* One or more lines read */ + break; /* One or more lines read */ } if (lineptr != line) @@ -521,18 +518,18 @@ pipe_read_line(char *cmd, char *line, int maxsize) int len; /* If we got more than one line, cut off after the first \n */ - lineptr = strchr(line,'\n'); + lineptr = strchr(line, '\n'); if (lineptr) - *(lineptr+1) = '\0'; + *(lineptr + 1) = '\0'; len = strlen(line); /* * If EOL is \r\n, convert to just \n. Because stdout is a * text-mode stream, the \n output by the child process is - * received as \r\n, so we convert it to \n. The server - * main.c sets setvbuf(stdout, NULL, _IONBF, 0) which has the - * effect of disabling \n to \r\n expansion for stdout. + * received as \r\n, so we convert it to \n. The server main.c + * sets setvbuf(stdout, NULL, _IONBF, 0) which has the effect of + * disabling \n to \r\n expansion for stdout. */ if (len >= 2 && line[len - 2] == '\r' && line[len - 1] == '\n') { @@ -542,8 +539,8 @@ pipe_read_line(char *cmd, char *line, int maxsize) } /* - * We emulate fgets() behaviour. So if there is no newline at - * the end, we add one... + * We emulate fgets() behaviour. So if there is no newline at the + * end, we add one... */ if (len == 0 || line[len - 1] != '\n') strcat(line, "\n"); @@ -559,7 +556,7 @@ pipe_read_line(char *cmd, char *line, int maxsize) CloseHandle(childstdoutrddup); return retval; -#endif /* WIN32 */ +#endif /* WIN32 */ } diff --git a/src/port/getaddrinfo.c b/src/port/getaddrinfo.c index 86b21b3af6..49a7293dec 100644 --- a/src/port/getaddrinfo.c +++ b/src/port/getaddrinfo.c @@ -16,7 +16,7 @@ * Copyright (c) 2003-2005, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/port/getaddrinfo.c,v 1.20 2005/10/13 23:22:11 momjian Exp $ + * $PostgreSQL: pgsql/src/port/getaddrinfo.c,v 1.21 2005/10/15 02:49:51 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -46,17 +46,17 @@ * Here we need to declare what the function pointers look like */ typedef int (__stdcall * getaddrinfo_ptr_t) (const char *nodename, - const char *servname, - const struct addrinfo * hints, - struct addrinfo ** res); + const char *servname, + const struct addrinfo * hints, + struct addrinfo ** res); typedef void (__stdcall * freeaddrinfo_ptr_t) (struct addrinfo * ai); typedef int (__stdcall * getnameinfo_ptr_t) (const struct sockaddr * sa, - int salen, - char *host, int hostlen, - char *serv, int servlen, - int flags); + int salen, + char *host, int hostlen, + char *serv, int servlen, + int flags); /* static pointers to the native routines, so we only do the lookup once. */ static getaddrinfo_ptr_t getaddrinfo_ptr = NULL; @@ -74,9 +74,8 @@ haveNativeWindowsIPv6routines(void) return (getaddrinfo_ptr != NULL); /* - * For Windows XP and Windows 2003 (and longhorn/vista), the IPv6 - * routines are present in the WinSock 2 library (ws2_32.dll). - * Try that first + * For Windows XP and Windows 2003 (and longhorn/vista), the IPv6 routines + * are present in the WinSock 2 library (ws2_32.dll). Try that first */ hLibrary = LoadLibraryA("ws2_32"); @@ -106,7 +105,7 @@ haveNativeWindowsIPv6routines(void) getaddrinfo_ptr = (getaddrinfo_ptr_t) GetProcAddress(hLibrary, "getaddrinfo"); freeaddrinfo_ptr = (freeaddrinfo_ptr_t) GetProcAddress(hLibrary, - "freeaddrinfo"); + "freeaddrinfo"); getnameinfo_ptr = (getnameinfo_ptr_t) GetProcAddress(hLibrary, "getnameinfo"); @@ -129,7 +128,6 @@ haveNativeWindowsIPv6routines(void) alreadyLookedForIpv6routines = true; return (getaddrinfo_ptr != NULL); } - #endif @@ -152,6 +150,7 @@ getaddrinfo(const char *node, const char *service, struct addrinfo hints; #ifdef WIN32 + /* * If Windows has native IPv6 support, use the native Windows routine. * Otherwise, fall through and use our own code. @@ -274,6 +273,7 @@ freeaddrinfo(struct addrinfo * res) if (res) { #ifdef WIN32 + /* * If Windows has native IPv6 support, use the native Windows routine. * Otherwise, fall through and use our own code. @@ -313,8 +313,7 @@ gai_strerror(int errcode) } return hstrerror(hcode); - -#else /* !HAVE_HSTRERROR */ +#else /* !HAVE_HSTRERROR */ switch (errcode) { @@ -322,7 +321,7 @@ gai_strerror(int errcode) return "Unknown host"; case EAI_AGAIN: return "Host name lookup failure"; - /* Errors below are probably WIN32 only */ + /* Errors below are probably WIN32 only */ #ifdef EAI_BADFLAGS case EAI_BADFLAGS: return "Invalid argument"; @@ -366,6 +365,7 @@ getnameinfo(const struct sockaddr * sa, int salen, char *service, int servicelen, int flags) { #ifdef WIN32 + /* * If Windows has native IPv6 support, use the native Windows routine. * Otherwise, fall through and use our own code. diff --git a/src/port/getopt.c b/src/port/getopt.c index 48d10fb9ee..28a0d0a476 100644 --- a/src/port/getopt.c +++ b/src/port/getopt.c @@ -81,8 +81,7 @@ const char *ostr; !(oli = strchr(ostr, optopt))) { /* - * if the user didn't specify '-' as an option, assume it means - * -1. + * if the user didn't specify '-' as an option, assume it means -1. */ if (optopt == (int) '-') return -1; diff --git a/src/port/getopt_long.c b/src/port/getopt_long.c index 2bf0c8c9e3..5ef058f892 100644 --- a/src/port/getopt_long.c +++ b/src/port/getopt_long.c @@ -35,7 +35,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $PostgreSQL: pgsql/src/port/getopt_long.c,v 1.4 2005/07/28 04:03:14 tgl Exp $ + * $PostgreSQL: pgsql/src/port/getopt_long.c,v 1.5 2005/10/15 02:49:51 momjian Exp $ */ #include "c.h" @@ -115,7 +115,7 @@ getopt_long(int argc, char *const argv[], return BADARG; if (opterr) fprintf(stderr, - "%s: option requires an argument -- %s\n", + "%s: option requires an argument -- %s\n", argv[0], place); place = EMSG; optind++; diff --git a/src/port/getrusage.c b/src/port/getrusage.c index 49d87d4c6f..b496429de1 100644 --- a/src/port/getrusage.c +++ b/src/port/getrusage.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/port/getrusage.c,v 1.10 2005/07/28 04:03:14 tgl Exp $ + * $PostgreSQL: pgsql/src/port/getrusage.c,v 1.11 2005/10/15 02:49:51 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -35,13 +35,13 @@ getrusage(int who, struct rusage * rusage) { #ifdef WIN32 - FILETIME starttime; - FILETIME exittime; - FILETIME kerneltime; - FILETIME usertime; + FILETIME starttime; + FILETIME exittime; + FILETIME kerneltime; + FILETIME usertime; ULARGE_INTEGER li; - if (rusage == (struct rusage *)NULL) + if (rusage == (struct rusage *) NULL) { errno = EFAULT; return -1; @@ -56,16 +56,15 @@ getrusage(int who, struct rusage * rusage) /* Convert FILETIMEs (0.1 us) to struct timeval */ memcpy(&li, &kerneltime, sizeof(FILETIME)); - li.QuadPart /= 10L; /* Convert to microseconds */ - rusage->ru_stime.tv_sec = li.QuadPart / 1000000L; + li.QuadPart /= 10L; /* Convert to microseconds */ + rusage->ru_stime.tv_sec = li.QuadPart / 1000000L; rusage->ru_stime.tv_usec = li.QuadPart % 1000000L; memcpy(&li, &usertime, sizeof(FILETIME)); - li.QuadPart /= 10L; /* Convert to microseconds */ - rusage->ru_utime.tv_sec = li.QuadPart / 1000000L; + li.QuadPart /= 10L; /* Convert to microseconds */ + rusage->ru_utime.tv_sec = li.QuadPart / 1000000L; rusage->ru_utime.tv_usec = li.QuadPart % 1000000L; - -#else /* all but WIN32 */ +#else /* all but WIN32 */ struct tms tms; int tick_rate = CLK_TCK; /* ticks per second */ @@ -102,8 +101,7 @@ getrusage(int who, struct rusage * rusage) rusage->ru_utime.tv_usec = TICK_TO_USEC(u, tick_rate); rusage->ru_stime.tv_sec = TICK_TO_SEC(s, tick_rate); rusage->ru_stime.tv_usec = TICK_TO_USEC(u, tick_rate); - -#endif /* WIN32 */ +#endif /* WIN32 */ return 0; } diff --git a/src/port/inet_aton.c b/src/port/inet_aton.c index 521e61dcf9..f5a64dbdbb 100644 --- a/src/port/inet_aton.c +++ b/src/port/inet_aton.c @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/port/inet_aton.c,v 1.7 2004/09/27 23:24:45 momjian Exp $ +/* $PostgreSQL: pgsql/src/port/inet_aton.c,v 1.8 2005/10/15 02:49:51 momjian Exp $ * * This inet_aton() function was taken from the GNU C library and * incorporated into Postgres for those systems which do not have this @@ -69,8 +69,8 @@ inet_aton(const char *cp, struct in_addr * addr) for (;;) { /* - * Collect number up to ``.''. Values are specified as for C: - * 0x=hex, 0=octal, other=decimal. + * Collect number up to ``.''. Values are specified as for C: 0x=hex, + * 0=octal, other=decimal. */ val = 0; base = 10; @@ -101,8 +101,8 @@ inet_aton(const char *cp, struct in_addr * addr) if (*cp == '.') { /* - * Internet format: a.b.c.d a.b.c (with c treated as - * 16-bits) a.b (with b treated as 24 bits) + * Internet format: a.b.c.d a.b.c (with c treated as 16-bits) + * a.b (with b treated as 24 bits) */ if (pp >= parts + 3 || val > 0xff) return 0; diff --git a/src/port/isinf.c b/src/port/isinf.c index 147f08c8fd..0ede85a265 100644 --- a/src/port/isinf.c +++ b/src/port/isinf.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/port/isinf.c,v 1.6 2004/12/31 22:03:53 pgsql Exp $ + * $PostgreSQL: pgsql/src/port/isinf.c,v 1.7 2005/10/15 02:49:51 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -17,8 +17,7 @@ #include #include -#if HAVE_FPCLASS /* this is _not_ HAVE_FP_CLASS, and not - * typo */ +#if HAVE_FPCLASS /* this is _not_ HAVE_FP_CLASS, and not typo */ #if HAVE_IEEEFP_H #include @@ -38,7 +37,6 @@ isinf(double d) } return 0; } - #else #if defined(HAVE_FP_CLASS) || defined(HAVE_FP_CLASS_D) @@ -52,7 +50,6 @@ double x; { #if HAVE_FP_CLASS int fpclass = fp_class(x); - #else int fpclass = fp_class_d(x); #endif @@ -63,7 +60,6 @@ double x; return -1; return 0; } - #elif defined(HAVE_CLASS) int isinf(double x) diff --git a/src/port/memcmp.c b/src/port/memcmp.c index c6df6c8df6..1a2d3b84db 100644 --- a/src/port/memcmp.c +++ b/src/port/memcmp.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/port/memcmp.c,v 1.8 2005/07/28 04:03:14 tgl Exp $ + * $PostgreSQL: pgsql/src/port/memcmp.c,v 1.9 2005/10/15 02:49:51 momjian Exp $ * * This file was taken from NetBSD and is used by SunOS because memcmp * on that platform does not properly compare negative bytes. The @@ -25,18 +25,18 @@ * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) diff --git a/src/port/noblock.c b/src/port/noblock.c index 1e5fb3630e..ca11b344fa 100644 --- a/src/port/noblock.c +++ b/src/port/noblock.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/port/noblock.c,v 1.7 2005/07/28 04:03:14 tgl Exp $ + * $PostgreSQL: pgsql/src/port/noblock.c,v 1.8 2005/10/15 02:49:51 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -40,7 +40,8 @@ bool pg_set_block(int sock) { #if !defined(WIN32) && !defined(__BEOS__) - int flags; + int flags; + flags = fcntl(sock, F_GETFL); if (flags < 0 || fcntl(sock, F_SETFL, (long) (flags & ~O_NONBLOCK))) return false; diff --git a/src/port/open.c b/src/port/open.c index fd7e010c1c..d56d5178b2 100644 --- a/src/port/open.c +++ b/src/port/open.c @@ -6,7 +6,7 @@ * * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/port/open.c,v 1.10 2005/07/28 04:03:14 tgl Exp $ + * $PostgreSQL: pgsql/src/port/open.c,v 1.11 2005/10/15 02:49:51 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -19,7 +19,7 @@ #include #include -int win32_open(const char *fileName, int fileFlags, ...); +int win32_open(const char *fileName, int fileFlags,...); static int openFlagsToCreateFileFlags(int openFlags) @@ -64,7 +64,7 @@ win32_open(const char *fileName, int fileFlags,...) assert((fileFlags & ((O_RDONLY | O_WRONLY | O_RDWR) | O_APPEND | (O_RANDOM | O_SEQUENTIAL | O_TEMPORARY) | _O_SHORT_LIVED | O_DSYNC | - (O_CREAT | O_TRUNC | O_EXCL) | (O_TEXT | O_BINARY))) == fileFlags); + (O_CREAT | O_TRUNC | O_EXCL) | (O_TEXT | O_BINARY))) == fileFlags); sa.nLength = sizeof(sa); sa.bInheritHandle = TRUE; @@ -72,18 +72,18 @@ win32_open(const char *fileName, int fileFlags,...) if ((h = CreateFile(fileName, /* cannot use O_RDONLY, as it == 0 */ - (fileFlags & O_RDWR) ? (GENERIC_WRITE | GENERIC_READ) : - ((fileFlags & O_WRONLY) ? GENERIC_WRITE : GENERIC_READ), - /* These flags allow concurrent rename/unlink */ - (FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE), + (fileFlags & O_RDWR) ? (GENERIC_WRITE | GENERIC_READ) : + ((fileFlags & O_WRONLY) ? GENERIC_WRITE : GENERIC_READ), + /* These flags allow concurrent rename/unlink */ + (FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE), &sa, openFlagsToCreateFileFlags(fileFlags), FILE_ATTRIBUTE_NORMAL | - ((fileFlags & O_RANDOM) ? FILE_FLAG_RANDOM_ACCESS : 0) | - ((fileFlags & O_SEQUENTIAL) ? FILE_FLAG_SEQUENTIAL_SCAN : 0) | - ((fileFlags & _O_SHORT_LIVED) ? FILE_ATTRIBUTE_TEMPORARY : 0) | - ((fileFlags & O_TEMPORARY) ? FILE_FLAG_DELETE_ON_CLOSE : 0)| - ((fileFlags & O_DSYNC) ? FILE_FLAG_WRITE_THROUGH : 0), + ((fileFlags & O_RANDOM) ? FILE_FLAG_RANDOM_ACCESS : 0) | + ((fileFlags & O_SEQUENTIAL) ? FILE_FLAG_SEQUENTIAL_SCAN : 0) | + ((fileFlags & _O_SHORT_LIVED) ? FILE_ATTRIBUTE_TEMPORARY : 0) | + ((fileFlags & O_TEMPORARY) ? FILE_FLAG_DELETE_ON_CLOSE : 0) | + ((fileFlags & O_DSYNC) ? FILE_FLAG_WRITE_THROUGH : 0), NULL)) == INVALID_HANDLE_VALUE) { switch (GetLastError()) diff --git a/src/port/path.c b/src/port/path.c index a1c91a24dd..c6137bd0a1 100644 --- a/src/port/path.c +++ b/src/port/path.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/port/path.c,v 1.60 2005/10/13 15:37:14 momjian Exp $ + * $PostgreSQL: pgsql/src/port/path.c,v 1.61 2005/10/15 02:49:51 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -47,7 +47,7 @@ #endif static void make_relative_path(char *ret_path, const char *target_path, - const char *bin_path, const char *my_exec_path); + const char *bin_path, const char *my_exec_path); static void trim_directory(char *path); static void trim_trailing_separator(char *path); @@ -55,7 +55,7 @@ static void trim_trailing_separator(char *path); /* * skip_drive * - * On Windows, a path may begin with "C:" or "//network/". Advance over + * On Windows, a path may begin with "C:" or "//network/". Advance over * this and point to the effective start of the path. */ #ifdef WIN32 @@ -75,11 +75,9 @@ skip_drive(const char *path) } return (char *) path; } - #else #define skip_drive(path) (path) - #endif /* @@ -177,9 +175,10 @@ join_path_components(char *ret_path, { if (ret_path != head) StrNCpy(ret_path, head, MAXPGPATH); + /* - * Remove any leading "." and ".." in the tail component, - * adjusting head as needed. + * Remove any leading "." and ".." in the tail component, adjusting head + * as needed. */ for (;;) { @@ -224,16 +223,17 @@ join_path_components(char *ret_path, void canonicalize_path(char *path) { - char *p, *to_p; + char *p, + *to_p; char *spath; bool was_sep = false; int pending_strips; #ifdef WIN32 + /* - * The Windows command processor will accept suitably quoted paths - * with forward slashes, but barfs badly with mixed forward and back - * slashes. + * The Windows command processor will accept suitably quoted paths with + * forward slashes, but barfs badly with mixed forward and back slashes. */ for (p = path; *p; p++) { @@ -242,22 +242,22 @@ canonicalize_path(char *path) } /* - * In Win32, if you do: prog.exe "a b" "\c\d\" the system will pass - * \c\d" as argv[2], so trim off trailing quote. + * In Win32, if you do: prog.exe "a b" "\c\d\" the system will pass \c\d" + * as argv[2], so trim off trailing quote. */ if (p > path && *(p - 1) == '"') *(p - 1) = '/'; #endif /* - * Removing the trailing slash on a path means we never get ugly - * double trailing slashes. Also, Win32 can't stat() a directory - * with a trailing slash. Don't remove a leading slash, though. + * Removing the trailing slash on a path means we never get ugly double + * trailing slashes. Also, Win32 can't stat() a directory with a trailing + * slash. Don't remove a leading slash, though. */ trim_trailing_separator(path); /* - * Remove duplicate adjacent separators + * Remove duplicate adjacent separators */ p = path; #ifdef WIN32 @@ -280,12 +280,12 @@ canonicalize_path(char *path) /* * Remove any trailing uses of "." and process ".." ourselves * - * Note that "/../.." should reduce to just "/", while "../.." has to - * be kept as-is. In the latter case we put back mistakenly trimmed - * ".." components below. Also note that we want a Windows drive spec - * to be visible to trim_directory(), but it's not part of the logic - * that's looking at the name components; hence distinction between - * path and spath. + * Note that "/../.." should reduce to just "/", while "../.." has to be kept + * as-is. In the latter case we put back mistakenly trimmed ".." + * components below. Also note that we want a Windows drive spec to be + * visible to trim_directory(), but it's not part of the logic that's + * looking at the name components; hence distinction between path and + * spath. */ spath = skip_drive(path); pending_strips = 0; @@ -324,9 +324,9 @@ canonicalize_path(char *path) if (pending_strips > 0) { /* - * We could only get here if path is now totally empty (other than - * a possible drive specifier on Windows). - * We have to put back one or more ".."'s that we took off. + * We could only get here if path is now totally empty (other than a + * possible drive specifier on Windows). We have to put back one or + * more ".."'s that we took off. */ while (--pending_strips > 0) strcat(path, "../"); @@ -345,15 +345,15 @@ canonicalize_path(char *path) bool path_contains_parent_reference(const char *path) { - int path_len; + int path_len; path = skip_drive(path); /* C: shouldn't affect our conclusion */ path_len = strlen(path); /* - * ".." could be the whole path; otherwise, if it's present it must - * be at the beginning, in the middle, or at the end. + * ".." could be the whole path; otherwise, if it's present it must be at + * the beginning, in the middle, or at the end. */ if (strcmp(path, "..") == 0 || strncmp(path, "../", 3) == 0 || @@ -373,7 +373,7 @@ path_contains_parent_reference(const char *path) bool path_is_prefix_of_path(const char *path1, const char *path2) { - int path1_len = strlen(path1); + int path1_len = strlen(path1); if (strncmp(path1, path2, path1_len) == 0 && (IS_DIR_SEP(path2[path1_len]) || path2[path1_len] == '\0')) @@ -382,7 +382,7 @@ path_is_prefix_of_path(const char *path1, const char *path2) } /* - * Extracts the actual name of the program as called - + * Extracts the actual name of the program as called - * stripped of .exe suffix if any */ const char * @@ -399,18 +399,18 @@ get_progname(const char *argv0) #if defined(__CYGWIN__) || defined(WIN32) /* strip .exe suffix, regardless of case */ if (strlen(nodir_name) > sizeof(EXE) - 1 && - pg_strcasecmp(nodir_name + strlen(nodir_name)-(sizeof(EXE)-1), EXE) == 0) + pg_strcasecmp(nodir_name + strlen(nodir_name) - (sizeof(EXE) - 1), EXE) == 0) { - char *progname; + char *progname; progname = strdup(nodir_name); /* leaks memory, but called only once */ if (progname == NULL) { fprintf(stderr, "%s: out of memory\n", nodir_name); - exit(1); /* This could exit the postmaster */ + exit(1); /* This could exit the postmaster */ } progname[strlen(progname) - (sizeof(EXE) - 1)] = '\0'; - nodir_name = progname; + nodir_name = progname; } #endif @@ -432,10 +432,10 @@ get_progname(const char *argv0) * bin_path, then we build the result as my_exec_path (less the executable * name and last directory) joined to the non-matching part of target_path. * Otherwise, we return target_path as-is. - * + * * For example: * target_path = '/usr/local/share/postgresql' - * bin_path = '/usr/local/bin' + * bin_path = '/usr/local/bin' * my_exec_path = '/opt/pgsql/bin/postmaster' * Given these inputs we would return '/opt/pgsql/share/postgresql' */ @@ -575,7 +575,6 @@ get_home_path(char *ret_path) return false; StrNCpy(ret_path, pwd->pw_dir, MAXPGPATH); return true; - #else char tmppath[MAX_PATH]; diff --git a/src/port/qsort.c b/src/port/qsort.c index 607fcaccb9..71c1f155dd 100644 --- a/src/port/qsort.c +++ b/src/port/qsort.c @@ -3,7 +3,7 @@ * Add do ... while() macro fix * Remove __inline, _DIAGASSERTs, __P * - * $PostgreSQL: pgsql/src/port/qsort.c,v 1.7 2005/07/28 04:03:14 tgl Exp $ + * $PostgreSQL: pgsql/src/port/qsort.c,v 1.8 2005/10/15 02:49:51 momjian Exp $ */ /* $NetBSD: qsort.c,v 1.13 2003/08/07 16:43:42 agc Exp $ */ @@ -16,18 +16,18 @@ * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) diff --git a/src/port/snprintf.c b/src/port/snprintf.c index e7024b038e..910f40320a 100644 --- a/src/port/snprintf.c +++ b/src/port/snprintf.c @@ -62,7 +62,7 @@ * causing nasty effects. **************************************************************/ -/*static char _id[] = "$PostgreSQL: pgsql/src/port/snprintf.c,v 1.28 2005/07/28 04:03:14 tgl Exp $";*/ +/*static char _id[] = "$PostgreSQL: pgsql/src/port/snprintf.c,v 1.29 2005/10/15 02:49:51 momjian Exp $";*/ static void dopr(char *buffer, const char *format, va_list args, char *end); @@ -140,16 +140,16 @@ pg_printf(const char *fmt,...) va_start(args, fmt); len = pg_vsnprintf(buffer, (size_t) 4096, fmt, args); va_end(args); - + for (p = buffer; *p; p++) putchar(*p); return len; } -static int adjust_sign(int is_negative, int forcesign, int *signvalue); +static int adjust_sign(int is_negative, int forcesign, int *signvalue); static void adjust_padlen(int minlen, int vallen, int leftjust, int *padlen); static void leading_pad(int zpad, int *signvalue, int *padlen, char *end, - char **output); + char **output); static void trailing_pad(int *padlen, char *end, char **output); static void fmtstr(char *value, int leftjust, int minlen, int maxwidth, @@ -157,8 +157,8 @@ static void fmtstr(char *value, int leftjust, int minlen, int maxwidth, static void fmtint(int64 value, int base, int dosign, int forcesign, int leftjust, int minlen, int zpad, char *end, char **output); static void fmtfloat(double value, char type, int forcesign, - int leftjust, int minlen, int zpad, int precision, int pointflag, char *end, - char **output); + int leftjust, int minlen, int zpad, int precision, int pointflag, char *end, + char **output); static void dostr(char *str, int cut, char *end, char **output); static void dopr_outch(int c, char *end, char **output); @@ -221,9 +221,9 @@ dopr(char *buffer, const char *format, va_list args, char *end) } *fmtpar, **fmtparptr; /* - * Create enough structures to hold all arguments. This overcounts, - * eg not all '*' characters are necessarily arguments, but it's not - * worth being exact. + * Create enough structures to hold all arguments. This overcounts, eg + * not all '*' characters are necessarily arguments, but it's not worth + * being exact. */ for (p = format; *p != '\0'; p++) if (*p == '%' || *p == '*') @@ -504,8 +504,8 @@ performpr: break; case FMTLEN: { - int minlen = va_arg(args, int); - int leftjust = 0; + int minlen = va_arg(args, int); + int leftjust = 0; if (minlen < 0) { @@ -563,10 +563,10 @@ performpr: break; case FMTFLOAT: fmtfloat(fmtparptr[i]->fvalue, fmtparptr[i]->type, - fmtparptr[i]->forcesign, fmtparptr[i]->leftjust, - fmtparptr[i]->minlen, fmtparptr[i]->zpad, - fmtparptr[i]->precision, fmtparptr[i]->pointflag, - end, &output); + fmtparptr[i]->forcesign, fmtparptr[i]->leftjust, + fmtparptr[i]->minlen, fmtparptr[i]->zpad, + fmtparptr[i]->precision, fmtparptr[i]->pointflag, + end, &output); break; case FMTCHAR: dopr_outch(fmtparptr[i]->charvalue, end, &output); @@ -626,7 +626,7 @@ fmtint(int64 value, int base, int dosign, int forcesign, int leftjust, /* Handle +/- and %X (uppercase hex) */ if (dosign && adjust_sign((value < 0), forcesign, &signvalue)) - value = -value; + value = -value; if (base < 0) { caps = 1; @@ -645,7 +645,7 @@ fmtint(int64 value, int base, int dosign, int forcesign, int leftjust, adjust_padlen(minlen, vallen, leftjust, &padlen); leading_pad(zpad, &signvalue, &padlen, end, output); - + while (vallen > 0) dopr_outch(convert[--vallen], end, output); @@ -670,7 +670,7 @@ fmtfloat(double value, char type, int forcesign, int leftjust, sprintf(fmt, "%%%c", type); if (adjust_sign((value < 0), forcesign, &signvalue)) - value = -value; + value = -value; vallen = sprintf(convert, fmt, value); @@ -761,7 +761,7 @@ leading_pad(int zpad, int *signvalue, int *padlen, char *end, char **output) { dopr_outch(*signvalue, end, output); if (*padlen > 0) - --*padlen; + --* padlen; if (padlen < 0) ++padlen; } @@ -777,4 +777,3 @@ trailing_pad(int *padlen, char *end, char **output) ++*padlen; } } - diff --git a/src/port/sprompt.c b/src/port/sprompt.c index 3b97eea7ec..cb0c910afb 100644 --- a/src/port/sprompt.c +++ b/src/port/sprompt.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/port/sprompt.c,v 1.11 2005/02/22 04:43:16 momjian Exp $ + * $PostgreSQL: pgsql/src/port/sprompt.c,v 1.12 2005/10/15 02:49:51 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -46,7 +46,6 @@ simple_prompt(const char *prompt, int maxlen, bool echo) #ifdef HAVE_TERMIOS_H struct termios t_orig, t; - #else #ifdef WIN32 HANDLE t = NULL; @@ -61,8 +60,8 @@ simple_prompt(const char *prompt, int maxlen, bool echo) prompt_state = true; /* disable SIGINT */ /* - * Do not try to collapse these into one "w+" mode file. Doesn't work - * on some platforms (eg, HPUX 10.20). + * Do not try to collapse these into one "w+" mode file. Doesn't work on + * some platforms (eg, HPUX 10.20). */ termin = fopen("/dev/tty", "r"); termout = fopen("/dev/tty", "w"); diff --git a/src/port/strtol.c b/src/port/strtol.c index 6bf14c5ff6..a948489390 100644 --- a/src/port/strtol.c +++ b/src/port/strtol.c @@ -92,19 +92,18 @@ int base; /* * Compute the cutoff value between legal numbers and illegal numbers. - * That is the largest legal value, divided by the base. An input - * number that is greater than this value, if followed by a legal - * input character, is too big. One that is equal to this value may - * be valid or not; the limit between valid and invalid numbers is - * then based on the last digit. For instance, if the range for longs - * is [-2147483648..2147483647] and the input base is 10, cutoff will - * be set to 214748364 and cutlim to either 7 (neg==0) or 8 (neg==1), - * meaning that if we have accumulated a value > 214748364, or equal - * but the next digit is > 7 (or 8), the number is too big, and we - * will return a range error. + * That is the largest legal value, divided by the base. An input number + * that is greater than this value, if followed by a legal input + * character, is too big. One that is equal to this value may be valid or + * not; the limit between valid and invalid numbers is then based on the + * last digit. For instance, if the range for longs is + * [-2147483648..2147483647] and the input base is 10, cutoff will be set + * to 214748364 and cutlim to either 7 (neg==0) or 8 (neg==1), meaning + * that if we have accumulated a value > 214748364, or equal but the next + * digit is > 7 (or 8), the number is too big, and we will return a range + * error. * - * Set any if any `digits' consumed; make it negative to indicate - * overflow. + * Set any if any `digits' consumed; make it negative to indicate overflow. */ cutoff = neg ? -(unsigned long) LONG_MIN : LONG_MAX; cutlim = cutoff % (unsigned long) base; diff --git a/src/port/thread.c b/src/port/thread.c index bfdf1bd282..a067af20d1 100644 --- a/src/port/thread.c +++ b/src/port/thread.c @@ -7,7 +7,7 @@ * * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/port/thread.c,v 1.30 2005/07/28 04:03:14 tgl Exp $ + * $PostgreSQL: pgsql/src/port/thread.c,v 1.31 2005/10/15 02:49:51 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -135,12 +135,11 @@ pqGethostbyname(const char *name, #if defined(FRONTEND) && defined(ENABLE_THREAD_SAFETY) && defined(HAVE_GETHOSTBYNAME_R) /* - * broken (well early POSIX draft) gethostbyname_r() which returns - * 'struct hostent *' + * broken (well early POSIX draft) gethostbyname_r() which returns 'struct + * hostent *' */ *result = gethostbyname_r(name, resultbuf, buffer, buflen, herrno); return (*result == NULL) ? -1 : 0; - #else /* no gethostbyname_r(), just use gethostbyname() */ diff --git a/src/port/unsetenv.c b/src/port/unsetenv.c index bc1c21effa..6509ff79f3 100644 --- a/src/port/unsetenv.c +++ b/src/port/unsetenv.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/port/unsetenv.c,v 1.4 2004/12/31 22:03:53 pgsql Exp $ + * $PostgreSQL: pgsql/src/port/unsetenv.c,v 1.5 2005/10/15 02:49:51 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -25,17 +25,16 @@ unsetenv(const char *name) return; /* no work */ /* - * The technique embodied here works if libc follows the Single Unix - * Spec and actually uses the storage passed to putenv() to hold the - * environ entry. When we clobber the entry in the second step we are - * ensuring that we zap the actual environ member. However, there are - * some libc implementations (notably recent BSDs) that do not obey - * SUS but copy the presented string. This method fails on such - * platforms. Hopefully all such platforms have unsetenv() and thus - * won't be using this hack. + * The technique embodied here works if libc follows the Single Unix Spec + * and actually uses the storage passed to putenv() to hold the environ + * entry. When we clobber the entry in the second step we are ensuring + * that we zap the actual environ member. However, there are some libc + * implementations (notably recent BSDs) that do not obey SUS but copy the + * presented string. This method fails on such platforms. Hopefully all + * such platforms have unsetenv() and thus won't be using this hack. * - * Note that repeatedly setting and unsetting a var using this code will - * leak memory. + * Note that repeatedly setting and unsetting a var using this code will leak + * memory. */ envstr = (char *) malloc(strlen(name) + 2); @@ -50,8 +49,8 @@ unsetenv(const char *name) strcpy(envstr, "="); /* - * This last putenv cleans up if we have multiple zero-length names as - * a result of unsetting multiple things. + * This last putenv cleans up if we have multiple zero-length names as a + * result of unsetting multiple things. */ putenv(envstr); } diff --git a/src/test/examples/testlibpq.c b/src/test/examples/testlibpq.c index 3295076481..b27c17386a 100644 --- a/src/test/examples/testlibpq.c +++ b/src/test/examples/testlibpq.c @@ -26,9 +26,8 @@ main(int argc, char **argv) /* * If the user supplies a parameter on the command line, use it as the - * conninfo string; otherwise default to setting dbname=postgres and - * using environment variables or defaults for all other connection - * parameters. + * conninfo string; otherwise default to setting dbname=postgres and using + * environment variables or defaults for all other connection parameters. */ if (argc > 1) conninfo = argv[1]; @@ -47,10 +46,10 @@ main(int argc, char **argv) } /* - * Our test case here involves using a cursor, for which we must be - * inside a transaction block. We could do the whole thing with a - * single PQexec() of "select * from pg_database", but that's too - * trivial to make a good example. + * Our test case here involves using a cursor, for which we must be inside + * a transaction block. We could do the whole thing with a single + * PQexec() of "select * from pg_database", but that's too trivial to make + * a good example. */ /* Start a transaction block */ @@ -63,8 +62,8 @@ main(int argc, char **argv) } /* - * Should PQclear PGresult whenever it is no longer needed to avoid - * memory leaks + * Should PQclear PGresult whenever it is no longer needed to avoid memory + * leaks */ PQclear(res); diff --git a/src/test/examples/testlibpq2.c b/src/test/examples/testlibpq2.c index 9f1e96d8da..5949c1364e 100644 --- a/src/test/examples/testlibpq2.c +++ b/src/test/examples/testlibpq2.c @@ -46,9 +46,8 @@ main(int argc, char **argv) /* * If the user supplies a parameter on the command line, use it as the - * conninfo string; otherwise default to setting dbname=postgres and - * using environment variables or defaults for all other connection - * parameters. + * conninfo string; otherwise default to setting dbname=postgres and using + * environment variables or defaults for all other connection parameters. */ if (argc > 1) conninfo = argv[1]; @@ -67,8 +66,7 @@ main(int argc, char **argv) } /* - * Issue LISTEN command to enable notifications from the rule's - * NOTIFY. + * Issue LISTEN command to enable notifications from the rule's NOTIFY. */ res = PQexec(conn, "LISTEN TBL2"); if (PQresultStatus(res) != PGRES_COMMAND_OK) @@ -79,8 +77,8 @@ main(int argc, char **argv) } /* - * should PQclear PGresult whenever it is no longer needed to avoid - * memory leaks + * should PQclear PGresult whenever it is no longer needed to avoid memory + * leaks */ PQclear(res); @@ -89,9 +87,9 @@ main(int argc, char **argv) while (nnotifies < 4) { /* - * Sleep until something happens on the connection. We use - * select(2) to wait for input, but you could also use poll() or - * similar facilities. + * Sleep until something happens on the connection. We use select(2) + * to wait for input, but you could also use poll() or similar + * facilities. */ int sock; fd_set input_mask; diff --git a/src/test/examples/testlibpq3.c b/src/test/examples/testlibpq3.c index 49b03066cd..918d142c7b 100644 --- a/src/test/examples/testlibpq3.c +++ b/src/test/examples/testlibpq3.c @@ -51,9 +51,8 @@ main(int argc, char **argv) /* * If the user supplies a parameter on the command line, use it as the - * conninfo string; otherwise default to setting dbname=postgres and - * using environment variables or defaults for all other connection - * parameters. + * conninfo string; otherwise default to setting dbname=postgres and using + * environment variables or defaults for all other connection parameters. */ if (argc > 1) conninfo = argv[1]; @@ -72,12 +71,11 @@ main(int argc, char **argv) } /* - * The point of this program is to illustrate use of PQexecParams() - * with out-of-line parameters, as well as binary transmission of - * results. By using out-of-line parameters we can avoid a lot of - * tedious mucking about with quoting and escaping. Notice how we - * don't have to do anything special with the quote mark in the - * parameter value. + * The point of this program is to illustrate use of PQexecParams() with + * out-of-line parameters, as well as binary transmission of results. By + * using out-of-line parameters we can avoid a lot of tedious mucking + * about with quoting and escaping. Notice how we don't have to do + * anything special with the quote mark in the parameter value. */ /* Here is our out-of-line parameter value */ @@ -118,19 +116,18 @@ main(int argc, char **argv) bptr = PQgetvalue(res, i, b_fnum); /* - * The binary representation of INT4 is in network byte order, - * which we'd better coerce to the local byte order. + * The binary representation of INT4 is in network byte order, which + * we'd better coerce to the local byte order. */ ival = ntohl(*((uint32_t *) iptr)); /* - * The binary representation of TEXT is, well, text, and since - * libpq was nice enough to append a zero byte to it, it'll work - * just fine as a C string. + * The binary representation of TEXT is, well, text, and since libpq + * was nice enough to append a zero byte to it, it'll work just fine + * as a C string. * - * The binary representation of BYTEA is a bunch of bytes, which - * could include embedded nulls so we have to pay attention to - * field length. + * The binary representation of BYTEA is a bunch of bytes, which could + * include embedded nulls so we have to pay attention to field length. */ blen = PQgetlength(res, i, b_fnum); diff --git a/src/test/examples/testlibpq4.c b/src/test/examples/testlibpq4.c index 977e4edd99..71b7d25f13 100644 --- a/src/test/examples/testlibpq4.c +++ b/src/test/examples/testlibpq4.c @@ -66,8 +66,8 @@ main(int argc, char **argv) /* * begin, by setting the parameters for a backend connection if the * parameters are null, then the system will try to use reasonable - * defaults by looking up environment variables or, failing that, - * using hardwired constants + * defaults by looking up environment variables or, failing that, using + * hardwired constants */ pghost = NULL; /* host name of the backend server */ pgport = NULL; /* port of the backend server */ @@ -92,14 +92,13 @@ main(int argc, char **argv) } /* - * make sure to PQclear() a PGresult whenever it is no longer - * needed to avoid memory leaks + * make sure to PQclear() a PGresult whenever it is no longer needed to + * avoid memory leaks */ PQclear(res1); /* - * fetch instances from the pg_database, the system catalog of - * databases + * fetch instances from the pg_database, the system catalog of databases */ res1 = PQexec(conn1, "DECLARE myportal CURSOR FOR select * from pg_database"); if (PQresultStatus(res1) != PGRES_COMMAND_OK) diff --git a/src/test/regress/regress.c b/src/test/regress/regress.c index b0421332f8..97fe608602 100644 --- a/src/test/regress/regress.c +++ b/src/test/regress/regress.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/src/test/regress/regress.c,v 1.63 2005/07/23 14:18:56 tgl Exp $ + * $PostgreSQL: pgsql/src/test/regress/regress.c,v 1.64 2005/10/15 02:49:51 momjian Exp $ */ #include "postgres.h" @@ -54,16 +54,16 @@ regress_dist_ptpath(PG_FUNCTION_ARGS) default: /* - * the distance from a point to a path is the smallest - * distance from the point to any of its constituent segments. + * the distance from a point to a path is the smallest distance + * from the point to any of its constituent segments. */ Assert(path->npts > 1); for (i = 0; i < path->npts - 1; ++i) { regress_lseg_construct(&lseg, &path->p[i], &path->p[i + 1]); tmp = DatumGetFloat8(DirectFunctionCall2(dist_ps, - PointPGetDatum(pt), - LsegPGetDatum(&lseg))); + PointPGetDatum(pt), + LsegPGetDatum(&lseg))); if (i == 0 || tmp < result) result = tmp; } @@ -100,7 +100,7 @@ regress_path_dist(PG_FUNCTION_ARGS) tmp = DatumGetFloat8(DirectFunctionCall2(lseg_distance, LsegPGetDatum(&seg1), - LsegPGetDatum(&seg2))); + LsegPGetDatum(&seg2))); if (!have_min || tmp < min) { min = tmp; @@ -422,11 +422,11 @@ funny_dup17(PG_FUNCTION_ARGS) if (SPI_processed > 0) { selected = DatumGetInt32(DirectFunctionCall1(int4in, - CStringGetDatum(SPI_getvalue( - SPI_tuptable->vals[0], - SPI_tuptable->tupdesc, - 1 - )))); + CStringGetDatum(SPI_getvalue( + SPI_tuptable->vals[0], + SPI_tuptable->tupdesc, + 1 + )))); } elog(DEBUG4, "funny_dup17 (fired %s) on level %3d: %d/%d tuples inserted/selected", @@ -554,7 +554,7 @@ ttdummy(PG_FUNCTION_ARGS) { text *seqname = DatumGetTextP(DirectFunctionCall1(textin, - CStringGetDatum("ttdummy_seq"))); + CStringGetDatum("ttdummy_seq"))); newoff = DirectFunctionCall1(nextval, PointerGetDatum(seqname)); diff --git a/src/timezone/ialloc.c b/src/timezone/ialloc.c index a133507571..547a786e34 100644 --- a/src/timezone/ialloc.c +++ b/src/timezone/ialloc.c @@ -3,7 +3,7 @@ * 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov). * * IDENTIFICATION - * $PostgreSQL: pgsql/src/timezone/ialloc.c,v 1.6 2005/06/20 08:00:51 neilc Exp $ + * $PostgreSQL: pgsql/src/timezone/ialloc.c,v 1.7 2005/10/15 02:49:51 momjian Exp $ */ #include "postgres.h" @@ -38,9 +38,9 @@ irealloc(void *pointer, const int size) char * icatalloc(char *old, const char *new) { - char *result; - int oldsize, - newsize; + char *result; + int oldsize, + newsize; newsize = (new == NULL) ? 0 : strlen(new); if (old == NULL) diff --git a/src/timezone/localtime.c b/src/timezone/localtime.c index 098d6700f9..342bdc920c 100644 --- a/src/timezone/localtime.c +++ b/src/timezone/localtime.c @@ -3,7 +3,7 @@ * 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov). * * IDENTIFICATION - * $PostgreSQL: pgsql/src/timezone/localtime.c,v 1.11 2005/06/20 08:00:51 neilc Exp $ + * $PostgreSQL: pgsql/src/timezone/localtime.c,v 1.12 2005/10/15 02:49:51 momjian Exp $ */ /* @@ -69,8 +69,7 @@ struct rule #define JULIAN_DAY 0 /* Jn - Julian day */ #define DAY_OF_YEAR 1 /* n - day of year */ -#define MONTH_NTH_DAY_OF_WEEK 2 /* Mm.n.d - month, week, day of - * week */ +#define MONTH_NTH_DAY_OF_WEEK 2 /* Mm.n.d - month, week, day of week */ /* * Prototypes for static functions. @@ -81,15 +80,15 @@ static const char *getzname(const char *strp); static const char *getnum(const char *strp, int *nump, int min, int max); static const char *getsecs(const char *strp, long *secsp); static const char *getoffset(const char *strp, long *offsetp); -static const char *getrule(const char *strp, struct rule *rulep); -static void gmtload(struct state *sp); -static void gmtsub(const pg_time_t *timep, long offset, struct pg_tm *tmp); -static void localsub(const pg_time_t *timep, long offset, struct pg_tm *tmp, const pg_tz *tz); +static const char *getrule(const char *strp, struct rule * rulep); +static void gmtload(struct state * sp); +static void gmtsub(const pg_time_t *timep, long offset, struct pg_tm * tmp); +static void localsub(const pg_time_t *timep, long offset, struct pg_tm * tmp, const pg_tz *tz); static void timesub(const pg_time_t *timep, long offset, - const struct state *sp, struct pg_tm *tmp); + const struct state * sp, struct pg_tm * tmp); static pg_time_t transtime(pg_time_t janfirst, int year, - const struct rule *rulep, long offset); -int tzparse(const char *name, struct state *sp, int lastditch); + const struct rule * rulep, long offset); +int tzparse(const char *name, struct state * sp, int lastditch); /* GMT timezone */ static struct state gmtmem; @@ -113,8 +112,8 @@ static struct pg_tm tm; static long detzcode(const char *codep) { - long result; - int i; + long result; + int i; result = (codep[0] & 0x80) ? ~0L : 0L; for (i = 0; i < 4; ++i) @@ -123,16 +122,16 @@ detzcode(const char *codep) } int -tzload(const char *name, struct state *sp) +tzload(const char *name, struct state * sp) { const char *p; - int i; - int fid; + int i; + int fid; if (name == NULL && (name = TZDEFAULT) == NULL) return -1; { - int doaccess; + int doaccess; char fullname[MAXPGPATH]; if (name[0] == ':') @@ -286,7 +285,7 @@ static const int year_lengths[2] = { static const char * getzname(const char *strp) { - char c; + char c; while ((c = *strp) != '\0' && !is_digit(c) && c != ',' && c != '-' && c != '+') @@ -303,8 +302,8 @@ getzname(const char *strp) static const char * getnum(const char *strp, int *nump, int min, int max) { - char c; - int num; + char c; + int num; if (strp == NULL || !is_digit(c = *strp)) return NULL; @@ -336,8 +335,8 @@ getsecs(const char *strp, long *secsp) /* * `HOURSPERDAY * DAYSPERWEEK - 1' allows quasi-Posix rules like - * "M10.4.6/26", which does not conform to Posix, but which specifies - * the equivalent of ``02:00 on the first Sunday on or after 23 Oct''. + * "M10.4.6/26", which does not conform to Posix, but which specifies the + * equivalent of ``02:00 on the first Sunday on or after 23 Oct''. */ strp = getnum(strp, &num, 0, HOURSPERDAY * DAYSPERWEEK - 1); if (strp == NULL) @@ -372,7 +371,7 @@ getsecs(const char *strp, long *secsp) static const char * getoffset(const char *strp, long *offsetp) { - int neg = 0; + int neg = 0; if (*strp == '-') { @@ -396,7 +395,7 @@ getoffset(const char *strp, long *offsetp) * Otherwise, return a pointer to the first character not part of the rule. */ static const char * -getrule(const char *strp, struct rule *rulep) +getrule(const char *strp, struct rule * rulep) { if (*strp == 'J') { @@ -458,10 +457,10 @@ getrule(const char *strp, struct rule *rulep) */ static pg_time_t transtime(const pg_time_t janfirst, int year, - const struct rule *rulep, long offset) + const struct rule * rulep, long offset) { - int leapyear; - pg_time_t value = 0; + int leapyear; + pg_time_t value = 0; int i, d, m1, @@ -478,9 +477,9 @@ transtime(const pg_time_t janfirst, int year, /* * Jn - Julian day, 1 == January 1, 60 == March 1 even in leap - * years. In non-leap years, or if the day number is 59 or - * less, just add SECSPERDAY times the day number-1 to the - * time of January 1, midnight, to get the day. + * years. In non-leap years, or if the day number is 59 or less, + * just add SECSPERDAY times the day number-1 to the time of + * January 1, midnight, to get the day. */ value = janfirst + (rulep->r_day - 1) * SECSPERDAY; if (leapyear && rulep->r_day >= 60) @@ -490,8 +489,8 @@ transtime(const pg_time_t janfirst, int year, case DAY_OF_YEAR: /* - * n - day of year. Just add SECSPERDAY times the day number - * to the time of January 1, midnight, to get the day. + * n - day of year. Just add SECSPERDAY times the day number to + * the time of January 1, midnight, to get the day. */ value = janfirst + rulep->r_day * SECSPERDAY; break; @@ -519,9 +518,8 @@ transtime(const pg_time_t janfirst, int year, dow += DAYSPERWEEK; /* - * "dow" is the day-of-week of the first day of the month. Get - * the day-of-month (zero-origin) of the first "dow" day of - * the month. + * "dow" is the day-of-week of the first day of the month. Get the + * day-of-month (zero-origin) of the first "dow" day of the month. */ d = rulep->r_day - dow; if (d < 0) @@ -543,9 +541,8 @@ transtime(const pg_time_t janfirst, int year, /* * "value" is the Epoch-relative time of 00:00:00 UTC on the day in - * question. To get the Epoch-relative time of the specified local - * time on that day, add the transition time and the current offset - * from UTC. + * question. To get the Epoch-relative time of the specified local time + * on that day, add the transition time and the current offset from UTC. */ return value + rulep->r_time + offset; } @@ -556,7 +553,7 @@ transtime(const pg_time_t janfirst, int year, */ int -tzparse(const char *name, struct state *sp, int lastditch) +tzparse(const char *name, struct state * sp, int lastditch) { const char *stdname; const char *dstname = NULL; @@ -564,10 +561,10 @@ tzparse(const char *name, struct state *sp, int lastditch) size_t dstlen; long stdoffset; long dstoffset; - pg_time_t *atp; + pg_time_t *atp; unsigned char *typep; - char *cp; - int load_result; + char *cp; + int load_result; stdname = name; if (lastditch) @@ -614,8 +611,8 @@ tzparse(const char *name, struct state *sp, int lastditch) { struct rule start; struct rule end; - int year; - pg_time_t janfirst; + int year; + pg_time_t janfirst; pg_time_t starttime; pg_time_t endtime; @@ -671,12 +668,12 @@ tzparse(const char *name, struct state *sp, int lastditch) } else { - long theirstdoffset; - long theirdstoffset; - long theiroffset; - int isdst; - int i; - int j; + long theirstdoffset; + long theirdstoffset; + long theiroffset; + int isdst; + int i; + int j; if (*name != '\0') return -1; @@ -714,8 +711,8 @@ tzparse(const char *name, struct state *sp, int lastditch) theiroffset = theirstdoffset; /* - * Now juggle transition times and types tracking offsets as - * you do. + * Now juggle transition times and types tracking offsets as you + * do. */ for (i = 0; i < sp->timecnt; ++i) { @@ -728,17 +725,15 @@ tzparse(const char *name, struct state *sp, int lastditch) else { /* - * If summer time is in effect, and the transition - * time was not specified as standard time, add the - * summer time offset to the transition time; - * otherwise, add the standard time offset to the - * transition time. + * If summer time is in effect, and the transition time + * was not specified as standard time, add the summer time + * offset to the transition time; otherwise, add the + * standard time offset to the transition time. */ /* - * Transitions from DST to DDST will effectively - * disappear since POSIX provides for only one DST - * offset. + * Transitions from DST to DDST will effectively disappear + * since POSIX provides for only one DST offset. */ if (isdst && !sp->ttis[j].tt_ttisstd) { @@ -759,8 +754,7 @@ tzparse(const char *name, struct state *sp, int lastditch) } /* - * Finally, fill in ttis. ttisstd and ttisgmt need not be - * handled. + * Finally, fill in ttis. ttisstd and ttisgmt need not be handled. */ sp->ttis[0].tt_gmtoff = -stdoffset; sp->ttis[0].tt_isdst = FALSE; @@ -798,7 +792,7 @@ tzparse(const char *name, struct state *sp, int lastditch) } static void -gmtload(struct state *sp) +gmtload(struct state * sp) { if (tzload(gmt, sp) != 0) (void) tzparse(gmt, sp, TRUE); @@ -814,11 +808,11 @@ gmtload(struct state *sp) * The unused offset argument is for the benefit of mktime variants. */ static void -localsub(const pg_time_t *timep, long offset, struct pg_tm *tmp, const pg_tz *tz) +localsub(const pg_time_t *timep, long offset, struct pg_tm * tmp, const pg_tz *tz) { - const struct state *sp; + const struct state *sp; const struct ttinfo *ttisp; - int i; + int i; const pg_time_t t = *timep; sp = &tz->state; @@ -859,7 +853,7 @@ pg_localtime(const pg_time_t *timep, const pg_tz *tz) * gmtsub is to gmtime as localsub is to localtime. */ static void -gmtsub(const pg_time_t *timep, long offset, struct pg_tm *tmp) +gmtsub(const pg_time_t *timep, long offset, struct pg_tm * tmp) { if (!gmt_is_set) { @@ -870,8 +864,8 @@ gmtsub(const pg_time_t *timep, long offset, struct pg_tm *tmp) /* * Could get fancy here and deliver something such as "UTC+xxxx" or - * "UTC-xxxx" if offset is non-zero, but this is no time for a - * treasure hunt. + * "UTC-xxxx" if offset is non-zero, but this is no time for a treasure + * hunt. */ if (offset != 0) tmp->tm_zone = wildabbr; @@ -889,20 +883,20 @@ pg_gmtime(const pg_time_t *timep) static void timesub(const pg_time_t *timep, long offset, - const struct state *sp, struct pg_tm *tmp) + const struct state * sp, struct pg_tm * tmp) { const struct lsinfo *lp; /* expand days to 64 bits to support full Julian-day range */ - int64 days; - int idays; - long rem; - int y; - int yleap; - const int *ip; - long corr; - int hit; - int i; + int64 days; + int idays; + long rem; + int y; + int yleap; + const int *ip; + long corr; + int hit; + int i; corr = 0; hit = 0; @@ -959,8 +953,8 @@ timesub(const pg_time_t *timep, long offset, tmp->tm_min = (int) (rem / SECSPERMIN); /* - * A positive leap second requires a special representation. This - * uses "... ??:59:60" et seq. + * A positive leap second requires a special representation. This uses + * "... ??:59:60" et seq. */ tmp->tm_sec = (int) (rem % SECSPERMIN) + hit; tmp->tm_wday = (int) ((EPOCH_WDAY + days) % DAYSPERWEEK); @@ -970,16 +964,16 @@ timesub(const pg_time_t *timep, long offset, /* * Note: the point of adding 4800 is to ensure we make the same - * assumptions as Postgres' Julian-date routines about the placement - * of leap years in centuries BC, at least back to 4713BC which is as - * far as we'll go. This is effectively extending Gregorian - * timekeeping into pre-Gregorian centuries, which is a tad bogus but - * it conforms to the SQL spec... + * assumptions as Postgres' Julian-date routines about the placement of + * leap years in centuries BC, at least back to 4713BC which is as far as + * we'll go. This is effectively extending Gregorian timekeeping into + * pre-Gregorian centuries, which is a tad bogus but it conforms to the + * SQL spec... */ #define LEAPS_THRU_END_OF(y) (((y) + 4800) / 4 - ((y) + 4800) / 100 + ((y) + 4800) / 400) while (days < 0 || days >= (int64) year_lengths[yleap = isleap(y)]) { - int newy; + int newy; newy = y + days / DAYSPERNYEAR; if (days < 0) @@ -1027,12 +1021,12 @@ pg_next_dst_boundary(const pg_time_t *timep, pg_time_t *boundary, long int *after_gmtoff, int *after_isdst, - const pg_tz *tz) + const pg_tz *tz) { const struct state *sp; const struct ttinfo *ttisp; - int i; - int j; + int i; + int j; const pg_time_t t = *timep; sp = &tz->state; diff --git a/src/timezone/pgtz.c b/src/timezone/pgtz.c index 2512061222..23165062bf 100644 --- a/src/timezone/pgtz.c +++ b/src/timezone/pgtz.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/timezone/pgtz.c,v 1.37 2005/09/09 02:31:50 tgl Exp $ + * $PostgreSQL: pgsql/src/timezone/pgtz.c,v 1.38 2005/10/15 02:49:51 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -29,7 +29,7 @@ #include "utils/hsearch.h" /* Current global timezone */ -pg_tz *global_timezone = NULL; +pg_tz *global_timezone = NULL; static char tzdir[MAXPGPATH]; @@ -97,7 +97,7 @@ static void scan_available_timezones(char *tzdir, char *tzdirsub, * Get GMT offset from a system struct tm */ static int -get_timezone_offset(struct tm *tm) +get_timezone_offset(struct tm * tm) { #if defined(HAVE_STRUCT_TM_TM_ZONE) return tm->tm_gmtoff; @@ -128,7 +128,7 @@ build_time_t(int year, int month, int day) * Does a system tm value match one we computed ourselves? */ static bool -compare_tm(struct tm *s, struct pg_tm *p) +compare_tm(struct tm * s, struct pg_tm * p) { if (s->tm_sec != p->tm_sec || s->tm_min != p->tm_min || @@ -155,21 +155,25 @@ compare_tm(struct tm *s, struct pg_tm *p) * test time. */ static int -score_timezone(const char *tzname, struct tztry *tt) +score_timezone(const char *tzname, struct tztry * tt) { int i; pg_time_t pgtt; struct tm *systm; struct pg_tm *pgtm; char cbuf[TZ_STRLEN_MAX + 1]; - pg_tz tz; + pg_tz tz; - /* Load timezone directly. Don't use pg_tzset, because we don't want - * all timezones loaded in the cache at startup. */ - if (tzload(tzname, &tz.state) != 0) { - if (tzname[0] == ':' || tzparse(tzname, &tz.state, FALSE) != 0) { - return -1; /* can't handle the TZ name at all */ + /* + * Load timezone directly. Don't use pg_tzset, because we don't want all + * timezones loaded in the cache at startup. + */ + if (tzload(tzname, &tz.state) != 0) + { + if (tzname[0] == ':' || tzparse(tzname, &tz.state, FALSE) != 0) + { + return -1; /* can't handle the TZ name at all */ } } @@ -257,20 +261,19 @@ identify_system_timezone(void) /* * Set up the list of dates to be probed to see how well our timezone - * matches the system zone. We first probe January and July of 2004; - * this serves to quickly eliminate the vast majority of the TZ - * database entries. If those dates match, we probe every week from - * 2004 backwards to late 1904. (Weekly resolution is good enough to - * identify DST transition rules, since everybody switches on - * Sundays.) The further back the zone matches, the better we score - * it. This may seem like a rather random way of doing things, but - * experience has shown that system-supplied timezone definitions are - * likely to have DST behavior that is right for the recent past and - * not so accurate further back. Scoring in this way allows us to - * recognize zones that have some commonality with the zic database, - * without insisting on exact match. (Note: we probe Thursdays, not - * Sundays, to avoid triggering DST-transition bugs in localtime - * itself.) + * matches the system zone. We first probe January and July of 2004; this + * serves to quickly eliminate the vast majority of the TZ database + * entries. If those dates match, we probe every week from 2004 backwards + * to late 1904. (Weekly resolution is good enough to identify DST + * transition rules, since everybody switches on Sundays.) The further + * back the zone matches, the better we score it. This may seem like a + * rather random way of doing things, but experience has shown that + * system-supplied timezone definitions are likely to have DST behavior + * that is right for the recent past and not so accurate further back. + * Scoring in this way allows us to recognize zones that have some + * commonality with the zic database, without insisting on exact match. + * (Note: we probe Thursdays, not Sundays, to avoid triggering + * DST-transition bugs in localtime itself.) */ tt.n_test_times = 0; tt.test_times[tt.n_test_times++] = build_time_t(2004, 1, 15); @@ -292,12 +295,12 @@ identify_system_timezone(void) return resultbuf; /* - * Couldn't find a match in the database, so next we try constructed - * zone names (like "PST8PDT"). + * Couldn't find a match in the database, so next we try constructed zone + * names (like "PST8PDT"). * - * First we need to determine the names of the local standard and - * daylight zones. The idea here is to scan forward from today until - * we have seen both zones, if both are in use. + * First we need to determine the names of the local standard and daylight + * zones. The idea here is to scan forward from today until we have seen + * both zones, if both are in use. */ memset(std_zone_name, 0, sizeof(std_zone_name)); memset(dst_zone_name, 0, sizeof(dst_zone_name)); @@ -306,15 +309,15 @@ identify_system_timezone(void) tnow = time(NULL); /* - * Round back to a GMT midnight so results don't depend on local time - * of day + * Round back to a GMT midnight so results don't depend on local time of + * day */ tnow -= (tnow % T_DAY); /* - * We have to look a little further ahead than one year, in case today - * is just past a DST boundary that falls earlier in the year than the - * next similar boundary. Arbitrarily scan up to 14 months. + * We have to look a little further ahead than one year, in case today is + * just past a DST boundary that falls earlier in the year than the next + * similar boundary. Arbitrarily scan up to 14 months. */ for (t = tnow; t <= tnow + T_MONTH * 14; t += T_MONTH) { @@ -348,7 +351,7 @@ identify_system_timezone(void) { ereport(LOG, (errmsg("unable to determine system timezone, defaulting to \"%s\"", "GMT"), - errhint("You can specify the correct timezone in postgresql.conf."))); + errhint("You can specify the correct timezone in postgresql.conf."))); return NULL; /* go to GMT */ } @@ -373,19 +376,18 @@ identify_system_timezone(void) return resultbuf; /* - * Did not find the timezone. Fallback to use a GMT zone. Note that - * the zic timezone database names the GMT-offset zones in POSIX - * style: plus is west of Greenwich. It's unfortunate that this is - * opposite of SQL conventions. Should we therefore change the names? - * Probably not... + * Did not find the timezone. Fallback to use a GMT zone. Note that the + * zic timezone database names the GMT-offset zones in POSIX style: plus + * is west of Greenwich. It's unfortunate that this is opposite of SQL + * conventions. Should we therefore change the names? Probably not... */ snprintf(resultbuf, sizeof(resultbuf), "Etc/GMT%s%d", (-std_ofs > 0) ? "+" : "", -std_ofs / 3600); ereport(LOG, - (errmsg("could not recognize system timezone, defaulting to \"%s\"", - resultbuf), - errhint("You can specify the correct timezone in postgresql.conf."))); + (errmsg("could not recognize system timezone, defaulting to \"%s\"", + resultbuf), + errhint("You can specify the correct timezone in postgresql.conf."))); return resultbuf; } @@ -409,7 +411,7 @@ identify_system_timezone(void) * score. bestzonename must be a buffer of length TZ_STRLEN_MAX + 1. */ static void -scan_available_timezones(char *tzdir, char *tzdirsub, struct tztry *tt, +scan_available_timezones(char *tzdir, char *tzdirsub, struct tztry * tt, int *bestscore, char *bestzonename) { int tzdir_orig_len = strlen(tzdir); @@ -477,7 +479,6 @@ scan_available_timezones(char *tzdir, char *tzdirsub, struct tztry *tt, FreeDir(dirdesc); } - #else /* WIN32 */ static const struct @@ -490,12 +491,11 @@ static const struct { /* * This list was built from the contents of the registry at - * HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows - * NT\CurrentVersion\Time Zones on Windows XP Professional SP1 + * HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time + * Zones on Windows XP Professional SP1 * * The zones have been matched to zic timezones by looking at the cities - * listed in the win32 display name (in the comment here) in most - * cases. + * listed in the win32 display name (in the comment here) in most cases. */ { "Afghanistan Standard Time", "Afghanistan Daylight Time", @@ -560,8 +560,8 @@ static const struct { "Central Europe Standard Time", "Central Europe Daylight Time", "Europe/Belgrade" - }, /* (GMT+01:00) Belgrade, Bratislava, - * Budapest, Ljubljana, Prague */ + }, /* (GMT+01:00) Belgrade, Bratislava, Budapest, + * Ljubljana, Prague */ { "Central European Standard Time", "Central European Daylight Time", "Europe/Sarajevo" @@ -579,13 +579,12 @@ static const struct { "China Standard Time", "China Daylight Time", "Asia/Hong_Kong" - }, /* (GMT+08:00) Beijing, Chongqing, Hong - * Kong, Urumqi */ + }, /* (GMT+08:00) Beijing, Chongqing, Hong Kong, + * Urumqi */ { "Dateline Standard Time", "Dateline Daylight Time", "Etc/GMT+12" - }, /* (GMT-12:00) International Date Line - * West */ + }, /* (GMT-12:00) International Date Line West */ { "E. Africa Standard Time", "E. Africa Daylight Time", "Africa/Nairobi" @@ -617,13 +616,12 @@ static const struct { "Fiji Standard Time", "Fiji Daylight Time", "Pacific/Fiji" - }, /* (GMT+12:00) Fiji, Kamchatka, Marshall - * Is. */ + }, /* (GMT+12:00) Fiji, Kamchatka, Marshall Is. */ { "FLE Standard Time", "FLE Daylight Time", "Europe/Helsinki" - }, /* (GMT+02:00) Helsinki, Kyiv, Riga, - * Sofia, Tallinn, Vilnius */ + }, /* (GMT+02:00) Helsinki, Kyiv, Riga, Sofia, + * Tallinn, Vilnius */ { "GMT Standard Time", "GMT Daylight Time", "Europe/Dublin" @@ -648,8 +646,8 @@ static const struct { "India Standard Time", "India Daylight Time", "Asia/Calcutta" - }, /* (GMT+05:30) Chennai, Kolkata, Mumbai, - * New Delhi */ + }, /* (GMT+05:30) Chennai, Kolkata, Mumbai, New + * Delhi */ { "Iran Standard Time", "Iran Daylight Time", "Asia/Tehran" @@ -719,8 +717,8 @@ static const struct { "Romance Standard Time", "Romance Daylight Time", "Europe/Brussels" - }, /* (GMT+01:00) Brussels, Copenhagen, - * Madrid, Paris */ + }, /* (GMT+01:00) Brussels, Copenhagen, Madrid, + * Paris */ { "Russian Standard Time", "Russian Daylight Time", "Europe/Moscow" @@ -791,18 +789,17 @@ static const struct "Australia/Perth" }, /* (GMT+08:00) Perth */ /* {"W. Central Africa Standard Time", "W. Central Africa Daylight Time", - * * ""}, Could not find a match for this one. Excluded for now. *//* ( + * * * ""}, Could not find a match for this one. Excluded for now. *//* ( * G MT+01:00) West Central Africa */ { "W. Europe Standard Time", "W. Europe Daylight Time", "CET" - }, /* (GMT+01:00) Amsterdam, Berlin, Bern, - * Rome, Stockholm, Vienna */ + }, /* (GMT+01:00) Amsterdam, Berlin, Bern, Rome, + * Stockholm, Vienna */ { "West Asia Standard Time", "West Asia Daylight Time", "Asia/Karachi" - }, /* (GMT+05:00) Islamabad, Karachi, - * Tashkent */ + }, /* (GMT+05:00) Islamabad, Karachi, Tashkent */ { "West Pacific Standard Time", "West Pacific Daylight Time", "Pacific/Guam" @@ -821,11 +818,11 @@ identify_system_timezone(void) { int i; char tzname[128]; - char localtzname[256]; + char localtzname[256]; time_t t = time(NULL); struct tm *tm = localtime(&t); - HKEY rootKey; - int idx; + HKEY rootKey; + int idx; if (!tm) { @@ -849,62 +846,62 @@ identify_system_timezone(void) } /* - * Localized Windows versions return localized names for the - * timezone. Scan the registry to find the English name, - * and then try matching against our table again. + * Localized Windows versions return localized names for the timezone. + * Scan the registry to find the English name, and then try matching + * against our table again. */ memset(localtzname, 0, sizeof(localtzname)); if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, - "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones", + "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones", 0, KEY_READ, &rootKey) != ERROR_SUCCESS) { ereport(WARNING, - (errmsg_internal("could not open registry key to identify Windows timezone: %i", (int)GetLastError()))); + (errmsg_internal("could not open registry key to identify Windows timezone: %i", (int) GetLastError()))); return NULL; } - - for (idx = 0; ; idx++) + + for (idx = 0;; idx++) { - char keyname[256]; - char zonename[256]; - DWORD namesize; - FILETIME lastwrite; - HKEY key; - LONG r; - + char keyname[256]; + char zonename[256]; + DWORD namesize; + FILETIME lastwrite; + HKEY key; + LONG r; + memset(keyname, 0, sizeof(keyname)); namesize = sizeof(keyname); - if ((r=RegEnumKeyEx(rootKey, - idx, - keyname, - &namesize, - NULL, - NULL, - NULL, - &lastwrite)) != ERROR_SUCCESS) + if ((r = RegEnumKeyEx(rootKey, + idx, + keyname, + &namesize, + NULL, + NULL, + NULL, + &lastwrite)) != ERROR_SUCCESS) { if (r == ERROR_NO_MORE_ITEMS) break; ereport(WARNING, - (errmsg_internal("could not enumerate registry subkeys to identify Windows timezone: %i", (int)r))); + (errmsg_internal("could not enumerate registry subkeys to identify Windows timezone: %i", (int) r))); break; } - if ((r=RegOpenKeyEx(rootKey,keyname,0,KEY_READ,&key)) != ERROR_SUCCESS) + if ((r = RegOpenKeyEx(rootKey, keyname, 0, KEY_READ, &key)) != ERROR_SUCCESS) { ereport(WARNING, - (errmsg_internal("could not open registry subkey to identify Windows timezone: %i", (int)r))); + (errmsg_internal("could not open registry subkey to identify Windows timezone: %i", (int) r))); break; } - + memset(zonename, 0, sizeof(zonename)); namesize = sizeof(zonename); - if ((r=RegQueryValueEx(key, "Std", NULL, NULL, zonename, &namesize)) != ERROR_SUCCESS) + if ((r = RegQueryValueEx(key, "Std", NULL, NULL, zonename, &namesize)) != ERROR_SUCCESS) { ereport(WARNING, - (errmsg_internal("could not query value for 'std' to identify Windows timezone: %i", (int)r))); + (errmsg_internal("could not query value for 'std' to identify Windows timezone: %i", (int) r))); RegCloseKey(key); break; } @@ -917,10 +914,10 @@ identify_system_timezone(void) } memset(zonename, 0, sizeof(zonename)); namesize = sizeof(zonename); - if ((r=RegQueryValueEx(key, "Dlt", NULL, NULL, zonename, &namesize)) != ERROR_SUCCESS) + if ((r = RegQueryValueEx(key, "Dlt", NULL, NULL, zonename, &namesize)) != ERROR_SUCCESS) { ereport(WARNING, - (errmsg_internal("could not query value for 'dlt' to identify Windows timezone: %i", (int)r))); + (errmsg_internal("could not query value for 'dlt' to identify Windows timezone: %i", (int) r))); RegCloseKey(key); break; } @@ -994,9 +991,9 @@ init_timezone_hashtable(void) struct pg_tz * pg_tzset(const char *name) { - pg_tz *tzp; - pg_tz tz; - + pg_tz *tzp; + pg_tz tz; + if (strlen(name) > TZ_STRLEN_MAX) return NULL; /* not going to fit */ @@ -1004,10 +1001,10 @@ pg_tzset(const char *name) if (!init_timezone_hashtable()) return NULL; - tzp = (pg_tz *)hash_search(timezone_cache, - name, - HASH_FIND, - NULL); + tzp = (pg_tz *) hash_search(timezone_cache, + name, + HASH_FIND, + NULL); if (tzp) { /* Timezone found in cache, nothing more to do */ @@ -1030,7 +1027,7 @@ pg_tzset(const char *name) name, HASH_ENTER, NULL); - + strcpy(tzp->TZname, tz.TZname); memcpy(&tzp->state, &tz.state, sizeof(tz.state)); @@ -1055,9 +1052,9 @@ tz_acceptable(pg_tz *tz) pg_time_t time2000; /* - * To detect leap-second timekeeping, run pg_localtime for what should - * be GMT midnight, 2000-01-01. Insist that the tm_sec value be zero; - * any other result has to be due to leap seconds. + * To detect leap-second timekeeping, run pg_localtime for what should be + * GMT midnight, 2000-01-01. Insist that the tm_sec value be zero; any + * other result has to be due to leap seconds. */ time2000 = (POSTGRES_EPOCH_JDATE - UNIX_EPOCH_JDATE) * SECS_PER_DAY; tt = pg_localtime(&time2000, tz); @@ -1074,11 +1071,11 @@ tz_acceptable(pg_tz *tz) static bool set_global_timezone(const char *tzname) { - pg_tz *tznew; + pg_tz *tznew; if (!tzname || !tzname[0]) return false; - + tznew = pg_tzset(tzname); if (!tznew) return false; diff --git a/src/timezone/pgtz.h b/src/timezone/pgtz.h index 986122efd3..5f681cee36 100644 --- a/src/timezone/pgtz.h +++ b/src/timezone/pgtz.h @@ -9,7 +9,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/timezone/pgtz.h,v 1.14 2005/07/04 19:54:51 momjian Exp $ + * $PostgreSQL: pgsql/src/timezone/pgtz.h,v 1.15 2005/10/15 02:49:51 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -46,18 +46,19 @@ struct state pg_time_t ats[TZ_MAX_TIMES]; unsigned char types[TZ_MAX_TIMES]; struct ttinfo ttis[TZ_MAX_TYPES]; - char chars[BIGGEST(BIGGEST(TZ_MAX_CHARS + 1, 3 /* sizeof gmt */), + char chars[BIGGEST(BIGGEST(TZ_MAX_CHARS + 1, 3 /* sizeof gmt */ ), (2 * (TZ_STRLEN_MAX + 1)))]; struct lsinfo lsis[TZ_MAX_LEAPS]; }; -struct pg_tz { - char TZname[TZ_STRLEN_MAX + 1]; +struct pg_tz +{ + char TZname[TZ_STRLEN_MAX + 1]; struct state state; }; -int tzload(const char *name, struct state * sp); -int tzparse(const char *name, struct state * sp, int lastditch); +int tzload(const char *name, struct state * sp); +int tzparse(const char *name, struct state * sp, int lastditch); #endif /* _PGTZ_H */ diff --git a/src/timezone/scheck.c b/src/timezone/scheck.c index 2849e8b6a7..218d2467d5 100644 --- a/src/timezone/scheck.c +++ b/src/timezone/scheck.c @@ -3,7 +3,7 @@ * 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov). * * IDENTIFICATION - * $PostgreSQL: pgsql/src/timezone/scheck.c,v 1.6 2005/06/20 08:00:51 neilc Exp $ + * $PostgreSQL: pgsql/src/timezone/scheck.c,v 1.7 2005/10/15 02:49:51 momjian Exp $ */ #include "postgres.h" @@ -14,11 +14,11 @@ char * scheck(const char *string, const char *format) { - char *fbuf; + char *fbuf; const char *fp; - char *tp; - int c; - char *result; + char *tp; + int c; + char *result; char dummy; static char nada; diff --git a/src/timezone/strftime.c b/src/timezone/strftime.c index e5490319c6..7068a56a26 100644 --- a/src/timezone/strftime.c +++ b/src/timezone/strftime.c @@ -15,7 +15,7 @@ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * IDENTIFICATION - * $PostgreSQL: pgsql/src/timezone/strftime.c,v 1.7 2005/06/20 08:00:51 neilc Exp $ + * $PostgreSQL: pgsql/src/timezone/strftime.c,v 1.8 2005/10/15 02:49:51 momjian Exp $ */ #include "postgres.h" @@ -73,9 +73,9 @@ static const struct lc_time_T C_time_locale = { /* * c_fmt * - * C99 requires this format. Previously this code used "%D %X", but we - * now conform to C99. Note that "%a %b %d %H:%M:%S %Y" is used by - * Solaris 2.3. + * C99 requires this format. Previously this code used "%D %X", but we now + * conform to C99. Note that "%a %b %d %H:%M:%S %Y" is used by Solaris + * 2.3. */ "%a %b %e %T %Y", @@ -102,7 +102,7 @@ static char *_fmt(const char *, const struct pg_tm *, char *, size_t pg_strftime(char *s, size_t maxsize, const char *format, - const struct pg_tm *t) + const struct pg_tm * t) { char *p; int warn; @@ -116,7 +116,7 @@ pg_strftime(char *s, size_t maxsize, const char *format, } static char * -_fmt(const char *format, const struct pg_tm *t, char *pt, const char *ptlim, +_fmt(const char *format, const struct pg_tm * t, char *pt, const char *ptlim, int *warnp) { for (; *format; ++format) @@ -185,9 +185,9 @@ _fmt(const char *format, const struct pg_tm *t, char *pt, const char *ptlim, case 'O': /* - * C99 locale modifiers. The sequences %Ec %EC %Ex - * %EX %Ey %EY %Od %oe %OH %OI %Om %OM %OS %Ou %OU - * %OV %Ow %OW %Oy are supposed to provide alternate + * C99 locale modifiers. The sequences %Ec %EC %Ex %EX + * %Ey %EY %Od %oe %OH %OI %Om %OM %OS %Ou %OU %OV %Ow + * %OW %Oy are supposed to provide alternate * representations. */ goto label; @@ -211,11 +211,11 @@ _fmt(const char *format, const struct pg_tm *t, char *pt, const char *ptlim, case 'k': /* - * This used to be... _conv(t->tm_hour % 12 ? - * t->tm_hour % 12 : 12, 2, ' '); ...and has been - * changed to the below to match SunOS 4.1.1 and - * Arnold Robbins' strftime version 3.0. That is, - * "%k" and "%l" have been swapped. (ado, 1993-05-24) + * This used to be... _conv(t->tm_hour % 12 ? t->tm_hour + * % 12 : 12, 2, ' '); ...and has been changed to the + * below to match SunOS 4.1.1 and Arnold Robbins' strftime + * version 3.0. That is, "%k" and "%l" have been swapped. + * (ado, 1993-05-24) */ pt = _conv(t->tm_hour, "%2d", pt, ptlim); continue; @@ -231,11 +231,10 @@ _fmt(const char *format, const struct pg_tm *t, char *pt, const char *ptlim, case 'l': /* - * This used to be... _conv(t->tm_hour, 2, ' '); - * ...and has been changed to the below to match SunOS - * 4.1.1 and Arnold Robbin's strftime version 3.0. - * That is, "%k" and "%l" have been swapped. (ado, - * 1993-05-24) + * This used to be... _conv(t->tm_hour, 2, ' '); ...and + * has been changed to the below to match SunOS 4.1.1 and + * Arnold Robbin's strftime version 3.0. That is, "%k" and + * "%l" have been swapped. (ado, 1993-05-24) */ pt = _conv((t->tm_hour % 12) ? (t->tm_hour % 12) : 12, @@ -279,9 +278,9 @@ _fmt(const char *format, const struct pg_tm *t, char *pt, const char *ptlim, case 'u': /* - * From Arnold Robbins' strftime version 3.0: "ISO - * 8601: Weekday as a decimal number [1 (Monday) - 7]" - * (ado, 1993-05-24) + * From Arnold Robbins' strftime version 3.0: "ISO 8601: + * Weekday as a decimal number [1 (Monday) - 7]" (ado, + * 1993-05-24) */ pt = _conv((t->tm_wday == 0) ? DAYSPERWEEK : t->tm_wday, @@ -328,8 +327,8 @@ _fmt(const char *format, const struct pg_tm *t, char *pt, const char *ptlim, DAYSPERNYEAR; /* - * What yday (-3 ... 3) does the ISO year - * begin on? + * What yday (-3 ... 3) does the ISO year begin + * on? */ bot = ((yday + 11 - wday) % DAYSPERWEEK) - 3; @@ -419,8 +418,8 @@ _fmt(const char *format, const struct pg_tm *t, char *pt, const char *ptlim, pt = _add(t->tm_zone, pt, ptlim); /* - * C99 says that %Z must be replaced by the empty - * string if the time zone is not determinable. + * C99 says that %Z must be replaced by the empty string + * if the time zone is not determinable. */ continue; case 'z': diff --git a/src/timezone/tzfile.h b/src/timezone/tzfile.h index 29096f7d79..0f447a543d 100644 --- a/src/timezone/tzfile.h +++ b/src/timezone/tzfile.h @@ -6,7 +6,7 @@ * 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov). * * IDENTIFICATION - * $PostgreSQL: pgsql/src/timezone/tzfile.h,v 1.5 2004/05/21 20:59:10 tgl Exp $ + * $PostgreSQL: pgsql/src/timezone/tzfile.h,v 1.6 2005/10/15 02:49:51 momjian Exp $ */ /* @@ -34,10 +34,8 @@ struct tzhead { char tzh_magic[4]; /* TZ_MAGIC */ char tzh_reserved[16]; /* reserved for future use */ - char tzh_ttisgmtcnt[4]; /* coded number of trans. time - * flags */ - char tzh_ttisstdcnt[4]; /* coded number of trans. time - * flags */ + char tzh_ttisgmtcnt[4]; /* coded number of trans. time flags */ + char tzh_ttisstdcnt[4]; /* coded number of trans. time flags */ char tzh_leapcnt[4]; /* coded number of leap seconds */ char tzh_timecnt[4]; /* coded number of transition times */ char tzh_typecnt[4]; /* coded number of local time types */ @@ -83,15 +81,12 @@ struct tzhead */ #define TZ_MAX_TIMES 370 -#define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can - * hold */ +#define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */ -#define TZ_MAX_CHARS 50 /* Maximum number of abbreviation - * characters */ +#define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */ /* (limited by what unsigned chars can hold) */ -#define TZ_MAX_LEAPS 50 /* Maximum number of leap second - * corrections */ +#define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */ #define SECSPERMIN 60 #define MINSPERHOUR 60 diff --git a/src/timezone/zic.c b/src/timezone/zic.c index 4bb14bfca4..8ef425367f 100644 --- a/src/timezone/zic.c +++ b/src/timezone/zic.c @@ -3,7 +3,7 @@ * 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov). * * IDENTIFICATION - * $PostgreSQL: pgsql/src/timezone/zic.c,v 1.15 2005/06/20 08:00:51 neilc Exp $ + * $PostgreSQL: pgsql/src/timezone/zic.c,v 1.16 2005/10/15 02:49:51 momjian Exp $ */ #include "postgres.h" @@ -134,11 +134,11 @@ static char *memcheck(char *tocheck); static int mkdirs(char *filename); static void newabbr(const char *abbr); static long oadd(long t1, long t2); -static void outzone(const struct zone *zp, int ntzones); +static void outzone(const struct zone * zp, int ntzones); static void puttzcode(long code, FILE *fp); static int rcomp(const void *leftp, const void *rightp); -static pg_time_t rpytime(const struct rule *rp, int wantedy); -static void rulesub(struct rule *rp, +static pg_time_t rpytime(const struct rule * rp, int wantedy); +static void rulesub(struct rule * rp, const char *loyearp, const char *hiyearp, const char *typep, const char *monthp, const char *dayp, const char *timep); @@ -408,8 +408,8 @@ static void error(const char *string) { /* - * Match the format of "cc" to allow sh users to zic ... 2>&1 | error - * -t "*" -v on BSD systems. + * Match the format of "cc" to allow sh users to zic ... 2>&1 | error -t + * "*" -v on BSD systems. */ (void) fprintf(stderr, _("\"%s\", line %d: %s"), filename, linenum, string); @@ -450,9 +450,9 @@ static int sflag = FALSE; int main(int argc, char *argv[]) { - int i; - int j; - int c; + int i; + int j; + int c; #ifndef WIN32 (void) umask(umask(S_IWGRP | S_IWOTH) | (S_IWGRP | S_IWOTH)); @@ -475,7 +475,7 @@ main(int argc, char *argv[]) else { (void) fprintf(stderr, - _("%s: More than one -d option specified\n"), + _("%s: More than one -d option specified\n"), progname); (void) exit(EXIT_FAILURE); } @@ -486,7 +486,7 @@ main(int argc, char *argv[]) else { (void) fprintf(stderr, - _("%s: More than one -l option specified\n"), + _("%s: More than one -l option specified\n"), progname); (void) exit(EXIT_FAILURE); } @@ -497,7 +497,7 @@ main(int argc, char *argv[]) else { (void) fprintf(stderr, - _("%s: More than one -p option specified\n"), + _("%s: More than one -p option specified\n"), progname); (void) exit(EXIT_FAILURE); } @@ -508,7 +508,7 @@ main(int argc, char *argv[]) else { (void) fprintf(stderr, - _("%s: More than one -y option specified\n"), + _("%s: More than one -y option specified\n"), progname); (void) exit(EXIT_FAILURE); } @@ -519,7 +519,7 @@ main(int argc, char *argv[]) else { (void) fprintf(stderr, - _("%s: More than one -L option specified\n"), + _("%s: More than one -L option specified\n"), progname); (void) exit(EXIT_FAILURE); } @@ -585,8 +585,8 @@ main(int argc, char *argv[]) static void dolink(const char *fromfile, const char *tofile) { - char *fromname; - char *toname; + char *fromname; + char *toname; if (fromfile[0] == '/') fromname = ecpyalloc(fromfile); @@ -606,8 +606,8 @@ dolink(const char *fromfile, const char *tofile) } /* - * We get to be careful here since there's a fair chance of root - * running us. + * We get to be careful here since there's a fair chance of root running + * us. */ if (!itsdir(toname)) (void) remove(toname); @@ -625,7 +625,7 @@ dolink(const char *fromfile, const char *tofile) !itsdir(fromname)) { const char *s = tofile; - char *symlinkcontents = NULL; + char *symlinkcontents = NULL; while ((s = strchr(s + 1, '/')) != NULL) symlinkcontents = ecatalloc(symlinkcontents, "../"); @@ -695,8 +695,8 @@ setboundaries(void) static int itsdir(const char *name) { - char *myname; - int accres; + char *myname; + int accres; myname = ecpyalloc(name); myname = ecatalloc(myname, "/."); @@ -725,10 +725,10 @@ associate(void) { struct zone *zp; struct rule *rp; - int base, - out; - int i, - j; + int base, + out; + int i, + j; if (nrules != 0) { @@ -796,8 +796,8 @@ associate(void) TRUE); /* - * Note, though, that if there's no rule, a '%s' in the format - * is a bad thing. + * Note, though, that if there's no rule, a '%s' in the format is + * a bad thing. */ if (strchr(zp->z_format, '%') != 0) error(_("%s in ruleless zone")); @@ -810,13 +810,13 @@ associate(void) static void infile(const char *name) { - FILE *fp; - char **fields; - char *cp; + FILE *fp; + char **fields; + char *cp; const struct lookup *lp; - int nfields; - int wantcont; - int num; + int nfields; + int wantcont; + int num; char buf[BUFSIZ]; if (strcmp(name, "-") == 0) @@ -883,7 +883,7 @@ infile(const char *name) case LC_LEAP: if (name != leapsec) (void) fprintf(stderr, - _("%s: Leap line in non leap seconds file %s\n"), + _("%s: Leap line in non leap seconds file %s\n"), progname, name); else inleap(fields, nfields); @@ -891,7 +891,7 @@ infile(const char *name) break; default: /* "cannot happen" */ (void) fprintf(stderr, - _("%s: panic: Invalid l_value %d\n"), + _("%s: panic: Invalid l_value %d\n"), progname, lp->l_value); (void) exit(EXIT_FAILURE); } @@ -991,14 +991,14 @@ inrule(char **fields, int nfields) r.r_name = ecpyalloc(fields[RF_NAME]); r.r_abbrvar = ecpyalloc(fields[RF_ABBRVAR]); rules = (struct rule *) (void *) erealloc((char *) rules, - (int) ((nrules + 1) * sizeof *rules)); + (int) ((nrules + 1) * sizeof *rules)); rules[nrules++] = r; } static int inzone(char **fields, int nfields) { - int i; + int i; static char *buf; if (nfields < ZONE_MINFIELDS || nfields > ZONE_MAXFIELDS) @@ -1010,7 +1010,7 @@ inzone(char **fields, int nfields) { buf = erealloc(buf, (int) (132 + strlen(TZDEFAULT))); (void) sprintf(buf, - _("\"Zone %s\" line and -l option are mutually exclusive"), + _("\"Zone %s\" line and -l option are mutually exclusive"), TZDEFAULT); error(buf); return FALSE; @@ -1019,7 +1019,7 @@ inzone(char **fields, int nfields) { buf = erealloc(buf, (int) (132 + strlen(TZDEFRULES))); (void) sprintf(buf, - _("\"Zone %s\" line and -p option are mutually exclusive"), + _("\"Zone %s\" line and -p option are mutually exclusive"), TZDEFRULES); error(buf); return FALSE; @@ -1032,7 +1032,7 @@ inzone(char **fields, int nfields) strlen(fields[ZF_NAME]) + strlen(zones[i].z_filename))); (void) sprintf(buf, - _("duplicate zone name %s (file \"%s\", line %d)"), + _("duplicate zone name %s (file \"%s\", line %d)"), fields[ZF_NAME], zones[i].z_filename, zones[i].z_linenum); @@ -1056,16 +1056,16 @@ inzcont(char **fields, int nfields) static int inzsub(char **fields, int nfields, int iscont) { - char *cp; + char *cp; static struct zone z; - int i_gmtoff, - i_rule, - i_format; - int i_untilyear, - i_untilmonth; - int i_untilday, - i_untiltime; - int hasuntil; + int i_gmtoff, + i_rule, + i_format; + int i_untilyear, + i_untilmonth; + int i_untilday, + i_untiltime; + int hasuntil; if (iscont) { @@ -1129,7 +1129,7 @@ inzsub(char **fields, int nfields, int iscont) } } zones = (struct zone *) (void *) erealloc((char *) zones, - (int) ((nzones + 1) * sizeof *zones)); + (int) ((nzones + 1) * sizeof *zones)); zones[nzones++] = z; /* @@ -1281,19 +1281,19 @@ inlink(char **fields, int nfields) l.l_from = ecpyalloc(fields[LF_FROM]); l.l_to = ecpyalloc(fields[LF_TO]); links = (struct link *) (void *) erealloc((char *) links, - (int) ((nlinks + 1) * sizeof *links)); + (int) ((nlinks + 1) * sizeof *links)); links[nlinks++] = l; } static void -rulesub(struct rule *rp, const char *loyearp, const char *hiyearp, +rulesub(struct rule * rp, const char *loyearp, const char *hiyearp, const char *typep, const char *monthp, const char *dayp, const char *timep) { const struct lookup *lp; const char *cp; - char *dp; - char *ep; + char *dp; + char *ep; if ((lp = byword(monthp, mon_names)) == NULL) { @@ -1466,8 +1466,8 @@ rulesub(struct rule *rp, const char *loyearp, const char *hiyearp, static void convert(long val, char *buf) { - int i; - long shift; + int i; + long shift; for (i = 0, shift = 24; i < 4; ++i, shift -= 8) buf[i] = val >> shift; @@ -1496,9 +1496,9 @@ atcomp(const void *avp, const void *bvp) static void writezone(const char *name) { - FILE *fp; - int i, - j; + FILE *fp; + int i, + j; static char *fullname; static struct tzhead tzh; pg_time_t ats[TZ_MAX_TIMES]; @@ -1679,23 +1679,23 @@ doabbr(char *abbr, const char *format, const char *letters, int isdst) } static void -outzone(const struct zone *zpfirst, int zonecount) +outzone(const struct zone * zpfirst, int zonecount) { const struct zone *zp; struct rule *rp; - int i, - j; - int usestart, - useuntil; - pg_time_t starttime = 0; - pg_time_t untiltime = 0; - long gmtoff; - long stdoff; - int year; - long startoff; - int startttisstd; - int startttisgmt; - int type; + int i, + j; + int usestart, + useuntil; + pg_time_t starttime = 0; + pg_time_t untiltime = 0; + long gmtoff; + long stdoff; + int year; + long startoff; + int startttisstd; + int startttisgmt; + int type; char startbuf[BUFSIZ]; /* @@ -1706,8 +1706,8 @@ outzone(const struct zone *zpfirst, int zonecount) charcnt = 0; /* - * Thanks to Earl Chew (earl@dnd.icp.nec.com.au) for noting the need - * to unconditionally initialize startttisstd. + * Thanks to Earl Chew (earl@dnd.icp.nec.com.au) for noting the need to + * unconditionally initialize startttisstd. */ startttisstd = FALSE; startttisgmt = FALSE; @@ -1749,8 +1749,8 @@ outzone(const struct zone *zpfirst, int zonecount) break; /* - * Mark which rules to do in the current year. For those - * to do, calculate rpytime(rp, year); + * Mark which rules to do in the current year. For those to + * do, calculate rpytime(rp, year); */ for (j = 0; j < zp->z_nrules; ++j) { @@ -1765,16 +1765,17 @@ outzone(const struct zone *zpfirst, int zonecount) } for (;;) { - int k; - pg_time_t jtime, ktime = 0; - long offset; + int k; + pg_time_t jtime, + ktime = 0; + long offset; char buf[BUFSIZ]; if (useuntil) { /* - * Turn untiltime into UTC assuming the current - * gmtoff and stdoff values. + * Turn untiltime into UTC assuming the current gmtoff + * and stdoff values. */ untiltime = zp->z_untiltime; if (!zp->z_untilrule.r_todisgmt) @@ -1917,8 +1918,8 @@ static int addtype(long gmtoff, const char *abbr, int isdst, int ttisstd, int ttisgmt) { - int i; - int j; + int i; + int j; if (isdst != TRUE && isdst != FALSE) { @@ -1937,8 +1938,8 @@ addtype(long gmtoff, const char *abbr, int isdst, } /* - * See if there's already an entry for this zone type. If so, just - * return its index. + * See if there's already an entry for this zone type. If so, just return + * its index. */ for (i = 0; i < typecnt; ++i) { @@ -1975,8 +1976,8 @@ addtype(long gmtoff, const char *abbr, int isdst, static void leapadd(const pg_time_t t, int positive, int rolling, int count) { - int i; - int j; + int i; + int j; if (leapcnt + (positive ? count : 1) > TZ_MAX_LEAPS) { @@ -2011,8 +2012,8 @@ leapadd(const pg_time_t t, int positive, int rolling, int count) static void adjleap(void) { - int i; - long last = 0; + int i; + long last = 0; /* * propagate leap seconds forward @@ -2082,7 +2083,7 @@ itsabbr(const char *abbr, const char *word) } static const struct lookup * -byword(const char *word, const struct lookup *table) +byword(const char *word, const struct lookup * table) { const struct lookup *foundlp; const struct lookup *lp; @@ -2115,9 +2116,9 @@ byword(const char *word, const struct lookup *table) static char ** getfields(char *cp) { - char *dp; - char **array; - int nsubs; + char *dp; + char **array; + int nsubs; if (cp == NULL) return NULL; @@ -2154,7 +2155,7 @@ getfields(char *cp) static long oadd(long t1, long t2) { - long t; + long t; t = t1 + t2; if ((t2 > 0 && t <= t1) || (t2 < 0 && t >= t1)) @@ -2168,7 +2169,7 @@ oadd(long t1, long t2) static pg_time_t tadd(const pg_time_t t1, long t2) { - pg_time_t t; + pg_time_t t; if (t1 == max_time && t2 > 0) return max_time; @@ -2189,13 +2190,13 @@ tadd(const pg_time_t t1, long t2) */ static pg_time_t -rpytime(const struct rule *rp, int wantedy) +rpytime(const struct rule * rp, int wantedy) { - int y, - m, - i; - long dayoff; /* with a nod to Margaret O. */ - pg_time_t t; + int y, + m, + i; + long dayoff; /* with a nod to Margaret O. */ + pg_time_t t; if (wantedy == INT_MIN) return min_time; @@ -2239,7 +2240,7 @@ rpytime(const struct rule *rp, int wantedy) dayoff = oadd(dayoff, eitol(i)); if (rp->r_dycode == DC_DOWGEQ || rp->r_dycode == DC_DOWLEQ) { - long wday; + long wday; #define LDAYSPERWEEK ((long) DAYSPERWEEK) wday = eitol(EPOCH_WDAY); @@ -2288,7 +2289,7 @@ rpytime(const struct rule *rp, int wantedy) static void newabbr(const char *string) { - int i; + int i; i = strlen(string) + 1; if (charcnt + i > TZ_MAX_CHARS) @@ -2303,8 +2304,8 @@ newabbr(const char *string) static int mkdirs(char *argname) { - char *name; - char *cp; + char *name; + char *cp; if (argname == NULL || *argname == '\0') return 0; @@ -2327,9 +2328,9 @@ mkdirs(char *argname) if (!itsdir(name)) { /* - * It doesn't seem to exist, so we try to create it. Creation - * may fail because of the directory being created by some - * other multiprocessor, so we get to do extra checking. + * It doesn't seem to exist, so we try to create it. Creation may + * fail because of the directory being created by some other + * multiprocessor, so we get to do extra checking. */ if (mkdir(name, MKDIR_UMASK) != 0) { @@ -2338,7 +2339,7 @@ mkdirs(char *argname) if (errno != EEXIST || !itsdir(name)) { (void) fprintf(stderr, - _("%s: Can't create directory %s: %s\n"), + _("%s: Can't create directory %s: %s\n"), progname, name, e); ifree(name); return -1; diff --git a/src/tools/entab/entab.c b/src/tools/entab/entab.c index 2e91bdb488..455c4deba2 100644 --- a/src/tools/entab/entab.c +++ b/src/tools/entab/entab.c @@ -132,9 +132,9 @@ main(int argc, char **argv) if (col_in_tab == tab_size) { /* - * Is the next character going to be a tab? Needed - * to do tab replacement in current spot if next - * char is going to be a tab, ignoring min_spaces + * Is the next character going to be a tab? Needed to + * do tab replacement in current spot if next char is + * going to be a tab, ignoring min_spaces */ nxt_spaces = 0; while (1) diff --git a/src/tools/entab/halt.c b/src/tools/entab/halt.c index dda2f23791..d39c9cc339 100644 --- a/src/tools/entab/halt.c +++ b/src/tools/entab/halt.c @@ -19,10 +19,10 @@ /*VARARGS*/ void -halt(const char *format, ...) +halt(const char *format,...) { va_list arg_ptr; - const char *pstr; + const char *pstr; void (*sig_func) (); va_start(arg_ptr, format); diff --git a/src/tools/findoidjoins/findoidjoins.c b/src/tools/findoidjoins/findoidjoins.c index db1fc12460..dc86743ff6 100644 --- a/src/tools/findoidjoins/findoidjoins.c +++ b/src/tools/findoidjoins/findoidjoins.c @@ -3,7 +3,7 @@ * * Copyright (c) 2002-2005, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/tools/findoidjoins/findoidjoins.c,v 1.1 2005/06/23 02:33:28 tgl Exp $ + * $PostgreSQL: pgsql/src/tools/findoidjoins/findoidjoins.c,v 1.2 2005/10/15 02:49:51 momjian Exp $ */ #include "postgres_fe.h" @@ -51,7 +51,7 @@ main(int argc, char **argv) appendPQExpBuffer(&sql, "%s", "SET search_path = public;" "SELECT c.relname, (SELECT nspname FROM " - "pg_catalog.pg_namespace n WHERE n.oid = c.relnamespace) AS nspname " + "pg_catalog.pg_namespace n WHERE n.oid = c.relnamespace) AS nspname " "FROM pg_catalog.pg_class c " "WHERE c.relkind = 'r' " "AND c.relhasoids " @@ -74,7 +74,7 @@ main(int argc, char **argv) "SELECT c.relname, " "(SELECT nspname FROM pg_catalog.pg_namespace n WHERE n.oid = c.relnamespace) AS nspname, " "a.attname " - "FROM pg_catalog.pg_class c, pg_catalog.pg_attribute a " + "FROM pg_catalog.pg_class c, pg_catalog.pg_attribute a " "WHERE a.attnum > 0 AND c.relkind = 'r' " "AND a.attrelid = c.oid " "AND a.atttypid IN ('pg_catalog.oid'::regtype, " @@ -119,7 +119,7 @@ main(int argc, char **argv) "\"%s\".\"%s\" t2 " "WHERE t1.\"%s\"::pg_catalog.oid = t2.oid " "LIMIT 1", - fk_nspname, fk_relname, pk_nspname, pk_relname, fk_attname); + fk_nspname, fk_relname, pk_nspname, pk_relname, fk_attname); res = PQexec(conn, sql.data); if (!res || PQresultStatus(res) != PGRES_TUPLES_OK) diff --git a/src/tools/fsync/test_fsync.c b/src/tools/fsync/test_fsync.c index 42701767b9..8619fb6888 100644 --- a/src/tools/fsync/test_fsync.c +++ b/src/tools/fsync/test_fsync.c @@ -61,8 +61,7 @@ main(int argc, char *argv[]) if ((tmpfile = open(FSYNC_FILENAME, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR)) == -1) die("can't open /var/tmp/test_fsync.out"); write(tmpfile, strout, WAL_FILE_SIZE); - fsync(tmpfile); /* fsync so later fsync's don't have to do - * it */ + fsync(tmpfile); /* fsync so later fsync's don't have to do it */ close(tmpfile); printf("Simple write timing:\n"); diff --git a/src/tools/thread/thread_test.c b/src/tools/thread/thread_test.c index 70babc09cd..2e66813855 100644 --- a/src/tools/thread/thread_test.c +++ b/src/tools/thread/thread_test.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/tools/thread/thread_test.c,v 1.40 2005/08/23 21:02:05 momjian Exp $ + * $PostgreSQL: pgsql/src/tools/thread/thread_test.c,v 1.41 2005/10/15 02:49:52 momjian Exp $ * * This program tests to see if your standard libc functions use * pthread_setspecific()/pthread_getspecific() to be thread-safe. @@ -51,26 +51,25 @@ typedef char bool; /****************************************************************** * Windows Hacks *****************************************************************/ - + #ifdef WIN32 #define MAXHOSTNAMELEN 63 #include -int mkstemp(char *template); +int mkstemp(char *template); int mkstemp(char *template) { - FILE *foo; + FILE *foo; mktemp(template); foo = fopen(template, "rw"); if (!foo) return -1; else - return (int)foo; + return (int) foo; } - #endif /****************************************************************** @@ -80,7 +79,7 @@ mkstemp(char *template) /* Test for POSIX.1c 2-arg sigwait() and fail on single-arg version */ #include -int sigwait(const sigset_t *set, int *sig); +int sigwait(const sigset_t *set, int *sig); #if !defined(ENABLE_THREAD_SAFETY) && !defined(IN_CONFIGURE) && !(defined(WIN32)) @@ -91,14 +90,13 @@ main(int argc, char *argv[]) fprintf(stderr, "Perhaps rerun 'configure' using '--enable-thread-safety'.\n"); return 1; } - #else /* This must be down here because this is the code that uses threads. */ #include -static void func_call_1(void); -static void func_call_2(void); +static void func_call_1(void); +static void func_call_2(void); #ifdef WIN32 #define TEMP_FILENAME_1 "thread_test.1.XXXXXX" @@ -108,8 +106,8 @@ static void func_call_2(void); #define TEMP_FILENAME_2 "/tmp/thread_test.2.XXXXXX" #endif -static char *temp_filename_1; -static char *temp_filename_2; +static char *temp_filename_1; +static char *temp_filename_2; static pthread_mutex_t init_mutex = PTHREAD_MUTEX_INITIALIZER; @@ -120,37 +118,38 @@ static volatile int errno1_set = 0; static volatile int errno2_set = 0; #ifndef HAVE_STRERROR_R -static char *strerror_p1; -static char *strerror_p2; -static bool strerror_threadsafe = false; +static char *strerror_p1; +static char *strerror_p2; +static bool strerror_threadsafe = false; #endif #ifndef WIN32 #ifndef HAVE_GETPWUID_R static struct passwd *passwd_p1; static struct passwd *passwd_p2; -static bool getpwuid_threadsafe = false; +static bool getpwuid_threadsafe = false; #endif #endif #if !defined(HAVE_GETADDRINFO) && !defined(HAVE_GETHOSTBYNAME_R) static struct hostent *hostent_p1; static struct hostent *hostent_p2; -static char myhostname[MAXHOSTNAMELEN]; -static bool gethostbyname_threadsafe = false; +static char myhostname[MAXHOSTNAMELEN]; +static bool gethostbyname_threadsafe = false; #endif -static bool platform_is_threadsafe = true; +static bool platform_is_threadsafe = true; int main(int argc, char *argv[]) { pthread_t thread1, - thread2; - int fd; + thread2; + int fd; + #ifdef WIN32 WSADATA wsaData; - int err; + int err; #endif if (argc > 1) @@ -167,7 +166,8 @@ main(int argc, char *argv[]) #ifdef WIN32 err = WSAStartup(MAKEWORD(1, 1), &wsaData); - if (err != 0) { + if (err != 0) + { fprintf(stderr, "Cannot start the network subsystem - %d**\nexiting\n", err); exit(1); } @@ -199,8 +199,7 @@ main(int argc, char *argv[]) pthread_create(&thread2, NULL, (void *(*) (void *)) func_call_2, NULL); while (thread1_done == 0 || thread2_done == 0) - sched_yield(); /* if this is a portability problem, - * remove it */ + sched_yield(); /* if this is a portability problem, remove it */ #ifdef WIN32 printf("Your GetLastError() is thread-safe.\n"); #else @@ -298,16 +297,16 @@ func_call_1(void) void *p; #endif #ifdef WIN32 - HANDLE h1; - HANDLE h2; -#endif + HANDLE h1; + HANDLE h2; +#endif unlink(temp_filename_1); - - + + /* create, then try to fail on exclusive create open */ #ifdef WIN32 - h1 = CreateFile(temp_filename_1, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, 0, NULL); - h2 = CreateFile(temp_filename_1, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, NULL); + h1 = CreateFile(temp_filename_1, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, 0, NULL); + h2 = CreateFile(temp_filename_1, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, NULL); if (h1 == INVALID_HANDLE_VALUE || GetLastError() != ERROR_FILE_EXISTS) #else if (open(temp_filename_1, O_RDWR | O_CREAT, 0600) < 0 || @@ -332,16 +331,16 @@ func_call_1(void) while (errno2_set == 0) sched_yield(); #ifdef WIN32 - if (GetLastError() != ERROR_FILE_EXISTS) + if (GetLastError() != ERROR_FILE_EXISTS) #else - if (errno != EEXIST) + if (errno != EEXIST) #endif { #ifdef WIN32 - fprintf(stderr, "GetLastError() not thread-safe **\nexiting\n"); + fprintf(stderr, "GetLastError() not thread-safe **\nexiting\n"); #else - fprintf(stderr, "errno not thread-safe **\nexiting\n"); -#endif + fprintf(stderr, "errno not thread-safe **\nexiting\n"); +#endif unlink(temp_filename_1); exit(1); } @@ -351,9 +350,8 @@ func_call_1(void) strerror_p1 = strerror(EACCES); /* - * If strerror() uses sys_errlist, the pointer might change for - * different errno values, so we don't check to see if it varies - * within the thread. + * If strerror() uses sys_errlist, the pointer might change for different + * errno values, so we don't check to see if it varies within the thread. */ #endif @@ -398,8 +396,8 @@ func_call_2(void) unlink(temp_filename_2); /* open non-existant file */ #ifdef WIN32 - CreateFile(temp_filename_2, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); - if (GetLastError() != ERROR_FILE_NOT_FOUND) + CreateFile(temp_filename_2, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); + if (GetLastError() != ERROR_FILE_NOT_FOUND) #else if (open(temp_filename_2, O_RDONLY, 0600) >= 0) #endif @@ -416,15 +414,15 @@ func_call_2(void) while (errno1_set == 0) sched_yield(); #ifdef WIN32 - if (GetLastError() != ENOENT) + if (GetLastError() != ENOENT) #else - if (errno != ENOENT) + if (errno != ENOENT) #endif { #ifdef WIN32 - fprintf(stderr, "GetLastError() not thread-safe **\nexiting\n"); + fprintf(stderr, "GetLastError() not thread-safe **\nexiting\n"); #else - fprintf(stderr, "errno not thread-safe **\nexiting\n"); + fprintf(stderr, "errno not thread-safe **\nexiting\n"); #endif unlink(temp_filename_2); exit(1); @@ -435,9 +433,8 @@ func_call_2(void) strerror_p2 = strerror(EINVAL); /* - * If strerror() uses sys_errlist, the pointer might change for - * different errno values, so we don't check to see if it varies - * within the thread. + * If strerror() uses sys_errlist, the pointer might change for different + * errno values, so we don't check to see if it varies within the thread. */ #endif diff --git a/src/tutorial/beard.c b/src/tutorial/beard.c index 4157d2195d..f31a119770 100644 --- a/src/tutorial/beard.c +++ b/src/tutorial/beard.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/tutorial/beard.c,v 1.12 2004/12/31 22:04:05 pgsql Exp $ + * $PostgreSQL: pgsql/src/tutorial/beard.c,v 1.13 2005/10/15 02:49:52 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -55,7 +55,7 @@ beard(Oid picture) beard_fd = DatumGetInt32(DirectFunctionCall2(lo_open, ObjectIdGetDatum(beard), - Int32GetDatum(INV_WRITE))); + Int32GetDatum(INV_WRITE))); if (beard_fd < 0) elog(ERROR, "Cannot access beard large object"); diff --git a/src/tutorial/funcs_new.c b/src/tutorial/funcs_new.c index e548b85ee4..9c63abaf14 100644 --- a/src/tutorial/funcs_new.c +++ b/src/tutorial/funcs_new.c @@ -125,8 +125,7 @@ c_overpaid(PG_FUNCTION_ARGS) PG_RETURN_BOOL(false); /* - * Alternatively, we might prefer to do PG_RETURN_NULL() for null - * salary + * Alternatively, we might prefer to do PG_RETURN_NULL() for null salary */ PG_RETURN_BOOL(salary > limit);